export var calculateInvoiceTotals = function (data) {
    var amountWithoutTax = 0;
    var totalDiscount = 0;
    var totalTaxAmount = 0;
    var totalAmount = 0;
    for (var _i = 0, data_1 = data; _i < data_1.length; _i++) {
        var item = data_1[_i];
        var discountAmount = item.discount && item.unitPrice - item.discount;
        var taxableAmount = (item.unitPrice - item.discount) * item.quantity;
        amountWithoutTax += taxableAmount;
        totalDiscount += discountAmount * item.quantity;
        var itemTaxAmount = taxableAmount * (item.tax.amount / 100);
        totalTaxAmount += itemTaxAmount;
        totalAmount += taxableAmount + itemTaxAmount;
    }
    totalAmount = amountWithoutTax + totalTaxAmount;
    return {
        amountWithoutTax: amountWithoutTax,
        totalDiscount: totalDiscount,
        totalTaxAmount: totalTaxAmount,
        totalAmount: totalAmount,
    };
};
export var calculateItemTotal = function (item) {
    var discountAmount = item.discount;
    var priceAfterDiscount = item.unitPrice - discountAmount;
    var taxAmount = priceAfterDiscount * (item.tax.amount / 100);
    var itemTotal = (priceAfterDiscount + taxAmount) * item.quantity;
    return itemTotal;
};
