Beispiel #1
0
        public async Task <int> Create(GarmentShippingLocalPriceCorrectionNoteViewModel viewModel)
        {
            var model = MapToModel(viewModel);

            int Created = await _repository.InsertAsync(model);

            return(Created);
        }
Beispiel #2
0
        private GarmentShippingLocalPriceCorrectionNoteModel MapToModel(GarmentShippingLocalPriceCorrectionNoteViewModel vm)
        {
            var items = (vm.items ?? new List <GarmentShippingLocalPriceCorrectionNoteItemViewModel>())
                        .Where(w => w.isChecked)
                        .Select(i =>
            {
                i.salesNoteItem = i.salesNoteItem ?? new GarmentShippingLocalSalesNoteItemViewModel();
                return(new GarmentShippingLocalPriceCorrectionNoteItemModel(i.salesNoteItem.Id, null, i.priceCorrection)
                {
                    Id = i.Id
                });
            }).ToList();

            vm.salesNote = vm.salesNote ?? new GarmentShippingLocalSalesNoteViewModel();
            return(new GarmentShippingLocalPriceCorrectionNoteModel(GenerateNo(), vm.correctionDate.GetValueOrDefault(), vm.salesNote.Id, null, vm.remark, items)
            {
                Id = vm.Id
            });
        }
Beispiel #3
0
        private GarmentShippingLocalPriceCorrectionNoteViewModel MapToViewModel(GarmentShippingLocalPriceCorrectionNoteModel model)
        {
            GarmentShippingLocalPriceCorrectionNoteViewModel viewModel = new GarmentShippingLocalPriceCorrectionNoteViewModel
            {
                Active            = model.Active,
                Id                = model.Id,
                CreatedAgent      = model.CreatedAgent,
                CreatedBy         = model.CreatedBy,
                CreatedUtc        = model.CreatedUtc,
                DeletedAgent      = model.DeletedAgent,
                DeletedBy         = model.DeletedBy,
                DeletedUtc        = model.DeletedUtc,
                IsDeleted         = model.IsDeleted,
                LastModifiedAgent = model.LastModifiedAgent,
                LastModifiedBy    = model.LastModifiedBy,
                LastModifiedUtc   = model.LastModifiedUtc,

                correctionNoteNo = model.CorrectionNoteNo,
                correctionDate   = model.CorrectionDate,
                salesNote        = new GarmentShippingLocalSalesNoteViewModel
                {
                    Active            = model.SalesNote.Active,
                    Id                = model.SalesNote.Id,
                    CreatedAgent      = model.SalesNote.CreatedAgent,
                    CreatedBy         = model.SalesNote.CreatedBy,
                    CreatedUtc        = model.SalesNote.CreatedUtc,
                    DeletedAgent      = model.SalesNote.DeletedAgent,
                    DeletedBy         = model.SalesNote.DeletedBy,
                    DeletedUtc        = model.SalesNote.DeletedUtc,
                    IsDeleted         = model.SalesNote.IsDeleted,
                    LastModifiedAgent = model.SalesNote.LastModifiedAgent,
                    LastModifiedBy    = model.SalesNote.LastModifiedBy,
                    LastModifiedUtc   = model.SalesNote.LastModifiedUtc,

                    noteNo          = model.SalesNote.NoteNo,
                    date            = model.SalesNote.Date,
                    transactionType = new TransactionType
                    {
                        id   = model.SalesNote.TransactionTypeId,
                        code = model.SalesNote.TransactionTypeCode,
                        name = model.SalesNote.TransactionTypeName
                    },
                    buyer = new Buyer
                    {
                        Id   = model.SalesNote.BuyerId,
                        Code = model.SalesNote.BuyerCode,
                        Name = model.SalesNote.BuyerName,
                        npwp = model.SalesNote.BuyerNPWP
                    },
                    tempo         = model.SalesNote.Tempo,
                    dispositionNo = model.SalesNote.DispositionNo,
                    useVat        = model.SalesNote.UseVat,
                    remark        = model.SalesNote.Remark,
                    isUsed        = model.SalesNote.IsUsed,
                },
                remark = model.Remark,

                items = (model.Items ?? new List <GarmentShippingLocalPriceCorrectionNoteItemModel>()).Select(i => new GarmentShippingLocalPriceCorrectionNoteItemViewModel
                {
                    Active            = i.Active,
                    Id                = i.Id,
                    CreatedAgent      = i.CreatedAgent,
                    CreatedBy         = i.CreatedBy,
                    CreatedUtc        = i.CreatedUtc,
                    DeletedAgent      = i.DeletedAgent,
                    DeletedBy         = i.DeletedBy,
                    DeletedUtc        = i.DeletedUtc,
                    IsDeleted         = i.IsDeleted,
                    LastModifiedAgent = i.LastModifiedAgent,
                    LastModifiedBy    = i.LastModifiedBy,
                    LastModifiedUtc   = i.LastModifiedUtc,

                    isChecked       = true,
                    priceCorrection = i.PriceCorrection,
                    salesNoteItem   = new GarmentShippingLocalSalesNoteItemViewModel
                    {
                        Active            = i.SalesNoteItem.Active,
                        Id                = i.SalesNoteItem.Id,
                        CreatedAgent      = i.SalesNoteItem.CreatedAgent,
                        CreatedBy         = i.SalesNoteItem.CreatedBy,
                        CreatedUtc        = i.SalesNoteItem.CreatedUtc,
                        DeletedAgent      = i.SalesNoteItem.DeletedAgent,
                        DeletedBy         = i.SalesNoteItem.DeletedBy,
                        DeletedUtc        = i.SalesNoteItem.DeletedUtc,
                        IsDeleted         = i.SalesNoteItem.IsDeleted,
                        LastModifiedAgent = i.SalesNoteItem.LastModifiedAgent,
                        LastModifiedBy    = i.SalesNoteItem.LastModifiedBy,
                        LastModifiedUtc   = i.SalesNoteItem.LastModifiedUtc,

                        product = new ProductViewModel
                        {
                            id   = i.SalesNoteItem.ProductId,
                            code = i.SalesNoteItem.ProductCode,
                            name = i.SalesNoteItem.ProductName
                        },
                        quantity = i.SalesNoteItem.Quantity,
                        uom      = new UnitOfMeasurement
                        {
                            Id   = i.SalesNoteItem.UomId,
                            Unit = i.SalesNoteItem.UomUnit
                        },
                        price = i.SalesNoteItem.Price
                    }
                }).ToList()
            };

            return(viewModel);
        }
