deleteAssetGrn method
Implementation
deleteAssetGrn(String assetid, ProductContentModel product) {
BuildContext context = Get.context!;
Helper.progressDialog(context, "Please wait..");
var tempIccids = <String>[].obs;
List<SingleScannedModel>? tempIccidList = <SingleScannedModel>[];
tempIccids.addAll(scannedIccidList);
try {
RxList<ProductContentModel> temp = <ProductContentModel>[].obs;
temp.addAll(productDataScannedList);
for (int i = 0; i < productDataScannedList.length; i++) {
if (productDataScannedList[i].productCode == product.productCode) {
tempIccidList.addAll(productDataScannedList[i].iccidList ?? []);
for (int j = 0;
j < productDataScannedList[i].iccidList!.length;
j++) {
if (assetid == productDataScannedList[i].iccidList![j].iccid) {
tempIccids.remove(assetid);
tempIccidList.removeAt(j);
// temp[i].
break;
}
}
var grnProduct = temp[i].copyWith(
iccidList: tempIccidList, scannedQty: tempIccidList.length);
temp[i] = grnProduct;
break;
}
}
scannedIccidList = tempIccids;
productDataScannedList.value = [...temp];
Helper.close();
} catch (err, stacktrace) {
Helper.close();
ConditionalLogs().customLog("$err");
ConditionalLogs().customLog("$stacktrace");
MainController mainController = Get.put(MainController());
mainController.showErrorPopup();
}
}