예제 #1
0
        public async Task <BankExpenditureNoteModel> GetImportData()
        {
            PurchasingDocumentExpedition purchasingDocumentExpedition1 = await Task.Run(() => this.pdaDataUtil.GetCashierTestData());

            PurchasingDocumentExpedition purchasingDocumentExpedition2 = await Task.Run(() => this.pdaDataUtil.GetCashierTestData());

            List <BankExpenditureNoteDetailModel> Details = new List <BankExpenditureNoteDetailModel>()
            {
                await GetNewDetailSpinningData(),
                await GetNewDetailWeavingData(),
                await GetNewDetailFinishingPrintingData(),
                await GetNewDetailGarmentData()
            };

            BankExpenditureNoteModel TestData = new BankExpenditureNoteModel()
            {
                BankAccountNumber = "100020003000",
                BankAccountCOA    = "BankAccountCOA",
                BankAccountName   = "BankAccountName",
                BankCode          = "BankCode",
                BankId            = 1,
                BankName          = "BankName",
                BankCurrencyCode  = "CurrencyCode",
                BankCurrencyId    = 1,
                BankCurrencyRate  = "1",
                GrandTotal        = 120,
                BGCheckNumber     = "BGNo",
                SupplierImport    = true,
                Details           = Details,
            };

            return(TestData);
        }
        public void Should_Success_Get_Data_PaymentOrderMemoLoader()
        {
            var dbContext = _dbContext(GetCurrentMethod());
            var facade    = new PurchasingDispositionFacade(ServiceProvider, dbContext);

            var bankExpenditureNote = new BankExpenditureNoteModel()
            {
                Id = 1, SupplierImport = false, CurrencyCode = "IDR"
            };
            var bankExpenditureNoteDetail = new BankExpenditureNoteDetailModel()
            {
                Id = 1, BankExpenditureNoteId = 1, UnitPaymentOrderNo = "Test"
            };
            var unitPaymentOrder = new UnitPaymentOrder()
            {
                Id = 1, UPONo = "Test", CurrencyCode = "IDR", DivisionId = "1", UseVat = true, UseIncomeTax = true
            };

            dbContext.BankExpenditureNotes.Add(bankExpenditureNote);
            dbContext.BankExpenditureNoteDetails.Add(bankExpenditureNoteDetail);
            dbContext.UnitPaymentOrders.Add(unitPaymentOrder);
            dbContext.SaveChanges();

            var Response  = facade.GetUnitPaymentOrderMemoLoader("Test", 1, false, "IDR");
            var Response2 = facade.GetUnitPaymentOrderMemoLoader("", 1, false, "");

            Assert.NotNull(Response);
            Assert.NotNull(Response2);
        }
예제 #3
0
        public async Task <IActionResult> Put([FromRoute] int id, [FromBody] BankExpenditureNoteViewModel vm)
        {
            identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value;
            identityService.Token    = Request.Headers["Authorization"].FirstOrDefault().Replace("Bearer ", "");

            BankExpenditureNoteModel m = mapper.Map <BankExpenditureNoteModel>(vm);

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

            try
            {
                validateService.Validate(vm);

                int result = await facade.Update(id, m, identityService);

                return(NoContent());
            }
            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));
            }
        }
예제 #4
0
        public BankExpenditureNoteModel GetNewData()
        {
            PurchasingDocumentExpedition purchasingDocumentExpedition1 = Task.Run(() => this.pdaDataUtil.GetCashierTestData()).Result;
            PurchasingDocumentExpedition purchasingDocumentExpedition2 = Task.Run(() => this.pdaDataUtil.GetCashierTestData()).Result;

            List <BankExpenditureNoteDetailModel> Details = new List <BankExpenditureNoteDetailModel>()
            {
                GetNewDetailData()
            };

            BankExpenditureNoteModel TestData = new BankExpenditureNoteModel()
            {
                BankAccountNumber = "100020003000",
                BankAccountName   = "BankAccountName",
                BankCode          = "BankCode",
                BankId            = "BankId",
                BankName          = "BankName",
                BankCurrencyCode  = "CurrencyCode",
                BankCurrencyId    = "CurrencyId",
                BankCurrencyRate  = "1",
                GrandTotal        = 120,
                BGCheckNumber     = "BGNo",
                Details           = Details,
            };

            return(TestData);
        }
