Browse Source

Refactor withdrawMoney

remotes/origin/Alpha
fdlt3817 2 years ago
parent
commit
635efaadf2
  1. 13
      src/withdrawMoney.c

13
src/withdrawMoney.c

@ -81,23 +81,22 @@ bool withdraw(int user_id) {
bool withdrawSpecificAmount(int user_id, float amountToWithdraw) { bool withdrawSpecificAmount(int user_id, float amountToWithdraw) {
float remainingAccountBalance; float remainingAccountBalance;
float availableAccountBalance = getAvailableAccountBalance(user_id); float availableAccountBalance = getAvailableAccountBalance(user_id);
if (amountToWithdraw > 0) {
if (amountToWithdraw > 0) {
if (amountToWithdraw <= availableAccountBalance) { if (amountToWithdraw <= availableAccountBalance) {
remainingAccountBalance = initiateWithdraw(amountToWithdraw, availableAccountBalance); remainingAccountBalance = initiateWithdraw(amountToWithdraw, availableAccountBalance);
if(updateAvailableAccountBalance(user_id, remainingAccountBalance)){
if (updateAvailableAccountBalance(user_id, remainingAccountBalance)) {
return true; return true;
} }
}
} }
}
return false; return false;
} }
// int main(){ // int main(){
// withdraw(1234); // withdraw(1234);
// return 1; // return 1;
// }
// }
Loading…
Cancel
Save