public void Get_Succes_Return_OK()
        {
            //Setup
            Mock <IServiceProvider> serviceProviderMock = GetServiceProvider();
            var service = new Mock <IDPPVATBankExpenditureNoteService>();

            service
            .Setup(s => s.Read(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>()))
            .Returns(new ReadResponse <DPPVATBankExpenditureNoteIndexDto>(new List <DPPVATBankExpenditureNoteIndexDto>(), 1, new Dictionary <string, string>(), new List <string>()));

            serviceProviderMock
            .Setup(serviceProvider => serviceProvider.GetService(typeof(IDPPVATBankExpenditureNoteService)))
            .Returns(service.Object);

            //Act
            FormDto       form     = new FormDto();
            IActionResult response = GetController(serviceProviderMock).Get("", 1, 10, "{}");

            //Assert
            int statusCode = this.GetStatusCode(response);

            Assert.Equal((int)HttpStatusCode.OK, statusCode);
        }
        public void Posting_Return_InternalServerError()
        {
            //Setup
            Mock <IServiceProvider> serviceProviderMock = GetServiceProvider();
            var service = new Mock <IDPPVATBankExpenditureNoteService>();

            service
            .Setup(s => s.Posting(It.IsAny <List <int> >()))
            .Throws(new Exception());

            serviceProviderMock
            .Setup(serviceProvider => serviceProvider.GetService(typeof(IDPPVATBankExpenditureNoteService)))
            .Returns(service.Object);

            //Act
            FormDto       form     = new FormDto();
            IActionResult response = GetController(serviceProviderMock).Posting(new List <int>());

            //Assert
            int statusCode = this.GetStatusCode(response);

            Assert.Equal((int)HttpStatusCode.InternalServerError, statusCode);
        }
        public IActionResult Post([FromBody] FormDto form)
        {
            try
            {
                VerifyUser();
                _validateService.Validate(form);

                _service.Create(form);

                var response = new ResultFormatter(ApiVersion, General.CREATED_STATUS_CODE, General.OK_MESSAGE).Ok();
                return(Created(string.Concat(Request.Path, "/", 0), response));
            }
            catch (ServiceValidationException e)
            {
                var response = new ResultFormatter(ApiVersion, General.BAD_REQUEST_STATUS_CODE, General.BAD_REQUEST_MESSAGE).Fail(e);
                return(BadRequest(response));
            }
            catch (Exception e)
            {
                var response = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message).Fail();
                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, response));
            }
        }
        public async Task PostCashflowType_Return_InternalServerError()
        {
            //Setup
            Mock <IServiceProvider> serviceProviderMock = GetServiceProvider();
            var service = new Mock <IDPPVATBankExpenditureNoteService>();

            service
            .Setup(s => s.Create(It.IsAny <FormDto>()))
            .ThrowsAsync(new Exception());

            serviceProviderMock
            .Setup(serviceProvider => serviceProvider.GetService(typeof(IDPPVATBankExpenditureNoteService)))
            .Returns(service.Object);

            //Act
            FormDto       form     = new FormDto();
            IActionResult response = await GetController(serviceProviderMock).Post(form);

            //Assert
            int statusCode = this.GetStatusCode(response);

            Assert.Equal((int)HttpStatusCode.InternalServerError, statusCode);
        }
Example #5
0
        public FormDto GetFormData()
        {
            var formDto = new FormDto()
            {
                FormTitle   = this.Text,
                FilePath    = tbFilePath.Text,
                Url         = tbUrl.Text,
                HttpMethord = cbMethord.SelectedItem.ToString(),
                IsSendFile  = cbUploadFile.Checked,
                Headers     = new List <HeaderDto>(),
                RequestBody = tbRequestBody.Text
            };

            formDto.Headers.Add(new HeaderDto()
            {
                Key = tbIdKey.Text, Value = tbAppId.Text
            });
            formDto.Headers.Add(new HeaderDto()
            {
                Key = tbAppSecretyKey.Text, Value = tbAppSecurity.Text
            });
            return(formDto);
        }
Example #6
0
        public async Task Should_Success_Create()
        {
            //Arrange
            var dbContex        = GetDbContext(GetCurrentAsyncMethod());
            var serviceProvider = GetServiceProvider();

            serviceProvider
            .Setup(x => x.GetService(typeof(IHttpClientService)))
            .Returns(new HttpClientTestService());

            serviceProvider
            .Setup(s => s.GetService(typeof(FinanceDbContext)))
            .Returns(dbContex);


            DPPVATBankExpenditureNoteService service = new DPPVATBankExpenditureNoteService(serviceProvider.Object);
            FormDto form = _dataUtil(service).GetNewForm();

            //Act
            var response = await service.Create(form);

            //Assert
            Assert.NotEqual(0, response);
        }
