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(); }
public static void ClassInit(TestContext context) { BillingSequenceNumbersMock invoiceDataManagerMock = new BillingSequenceNumbersMock(); BillingDataManager.Instance.SetBillingSequenceNumberCollaborator(invoiceDataManagerMock); BillingDataManager.Instance.InvoiceSequenceNumber=5000; invoicesManager = new InvoicesManager(); clubMembers = new Dictionary<string, ClubMember>() { {"00001", new ClubMember("00001", "Francisco", "Gómez-Caldito", "Viseas")}, {"00002", new ClubMember("00002", "Pedro", "Pérez", "Gómez")} }; creditor = new Creditor("G35008770", "Real Club Náutico de Gran Canaria"); creditorAgent = new CreditorAgent(new BankCode("2100", "CaixaBank","CAIXESBBXXX")); directDebitInitiationContract = new DirectDebitInitiationContract( new BankAccount(new InternationalAccountBankNumberIBAN("ES5621001111301111111111")), creditor.NIF, "777", creditorAgent); var directDebitmandateslist = new[] { new {clubMemberID = "00001", internalReference = 1234, ccc = "21002222002222222222" }, new {clubMemberID = "00002", internalReference = 1235, ccc = "21003333802222222222" } }; foreach (var ddM in directDebitmandateslist) { DirectDebitMandate directDebitMandate = new DirectDebitMandate( ddM.internalReference, new DateTime(2013,11,11), new BankAccount(new ClientAccountCodeCCC(ddM.ccc)), clubMembers[ddM.clubMemberID].FullName); clubMembers[ddM.clubMemberID].AddDirectDebitMandate(directDebitMandate); } var billsList = new[] { new {clubMemberID = "00001", Amount = 79, transactionDescription = "Cuota Social Octubre 2013" }, new {clubMemberID = "00002", Amount = 79, transactionDescription="Cuota Social Octubre 2013" }, new {clubMemberID = "00002", Amount = 79, transactionDescription="Cuota Social Noviembre 2013"} }; foreach (var bill in billsList) { List<Transaction> transaction = new List<Transaction>() { new Transaction(bill.transactionDescription,1,bill.Amount,new Tax("NoTAX",0),0) }; ClubMember clubMember = clubMembers[bill.clubMemberID]; InvoiceCustomerData invoiceCustomerData = new InvoiceCustomerData(clubMember); Invoice invoice = new Invoice(invoiceCustomerData, transaction, new DateTime(2013, 11, 11)); invoicesManager.AddInvoiceToClubMember(invoice, clubMember); } spanishBankCodes = new BankCodes(@"XMLFiles\SpanishBankCodes.xml", BankCodes.BankCodesFileFormat.XML); }
public void GivenIHaveAnInvoiceForTheService(string serviceName) { ClubService clubService = invoiceContextData.servicesDictionary[serviceName]; DateTime issueDate = DateTime.Now; List<Transaction> serviceChargeList = new List<Transaction> { new ServiceCharge(clubService) }; Invoice invoice = new Invoice(new InvoiceCustomerData(membersManagementContextData.clubMember), serviceChargeList, issueDate); ScenarioContext.Current.Add("Invoice", invoice); invoicesManager.AddInvoiceToClubMember(invoice, membersManagementContextData.clubMember); }
public void AmendingInvoiceHasTheSameInvoiceIDButWithDifferentPrefix() { DateTime issueDate = DateTime.Parse("01/01/2013"); billDataManager.InvoiceSequenceNumber = 5000; Invoice invoice = new Invoice(invoiceCustomerData, transactionsList, issueDate); AmendingInvoice amendingInvoice = new AmendingInvoice(invoice); Assert.AreEqual("INV2013005000", invoice.InvoiceID); Assert.AreEqual("AMN2013005000", amendingInvoice.InvoiceID); }
public void AnInvoiceIsCorrectlyAddedToClubMember() { clubMemberDataManager.MemberIDSequenceNumber = 5; ClubMember clubMember = new ClubMember("Francisco", "Gomez-Caldito", "Viseas"); Assert.AreEqual(0, clubMember.InvoicesList.Count); InvoiceCustomerData invoiceCustomerData = new InvoiceCustomerData(clubMember); Invoice invoice = new Invoice( new InvoiceCustomerData(clubMember), new List<Transaction>() { new Transaction("Kajak Rent", 1, 50, new Tax("No Tax", 0), 0) }, DateTime.Now); clubMember.AddInvoice(invoice); Assert.IsNotNull(clubMember.InvoicesList[invoice.InvoiceID]); }
public void AnInvoiceIsCorrectlyCancelled() { clubMemberDataManager.MemberIDSequenceNumber = 5; ClubMember clubMember = new ClubMember("Francisco", "Gomez-Caldito", "Viseas"); InvoiceCustomerData invoiceCustomerData = new InvoiceCustomerData(clubMember); Invoice invoice = new Invoice( new InvoiceCustomerData(clubMember), new List<Transaction>() { new Transaction("Kajak Rent", 1, 50, new Tax("No Tax", 0), 0) }, DateTime.Now); InvoicesManager invoicesManager = new InvoicesManager(); invoicesManager.AddInvoiceToClubMember(invoice, clubMember); invoicesManager.CancelInvoice(invoice, clubMember); Assert.AreEqual(Invoice.InvoicePaymentState.Cancelled, invoice.InvoiceState); }
private List<Transaction> CreateAmendingTransactions(Invoice invoiceToAmend) { List<Transaction> amendingInvoiceDetail = new List<Transaction>(); Tax voidTax = new Tax("", 0); Transaction originalInvoiceReference = new Transaction("Amending invoice " + invoiceToAmend.InvoiceID + "as detailed", 1, 0, voidTax, 0); amendingInvoiceDetail.Add(originalInvoiceReference); foreach (Transaction transaction in invoiceToAmend.InvoiceDetail) { Transaction amendedTransaction = new Transaction( "Amending " + transaction.Description, -transaction.Units, transaction.UnitCost, transaction.Tax, transaction.Discount); amendingInvoiceDetail.Add(amendedTransaction); } return amendingInvoiceDetail; }
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; } } }
public void WhenCancellingAnInvoiceAnAmendingInvoiceIsCreatedAndAssignedToTheDebtor() { clubMemberDataManager.MemberIDSequenceNumber = 5; billDataManager.InvoiceSequenceNumber = 5; ClubMember clubMember = new ClubMember("Francisco", "Gomez-Caldito", "Viseas"); InvoiceCustomerData invoiceCustomerData = new InvoiceCustomerData(clubMember); Invoice invoice = new Invoice( new InvoiceCustomerData(clubMember), new List<Transaction>() { new Transaction("Kajak Rent", 1, 50, new Tax("No Tax", 0), 0) }, DateTime.Now); InvoicesManager invoicesManager = new InvoicesManager(); invoicesManager.AddInvoiceToClubMember(invoice, clubMember); Assert.AreEqual(0, clubMember.AmendingInvoicesList.Count); invoicesManager.CancelInvoice(invoice, clubMember); Assert.IsNotNull(clubMember.AmendingInvoicesList["AMN2013000005"]); }
public void AfterTheFirstReferenceAnAmendingInvoiceHasTheSameTransactionsThanOriginalInvoiceButWithNegativeUnits() { DateTime issueDate = DateTime.Now; Invoice invoice = new Invoice(invoiceCustomerData, transactionsList, issueDate); AmendingInvoice amendingInvoice = new AmendingInvoice(invoice); List<Transaction> invoiceDetail = invoice.InvoiceDetail; List<Transaction> amendingInvoiceDetail = amendingInvoice.InvoiceDetail; bool bothDetailsAreComplementary = true; for (int index = 0; index < invoiceDetail.Count; index++) { Transaction currentLine= invoiceDetail[index]; Transaction amendingTransaction = new Transaction( "Amending " + currentLine.Description, -currentLine.Units, currentLine.UnitCost, currentLine.Tax, currentLine.Discount); if (!amendingTransaction.CompareTo(amendingInvoiceDetail[index + 1])) { bothDetailsAreComplementary = false; break; } } Assert.AreEqual(true, bothDetailsAreComplementary); }
private InvoiceCustomerData CloneCustomerDataFromInvoice(Invoice invoiceToAmend) { return invoiceToAmend.CustomerData; }
public void GivenTheseBills(Table billsTable) { invoiceContextData.billDataManager.InvoiceSequenceNumber = 5000; Dictionary<string, ClubMember> membersCollection = (Dictionary<string, ClubMember>)ScenarioContext.Current["Members"]; foreach (var row in billsTable.Rows) { string description = row["TransactionConcept"]; double amount = double.Parse(row["Amount"]); List<Transaction> transaction = new List<Transaction>() { new Transaction(description,1,amount,new Tax("NoTAX",0),0) }; ClubMember clubMember = membersCollection[row["MemberID"]]; InvoiceCustomerData invoiceCustomerData = new InvoiceCustomerData(clubMember); Invoice invoice = new Invoice(invoiceCustomerData, transaction, new DateTime(2013, 11, 11)); invoicesManager.AddInvoiceToClubMember(invoice, clubMember); } }
public void RenewBillDueDate(Invoice invoiceContainingTheBill, Bill billToRenew, DateTime newDueDate, DateTime todayDate) { billToRenew.RenewDueDate(newDueDate, todayDate); invoiceContainingTheBill.SetInvoiceToBePaidIfHasNoUnpaidBills(); }
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 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"]); }
private void InitializeAmendingInvoice(Invoice invoiceToAmend) { this.invoiceID = GenerateAmendingInvoiceID(invoiceToAmend); this.invoiceDetail = CreateAmendingTransactions(invoiceToAmend); this.customerData = CloneCustomerDataFromInvoice(invoiceToAmend); }
public void GivenIHaveAnInvoiceWithCostWithASingleBillWithID(int invoiceNetAmout, string billID) { List<Transaction> transactionList = new List<Transaction>() { new Transaction("Big Payment", 1, invoiceNetAmout, new Tax("NOIGIC", 0), 0) }; DateTime issueDate = DateTime.Now.Date; Invoice invoice = new Invoice(new InvoiceCustomerData(membersManagementContextData.clubMember), transactionList, issueDate); invoicesManager.AddInvoiceToClubMember(invoice, membersManagementContextData.clubMember); ScenarioContext.Current.Add("Invoice", invoice); ScenarioContext.Current.Add("InvoiceNetAmount", invoiceNetAmout); ScenarioContext.Current.Add("BillID",billID); ScenarioContext.Current.Add("IssueDate", issueDate); }
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 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 WhenInstantiatingANewInvoiceANewInvoiceIDIsAssigned() { DateTime issueDate = DateTime.Now; Invoice invoice = new Invoice(invoiceCustomerData, transactionsList, issueDate); Assert.IsNotNull(invoice.InvoiceID); }
public void WhenCancellingAnInvoiceTheInvoiceIsMarkedAsCancelled() { DateTime issueDate = DateTime.Now; Invoice invoice = new Invoice(invoiceCustomerData, transactionsList, issueDate); invoice.Cancel(); Assert.AreEqual(Invoice.InvoicePaymentState.Cancelled, invoice.InvoiceState); }
public void WhenCancellingAnInvoiceTheBillTotalAmountToBePaidIs0() { DateTime issueDate = DateTime.Now; Invoice invoice = new Invoice(invoiceCustomerData, transactionsList, issueDate); List<Bill> pendingBills = invoice.Bills .Select(billsDictionayElement => billsDictionayElement.Value) .Where(bill => bill.PaymentResult == Bill.BillPaymentResult.ToCollect || bill.PaymentResult == Bill.BillPaymentResult.Unpaid).ToList(); invoice.Cancel(); foreach (Bill bill in pendingBills) Assert.AreEqual(Bill.BillPaymentResult.CancelledOut, bill.PaymentResult); }
private string GenerateAmendingInvoiceID(Invoice invoiceToAmend) { BillingDataManager billDataManager = BillingDataManager.Instance; return invoiceToAmend.InvoiceID.Replace(billDataManager.InvoicePrefix, billDataManager.AmendingInvoicePrefix); }
public void AFreshlyCreatedInvoiceIsSetToBePaid() { DateTime issueDate = DateTime.Now; Invoice invoice = new Invoice(invoiceCustomerData, transactionsList, issueDate); Assert.AreEqual(Invoice.InvoicePaymentState.ToBePaid, invoice.InvoiceState); }
public AmendingInvoice(Invoice invoiceToAmend) : base(null,DateTime.Now) { InitializeAmendingInvoice(invoiceToAmend); }
public void PayBill(Invoice invoiceContainingTheBill, Bill billToPay, Payment payment) { billToPay.PayBill(payment); CheckIfAgreementIsAccomplished(invoiceContainingTheBill, billToPay); invoiceContainingTheBill.CheckIfInvoiceIsFullPaid(); }
public void WhenIGenerateAnInvoiceForTheService() { DateTime issueDate = DateTime.Now; List<Transaction> serviceChargeList = new List<Transaction> { new ServiceCharge((ClubService)ScenarioContext.Current["A_Club_Service"]) }; Invoice invoice = new Invoice(new InvoiceCustomerData(membersManagementContextData.clubMember), serviceChargeList, issueDate); invoicesManager.AddInvoiceToClubMember(invoice, membersManagementContextData.clubMember); ScenarioContext.Current.Add("Invoice", invoice); }
public void WeCanSetTheInvoiceSequenceNumberValue() { billDataManager.InvoiceSequenceNumber=5000; DateTime issueDate = DateTime.Now; Invoice invoice = new Invoice(invoiceCustomerData, transactionsList, issueDate); int invoiceSequenceNumber = int.Parse(invoice.InvoiceID.Substring(invoice.InvoiceID.Length - 6)); Assert.AreEqual(5000, invoiceSequenceNumber); }
public void GivenIHaveAnInvoiceWithSomeBills() { string invoiceID = "MMM2013005001"; List<Transaction> transactionList = new List<Transaction>() {new Transaction("Big Payment",1,650,new Tax("NOIGIC",0),0)}; List<Bill> unassignedBillsList = new List<Bill>() { {new Bill("MMM2013005001/001", "First Instalment", 200, new DateTime(2013,11,01), new DateTime(2013,12,01))}, {new Bill("MMM2013005001/002", "Second Instalment", 200, new DateTime(2013,11,01), new DateTime(2014,01,01))}, {new Bill("MMM2013005001/003", "Third Instalment", 250, new DateTime(2013,11,01), new DateTime(2014,02,01))} }; Invoice invoice = new Invoice( invoiceID, new InvoiceCustomerData(membersManagementContextData.clubMember), transactionList, unassignedBillsList, DateTime.Now); ScenarioContext.Current.Add("Invoice", invoice); }
public void AnAmendingInvoiceHasTheSameNetAmountThanTheAmendedInvoiceButNegative() { DateTime issueDate = DateTime.Now; Invoice invoice = new Invoice(invoiceCustomerData, transactionsList, issueDate); AmendingInvoice amendingInvoice = new AmendingInvoice(invoice); Assert.AreEqual(-invoice.NetAmount, amendingInvoice.NetAmount); }