Commit d33888983e7d1f3f711b6b0174f0c30384846a72

Authored by Adhidarma Hadiwinoto
1 parent b8e0a64153
Exists in master

daysummaryall

Showing 3 changed files with 4 additions and 3 deletions Inline Diff

lib/command-handler/daysummary.js
1 "use strict"; 1 "use strict";
2 2
3 const coreEndpoint = '/stores/summary'; 3 const coreEndpoint = '/stores/summary';
4 4
5 const commandError = require('./error'); 5 const commandError = require('./error');
6 const coreapi = require('../coreapi'); 6 const coreapi = require('../coreapi');
7 7
8 function help(keyword) { 8 function help(keyword) {
9 return `Untuk melihat laporan harian, ketik perintah dengan format: ${ keyword.toUpperCase() }.<PIN> atau ${ keyword.toUpperCase() }.<TANGGAL>.<PIN>. Format tanggal YYYY-MM-DD, contoh 2018-12-31 untuk tanggal 31 Desember 2018.`; 9 return `Untuk melihat laporan harian, ketik perintah dengan format: ${ keyword.toUpperCase() }.<PIN> atau ${ keyword.toUpperCase() }.<TANGGAL>.<PIN>. Format tanggal YYYY-MM-DD, contoh 2018-12-31 untuk tanggal 31 Desember 2018.`;
10 } 10 }
11 11
12 function execute(tokens, params, cb) { 12 function execute(tokens, params, cb) {
13 13
14 if (!tokens || tokens.length < 2) { 14 if (!tokens || tokens.length < 2) {
15 const responseParams = { 15 const responseParams = {
16 body: `${ commandError.ERR_INVALID_FORMAT }. ${ help(tokens[0]) }` 16 body: `${ commandError.ERR_INVALID_FORMAT }. ${ help(tokens[0]) }`
17 } 17 }
18 18
19 cb(null, null, responseParams); 19 cb(null, null, responseParams);
20 return; 20 return;
21 } 21 }
22 22
23 const idxPin = tokens.length < 3 ? 1 : 2; 23 const idxPin = tokens.length < 3 ? 1 : 2;
24 24
25 const coreParams = { 25 const coreParams = {
26 origin: params.origin, 26 origin: params.origin,
27 asker_terminal_name: params.from, 27 asker_terminal_name: params.from,
28 asker_terminal_password: tokens[idxPin], 28 asker_terminal_password: tokens[idxPin],
29 created_date: tokens.length < 3 ? null : tokens[1] 29 created_date: tokens.length < 3 ? null : tokens[1],
30 include_downline: params.commandGroup === 'daysummaryall',
30 }; 31 };
31 32
32 coreapi(coreEndpoint, coreParams, 'GET', cb); 33 coreapi(coreEndpoint, coreParams, 'GET', cb);
33 } 34 }
34 35
35 module.exports = execute; 36 module.exports = execute;
lib/command-handler/index.js
1 "use strict"; 1 "use strict";
2 2
3 const logger = require('komodo-sdk/logger'); 3 const logger = require('komodo-sdk/logger');
4 4
5 const commandParser = require('../command-parser'); 5 const commandParser = require('../command-parser');
6 6
7 const commandError = require('./error'); 7 const commandError = require('./error');
8 8
9 const handlerAddBalance = require('./addbalance'); 9 const handlerAddBalance = require('./addbalance');
10 const handlerAddDownline = require('./adddownline'); 10 const handlerAddDownline = require('./adddownline');
11 const handlerAddTerminal = require('./addterminal'); 11 const handlerAddTerminal = require('./addterminal');
12 const handlerBalance = require('./balance'); 12 const handlerBalance = require('./balance');
13 const handlerBuy = require('./buy'); 13 const handlerBuy = require('./buy');
14 const handlerChangePin = require('./changepin'); 14 const handlerChangePin = require('./changepin');
15 const handlerDaySummary = require('./daysummary'); 15 const handlerDaySummary = require('./daysummary');
16 const handlerDepositTicket = require('./depositticket'); 16 const handlerDepositTicket = require('./depositticket');
17 const handlerDisableDownline = require('./disabledownline'); 17 const handlerDisableDownline = require('./disabledownline');
18 const handlerDownlineInfo = require('./downlineinfo'); 18 const handlerDownlineInfo = require('./downlineinfo');
19 const handlerEnableDownline = require('./enabledownline'); 19 const handlerEnableDownline = require('./enabledownline');
20 const handlerHelp = require('./help'); 20 const handlerHelp = require('./help');
21 const handlerListDownline = require('./listdownline'); 21 const handlerListDownline = require('./listdownline');
22 const handlerListTerminal = require('./listterminal'); 22 const handlerListTerminal = require('./listterminal');
23 const handlerListTrx = require('./listtrx'); 23 const handlerListTrx = require('./listtrx');
24 const handlerPrice = require('./price'); 24 const handlerPrice = require('./price');
25 const handlerSupplierBalances = require('./supplierbalances'); 25 const handlerSupplierBalances = require('./supplierbalances');
26 const handlerTransferBalance = require('./transferbalance'); 26 const handlerTransferBalance = require('./transferbalance');
27 27
28 function execute(msg, params, cb) { 28 function execute(msg, params, cb) {
29 29
30 if ( typeof msg !== 'string' || !msg.trim() ) { 30 if ( typeof msg !== 'string' || !msg.trim() ) {
31 cb(commandError.ERR_EMPTY_MESSAGE); 31 cb(commandError.ERR_EMPTY_MESSAGE);
32 return; 32 return;
33 } 33 }
34 34
35 const tokens = commandParser.splitToken(msg); 35 const tokens = commandParser.splitToken(msg);
36 const commandGroup = commandParser.extractCommandGroup(tokens); 36 const commandGroup = commandParser.extractCommandGroup(tokens);
37 params.commandGroup = commandGroup; 37 params.commandGroup = commandGroup;
38 logger.info('Processing message from partner', { msg, params, tokens, commandGroup }); 38 logger.info('Processing message from partner', { msg, params, tokens, commandGroup });
39 39
40 if (!commandGroup || commandGroup === 'buy') { 40 if (!commandGroup || commandGroup === 'buy') {
41 handlerBuy(tokens, params, cb); 41 handlerBuy(tokens, params, cb);
42 } 42 }
43 else if (commandGroup === 'balance') { 43 else if (commandGroup === 'balance') {
44 handlerBalance(tokens, params, cb); 44 handlerBalance(tokens, params, cb);
45 } 45 }
46 else if (commandGroup === 'addbalance') { 46 else if (commandGroup === 'addbalance') {
47 handlerAddBalance(tokens, params, cb); 47 handlerAddBalance(tokens, params, cb);
48 } 48 }
49 else if (commandGroup === 'transferbalance') { 49 else if (commandGroup === 'transferbalance') {
50 handlerTransferBalance(tokens, params, cb); 50 handlerTransferBalance(tokens, params, cb);
51 } 51 }
52 else if (commandGroup === 'price') { 52 else if (commandGroup === 'price') {
53 handlerPrice(tokens, params, cb); 53 handlerPrice(tokens, params, cb);
54 } 54 }
55 else if (commandGroup === 'listdownline') { 55 else if (commandGroup === 'listdownline') {
56 handlerListDownline(tokens, params, cb); 56 handlerListDownline(tokens, params, cb);
57 } 57 }
58 else if (commandGroup === 'downlineinfo') { 58 else if (commandGroup === 'downlineinfo') {
59 handlerDownlineInfo(tokens, params, cb); 59 handlerDownlineInfo(tokens, params, cb);
60 } 60 }
61 else if (commandGroup === 'adddownline') { 61 else if (commandGroup === 'adddownline') {
62 handlerAddDownline(tokens, params, cb); 62 handlerAddDownline(tokens, params, cb);
63 } 63 }
64 else if (commandGroup === 'listterminal') { 64 else if (commandGroup === 'listterminal') {
65 handlerListTerminal(tokens, params, cb); 65 handlerListTerminal(tokens, params, cb);
66 } 66 }
67 else if (commandGroup === 'listtrx' || commandGroup === 'listtrxall') { 67 else if (commandGroup === 'listtrx' || commandGroup === 'listtrxall') {
68 handlerListTrx(tokens, params, cb); 68 handlerListTrx(tokens, params, cb);
69 } 69 }
70 else if (commandGroup === 'addterminal') { 70 else if (commandGroup === 'addterminal') {
71 handlerAddTerminal(tokens, params, cb); 71 handlerAddTerminal(tokens, params, cb);
72 } 72 }
73 else if (commandGroup === 'changepin') { 73 else if (commandGroup === 'changepin') {
74 handlerChangePin(tokens, params, cb); 74 handlerChangePin(tokens, params, cb);
75 } 75 }
76 else if (commandGroup === 'enabledownline') { 76 else if (commandGroup === 'enabledownline') {
77 handlerEnableDownline(tokens, params, cb); 77 handlerEnableDownline(tokens, params, cb);
78 } 78 }
79 else if (commandGroup === 'daysummary') { 79 else if (commandGroup === 'daysummary' || commandGroup === 'daysummaryall') {
80 handlerDaySummary(tokens, params, cb); 80 handlerDaySummary(tokens, params, cb);
81 } 81 }
82 else if (commandGroup === 'depositticket') { 82 else if (commandGroup === 'depositticket') {
83 handlerDepositTicket(tokens, params, cb); 83 handlerDepositTicket(tokens, params, cb);
84 } 84 }
85 else if (commandGroup === 'disabledownline') { 85 else if (commandGroup === 'disabledownline') {
86 handlerDisableDownline(tokens, params, cb); 86 handlerDisableDownline(tokens, params, cb);
87 } 87 }
88 else if (commandGroup === 'supplierbalances') { 88 else if (commandGroup === 'supplierbalances') {
89 handlerSupplierBalances(tokens, params, cb); 89 handlerSupplierBalances(tokens, params, cb);
90 } 90 }
91 else if (commandGroup === 'help') { 91 else if (commandGroup === 'help') {
92 handlerHelp(cb) 92 handlerHelp(cb)
93 } 93 }
94 else { 94 else {
95 cb(commandError.ERR_NOT_IMPLEMENTED); 95 cb(commandError.ERR_NOT_IMPLEMENTED);
96 } 96 }
97 } 97 }
98 98
99 module.exports = execute; 99 module.exports = execute;
lib/default-command.js
1 module.exports = { 1 module.exports = {
2 help: [ 2 help: [
3 "bantu", 3 "bantu",
4 "bantuan", 4 "bantuan",
5 "format", 5 "format",
6 "help", 6 "help",
7 "tolong", 7 "tolong",
8 ], 8 ],
9 buy: [ 9 buy: [
10 "beli", 10 "beli",
11 "buy", 11 "buy",
12 "i", 12 "i",
13 "isi", 13 "isi",
14 ], 14 ],
15 _statuscheck: [ 15 _statuscheck: [
16 "cekstatus", 16 "cekstatus",
17 "checkstatus", 17 "checkstatus",
18 "status", 18 "status",
19 ], 19 ],
20 balance: [ 20 balance: [
21 "bal", 21 "bal",
22 "balance", 22 "balance",
23 "ceksaldo", 23 "ceksaldo",
24 "checksaldo", 24 "checksaldo",
25 "s", 25 "s",
26 "sal", 26 "sal",
27 "saldo", 27 "saldo",
28 ], 28 ],
29 transferbalance: [ 29 transferbalance: [
30 "transfer", 30 "transfer",
31 "trf", 31 "trf",
32 ], 32 ],
33 addbalance: [ 33 addbalance: [
34 "addbalance", 34 "addbalance",
35 "addbal", 35 "addbal",
36 "tambahsaldo", 36 "tambahsaldo",
37 ], 37 ],
38 listdownline: [ 38 listdownline: [
39 "dllist", 39 "dllist",
40 "dlls", 40 "dlls",
41 "downlinelist", 41 "downlinelist",
42 "downlinels", 42 "downlinels",
43 "ldl", 43 "ldl",
44 "listdl", 44 "listdl",
45 "listdownline", 45 "listdownline",
46 "listmitra", 46 "listmitra",
47 "lsdl", 47 "lsdl",
48 "lsdownline", 48 "lsdownline",
49 "lsmitra", 49 "lsmitra",
50 "mitrals", 50 "mitrals",
51 ], 51 ],
52 adddownline: [ 52 adddownline: [
53 "adddl", 53 "adddl",
54 "adddownline", 54 "adddownline",
55 "addmitra", 55 "addmitra",
56 "buatdl", 56 "buatdl",
57 "buatdownline", 57 "buatdownline",
58 "createdl", 58 "createdl",
59 "createdownlne", 59 "createdownlne",
60 "createmitra", 60 "createmitra",
61 "regdl", 61 "regdl",
62 "regdownline", 62 "regdownline",
63 "registerdl", 63 "registerdl",
64 "registerdownline", 64 "registerdownline",
65 "registermitra", 65 "registermitra",
66 "regmitra", 66 "regmitra",
67 "tambahdl", 67 "tambahdl",
68 "tambahdownline", 68 "tambahdownline",
69 "tambahmitra", 69 "tambahmitra",
70 ], 70 ],
71 downlineinfo: [ 71 downlineinfo: [
72 "dl", 72 "dl",
73 "downline", 73 "downline",
74 "mitra", 74 "mitra",
75 "saldodownline", 75 "saldodownline",
76 "saldomitra", 76 "saldomitra",
77 "sd", 77 "sd",
78 "sdl", 78 "sdl",
79 ], 79 ],
80 disabledownline: [ 80 disabledownline: [
81 "disabledl", 81 "disabledl",
82 "disabledownline", 82 "disabledownline",
83 "disablemitra", 83 "disablemitra",
84 "nonaktifdl", 84 "nonaktifdl",
85 "nonaktifdownline", 85 "nonaktifdownline",
86 "nonaktifkandl", 86 "nonaktifkandl",
87 "nonaktifkandownline", 87 "nonaktifkandownline",
88 "nonaktifkanmitra", 88 "nonaktifkanmitra",
89 "nonaktifmitra", 89 "nonaktifmitra",
90 ], 90 ],
91 enabledownline: [ 91 enabledownline: [
92 "aktifkandl", 92 "aktifkandl",
93 "aktifkandownline", 93 "aktifkandownline",
94 "aktifkanmitra", 94 "aktifkanmitra",
95 "aktivasidl", 95 "aktivasidl",
96 "aktivasidownline", 96 "aktivasidownline",
97 "aktivasimitra", 97 "aktivasimitra",
98 "enabledl", 98 "enabledl",
99 "enabledownline", 99 "enabledownline",
100 "enablemitra", 100 "enablemitra",
101 ], 101 ],
102 daysummary: [ 102 daysummary: [
103 "lap", 103 "lap",
104 "laporan", 104 "laporan",
105 "rekap", 105 "rekap",
106 ], 106 ],
107 _daysummaryall: [ 107 daysummaryall: [
108 "lapall", 108 "lapall",
109 "laporanall", 109 "laporanall",
110 "rekapall", 110 "rekapall",
111 ], 111 ],
112 _daysummarydownline: [ 112 _daysummarydownline: [
113 "lapdl", 113 "lapdl",
114 "lapdownline", 114 "lapdownline",
115 "lapmitra", 115 "lapmitra",
116 "laporandl", 116 "laporandl",
117 "laporandownline", 117 "laporandownline",
118 "laporanmitra", 118 "laporanmitra",
119 "rekapalldl", 119 "rekapalldl",
120 "rekapalldownline", 120 "rekapalldownline",
121 "rekapallmitra", 121 "rekapallmitra",
122 ], 122 ],
123 _maintenanceactivate: [ 123 _maintenanceactivate: [
124 "activatemaintenance", 124 "activatemaintenance",
125 "maintenanceactivate" 125 "maintenanceactivate"
126 ], 126 ],
127 _maintenancedeactivate: [ 127 _maintenancedeactivate: [
128 "deactivatemaintenance", 128 "deactivatemaintenance",
129 "maintenancedeactivate" 129 "maintenancedeactivate"
130 ], 130 ],
131 price: [ 131 price: [
132 "cekharga", 132 "cekharga",
133 "ch", 133 "ch",
134 "checkharga", 134 "checkharga",
135 "h", 135 "h",
136 "harga", 136 "harga",
137 "hargaproduct", 137 "hargaproduct",
138 "hargaproduk", 138 "hargaproduk",
139 "price", 139 "price",
140 ], 140 ],
141 changepin: [ 141 changepin: [
142 "changepin", 142 "changepin",
143 "gantipin", 143 "gantipin",
144 "pin", 144 "pin",
145 "setpin", 145 "setpin",
146 "ubahpin", 146 "ubahpin",
147 ], 147 ],
148 depositticket: [ 148 depositticket: [
149 'depo', 149 'depo',
150 'depositticket', 150 'depositticket',
151 'depoticket', 151 'depoticket',
152 'tiket', 152 'tiket',
153 'tiketdeposit', 153 'tiketdeposit',
154 ], 154 ],
155 listterminal: [ 155 listterminal: [
156 'listmsisdn', 156 'listmsisdn',
157 'listterminal', 157 'listterminal',
158 'listterm', 158 'listterm',
159 'lsmsisdn', 159 'lsmsisdn',
160 'lsterminal', 160 'lsterminal',
161 'lsterm', 161 'lsterm',
162 'msisdn', 162 'msisdn',
163 'msisdnlist', 163 'msisdnlist',
164 'msisdnls', 164 'msisdnls',
165 'terminal', 165 'terminal',
166 'terminallist', 166 'terminallist',
167 'terminalls', 167 'terminalls',
168 'terminalterdaftar', 168 'terminalterdaftar',
169 ], 169 ],
170 addterminal: [ 170 addterminal: [
171 'addmsisdn', 171 'addmsisdn',
172 'addterminal', 172 'addterminal',
173 'createmsisdn', 173 'createmsisdn',
174 'createterminal', 174 'createterminal',
175 'msisdnadd', 175 'msisdnadd',
176 'newmsisdn', 176 'newmsisdn',
177 'newterminal', 177 'newterminal',
178 'registerterminal', 178 'registerterminal',
179 'regmsisdn', 179 'regmsisdn',
180 'regterminal', 180 'regterminal',
181 'tambahmsisdn', 181 'tambahmsisdn',
182 'tambahterminal', 182 'tambahterminal',
183 'terminaladd', 183 'terminaladd',
184 ], 184 ],
185 supplierbalances: [ 185 supplierbalances: [
186 'supbal', 186 'supbal',
187 'supplier', 187 'supplier',
188 'supplierbal', 188 'supplierbal',
189 'supplierbalance', 189 'supplierbalance',
190 'supplierbalances', 190 'supplierbalances',
191 'suppliers', 191 'suppliers',
192 'suppliersbal', 192 'suppliersbal',
193 'suppliersbalance', 193 'suppliersbalance',
194 'suppliersbalances', 194 'suppliersbalances',
195 ], 195 ],
196 listtrx: [ 196 listtrx: [
197 'listtrx', 197 'listtrx',
198 'listtransaksi', 198 'listtransaksi',
199 ], 199 ],
200 listtrxall: [ 200 listtrxall: [
201 'listtrxall', 201 'listtrxall',
202 'listtransaksiall', 202 'listtransaksiall',
203 ], 203 ],
204 _setmarkup: [ 204 _setmarkup: [
205 'markup' 205 'markup'
206 ], 206 ],
207 _news: [ 207 _news: [
208 'berita', 208 'berita',
209 'news', 209 'news',
210 'promo', 210 'promo',
211 ] 211 ]
212 } 212 }
213 213