コード例 #1
0
        public IHttpActionResult GetQuestions(int id)
        {
            PatientForm patientForm = _db.PatientForms.FirstOrDefault(x => x.PatientFormId == id);

            if (patientForm == null)
            {
                return(NotFound());
            }

            IQueryable <AnswerListView> col = _db.AnswerListViews.Where(p => p.PatientFormId == id).OrderBy(x => x.QuestionIndex);

            List <QuestionDto> questions = new List <QuestionDto>();

            foreach (AnswerListView item in col)
            {
                questions.Add(Mapper.MapToDto(item));
            }

            FormDetailDto formDetails = new FormDetailDto {
                Id           = id,
                FormDate     = patientForm.FormDate,
                FormTypeName = patientForm.FormType.FormTypeName,
                FormTypeId   = patientForm.FormType.FormTypeId,
                PatientId    = patientForm.PatientId,
                Questions    = questions
            };

            return(Ok(formDetails));
        }
コード例 #2
0
        public IHttpActionResult GetQuestions(int formtypeid, string patientid)
        {
            FormType formType = _db.FormTypes.FirstOrDefault(x => x.FormTypeId == formtypeid);

            if (formType == null)
            {
                return(NotFound());
            }
            IQueryable <Question> col = _db.Questions.Where(x => x.FormTypeId == formtypeid).OrderBy(x => x.QuestionIndex);

            List <QuestionDto> questions = new List <QuestionDto>();

            foreach (Question item in col)
            {
                questions.Add(Mapper.MapToDto(item));
            }
            FormDetailDto formDetails = new FormDetailDto {
                Id           = 0,
                FormDate     = DateTime.Now.Date,
                FormTypeName = formType.FormTypeName,
                FormTypeId   = formtypeid,
                PatientId    = patientid,
                Questions    = questions
            };

            return(Ok(formDetails));
        }
コード例 #3
0
        public async Task <bool> UpdateAsync(FormDetailDto model)
        {
            var uri      = API.Form.UpdateAsync(_baseUrl);
            var content  = new StringContent(JsonConvert.SerializeObject(model), System.Text.Encoding.UTF8, "application/json");
            var response = await _apiClient.PostAsync(uri, content);

            response.EnsureSuccessStatusCode();
            string res = await response.Content.ReadAsStringAsync();

            return(res.ToLower() == bool.TrueString.ToLower());
        }
コード例 #4
0
        public async Task <IActionResult> PostDetail([FromBody] FormDetailDto formDetailDto)
        {
            if (ModelState.IsValid)
            {
                var item = await _formHdService.AddOrUpdateDetailAsync(formDetailDto);

                return(Ok(item));
            }

            return(NoContent());
        }
コード例 #5
0
        public async Task <IActionResult> Show(Guid?id)
        {
            FormDetailDto model;

            if (id == null || id == default(Guid))
            {
                model = new FormDetailDto();
            }
            else
            {
                model = await formService.GetFormDetailAsync(id.Value);
            }
            return(View(model));
        }
コード例 #6
0
        private static string GetXmlValue(FormDetailDto formDetailDto)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<Questions>");
            foreach (var item in formDetailDto.Questions)
            {
                sb.Append(
                    $"<Question><Answer>{item.Answer}</Answer><Checked>{item.Checked}</Checked><QuestionId>{item.Id}</QuestionId></Question>"
                    );
            }
            sb.Append("</Questions>");
            return(sb.ToString());
        }
コード例 #7
0
        public async Task <FormDetailDto> GetDetailByIdAsync(string id)
        {
            FormDetailDto itemDto = null;

            try
            {
                var item = await _formDetailRepository.FindEntityBy(x => x.Id == id);

                itemDto = _mapper.Map <FormDetailDto>(item);
            }
            catch (System.Exception ex)
            {
                LoggerService.LogToFile(ex);
            }

            return(itemDto);
        }
コード例 #8
0
        public async Task <BaseResponse> AddOrUpdateDetailAsync(FormDetailDto formDetailDto)
        {
            var response = new BaseResponse();

            try
            {
                var formDetail = _mapper.Map <FormDetail>(formDetailDto);
                if (string.IsNullOrEmpty(formDetail.Id))
                {
                    formDetail.Id       = Common.Utilities.Utils.NewGuid;
                    formDetail.IsActive = true;
                    _formDetailRepository.Add(formDetail);
                    response.Message = LoggingEvents.INSERT_SUCCESS_MESSAGE;
                }
                else
                {
                    formDetail = await _formDetailRepository.FindEntityBy(x => x.Id == formDetailDto.Id);

                    if (formDetail != null)
                    {
                        formDetail.FieldLabel = formDetailDto.FieldLabel;
                        formDetail.Order      = formDetailDto.Order;
                        _formDetailRepository.Edit(formDetail);
                    }
                    else
                    {
                        response.Message = LoggingEvents.UPDATE_FAILED_MESSAGE;
                        return(response);
                    }
                    response.Message = LoggingEvents.UPDATE_SUCCESS_MESSAGE;
                }

                var item = await _formDetailRepository.SaveChanges();

                response.Success = true;
                response.Id      = formDetail.Id;
            }
            catch (System.Exception ex)
            {
                response.Message = LoggingEvents.INSERT_FAILED_MESSAGE;
                LoggerService.LogToFile(ex);
            }

            return(response);
        }
