33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
using FruitBank.Common.Entities;
|
|
|
|
namespace Nop.Plugin.Misc.FruitBankPlugin.Services;
|
|
|
|
public interface ICustomerCreditService
|
|
{
|
|
/// <summary>Gets the credit record for a customer, or null if none exists (= unlimited).</summary>
|
|
Task<CustomerCredit?> GetByCustomerIdAsync(int customerId);
|
|
|
|
/// <summary>Insert or update a customer credit record.</summary>
|
|
Task SaveAsync(CustomerCredit entity);
|
|
|
|
/// <summary>Delete the credit record for a customer, restoring unlimited access.</summary>
|
|
Task DeleteAsync(CustomerCredit entity);
|
|
|
|
/// <summary>
|
|
/// Sum of OrderTotal for all pending/unpaid, non-cancelled orders for the customer.
|
|
/// </summary>
|
|
Task<decimal> GetOutstandingBalanceAsync(int customerId);
|
|
|
|
/// <summary>
|
|
/// CreditLimit - OutstandingBalance. Returns null if no credit record exists (= unlimited).
|
|
/// </summary>
|
|
Task<decimal?> GetRemainingCreditAsync(int customerId);
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
Task<bool> IsOrderAllowedAsync(int customerId, decimal newOrderTotal);
|
|
}
|