// Assumption: Subtotal has been calculated already static void calculateTotalForItem(InvoiceItem item, decimal TaxRate) { // TaxRate and Discount should both be decimals, but they're not, so, whee, dumb math to do. item.Total = (item.SubTotal * (1m - item.Discount / 100m)) * (1m + (item.Taxable ? TaxRate : 0m)); }
static decimal getCommissionForItem(InvoiceItem item, decimal CommissionRate) { // Okay, so, I'm ignoring tax entirely when looking at the commission. It's factored in before tax (per instructions), // and it itself doesn't get taxed (because it seemed that the commission was meant to be for the entire invoice, and tax is calculated on a per-line basis) return (item.SubTotal * (1m - item.Discount/100m)) * CommissionRate; }
static void calculateSubTotalForItem(InvoiceItem item) { item.SubTotal = item.UnitPrice * item.Quantity; }