feat: add rows count (broken), fix: bug with low stock items
This commit is contained in:
@@ -4,6 +4,13 @@ import 'package:uuid/uuid.dart';
|
||||
import '../database/app_database.dart';
|
||||
import '../models/product.dart';
|
||||
|
||||
class InsufficientStockException implements Exception {
|
||||
const InsufficientStockException();
|
||||
|
||||
@override
|
||||
String toString() => 'Not enough stock';
|
||||
}
|
||||
|
||||
abstract class ProductService {
|
||||
Future<List<Product>> getProducts();
|
||||
|
||||
@@ -130,7 +137,7 @@ class DriftProductService implements ProductService {
|
||||
}
|
||||
|
||||
if (product.stockQuantity < amount) {
|
||||
throw Exception('Not enough stock');
|
||||
throw const InsufficientStockException();
|
||||
}
|
||||
|
||||
await updateProduct(
|
||||
|
||||
@@ -26,6 +26,7 @@ class DriftSettingsService implements SettingsService {
|
||||
(language) => language.name == row.language,
|
||||
orElse: () => AppLanguage.system,
|
||||
),
|
||||
barGridRows: row.barGridRows.clamp(2, 6).toInt(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -51,6 +52,7 @@ class DriftSettingsService implements SettingsService {
|
||||
pinRequired: Value(settings.pinRequired),
|
||||
themeMode: Value(settings.themeMode.name),
|
||||
language: Value(settings.language.name),
|
||||
barGridRows: Value(settings.barGridRows),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user