コード例 #1
0
 public void CheckDueDate(Invoice invoiceContainingTheBill, Bill billToCheck, DateTime todayDate)
 {
     bool itWasToCollect = billToCheck.PaymentResult == Bill.BillPaymentResult.ToCollect;
     billToCheck.CheckDueDate(todayDate);
     bool itIsUnpaid = billToCheck.PaymentResult == Bill.BillPaymentResult.Unpaid;
     if (itWasToCollect && itIsUnpaid) invoiceContainingTheBill.SetInvoiceAsUnpaid();
 }
コード例 #2
0
 private PaymentAgreement GetActiveAgreementFromBill(Bill bill)
 {
     if (bill.PaymentAgreements.Count == 0) return null;
     PaymentAgreement activePaymentAgreement =
         bill.PaymentAgreements.First(keyValuePair => keyValuePair.Value.PaymentAgreementActualStatus == PaymentAgreement.PaymentAgreementStatus.Active).Value;
     return activePaymentAgreement;
 }
コード例 #3
0
 public void ABillPastDueDateIsMarkedAsUnpaid()
 {
     Bill bill = new Bill("MMM201300015/001", "This bill is past due date", 1, new DateTime(2013, 11, 11), new DateTime(2013, 11, 15));
     Assert.AreEqual(Bill.BillPaymentResult.ToCollect, bill.PaymentResult);
     bill.CheckDueDate(new DateTime(2013,11,30));
     Assert.AreEqual(Bill.BillPaymentResult.Unpaid, bill.PaymentResult);
 }
コード例 #4
0
 public void ABillIsCorrectlyCreated()
 {
     DateTime issueDate = new DateTime(2013, 11, 11);
     DateTime dueDate = issueDate.AddYears(10);
     Bill bill = new Bill("MMM201300015/001", "An easy to pay bill", 1, issueDate, dueDate);
     Assert.AreEqual("MMM201300015/001", bill.BillID);
     Assert.AreEqual("An easy to pay bill", bill.Description);
     Assert.AreEqual((decimal)1, bill.Amount);
     Assert.AreEqual(issueDate, bill.IssueDate);
     Assert.AreEqual(dueDate, bill.DueDate);
 }
コード例 #5
0
 private void CheckIfAgreementIsAccomplished(Invoice invoiceContainingTheBill, Bill paidBill)
 {
     PaymentAgreement activeAgreement = GetActiveAgreementFromBill(paidBill);
     if (activeAgreement!=null)
     {
         DateTime agreementDate = activeAgreement.AgreementDate;
         var billsIncludedInTheAgreement = invoiceContainingTheBill.Bills.Values.Where(bill => bill.PaymentAgreements.ContainsKey(agreementDate));
         var unpaidBillsFromAgreement = billsIncludedInTheAgreement.Where(bill => bill.PaymentResult == Bill.BillPaymentResult.ToCollect);
         if (unpaidBillsFromAgreement.Count() == 0)
         {
             foreach (Bill bill in billsIncludedInTheAgreement)
                 bill.PaymentAgreements[agreementDate].PaymentAgreementActualStatus = PaymentAgreement.PaymentAgreementStatus.Accomplished;
             invoiceContainingTheBill.PaymentAgreements[agreementDate].PaymentAgreementActualStatus = PaymentAgreement.PaymentAgreementStatus.Accomplished;
         }
     }
 }
コード例 #6
0
 private decimal GetBillsTotalAmount(Bill.BillPaymentResult paymentResult)
 {
     decimal amount = 0;
     foreach (KeyValuePair<string, Bill> bill in invoiceBills)
     {
         if (bill.Value.PaymentResult == paymentResult) amount += bill.Value.Amount;
     }
     return amount;
 }
コード例 #7
0
 public void ABillShouldHaveABillID()
 {
     Bill bill = new Bill("MMM201300015/001", "An easy to pay bill", 1, DateTime.Now, DateTime.Now.AddYears(10));
     Assert.AreEqual("MMM201300015/001", bill.BillID);
 }
