Нельзя добавить повторно одинаковые товары
parent
07c661c994
commit
4210c98f18
|
|
@ -5,6 +5,7 @@ import 'package:aman_kassa_flutter/core/locator.dart';
|
|||
import 'package:aman_kassa_flutter/core/models/dict_dao.dart';
|
||||
import 'package:aman_kassa_flutter/core/models/product_dao.dart';
|
||||
import 'package:aman_kassa_flutter/core/services/DataService.dart';
|
||||
import 'package:aman_kassa_flutter/core/services/dialog_service.dart';
|
||||
import 'package:aman_kassa_flutter/redux/constants/setting_const.dart';
|
||||
import 'package:aman_kassa_flutter/redux/state/kassa_state.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
|
@ -20,6 +21,7 @@ class SetKassaStateAction {
|
|||
}
|
||||
|
||||
final DataService _dataService = locator<DataService>();
|
||||
final DialogService _dialogService = locator<DialogService>();
|
||||
|
||||
Future<void> backBottomElement(Store<AppState> store) async {
|
||||
List<DictDao> prevCategories = store.state.kassaState.prevCategories;
|
||||
|
|
@ -47,6 +49,13 @@ ThunkAction<AppState> addProductToKassaItems(Good good, String excise) {
|
|||
return (Store<AppState> store) async {
|
||||
List<ProductDao> items = store.state.kassaState.kassaItems;
|
||||
int index = items.indexWhere((element) => element.excise == null && element.good?.id == good.id);
|
||||
if(excise !=null) {
|
||||
int existIndex = items.indexWhere((element) => element.excise != null && element.excise == excise);
|
||||
if(existIndex > -1) {
|
||||
_dialogService.showDialog(description: 'Нельзя добавить повторно одинаковые товары');
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (index > -1 && excise == null) {
|
||||
store.dispatch(counterProductFromKassaItems(index, 1));
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue