using FruitBank.Common.Entities; namespace Nop.Plugin.Misc.FruitBankPlugin.Services; public interface ICustomerCreditService { /// Gets the credit record for a customer, or null if none exists (= unlimited). Task GetByCustomerIdAsync(int customerId); /// Insert or update a customer credit record. Task SaveAsync(CustomerCredit entity); /// Delete the credit record for a customer, restoring unlimited access. Task DeleteAsync(CustomerCredit entity); /// /// Sum of OrderTotal for all pending/unpaid, non-cancelled orders for the customer. /// Task GetOutstandingBalanceAsync(int customerId); /// /// CreditLimit - OutstandingBalance. Returns null if no credit record exists (= unlimited). /// Task GetRemainingCreditAsync(int customerId); /// /// Returns true if the customer is allowed to place a new order with the given total. /// Rule: no credit record = always allowed. /// Otherwise: OutstandingBalance + newOrderTotal must be <= CreditLimit. /// Task IsOrderAllowedAsync(int customerId, decimal newOrderTotal); }