Example #7
0
        public static List <VPRequestViewModel> SubmitRequest(VPRequestForm VPRequestForm)
        {
            #region Commented
            //VoluntaryPlanWaiverRequestDto obj = new VoluntaryPlanWaiverRequestDto();
            //obj.EmployerId = 1;
            //obj.StartDate = DateTime.Now;
            //obj.EndDate = DateTime.Now;
            //obj.IsVoluntaryPlanWaiverRequestAcknowledged = true;
            //obj.VoluntaryPlanWaiverRequestTypes.Add(new VoluntaryPlanWaiverRequestTypeDto()
            //{
            //	LeaveTypeCode = LookupTable_WaiverLeaveType.Medical,
            //	PercentagePaid = 2,
            //	DurationInWeeksCode = LookupTable_WaiverWeeksAvailable._1Week
            //});
            //obj.VoluntaryPlanWaiverRequestTypes.Add(new VoluntaryPlanWaiverRequestTypeDto()
            //{
            //	LeaveTypeCode = LookupTable_WaiverLeaveType.Medical,
            //	PercentagePaid = 1,
            //	DurationInWeeksCode = LookupTable_WaiverWeeksAvailable._4Weeks
            //});

            //VPRequestForm = new VPRequestForm()
            //{
            //	EmployerId = 1,
            //	StartDate = DateTime.Now,
            //	EndDate = DateTime.Now,
            //	IsAcknolwedged = true,
            //	RequestType = new List<VoluntaryPlanWaiverRequestTypeDto>() {
            //		new VoluntaryPlanWaiverRequestTypeDto()
            //		{
            //			 LeaveTypeCode = LookupTable_WaiverLeaveType.Medical,
            //			  PercentagePaid = 2,
            //			  DurationInWeeksCode = LookupTable_WaiverWeeksAvailable._1Week
            //		},
            //		new VoluntaryPlanWaiverRequestTypeDto()
            //		{
            //			 LeaveTypeCode = LookupTable_WaiverLeaveType.Medical,
            //			  PercentagePaid = 1,
            //			  DurationInWeeksCode = LookupTable_WaiverWeeksAvailable._1Week
            //		}
            //	},
            //	Document = new List<DocumentDto>() {
            //		 new DocumentDto(){
            //			  DocumentDescription="Doc Description",
            //			  DocumentName ="DJ.pdf"
            //		 }
            //	}

            //};
            #endregion

            ExecuteSubmitRequestRules(VPRequestForm);
            if (Context.ValidationMessages.Count(ValidationMessageSeverity.Error) == 0)
            {
                using (DbContext context = new DbContext())
                {
                    FormDto FormReq = new FormDto()
                    {
                        FormTypeCode = LookupTable_FormType.VPWaiverForm,
                        StatusCode   = LookupTable_WaiverRequestStatus.SavedasDraft
                    };
                    Form.FromDto(context, FormReq);

                    VoluntaryPlanWaiverRequestDto VPWReq = new VoluntaryPlanWaiverRequestDto()
                    {
                        EmployerId = VPRequestForm.EmployerId,
                        StartDate  = VPRequestForm.StartDate,
                        EndDate    = VPRequestForm.EndDate,
                        IsVoluntaryPlanWaiverRequestAcknowledged = VPRequestForm.IsAcknolwedged
                    };
                    VoluntaryPlanWaiverRequest.FromDto(context, VPWReq);


                    VPRequestForm.RequestType.RemoveAll(p => string.IsNullOrWhiteSpace(p.LeaveTypeCode));
                    foreach (var requestType in VPRequestForm.RequestType)
                    {
                        VoluntaryPlanWaiverRequestType VPWReqType = new VoluntaryPlanWaiverRequestType()
                        {
                            LeaveTypeCode       = requestType.LeaveTypeCode,
                            PercentagePaid      = requestType.PercentagePaid,
                            DurationInWeeksCode = requestType.DurationInWeeksCode
                        };
                        context.VoluntaryPlanWaiverRequestTypes.Add(VPWReqType);
                    }

                    if (VPRequestForm.Document != null)
                    {
                        foreach (var docItem in VPRequestForm.Document)
                        {
                            Document doc = new Document()
                            {
                                DocumentName        = docItem.DocumentName,
                                ExternalDocumentId  = Guid.NewGuid(),
                                DocumentDescription = docItem.DocumentDescription
                            };
                            context.Documents.Add(doc);
                            context.FormAttachments.Add(new FormAttachment());
                        }
                    }

                    context.SaveChanges();
                }
            }
            else
            {
                Context.ValidationMessages.ThrowCheck(ValidationMessageSeverity.Error);
            }
            return(GetRequestColl(VPRequestForm.EmployerId));
        }
