43 lines
1.4 KiB
Dart
43 lines
1.4 KiB
Dart
import '../entities/customer.dart';
|
|
import '../entities/transaction.dart';
|
|
|
|
abstract class TransactionRepository {
|
|
/// Persists a completed sale as one atomic unit.
|
|
///
|
|
/// The bill, the stock it consumed and the shopper's loyalty movement either
|
|
/// all land or none do, so a failure part-way through can never leave a
|
|
/// persisted bill that the cashier believes failed.
|
|
Future<void> commitSale({
|
|
required SaleTransaction transaction,
|
|
required Map<String, double> stockMovements,
|
|
Customer? updatedCustomer,
|
|
});
|
|
|
|
/// Reverses a sale still inside its cancellation window: deletes the order,
|
|
/// restores the stock it consumed, and puts an attached shopper's loyalty
|
|
/// balance back to what it was immediately before the sale.
|
|
///
|
|
/// Only valid before the bill has been offered to the back office — this
|
|
/// does not send a cancellation anywhere, it erases the sale as if it had
|
|
/// never happened locally.
|
|
Future<void> voidSale({
|
|
required SaleTransaction transaction,
|
|
required Map<String, double> stockMovements,
|
|
});
|
|
|
|
Future<List<SaleTransaction>> history({int limit = 50});
|
|
|
|
Future<SaleTransaction?> findByInvoice(String invoiceNumber);
|
|
|
|
/// Next invoice sequence for the current month.
|
|
Future<int> nextInvoiceSequence();
|
|
|
|
Future<void> park(ParkedBill bill);
|
|
|
|
Future<List<ParkedBill>> parkedBills();
|
|
|
|
Future<void> removeParked(String id);
|
|
|
|
Future<double> salesTotalForDay(DateTime day);
|
|
}
|