예제 #5
0
        public async Task <BankExpenditureNoteModel> GetTestData()
        {
            BankExpenditureNoteModel model = GetNewData();
            await Facade.Create(model, "Unit Test");

            return(await Facade.ReadById((int)model.Id));
        }
예제 #6
0
        public async void Should_Success_Delete_Data()
        {
            var numberGeneratorMock          = new Mock <IBankDocumentNumberGenerator>();
            BankExpenditureNoteFacade facade = new BankExpenditureNoteFacade(_dbContext(GetCurrentMethod()), numberGeneratorMock.Object);
            BankExpenditureNoteModel  Data   = await _dataUtil(facade, GetCurrentMethod()).GetTestData();

            int AffectedRows = await facade.Delete((int)Data.Id, "Test");

            Assert.True(AffectedRows > 0);
        }
예제 #7
0
        public async void Should_Success_Get_Report_Data()
        {
            var numberGeneratorMock          = new Mock <IBankDocumentNumberGenerator>();
            BankExpenditureNoteFacade facade = new BankExpenditureNoteFacade(_dbContext(GetCurrentMethod()), numberGeneratorMock.Object);
            BankExpenditureNoteModel  model  = await _dataUtil(facade, GetCurrentMethod()).GetTestData();

            ReadResponse response = facade.GetReport(1, 25, null, null, null, null, null, null, null, null, 0);

            Assert.NotEqual(null, response);
        }
예제 #8
0
        public async Task Should_Success_Get_PDF_IDR_NONIDR_By_Id()
        {
            var numberGeneratorMock          = new Mock <IBankDocumentNumberGenerator>();
            BankExpenditureNoteFacade facade = new BankExpenditureNoteFacade(_dbContext(GetCurrentMethod()), numberGeneratorMock.Object, GetServiceProviderMock().Object);
            BankExpenditureNoteModel  model  = await _dataUtil(facade, GetCurrentMethod()).GetTestDataIDRNONIDR();

            var Response = facade.GeneratePdfTemplate(model, 0);

            Assert.NotNull(Response);
        }
예제 #9
0
        public async void Should_Success_Get_Data_By_Id()
        {
            var numberGeneratorMock          = new Mock <IBankDocumentNumberGenerator>();
            BankExpenditureNoteFacade facade = new BankExpenditureNoteFacade(_dbContext(GetCurrentMethod()), numberGeneratorMock.Object);
            BankExpenditureNoteModel  model  = await _dataUtil(facade, GetCurrentMethod()).GetTestData();

            var Response = facade.ReadById((int)model.Id);

            Assert.NotNull(Response);
        }
        public async Task <BankExpenditureNoteModel> GetTestData()
        {
            IdentityService identityService = new IdentityService()
            {
                Token    = "Token",
                Username = "******"
            };
            BankExpenditureNoteModel model = GetNewData();
            await Facade.Create(model, identityService);

            return(await Facade.ReadById((int)model.Id));
        }
예제 #11
0
        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");
            BankExpenditureNoteFacade facade = new BankExpenditureNoteFacade(_dbContext(GetCurrentMethod()), numberGeneratorMock.Object);
            BankExpenditureNoteModel  model  = _dataUtil(facade, GetCurrentMethod()).GetNewData();

            var Response = await facade.Create(model, "Unit Test");

            Assert.NotEqual(Response, 0);
        }
예제 #12
0
        public async Task Should_Success_Posting_Data_Debit_Greater_Than_Credit()
        {
            var numberGeneratorMock          = new Mock <IBankDocumentNumberGenerator>();
            BankExpenditureNoteFacade facade = new BankExpenditureNoteFacade(_dbContext(GetCurrentMethod()), numberGeneratorMock.Object, GetServiceProviderMock().Object);
            BankExpenditureNoteModel  model  = await _dataUtil(facade, GetCurrentMethod()).GetTestData2();

            var Response = facade.Posting(new List <long>()
            {
                model.Id
            });

            Assert.NotNull(Response);
        }
