Commit 3451d94d445fad31f1ac627ce17a67cab2e73c23
1 parent
d5dec1a394
Exists in
master
supplier_ending_balance
Showing 1 changed file with 4 additions and 2 deletions Inline Diff
lib/partner.js
1 | "use strict"; | 1 | "use strict"; |
2 | 2 | ||
3 | const moment = require('moment'); | 3 | const moment = require('moment'); |
4 | 4 | ||
5 | const config = require('komodo-sdk/config'); | 5 | const config = require('komodo-sdk/config'); |
6 | const logger = require('komodo-sdk/logger'); | 6 | const logger = require('komodo-sdk/logger'); |
7 | const matrix = require('komodo-sdk/matrix'); | 7 | const matrix = require('komodo-sdk/matrix'); |
8 | const pull = require('komodo-sdk/gateway/pull'); | 8 | const pull = require('komodo-sdk/gateway/pull'); |
9 | 9 | ||
10 | function buy(task) { | 10 | function buy(task) { |
11 | logger.verbose('Got task from CORE', {task: task}); | 11 | logger.verbose('Got task from CORE', {task: task}); |
12 | 12 | ||
13 | setTimeout( | 13 | setTimeout( |
14 | function() { | 14 | function() { |
15 | if (task.destination % 2) { | 15 | if (task.destination % 2) { |
16 | pull.report({ | 16 | pull.report({ |
17 | trx_id: task.trx_id, | 17 | trx_id: task.trx_id, |
18 | rc: '14', | 18 | rc: '14', |
19 | message: `GAGAL karena nomor tujuan ${task.destination} adalah nomor ganjil` | 19 | message: `GAGAL karena nomor tujuan ${task.destination} adalah nomor ganjil`, |
20 | balance: config.supplier_ending_balance | ||
20 | }); | 21 | }); |
21 | } | 22 | } |
22 | else { | 23 | else { |
23 | pull.report({ | 24 | pull.report({ |
24 | trx_id: task.trx_id, | 25 | trx_id: task.trx_id, |
25 | rc: '00', | 26 | rc: '00', |
26 | sn: moment().format('YYYYMMDDHHmmssSSS'), | 27 | sn: moment().format('YYYYMMDDHHmmssSSS'), |
27 | message: `BERHASIL karena nomor tujuan ${task.destination} adalah nomor genap`, | 28 | message: `BERHASIL karena nomor tujuan ${task.destination} adalah nomor genap`, |
28 | amount: config.supplier_price ? config.supplier_price[task.product] : null | 29 | amount: config.supplier_price ? config.supplier_price[task.product] : null, |
30 | balance: config.supplier_ending_balance | ||
29 | }); | 31 | }); |
30 | } | 32 | } |
31 | 33 | ||
32 | }, | 34 | }, |
33 | (config.max_result_timeout_ms || 2000) * Math.random() | 35 | (config.max_result_timeout_ms || 2000) * Math.random() |
34 | ) | 36 | ) |
35 | } | 37 | } |
36 | 38 | ||
37 | exports.buy = buy; | 39 | exports.buy = buy; |
38 | 40 |