addProductToOrderList method
bool
addProductToOrderList({
- required CollectStockCardModel product,
- required bool isSingle,
- required bool isRange,
- required bool isBox,
Implementation
bool addProductToOrderList({
required CollectStockCardModel product,
required bool isSingle,
required bool isRange,
required bool isBox,
}) {
if (isSingle) {
CollectStockCardModel? orderProduct;
for (final data in searchedList) {
if (data.materialCode == product.materialCode) {
orderProduct = data;
break;
}
}
if (orderProduct != null) {
orderProduct.singleList!.addAll(product.singleList!);
orderProduct.scannedQty =
product.singleList!.length + orderProduct.scannedQty;
selectedProduct.value = CollectStockCardModel();
selectedProduct.value = orderProduct;
return true;
} else {
Helper.assetSuccessDialog(
Get.context!,
"Failed to add asset.",
"Scanned product is not availale in the order",
const AssetImage(
"assets/images/failed.png",
package: Constants.packageName,
));
return false;
}
} else if (isRange) {
CollectStockCardModel? orderProduct;
for (final data in searchedList) {
if (data.materialCode == product.materialCode) {
orderProduct = data;
break;
}
}
if (orderProduct != null) {
orderProduct.rangeList!.addAll(product.rangeList!);
int qty = 0;
for (final data in product.rangeList!) {
qty = qty + data.iccidList!.length;
}
orderProduct.scannedQty = qty + orderProduct.scannedQty;
selectedProduct.value = CollectStockCardModel();
selectedProduct.value = orderProduct;
return true;
} else {
Helper.assetSuccessDialog(
Get.context!,
"Failed to add asset.",
"Scanned product is not availale in the order",
const AssetImage(
"assets/images/failed.png",
package: Constants.packageName,
));
return false;
}
} else {
return false;
}
}