Commit a79b1614c3eaac6fa74379273193634546281c47

Authored by Adhidarma Hadiwinoto
1 parent 27a59eca52
Exists in master

More test

Showing 1 changed file with 5 additions and 0 deletions Inline Diff

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 }); 20 });
21 }); 21 });
22 22
23 describe('#getPriceFromMessage', function() { 23 describe('#getPriceFromMessage', function() {
24 describe('#generic', function() { 24 describe('#generic', function() {
25 it('should return correct price', function() { 25 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); 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);
27 }); 27 });
28 28
29 it('should handle postpaid response', () => { 29 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'); 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');
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'); 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');
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); 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);
33 }) 33 })
34 34
35 it('should handle missing price', function() { 35 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')); 36 should.not.exist(irs.getPriceFromMessage('REFF#11538167 Trx IBP25.085736328877 BERHASIL, SN: 503133415264594 @5/3/2018 1:34:13 PM'));
37 }); 37 });
38 }); 38 });
39 39
40 describe('#eflashtron', function() { 40 describe('#eflashtron', function() {
41 it('should return correct price', function() { 41 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); 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);
43 }); 43 });
44 }); 44 });
45 45
46 describe('#some suppliers', () => { 46 describe('#some suppliers', () => {
47 it('should return correct price', () => { 47 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') 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')
49 .should.equal(5285, 'tajir price'); 49 .should.equal(5285, 'tajir price');
50 }); 50 });
51 }); 51 });
52 52
53 describe('#custom', () => { 53 describe('#custom', () => {
54 it('should return correct price', () => { 54 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'; 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';
56 const rule = { 56 const rule = {
57 pattern: 'Saldo Anda (?:[\\d\\.]+) - Rp ([\\d\\.]+)', 57 pattern: 'Saldo Anda (?:[\\d\\.]+) - Rp ([\\d\\.]+)',
58 match_idx: 1, 58 match_idx: 1,
59 } 59 }
60 irs.getPriceFromMessage(msg, rule).should.equal(5525); 60 irs.getPriceFromMessage(msg, rule).should.equal(5525);
61 should.not.exists(irs.getPriceFromMessage('kosong', rule)); 61 should.not.exists(irs.getPriceFromMessage('kosong', rule));
62 }); 62 });
63 }) 63 })
64 }); 64 });
65 65
66 describe('#getBalanceFromMessage', () => { 66 describe('#getBalanceFromMessage', () => {
67 67
68 describe('#some suppliers', () => { 68 describe('#some suppliers', () => {
69 it('should return correct price', () => { 69 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') 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')
71 .should.equal(2278726, 'tajir balance'); 71 .should.equal(2278726, 'tajir balance');
72 }); 72 });
73 }); 73 });
74 74
75 75
76 describe('#custom', () => { 76 describe('#custom', () => {
77 it('should return correct price', () => { 77 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'; 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';
79 const rule = { 79 const rule = {
80 pattern: 'Saldo Anda (?:[\\d\\.]+) - Rp (?:[\\d\\.]+) = Rp ([\\d\\.]+)', 80 pattern: 'Saldo Anda (?:[\\d\\.]+) - Rp (?:[\\d\\.]+) = Rp ([\\d\\.]+)',
81 match_idx: 1, 81 match_idx: 1,
82 } 82 }
83 irs.getBalanceFromMessage(msg, rule).should.equal(490105); 83 irs.getBalanceFromMessage(msg, rule).should.equal(490105);
84 should.not.exists(irs.getBalanceFromMessage('kosong', rule)); 84 should.not.exists(irs.getBalanceFromMessage('kosong', rule));
85 }); 85 });
86 }) 86 })
87 }); 87 });
88 88
89 describe('#getSnFromMessage', () => { 89 describe('#getSnFromMessage', () => {
90 it('should return correct result', () => { 90 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'); 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');
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'); 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');
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') 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')
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'); 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');
95 }); 95 });
96 }); 96 });
97 97
98 describe('#getDetailFromMessage', () => { 98 describe('#getDetailFromMessage', () => {
99 it('should return correct result', () => { 99 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') 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')
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'); 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');
102 102
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') 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')
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'); 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');
105 105
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') 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')
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'); 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');
108 }); 108 });
109 109
110 it('should return correct result with tajira response', () => { 110 it('should return correct result with tajira response', () => {
111 const detailPattern = { 111 const detailPattern = {
112 pattern: '(REFID: .*?)($|(, *SALDO))', 112 pattern: '(REFID: .*?)($|(, *SALDO))',
113 match_idx: 1, 113 match_idx: 1,
114 }; 114 };
115 115
116 const detailReplacements = [ 116 const detailReplacements = [
117 { 117 {
118 pattern: ' *\\.\\.+ *', 118 pattern: ' *\\.\\.+ *',
119 replacement: '/', 119 replacement: '/',
120 flags: 'g', 120 flags: 'g',
121 }, 121 },
122 { 122 {
123 pattern: ' *, *', 123 pattern: ' *, *',
124 replacement: '/', 124 replacement: '/',
125 flags: 'g', 125 flags: 'g',
126 }, 126 },
127 { 127 {
128 pattern: ' *: *', 128 pattern: ' *: *',
129 replacement: ':', 129 replacement: ':',
130 flags: 'g', 130 flags: 'g',
131 }, 131 },
132 { 132 {
133 pattern: 'TOTAL TAGIHAN*', 133 pattern: 'TOTAL TAGIHAN*',
134 replacement: 'TOTALTAGIHAN', 134 replacement: 'TOTALTAGIHAN',
135 }, 135 },
136 ] 136 ]
137 137
138 irs.getDetailFromMessage( 138 irs.getDetailFromMessage(
139 'Cek Tagihan PLN SUKSES ke 520550410074, REFID: 520550410074/MASJID.. KATEGORI:S2/900 , PERIODE:092020, JUMLAH:1, TOTAL TAGIHAN : 72.010', 139 'Cek Tagihan PLN SUKSES ke 520550410074, REFID: 520550410074/MASJID.. KATEGORI:S2/900 , PERIODE:092020, JUMLAH:1, TOTAL TAGIHAN : 72.010',
140 detailPattern, 140 detailPattern,
141 detailReplacements 141 detailReplacements
142 ).should.equal('REFID:520550410074/MASJID/KATEGORI:S2/900/PERIODE:092020/JUMLAH:1/TOTALTAGIHAN:72.010', 'TAJIRA PLN POSTPAID'); 142 ).should.equal('REFID:520550410074/MASJID/KATEGORI:S2/900/PERIODE:092020/JUMLAH:1/TOTALTAGIHAN:72.010', 'TAJIRA PLN POSTPAID');
143 143
144 // const detailPattern2 = { 144 // const detailPattern2 = {
145 // pattern: '(REFID: .*), SALDO', 145 // pattern: '(REFID: .*), SALDO',
146 // match_idx: 1, 146 // match_idx: 1,
147 // }; 147 // };
148 148
149 irs.getDetailFromMessage( 149 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', 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',
151 detailPattern, 151 detailPattern,
152 detailReplacements 152 detailReplacements
153 ).should.equal( 153 ).should.equal(
154 'REFID:52055038832320700700/NAMA:MUSHOLA AL AMIN/KATEGORIDAYA:S2/450/PERIODE:092020/TAGIHANASLI:16620/DENDA:3000/ADMIN:2750/TOTALBAYAR:19.370', 154 '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', 155 'TAJIRA PLN POSTPAID 2',
156 ); 156 );
157 157
158 irs.getDetailFromMessage( 158 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', 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',
160 detailPattern, 160 detailPattern,
161 detailReplacements, 161 detailReplacements,
162 ).should.equal( 162 ).should.equal(
163 'REFID:20809404/NAMA:SALWA AZ ZAHRA/CABANG:1012-DEPOK/Periode:1/Admin:2500/TOTALBAYAR:28.000', 163 'REFID:20809404/NAMA:SALWA AZ ZAHRA/CABANG:1012-DEPOK/Periode:1/Admin:2500/TOTALBAYAR:28.000',
164 'TAJIRA BPJS', 164 'TAJIRA BPJS',
165 ) 165 )
166 166
167 }); 167 });
168 }); 168 });
169 169
170 describe('#splitPostpaidDetail', () => { 170 describe('#splitPostpaidDetail', () => {
171 it('should handle invalid input', () => {
172 irs.splitPostpaidDetail(null).length.should.equal(0);
173 irs.splitPostpaidDetail('').length.should.equal(0);
174 });
175
171 it('should return correct result - inquiry', () => { 176 it('should return correct result - inquiry', () => {
172 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'; 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';
173 const splitted = irs.splitPostpaidDetail(detail); 178 const splitted = irs.splitPostpaidDetail(detail);
174 179
175 splitted.should.ok(); 180 splitted.should.ok();
176 splitted.find((item) => item.keyword === 'NAMA').value.should.equal('MUSHOLLA-NURUL-KHOIR'); 181 splitted.find((item) => item.keyword === 'NAMA').value.should.equal('MUSHOLLA-NURUL-KHOIR');
177 splitted.find((item) => item.keyword === 'TAGIHAN').value.should.equal('14441'); 182 splitted.find((item) => item.keyword === 'TAGIHAN').value.should.equal('14441');
178 splitted.find((item) => item.keyword === 'DENDA').value.should.equal('3000'); 183 splitted.find((item) => item.keyword === 'DENDA').value.should.equal('3000');
179 }); 184 });
180 185
181 it('should return correct result - pay', () => { 186 it('should return correct result - pay', () => {
182 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'; 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';
183 const splitted = irs.splitPostpaidDetail(detail); 188 const splitted = irs.splitPostpaidDetail(detail);
184 189
185 splitted.should.ok(); 190 splitted.should.ok();
186 splitted.find((item) => item.keyword === 'SN').value.should.equal('0BNS25G5082152526173'); 191 splitted.find((item) => item.keyword === 'SN').value.should.equal('0BNS25G5082152526173');
187 splitted.find((item) => item.keyword === 'NAMA').value.should.equal('DONAR-HARHAP'); 192 splitted.find((item) => item.keyword === 'NAMA').value.should.equal('DONAR-HARHAP');
188 splitted.find((item) => item.keyword === 'TAGIHAN').value.should.equal('131560'); 193 splitted.find((item) => item.keyword === 'TAGIHAN').value.should.equal('131560');
189 splitted.find((item) => item.keyword === 'DENDA').value.should.equal('9000'); 194 splitted.find((item) => item.keyword === 'DENDA').value.should.equal('9000');
190 }); 195 });
191 196
192 it('should return correct result - tajira', () => { 197 it('should return correct result - tajira', () => {
193 const splitted = irs.splitPostpaidDetail('REFID:20770812/NAMA:SALWA AZ ZAHRA/CABANG:1012-DEPOK/Periode:1/Admin:2500/TOTALBAYAR:28.000'); 198 const splitted = irs.splitPostpaidDetail('REFID:20770812/NAMA:SALWA AZ ZAHRA/CABANG:1012-DEPOK/Periode:1/Admin:2500/TOTALBAYAR:28.000');
194 // console.log(splitted); 199 // console.log(splitted);
195 splitted.find((item) => item.keyword === 'REFID').value.should.equal('20770812'); 200 splitted.find((item) => item.keyword === 'REFID').value.should.equal('20770812');
196 splitted.find((item) => item.keyword === 'Admin').value.should.equal('2500'); 201 splitted.find((item) => item.keyword === 'Admin').value.should.equal('2500');
197 202
198 const splitted2 = irs.splitPostpaidDetail('REFID:20809404/NAMA:SALWA AZ ZAHRA/CABANG:1012-DEPOK/Periode:1/Admin:2500/TOTALBAYAR:28.000'); 203 const splitted2 = irs.splitPostpaidDetail('REFID:20809404/NAMA:SALWA AZ ZAHRA/CABANG:1012-DEPOK/Periode:1/Admin:2500/TOTALBAYAR:28.000');
199 splitted2.find((item) => item.keyword === 'TOTALBAYAR').value.should.equal('28.000', 'TAJIRA BPJS'); 204 splitted2.find((item) => item.keyword === 'TOTALBAYAR').value.should.equal('28.000', 'TAJIRA BPJS');
200 }); 205 });
201 }); 206 });
202 207
203 describe('#calculateBaseBillAmount', () => { 208 describe('#calculateBaseBillAmount', () => {
204 it('should return correct value - inquiry', () => { 209 it('should return correct value - inquiry', () => {
205 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'; 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';
206 const splitted = irs.splitPostpaidDetail(detail); 211 const splitted = irs.splitPostpaidDetail(detail);
207 212
208 irs.calculateBaseBillAmount(splitted).should.equal(17441); 213 irs.calculateBaseBillAmount(splitted).should.equal(17441);
209 214
210 }) 215 })
211 216
212 it('should return correct value - payment', () => { 217 it('should return correct value - payment', () => {
213 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'; 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';
214 const splitted = irs.splitPostpaidDetail(detail); 219 const splitted = irs.splitPostpaidDetail(detail);
215 220
216 // console.log('--- DEBUG'); 221 // console.log('--- DEBUG');
217 // console.log(splitted); 222 // console.log(splitted);
218 // console.log('---'); 223 // console.log('---');
219 224
220 irs.calculateBaseBillAmount(splitted).should.equal(140560, '#2CBDCEB8'); 225 irs.calculateBaseBillAmount(splitted).should.equal(140560, '#2CBDCEB8');
221 226
222 }) 227 })
223 228
224 it('should return correct value - inquiry - tajira', () => { 229 it('should return correct value - inquiry - tajira', () => {
225 const detail = 'REFID:52055038964420747312/NAMA:MASJID AN NUR/KATEGORIDAYA:S2/450/PERIODE:092020/TAGIHANASLI:7140/DENDA:3000/ADMIN:2750/TOTALBAYAR:12.890'; 230 const detail = 'REFID:52055038964420747312/NAMA:MASJID AN NUR/KATEGORIDAYA:S2/450/PERIODE:092020/TAGIHANASLI:7140/DENDA:3000/ADMIN:2750/TOTALBAYAR:12.890';
226 const splitted = irs.splitPostpaidDetail(detail); 231 const splitted = irs.splitPostpaidDetail(detail);
227 232
228 irs.calculateBaseBillAmount( 233 irs.calculateBaseBillAmount(
229 splitted, 234 splitted,
230 null, 235 null,
231 // { 236 // {
232 // KEYWORD_TAGASLI: 'TAGIHANASLI,DENDA', 237 // KEYWORD_TAGASLI: 'TAGIHANASLI,DENDA',
233 // }, 238 // },
234 // 1 239 // 1
235 ).should.equal(10140); 240 ).should.equal(10140);
236 241
237 irs.calculateBaseBillAmount( 242 irs.calculateBaseBillAmount(
238 irs.splitPostpaidDetail('REFID:20770812/NAMA:SALWA AZ ZAHRA/CABANG:1012-DEPOK/Periode:1/Admin:2500/TOTALBAYAR:28.000'), 243 irs.splitPostpaidDetail('REFID:20770812/NAMA:SALWA AZ ZAHRA/CABANG:1012-DEPOK/Periode:1/Admin:2500/TOTALBAYAR:28.000'),
239 null, 244 null,
240 { 245 {
241 KEYWORD_TOTALTAG: 'TOTALBAYAR', 246 KEYWORD_TOTALTAG: 'TOTALBAYAR',
242 KEYWORD_ADMINFEE: 'Admin', 247 KEYWORD_ADMINFEE: 'Admin',
243 }, 248 },
244 1 249 1
245 ).should.equal(25500); 250 ).should.equal(25500);
246 251
247 const productKeyvalBPJSK = { 252 const productKeyvalBPJSK = {
248 KEYWORD_TOTALTAG: 'TOTALBAYAR', 253 KEYWORD_TOTALTAG: 'TOTALBAYAR',
249 KEYWORD_ADMINFEE: 'Admin', 254 KEYWORD_ADMINFEE: 'Admin',
250 }; 255 };
251 irs.calculateBaseBillAmount( 256 irs.calculateBaseBillAmount(
252 irs.splitPostpaidDetail('REFID:20809404/NAMA:SALWA AZ ZAHRA/CABANG:1012-DEPOK/Periode:1/Admin:2500/TOTALBAYAR:28.000'), 257 irs.splitPostpaidDetail('REFID:20809404/NAMA:SALWA AZ ZAHRA/CABANG:1012-DEPOK/Periode:1/Admin:2500/TOTALBAYAR:28.000'),
253 null, 258 null,
254 productKeyvalBPJSK, 259 productKeyvalBPJSK,
255 1 260 1
256 ).should.equal(25500, 'TAJIRA BPJS #8A46CFD1'); 261 ).should.equal(25500, 'TAJIRA BPJS #8A46CFD1');
257 }); 262 });
258 }); 263 });
259 264
260 describe('#getBillCount', () => { 265 describe('#getBillCount', () => {
261 it('should return correct value', () => { 266 it('should return correct value', () => {
262 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); 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);
263 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')); 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'));
264 should.not.exists(irs.getBillCount('')); 269 should.not.exists(irs.getBillCount(''));
265 should.not.exists(irs.getBillCount()); 270 should.not.exists(irs.getBillCount());
266 }); 271 });
267 }); 272 });
268 }); 273 });