Commit e81698329765bf70dffb2c8db9b2f15190e38920

Authored by Adhidarma Hadiwinoto
1 parent 37f835929d
Exists in master

Add pending on last digit of destination is 0

Showing 1 changed file with 10 additions and 1 deletions Inline Diff

1 const moment = require('moment'); 1 const moment = require('moment');
2 2
3 const logger = require('tektrans-logger'); 3 const logger = require('tektrans-logger');
4 const config = require('komodo-sdk/config'); 4 const config = require('komodo-sdk/config');
5 const pull = require('komodo-sdk/gateway/pull'); 5 const pull = require('komodo-sdk/gateway/pull');
6 6
7 function buy(task, xid) { 7 function buy(task, xid) {
8 logger.verbose('Got task from CORE', { xid, task }); 8 logger.verbose('Got task from CORE', { xid, task });
9 const [remoteProduct, amount] = task.remote_product.split(/ *, */); 9 const [remoteProduct, amount] = task.remote_product.split(/ *, */);
10 10
11 setTimeout( 11 setTimeout(
12 () => { 12 () => {
13 if (task.destination % 2) { 13 const destination = task.destination.toString();
14
15 if ((destination % 10) === 0) {
16 pull.report({
17 trx_id: task.trx_id,
18 rc: '68',
19 message: `PENDING karena nomor tujuan ${task.destination} diakhiri 0`,
20 balance: config.supplier_ending_balance,
21 });
22 } else if (destination % 2) {
14 pull.report({ 23 pull.report({
15 trx_id: task.trx_id, 24 trx_id: task.trx_id,
16 rc: '14', 25 rc: '14',
17 message: `GAGAL karena nomor tujuan ${task.destination} adalah nomor ganjil`, 26 message: `GAGAL karena nomor tujuan ${task.destination} adalah nomor ganjil`,
18 balance: config.supplier_ending_balance, 27 balance: config.supplier_ending_balance,
19 }); 28 });
20 } else { 29 } else {
21 pull.report({ 30 pull.report({
22 trx_id: task.trx_id, 31 trx_id: task.trx_id,
23 rc: '00', 32 rc: '00',
24 sn: moment().format('YYYYMMDDHHmmssSSS'), 33 sn: moment().format('YYYYMMDDHHmmssSSS'),
25 amount, 34 amount,
26 remote_product: remoteProduct, 35 remote_product: remoteProduct,
27 message: `BERHASIL karena nomor tujuan ${task.destination} adalah nomor genap`, 36 message: `BERHASIL karena nomor tujuan ${task.destination} adalah nomor genap`,
28 balance: config.supplier_ending_balance, 37 balance: config.supplier_ending_balance,
29 }); 38 });
30 } 39 }
31 }, 40 },
32 (config.max_result_timeout_ms || 2000) * Math.random(), 41 (config.max_result_timeout_ms || 2000) * Math.random(),
33 ); 42 );
34 } 43 }
35 44
36 exports.buy = buy; 45 exports.buy = buy;
37 46