Scratch
This commit is contained in:
@@ -60,6 +60,8 @@ const asN2 = (dineroLike) => {
|
||||
* {
|
||||
* center,
|
||||
* partsSale,
|
||||
* partsTaxableSale,
|
||||
* partsNonTaxableSale,
|
||||
* laborTaxableSale,
|
||||
* laborNonTaxableSale,
|
||||
* extrasSale,
|
||||
@@ -69,19 +71,21 @@ const asN2 = (dineroLike) => {
|
||||
* costCenter
|
||||
* }
|
||||
*
|
||||
* For each center, we can emit up to 3 GOG *segments*:
|
||||
* - parts+extras (uses profitCenter.rr_cust_txbl_flag)
|
||||
* - taxable labor (CustTxblNTxblFlag="T")
|
||||
* - non-tax labor (CustTxblNTxblFlag="N")
|
||||
* For each center, we can emit up to 5 GOG *segments*:
|
||||
* - taxable parts (CustTxblNTxblFlag="T")
|
||||
* - non-taxable parts (CustTxblNTxblFlag="N")
|
||||
* - extras (uses profitCenter.rr_cust_txbl_flag)
|
||||
* - taxable labor (CustTxblNTxblFlag="T")
|
||||
* - non-tax labor (CustTxblNTxblFlag="N")
|
||||
*
|
||||
* IMPORTANT CHANGE:
|
||||
* IMPORTANT:
|
||||
* Each segment becomes its OWN JobNo / AllGogOpCodeInfo, with exactly one
|
||||
* AllGogLineItmInfo inside. This makes the count of:
|
||||
* AllGogLineItmInfo inside. This keeps a clean 1:1 mapping between:
|
||||
* - <AllGogOpCodeInfo> (ROGOG)
|
||||
* - <OpCodeLaborInfo> (ROLABOR)
|
||||
* match 1:1, and ensures taxable/non-taxable flags line up by JobNo.
|
||||
* and ensures taxable/non-taxable flags line up by JobNo.
|
||||
*
|
||||
* We now also attach segmentKind/segmentIndex/segmentCount metadata on each op
|
||||
* We attach segmentKind/segmentIndex/segmentCount metadata on each op
|
||||
* for UI/debug purposes. The XML templates can safely ignore these.
|
||||
*
|
||||
* @param {Array} allocations
|
||||
@@ -147,27 +151,43 @@ const buildRogogFromAllocations = (allocations, { opCode, payType = "Cust", roNo
|
||||
// Only centers configured for RR GOG are included
|
||||
if (!breakOut || !itemType) continue;
|
||||
|
||||
const partsCents = toCents(alloc.partsSale);
|
||||
const partsTaxableCents = toCents(alloc.partsTaxableSale);
|
||||
const partsNonTaxableCents = toCents(alloc.partsNonTaxableSale);
|
||||
const extrasCents = toCents(alloc.extrasSale);
|
||||
const laborTaxableCents = toCents(alloc.laborTaxableSale);
|
||||
const laborNonTaxableCents = toCents(alloc.laborNonTaxableSale);
|
||||
const costCents = toCents(alloc.cost);
|
||||
|
||||
// Parts + extras share a single segment
|
||||
const partsExtrasCents = partsCents + extrasCents;
|
||||
|
||||
const segments = [];
|
||||
|
||||
// 1) Parts + extras segment (respect center's default tax flag)
|
||||
if (partsExtrasCents !== 0) {
|
||||
// 1) Taxable parts segment -> "T"
|
||||
if (partsTaxableCents !== 0) {
|
||||
segments.push({
|
||||
kind: "partsExtras",
|
||||
saleCents: partsExtrasCents,
|
||||
kind: "partsTaxable",
|
||||
saleCents: partsTaxableCents,
|
||||
txFlag: "T"
|
||||
});
|
||||
}
|
||||
|
||||
// 2) Non-taxable parts segment -> "N"
|
||||
if (partsNonTaxableCents !== 0) {
|
||||
segments.push({
|
||||
kind: "partsNonTaxable",
|
||||
saleCents: partsNonTaxableCents,
|
||||
txFlag: "N"
|
||||
});
|
||||
}
|
||||
|
||||
// 3) Extras segment (respect center's default tax flag)
|
||||
if (extrasCents !== 0) {
|
||||
segments.push({
|
||||
kind: "extras",
|
||||
saleCents: extrasCents,
|
||||
txFlag: pc.rr_cust_txbl_flag || "N"
|
||||
});
|
||||
}
|
||||
|
||||
// 2) Taxable labor segment -> "T"
|
||||
// 4) Taxable labor segment -> "T"
|
||||
if (laborTaxableCents !== 0) {
|
||||
segments.push({
|
||||
kind: "laborTaxable",
|
||||
@@ -176,7 +196,7 @@ const buildRogogFromAllocations = (allocations, { opCode, payType = "Cust", roNo
|
||||
});
|
||||
}
|
||||
|
||||
// 3) Non-taxable labor segment -> "N"
|
||||
// 5) Non-taxable labor segment -> "N"
|
||||
if (laborNonTaxableCents !== 0) {
|
||||
segments.push({
|
||||
kind: "laborNonTaxable",
|
||||
@@ -254,6 +274,12 @@ const buildRogogFromAllocations = (allocations, { opCode, payType = "Cust", roNo
|
||||
/**
|
||||
* Build RO.ROLABOR structure for the reynolds-rome-client `createRepairOrder` payload
|
||||
* from an already-built RO.GOG structure.
|
||||
*
|
||||
* We still keep a 1:1 mapping with GOG ops: each op gets a corresponding
|
||||
* OpCodeLaborInfo entry using the same JobNo and the same tax flag as its
|
||||
* GOG line. Labor-specific details (hrs/rate) remain zeroed out, and the
|
||||
* DMS can ignore non-labor ops by virtue of the zero hours/amounts.
|
||||
*
|
||||
* @param {Object} rogg - result of buildRogogFromAllocations
|
||||
* @param {Object} opts
|
||||
* @param {string} [opts.payType="Cust"]
|
||||
|
||||
Reference in New Issue
Block a user