public async Task Should_Success_Delete_Data() { var numberGeneratorMock = new Mock <IBankDocumentNumberGenerator>(); var serviceProvider = new Mock <IServiceProvider>(); serviceProvider .Setup(x => x.GetService(typeof(IHttpClientService))) .Returns(new HttpClientTestService()); var services = new ServiceCollection(); services.AddMemoryCache(); var serviceProviders = services.BuildServiceProvider(); var memoryCache = serviceProviders.GetService <IMemoryCache>(); var mockMemoryCache = new Mock <IMemoryCacheManager>(); mockMemoryCache.Setup(x => x.Get(MemoryCacheConstant.Divisions, It.IsAny <Func <ICacheEntry, List <IdCOAResult> > >())) .Returns(new List <IdCOAResult>()); mockMemoryCache.Setup(x => x.Get(MemoryCacheConstant.BankAccounts, It.IsAny <Func <ICacheEntry, List <BankAccountCOAResult> > >())) .Returns(new List <BankAccountCOAResult>()); mockMemoryCache.Setup(x => x.Get(MemoryCacheConstant.IncomeTaxes, It.IsAny <Func <ICacheEntry, List <IncomeTaxCOAResult> > >())) .Returns(new List <IncomeTaxCOAResult>()); serviceProvider .Setup(x => x.GetService(typeof(IMemoryCacheManager))) .Returns(mockMemoryCache.Object); PPHBankExpenditureNoteFacade facade = new PPHBankExpenditureNoteFacade(_dbContext(GetCurrentMethod()), numberGeneratorMock.Object, serviceProvider.Object); PPHBankExpenditureNote Data = await _dataUtil(facade, GetCurrentMethod()).GetTestData(); int AffectedRows = await facade.Delete(Data.Id, "Test"); Assert.True(AffectedRows > 0); }
public async Task <PPHBankExpenditureNote> GetTestData() { PPHBankExpenditureNote model = GetNewData(); await Facade.Create(model, "Unit Test"); return(await Facade.ReadById(model.Id)); }
public PPHBankExpenditureNote ToModel() { PPHBankExpenditureNote model = new PPHBankExpenditureNote() { Id = Id, No = No, Date = Date.Value, TotalIncomeTax = TotalIncomeTax, TotalDPP = TotalDPP, BankId = Bank._id, BankCode = Bank.code, BankName = Bank.bankName, BankAccountName = Bank.accountName, BankAccountNumber = Bank.accountNumber, IncomeTaxId = IncomeTax._id, IncomeTaxName = IncomeTax.name, IncomeTaxRate = IncomeTax.rate, BGNo = BGNo, Currency = Currency, Items = new List <PPHBankExpenditureNoteItem>() }; foreach (var item in PPHBankExpenditureNoteItems) { model.Items.Add(new PPHBankExpenditureNoteItem() { Id = item.Id, PurchasingDocumentExpeditionId = item.PurchasingDocumentExpeditionId, UnitPaymentOrderNo = item.No }); } return(model); }
public async Task <ActionResult> Post([FromBody] PPHBankExpenditureNoteViewModel viewModel) { this.identityService.Token = Request.Headers["Authorization"].First().Replace("Bearer ", ""); this.identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value; IValidateService validateService = (IValidateService)serviceProvider.GetService(typeof(IValidateService)); try { validateService.Validate(viewModel); PPHBankExpenditureNote model = viewModel.ToModel(); await PPHBankExpenditureNoteFacade.Create(model, this.identityService.Username); Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.CREATED_STATUS_CODE, General.OK_MESSAGE) .Ok(); return(Created(String.Concat(Request.Path, "/", 0), Result)); } catch (ServiceValidationExeption e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.BAD_REQUEST_STATUS_CODE, General.BAD_REQUEST_MESSAGE) .Fail(e); return(BadRequest(Result)); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public async Task Should_Success_Delete_Data() { var numberGeneratorMock = new Mock <IBankDocumentNumberGenerator>(); PPHBankExpenditureNoteFacade facade = new PPHBankExpenditureNoteFacade(_dbContext(GetCurrentMethod()), numberGeneratorMock.Object); PPHBankExpenditureNote Data = await _dataUtil(facade, GetCurrentMethod()).GetTestData(); int AffectedRows = await facade.Delete(Data.Id, "Test"); Assert.True(AffectedRows > 0); }
public async Task Should_Success_Get_Data_By_Id() { var numberGeneratorMock = new Mock <IBankDocumentNumberGenerator>(); PPHBankExpenditureNoteFacade facade = new PPHBankExpenditureNoteFacade(_dbContext(GetCurrentMethod()), numberGeneratorMock.Object); PPHBankExpenditureNote model = await _dataUtil(facade, GetCurrentMethod()).GetTestData(); var Response = facade.ReadById((int)model.Id); Assert.NotNull(Response); }
public async void Should_Success_Create_Data() { var numberGeneratorMock = new Mock <IBankDocumentNumberGenerator>(); numberGeneratorMock.Setup(s => s.GenerateDocumentNumber(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync("test-code"); PPHBankExpenditureNoteFacade facade = new PPHBankExpenditureNoteFacade(_dbContext(GetCurrentMethod()), numberGeneratorMock.Object); PPHBankExpenditureNote model = _dataUtil(facade, GetCurrentMethod()).GetNewData(); var Response = await facade.Create(model, "Unit Test"); Assert.NotEqual(Response, 0); }
public async Task Should_Success_Update_Data() { var numberGeneratorMock = new Mock <IBankDocumentNumberGenerator>(); PPHBankExpenditureNoteFacade facade = new PPHBankExpenditureNoteFacade(_dbContext(GetCurrentMethod()), numberGeneratorMock.Object); PPHBankExpenditureNote model = await _dataUtil(facade, GetCurrentMethod()).GetTestData(); PPHBankExpenditureNoteItem modelItem = await _dataUtil(facade, GetCurrentMethod()).GetItemNewData(); model.Items.Clear(); model.Items.Add(modelItem); var Response = await facade.Update((int)model.Id, model, "Unit Test"); Assert.NotEqual(Response, 0); }
public async Task Should_Success_Update_Data() { var numberGeneratorMock = new Mock <IBankDocumentNumberGenerator>(); var serviceProvider = new Mock <IServiceProvider>(); serviceProvider .Setup(x => x.GetService(typeof(IHttpClientService))) .Returns(new HttpClientTestService()); var services = new ServiceCollection(); services.AddMemoryCache(); var serviceProviders = services.BuildServiceProvider(); var memoryCache = serviceProviders.GetService <IMemoryCache>(); var mockMemoryCache = new Mock <IMemoryCacheManager>(); mockMemoryCache.Setup(x => x.Get(MemoryCacheConstant.Divisions, It.IsAny <Func <ICacheEntry, List <IdCOAResult> > >())) .Returns(new List <IdCOAResult>()); mockMemoryCache.Setup(x => x.Get(MemoryCacheConstant.BankAccounts, It.IsAny <Func <ICacheEntry, List <BankAccountCOAResult> > >())) .Returns(new List <BankAccountCOAResult>()); mockMemoryCache.Setup(x => x.Get(MemoryCacheConstant.IncomeTaxes, It.IsAny <Func <ICacheEntry, List <IncomeTaxCOAResult> > >())) .Returns(new List <IncomeTaxCOAResult>()); serviceProvider .Setup(x => x.GetService(typeof(IMemoryCacheManager))) .Returns(mockMemoryCache.Object); serviceProvider .Setup(x => x.GetService(typeof(IdentityService))) .Returns(new IdentityService() { TimezoneOffset = 1, Token = "token", Username = "******" }); PPHBankExpenditureNoteFacade facade = new PPHBankExpenditureNoteFacade(_dbContext(GetCurrentMethod()), numberGeneratorMock.Object, serviceProvider.Object); PPHBankExpenditureNote model = await _dataUtil(facade, GetCurrentMethod()).GetTestData(); PPHBankExpenditureNoteItem modelItem = await _dataUtil(facade, GetCurrentMethod()).GetItemNewData(); model.Items.Clear(); model.Items.Add(modelItem); var Response = await facade.Update((int)model.Id, model, "Unit Test"); Assert.NotEqual(0, Response); }
public async Task <PPHBankExpenditureNote> GetNewData() { PurchasingDocumentExpedition purchasingDocumentExpedition1 = await Task.Run(() => this.pdaDataUtil.GetCashierTestData()); PurchasingDocumentExpedition purchasingDocumentExpedition2 = await Task.Run(() => this.pdaDataUtil.GetCashierTestData()); List <PPHBankExpenditureNoteItem> Items = new List <PPHBankExpenditureNoteItem>() { new PPHBankExpenditureNoteItem() { PurchasingDocumentExpeditionId = purchasingDocumentExpedition1.Id, UnitPaymentOrderNo = purchasingDocumentExpedition1.UnitPaymentOrderNo, }, new PPHBankExpenditureNoteItem() { PurchasingDocumentExpeditionId = purchasingDocumentExpedition2.Id, UnitPaymentOrderNo = purchasingDocumentExpedition2.UnitPaymentOrderNo, } }; PPHBankExpenditureNote TestData = new PPHBankExpenditureNote() { Date = DateTimeOffset.UtcNow, BankAccountNumber = "100020003000", BankAccountName = "BankAccountName", BankCode = "BankCode", BankId = "BankId", BankName = "BankName", BGNo = "BGNo", IncomeTaxId = "IncomeTaxId", IncomeTaxName = "IncomeTaxName", IncomeTaxRate = 2, Items = Items, No = "No", TotalDPP = 1100000, TotalIncomeTax = 100000, Currency = "IDR" }; return(TestData); }
public async Task Should_Success_Create_Data() { var numberGeneratorMock = new Mock <IBankDocumentNumberGenerator>(); numberGeneratorMock.Setup(s => s.GenerateDocumentNumber(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync("test-code"); var serviceProvider = new Mock <IServiceProvider>(); serviceProvider .Setup(x => x.GetService(typeof(IHttpClientService))) .Returns(new HttpClientTestService()); var services = new ServiceCollection(); services.AddMemoryCache(); var serviceProviders = services.BuildServiceProvider(); var memoryCache = serviceProviders.GetService <IMemoryCache>(); var mockMemoryCache = new Mock <IMemoryCacheManager>(); mockMemoryCache.Setup(x => x.Get(MemoryCacheConstant.Divisions, It.IsAny <Func <ICacheEntry, List <IdCOAResult> > >())) .Returns(new List <IdCOAResult>()); mockMemoryCache.Setup(x => x.Get(MemoryCacheConstant.BankAccounts, It.IsAny <Func <ICacheEntry, List <BankAccountCOAResult> > >())) .Returns(new List <BankAccountCOAResult>()); mockMemoryCache.Setup(x => x.Get(MemoryCacheConstant.IncomeTaxes, It.IsAny <Func <ICacheEntry, List <IncomeTaxCOAResult> > >())) .Returns(new List <IncomeTaxCOAResult>()); serviceProvider .Setup(x => x.GetService(typeof(IMemoryCacheManager))) .Returns(mockMemoryCache.Object); PPHBankExpenditureNoteFacade facade = new PPHBankExpenditureNoteFacade(_dbContext(GetCurrentMethod()), numberGeneratorMock.Object, serviceProvider.Object); PPHBankExpenditureNote model = await _dataUtil(facade, GetCurrentMethod()).GetNewData(); var Response = await facade.Create(model, "Unit Test"); Assert.NotEqual(0, Response); }
public PPHBankExpenditureNoteViewModel(PPHBankExpenditureNote model) { int.TryParse(model.BankId, out var bankId); Id = model.Id; No = model.No; TotalIncomeTax = model.TotalIncomeTax; TotalDPP = model.TotalDPP; Date = model.Date; IsPosted = model.IsPosted; Bank = new NewIntegrationViewModel.AccountBankViewModel() { Id = bankId, Code = model.BankCode, BankName = model.BankName, AccountName = model.BankAccountName, AccountNumber = model.BankAccountNumber, Currency = new NewIntegrationViewModel.CurrencyViewModel() { Code = model.Currency } }; IncomeTax = new IncomeTaxExpeditionViewModel() { _id = model.IncomeTaxId, name = model.IncomeTaxName, rate = model.IncomeTaxRate }; Division = new NewIntegrationViewModel.DivisionViewModel() { Code = model.DivisionCode, Id = model.DivisionId, Name = model.DivisionName }; BGNo = model.BGNo; Currency = model.Currency; PPHBankExpenditureNoteItems = new List <UnitPaymentOrderViewModel>(); foreach (var item in model.Items) { var m = new UnitPaymentOrderViewModel() { Id = item.Id, PurchasingDocumentExpeditionId = item.PurchasingDocumentExpeditionId, No = item.UnitPaymentOrderNo, UPODate = item.PurchasingDocumentExpedition.UPODate, DueDate = item.PurchasingDocumentExpedition.DueDate, InvoiceNo = item.PurchasingDocumentExpedition.InvoiceNo, SupplierCode = item.PurchasingDocumentExpedition.SupplierCode, SupplierName = item.PurchasingDocumentExpedition.SupplierName, DivisionCode = item.PurchasingDocumentExpedition.DivisionCode, DivisionName = item.PurchasingDocumentExpedition.DivisionName, IncomeTax = item.PurchasingDocumentExpedition.IncomeTax, Vat = item.PurchasingDocumentExpedition.Vat, IncomeTaxId = item.PurchasingDocumentExpedition.IncomeTaxId, IncomeTaxName = item.PurchasingDocumentExpedition.IncomeTaxName, IncomeTaxRate = item.PurchasingDocumentExpedition.IncomeTaxRate, TotalPaid = item.PurchasingDocumentExpedition.TotalPaid, Currency = item.PurchasingDocumentExpedition.Currency, Items = new List <UnitPaymentOrderItemViewModel>() }; foreach (var detail in item.PurchasingDocumentExpedition.Items) { m.Items.Add(new UnitPaymentOrderItemViewModel() { ProductId = detail.ProductId, ProductCode = detail.ProductCode, ProductName = detail.ProductName, Price = detail.Price, Quantity = detail.Quantity, UnitCode = detail.UnitCode, UnitId = detail.UnitId, UnitName = detail.UnitName, Uom = detail.Uom }); } this.PPHBankExpenditureNoteItems.Add(m); } }
public MemoryStream GeneratePdfTemplate(PPHBankExpenditureNote model, int clientTimeZoneOffset) { const int MARGIN = 20; 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, 10); Font bold_font = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 10); Document document = new Document(PageSize.A4, MARGIN, MARGIN, MARGIN, MARGIN); MemoryStream stream = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(document, stream); document.Open(); #region Header PdfPTable headerTable = new PdfPTable(2); headerTable.SetWidths(new float[] { 10f, 10f }); headerTable.WidthPercentage = 100; PdfPTable headerTable1 = new PdfPTable(1); PdfPTable headerTable2 = new PdfPTable(2); headerTable2.SetWidths(new float[] { 15f, 40f }); headerTable2.WidthPercentage = 100; PdfPCell cellHeader1 = new PdfPCell() { Border = Rectangle.NO_BORDER }; PdfPCell cellHeader2 = new PdfPCell() { Border = Rectangle.NO_BORDER }; PdfPCell cellHeaderBody = new PdfPCell() { Border = Rectangle.NO_BORDER }; PdfPCell cellHeaderCS2 = new PdfPCell() { Border = Rectangle.NO_BORDER, Colspan = 2 }; cellHeaderCS2.Phrase = new Phrase("BUKTI PENGELUARAN BANK PPH", bold_font); cellHeaderCS2.HorizontalAlignment = Element.ALIGN_CENTER; headerTable.AddCell(cellHeaderCS2); cellHeaderBody.Phrase = new Phrase("PT. DANLIRIS", normal_font); headerTable1.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("Kel. Banaran, Kec. Grogol", normal_font); headerTable1.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("Sukoharjo - 57100", normal_font); headerTable1.AddCell(cellHeaderBody); cellHeader1.AddElement(headerTable1); headerTable.AddCell(cellHeader1); cellHeaderCS2.Phrase = new Phrase("", bold_font); headerTable2.AddCell(cellHeaderCS2); cellHeaderBody.Phrase = new Phrase("Tanggal", normal_font); headerTable2.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase(": " + DateTimeOffset.UtcNow.AddHours(clientTimeZoneOffset).ToString("dd MMMM yyyy"), normal_font); headerTable2.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("NO", normal_font); headerTable2.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase(": " + model.No, normal_font); headerTable2.AddCell(cellHeaderBody); var purchasingDocumentExpedition = model.Items .GroupBy(p => new { IncomeTaxName = p.PurchasingDocumentExpedition.IncomeTaxName, IncomeTaxRate = p.PurchasingDocumentExpedition.IncomeTaxRate, IncomeTaxId = p.PurchasingDocumentExpedition.IncomeTaxId, PPHBankExpenditureNoteId = p.PPHBankExpenditureNoteId }) .OrderBy(p => p.Key.IncomeTaxId) .Select(g => new { IncomeTaxName = g.Key.IncomeTaxName, IncomeTaxRate = g.Key.IncomeTaxRate, IncomeTaxId = g.Key.IncomeTaxId, PPHBankExpenditureNoteId = g.Key.PPHBankExpenditureNoteId }).ToList(); cellHeaderBody.Phrase = new Phrase("Pasal PPH", normal_font); headerTable2.AddCell(cellHeaderBody); var count = 0; foreach (var item in purchasingDocumentExpedition) { if (count == 0) { cellHeaderBody.Phrase = new Phrase(": - " + item.IncomeTaxName + " - " + item.IncomeTaxRate, normal_font); headerTable2.AddCell(cellHeaderBody); } else { cellHeaderBody.Phrase = new Phrase("", normal_font); headerTable2.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase(" - " + item.IncomeTaxName + " - " + item.IncomeTaxRate, normal_font); headerTable2.AddCell(cellHeaderBody); } count++; } cellHeaderBody.Phrase = new Phrase("Bank", normal_font); headerTable2.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase(": " + model.BankAccountName + " - A/C : " + model.BankAccountNumber, normal_font); headerTable2.AddCell(cellHeaderBody); cellHeader2.AddElement(headerTable2); headerTable.AddCell(cellHeader2); document.Add(headerTable); document.Add(new Paragraph("\n")); #endregion Header #region Body PdfPTable bodyTable = new PdfPTable(7); PdfPCell bodyCell = new PdfPCell(); float[] widthsBody = new float[] { 5f, 12f, 10f, 5f, 5f, 15f, 15f }; bodyTable.SetWidths(widthsBody); bodyTable.WidthPercentage = 100; bodyCell.HorizontalAlignment = Element.ALIGN_CENTER; bodyCell.Colspan = 1; bodyCell.Rowspan = 2; bodyCell.Phrase = new Phrase("No.", normal_font); bodyTable.AddCell(bodyCell); bodyCell.Colspan = 4; bodyCell.Rowspan = 1; bodyCell.Phrase = new Phrase("Uraian", normal_font); bodyTable.AddCell(bodyCell); bodyCell.Colspan = 1; bodyCell.Rowspan = 2; bodyCell.Phrase = new Phrase("PPH", normal_font); bodyTable.AddCell(bodyCell); bodyCell.Phrase = new Phrase("DPP", normal_font); bodyTable.AddCell(bodyCell); bodyCell.Colspan = 1; bodyCell.Rowspan = 1; bodyCell.Phrase = new Phrase("No. SPB", normal_font); bodyTable.AddCell(bodyCell); bodyCell.Phrase = new Phrase("Supplier", normal_font); bodyTable.AddCell(bodyCell); bodyCell.Phrase = new Phrase("Unit", normal_font); bodyTable.AddCell(bodyCell); bodyCell.Phrase = new Phrase("Mata Uang", normal_font); bodyTable.AddCell(bodyCell); int index = 1; double totalDPP = 0, totalPPH = 0; Dictionary <string, double> units = new Dictionary <string, double>(); model.Items = model.Items.OrderBy(p => p.PurchasingDocumentExpedition.SupplierName).ToList(); foreach (PPHBankExpenditureNoteItem item in model.Items) { var pdeItems = item.PurchasingDocumentExpedition.Items .GroupBy(m => new { m.UnitCode, m.UnitName }) .Select(s => new { UnitCode = s.First().UnitCode, UnitName = s.First().UnitName, TotalDPP = s.Sum(d => d.Price), TotalPPH = item.PurchasingDocumentExpedition.IncomeTax //(s.Sum(d => d.Price) * ((model.IncomeTaxRate == 0 ? 1 : model.IncomeTaxRate) / 100)) }); foreach (var pdeItem in pdeItems) { bodyCell.HorizontalAlignment = Element.ALIGN_CENTER; bodyCell.VerticalAlignment = Element.ALIGN_TOP; bodyCell.Phrase = new Phrase((index++).ToString(), normal_font); bodyTable.AddCell(bodyCell); bodyCell.HorizontalAlignment = Element.ALIGN_LEFT; bodyCell.Phrase = new Phrase(item.PurchasingDocumentExpedition.UnitPaymentOrderNo, normal_font); bodyTable.AddCell(bodyCell); bodyCell.Phrase = new Phrase(item.PurchasingDocumentExpedition.SupplierName, normal_font); bodyTable.AddCell(bodyCell); bodyCell.HorizontalAlignment = Element.ALIGN_CENTER; bodyCell.Phrase = new Phrase(pdeItem.UnitCode, normal_font); bodyTable.AddCell(bodyCell); bodyCell.Phrase = new Phrase(item.PurchasingDocumentExpedition.Currency, normal_font); bodyTable.AddCell(bodyCell); bodyCell.HorizontalAlignment = Element.ALIGN_RIGHT; bodyCell.Phrase = new Phrase(string.Format("{0:n4}", pdeItem.TotalPPH), normal_font); bodyTable.AddCell(bodyCell); bodyCell.Phrase = new Phrase(string.Format("{0:n4}", pdeItem.TotalDPP), normal_font); bodyTable.AddCell(bodyCell); if (units.ContainsKey(pdeItem.UnitCode)) { units[pdeItem.UnitCode] += pdeItem.TotalPPH; } else { units.Add(pdeItem.UnitCode, pdeItem.TotalPPH); } totalPPH += pdeItem.TotalPPH; totalDPP += pdeItem.TotalDPP; } } bodyCell.Colspan = 3; bodyCell.Border = Rectangle.NO_BORDER; bodyCell.Phrase = new Phrase("", normal_font); bodyTable.AddCell(bodyCell); bodyCell.Colspan = 1; bodyCell.Border = Rectangle.RECTANGLE; bodyCell.HorizontalAlignment = Element.ALIGN_LEFT; bodyCell.Phrase = new Phrase("Total", bold_font); bodyTable.AddCell(bodyCell); bodyCell.Colspan = 1; bodyCell.HorizontalAlignment = Element.ALIGN_CENTER; bodyCell.Phrase = new Phrase(model.Currency, bold_font); bodyTable.AddCell(bodyCell); bodyCell.HorizontalAlignment = Element.ALIGN_RIGHT; bodyCell.Phrase = new Phrase(string.Format("{0:n4}", totalPPH), bold_font); bodyTable.AddCell(bodyCell); bodyCell.HorizontalAlignment = Element.ALIGN_RIGHT; bodyCell.Phrase = new Phrase(string.Format("{0:n4}", totalDPP), bold_font); bodyTable.AddCell(bodyCell); document.Add(bodyTable); document.Add(new Paragraph("\n")); #endregion Body #region BodyFooter PdfPTable bodyFooterTable = new PdfPTable(6); bodyFooterTable.SetWidths(new float[] { 3f, 8f, 2f, 6f, 10f, 10f }); bodyFooterTable.WidthPercentage = 100; PdfPCell bodyFooterCell = new PdfPCell() { Border = Rectangle.NO_BORDER }; bodyFooterCell.Colspan = 1; bodyFooterCell.Phrase = new Phrase(""); bodyFooterTable.AddCell(bodyFooterCell); bodyFooterCell.Colspan = 5; bodyFooterCell.HorizontalAlignment = Element.ALIGN_LEFT; bodyFooterCell.Phrase = new Phrase("Rincian PPH per bagian:", normal_font); bodyFooterTable.AddCell(bodyFooterCell); bodyFooterCell.HorizontalAlignment = Element.ALIGN_RIGHT; foreach (var unit in units) { bodyFooterCell.Colspan = 1; bodyFooterCell.Phrase = new Phrase(""); bodyFooterTable.AddCell(bodyFooterCell); bodyFooterCell.Phrase = new Phrase(unit.Key, normal_font); bodyFooterTable.AddCell(bodyFooterCell); bodyFooterCell.Phrase = new Phrase(model.Currency, normal_font); bodyFooterTable.AddCell(bodyFooterCell); bodyFooterCell.Phrase = new Phrase(string.Format("{0:n4}", unit.Value), normal_font); bodyFooterTable.AddCell(bodyFooterCell); bodyFooterCell.Colspan = 2; bodyFooterCell.Phrase = new Phrase(""); bodyFooterTable.AddCell(bodyFooterCell); } bodyFooterCell.Colspan = 1; bodyFooterCell.HorizontalAlignment = Element.ALIGN_LEFT; bodyFooterCell.Phrase = new Phrase(""); bodyFooterTable.AddCell(bodyFooterCell); bodyFooterCell.Phrase = new Phrase("Terbilang", normal_font); bodyFooterTable.AddCell(bodyFooterCell); bodyFooterCell.HorizontalAlignment = Element.ALIGN_RIGHT; bodyFooterCell.Phrase = new Phrase(": " + model.Currency, normal_font); bodyFooterTable.AddCell(bodyFooterCell); bodyFooterCell.Colspan = 3; bodyFooterCell.HorizontalAlignment = Element.ALIGN_LEFT; bodyFooterCell.Phrase = new Phrase(NumberToTextIDN.terbilang(totalPPH), normal_font); bodyFooterTable.AddCell(bodyFooterCell); document.Add(bodyFooterTable); document.Add(new Paragraph("\n")); #endregion BodyFooter #region Footer PdfPTable footerTable = new PdfPTable(2); PdfPCell cellFooter = new PdfPCell() { Border = Rectangle.NO_BORDER }; float[] widthsFooter = new float[] { 10f, 5f }; footerTable.SetWidths(widthsFooter); footerTable.WidthPercentage = 100; cellFooter.Phrase = new Phrase("Dikeluarkan dengan cek/BG No. : " + model.BGNo, normal_font); footerTable.AddCell(cellFooter); cellFooter.Phrase = new Phrase("", normal_font); footerTable.AddCell(cellFooter); PdfPTable signatureTable = new PdfPTable(3); PdfPCell signatureCell = new PdfPCell() { HorizontalAlignment = Element.ALIGN_CENTER }; signatureCell.Phrase = new Phrase("Bag. Keuangan", normal_font); signatureTable.AddCell(signatureCell); signatureCell.Colspan = 2; signatureCell.HorizontalAlignment = Element.ALIGN_CENTER; signatureCell.Phrase = new Phrase("Direksi", normal_font); signatureTable.AddCell(signatureCell); signatureTable.AddCell(new PdfPCell() { Phrase = new Phrase("---------------------------", normal_font), FixedHeight = 40, VerticalAlignment = Element.ALIGN_BOTTOM, HorizontalAlignment = Element.ALIGN_CENTER }); signatureTable.AddCell(new PdfPCell() { Phrase = new Phrase("---------------------------", normal_font), FixedHeight = 40, Border = Rectangle.NO_BORDER, VerticalAlignment = Element.ALIGN_BOTTOM, HorizontalAlignment = Element.ALIGN_CENTER }); signatureTable.AddCell(new PdfPCell() { Phrase = new Phrase("---------------------------", normal_font), FixedHeight = 40, Border = Rectangle.NO_BORDER, VerticalAlignment = Element.ALIGN_BOTTOM, HorizontalAlignment = Element.ALIGN_CENTER }); footerTable.AddCell(new PdfPCell(signatureTable)); cellFooter.Phrase = new Phrase("", normal_font); footerTable.AddCell(cellFooter); document.Add(footerTable); #endregion Footer document.Close(); byte[] byteInfo = stream.ToArray(); stream.Write(byteInfo, 0, byteInfo.Length); stream.Position = 0; return(stream); }