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 WhenTheBillIsPaidByBankTransfer()
 {
     Invoice invoice = (Invoice)ScenarioContext.Current["Invoice"];
     Bill bill = (Bill)ScenarioContext.Current["Bill"];
     BankAccount transferorAccount = new BankAccount(new ClientAccountCodeCCC("20381111401111111111"));
     BankAccount transfereeAccount = new BankAccount(new ClientAccountCodeCCC("21001111301111111111"));
     BankTransferPaymentMethod bankTransferPaymentMethod = new BankTransferPaymentMethod(transferorAccount, transfereeAccount);
     Payment payment = new Payment(bill.Amount, new DateTime(2013, 11, 11), bankTransferPaymentMethod);
     billsManager.PayBill(invoice, bill, payment);
 }
 public void WhenTheBillIsPaidByDirectDebit()
 {
     Invoice invoice = (Invoice)ScenarioContext.Current["Invoice"];
     Bill bill = (Bill)ScenarioContext.Current["Bill"];
     int internalReferenceNumber = 2645;
     BankAccount bankAccount = new BankAccount(new ClientAccountCodeCCC("12345678061234567890"));
     DateTime directDebitMandateCreationDate = new DateTime(2013, 11, 11);
     string debtorname = membersManagementContextData.clubMember.FullName;
     DirectDebitMandate directDebitMandate = new DirectDebitMandate(internalReferenceNumber, directDebitMandateCreationDate, bankAccount, debtorname);
     string directDebitTransactionPaymentIdentification = "201311110000123456";
     DirectDebitPaymentMethod directDebitPaymentMethod = new DirectDebitPaymentMethod(directDebitMandate, directDebitTransactionPaymentIdentification);
     DateTime paymentDate = new DateTime(2013, 11, 11);
     Payment payment = new Payment(bill.Amount, paymentDate, directDebitPaymentMethod);
     billsManager.PayBill(invoice, bill, payment);
 }
 public void PayBill(Invoice invoiceContainingTheBill, Bill billToPay, Payment payment)
 {
     billToPay.PayBill(payment);
     CheckIfAgreementIsAccomplished(invoiceContainingTheBill, billToPay);
     invoiceContainingTheBill.CheckIfInvoiceIsFullPaid();
 }
 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 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 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 WhenABillIsPaidByDirectDebitTheDebtorAccountAndTheDirectDebitTransactionPaymentIdentificartionAreStored()
 {
     Bill bill = new Bill("MMM201300015/001", "An easy to pay bill", 1, DateTime.Now, DateTime.Now.AddYears(10));
     int internalReferenceNumber = 2645;
     BankAccount bankAccount = new BankAccount(new ClientAccountCodeCCC("12345678061234567890"));
     DateTime directDebitMandateCreationDate = new DateTime(2013, 11, 11);
     DirectDebitMandate directDebitMandate = new DirectDebitMandate(internalReferenceNumber, directDebitMandateCreationDate, bankAccount, "NoName");
     string directDebitTransactionPaymentIdentification = "201311110000123456";
     DirectDebitPaymentMethod directDebitTransfermethod = new DirectDebitPaymentMethod(directDebitMandate, directDebitTransactionPaymentIdentification);
     DateTime paymentDate = new DateTime(2013, 11, 11);
     Payment payment = new Payment(bill.Amount, paymentDate, directDebitTransfermethod);
     bill.PayBill(payment);
     Assert.AreEqual("12345678061234567890", ((DirectDebitPaymentMethod)bill.Payment.PaymentMethod).DirectDebitMandate.BankAccount.CCC.CCC);
     Assert.AreEqual("201311110000123456", ((DirectDebitPaymentMethod)bill.Payment.PaymentMethod).DDTXPaymentIdentification);
 }
 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 WhenABillIsPaidByBankTransferTheTransferorAndTheTransfereeAccountsAreStored()
 {
     Bill bill = new Bill("MMM201300015/001", "An easy to pay bill", 1, DateTime.Now, DateTime.Now.AddYears(10));
     BankAccount transferorAccount = new BankAccount(new ClientAccountCodeCCC("20381111401111111111"));
     BankAccount transfereeAccount = new BankAccount(new ClientAccountCodeCCC("21001111301111111111"));
     BankTransferPaymentMethod bankTransferPaymentMethod = new BankTransferPaymentMethod(transferorAccount, transfereeAccount);
     DateTime paymentDate = new DateTime(2013, 11, 11);
     Payment payment = new Payment(bill.Amount, paymentDate, bankTransferPaymentMethod);
     bill.PayBill(payment);
     Assert.AreEqual(transferorAccount, ((BankTransferPaymentMethod)bill.Payment.PaymentMethod).TransferorAccount);
     Assert.AreEqual(transfereeAccount, ((BankTransferPaymentMethod)bill.Payment.PaymentMethod).TransfereeAccount);
 }
 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);
 }
Ejemplo n.º 14
0
 public void PayBill(Payment payment)
 {
     if (this.amount != payment.PaymentAmount)
         throw new System.ArgumentException("Only payments for the bill total amount are accepted", "payment");
     this.payment = payment;
     paymentResult = BillPaymentResult.Paid;
 }