Futher calculations refinments and QBD testing.
This commit is contained in:
@@ -180,8 +180,6 @@ async function AutoAddAtsIfRequired({ job, client }) {
|
||||
});
|
||||
job.joblines[atsLineIndex].act_price = atsAmount;
|
||||
}
|
||||
|
||||
console.log(job.jobLines);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,7 +377,6 @@ function CalculatePartsTotals(jobLines, parts_tax_rates) {
|
||||
|
||||
const ret = jl.reduce(
|
||||
(acc, value) => {
|
||||
console.log(JSON.stringify(acc, null, 2));
|
||||
switch (value.part_type) {
|
||||
case "PAS":
|
||||
case "PASL":
|
||||
@@ -524,7 +521,11 @@ function CalculatePartsTotals(jobLines, parts_tax_rates) {
|
||||
//Check if there's any parts in this part type.
|
||||
if (ret.parts.list[key] !== undefined) {
|
||||
disc = ret.parts.list[key].total
|
||||
.percentage(parts_tax_rates[key].prt_discp)
|
||||
.percentage(
|
||||
Math.abs(parts_tax_rates[key].prt_discp) > 1
|
||||
? parts_tax_rates[key].prt_discp
|
||||
: parts_tax_rates[key].prt_discp * 100
|
||||
)
|
||||
.multiply(-1);
|
||||
}
|
||||
}
|
||||
@@ -535,7 +536,9 @@ function CalculatePartsTotals(jobLines, parts_tax_rates) {
|
||||
//Check if there's any parts in this part type.
|
||||
if (ret.parts.list[key] !== undefined) {
|
||||
markup = ret.parts.list[key].total.percentage(
|
||||
parts_tax_rates[key].prt_mkupp * 100 //Seems that mark up is written as decimal not %.
|
||||
Math.abs(parts_tax_rates[key].prt_mkupp) > 1
|
||||
? parts_tax_rates[key].prt_mkupp
|
||||
: parts_tax_rates[key].prt_mkupp * 100 //Seems that mark up is written as decimal not %.
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -736,20 +739,20 @@ function CalculateTaxesTotals(job, otherTotals) {
|
||||
otherTotals.additional.storage.percentage((job.tax_str_rt || 0) * 100)
|
||||
)
|
||||
.add(additionalItemsTax),
|
||||
// .add(
|
||||
// otherTotals.rates.mapa.hasMapaLine === false //If parts and materials were not added as lines, we must calculate the taxes on them.
|
||||
// ? otherTotals.rates.mapa.total.percentage(
|
||||
// (job.tax_paint_mat_rt || 0) * 100
|
||||
// )
|
||||
// : Dinero()
|
||||
// )
|
||||
// .add(
|
||||
// otherTotals.rates.mash.hasMashLine === false //If parts and materials were not added as lines, we must calculate the taxes on them.
|
||||
// ? otherTotals.rates.mash.total.percentage(
|
||||
// (job.tax_paint_mat_rt || 0) * 100
|
||||
// )
|
||||
// : Dinero()
|
||||
// )
|
||||
// .add(
|
||||
// otherTotals.rates.mapa.hasMapaLine === false //If parts and materials were not added as lines, we must calculate the taxes on them.
|
||||
// ? otherTotals.rates.mapa.total.percentage(
|
||||
// (job.tax_paint_mat_rt || 0) * 100
|
||||
// )
|
||||
// : Dinero()
|
||||
// )
|
||||
// .add(
|
||||
// otherTotals.rates.mash.hasMashLine === false //If parts and materials were not added as lines, we must calculate the taxes on them.
|
||||
// ? otherTotals.rates.mash.total.percentage(
|
||||
// (job.tax_paint_mat_rt || 0) * 100
|
||||
// )
|
||||
// : Dinero()
|
||||
// ),
|
||||
// .add(otherTotals.additional.pvrt),
|
||||
local_tax: subtotal.percentage((job.local_tax_rate || 0) * 100),
|
||||
};
|
||||
@@ -787,6 +790,15 @@ function CalculateTaxesTotals(job, otherTotals) {
|
||||
exports.default = Totals;
|
||||
|
||||
function DiscountNotAlreadyCounted(jobline, joblines) {
|
||||
//CCC already factors in the discount. If the difference between the 2 is exactly the discount, it's all good.
|
||||
if (
|
||||
Math.round(
|
||||
(jobline.prt_dsmk_m / (jobline.act_price - jobline.prt_dsmk_m)) * 100
|
||||
) === Math.abs(jobline.prt_dsmk_p)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
//If it's not a discount line, then it definitely hasn't been counted yet.
|
||||
jobline.db_ref !== "900510" &&
|
||||
@@ -794,16 +806,6 @@ function DiscountNotAlreadyCounted(jobline, joblines) {
|
||||
)
|
||||
return true;
|
||||
|
||||
if (jobline.unq_seq === '68') {
|
||||
console.log("stophere");
|
||||
}
|
||||
//CCC already factors in the discount. If the difference between the 2 is exactly the discount, it's all good.
|
||||
if (
|
||||
Math.round(jobline.prt_dsmk_m / jobline.act_price - jobline.prt_dsmk_m) ===
|
||||
Math.abs(jobline.prt_dsmk_p)
|
||||
)
|
||||
return false;
|
||||
|
||||
const ParentLine = joblines.find((j) => j.unq_seq === jobline.line_ref);
|
||||
|
||||
return ParentLine && !(ParentLine.prt_dsmk_m && ParentLine.prt_dsmk_m !== 0);
|
||||
|
||||
Reference in New Issue
Block a user