Esempio n. 1
0
        private float DrawBuyer(InvoicePdfModel model, PdfPage page, float x, float y)
        {
            PdfLayoutResult layoutResult;

            layoutResult = new PdfTextElement("nabywca:", fontNormalItalicUnderline, brushBlack).Draw(page, new PointF(x, y));

            y            = layoutResult.Bounds.Bottom;
            layoutResult = new PdfTextElement(model.Customer.Name, fontNormalBold, brushBlack).Draw(page, new PointF(x, y));

            y            = layoutResult.Bounds.Bottom;
            layoutResult = new PdfTextElement(model.Customer.StreetNumber, fontNormalBold, brushBlack).Draw(page, new PointF(x, y));

            y            = layoutResult.Bounds.Bottom;
            x            = page.Size.Width / 2;
            layoutResult = new PdfTextElement(model.Customer.ZipCode, fontNormalBold, brushBlack).Draw(page, new PointF(x, y));
            x           += layoutResult.Bounds.Width + 4;
            layoutResult = new PdfTextElement(model.Customer.City, fontNormalBold, brushBlack).Draw(page, new PointF(x, y));

            y            = layoutResult.Bounds.Bottom;
            x            = page.Size.Width / 2;
            layoutResult = new PdfTextElement("NIP: ", fontNormalItalic, brushBlack).Draw(page, new PointF(x, y));
            x           += layoutResult.Bounds.Width + 4;
            layoutResult = new PdfTextElement(model.Customer.Nip, fontNormalBold, brushBlack).Draw(page, new PointF(x, y));

            return(layoutResult.Bounds.Bottom);
        }
Esempio n. 2
0
        public async Task <byte[]> GetPdfList(InvoicePdfModel model)
        {
            var reponse = await flurlClient.Request($"/v1/inboxinvoice/pdflist")
                          .PostJsonAsync(model);

            return(await reponse.Content.ReadAsByteArrayAsync());
        }
Esempio n. 3
0
        public async Task <byte[]> GetPdfList(InvoicePdfModel model)
        {
            var response = await flurlClient.Request($"/v1/outboxinvoice/pdflist")
                           .PostJsonAsync(model)
                           .ReceiveBytes();

            return(response);
        }
Esempio n. 4
0
        public byte[] ProForma(InvoicePdfModel model)
        {
            PdfLayoutResult layoutResult;
            string          data;
            float           y        = 30;
            float           x        = 0;
            var             document = new PdfDocument();

            document.PageSettings.Margins.All = marginSize;

            var page = document.Pages.Add();

            data         = $"Faktura PRO FORMA nr {model.Number}";
            layoutResult = new PdfTextElement(data, fontBig, brushBlack).Draw(page, new PointF(x, y));

            data         = $"Data wystawienia: {model.ExposureDate.ToString("yyyy-MM-dd")}";
            y            = layoutResult.Bounds.Bottom;
            x            = page.Size.Width - fontNormal.MeasureString(data).Width - marginSize * 2 - 4;
            layoutResult = new PdfTextElement("data wystawienia:", fontNormalItalic, brushBlack).Draw(page, new PointF(x, y));
            x           += layoutResult.Bounds.Width + 4;
            layoutResult = new PdfTextElement(model.ExposureDate.ToString("yyyy-MM-dd"), fontNormalBold, brushBlack).Draw(page, new PointF(x, y));

            data         = $"Miejsce wystawienia: {model.InvoiceConfig.ExposurePlace}";
            y            = layoutResult.Bounds.Bottom;
            x            = page.Size.Width - fontNormal.MeasureString(data).Width - marginSize * 2 - 4;
            layoutResult = new PdfTextElement("miejsce wystawienia:", fontNormalItalic, brushBlack).Draw(page, new PointF(x, y));
            x           += layoutResult.Bounds.Width + 4;
            layoutResult = new PdfTextElement(model.InvoiceConfig.ExposurePlace, fontNormalBold, brushBlack).Draw(page, new PointF(x, y));

            float section = layoutResult.Bounds.Bottom + 32;

            DrawBuyer(model, page, page.Size.Width / 2, section);

            section = DrawSeller(model, page, 0, section);

            section = section + 48;

            section = DrawProducts(model, page, section);

            section = section + 48;

            section = DrawFooter(model, page, 0, section);

            using (var memoryStream = new MemoryStream())
            {
                document.Save(memoryStream);
                return(memoryStream.ToArray());
            }
        }
