feature/IO-3647-Reynolds-Integration-Phase-2 - Enhance early RO with meaningful amounts.
This commit is contained in:
118
server/rr/rr-job-helpers.test.js
Normal file
118
server/rr/rr-job-helpers.test.js
Normal file
@@ -0,0 +1,118 @@
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { createRequire } from "node:module";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const mock = require("mock-require");
|
||||
|
||||
const graphClientModuleId = require.resolve("../graphql-client/graphql-client");
|
||||
const queriesModuleId = require.resolve("../graphql-client/queries");
|
||||
const helpersModuleId = require.resolve("./rr-job-helpers");
|
||||
|
||||
const loadHelpers = () => {
|
||||
mock.stopAll();
|
||||
mock(graphClientModuleId, { client: { request: async () => ({}) } });
|
||||
mock(queriesModuleId, { GET_JOB_BY_PK: "GET_JOB_BY_PK" });
|
||||
delete require.cache[helpersModuleId];
|
||||
return require(helpersModuleId);
|
||||
};
|
||||
|
||||
afterEach(() => {
|
||||
mock.stopAll();
|
||||
delete require.cache[helpersModuleId];
|
||||
});
|
||||
|
||||
describe("server/rr/rr-job-helpers", () => {
|
||||
it("builds a single early-RO labor row from aggregated job labor", () => {
|
||||
const { buildMinimalRolaborFromJob } = loadHelpers();
|
||||
|
||||
const rolabor = buildMinimalRolaborFromJob(
|
||||
{
|
||||
tax_lbr_rt: 13,
|
||||
joblines: [
|
||||
{ mod_lbr_ty: "LAB", mod_lb_hrs: 2, lbr_amt: 200 },
|
||||
{ mod_lbr_ty: "LAD", mod_lb_hrs: 1.5, lbr_amt: 180 }
|
||||
]
|
||||
},
|
||||
{ opCode: "51DOZ" }
|
||||
);
|
||||
|
||||
expect(rolabor).toEqual({
|
||||
ops: [
|
||||
{
|
||||
opCode: "51DOZ",
|
||||
jobNo: "1",
|
||||
custPayTypeFlag: "C",
|
||||
custTxblNtxblFlag: "T",
|
||||
bill: {
|
||||
payType: "Cust",
|
||||
jobTotalHrs: "3.5",
|
||||
billTime: "3.5",
|
||||
billRate: "108.57"
|
||||
},
|
||||
amount: {
|
||||
payType: "Cust",
|
||||
amtType: "Job",
|
||||
custPrice: "380.00",
|
||||
totalAmt: "380.00"
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
it("populates labor bill fields from allocation hours on the full RR payload", () => {
|
||||
const { buildRRRepairOrderPayload } = loadHelpers();
|
||||
|
||||
const payload = buildRRRepairOrderPayload({
|
||||
job: {
|
||||
id: "job-1",
|
||||
ro_number: "RO-123",
|
||||
v_vin: "1HGBH41JXMN109186"
|
||||
},
|
||||
selectedCustomer: { customerNo: "1134485" },
|
||||
advisorNo: "70754",
|
||||
allocations: [
|
||||
{
|
||||
center: "Body Labor",
|
||||
partsSale: { amount: 0, precision: 2 },
|
||||
laborTaxableSale: { amount: 24000, precision: 2 },
|
||||
laborNonTaxableSale: { amount: 0, precision: 2 },
|
||||
extrasSale: { amount: 0, precision: 2 },
|
||||
totalSale: { amount: 24000, precision: 2 },
|
||||
cost: { amount: 12000, precision: 2 },
|
||||
laborTaxableHours: 2,
|
||||
laborNonTaxableHours: 0,
|
||||
profitCenter: {
|
||||
rr_gogcode: "BL",
|
||||
rr_item_type: "G",
|
||||
accountdesc: "BODY LABOR"
|
||||
}
|
||||
}
|
||||
],
|
||||
opCode: "51DOZ"
|
||||
});
|
||||
|
||||
expect(payload.rolabor).toEqual({
|
||||
ops: [
|
||||
{
|
||||
opCode: "51DOZ",
|
||||
jobNo: "1",
|
||||
custPayTypeFlag: "C",
|
||||
custTxblNtxblFlag: "T",
|
||||
bill: {
|
||||
payType: "Cust",
|
||||
jobTotalHrs: "2",
|
||||
billTime: "2",
|
||||
billRate: "120.00"
|
||||
},
|
||||
amount: {
|
||||
payType: "Cust",
|
||||
amtType: "Job",
|
||||
custPrice: "240.00",
|
||||
totalAmt: "240.00"
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user