コード例 #1
0
        public async Task <int> Create(GarmentShippingInstructionViewModel viewModel)
        {
            GarmentShippingInstructionModel garmentShippingInstructionModel = MapToModel(viewModel);

            int Created = await _shippingInstructionRepository.InsertAsync(garmentShippingInstructionModel);

            return(Created);
        }
コード例 #2
0
        private GarmentShippingInstructionModel MapToModel(GarmentShippingInstructionViewModel viewModel)
        {
            viewModel.forwarder  = viewModel.forwarder ?? new Forwarder();
            viewModel.BuyerAgent = viewModel.BuyerAgent ?? new Buyer();
            GarmentShippingInstructionModel garmentShippingInstructionModel = new GarmentShippingInstructionModel(viewModel.InvoiceNo, viewModel.InvoiceId,
                                                                                                                  viewModel.Date, viewModel.forwarder.id, viewModel.forwarder.code, viewModel.forwarder.name, viewModel.forwarder.address,
                                                                                                                  viewModel.forwarder.phone, viewModel.ATTN, viewModel.forwarder.fax, viewModel.CC, viewModel.ShippingStaffId,
                                                                                                                  viewModel.ShippingStaffName, viewModel.Phone, viewModel.ShippedBy, viewModel.TruckingDate,
                                                                                                                  viewModel.CartonNo, viewModel.PortOfDischarge, viewModel.PlaceOfDelivery,
                                                                                                                  viewModel.FeederVessel, viewModel.OceanVessel, viewModel.Carrier, viewModel.Flight,
                                                                                                                  viewModel.Transit, viewModel.BankAccountId, viewModel.BankAccountName, viewModel.BuyerAgent.Id,
                                                                                                                  viewModel.BuyerAgent.Code, viewModel.BuyerAgent.Name, viewModel.BuyerAgentAddress,
                                                                                                                  viewModel.Notify, viewModel.SpecialInstruction, viewModel.LadingDate.GetValueOrDefault(),
                                                                                                                  viewModel.LadingBill, viewModel.Freight, viewModel.Marks);

            return(garmentShippingInstructionModel);
        }