コード例 #9
0
        public async Task <bool> InsertAsync(FormDetailDto model)
        {
            var form = mapper.Map <FormDetailDto, WfWorkflowForm>(model);

            form.FormId = Guid.NewGuid();
            if ((WorkFlowFormType)form.FormType == WorkFlowFormType.Custom)
            {
                form.FormUrl = null;

                form.OriginalContent = model.Content;
                //解析html内容
                form.Content = addHtmlNameAttr(model.Content);
            }
            else
            {
                form.Content         = null;
                form.OriginalContent = null;
            }
            return(await databaseFixture.Db.WorkflowForm.InsertAsync(form));
        }
コード例 #10
0
        public async Task <bool> UpdateAsync(FormDetailDto model)
        {
            var dbform = await databaseFixture.Db.WorkflowForm.FindByIdAsync(model.FormId);

            dbform.FormName = model.FormName;
            dbform.FormType = model.FormType;
            if ((WorkFlowFormType)dbform.FormType == WorkFlowFormType.Custom)
            {
                dbform.FormUrl         = null;
                dbform.OriginalContent = model.Content;
                dbform.Content         = addHtmlNameAttr(model.Content);
            }
            else
            {
                dbform.Content         = null;
                dbform.OriginalContent = null;
                dbform.FormUrl         = model.FormUrl;
            }
            return(await databaseFixture.Db.WorkflowForm.UpdateAsync(dbform));
        }
        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);
        }
コード例 #12
0
 public async Task <bool> UpdateAsync(FormDetailDto model)
 {
     return(await formService.UpdateAsync(model));
 }
コード例 #13
0
 public async Task <bool> InsertAsync(FormDetailDto model)
 {
     model.CreateUserId = UserIdentity.UserId.ToString();
     return(await formService.InsertAsync(model));
 }
コード例 #14
0
 public async Task <bool> InsertAsync([FromBody] FormDetailDto model)
 {
     return(await formService.InsertAsync(model));
 }
コード例 #15
0
        public IHttpActionResult PostPatientForm(FormDetailDto formDetailDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            var param1 = new SqlParameter
            {
                ParameterName = "@PatientFormId",
                SqlDbType     = SqlDbType.Int,
                Direction     = ParameterDirection.InputOutput,
                Value         = formDetailDto.Id
            };

            var param2 = new SqlParameter
            {
                ParameterName = "@FormTypeId",
                SqlDbType     = SqlDbType.Int,
                Direction     = ParameterDirection.Input,
                Value         = formDetailDto.FormTypeId
            };

            var param3 = new SqlParameter
            {
                ParameterName = "@PatientId",
                SqlDbType     = SqlDbType.VarChar,
                Direction     = ParameterDirection.Input,
                Size          = 20,
                Value         = formDetailDto.PatientId
            };

            var param4 = new SqlParameter
            {
                ParameterName = "@FormDate",
                SqlDbType     = SqlDbType.Date,
                Direction     = ParameterDirection.Input,
                Value         = formDetailDto.FormDate
            };

            var param5 = new SqlParameter
            {
                ParameterName = "@XmlData",
                SqlDbType     = SqlDbType.Xml,
                Direction     = ParameterDirection.Input,
                Value         = new SqlXml(new XmlTextReader(GetXmlValue(formDetailDto), XmlNodeType.Document, null))
            };

            var param6 = new SqlParameter
            {
                ParameterName = "@SavedId",
                SqlDbType     = SqlDbType.Int,
                Direction     = ParameterDirection.Output,
                Value         = 0
            };

            try
            {
                _db.Database.ExecuteSqlCommand(
                    "spSaveFormDetail @PatientFormId, @FormTypeId, @PatientId, @FormDate, @XmlData, @SavedId OUT",
                    param1, param2, param3, param4, param5, param6);
            }
            catch (Exception exc)
            {
                return(BadRequest(exc.Message));
            }

            formDetailDto.Id = (int)param6.Value;

            return(CreatedAtRoute("DefaultApi", new { id = param6.Value }, formDetailDto));
        }