forked from sanchezvem/pyrofetes-backend
Refactor all code
This commit is contained in:
@@ -7,18 +7,18 @@ namespace PyroFetes.Services.Pdf;
|
||||
|
||||
public interface IDeliveryNotePdfService
|
||||
{
|
||||
byte[] Generate(DeliveryNote deliveryNote, List<ProductDelivery> lignes);
|
||||
byte[] Generate(DeliveryNote deliveryNote, List<ProductDelivery> lignes, Setting setting);
|
||||
}
|
||||
|
||||
public class DeliveryNotePdfService : IDeliveryNotePdfService
|
||||
{
|
||||
public byte[] Generate(DeliveryNote deliveryNote, List<ProductDelivery> lignes)
|
||||
public byte[] Generate(DeliveryNote deliveryNote, List<ProductDelivery> lignes, Setting setting)
|
||||
{
|
||||
var logoPath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "Images", "logo.jpg");
|
||||
var signaturePath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "Images", "signature.png");
|
||||
byte[] logo = Convert.FromBase64String(setting.Logo!);
|
||||
byte[] signature = Convert.FromBase64String(setting.ElectronicSignature!);
|
||||
int total = 0;
|
||||
int totalQuantity = 0;
|
||||
var document = Document.Create(container =>
|
||||
Document document = Document.Create(container =>
|
||||
{
|
||||
container.Page(page =>
|
||||
{
|
||||
@@ -48,7 +48,7 @@ public class DeliveryNotePdfService : IDeliveryNotePdfService
|
||||
// Logo + société à droite
|
||||
row.ConstantItem(200).Column(col =>
|
||||
{
|
||||
col.Item().AlignRight().Height(70).Image(logoPath, ImageScaling.FitArea);
|
||||
col.Item().AlignRight().Height(70).Image(logo, ImageScaling.FitArea);
|
||||
col.Item().Height(20);
|
||||
col.Item().AlignRight().Text("Pyro-Fêtes").SemiBold();
|
||||
col.Item().Height(5);
|
||||
@@ -93,7 +93,7 @@ public class DeliveryNotePdfService : IDeliveryNotePdfService
|
||||
header.Cell().Element(CellHeader).AlignRight().Text("Total");
|
||||
});
|
||||
|
||||
foreach (var l in lignes)
|
||||
foreach (ProductDelivery l in lignes)
|
||||
{
|
||||
table.Cell().Element(CellBody).Text(l.Product?.Name);
|
||||
table.Cell().Element(CellBody).AlignRight().Text(l.Quantity.ToString());
|
||||
@@ -123,7 +123,7 @@ public class DeliveryNotePdfService : IDeliveryNotePdfService
|
||||
// Signature en bas à droite
|
||||
page.Footer().AlignRight().Column(col =>
|
||||
{
|
||||
col.Item().AlignRight().Height(100).Image(signaturePath, ImageScaling.FitArea);
|
||||
col.Item().AlignRight().Height(100).Image(signature, ImageScaling.FitArea);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,18 +7,18 @@ namespace PyroFetes.Services.Pdf;
|
||||
|
||||
public interface IPurchaseOrderPdfService
|
||||
{
|
||||
byte[] Generate(PurchaseOrder purchaseOrder, List<PurchaseProduct> lignes);
|
||||
byte[] Generate(PurchaseOrder purchaseOrder, List<PurchaseProduct> lignes, Setting setting);
|
||||
}
|
||||
|
||||
public class PurchaseOrderPdfService : IPurchaseOrderPdfService
|
||||
{
|
||||
public byte[] Generate(PurchaseOrder purchaseOrder, List<PurchaseProduct> lignes)
|
||||
public byte[] Generate(PurchaseOrder purchaseOrder, List<PurchaseProduct> lignes, Setting setting)
|
||||
{
|
||||
var logoPath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "Images", "logo.jpg");
|
||||
var signaturePath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "Images", "signature.png");
|
||||
byte[] logo = Convert.FromBase64String(setting.Logo!);
|
||||
byte[] signature = Convert.FromBase64String(setting.ElectronicSignature!);
|
||||
int totalQuantity = 0;
|
||||
decimal total = 0;
|
||||
var document = Document.Create(container =>
|
||||
Document document = Document.Create(container =>
|
||||
{
|
||||
container.Page(page =>
|
||||
{
|
||||
@@ -42,7 +42,7 @@ public class PurchaseOrderPdfService : IPurchaseOrderPdfService
|
||||
// Logo + société à droite
|
||||
row.ConstantItem(200).Column(col =>
|
||||
{
|
||||
col.Item().AlignRight().Height(70).Image(logoPath, ImageScaling.FitArea);
|
||||
col.Item().AlignRight().Height(70).Image(logo, ImageScaling.FitArea);
|
||||
col.Item().Height(20);
|
||||
col.Item().AlignRight().Text("Pyro-Fêtes").SemiBold();
|
||||
col.Item().Height(5);
|
||||
@@ -90,7 +90,7 @@ public class PurchaseOrderPdfService : IPurchaseOrderPdfService
|
||||
header.Cell().Element(CellHeader).AlignRight().Text("Total");
|
||||
});
|
||||
|
||||
foreach (var l in lignes)
|
||||
foreach (PurchaseProduct l in lignes)
|
||||
{
|
||||
decimal price = l.Product!.Prices!
|
||||
.FirstOrDefault(p => p.SupplierId == l.PurchaseOrder!.SupplierId)
|
||||
@@ -140,7 +140,7 @@ public class PurchaseOrderPdfService : IPurchaseOrderPdfService
|
||||
// Signature en bas à droite
|
||||
page.Footer().AlignRight().Column(col =>
|
||||
{
|
||||
col.Item().AlignRight().Height(100).Image(signaturePath, ImageScaling.FitArea);
|
||||
col.Item().AlignRight().Height(100).Image(signature, ImageScaling.FitArea);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using PyroFetes.Models;
|
||||
using QuestPDF.Companion;
|
||||
using QuestPDF.Fluent;
|
||||
using QuestPDF.Helpers;
|
||||
using QuestPDF.Infrastructure;
|
||||
@@ -8,17 +7,17 @@ namespace PyroFetes.Services.Pdf;
|
||||
|
||||
public interface IQuotationPdfService
|
||||
{
|
||||
byte[] Generate(Quotation quotation, List<QuotationProduct> lignes);
|
||||
byte[] Generate(Quotation quotation, List<QuotationProduct> lignes, Setting setting);
|
||||
}
|
||||
|
||||
public class QuotationPdfService : IQuotationPdfService
|
||||
{
|
||||
public byte[] Generate(Quotation quotation, List<QuotationProduct> lignes)
|
||||
public byte[] Generate(Quotation quotation, List<QuotationProduct> lignes, Setting setting)
|
||||
{
|
||||
var logoPath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "Images", "logo.jpg");
|
||||
var signaturePath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "Images", "signature.png");
|
||||
byte[] logo = Convert.FromBase64String(setting.Logo!);
|
||||
byte[] signature = Convert.FromBase64String(setting.ElectronicSignature!);
|
||||
int total = 0;
|
||||
var document = Document.Create(container =>
|
||||
Document document = Document.Create(container =>
|
||||
{
|
||||
container.Page(page =>
|
||||
{
|
||||
@@ -42,7 +41,7 @@ public class QuotationPdfService : IQuotationPdfService
|
||||
// Logo + société à droite
|
||||
row.ConstantItem(200).Column(col =>
|
||||
{
|
||||
col.Item().AlignRight().Height(70).Image(logoPath, ImageScaling.FitArea);
|
||||
col.Item().AlignRight().Height(70).Image(logo, ImageScaling.FitArea);
|
||||
col.Item().Height(20);
|
||||
col.Item().AlignRight().Text("Pyro-Fêtes").SemiBold();
|
||||
col.Item().Height(5);
|
||||
@@ -90,7 +89,7 @@ public class QuotationPdfService : IQuotationPdfService
|
||||
header.Cell().Element(CellHeader).AlignRight().Text("Total");
|
||||
});
|
||||
|
||||
foreach (var l in lignes)
|
||||
foreach (QuotationProduct l in lignes)
|
||||
{
|
||||
table.Cell().Element(CellBody).Text(l.Product?.Name);
|
||||
table.Cell().Element(CellBody).AlignRight().Text(l.Quantity.ToString());
|
||||
@@ -134,7 +133,7 @@ public class QuotationPdfService : IQuotationPdfService
|
||||
// Signature en bas à droite
|
||||
page.Footer().AlignRight().Column(col =>
|
||||
{
|
||||
col.Item().AlignRight().Height(100).Image(signaturePath, ImageScaling.FitArea);
|
||||
col.Item().AlignRight().Height(100).Image(signature, ImageScaling.FitArea);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user