fix: alot

This commit is contained in:
2026-10-19 21:41:34 +02:00
parent 30dd74af90
commit b0074aeb3f
40 changed files with 1979 additions and 405 deletions
+3 -19
View File
@@ -9,6 +9,7 @@ import 'package:provider/provider.dart';
import '../l10n/app_localizations.dart';
import '../l10n/app_localizations_helpers.dart';
import '../models/product.dart';
import '../utils/money.dart';
import '../utils/navigation.dart';
import '../viewmodels/product_list_view_model.dart';
@@ -148,24 +149,10 @@ class _ProductFormViewState extends State<ProductFormView> {
});
}
int _parsePriceToCents(String value) {
final normalized = value.replaceAll(',', '.');
final euros = double.tryParse(normalized) ?? 0;
return (euros * 100).round();
}
Future<void> _save() async {
final l10n = AppLocalizations.of(context);
if (!_formKey.currentState!.validate()) return;
if (_imagePath == null || _imagePath!.isEmpty) {
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text(l10n.chooseImage)));
return;
}
if (_selectedCategory == null) {
ScaffoldMessenger.of(
context,
@@ -179,7 +166,7 @@ class _ProductFormViewState extends State<ProductFormView> {
final name = _nameController.text.trim();
final category = _selectedCategory!;
final priceInCents = _parsePriceToCents(_priceController.text);
final priceInCents = parseEuroToCents(_priceController.text)!;
final stockQuantity = int.tryParse(_stockController.text) ?? 0;
final lowStockThreshold = int.tryParse(_lowStockController.text) ?? 0;
@@ -422,10 +409,7 @@ class _ProductFormViewState extends State<ProductFormView> {
return l10n.enterPrice;
}
final normalized = value.replaceAll(',', '.');
final price = double.tryParse(normalized);
if (price == null || price < 0) {
if (parseEuroToCents(value) == null) {
return l10n.enterValidPrice;
}