コード例 #8
0
 public void AsigningAPaymentMethodToANewlyCreatedBill()
 {
     Bill bill = new Bill("MMM201300015/001", "An easy to pay bill", 1, DateTime.Now, DateTime.Now.AddYears(10));
     bill.AssignedPaymentMethod = new CashPaymentMethod();
     Assert.AreEqual(typeof(CashPaymentMethod),bill.AssignedPaymentMethod.GetType());
 }
コード例 #9
0
 public void WhenIRenewTheDueDateOfABillItIsCorrectlyUpdated()
 {
     Bill bill = new Bill("MMM201300015/001", "This bill is past due date", 1, new DateTime(2013, 11, 11), new DateTime(2013, 11, 15));
     DateTime newDueDate = new DateTime(2013, 11, 30);
     DateTime todayDate = new DateTime(2013, 11, 20);
     bill.RenewDueDate(newDueDate, todayDate);
     Assert.AreEqual(newDueDate, bill.DueDate);
 }
コード例 #10
0
 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);
 }
コード例 #11
0
 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);
 }
コード例 #12
0
 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;
     }
 }
コード例 #13
0
 public void IfTheBillIsNotPastDueDateItKeepsToCollect()
 {
     Bill bill = new Bill("MMM201300015/001", "This bill is not past due date", 1, new DateTime(2013, 11, 01), new DateTime(2013, 12, 01));
     Assert.AreEqual(Bill.BillPaymentResult.ToCollect, bill.PaymentResult);
     bill.CheckDueDate(new DateTime(2013, 11, 30));
     Assert.AreEqual(Bill.BillPaymentResult.ToCollect, bill.PaymentResult);
 }
コード例 #14
0
 public void ByDefaultABillIsGeneratedWithoutAPaymentMethod()
 {
     Bill bill = new Bill("MMM201300015/001","An easy to pay bill", 1, DateTime.Now, DateTime.Now.AddYears(10));
     Assert.IsNull(bill.AssignedPaymentMethod);
 }
コード例 #15
0
 public void BillIDCanBeNullForLaterInitializationWhenAssignedToInvoices()
 {
     Bill bill = new Bill("An easy to pay bill", 1, DateTime.Now, DateTime.Now.AddYears(10));
     Assert.IsNull(bill.BillID);
 }
コード例 #16
0
 public void PayBill(Invoice invoiceContainingTheBill, Bill billToPay, Payment payment)
 {
     billToPay.PayBill(payment);
     CheckIfAgreementIsAccomplished(invoiceContainingTheBill, billToPay);
     invoiceContainingTheBill.CheckIfInvoiceIsFullPaid();
 }
コード例 #17
0
 public void RenewBillDueDate(Invoice invoiceContainingTheBill, Bill billToRenew, DateTime newDueDate, DateTime todayDate)
 {
     billToRenew.RenewDueDate(newDueDate, todayDate);
     invoiceContainingTheBill.SetInvoiceToBePaidIfHasNoUnpaidBills();
 }
コード例 #18
0
 public void WhenIRenewTheDueDateOfAPastDueDateBillTheBillIsSetAgainToToCollect()
 {
     Bill bill = new Bill("MMM201300015/001", "This bill is past due date", 1, new DateTime(2013, 11, 11), new DateTime(2013, 11, 15));
     DateTime newDueDate = new DateTime(2013, 11, 30);
     DateTime todayDate = new DateTime(2013, 11, 20);
     bill.CheckDueDate(todayDate);
     Assert.AreEqual(Bill.BillPaymentResult.Unpaid, bill.PaymentResult);
     bill.RenewDueDate(newDueDate, todayDate);
     Assert.AreEqual(Bill.BillPaymentResult.ToCollect, bill.PaymentResult);
 }
コード例 #19
0
 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);
 }
コード例 #20
0
 public void AddBilllToExistingDirectDebitTransaction(DirectDebitTransaction directDebitTransaction, Bill bill)
 {
     directDebitTransaction.AddBill(bill);
 }