merge ?3
This commit is contained in:
parent
11c66e7bf1
commit
3a013c829f
1 changed files with 41 additions and 0 deletions
|
|
@ -52,6 +52,47 @@ class SellViewModel extends ChangeNotifier {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> scanBook(BarcodeCapture barcode) async {
|
||||||
|
int ean = int.parse(barcode.barcodes.first.rawValue!);
|
||||||
|
Bal? bal = await _balRepository.ongoingBal();
|
||||||
|
_scannedBooks.clear();
|
||||||
|
|
||||||
|
final result = await _bookInstanceRepository.getByEan(bal!.id, ean);
|
||||||
|
switch (result) {
|
||||||
|
case Ok():
|
||||||
|
for (BookInstance instance in result.value) {
|
||||||
|
Book book;
|
||||||
|
final result2 = await _bookRepository.getBookById(instance.bookId);
|
||||||
|
switch (result2) {
|
||||||
|
case Ok():
|
||||||
|
book = result2.value;
|
||||||
|
break;
|
||||||
|
case Error():
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Owner owner;
|
||||||
|
final result3 = await _ownerRepository.getOwnerById(instance.ownerId);
|
||||||
|
switch (result3) {
|
||||||
|
case Ok():
|
||||||
|
owner = result3.value;
|
||||||
|
break;
|
||||||
|
case Error():
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
_scannedBooks.add(
|
||||||
|
BookStack(instance: instance, book: book, owner: owner),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Error():
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
isScanLoaded = true;
|
||||||
|
notifyListeners();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* =================
|
* =================
|
||||||
* =====[ BAL ]=====
|
* =====[ BAL ]=====
|
||||||
|
|
|
||||||
Reference in a new issue