public void GivenIHaveAnInvoiceWithSomeBillsWithAgreements()
 {
     string invoiceID = "MMM2013005001";
     List<Transaction> transactionList = new List<Transaction>() { new Transaction("Big Payment", 1, 650, new Tax("NOIGIC", 0), 0) };
     DateTime issueDate = new DateTime(2013,10,1);
     Invoice invoice = new Invoice(invoiceID, new InvoiceCustomerData(membersManagementContextData.clubMember), transactionList, issueDate);
     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["MMM2013005001/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);
     ScenarioContext.Current.Add("Invoice", invoice);
     ScenarioContext.Current.Add("AgreementDate", agreementDate);
     ScenarioContext.Current.Add("Bill", invoice.Bills["MMM2013005001/002"]);
 }
 public void WhenIRenegotiateTheBillIntoThreeInstalmentsToPayInAndDaysWithAgreementTerms(
     string billID,
     decimal firstInstalmentAmount,
     decimal secondInstalmentAmount,
     decimal thirdInstalmentAmount,
     int firstInstalmentDueDays,
     int secondInstalmentDueDays,
     int thirdInstalmentDueDays,
     string agreementTerms)
 {
     Invoice invoice = (Invoice)ScenarioContext.Current["Invoice"];
     List<Bill> billsToRenegotiate = new List<Bill>() { invoice.Bills[ScenarioContext.Current["BillID"].ToString()] };
     List<Bill> billsToAdd = new List<Bill>()
     {
         {new Bill("First Instalment", 200, DateTime.Now, DateTime.Now.AddDays(firstInstalmentDueDays))},
         {new Bill("Second Instalment", 200, DateTime.Now, DateTime.Now.AddDays(secondInstalmentDueDays))},
         {new Bill("Third Instalment", 250, DateTime.Now, DateTime.Now.AddDays(thirdInstalmentDueDays))}
     };
     string authorizingPerson = "Club President";
     DateTime agreementDate = DateTime.Now;
     ScenarioContext.Current.Add("AgreementDate", agreementDate);
     PaymentAgreement paymentAgreement = new PaymentAgreement(authorizingPerson, agreementTerms, agreementDate);
     invoicesManager.RenegotiateBillsOnInvoice(invoice, paymentAgreement, billsToRenegotiate, billsToAdd);
 }
Пример #3
0
 private void MarkRenegotiatedBills(List<Bill> billsToMark, PaymentAgreement paymentAgreement)
 {
     foreach (Bill bill in billsToMark) bill.RenegotiateBill(paymentAgreement);
 }
Пример #4
0
 private void ReplaceNegotiatedBills(List<Bill> billsToRenegotiate, List<Bill> billsToAdd, PaymentAgreement paymentAgreement)
 {
     AssignPaymentAgreementToBills(paymentAgreement, billsToAdd);
     MarkRenegotiatedBills(billsToRenegotiate, paymentAgreement);
     AddBillsToInvoice(billsToAdd);
 }
Пример #5
0
 public void RenegotiateBillsIntoInstalments(PaymentAgreement paymentAgreement, List<Bill> billsToRenegotiate, List<Bill> billsToAdd)
 {
     this.paymentAgreements.Add(paymentAgreement.AgreementDate.Date, paymentAgreement);
     ReplaceNegotiatedBills(billsToRenegotiate, billsToAdd, paymentAgreement);
 }
Пример #6
0
 private void AssignPaymentAgreementToBills(PaymentAgreement paymentAgreement, List<Bill> billsList)
 {
     foreach (Bill bill in billsList) bill.AssignAgreement(paymentAgreement);
 }
 public void WhenReplacingBillsThePaymentAgreementIsAssociatedToReplacedAndReplacingBills()
 {
     Invoice invoice = new Invoice(invoiceCustomerData, transactionList, DateTime.Now);
     string authorizingPerson = "Club President";
     string agreementTerms = "New Payment Agreement";
     DateTime agreementDate = DateTime.Now.Date;
     PaymentAgreement paymentAgreement = new PaymentAgreement(authorizingPerson, agreementTerms, agreementDate);
     List<Bill> billsToRenegotiate = new List<Bill>() { invoice.Bills["INV2013005000/001"] };
     List<Bill> billsToAdd = new List<Bill>(unassignedBillsList);
     invoice.RenegotiateBillsIntoInstalments(paymentAgreement, billsToRenegotiate, billsToAdd);
     billsToRenegotiate.ForEach(bill => Assert.AreEqual(Bill.BillPaymentResult.Renegotiated, bill.PaymentResult));
     billsToRenegotiate.ForEach(bill => Assert.AreEqual("New Payment Agreement", bill.RenegotiationAgreement.AgreementTerms));
     billsToAdd.ForEach(bill => Assert.AreEqual("New Payment Agreement", bill.PaymentAgreements[agreementDate].AgreementTerms));
 }
 public void RenegotiateBillsOnInvoice(Invoice invoice, PaymentAgreement paymentAgreement, List<Bill> billsToRenegotiate, List<Bill> billsToAdd)
 {
     invoice.RenegotiateBillsIntoInstalments(paymentAgreement, billsToRenegotiate, billsToAdd);
 }
 public void TheBillIDOfTheReplpacingBillsAreCalculatedByTheInvoiceAndHaveConsecutiveNumbers()
 {
     Invoice invoice = new Invoice(invoiceCustomerData, transactionList, DateTime.Now);
     string authorizingPerson = "Club President";
     string agreementTerms = "New Payment Agreement";
     DateTime agreementDate = DateTime.Now;
     PaymentAgreement paymentAgreement = new PaymentAgreement(authorizingPerson, agreementTerms, agreementDate);
     List<Bill> billsToRenegotiate = new List<Bill>() { invoice.Bills["INV2013005000/001"] };
     List<Bill> billsToAdd = new List<Bill>(unassignedBillsList);
     invoice.RenegotiateBillsIntoInstalments(paymentAgreement, billsToRenegotiate, billsToAdd);
     Assert.AreEqual("INV2013005000/002", billsToAdd[0].BillID);
     Assert.AreEqual("INV2013005000/003", billsToAdd[1].BillID);
     Assert.AreEqual("INV2013005000/004", billsToAdd[2].BillID);
 }
 public void WhenABillIsUnpaidIfThereIsAnAgreementAssociatedToItTheAgreementIsCancelled()
 {
     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);
     Bill bill = invoice.Bills["MMM2013005001/002"];
     Assert.AreEqual(PaymentAgreement.PaymentAgreementStatus.Active, bill.PaymentAgreements[new DateTime(2013, 10, 1)].PaymentAgreementActualStatus);
     bill.CheckDueDate(new DateTime(2013, 11, 30));
     Assert.AreEqual(PaymentAgreement.PaymentAgreementStatus.NotAcomplished, bill.PaymentAgreements[new DateTime(2013, 10, 1)].PaymentAgreementActualStatus);
 }
 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 ICanReplaceASetOfBillsInAnInvoiceWithASetOfNewBillsThatAddTheSameAmountByAddingABillPaymentAgreement()
 {
     decimal invoiceInitialAmount;
     Invoice invoice = new Invoice(invoiceCustomerData, transactionList, DateTime.Now);
     invoiceInitialAmount = invoice.NetAmount;
     string authorizingPerson = "Club President";
     string agreementTerms = "New Payment Agreement";
     DateTime agreementDate = DateTime.Now.Date;
     PaymentAgreement paymentAgreement = new PaymentAgreement(authorizingPerson, agreementTerms, agreementDate);
     List<Bill> billsToRenegotiate = new List<Bill>() {invoice.Bills["INV2013005000/001"]};
     List<Bill> billsToAdd = new List<Bill>(unassignedBillsList);
     invoice.RenegotiateBillsIntoInstalments(paymentAgreement, billsToRenegotiate, billsToAdd);
     Assert.AreEqual(invoiceInitialAmount, invoice.NetAmount);
 }
 public void APaymentAgreementIsCorrectlyCreated()
 {
     PaymentAgreement paymentAgreement = new PaymentAgreement("Club President", "New Payment Agreement", new DateTime(2013, 11, 11));
     Assert.AreEqual("Club President", paymentAgreement.AuthorizingPerson);
     Assert.AreEqual("New Payment Agreement", paymentAgreement.AgreementTerms);
     Assert.AreEqual(new DateTime(2013,11,11), paymentAgreement.AgreementDate);
 }
Пример #14
0
 public void RenegotiateBill(PaymentAgreement renegotiationAgreement)
 {
     paymentResult = BillPaymentResult.Renegotiated;
     this.renegotiationAgreement = renegotiationAgreement;
 }
Пример #15
0
 public void AssignAgreement(PaymentAgreement paymentAgreement)
 {
     this.paymentAgreements.Add(paymentAgreement.AgreementDate.Date, paymentAgreement);
 }