public async Task <int> Create(GarmentShippingInsuranceDispositionViewModel viewModel) { GarmentShippingInsuranceDispositionModel model = MapToModel(viewModel); int Created = await _repository.InsertAsync(model); return(Created); }
private string GenerateNo(GarmentShippingInsuranceDispositionViewModel vm) { var year = DateTime.Now.ToString("yyyy"); var month = DateTime.Now.ToString("MM"); var prefix = $"DL/Polis Asuransi/{month}/{year}/"; var lastInvoiceNo = _repository.ReadAll().Where(w => w.DispositionNo.StartsWith(prefix)) .OrderByDescending(o => o.DispositionNo) .Select(s => int.Parse(s.DispositionNo.Replace(prefix, ""))) .FirstOrDefault(); var invoiceNo = $"{prefix}{(lastInvoiceNo + 1).ToString("D3")}"; return(invoiceNo); }
private GarmentShippingInsuranceDispositionModel MapToModel(GarmentShippingInsuranceDispositionViewModel viewModel) { var items = (viewModel.items ?? new List <GarmentShippingInsuranceDispositionItemViewModel>()).Select(i => { i.BuyerAgent = i.BuyerAgent ?? new BuyerAgent(); return(new GarmentShippingInsuranceDispositionItemModel(i.policyDate, i.policyNo, i.invoiceNo, i.invoiceId, i.BuyerAgent.Id, i.BuyerAgent.Code, i.BuyerAgent.Name, i.amount, i.currencyRate, i.amount2A, i.amount2B, i.amount2C, i.amount1A, i.amount1B) { Id = i.Id }); }).ToList(); viewModel.insurance = viewModel.insurance ?? new Insurance(); GarmentShippingInsuranceDispositionModel garmentShippingInvoiceModel = new GarmentShippingInsuranceDispositionModel(GenerateNo(viewModel), viewModel.policyType, viewModel.paymentDate.GetValueOrDefault(), viewModel.bankName, viewModel.insurance.Id, viewModel.insurance.Name, viewModel.insurance.Code, viewModel.rate, viewModel.remark, items); return(garmentShippingInvoiceModel); }
public MemoryStream GeneratePdfTemplate(GarmentShippingInsuranceDispositionViewModel viewModel, Insurance insurance, int timeoffset) { const int MARGIN = 20; Font header_font_bold_big = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 12); Font header_font_bold = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 10); Font header_font_bold_underlined = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 12, Font.UNDERLINE); Font header_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 11); Font normal_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 10); Font normal_font_underlined = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 10, Font.UNDERLINE); Font normal_font_bold = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 10); Document document = new Document(PageSize.A4, MARGIN, MARGIN, 120, MARGIN); MemoryStream stream = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(document, stream); document.Open(); #region header Paragraph title = new Paragraph("DISPOSISI PEMBAYARAN", header_font_bold_underlined); title.Alignment = Element.ALIGN_CENTER; decimal totalPremi = viewModel.items.Sum(a => a.amount * viewModel.rate / 100); Phrase intro = new Phrase(); intro.Add(new Chunk("Mohon dibayarkan uang sebesar ", normal_font)); intro.Add(new Chunk("USD " + string.Format("{0:n2}", totalPremi), normal_font_bold)); var terbilang = NumberToTextIDN.terbilangDollar((double)totalPremi).Contains("us dolar") ? NumberToTextIDN.terbilangDollar((double)totalPremi) : NumberToTextIDN.terbilangDollar((double)totalPremi) + " us dolar"; intro.Add(new Chunk($" (terbilang : {terbilang}) untuk pembayaran polis asuransi proteksi piutang" + $"dagang ke {viewModel.insurance.Name}.\n", normal_font)); intro.Add(new Chunk("Disposisi no : " + viewModel.dispositionNo, normal_font)); document.Add(title); document.Add(new Paragraph("\n", normal_font)); document.Add(intro); #endregion #region bodyTable PdfPTable tableBody = new PdfPTable(8); tableBody.WidthPercentage = 100; tableBody.SetWidths(new float[] { 3.5f, 2.5f, 3.5f, 2f, 0.2f, 2f, 0.2f, 2f }); PdfPCell cellCenter = new PdfPCell() { Border = Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER | Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER, HorizontalAlignment = Element.ALIGN_CENTER }; PdfPCell cellLeft = new PdfPCell() { Border = Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER | Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }; PdfPCell cellRight = new PdfPCell() { Border = Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER | Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }; PdfPCell cellCurrency = new PdfPCell() { Border = Rectangle.LEFT_BORDER | Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }; PdfPCell cellAmount = new PdfPCell() { Border = Rectangle.RIGHT_BORDER | Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }; cellLeft.Phrase = new Phrase("Nomor Polis & Certificate", normal_font); tableBody.AddCell(cellLeft); cellLeft.Phrase = new Phrase("Tgl Polis", normal_font); tableBody.AddCell(cellLeft); cellLeft.Phrase = new Phrase("Buyer", normal_font); tableBody.AddCell(cellLeft); cellLeft.Phrase = new Phrase("Invoice", normal_font); tableBody.AddCell(cellLeft); cellCenter.Phrase = new Phrase("Amount", normal_font); cellCenter.Colspan = 2; tableBody.AddCell(cellCenter); cellCenter.Phrase = new Phrase("Premi", normal_font); tableBody.AddCell(cellCenter); foreach (var item in viewModel.items) { cellLeft.Phrase = new Phrase(item.policyNo, normal_font); cellLeft.Colspan = 1; tableBody.AddCell(cellLeft); cellLeft.Phrase = new Phrase(item.policyDate.ToOffset(new TimeSpan(timeoffset, 0, 0)).ToString("dd MMMM yyyy", new System.Globalization.CultureInfo("id-ID")), normal_font); tableBody.AddCell(cellLeft); cellLeft.Phrase = new Phrase(item.BuyerAgent.Name, normal_font); tableBody.AddCell(cellLeft); cellLeft.Phrase = new Phrase(item.invoiceNo, normal_font); tableBody.AddCell(cellLeft); cellCurrency.Phrase = new Phrase("$", normal_font); tableBody.AddCell(cellCurrency); cellAmount.Phrase = new Phrase(string.Format("{0:n2}", item.amount), normal_font); tableBody.AddCell(cellAmount); cellCurrency.Phrase = new Phrase("$", normal_font); tableBody.AddCell(cellCurrency); cellAmount.Phrase = new Phrase(string.Format("{0:n2}", item.amount * viewModel.rate), normal_font); tableBody.AddCell(cellAmount); } cellRight.Phrase = new Phrase("Total Premi", normal_font); cellRight.Colspan = 4; tableBody.AddCell(cellRight); cellCurrency.Phrase = new Phrase("$", normal_font_bold); tableBody.AddCell(cellCurrency); decimal totalAmount = viewModel.items.Sum(a => a.amount); cellAmount.Phrase = new Phrase(string.Format("{0:n2}", totalAmount), normal_font_bold); cellAmount.Colspan = 1; tableBody.AddCell(cellAmount); cellCurrency.Phrase = new Phrase("$", normal_font_bold); tableBody.AddCell(cellCurrency); cellAmount.Phrase = new Phrase(string.Format("{0:n2}", totalPremi), normal_font_bold); tableBody.AddCell(cellAmount); tableBody.SpacingAfter = 10; tableBody.SpacingBefore = 5; document.Add(tableBody); #endregion #region bank Paragraph bank = new Paragraph("Mohon ditransfer ke rekening bank sbb :\n\n", normal_font); document.Add(bank); PdfPTable tableBank = new PdfPTable(3); tableBank.WidthPercentage = 80; tableBank.SetWidths(new float[] { 3f, 0.5f, 14f }); cellLeft.Phrase = new Phrase("AccountName", normal_font); cellLeft.Border = Rectangle.NO_BORDER; tableBank.AddCell(cellLeft); cellLeft.Phrase = new Phrase(":", normal_font); tableBank.AddCell(cellLeft); cellLeft.Phrase = new Phrase(viewModel.insurance.Name, normal_font); tableBank.AddCell(cellLeft); cellLeft.Phrase = new Phrase("Bank name", normal_font); tableBank.AddCell(cellLeft); cellLeft.Phrase = new Phrase(":", normal_font); tableBank.AddCell(cellLeft); cellLeft.Phrase = new Phrase(viewModel.bankName, normal_font); tableBank.AddCell(cellLeft); cellLeft.Phrase = new Phrase("Account no.", normal_font); tableBank.AddCell(cellLeft); cellLeft.Phrase = new Phrase(":", normal_font); tableBank.AddCell(cellLeft); cellLeft.Phrase = new Phrase(insurance.AccountNumber, normal_font); tableBank.AddCell(cellLeft); cellLeft.Phrase = new Phrase("Swift code", normal_font); tableBank.AddCell(cellLeft); cellLeft.Phrase = new Phrase(":", normal_font); tableBank.AddCell(cellLeft); cellLeft.Phrase = new Phrase(insurance.SwiftCode, normal_font); tableBank.AddCell(cellLeft); tableBank.SpacingAfter = 10; tableBank.HorizontalAlignment = Element.ALIGN_LEFT; document.Add(tableBank); Paragraph closing = new Paragraph("Demikian permohonan kami, terima kasih.\n\n", normal_font); document.Add(closing); #endregion #region sign Paragraph date = new Paragraph($"Sukoharjo, {DateTimeOffset.Now.ToOffset(new TimeSpan(timeoffset, 0, 0)).ToString("dd MMMM yyyy", new System.Globalization.CultureInfo("id-ID"))}", normal_font); document.Add(date); PdfPTable tableSign = new PdfPTable(4); tableSign.WidthPercentage = 100; tableSign.SetWidths(new float[] { 1f, 1f, 1f, 1f }); PdfPCell cellBodySignNoBorder = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER }; cellBodySignNoBorder.Phrase = new Phrase("Hormat kami,\n\n\n\n", normal_font); tableSign.AddCell(cellBodySignNoBorder); cellBodySignNoBorder.Phrase = new Phrase("Mengetahui,\n\n\n\n", normal_font); tableSign.AddCell(cellBodySignNoBorder); cellBodySignNoBorder.Phrase = new Phrase("Dicek,\n\n\n\n", normal_font); tableSign.AddCell(cellBodySignNoBorder); cellBodySignNoBorder.Phrase = new Phrase("Diterima,\n\n\n\n", normal_font); tableSign.AddCell(cellBodySignNoBorder); cellBodySignNoBorder.Phrase = new Phrase("( )", normal_font); tableSign.AddCell(cellBodySignNoBorder); cellBodySignNoBorder.Phrase = new Phrase("( )", normal_font); tableSign.AddCell(cellBodySignNoBorder); cellBodySignNoBorder.Phrase = new Phrase("( )", normal_font); tableSign.AddCell(cellBodySignNoBorder); cellBodySignNoBorder.Phrase = new Phrase("( )", normal_font); tableSign.AddCell(cellBodySignNoBorder); cellBodySignNoBorder.Phrase = new Phrase("STAFF SHIPPING", normal_font); tableSign.AddCell(cellBodySignNoBorder); cellBodySignNoBorder.Phrase = new Phrase("KABAG/KASIE SHIPPING", normal_font); tableSign.AddCell(cellBodySignNoBorder); cellBodySignNoBorder.Phrase = new Phrase("BAGIAN VERIFIKASI", normal_font); tableSign.AddCell(cellBodySignNoBorder); cellBodySignNoBorder.Phrase = new Phrase("BAGIAN KASIR", normal_font); tableSign.AddCell(cellBodySignNoBorder); document.Add(tableSign); #endregion document.Close(); byte[] byteInfo = stream.ToArray(); stream.Write(byteInfo, 0, byteInfo.Length); stream.Position = 0; return(stream); }
public MemoryStream GeneratePdfTemplate(GarmentShippingInsuranceDispositionViewModel viewModel, Insurance insurance, int timeoffset) { const int MARGIN = 20; Font header_font_bold_big = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 12); Font header_font_bold = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 10); Font header_font_bold_underlined = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 12, Font.UNDERLINE); Font header_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 11); Font normal_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 10); Font normal_font_underlined = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 10, Font.UNDERLINE); Font normal_font_bold = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 10); Font small_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 9); Font small_font_bold = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 9); Document document = new Document(PageSize.A4, MARGIN, MARGIN, 120, MARGIN); MemoryStream stream = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(document, stream); document.Open(); #region header Paragraph title = new Paragraph("L A M P I R A N", header_font_bold_underlined); title.Alignment = Element.ALIGN_CENTER; decimal totalAmountIDR = Math.Round(viewModel.items.Sum(a => a.amount * a.currencyRate), 0); //Phrase intro = new Phrase(); //intro.Add(new Chunk("Mohon dibayarkan uang sejumlah ", normal_font)); //intro.Add(new Chunk("Rp " + string.Format("{0:n2}", totalAmountIDR), normal_font_bold)); var terbilang = NumberToTextIDN.terbilang((double)totalAmountIDR) + " Rupiah"; //intro.Add(new Chunk($" (terbilang : {terbilang}) sesuai disposisi nomor \n", normal_font)); //intro.Add(new Chunk("Disposisi no : " + viewModel.dispositionNo + " tgl. " + viewModel.paymentDate.GetValueOrDefault().ToOffset(new TimeSpan(timeoffset, 0, 0)).ToString("dd MMMM yyyy", new System.Globalization.CultureInfo("id-ID")), normal_font)); //intro.Add(new Chunk("\nuntuk pembayaran Polis Asuransi ke " + viewModel.insurance.Name, normal_font)); document.Add(title); //document.Add(new Paragraph("\n", normal_font)); //document.Add(intro); #endregion //#region bank //Paragraph bank = new Paragraph("\nMohon ditransfer ke alamat :\n\n", normal_font); //document.Add(bank); //PdfPTable tableBank = new PdfPTable(3); //tableBank.WidthPercentage = 80; //tableBank.SetWidths(new float[] { 3f, 0.5f, 14f }); //PdfPCell cellCenter = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER }; //PdfPCell cellLeft = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }; //PdfPCell cellRight = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }; //cellLeft.Phrase = new Phrase("AccountName", normal_font); //tableBank.AddCell(cellLeft); //cellLeft.Phrase = new Phrase(":", normal_font); //tableBank.AddCell(cellLeft); //cellLeft.Phrase = new Phrase(viewModel.insurance.Name, normal_font); //tableBank.AddCell(cellLeft); //cellLeft.Phrase = new Phrase("Bank name", normal_font); //tableBank.AddCell(cellLeft); //cellLeft.Phrase = new Phrase(":", normal_font); //tableBank.AddCell(cellLeft); //cellLeft.Phrase = new Phrase(viewModel.bankName, normal_font); //tableBank.AddCell(cellLeft); //cellLeft.Phrase = new Phrase("Account no.", normal_font); //tableBank.AddCell(cellLeft); //cellLeft.Phrase = new Phrase(":", normal_font); //tableBank.AddCell(cellLeft); //cellLeft.Phrase = new Phrase(insurance.AccountNumber, normal_font); //tableBank.AddCell(cellLeft); //cellLeft.Phrase = new Phrase("Swift code", normal_font); //tableBank.AddCell(cellLeft); //cellLeft.Phrase = new Phrase(":", normal_font); //tableBank.AddCell(cellLeft); //cellLeft.Phrase = new Phrase(insurance.SwiftCode, normal_font); //tableBank.AddCell(cellLeft); //tableBank.SpacingAfter = 10; //tableBank.HorizontalAlignment = Element.ALIGN_LEFT; //document.Add(tableBank); //Paragraph closing = new Paragraph("Demikian permohonan kami, terima kasih.\n\n", normal_font); //document.Add(closing); //#endregion //#region sign //Paragraph date = new Paragraph($"Sukoharjo, {DateTimeOffset.Now.ToOffset(new TimeSpan(timeoffset, 0, 0)).ToString("dd MMMM yyyy", new System.Globalization.CultureInfo("id-ID"))}", normal_font); //document.Add(date); //PdfPTable tableSign = new PdfPTable(4); //tableSign.WidthPercentage = 100; //tableSign.SetWidths(new float[] { 1f, 1f, 1f, 1f }); //PdfPCell cellBodySignNoBorder = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER }; //cellBodySignNoBorder.Phrase = new Phrase("Hormat kami,\n\n\n\n", normal_font); //tableSign.AddCell(cellBodySignNoBorder); //cellBodySignNoBorder.Phrase = new Phrase("Mengetahui,\n\n\n\n", normal_font); //tableSign.AddCell(cellBodySignNoBorder); //cellBodySignNoBorder.Phrase = new Phrase("Dicek,\n\n\n\n", normal_font); //tableSign.AddCell(cellBodySignNoBorder); //cellBodySignNoBorder.Phrase = new Phrase("Diterima,\n\n\n\n", normal_font); //tableSign.AddCell(cellBodySignNoBorder); //cellBodySignNoBorder.Phrase = new Phrase("( )", normal_font); //tableSign.AddCell(cellBodySignNoBorder); //cellBodySignNoBorder.Phrase = new Phrase("( )", normal_font); //tableSign.AddCell(cellBodySignNoBorder); //cellBodySignNoBorder.Phrase = new Phrase("( )", normal_font); //tableSign.AddCell(cellBodySignNoBorder); //cellBodySignNoBorder.Phrase = new Phrase("( )", normal_font); //tableSign.AddCell(cellBodySignNoBorder); //cellBodySignNoBorder.Phrase = new Phrase("STAFF SHIPPING", normal_font); //tableSign.AddCell(cellBodySignNoBorder); //cellBodySignNoBorder.Phrase = new Phrase("KABAG/KASIE SHIPPING", normal_font); //tableSign.AddCell(cellBodySignNoBorder); //cellBodySignNoBorder.Phrase = new Phrase("BAGIAN VERIFIKASI", normal_font); //tableSign.AddCell(cellBodySignNoBorder); //cellBodySignNoBorder.Phrase = new Phrase("BAGIAN KASIR", normal_font); //tableSign.AddCell(cellBodySignNoBorder); //document.Add(tableSign); //#endregion //document.NewPage(); #region intro2 //Paragraph to = new Paragraph("Kepada : Yth. Bp. Ricky H. - Keuangan \n " + // "Mohon dibayarkan kepada " +viewModel.insurance.Name +" biaya asuransi sbb: ",small_font); Paragraph disposisi = new Paragraph("Disposisi No : " + viewModel.dispositionNo, small_font); disposisi.Alignment = Element.ALIGN_RIGHT; //document.Add(to); document.Add(disposisi); #endregion #region table PdfPTable tableDetail = new PdfPTable(10); tableDetail.WidthPercentage = 100; tableDetail.SetWidths(new float[] { 1f, 3.5f, 3f, 3f, 4f, 1.2f, 2.8f, 2f, 1f, 3f }); PdfPCell cellCenterBorder = new PdfPCell() { Border = Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER | Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER, HorizontalAlignment = Element.ALIGN_CENTER }; PdfPCell cellRightBorder = new PdfPCell() { Border = Rectangle.RIGHT_BORDER | Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }; PdfPCell cellLeftBorder = new PdfPCell() { Border = Rectangle.LEFT_BORDER | Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }; cellCenterBorder.Phrase = new Phrase("No", small_font); tableDetail.AddCell(cellCenterBorder); cellCenterBorder.Phrase = new Phrase("Tgl Polis", small_font); tableDetail.AddCell(cellCenterBorder); cellCenterBorder.Phrase = new Phrase("No Polis", small_font); tableDetail.AddCell(cellCenterBorder); cellCenterBorder.Phrase = new Phrase("Invoice", small_font); tableDetail.AddCell(cellCenterBorder); cellCenterBorder.Phrase = new Phrase("Buyer", small_font); tableDetail.AddCell(cellCenterBorder); cellCenterBorder.Phrase = new Phrase("Amount", small_font); cellCenterBorder.Colspan = 2; tableDetail.AddCell(cellCenterBorder); cellCenterBorder.Phrase = new Phrase("Kurs", small_font); cellCenterBorder.Colspan = 1; tableDetail.AddCell(cellCenterBorder); cellCenterBorder.Phrase = new Phrase("Amount IDR", small_font); cellCenterBorder.Colspan = 2; tableDetail.AddCell(cellCenterBorder); int index = 0; foreach (var item in viewModel.items) { index++; cellCenterBorder.Phrase = new Phrase(index.ToString(), small_font); cellCenterBorder.Colspan = 1; tableDetail.AddCell(cellCenterBorder); cellCenterBorder.Phrase = new Phrase(item.policyDate.ToOffset(new TimeSpan(timeoffset, 0, 0)).ToString("dd MMMM yyyy", new System.Globalization.CultureInfo("id-ID")), small_font); tableDetail.AddCell(cellCenterBorder); cellCenterBorder.Phrase = new Phrase(item.policyNo, small_font); tableDetail.AddCell(cellCenterBorder); cellCenterBorder.Phrase = new Phrase(item.invoiceNo, small_font); tableDetail.AddCell(cellCenterBorder); cellCenterBorder.Phrase = new Phrase(item.BuyerAgent.Name, small_font); tableDetail.AddCell(cellCenterBorder); cellLeftBorder.Phrase = new Phrase("USD", small_font); tableDetail.AddCell(cellLeftBorder); cellRightBorder.Phrase = new Phrase(string.Format("{0:n2}", item.amount), small_font); tableDetail.AddCell(cellRightBorder); cellCenterBorder.Phrase = new Phrase(string.Format("{0:n0}", item.currencyRate), small_font); tableDetail.AddCell(cellCenterBorder); cellLeftBorder.Phrase = new Phrase("IDR", small_font); tableDetail.AddCell(cellLeftBorder); cellRightBorder.Phrase = new Phrase(string.Format("{0:n0}", item.amount * item.currencyRate), small_font); tableDetail.AddCell(cellRightBorder); } cellCenterBorder.Phrase = new Phrase("TOTAL", small_font_bold); cellCenterBorder.HorizontalAlignment = Element.ALIGN_RIGHT; cellCenterBorder.Colspan = 5; tableDetail.AddCell(cellCenterBorder); cellLeftBorder.Phrase = new Phrase("USD", small_font_bold); tableDetail.AddCell(cellLeftBorder); cellRightBorder.Phrase = new Phrase(string.Format("{0:n2}", viewModel.items.Sum(a => a.amount)), small_font_bold); tableDetail.AddCell(cellRightBorder); cellCenterBorder.Phrase = new Phrase("", small_font); cellCenterBorder.Colspan = 1; tableDetail.AddCell(cellCenterBorder); cellLeftBorder.Phrase = new Phrase("IDR", small_font_bold); tableDetail.AddCell(cellLeftBorder); cellRightBorder.Phrase = new Phrase(string.Format("{0:n0}", totalAmountIDR), small_font_bold); tableDetail.AddCell(cellRightBorder); tableDetail.SpacingAfter = 10; tableDetail.SpacingBefore = 5; document.Add(tableDetail); #endregion #region unitCharge Phrase titleUnit = new Phrase("Beban per Unit", small_font); document.Add(titleUnit); PdfPTable tableUnit = new PdfPTable(2); tableUnit.WidthPercentage = 40; tableUnit.SetWidths(new float[] { 3f, 6f }); PdfPCell cellUnitLeft = new PdfPCell() { Border = Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER | Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }; PdfPCell cellUnitRight = new PdfPCell() { Border = Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER | Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT }; PdfPCell cellUnitCenter = new PdfPCell() { Border = Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER | Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER, HorizontalAlignment = Element.ALIGN_CENTER }; cellUnitCenter.Phrase = new Phrase("Unit", small_font); tableUnit.AddCell(cellUnitCenter); cellUnitCenter.Phrase = new Phrase("Amount IDR", small_font); tableUnit.AddCell(cellUnitCenter); decimal amount1A = viewModel.items.Sum(a => a.amount1A); cellUnitLeft.Phrase = new Phrase("UNIT 1A", small_font); tableUnit.AddCell(cellUnitLeft); cellUnitRight.Phrase = new Phrase(amount1A > 0 ? string.Format("{0:n0}", amount1A) : "", small_font); tableUnit.AddCell(cellUnitRight); decimal amount1B = viewModel.items.Sum(a => a.amount1B); cellUnitLeft.Phrase = new Phrase("UNIT 1B", small_font); tableUnit.AddCell(cellUnitLeft); cellUnitRight.Phrase = new Phrase(amount1B > 0 ? string.Format("{0:n0}", amount1B) : "", small_font); tableUnit.AddCell(cellUnitRight); decimal amount2A = viewModel.items.Sum(a => a.amount2A); cellUnitLeft.Phrase = new Phrase("UNIT 2A", small_font); tableUnit.AddCell(cellUnitLeft); cellUnitRight.Phrase = new Phrase(amount2A > 0 ? string.Format("{0:n0}", amount2A) : "", small_font); tableUnit.AddCell(cellUnitRight); decimal amount2B = viewModel.items.Sum(a => a.amount2B); cellUnitLeft.Phrase = new Phrase("UNIT 2B", small_font); tableUnit.AddCell(cellUnitLeft); cellUnitRight.Phrase = new Phrase(amount2B > 0 ? string.Format("{0:n0}", amount2B) : "", small_font); tableUnit.AddCell(cellUnitRight); decimal amount2C = viewModel.items.Sum(a => a.amount2C); cellUnitLeft.Phrase = new Phrase("UNIT 2C", small_font); tableUnit.AddCell(cellUnitLeft); cellUnitRight.Phrase = new Phrase(amount2C > 0 ? string.Format("{0:n0}", amount2C) : "", small_font); tableUnit.AddCell(cellUnitRight); decimal totalUnitCharge = amount1A + amount1B + amount2A + amount2B + amount2C; cellUnitLeft.Phrase = new Phrase("Total", small_font_bold); tableUnit.AddCell(cellUnitLeft); cellUnitRight.Phrase = new Phrase(string.Format("{0:n0}", totalUnitCharge), small_font_bold); tableUnit.AddCell(cellUnitRight); tableUnit.SpacingAfter = 5; tableUnit.HorizontalAlignment = Element.ALIGN_LEFT; document.Add(tableUnit); document.Add(new Phrase("[Terbilang : " + terbilang + "]", small_font)); #endregion //#region sign2 //Paragraph date2 = new Paragraph($"Sukoharjo, {DateTimeOffset.Now.ToOffset(new TimeSpan(timeoffset, 0, 0)).ToString("dd MMMM yyyy", new System.Globalization.CultureInfo("id-ID"))}", small_font); //document.Add(date2); //PdfPTable tableSign2 = new PdfPTable(4); //tableSign2.WidthPercentage = 100; //tableSign2.SetWidths(new float[] { 1f, 1f, 1f, 1f }); //PdfPCell cellBodySignNoBorder2 = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER }; //cellBodySignNoBorder2.Phrase = new Phrase("Hormat kami,\n\n\n\n", small_font); //tableSign2.AddCell(cellBodySignNoBorder2); //cellBodySignNoBorder2.Phrase = new Phrase("Mengetahui,\n\n\n\n", small_font); //tableSign2.AddCell(cellBodySignNoBorder2); //cellBodySignNoBorder2.Phrase = new Phrase("Dicek,\n\n\n\n", small_font); //tableSign2.AddCell(cellBodySignNoBorder2); //cellBodySignNoBorder2.Phrase = new Phrase("Diterima,\n\n\n\n", small_font); //tableSign2.AddCell(cellBodySignNoBorder2); //cellBodySignNoBorder2.Phrase = new Phrase("( )", small_font); //tableSign2.AddCell(cellBodySignNoBorder2); //cellBodySignNoBorder2.Phrase = new Phrase("( )", small_font); //tableSign2.AddCell(cellBodySignNoBorder2); //cellBodySignNoBorder2.Phrase = new Phrase("( )", small_font); //tableSign2.AddCell(cellBodySignNoBorder2); //cellBodySignNoBorder2.Phrase = new Phrase("( )", small_font); //tableSign2.AddCell(cellBodySignNoBorder2); //cellBodySignNoBorder2.Phrase = new Phrase("STAFF SHIPPING", small_font); //tableSign2.AddCell(cellBodySignNoBorder2); //cellBodySignNoBorder2.Phrase = new Phrase("KABAG/KASIE SHIPPING", small_font); //tableSign2.AddCell(cellBodySignNoBorder2); //cellBodySignNoBorder2.Phrase = new Phrase("BAGIAN VERIFIKASI", small_font); //tableSign2.AddCell(cellBodySignNoBorder2); //cellBodySignNoBorder2.Phrase = new Phrase("BAGIAN KASIR", small_font); //tableSign2.AddCell(cellBodySignNoBorder2); //document.Add(tableSign2); //#endregion document.Close(); byte[] byteInfo = stream.ToArray(); stream.Write(byteInfo, 0, byteInfo.Length); stream.Position = 0; return(stream); }
private GarmentShippingInsuranceDispositionViewModel MapToViewModel(GarmentShippingInsuranceDispositionModel model) { var vm = new GarmentShippingInsuranceDispositionViewModel() { Active = model.Active, Id = model.Id, CreatedAgent = model.CreatedAgent, CreatedBy = model.CreatedBy, CreatedUtc = model.CreatedUtc, DeletedAgent = model.DeletedAgent, DeletedBy = model.DeletedBy, DeletedUtc = model.DeletedUtc, IsDeleted = model.IsDeleted, LastModifiedAgent = model.LastModifiedAgent, LastModifiedBy = model.LastModifiedBy, LastModifiedUtc = model.LastModifiedUtc, bankName = model.BankName, dispositionNo = model.DispositionNo, insurance = new Insurance { Id = model.InsuranceId, Code = model.InsuranceCode, Name = model.InsuranceName }, paymentDate = model.PaymentDate, policyType = model.PolicyType, rate = model.Rate, remark = model.Remark, items = (model.Items ?? new List <GarmentShippingInsuranceDispositionItemModel>()).Select(i => new GarmentShippingInsuranceDispositionItemViewModel { Active = i.Active, Id = i.Id, CreatedAgent = i.CreatedAgent, CreatedBy = i.CreatedBy, CreatedUtc = i.CreatedUtc, DeletedAgent = i.DeletedAgent, DeletedBy = i.DeletedBy, DeletedUtc = i.DeletedUtc, IsDeleted = i.IsDeleted, LastModifiedAgent = i.LastModifiedAgent, LastModifiedBy = i.LastModifiedBy, LastModifiedUtc = i.LastModifiedUtc, amount = i.Amount, currencyRate = i.CurrencyRate, BuyerAgent = new BuyerAgent { Id = i.BuyerAgentId, Code = i.BuyerAgentCode, Name = i.BuyerAgentName }, insuranceDispositionId = i.InsuranceDispositionId, invoiceId = i.InvoiceId, invoiceNo = i.InvoiceNo, policyDate = i.PolicyDate, policyNo = i.PolicyNo, amount1A = i.Amount1A, amount1B = i.Amount1B, amount2A = i.Amount2A, amount2B = i.Amount2B, amount2C = i.Amount2C }).ToList(), }; return(vm); }
public async Task <int> Update(int id, GarmentShippingInsuranceDispositionViewModel viewModel) { GarmentShippingInsuranceDispositionModel model = MapToModel(viewModel); return(await _repository.UpdateAsync(id, model)); }