From 6339fbdb8c2f1afaa7aef22a5be9afbb86691dab Mon Sep 17 00:00:00 2001 From: sanchezvem Date: Wed, 27 May 2026 17:23:02 +0100 Subject: [PATCH] Added spec for see all documents order by desc --- .../PurchaseOrders/GetAllPurchaseOrderEndpoint.cs | 3 ++- .../Quotations/GetAllQuotationEndpoint.cs | 3 ++- .../Products/GetProductsUnderLimitSpec.cs | 3 ++- .../PurchaseOrders/GetAllPurchaseOrderSpec.cs | 14 ++++++++++++++ .../Quotations/GetAllQuotationSpec.cs | 14 ++++++++++++++ 5 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 PyroFetes/Specifications/PurchaseOrders/GetAllPurchaseOrderSpec.cs create mode 100644 PyroFetes/Specifications/Quotations/GetAllQuotationSpec.cs diff --git a/PyroFetes/Endpoints/PurchaseOrders/GetAllPurchaseOrderEndpoint.cs b/PyroFetes/Endpoints/PurchaseOrders/GetAllPurchaseOrderEndpoint.cs index 8a3dd58..09d7dcb 100644 --- a/PyroFetes/Endpoints/PurchaseOrders/GetAllPurchaseOrderEndpoint.cs +++ b/PyroFetes/Endpoints/PurchaseOrders/GetAllPurchaseOrderEndpoint.cs @@ -1,6 +1,7 @@ using FastEndpoints; using PyroFetes.DTO.PurchaseOrder.Response; using PyroFetes.Repositories; +using PyroFetes.Specifications.PurchaseOrders; namespace PyroFetes.Endpoints.PurchaseOrders; @@ -14,6 +15,6 @@ public class GetAllPurchaseOrderEndpoint(PurchaseOrdersRepository purchaseOrders public override async Task HandleAsync(CancellationToken ct) { - await Send.OkAsync(await purchaseOrdersRepository.ProjectToListAsync(ct), ct); + await Send.OkAsync(await purchaseOrdersRepository.ProjectToListAsync(new GetAllPurchaseOrderSpec(), ct), ct); } } \ No newline at end of file diff --git a/PyroFetes/Endpoints/Quotations/GetAllQuotationEndpoint.cs b/PyroFetes/Endpoints/Quotations/GetAllQuotationEndpoint.cs index 9d7059d..bccafd3 100644 --- a/PyroFetes/Endpoints/Quotations/GetAllQuotationEndpoint.cs +++ b/PyroFetes/Endpoints/Quotations/GetAllQuotationEndpoint.cs @@ -1,6 +1,7 @@ using FastEndpoints; using PyroFetes.DTO.Quotation.Response; using PyroFetes.Repositories; +using PyroFetes.Specifications.Quotations; namespace PyroFetes.Endpoints.Quotations; @@ -14,6 +15,6 @@ public class GetAllQuotationEndpoint(QuotationsRepository quotationsRepository) public override async Task HandleAsync(CancellationToken ct) { - await Send.OkAsync(await quotationsRepository.ProjectToListAsync(ct), ct); + await Send.OkAsync(await quotationsRepository.ProjectToListAsync(new GetAllQuotationSpec(), ct), ct); } } \ No newline at end of file diff --git a/PyroFetes/Specifications/Products/GetProductsUnderLimitSpec.cs b/PyroFetes/Specifications/Products/GetProductsUnderLimitSpec.cs index 5b3c1f4..df57b0c 100644 --- a/PyroFetes/Specifications/Products/GetProductsUnderLimitSpec.cs +++ b/PyroFetes/Specifications/Products/GetProductsUnderLimitSpec.cs @@ -9,6 +9,7 @@ public sealed class GetProductsUnderLimitSpec : Specification { Query .Include(x => x.WarehouseProducts) - .Where(x => x.WarehouseProducts != null && x.WarehouseProducts.Sum(p => p.Quantity) < x.MinimalQuantity); + .Where(x => x.WarehouseProducts != null && x.WarehouseProducts.Sum(p => p.Quantity) < x.MinimalQuantity + && !x.ProductDeliveries!.Any(d => d.DeliveryNote!.RealDeliveryDate == null)); } } \ No newline at end of file diff --git a/PyroFetes/Specifications/PurchaseOrders/GetAllPurchaseOrderSpec.cs b/PyroFetes/Specifications/PurchaseOrders/GetAllPurchaseOrderSpec.cs new file mode 100644 index 0000000..827d952 --- /dev/null +++ b/PyroFetes/Specifications/PurchaseOrders/GetAllPurchaseOrderSpec.cs @@ -0,0 +1,14 @@ +using Ardalis.Specification; +using PyroFetes.Models; + +namespace PyroFetes.Specifications.PurchaseOrders; + +public class GetAllPurchaseOrderSpec : Specification +{ + public GetAllPurchaseOrderSpec() + { + Query + .Where(x => true) + .OrderByDescending(x => x.Id); + } +} \ No newline at end of file diff --git a/PyroFetes/Specifications/Quotations/GetAllQuotationSpec.cs b/PyroFetes/Specifications/Quotations/GetAllQuotationSpec.cs new file mode 100644 index 0000000..e386950 --- /dev/null +++ b/PyroFetes/Specifications/Quotations/GetAllQuotationSpec.cs @@ -0,0 +1,14 @@ +using Ardalis.Specification; +using PyroFetes.Models; + +namespace PyroFetes.Specifications.Quotations; + +public class GetAllQuotationSpec : Specification +{ + public GetAllQuotationSpec() + { + Query + .Where(x => true) + .OrderByDescending(x => x.Id); + } +} \ No newline at end of file