Files
Aislo/tools/est-test/jdl-mainpart.cjs
T

10 lines
358 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
function matchesAmounts(row, quantity, prices, num) {
const factor = quantity / (["%", "%"].includes(row.Unite) ? 100 : 1);
const amounts = [num(row.GC), num(row.NC), num(row.JC) + num(row.SC)];
return prices.every(
(price, index) => Math.abs(Math.trunc(factor * price) - amounts[index]) <= 0.000001,
);
}
module.exports = { matchesAmounts };