Esempio n. 5
0
        private float DrawFooter(InvoicePdfModel model, PdfPage page, float x, float y)
        {
            PdfLayoutResult layoutResult;

            layoutResult = new PdfTextElement("do zapłaty: ", fontNormalItalic, brushBlack).Draw(page, new PointF(x, y));
            x            = layoutResult.Bounds.Width + 4;
            layoutResult = new PdfTextElement($"{model.GrossAmount.ToString("#,##0.00")} zł", fontNormalBold, brushBlack).Draw(page, new PointF(x, y));

            y            = layoutResult.Bounds.Bottom;
            x            = 0;
            layoutResult = new PdfTextElement("słownie: ", fontNormalItalic, brushBlack).Draw(page, new PointF(x, y));
            x            = layoutResult.Bounds.Width + 4;
            layoutResult = new PdfTextElement(model.GrossAmountStringified, fontNormalBold, brushBlack).Draw(page, new PointF(x, y));

            return(layoutResult.Bounds.Bottom);
        }
Esempio n. 6
0
        private async Task <InvoicePdfModel> GetProFormaPdfModel(Guid orderId)
        {
            var orderContract = await query.Get <OrderEntity>().Where(x => x.Id == orderId).SelectOrderContract().SingleAsync();

            var customerContract = await query.Get <CustomerEntity>().Where(x => x.Id == orderContract.CustomerId).SelectCustomerContract().SingleAsync();

            var productContract = await query.Get <ProductEntity>().Where(x => x.Id == orderContract.ProductId).SelectProductContract().SingleAsync();

            var proFormaEntity = await query.SingleAsync <ProFormaEntity>(x => x.OrderId == orderId);

            var invoicePdfModel = new InvoicePdfModel
            {
                Customer               = customerContract,
                InvoiceConfig          = configuration.InvoiceConfiguration,
                ExposureDate           = proFormaEntity.ExposureDate,
                Number                 = proFormaEntity.FullNumber,
                GrossAmountStringified = productContract.GrossPrice.ToStringify(),
                Products               = new List <InvoiceProductPdfModel>
                {
                    new InvoiceProductPdfModel
                    {
                        MeasureUnitCaption = InvoiceConsts.DefaultMeasureUnit,
                        Pkwiu          = string.Empty,
                        Name           = productContract.FullName,
                        Quantity       = orderContract.Quantity,
                        VatRateCaption = productContract.VatRateName,
                        UnitPrice      = productContract.UnitPrice,
                        VatRateValue   = productContract.VatRateValue,
                    }
                },
                Rates = new List <InvoiceVatRatePdfModel>
                {
                    new InvoiceVatRatePdfModel
                    {
                        UnitPrice      = productContract.UnitPrice,
                        Quantity       = orderContract.Quantity,
                        VatRateValue   = productContract.VatRateValue,
                        VatRateCaption = productContract.VatRateName,
                    }
                }
            };

            return(invoicePdfModel);
        }
Esempio n. 7
0
        private InvoicePdfModel GetInvoicePdfModel(Guid invoiceId)
        {
            var invoiceContract  = query.Get <InvoiceEntity>().Where(x => x.LicenceId == invoiceId).SelectInvoiceContract().Single();
            var licenceContract  = query.Get <LicenceEntity>().Where(x => x.Id == invoiceId).SelectLicenceContract().Single();
            var customerContract = query.Get <CustomerEntity>().Where(x => x.Id == licenceContract.CustomerId).SelectCustomerContract().Single();
            var invoicePdfModel  = new InvoicePdfModel
            {
                Customer               = customerContract,
                InvoiceConfig          = configuration.InvoiceConfiguration,
                PaymentTypeCaption     = invoiceContract.PaymentTypeCaption,
                PaymentTypeCode        = invoiceContract.PaymentTypeCode,
                PaymentDays            = invoiceContract.PaymentDays,
                ExposureDate           = invoiceContract.ExposureDate,
                SellDate               = invoiceContract.SellDate,
                Number                 = invoiceContract.Number,
                GrossAmountStringified = licenceContract.ProductGrossPrice.ToStringify(),
                Products               = new List <InvoiceProductPdfModel>
                {
                    new InvoiceProductPdfModel
                    {
                        MeasureUnitCaption = InvoiceConsts.DefaultMeasureUnit,
                        Pkwiu          = string.Empty,
                        Name           = licenceContract.ProductFullName,
                        Quantity       = licenceContract.Quantity,
                        VatRateCaption = licenceContract.ProductVatRateName,
                        UnitPrice      = licenceContract.ProductUnitPrice,
                        VatRateValue   = licenceContract.ProductVatRateValue,
                    }
                },
                Rates = new List <InvoiceVatRatePdfModel>
                {
                    new InvoiceVatRatePdfModel
                    {
                        UnitPrice      = licenceContract.ProductUnitPrice,
                        Quantity       = licenceContract.Quantity,
                        VatRateValue   = licenceContract.ProductVatRateValue,
                        VatRateCaption = licenceContract.ProductVatRateName,
                    }
                }
            };

            return(invoicePdfModel);
        }
Esempio n. 8
0
        private float DrawRates(InvoicePdfModel model, PdfPage page, float y)
        {
            PdfLayoutResult layoutResult;

            layoutResult = new PdfTextElement("ogółem stawkami:", fontSmallItalic, brushBlack).Draw(page, new PointF(0, y));
            y            = layoutResult.Bounds.Bottom + 4;

            float xCol1 = 2;
            float xCol2 = xCol1 + 60;
            float xCol3 = xCol2 + 60;
            float xCol4 = xCol3 + 60;
            float xCol5 = xCol4 + 80;

            float padding = 2;
            float height  = 0;

            layoutResult = new PdfTextElement("Stawka VAT", fontSmallItalic, brushBlack).Draw(page, new PointF(xCol1, y));
            height       = layoutResult.Bounds.Height + padding * 2;
            page.Graphics.DrawRectangle(penGray, xCol1 - padding, y - padding, xCol2 - xCol1, height);
            layoutResult = new PdfTextElement("Wartość netto", fontSmallItalic, brushBlack).Draw(page, new PointF(xCol2, y));
            page.Graphics.DrawRectangle(penGray, xCol2 - padding, y - padding, xCol3 - xCol2, height);
            layoutResult = new PdfTextElement("Kwota VAT", fontSmallItalic, brushBlack).Draw(page, new PointF(xCol3, y));
            page.Graphics.DrawRectangle(penGray, xCol3 - padding, y - padding, xCol4 - xCol3, height);
            layoutResult = new PdfTextElement("Wartość brutto", fontSmallItalic, brushBlack).Draw(page, new PointF(xCol4, y));
            page.Graphics.DrawRectangle(penGray, xCol4 - padding, y - padding, xCol5 - xCol4, height);
            y = layoutResult.Bounds.Bottom + padding * 2;

            foreach (var tax in model.Rates)
            {
                layoutResult = new PdfTextElement(tax.VatRateCaption, fontSmallBold, brushBlack).Draw(page, new PointF(xCol1, y));
                height       = layoutResult.Bounds.Height + padding * 2;
                page.Graphics.DrawRectangle(penGray, xCol1 - padding, y - padding, xCol2 - xCol1, height);
                layoutResult = new PdfTextElement($"{tax.NetAmount.ToString("#,##0.00")} zł", fontSmallBold, brushBlack).Draw(page, new PointF(xCol2, y));
                page.Graphics.DrawRectangle(penGray, xCol2 - padding, y - padding, xCol3 - xCol2, height);
                layoutResult = new PdfTextElement($"{tax.VatAmount.ToString("#,##0.00")} zł", fontSmallBold, brushBlack).Draw(page, new PointF(xCol3, y));
                page.Graphics.DrawRectangle(penGray, xCol3 - padding, y - padding, xCol4 - xCol3, height);
                layoutResult = new PdfTextElement($"{tax.GrossAmount.ToString("#,##0.00")} zł", fontSmallBold, brushBlack).Draw(page, new PointF(xCol4, y));
                page.Graphics.DrawRectangle(penGray, xCol4 - padding, y - padding, xCol5 - xCol4, height);
                y = layoutResult.Bounds.Bottom;
            }
            return(layoutResult.Bounds.Bottom);
        }
Esempio n. 9
0
        private float DrawSeller(InvoicePdfModel model, PdfPage page, float x, float y)
        {
            PdfLayoutResult layoutResult;

            layoutResult = new PdfTextElement("sprzedawca:", fontNormalItalicUnderline, brushBlack).Draw(page, new PointF(x, y));

            y            = layoutResult.Bounds.Bottom;
            layoutResult = new PdfTextElement(model.InvoiceConfig.Seller.Name, fontNormalBold, brushBlack).Draw(page, new PointF(x, y));

            y            = layoutResult.Bounds.Bottom;
            layoutResult = new PdfTextElement("NIP: ", fontNormalItalic, brushBlack).Draw(page, new PointF(x, y));
            x            = layoutResult.Bounds.Width + 4;
            layoutResult = new PdfTextElement(model.InvoiceConfig.Seller.Nip, fontNormalBold, brushBlack).Draw(page, new PointF(x, y));

            y            = layoutResult.Bounds.Bottom;
            x            = 0;
            layoutResult = new PdfTextElement(model.InvoiceConfig.Seller.StreetNumber, fontNormalBold, brushBlack).Draw(page, new PointF(x, y));

            y            = layoutResult.Bounds.Bottom;
            x            = 0;
            layoutResult = new PdfTextElement(model.InvoiceConfig.Seller.ZipCode, fontNormalBold, brushBlack).Draw(page, new PointF(x, y));
            x            = layoutResult.Bounds.Width + 4;
            layoutResult = new PdfTextElement(model.InvoiceConfig.Seller.City, fontNormalBold, brushBlack).Draw(page, new PointF(x, y));

            y            = layoutResult.Bounds.Bottom;
            x            = 0;
            layoutResult = new PdfTextElement("nr konta: ", fontNormalItalic, brushBlack).Draw(page, new PointF(x, y));
            x            = layoutResult.Bounds.Width + 4;
            layoutResult = new PdfTextElement(model.InvoiceConfig.Seller.AccountNumber, fontNormalBold, brushBlack).Draw(page, new PointF(x, y));

            y            = layoutResult.Bounds.Bottom;
            x            = 0;
            layoutResult = new PdfTextElement(model.InvoiceConfig.Seller.Bank, fontNormalBold, brushBlack).Draw(page, new PointF(x, y));

            return(layoutResult.Bounds.Bottom);
        }
Esempio n. 10
0
        private float DrawProducts(InvoicePdfModel model, PdfPage page, float y)
        {
            PdfLayoutResult layoutResult;
            float           xCol1  = 2;
            float           xCol2  = 16;
            float           xCol3  = xCol2 + 140;
            float           xCol4  = xCol3 + 40;
            float           xCol5  = xCol4 + 30;
            float           xCol6  = xCol5 + 30;
            float           xCol7  = xCol6 + 50;
            float           xCol8  = xCol7 + 60;
            float           xCol9  = xCol8 + 60;
            float           xCol10 = xCol9 + 50;

            float padding = 2;
            float height  = 0;

            layoutResult = new PdfTextElement("#", fontSmallItalic, brushBlack).Draw(page, new PointF(xCol1, y));
            height       = layoutResult.Bounds.Height + padding * 2;
            page.Graphics.DrawRectangle(penGray, xCol1 - padding, y - padding, xCol2 - xCol1, height);
            layoutResult = new PdfTextElement("Nazwa", fontSmallItalic, brushBlack).Draw(page, new PointF(xCol2, y));
            page.Graphics.DrawRectangle(penGray, xCol2 - padding, y - padding, xCol3 - xCol2, height);
            layoutResult = new PdfTextElement("PKWiU", fontSmallItalic, brushBlack).Draw(page, new PointF(xCol3, y));
            page.Graphics.DrawRectangle(penGray, xCol3 - padding, y - padding, xCol4 - xCol3, height);
            layoutResult = new PdfTextElement("Ilość", fontSmallItalic, brushBlack).Draw(page, new PointF(xCol4, y));
            page.Graphics.DrawRectangle(penGray, xCol4 - padding, y - padding, xCol5 - xCol4, height);
            layoutResult = new PdfTextElement("Jm.", fontSmallItalic, brushBlack).Draw(page, new PointF(xCol5, y));
            page.Graphics.DrawRectangle(penGray, xCol5 - padding, y - padding, xCol6 - xCol5, height);
            layoutResult = new PdfTextElement("Cena jedn.", fontSmallItalic, brushBlack).Draw(page, new PointF(xCol6, y));
            page.Graphics.DrawRectangle(penGray, xCol6 - padding, y - padding, xCol7 - xCol6, height);
            layoutResult = new PdfTextElement("Stawka VAT", fontSmallItalic, brushBlack).Draw(page, new PointF(xCol7, y));
            page.Graphics.DrawRectangle(penGray, xCol7 - padding, y - padding, xCol8 - xCol7, height);
            layoutResult = new PdfTextElement("Wartość netto", fontSmallItalic, brushBlack).Draw(page, new PointF(xCol8, y));
            page.Graphics.DrawRectangle(penGray, xCol8 - padding, y - padding, xCol9 - xCol8, height);
            layoutResult = new PdfTextElement("Kwota VAT", fontSmallItalic, brushBlack).Draw(page, new PointF(xCol9, y));
            page.Graphics.DrawRectangle(penGray, xCol9 - padding, y - padding, xCol10 - xCol9, height);
            layoutResult = new PdfTextElement("Wartość brutto", fontSmallItalic, brushBlack).Draw(page, new PointF(xCol10, y));
            page.Graphics.DrawRectangle(penGray, xCol10 - padding, y - padding, page.Size.Width - marginSize * 2 - xCol10, height);

            float section = layoutResult.Bounds.Bottom + padding * 2;
            int   counter = 0;

            y = section;
            foreach (var product in model.Products)
            {
                layoutResult = new PdfTextElement($"{(++counter).ToString()}.", fontSmallBold, brushBlack).Draw(page, new PointF(xCol1, y));
                height       = layoutResult.Bounds.Height + padding * 2;
                page.Graphics.DrawRectangle(penGray, xCol1 - padding, y - padding, xCol2 - xCol1, height);
                layoutResult = new PdfTextElement(product.Name, fontSmallBold, brushBlack).Draw(page, new PointF(xCol2, y));
                page.Graphics.DrawRectangle(penGray, xCol2 - padding, y - padding, xCol3 - xCol2, height);
                layoutResult = new PdfTextElement(string.Empty, fontSmallBold, brushBlack).Draw(page, new PointF(xCol3, y));
                page.Graphics.DrawRectangle(penGray, xCol3 - padding, y - padding, xCol4 - xCol3, height);
                layoutResult = new PdfTextElement(product.Quantity.ToString("0"), fontSmallBold, brushBlack).Draw(page, new PointF(xCol4, y));
                page.Graphics.DrawRectangle(penGray, xCol4 - padding, y - padding, xCol5 - xCol4, height);
                layoutResult = new PdfTextElement(product.MeasureUnitCaption, fontSmallBold, brushBlack).Draw(page, new PointF(xCol5, y));
                page.Graphics.DrawRectangle(penGray, xCol5 - padding, y - padding, xCol6 - xCol5, height);
                layoutResult = new PdfTextElement($"{product.UnitPrice.ToString("#,##0.00")} zł", fontSmallBold, brushBlack).Draw(page, new PointF(xCol6, y));
                page.Graphics.DrawRectangle(penGray, xCol6 - padding, y - padding, xCol7 - xCol6, height);
                layoutResult = new PdfTextElement(product.VatRateCaption, fontSmallBold, brushBlack).Draw(page, new PointF(xCol7, y));
                page.Graphics.DrawRectangle(penGray, xCol7 - padding, y - padding, xCol8 - xCol7, height);
                layoutResult = new PdfTextElement($"{product.NetAmount.ToString("#,##0.00")} zł", fontSmallBold, brushBlack).Draw(page, new PointF(xCol8, y));
                page.Graphics.DrawRectangle(penGray, xCol8 - padding, y - padding, xCol9 - xCol8, height);
                layoutResult = new PdfTextElement($"{product.VatAmount.ToString("#,##0.00")} zł", fontSmallBold, brushBlack).Draw(page, new PointF(xCol9, y));
                page.Graphics.DrawRectangle(penGray, xCol9 - padding, y - padding, xCol10 - xCol9, height);
                layoutResult = new PdfTextElement($"{product.GrossAmount.ToString("#,##0.00")} zł", fontSmallBold, brushBlack).Draw(page, new PointF(xCol10, y));
                page.Graphics.DrawRectangle(penGray, xCol10 - padding, y - padding, page.Size.Width - marginSize * 2 - xCol10, height);
                y = layoutResult.Bounds.Bottom;
            }
            return(layoutResult.Bounds.Bottom);
        }