public FormPaymentPlanOptions(PaymentSchedule paySchedule) { InitializeComponent(); Lan.F(this); if(paySchedule==PaymentSchedule.Weekly) { radioWeekly.Checked=true; } else if(paySchedule==PaymentSchedule.BiWeekly) { radioEveryOtherWeek.Checked=true; } else if(paySchedule==PaymentSchedule.MonthlyDayOfWeek) { radioOrdinalWeekday.Checked=true; } else if(paySchedule==PaymentSchedule.Monthly) { radioMonthly.Checked=true; } else {//quarterly radioQuarterly.Checked=true; } }
// parses the swap internal Swap parseSwap(FpmlDocument document, XmlElement tradeEl, TradeInfoBuilder tradeInfoBuilder) { XmlElement swapEl = tradeEl.getChild("swap"); ImmutableList <XmlElement> legEls = swapEl.getChildren("swapStream"); ImmutableList.Builder <SwapLeg> legsBuilder = ImmutableList.builder(); foreach (XmlElement legEl in legEls) { // calculation XmlElement calcPeriodAmountEl = legEl.getChild("calculationPeriodAmount"); XmlElement calcEl = calcPeriodAmountEl.findChild("calculation").orElse(XmlElement.ofChildren("calculation", ImmutableList.of())); PeriodicSchedule accrualSchedule = parseSwapAccrualSchedule(legEl, document); PaymentSchedule paymentSchedule = parseSwapPaymentSchedule(legEl, calcEl, document); // known amount or rate calculation Optional <XmlElement> knownAmountOptEl = calcPeriodAmountEl.findChild("knownAmountSchedule"); if (knownAmountOptEl.Present) { XmlElement knownAmountEl = knownAmountOptEl.get(); document.validateNotPresent(legEl, "stubCalculationPeriodAmount"); document.validateNotPresent(legEl, "resetDates"); // pay/receive and counterparty PayReceive payReceive = document.parsePayerReceiver(legEl, tradeInfoBuilder); ValueSchedule amountSchedule = parseSchedule(knownAmountEl, document); // build legsBuilder.add(KnownAmountSwapLeg.builder().payReceive(payReceive).accrualSchedule(accrualSchedule).paymentSchedule(paymentSchedule).amount(amountSchedule).currency(document.parseCurrency(knownAmountEl.getChild("currency"))).build()); } else { document.validateNotPresent(calcEl, "fxLinkedNotionalSchedule"); document.validateNotPresent(calcEl, "futureValueNotional"); // pay/receive and counterparty PayReceive payReceive = document.parsePayerReceiver(legEl, tradeInfoBuilder); NotionalSchedule notionalSchedule = parseSwapNotionalSchedule(legEl, calcEl, document); RateCalculation calculation = parseSwapCalculation(legEl, calcEl, accrualSchedule, document); // build legsBuilder.add(RateCalculationSwapLeg.builder().payReceive(payReceive).accrualSchedule(accrualSchedule).paymentSchedule(paymentSchedule).notionalSchedule(notionalSchedule).calculation(calculation).build()); } } return(Swap.of(legsBuilder.build())); }
public static PaymentSchedule CalculateAnnuitySchedule(Tariff tariff, decimal loanAmount, int term, DateTime?startDate) { var rate = tariff.InterestRate * tariff.PmtFrequency / 12; var helpCoeff = PowDecimal(1 + rate, term); var annuityCoeff = (rate * helpCoeff) / (helpCoeff - 1); var monthlyPayment = loanAmount * annuityCoeff; var schedule = new PaymentSchedule(); var remainMainDebt = loanAmount; for (var i = 0; i < term; i++) { var pmtInterest = remainMainDebt * rate; var pmtMainDebt = monthlyPayment - pmtInterest; var accruedDate = CalculateAccrualDate(startDate, i + 1); var payBefore = CalculatePaymentDate(startDate, i + 1); if (startDate.HasValue && payBefore > startDate.Value.AddMonths(term)) { payBefore = startDate.Value.AddMonths(term); } if (i == 0 && startDate.HasValue) { pmtInterest *= ((30 - startDate.Value.Day + 1) / 30M); } if (i + 1 == term && startDate.HasValue) { pmtInterest += pmtInterest * ((startDate.Value.Day - 1) / 30M); } var pmt = new Payment { MainDebtAmount = pmtMainDebt, AccruedInterestAmount = pmtInterest, AccruedOn = accruedDate, ShouldBePaidBefore = payBefore }; schedule.AddPayment(pmt); remainMainDebt -= pmtMainDebt; } return(RoundPayments(schedule, 2)); }
public void ExecuteTest() { AddEmployeeTransaction addEmp = new AddSalariedEmployee(1, "Bob", "Street Lasa", 1800, database); addEmp.Execute(); Employee emp = database.GetEmployee(1); Assert.IsNotNull(emp); PaymentClassification classifiction = emp.Classification; PaymentMethod method = emp.Method; PaymentSchedule schedule = emp.Schedule; Assert.AreEqual("Bob", emp.Name); Assert.IsTrue(classifiction is SalariedClassification); Assert.IsTrue(method is HoldMethod); Assert.IsTrue(schedule is MonthlySchedule); SalariedClassification salaryClassifiction = classifiction as SalariedClassification; //as 不会报错,只会返回空 Assert.AreEqual(1800, salaryClassifiction.Salary, 0.0001); }
public void AddHourlyEmployee() { int empid = 3; AddHourlyEmployee t = new AddHourlyEmployee(empid, "Bill", "Home", 265); t.Execute(); Employee e = PayrollDatabase.GetEmployee_Static(empid); Assert.AreEqual("Bill", e.Name); PaymentClassification pc = e.Classification; Assert.IsTrue(pc is HourlyClassification); HourlyClassification sc = pc as HourlyClassification; Assert.AreEqual(265, sc.Hourly, .001); PaymentSchedule ps = e.Schedule; Assert.IsTrue(ps is WeeklySchedule); PaymentMethod pm = e.Method; Assert.IsTrue(pm is HoldMethod); }
public void TestAddHourlyEmployee() { int empId = 1; AddHourlyEmployee t = new AddHourlyEmployee(empId, "Йорик", "Гочина 23", 2000.00); t.Execute(); Employee e = PayrollDatabase.GetEmployee(empId); Assert.AreEqual("Йорик", e.name); PaymentClassification pc = e.classification; Assert.IsTrue(pc is HourlyClassification); HourlyClassification sc = pc as HourlyClassification; Assert.AreEqual(2000.00, sc.HourlyRate, .001); PaymentSchedule ps = e.schedule; Assert.IsTrue(ps is WeeklySchedule); PaymentMethod pm = e.method; Assert.IsTrue(pm is HoldMethod); }
public void AddSalariedEmployee() { int empid = 3; AddSalariedEmployee t = new AddSalariedEmployee(empid, "Bob", "Home", 1000.00); t.Execute(); Employee e = PayrollDatabase.instance.GetEmployee(empid); Assert.AreEqual("Bob", e.Name); PaymentClassification pc = e.Classification; Assert.IsTrue(pc is SalariedClassification); SalariedClassification sc = pc as SalariedClassification; Assert.AreEqual(1000.00, sc.Salary, .001); PaymentSchedule ps = e.Schedule; Assert.IsTrue(ps is MonthlySchedule); PaymentMethod pm = e.Method; Assert.IsTrue(pm is HoldMethod); }
public void ExecuteTest() { AddEmployeeTransaction addEmp = new AddHourlyEmployee(2, "Cala", "Selee Street", 0.8, database); addEmp.Execute(); Employee emp = database.GetEmployee(2); Assert.IsNotNull(emp); PaymentClassification classification = emp.Classification; PaymentMethod method = emp.Method; PaymentSchedule schedule = emp.Schedule; Assert.AreEqual("Cala", emp.Name); Assert.IsTrue(classification is HourlyClassification); Assert.IsTrue(method is HoldMethod); Assert.IsTrue(schedule is WeeklySchedule); HourlyClassification hourlyClassifiction = classification as HourlyClassification; Assert.AreEqual(0.8, hourlyClassifiction.HourlyRate, 0.0001); }
public void TestAddCommissionedEmployee() { int empId = 1; app.ExexcuteTransaction("addCommissionedEmployee", RequestFactory.rf.MakeCommissionedEmployeeRequest(empId, "Bob", "Home", 0.5, 1000)); Employee e = PayrollDb.GetEmployee(empId); Assert.AreEqual("Bob", e.Name); PaymentClassification pc = e.Classification; Assert.IsTrue(pc is CommissionedClassification); PaymentSchedule ps = e.Schedule; Assert.IsTrue(ps is BiWeeklySchedule); PaymentMethod pm = e.Method; Assert.IsTrue(pm is HoldMethod); }
public PaymentSchedule CreatePaymentSchedule(Template template, IntervalType interval, DateTime dateStart, string dateEnd) { PaymentSchedule paymentSchedule = context.PaymentSchedules.FirstOrDefault(ps => ps.TemplateId == template.Id); if (paymentSchedule != null) { return(null); } DateTime? finishDate = FinishDateParse(dateEnd); PaymentSchedule schedule = new PaymentSchedule { Template = template, IntervalType = interval, Start = dateStart, Finish = finishDate, NextPaymentDate = dateStart }; context.PaymentSchedules.Add(schedule); context.SaveChanges(); return(schedule); }
public void AddCommissionedEmployee() { int empid = 4; AddCommissionedEmployee t = new AddCommissionedEmployee(empid, "Bob", "Home", 265, 10); t.Execute(); Employee e = PayrollDatabase.GetEmployee_Static(empid); Assert.AreEqual("Bob", e.Name); PaymentClassification pc = e.Classification; Assert.IsTrue(pc is CommissionedClassification); CommissionedClassification sc = pc as CommissionedClassification; Assert.AreEqual(10, sc.Commission, .001); Assert.AreEqual(265, sc.Salary, .001); PaymentSchedule ps = e.Schedule; Assert.IsTrue(ps is BiweeklySchedule); PaymentMethod pm = e.Method; Assert.IsTrue(pm is HoldMethod); }
public void ExecuteTest() { AddEmployeeTransaction addEmp = new AddCommissionedEmployee(3, "Dalai", "Bree Street", 0.6, 0.7, database); addEmp.Execute(); Employee emp = database.GetEmployee(3); Assert.IsNotNull(emp); PaymentClassification classification = emp.Classification; PaymentMethod method = emp.Method; PaymentSchedule schedule = emp.Schedule; Assert.AreEqual("Dalai", emp.Name); Assert.IsTrue(classification is CommissionClassification); Assert.IsTrue(method is HoldMethod); Assert.IsTrue(schedule is BiWeeklySchedule); CommissionClassification hourlyClassifiction = classification as CommissionClassification; Assert.AreEqual(0.6, hourlyClassifiction.BaseRate, 0.0001); Assert.AreEqual(0.7, hourlyClassifiction.CommissionRate, 0.0001); }
/// <summary> /// Parses a typed data set of payment installments into a <see cref="PaymentSchedule"/> collection. /// </summary> /// <param name="ds">The typed data set to parse.</param> /// <returns>A collection representing the data contained in the data set.</returns> private PaymentSchedule ParsePaymentSchedule(PaymentPlanTds ds) { PaymentSchedule schedule = new PaymentSchedule(ds.PaymentSchedule.Count); foreach (PaymentPlanTds.PaymentScheduleRow row in ds.PaymentSchedule.Rows) { schedule.Add(new PaymentInstallment(Convert.ToUInt16(row.Number)) { AmountDue = Convert.ToUInt32(row.Amount), DueDate = row.DueDate.Date, AmountPaid = null, }); } // TODO: what the heck is up with start date? DateTime startDate = DateTime.MinValue.Date; foreach (PaymentInstallment installment in schedule.Values) { installment.StartDate = startDate; startDate = installment.DueDate.AddDays(1); } return(schedule); }
public void ChangeSalariedTransaction() { int empid = 12; AddHourlyEmployee t = new AddHourlyEmployee(empid, "Bob", "Home", 23.41); t.Execute(); ChangeSalariedTransaction cht = new ChangeSalariedTransaction(empid, 20.44); cht.Execute(); Employee e = PayrollDatabase.GetEmployee_Static(empid); Assert.IsNotNull(e); PaymentClassification pc = e.Classification; Assert.IsNotNull(pc); Assert.IsTrue(pc is SalariedClassification); SalariedClassification sc = pc as SalariedClassification; Assert.AreEqual(20.44, sc.Salary); PaymentSchedule ps = e.Schedule; Assert.IsTrue(ps is MonthlySchedule); }
public void ChangeHourlyTransaction() { int empId = SetupCommissionedEmployee(); var cht = new ChangeHourlyTransaction(empId, 27.52); cht.Execute(); Employee e = PayrollDatabase.GetEmployee(empId); Assert.NotNull(e); PaymentClassification pc = e.Classification; Assert.NotNull(pc); var hc = Assert.IsType <HourlyClassification>(pc); Assert.Equal(27.52, hc.HourlyRate); PaymentSchedule ps = e.Schedule; Assert.IsType <WeeklySchedule>(ps); }
public void ChangeSalariedTransaction() { int empId = SetupCommissionedEmployee(); var cst = new ChangeSalariedTransaction(empId, 2500.0); cst.Execute(); Employee e = PayrollDatabase.GetEmployee(empId); Assert.NotNull(e); PaymentClassification pc = e.Classification; Assert.NotNull(e); var sc = Assert.IsType <SalariedClassification>(pc); Assert.Equal(2500.0, sc.Salary); PaymentSchedule ps = e.Schedule; Assert.IsType <MonthlySchedule>(ps); }
public void TestChangeHourlyTransactionTest() { int empId = 3; AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Lance", "Home", 2500, 3.2, database); t.Execute(); ChangeHourlyTransaction cht = new ChangeHourlyTransaction(empId, 27.52, database); cht.Execute(); Employee e = database.GetEmployee(empId); Assert.IsNotNull(e); PaymentClassification pc = e.Classification; Assert.IsNotNull(pc); Assert.IsTrue(pc is HourlyClassification); HourlyClassification hc = pc as HourlyClassification; Assert.AreEqual(27.52, hc.HourlyRate, .001); PaymentSchedule ps = e.Schedule; Assert.IsTrue(ps is WeeklySchedule); }
public void ChangeHourlyTransaction() { int empid = 11; AddCommissionedEmployee t = new AddCommissionedEmployee(empid, "Bill", "Home", 23.41, 3.2); t.Execute(); ChangeHourlyTransaction cht = new ChangeHourlyTransaction(empid, 19.84); cht.Execute(); Employee e = PayrollDatabase.GetEmployee_Static(empid); Assert.IsNotNull(e); PaymentClassification pc = e.Classification; Assert.IsNotNull(pc); Assert.IsTrue(pc is HourlyClassification); HourlyClassification hc = pc as HourlyClassification; Assert.AreEqual(19.84, hc.Hourly, .001); PaymentSchedule ps = e.Schedule; Assert.IsTrue(ps is WeeklySchedule); }
/// <summary> /// Creates a scheduled transaction plan XML element /// </summary> /// <param name="schedule">The schedule.</param> /// <param name="paymentInfo">The payment information.</param> /// <returns></returns> private XElement GetPlan(PaymentSchedule schedule, PaymentInfo paymentInfo) { var selectedFrequencyGuid = schedule.TransactionFrequencyValue.Guid.ToString().ToUpper(); if (selectedFrequencyGuid == Rock.SystemGuid.DefinedValue.TRANSACTION_FREQUENCY_ONE_TIME) { // Make sure number of payments is set to 1 for one-time future payments schedule.NumberOfPayments = 1; } XElement planElement = new XElement("plan", new XElement("payments", schedule.NumberOfPayments.HasValue ? schedule.NumberOfPayments.Value.ToString() : "0"), new XElement("amount", paymentInfo.Amount.ToString())); switch (selectedFrequencyGuid) { case Rock.SystemGuid.DefinedValue.TRANSACTION_FREQUENCY_ONE_TIME: planElement.Add(new XElement("month-frequency", "12")); planElement.Add(new XElement("day-of-month", schedule.StartDate.Day.ToString())); break; case Rock.SystemGuid.DefinedValue.TRANSACTION_FREQUENCY_WEEKLY: planElement.Add(new XElement("day-frequency", "7")); break; case Rock.SystemGuid.DefinedValue.TRANSACTION_FREQUENCY_BIWEEKLY: planElement.Add(new XElement("day-frequency", "14")); break; case Rock.SystemGuid.DefinedValue.TRANSACTION_FREQUENCY_MONTHLY: planElement.Add(new XElement("month-frequency", "1")); planElement.Add(new XElement("day-of-month", schedule.StartDate.Day.ToString())); break; } return(planElement); }
public async Task UpdatePaymentSchedule(PaymentSchedule updatedRecord) { this.logger.LogInformation($"{nameof(UpdatePaymentSchedule)}(PaymentScheduleId : {updatedRecord.PaymentScheduleId}, NextPaymentDate : {updatedRecord.NextPaymentDate}, LastPaymentDate : {updatedRecord.LastPaymentDate})"); var query = from paymentSchedule in this.context.PaymentSchedule where paymentSchedule.PaymentScheduleId == updatedRecord.PaymentScheduleId select new { paymentSchedule.NextPaymentDate, paymentSchedule.LastPaymentDate, }; var existingRecords = await query.SingleOrDefaultAsync(); if (existingRecords != null) { var existingNextPaymentDate = existingRecords.NextPaymentDate; var existingLastPaymentDate = existingRecords.LastPaymentDate; if (updatedRecord.NextPaymentDate < existingNextPaymentDate || (updatedRecord.NextPaymentDate == null && existingNextPaymentDate != null)) { this.logger.LogInformation($"Overwrting NextPaymentDate value '{updatedRecord.NextPaymentDate}' with '{existingNextPaymentDate}'"); updatedRecord.NextPaymentDate = existingNextPaymentDate; } if (updatedRecord.LastPaymentDate < existingLastPaymentDate || (updatedRecord.LastPaymentDate == null && existingLastPaymentDate != null)) { this.logger.LogInformation($"Overwrting LastPaymentDate value '{updatedRecord.LastPaymentDate}' with '{existingLastPaymentDate}'"); updatedRecord.LastPaymentDate = existingLastPaymentDate; } } // Create the entity record in the Azure SQL DB: _paymentScheduleWorker.UpdateCreate(updatedRecord); }
public void ChangeCommissionedTransaction() { int empId = SetupSalariedEmployee(); var cct = new ChangeCommissionedTransaction(empId, 2200.0, 3.2); cct.Execute(); Employee e = PayrollDatabase.GetEmployee(empId); Assert.NotNull(e); PaymentClassification pc = e.Classification; Assert.NotNull(pc); var cc = Assert.IsType <CommissionedClassification>(pc); Assert.Equal(2200.0, cc.Salary); Assert.Equal(3.2, cc.CommissionRate); PaymentSchedule ps = e.Schedule; Assert.IsType <BiweeklySchedule>(ps); }
public void TestChangeSalariedTransaction() { int empId = 4; AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Bill", "Home", 2500, 3.2); t.Execute(); ChangeSalariedTransaction cht = new ChangeSalariedTransaction(empId, 5000); cht.Execute(); Employee e = PayrollDatabase.GetEmployee(empId); Assert.IsNotNull(e); PaymentClassification pc = e.Classification; Assert.IsNotNull(pc); Assert.IsTrue(pc is SalariedClassification); SalariedClassification hc = pc as SalariedClassification; Assert.AreEqual(5000, hc.Salary); PaymentSchedule ps = e.Schedule; Assert.IsTrue(ps is MonthlySchedule); }
//------------------------------------------------------------------------- public virtual void test_inflation_monthly() { BusinessDayAdjustment bda = BusinessDayAdjustment.of(FOLLOWING, GBLO); PeriodicSchedule accrualSchedule = PeriodicSchedule.builder().startDate(DATE_14_06_09).endDate(DATE_19_06_09).frequency(Frequency.ofYears(5)).businessDayAdjustment(bda).build(); PaymentSchedule paymentSchedule = PaymentSchedule.builder().paymentFrequency(Frequency.ofYears(5)).paymentDateOffset(DaysAdjustment.ofBusinessDays(2, GBLO)).build(); InflationRateCalculation rateCalc = InflationRateCalculation.builder().index(GB_RPI).indexCalculationMethod(MONTHLY).lag(Period.ofMonths(3)).build(); NotionalSchedule notionalSchedule = NotionalSchedule.of(GBP, 1000d); RateCalculationSwapLeg test = RateCalculationSwapLeg.builder().payReceive(PAY).accrualSchedule(accrualSchedule).paymentSchedule(paymentSchedule).notionalSchedule(notionalSchedule).calculation(rateCalc).build(); assertEquals(test.StartDate, AdjustableDate.of(DATE_14_06_09, bda)); assertEquals(test.EndDate, AdjustableDate.of(DATE_19_06_09, bda)); assertEquals(test.Currency, GBP); assertEquals(test.PayReceive, PAY); assertEquals(test.AccrualSchedule, accrualSchedule); assertEquals(test.PaymentSchedule, paymentSchedule); assertEquals(test.NotionalSchedule, notionalSchedule); assertEquals(test.Calculation, rateCalc); RatePaymentPeriod rpp = RatePaymentPeriod.builder().paymentDate(DaysAdjustment.ofBusinessDays(2, GBLO).adjust(bda.adjust(DATE_19_06_09, REF_DATA), REF_DATA)).accrualPeriods(RateAccrualPeriod.builder().startDate(BusinessDayAdjustment.of(FOLLOWING, GBLO).adjust(DATE_14_06_09, REF_DATA)).endDate(BusinessDayAdjustment.of(FOLLOWING, GBLO).adjust(DATE_19_06_09, REF_DATA)).unadjustedStartDate(DATE_14_06_09).unadjustedEndDate(DATE_19_06_09).yearFraction(1.0).rateComputation(InflationMonthlyRateComputation.of(GB_RPI, YearMonth.from(bda.adjust(DATE_14_06_09, REF_DATA)).minusMonths(3), YearMonth.from(bda.adjust(DATE_19_06_09, REF_DATA)).minusMonths(3))).build()).dayCount(ONE_ONE).currency(GBP).notional(-1000d).build(); ResolvedSwapLeg expected = ResolvedSwapLeg.builder().paymentPeriods(rpp).payReceive(PAY).type(SwapLegType.INFLATION).build(); ResolvedSwapLeg testResolved = test.resolve(REF_DATA); assertEquals(testResolved, expected); }
public void TestAddSalariedEmployee() { int empId = 1; AddEmployeeTransaction t = new AddSalariedEmployee(empId, "Bob", "Home", 1000); t.Execute(); Employee e = PayrollDatabase.GetEmployee(empId); Assert.That(e.Name, Is.EqualTo("Bob")); PaymentClassification pc = e.Classification; Assert.That(pc is SalariedClassification, Is.True); SalariedClassification sc = pc as SalariedClassification; Assert.That(sc.Salary, Is.EqualTo(1000)); PaymentSchedule ps = e.Schedule; Assert.That(ps is MonthlySchedule, Is.True); PaymentMethod pm = e.Method; Assert.That(pm is HoldMethod, Is.True); }
public void TestAddHourlyEmployee() { int empId = 1; AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bob", "Home", 5.00); t.Execute(); Employee e = PayrollDatabase.GetEmployee(empId); Assert.AreEqual("Bob", e.Name); PaymentClassification pc = e.Classification; Assert.IsTrue(pc is HourlyClassification); HourlyClassification sc = pc as HourlyClassification; Assert.AreEqual(5.00, sc.HourlyRate); PaymentSchedule ps = e.Schedule; Assert.IsTrue(ps is WeeklySchedule); PaymentMethod pm = e.Method; Assert.IsTrue(pm is HoldMethod); }
public void TestChangeHourlyTransaction() { int empId = 3; AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Bob", "Home", 2500m, 3.4m); t.Execute(); ChangeClassificationTransaction cht = new ChangeHourlyTransaction(empId, 27.52m); cht.Execute(); Employee e = PayrollDatabase.GetEmployee(empId); Assert.That(e, Is.Not.Null); PaymentClassification pc = e.Classification; Assert.That(pc, Is.Not.Null); Assert.That(pc is HourlyClassification, Is.True); HourlyClassification hc = pc as HourlyClassification; Assert.That(hc.HourlyRate, Is.EqualTo(27.52m)); PaymentSchedule ps = e.Schedule; Assert.That(ps is WeeklySchedule); }
private static PaymentSchedule CalculateStandardSchedule(Tariff tariff, decimal loanAmount, int term, DateTime?startDate) { var rate = tariff.InterestRate * tariff.PmtFrequency / 12; var pmtMainDebt = loanAmount / term; var schedule = new PaymentSchedule(); var remainMainDebt = loanAmount; for (var i = 0; i < term; i++) { var pmtInterest = remainMainDebt * rate; var payBefore = CalculatePaymentDate(startDate, i + 1); if (i == 0 && startDate.HasValue) { pmtInterest *= ((30 - startDate.Value.Day + 1) / 30M); } if (i + 1 == term && startDate.HasValue) { pmtInterest += pmtInterest * ((startDate.Value.Day - 1) / 30M); } if (startDate.HasValue && payBefore > startDate.Value.AddMonths(term)) { payBefore = startDate.Value.AddMonths(term); } var pmt = new Payment { MainDebtAmount = pmtMainDebt, AccruedInterestAmount = pmtInterest, AccruedOn = CalculateAccrualDate(startDate, i), ShouldBePaidBefore = payBefore }; schedule.AddPayment(pmt); remainMainDebt -= pmtMainDebt; } return(RoundPayments(schedule, 2)); }
public void TestChangeSalariedTransaction() { int empId = 3; AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Bob", "Home", 2500m, 3.4m); t.Execute(); ChangeClassificationTransaction cht = new ChangeSalariedTransaction(empId, 3000m); cht.Execute(); Employee e = PayrollDatabase.GetEmployee(empId); Assert.That(e, Is.Not.Null); PaymentClassification pc = e.Classification; Assert.That(pc, Is.Not.Null); Assert.That(pc is SalariedClassification, Is.True); SalariedClassification sc = pc as SalariedClassification; Assert.That(sc.Salary, Is.EqualTo(3000m)); PaymentSchedule ps = e.Schedule; Assert.That(ps is MonthlySchedule); }
public void TestAddHourlyEmployee() { int empId = 2; AddEmployeeTransaction t = new AddHourlyEmployee(empId, "Bob", "Home", 12.75m); t.Execute(); Employee e = PayrollDatabase.GetEmployee(empId); Assert.That(e.Name, Is.EqualTo("Bob")); PaymentClassification pc = e.Classification; Assert.That(pc is HourlyClassification, Is.True); HourlyClassification hc = pc as HourlyClassification; Assert.That(hc.HourlyRate, Is.EqualTo(12.75m)); PaymentSchedule ps = e.Schedule; Assert.That(ps is WeeklySchedule, Is.True); PaymentMethod pm = e.Method; Assert.That(pm is HoldMethod, Is.True); }
/// <summary> /// Gets the payment schedule. /// </summary> /// <returns></returns> private PaymentSchedule GetSchedule() { if (RockTransactionEntry == null) { return(null); } btnFrequency = ((ButtonDropDownList)RockTransactionEntry.FindControl("btnFrequency")); dtpStartDate = ((DatePicker)RockTransactionEntry.FindControl("dtpStartDate")); // Figure out if this is a one-time transaction or a future scheduled transaction if (GetAttributeValue("AllowScheduled").AsBoolean()) { // If a one-time gift was selected for today's date, then treat as a onetime immediate transaction (not scheduled) int oneTimeFrequencyId = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.TRANSACTION_FREQUENCY_ONE_TIME).Id; if (btnFrequency.SelectedValue == oneTimeFrequencyId.ToString() && dtpStartDate.SelectedDate <= RockDateTime.Today) { // one-time immediate payment return(null); } var schedule = new PaymentSchedule(); schedule.TransactionFrequencyValue = DefinedValueCache.Get(btnFrequency.SelectedValueAsId().Value); if (dtpStartDate.SelectedDate.HasValue && dtpStartDate.SelectedDate > RockDateTime.Today) { schedule.StartDate = dtpStartDate.SelectedDate.Value; } else { schedule.StartDate = DateTime.MinValue; } return(schedule); } return(null); }
public void ChangeCommissionedTransaction() { int empid = 13; AddSalariedEmployee t = new AddSalariedEmployee(empid, "Bill", "Home", 23.41); t.Execute(); ChangeCommissionedTransaction cht = new ChangeCommissionedTransaction(empid, 20.44, 10); cht.Execute(); Employee e = PayrollDatabase.GetEmployee_Static(empid); Assert.IsNotNull(e); PaymentClassification pc = e.Classification; Assert.IsNotNull(pc); Assert.IsTrue(pc is CommissionedClassification); CommissionedClassification sc = pc as CommissionedClassification; Assert.AreEqual(10, sc.Commission); Assert.AreEqual(20.44, sc.Salary); PaymentSchedule ps = e.Schedule; Assert.IsTrue(ps is BiweeklySchedule); }
public void Insert(int CurrencySender,int CurrencyReceiver,DateTime TimeToDelivery) { PaymentSchedule item = new PaymentSchedule(); item.CurrencySender = CurrencySender; item.CurrencyReceiver = CurrencyReceiver; item.TimeToDelivery = TimeToDelivery; item.Save(UserName); }
public void Update(int PaymentScheduleKey,int CurrencySender,int CurrencyReceiver,DateTime TimeToDelivery) { PaymentSchedule item = new PaymentSchedule(); item.MarkOld(); item.IsLoaded = true; item.PaymentScheduleKey = PaymentScheduleKey; item.CurrencySender = CurrencySender; item.CurrencyReceiver = CurrencyReceiver; item.TimeToDelivery = TimeToDelivery; item.Save(UserName); }