public void WhenAllTheBillsArePaid() { Invoice invoice = (Invoice)ScenarioContext.Current["Invoice"]; 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); billsManager.PayBill(invoice, invoice.Bills["MMM2013005001/002"], payment200); billsManager.PayBill(invoice, invoice.Bills["MMM2013005001/003"], payment250); }
public void WhenTheBillIsPaidInCash() { Invoice invoice = (Invoice)ScenarioContext.Current["Invoice"]; Bill bill = (Bill)ScenarioContext.Current["Bill"]; CashPaymentMethod cashPaymentMethod = new CashPaymentMethod(); Payment payment = new Payment(bill.Amount, new DateTime(2013, 11, 11), cashPaymentMethod); billsManager.PayBill(invoice, bill, payment); }
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 GivenTheMemberHasAssociatedCashAsPaymentMethod() { ClubMember clubMember = (ClubMember)ScenarioContext.Current["Member1"]; CashPaymentMethod cashPaymnentMethod = new CashPaymentMethod(); clubMember.SetDefaultPaymentMethod(cashPaymnentMethod); }
public void WhenPayingABillTheInvoiceTotalAmountToCollectIsCorrectlyUpdates() { string invoiceID = "MMM2013005001"; List<Bill> assignedBillsList = new List<Bill>(unassignedBillsList); assignedBillsList[0].BillID = "MMM2013005001/001"; assignedBillsList[1].BillID = "MMM2013005001/002"; assignedBillsList[2].BillID = "MMM2013005001/003"; Invoice invoice = new Invoice(invoiceID, invoiceCustomerData, transactionList, assignedBillsList, DateTime.Now); Assert.AreEqual((decimal)650, invoice.BillsTotalAmountToCollect); CashPaymentMethod cashPayment = new CashPaymentMethod(); DateTime paymentDate = new DateTime(2013, 11, 11); Payment payment = new Payment((decimal)200, paymentDate, cashPayment); invoice.Bills["MMM2013005001/001"].PayBill(payment); Assert.AreEqual((decimal)450, invoice.BillsTotalAmountToCollect); }
public void WhenPayingABillTheBillPaymentDateIsStored() { Bill bill = new Bill("MMM201300015/001", "An easy to pay bill", 1, DateTime.Now, DateTime.Now.AddYears(10)); CashPaymentMethod cashPayment = new CashPaymentMethod(); DateTime paymentDate = new DateTime(2013, 11, 11); Payment payment = new Payment(bill.Amount, paymentDate, cashPayment); bill.PayBill(payment); Assert.AreEqual(paymentDate, bill.Payment.PaymentDate); }
public void OnlyPaymentsForTheTotalBillAmoutAreAccepted() { Bill bill = new Bill("MMM201300015/001", "An easy to pay bill", 1, DateTime.Now, DateTime.Now.AddYears(10)); CashPaymentMethod cashPaymentMethod = new CashPaymentMethod(); DateTime paymentDate = new DateTime(2013, 11, 11); Payment payment = new Payment((decimal)2, paymentDate, cashPaymentMethod); try { bill.PayBill(payment); } catch (ArgumentException exception) { Assert.AreEqual("Only payments for the bill total amount are accepted", exception.GetMessageWithoutParamName()); throw exception; } }
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); }
public void APaymentIsCorrectlyCreated() { CashPaymentMethod cashPayment = new CashPaymentMethod(); DateTime paymentDate = new DateTime(2013,11,11); Payment payment= new Payment((decimal)100, paymentDate , cashPayment); Assert.AreEqual((decimal)100, payment.PaymentAmount); Assert.AreEqual(paymentDate, payment.PaymentDate); Assert.AreEqual(cashPayment, payment.PaymentMethod); }