public ManageBillsFeatureSteps( MembersManagementContextData membersManagementContextData, InvoiceContextData invoiceContextData) { this.membersManagementContextData = membersManagementContextData; this.invoiceContextData = invoiceContextData; invoicesManager = new InvoicesManager(); billsManager = new BillsManager(); }
public void WhenTheDueDateOfABillInAnUnpaidInvoiceisRenewedTheBillIsSetAgainToBePaid() { BillsManager billsManager = new BillsManager(); string invoiceID = "MMM2013005001"; List<Bill> billsList = new List<Bill>() { {new Bill("MMM2013005001/001", "First Instalment", 200, new DateTime(2013,10,1), new DateTime(2013,11,1))}, {new Bill("MMM2013005001/002", "Second Instalment", 200, new DateTime(2013,10,1), new DateTime(2013,12,1))}, {new Bill("MMM2013005001/003", "Third Instalment", 250, new DateTime(2013,10,1), new DateTime(2014,1,1))} }; Invoice invoice = new Invoice(invoiceID, invoiceCustomerData, transactionsList, billsList, DateTime.Now); Assert.AreEqual(Invoice.InvoicePaymentState.ToBePaid, invoice.InvoiceState); foreach (Bill bill in invoice.Bills.Values) { billsManager.CheckDueDate(invoice, bill, new DateTime(2013, 11, 11)); } Assert.AreEqual(Invoice.InvoicePaymentState.Unpaid, invoice.InvoiceState); Assert.AreEqual(Bill.BillPaymentResult.Unpaid, invoice.Bills["MMM2013005001/001"].PaymentResult); Assert.AreEqual(Bill.BillPaymentResult.ToCollect, invoice.Bills["MMM2013005001/002"].PaymentResult); Assert.AreEqual(Bill.BillPaymentResult.ToCollect, invoice.Bills["MMM2013005001/003"].PaymentResult); DateTime renewDate = new DateTime(2013, 11, 30); DateTime todayDate = new DateTime(2013, 11, 20); billsManager.RenewBillDueDate(invoice, invoice.Bills["MMM2013005001/001"], renewDate, todayDate); Assert.AreEqual(Bill.BillPaymentResult.ToCollect, invoice.Bills["MMM2013005001/001"].PaymentResult); Assert.AreEqual(Invoice.InvoicePaymentState.ToBePaid, invoice.InvoiceState); }
public void WhenABillIsUnpaidTheInvoiceIsSetAsUnpaidButTheRestOfTheBillsRemailToCollect() { BillsManager billsManager = new BillsManager(); string invoiceID = "MMM2013005001"; List<Bill> billsList = new List<Bill>() { {new Bill("MMM2013005001/001", "First Instalment", 200, new DateTime(2013,10,1), new DateTime(2013,11,1))}, {new Bill("MMM2013005001/002", "Second Instalment", 200, new DateTime(2013,10,1), new DateTime(2013,12,1))}, {new Bill("MMM2013005001/003", "Third Instalment", 250, new DateTime(2013,10,1), new DateTime(2014,1,1))} }; Invoice invoice = new Invoice(invoiceID, invoiceCustomerData, transactionsList, billsList, DateTime.Now); foreach (Bill bill in invoice.Bills.Values) { billsManager.CheckDueDate(invoice, bill, new DateTime(2013, 11, 11)); } Assert.AreEqual(Invoice.InvoicePaymentState.Unpaid, invoice.InvoiceState); Assert.AreEqual(Bill.BillPaymentResult.Unpaid, invoice.Bills["MMM2013005001/001"].PaymentResult); Assert.AreEqual(Bill.BillPaymentResult.ToCollect, invoice.Bills["MMM2013005001/002"].PaymentResult); Assert.AreEqual(Bill.BillPaymentResult.ToCollect, invoice.Bills["MMM2013005001/003"].PaymentResult); }
public void WhenPayingABillIfThereAreNoMoreBillsToCollectTheInvoiceIsMarkedAsPaid() { BillsManager billsManager = new BillsManager(); string invoiceID = "MMM2013005001"; List<Bill> billsList = new List<Bill>() { {new Bill("MMM2013005001/001", "First Instalment", 200, DateTime.Now, DateTime.Now.AddDays(30))}, {new Bill("MMM2013005001/002", "Second Instalment", 200, DateTime.Now, DateTime.Now.AddDays(60))}, {new Bill("MMM2013005001/003", "Third Instalment", 250, DateTime.Now, DateTime.Now.AddDays(90))} }; Invoice invoice = new Invoice(invoiceID, invoiceCustomerData, transactionsList, billsList, DateTime.Now); Assert.AreEqual(Invoice.InvoicePaymentState.ToBePaid, invoice.InvoiceState); CashPaymentMethod cashPayment = new CashPaymentMethod(); DateTime paymentDate = new DateTime(2013, 11, 11); Payment payment200 = new Payment((decimal)200, paymentDate, cashPayment); Payment payment250 = new Payment((decimal)250, paymentDate, cashPayment); billsManager.PayBill(invoice, invoice.Bills["MMM2013005001/001"], payment200); Assert.AreEqual(Invoice.InvoicePaymentState.ToBePaid, invoice.InvoiceState); billsManager.PayBill(invoice, invoice.Bills["MMM2013005001/002"], payment200); Assert.AreEqual(Invoice.InvoicePaymentState.ToBePaid, invoice.InvoiceState); billsManager.PayBill(invoice, invoice.Bills["MMM2013005001/003"], payment250); Assert.AreEqual(Invoice.InvoicePaymentState.Paid, invoice.InvoiceState); }
public void IfTheLastBillOfAnAgreementIsPaidTheAgreementIsConsideredAccompllished() { Invoice invoice = new Invoice(invoiceCustomerData, transactionList, DateTime.Now); string authorizingPerson = "Club President"; string agreementTerms = "New Payment Agreement"; DateTime agreementDate = new DateTime(2013, 10, 1); PaymentAgreement paymentAgreement = new PaymentAgreement(authorizingPerson, agreementTerms, agreementDate); List<Bill> billsToRenegotiate = new List<Bill>() { invoice.Bills["INV2013005000/001"] }; List<Bill> billsToAdd = new List<Bill>() { {new Bill("MMM2013005001/002", "First Instalment", 200, new DateTime(2013,10,1), new DateTime(2013,11,1))}, {new Bill("MMM2013005001/003", "Second Instalment", 200, new DateTime(2013,10,1), new DateTime(2013,12,1))}, {new Bill("MMM2013005001/004", "Third Instalment", 250, new DateTime(2013,10,1), new DateTime(2014,1,1))} }; invoice.RenegotiateBillsIntoInstalments(paymentAgreement, billsToRenegotiate, billsToAdd); BillsManager billsManager = new BillsManager(); CashPaymentMethod cashPayment = new CashPaymentMethod(); DateTime paymentDate = new DateTime(2013, 11, 11); Payment payment200 = new Payment((decimal)200, paymentDate, cashPayment); Payment payment250 = new Payment((decimal)250, paymentDate, cashPayment); billsManager.PayBill(invoice, invoice.Bills["MMM2013005001/002"], payment200); Assert.AreEqual(PaymentAgreement.PaymentAgreementStatus.Active, invoice.Bills["MMM2013005001/002"].PaymentAgreements[agreementDate].PaymentAgreementActualStatus); billsManager.PayBill(invoice, invoice.Bills["MMM2013005001/003"], payment200); Assert.AreEqual(PaymentAgreement.PaymentAgreementStatus.Active, invoice.Bills["MMM2013005001/003"].PaymentAgreements[agreementDate].PaymentAgreementActualStatus); billsManager.PayBill(invoice, invoice.Bills["MMM2013005001/004"], payment250); Assert.AreEqual(PaymentAgreement.PaymentAgreementStatus.Accomplished, invoice.Bills["MMM2013005001/004"].PaymentAgreements[agreementDate].PaymentAgreementActualStatus); Assert.AreEqual(PaymentAgreement.PaymentAgreementStatus.Accomplished, invoice.Bills["MMM2013005001/002"].PaymentAgreements[agreementDate].PaymentAgreementActualStatus); Assert.AreEqual(PaymentAgreement.PaymentAgreementStatus.Accomplished, invoice.Bills["MMM2013005001/003"].PaymentAgreements[agreementDate].PaymentAgreementActualStatus); }