From 68717b5ed7e4a34b3c1a307a46167f947ed71d0b Mon Sep 17 00:00:00 2001 From: Adhidarma Hadiwinoto <me@adhisimon.org> Date: Thu, 1 Oct 2020 19:28:44 +0700 Subject: [PATCH] Perbaikan deteksi auto calculate pada detail postpaid. Butuh unit test untuk cek. Coba dengan respon HTC --- index.js | 2 +- test/main.js | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) 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))', -- 1.9.0