|
@ -64,57 +64,49 @@ void askToShowBalance(int customerID){ |
|
|
} |
|
|
} |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool sendMoney(int customerID) { |
|
|
bool sendMoney(int customerID) { |
|
|
float availableAccountBalance=getAvailableAccountBalance(customerID); |
|
|
|
|
|
float amountToSend; |
|
|
|
|
|
int recID; |
|
|
|
|
|
|
|
|
float available_account_balance = getAvailableAccountBalance(customerID); |
|
|
|
|
|
float amount_to_send; |
|
|
|
|
|
int recipient_id; |
|
|
|
|
|
|
|
|
showBalance(customerID); |
|
|
showBalance(customerID); |
|
|
printf("\nHow much would you like to send?\n"); |
|
|
printf("\nHow much would you like to send?\n"); |
|
|
scanf("%f",&amountToSend); |
|
|
|
|
|
if(amountToSend>0 && amountToSend<availableAccountBalance){ |
|
|
|
|
|
printf("\nYour input was %.2f€. Please enter the recipient id.\n",amountToSend); |
|
|
|
|
|
scanf("%d",&recID); |
|
|
|
|
|
if(recID>1000){ |
|
|
|
|
|
bool recExists=checkCustomerExists(recID); |
|
|
|
|
|
if(recExists){ |
|
|
|
|
|
if(recID==customerID){ |
|
|
|
|
|
|
|
|
scanf("%f", &amount_to_send); |
|
|
|
|
|
if (amount_to_send > 0 && amount_to_send < available_account_balance) { |
|
|
|
|
|
printf("\nYour input was %.2f€. Please enter the recipient id.\n", amount_to_send); |
|
|
|
|
|
scanf("%d", &recipient_id); |
|
|
|
|
|
if (recipient_id > 1000) { |
|
|
|
|
|
bool recipient_exists = checkCustomerExists(recipient_id); |
|
|
|
|
|
if (recipient_exists) { |
|
|
|
|
|
if (recipient_id == customerID) { |
|
|
printf("\nYou cannot send money to yourself. Aborting. \n"); |
|
|
printf("\nYou cannot send money to yourself. Aborting. \n"); |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
|
|
|
else{ |
|
|
|
|
|
if(withdrawSpecificAmount(customerID, amountToSend)){ |
|
|
|
|
|
if(depositSpecificAmount(recID, amountToSend)){ |
|
|
|
|
|
askToConvert(amountToSend, recID); |
|
|
|
|
|
//printf("\nYou have successfuly transfered %.2f€ to [%d]",amountToSend,recID); |
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
if (withdrawSpecificAmount(customerID, amount_to_send)) { |
|
|
|
|
|
if (depositSpecificAmount(recipient_id, amount_to_send)) { |
|
|
|
|
|
askToConvert(amount_to_send, recipient_id); |
|
|
askToShowBalance(customerID); |
|
|
askToShowBalance(customerID); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
|
|
|
else{ |
|
|
|
|
|
|
|
|
} else { |
|
|
printf("\nSomething went wrong with the transfer. Please contact staff."); |
|
|
printf("\nSomething went wrong with the transfer. Please contact staff."); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
printf("\nThis ID is not from a customer of our bank. A transfer fee of %.2f€ will be taken.\n", TRANSFER_FEE); |
|
|
printf("\nThis ID is not from a customer of our bank. A transfer fee of %.2f€ will be taken.\n", TRANSFER_FEE); |
|
|
if(withdrawSpecificAmount(customerID, amountToSend+TRANSFER_FEE)){ |
|
|
|
|
|
askToConvert(amountToSend, recID); |
|
|
|
|
|
//printf("\nYou have successfuly transfered %.2f€ to [%d]\n",amountToSend,recID); |
|
|
|
|
|
|
|
|
if (withdrawSpecificAmount(customerID, amount_to_send + TRANSFER_FEE)) { |
|
|
|
|
|
askToConvert(amount_to_send, recipient_id); |
|
|
askToShowBalance(customerID); |
|
|
askToShowBalance(customerID); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
} else { |
|
|
printf("\nThe ID you have entered is not valid. Aborting. \n"); |
|
|
printf("\nThe ID you have entered is not valid. Aborting. \n"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
// error |
|
|
// error |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|