estimate-library
Advanced tools
Comparing version 0.2.13 to 0.2.14
import ITable from "../types/ITable"; | ||
import IRow from "../types/IRow"; | ||
import IDepartment from "../types/IDepartment"; | ||
export declare function calculateRow(this: ITable, row: IRow): IRow; | ||
@@ -10,1 +11,2 @@ export declare function calculateAdditionalRow(this: ITable, subtotal: number): { | ||
}; | ||
export declare function calculateAdditionalRowPrice(this: ITable, departments: Array<IDepartment>): number; |
@@ -14,3 +14,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.calculateAdditionalRow = exports.calculateRow = void 0; | ||
exports.calculateAdditionalRowPrice = exports.calculateAdditionalRow = exports.calculateRow = void 0; | ||
var getMargin = function (costPrice, discountPercent) { return normalizePrice(costPrice * divIn100(discountPercent)); }; | ||
@@ -47,1 +47,5 @@ var getDiscount = function (subtotal, discountPercent) { | ||
exports.calculateAdditionalRow = calculateAdditionalRow; | ||
function calculateAdditionalRowPrice(departments) { | ||
return departments.reduce(function (acc, dep) { return (acc + dep.value); }, 0); | ||
} | ||
exports.calculateAdditionalRowPrice = calculateAdditionalRowPrice; |
@@ -191,6 +191,9 @@ "use strict"; | ||
return section.total.departments.forEach(function (dep, d) { | ||
subtotal.departments[d].value += dep.value; | ||
subtotal.departments[d].value += dep.value * dep.rate; | ||
}); | ||
}); | ||
this.subtotal = calculations_1.calculateRow.call(this, subtotal); | ||
subtotal.costPrice = subtotal.departments.reduce(function (acc, dep) { return acc + dep.value; }, 0); | ||
subtotal.margin = (subtotal.costPrice * this.config.margin) / 100; | ||
subtotal.price = subtotal.costPrice + subtotal.margin; | ||
this.subtotal = subtotal; | ||
} | ||
@@ -210,6 +213,6 @@ function calculateAdditionalRows() { | ||
}); | ||
this.discount = calculations_1.calculateRow.call(this, discountRow); | ||
this.fees = calculations_1.calculateRow.call(this, feesRow); | ||
this.taxes = calculations_1.calculateRow.call(this, taxesRow); | ||
this.total = calculations_1.calculateRow.call(this, totalRow); | ||
this.discount = __assign(__assign({}, discountRow), { price: calculations_1.calculateAdditionalRowPrice.call(this, discountRow.departments) }); | ||
this.fees = __assign(__assign({}, feesRow), { price: calculations_1.calculateAdditionalRowPrice.call(this, feesRow.departments) }); | ||
this.taxes = __assign(__assign({}, taxesRow), { price: calculations_1.calculateAdditionalRowPrice.call(this, taxesRow.departments) }); | ||
this.total = __assign(__assign({}, totalRow), { price: calculations_1.calculateAdditionalRowPrice.call(this, totalRow.departments) }); | ||
} | ||
@@ -216,0 +219,0 @@ function calculateTable() { |
{ | ||
"name": "estimate-library", | ||
"version": "0.2.13", | ||
"version": "0.2.14", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32795
751