RrScratch3 - Tax / Extras Improvements
This commit is contained in:
@@ -56,7 +56,7 @@ const asN2 = (dineroLike) => {
|
||||
* Build RO.GOG structure for the reynolds-rome-client `createRepairOrder` payload
|
||||
* from allocations.
|
||||
*
|
||||
* Supports the new allocation shape:
|
||||
* Supports the allocation shape:
|
||||
* {
|
||||
* center,
|
||||
* partsSale,
|
||||
@@ -65,18 +65,21 @@ const asN2 = (dineroLike) => {
|
||||
* laborTaxableSale,
|
||||
* laborNonTaxableSale,
|
||||
* extrasSale,
|
||||
* extrasTaxableSale,
|
||||
* extrasNonTaxableSale,
|
||||
* totalSale,
|
||||
* cost,
|
||||
* profitCenter,
|
||||
* costCenter
|
||||
* }
|
||||
*
|
||||
* 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")
|
||||
* For each center, we can emit up to 6 GOG *segments*:
|
||||
* - taxable parts (CustTxblNTxblFlag="T")
|
||||
* - non-taxable parts (CustTxblNTxblFlag="N")
|
||||
* - taxable extras (CustTxblNTxblFlag="T")
|
||||
* - non-taxable extras (CustTxblNTxblFlag="N")
|
||||
* - taxable labor (CustTxblNTxblFlag="T")
|
||||
* - non-taxable labor (CustTxblNTxblFlag="N")
|
||||
*
|
||||
* IMPORTANT:
|
||||
* Each segment becomes its OWN JobNo / AllGogOpCodeInfo, with exactly one
|
||||
@@ -153,7 +156,8 @@ const buildRogogFromAllocations = (allocations, { opCode, payType = "Cust", roNo
|
||||
|
||||
const partsTaxableCents = toCents(alloc.partsTaxableSale);
|
||||
const partsNonTaxableCents = toCents(alloc.partsNonTaxableSale);
|
||||
const extrasCents = toCents(alloc.extrasSale);
|
||||
const extrasTaxableCents = toCents(alloc.extrasTaxableSale);
|
||||
const extrasNonTaxableCents = toCents(alloc.extrasNonTaxableSale);
|
||||
const laborTaxableCents = toCents(alloc.laborTaxableSale);
|
||||
const laborNonTaxableCents = toCents(alloc.laborNonTaxableSale);
|
||||
const costCents = toCents(alloc.cost);
|
||||
@@ -178,16 +182,25 @@ const buildRogogFromAllocations = (allocations, { opCode, payType = "Cust", roNo
|
||||
});
|
||||
}
|
||||
|
||||
// 3) Extras segment (respect center's default tax flag)
|
||||
if (extrasCents !== 0) {
|
||||
// 3) Taxable extras -> "T"
|
||||
if (extrasTaxableCents !== 0) {
|
||||
segments.push({
|
||||
kind: "extras",
|
||||
saleCents: extrasCents,
|
||||
txFlag: pc.rr_cust_txbl_flag || "N"
|
||||
kind: "extrasTaxable",
|
||||
saleCents: extrasTaxableCents,
|
||||
txFlag: "T"
|
||||
});
|
||||
}
|
||||
|
||||
// 4) Taxable labor segment -> "T"
|
||||
// 4) Non-taxable extras -> "N"
|
||||
if (extrasNonTaxableCents !== 0) {
|
||||
segments.push({
|
||||
kind: "extrasNonTaxable",
|
||||
saleCents: extrasNonTaxableCents,
|
||||
txFlag: "N"
|
||||
});
|
||||
}
|
||||
|
||||
// 5) Taxable labor segment -> "T"
|
||||
if (laborTaxableCents !== 0) {
|
||||
segments.push({
|
||||
kind: "laborTaxable",
|
||||
@@ -196,7 +209,7 @@ const buildRogogFromAllocations = (allocations, { opCode, payType = "Cust", roNo
|
||||
});
|
||||
}
|
||||
|
||||
// 5) Non-taxable labor segment -> "N"
|
||||
// 6) Non-tax labor segment -> "N"
|
||||
if (laborNonTaxableCents !== 0) {
|
||||
segments.push({
|
||||
kind: "laborNonTaxable",
|
||||
@@ -356,10 +369,8 @@ const QueryJobData = async (ctx = {}, jobId) => {
|
||||
* @param advisorNo
|
||||
* @param story
|
||||
* @param makeOverride
|
||||
* @param bodyshop
|
||||
* @param allocations
|
||||
* @param {string} [opCode] - RR OpCode for this RO (global default / override)
|
||||
* @param {string} [taxCode] - RR tax code for header tax (e.g. state/prov code)
|
||||
* @returns {Object}
|
||||
*/
|
||||
const buildRRRepairOrderPayload = ({
|
||||
@@ -370,7 +381,6 @@ const buildRRRepairOrderPayload = ({
|
||||
makeOverride,
|
||||
allocations,
|
||||
opCode
|
||||
// taxCode
|
||||
} = {}) => {
|
||||
const customerNo = selectedCustomer?.customerNo
|
||||
? String(selectedCustomer.customerNo).trim()
|
||||
@@ -421,7 +431,6 @@ const buildRRRepairOrderPayload = ({
|
||||
|
||||
if (haveAllocations) {
|
||||
const effectiveOpCode = (opCode && String(opCode).trim()) || null;
|
||||
// const effectiveTaxCode = (taxCode && String(taxCode).trim()) || null;
|
||||
|
||||
if (effectiveOpCode) {
|
||||
// Build RO.GOG and RO.LABOR in the new normalized shape
|
||||
|
||||
Reference in New Issue
Block a user