예제 #13
0
        public async void Should_Success_Update_Data()
        {
            var numberGeneratorMock          = new Mock <IBankDocumentNumberGenerator>();
            BankExpenditureNoteFacade facade = new BankExpenditureNoteFacade(_dbContext(GetCurrentMethod()), numberGeneratorMock.Object);
            BankExpenditureNoteModel  model  = await _dataUtil(facade, GetCurrentMethod()).GetTestData();

            BankExpenditureNoteDetailModel modelDetail = _dataUtil(facade, GetCurrentMethod()).GetNewDetailData();

            model.Details.Clear();
            model.Details.Add(modelDetail);
            var Response = await facade.Update((int)model.Id, model, "Unit Test");

            Assert.NotEqual(Response, 0);
        }
        public async Task Should_Success_Delete_Data()
        {
            IdentityService identityService = new IdentityService()
            {
                Token = "Token",

                Username = "******"
            };
            var numberGeneratorMock          = new Mock <IBankDocumentNumberGenerator>();
            BankExpenditureNoteFacade facade = new BankExpenditureNoteFacade(_dbContext(GetCurrentMethod()), numberGeneratorMock.Object, GetServiceProviderMock().Object);
            BankExpenditureNoteModel  Data   = await _dataUtil(facade, GetCurrentMethod()).GetTestData();

            int AffectedRows = await facade.Delete((int)Data.Id, identityService);

            Assert.True(AffectedRows > 0);
        }
        public async Task Should_Success_Create_Daily_Bank_Transaction()
        {
            var numberGeneratorMock = new Mock <IBankDocumentNumberGenerator>();

            numberGeneratorMock.Setup(s => s.GenerateDocumentNumber(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync("test-code");
            BankExpenditureNoteFacade facade          = new BankExpenditureNoteFacade(_dbContext(GetCurrentMethod()), numberGeneratorMock.Object, GetServiceProviderMock().Object);
            BankExpenditureNoteModel  model           = _dataUtil(facade, GetCurrentMethod()).GetNewData();
            IdentityService           identityService = new IdentityService()
            {
                Token = "Token",

                Username = "******"
            };
            var Response = await facade.Create(model, identityService);

            Assert.NotEqual(Response, 0);
        }
        public async Task Should_Success_Update_Data()
        {
            var numberGeneratorMock          = new Mock <IBankDocumentNumberGenerator>();
            BankExpenditureNoteFacade facade = new BankExpenditureNoteFacade(_dbContext(GetCurrentMethod()), numberGeneratorMock.Object, GetServiceProviderMock().Object);
            BankExpenditureNoteModel  model  = await _dataUtil(facade, GetCurrentMethod()).GetTestData();

            IdentityService identityService = new IdentityService()
            {
                Token = "Token",

                Username = "******"
            };
            BankExpenditureNoteDetailModel modelDetail = _dataUtil(facade, GetCurrentMethod()).GetNewDetailData();

            model.Details.Clear();
            model.Details.Add(modelDetail);
            var Response = await facade.Update((int)model.Id, model, identityService);

            Assert.NotEqual(Response, 0);
        }
예제 #17
0
        public async Task Should_Success_Create_Data_And_Error_With_AmountPaid_and_Expedition()
        {
            var numberGeneratorMock = new Mock <IBankDocumentNumberGenerator>();

            numberGeneratorMock.Setup(s => s.GenerateDocumentNumber(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync("test-code");
            BankExpenditureNoteFacade facade = new BankExpenditureNoteFacade(_dbContext(GetCurrentMethod()), numberGeneratorMock.Object, GetServiceProviderMock().Object);
            BankExpenditureNoteModel  model  = await _dataUtil(facade, GetCurrentMethod()).GetNewData();

            IdentityService identityService = new IdentityService()
            {
                Token = "Token",

                Username = "******"
            };
            var Response = await facade.Create(model, identityService);

            var exception = await Assert.ThrowsAsync <Exception>(() => facade.Create(model, identityService));

            Assert.NotNull(exception.Message);
            Assert.NotEqual(0, Response);
        }
        public async Task <BankExpenditureNoteModel> GetNewDataVatZero()
        {
            PurchasingDocumentExpedition purchasingDocumentExpedition1 = await Task.Run(() => this.pdaDataUtil.GetCashierTestData());

            PurchasingDocumentExpedition purchasingDocumentExpedition2 = await Task.Run(() => this.pdaDataUtil.GetCashierTestData());

            var detail = await GetNewDetailSpinningData();

            detail.Vat = 0;
            List <BankExpenditureNoteDetailModel> Details = new List <BankExpenditureNoteDetailModel>()
            {
                detail
            };

            BankExpenditureNoteModel TestData = new BankExpenditureNoteModel()
            {
                BankAccountNumber = "100020003000",
                BankAccountCOA    = "BankAccountCOA",
                BankAccountName   = "BankAccountName",
                BankCode          = "BankCode",
                BankId            = 1,
                BankName          = "BankName",
                BankCurrencyCode  = "CurrencyCode",
                BankCurrencyId    = 1,
                BankCurrencyRate  = "1",
                GrandTotal        = 120,
                BGCheckNumber     = "BGNo",
                SupplierImport    = false,
                CurrencyRate      = 1,
                CurrencyId        = 1,
                CurrencyCode      = "Code",
                Details           = Details,
            };

            return(TestData);
        }
예제 #19
0
        public async Task <IActionResult> Post([FromBody] BankExpenditureNoteViewModel viewModel)
        {
            identityService.Token    = Request.Headers["Authorization"].First().Replace("Bearer ", "");
            identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value;

            //ValidateService validateService = (ValidateService)facade.serviceProvider.GetService(typeof(ValidateService));
            IValidateService validateService = (IValidateService)serviceProvider.GetService(typeof(IValidateService));

            try
            {
                validateService.Validate(viewModel);

                BankExpenditureNoteModel model = mapper.Map <BankExpenditureNoteModel>(viewModel);

                int result = await facade.Create(model, identityService);

                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));
            }
        }
예제 #20
0
        public MemoryStream GeneratePdfTemplate(BankExpenditureNoteModel model, int clientTimeZoneOffset)
        {
            const int MARGIN = 15;

            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, 8);
            Font bold_font   = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8);

            Document     document = new Document(PageSize.A5.Rotate(), MARGIN, MARGIN, MARGIN, MARGIN);
            MemoryStream stream   = new MemoryStream();
            PdfWriter    writer   = PdfWriter.GetInstance(document, stream);

            document.Open();

            Dictionary <string, double> units = new Dictionary <string, double>();

            model.Details = model.Details.OrderBy(o => o.SupplierName).ToList();

            #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", 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.DocumentNo, normal_font);
            headerTable2.AddCell(cellHeaderBody);

            List <string> supplier = model.Details.Select(m => m.SupplierName).Distinct().ToList();
            cellHeaderBody.Phrase = new Phrase("Dibayarkan ke", normal_font);
            headerTable2.AddCell(cellHeaderBody);
            cellHeaderBody.Phrase = new Phrase(": " + (supplier.Count > 0 ? supplier[0] : "-"), normal_font);
            headerTable2.AddCell(cellHeaderBody);

            for (int i = 1; i < supplier.Count; i++)
            {
                cellHeaderBody.Phrase = new Phrase("", normal_font);
                headerTable2.AddCell(cellHeaderBody);
                cellHeaderBody.Phrase = new Phrase(": " + supplier[i], normal_font);
                headerTable2.AddCell(cellHeaderBody);
            }

            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);

            cellHeaderCS2.Phrase = new Phrase("", normal_font);
            headerTable.AddCell(cellHeaderCS2);

            document.Add(headerTable);

            #endregion Header

            #region Body

            PdfPTable bodyTable = new PdfPTable(7);
            PdfPCell  bodyCell  = new PdfPCell();

            float[] widthsBody = new float[] { 5f, 10f, 10f, 10f, 8f, 7f, 15f };
            bodyTable.SetWidths(widthsBody);
            bodyTable.WidthPercentage = 100;

            bodyCell.HorizontalAlignment = Element.ALIGN_CENTER;
            bodyCell.Phrase = new Phrase("No.", bold_font);
            bodyTable.AddCell(bodyCell);

            bodyCell.Phrase = new Phrase("No. SPB", bold_font);
            bodyTable.AddCell(bodyCell);

            bodyCell.Phrase = new Phrase("Kategori Barang", bold_font);
            bodyTable.AddCell(bodyCell);

            bodyCell.Phrase = new Phrase("Divisi", bold_font);
            bodyTable.AddCell(bodyCell);

            bodyCell.Phrase = new Phrase("Unit", bold_font);
            bodyTable.AddCell(bodyCell);

            bodyCell.Phrase = new Phrase("Mata Uang", bold_font);
            bodyTable.AddCell(bodyCell);

            bodyCell.Phrase = new Phrase("Jumlah", bold_font);
            bodyTable.AddCell(bodyCell);

            int    index = 1;
            double total = 0;
            foreach (BankExpenditureNoteDetailModel detail in model.Details)
            {
                var items = detail.Items
                            .GroupBy(m => new { m.UnitCode, m.UnitName })
                            .Select(s => new
                {
                    s.First().UnitCode,
                    s.First().UnitName,
                    Total = s.Sum(d => detail.Vat == 0 ? d.Price : d.Price * 1.1)
                });
                foreach (var item in items)
                {
                    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(detail.UnitPaymentOrderNo, normal_font);
                    bodyTable.AddCell(bodyCell);

                    bodyCell.Phrase = new Phrase(detail.CategoryName, normal_font);
                    bodyTable.AddCell(bodyCell);

                    bodyCell.Phrase = new Phrase(detail.DivisionName, normal_font);
                    bodyTable.AddCell(bodyCell);

                    bodyCell.HorizontalAlignment = Element.ALIGN_CENTER;
                    bodyCell.Phrase = new Phrase(item.UnitCode, normal_font);
                    bodyTable.AddCell(bodyCell);

                    bodyCell.Phrase = new Phrase(detail.Currency, normal_font);
                    bodyTable.AddCell(bodyCell);

                    bodyCell.HorizontalAlignment = Element.ALIGN_RIGHT;
                    bodyCell.Phrase = new Phrase(string.Format("{0:n4}", item.Total), normal_font);
                    bodyTable.AddCell(bodyCell);

                    if (units.ContainsKey(item.UnitCode))
                    {
                        units[item.UnitCode] += item.Total;
                    }
                    else
                    {
                        units.Add(item.UnitCode, item.Total);
                    }

                    total += item.Total;
                }
            }

            bodyCell.Colspan = 4;
            bodyCell.Border  = Rectangle.NO_BORDER;
            bodyCell.Phrase  = new Phrase("", normal_font);
            bodyTable.AddCell(bodyCell);

            bodyCell.Colspan             = 1;
            bodyCell.Border              = Rectangle.BOX;
            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.BankCurrencyCode, bold_font);
            bodyTable.AddCell(bodyCell);

            bodyCell.HorizontalAlignment = Element.ALIGN_RIGHT;
            bodyCell.Phrase = new Phrase(string.Format("{0:n4}", total), bold_font);
            bodyTable.AddCell(bodyCell);

            document.Add(bodyTable);

            #endregion Body

            #region BodyFooter

            PdfPTable bodyFooterTable = new PdfPTable(6);
            bodyFooterTable.SetWidths(new float[] { 3f, 6f, 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             = 1;
            bodyFooterCell.HorizontalAlignment = Element.ALIGN_LEFT;
            bodyFooterCell.Phrase = new Phrase("Rincian per bagian:", normal_font);
            bodyFooterTable.AddCell(bodyFooterCell);

            bodyFooterCell.Colspan             = 4;
            bodyFooterCell.HorizontalAlignment = Element.ALIGN_RIGHT;
            bodyFooterCell.Phrase = new Phrase("");
            bodyFooterTable.AddCell(bodyFooterCell);

            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.BankCurrencyCode, 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.BankCurrencyCode, normal_font);
            bodyFooterTable.AddCell(bodyFooterCell);

            bodyFooterCell.Colspan             = 3;
            bodyFooterCell.HorizontalAlignment = Element.ALIGN_LEFT;
            bodyFooterCell.Phrase = new Phrase(NumberToTextIDN.terbilang(total), 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.BGCheckNumber, 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);
        }