Commit 68717b5ed7e4a34b3c1a307a46167f947ed71d0b
1 parent
9387d1a2f7
Exists in
master
Perbaikan deteksi auto calculate pada detail postpaid.
Butuh unit test untuk cek. Coba dengan respon HTC
Showing 2 changed files with 35 additions and 1 deletions Side-by-side Diff
index.js
... | ... | @@ -169,7 +169,7 @@ function calculateBaseBillAmount(detailSplitted, customKeywords, productKeyval, |
169 | 169 | if ( |
170 | 170 | !productKeyval |
171 | 171 | || !productKeyval.KEYWORD_TOTALTAG |
172 | - || !productKeyval.KEYWORD_ADMINFEE | |
172 | + || (!productKeyval.KEYWORD_ADMINFEE && !!productKeyval.ADMINFEE) | |
173 | 173 | ) { |
174 | 174 | return calculateBaseBillAmountAuto(detailSplitted, customKeywords, productKeyval, billCount); |
175 | 175 | } |
test/main.js
... | ... | @@ -109,6 +109,40 @@ describe('#irs', function() { |
109 | 109 | .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'); |
110 | 110 | }); |
111 | 111 | |
112 | + it('should return correct result with htc postpaid bpjsks response', () => { | |
113 | + const msg = 'CEK BPJSKS BERHASIL,SN:IDPEL:0001465757368,NAMA:BAMBANG PARTODEWO,CABANG:1101-SEMARANG,JML:,TOTALBAYAR:28.000'; | |
114 | + | |
115 | + const detailPattern = { | |
116 | + pattern: 'SN:(.*)($|(, *SALDO))', | |
117 | + match_idx: 1, | |
118 | + }; | |
119 | + | |
120 | + const detailReplacements = [ | |
121 | + { | |
122 | + pattern: ' *\\.\\.+ *', | |
123 | + replacement: '/', | |
124 | + flags: 'g', | |
125 | + }, | |
126 | + { | |
127 | + pattern: ' *, *', | |
128 | + replacement: '/', | |
129 | + flags: 'g', | |
130 | + }, | |
131 | + { | |
132 | + pattern: ' *: *', | |
133 | + replacement: ':', | |
134 | + flags: 'g', | |
135 | + }, | |
136 | + ] | |
137 | + | |
138 | + irs.getDetailFromMessage( | |
139 | + msg, | |
140 | + detailPattern, | |
141 | + detailReplacements | |
142 | + ).should.equal('IDPEL:0001465757368/NAMA:BAMBANG PARTODEWO/CABANG:1101-SEMARANG/JML:/TOTALBAYAR:28.000', 'HTC BPJSK POSTPAID'); | |
143 | + | |
144 | + }); | |
145 | + | |
112 | 146 | it('should return correct result with tajira response', () => { |
113 | 147 | const detailPattern = { |
114 | 148 | pattern: '(REFID: .*?)($|(, *SALDO))', |