added product import and billing integration
This commit is contained in:
@@ -302,6 +302,15 @@ class CartController extends StateNotifier<Cart> {
|
||||
}
|
||||
|
||||
Future<void> resume(ParkedBill bill) async {
|
||||
// Resuming a bill on top of an already-active cart would otherwise
|
||||
// silently overwrite whatever was already there — picking a second
|
||||
// parked bill while the first one's items are still sitting in the
|
||||
// cart, unsaved. Same hole startNewSale closes for the header button;
|
||||
// this closes it here by parking what's active first.
|
||||
if (state.isNotEmpty) {
|
||||
await park(label: 'Auto-parked — replaced by resuming another bill');
|
||||
}
|
||||
|
||||
await _transactions.removeParked(bill.id);
|
||||
_undoStack.clear();
|
||||
// Re-evaluated rather than restored: a campaign that has since ended must
|
||||
@@ -309,6 +318,32 @@ class CartController extends StateNotifier<Cart> {
|
||||
_commit(bill.cart);
|
||||
}
|
||||
|
||||
/// What the header's "New Sale" button actually calls.
|
||||
///
|
||||
/// A cashier can always start over — that's the whole point of the escape
|
||||
/// hatch — but silently wiping a non-empty cart here would be the exact
|
||||
/// same hole the removal PIN closes: scan an item, then abandon the cart
|
||||
/// instead of removing that one line, and it disappears just the same,
|
||||
/// with nobody having approved anything. So a non-empty cart is parked,
|
||||
/// not discarded — visible and resumable from Parked bills — and only an
|
||||
/// already-empty cart takes the plain reset path.
|
||||
Future<void> startNewSale() async {
|
||||
if (state.isNotEmpty) {
|
||||
await park(label: 'Auto-parked — new sale started with items still in cart');
|
||||
return;
|
||||
}
|
||||
reset();
|
||||
}
|
||||
|
||||
/// Puts a cart back exactly as it was just before a sale that has since
|
||||
/// been voided, so cancelling a completed bill doesn't make the cashier
|
||||
/// re-scan everything. Promos are re-evaluated for the same reason
|
||||
/// [resume] re-evaluates them, not restored verbatim.
|
||||
void restore(Cart cart) {
|
||||
_undoStack.clear();
|
||||
_commit(cart);
|
||||
}
|
||||
|
||||
List<CartLine> _replace(CartLine updated) => [
|
||||
for (final l in state.lines)
|
||||
if (l.product.id == updated.product.id) updated else l,
|
||||
|
||||
Reference in New Issue
Block a user