feat: move inventory to own view model, add signing keys
This commit is contained in:
@@ -4,15 +4,15 @@ import '../models/bar_tab.dart';
|
||||
import '../models/product.dart';
|
||||
import '../models/tab_item.dart';
|
||||
import '../services/bar_tab_service.dart';
|
||||
import '../services/product_service.dart';
|
||||
import 'inventory_view_model.dart';
|
||||
|
||||
class BarScreenViewModel extends ChangeNotifier {
|
||||
final BarTabService barTabService;
|
||||
final ProductService productService;
|
||||
final InventoryViewModel inventory;
|
||||
|
||||
BarScreenViewModel({
|
||||
required this.barTabService,
|
||||
required this.productService,
|
||||
required this.inventory,
|
||||
});
|
||||
|
||||
List<BarTab> _tabs = [];
|
||||
@@ -96,7 +96,7 @@ class BarScreenViewModel extends ChangeNotifier {
|
||||
product: product,
|
||||
);
|
||||
|
||||
await productService.decreaseStock(product.id, 1);
|
||||
await inventory.decreaseStock(product.id, 1);
|
||||
|
||||
await _reloadTabs();
|
||||
}
|
||||
@@ -110,9 +110,9 @@ class BarScreenViewModel extends ChangeNotifier {
|
||||
);
|
||||
|
||||
if (difference > 0) {
|
||||
await productService.decreaseStock(item.productId, difference);
|
||||
await inventory.decreaseStock(item.productId, difference);
|
||||
} else if (difference < 0) {
|
||||
await productService.increaseStock(item.productId, -difference);
|
||||
await inventory.increaseStock(item.productId, -difference);
|
||||
}
|
||||
|
||||
await _reloadTabs();
|
||||
|
||||
Reference in New Issue
Block a user