WIP America
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
const { objectLength } = require("@oozcitak/util");
|
||||
const Dinero = require("dinero.js");
|
||||
const queries = require("../graphql-client/queries");
|
||||
const GraphQLClient = require("graphql-request").GraphQLClient;
|
||||
@@ -380,6 +379,7 @@ 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":
|
||||
@@ -535,7 +535,7 @@ 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
|
||||
parts_tax_rates[key].prt_mkupp * 100 //Seems that mark up is written as decimal not %.
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -543,14 +543,15 @@ function CalculatePartsTotals(jobLines, parts_tax_rates) {
|
||||
adjustments[key] = adjustment;
|
||||
});
|
||||
|
||||
Object.keys(adjustments).forEach((key) => {
|
||||
if (ret.parts.list[key] !== undefined) {
|
||||
ret.parts.list[key].total = ret.parts.list[key].total.add(
|
||||
adjustments[key]
|
||||
);
|
||||
ret.parts.subtotal = ret.parts.subtotal.add(adjustments[key]);
|
||||
}
|
||||
});
|
||||
//Temporarily commenting this out since these totals appear to be already included in the calculation.
|
||||
// Object.keys(adjustments).forEach((key) => {
|
||||
// if (ret.parts.list[key] !== undefined) {
|
||||
// ret.parts.list[key].total = ret.parts.list[key].total.add(
|
||||
// adjustments[key]
|
||||
// );
|
||||
// ret.parts.subtotal = ret.parts.subtotal.add(adjustments[key]);
|
||||
// }
|
||||
// });
|
||||
|
||||
return {
|
||||
adjustments,
|
||||
@@ -575,19 +576,12 @@ function IsAdditionalCost(jobLine) {
|
||||
const isPaintOrShopMat =
|
||||
jobLine.db_ref === "936008" || jobLine.db_ref === "936007";
|
||||
|
||||
// if (process.env.COUNTRY === "USA") {
|
||||
// return (
|
||||
// jobLine.lbr_op === "OP13" || //Added to resolve manual job lines coming into other totals because they have no reference.
|
||||
// (jobLine.part_type === null && (jobLine.act_price || 0 > 0))
|
||||
// );
|
||||
// } else {
|
||||
return (
|
||||
(jobLine.lbr_op === "OP13" || //Added to resolve manual job lines coming into other totals because they have no reference.
|
||||
(jobLine.part_type === null && (jobLine.act_price || 0 > 0)) ||
|
||||
(jobLine.db_ref && jobLine.db_ref.startsWith("9360"))) && //This ref works in Canada, but DB_REFS in the US do not fill in.
|
||||
!isPaintOrShopMat
|
||||
);
|
||||
//}
|
||||
}
|
||||
|
||||
function CalculateAdditional(job) {
|
||||
@@ -800,6 +794,16 @@ 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