Beispiel #4
0
        public MemoryStream GeneratePdfTemplate(GarmentShippingLocalPriceCorrectionNoteViewModel viewModel, Buyer buyer, int timeoffset)
        {
            const int MARGIN = 20;

            Font header_font_bold_big        = FontFactory.GetFont(BaseFont.COURIER_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 12);
            Font header_font_bold            = FontFactory.GetFont(BaseFont.COURIER_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 9);
            Font header_font_bold_underlined = FontFactory.GetFont(BaseFont.COURIER_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 10, Font.UNDERLINE);
            Font header_font            = FontFactory.GetFont(BaseFont.COURIER, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 11);
            Font normal_font            = FontFactory.GetFont(BaseFont.COURIER, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8);
            Font normal_font_underlined = FontFactory.GetFont(BaseFont.COURIER, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8, Font.UNDERLINE);
            Font normal_font_bold       = FontFactory.GetFont(BaseFont.COURIER_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();

            #region header
            PdfPTable tableHeader = new PdfPTable(2);
            tableHeader.WidthPercentage = 100;
            tableHeader.SetWidths(new float[] { 3f, 2f });

            PdfPCell cellHeaderContent1 = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER
            };
            PdfPCell cellHeaderContent2 = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER
            };


            cellHeaderContent1.AddElement(new Phrase("\n", normal_font));
            cellHeaderContent1.AddElement(new Phrase("PT. DAN LIRIS", header_font_bold));
            cellHeaderContent1.AddElement(new Phrase("Jl. Merapi No. 23, Kel. Banaran Kec.Grogol Kab. Sukoharjo", normal_font));
            cellHeaderContent1.AddElement(new Phrase("Telp : 0271-714400, Fax. 0271-717178", normal_font));
            cellHeaderContent1.AddElement(new Phrase("PO. Box. 166 Solo-57100 Indonesia", normal_font));
            cellHeaderContent1.AddElement(new Phrase("\n", normal_font));
            cellHeaderContent1.AddElement(new Phrase("\n", normal_font));
            cellHeaderContent1.AddElement(new Phrase("NOTA KOREKSI HARGA", normal_font));
            tableHeader.AddCell(cellHeaderContent1);

            cellHeaderContent2.AddElement(new Phrase("Sukoharjo, " + viewModel.correctionDate.GetValueOrDefault().ToOffset(new TimeSpan(timeoffset, 0, 0)).ToString("dd MMMM yyyy", new System.Globalization.CultureInfo("id-ID")), normal_font));
            cellHeaderContent2.AddElement(new Phrase("\n", normal_font));
            cellHeaderContent2.AddElement(new Phrase("\n", normal_font));
            cellHeaderContent2.AddElement(new Phrase(viewModel.salesNote.buyer.Name, normal_font));
            cellHeaderContent2.AddElement(new Phrase(buyer.Address, normal_font));
            tableHeader.AddCell(cellHeaderContent2);

            document.Add(tableHeader);
            #endregion

            #region title

            PdfPTable tableTitle = new PdfPTable(3);
            tableTitle.WidthPercentage = 100;
            tableTitle.SetWidths(new float[] { 2f, 2f, 1f });

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

            cellTitle1.Phrase  = new Phrase(viewModel.correctionNoteNo, normal_font_bold);
            cellTitle1.Colspan = 2;
            tableTitle.AddCell(cellTitle1);

            cellTitle1.Phrase              = new Phrase("SUKOHARJO - JATENG", normal_font_underlined);
            cellTitle1.Colspan             = 1;
            cellTitle1.HorizontalAlignment = Element.ALIGN_LEFT;
            tableTitle.AddCell(cellTitle1);

            tableTitle.SpacingAfter = 10;
            document.Add(tableTitle);
            #endregion

            #region bodyTable
            PdfPTable tableBody = new PdfPTable(5);
            tableBody.WidthPercentage = 100;
            tableBody.SetWidths(new float[] { 4f, 2f, 1f, 2.3f, 2.5f });
            PdfPCell cellBodyLeft = new PdfPCell()
            {
                Border = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_LEFT
            };
            PdfPCell cellBodyLeftNoBorder = new PdfPCell()
            {
                Border = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_LEFT
            };
            PdfPCell cellBodyRight = new PdfPCell()
            {
                Border = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT
            };
            PdfPCell cellBodyRightNoBorder = new PdfPCell()
            {
                Border = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT
            };
            PdfPCell cellBodyCenter = new PdfPCell()
            {
                Border = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_CENTER
            };

            cellBodyCenter.Phrase = new Phrase("N a m a B a r a n g", normal_font);
            tableBody.AddCell(cellBodyCenter);

            cellBodyCenter.Phrase  = new Phrase("Quantity", normal_font);
            cellBodyCenter.Colspan = 2;
            tableBody.AddCell(cellBodyCenter);

            cellBodyCenter.Phrase  = new Phrase("Harga Sat.", normal_font);
            cellBodyCenter.Colspan = 1;
            tableBody.AddCell(cellBodyCenter);

            cellBodyCenter.Phrase  = new Phrase("Jumlah", normal_font);
            cellBodyCenter.Colspan = 1;
            tableBody.AddCell(cellBodyCenter);

            double totalPrice = 0;
            foreach (var item in viewModel.items)
            {
                cellBodyLeft.Phrase = new Phrase(item.salesNoteItem.product.name, normal_font);
                tableBody.AddCell(cellBodyLeft);

                cellBodyRightNoBorder.Phrase = new Phrase(string.Format("{0:n2}", item.salesNoteItem.quantity), normal_font);
                tableBody.AddCell(cellBodyRightNoBorder);

                cellBodyLeftNoBorder.Phrase = new Phrase(item.salesNoteItem.uom.Unit, normal_font);
                tableBody.AddCell(cellBodyLeftNoBorder);

                var diffPrice = item.priceCorrection - item.salesNoteItem.price;
                cellBodyRight.Phrase = new Phrase(string.Format("{0:n2}", diffPrice), normal_font);
                tableBody.AddCell(cellBodyRight);

                var price = diffPrice * item.salesNoteItem.quantity;
                cellBodyRight.Phrase = new Phrase(string.Format("{0:n2}", price), normal_font);
                tableBody.AddCell(cellBodyRight);

                totalPrice += price;
            }

            double ppn = 0;
            if (viewModel.salesNote.useVat)
            {
                ppn = totalPrice * 0.1;
            }
            double finalPrice = totalPrice + ppn;

            cellBodyRight.Phrase  = new Phrase("Dasar Pengenaan Pajak...............Rp.", normal_font);
            cellBodyRight.Border  = Rectangle.NO_BORDER;
            cellBodyRight.Colspan = 4;
            tableBody.AddCell(cellBodyRight);

            cellBodyRightNoBorder.Phrase = new Phrase(string.Format("{0:n2}", totalPrice), normal_font);
            cellBodyRightNoBorder.Border = Rectangle.NO_BORDER;
            tableBody.AddCell(cellBodyRightNoBorder);

            cellBodyRight.Phrase = new Phrase("PPN = 10% X Dasar Pengenaan Pajak...Rp.", normal_font);
            tableBody.AddCell(cellBodyRight);

            cellBodyRightNoBorder.Phrase = new Phrase(string.Format("{0:n2}", ppn), normal_font);
            cellBodyRightNoBorder.Border = Rectangle.BOTTOM_BORDER;
            tableBody.AddCell(cellBodyRightNoBorder);

            cellBodyRight.Phrase = new Phrase("Jumlah..............................Rp.", normal_font);
            tableBody.AddCell(cellBodyRight);

            cellBodyRightNoBorder.Phrase = new Phrase(string.Format("{0:n2}", finalPrice), normal_font);
            cellBodyRightNoBorder.Border = Rectangle.NO_BORDER;
            tableBody.AddCell(cellBodyRightNoBorder);


            tableBody.SpacingAfter = 10;
            document.Add(tableBody);
            #endregion

            #region footer
            PdfPTable tableFooter = new PdfPTable(2);
            tableFooter.WidthPercentage = 100;
            tableFooter.SetWidths(new float[] { 1.5f, 9f });

            PdfPCell cellFooterContent1 = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER
            };
            PdfPCell cellFooterContent2 = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER
            };

            string terbilang = NumberToTextIDN.terbilang(Math.Round(finalPrice, 2));

            cellFooterContent1.Phrase = (new Phrase("Terbilang :", normal_font));
            tableFooter.AddCell(cellFooterContent1);
            cellFooterContent2.Phrase = (new Phrase(terbilang, normal_font));
            tableFooter.AddCell(cellFooterContent2);

            cellFooterContent1.Phrase = (new Phrase("Catatan   :", normal_font));
            tableFooter.AddCell(cellFooterContent1);
            cellFooterContent2.Phrase = (new Phrase(viewModel.remark, normal_font));
            tableFooter.AddCell(cellFooterContent2);

            tableFooter.SpacingAfter = 10;
            document.Add(tableFooter);
            #endregion

            #region sign
            PdfPTable tableSign = new PdfPTable(5);
            tableSign.WidthPercentage = 80;
            tableSign.SetWidths(new float[] { 1f, 1f, 1f, 1f, 1f });
            PdfPCell cellBodySign = new PdfPCell()
            {
                Border = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_CENTER
            };
            PdfPCell cellBodySignNoBorder = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER
            };

            cellBodySign.Phrase = new Phrase("Diterima Oleh", normal_font);
            tableSign.AddCell(cellBodySign);

            cellBodySignNoBorder.Phrase = new Phrase("", normal_font);
            tableSign.AddCell(cellBodySignNoBorder);

            cellBodySign.Phrase = new Phrase("Dibuat Oleh", normal_font);
            tableSign.AddCell(cellBodySign);
            cellBodySign.Phrase = new Phrase("Diperiksa Oleh", normal_font);
            tableSign.AddCell(cellBodySign);
            cellBodySign.Phrase = new Phrase("Disetujui Oleh", normal_font);
            tableSign.AddCell(cellBodySign);


            cellBodySign.Phrase = new Phrase("\n\n\n", normal_font);
            tableSign.AddCell(cellBodySign);

            cellBodySignNoBorder.Phrase = new Phrase("\n\n\n", normal_font);
            tableSign.AddCell(cellBodySignNoBorder);

            cellBodySign.Phrase = new Phrase("\n\n\n", normal_font);
            tableSign.AddCell(cellBodySign);
            cellBodySign.Phrase = new Phrase("\n\n\n", normal_font);
            tableSign.AddCell(cellBodySign);
            cellBodySign.Phrase = new Phrase("\n\n\n", normal_font);
            tableSign.AddCell(cellBodySign);

            document.Add(tableSign);
            #endregion

            document.Close();
            byte[] byteInfo = stream.ToArray();
            stream.Write(byteInfo, 0, byteInfo.Length);
            stream.Position = 0;

            return(stream);
        }