コード例 #3
0
        public MemoryStream GeneratePdfTemplate(GarmentShippingInstructionViewModel viewModel, GarmentCoverLetterViewModel cl, GarmentPackingListViewModel pl, GarmentShippingInvoiceViewModel invoice, int timeoffset)
        {
            const int MARGIN = 25;

            Font header_font            = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8);
            Font normal_font            = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8);
            Font body_font              = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8);
            Font normal_font_underlined = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8, Font.UNDERLINE);
            Font bold_font              = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8);
            //Font body_bold_font = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8);

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

            writer.PageEvent = new GarmentShippingInstructionPDFTemplatePageEvent();

            document.Open();

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

            PdfPCell cellHeaderContent1 = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER
            };
            cellHeaderContent1.AddElement(new Phrase("TO", normal_font));
            cellHeaderContent1.AddElement(new Phrase("ATTN", normal_font));
            cellHeaderContent1.AddElement(new Phrase("CC", normal_font));
            cellHeaderContent1.AddElement(new Phrase("FROM", normal_font));
            tableHeader.AddCell(cellHeaderContent1);

            PdfPCell cellHeaderContent2 = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER
            };
            cellHeaderContent2.AddElement(new Phrase(": " + viewModel.forwarder.name, normal_font));
            cellHeaderContent2.AddElement(new Phrase(": " + viewModel.ATTN, normal_font));
            cellHeaderContent2.AddElement(new Phrase(": " + viewModel.CC, normal_font));
            cellHeaderContent2.AddElement(new Phrase(": " + viewModel.ShippingStaffName + "/" + viewModel.Phone, normal_font));
            tableHeader.AddCell(cellHeaderContent2);

            PdfPCell cellHeaderContent3 = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER
            };
            cellHeaderContent3.AddElement(new Phrase("FAX", normal_font));
            cellHeaderContent3.AddElement(new Phrase("REF", normal_font));
            cellHeaderContent3.AddElement(new Phrase("DATE", normal_font));
            tableHeader.AddCell(cellHeaderContent3);


            PdfPCell cellHeaderContent4 = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER
            };
            cellHeaderContent4.AddElement(new Phrase(": " + viewModel.forwarder.fax, normal_font));
            cellHeaderContent4.AddElement(new Phrase(": " + viewModel.InvoiceNo, normal_font));
            cellHeaderContent4.AddElement(new Phrase(": " + viewModel.Date.ToOffset(new TimeSpan(timeoffset, 0, 0)).ToString("dd MMMM yyyy", new System.Globalization.CultureInfo("en-EN")), normal_font));
            tableHeader.AddCell(cellHeaderContent4);

            document.Add(tableHeader);
            #endregion

            Paragraph sub = new Paragraph("SUBJECT : SHIPPING INSTRUCTION", header_font);
            sub.Alignment = Element.ALIGN_CENTER;
            document.Add(sub);

            document.Add(new Paragraph("DEAR SIRS,", normal_font));
            document.Add(new Paragraph("WE REQUEST YOU TO ARRANGE THE FOLLOWING SHIPMENT", normal_font));

            document.Add(new Paragraph("\n", normal_font));
            document.Add(new Paragraph($"{invoice.Description}", normal_font));
            document.Add(new Paragraph("\n", normal_font));

            #region detail
            PdfPTable detailTable = new PdfPTable(3);
            detailTable.HorizontalAlignment = Element.ALIGN_LEFT;
            float[] detailTableWidths = new float[] { 2.5f, 0.5f, 6f };
            detailTable.SetWidths(detailTableWidths);
            detailTable.WidthPercentage = 100;

            PdfPCell cellLeft = new PdfPCell()
            {
                MinimumHeight = 15, Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT
            };

            double qty = 0;
            foreach (var invItem in invoice.Items)
            {
                qty += invItem.Quantity;
            }

            cellLeft.Phrase = new Phrase("QUANTITY", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(string.Format("{0:n0}", qty), normal_font);
            detailTable.AddCell(cellLeft);

            cellLeft.Phrase = new Phrase("GROSS WEIGHT", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase($"{string.Format("{0:n2}", pl.GrossWeight)} KGS", normal_font);
            detailTable.AddCell(cellLeft);

            cellLeft.Phrase = new Phrase("NETT WEIGHT", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase($"{string.Format("{0:n2}", pl.NettWeight)} KGS", normal_font);
            detailTable.AddCell(cellLeft);


            cellLeft.Phrase = new Phrase("MEASUREMENT", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            PdfPTable tableMeasurement = new PdfPTable(5);
            tableMeasurement.SetWidths(new float[] { 1f, 1f, 1f, 2f, 2f });
            tableMeasurement.WidthPercentage = 100;

            double totcbm    = 0;
            double volweight = 0;

            PdfPCell cellMeasurement = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT
            };
            if (pl.Measurements.Count > 0)
            {
                foreach (var m in pl.Measurements)
                {
                    double cbm = (m.Length * m.Width * m.Height * m.CartonsQuantity) / 1000000;
                    double vlm = (m.Length * m.Width * m.Height * m.CartonsQuantity) / 6000;

                    cellMeasurement.Phrase      = new Phrase($"{string.Format("{0:n2}", m.Length)} X", normal_font);
                    cellMeasurement.PaddingLeft = 1;
                    tableMeasurement.AddCell(cellMeasurement);

                    cellMeasurement.Phrase = new Phrase($"{string.Format("{0:n2}", m.Width)} X", normal_font);
                    tableMeasurement.AddCell(cellMeasurement);

                    cellMeasurement.Phrase = new Phrase($"{string.Format("{0:n2}", m.Height)} X", normal_font);
                    tableMeasurement.AddCell(cellMeasurement);

                    cellMeasurement.Phrase = new Phrase($"{string.Format("{0:n2}", m.CartonsQuantity)} CTNS = ", normal_font);
                    tableMeasurement.AddCell(cellMeasurement);

                    cellMeasurement.Phrase = new Phrase(string.Format("{0:n2}", cbm) + " CBM", normal_font);
                    tableMeasurement.AddCell(cellMeasurement);

                    totcbm    += cbm;
                    volweight += vlm;
                }

                cellMeasurement.Phrase      = new Phrase("", normal_font);
                cellMeasurement.PaddingLeft = 1;
                tableMeasurement.AddCell(cellMeasurement);

                cellMeasurement.Phrase = new Phrase("", normal_font);
                tableMeasurement.AddCell(cellMeasurement);

                cellMeasurement.Phrase = new Phrase("", normal_font);
                tableMeasurement.AddCell(cellMeasurement);

                cellMeasurement.Phrase = new Phrase("", normal_font);
                tableMeasurement.AddCell(cellMeasurement);

                cellMeasurement.Phrase = new Phrase("---------------------", normal_font);
                tableMeasurement.AddCell(cellMeasurement);

                cellMeasurement.Phrase      = new Phrase("", normal_font);
                cellMeasurement.PaddingLeft = 1;
                tableMeasurement.AddCell(cellMeasurement);

                cellMeasurement.Phrase = new Phrase("", normal_font);
                tableMeasurement.AddCell(cellMeasurement);

                cellMeasurement.Phrase = new Phrase("", normal_font);
                tableMeasurement.AddCell(cellMeasurement);

                cellMeasurement.Phrase = new Phrase("TOTAL CBM = ", normal_font);
                tableMeasurement.AddCell(cellMeasurement);

                cellMeasurement.Phrase = new Phrase(string.Format("{0:n2}", totcbm) + " CBM", normal_font);
                tableMeasurement.AddCell(cellMeasurement);

                cellLeft.AddElement(tableMeasurement);
            }

            detailTable.AddCell(cellLeft);

            cellLeft.Phrase = new Phrase("VOLUME WEIGHT", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase($"{string.Format("{0:n0}", volweight)} KGS", normal_font);
            detailTable.AddCell(cellLeft);

            cellLeft.Phrase = new Phrase("CARTON", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase($"{string.Format("{0:n0}", viewModel.CartonNo)} CTNS", normal_font);
            detailTable.AddCell(cellLeft);

            cellLeft.Phrase = new Phrase("MARKS", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(viewModel.Marks, normal_font);
            detailTable.AddCell(cellLeft);

            cellLeft.Phrase = new Phrase("PORT OF LOADING", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase($"{invoice.From}", normal_font);
            detailTable.AddCell(cellLeft);

            cellLeft.Phrase = new Phrase("PORT OF DISCHARGE", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(viewModel.PortOfDischarge, normal_font);
            detailTable.AddCell(cellLeft);

            cellLeft.Phrase = new Phrase("PLACE OF DELIVERY", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase($"{viewModel.PlaceOfDelivery}", normal_font);
            detailTable.AddCell(cellLeft);

            cellLeft.Phrase = new Phrase("FEEDER VESSEL BY/DATE", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase($"{viewModel.FeederVessel}", normal_font);
            detailTable.AddCell(cellLeft);

            cellLeft.Phrase = new Phrase("OCEAN VESSEL BY/DATE", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase($"{viewModel.OceanVessel}", normal_font);
            detailTable.AddCell(cellLeft);

            cellLeft.Phrase = new Phrase("SHIPPER", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase("PT. DAN LIRIS, JL. MERAPI NO. 23, KELURAHAN BANARAN, KECAMATAN GROGOL,\n" +
                                         "SUKOHARJO 57193, INDONESIA.\n" +
                                         "PHONE : 0271-714400  FAX : 0271-735222", normal_font);
            detailTable.AddCell(cellLeft);

            cellLeft.Phrase = new Phrase("CONSIGNEE", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase($"{viewModel.BuyerAgent.Name} \n" +
                                         $"{viewModel.BuyerAgentAddress}", normal_font);
            detailTable.AddCell(cellLeft);

            cellLeft.Phrase = new Phrase("NOTIFY ADDRESS", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase($"{viewModel.Notify}", normal_font);
            detailTable.AddCell(cellLeft);

            cellLeft.Phrase = new Phrase("BILL OF LADING", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase($"{viewModel.LadingBill}", normal_font);
            detailTable.AddCell(cellLeft);

            string ladingDate = viewModel.LadingDate == DateTimeOffset.MinValue ? "" :
                                viewModel.LadingDate.GetValueOrDefault().ToOffset(new TimeSpan(timeoffset, 0, 0)).ToString("dd MMMM yyyy", new System.Globalization.CultureInfo("en-EN"));

            cellLeft.Phrase = new Phrase("DATE OF BILL OF LADING", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase($"{ladingDate}", normal_font);
            detailTable.AddCell(cellLeft);

            cellLeft.Phrase = new Phrase("FREIGHT", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase($"{viewModel.Freight}", normal_font);
            detailTable.AddCell(cellLeft);

            cellLeft.Phrase = new Phrase("CONTAINER NO.", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(cl == null ? "-" : cl.containerNo, normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase("SHIPPING SEAL.", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(cl == null ? "-" : cl.shippingSeal, normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase("LETTER OF CREDIT NO.", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase($"{pl.LCNo}", normal_font);
            detailTable.AddCell(cellLeft);

            cellLeft.Phrase = new Phrase("ISSUING BANK", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase($"{pl.IssuedBy}", normal_font);
            detailTable.AddCell(cellLeft);

            cellLeft.Phrase = new Phrase("SPECIAL INSTRUCTION", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase(":", normal_font);
            detailTable.AddCell(cellLeft);
            cellLeft.Phrase = new Phrase($"{viewModel.SpecialInstruction}", normal_font);
            detailTable.AddCell(cellLeft);

            document.Add(detailTable);
            #endregion

            #region SIGN
            document.Add(new Paragraph("\n", normal_font));
            document.Add(new Paragraph("THANK YOU,", normal_font));
            document.Add(new Paragraph("WITH BEST REGARDS,", normal_font));
            document.Add(new Paragraph("\n", normal_font));
            document.Add(new Paragraph("\n", normal_font));
            document.Add(new Paragraph("\n", normal_font));
            document.Add(new Paragraph($"{invoice.ShippingStaff}", normal_font));
            #endregion

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

            return(stream);
        }
コード例 #4
0
        private GarmentShippingInstructionViewModel MapToViewModel(GarmentShippingInstructionModel model)
        {
            var vm = new GarmentShippingInstructionViewModel()
            {
                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,

                BuyerAgent = new Buyer
                {
                    Id   = model.BuyerAgentId,
                    Code = model.BuyerAgentCode,
                    Name = model.BuyerAgentName,
                },
                forwarder = new Forwarder
                {
                    id      = model.ForwarderId,
                    address = model.ForwarderAddress,
                    //attn=model.ATTN,
                    code  = model.ForwarderCode,
                    fax   = model.Fax,
                    name  = model.ForwarderName,
                    phone = model.ForwarderPhone
                },
                BankAccountId     = model.BankAccountId,
                BankAccountName   = model.BankAccountName,
                BuyerAgentAddress = model.BuyerAgentAddress,
                Carrier           = model.Carrier,
                CartonNo          = model.CartonNo,
                ATTN               = model.ATTN,
                CC                 = model.CC,
                Date               = model.Date,
                FeederVessel       = model.FeederVessel,
                Flight             = model.Flight,
                InvoiceNo          = model.InvoiceNo,
                Notify             = model.Notify,
                OceanVessel        = model.OceanVessel,
                InvoiceId          = model.InvoiceId,
                Phone              = model.Phone,
                PlaceOfDelivery    = model.PlaceOfDelivery,
                PortOfDischarge    = model.PortOfDischarge,
                ShippedBy          = model.ShippedBy,
                ShippingStaffId    = model.ShippingStaffId,
                ShippingStaffName  = model.ShippingStaffName,
                SpecialInstruction = model.SpecialInstruction,
                Transit            = model.Transit,
                TruckingDate       = model.TruckingDate,
                LadingDate         = model.LadingDate,
                LadingBill         = model.LadingBill,
                Freight            = model.Freight,
                Marks              = model.Marks
            };

            return(vm);
        }
コード例 #5
0
        public async Task <int> Update(int id, GarmentShippingInstructionViewModel viewModel)
        {
            GarmentShippingInstructionModel garmentShippingInstructionModel = MapToModel(viewModel);

            return(await _shippingInstructionRepository.UpdateAsync(id, garmentShippingInstructionModel));
        }