IO-3001 Null Coalesce for some items for better handling.
This commit is contained in:
@@ -548,7 +548,7 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jobs_by_pk.job_totals.totals.ttl_adjustment) {
|
if (jobs_by_pk.job_totals.totals?.ttl_adjustment) {
|
||||||
// Do not need to check for ImEX or Rome because ImEX uses a different totals calculation that will never set this field.
|
// Do not need to check for ImEX or Rome because ImEX uses a different totals calculation that will never set this field.
|
||||||
if (qbo) {
|
if (qbo) {
|
||||||
const taxAccountCode = findTaxCode(
|
const taxAccountCode = findTaxCode(
|
||||||
@@ -571,11 +571,11 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes
|
|||||||
|
|
||||||
InvoiceLineAdd.push({
|
InvoiceLineAdd.push({
|
||||||
DetailType: "SalesItemLineDetail",
|
DetailType: "SalesItemLineDetail",
|
||||||
Amount: Dinero(jobs_by_pk.job_totals.totals.ttl_adjustment).toFormat(DineroQbFormat),
|
Amount: Dinero(jobs_by_pk.job_totals.totals?.ttl_adjustment).toFormat(DineroQbFormat),
|
||||||
SalesItemLineDetail: {
|
SalesItemLineDetail: {
|
||||||
...(jobs_by_pk.class ? { ClassRef: { value: classes[jobs_by_pk.class] } } : {}),
|
...(jobs_by_pk.class ? { ClassRef: { value: classes[jobs_by_pk.class] } } : {}),
|
||||||
ItemRef: {
|
ItemRef: {
|
||||||
value: items[responsibilityCenters.ttl_adjustment.accountitem]
|
value: items[responsibilityCenters.ttl_adjustment?.accountitem]
|
||||||
},
|
},
|
||||||
TaxCodeRef: {
|
TaxCodeRef: {
|
||||||
value: QboTaxId
|
value: QboTaxId
|
||||||
@@ -586,11 +586,11 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes
|
|||||||
} else {
|
} else {
|
||||||
InvoiceLineAdd.push({
|
InvoiceLineAdd.push({
|
||||||
ItemRef: {
|
ItemRef: {
|
||||||
FullName: responsibilityCenters.ttl_adjustment.accountitem
|
FullName: responsibilityCenters.ttl_adjustment?.accountitem
|
||||||
},
|
},
|
||||||
Desc: "Adjustment",
|
Desc: "Adjustment",
|
||||||
Quantity: 1,
|
Quantity: 1,
|
||||||
Amount: Dinero(jobs_by_pk.job_totals.totals.ttl_adjustment).toFormat(DineroQbFormat),
|
Amount: Dinero(jobs_by_pk.job_totals.totals?.ttl_adjustment).toFormat(DineroQbFormat),
|
||||||
SalesTaxCodeRef: InstanceManager({
|
SalesTaxCodeRef: InstanceManager({
|
||||||
imex: {
|
imex: {
|
||||||
FullName: "E"
|
FullName: "E"
|
||||||
@@ -902,11 +902,11 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes
|
|||||||
|
|
||||||
InvoiceLineAdd.push({
|
InvoiceLineAdd.push({
|
||||||
DetailType: "SalesItemLineDetail",
|
DetailType: "SalesItemLineDetail",
|
||||||
Amount: Dinero(jobs_by_pk.job_totals.totals.ttl_tax_adjustment).toFormat(DineroQbFormat),
|
Amount: Dinero(jobs_by_pk.job_totals.totals?.ttl_tax_adjustment).toFormat(DineroQbFormat),
|
||||||
SalesItemLineDetail: {
|
SalesItemLineDetail: {
|
||||||
...(jobs_by_pk.class ? { ClassRef: { value: classes[jobs_by_pk.class] } } : {}),
|
...(jobs_by_pk.class ? { ClassRef: { value: classes[jobs_by_pk.class] } } : {}),
|
||||||
ItemRef: {
|
ItemRef: {
|
||||||
value: items[responsibilityCenters.ttl_tax_adjustment.accountitem]
|
value: items[responsibilityCenters.ttl_tax_adjustment?.accountitem]
|
||||||
},
|
},
|
||||||
TaxCodeRef: {
|
TaxCodeRef: {
|
||||||
value: QboTaxId
|
value: QboTaxId
|
||||||
@@ -917,11 +917,11 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes
|
|||||||
} else {
|
} else {
|
||||||
InvoiceLineAdd.push({
|
InvoiceLineAdd.push({
|
||||||
ItemRef: {
|
ItemRef: {
|
||||||
FullName: responsibilityCenters.ttl_tax_adjustment.accountitem
|
FullName: responsibilityCenters.ttl_tax_adjustment?.accountitem
|
||||||
},
|
},
|
||||||
Desc: "Tax Adjustment",
|
Desc: "Tax Adjustment",
|
||||||
Quantity: 1,
|
Quantity: 1,
|
||||||
Amount: Dinero(jobs_by_pk.job_totals.totals.ttl_tax_adjustment).toFormat(DineroQbFormat),
|
Amount: Dinero(jobs_by_pk.job_totals.totals?.ttl_tax_adjustment).toFormat(DineroQbFormat),
|
||||||
SalesTaxCodeRef: InstanceManager({
|
SalesTaxCodeRef: InstanceManager({
|
||||||
imex: {
|
imex: {
|
||||||
FullName: "E"
|
FullName: "E"
|
||||||
|
|||||||
@@ -850,7 +850,7 @@ function GenerateCostingData(job) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
//Push adjustments to bottom line.
|
//Push adjustments to bottom line.
|
||||||
if (job.job_totals.totals.ttl_adjustment) {
|
if (job.job_totals?.totals?.ttl_adjustment) {
|
||||||
//Add to totals.
|
//Add to totals.
|
||||||
const Adjustment = Dinero(job.job_totals.totals.ttl_adjustment); //Need to invert, since this is being assigned as a cost.
|
const Adjustment = Dinero(job.job_totals.totals.ttl_adjustment); //Need to invert, since this is being assigned as a cost.
|
||||||
summaryData.totalAdditionalSales = summaryData.totalAdditionalSales.add(Adjustment);
|
summaryData.totalAdditionalSales = summaryData.totalAdditionalSales.add(Adjustment);
|
||||||
|
|||||||
Reference in New Issue
Block a user