IO-233 CDK updates.

This commit is contained in:
Patrick Fic
2021-12-02 10:50:11 -08:00
parent a77e664ab1
commit 39ec9d92ec
23 changed files with 688 additions and 201 deletions

View File

@@ -106,10 +106,23 @@ exports.default = async function (socket, jobid) {
return acc;
}, {});
const selectedDmsAllocationConfig =
bodyshop.md_responsibility_centers.dms_defaults.find(
(d) => d.name === job.dms_allocation
);
CdkBase.createLogEvent(
socket,
"DEBUG",
`Using DMS Allocation ${
selectedDmsAllocationConfig && selectedDmsAllocationConfig.name
} for cost export.`
);
const costCenterHash = job.bills.reduce((bill_acc, bill_val) => {
bill_val.billlines.map((line_val) => {
if (!bill_acc[line_val.cost_center])
bill_acc[line_val.cost_center] = Dinero();
if (!bill_acc[selectedDmsAllocationConfig.costs[line_val.cost_center]])
bill_acc[selectedDmsAllocationConfig.costs[line_val.cost_center]] =
Dinero();
let lineDinero = Dinero({
amount: Math.round((line_val.actual_cost || 0) * 100),
@@ -117,8 +130,10 @@ exports.default = async function (socket, jobid) {
.multiply(line_val.quantity)
.multiply(bill_val.is_credit_memo ? -1 : 1);
bill_acc[line_val.cost_center] =
bill_acc[line_val.cost_center].add(lineDinero);
bill_acc[selectedDmsAllocationConfig.costs[line_val.cost_center]] =
bill_acc[selectedDmsAllocationConfig.costs[line_val.cost_center]].add(
lineDinero
);
return null;
});
return bill_acc;
@@ -136,17 +151,19 @@ exports.default = async function (socket, jobid) {
),
});
//Add it to the right cost center.
if (!costCenterHash[ticket.cost_center])
costCenterHash[ticket.cost_center] = Dinero();
if (!costCenterHash[selectedDmsAllocationConfig.costs[ticket.ciecacode]])
costCenterHash[selectedDmsAllocationConfig.costs[ticket.ciecacode]] =
Dinero();
costCenterHash[ticket.cost_center] =
costCenterHash[ticket.cost_center].add(TicketTotal);
costCenterHash[selectedDmsAllocationConfig.costs[ticket.ciecacode]] =
costCenterHash[selectedDmsAllocationConfig.costs[ticket.ciecacode]].add(
TicketTotal
);
});
if (!hasMapaLine && job.job_totals.rates.mapa.total.amount > 0) {
// console.log("Adding MAPA Line Manually.");
const mapaAccountName =
bodyshop.md_responsibility_centers.defaults.profits.MAPA;
const mapaAccountName = selectedDmsAllocationConfig.profits.MAPA;
const mapaAccount = bodyshop.md_responsibility_centers.profits.find(
(c) => c.name === mapaAccountName
@@ -167,8 +184,7 @@ exports.default = async function (socket, jobid) {
if (!hasMashLine && job.job_totals.rates.mash.total.amount > 0) {
// console.log("Adding MASH Line Manually.");
const mashAccountName =
bodyshop.md_responsibility_centers.defaults.profits.MASH;
const mashAccountName = selectedDmsAllocationConfig.profits.MASH;
const mashAccount = bodyshop.md_responsibility_centers.profits.find(
(c) => c.name === mashAccountName
@@ -198,7 +214,7 @@ exports.default = async function (socket, jobid) {
if (job.towing_payable && job.towing_payable !== 0) {
const towAccountName =
bodyshop.md_responsibility_centers.defaults.profits.TOW;
selectedDmsAllocationConfig.profits.TOW;
const towAccount = bodyshop.md_responsibility_centers.profits.find(
(c) => c.name === towAccountName
@@ -219,7 +235,7 @@ exports.default = async function (socket, jobid) {
}
if (job.storage_payable && job.storage_payable !== 0) {
const storageAccountName =
bodyshop.md_responsibility_centers.defaults.profits.TOW;
selectedDmsAllocationConfig.profits.TOW;
const towAccount = bodyshop.md_responsibility_centers.profits.find(
(c) => c.name === storageAccountName
@@ -243,7 +259,7 @@ exports.default = async function (socket, jobid) {
if (job.adjustment_bottom_line && job.adjustment_bottom_line !== 0) {
const otherAccountName =
bodyshop.md_responsibility_centers.defaults.profits.PAO;
selectedDmsAllocationConfig.profits.PAO;
const otherAccount = bodyshop.md_responsibility_centers.profits.find(
(c) => c.name === otherAccountName

View File

@@ -253,6 +253,7 @@ query QUERY_JOBS_FOR_PBS_EXPORT($id: uuid!) {
ro_number
clm_total
clm_no
dms_allocation
invoice_allocation
ownerid
ownr_ln
@@ -1200,6 +1201,7 @@ exports.GET_CDK_ALLOCATIONS = `query QUERY_JOB_CLOSE_DETAILS($id: uuid!) {
cdk_configuration
}
ro_number
dms_allocation
invoice_allocation
ins_co_id
id
@@ -1261,6 +1263,7 @@ exports.GET_CDK_ALLOCATIONS = `query QUERY_JOB_CLOSE_DETAILS($id: uuid!) {
cost_center
productivehrs
rate
ciecacode
employee {
flat_rate
}