diff --git a/index.js b/index.js index 731a15b..91364f6 100644 --- a/index.js +++ b/index.js @@ -173,20 +173,26 @@ function calculateBaseBillAmount(detailSplitted, customKeywords, productKeyval, ) { return calculateBaseBillAmountAuto(detailSplitted, customKeywords, productKeyval, billCount); } - + const billCountOrDefault = billCount || 1; const totalTagihanKeyword = productKeyval.KEYWORD_TOTALTAG; if (!totalTagihanKeyword) return 0; const totalTagihanItem = detailSplitted.find((item) => (item.keyword || '').toUpperCase() === totalTagihanKeyword.toUpperCase()); - const totalTagihanValue = Number((totalTagihanItem.value || '').trim().replace(/^rp */i, '').replace(/\./g, '')); + const totalTagihanValue = Number( + ((totalTagihanItem && totalTagihanItem.value) || '') + .trim() + .replace(/^rp */i, '') + .replace(/\./g, '') + ); + if (!totalTagihanValue) { if (process.env.DEBUG_IRS_CALCULATE_BASE_BILL_AMOUNT) { // eslint-disable-next-line no-console console.log('=========== MISSING totalTagihanValue D7282FA7'); } - + return 0; }