Last active
September 27, 2020 10:15
-
-
Save itsashis4u/7a6f75547e75944ee3d8739bd804bc89 to your computer and use it in GitHub Desktop.
Payment Validations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function paymentModeClick(panCardMember, AVPA) { | |
if (!panCardMember) { | |
var maxLimit = AVPA ? AVPA : maxCashLimit; | |
if (totalCart > maxLimit) { | |
return `${totalCart} cannot be greater than ${Constants.rupee_sign}${maxLimit}`; | |
} | |
} | |
var totalCart = 210000; | |
var usableBalance = 50000; | |
var CHDL = null; // daily check | |
var AVCA = null; // available cash | |
var ADVC = null; // ledger cash | |
var maxCashLimit = 199999; | |
var minDailyLimit = maxCashLimit; | |
if (CHDL || AVCA) { | |
// if ledger is successful | |
minDailyLimit = Math.min(CHDL, AVCA) - ADVC; | |
} | |
console.log("Min daily limit: ", minDailyLimit); | |
var ledgerSelected = true; | |
var ledgerBalanceToUse = 0; | |
if (ledgerSelected) { | |
ledgerBalanceToUse = usableBalance; | |
} | |
var shouldDisableCashMode = totalCart - ledgerBalanceToUse > minDailyLimit; | |
console.log({ shouldDisableCashMode }); | |
// do rest of the logic | |
} | |
console.log(paymentModeClick(false, 51218.04)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment