fix: Make transactions atomic / AutoLogout
This commit is contained in:
@@ -65,4 +65,16 @@ class InventoryViewModel extends ChangeNotifier {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
void applyStockDelta(String productId, int delta) {
|
||||
if (delta == 0) return;
|
||||
|
||||
final index = _products.indexWhere((product) => product.id == productId);
|
||||
if (index == -1) return;
|
||||
|
||||
_products[index] = _products[index].copyWith(
|
||||
stockQuantity: _products[index].stockQuantity + delta,
|
||||
);
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user