public async Task <IActionResult> Put(int id, [FromBody] GarmentInternNoteViewModel ViewModel)
        {
            try
            {
                identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value;

                IValidateService validateService = (IValidateService)serviceProvider.GetService(typeof(IValidateService));

                validateService.Validate(ViewModel);

                var model = mapper.Map <GarmentInternNote>(ViewModel);

                await facade.Update(id, model, identityService.Username);

                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.CREATED_STATUS_CODE, General.OK_MESSAGE)
                    .Ok();
                return(Created(String.Concat(Request.Path, "/", 0), Result));
            }
            catch (ServiceValidationExeption e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.BAD_REQUEST_STATUS_CODE, General.BAD_REQUEST_MESSAGE)
                    .Fail(e);
                return(BadRequest(Result));
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }
        public IActionResult GetInternNotePDF(int id)
        {
            try
            {
                identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value;
                identityService.Token    = Request.Headers["Authorization"].FirstOrDefault().Replace("Bearer ", "");

                var indexAcceptPdf = Request.Headers["Accept"].ToList().IndexOf("application/pdf");

                GarmentInternNote          model     = facade.ReadById(id);
                GarmentInternNoteViewModel viewModel = mapper.Map <GarmentInternNoteViewModel>(model);
                if (viewModel == null)
                {
                    throw new Exception("Invalid Id");
                }
                if (indexAcceptPdf < 0)
                {
                    return(Ok(new
                    {
                        apiVersion = ApiVersion,
                        statusCode = General.OK_STATUS_CODE,
                        message = General.OK_MESSAGE,
                        data = viewModel,
                    }));
                }
                else
                {
                    int clientTimeZoneOffset = int.Parse(Request.Headers["x-timezone-offset"].First());

                    foreach (var item in viewModel.items)
                    {
                        var garmentInvoice          = invoiceFacade.ReadById((int)item.garmentInvoice.Id);
                        var garmentInvoiceViewModel = mapper.Map <GarmentInvoiceViewModel>(garmentInvoice);
                        item.garmentInvoice = garmentInvoiceViewModel;

                        foreach (var detail in item.details)
                        {
                            var deliveryOrder          = deliveryOrderFacade.ReadById((int)detail.deliveryOrder.Id);
                            var deliveryOrderViewModel = mapper.Map <GarmentDeliveryOrderViewModel>(deliveryOrder);
                            detail.deliveryOrder = deliveryOrderViewModel;
                        }
                    }

                    GarmentInternNotePDFTemplate PdfTemplateLocal = new GarmentInternNotePDFTemplate();
                    MemoryStream stream = PdfTemplateLocal.GeneratePdfTemplate(viewModel, serviceProvider, clientTimeZoneOffset, deliveryOrderFacade);

                    return(new FileStreamResult(stream, "application/pdf")
                    {
                        FileDownloadName = $"{viewModel.inNo}.pdf"
                    });
                }
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }
        public async Task<IActionResult> Post([FromBody] GarmentInternNoteViewModel ViewModel)
        {
            try
            {
                identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value;
                identityService.Token = Request.Headers["Authorization"].FirstOrDefault().Replace("Bearer ", "");

                identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value;

                IValidateService validateService = (IValidateService)serviceProvider.GetService(typeof(IValidateService));

                validateService.Validate(ViewModel);

                var model = mapper.Map<GarmentInternNote>(ViewModel);

                await facade.Create(model, ViewModel.supplier.Import, identityService.Username);

                Dictionary<string, object> Result =
                    new ResultFormatter(ApiVersion, General.CREATED_STATUS_CODE, General.OK_MESSAGE)
                    .Ok();
                return Created(String.Concat(Request.Path, "/", 0), Result);
            }
            catch (ServiceValidationExeption e)
            {
                Dictionary<string, object> Result =
                    new ResultFormatter(ApiVersion, General.BAD_REQUEST_STATUS_CODE, General.BAD_REQUEST_MESSAGE)
                    .Fail(e);
                    
                //return BadRequest(Result);
                return StatusCode(General.BAD_REQUEST_STATUS_CODE, Result);
            }
            catch (Exception e)
            {
                Dictionary<string, object> Result =
                    new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result);
            }
        }
