Ejemplo n.º 1
0
 private void CloseAndTransfer(ISavingsContract from, ISavingsContract to, DateTime date, User pUser,
     OCurrency amount, bool pIsDesactivateFees, Teller teller)
 {
     from.Transfer(to, amount, 0, date, "Closing transfer");
     from.Close(date, pUser, "Close savings contract", pIsDesactivateFees, teller, true);
 }
Ejemplo n.º 2
0
        public override List<SavingEvent> Close(DateTime pDate, User pUser, string pDescription, bool pIsDesactivateFees, Teller teller, bool isFromClosure)
        {
            int? tellerId = null;
            if (teller != null && teller.Id != 0) tellerId = teller.Id;
            List<SavingEvent> listEvents = new List<SavingEvent>();
            if (!isFromClosure)
                listEvents = Closure(pDate, pUser);

            SavingInterestsPostingEvent postingEvent = PostPayableInterests(pDate, pUser);
            if (postingEvent != null)
            {
                listEvents.Add(postingEvent);
            }
            OCurrency amountToPost = listEvents.Where(item => item is SavingInterestsPostingEvent).Sum(item => item.Amount.Value);

            SavingCloseEvent closeEvent = new SavingCloseEvent
            {
                Amount = amountToPost,
                Date = pDate,
                Description = pDescription,
                User = pUser,
                Cancelable = false,
                Fee = 0m,
                TellerId = tellerId,
                ProductType = typeof(SavingsBookProduct),
            };

            Events.Add(closeEvent);

            if (!pIsDesactivateFees)
            {
                closeEvent.Fee = CloseFees;
            }

            listEvents.Clear();
            listEvents.Add(closeEvent);
            Status = OSavingsStatus.Closed;
            ClosedDate = pDate;

            foreach (SavingEvent e in listEvents)
            {
                e.Target = this;
            }
            return listEvents;
        }
Ejemplo n.º 3
0
 public override List<SavingEvent> SimulateClose(DateTime pDate, User pUser, string pDescription, bool pIsDesactivateFees, Teller teller)
 {
     return Close(pDate, pUser, pDescription, pIsDesactivateFees, teller, false);
 }
Ejemplo n.º 4
0
        public override List<SavingEvent> Deposit(OCurrency pAmount, DateTime pDate, string pDescription, User pUser,
                bool pIsDesactivateFees, bool isPending, OSavingsMethods savingsMethod, PaymentMethod paymentMethod, int? pendingEventId, Teller teller)
        {
            List<SavingEvent> events = new List<SavingEvent>();

            int? tellerId = null;
            if (teller != null && teller.Id != 0) tellerId = teller.Id;

            SavingEvent savingEvent;

            if (isPending)
            {
                savingEvent = new SavingPendingDepositEvent();
            }
            else
            {
                savingEvent = new SavingDepositEvent();
            }

            savingEvent.Amount = pAmount;
            savingEvent.Date = pDate;
            savingEvent.Description = pDescription;
            savingEvent.User = pUser;
            savingEvent.Cancelable = true;
            savingEvent.IsPending = isPending;
            savingEvent.SavingsMethod = savingsMethod;
            savingEvent.PaymentsMethod = paymentMethod;
            savingEvent.PendingEventId = pendingEventId;
            savingEvent.TellerId = tellerId;
            savingEvent.ProductType = typeof(SavingsBookProduct);

            Events.Add(savingEvent);
            events.Add(savingEvent);

            if (Status != OSavingsStatus.Closed && !pIsDesactivateFees)
                savingEvent.Fee = savingsMethod == OSavingsMethods.Cheque ? ChequeDepositFees : DepositFees;

            return events;
        }
Ejemplo n.º 5
0
        public override List<SavingEvent> Withdraw(OCurrency pAmount, DateTime pDate, string pDescription, User pUser, bool pIsDesactivateFees, Teller teller, PaymentMethod paymentMethod)
        {
            List<SavingEvent> events = new List<SavingEvent>();

            int? tellerId = null;
            if (teller != null && teller.Id != 0) tellerId = teller.Id;

            SavingWithdrawEvent withdrawEvent = new SavingWithdrawEvent
            {
                Amount = pAmount,
                Date = pDate,
                Description = pDescription,
                User = pUser,
                Cancelable = true,
                Fee = 0m,
                TellerId = tellerId,
                ProductType = typeof(SavingsBookProduct),
                SavingsMethod = OSavingsMethods.Cash
            };
            Events.Add(withdrawEvent);
            events.Add(withdrawEvent);

            if (Status != OSavingsStatus.Closed && !pIsDesactivateFees)
               withdrawEvent.Fee = Product.WithdrawFeesType == OSavingsFeesType.Flat ? FlatWithdrawFees : pAmount * RateWithdrawFees.Value;

            return events;
        }
Ejemplo n.º 6
0
        public override List<SavingEvent> FirstDeposit(OCurrency pInitialAmount, DateTime pCreationDate, 
                                                        OCurrency pEntryFees, User pUser, Teller teller)
        {
            List<SavingEvent> events = new List<SavingEvent>();

            int? tellerId = null;
            if (teller != null && teller.Id != 0) tellerId = teller.Id;

            SavingInitialDepositEvent initialEvent = new SavingInitialDepositEvent
            {
                Amount = pInitialAmount,
                Date = pCreationDate,
                Description = "First deposit",
                User = pUser,
                Fee = pEntryFees,
                TellerId = tellerId,
                ProductType = typeof(SavingsBookProduct),
                SavingsMethod = OSavingsMethods.Cash
            };

            Events.Add(initialEvent);
            events.Add(initialEvent);

            CreationDate = pCreationDate;
            
            return events;
        }
