Browse Source

Set upper limit for money withdrawal

remotes/origin/feature/balance-operations
fdlt3817 2 years ago
parent
commit
51e0a2e753
  1. 14
      src/withdrawMoney.c
  2. 2
      src/withdrawMoney.h

14
src/withdrawMoney.c

@ -41,6 +41,12 @@ bool withdraw(int user_id) {
if (amountToWithdraw > 0) { if (amountToWithdraw > 0) {
if (amountToWithdraw <= availableAccountBalance) { if (amountToWithdraw <= availableAccountBalance) {
if(amountToWithdraw>MAX_AMOUNT){
printf("\nYou cannot withdraw more than %d€.",MAX_AMOUNT);
return false;
}
remainingAccountBalance = initiateWithdraw(amountToWithdraw, availableAccountBalance); remainingAccountBalance = initiateWithdraw(amountToWithdraw, availableAccountBalance);
updateSuccess = updateAvailableAccountBalance(user_id, remainingAccountBalance); updateSuccess = updateAvailableAccountBalance(user_id, remainingAccountBalance);
if( updateSuccess ) { if( updateSuccess ) {
@ -91,7 +97,7 @@ bool withdrawSpecificAmount(int user_id, float amountToWithdraw) {
return false; return false;
} }
int main(){
withdraw(1234);
return 1;
}
// int main(){
// withdraw(1234);
// return 1;
// }

2
src/withdrawMoney.h

@ -4,6 +4,8 @@
#include <stdio.h> #include <stdio.h>
#include <stdbool.h> #include <stdbool.h>
#define MAX_AMOUNT 10000
bool withdraw(int user_id); bool withdraw(int user_id);
float initiateWithdraw(float amountToWithdraw, float availableAccountBalance); float initiateWithdraw(float amountToWithdraw, float availableAccountBalance);
void notifyCustomer(float amountToWithdraw, float remainingAccountBalance, int user_id); void notifyCustomer(float amountToWithdraw, float remainingAccountBalance, int user_id);

Loading…
Cancel
Save