public GarmentDeliveryOrderController(IServiceProvider serviceProvider, IMapper mapper, IGarmentDeliveryOrderFacade facade) { this.serviceProvider = serviceProvider; this.mapper = mapper; this.facade = facade; this.identityService = (IdentityService)serviceProvider.GetService(typeof(IdentityService)); }
public GarmentInternNoteController(IServiceProvider serviceProvider, IMapper mapper, IGarmentInternNoteFacade facade, IGarmentDeliveryOrderFacade deliveryOrderFacade, IGarmentInvoice invoiceFacade) { this.serviceProvider = serviceProvider; this.mapper = mapper; this.facade = facade; this.identityService = (IdentityService)serviceProvider.GetService(typeof(IdentityService)); this.deliveryOrderFacade = deliveryOrderFacade; this.invoiceFacade = invoiceFacade; }
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); }
public static MemoryStream Generate(GarmentCorrectionNote model, IServiceProvider serviceProvider, int clientTimeZoneOffset = 7, string userName = "") { IGarmentDeliveryOrderFacade garmentDeliveryOrderFacade = (IGarmentDeliveryOrderFacade)serviceProvider.GetService(typeof(IGarmentDeliveryOrderFacade)); IGarmentInternalPurchaseOrderFacade garmentInternalPurchaseOrderFacade = (IGarmentInternalPurchaseOrderFacade)serviceProvider.GetService(typeof(IGarmentInternalPurchaseOrderFacade)); Document document = new Document(PageSize.A4, 10, 10, 10, 10); MemoryStream stream = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(document, stream); document.Open(); Font header_font = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 10); Font normal_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8); Font bold_font = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8); PdfPCell cellLeftNoBorder = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }; PdfPCell cellCenterNoBorder = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER }; PdfPCell cellCenterTopNoBorder = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_TOP }; PdfPCell cellRightNoBorder = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }; PdfPCell cellJustifyNoBorder = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_JUSTIFIED }; PdfPCell cellJustifyAllNoBorder = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_JUSTIFIED_ALL }; 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 }; var garmentDeliveryOrder = garmentDeliveryOrderFacade.ReadById((int)model.DOId); #region Header string addressString = "PT. DAN LIRIS\n" + "Head Offce :\n" + "Kelurahan Banaran, Kecamatan Grogol\n" + "Sukoharjo 57193 - INDONESIA\n" + "PO.BOX 166 Solo 57100\n" + "Telp. (0271) 740888, 714400\n" + "Fax. (0271) 735222, 740777"; Paragraph addressParagraph = new Paragraph(8f, addressString, bold_font) { Alignment = Element.ALIGN_LEFT }; document.Add(addressParagraph); Paragraph headerParagraph = new Paragraph("NOTA KOREKSI", header_font) { Alignment = Element.ALIGN_CENTER, SpacingAfter = 15f }; document.Add(headerParagraph); #endregion #region Identity PdfPTable tableIdentity = new PdfPTable(2); tableIdentity.SetWidths(new float[] { 1f, 1f }); PdfPTable tableIdentityLeft = new PdfPTable(2); tableIdentityLeft.SetWidths(new float[] { 3f, 5f }); cellLeftNoBorder.Phrase = new Phrase("No. Nota Koreksi", normal_font); tableIdentityLeft.AddCell(cellLeftNoBorder); cellLeftNoBorder.Phrase = new Phrase($": {model.CorrectionNo}", normal_font); tableIdentityLeft.AddCell(cellLeftNoBorder); cellLeftNoBorder.Phrase = new Phrase("Kode Supplier", normal_font); tableIdentityLeft.AddCell(cellLeftNoBorder); cellLeftNoBorder.Phrase = new Phrase($": {model.SupplierCode}", normal_font); tableIdentityLeft.AddCell(cellLeftNoBorder); cellLeftNoBorder.Phrase = new Phrase("Nama Supplier", normal_font); tableIdentityLeft.AddCell(cellLeftNoBorder); cellLeftNoBorder.Phrase = new Phrase($": {model.SupplierName}", normal_font); tableIdentityLeft.AddCell(cellLeftNoBorder); PdfPTable tableIdentityRight = new PdfPTable(2); tableIdentityRight.SetWidths(new float[] { 3f, 5f }); cellLeftNoBorder.Phrase = new Phrase("Tanggal", normal_font); tableIdentityRight.AddCell(cellLeftNoBorder); cellLeftNoBorder.Phrase = new Phrase($": {model.CorrectionDate.ToOffset(new TimeSpan(clientTimeZoneOffset, 0, 0)).ToString("dd MMMM yyyy", new CultureInfo("id-ID"))}", normal_font); tableIdentityRight.AddCell(cellLeftNoBorder); cellLeftNoBorder.Phrase = new Phrase("No. Surat Jalan", normal_font); tableIdentityRight.AddCell(cellLeftNoBorder); cellLeftNoBorder.Phrase = new Phrase($": {model.DONo}", normal_font); tableIdentityRight.AddCell(cellLeftNoBorder); cellLeftNoBorder.Phrase = new Phrase("Tanggal Surat Jalan", normal_font); tableIdentityRight.AddCell(cellLeftNoBorder); cellLeftNoBorder.Phrase = new Phrase($": {garmentDeliveryOrder.DODate.ToOffset(new TimeSpan(clientTimeZoneOffset, 0, 0)).ToString("dd MMMM yyyy", new CultureInfo("id-ID"))}", normal_font); tableIdentityRight.AddCell(cellLeftNoBorder); PdfPCell cellIdentityLeft = new PdfPCell(tableIdentityLeft) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER }; tableIdentity.AddCell(cellIdentityLeft); PdfPCell cellIdentityRight = new PdfPCell(tableIdentityRight) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER }; tableIdentity.AddCell(cellIdentityRight); PdfPCell cellIdentity = new PdfPCell(tableIdentity); tableIdentity.ExtendLastRow = false; tableIdentity.SpacingAfter = 15f; document.Add(tableIdentity); #endregion #region TableContent PdfPTable tableContent = new PdfPTable(10); tableContent.SetWidths(new float[] { 1.1f, 1.2f, 1f, 1f, 0.9f, 0.7f, 1.2f, 0.8f, 1.2f, 1.3f }); foreach (var columnName in new List <string> { "Plan PO", "Artikel", "Kode Barang", "Nama Barang", "Jumlah SJ", "Satuan", "Harga Satuan", "Jumlah Koreksi", "Harga/Satuan (Koreksi)", "Total Harga" }) { cellCenter.Phrase = new Phrase(columnName, bold_font); tableContent.AddCell(cellCenter); } Dictionary <string, decimal> dictionaryUnitAmount = new Dictionary <string, decimal>(); var totalAmount = 0m; foreach (var item in model.Items) { var garmentInternalPurchaseOrder = garmentInternalPurchaseOrderFacade.ReadById((int)item.POId); var deliveryOrderItem = garmentDeliveryOrder.Items.First(i => i.Details.Any(d => d.Id == item.DODetailId)); var doDetail = deliveryOrderItem.Details.FirstOrDefault(d => d.Id == item.DODetailId); cellLeft.Phrase = new Phrase(item.POSerialNumber, normal_font); tableContent.AddCell(cellLeft); cellLeft.Phrase = new Phrase(garmentInternalPurchaseOrder.Article, normal_font); tableContent.AddCell(cellLeft); cellLeft.Phrase = new Phrase(item.ProductCode, normal_font); tableContent.AddCell(cellLeft); cellLeft.Phrase = new Phrase(item.ProductName, normal_font); tableContent.AddCell(cellLeft); cellRight.Phrase = new Phrase(doDetail.DOQuantity.ToString("n", new CultureInfo("id-ID")), normal_font); tableContent.AddCell(cellRight); cellLeft.Phrase = new Phrase(item.UomIUnit, normal_font); tableContent.AddCell(cellLeft); cellRight.Phrase = new Phrase(doDetail.PricePerDealUnit.ToString("n", new CultureInfo("id-ID")), normal_font); tableContent.AddCell(cellRight); cellRight.Phrase = new Phrase(((double)item.Quantity).ToString(), normal_font); tableContent.AddCell(cellRight); cellRight.Phrase = new Phrase(item.PricePerDealUnitAfter.ToString("n", new CultureInfo("id-ID")), normal_font); tableContent.AddCell(cellRight); var totalHarga = (item.Quantity * item.PricePerDealUnitAfter); totalAmount += totalHarga; if (dictionaryUnitAmount.ContainsKey(garmentInternalPurchaseOrder.UnitCode)) { dictionaryUnitAmount[garmentInternalPurchaseOrder.UnitCode] += totalHarga; } else { dictionaryUnitAmount.Add(garmentInternalPurchaseOrder.UnitCode, totalHarga); } cellRight.Phrase = new Phrase(totalHarga.ToString("n", new CultureInfo("id-ID")), normal_font); tableContent.AddCell(cellRight); } PdfPCell cellContent = new PdfPCell(tableContent); tableContent.ExtendLastRow = false; tableContent.SpacingAfter = 10f; 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 }); foreach (var unitAmount in dictionaryUnitAmount) { cellLeftNoBorder.Phrase = new Phrase($"Total {unitAmount.Key}", normal_font); tableFooterLeft.AddCell(cellLeftNoBorder); cellLeftNoBorder.Phrase = new Phrase($": {unitAmount.Value.ToString("n", new CultureInfo("id-ID"))}", normal_font); tableFooterLeft.AddCell(cellLeftNoBorder); } PdfPTable tableFooterRight = new PdfPTable(2); tableFooterRight.SetWidths(new float[] { 3f, 5f }); cellLeftNoBorder.Phrase = new Phrase("Total Amount", normal_font); tableFooterRight.AddCell(cellLeftNoBorder); cellLeftNoBorder.Phrase = new Phrase($": {totalAmount.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($": {model.CurrencyCode}", normal_font); tableFooterRight.AddCell(cellLeftNoBorder); cellLeftNoBorder.Phrase = new Phrase("Total Harga Pokok (Rp)", normal_font); tableFooterRight.AddCell(cellLeftNoBorder); cellLeftNoBorder.Phrase = new Phrase($": {(totalAmount * (decimal)garmentDeliveryOrder.DOCurrencyRate).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); tableFooter.ExtendLastRow = false; tableFooter.SpacingAfter = 15f; document.Add(tableFooter); #endregion #region TableSignature var signer = new List <string> { "Administrasi", "Staff Pembelian", "Verifikasi" }; PdfPTable tableSignature = new PdfPTable(signer.Count); foreach (var columnName in signer) { cellCenter.Phrase = new Phrase(columnName, bold_font); tableSignature.AddCell(cellCenter); } for (int i = 0; i < signer.Count; i++) { cellCenter.Phrase = new Phrase("\n\n\n\n\n\n(Nama & Tanggal)", bold_font); tableSignature.AddCell(cellCenter); } PdfPCell cellSignature = new PdfPCell(tableSignature); // dont remove tableSignature.ExtendLastRow = false; tableSignature.SpacingBefore = 20f; tableSignature.SpacingAfter = 10f; document.Add(tableSignature); #endregion document.Close(); byte[] byteInfo = stream.ToArray(); stream.Write(byteInfo, 0, byteInfo.Length); stream.Position = 0; return(stream); }
public static MemoryStream Generate(GarmentCorrectionNote model, IServiceProvider serviceProvider, int clientTimeZoneOffset = 7, string userName = "") { IGarmentDeliveryOrderFacade garmentDeliveryOrderFacade = (IGarmentDeliveryOrderFacade)serviceProvider.GetService(typeof(IGarmentDeliveryOrderFacade)); IGarmentInvoice garmentInvoiceFacade = (IGarmentInvoice)serviceProvider.GetService(typeof(IGarmentInvoice)); Document document = new Document(PageSize.A4, 10, 10, 10, 10); MemoryStream stream = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(document, stream); document.Open(); Font header_font = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 10); Font normal_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8); Font bold_font = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8); PdfPCell cellLeftNoBorder = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }; PdfPCell cellCenterNoBorder = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER }; PdfPCell cellCenterTopNoBorder = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_TOP }; PdfPCell cellRightNoBorder = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }; PdfPCell cellJustifyNoBorder = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_JUSTIFIED }; PdfPCell cellJustifyAllNoBorder = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_JUSTIFIED_ALL }; 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 }; var deliveryOrder = garmentDeliveryOrderFacade.ReadById((int)model.DOId); var invoice = garmentInvoiceFacade.ReadByDOId((int)model.DOId); #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 addressParagraph = new Paragraph(8f, addressString, bold_font) { Alignment = Element.ALIGN_LEFT }; document.Add(addressParagraph); Paragraph headerParagraph = new Paragraph("NOTA KOREKSI PAJAK", header_font) { Alignment = Element.ALIGN_CENTER, SpacingAfter = 15f }; document.Add(headerParagraph); #endregion #region Identity PdfPTable tableIdentity = new PdfPTable(2); tableIdentity.SetWidths(new float[] { 1f, 1f }); PdfPTable tableIdentityLeft = new PdfPTable(2); tableIdentityLeft.SetWidths(new float[] { 3f, 5f }); cellLeftNoBorder.Phrase = new Phrase("No. Nota Koreksi", normal_font); tableIdentityLeft.AddCell(cellLeftNoBorder); cellLeftNoBorder.Phrase = new Phrase($": {model.CorrectionNo}", normal_font); tableIdentityLeft.AddCell(cellLeftNoBorder); cellLeftNoBorder.Phrase = new Phrase("No. Nota Pajak", normal_font); tableIdentityLeft.AddCell(cellLeftNoBorder); cellLeftNoBorder.Phrase = new Phrase($": {model.NKPN}", normal_font); tableIdentityLeft.AddCell(cellLeftNoBorder); PdfPTable tableIdentityRight = new PdfPTable(2); cellLeftNoBorder.Phrase = new Phrase("Kode Supplier", normal_font); tableIdentityRight.AddCell(cellLeftNoBorder); cellLeftNoBorder.Phrase = new Phrase($": {model.SupplierCode}", normal_font); tableIdentityRight.AddCell(cellLeftNoBorder); cellLeftNoBorder.Phrase = new Phrase("Nama Supplier", normal_font); tableIdentityRight.AddCell(cellLeftNoBorder); cellLeftNoBorder.Phrase = new Phrase($": {model.SupplierName}", normal_font); tableIdentityRight.AddCell(cellLeftNoBorder); PdfPCell cellIdentityLeft = new PdfPCell(tableIdentityLeft) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER }; tableIdentity.AddCell(cellIdentityLeft); PdfPCell cellIdentityRight = new PdfPCell(tableIdentityRight) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER }; tableIdentity.AddCell(cellIdentityRight); PdfPCell cellIdentity = new PdfPCell(tableIdentity); tableIdentity.ExtendLastRow = false; tableIdentity.SpacingAfter = 5f; document.Add(tableIdentity); #endregion #region TableContent var columnHeaders = new List <string> { "No. Surat Jalan", "Tgl. Surat Jalan", "Tgl. Jatuh Tempo", "No. Invoice", "Nama Barang", $"Total PPN ({model.CurrencyCode})" }; PdfPTable tableContent = new PdfPTable(columnHeaders.Count); tableContent.SetWidths(new float[] { 1.1f, 1.2f, 1f, 1f, 1.1f, 1.2f }); foreach (var columnName in columnHeaders) { cellCenter.Phrase = new Phrase(columnName, bold_font); tableContent.AddCell(cellCenter); } Dictionary <string, decimal> dictionaryUnitAmount = new Dictionary <string, decimal>(); var totalAmountPPH = 0m; foreach (var item in model.Items) { var deliveryOrderItem = deliveryOrder.Items.First(i => i.Details.Any(d => d.Id == item.DODetailId)); cellLeft.Phrase = new Phrase(deliveryOrder.DONo, normal_font); tableContent.AddCell(cellLeft); cellLeft.Phrase = new Phrase(deliveryOrder.DODate.ToOffset(new TimeSpan(clientTimeZoneOffset, 0, 0)).ToString("dd MMMM yyyy", new CultureInfo("id-ID")), normal_font); tableContent.AddCell(cellLeft); cellLeft.Phrase = new Phrase(deliveryOrder.DODate.AddDays(deliveryOrderItem.PaymentDueDays).ToOffset(new TimeSpan(clientTimeZoneOffset, 0, 0)).ToString("dd MMMM yyyy", new CultureInfo("id-ID")), normal_font); tableContent.AddCell(cellLeft); if (invoice != null) { cellLeft.Phrase = new Phrase(invoice.InvoiceNo, normal_font); tableContent.AddCell(cellLeft); } else { cellLeft.Phrase = new Phrase("", normal_font); tableContent.AddCell(cellLeft); } cellLeft.Phrase = new Phrase(item.ProductName, normal_font); tableContent.AddCell(cellLeft); decimal totalPPH; var convertdouble = Convert.ToDecimal(model.VatRate); totalPPH = (convertdouble / 100) * item.PricePerDealUnitAfter * item.Quantity; totalAmountPPH += totalPPH; cellRight.Phrase = new Phrase(totalPPH.ToString("n", new CultureInfo("id-ID")), normal_font); tableContent.AddCell(cellRight); } PdfPCell cellRightMerge = new PdfPCell() { Border = Rectangle.LEFT_BORDER | Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_TOP, Padding = 5, Colspan = columnHeaders.Count - 1 }; cellRightMerge.Phrase = new Phrase($"Total PPN ({model.CurrencyCode})", normal_font); tableContent.AddCell(cellRightMerge); cellRight.Phrase = new Phrase(totalAmountPPH.ToString("n", new CultureInfo("id-ID")), normal_font); tableContent.AddCell(cellRight); cellRightMerge.Phrase = new Phrase("Total PPN (IDR)", normal_font); tableContent.AddCell(cellRightMerge); cellRight.Phrase = new Phrase((totalAmountPPH * (decimal)deliveryOrder.DOCurrencyRate).ToString("n", new CultureInfo("id-ID")), normal_font); tableContent.AddCell(cellRight); PdfPCell cellContent = new PdfPCell(tableContent); tableContent.ExtendLastRow = false; tableContent.SpacingAfter = 60f; document.Add(tableContent); #endregion #region TableSignature var signer = new List <string> { "Staff Pembelian", "Administrasi", "Keuangan", "Pembukuan" }; PdfPTable tableSignature = new PdfPTable(signer.Count); foreach (var columnName in signer) { cellCenter.Phrase = new Phrase(columnName, bold_font); tableSignature.AddCell(cellCenter); } for (int i = 0; i < signer.Count; i++) { cellCenter.Phrase = new Phrase("\n\n\n\n\n\n(Nama & Tanggal)", bold_font); tableSignature.AddCell(cellCenter); } PdfPCell cellSignature = new PdfPCell(tableSignature); // dont remove tableSignature.ExtendLastRow = false; tableSignature.SpacingAfter = 10f; document.Add(tableSignature); #endregion document.Close(); byte[] byteInfo = stream.ToArray(); stream.Write(byteInfo, 0, byteInfo.Length); stream.Position = 0; return(stream); }
public MemoryStream GeneratePdfTemplate(GarmentInvoiceViewModel 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.nph); 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 PdfPTable tableHeader = new PdfPTable(1); tableHeader.SetWidths(new float[] { 4f }); PdfPCell cellHeaderContentLeft = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }; //PdfPCell cellHeaderContentRight = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }; cellHeaderContentLeft.Phrase = new Phrase("PT AMBASSADOR GARMINDO" + "\n" + "Head Office : Kelurahan Banaran" + "\n" + "Kecamatan Grogol" + "\n" + "Sukoharjo 57193 - INDONESIA" + "\n" + "PO BOX 166 Solo 57100" + "\n" + "Telp. (0271) 714400, 7652913" + "\n" + "Fax. (0271) 735222, 740777", bold_font); tableHeader.AddCell(cellHeaderContentLeft); //string noPO = viewModel.Supplier.Import ? "FM-PB-00-06-009/R1" + "\n" + "PO: " + EPONo : "PO: " + EPONo; PdfPCell cellHeader = new PdfPCell(tableHeader); // dont remove tableHeader.ExtendLastRow = false; tableHeader.SpacingAfter = 10f; document.Add(tableHeader); string titleString = "NOTA PAJAK PPH\n\n"; Paragraph title = new Paragraph(titleString, bold_font) { Alignment = Element.ALIGN_CENTER }; document.Add(title); bold_font.SetStyle(Font.NORMAL); PdfPTable tableIncomeTax = new PdfPTable(1); tableIncomeTax.SetWidths(new float[] { 4.5f }); PdfPCell cellTaxLeft = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }; cellTaxLeft.Phrase = new Phrase("No. Nota Pajak" + " : " + viewModel.nph, normal_font); tableIncomeTax.AddCell(cellTaxLeft); cellTaxLeft.Phrase = new Phrase("Kode Supplier" + " : " + viewModel.supplier.Code, normal_font); tableIncomeTax.AddCell(cellTaxLeft); cellTaxLeft.Phrase = new Phrase("Nama Supplier" + " : " + viewModel.supplier.Name, normal_font); tableIncomeTax.AddCell(cellTaxLeft); PdfPCell cellSupplier = new PdfPCell(tableIncomeTax); // dont remove tableIncomeTax.ExtendLastRow = false; tableIncomeTax.SpacingAfter = 10f; document.Add(tableIncomeTax); #endregion #region data 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(6); tableContent.SetWidths(new float[] { 4.5f, 5f, 3.5f, 4f, 2.2f, 5f }); cellCenter.Phrase = new Phrase("No Surat Jalan", bold_font); tableContent.AddCell(cellCenter); cellCenter.Phrase = new Phrase("Tanggal Surat Jalan", bold_font); tableContent.AddCell(cellCenter); cellCenter.Phrase = new Phrase("No Invoice", bold_font); tableContent.AddCell(cellCenter); cellCenter.Phrase = new Phrase("Nama Barang", bold_font); tableContent.AddCell(cellCenter); cellCenter.Phrase = new Phrase("Rate PPh", bold_font); tableContent.AddCell(cellCenter); cellCenter.Phrase = new Phrase("Sub Total PPh", bold_font); tableContent.AddCell(cellCenter); double total = 0; double totalPPH = 0; double totalPPHIDR = 0; foreach (GarmentInvoiceItemViewModel item in viewModel.items) { total += item.deliveryOrder.totalAmount; foreach (GarmentInvoiceDetailViewModel detail in item.details) { cellLeft.Phrase = new Phrase(item.deliveryOrder.doNo, normal_font); tableContent.AddCell(cellLeft); string doDate = item.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(viewModel.invoiceNo, normal_font); tableContent.AddCell(cellLeft); cellLeft.Phrase = new Phrase(detail.product.Name, normal_font); tableContent.AddCell(cellLeft); cellRight.Phrase = new Phrase(viewModel.incomeTaxRate.ToString(), normal_font); tableContent.AddCell(cellRight); cellRight.Phrase = new Phrase(Math.Round(viewModel.incomeTaxRate * detail.pricePerDealUnit * detail.doQuantity / 100, 2).ToString("N2"), normal_font); tableContent.AddCell(cellRight); totalPPH += (viewModel.incomeTaxRate * detail.pricePerDealUnit * detail.doQuantity / 100); var garmentDeliveryOrder = DOfacade.ReadById((int)item.deliveryOrder.Id); double rate = 1; if (garmentDeliveryOrder != null) { rate = (double)garmentDeliveryOrder.DOCurrencyRate; } totalPPHIDR += ((viewModel.incomeTaxRate * detail.pricePerDealUnit * detail.doQuantity / 100) * rate); /**dikali rate DO*/ } } cellRight.Phrase = new Phrase("Total Pph", normal_font); cellRight.Colspan = 5; tableContent.AddCell(cellRight); cellRight.Phrase = new Phrase(totalPPH.ToString("N2"), normal_font); cellRight.Colspan = 5; tableContent.AddCell(cellRight); cellRight.Phrase = new Phrase("Total Pph IDR", normal_font); cellRight.Colspan = 5; tableContent.AddCell(cellRight); cellRight.Phrase = new Phrase(totalPPHIDR.ToString("N2"), normal_font); cellRight.Colspan = 5; tableContent.AddCell(cellRight); PdfPCell cellContent = new PdfPCell(tableContent); // dont remove tableContent.ExtendLastRow = false; tableContent.SpacingAfter = 20f; document.Add(tableContent); #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); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { IGarmentInvoice invoiceFacade = validationContext == null ? null : (IGarmentInvoice)validationContext.GetService(typeof(IGarmentInvoice)); IGarmentDeliveryOrderFacade doFacade = validationContext == null ? null : (IGarmentDeliveryOrderFacade)validationContext.GetService(typeof(IGarmentDeliveryOrderFacade)); if (currency == null) { yield return(new ValidationResult("currency is required", new List <string> { "currency" })); } if (supplier == null) { yield return(new ValidationResult("Supplier is required", new List <string> { "supplier" })); } int itemErrorCount = 0; int detailErrorCount = 0; if (this.items == null || items.Count <= 0) { yield return(new ValidationResult("Item is required", new List <string> { "itemscount" })); } else { //Enhance Jason Sept 2021 List <string> arrNo = new List <string>(); foreach (var detailItem in items) { if (detailItem.garmentInvoice != null) { arrNo.Add(detailItem.garmentInvoice.invoiceNo); } } string itemError = "["; bool? prevUseIncomeTax = null; bool? prevUseVat = null; string paymentMethod = ""; long? IncomeTaxId = null; foreach (var item in items) { itemError += "{"; if (item.garmentInvoice == null || item.garmentInvoice.Id == 0) { itemErrorCount++; itemError += "garmentInvoice: 'No Garment Invoice selected', "; } else { //Enhance Jason Sept 2019 : Invoice No Validation //Check Duplicate Invoice No for 1 Invoice //if (arrNo.FindAll(e => e == item.garmentInvoice.invoiceNo).Count > 1) //{ // itemErrorCount++; // itemError += "garmentInvoice: 'there is duplication of invoiceNo " + item.garmentInvoice.invoiceNo + "', "; //} if (items.ToList().Where(x => x.garmentInvoice.invoiceNo == item.garmentInvoice.invoiceNo && x.garmentInvoice.invoiceDate == item.garmentInvoice.invoiceDate).Count() > 1) { itemErrorCount++; itemError += "garmentInvoice: 'there is duplication of invoiceNo " + item.garmentInvoice.invoiceNo + "', "; } //Check if Invoice No for Specific Supplier is Existed PurchasingDbContext purchasingDbContext = (PurchasingDbContext)validationContext.GetService(typeof(PurchasingDbContext)); var detailData = purchasingDbContext.GarmentInternNoteItems.Where(w => w.InvoiceId == item.garmentInvoice.Id && w.InvoiceDate == item.garmentInvoice.invoiceDate && w.IsDeleted == false).Select(s => new { s.Id, s.GarmentINId, s.InvoiceId, s.InvoiceNo }); if (detailData.ToList().Count > 0) { foreach (var itemDetail in detailData) { var headerData = purchasingDbContext.GarmentInternNotes.Where(w => w.Id == itemDetail.GarmentINId && w.SupplierId == supplier.Id && w.IsDeleted == false).Select(s => new { s.INNo }); if (headerData.ToList().Count > 0) { foreach (var itemHeader in headerData) { itemErrorCount++; itemError += "garmentInvoice: 'invoiceNo " + item.garmentInvoice.invoiceNo + " already existed on Intern Note No " + itemHeader.INNo.ToString() + "', "; } } } } var invoice = invoiceFacade.ReadById((int)item.garmentInvoice.Id); if (prevUseIncomeTax != null && prevUseIncomeTax != invoice.UseIncomeTax) { itemErrorCount++; itemError += "useincometax: 'UseIncomeTax harus sama', "; } prevUseIncomeTax = invoice.UseIncomeTax; if (prevUseVat != null && prevUseVat != invoice.UseVat) { itemErrorCount++; itemError += "usevat: 'UseVat harus sama', "; } prevUseVat = invoice.UseVat; if (IncomeTaxId != null && IncomeTaxId != invoice.IncomeTaxId) { itemErrorCount++; itemError += "incometax: 'Income Tax Harus Sama', "; } IncomeTaxId = invoice.IncomeTaxId; if (item.details == null || item.details.Count.Equals(0)) { itemErrorCount++; itemError += "detailscount: 'Details is required', "; } else { string detailError = "["; foreach (var detail in item.details) { detailError += "{"; var deliveryOrder = doFacade.ReadById((int)detail.deliveryOrder.Id); var invitem = invoice.Items.First(s => s.InvoiceId == item.garmentInvoice.Id); if (invitem != null) { if (paymentMethod != "" && paymentMethod != invitem.PaymentMethod) { detailErrorCount++; detailError += "paymentMethod: 'TermOfPayment Harus Sama', "; } paymentMethod = deliveryOrder.PaymentMethod; } detailError += "}, "; } detailError += "]"; if (detailErrorCount > 0) { itemErrorCount++; itemError += $"details: {detailError}, "; } } } itemError += "}, "; } itemError += "]"; if (itemErrorCount > 0) { yield return(new ValidationResult(itemError, new List <string> { "items" })); } } }
public static MemoryStream GeneratePdfTemplate(IServiceProvider serviceProvider, GarmentUnitReceiptNoteViewModel viewModel) { Font header_font = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 15); Font normal_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 10); Font bold_font = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 10); Document document = new Document(PageSize.A4, 40, 40, 40, 40); MemoryStream stream = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(document, stream); document.Open(); IGarmentDeliveryOrderFacade garmentDeliveryOrderFacade = (IGarmentDeliveryOrderFacade)serviceProvider.GetService(typeof(IGarmentDeliveryOrderFacade)); var garmentDeliveryOrder = garmentDeliveryOrderFacade.ReadById((int)viewModel.DOId); IdentityService identityService = (IdentityService)serviceProvider.GetService(typeof(IdentityService)); #region Header string titleString = "BON PENERIMAAN BARANG"; Paragraph title = new Paragraph(titleString, header_font) { Alignment = Element.ALIGN_CENTER }; document.Add(title); string companyNameString = "PT AMBASSADOR GARMINDO"; Paragraph companyName = new Paragraph(companyNameString, bold_font) { Alignment = Element.ALIGN_LEFT }; document.Add(companyName); string companyAddressString = "BANARAN, GROGOL, SUKOHARJO"; Paragraph companyAddress = new Paragraph(companyAddressString, normal_font) { Alignment = Element.ALIGN_LEFT }; companyAddress.SpacingAfter = 10f; document.Add(companyAddress); LineSeparator lineSeparator = new LineSeparator(1f, 100f, BaseColor.Black, Element.ALIGN_CENTER, 1); document.Add(lineSeparator); #endregion #region Identity PdfPTable tableIdentity = new PdfPTable(4); tableIdentity.SetWidths(new float[] { 3f, 4f, 3f, 4f }); PdfPCell cellIdentityContentLeft = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }; cellIdentityContentLeft.Phrase = new Phrase("Tgl. Terima", normal_font); tableIdentity.AddCell(cellIdentityContentLeft); cellIdentityContentLeft.Phrase = new Phrase(": " + garmentDeliveryOrder.DODate.ToOffset(new TimeSpan(identityService.TimezoneOffset, 0, 0)).ToString("dd MMMM yyyy", new CultureInfo("id-ID")), normal_font); tableIdentity.AddCell(cellIdentityContentLeft); cellIdentityContentLeft.Phrase = new Phrase("Tgl. Bon Penerimaan", normal_font); tableIdentity.AddCell(cellIdentityContentLeft); cellIdentityContentLeft.Phrase = new Phrase(": " + viewModel.ReceiptDate.GetValueOrDefault().ToOffset(new TimeSpan(identityService.TimezoneOffset, 0, 0)).ToString("dd MMMM yyyy", new CultureInfo("id-ID")), normal_font); tableIdentity.AddCell(cellIdentityContentLeft); cellIdentityContentLeft.Phrase = new Phrase("Diterima dari", normal_font); tableIdentity.AddCell(cellIdentityContentLeft); cellIdentityContentLeft.Phrase = new Phrase(": " + viewModel.Supplier.Name, normal_font); tableIdentity.AddCell(cellIdentityContentLeft); cellIdentityContentLeft.Phrase = new Phrase("Bagian", normal_font); tableIdentity.AddCell(cellIdentityContentLeft); cellIdentityContentLeft.Phrase = new Phrase(": " + viewModel.Unit.Name, normal_font); tableIdentity.AddCell(cellIdentityContentLeft); cellIdentityContentLeft.Phrase = new Phrase("Dasar Penerimaan", normal_font); tableIdentity.AddCell(cellIdentityContentLeft); cellIdentityContentLeft.Phrase = new Phrase(": " + viewModel.DONo, normal_font); tableIdentity.AddCell(cellIdentityContentLeft); cellIdentityContentLeft.Phrase = new Phrase("No.", normal_font); tableIdentity.AddCell(cellIdentityContentLeft); cellIdentityContentLeft.Phrase = new Phrase(": " + viewModel.URNNo, normal_font); tableIdentity.AddCell(cellIdentityContentLeft); PdfPCell cellIdentity = new PdfPCell(tableIdentity); tableIdentity.ExtendLastRow = false; tableIdentity.SpacingAfter = 10f; tableIdentity.SpacingBefore = 20f; document.Add(tableIdentity); #endregion #region TableContent 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(5); tableContent.SetWidths(new float[] { 1f, 7f, 3f, 3f, 5f }); cellCenter.Phrase = new Phrase("No", bold_font); tableContent.AddCell(cellCenter); cellCenter.Phrase = new Phrase("Nama 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("Keterangan", bold_font); tableContent.AddCell(cellCenter); int indexItem = 0; foreach (var item in viewModel.Items) { cellCenter.Phrase = new Phrase((++indexItem).ToString(), normal_font); tableContent.AddCell(cellCenter); cellLeft.Phrase = new Phrase($"{item.Product.Code} - {item.Product.Name}", normal_font); tableContent.AddCell(cellLeft); cellCenter.Phrase = new Phrase($"{item.ReceiptQuantity}", normal_font); tableContent.AddCell(cellCenter); cellCenter.Phrase = new Phrase(item.Uom.Unit, normal_font); tableContent.AddCell(cellCenter); cellCenter.Phrase = new Phrase($"{item.POSerialNumber}; {item.RONo}; {item.Article}; {item.Product.Remark}", normal_font); tableContent.AddCell(cellCenter); } PdfPCell cellContent = new PdfPCell(tableContent); tableContent.ExtendLastRow = false; tableContent.SpacingAfter = 20f; document.Add(tableContent); #endregion #region TableSignature PdfPTable tableSignature = new PdfPTable(2); PdfPCell cellSignatureContent = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER }; cellSignatureContent.Phrase = new Phrase("", normal_font); tableSignature.AddCell(cellSignatureContent); cellSignatureContent.Phrase = new Phrase($"Sukoharjo, {viewModel.ReceiptDate.GetValueOrDefault().ToOffset(new TimeSpan(identityService.TimezoneOffset, 0, 0)).ToString("dd MMMM yyyy", new CultureInfo("id-ID"))}", normal_font); tableSignature.AddCell(cellSignatureContent); cellSignatureContent.Phrase = new Phrase("Mengetahui\n\n\n\n\n\n\n( _____________________ )", normal_font); tableSignature.AddCell(cellSignatureContent); cellSignatureContent.Phrase = new Phrase("Yang Menerima\n\n\n\n\n\n\n( _____________________ )", normal_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); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { IGarmentInvoice invoiceFacade = validationContext == null ? null : (IGarmentInvoice)validationContext.GetService(typeof(IGarmentInvoice)); IGarmentDeliveryOrderFacade doFacade = validationContext == null ? null : (IGarmentDeliveryOrderFacade)validationContext.GetService(typeof(IGarmentDeliveryOrderFacade)); if (currency == null) { yield return(new ValidationResult("currency is required", new List <string> { "currency" })); } if (supplier == null) { yield return(new ValidationResult("Supplier is required", new List <string> { "supplier" })); } int itemErrorCount = 0; int detailErrorCount = 0; if (this.items == null || items.Count <= 0) { yield return(new ValidationResult("Item is required", new List <string> { "itemscount" })); } else { string itemError = "["; bool? prevUseIncomeTax = null; bool? prevUseVat = null; string paymentMethod = ""; foreach (var item in items) { itemError += "{"; if (item.garmentInvoice == null || item.garmentInvoice.Id == 0) { itemErrorCount++; itemError += "garmentInvoice: 'No Garment Invoice selected', "; } else { var invoice = invoiceFacade.ReadById((int)item.garmentInvoice.Id); if (prevUseIncomeTax != null && prevUseIncomeTax != invoice.UseIncomeTax) { itemErrorCount++; itemError += "useincometax: 'UseIncomeTax harus sama', "; } prevUseIncomeTax = invoice.UseIncomeTax; if (prevUseVat != null && prevUseVat != invoice.UseVat) { itemErrorCount++; itemError += "usevat: 'UseVat harus sama', "; } prevUseVat = invoice.UseVat; if (item.details == null || item.details.Count.Equals(0)) { itemErrorCount++; itemError += "detailscount: 'Details is required', "; } else { string detailError = "["; foreach (var detail in item.details) { detailError += "{"; var deliveryOrder = doFacade.ReadById((int)detail.deliveryOrder.Id); if (deliveryOrder != null) { if (paymentMethod != "" && paymentMethod != deliveryOrder.PaymentMethod) { detailErrorCount++; detailError += "paymentMethod: 'TermOfPayment Harus Sama', "; } paymentMethod = deliveryOrder.PaymentMethod; } detailError += "}, "; } detailError += "]"; if (detailErrorCount > 0) { itemErrorCount++; itemError += $"details: {detailError}, "; } } } itemError += "}, "; } itemError += "]"; if (itemErrorCount > 0) { yield return(new ValidationResult(itemError, new List <string> { "items" })); } } }
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); }