コード例 #4
0
        public MemoryStream GeneratePdfTemplate(GarmentInternNoteViewModel viewModel, IServiceProvider serviceProvider, int clientTimeZoneOffset, IGarmentDeliveryOrderFacade DOfacade)
        {
            IGarmentCorrectionNoteQuantityFacade correctionNote = (IGarmentCorrectionNoteQuantityFacade)serviceProvider.GetService(typeof(IGarmentCorrectionNoteQuantityFacade));

            Font header_font  = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 18);
            Font normal_font  = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 9);
            Font normal_font1 = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8);
            Font bold_font    = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8);
            //Font header_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8);

            Document document = new Document(PageSize.A4, 40, 40, 40, 40);

            document.AddHeader("Header", viewModel.inNo);
            MemoryStream stream = new MemoryStream();
            PdfWriter    writer = PdfWriter.GetInstance(document, stream);

            writer.PageEvent = new PDFPages();
            document.Open();


            PdfPCell cellLeftNoBorder = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT
            };
            PdfPCell cellRightNoBorder = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT
            };

            Chunk        chkHeader = new Chunk(" ");
            Phrase       pheader   = new Phrase(chkHeader);
            HeaderFooter header    = new HeaderFooter(pheader, false);

            header.Border    = Rectangle.NO_BORDER;
            header.Alignment = Element.ALIGN_RIGHT;
            document.Header  = header;

            #region Header

            string    addressString = "PT DAN LIRIS" + "\n" + "JL. Merapi No.23" + "\n" + "Banaran, Grogol, Kab. Sukoharjo" + "\n" + "Jawa Tengah 57552 - INDONESIA" + "\n" + "PO.BOX 166 Solo 57100" + "\n" + "Telp. (0271) 740888, 714400" + "\n" + "Fax. (0271) 735222, 740777";
            Paragraph address       = new Paragraph(addressString, bold_font)
            {
                Alignment = Element.ALIGN_LEFT
            };
            document.Add(address);
            bold_font.SetStyle(Font.NORMAL);

            string    titleString = "NOTA INTERN\n\n";
            Paragraph title       = new Paragraph(titleString, bold_font)
            {
                Alignment = Element.ALIGN_CENTER
            };
            document.Add(title);
            bold_font.SetStyle(Font.NORMAL);

            PdfPTable tableInternNoteHeader = new PdfPTable(2);
            tableInternNoteHeader.SetWidths(new float[] { 4.5f, 4.5f });
            PdfPCell cellInternNoteHeaderLeft = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT
            };
            PdfPCell cellInternNoteHeaderRight = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT
            };

            cellInternNoteHeaderLeft.Phrase = new Phrase("No. Nota Intern" + "      : " + viewModel.inNo, normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft);

            cellInternNoteHeaderRight.Phrase = new Phrase("Tanggal Nota Intern" + "       : " + viewModel.inDate.ToOffset(new TimeSpan(clientTimeZoneOffset, 0, 0)).ToString("dd MMMM yyyy", new CultureInfo("id-ID")), normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderRight);

            cellInternNoteHeaderLeft.Phrase = new Phrase("Kode Supplier" + "        : " + viewModel.supplier.Code, normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft);

            string paymentmethods      = "";
            List <DateTimeOffset> coba = new List <DateTimeOffset>();
            foreach (GarmentInternNoteItemViewModel item in viewModel.items)
            {
                foreach (GarmentInternNoteDetailViewModel detail in item.details)
                {
                    coba.Add(detail.paymentDueDate);
                    paymentmethods = detail.deliveryOrder.paymentMethod;
                }
            }
            DateTimeOffset coba1 = coba.Min(p => p);
            cellInternNoteHeaderRight.Phrase = new Phrase("Tanggal Jatuh Tempo" + "    : " + coba1.ToOffset(new TimeSpan(clientTimeZoneOffset, 0, 0)).ToString("dd MMMM yyyy", new CultureInfo("id-ID")), normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderRight);

            cellInternNoteHeaderLeft.Phrase = new Phrase("Nama Supplier" + "       : " + viewModel.supplier.Name, normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft);

            cellInternNoteHeaderRight.Phrase = new Phrase("Term Pembayaran" + "         : " + paymentmethods, normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderRight);


            PdfPCell cellInternNoteHeader = new PdfPCell(tableInternNoteHeader); // dont remove
            tableInternNoteHeader.ExtendLastRow = false;
            tableInternNoteHeader.SpacingAfter  = 10f;
            document.Add(tableInternNoteHeader);
            #endregion

            #region Table_Of_Content
            PdfPCell cellCenter = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 5
            };
            PdfPCell cellRight = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 5
            };
            PdfPCell cellLeft = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 5
            };

            PdfPTable tableContent = new PdfPTable(9);
            tableContent.SetWidths(new float[] { 4f, 4f, 5f, 4.5f, 5.5f, 3.3f, 2.7f, 3f, 4.5f });
            cellCenter.Phrase = new Phrase("NO. Bon Pusat", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("NO. Surat Jalan", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Tgl. Surat Jalan", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("No. Referensi PR", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Keterangan Barang", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Jumlah", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Satuan", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Harga Satuan", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Harga Total", bold_font);
            tableContent.AddCell(cellCenter);

            double  totalPriceTotal           = 0;
            double  total                     = 0;
            double  ppn                       = 0;
            double  pph                       = 0;
            double  maxtotal                  = 0;
            decimal totalcorrection           = 0;
            Dictionary <string, double> units = new Dictionary <string, double>();
            units.Add("C1A", 0);
            units.Add("C1B", 0);
            units.Add("C2A", 0);
            units.Add("C2B", 0);
            units.Add("C2C", 0);
            units.Add("E05", 0);
            Dictionary <long, decimal> koreksi = new Dictionary <long, decimal>();
            Dictionary <long, double>  kurs    = new Dictionary <long, double>();

            List <TableContent> TableContents = new List <TableContent>();

            foreach (GarmentInternNoteItemViewModel item in viewModel.items)
            {
                foreach (GarmentInternNoteDetailViewModel detail in item.details)
                {
                    TableContents.Add(new TableContent
                    {
                        BillNo           = detail.deliveryOrder.billNo,
                        DONo             = detail.deliveryOrder.doNo,
                        DODate           = detail.deliveryOrder.doDate.ToOffset(new TimeSpan(clientTimeZoneOffset, 0, 0)).ToString("dd MMMM yyyy", new CultureInfo("id-ID")),
                        RefNo            = detail.poSerialNumber + " - " + detail.ePONo,
                        Product          = detail.product.Name,
                        Quantity         = detail.quantity.ToString("N", new CultureInfo("id-ID")),
                        UomUnit          = detail.uomUnit.Unit,
                        PricePerdealUnit = detail.pricePerDealUnit.ToString("N", new CultureInfo("id-ID")),
                        PriceTotal       = detail.priceTotal.ToString("N", new CultureInfo("id-ID"))
                    });

                    totalPriceTotal += detail.priceTotal;

                    total += detail.priceTotal * detail.deliveryOrder.docurrency.Rate;

                    if (units.ContainsKey(detail.unit.Code))
                    {
                        units[detail.unit.Code] += detail.priceTotal;
                    }
                    else
                    {
                        units.Add(detail.unit.Code, detail.priceTotal);
                    }

                    if (item.garmentInvoice.useVat == true && item.garmentInvoice.isPayVat == true)
                    {
                        ppn = 0.1 * totalPriceTotal;
                    }
                    else if (item.garmentInvoice.isPayVat == false)
                    {
                        ppn = 0;
                    }

                    if (item.garmentInvoice.useIncomeTax == true && item.garmentInvoice.isPayTax == true)
                    {
                        pph = (item.garmentInvoice.incomeTaxRate / 100) * totalPriceTotal;
                    }
                    else if (item.garmentInvoice.isPayTax == false)
                    {
                        pph = 0;
                    }

                    var correctionNotes = correctionNote.ReadByDOId((int)detail.deliveryOrder.Id);

                    if (!koreksi.ContainsKey(detail.deliveryOrder.Id))
                    {
                        totalcorrection += correctionNotes.Sum(s =>
                        {
                            if (s.CorrectionType.ToUpper() == "RETUR")
                            {
                                return(s.Items.Sum(i => i.PricePerDealUnitAfter * i.Quantity));
                            }
                            else
                            {
                                return(s.TotalCorrection);
                            }
                        });
                        koreksi.Add(detail.deliveryOrder.Id, correctionNotes.Sum(s => s.TotalCorrection));
                    }

                    maxtotal = (totalPriceTotal + ppn - pph) + (double)totalcorrection;
                }
            }

            foreach (TableContent c in TableContents.OrderBy(o => o.DONo))
            {
                cellLeft.Phrase = new Phrase(c.BillNo, normal_font1);
                tableContent.AddCell(cellLeft);

                cellLeft.Phrase = new Phrase(c.DONo, normal_font1);
                tableContent.AddCell(cellLeft);

                cellLeft.Phrase = new Phrase(c.DODate, normal_font1);
                tableContent.AddCell(cellLeft);

                cellLeft.Phrase = new Phrase(c.RefNo, normal_font1);
                tableContent.AddCell(cellLeft);

                cellLeft.Phrase = new Phrase(c.Product, normal_font1);
                tableContent.AddCell(cellLeft);

                cellRight.Phrase = new Phrase(c.Quantity, normal_font1);
                tableContent.AddCell(cellRight);

                cellRight.Phrase = new Phrase(c.UomUnit, normal_font1);
                tableContent.AddCell(cellRight);

                cellRight.Phrase = new Phrase(c.PricePerdealUnit, normal_font1);
                tableContent.AddCell(cellRight);

                cellRight.Phrase = new Phrase(c.PriceTotal, normal_font1);
                tableContent.AddCell(cellRight);
            }

            PdfPCell cellContent = new PdfPCell(tableContent); // dont remove
            tableContent.ExtendLastRow = false;
            tableContent.SpacingAfter  = 20f;
            document.Add(tableContent);
            #endregion

            #region Footer

            PdfPTable tableFooter = new PdfPTable(2);
            tableFooter.SetWidths(new float[] { 1f, 1f });

            PdfPTable tableFooterLeft = new PdfPTable(2);
            tableFooterLeft.SetWidths(new float[] { 3f, 5f });

            PdfPCell cellInternNoteFooterLeft = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT
            };
            PdfPCell cellInternNoteFooterRight = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT
            };
            foreach (var unit in units)
            {
                if (unit.Value == 0)
                {
                    cellLeftNoBorder.Phrase = new Phrase($"Total {unit.Key}", normal_font);
                    tableFooterLeft.AddCell(cellLeftNoBorder);
                    cellLeftNoBorder.Phrase = new Phrase($":   -", normal_font);
                    tableFooterLeft.AddCell(cellLeftNoBorder);
                }
                else
                {
                    cellLeftNoBorder.Phrase = new Phrase($"Total {unit.Key}", normal_font);
                    tableFooterLeft.AddCell(cellLeftNoBorder);
                    cellLeftNoBorder.Phrase = new Phrase($":   {unit.Value.ToString("n", new CultureInfo("id-ID"))}", normal_font);
                    tableFooterLeft.AddCell(cellLeftNoBorder);
                }
            }

            PdfPTable tableFooterRight = new PdfPTable(2);
            tableFooterRight.SetWidths(new float[] { 5f, 5f });

            cellLeftNoBorder.Phrase = new Phrase($"Total Harga Pokok (DPP)", normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase($": " + totalPriceTotal.ToString("N", new CultureInfo("id-ID")), normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase("Mata Uang", normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase($": " + viewModel.currency.Code, normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase("Total Harga Pokok (Rp)", normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase($": " + total.ToString("N", new CultureInfo("id-ID")), normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase("Total Nota Koreksi", normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            if (correctionNote != null)
            {
                cellLeftNoBorder.Phrase = new Phrase($": " + totalcorrection.ToString("N", new CultureInfo("id-ID")), normal_font);
                tableFooterRight.AddCell(cellLeftNoBorder);
            }
            else
            {
                cellLeftNoBorder.Phrase = new Phrase($": " + 0, normal_font);
                tableFooterRight.AddCell(cellLeftNoBorder);
            }

            cellLeftNoBorder.Phrase = new Phrase("Total Nota PPn", normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase($": " + ppn.ToString("N", new CultureInfo("id-ID")), normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase("Total Nota PPh", normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase($": " + pph.ToString("N", new CultureInfo("id-ID")), normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase("Total yang Harus Dibayar", normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase($": " + maxtotal.ToString("N", new CultureInfo("id-ID")), normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            PdfPCell cellFooterLeft = new PdfPCell(tableFooterLeft)
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER
            };
            tableFooter.AddCell(cellFooterLeft);
            PdfPCell cellFooterRight = new PdfPCell(tableFooterRight)
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER
            };
            tableFooter.AddCell(cellFooterRight);


            PdfPCell cellFooter = new PdfPCell(tableFooter); // dont remove
            tableFooter.ExtendLastRow = false;
            tableFooter.SpacingAfter  = 20f;
            document.Add(tableFooter);

            #endregion

            #region TableSignature

            PdfPTable tableSignature = new PdfPTable(3);

            PdfPCell cellSignatureContent = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_CENTER
            };

            cellSignatureContent.Phrase = new Phrase("Administrasi\n\n\n\n\n\n\n(  " + "Nama & Tanggal" + "  )", bold_font);
            tableSignature.AddCell(cellSignatureContent);
            cellSignatureContent.Phrase = new Phrase("Staff Pembelian\n\n\n\n\n\n\n(  " + "Nama & Tanggal" + "  )", bold_font);
            tableSignature.AddCell(cellSignatureContent);
            cellSignatureContent.Phrase = new Phrase("Verifikasi\n\n\n\n\n\n\n(  " + "Nama & Tanggal" + "  )", bold_font);
            tableSignature.AddCell(cellSignatureContent);


            PdfPCell cellSignature = new PdfPCell(tableSignature); // dont remove
            tableSignature.ExtendLastRow = false;
            tableSignature.SpacingBefore = 20f;
            tableSignature.SpacingAfter  = 20f;
            document.Add(tableSignature);

            #endregion

            document.Close();
            byte[] byteInfo = stream.ToArray();
            stream.Write(byteInfo, 0, byteInfo.Length);
            stream.Position = 0;

            return(stream);
        }
コード例 #5
0
        public void Should_Success_Validate_Data()
        {
            var viewModelNullItems = new GarmentInternNoteViewModel
            {
                items = null,
            };

            Assert.True(viewModelNullItems.Validate(null).Count() > 0);

            Mock <IGarmentInvoice> garmentInvoiceFacadeMock = new Mock <IGarmentInvoice>();

            garmentInvoiceFacadeMock.Setup(s => s.ReadById(1))
            .Returns(new Lib.Models.GarmentInvoiceModel.GarmentInvoice {
                UseIncomeTax = false, UseVat = false, IncomeTaxId = 1, Items = new List <GarmentInvoiceItem> {
                    new GarmentInvoiceItem
                    {
                        InvoiceId     = 1,
                        PaymentMethod = "PaymentMethod1"
                    }
                }
            });
            garmentInvoiceFacadeMock.Setup(s => s.ReadById(2))
            .Returns(new Lib.Models.GarmentInvoiceModel.GarmentInvoice
            {
                UseIncomeTax = true,
                UseVat       = true,
                IncomeTaxId  = 2,
                Items        = new List <GarmentInvoiceItem> {
                    new GarmentInvoiceItem
                    {
                        InvoiceId     = 2,
                        PaymentMethod = "PaymentMethod2"
                    }
                }
            });

            Mock <IGarmentDeliveryOrderFacade> garmentDeliveryOrderFacadeMock = new Mock <IGarmentDeliveryOrderFacade>();

            garmentDeliveryOrderFacadeMock.Setup(s => s.ReadById(It.IsAny <int>()))
            .Returns(new Lib.Models.GarmentDeliveryOrderModel.GarmentDeliveryOrder());

            Mock <IServiceProvider> serviceProvider = new Mock <IServiceProvider>();

            serviceProvider.
            Setup(x => x.GetService(typeof(IGarmentInvoice)))
            .Returns(garmentInvoiceFacadeMock.Object);
            serviceProvider.
            Setup(x => x.GetService(typeof(IGarmentDeliveryOrderFacade)))
            .Returns(garmentDeliveryOrderFacadeMock.Object);

            var sameUseVat = new GarmentInternNoteViewModel
            {
                items = new List <GarmentInternNoteItemViewModel>
                {
                    new GarmentInternNoteItemViewModel
                    {
                        garmentInvoice = new GarmentInvoiceViewModel
                        {
                            Id = 1
                        },
                        details = new List <GarmentInternNoteDetailViewModel>
                        {
                            new GarmentInternNoteDetailViewModel
                            {
                                deliveryOrder = new Lib.ViewModels.GarmentDeliveryOrderViewModel.GarmentDeliveryOrderViewModel
                                {
                                    Id = 1
                                }
                            }
                        }
                    },
                    new GarmentInternNoteItemViewModel
                    {
                        garmentInvoice = new GarmentInvoiceViewModel
                        {
                            Id = 2
                        },
                        details = new List <GarmentInternNoteDetailViewModel>
                        {
                            new GarmentInternNoteDetailViewModel
                            {
                                deliveryOrder = new Lib.ViewModels.GarmentDeliveryOrderViewModel.GarmentDeliveryOrderViewModel
                                {
                                    Id = 2
                                }
                            }
                        }
                    },
                }
            };

            ValidationContext Usevats = new ValidationContext(sameUseVat, serviceProvider.Object, null);

            Assert.True(sameUseVat.Validate(Usevats).Count() > 0);

            var viewModelNullDetail = new GarmentInternNoteViewModel
            {
                items = new List <GarmentInternNoteItemViewModel>
                {
                    new GarmentInternNoteItemViewModel
                    {
                        garmentInvoice = null,
                        details        = null
                    }
                }
            };

            Assert.True(viewModelNullDetail.Validate(null).Count() > 0);
        }
コード例 #6
0
        public void Should_Success_Validate_Data()
        {
            var viewModelNullItems = new GarmentInternNoteViewModel
            {
                items = null,
            };

            //System.ComponentModel.DataAnnotations.ValidationContext garmentINValidate1 = new System.ComponentModel.DataAnnotations.ValidationContext(viewModelNullItems, serviceProvider.Object, null);
            Assert.True(viewModelNullItems.Validate(null).Count() > 0);

            Mock <IGarmentInvoice> garmentInvoiceFacadeMock = new Mock <IGarmentInvoice>();

            garmentInvoiceFacadeMock.Setup(s => s.ReadById(1))
            .Returns(new Lib.Models.GarmentInvoiceModel.GarmentInvoice {
                UseIncomeTax = false, UseVat = false, IncomeTaxId = 1, Items = new List <GarmentInvoiceItem> {
                    new GarmentInvoiceItem
                    {
                        InvoiceId     = 1,
                        PaymentMethod = "PaymentMethod1"
                    }
                }
            });
            garmentInvoiceFacadeMock.Setup(s => s.ReadById(2))
            .Returns(new Lib.Models.GarmentInvoiceModel.GarmentInvoice
            {
                UseIncomeTax = true,
                UseVat       = true,
                IncomeTaxId  = 2,
                Items        = new List <GarmentInvoiceItem> {
                    new GarmentInvoiceItem
                    {
                        InvoiceId     = 2,
                        PaymentMethod = "PaymentMethod2"
                    }
                }
            });

            Mock <IGarmentDeliveryOrderFacade> garmentDeliveryOrderFacadeMock = new Mock <IGarmentDeliveryOrderFacade>();

            garmentDeliveryOrderFacadeMock.Setup(s => s.ReadById(It.IsAny <int>()))
            .Returns(new Lib.Models.GarmentDeliveryOrderModel.GarmentDeliveryOrder());

            Mock <IServiceProvider> serviceProvider = new Mock <IServiceProvider>();

            serviceProvider.
            Setup(x => x.GetService(typeof(IGarmentInvoice)))
            .Returns(garmentInvoiceFacadeMock.Object);
            serviceProvider.
            Setup(x => x.GetService(typeof(IGarmentDeliveryOrderFacade)))
            .Returns(garmentDeliveryOrderFacadeMock.Object);
            serviceProvider.
            Setup(x => x.GetService(typeof(PurchasingDbContext)))
            .Returns(_dbContext(GetCurrentMethod()));

            //var sameUseVat = new GarmentInternNoteViewModel
            //{
            //    items = new List<GarmentInternNoteItemViewModel>
            //    {
            //        new GarmentInternNoteItemViewModel
            //        {
            //            garmentInvoice  = new GarmentInvoiceViewModel
            //            {
            //                Id = 1
            //            },
            //            details = new List<GarmentInternNoteDetailViewModel>
            //            {
            //                new GarmentInternNoteDetailViewModel
            //                {
            //                    deliveryOrder = new Lib.ViewModels.GarmentDeliveryOrderViewModel.GarmentDeliveryOrderViewModel
            //                    {
            //                        Id = 1
            //                    }
            //                }
            //            }
            //        },
            //        new GarmentInternNoteItemViewModel
            //        {
            //            garmentInvoice  = new GarmentInvoiceViewModel
            //            {
            //                Id = 2
            //            },
            //            details = new List<GarmentInternNoteDetailViewModel>
            //            {
            //                new GarmentInternNoteDetailViewModel
            //                {
            //                     deliveryOrder = new Lib.ViewModels.GarmentDeliveryOrderViewModel.GarmentDeliveryOrderViewModel
            //                    {
            //                        Id = 2
            //                    }
            //                }
            //            }
            //        },

            //    }
            //};
            //ValidationContext Usevats = new ValidationContext(sameUseVat, serviceProvider.Object, null);
            //Assert.True(sameUseVat.Validate(Usevats).Count() > 0);

            var viewModelNullDetail = new GarmentInternNoteViewModel
            {
                items = new List <GarmentInternNoteItemViewModel>
                {
                    new GarmentInternNoteItemViewModel
                    {
                        garmentInvoice = null,
                        details        = null
                    }
                }
            };

            Assert.True(viewModelNullDetail.Validate(null).Count() > 0);

            var date = DateTime.Now;

            var viewModelNullDetail2 = new GarmentInternNoteViewModel
            {
                items = new List <GarmentInternNoteItemViewModel>
                {
                    new GarmentInternNoteItemViewModel
                    {
                        garmentInvoice = new GarmentInvoiceViewModel {
                            Id          = 1,
                            invoiceNo   = "invotest123",
                            invoiceDate = date
                        },
                        details = null
                    },

                    new GarmentInternNoteItemViewModel
                    {
                        garmentInvoice = new GarmentInvoiceViewModel {
                            Id          = 2,
                            invoiceNo   = "invotest123",
                            invoiceDate = date
                        },
                        details = null
                    },
                }
            };
            ValidationContext Usevats = new ValidationContext(viewModelNullDetail2, serviceProvider.Object, null);

            Assert.True(viewModelNullDetail2.Validate(Usevats).Count() > 0);
        }
コード例 #7
0
        public MemoryStream GeneratePdfTemplate(GarmentInternNoteViewModel viewModel, int clientTimeZoneOffset, IGarmentDeliveryOrderFacade DOfacade)
        {
            Font header_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 18);
            Font normal_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 9);
            Font bold_font   = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8);
            //Font header_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8);

            Document document = new Document(PageSize.A4, 40, 40, 40, 40);

            document.AddHeader("Header", viewModel.inNo);
            MemoryStream stream = new MemoryStream();
            PdfWriter    writer = PdfWriter.GetInstance(document, stream);

            writer.PageEvent = new PDFPages();
            document.Open();

            Chunk        chkHeader = new Chunk(" ");
            Phrase       pheader   = new Phrase(chkHeader);
            HeaderFooter header    = new HeaderFooter(pheader, false);

            header.Border    = Rectangle.NO_BORDER;
            header.Alignment = Element.ALIGN_RIGHT;
            document.Header  = header;

            #region Header

            string    addressString = "PT DAN LIRIS" + "\n" + "Head Office: Kelurahan Banaran" + "\n" + "Kecamatan Grogol" + "\n" + "Sukoharjo 57193 - INDONESIA" + "\n" + "PO.BOX 166 Solo 57100" + "\n" + "Telp. (0271) 740888, 714400" + "\n" + "Fax. (0271) 735222, 740777";
            Paragraph address       = new Paragraph(addressString, bold_font)
            {
                Alignment = Element.ALIGN_LEFT
            };
            document.Add(address);
            bold_font.SetStyle(Font.NORMAL);

            string    titleString = "NOTA INTERN\n\n";
            Paragraph title       = new Paragraph(titleString, bold_font)
            {
                Alignment = Element.ALIGN_CENTER
            };
            document.Add(title);
            bold_font.SetStyle(Font.NORMAL);

            PdfPTable tableInternNoteHeader = new PdfPTable(2);
            tableInternNoteHeader.SetWidths(new float[] { 4.5f, 4.5f });
            PdfPCell cellInternNoteHeaderLeft = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT
            };
            PdfPCell cellInternNoteHeaderRight = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT
            };

            cellInternNoteHeaderLeft.Phrase = new Phrase("No. Nota Intern" + "      : " + viewModel.inNo, normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft);

            cellInternNoteHeaderRight.Phrase = new Phrase("Tanggal Nota Intern" + "       : " + viewModel.inDate.ToOffset(new TimeSpan(clientTimeZoneOffset, 0, 0)).ToString("dd MMMM yyyy", new CultureInfo("id-ID")), normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderRight);

            cellInternNoteHeaderLeft.Phrase = new Phrase("Kode Supplier" + "        : " + viewModel.supplier.Code, normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft);

            DateTimeOffset paymentduedates;
            string         paymentmethods = "";

            var paymentDueDateTemp = DateTimeOffset.MinValue;
            foreach (GarmentInternNoteItemViewModel item in viewModel.items)
            {
                foreach (GarmentInternNoteDetailViewModel detail in item.details)
                {
                    if (paymentDueDateTemp > detail.paymentDueDate)
                    {
                        paymentduedates = paymentDueDateTemp;
                    }
                    else if (detail.paymentDueDate > paymentDueDateTemp)
                    {
                        paymentduedates = detail.paymentDueDate;
                    }
                    paymentmethods = detail.deliveryOrder.paymentMethod;
                }
            }

            cellInternNoteHeaderRight.Phrase = new Phrase("Tanggal Jatuh Tempo" + "    : " + paymentduedates.ToOffset(new TimeSpan(clientTimeZoneOffset, 0, 0)).ToString("dd MMMM yyyy", new CultureInfo("id-ID")), normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderRight);

            cellInternNoteHeaderLeft.Phrase = new Phrase("Nama Supplier" + "       : " + viewModel.supplier.Name, normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft);

            cellInternNoteHeaderRight.Phrase = new Phrase("Term Pembayaran" + "         : " + paymentmethods, normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderRight);


            PdfPCell cellInternNoteHeader = new PdfPCell(tableInternNoteHeader); // dont remove
            tableInternNoteHeader.ExtendLastRow = false;
            tableInternNoteHeader.SpacingAfter  = 10f;
            document.Add(tableInternNoteHeader);
            #endregion

            #region Table_Of_Content
            PdfPCell cellCenter = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 5
            };
            PdfPCell cellRight = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 5
            };
            PdfPCell cellLeft = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 5
            };

            PdfPTable tableContent = new PdfPTable(8);
            tableContent.SetWidths(new float[] { 3.5f, 4f, 5f, 5.5f, 3f, 3f, 3f, 4f });
            cellCenter.Phrase = new Phrase("NO. Surat Jalan", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Tgl. Surat Jalan", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("No. Referensi PR", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Keterangan Barang", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Jumlah", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Satuan", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Harga Satuan", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Harga Total", bold_font);
            tableContent.AddCell(cellCenter);

            double totalPriceTotal            = 0;
            double total                      = 0;
            double ppn                        = 0;
            double pph                        = 0;
            double maxtotal                   = 0;
            Dictionary <string, double> units = new Dictionary <string, double>();
            foreach (GarmentInternNoteItemViewModel item in viewModel.items)
            {
                foreach (GarmentInternNoteDetailViewModel detail in item.details)
                {
                    cellLeft.Phrase = new Phrase(detail.deliveryOrder.doNo, normal_font);
                    tableContent.AddCell(cellLeft);

                    string doDate = detail.deliveryOrder.doDate.ToOffset(new TimeSpan(clientTimeZoneOffset, 0, 0)).ToString("dd MMMM yyyy", new CultureInfo("id-ID"));

                    cellLeft.Phrase = new Phrase(doDate, normal_font);
                    tableContent.AddCell(cellLeft);

                    cellLeft.Phrase = new Phrase(detail.poSerialNumber, normal_font);
                    tableContent.AddCell(cellLeft);

                    cellLeft.Phrase = new Phrase(detail.product.Name, normal_font);
                    tableContent.AddCell(cellLeft);

                    cellRight.Phrase = new Phrase(detail.quantity.ToString("N", new CultureInfo("id-ID")), normal_font);
                    tableContent.AddCell(cellRight);

                    cellRight.Phrase = new Phrase(detail.uomUnit.Unit, normal_font);
                    tableContent.AddCell(cellRight);

                    cellRight.Phrase = new Phrase(detail.pricePerDealUnit.ToString("N", new CultureInfo("id-ID")), normal_font);
                    tableContent.AddCell(cellRight);

                    cellRight.Phrase = new Phrase(detail.priceTotal.ToString("N", new CultureInfo("id-ID")), normal_font);
                    tableContent.AddCell(cellRight);

                    totalPriceTotal += detail.priceTotal;
                    total            = totalPriceTotal * detail.deliveryOrder.docurrency.Rate;

                    if (units.ContainsKey(detail.unit.Code))
                    {
                        units[detail.unit.Code] += detail.priceTotal;
                    }
                    else
                    {
                        units.Add(detail.unit.Code, detail.priceTotal);
                    }

                    if (item.garmentInvoice.useVat)
                    {
                        ppn = 0.1 * totalPriceTotal;
                    }

                    if (item.garmentInvoice.useIncomeTax)
                    {
                        pph = item.garmentInvoice.incomeTaxRate * totalPriceTotal;
                    }

                    maxtotal = pph + ppn + totalPriceTotal;
                }
            }

            PdfPCell cellContent = new PdfPCell(tableContent); // dont remove
            tableContent.ExtendLastRow = false;
            tableContent.SpacingAfter  = 20f;
            document.Add(tableContent);
            #endregion

            #region Footer

            PdfPTable tableFooter = new PdfPTable(4);
            tableFooter.SetWidths(new float[] { 1.5f, 6f, 3f, 3f });

            PdfPCell cellInternNoteFooterLeft = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT
            };
            PdfPCell cellInternNoteFooterRight = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT
            };


            foreach (var unit in units)
            {
                cellInternNoteFooterLeft.Phrase = new Phrase("Total " + unit.Key, normal_font);
                tableFooter.AddCell(cellInternNoteFooterLeft);

                cellInternNoteFooterLeft.Phrase = new Phrase(" : " + unit.Value.ToString("N", new CultureInfo("id-ID")), normal_font);
                tableFooter.AddCell(cellInternNoteFooterLeft);
            }

            cellInternNoteFooterRight.Phrase = new Phrase("Total Harga Pokok (DPP)", normal_font);
            tableFooter.AddCell(cellInternNoteFooterRight);

            cellInternNoteFooterLeft.Phrase = new Phrase(": " + totalPriceTotal.ToString("N", new CultureInfo("id-ID")), normal_font);
            tableFooter.AddCell(cellInternNoteFooterLeft);

            cellInternNoteFooterLeft.Phrase = new Phrase("", normal_font);
            tableFooter.AddCell(cellInternNoteFooterLeft);

            cellInternNoteFooterLeft.Phrase = new Phrase("", normal_font);
            tableFooter.AddCell(cellInternNoteFooterLeft);

            cellInternNoteFooterRight.Phrase = new Phrase("Mata Uang", normal_font);
            tableFooter.AddCell(cellInternNoteFooterRight);

            cellInternNoteFooterLeft.Phrase = new Phrase(": " + viewModel.currency.Code, normal_font);
            tableFooter.AddCell(cellInternNoteFooterLeft);

            cellInternNoteFooterLeft.Phrase = new Phrase("", normal_font);
            tableFooter.AddCell(cellInternNoteFooterLeft);

            cellInternNoteFooterLeft.Phrase = new Phrase("", normal_font);
            tableFooter.AddCell(cellInternNoteFooterLeft);

            cellInternNoteFooterRight.Phrase = new Phrase("Total Harga Pokok (Rp)", normal_font);
            tableFooter.AddCell(cellInternNoteFooterRight);

            cellInternNoteFooterLeft.Phrase = new Phrase(": " + total.ToString("N", new CultureInfo("id-ID")), normal_font);
            tableFooter.AddCell(cellInternNoteFooterLeft);

            cellInternNoteFooterLeft.Phrase = new Phrase("", normal_font);
            tableFooter.AddCell(cellInternNoteFooterLeft);

            cellInternNoteFooterLeft.Phrase = new Phrase("", normal_font);
            tableFooter.AddCell(cellInternNoteFooterLeft);

            cellInternNoteFooterRight.Phrase = new Phrase("Total Nota Koreksi", normal_font);
            tableFooter.AddCell(cellInternNoteFooterRight);

            cellInternNoteFooterLeft.Phrase = new Phrase(": " + 0, normal_font);
            tableFooter.AddCell(cellInternNoteFooterLeft);

            cellInternNoteFooterLeft.Phrase = new Phrase("", normal_font);
            tableFooter.AddCell(cellInternNoteFooterLeft);

            cellInternNoteFooterLeft.Phrase = new Phrase("", normal_font);
            tableFooter.AddCell(cellInternNoteFooterLeft);

            cellInternNoteFooterRight.Phrase = new Phrase("Total Nota PPn", normal_font);
            tableFooter.AddCell(cellInternNoteFooterRight);

            cellInternNoteFooterLeft.Phrase = new Phrase(": " + ppn.ToString("N", new CultureInfo("id-ID")), normal_font);
            tableFooter.AddCell(cellInternNoteFooterLeft);

            cellInternNoteFooterLeft.Phrase = new Phrase("", normal_font);
            tableFooter.AddCell(cellInternNoteFooterLeft);

            cellInternNoteFooterLeft.Phrase = new Phrase("", normal_font);
            tableFooter.AddCell(cellInternNoteFooterLeft);

            cellInternNoteFooterRight.Phrase = new Phrase("Total Nota PPh", normal_font);
            tableFooter.AddCell(cellInternNoteFooterRight);

            cellInternNoteFooterLeft.Phrase = new Phrase(": " + pph.ToString("N", new CultureInfo("id-ID")), normal_font);
            tableFooter.AddCell(cellInternNoteFooterLeft);

            cellInternNoteFooterLeft.Phrase = new Phrase("", normal_font);
            tableFooter.AddCell(cellInternNoteFooterLeft);

            cellInternNoteFooterLeft.Phrase = new Phrase("", normal_font);
            tableFooter.AddCell(cellInternNoteFooterLeft);

            cellInternNoteFooterRight.Phrase = new Phrase("Total yang Harus Dibayar", normal_font);
            tableFooter.AddCell(cellInternNoteFooterRight);

            cellInternNoteFooterLeft.Phrase = new Phrase(": " + maxtotal.ToString("N", new CultureInfo("id-ID")), normal_font);
            tableFooter.AddCell(cellInternNoteFooterLeft);



            PdfPCell cellFooter = new PdfPCell(tableFooter); // dont remove
            tableFooter.ExtendLastRow = false;
            tableFooter.SpacingAfter  = 20f;
            document.Add(tableFooter);

            #endregion

            #region TableSignature

            PdfPTable tableSignature = new PdfPTable(3);

            PdfPCell cellSignatureContent = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_CENTER
            };

            cellSignatureContent.Phrase = new Phrase("Administrasi\n\n\n\n\n\n\n(  " + "Nama & Tanggal" + "  )", bold_font);
            tableSignature.AddCell(cellSignatureContent);
            cellSignatureContent.Phrase = new Phrase("Staff Pembelian\n\n\n\n\n\n\n(  " + "Nama & Tanggal" + "  )", bold_font);
            tableSignature.AddCell(cellSignatureContent);
            cellSignatureContent.Phrase = new Phrase("Verifikasi\n\n\n\n\n\n\n(  " + "Nama & Tanggal" + "  )", bold_font);
            tableSignature.AddCell(cellSignatureContent);


            PdfPCell cellSignature = new PdfPCell(tableSignature); // dont remove
            tableSignature.ExtendLastRow = false;
            tableSignature.SpacingBefore = 20f;
            tableSignature.SpacingAfter  = 20f;
            document.Add(tableSignature);

            #endregion

            document.Close();
            byte[] byteInfo = stream.ToArray();
            stream.Write(byteInfo, 0, byteInfo.Length);
            stream.Position = 0;

            return(stream);
        }