Example #8
0
 public Server(FormDto formDto)
     : base(formDto)
 {
 }
Example #9
0
        public FormDto GetNewData_FormDto_Type_DenganNomorVB()
        {
            FormDto formDto = new FormDto()
            {
                Date          = DateTimeOffset.Now,
                SuppliantUnit = new UnitDto()
                {
                    Name = "Name",
                    Id   = 1,
                    VBDocumentLayoutOrder = 1,
                    Code     = "Code",
                    Division = new DivisionDto()
                    {
                        Code = "G",
                        Name = "GARMENT"
                    }
                },
                VBRequestDocument = new VBRequestDocumentDto()
                {
                    Id = 1
                },
                Type     = "Dengan Nomor VB",
                Currency = new CurrencyDto()
                {
                    Code        = "IDR",
                    Symbol      = "Rp",
                    Description = "Description",
                    Rate        = 1
                },

                Items = new List <FormItemDto>()
                {
                    new FormItemDto()
                    {
                        UnitPaymentOrder = new UnitPaymentOrderDto()
                        {
                            No        = "1",
                            Id        = 1,
                            Amount    = 1,
                            Date      = DateTimeOffset.Now,
                            IncomeTax = new IncomeTaxDto()
                            {
                                Name = "Name",
                                Rate = 1
                            },
                            IncomeTaxBy  = "Supplier",
                            UseIncomeTax = true,
                            UseVat       = true,
                            Division     = new DivisionDto()
                            {
                                Code = "Code",
                                Name = "Name"
                            },
                            Supplier = new SupplierDto()
                            {
                                Code = "Code",
                                Name = "Name"
                            },
                            UnitCosts = new List <UnitCostDto>()
                            {
                                new UnitCostDto()
                                {
                                    Amount = 1,
                                    Unit   = new UnitDto()
                                    {
                                        Code     = "Code",
                                        Division = new DivisionDto()
                                        {
                                            Code = "Code",
                                            Name = "Name"
                                        },
                                        Name = "Name",
                                        VBDocumentLayoutOrder = 1
                                    }
                                }
                            },
                        }
                    }
                }
            };

            return(formDto);
        }
Example #10
0
        public async Task <FormDto> DuplicateFormAsync([FromBody] DuplicateFormDto dto)
        {
            FormDto form = await _formStore.GetAsync(dto.Id);

            return(await _formStore.CreateAsync(form, Guid.NewGuid()));
        }
Example #11
0
        public async Task <string> ImportConfigurationAsync([FromForm] ImportConfigDto importConfig)
        {
            IFormFile formFile = importConfig.File;

            if (formFile.Length > 0)
            {
                var result = new StringBuilder();
                using (var reader = new StreamReader(formFile.OpenReadStream()))
                {
                    while (reader.Peek() >= 0)
                    {
                        result.AppendLine(await reader.ReadLineAsync());
                    }
                }


                var deserialisedJson = JsonSerializer.Deserialize <List <Dictionary <string, string> > >(result.ToString());

                foreach (var config in deserialisedJson)
                {
                    //Create FormDTO and validate
                    string formId = config.GetValueOrDefault("Id");

                    var existingForm = await _formStore.GetAsyncOrDefault(Guid.Parse(formId));

                    if (existingForm == null)
                    {
                        FormDto form = GenerateFormDtoHelper(config, formId);

                        await _formStore.CreateAsync(form, Guid.Parse(formId));

                        Logger.Info("Config added successfully!");
                    }
                    else
                    {
                        //Handle scenario that the path already exists
                        Logger.Info("Duplicate config!");
                        //Overide the config
                        Logger.Info("Overwriting them");
                        FormDto form = GenerateFormDtoHelper(config, formId);

                        existingForm.Markup      = form.Markup;
                        existingForm.Name        = form.Name;
                        existingForm.Path        = form.Path;
                        existingForm.ModelType   = form.ModelType;
                        existingForm.Type        = form.Type;
                        existingForm.Description = form.Description;

                        await _formStore.UpdateAsync(existingForm);

                        Logger.Info("Config added successfully!");
                    }
                }

                return("Import success!");
            }
            else
            {
                return("File Import Failed. An error occured!");
            }
        }
