callSubmitApi method
Implementation
Future<void> callSubmitApi(String cartId, double totalRetailprice,
double availableCreditLimit) async {
BuildContext context = Get.context!;
if (totalRetailprice > availableCreditLimit) {
// if (totalRetailprice > availableCreditLimit) {
Helper.messageDialog(Get.context!, "Can't proceed with submission",
"Your available credit balance is less than the total amount");
} else {
WidgetsBinding.instance.addPostFrameCallback((_) {
Helper.progressDialog(context, "Please wait..");
});
CollectStockSubmitRequest request = CollectStockSubmitRequest(
fieldForceAgentId: fieldForceAgentId,
fromPartyId: fromPartyId,
scanbyParty: scanByParty,
toPartyType: toPartyType.toUpperCase(),
toPartyName: toPartyName,
toPartyId: toPartyId);
await ApiClient(baseUrl: ApiConstant.posBFF)
.ownershipTransferForAssets(
xUserToken: storage.read("ACCESS_TOKEN"),
body: request,
type: "SCAN_IN",
cartId: cartId)
.then((response) {
Get.back();
OwnershipChangeModel model = response;
if (model.status == "POS200") {
Get.to(() => CollectStockSuccess(model: model));
} else {
if (model.errors != null) {
Helper.messageDialog(
Get.context!,
model.errors![0].code ?? "Try again!!",
model.errors![0].description ?? "Something went wrong");
}
}
}, onError: (error) {
print(error.toString());
Get.back();
Helper.messageDialog(Get.context!, "Try Again!!", error.toString());
});
}
}