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.
|
||||
if (qbo) {
|
||||
const taxAccountCode = findTaxCode(
|
||||
@@ -571,11 +571,11 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes
|
||||
|
||||
InvoiceLineAdd.push({
|
||||
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: {
|
||||
...(jobs_by_pk.class ? { ClassRef: { value: classes[jobs_by_pk.class] } } : {}),
|
||||
ItemRef: {
|
||||
value: items[responsibilityCenters.ttl_adjustment.accountitem]
|
||||
value: items[responsibilityCenters.ttl_adjustment?.accountitem]
|
||||
},
|
||||
TaxCodeRef: {
|
||||
value: QboTaxId
|
||||
@@ -586,11 +586,11 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes
|
||||
} else {
|
||||
InvoiceLineAdd.push({
|
||||
ItemRef: {
|
||||
FullName: responsibilityCenters.ttl_adjustment.accountitem
|
||||
FullName: responsibilityCenters.ttl_adjustment?.accountitem
|
||||
},
|
||||
Desc: "Adjustment",
|
||||
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({
|
||||
imex: {
|
||||
FullName: "E"
|
||||
@@ -902,11 +902,11 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes
|
||||
|
||||
InvoiceLineAdd.push({
|
||||
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: {
|
||||
...(jobs_by_pk.class ? { ClassRef: { value: classes[jobs_by_pk.class] } } : {}),
|
||||
ItemRef: {
|
||||
value: items[responsibilityCenters.ttl_tax_adjustment.accountitem]
|
||||
value: items[responsibilityCenters.ttl_tax_adjustment?.accountitem]
|
||||
},
|
||||
TaxCodeRef: {
|
||||
value: QboTaxId
|
||||
@@ -917,11 +917,11 @@ exports.default = function ({ bodyshop, jobs_by_pk, qbo = false, items, taxCodes
|
||||
} else {
|
||||
InvoiceLineAdd.push({
|
||||
ItemRef: {
|
||||
FullName: responsibilityCenters.ttl_tax_adjustment.accountitem
|
||||
FullName: responsibilityCenters.ttl_tax_adjustment?.accountitem
|
||||
},
|
||||
Desc: "Tax Adjustment",
|
||||
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({
|
||||
imex: {
|
||||
FullName: "E"
|
||||
|
||||
@@ -850,7 +850,7 @@ function GenerateCostingData(job) {
|
||||
});
|
||||
}
|
||||
//Push adjustments to bottom line.
|
||||
if (job.job_totals.totals.ttl_adjustment) {
|
||||
if (job.job_totals?.totals?.ttl_adjustment) {
|
||||
//Add to totals.
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user