Ejemplo n.º 7
0
        public override List<SavingEvent> LoanDisbursement(Loan loan, DateTime date, string description, User user, 
                bool isDesactivateFees, bool isPending, OSavingsMethods savingsMethod, int? pendingEventId, Teller teller)
        {
            var events = new List<SavingEvent>();
            int? tellerId = null;
            if (teller != null && teller.Id != 0) tellerId = teller.Id;

            SavingEvent savingEvent = new SavingLoanDisbursementEvent
                                          {
                                              Amount = loan.Amount,
                                              Date = date,
                                              Description = description,
                                              User = user,
                                              Cancelable = false,
                                              IsPending = isPending,
                                              SavingsMethod = null,
                                              PendingEventId = pendingEventId,
                                              TellerId = tellerId,
                                              LoanEventId = loan.GetNotDeletedDisbursementEvent().Id,
                                              ProductType = typeof (SavingsBookProduct)
                                          };
            Events.Add(savingEvent);
            events.Add(savingEvent);
            savingEvent.Fee = Status != OSavingsStatus.Closed && !isDesactivateFees ? loan.GetSumOfFees() : 0;

            return events;
        }
Ejemplo n.º 8
0
 public virtual List<SavingEvent> SimulateClose(DateTime pDate, User pUser, string pDescription, bool pIsDesactivateFees, Teller teller)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 9
0
        public virtual List<SavingEvent> Withdraw(OCurrency pAmount, DateTime pDate, string pDescription, User pUser, bool pIsDesactivateFees, Teller teller)
        {
            List<SavingEvent> events = new List<SavingEvent>();

            int? tellerId = null;
            if (teller != null) tellerId = teller.Id;

            SavingWithdrawEvent withdrawEvent = new SavingWithdrawEvent
            {
                Amount = pAmount,
                Date = pDate,
                Description = pDescription,
                User = pUser,
                Cancelable = true,
                TellerId = tellerId,
                ProductType = Product.GetType()
            };
            events.Add(withdrawEvent);
            Events.Add(withdrawEvent);

            return events;
        }
Ejemplo n.º 10
0
        public virtual List<SavingEvent> RepayLoanFromSaving(Loan loan, int repaymentEventId, DateTime date, OCurrency amount, string description, User user, Teller teller)
        {
            var events = new List<SavingEvent>();
            int? tellerId = null;
            if (teller != null && teller.Id != 0) tellerId = teller.Id;

            SavingEvent repaymentFromSavingEvent = new LoanRepaymentFromSavingEvent
            {
                Amount = amount,
                Date = date,
                Description = description,
                User = user,
                Cancelable = false,
                TellerId = tellerId,
                IsPending = false,
                SavingsMethod = null,
                ProductType = typeof(SavingsBookProduct),
                LoanEventId = repaymentEventId
            };
            events.Add(repaymentFromSavingEvent);
            Events.Add(repaymentFromSavingEvent);
            return events;
        }
Ejemplo n.º 11
0
        public virtual List<SavingEvent> Deposit(OCurrency pAmount, DateTime pDate, string pDescription, User pUser,
            bool pIsDesactivateFees, bool isPending, OSavingsMethods savingsMethod, int? pendingEventId, Teller teller)
        {
            List<SavingEvent> events = new List<SavingEvent>();
            SavingEvent savingEvent;

            int? tellerId = null;
            if (teller != null) tellerId = teller.Id;

            if (isPending)
            {
                savingEvent = new SavingPendingDepositEvent();
            }
            else
            {
                savingEvent = new SavingDepositEvent();
            }

            savingEvent.Amount = pAmount;
            savingEvent.Date = pDate;
            savingEvent.Description = pDescription;
            savingEvent.User = pUser;
            savingEvent.Cancelable = true;
            savingEvent.IsPending = isPending;
            savingEvent.SavingsMethod = savingsMethod;
            savingEvent.PendingEventId = pendingEventId;
            savingEvent.TellerId = tellerId;
            savingEvent.ProductType = typeof(SavingsBookProduct);

            Events.Add(savingEvent);
            events.Add(savingEvent);

            return events;
        }
Ejemplo n.º 12
0
 public void Setup()
 {
     _accountRepository = Mock.Of<AccountRepository>();
     _teller = new Teller(_accountRepository);
 }
Ejemplo n.º 13
0
 public void Clear()
 {
     start.Enabled = true;
     savings.Enabled = false;
     checking.Enabled = false;
     transaction.Enabled = false;
     enter.Text = "Enter Name";
     enter.Enabled = false;
     dataEntry.Text = "";
     dataEntry.Enabled = false;
     message = "Welcome to Art's bank";
     Invalidate();
     teller = new Teller(bank,this);
 }
Ejemplo n.º 14
0
 public void Find(String id, int acctType, Teller teller)
 {
     for (int i = 0; i < accounts.Length; i++) {
       Account acct = accounts[i];
       if (acct.GetId() == id)
     switch(acctType) {
       case SAVINGS:
         if (acct is Savings){
           teller.AcceptAccount(acct);
           return;
         }
         break;
       case CHECKING:
         if (acct is Checking){
           teller.AcceptAccount(acct);
           return;
         }
         break;
       }
      }
      teller.AcceptAccount(null);
 }