Example #12
0
        public async Task <FormDto> CreateAsync(FormDto form)
        {
            var dto = await _formStore.CreateAsync(form);

            return(dto);
        }
        public async Task <int> Update(int id, FormDto form)
        {
            await Task.Delay(1000);

            return(await Task.FromResult(1));
        }
Example #14
0
 private void btnRelabel_Click(object sender, EventArgs e)
 {
     FormDto dto = new FormDto { ModelRoot = txtModelRoot.Text, From = txtFrom.Text, To = txtTo.Text };
     if (txtModelRoot.Text == "" || txtFrom.Text == "" || txtTo.Text == "")
     {
         MessageBox.Show("Missing parameter");
         return;
     }
     btnCancel.Enabled = true;
     btnRelabel.Enabled = false;
     backgroundWorker1.RunWorkerAsync(dto);
 }
Example #15
0
 public Server(FormDto formDto)
     : base(formDto)
 {
 }
Example #16
0
 public async Task <FormDto> UpdateAsync(FormDto form)
 {
     return(await _formStore.UpdateAsync(form));
 }
        public MemoryStream GeneratePdfTemplate(FormDto viewModel, int clientTimeZoneOffset, string userName)
        {
            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 small_font   = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8);
            Font smaller_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 7);
            Font bold_font    = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 7);
            Font bold_font2   = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8);
            Font bold_font3   = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 9);
            Font bold_font4   = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 10);

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

            PdfPCell cellRightMerge = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER | Rectangle.NO_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_TOP, Padding = 5
            };
            PdfPCell cellLeftMerge = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_TOP, Padding = 5
            };


            Document     document = new Document(PageSize.A4, 30, 30, 100, 30);
            MemoryStream stream   = new MemoryStream();
            PdfWriter    writer   = PdfWriter.GetInstance(document, stream);

            writer.PageEvent = new TextEvents(viewModel.DispositionNo);
            document.Open();

            string    fmString = "FM-PB-00-06-011";
            Paragraph fm       = new Paragraph(fmString, bold_font4)
            {
                Alignment = Element.ALIGN_RIGHT
            };

            //string titleString = "DISPOSISI PEMBAYARAN";
            //Paragraph title = new Paragraph(titleString, bold_font4) { Alignment = Element.ALIGN_CENTER };

            //document.Add(title);
            bold_font.SetStyle(Font.NORMAL);


            //string NoString = "NO : " + viewModel.DispositionNo;
            //Paragraph dispoNumber = new Paragraph(NoString, bold_font4) { Alignment = Element.ALIGN_CENTER };
            //dispoNumber.SpacingAfter = 20f;
            //document.Add(dispoNumber);



            #region Identity

            PdfPTable tableIdentity = new PdfPTable(5);
            tableIdentity.SetWidths(new float[] { 5f, 0.5f, 2f, 7f, 4f });

            double dpp = 0;
            foreach (var item in viewModel.Items)
            {
                foreach (var detail in item.Details)
                {
                    dpp += detail.PaidPrice;
                }
            }

            double ppn     = (dpp * 0.1);
            string pph     = "";
            double pphRate = 0;

            foreach (var item in viewModel.Items)
            {
                if (!item.IsUseVat)
                {
                    ppn = 0;
                }
                if (item.IsUseIncomeTax)
                {
                    pph     = item.IncomeTaxName;
                    pphRate = dpp * (Convert.ToDouble(item.IncomeTaxRate) / 100);
                }
                break;
            }

            //Jumlah dibayar ke Supplier
            double paidToSupp = dpp + ppn - pphRate;
            //if (viewModel.IncomeTaxBy == "Dan Liris")
            //{
            //    paidToSupp = dpp + ppn;
            //}

            double amount = dpp + ppn;

            //if (viewModel.IncomeTaxBy == "Dan Liris")
            //{
            //    amount = dpp + ppn + pphRate;
            //}

            var payingDisposition = Math.Round((paidToSupp + viewModel.MiscAmount + pphRate), 2, MidpointRounding.AwayFromZero);
            cellLeftNoBorder.SetLeading(13f, 0f);
            cellLeftNoBorder.Phrase = new Phrase("Mohon Disposisi Pembayaran", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase  = new Phrase(viewModel.PaymentType + "  " + viewModel.CurrencyCode + " " + $"{(paidToSupp + viewModel.MiscAmount).ToString("N", new CultureInfo("id-ID"))}", normal_font); /*$"{viewModel.Amount.ToString("N", new CultureInfo("id-ID"))}", normal_font);*/
            cellLeftNoBorder.Colspan = 2;
            tableIdentity.AddCell(cellLeftNoBorder);
            //cellLeftNoBorder.Phrase = new Phrase( viewModel.Currency.code + " " +  $"{(paidToSupp + viewModel.PaymentCorrection + pphRate).ToString("N", new CultureInfo("id-ID")) }", normal_font);
            //tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase  = new Phrase("", normal_font);
            cellLeftNoBorder.Colspan = 0;
            tableIdentity.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase("Terbilang", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase  = new Phrase($"{ NumberToTextIDN.terbilang(viewModel.Amount) }" + " " + (viewModel.CurrencyCode == "IDR"?"Rupiah":viewModel.CurrencyCode == "USD"?"Dollar":viewModel.CurrencyCode), normal_font);
            cellLeftNoBorder.Colspan = 2;
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase("", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase  = new Phrase("", normal_font);
            cellLeftNoBorder.Colspan = 4;
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase("", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase  = new Phrase("Perhitungan :", bold_font3);
            cellLeftNoBorder.Colspan = 4;
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase("", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);

            //calculate vat and incomeTax
            double vat       = 0;
            double incomeTax = 0;
            foreach (var item in viewModel.Items)
            {
                if (item.IsPayVat)
                {
                    vat += item.VatValue;
                }

                if (item.IsPayIncomeTax)
                {
                    incomeTax += item.IncomeTaxValue;
                }
            }

            cellLeftNoBorder.Colspan = 0;
            cellLeftNoBorder.Phrase  = new Phrase("Biaya", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Colspan = 3;
            cellLeftNoBorder.Phrase  = new Phrase(viewModel.CurrencyCode + "  " + $"{viewModel.DPP.ToString("N", new CultureInfo("id-ID")) }", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Colspan = 0;
            cellLeftNoBorder.Phrase  = new Phrase("(PPn)", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Colspan = 3;
            cellLeftNoBorder.Phrase  = new Phrase(viewModel.CurrencyCode + "  " + $"{viewModel.VatValue.ToString("N", new CultureInfo("id-ID")) }", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Colspan = 0;
            cellLeftNoBorder.Phrase  = new Phrase("Total", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Colspan = 3;
            cellLeftNoBorder.Phrase  = new Phrase(viewModel.CurrencyCode + "  " + $"{(viewModel.DPP + vat).ToString("N", new CultureInfo("id-ID")) }", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Colspan = 0;
            cellLeftNoBorder.Phrase  = new Phrase("", normal_font);
            cellLeftNoBorder.Colspan = 4;
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase("", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Colspan = 0;
            cellLeftNoBorder.Phrase  = new Phrase("", normal_font);
            cellLeftNoBorder.Colspan = 4;
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase("", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);

            var pphDanliris = pphRate;
            //if (viewModel.IncomeTaxBy == "Dan Liris")
            //{
            //    pphDanliris = 0;
            //}

            cellLeftNoBorder.Colspan = 0;
            cellLeftNoBorder.Phrase  = new Phrase("PPh " + pph, normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Colspan = 3;
            cellLeftNoBorder.Phrase  = new Phrase(viewModel.CurrencyCode + "  " + $"{viewModel.IncomeTaxValue.ToString("N", new CultureInfo("id-ID")) }", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);



            cellLeftNoBorder.Colspan = 0;
            cellLeftNoBorder.Phrase  = new Phrase("Jumlah dibayar ke Supplier ", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Colspan = 2;
            cellLeftNoBorder.Phrase  = new Phrase(viewModel.CurrencyCode + "  " + $"{(viewModel.DPP+ vat - incomeTax).ToString("N", new CultureInfo("id-ID")) }", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase("", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Colspan = 0;
            cellLeftNoBorder.Phrase  = new Phrase("Biaya Lain - Lain", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Colspan = 3;
            cellLeftNoBorder.Phrase  = new Phrase(viewModel.CurrencyCode + "  " + $"{viewModel.MiscAmount.ToString("N", new CultureInfo("id-ID"))}", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Colspan = 0;
            cellLeftNoBorder.Phrase  = new Phrase("", normal_font);
            cellLeftNoBorder.Colspan = 4;
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase("", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Colspan = 0;
            cellLeftNoBorder.Phrase  = new Phrase("", normal_font);
            cellLeftNoBorder.Colspan = 4;
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase("", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);

            PdfPCell cellSuppLeft = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 5
            };
            PdfPCell cellSuppMid = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 5
            };
            PdfPCell cellSuppRight = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 5
            };

            cellSuppLeft.Phrase = new Phrase("Total dibayar ke Supplier", normal_font);
            tableIdentity.AddCell(cellSuppLeft);
            cellSuppMid.Phrase = new Phrase(":", normal_font);
            tableIdentity.AddCell(cellSuppMid);
            cellSuppRight.Colspan = 2;
            cellSuppRight.Phrase  = new Phrase(viewModel.CurrencyCode + "  " + $"{((viewModel.DPP + vat - incomeTax)+viewModel.MiscAmount).ToString("N", new CultureInfo("id-ID"))}", normal_font);
            tableIdentity.AddCell(cellSuppRight);
            cellLeftNoBorder.Colspan = 0;
            cellLeftNoBorder.Phrase  = new Phrase("", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Colspan = 0;
            cellLeftNoBorder.Phrase  = new Phrase("", normal_font);
            cellLeftNoBorder.Colspan = 4;
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase("", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Colspan = 0;
            cellLeftNoBorder.Phrase  = new Phrase("", normal_font);
            cellLeftNoBorder.Colspan = 4;
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase("", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Colspan = 0;
            cellLeftNoBorder.Phrase  = new Phrase("Pembayaran ditransfer ke", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase  = new Phrase(viewModel.Bank, normal_font);
            cellLeftNoBorder.Colspan = 3;
            tableIdentity.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Colspan = 0;
            cellLeftNoBorder.Phrase  = new Phrase("Dibayar ke Kas Negara", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Colspan = 3;
            cellLeftNoBorder.Phrase  = new Phrase(viewModel.CurrencyCode + "  " + $"{(viewModel.IncomeTaxValue).ToString("N", new CultureInfo("id-ID")) }", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);


            PdfPCell cellIdentity = new PdfPCell(tableIdentity);
            tableIdentity.ExtendLastRow = false;
            tableIdentity.SpacingAfter  = 15f;
            document.Add(tableIdentity);
            #endregion

            #region Content
            PdfPTable tableContent = new PdfPTable(9);
            tableContent.SetWidths(new float[] { 6f, 5f, 4f, 3f, 3f, 2.5f, 2.5f, 3.5f, 3f });

            cellCenter.Phrase = new Phrase("Nama Barang", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("No PO Internal", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("No PO Eksternal", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("QTY Dipesan", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("QTY Dibayar", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("QTY Sisa", 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("% Over Qty", bold_font);
            tableContent.AddCell(cellCenter);

            double total         = 0;
            double totalPurchase = 0;

            foreach (FormItemDto item in viewModel.Items)
            {
                for (int indexItem = 0; indexItem < item.Details.Count; indexItem++)
                {
                    FormDetailDto detail   = item.Details[indexItem];
                    var           unitName = detail.UnitName;
                    //var unitName = "";
                    //var unitId = detail.Unit._id;
                    //if (unitId == "50")
                    //{
                    //    unitName = "WEAVING";
                    //}
                    //else if (unitId == "35")
                    //{
                    //    unitName = "SPINNING 1";
                    //}
                    //else
                    //{
                    //unitName = detail.UnitName;
                    //}
                    cellLeft.Colspan = 0;
                    cellLeft.Phrase  = new Phrase($"{detail.ProductName}", smaller_font);
                    tableContent.AddCell(cellLeft);
                    cellCenter.Colspan = 0;
                    cellCenter.Phrase  = new Phrase($"{detail.IPONo}", smaller_font);
                    tableContent.AddCell(cellCenter);

                    cellCenter.Phrase = new Phrase($"{item.EPONo}", smaller_font);
                    tableContent.AddCell(cellCenter);

                    cellCenter.Phrase = new Phrase($"{detail.QTYOrder}", smaller_font);
                    tableContent.AddCell(cellCenter);

                    cellCenter.Phrase = new Phrase($"{detail.QTYPaid}", smaller_font);
                    tableContent.AddCell(cellCenter);

                    cellCenter.Phrase = new Phrase($"{detail.QTYRemains}", smaller_font);
                    tableContent.AddCell(cellCenter);

                    cellCenter.Phrase = new Phrase($"{detail.QTYUnit}", smaller_font);
                    tableContent.AddCell(cellCenter);

                    cellRightMerge.Phrase = new Phrase($"{detail.PricePerQTY.ToString("N", new CultureInfo("id-ID"))}", smaller_font);
                    tableContent.AddCell(cellRightMerge);

                    cellCenter.Phrase = new Phrase($"{detail.PercentageOverQTY.ToString("N", new CultureInfo("id-ID"))}", smaller_font);
                    tableContent.AddCell(cellCenter);

                    double subtotalPrice = detail.PercentageOverQTY;

                    total += detail.PaidPrice;

                    totalPurchase += (detail.PricePerQTY * detail.QTYOrder);
                }
            }


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

            #region note

            PdfPTable tableNote = new PdfPTable(3);
            tableNote.SetWidths(new float[] { 4f, 0.5f, 11f });

            cellLeftNoBorder.Phrase  = new Phrase("Note :", bold_font3);
            cellLeftNoBorder.Colspan = 4;
            tableNote.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Colspan = 0;
            cellLeftNoBorder.Phrase  = new Phrase("Kategori", normal_font);
            tableNote.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableNote.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(viewModel.Category, normal_font);
            tableNote.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Colspan = 0;
            cellLeftNoBorder.Phrase  = new Phrase("Supplier / Agent", normal_font);
            tableNote.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableNote.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(viewModel.SupplierName, normal_font);
            tableNote.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase("No Order Confirmation", normal_font);
            tableNote.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableNote.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(viewModel.ConfirmationOrderNo, normal_font);
            tableNote.AddCell(cellLeftNoBorder);

            //cellLeftNoBorder.Phrase = new Phrase("No Invoice", normal_font);
            //tableNote.AddCell(cellLeftNoBorder);
            //cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            //tableNote.AddCell(cellLeftNoBorder);
            //cellLeftNoBorder.Phrase = new Phrase(viewModel.InvoiceNo, normal_font);
            //tableNote.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase("No Proforma/Invoice", normal_font);
            tableNote.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableNote.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(viewModel.ProformaNo, normal_font);
            tableNote.AddCell(cellLeftNoBorder);

            //cellLeftNoBorder.Phrase = new Phrase("Investasi", normal_font);
            //tableNote.AddCell(cellLeftNoBorder);
            //cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            //tableNote.AddCell(cellLeftNoBorder);
            //cellLeftNoBorder.Phrase = new Phrase(viewModel.Investation, normal_font);
            //tableNote.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase("Mohon dibayar Tanggal", normal_font);
            tableNote.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableNote.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(viewModel.PaymentDueDate.ToOffset(new TimeSpan(clientTimeZoneOffset, 0, 0)).ToString("dd MMMM yyyy", new CultureInfo("id-ID")), normal_font);
            tableNote.AddCell(cellLeftNoBorder);

            //cellLeftNoBorder.Phrase = new Phrase("Bank", normal_font);
            //tableNote.AddCell(cellLeftNoBorder);
            //cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            //tableNote.AddCell(cellLeftNoBorder);
            //cellLeftNoBorder.Phrase = new Phrase(viewModel.Bank, normal_font);
            //tableNote.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase("Keterangan", normal_font);
            tableNote.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableNote.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(viewModel.Remark, normal_font);
            tableNote.AddCell(cellLeftNoBorder);

            var ppnPurchase = viewModel.VatValue > 0 ? (totalPurchase * 10 / 100) : 0;


            cellLeftNoBorder.Phrase = new Phrase("Total Pembelian", normal_font);
            tableNote.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableNote.AddCell(cellLeftNoBorder);
            //cellLeftNoBorder.Phrase = new Phrase($"{viewModel.CurrencyCode}" + " " + $"{(totalPurchase + ppnPurchase).ToString("N", new CultureInfo("id-ID"))}", normal_font);
            cellLeftNoBorder.Phrase = new Phrase($"{viewModel.CurrencyCode}" + " " + $"{((viewModel.DPP + vat)- incomeTax).ToString("N", new CultureInfo("id-ID"))}", normal_font);

            tableNote.AddCell(cellLeftNoBorder);

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

            #region beban
            PdfPTable tableBeban = new PdfPTable(1);
            tableBeban.SetWidths(new float[] { 5f });
            cellLeftNoBorder.Phrase = new Phrase("Beban Unit :", bold_font3);;
            tableBeban.AddCell(cellLeftNoBorder);

            var AmountPerUnit = viewModel.Items.SelectMany(s => s.Details)
                                .GroupBy(
                key => new { key.UnitId, key.UnitName, key.UnitCode },
                val => val,
                (key, val) => new { Key = key, Value = val }
                ).ToList();
            foreach (var perUnit in AmountPerUnit)
            {
                var sumPerUnit = perUnit.Value.Sum(t =>
                                                   (t.PaidPrice) +
                                                   (viewModel.Items.Where(a => a.Id == t.GarmentDispositionPurchaseItemId).FirstOrDefault().IsPayVat? t.PaidPrice * 0.1:0) -
                                                   (t.PaidPrice * (viewModel.Items.Where(a => a.Id == t.GarmentDispositionPurchaseItemId).FirstOrDefault()?.IncomeTaxRate / 100)))?.ToString("N", new CultureInfo("id-ID"));
                cellLeftNoBorder.Phrase = new Phrase($"- {perUnit.Key.UnitName} = {sumPerUnit}", bold_font3);
                tableBeban.AddCell(cellLeftNoBorder);
            }
            PdfPCell cellBeban = new PdfPCell(tableBeban); // dont remove
            tableBeban.ExtendLastRow = false;
            document.Add(tableBeban);
            #endregion

            #region signature
            PdfPTable tableSignature = new PdfPTable(5);
            tableSignature.SetWidths(new float[] { 4f, 4f, 4f, 4f, 4.5f });

            PdfPCell cellSignatureContent = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER
            };

            cellSignatureContent.Phrase = new Phrase("", bold_font3);
            tableSignature.AddCell(cellSignatureContent);
            cellSignatureContent.Phrase  = new Phrase("", bold_font3);
            cellSignatureContent.Colspan = 3;
            tableSignature.AddCell(cellSignatureContent);

            cellSignatureContent.Colspan = 0;
            cellSignatureContent.Phrase  = new Phrase("Sukoharjo, " + viewModel.CreatedUtc.ToString("dd MMMM yyyy", new CultureInfo("id-ID")), bold_font3);
            tableSignature.AddCell(cellSignatureContent);

            cellSignatureContent.Colspan = 2;
            cellSignatureContent.Phrase  = new Phrase("Menyetujui,", bold_font3);
            tableSignature.AddCell(cellSignatureContent);
            cellSignatureContent.Phrase  = new Phrase("Mengetahui,", bold_font3);
            cellSignatureContent.Colspan = 2;
            tableSignature.AddCell(cellSignatureContent);

            cellSignatureContent.Colspan = 0;
            cellSignatureContent.Phrase  = new Phrase("Hormat Kami,", bold_font3);
            tableSignature.AddCell(cellSignatureContent);

            cellSignatureContent.Phrase = new Phrase("\n\n\n\n\n\n\n(    Hendro Suseno     )\n  Direktur Keuangan", bold_font3);
            tableSignature.AddCell(cellSignatureContent);
            cellSignatureContent.Phrase = new Phrase("\n\n\n\n\n\n\n(      Verifikasi      )", bold_font3);
            tableSignature.AddCell(cellSignatureContent);
            cellSignatureContent.Phrase = new Phrase("\n\n\n\n\n\n\n(   Kabag Pembelian    )", bold_font3);
            tableSignature.AddCell(cellSignatureContent);
            cellSignatureContent.Phrase = new Phrase("\n\n\n\n\n\n\n(   Kasie Pembelian    )", bold_font3);
            tableSignature.AddCell(cellSignatureContent);
            cellSignatureContent.Phrase = new Phrase("\n\n\n\n\n\n\n(     " + userName + "     )", bold_font3);
            tableSignature.AddCell(cellSignatureContent);

            //PdfPCell cellSignatureContentDir = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER,VerticalAlignment=Element.ALIGN_TOP };

            //cellSignatureContentDir.Phrase = new Phrase("\n\n\n\n\n\n\n    Direktur Keuangan   ", bold_font3);
            //tableSignature.AddCell(cellSignatureContentDir);
            //cellSignatureContentDir.Colspan = 4;
            //cellSignatureContentDir.Phrase = new Phrase("", bold_font3);
            //tableSignature.AddCell(cellSignatureContentDir);

            PdfPCell cellSignature = new PdfPCell(tableSignature); // dont remove
            tableSignature.ExtendLastRow = false;
            tableSignature.SpacingBefore = 10f;
            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 async Task <int> Create(FormDto form)
        {
            await Task.Delay(1000);

            return(await Task.FromResult(1));
        }