IO-1487 MPI Totals Adjustments

This commit is contained in:
Patrick Fic
2021-10-26 13:10:07 -07:00
parent 9c3e4b7b83
commit 1511b87959
3 changed files with 11 additions and 1 deletions

View File

@@ -535,6 +535,7 @@ export const GET_JOB_BY_PK = gql`
unq_seq
line_ind
line_desc
line_ref
part_type
oem_partno
db_price

View File

@@ -797,6 +797,7 @@ exports.GET_JOB_BY_PK = ` query GET_JOB_BY_PK($id: uuid!) {
line_ind
line_desc
part_type
line_ref
oem_partno
db_price
act_price

View File

@@ -486,7 +486,9 @@ function CalculateTaxesTotals(job, otherTotals) {
Dinero({ amount: Math.round((val.act_price || 0) * 100) })
.multiply(val.part_qty || 0)
.add(
val.prt_dsmk_m && val.prt_dsmk_m !== 0
val.prt_dsmk_m &&
val.prt_dsmk_m !== 0 &&
DiscountNotAlreadyCounted(val, job.joblines)
? Dinero({ amount: Math.round(val.prt_dsmk_m * 100) })
: Dinero({
amount: Math.round(val.act_price * 100),
@@ -566,3 +568,9 @@ function CalculateTaxesTotals(job, otherTotals) {
}
exports.default = Totals;
function DiscountNotAlreadyCounted(jobline, joblines) {
if (jobline.db_ref !== "900510") return true;
const ParentLine = joblines.find((j) => j.unq_seq === jobline.line_ref);
return ParentLine && !(ParentLine.prt_dsmk_m && ParentLine.prt_dsmk_m !== 0);
}