public void DiscountsAreCalculatedPerUnitNotOnTotal() { Transaction oneArticleOfTwoCents = new Transaction("Great! Half-price!", 1, 0.02, new Tax("No VAT", 0), 51); Transaction TwoArticlesOfOneCents = new Transaction("May I have a thousand of theese?", 2, 0.01, new Tax("No VAT", 0), 51); Assert.AreEqual((decimal)0.01, oneArticleOfTwoCents.GrossAmount); Assert.AreEqual((decimal)0.00, TwoArticlesOfOneCents.GrossAmount); }
public void ATransactionCanHaveTaxes() { Transaction transaction = new Transaction("Nice Blue Cap", 1, 10, new Tax("5% VAT", 5), 0); Assert.AreEqual((decimal)10, transaction.GrossAmount); Assert.AreEqual((decimal)10.5, transaction.NetAmount); Assert.AreEqual((decimal)0.5, transaction.TaxAmount); }
public bool CompareTo(Transaction otherTransaction) { return Description == otherTransaction.Description && Units == otherTransaction.Units && UnitCost == otherTransaction.UnitCost && Discount == otherTransaction.Discount && Tax.TaxPercentage == otherTransaction.Tax.TaxPercentage; }
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; }
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); }
public void RoundingTaxIsWellCalculatedThirdDecimalIsBelowFive() { Transaction transaction = new Transaction("1% VAT is NO VAT!", 1, 0.1, new Tax("4% VAT", 4), 0); Assert.AreEqual((decimal)0, transaction.TaxAmount); }
public void TransactionsCantHaveNegativeCost() { DateTime issueDate = DateTime.Now; try { Transaction transaction= new Transaction("June Membership Fee", 1,-79,taxesDictionary["IGIC General"],0); } catch (ArgumentOutOfRangeException exception) { Assert.AreEqual("Transactions units cost can't be negative", exception.GetMessageWithoutParamName()); throw exception; } }
public void RoundingIsAllwaysTwoDecimalDigitsAwayFromZero_ExampleThirdDecimalIsAboveFive() { Transaction transaction = new Transaction("In fact, it's 10", 1, 9.996, new Tax("No VAT", 0), 0); Assert.AreEqual((decimal)10, transaction.GrossAmount); }
public void RoundingDiscoutsIsWellCalculatedThirdDecimalIsBelowFive() { Transaction transaction = new Transaction("Ooops... it's for free!", 1, 0.01, new Tax("No VAT", 0), 51); Assert.AreEqual((decimal)0, transaction.GrossAmount); }
public void TheTaxAmountOfANegativeGrossAmountIsNegative() { Transaction transaction = new Transaction("This product is defective. Return me my money!", -1, 10, new Tax("5% VAT", 5), 0); Assert.AreEqual((decimal)-10, transaction.GrossAmount); Assert.AreEqual((decimal)-0.5, transaction.TaxAmount); }
public void TheAmoutOfATransactionWithTwoUnitsHavingACostOf10Is20() { Transaction transaction = new Transaction("Nice Blue Cap", 2, 10, new Tax("No VAT", 0), 0); Assert.AreEqual((decimal)20, transaction.GrossAmount); }
public void TheAmountOfReturningOneProductIsExactlyTheSameThanBuyinOneProductButnegative_CheckWithTax() { Transaction transaction = new Transaction("I'll buy this!", 1, 10, new Tax("5% Tax", 5), 0); Transaction amendingTransaction = new Transaction("I don't like. Return me exactly the same I paid!", -1, 10, new Tax("5% Tax", 5), 0); Assert.AreEqual(amendingTransaction.GrossAmount, -transaction.GrossAmount); Assert.AreEqual(amendingTransaction.NetAmount, -transaction.NetAmount); Assert.AreEqual(amendingTransaction.TaxAmount, -transaction.TaxAmount); }
public void TaxIsAppliedPerUnitNotToTotal() { Transaction aSingleTwoCentsProduct = new Transaction("6% VAT is the same than 10% VAT!", 1, 0.2, new Tax("6% VAT", 6), 0); Transaction twoOneCentsProducts = new Transaction("6% VAT is the same than 10% VAT!", 2, 0.1, new Tax("6% VAT", 6), 0); Assert.AreEqual((decimal)0.01, aSingleTwoCentsProduct.TaxAmount); Assert.AreEqual((decimal)0.02, twoOneCentsProducts.TaxAmount); }
public void TaxIsAppliedAfterDiscount() { Transaction transaction = new Transaction("Ooops... it's for free!", 1, 0.01, new Tax("100% VAT", 100), 51); Assert.AreEqual((decimal)0, transaction.TaxAmount); }
public void RoundingTaxIsWellCalculatedThirdDecimalIsFive() { Transaction transaction = new Transaction("5% VAT is the same than 10% VAT!", 1, 0.1, new Tax("5% VAT", 5), 0); Assert.AreEqual((decimal)0.01, transaction.TaxAmount); }
public void NegativeDiscountsAreConsideredSurcharges() { Transaction surchargedTransaction = new Transaction("For delay in payment", 1, 10, new Tax("No VAT", 0), -10); Assert.AreEqual((decimal)11, surchargedTransaction.GrossAmount); }
public void TheTotalAmoutOfATransacationCanBeNegative() { Transaction transaction = new Transaction("This product is defective. Return me my money!", -1, 50, new Tax("0% VAT", 0), 0); Assert.AreEqual((decimal)-50, transaction.NetAmount); }
public void RoundingDiscoutsIsWellCalculatedThirdDecimalIsFive() { Transaction transaction = new Transaction("No Applicable Discount", 1, 0.01, new Tax("No VAT", 0), 50); Assert.AreEqual((decimal)0.01, transaction.GrossAmount); }
public void TransactionsCanHaveNegativeUnitNumbersToReflectDevolutionsOrCancellationsOnAmendingInvoices() { Transaction transaction = new Transaction("This product is defective. Return me my money!", -1, 50, new Tax("0% VAT", 0), 0); Assert.AreEqual((decimal)-1, transaction.Units); }
public void RoundingIsAllwaysTwoDecimalDigitsAwayFromZero_ExampleThirdDecimalIsBelowFive() { Transaction transaction = new Transaction("Cheaper than 10!", 1, 9.994, new Tax("No VAT", 0), 0); Assert.AreEqual((decimal)9.99, transaction.GrossAmount); }
public void TransactionsCantHaveNegativeCost() { try { Transaction transaction = new Transaction("A gift?! For me?!", 1, -100, new Tax("No VAT", 0), 0); } catch (ArgumentOutOfRangeException exception) { Assert.AreEqual("Transactions units cost can't be negative", exception.GetMessageWithoutParamName()); throw exception; } }
public void FirstTransactionInAmendingInvoiceIsANoValueReferenceToOriginalInvoice() { DateTime issueDate = DateTime.Now; Invoice invoice = new Invoice(invoiceCustomerData, transactionsList, issueDate); Transaction originalInvoiceReference = new Transaction("Amending invoice " + invoice.InvoiceID + "as detailed", 1, 0, new Tax("VoidTax", 0), 0); AmendingInvoice amendingInvoice = new AmendingInvoice(invoice); Transaction firstTransactionFromAmendingInvoice = amendingInvoice.InvoiceDetail[0]; Assert.AreEqual(true, firstTransactionFromAmendingInvoice.CompareTo(originalInvoiceReference)); }
public void TransactionsCantHaveZeroUnits() { try { Transaction transaction = new Transaction("Invoice me nothing!", 0, 100000, new Tax("No VAT", 0), 0); } catch (ArgumentOutOfRangeException exception) { Assert.AreEqual("A transaction can't have zero units", exception.GetMessageWithoutParamName()); throw exception; } }
public void TransactionsMustAcceptNegativeUnitCostsForTheCaseOfAmendingInvoices() { DateTime issueDate = DateTime.Now; Transaction transaction; try { transaction = new Transaction("AmmendingInvoice", -1, 79, taxesDictionary["IGIC General"], 0); } catch (ArgumentOutOfRangeException exception) { throw exception; } Assert.AreEqual((decimal)-84.53, transaction.NetAmount); }
public void WhenReturninManyProductsTheAmountIsTheSameThanWhenBuying() { Transaction transaction = new Transaction("I'll buy this!", 3, 10, new Tax("5% Tax", 5), 10); Transaction amendingTransaction = new Transaction("I don't like. Return me exactly the same I paid!", -3, 10, new Tax("5% Tax", 5), 10); Assert.AreEqual(amendingTransaction.GrossAmount, -transaction.GrossAmount); Assert.AreEqual(amendingTransaction.NetAmount, -transaction.NetAmount); Assert.AreEqual(amendingTransaction.TaxAmount, -transaction.TaxAmount); }
public void ATransactionCanHaveADiscount() { Transaction transaction = new Transaction("Nice Blue Cap", 2, 10, new Tax("No VAT", 0), 10); Assert.AreEqual((decimal)18, transaction.GrossAmount); }
public void RoundingNegativeTransactionsIsAllwaysTwoDecimalDigitsAwayFromZero_ExampleThirdDecimalIsFive() { Transaction transaction = new Transaction("This product is defective. Return me my money!", -1, 9.995, new Tax("No VAT", 0), 0); Assert.AreEqual((decimal)-10, transaction.GrossAmount); }