Fixed error of display with price of product in all documents

This commit is contained in:
2026-05-25 16:38:33 +01:00
parent 48b9db6e1c
commit 3cb619cfa6
12 changed files with 2128 additions and 27 deletions
@@ -16,7 +16,7 @@ public class DeliveryNotePdfService : IDeliveryNotePdfService
{
byte[] logo = Convert.FromBase64String(setting.Logo!);
byte[] signature = Convert.FromBase64String(setting.ElectronicSignature!);
int total = 0;
decimal total = 0;
int totalQuantity = 0;
Document document = Document.Create(container =>
{
@@ -42,7 +42,7 @@ public class DeliveryNotePdfService : IDeliveryNotePdfService
col.Item().Height(5);
col.Item().AlignLeft().Text($"Estimée au {deliveryNote.EstimateDeliveryDate}");
col.Item().Height(5);
col.Item().AlignLeft().Text($"Reçu le {deliveryNote.RealDeliveryDate}");
col.Item().AlignLeft().Text(deliveryNote.RealDeliveryDate is null ? "Pas encore arrivée à destination" : $"Reçu le {deliveryNote.RealDeliveryDate}");
});
// Logo + société à droite
@@ -95,13 +95,17 @@ public class DeliveryNotePdfService : IDeliveryNotePdfService
foreach (ProductDelivery l in lignes)
{
decimal price = l.Product!.Prices!
.FirstOrDefault(x => x.SupplierId == l.DeliveryNote!.SupplierId && x.ProductId == l.ProductId)
?.SellingPrice ?? 0;
table.Cell().Element(CellBody).Text(l.Product?.Name);
table.Cell().Element(CellBody).AlignRight().Text(l.Quantity.ToString());
table.Cell().Element(CellBody).AlignRight().Text($"{l.Quantity:n2} €");
table.Cell().Element(CellBody).AlignRight().Text($"{l.Quantity * l.Quantity:n2} €");
table.Cell().Element(CellBody).AlignRight().Text($"{price:n2} €");
table.Cell().Element(CellBody).AlignRight().Text($"{l.Quantity * price:n2} €");
totalQuantity += l.Quantity;
total += l.Quantity * l.Quantity;
total += l.Quantity * price;
}
IContainer CellHeader(IContainer c) =>
@@ -114,10 +118,10 @@ public class DeliveryNotePdfService : IDeliveryNotePdfService
col.Item().LineHorizontal(1);
col.Item().Height(30);
col.Item().AlignRight().Text($"Total: {totalQuantity:n2} produits");
col.Item().AlignRight().Text($"Total: {totalQuantity} produits");
col.Item().AlignRight().Text($"Total HT: {total:n2} €");
col.Item().AlignRight().Text("Taxe : 20 %");
col.Item().AlignRight().Text($"Total TTC: {(total * 1.2):n2} €");
col.Item().AlignRight().Text($"Total TTC: {total * (decimal)1.2:n2} €");
});
// Signature en bas à droite
@@ -35,8 +35,11 @@ public class PurchaseOrderPdfService : IPurchaseOrderPdfService
col.Item().Text("");
col.Item().Text("");
col.Item().Text("");
col.Item().Text("Fournisseur").SemiBold().FontSize(12);
col.Item().Text("Mettre fournisseur ici");
col.Item().Text("Fournisseur :").SemiBold().FontSize(12);
col.Item().Text($"{purchaseOrder.Supplier?.Name}");
col.Item().Text($"{purchaseOrder.Supplier?.Address}");
col.Item().Text($"{purchaseOrder.Supplier?.ZipCode} {purchaseOrder.Supplier?.City}");
col.Item().Text($"{purchaseOrder.Supplier?.DeliveryDelay} jours de délai moyen de livraison");
});
// Logo + société à droite
@@ -93,7 +96,7 @@ public class PurchaseOrderPdfService : IPurchaseOrderPdfService
foreach (PurchaseProduct l in lignes)
{
decimal price = l.Product!.Prices!
.FirstOrDefault(p => p.SupplierId == l.PurchaseOrder!.SupplierId)
.FirstOrDefault(x => x.SupplierId == l.PurchaseOrder!.SupplierId && x.ProductId == l.ProductId)
?.SellingPrice ?? 0;
table.Cell().Element(CellBody).Text(l.Product?.Name);
@@ -129,10 +132,10 @@ public class PurchaseOrderPdfService : IPurchaseOrderPdfService
// Colonne droite : totaux
row.ConstantItem(180).Column(right =>
{
right.Item().AlignRight().Text($"Total: {totalQuantity:n2} produits");
right.Item().AlignRight().Text($"Total: {totalQuantity} produits");
right.Item().AlignRight().Text($"Total HT: {total:n2} €");
right.Item().AlignRight().Text("Taxe: 20 %");
right.Item().AlignRight().Text($"Total TTC: {(total * 1, 2):n2} €");
right.Item().AlignRight().Text($"Total TTC: {total * (decimal)1.2:n2} €");
});
});
});
+11 -9
View File
@@ -16,7 +16,7 @@ public class QuotationPdfService : IQuotationPdfService
{
byte[] logo = Convert.FromBase64String(setting.Logo!);
byte[] signature = Convert.FromBase64String(setting.ElectronicSignature!);
int total = 0;
decimal total = 0;
Document document = Document.Create(container =>
{
container.Page(page =>
@@ -91,19 +91,21 @@ public class QuotationPdfService : IQuotationPdfService
foreach (QuotationProduct l in lignes)
{
decimal price = l.Product!.Prices!
.FirstOrDefault(x => x.SupplierId == l.Quotation!.SupplierId && x.ProductId == l.ProductId)
?.SellingPrice ?? 0;
table.Cell().Element(CellBody).Text(l.Product?.Name);
table.Cell().Element(CellBody).AlignRight().Text(l.Quantity.ToString());
table.Cell().Element(CellBody).AlignRight().Text($"{l.Quantity:n2} €");
table.Cell().Element(CellBody).AlignRight().Text($"{l.Quantity * l.Quantity:n2} €");
table.Cell().Element(CellBody).AlignRight().Text($"{price:n2} €");
table.Cell().Element(CellBody).AlignRight().Text($"{price * l.Quantity:n2} €");
total = total + l.Quantity * l.Quantity;
total += l.Quantity * price;
}
IContainer CellHeader(IContainer c) =>
c.BorderBottom(1).PaddingVertical(5).DefaultTextStyle(x => x.SemiBold());
IContainer CellHeader(IContainer c) => c.BorderBottom(1).PaddingVertical(5).DefaultTextStyle(x => x.SemiBold());
IContainer CellBody(IContainer c) =>
c.PaddingVertical(2);
IContainer CellBody(IContainer c) => c.PaddingVertical(2);
});
col.Item().LineHorizontal(1);
@@ -125,7 +127,7 @@ public class QuotationPdfService : IQuotationPdfService
{
right.Item().AlignRight().Text($"Total HT : {total:n2} €");
right.Item().AlignRight().Text("Taxe : 20 %");
right.Item().AlignRight().Text($"Total TTC : {(total * 1.2):n2} €");
right.Item().AlignRight().Text($"Total TTC : {total * (decimal)1.2:n2} €");
});
});
});