6 Commits

33 changed files with 4238 additions and 141 deletions
@@ -7,6 +7,7 @@ public class CreateDeliveryNoteDto
public DateOnly ExpeditionDate { get; set; }
public int DelivererId { get; set; }
public int SupplierId { get; set; }
public Dictionary<int, int>? ProductQuantities { get; set; }
}
@@ -7,5 +7,6 @@ public class GetPurchaseOrderDto
public int Id { get; set; }
public string? PurchaseConditions { get; set; }
public int SupplierId { get; set; }
public string? SupplierName { get; set; }
public List<GetPurchaseProductDto>? Products { get; set; }
}
@@ -14,6 +14,8 @@ public class GetPurchaseProductDto
public string? ProductLink { get; set; }
public int ProductMinimalQuantity { get; set; }
public decimal ProductPrice { get; set; }
public int PurchaseOrderId { get; set; }
public int Quantity { get; set; }
}
@@ -15,4 +15,6 @@ public class GetQuotationProductDto
public string? ProductImage { get; set; }
public string? ProductLink { get; set; }
public int ProductMinimalQuantity { get; set; }
public decimal ProductPrice { get; set; }
public int QuotationId { get; set; }
}
@@ -2,6 +2,5 @@ namespace PyroFetes.DTO.SettingDTO.Request;
public class PatchSettingElectronicSignatureDto
{
public int Id { get; set; }
public IFormFile? ElectronicSignature { get; set; }
}
@@ -2,6 +2,5 @@ namespace PyroFetes.DTO.SettingDTO.Request;
public class PatchSettingLogoDto
{
public int Id { get; set; }
public IFormFile? Logo { get; set; }
}
@@ -4,6 +4,7 @@ using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Deliverers;
using PyroFetes.Specifications.Products;
using PyroFetes.Specifications.Suppliers;
namespace PyroFetes.Endpoints.DeliveryNotes;
@@ -11,6 +12,7 @@ public class CreateDeliveryNoteEndpoint(
DeliveryNotesRepository deliveryNotesRepository,
DeliverersRepository deliverersRepository,
ProductsRepository productsRepository,
SuppliersRepository suppliersRepository,
ProductDeliveriesRepository productDeliveriesRepository) : Endpoint<CreateDeliveryNoteDto>
{
public override void Configure()
@@ -22,7 +24,8 @@ public class CreateDeliveryNoteEndpoint(
public override async Task HandleAsync(CreateDeliveryNoteDto req, CancellationToken ct)
{
Deliverer? deliverer = await deliverersRepository.SingleOrDefaultAsync(new GetDelivererByIdSpec(req.DelivererId), ct);
if (deliverer is null)
Supplier? supplier = await suppliersRepository.SingleOrDefaultAsync(new GetSupplierByIdSpec(req.SupplierId), ct);
if (deliverer is null || supplier is null)
{
await Send.NotFoundAsync(ct);
return;
@@ -36,6 +39,8 @@ public class CreateDeliveryNoteEndpoint(
ExpeditionDate = req.ExpeditionDate,
DelivererId = deliverer.Id,
Deliverer = deliverer,
SupplierId = req.SupplierId,
Supplier = supplier
};
await deliveryNotesRepository.AddAsync(newDeliveryNote, ct);
@@ -23,6 +23,7 @@ public class CreatePurchaseOrder(
public override async Task HandleAsync(CreatePurchaseOrderDto req, CancellationToken ct)
{
PurchaseOrder purchaseOrder = mapper.Map<PurchaseOrder>(req);
await purchaseOrdersRepository.AddAsync(purchaseOrder, ct);
if (req.Products != null)
{
@@ -49,8 +50,6 @@ public class CreatePurchaseOrder(
await purchaseProductsRepository.AddAsync(productOnPurchase, ct);
}
}
await purchaseOrdersRepository.AddAsync(purchaseOrder, ct);
await Send.NoContentAsync(ct);
}
}
@@ -1,6 +1,5 @@
using FastEndpoints;
using PyroFetes.DTO.Quotation.Request;
using PyroFetes.DTO.Quotation.Response;
using PyroFetes.DTO.QuotationProduct.Request;
using PyroFetes.Models;
using PyroFetes.Repositories;
@@ -25,6 +24,7 @@ public class CreateQuotationEndpoint(
{
Quotation quotation = mapper.Map<Quotation>(req);
quotation.CustomerId = 1; // TODO: A changer
await quotationsRepository.AddAsync(quotation, ct);
if (req.Products != null)
{
@@ -43,6 +43,7 @@ public class CreateQuotationEndpoint(
if (quotationProduct is not null)
{
await Send.StringAsync("Le produit est déjà dans le devis", 400, cancellation: ct);
return;
}
QuotationProduct? productOnQuotation = mapper.Map<QuotationProduct>(line);
@@ -51,8 +52,7 @@ public class CreateQuotationEndpoint(
await quotationProductsRepository.AddAsync(productOnQuotation, ct);
}
}
await quotationsRepository.AddAsync(quotation, ct);
await Send.NoContentAsync(ct);
}
}
@@ -1,6 +1,5 @@
using FastEndpoints;
using PyroFetes.DTO.Quotation.Request;
using PyroFetes.DTO.Quotation.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Quotations;
@@ -1,35 +0,0 @@
using FastEndpoints;
using PyroFetes.DTO.SettingDTO.Request;
using PyroFetes.Models;
using PyroFetes.Repositories;
namespace PyroFetes.Endpoints.Settings;
public class CreateSettingEndpoint(SettingsRepository settingsRepository) : Endpoint<CreateSettingDto>
{
public override void Configure()
{
Post("/settings");
AllowAnonymous();
}
public override async Task HandleAsync(CreateSettingDto req, CancellationToken ct)
{
// Encodage en base64
using MemoryStream memoryStream = new();
if (req.Logo != null) await req.Logo.CopyToAsync(memoryStream, ct);
byte[] logoBytes = memoryStream.ToArray();
if (req.ElectronicSignature != null) await req.ElectronicSignature.CopyToAsync(memoryStream, ct);
byte[] signatureBytes = memoryStream.ToArray();
Setting setting = new()
{
ElectronicSignature = Convert.ToBase64String(signatureBytes),
Logo = Convert.ToBase64String(logoBytes)
};
await settingsRepository.AddAsync(setting, ct);
await Send.NoContentAsync(ct);
}
}
@@ -1,34 +0,0 @@
using FastEndpoints;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Settings;
namespace PyroFetes.Endpoints.Settings;
public class DeleteSettingRequest
{
public int Id { get; set; }
}
public class DeleteSettingEndpoint(SettingsRepository settingsRepository) : Endpoint<DeleteSettingRequest>
{
public override void Configure()
{
Delete("/settings/{@Id}", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(DeleteSettingRequest req, CancellationToken ct)
{
Setting? setting = await settingsRepository.SingleOrDefaultAsync(new GetSettingByIdSpec(req.Id), ct);
if (setting is null)
{
await Send.NotFoundAsync(ct);
return;
}
await settingsRepository.DeleteAsync(setting, ct);
await Send.NoContentAsync(ct);
}
}
@@ -2,28 +2,20 @@
using PyroFetes.DTO.SettingDTO.Response;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Settings;
namespace PyroFetes.Endpoints.Settings;
public class GetSettingRequest
{
public int Id { get; set; }
}
public class GetSettingEndpoint(
SettingsRepository settingsRepository,
AutoMapper.IMapper mapper) : Endpoint<GetSettingRequest, GetSettingDto>
public class GetSettingEndpoint(SettingsRepository settingsRepository, AutoMapper.IMapper mapper) : EndpointWithoutRequest<GetSettingDto>
{
public override void Configure()
{
Get("/settings/{@Id}", x => new { x.Id });
Get("/settings/");
AllowAnonymous();
}
public override async Task HandleAsync(GetSettingRequest req, CancellationToken ct)
public override async Task HandleAsync(CancellationToken ct)
{
Setting? setting = await settingsRepository.SingleOrDefaultAsync(new GetSettingByIdSpec(req.Id), ct);
Setting? setting = await settingsRepository.FirstOrDefaultAsync(ct);
if (setting is null)
{
@@ -2,7 +2,6 @@
using PyroFetes.DTO.SettingDTO.Request;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Settings;
namespace PyroFetes.Endpoints.Settings;
@@ -10,13 +9,14 @@ public class PatchSettingElectronicSignatureEndpoint(SettingsRepository settings
{
public override void Configure()
{
Patch("/settings/{@Id}/ElectronicSignature", x => new { x.Id });
Patch("/settings/electronicSignature");
AllowFormData();
AllowAnonymous();
}
public override async Task HandleAsync(PatchSettingElectronicSignatureDto req, CancellationToken ct)
{
Setting? setting = await settingsRepository.SingleOrDefaultAsync(new GetSettingByIdSpec(req.Id), ct);
Setting? setting = await settingsRepository.FirstOrDefaultAsync(ct);
if (setting is null)
{
@@ -2,7 +2,6 @@
using PyroFetes.DTO.SettingDTO.Request;
using PyroFetes.Models;
using PyroFetes.Repositories;
using PyroFetes.Specifications.Settings;
namespace PyroFetes.Endpoints.Settings;
@@ -10,13 +9,14 @@ public class PatchSettingLogoEndpoint(SettingsRepository settingsRepository) : E
{
public override void Configure()
{
Patch("/settings/{@Id}/logo", x => new { x.Id });
Patch("/settings/logo");
AllowFormData();
AllowAnonymous();
}
public override async Task HandleAsync(PatchSettingLogoDto req, CancellationToken ct)
{
Setting? setting = await settingsRepository.SingleOrDefaultAsync(new GetSettingByIdSpec(req.Id), ct);
Setting? setting = await settingsRepository.FirstOrDefaultAsync(ct);
if (setting is null)
{
@@ -44,6 +44,7 @@ public class DtoToEntityMappings : Profile
.ForMember(dest => dest.Id, opt => opt.Ignore());
CreateMap<CreatePurchaseProductDto, PurchaseProduct>();
CreateMap<CreatePurchaseOrderProductDto, PurchaseProduct>();
CreateMap<PatchPurchaseProductQuantityDto, PurchaseProduct>()
.ForMember(dest => dest.ProductId, opt => opt.Ignore())
.ForMember(dest => dest.PurchaseOrderId, opt => opt.Ignore());
@@ -52,7 +53,10 @@ public class DtoToEntityMappings : Profile
.ForMember(dest => dest.Id, opt => opt.Ignore());
CreateMap<PatchQuotationMessageDto, Quotation>()
.ForMember(dest => dest.Id, opt => opt.Ignore());
CreateMap<CreateProductQuotationDto, Quotation>();
CreateMap<CreateQuotationDto, Quotation>();
CreateMap<CreateProductQuotationDto, QuotationProduct>();
CreateMap<UpdateQuotationDto, Quotation>()
.ForMember(dest => dest.Id, opt => opt.Ignore());
CreateMap<AddQuotationProductDto, QuotationProduct>();
CreateMap<PatchQuotationProductQuantityDto, QuotationProduct>()
@@ -35,15 +35,22 @@ public class EntityToDtoMappings : Profile
CreateMap<ProductDelivery, GetProductDeliveryDto>();
CreateMap<PurchaseOrder, GetPurchaseOrderDto>()
.ForMember(dest => dest.SupplierName, opt => opt.MapFrom(src => src.Supplier!.Name))
.ForMember(dest => dest.Products, opt => opt.MapFrom(src => src.PurchaseProducts));
CreateMap<PurchaseProduct, GetPurchaseProductDto>();
CreateMap<PurchaseProduct, GetPurchaseProductDto>()
.ForMember(dest => dest.ProductPrice,
opt => opt.MapFrom(src =>
src.Product!.Prices.Where(x => x.SupplierId == src.PurchaseOrder!.SupplierId && x.ProductId == src.ProductId).Select(x => x.SellingPrice).FirstOrDefault()));
CreateMap<Quotation, GetQuotationDto>()
.ForMember(dest => dest.Products, opt => opt.MapFrom(src => src.QuotationProducts));
CreateMap<QuotationProduct, GetQuotationProductDto>();
CreateMap<QuotationProduct, GetQuotationProductDto>()
.ForMember(dest => dest.ProductPrice,
opt => opt.MapFrom(src =>
src.Product!.Prices.Where(x => x.SupplierId == src.Quotation!.SupplierId && x.ProductId == src.ProductId).Select(x => x.SellingPrice).FirstOrDefault()));
CreateMap<Setting, GetSettingDto>();
CreateMap<User, GetUserDto>();
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,50 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PyroFetes.Migrations
{
/// <inheritdoc />
public partial class AddedMissingFieldForSupplierInDocuments : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "SupplierId",
table: "Quotations",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateIndex(
name: "IX_Quotations_SupplierId",
table: "Quotations",
column: "SupplierId");
migrationBuilder.AddForeignKey(
name: "FK_Quotations_Suppliers_SupplierId",
table: "Quotations",
column: "SupplierId",
principalTable: "Suppliers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Quotations_Suppliers_SupplierId",
table: "Quotations");
migrationBuilder.DropIndex(
name: "IX_Quotations_SupplierId",
table: "Quotations");
migrationBuilder.DropColumn(
name: "SupplierId",
table: "Quotations");
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,50 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PyroFetes.Migrations
{
/// <inheritdoc />
public partial class AddedMissingFieldForSupplierInDeliveryNote : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "SupplierId",
table: "DeliveryNotes",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateIndex(
name: "IX_DeliveryNotes_SupplierId",
table: "DeliveryNotes",
column: "SupplierId");
migrationBuilder.AddForeignKey(
name: "FK_DeliveryNotes_Suppliers_SupplierId",
table: "DeliveryNotes",
column: "SupplierId",
principalTable: "Suppliers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_DeliveryNotes_Suppliers_SupplierId",
table: "DeliveryNotes");
migrationBuilder.DropIndex(
name: "IX_DeliveryNotes_SupplierId",
table: "DeliveryNotes");
migrationBuilder.DropColumn(
name: "SupplierId",
table: "DeliveryNotes");
}
}
}
@@ -329,6 +329,9 @@ namespace PyroFetes.Migrations
b.Property<DateOnly?>("RealDeliveryDate")
.HasColumnType("date");
b.Property<int>("SupplierId")
.HasColumnType("int");
b.Property<string>("TrackingNumber")
.IsRequired()
.HasMaxLength(100)
@@ -338,6 +341,8 @@ namespace PyroFetes.Migrations
b.HasIndex("DelivererId");
b.HasIndex("SupplierId");
b.ToTable("DeliveryNotes");
});
@@ -744,10 +749,15 @@ namespace PyroFetes.Migrations
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<int>("SupplierId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CustomerId");
b.HasIndex("SupplierId");
b.ToTable("Quotations");
});
@@ -1348,7 +1358,15 @@ namespace PyroFetes.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PyroFetes.Models.Supplier", "Supplier")
.WithMany("DeliveryNotes")
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Deliverer");
b.Navigation("Supplier");
});
modelBuilder.Entity("PyroFetes.Models.ExperienceLevel", b =>
@@ -1553,7 +1571,7 @@ namespace PyroFetes.Migrations
modelBuilder.Entity("PyroFetes.Models.PurchaseOrder", b =>
{
b.HasOne("PyroFetes.Models.Supplier", "Supplier")
.WithMany()
.WithMany("PurchaseOrders")
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -1588,7 +1606,15 @@ namespace PyroFetes.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PyroFetes.Models.Supplier", "Supplier")
.WithMany("Quotations")
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Customer");
b.Navigation("Supplier");
});
modelBuilder.Entity("PyroFetes.Models.QuotationProduct", b =>
@@ -1956,7 +1982,13 @@ namespace PyroFetes.Migrations
modelBuilder.Entity("PyroFetes.Models.Supplier", b =>
{
b.Navigation("DeliveryNotes");
b.Navigation("Prices");
b.Navigation("PurchaseOrders");
b.Navigation("Quotations");
});
modelBuilder.Entity("PyroFetes.Models.Truck", b =>
+2
View File
@@ -7,10 +7,12 @@ public class DeliveryNote
[Key] public int Id { get; set; }
[Required, MaxLength(100)] public string? TrackingNumber { get; set; }
public int DelivererId { get; set; }
public int SupplierId { get; set; }
[Required] public DateOnly EstimateDeliveryDate { get; set; }
[Required] public DateOnly ExpeditionDate { get; set; }
public DateOnly? RealDeliveryDate { get; set; }
public Deliverer? Deliverer { get; set; }
public Supplier? Supplier { get; set; }
public List<ProductDelivery>? ProductDeliveries { get; set; }
}
+3
View File
@@ -10,6 +10,9 @@ public class Quotation
[Required] public int CustomerId { get; set; }
public Customer? Customer { get; set; }
[Required] public int SupplierId { get; set; }
public Supplier? Supplier { get; set; }
public List<QuotationProduct>? QuotationProducts { get; set; }
}
+4 -1
View File
@@ -13,5 +13,8 @@ public class Supplier
[Required, MaxLength(100)] public string? City { get; set; }
[Required] public int DeliveryDelay { get; set; }
public List<Price>? Prices { get; set; }
public List<Price>? Prices { get; set; }
public List<Quotation>? Quotations { get; set; }
public List<DeliveryNote>? DeliveryNotes { get; set; }
public List<PurchaseOrder>? PurchaseOrders { get; set; }
}
@@ -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} €");
});
});
});
@@ -8,8 +8,11 @@ public class GetDeliveryNoteByIdWithProductsSpec : SingleResultSpecification<Del
public GetDeliveryNoteByIdWithProductsSpec(int deliveryNoteId)
{
Query
.Where(x => x.Id == deliveryNoteId)
.Include(x => x.ProductDeliveries!)
.ThenInclude(p => p.Product);
.ThenInclude(p => p.Product)
.ThenInclude(x => x!.Prices)
.Include(x => x.Deliverer)
.Include(x => x.Supplier)
.Where(x => x.Id == deliveryNoteId);
}
}
@@ -11,6 +11,7 @@ public class GetPurchaseOrderByIdWithProductsSpec : SingleResultSpecification<Pu
.Where(x => x.Id == purchaseOrderId)
.Include(x => x.PurchaseProducts!)
.ThenInclude(p => p.Product)
.ThenInclude(p => p!.Prices);
.ThenInclude(p => p!.Prices)
.Include(x => x.Supplier);
}
}
@@ -10,6 +10,7 @@ public class GetQuotationByIdWithProductsSpec : SingleResultSpecification<Quotat
Query
.Where(x => x.Id == quotationId)
.Include(x => x.QuotationProducts!)
.ThenInclude(p => p.Product);
.ThenInclude(x => x.Product)
.ThenInclude(x => x!.Prices);
}
}
@@ -1,13 +0,0 @@
using Ardalis.Specification;
using PyroFetes.Models;
namespace PyroFetes.Specifications.Settings;
public sealed class GetSettingByIdSpec : SingleResultSpecification<Setting>
{
public GetSettingByIdSpec(int settingId)
{
Query
.Where(setting => setting.Id == settingId);
}
}