Commit 1f26bcc20c75553fcfe8564cb208986411a83c08
1 parent
22771692d9
Exists in
master
One test added
Showing 1 changed file with 2 additions and 0 deletions Inline Diff
test/main.js
1 | /* eslint-disable no-console */ | 1 | /* eslint-disable no-console */ |
2 | /* global describe it */ | 2 | /* global describe it */ |
3 | 3 | ||
4 | //process.env.KOMODO_SDK_DEBUG_RC_FROM_MSG = 'YES'; | 4 | //process.env.KOMODO_SDK_DEBUG_RC_FROM_MSG = 'YES'; |
5 | 5 | ||
6 | const should = require('should'); | 6 | const should = require('should'); |
7 | const irs = require('../index'); | 7 | const irs = require('../index'); |
8 | 8 | ||
9 | describe('#irs', function() { | 9 | describe('#irs', function() { |
10 | describe('#getRcFromMessage', function() { | 10 | describe('#getRcFromMessage', function() { |
11 | it('should return correct rc', function() { | 11 | it('should return correct rc', function() { |
12 | irs.getRcFromMessage('Request IBP25 ke 085736328877 under proses..').should.equal('68'); | 12 | irs.getRcFromMessage('Request IBP25 ke 085736328877 under proses..').should.equal('68'); |
13 | irs.getRcFromMessage('Transaksi HX5 ke 081809903333 GAGAL. Mohon periksa kembali No tujuan sebelum di ulang. Saldo: Rp 26.857.538').should.equal('40'); | 13 | irs.getRcFromMessage('Transaksi HX5 ke 081809903333 GAGAL. Mohon periksa kembali No tujuan sebelum di ulang. Saldo: Rp 26.857.538').should.equal('40'); |
14 | irs.getRcFromMessage('REFF#11538167 Trx IBP25.085736328877 BERHASIL,Harga: 24.475 SN: 503133415264594 Sisa Saldo: 1.169.227 - 24.475 = 1.144.752 @5/3/2018 1:34:13 PM').should.equal('00'); | 14 | irs.getRcFromMessage('REFF#11538167 Trx IBP25.085736328877 BERHASIL,Harga: 24.475 SN: 503133415264594 Sisa Saldo: 1.169.227 - 24.475 = 1.144.752 @5/3/2018 1:34:13 PM').should.equal('00'); |
15 | 15 | ||
16 | irs.getRcFromMessage('REFF#1238 CEK TAGIHAN PLN16 SUKSES IDPEL:538710624871 Detail: NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041 Sisa Saldo: 180.318 - 0 = 180.318 @29/12/2017 9:48:16').should.equal('00', 'postpaid inquiry success'); | 16 | irs.getRcFromMessage('REFF#1238 CEK TAGIHAN PLN16 SUKSES IDPEL:538710624871 Detail: NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041 Sisa Saldo: 180.318 - 0 = 180.318 @29/12/2017 9:48:16').should.equal('00', 'postpaid inquiry success'); |
17 | irs.getRcFromMessage('REFF#1239 BAYAR TAGIHAN PLN16 SUKSES IDPEL:538710624871 Detail:S/N:0BNS25G5043265250358/NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLNPERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALBAYAR:19041 Sisa Saldo: 180.318 - 17.741 = 162.577 @29/12/2017 9:48:41').should.equal('00', 'postpaid payment success'); | 17 | irs.getRcFromMessage('REFF#1239 BAYAR TAGIHAN PLN16 SUKSES IDPEL:538710624871 Detail:S/N:0BNS25G5043265250358/NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLNPERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALBAYAR:19041 Sisa Saldo: 180.318 - 17.741 = 162.577 @29/12/2017 9:48:41').should.equal('00', 'postpaid payment success'); |
18 | 18 | ||
19 | irs.getRcFromMessage('Maaf Produk sedang gangguan').should.equal('90'); | 19 | irs.getRcFromMessage('Maaf Produk sedang gangguan').should.equal('90'); |
20 | |||
21 | irs.getRcFromMessage('Trx PLN ke 0001465757368 GAGAL. NOMOR ID YANG ANDA MASUKKAN SALAH, MOHON TELITI KEMBALI 43.156.10').should.equal('14'); | ||
20 | }); | 22 | }); |
21 | }); | 23 | }); |
22 | 24 | ||
23 | describe('#getPriceFromMessage', function() { | 25 | describe('#getPriceFromMessage', function() { |
24 | describe('#generic', function() { | 26 | describe('#generic', function() { |
25 | it('should return correct price', function() { | 27 | it('should return correct price', function() { |
26 | irs.getPriceFromMessage('REFF#11538167 Trx IBP25.085736328877 BERHASIL,Harga: 24.475 SN: 503133415264594 Sisa Saldo: 1.169.227 - 24.475 = 1.144.752 @5/3/2018 1:34:13 PM').should.equal(24475); | 28 | irs.getPriceFromMessage('REFF#11538167 Trx IBP25.085736328877 BERHASIL,Harga: 24.475 SN: 503133415264594 Sisa Saldo: 1.169.227 - 24.475 = 1.144.752 @5/3/2018 1:34:13 PM').should.equal(24475); |
27 | }); | 29 | }); |
28 | 30 | ||
29 | it('should handle postpaid response', () => { | 31 | it('should handle postpaid response', () => { |
30 | irs.getPriceFromMessage('REFF#1238 CEK TAGIHAN PLN16 SUKSES IDPEL:538710624871 Detail: NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041 Sisa Saldo: 180.318 - 0 = 180.318 @29/12/2017 9:48:16').should.equal(0, 'postpaid inquiry succces'); | 32 | irs.getPriceFromMessage('REFF#1238 CEK TAGIHAN PLN16 SUKSES IDPEL:538710624871 Detail: NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041 Sisa Saldo: 180.318 - 0 = 180.318 @29/12/2017 9:48:16').should.equal(0, 'postpaid inquiry succces'); |
31 | irs.getPriceFromMessage('REFF#1239 BAYAR TAGIHAN PLN16 SUKSES IDPEL:538710624871 Detail:S/N:0BNS25G5043265250358/NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLNPERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALBAYAR:19041 Sisa Saldo: 180.318 - 17.741 = 162.577 @29/12/2017 9:48:41').should.equal(17741, 'postpaid payment success'); | 33 | irs.getPriceFromMessage('REFF#1239 BAYAR TAGIHAN PLN16 SUKSES IDPEL:538710624871 Detail:S/N:0BNS25G5043265250358/NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLNPERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALBAYAR:19041 Sisa Saldo: 180.318 - 17.741 = 162.577 @29/12/2017 9:48:41').should.equal(17741, 'postpaid payment success'); |
32 | irs.getPriceFromMessage('REFF#562126 BAYAR TAGIHAN PLN25 SUKSES IDPEL:172000147469 Detail:S/N: 0BNS25G5008509025529/NAMA:MASJID-NURUL-IMAN/DAYA:900/TARIF:S2/JMLBLN:1BLN/PERIODE:201912/METERKINI:19627/METERLALU:19428/TAGIHAN:79340/ADM:2500/DENDA:0/TOTALBAYAR:81840 Sisa Saldo: 1.000.000 - 79.540 = 920.460 @2019/12/20 19:49:21').should.equal(79540); | 34 | irs.getPriceFromMessage('REFF#562126 BAYAR TAGIHAN PLN25 SUKSES IDPEL:172000147469 Detail:S/N: 0BNS25G5008509025529/NAMA:MASJID-NURUL-IMAN/DAYA:900/TARIF:S2/JMLBLN:1BLN/PERIODE:201912/METERKINI:19627/METERLALU:19428/TAGIHAN:79340/ADM:2500/DENDA:0/TOTALBAYAR:81840 Sisa Saldo: 1.000.000 - 79.540 = 920.460 @2019/12/20 19:49:21').should.equal(79540); |
33 | }) | 35 | }) |
34 | 36 | ||
35 | it('should handle missing price', function() { | 37 | it('should handle missing price', function() { |
36 | should.not.exist(irs.getPriceFromMessage('REFF#11538167 Trx IBP25.085736328877 BERHASIL, SN: 503133415264594 @5/3/2018 1:34:13 PM')); | 38 | should.not.exist(irs.getPriceFromMessage('REFF#11538167 Trx IBP25.085736328877 BERHASIL, SN: 503133415264594 @5/3/2018 1:34:13 PM')); |
37 | }); | 39 | }); |
38 | }); | 40 | }); |
39 | 41 | ||
40 | describe('#eflashtron', function() { | 42 | describe('#eflashtron', function() { |
41 | it('should return correct price', function() { | 43 | it('should return correct price', function() { |
42 | irs.getPriceFromMessage('Trx HT5.08989355280 BERHASIL. SN: 0608211002164754102. Sisa Saldo: 536.581 - 5.265 = 531.316 @08/06/2019 21:10:03 Komplen max. H+7').should.equal(5265); | 44 | irs.getPriceFromMessage('Trx HT5.08989355280 BERHASIL. SN: 0608211002164754102. Sisa Saldo: 536.581 - 5.265 = 531.316 @08/06/2019 21:10:03 Komplen max. H+7').should.equal(5265); |
43 | }); | 45 | }); |
44 | }); | 46 | }); |
45 | 47 | ||
46 | describe('#some suppliers', () => { | 48 | describe('#some suppliers', () => { |
47 | it('should return correct price', () => { | 49 | it('should return correct price', () => { |
48 | irs.getPriceFromMessage('Trx S10 085212341234 BERHASIL, Harga: 5.285 SN: 41002553325946 Saldo: 2.284.011 - 5.285 = 2.278.726 @24/06/2018 18:38:06') | 50 | irs.getPriceFromMessage('Trx S10 085212341234 BERHASIL, Harga: 5.285 SN: 41002553325946 Saldo: 2.284.011 - 5.285 = 2.278.726 @24/06/2018 18:38:06') |
49 | .should.equal(5285, 'tajir price'); | 51 | .should.equal(5285, 'tajir price'); |
50 | }); | 52 | }); |
51 | }); | 53 | }); |
52 | 54 | ||
53 | describe('#custom', () => { | 55 | describe('#custom', () => { |
54 | it('should return correct price', () => { | 56 | it('should return correct price', () => { |
55 | const msg = 'HX5 No.087781522208 Berhasil SN:99971113094584 Tgl 2019-13-11 12:31:47.Saldo Anda 495.630 - Rp 5.525 = Rp 490.105'; | 57 | const msg = 'HX5 No.087781522208 Berhasil SN:99971113094584 Tgl 2019-13-11 12:31:47.Saldo Anda 495.630 - Rp 5.525 = Rp 490.105'; |
56 | const rule = { | 58 | const rule = { |
57 | pattern: 'Saldo Anda (?:[\\d\\.]+) - Rp ([\\d\\.]+)', | 59 | pattern: 'Saldo Anda (?:[\\d\\.]+) - Rp ([\\d\\.]+)', |
58 | match_idx: 1, | 60 | match_idx: 1, |
59 | } | 61 | } |
60 | irs.getPriceFromMessage(msg, rule).should.equal(5525); | 62 | irs.getPriceFromMessage(msg, rule).should.equal(5525); |
61 | should.not.exists(irs.getPriceFromMessage('kosong', rule)); | 63 | should.not.exists(irs.getPriceFromMessage('kosong', rule)); |
62 | }); | 64 | }); |
63 | }) | 65 | }) |
64 | }); | 66 | }); |
65 | 67 | ||
66 | describe('#getBalanceFromMessage', () => { | 68 | describe('#getBalanceFromMessage', () => { |
67 | 69 | ||
68 | describe('#some suppliers', () => { | 70 | describe('#some suppliers', () => { |
69 | it('should return correct price', () => { | 71 | it('should return correct price', () => { |
70 | irs.getBalanceFromMessage('Trx S10 085212341234 BERHASIL, Harga: 5.285 SN: 41002553325946 Saldo: 2.284.011 - 5.285 = 2.278.726 @24/06/2018 18:38:06') | 72 | irs.getBalanceFromMessage('Trx S10 085212341234 BERHASIL, Harga: 5.285 SN: 41002553325946 Saldo: 2.284.011 - 5.285 = 2.278.726 @24/06/2018 18:38:06') |
71 | .should.equal(2278726, 'tajir balance'); | 73 | .should.equal(2278726, 'tajir balance'); |
72 | }); | 74 | }); |
73 | }); | 75 | }); |
74 | 76 | ||
75 | 77 | ||
76 | describe('#custom', () => { | 78 | describe('#custom', () => { |
77 | it('should return correct price', () => { | 79 | it('should return correct price', () => { |
78 | const msg = 'HX5 No.087781522208 Berhasil SN:99971113094584 Tgl 2019-13-11 12:31:47.Saldo Anda 495.630 - Rp 5.525 = Rp 490.105'; | 80 | const msg = 'HX5 No.087781522208 Berhasil SN:99971113094584 Tgl 2019-13-11 12:31:47.Saldo Anda 495.630 - Rp 5.525 = Rp 490.105'; |
79 | const rule = { | 81 | const rule = { |
80 | pattern: 'Saldo Anda (?:[\\d\\.]+) - Rp (?:[\\d\\.]+) = Rp ([\\d\\.]+)', | 82 | pattern: 'Saldo Anda (?:[\\d\\.]+) - Rp (?:[\\d\\.]+) = Rp ([\\d\\.]+)', |
81 | match_idx: 1, | 83 | match_idx: 1, |
82 | } | 84 | } |
83 | irs.getBalanceFromMessage(msg, rule).should.equal(490105); | 85 | irs.getBalanceFromMessage(msg, rule).should.equal(490105); |
84 | should.not.exists(irs.getBalanceFromMessage('kosong', rule)); | 86 | should.not.exists(irs.getBalanceFromMessage('kosong', rule)); |
85 | }); | 87 | }); |
86 | }) | 88 | }) |
87 | }); | 89 | }); |
88 | 90 | ||
89 | describe('#getSnFromMessage', () => { | 91 | describe('#getSnFromMessage', () => { |
90 | it('should return correct result', () => { | 92 | it('should return correct result', () => { |
91 | irs.getSnFromMessage('HX5 No.087781522208 Berhasil SN: 99971113094584 Tgl 2019-13-11 12:31:47.Saldo Anda 495.630 - Rp 5.525 = Rp 490.105').should.equal('99971113094584', 'SN: 99971113094584'); | 93 | irs.getSnFromMessage('HX5 No.087781522208 Berhasil SN: 99971113094584 Tgl 2019-13-11 12:31:47.Saldo Anda 495.630 - Rp 5.525 = Rp 490.105').should.equal('99971113094584', 'SN: 99971113094584'); |
92 | irs.getSnFromMessage('HX5 No.087781522208 Berhasil SN:99971113094584 Tgl 2019-13-11 12:31:47.Saldo Anda 495.630 - Rp 5.525 = Rp 490.105').should.equal('99971113094584', 'SN:99971113094584'); | 94 | irs.getSnFromMessage('HX5 No.087781522208 Berhasil SN:99971113094584 Tgl 2019-13-11 12:31:47.Saldo Anda 495.630 - Rp 5.525 = Rp 490.105').should.equal('99971113094584', 'SN:99971113094584'); |
93 | irs.getSnFromMessage('REFF#22955367 BAYAR TAGIHAN PLN25 SUKSES IDPEL:173300992349 Detail:S/N: 0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560 Sisa Saldo: 40.653.798 - 140.960 = 40.512.838 @2019/11/28 11:44:36') | 95 | irs.getSnFromMessage('REFF#22955367 BAYAR TAGIHAN PLN25 SUKSES IDPEL:173300992349 Detail:S/N: 0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560 Sisa Saldo: 40.653.798 - 140.960 = 40.512.838 @2019/11/28 11:44:36') |
94 | .should.equal('0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560', 'kiosbayar postpaid payment'); | 96 | .should.equal('0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560', 'kiosbayar postpaid payment'); |
95 | }); | 97 | }); |
96 | }); | 98 | }); |
97 | 99 | ||
98 | describe('#getDetailFromMessage', () => { | 100 | describe('#getDetailFromMessage', () => { |
99 | it('should return correct result', () => { | 101 | it('should return correct result', () => { |
100 | irs.getDetailFromMessage('REFF#1238 CEK TAGIHAN PLN16 SUKSES IDPEL:538710624871 Detail: NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041 Sisa Saldo: 180.318 - 0 = 180.318 @29/12/2017 9:48:16') | 102 | irs.getDetailFromMessage('REFF#1238 CEK TAGIHAN PLN16 SUKSES IDPEL:538710624871 Detail: NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041 Sisa Saldo: 180.318 - 0 = 180.318 @29/12/2017 9:48:16') |
101 | .should.equal('NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041', 'postpaid inquiry success'); | 103 | .should.equal('NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041', 'postpaid inquiry success'); |
102 | 104 | ||
103 | irs.getDetailFromMessage('REFF#22955367 BAYAR TAGIHAN PLN25 SUKSES IDPEL:173300992349 Detail:S/N: 0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560 Sisa Saldo: 40.653.798 - 140.960 = 40.512.838 @2019/11/28 11:44:36') | 105 | irs.getDetailFromMessage('REFF#22955367 BAYAR TAGIHAN PLN25 SUKSES IDPEL:173300992349 Detail:S/N: 0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560 Sisa Saldo: 40.653.798 - 140.960 = 40.512.838 @2019/11/28 11:44:36') |
104 | .should.equal('S/N: 0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560', 'kiosbayar postpaid payment'); | 106 | .should.equal('S/N: 0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560', 'kiosbayar postpaid payment'); |
105 | 107 | ||
106 | irs.getDetailFromMessage('REFF#561744 CEK TAGIHAN PLN25 SUKSES IDPEL:172000147469 Detail: NAMA:MASJID-NURUL-IMAN/DAYA:900/TARIF:S2/JMLBLN:1BLN/PERIODE:201912/METERKINI:19627/METERLALU:19428/TAGIHAN:79340/ADM:2500/DENDA:0/TOTALTAGIHAN:81840 Sisa Saldo: 1.000.000 - 0 = 1.000.000 @2019/12/20 19:41:21') | 108 | irs.getDetailFromMessage('REFF#561744 CEK TAGIHAN PLN25 SUKSES IDPEL:172000147469 Detail: NAMA:MASJID-NURUL-IMAN/DAYA:900/TARIF:S2/JMLBLN:1BLN/PERIODE:201912/METERKINI:19627/METERLALU:19428/TAGIHAN:79340/ADM:2500/DENDA:0/TOTALTAGIHAN:81840 Sisa Saldo: 1.000.000 - 0 = 1.000.000 @2019/12/20 19:41:21') |
107 | .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'); | 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'); |
108 | }); | 110 | }); |
109 | 111 | ||
110 | it('should return correct result with tajira response', () => { | 112 | it('should return correct result with tajira response', () => { |
111 | const detailPattern = { | 113 | const detailPattern = { |
112 | pattern: '(REFID: .*?)($|(, *SALDO))', | 114 | pattern: '(REFID: .*?)($|(, *SALDO))', |
113 | match_idx: 1, | 115 | match_idx: 1, |
114 | }; | 116 | }; |
115 | 117 | ||
116 | const detailReplacements = [ | 118 | const detailReplacements = [ |
117 | { | 119 | { |
118 | pattern: ' *\\.\\.+ *', | 120 | pattern: ' *\\.\\.+ *', |
119 | replacement: '/', | 121 | replacement: '/', |
120 | flags: 'g', | 122 | flags: 'g', |
121 | }, | 123 | }, |
122 | { | 124 | { |
123 | pattern: ' *, *', | 125 | pattern: ' *, *', |
124 | replacement: '/', | 126 | replacement: '/', |
125 | flags: 'g', | 127 | flags: 'g', |
126 | }, | 128 | }, |
127 | { | 129 | { |
128 | pattern: ' *: *', | 130 | pattern: ' *: *', |
129 | replacement: ':', | 131 | replacement: ':', |
130 | flags: 'g', | 132 | flags: 'g', |
131 | }, | 133 | }, |
132 | { | 134 | { |
133 | pattern: 'TOTAL TAGIHAN*', | 135 | pattern: 'TOTAL TAGIHAN*', |
134 | replacement: 'TOTALTAGIHAN', | 136 | replacement: 'TOTALTAGIHAN', |
135 | }, | 137 | }, |
136 | ] | 138 | ] |
137 | 139 | ||
138 | irs.getDetailFromMessage( | 140 | irs.getDetailFromMessage( |
139 | 'Cek Tagihan PLN SUKSES ke 520550410074, REFID: 520550410074/MASJID.. KATEGORI:S2/900 , PERIODE:092020, JUMLAH:1, TOTAL TAGIHAN : 72.010', | 141 | 'Cek Tagihan PLN SUKSES ke 520550410074, REFID: 520550410074/MASJID.. KATEGORI:S2/900 , PERIODE:092020, JUMLAH:1, TOTAL TAGIHAN : 72.010', |
140 | detailPattern, | 142 | detailPattern, |
141 | detailReplacements | 143 | detailReplacements |
142 | ).should.equal('REFID:520550410074/MASJID/KATEGORI:S2/900/PERIODE:092020/JUMLAH:1/TOTALTAGIHAN:72.010', 'TAJIRA PLN POSTPAID'); | 144 | ).should.equal('REFID:520550410074/MASJID/KATEGORI:S2/900/PERIODE:092020/JUMLAH:1/TOTALTAGIHAN:72.010', 'TAJIRA PLN POSTPAID'); |
143 | 145 | ||
144 | // const detailPattern2 = { | 146 | // const detailPattern2 = { |
145 | // pattern: '(REFID: .*), SALDO', | 147 | // pattern: '(REFID: .*), SALDO', |
146 | // match_idx: 1, | 148 | // match_idx: 1, |
147 | // }; | 149 | // }; |
148 | 150 | ||
149 | irs.getDetailFromMessage( | 151 | irs.getDetailFromMessage( |
150 | 'CEK TAGIHAN PLNFULL SUKSES KE 520550388323, REFID: 52055038832320700700.. NAMA:MUSHOLA AL AMIN, KATEGORIDAYA:S2/450, PERIODE:092020, TAGIHANASLI:16620, DENDA:3000, ADMIN:2750, TOTALBAYAR:19.370, SALDO:500.000', | 152 | 'CEK TAGIHAN PLNFULL SUKSES KE 520550388323, REFID: 52055038832320700700.. NAMA:MUSHOLA AL AMIN, KATEGORIDAYA:S2/450, PERIODE:092020, TAGIHANASLI:16620, DENDA:3000, ADMIN:2750, TOTALBAYAR:19.370, SALDO:500.000', |
151 | detailPattern, | 153 | detailPattern, |
152 | detailReplacements | 154 | detailReplacements |
153 | ).should.equal( | 155 | ).should.equal( |
154 | 'REFID:52055038832320700700/NAMA:MUSHOLA AL AMIN/KATEGORIDAYA:S2/450/PERIODE:092020/TAGIHANASLI:16620/DENDA:3000/ADMIN:2750/TOTALBAYAR:19.370', | 156 | 'REFID:52055038832320700700/NAMA:MUSHOLA AL AMIN/KATEGORIDAYA:S2/450/PERIODE:092020/TAGIHANASLI:16620/DENDA:3000/ADMIN:2750/TOTALBAYAR:19.370', |
155 | 'TAJIRA PLN POSTPAID 2', | 157 | 'TAJIRA PLN POSTPAID 2', |
156 | ); | 158 | ); |
157 | 159 | ||
158 | irs.getDetailFromMessage( | 160 | irs.getDetailFromMessage( |
159 | 'Cek Tagihan BPJSKH2H SUKSES ke 0002058343828, REFID: 20809404.. NAMA:SALWA AZ ZAHRA, CABANG:1012-DEPOK, Periode:1,Admin:2500, TOTALBAYAR:28.000, SALDO:186.856', | 161 | 'Cek Tagihan BPJSKH2H SUKSES ke 0002058343828, REFID: 20809404.. NAMA:SALWA AZ ZAHRA, CABANG:1012-DEPOK, Periode:1,Admin:2500, TOTALBAYAR:28.000, SALDO:186.856', |
160 | detailPattern, | 162 | detailPattern, |
161 | detailReplacements, | 163 | detailReplacements, |
162 | ).should.equal( | 164 | ).should.equal( |
163 | 'REFID:20809404/NAMA:SALWA AZ ZAHRA/CABANG:1012-DEPOK/Periode:1/Admin:2500/TOTALBAYAR:28.000', | 165 | 'REFID:20809404/NAMA:SALWA AZ ZAHRA/CABANG:1012-DEPOK/Periode:1/Admin:2500/TOTALBAYAR:28.000', |
164 | 'TAJIRA BPJS', | 166 | 'TAJIRA BPJS', |
165 | ) | 167 | ) |
166 | 168 | ||
167 | }); | 169 | }); |
168 | }); | 170 | }); |
169 | 171 | ||
170 | describe('#splitPostpaidDetail', () => { | 172 | describe('#splitPostpaidDetail', () => { |
171 | it('should handle invalid input', () => { | 173 | it('should handle invalid input', () => { |
172 | irs.splitPostpaidDetail(null).length.should.equal(0); | 174 | irs.splitPostpaidDetail(null).length.should.equal(0); |
173 | irs.splitPostpaidDetail('').length.should.equal(0); | 175 | irs.splitPostpaidDetail('').length.should.equal(0); |
174 | }); | 176 | }); |
175 | 177 | ||
176 | it('should return correct result - inquiry', () => { | 178 | it('should return correct result - inquiry', () => { |
177 | const detail = 'NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041'; | 179 | const detail = 'NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041'; |
178 | const splitted = irs.splitPostpaidDetail(detail); | 180 | const splitted = irs.splitPostpaidDetail(detail); |
179 | 181 | ||
180 | splitted.should.ok(); | 182 | splitted.should.ok(); |
181 | splitted.find((item) => item.keyword === 'NAMA').value.should.equal('MUSHOLLA-NURUL-KHOIR'); | 183 | splitted.find((item) => item.keyword === 'NAMA').value.should.equal('MUSHOLLA-NURUL-KHOIR'); |
182 | splitted.find((item) => item.keyword === 'TAGIHAN').value.should.equal('14441'); | 184 | splitted.find((item) => item.keyword === 'TAGIHAN').value.should.equal('14441'); |
183 | splitted.find((item) => item.keyword === 'DENDA').value.should.equal('3000'); | 185 | splitted.find((item) => item.keyword === 'DENDA').value.should.equal('3000'); |
184 | }); | 186 | }); |
185 | 187 | ||
186 | it('should return correct result - pay', () => { | 188 | it('should return correct result - pay', () => { |
187 | const detail = 'S/N: 0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560'; | 189 | const detail = 'S/N: 0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560'; |
188 | const splitted = irs.splitPostpaidDetail(detail); | 190 | const splitted = irs.splitPostpaidDetail(detail); |
189 | 191 | ||
190 | splitted.should.ok(); | 192 | splitted.should.ok(); |
191 | splitted.find((item) => item.keyword === 'SN').value.should.equal('0BNS25G5082152526173'); | 193 | splitted.find((item) => item.keyword === 'SN').value.should.equal('0BNS25G5082152526173'); |
192 | splitted.find((item) => item.keyword === 'NAMA').value.should.equal('DONAR-HARHAP'); | 194 | splitted.find((item) => item.keyword === 'NAMA').value.should.equal('DONAR-HARHAP'); |
193 | splitted.find((item) => item.keyword === 'TAGIHAN').value.should.equal('131560'); | 195 | splitted.find((item) => item.keyword === 'TAGIHAN').value.should.equal('131560'); |
194 | splitted.find((item) => item.keyword === 'DENDA').value.should.equal('9000'); | 196 | splitted.find((item) => item.keyword === 'DENDA').value.should.equal('9000'); |
195 | }); | 197 | }); |
196 | 198 | ||
197 | it('should return correct result - tajira', () => { | 199 | it('should return correct result - tajira', () => { |
198 | const splitted = irs.splitPostpaidDetail('REFID:20770812/NAMA:SALWA AZ ZAHRA/CABANG:1012-DEPOK/Periode:1/Admin:2500/TOTALBAYAR:28.000'); | 200 | const splitted = irs.splitPostpaidDetail('REFID:20770812/NAMA:SALWA AZ ZAHRA/CABANG:1012-DEPOK/Periode:1/Admin:2500/TOTALBAYAR:28.000'); |
199 | // console.log(splitted); | 201 | // console.log(splitted); |
200 | splitted.find((item) => item.keyword === 'REFID').value.should.equal('20770812'); | 202 | splitted.find((item) => item.keyword === 'REFID').value.should.equal('20770812'); |
201 | splitted.find((item) => item.keyword === 'Admin').value.should.equal('2500'); | 203 | splitted.find((item) => item.keyword === 'Admin').value.should.equal('2500'); |
202 | 204 | ||
203 | const splitted2 = irs.splitPostpaidDetail('REFID:20809404/NAMA:SALWA AZ ZAHRA/CABANG:1012-DEPOK/Periode:1/Admin:2500/TOTALBAYAR:28.000'); | 205 | const splitted2 = irs.splitPostpaidDetail('REFID:20809404/NAMA:SALWA AZ ZAHRA/CABANG:1012-DEPOK/Periode:1/Admin:2500/TOTALBAYAR:28.000'); |
204 | splitted2.find((item) => item.keyword === 'TOTALBAYAR').value.should.equal('28.000', 'TAJIRA BPJS'); | 206 | splitted2.find((item) => item.keyword === 'TOTALBAYAR').value.should.equal('28.000', 'TAJIRA BPJS'); |
205 | }); | 207 | }); |
206 | }); | 208 | }); |
207 | 209 | ||
208 | describe('#calculateBaseBillAmount', () => { | 210 | describe('#calculateBaseBillAmount', () => { |
209 | it('should return correct value - inquiry', () => { | 211 | it('should return correct value - inquiry', () => { |
210 | const detail = 'NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041'; | 212 | const detail = 'NAMA:MUSHOLLA-NURUL-KHOIR/DAYA:450/TARIF:S2/JMLBLN:1BLN/PERIODE:201712/METERKINI:18984/METERLALU:18932/TAGIHAN:14441/ADM:1600/DENDA:3000/TOTALTAGIHAN:19041'; |
211 | const splitted = irs.splitPostpaidDetail(detail); | 213 | const splitted = irs.splitPostpaidDetail(detail); |
212 | 214 | ||
213 | irs.calculateBaseBillAmount(splitted).should.equal(17441); | 215 | irs.calculateBaseBillAmount(splitted).should.equal(17441); |
214 | 216 | ||
215 | }) | 217 | }) |
216 | 218 | ||
217 | it('should return correct value - payment', () => { | 219 | it('should return correct value - payment', () => { |
218 | const detail = 'S/N: 0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560'; | 220 | const detail = 'S/N: 0BNS25G5082152526173/NAMA:DONAR-HARHAP/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201910,201911/METERKINI:5508/METERLALU:5508/TAGIHAN:131560/ADM:5000/DENDA:9000/TOTALBAYAR:145560'; |
219 | const splitted = irs.splitPostpaidDetail(detail); | 221 | const splitted = irs.splitPostpaidDetail(detail); |
220 | 222 | ||
221 | // console.log('--- DEBUG'); | 223 | // console.log('--- DEBUG'); |
222 | // console.log(splitted); | 224 | // console.log(splitted); |
223 | // console.log('---'); | 225 | // console.log('---'); |
224 | 226 | ||
225 | irs.calculateBaseBillAmount(splitted).should.equal(140560, '#2CBDCEB8'); | 227 | irs.calculateBaseBillAmount(splitted).should.equal(140560, '#2CBDCEB8'); |
226 | 228 | ||
227 | }) | 229 | }) |
228 | 230 | ||
229 | it('should return correct value - inquiry - tajira', () => { | 231 | it('should return correct value - inquiry - tajira', () => { |
230 | const detail = 'REFID:52055038964420747312/NAMA:MASJID AN NUR/KATEGORIDAYA:S2/450/PERIODE:092020/TAGIHANASLI:7140/DENDA:3000/ADMIN:2750/TOTALBAYAR:12.890'; | 232 | const detail = 'REFID:52055038964420747312/NAMA:MASJID AN NUR/KATEGORIDAYA:S2/450/PERIODE:092020/TAGIHANASLI:7140/DENDA:3000/ADMIN:2750/TOTALBAYAR:12.890'; |
231 | const splitted = irs.splitPostpaidDetail(detail); | 233 | const splitted = irs.splitPostpaidDetail(detail); |
232 | 234 | ||
233 | irs.calculateBaseBillAmount( | 235 | irs.calculateBaseBillAmount( |
234 | splitted, | 236 | splitted, |
235 | null, | 237 | null, |
236 | // { | 238 | // { |
237 | // KEYWORD_TAGASLI: 'TAGIHANASLI,DENDA', | 239 | // KEYWORD_TAGASLI: 'TAGIHANASLI,DENDA', |
238 | // }, | 240 | // }, |
239 | // 1 | 241 | // 1 |
240 | ).should.equal(10140); | 242 | ).should.equal(10140); |
241 | 243 | ||
242 | irs.calculateBaseBillAmount( | 244 | irs.calculateBaseBillAmount( |
243 | irs.splitPostpaidDetail('REFID:20770812/NAMA:SALWA AZ ZAHRA/CABANG:1012-DEPOK/Periode:1/Admin:2500/TOTALBAYAR:28.000'), | 245 | irs.splitPostpaidDetail('REFID:20770812/NAMA:SALWA AZ ZAHRA/CABANG:1012-DEPOK/Periode:1/Admin:2500/TOTALBAYAR:28.000'), |
244 | null, | 246 | null, |
245 | { | 247 | { |
246 | KEYWORD_TOTALTAG: 'TOTALBAYAR', | 248 | KEYWORD_TOTALTAG: 'TOTALBAYAR', |
247 | KEYWORD_ADMINFEE: 'Admin', | 249 | KEYWORD_ADMINFEE: 'Admin', |
248 | }, | 250 | }, |
249 | 1 | 251 | 1 |
250 | ).should.equal(25500); | 252 | ).should.equal(25500); |
251 | 253 | ||
252 | const productKeyvalBPJSK = { | 254 | const productKeyvalBPJSK = { |
253 | KEYWORD_TOTALTAG: 'TOTALBAYAR', | 255 | KEYWORD_TOTALTAG: 'TOTALBAYAR', |
254 | KEYWORD_ADMINFEE: 'Admin', | 256 | KEYWORD_ADMINFEE: 'Admin', |
255 | }; | 257 | }; |
256 | irs.calculateBaseBillAmount( | 258 | irs.calculateBaseBillAmount( |
257 | irs.splitPostpaidDetail('REFID:20809404/NAMA:SALWA AZ ZAHRA/CABANG:1012-DEPOK/Periode:1/Admin:2500/TOTALBAYAR:28.000'), | 259 | irs.splitPostpaidDetail('REFID:20809404/NAMA:SALWA AZ ZAHRA/CABANG:1012-DEPOK/Periode:1/Admin:2500/TOTALBAYAR:28.000'), |
258 | null, | 260 | null, |
259 | productKeyvalBPJSK, | 261 | productKeyvalBPJSK, |
260 | 1 | 262 | 1 |
261 | ).should.equal(25500, 'TAJIRA BPJS #8A46CFD1'); | 263 | ).should.equal(25500, 'TAJIRA BPJS #8A46CFD1'); |
262 | }); | 264 | }); |
263 | }); | 265 | }); |
264 | 266 | ||
265 | describe('#getBillCount', () => { | 267 | describe('#getBillCount', () => { |
266 | it('should return correct value', () => { | 268 | it('should return correct value', () => { |
267 | irs.getBillCount('0BNS25G5087744307740/NAMA:SUYATMAN/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201911,201912/METERKINI:3606/METERLALU:3564/TAGIHAN:117260/ADM:5000/DENDA:9000/TOTALBAYAR:131260').should.equal(2); | 269 | irs.getBillCount('0BNS25G5087744307740/NAMA:SUYATMAN/DAYA:900/TARIF:R1M/JMLBLN:2BLN/PERIODE:201911,201912/METERKINI:3606/METERLALU:3564/TAGIHAN:117260/ADM:5000/DENDA:9000/TOTALBAYAR:131260').should.equal(2); |
268 | should.not.exists(irs.getBillCount('0BNS25G5087744307740/NAMA:SUYATMAN/DAYA:900/TARIF:R1M/JMLBLN:BLN/PERIODE:201911,201912/METERKINI:3606/METERLALU:3564/TAGIHAN:117260/ADM:5000/DENDA:9000/TOTALBAYAR:131260')); | 270 | should.not.exists(irs.getBillCount('0BNS25G5087744307740/NAMA:SUYATMAN/DAYA:900/TARIF:R1M/JMLBLN:BLN/PERIODE:201911,201912/METERKINI:3606/METERLALU:3564/TAGIHAN:117260/ADM:5000/DENDA:9000/TOTALBAYAR:131260')); |
269 | should.not.exists(irs.getBillCount('')); | 271 | should.not.exists(irs.getBillCount('')); |
270 | should.not.exists(irs.getBillCount()); | 272 | should.not.exists(irs.getBillCount()); |
271 | }); | 273 | }); |
272 | }); | 274 | }); |
273 | }); | 275 | }); |