feat: add HasLockedInvoiceAsync method to check invoice status and prevent scheme application

This commit is contained in:
2026-10-22 10:40:43 +05:30
parent e84ce29064
commit fdfca7cf5e
3 changed files with 8 additions and 0 deletions
@@ -52,6 +52,10 @@ public class SchemeRepository(AppDBContext context) : ISchemeRepository
public async Task<bool> HasRedemptionAsync(Guid schemeId, Guid shopPOId) =>
await context.SchemeRedemptions.AnyAsync(r => r.FK_SchemeId == schemeId && r.FK_ShopPOId == shopPOId);
// An invoice past Draft (printed or finalized) has a fixed amount, so it can no longer take a discount.
public async Task<bool> HasLockedInvoiceAsync(Guid shopPOId) =>
await context.Invoices.AnyAsync(i => i.FK_ShopPOId == shopPOId && i.IsActive && i.Status != Models.InvoiceStatus.Draft);
public async Task<Models.SchemeBundleComponent?> GetBundleComponentAsync(Guid schemeId, Guid itemId) =>
await context.SchemeBundleComponents
.FirstOrDefaultAsync(c => c.FK_SchemeId == schemeId && c.FK_ItemId == itemId);