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); }
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); }
public void Get_Set_Events() { List <SavingEvent> events = new List <SavingEvent>(); SavingInitialDepositEvent eventDeposit = new SavingInitialDepositEvent { Id = 1, Date = new DateTime(2008, 10, 18), Description = "First deposit of 100", Amount = 100 }; events.Add(eventDeposit); SavingWithdrawEvent eventWithdraw = new SavingWithdrawEvent { Id = 2, Date = new DateTime(2008, 10, 08), Description = "2nd withdraw of 75", Amount = 75 }; events.Add(eventWithdraw); CompulsorySavings CompulsorySavings = new CompulsorySavings(ApplicationSettings.GetInstance(""), ChartOfAccounts.GetInstance(new User()), new User(), 12m, new DateTime(2008, 08, 18), null); CompulsorySavings.Events.AddRange(events); Assert.AreEqual(events.Count + 1, CompulsorySavings.Events.Count); CompulsorySavings.Events.Sort(); events.Sort(); Assert.AreEqual(12m, CompulsorySavings.Events[0].Amount.Value); Assert.AreEqual(75m, CompulsorySavings.Events[1].Amount.Value); Assert.AreEqual(100m, CompulsorySavings.Events[2].Amount.Value); }
public void Get_Code() { SavingInitialDepositEvent savingInitialDeposit = new SavingInitialDepositEvent(); Assert.AreEqual("SVIE", savingInitialDeposit.Code); SavingDepositEvent savingDeposit = new SavingDepositEvent(); Assert.AreEqual("SVDE", savingDeposit.Code); SavingWithdrawEvent savingWithDraw = new SavingWithdrawEvent(); Assert.AreEqual("SVWE", savingWithDraw.Code); SavingInterestsAccrualEvent savingAccrualInterest = new SavingInterestsAccrualEvent(); Assert.AreEqual("SIAE", savingAccrualInterest.Code); SavingInterestsPostingEvent savingPostingInterest = new SavingInterestsPostingEvent(); Assert.AreEqual("SIPE", savingPostingInterest.Code); SavingCreditTransferEvent savingCreditTransfer = new SavingCreditTransferEvent(); Assert.AreEqual("SCTE", savingCreditTransfer.Code); SavingDebitTransferEvent savingDebitTransfer = new SavingDebitTransferEvent(); Assert.AreEqual("SDTE", savingDebitTransfer.Code); }
private static SavingEvent GetSavingsEvent(string code) { SavingEvent e; switch (code) { case OSavingEvents.Deposit: e = new SavingDepositEvent(); break; case OSavingEvents.Withdraw: e = new SavingWithdrawEvent(); break; case OSavingEvents.Accrual: e = new SavingInterestsAccrualEvent(); break; case OSavingEvents.Posting: e = new SavingInterestsPostingEvent(); break; case OSavingEvents.InitialDeposit: e = new SavingInitialDepositEvent(); break; case OSavingEvents.CreditTransfer: e = new SavingCreditTransferEvent(); break; case OSavingEvents.DebitTransfer: e = new SavingDebitTransferEvent(); break; case OSavingEvents.ManagementFee: e = new SavingManagementFeeEvent(); break; case OSavingEvents.SavingClosure: e = new SavingClosureEvent(); break; case OSavingEvents.Close: e = new SavingCloseEvent(); break; case OSavingEvents.OverdraftFees: e = new SavingOverdraftFeeEvent(); break; case OSavingEvents.Agio: e = new SavingAgioEvent(); break; case OSavingEvents.PendingDeposit: e = new SavingPendingDepositEvent(); break; case OSavingEvents.Reopen: e = new SavingReopenEvent(); break; case OSavingEvents.PendingDepositRefused: e = new SavingPendingDepositRefusedEvent(); break; case OSavingEvents.SpecialOperationCredit: e = new SavingCreditOperationEvent(); break; case OSavingEvents.SpecialOperationDebit: e = new SavingDebitOperationEvent(); break; case OSavingEvents.InterBranchCreditTransfer: e = new SavingCreditInterBranchTransferEvent(); break; case OSavingEvents.InterBranchDebitTransfer: e = new SavingDebitInterBranchTransferEvent(); break; case OSavingEvents.LoanDisbursement: e = new SavingLoanDisbursementEvent(); break; case OSavingEvents.SavingLoanRepayment: e = new LoanRepaymentFromSavingEvent(); break; case OSavingEvents.BlockCompulsarySavings: e = new SavingBlockCompulsarySavingsEvent(); break; case OSavingEvents.UnblockCompulsorySavings: e = new SavingUnblockCompulsorySavingsEvent(); break; default: Debug.Fail("Failed to create saving event object"); throw new Exception(); } return(e); }
public override List<SavingEvent> Withdraw(OCurrency pAmount, DateTime pDate, string pDescription, User pUser, bool pIsDesactivateFees) { List<SavingEvent> events = new List<SavingEvent>(); SavingWithdrawEvent withdrawEvent = new SavingWithdrawEvent { Amount = pAmount, Date = pDate, Description = pDescription, User = pUser, Cancelable = true, ProductType = typeof(TermDepositProduct) }; events.Add(withdrawEvent); _events.Add(withdrawEvent); events.AddRange(_calculateWithdrawFees(pDate, pUser, withdrawEvent, pIsDesactivateFees)); return events; }
public override List<SavingEvent> SimulateClose(DateTime date, User pUser, string pDescription, bool pIsDesactivateFees) { List<SavingEvent> listEvents = Closure(date, pUser); SavingInterestsPostingEvent postingEvent = _PostPayableInterests(date, pUser); if (postingEvent != null) listEvents.Add(postingEvent); SavingWithdrawEvent withdrawEvent = new SavingWithdrawEvent { Amount = 0, Date = date, Description = "Simulate Close - " + pDescription, User = pUser, Cancelable = true, ProductType = typeof(TermDepositProduct) }; if (!pIsDesactivateFees) { if (date != DateCalculationStrategy.GetLastMaturity(NextMaturity.Value, Product.Periodicity, NumberPeriods)) { OCurrency fees; if (Product.WithdrawalFeesType == OTermDepositFeesType.OnInterests) { fees = postingEvent != null ? postingEvent.Amount * WithdrawalFees : 0; } else { fees = GetBalance(date) - (GetBalance(date) / (1 + WithdrawalFees)); //fees = Balance * WithdrawalFees; } withdrawEvent.Fee = fees; } } _events.Add(withdrawEvent); listEvents.Add(withdrawEvent); Status = OSavingsStatus.Closed; ClosedDate = date; return listEvents; }
public override List<SavingEvent> Withdraw(OCurrency pAmount, DateTime pDate, string pDescription, User pUser, bool pIsDesactivateFees) { List<SavingEvent> events = new List<SavingEvent>(); SavingWithdrawEvent withdrawEvent = new SavingWithdrawEvent { Amount = pAmount, Date = pDate, Description = pDescription, User = pUser, Cancelable = true, Fee = 0m, ProductType = typeof(SavingBookProduct) }; _events.Add(withdrawEvent); events.Add(withdrawEvent); if (Status != OSavingsStatus.Closed && !pIsDesactivateFees) withdrawEvent.Fee = Product.WithdrawFeesType == OSavingsFeesType.Flat ? FlatWithdrawFees : pAmount * RateWithdrawFees.Value; return events; }
public virtual List<SavingEvent> Withdraw(OCurrency pAmount, DateTime pDate, string pDescription, User pUser, bool pIsDesactivateFees) { List<SavingEvent> events = new List<SavingEvent>(); SavingWithdrawEvent withdrawEvent = new SavingWithdrawEvent { Amount = pAmount, Date = pDate, Description = pDescription, User = pUser, Cancelable = true, ProductType = Product.GetType() }; events.Add(withdrawEvent); _events.Add(withdrawEvent); return events; }