diff --git a/index.js b/index.js index bf6f5f2..45750a0 100644 --- a/index.js +++ b/index.js @@ -169,7 +169,7 @@ function calculateBaseBillAmount(detailSplitted, customKeywords, productKeyval, if ( !productKeyval || !productKeyval.KEYWORD_TOTALTAG - || !productKeyval.KEYWORD_ADMINFEE + || (!productKeyval.KEYWORD_ADMINFEE && !!productKeyval.ADMINFEE) ) { return calculateBaseBillAmountAuto(detailSplitted, customKeywords, productKeyval, billCount); } diff --git a/test/main.js b/test/main.js index 43dca46..70b0b25 100644 --- a/test/main.js +++ b/test/main.js @@ -109,6 +109,40 @@ describe('#irs', function() { .should.equal('NAMA:MASJID-NURUL-IMAN/DAYA:900/TARIF:S2/JMLBLN:1BLN/PERIODE:201912/METERKINI:19627/METERLALU:19428/TAGIHAN:79340/ADM:2500/DENDA:0/TOTALTAGIHAN:81840'); }); + it('should return correct result with htc postpaid bpjsks response', () => { + const msg = 'CEK BPJSKS BERHASIL,SN:IDPEL:0001465757368,NAMA:BAMBANG PARTODEWO,CABANG:1101-SEMARANG,JML:,TOTALBAYAR:28.000'; + + const detailPattern = { + pattern: 'SN:(.*)($|(, *SALDO))', + match_idx: 1, + }; + + const detailReplacements = [ + { + pattern: ' *\\.\\.+ *', + replacement: '/', + flags: 'g', + }, + { + pattern: ' *, *', + replacement: '/', + flags: 'g', + }, + { + pattern: ' *: *', + replacement: ':', + flags: 'g', + }, + ] + + irs.getDetailFromMessage( + msg, + detailPattern, + detailReplacements + ).should.equal('IDPEL:0001465757368/NAMA:BAMBANG PARTODEWO/CABANG:1101-SEMARANG/JML:/TOTALBAYAR:28.000', 'HTC BPJSK POSTPAID'); + + }); + it('should return correct result with tajira response', () => { const detailPattern = { pattern: '(REFID: .*?)($|(, *SALDO))',