Commit 2b2e7581eb1a3dd13cc82ff2afa6fe6bdddc24f1

Authored by Adhidarma Hadiwinoto
1 parent 99f38aa7c6
Exists in master

More test on TAJIRA PLN

Showing 1 changed file with 14 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 }); 158 });
159 }); 159 });
160 160
161 describe('#splitPostpaidDetail', () => { 161 describe('#splitPostpaidDetail', () => {
162 it('should return correct result - inquiry', () => { 162 it('should return correct result - inquiry', () => {
163 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'; 163 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';
164 const splitted = irs.splitPostpaidDetail(detail); 164 const splitted = irs.splitPostpaidDetail(detail);
165 165
166 splitted.should.ok(); 166 splitted.should.ok();
167 splitted.find((item) => item.keyword === 'NAMA').value.should.equal('MUSHOLLA-NURUL-KHOIR'); 167 splitted.find((item) => item.keyword === 'NAMA').value.should.equal('MUSHOLLA-NURUL-KHOIR');
168 splitted.find((item) => item.keyword === 'TAGIHAN').value.should.equal('14441'); 168 splitted.find((item) => item.keyword === 'TAGIHAN').value.should.equal('14441');
169 splitted.find((item) => item.keyword === 'DENDA').value.should.equal('3000'); 169 splitted.find((item) => item.keyword === 'DENDA').value.should.equal('3000');
170 }); 170 });
171 171
172 it('should return correct result - pay', () => { 172 it('should return correct result - pay', () => {
173 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'; 173 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';
174 const splitted = irs.splitPostpaidDetail(detail); 174 const splitted = irs.splitPostpaidDetail(detail);
175 175
176 splitted.should.ok(); 176 splitted.should.ok();
177 splitted.find((item) => item.keyword === 'SN').value.should.equal('0BNS25G5082152526173'); 177 splitted.find((item) => item.keyword === 'SN').value.should.equal('0BNS25G5082152526173');
178 splitted.find((item) => item.keyword === 'NAMA').value.should.equal('DONAR-HARHAP'); 178 splitted.find((item) => item.keyword === 'NAMA').value.should.equal('DONAR-HARHAP');
179 splitted.find((item) => item.keyword === 'TAGIHAN').value.should.equal('131560'); 179 splitted.find((item) => item.keyword === 'TAGIHAN').value.should.equal('131560');
180 splitted.find((item) => item.keyword === 'DENDA').value.should.equal('9000'); 180 splitted.find((item) => item.keyword === 'DENDA').value.should.equal('9000');
181 }); 181 });
182 }); 182 });
183 183
184 describe('#calculateBaseBillAmount', () => { 184 describe('#calculateBaseBillAmount', () => {
185 it('should return correct value - inquiry', () => { 185 it('should return correct value - inquiry', () => {
186 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'; 186 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';
187 const splitted = irs.splitPostpaidDetail(detail); 187 const splitted = irs.splitPostpaidDetail(detail);
188 188
189 irs.calculateBaseBillAmount(splitted).should.equal(17441); 189 irs.calculateBaseBillAmount(splitted).should.equal(17441);
190 190
191 }) 191 })
192 192
193 it('should return correct value - payment', () => { 193 it('should return correct value - payment', () => {
194 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'; 194 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';
195 const splitted = irs.splitPostpaidDetail(detail); 195 const splitted = irs.splitPostpaidDetail(detail);
196 196
197 // console.log('--- DEBUG'); 197 // console.log('--- DEBUG');
198 // console.log(splitted); 198 // console.log(splitted);
199 // console.log('---'); 199 // console.log('---');
200 200
201 irs.calculateBaseBillAmount(splitted).should.equal(140560, '#2CBDCEB8'); 201 irs.calculateBaseBillAmount(splitted).should.equal(140560, '#2CBDCEB8');
202 202
203 }) 203 })
204
205 it('should return correct value - inquiry - tajira', () => {
206 const detail = 'REFID:52055038964420747312/NAMA:MASJID AN NUR/KATEGORIDAYA:S2/450/PERIODE:092020/TAGIHANASLI:7140/DENDA:3000/ADMIN:2750/TOTALBAYAR:12.890';
207 const splitted = irs.splitPostpaidDetail(detail);
208
209 irs.calculateBaseBillAmount(
210 splitted,
211 null,
212 // {
213 // KEYWORD_TAGASLI: 'TAGIHANASLI,DENDA',
214 // },
215 // 1
216 ).should.equal(10140);
217 });
204 }); 218 });
205 219
206 describe('#getBillCount', () => { 220 describe('#getBillCount', () => {
207 it('should return correct value', () => { 221 it('should return correct value', () => {
208 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); 222 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);
209 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')); 223 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'));
210 should.not.exists(irs.getBillCount('')); 224 should.not.exists(irs.getBillCount(''));
211 should.not.exists(irs.getBillCount()); 225 should.not.exists(irs.getBillCount());
212 }); 226 });
213 }); 227 });
214 }); 228 });