Example #1
0
        public Transaction DepositMoney(Bank bank, float amount, Customer customer)
        {
            customer.AddBalance(amount);
            bank.transactions.Add(new Deposit(customer.GetAccount().AccountId, bank.Id, amount));

            return(bank.transactions[bank.transactions.Count - 1]);
        }
Example #2
0
        public bool RevertFundsTransfer(Bank banKSource, Bank bankDest, FundsTransfer transaction)
        {
            string   sourceId = transaction.SourceId;
            string   destinationId = transaction.destinationAccId;
            Customer sender = null, reciever = null;
            float    amountFlow = transaction.Amountflow;

            sender   = this.CustomerExistsOrNotByAccId(banKSource, sourceId);
            reciever = this.CustomerExistsOrNotByAccId(banKSource, destinationId);

            if (reciever != null && sender != null)
            {
                if (reciever.GetAccount().IsBalanceSufficient(-1 * amountFlow))
                {
                    sender.AddBalance(-1 * amountFlow);
                    reciever.AddBalance(amountFlow);
                    bankDest.transactions.Add(new FundsTransfer(destinationId, bankDest.Id, amountFlow, sourceId, banKSource.Id));
                    if (sender.bankId != reciever.bankId)
                    {
                        banKSource.transactions.Add(new FundsTransfer(destinationId, transaction.destinationBankId, amountFlow * -1, sourceId, transaction.SourceBankId));
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Example #3
0
        public bool FundsTransfer(Bank bankSource, Bank bankDestination, float amount, Customer source, Customer destination)
        {
            if (amount >= 100000)
            {
                if (bankSource.Id.Equals(bankDestination.Id))
                {
                    amount = amount * ((100 + ((float)(bankSource.RTGS))) / 100);
                }
                else
                {
                    amount = amount * ((100 + ((float)(bankSource.fRTGS))) / 100);
                }
            }
            else
            {
                if (bankSource.Id.Equals(bankDestination.Id))
                {
                    amount = amount * ((100 + ((float)(bankSource.IMPS))) / 100);
                }
                else
                {
                    amount = amount * ((100 + ((float)(bankSource.fIMPS))) / 100);
                }
            }
            if (source.GetAccount().IsBalanceSufficient(amount))
            {
                source.AddBalance(-1 * amount);
                destination.AddBalance(amount);
                bankSource.transactions.Add(new FundsTransfer(source.GetAccount().AccountId, bankSource.Id, -1 * amount, destination.GetAccount().AccountId, bankDestination.Id));
                if (source.bankId != destination.bankId)
                {
                    bankDestination.transactions.Add(new FundsTransfer(source.GetAccount().AccountId, bankSource.Id, amount, destination.GetAccount().AccountId, bankDestination.Id));
                }

                return(true);
            }
            return(false);
        }