public void allocation_on_prepayment() { var transaction = new BankTransactions.BankTransactionTest().Given_a_bank_transaction(BankTransactionType.SpendPrepayment); var invoice = new Create().Given_an_authorised_invoice(); var expected = Math.Min(transaction.Total.GetValueOrDefault(), invoice.Total.GetValueOrDefault()); Api.Allocations.Add(new PrepaymentAllocation { AppliedAmount = expected, Prepayment = new Prepayment { Id = transaction.PrepaymentID.GetValueOrDefault() }, Invoice = new Invoice { Id = invoice.Id } }); var prepayment = Api.Prepayments.Find(transaction.PrepaymentID.GetValueOrDefault()); Assert.AreEqual(1, prepayment.Allocations.Count); Assert.AreEqual(expected, prepayment.Allocations.First().Amount); }
public void allocation_on_prepayment() { var transaction = new BankTransactions.BankTransactionTest().Given_a_bank_transaction(BankTransactionType.SpendPrepayment); var invoice = new Create().Given_an_authorised_invoice(); var expected = Math.Min(transaction.Total.GetValueOrDefault(), invoice.Total.GetValueOrDefault()); Api.Allocations.Add(new PrepaymentAllocation { AppliedAmount = expected, Prepayment = new Prepayment { Id = transaction.PrepaymentID.GetValueOrDefault() }, Invoice = new Invoice { Id = invoice.Id } }); var prepayment = Api.Prepayments.Find(transaction.PrepaymentID.GetValueOrDefault()); Assert.AreEqual(1, prepayment.Allocations.Count); Assert.AreEqual(expected, prepayment.Allocations.First().Amount); }
public void Overpayments_show_on_invoices() { var transaction = new BankTransactions.BankTransactionTest().Given_an_overpayment(BankTransactionType.SpendOverpayment); var invoice = new Create().Given_an_authorised_invoice(); var expected = Math.Min(transaction.Total.GetValueOrDefault(), invoice.Total.GetValueOrDefault()); Api.Allocations.Add(new OverpaymentAllocation { AppliedAmount = expected, Overpayment = new Overpayment { Id = transaction.OverpaymentID.GetValueOrDefault() }, Invoice = new Invoice { Id = invoice.Id } }); invoice = Api.Invoices.Find(invoice.Id); Assert.AreEqual(1, invoice.Overpayments.Count); Assert.AreEqual(transaction.OverpaymentID.GetValueOrDefault(), invoice.Overpayments.First().Id); }
public void Overpayments_show_on_invoices() { var transaction = new BankTransactions.BankTransactionTest().Given_an_overpayment(BankTransactionType.SpendOverpayment); var invoice = new Create().Given_an_authorised_invoice(); var expected = Math.Min(transaction.Total.GetValueOrDefault(), invoice.Total.GetValueOrDefault()); Api.Allocations.Add(new OverpaymentAllocation { AppliedAmount = expected, Overpayment = new Overpayment { Id = transaction.OverpaymentID.GetValueOrDefault() }, Invoice = new Invoice { Id = invoice.Id } }); invoice = Api.Invoices.Find(invoice.Id); Assert.AreEqual(1, invoice.Overpayments.Count); Assert.AreEqual(transaction.OverpaymentID.GetValueOrDefault(), invoice.Overpayments.First().Id); }