callGrnARMScanApi method
Implementation
Future<void> callGrnARMScanApi(
String? serialNum,
String? serialStartRange,
String? serialEndRange,
String requestToPartnerId,
) async {
BuildContext context = Get.context!;
Helper.progressDialog(context, "Please wait..");
try {
String requestTime = "";
String responseTime = "";
StockDeliveryScanModel model = await ApiClient(
baseUrl: ApiConstant.armBaseUrl,
onFetchRequestTime: (time) {
requestTime = time;
},
onFetchResponseTime: (time) {
responseTime = time;
},
screenName: "grn",
).validateAssets(
xUserId: SecureStorageService.readSecureData(
SecureStorageService.xUserId,
),
action: "INV_OPERATOR_STOCK_GR",
assetIds: serialNum,
assetStartRange: serialStartRange,
assetEndRange: serialEndRange,
fromPartnerId: requestToPartnerId,
transferOrderId: selectedGrnOrder.value.transferOrderId);
// Helper.close();
Helper.logEvent(
"RESPONSE_EVENT",
success: true,
endPoint: Api.validateAssets,
responseDate: responseTime,
screenName: "grn",
requestDate: requestTime,
);
if (model.status == true) {
Helper.close();
var tempIccids = <String>[].obs;
tempIccids.addAll(scannedIccidList);
RxList<ProductContentModel> temp = <ProductContentModel>[].obs;
temp.addAll(productDataScannedList);
for (int i = 0; i < temp.length; i++) {
if (model.data != null &&
model.data!.passedAssets != null &&
model.data!.passedAssets!.isNotEmpty) {
if (temp[i].productCode ==
model.data!.passedAssets![0].productCode) {
List<SingleScannedModel> iccidList = [];
iccidList.addAll(temp[i].iccidList ?? []);
for (final PassedAssets asset in model.data!.passedAssets ?? []) {
tempIccids.add(asset.serialnumber ?? "");
iccidList.add(
SingleScannedModel(
iccid: asset.serialnumber,
),
);
}
var grnProduct = temp[i]
.copyWith(iccidList: iccidList, scannedQty: iccidList.length);
temp[i] = grnProduct;
}
}
}
scannedIccidList = tempIccids; // assigning all the scanned iccids;
productDataScannedList.value = [...temp]; // assigning product list
} else {
Helper.close();
if (model.errors != null) {
Helper.messageDialog(
Get.context!,
model.errors![0].errorCode ?? "Try again!!",
model.errors![0].errorDescription ?? "Something went wrong",
);
}
}
} catch (err, stacktrace) {
Helper.close();
ConditionalLogs().customLog("$err");
ConditionalLogs().customLog("$stacktrace");
MainController mainController = Get.put(MainController());
mainController.showErrorPopup();
}
}