validateScanning method
dynamic
validateScanning()
Implementation
validateScanning() {
final condition = currentScan;
if (selectedScanType.value == "Single") {
String iccid = singleScanController.value.text;
if (iccid.isEmpty) {
Helper.assetSuccessDialog(
Get.context!,
localization.translate("failedToAddAsset"),
localization.translate("serialNumberCantBeEmpty"),
const AssetImage(
"assets/images/failed.png",
package: Constants.packageName,
));
return;
}
singleScanController.value.clear();
switch (condition) {
case ScanType.collectStock:
callARMMultipleStockDeliveryScanApi(
iccid, null, null, 1, storage.read("WAREHOUSE_ID"));
break;
case ScanType.spotSellThru:
callARMMultipleStockDeliveryScanApi(iccid, null, null, 1, userId);
break;
case ScanType.sellThru:
callARMMultipleStockDeliveryScanApi(iccid, null, null, 1, userId);
case ScanType.grn:
callARMMultipleGrnScanApi(iccid, null, null, 1, partnerIdLogin);
break;
default:
ConditionalLogs().customLog("default");
}
} else if (selectedScanType.value == "Range") {
String start = rangeStartScanController.value.text;
String end = rangeEndScanController.value.text;
rangeStartScanController.value.clear();
rangeEndScanController.value.clear();
if (start.isEmpty || end.isEmpty) {
Helper.assetSuccessDialog(
Get.context!,
localization.translate("failedToAddAsset"),
localization.translate("plsEnterStartAndEndRange"),
const AssetImage(
"assets/images/failed.png",
package: Constants.packageName,
));
return;
}
if (start.trim() == end.trim()) {
return;
}
BigInt startBigInt = BigInt.parse(start);
BigInt endBigInt = BigInt.parse(end);
if (startBigInt > endBigInt) {
Get.showSnackbar(
GetSnackBar(
title: localization.translate("failedToAddAsset"),
message: localization.translate("endRangeMustBeGreater"),
duration: const Duration(seconds: 2),
),
);
// Helper.assetSuccessDialog(
// Get.context!,
// localization.translate("failedToAddAsset"),
// localization.translate("endRangeMustBeGreater"),
// const AssetImage(
// "assets/images/failed.png",
// package: Constants.packageName,
// ));
return;
}
switch (condition) {
case ScanType.collectStock:
callARMMultipleStockDeliveryScanApi(
null, start, end, 1, storage.read("WAREHOUSE_ID"));
break;
case ScanType.spotSellThru:
callARMMultipleStockDeliveryScanApi(null, start, end, 1, userId);
break;
case ScanType.sellThru:
callARMMultipleStockDeliveryScanApi(null, start, end, 1, userId);
break;
case ScanType.grn:
callARMMultipleGrnScanApi(null, start, end, 1, partnerIdLogin);
break;
default:
ConditionalLogs().customLog("default");
}
}
}