mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 00:36:27 +00:00
Compare commits
71 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4140360736 | |||
| f4fc8cd147 | |||
| f5f75381ca | |||
| 5cbdccca11 | |||
| fd386788f8 | |||
| 6ddf225485 | |||
| 1645aa54aa | |||
| 797bf97bf8 | |||
| a7f5c8c8e0 | |||
| d2d44f3ba9 | |||
| 4dccbf20f5 | |||
| b888951ee3 | |||
| 87dedd241a | |||
| d4f56aacd8 | |||
| fec5209c83 | |||
| 93b6bd94ca | |||
| 39ac9e0e2d | |||
| 5037e022fd | |||
| cbb1d353a3 | |||
| f73accc275 | |||
| d7c62eda3f | |||
| a4b089ac85 | |||
| 3bf01d9059 | |||
| 8e54ebb704 | |||
| 48fb780252 | |||
| 382ccaab58 | |||
| 41444e037c | |||
| c49e4b3526 | |||
| d99882b8b9 | |||
| 45091038fe | |||
| 7c6e08a5b5 | |||
| 6e7d727b40 | |||
| 3bb2748387 | |||
| 6fea76b721 | |||
| 934e962dba | |||
| 3ccac7d220 | |||
| cede2396b7 | |||
| 9c06ec992e | |||
| 419700d6c5 | |||
| 6af2637bca | |||
| 8bb705f973 | |||
| 6755824ad0 | |||
| d93e3549ea | |||
| af697bd24d | |||
| c792a5ef15 | |||
| 282cc6372a | |||
| aea6577e38 | |||
| 6ae2de5010 | |||
| d7c3ad199a | |||
| 3808dafda7 | |||
| 14ea651b28 | |||
| 4079caa059 | |||
| 351a81a069 | |||
| 35aad851ba | |||
| e25797e091 | |||
| ac1c3c969b | |||
| 0e256ae481 | |||
| 2179a67b41 | |||
| fd3741e2ee | |||
| 2eb91dc105 | |||
| a257d50872 | |||
| fdebd4dbe9 | |||
| 745d186b3f | |||
| 0145ce5703 | |||
| a45acf1488 | |||
| bbc26c5964 | |||
| 7058143c4e | |||
| 5af2cc37d0 | |||
| 75acdc4195 | |||
| a08cedf7e8 | |||
| a16a0172a4 |
@@ -154,7 +154,115 @@ const apiGenerateCashInSales = async (req, res) => {
|
||||
}
|
||||
};
|
||||
|
||||
// RETRY POSTING INVOICE
|
||||
const apiGenerateCashInSalesInternal = async (req, res) => {
|
||||
try {
|
||||
// generate unique code
|
||||
uniqueCode = helper.getUniqueCode();
|
||||
// return uniqueCode
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} REQUEST generate cashin sales internal: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
// check validator
|
||||
const err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
result = {
|
||||
code: '400',
|
||||
message: err.errors[0].msg,
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE generate cashin sales internal: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
const cashIn = await _generateCashInSalesInternal(uniqueCode);
|
||||
|
||||
result = {
|
||||
code: '200',
|
||||
message: 'Success generate cash-in',
|
||||
data: cashIn,
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
code: '500',
|
||||
message:
|
||||
process.env.NODE_ENV != 'production'
|
||||
? error.message
|
||||
: '500 internal server error - backend server.',
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const apiGenerateCashInTopUpCashlessInternal = async (req, res) => {
|
||||
try {
|
||||
// generate unique code
|
||||
uniqueCode = helper.getUniqueCode();
|
||||
// return uniqueCode
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} REQUEST generate cashin topup cashless internal: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
// check validator
|
||||
const err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
result = {
|
||||
code: '400',
|
||||
message: err.errors[0].msg,
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE generate cashin topup cashless internal: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
const cashIn = await _generateCashInTopUpCashlessInternal(uniqueCode);
|
||||
|
||||
result = {
|
||||
code: '200',
|
||||
message: 'Success generate cash-in',
|
||||
data: cashIn,
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
code: '500',
|
||||
message:
|
||||
process.env.NODE_ENV != 'production'
|
||||
? error.message
|
||||
: '500 internal server error - backend server.',
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// RETRY POSTING CASH IN
|
||||
const apiPostingCahsIn = async (req, res) => {
|
||||
try {
|
||||
// generate unique code
|
||||
@@ -377,7 +485,6 @@ const _generateCashInSales = async (uniqueCode) => {
|
||||
);
|
||||
|
||||
for (const item of partnerRecon) {
|
||||
let reserve = [];
|
||||
let code = '';
|
||||
await knex.transaction(async (trx) => {
|
||||
try {
|
||||
@@ -481,7 +588,6 @@ const _generateCashInSales = async (uniqueCode) => {
|
||||
}
|
||||
}
|
||||
await wait(10000);
|
||||
winston.logger.info();
|
||||
}
|
||||
await trx.commit();
|
||||
|
||||
@@ -495,6 +601,260 @@ const _generateCashInSales = async (uniqueCode) => {
|
||||
return partnerRecon;
|
||||
};
|
||||
|
||||
const _generateCashInSalesInternal = async (uniqueCode) => {
|
||||
let partnerRecon = await model.getPartnerReconSalesInternal(knex);
|
||||
|
||||
// return partnerRecon
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} getPartner Recon cash in : ${JSON.stringify(
|
||||
partnerRecon
|
||||
)}`
|
||||
);
|
||||
|
||||
for (const item of partnerRecon) {
|
||||
let code = '';
|
||||
await knex.transaction(async (trx) => {
|
||||
try {
|
||||
code = await model.generateCode(
|
||||
trx,
|
||||
item.c_partner_code,
|
||||
moment().format('YYMMDD')
|
||||
);
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} generate cash in : ${code}`
|
||||
);
|
||||
|
||||
// Cash-in
|
||||
let dataCahsIn = {
|
||||
c_partner_code: item.c_partner_code,
|
||||
c_partner_name: item.c_partner_name,
|
||||
c_cash_in_no: code,
|
||||
c_in_period: item.c_in_period,
|
||||
d_credit: item.d_payment,
|
||||
c_invoice_no: item.c_invoice_no,
|
||||
i_amount: item.amount,
|
||||
c_source: 'S'
|
||||
};
|
||||
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} INSERT CASH-IN SALES ${code} DATA : ${JSON.stringify(
|
||||
dataCahsIn
|
||||
)}`
|
||||
);
|
||||
|
||||
// CASH-IN DETAIL
|
||||
const sales = await model.getSalesInternal(
|
||||
trx,
|
||||
item.c_partner_code,
|
||||
item.d_payment,
|
||||
item.c_invoice_no
|
||||
);
|
||||
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} DATA SALES INTERNAL ${code} : ${JSON.stringify( sales )}`
|
||||
);
|
||||
|
||||
//TOTAL AMOUNT CASH-IN
|
||||
let cashInAmount = 0;
|
||||
for (const itemCI of sales) {
|
||||
cashInAmount += parseInt(itemCI.i_total_price);
|
||||
}
|
||||
dataCahsIn.i_amount = cashInAmount;
|
||||
|
||||
if(cashInAmount > 0) {
|
||||
//INSERT CASH-IN
|
||||
const cashIn = await model.insertCashIn(trx, dataCahsIn);
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} INSERT CASH-IN HISTORY ${code} DATA : ${JSON.stringify(
|
||||
dataCahsIn
|
||||
)}`
|
||||
);
|
||||
const paymentyHistory = await model.writePaynentHistory(
|
||||
dataCahsIn, 'SUCCESSFULLY', 0, trx
|
||||
);
|
||||
|
||||
let m_amount = 0;
|
||||
for (const detail of sales) {
|
||||
let temp = {
|
||||
i_cash_in: cashIn.i_cash_in,
|
||||
c_reservation_no: detail.c_sales_no,
|
||||
m_amount: detail.i_total_price,
|
||||
c_payment_recon_no: detail.c_payment_recon_no,
|
||||
d_payment: detail.d_payment,
|
||||
d_payment_recon: detail.d_payment_recon,
|
||||
};
|
||||
|
||||
let salesNo = detail.c_sales_no;
|
||||
let dataSales = {
|
||||
i_cash_in: cashIn.i_cash_in,
|
||||
};
|
||||
m_amount += parseInt(detail.i_total_price);
|
||||
|
||||
if(m_amount <= detail.invoice_amount) {
|
||||
await model.updateIntoSalesInternal(trx, dataSales, salesNo);
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} CASH-IN UPDATE SALES INTERNAL ${salesNo} DATA : ${JSON.stringify(
|
||||
dataSales
|
||||
)}`
|
||||
);
|
||||
await model.insertCashInDetail(trx, temp);
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} INSERT CASH-IN DETAIL, ID CASH-IN ${cashIn.i_cash_in} : ${JSON.stringify(
|
||||
temp
|
||||
)}`
|
||||
);
|
||||
} else {
|
||||
await trx.rollback();
|
||||
winston.logger.info(
|
||||
`${uniqueCode} ROLLBACK CASH-IN: AMOUNT CASH-IN > TOTAL INVOICE. AMOUNT ${m_amount} > INVOICE AMOUNT (${detail.invoice_amount}) : ${JSON.stringify(
|
||||
dataCahsIn
|
||||
)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
await wait(10000);
|
||||
}
|
||||
await trx.commit();
|
||||
|
||||
} catch (error) {
|
||||
sts = "error";
|
||||
await trx.rollback();
|
||||
|
||||
throw new Error(error);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
return partnerRecon;
|
||||
};
|
||||
|
||||
const _generateCashInTopUpCashlessInternal = async (uniqueCode) => {
|
||||
let partnerRecon = await model.getPartnerReconTopUpCashlessInternal(knex);
|
||||
|
||||
// return partnerRecon
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} getPartner Recon cash in : ${JSON.stringify(
|
||||
partnerRecon
|
||||
)}`
|
||||
);
|
||||
|
||||
for (const item of partnerRecon) {
|
||||
let code = '';
|
||||
await knex.transaction(async (trx) => {
|
||||
try {
|
||||
code = await model.generateCode(
|
||||
trx,
|
||||
item.c_partner_code,
|
||||
moment().format('YYMMDD')
|
||||
);
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} generate cash in : ${code}`
|
||||
);
|
||||
|
||||
// Cash-in
|
||||
let dataCahsIn = {
|
||||
c_partner_code: item.c_partner_code,
|
||||
c_partner_name: item.c_partner_name,
|
||||
c_cash_in_no: code,
|
||||
c_in_period: item.c_in_period,
|
||||
d_credit: item.d_payment,
|
||||
c_invoice_no: item.c_invoice_no,
|
||||
i_amount: item.amount,
|
||||
c_source: 'T'
|
||||
};
|
||||
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} INSERT CASH-IN TOPUP CASHLESS INTERNAL ${code} DATA : ${JSON.stringify(
|
||||
dataCahsIn
|
||||
)}`
|
||||
);
|
||||
|
||||
// CASH-IN DETAIL
|
||||
const topup = await model.getTopUpCashlessInternal(
|
||||
trx,
|
||||
item.c_partner_code,
|
||||
item.d_payment,
|
||||
item.c_invoice_no
|
||||
);
|
||||
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} DATA TOPUP CASHLESS INTERNAL ${code} : ${JSON.stringify( topup )}`
|
||||
);
|
||||
|
||||
//TOTAL AMOUNT CASH-IN
|
||||
let cashInAmount = 0;
|
||||
for (const itemCI of topup) {
|
||||
cashInAmount += parseInt(itemCI.i_amount);
|
||||
}
|
||||
dataCahsIn.i_amount = cashInAmount;
|
||||
|
||||
if(cashInAmount > 0) {
|
||||
|
||||
//INSERT CASH-IN
|
||||
const cashIn = await model.insertCashIn(trx, dataCahsIn);
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} INSERT CASH-IN HISTORY ${code} DATA : ${JSON.stringify(
|
||||
dataCahsIn
|
||||
)}`
|
||||
);
|
||||
const paymentyHistory = await model.writePaynentHistory(
|
||||
dataCahsIn, 'SUCCESSFULLY', 0, trx
|
||||
);
|
||||
|
||||
let m_amount = 0;
|
||||
for (const detail of topup) {
|
||||
let temp = {
|
||||
i_cash_in: cashIn.i_cash_in,
|
||||
c_reservation_no: detail.c_topup_no,
|
||||
m_amount: detail.i_amount,
|
||||
c_payment_recon_no: detail.c_payment_recon_no,
|
||||
d_payment: detail.d_payment,
|
||||
d_payment_recon: detail.d_payment_recon,
|
||||
};
|
||||
|
||||
let topupNo = detail.c_topup_no;
|
||||
let dataTopup = {
|
||||
i_cash_in: cashIn.i_cash_in,
|
||||
};
|
||||
m_amount += parseInt(detail.i_amount);
|
||||
|
||||
if(m_amount <= detail.invoice_amount) {
|
||||
await model.updateIntoTopUpCashlessInternal(trx, dataTopup, topupNo);
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} CASH-IN UPDATE TOPUP CASHLESS INTERNAL ${topupNo} DATA : ${JSON.stringify(
|
||||
dataTopup
|
||||
)}`
|
||||
);
|
||||
await model.insertCashInDetail(trx, temp);
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} INSERT CASH-IN DETAIL, ID CASH-IN ${cashIn.i_cash_in} : ${JSON.stringify(
|
||||
temp
|
||||
)}`
|
||||
);
|
||||
} else {
|
||||
await trx.rollback();
|
||||
winston.logger.info(
|
||||
`${uniqueCode} ROLLBACK CASH-IN: AMOUNT CASH-IN > TOTAL INVOICE. AMOUNT ${m_amount} > INVOICE AMOUNT (${detail.invoice_amount}) : ${JSON.stringify(
|
||||
dataCahsIn
|
||||
)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
await wait(10000);
|
||||
}
|
||||
await trx.commit();
|
||||
|
||||
} catch (error) {
|
||||
sts = "error";
|
||||
await trx.rollback();
|
||||
throw new Error(error);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
return partnerRecon;
|
||||
};
|
||||
|
||||
const _postingCashIn = async (uniqueCode) => {
|
||||
let data = [];
|
||||
let postingEt = await model.getPostingEt(knex);
|
||||
@@ -579,8 +939,12 @@ module.exports = {
|
||||
validate,
|
||||
apiGenerateCahsIn,
|
||||
apiGenerateCashInSales,
|
||||
apiGenerateCashInSalesInternal,
|
||||
apiGenerateCashInTopUpCashlessInternal,
|
||||
apiPostingCahsIn,
|
||||
_postingCashIn,
|
||||
_generateCashIn,
|
||||
_generateCashInSales
|
||||
_generateCashInSales,
|
||||
_generateCashInSalesInternal,
|
||||
_generateCashInTopUpCashlessInternal,
|
||||
};
|
||||
|
||||
@@ -340,6 +340,66 @@ const getSalesKMT = async (trx, code, date, invoice) => {
|
||||
return res;
|
||||
};
|
||||
|
||||
const getSalesInternal = async (trx, code, date, invoice) => {
|
||||
const res = await trx
|
||||
.select([
|
||||
'tdskm.c_sales_no',
|
||||
'tdskm.i_total_price',
|
||||
'tdpr.c_payment_recon_no',
|
||||
'tdpr.d_payment',
|
||||
'tdpr.d_payment_recon',
|
||||
'tmp.c_code as c_partner_code',
|
||||
'tmp.c_name as c_partner_name',
|
||||
'tdsi.c_invoice_no',
|
||||
'tdsi.i_total_price as invoice_amount'
|
||||
])
|
||||
.from('trx.t_d_sales_internal AS tdskm')
|
||||
.leftJoin('payment.t_d_payment_recon_sales_internal as tdpr', 'tdpr.c_sales_no', 'tdskm.c_sales_no')
|
||||
.leftJoin('payment.t_d_sales_invoice_internal as tdsi', 'tdsi.i_sales_invoice_internal', 'tdskm.i_sales_invoice_internal')
|
||||
.leftJoin('public.t_m_partner as tmp', 'tmp.i_partner', 'tdskm.i_partner')
|
||||
.where('tdsi.c_status', '!=', 'X')
|
||||
.where('tmp.c_code', '=', code)
|
||||
.where('tdpr.d_payment', '=', date)
|
||||
.where('tdsi.c_invoice_no', '=', invoice)
|
||||
.where('tdpr.c_status', '=', 'S')
|
||||
.whereNotNull('tdsi.c_return_sap_fi')
|
||||
.whereRaw(
|
||||
`tdskm.c_sales_no NOT IN (SELECT c_reservation_no FROM payment.t_d_cash_in_detail WHERE b_reversal IS NOT TRUE)`
|
||||
);
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
const getTopUpCashlessInternal = async (trx, code, date, invoice) => {
|
||||
const res = await trx
|
||||
.select([
|
||||
'tdskm.c_topup_no',
|
||||
'tdskm.i_amount',
|
||||
'tdpr.c_payment_recon_no',
|
||||
'tdpr.d_payment',
|
||||
'tdpr.d_payment_recon',
|
||||
'tmp.c_code as c_partner_code',
|
||||
'tmp.c_name as c_partner_name',
|
||||
'tdsi.c_invoice_no',
|
||||
'tdsi.i_total_amount as invoice_amount'
|
||||
])
|
||||
.from('trx.t_d_topup_cashless_internal AS tdskm')
|
||||
.leftJoin('payment.t_d_payment_recon_topup_cashless_internal as tdpr', 'tdpr.c_topup_no', 'tdskm.c_topup_no')
|
||||
.leftJoin('payment.t_d_topup_cashless_invoice_internal as tdsi', 'tdsi.i_topup_cashless_invoice_internal', 'tdskm.i_topup_cashless_invoice_internal')
|
||||
.leftJoin('public.t_m_partner as tmp', 'tmp.i_partner', 'tdskm.i_partner')
|
||||
.where('tdsi.c_status', '!=', 'X')
|
||||
.where('tmp.c_code', '=', code)
|
||||
.where('tdpr.d_payment', '=', date)
|
||||
.where('tdsi.c_invoice_no', '=', invoice)
|
||||
.where('tdpr.c_status', '=', 'S')
|
||||
.whereNotNull('tdsi.c_return_sap')
|
||||
.whereRaw(
|
||||
`tdskm.c_topup_no NOT IN (SELECT c_reservation_no FROM payment.t_d_cash_in_detail WHERE b_reversal IS NOT TRUE)`
|
||||
);
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
const getPartnerRecon = async (trx) => {
|
||||
// const res = await trx
|
||||
// .select([
|
||||
@@ -510,6 +570,94 @@ const getPartnerReconSales = async (trx) => {
|
||||
return res;
|
||||
};
|
||||
|
||||
const getPartnerReconSalesInternal = async (trx) => {
|
||||
|
||||
const res = await trx
|
||||
.select([
|
||||
'tmp.c_code as c_partner_code',
|
||||
'tmp.c_name as c_partner_name',
|
||||
'tdsi.c_invoice_no',
|
||||
'tdsi.d_invoice_date',
|
||||
trx.raw("to_char(tdpr.d_payment, 'YYYY-MM-DD') AS d_payment"),
|
||||
trx.raw('coalesce(SUM(tdskm.i_total_price),0) AS amount'),
|
||||
'tmp.c_account_sales_revenue',
|
||||
'tmp.c_account_code_sales_ar',
|
||||
trx.raw(`CASE WHEN to_char(tdpr.d_payment, 'YYYYMM') >= to_char(tdsi.d_invoice_date, 'YYYYMM')
|
||||
THEN 'IP' ELSE 'OP'
|
||||
END c_in_period`),
|
||||
])
|
||||
.from('trx.t_d_sales_internal AS tdskm')
|
||||
|
||||
.leftJoin('payment.t_d_sales_invoice_internal as tdsi', function () {
|
||||
this.on('tdsi.i_sales_invoice_internal', '=', 'tdskm.i_sales_invoice_internal');
|
||||
})
|
||||
.leftJoin('payment.t_d_payment_recon_sales_internal as tdpr', function () {
|
||||
this.on('tdpr.c_sales_no', '=', 'tdskm.c_sales_no');
|
||||
})
|
||||
.leftJoin('public.t_m_partner as tmp', function () {
|
||||
this.on('tmp.i_partner', '=', 'tdskm.i_partner');
|
||||
})
|
||||
.where('tdsi.c_status', '!=', 'X')
|
||||
.where('tdpr.c_status', '=', 'S')
|
||||
.whereNotNull('tdsi.c_return_sap_fi')
|
||||
.whereNull('tdskm.i_cash_in')
|
||||
.groupBy([
|
||||
'tmp.c_code',
|
||||
'tmp.c_name',
|
||||
'tdsi.c_invoice_no',
|
||||
'tdsi.d_invoice_date',
|
||||
'tdpr.d_payment',
|
||||
'tmp.c_account_sales_revenue',
|
||||
'tmp.c_account_code_sales_ar'
|
||||
]);
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
const getPartnerReconTopUpCashlessInternal = async (trx) => {
|
||||
|
||||
const res = await trx
|
||||
.select([
|
||||
'tmp.c_code as c_partner_code',
|
||||
'tmp.c_name as c_partner_name',
|
||||
'tdsi.c_invoice_no',
|
||||
'tdsi.d_invoice_date',
|
||||
trx.raw("to_char(tdpr.d_payment, 'YYYY-MM-DD') AS d_payment"),
|
||||
trx.raw('coalesce(SUM(tdskm.i_amount),0) AS amount'),
|
||||
'tmp.c_account_topup',
|
||||
'tmp.c_account_code_topup',
|
||||
trx.raw(`CASE WHEN to_char(tdpr.d_payment, 'YYYYMM') >= to_char(tdsi.d_invoice_date, 'YYYYMM')
|
||||
THEN 'IP' ELSE 'OP'
|
||||
END c_in_period`),
|
||||
])
|
||||
.from('trx.t_d_topup_cashless_internal AS tdskm')
|
||||
|
||||
.leftJoin('payment.t_d_topup_cashless_invoice_internal as tdsi', function () {
|
||||
this.on('tdsi.i_topup_cashless_invoice_internal', '=', 'tdskm.i_topup_cashless_invoice_internal');
|
||||
})
|
||||
.leftJoin('payment.t_d_payment_recon_topup_cashless_internal as tdpr', function () {
|
||||
this.on('tdpr.c_topup_no', '=', 'tdskm.c_topup_no');
|
||||
})
|
||||
.leftJoin('public.t_m_partner as tmp', function () {
|
||||
this.on('tmp.i_partner', '=', 'tdskm.i_partner');
|
||||
})
|
||||
.where('tdsi.c_status', '!=', 'X')
|
||||
.where('tdpr.c_status', '=', 'S')
|
||||
.whereNotNull('tdsi.c_return_sap')
|
||||
.whereNull('tdskm.i_cash_in')
|
||||
.groupBy([
|
||||
'tmp.c_code',
|
||||
'tmp.c_name',
|
||||
'tdsi.c_invoice_no',
|
||||
'tdsi.d_invoice_date',
|
||||
'tdpr.d_payment',
|
||||
'tmp.c_account_topup',
|
||||
'tmp.c_account_code_topup'
|
||||
]);
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
const generateCode = async (trx, c_partner_code, d_payment_recon) => {
|
||||
let code = '';
|
||||
let prefix = `CIN${c_partner_code}${d_payment_recon}`;
|
||||
@@ -560,6 +708,20 @@ const updateIntoSalesKMT = async (trx, dataSales, salesNo) => {
|
||||
return result;
|
||||
};
|
||||
|
||||
const updateIntoSalesInternal = async (trx, dataSales, salesNo) => {
|
||||
let result = await trx('trx.t_d_sales_internal')
|
||||
.update(dataSales, ['*'])
|
||||
.where({ c_sales_no: salesNo });
|
||||
return result;
|
||||
};
|
||||
|
||||
const updateIntoTopUpCashlessInternal = async (trx, dataTopup, topupNo) => {
|
||||
let result = await trx('trx.t_d_topup_cashless_internal')
|
||||
.update(dataTopup, ['*'])
|
||||
.where({ c_topup_no: topupNo });
|
||||
return result;
|
||||
};
|
||||
|
||||
const insertCashIn = async (trx, data) => {
|
||||
let result = await trx('payment.t_d_cash_in').insert(data, ['*']);
|
||||
return result[0];
|
||||
@@ -600,9 +762,15 @@ module.exports = {
|
||||
insertCashInDetail,
|
||||
getPartnerRecon,
|
||||
getPartnerReconSales,
|
||||
getPartnerReconSalesInternal,
|
||||
getPartnerReconTopUpCashlessInternal,
|
||||
getReserve,
|
||||
getSalesKMT,
|
||||
getSalesInternal,
|
||||
getTopUpCashlessInternal,
|
||||
insertCashIn,
|
||||
updateIntoReserve,
|
||||
updateIntoSalesKMT
|
||||
updateIntoSalesKMT,
|
||||
updateIntoSalesInternal,
|
||||
updateIntoTopUpCashlessInternal,
|
||||
};
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
const { param, body, validationResult } = require('express-validator');
|
||||
const helper = require('../../helpers/helper');
|
||||
const winston = require('../../helpers/winston.logger');
|
||||
const model = require('./invoice.model');
|
||||
const moment = require('moment');
|
||||
const knex = require('../../../infrastructure/database/knex');
|
||||
moment.locale('id');
|
||||
const { param, body, validationResult } = require("express-validator");
|
||||
const helper = require("../../helpers/helper");
|
||||
const winston = require("../../helpers/winston.logger");
|
||||
const model = require("./invoice.model");
|
||||
const moment = require("moment");
|
||||
const knex = require("../../../infrastructure/database/knex");
|
||||
moment.locale("id");
|
||||
|
||||
// VALIDATION
|
||||
const validate = (method) => {
|
||||
switch (method) {
|
||||
case 'generateInvoice':
|
||||
case "generateInvoice":
|
||||
return [
|
||||
body('trx_date')
|
||||
body("trx_date")
|
||||
.notEmpty()
|
||||
.withMessage('trx_date is required!')
|
||||
.withMessage("trx_date is required!")
|
||||
.isISO8601()
|
||||
.withMessage('invalid trx_date format YYYY-MM-DD !')
|
||||
.withMessage("invalid trx_date format YYYY-MM-DD !")
|
||||
.escape()
|
||||
.trim(),
|
||||
body('repost')
|
||||
body("repost")
|
||||
.notEmpty()
|
||||
.withMessage('repost is required!')
|
||||
.withMessage("repost is required!")
|
||||
.isBoolean()
|
||||
.withMessage('repost must boolean!')
|
||||
.withMessage("repost must boolean!")
|
||||
.escape()
|
||||
.trim(),
|
||||
];
|
||||
case 'postingInvoice':
|
||||
case "postingInvoice":
|
||||
return [
|
||||
body('trx_date')
|
||||
body("trx_date")
|
||||
.notEmpty()
|
||||
.withMessage('trx_date is required!')
|
||||
.withMessage("trx_date is required!")
|
||||
.isISO8601()
|
||||
.withMessage('invalid trx_date format YYYY-MM-DD !')
|
||||
.withMessage("invalid trx_date format YYYY-MM-DD !")
|
||||
.escape()
|
||||
.trim(),
|
||||
];
|
||||
@@ -57,7 +57,7 @@ const apiGenerateInvoice = async (req, res) => {
|
||||
let err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
result = {
|
||||
code: '400',
|
||||
code: "400",
|
||||
message: err.errors[0].msg,
|
||||
data: {},
|
||||
};
|
||||
@@ -71,7 +71,7 @@ const apiGenerateInvoice = async (req, res) => {
|
||||
}
|
||||
|
||||
// time
|
||||
let invoiceDate = moment(req.body.trx_date).format('YYYY-MM-DD');
|
||||
let invoiceDate = moment(req.body.trx_date).format("YYYY-MM-DD");
|
||||
|
||||
let invoice = await _generateInvoice(
|
||||
invoiceDate,
|
||||
@@ -80,8 +80,8 @@ const apiGenerateInvoice = async (req, res) => {
|
||||
);
|
||||
|
||||
result = {
|
||||
code: '200',
|
||||
message: 'Succes posting',
|
||||
code: "200",
|
||||
message: "Succes posting",
|
||||
data: invoice,
|
||||
};
|
||||
|
||||
@@ -93,11 +93,11 @@ const apiGenerateInvoice = async (req, res) => {
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
code: '500',
|
||||
code: "500",
|
||||
message:
|
||||
process.env.NODE_ENV != 'production'
|
||||
process.env.NODE_ENV != "production"
|
||||
? error.message
|
||||
: '500 internal server error - backend server.',
|
||||
: "500 internal server error - backend server.",
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
@@ -119,7 +119,7 @@ const apiPostingInvoice = async (req, res) => {
|
||||
let err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
result = {
|
||||
code: '400',
|
||||
code: "400",
|
||||
message: err.errors[0].msg,
|
||||
data: {},
|
||||
};
|
||||
@@ -137,10 +137,15 @@ const apiPostingInvoice = async (req, res) => {
|
||||
|
||||
let invoice = await _postingInvoice(uniqueCode);
|
||||
|
||||
let errorCount = invoice[0].error;
|
||||
|
||||
invoice.splice(0, 1);
|
||||
|
||||
result = {
|
||||
code: '200',
|
||||
message: 'Succes',
|
||||
code: "200",
|
||||
message: "Succes",
|
||||
data: invoice,
|
||||
error: errorCount,
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
@@ -151,11 +156,11 @@ const apiPostingInvoice = async (req, res) => {
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
code: '500',
|
||||
code: "500",
|
||||
message:
|
||||
process.env.NODE_ENV != 'production'
|
||||
process.env.NODE_ENV != "production"
|
||||
? error.message
|
||||
: '500 internal server error - backend server.',
|
||||
: "500 internal server error - backend server.",
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
@@ -200,29 +205,29 @@ const _generateInvoice = async (invoiceDate, uniqueCode, repost) => {
|
||||
|
||||
let credUsername = await model.getParameterSetting(
|
||||
knex,
|
||||
'SAP_AUTH_USERNAME'
|
||||
"SAP_AUTH_USERNAME"
|
||||
);
|
||||
let credPassword = await model.getParameterSetting(
|
||||
knex,
|
||||
'SAP_AUTH_PASSWORD'
|
||||
"SAP_AUTH_PASSWORD"
|
||||
);
|
||||
let parameter = await model.getParameterSetting(
|
||||
knex,
|
||||
'SAP_FI_URL_FOR_FB70'
|
||||
"SAP_FI_URL_FOR_FB70"
|
||||
);
|
||||
|
||||
for (let key in invoice) {
|
||||
let prepare = {
|
||||
status: true,
|
||||
cms: true,
|
||||
message: 'Success',
|
||||
message: "Success",
|
||||
};
|
||||
|
||||
if (!credUsername) {
|
||||
prepare = {
|
||||
status: false,
|
||||
cms: false,
|
||||
message: '[CMS] FAILED GET SETTING FOR SAP_AUTH_USERNAME',
|
||||
message: "[CMS] FAILED GET SETTING FOR SAP_AUTH_USERNAME",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -230,7 +235,7 @@ const _generateInvoice = async (invoiceDate, uniqueCode, repost) => {
|
||||
prepare = {
|
||||
status: false,
|
||||
cms: false,
|
||||
message: '[CMS] FAILED GET SETTING FOR SAP_AUTH_PASSWORD',
|
||||
message: "[CMS] FAILED GET SETTING FOR SAP_AUTH_PASSWORD",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -238,7 +243,7 @@ const _generateInvoice = async (invoiceDate, uniqueCode, repost) => {
|
||||
prepare = {
|
||||
status: false,
|
||||
cms: false,
|
||||
message: '[CMS] FAILED GET SETTING FOR SAP_AUTH_PASSWORD',
|
||||
message: "[CMS] FAILED GET SETTING FOR SAP_AUTH_PASSWORD",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -255,49 +260,49 @@ const _generateInvoice = async (invoiceDate, uniqueCode, repost) => {
|
||||
status: false,
|
||||
cms: false,
|
||||
message:
|
||||
'[CMS] FAILED GET PARTNER ACCOUNT CODE TOPUP / ACCOUNT TOPUP',
|
||||
"[CMS] FAILED GET PARTNER ACCOUNT CODE TOPUP / ACCOUNT TOPUP",
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
invoice[key].c_account_code_topup == '' ||
|
||||
invoice[key].c_account_topup == ''
|
||||
invoice[key].c_account_code_topup == "" ||
|
||||
invoice[key].c_account_topup == ""
|
||||
) {
|
||||
prepare = {
|
||||
status: false,
|
||||
cms: false,
|
||||
message:
|
||||
'[CMS] FAILED GET PARTNER ACCOUNT CODE TOPUP / ACCOUNT TOPUP',
|
||||
"[CMS] FAILED GET PARTNER ACCOUNT CODE TOPUP / ACCOUNT TOPUP",
|
||||
};
|
||||
}
|
||||
|
||||
let xmlHeader = {
|
||||
doc_header_text: invoice[key].doc_header_text
|
||||
? invoice[key].doc_header_text
|
||||
: '',
|
||||
ba: invoice[key].ba ? invoice[key].ba : '',
|
||||
doc_date: invoice[key].doc_date ? invoice[key].doc_date : '',
|
||||
: "",
|
||||
ba: invoice[key].ba ? invoice[key].ba : "",
|
||||
doc_date: invoice[key].doc_date ? invoice[key].doc_date : "",
|
||||
posting_date: invoice[key].posting_date
|
||||
? invoice[key].posting_date
|
||||
: '',
|
||||
fisc_year: invoice[key].fisc_year ? invoice[key].fisc_year : '',
|
||||
fisc_period: invoice[key].fisc_period ? invoice[key].fisc_period : '',
|
||||
doc_type: invoice[key].doc_type ? invoice[key].doc_type : '',
|
||||
: "",
|
||||
fisc_year: invoice[key].fisc_year ? invoice[key].fisc_year : "",
|
||||
fisc_period: invoice[key].fisc_period ? invoice[key].fisc_period : "",
|
||||
doc_type: invoice[key].doc_type ? invoice[key].doc_type : "",
|
||||
c_invoice_no: invoice[key].c_invoice_no
|
||||
? invoice[key].c_invoice_no
|
||||
: '',
|
||||
: "",
|
||||
};
|
||||
|
||||
let xmlItem = ['S', 'H'].map((item) => {
|
||||
let xmlItem = ["S", "H"].map((item) => {
|
||||
return {
|
||||
c_account_code_topup:
|
||||
item == 'S' ? invoice[key].c_account_code_topup : '',
|
||||
c_account_topup: item == 'H' ? invoice[key].c_account_topup : '',
|
||||
item == "S" ? invoice[key].c_account_code_topup : "",
|
||||
c_account_topup: item == "H" ? invoice[key].c_account_topup : "",
|
||||
ba: invoice[key].ba,
|
||||
amount: invoice[key].amount,
|
||||
posting_date: invoice[key].posting_date,
|
||||
c_invoice_no: invoice[key].c_invoice_no,
|
||||
item_text: `${item == 'S' ? 'DEBIT' : 'KREDIT'} INVOICE CMS ${
|
||||
item_text: `${item == "S" ? "DEBIT" : "KREDIT"} INVOICE CMS ${
|
||||
invoice[key].doc_header_text
|
||||
}`,
|
||||
de_cre: item,
|
||||
@@ -305,7 +310,7 @@ const _generateInvoice = async (invoiceDate, uniqueCode, repost) => {
|
||||
});
|
||||
|
||||
let xmlRequest = helper.generateXMLRequest(
|
||||
'ZFMCMS_FI_001',
|
||||
"ZFMCMS_FI_001",
|
||||
xmlHeader,
|
||||
xmlItem
|
||||
);
|
||||
@@ -338,8 +343,8 @@ const _generateInvoice = async (invoiceDate, uniqueCode, repost) => {
|
||||
resSAP = helper.getXMLData(response);
|
||||
} else {
|
||||
resSAP = {
|
||||
type: 'E',
|
||||
message: prepare?.message || 'FAILED GET PARAMETER SETTING',
|
||||
type: "E",
|
||||
message: prepare?.message || "FAILED GET PARAMETER SETTING",
|
||||
data: {},
|
||||
};
|
||||
}
|
||||
@@ -382,33 +387,33 @@ const _postingInvoice = async (uniqueCode) => {
|
||||
)}`
|
||||
);
|
||||
|
||||
let credUsername = await model.getParameterSetting(knex, 'SAP_AUTH_USERNAME');
|
||||
let credPassword = await model.getParameterSetting(knex, 'SAP_AUTH_PASSWORD');
|
||||
let parameter = await model.getParameterSetting(knex, 'SAP_FI_URL_FOR_FB70');
|
||||
let credUsername = await model.getParameterSetting(knex, "SAP_AUTH_USERNAME");
|
||||
let credPassword = await model.getParameterSetting(knex, "SAP_AUTH_PASSWORD");
|
||||
let parameter = await model.getParameterSetting(knex, "SAP_FI_URL_FOR_FB70");
|
||||
|
||||
let prepare = {
|
||||
status: true,
|
||||
message: 'Success',
|
||||
message: "Success",
|
||||
};
|
||||
|
||||
if (!credUsername) {
|
||||
prepare = {
|
||||
status: false,
|
||||
message: 'FAILED GET SETTING FOR SAP_AUTH_USERNAME',
|
||||
message: "FAILED GET SETTING FOR SAP_AUTH_USERNAME",
|
||||
};
|
||||
}
|
||||
|
||||
if (!credPassword) {
|
||||
prepare = {
|
||||
status: false,
|
||||
message: 'FAILED GET SETTING FOR SAP_AUTH_PASSWORD',
|
||||
message: "FAILED GET SETTING FOR SAP_AUTH_PASSWORD",
|
||||
};
|
||||
}
|
||||
|
||||
if (!parameter) {
|
||||
prepare = {
|
||||
status: false,
|
||||
message: 'FAILED GET SETTING FOR SAP_AUTH_PASSWORD',
|
||||
message: "FAILED GET SETTING FOR SAP_AUTH_PASSWORD",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -417,6 +422,7 @@ const _postingInvoice = async (uniqueCode) => {
|
||||
password: credPassword.c_value,
|
||||
};
|
||||
|
||||
let errorCount = 0;
|
||||
for (let item of postingEt) {
|
||||
await knex.transaction(async (trx) => {
|
||||
let response = {};
|
||||
@@ -425,31 +431,31 @@ const _postingInvoice = async (uniqueCode) => {
|
||||
|
||||
if (prepare.status) {
|
||||
let xmlHeader = {
|
||||
doc_header_text: item.doc_header_text ? item.doc_header_text : '',
|
||||
ba: item.ba ? item.ba : '',
|
||||
doc_date: item.doc_date ? item.doc_date : '',
|
||||
posting_date: item.posting_date ? item.posting_date : '',
|
||||
fisc_year: item.fiscal_year ? item.fiscal_year : '',
|
||||
fisc_period: item.fis_period ? item.fis_period : '',
|
||||
doc_type: item.doc_type ? item.doc_type : '',
|
||||
c_invoice_no: item.reference ? item.reference : '',
|
||||
doc_header_text: item.doc_header_text ? item.doc_header_text : "",
|
||||
ba: item.ba ? item.ba : "",
|
||||
doc_date: item.doc_date ? item.doc_date : "",
|
||||
posting_date: item.posting_date ? item.posting_date : "",
|
||||
fisc_year: item.fiscal_year ? item.fiscal_year : "",
|
||||
fisc_period: item.fis_period ? item.fis_period : "",
|
||||
doc_type: item.doc_type ? item.doc_type : "",
|
||||
c_invoice_no: item.reference ? item.reference : "",
|
||||
};
|
||||
|
||||
let xmlItem = ['S', 'H'].map((key) => {
|
||||
let xmlItem = ["S", "H"].map((key) => {
|
||||
return {
|
||||
c_account_code_topup: key == 'S' ? item.customer : '',
|
||||
c_account_topup: key == 'H' ? item.account : '',
|
||||
c_account_code_topup: key == "S" ? item.customer : "",
|
||||
c_account_topup: key == "H" ? item.account : "",
|
||||
ba: item.ba,
|
||||
amount: item.amount,
|
||||
posting_date: item.posting_date,
|
||||
c_invoice_no: item.reference,
|
||||
item_text: key == 'S' ? item.text1 : item.text2,
|
||||
item_text: key == "S" ? item.text1 : item.text2,
|
||||
de_cre: key,
|
||||
};
|
||||
});
|
||||
|
||||
let xmlRequest = helper.generateXMLRequest(
|
||||
'ZFMCMS_FI_001',
|
||||
"ZFMCMS_FI_001",
|
||||
xmlHeader,
|
||||
xmlItem
|
||||
);
|
||||
@@ -471,10 +477,13 @@ const _postingInvoice = async (uniqueCode) => {
|
||||
);
|
||||
|
||||
resSAP = helper.getXMLData(response);
|
||||
if (resSAP.type == "E") {
|
||||
errorCount++;
|
||||
}
|
||||
} else {
|
||||
resSAP = {
|
||||
type: 'E',
|
||||
message: prepare?.message || 'FAILED GET PARAMETER SETTING',
|
||||
type: "E",
|
||||
message: prepare?.message || "FAILED GET PARAMETER SETTING",
|
||||
data: {},
|
||||
};
|
||||
}
|
||||
@@ -511,6 +520,8 @@ const _postingInvoice = async (uniqueCode) => {
|
||||
`SCHEDULER-RETRY-${uniqueCode} RESULT CMS : ${JSON.stringify(cms)}`
|
||||
);
|
||||
|
||||
collection.push({ error: errorCount });
|
||||
|
||||
collection.push(cms.invoice[0]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
|
||||
// GET PARTNER, MERCHANT, TERMINAL FROM TID
|
||||
const generateInvoice = async (invoiceDate, repost, trx) => {
|
||||
|
||||
let result = await trx.select(trx.raw(`* FROM payment.sp_payment_req_topup_online('${invoiceDate}', ${repost})`))
|
||||
let result = await trx.select(
|
||||
trx.raw(
|
||||
`* FROM payment.sp_payment_req_topup_online('${invoiceDate}', ${repost})`
|
||||
)
|
||||
);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const insertPostingEt = async (invoice, trx) => {
|
||||
console.log("invoice : ", invoice)
|
||||
let type = ['S', 'H']
|
||||
let et = []
|
||||
let posting_et = []
|
||||
console.log("invoice : ", invoice);
|
||||
let type = ["S", "H"];
|
||||
let et = [];
|
||||
let posting_et = [];
|
||||
type.forEach((item, index) => {
|
||||
let data = {
|
||||
file_name: invoice.file_name,
|
||||
@@ -26,222 +27,293 @@ const insertPostingEt = async (invoice, trx) => {
|
||||
reference: invoice.c_invoice_no,
|
||||
amount: invoice.amount,
|
||||
ba: invoice.ba,
|
||||
indeks: (index+1),
|
||||
indeks: index + 1,
|
||||
totalidx: type.length,
|
||||
doc_header_text: invoice.c_invoice_no,
|
||||
pos_status : 3
|
||||
}
|
||||
|
||||
if(item == 'H'){
|
||||
data = {...data, ...{
|
||||
text: `Posting Invoice CMS ${invoice.c_invoice_no}`,
|
||||
debit_kredit: item,
|
||||
account: invoice.c_account_topup,
|
||||
customer: null
|
||||
}}
|
||||
}else{
|
||||
data = {...data, ...{
|
||||
text: `Posting Invoice CMS ${invoice.c_invoice_no}`,
|
||||
debit_kredit: item,
|
||||
account: null,
|
||||
customer: invoice.c_account_code_topup
|
||||
}}
|
||||
}
|
||||
pos_status: 3,
|
||||
};
|
||||
|
||||
et.push(data)
|
||||
|
||||
});
|
||||
|
||||
posting_et = await trx('public.posting_et').insert(et, ['indeks', 'customer', 'account', 'ba', 'fiscal_year', 'amount', 'no_dok', 'text', 'debit_kredit'])
|
||||
|
||||
return posting_et[0]
|
||||
|
||||
}
|
||||
|
||||
const getPostingEt = async(trx) => {
|
||||
|
||||
const result = await trx('public.posting_et AS pe').select([
|
||||
'doc_header_text',
|
||||
'ba',
|
||||
'doc_date',
|
||||
'posting_date',
|
||||
'fiscal_year',
|
||||
trx.raw(`TO_CHAR(doc_date::DATE, 'MM') AS fis_period`),
|
||||
'doc_type',
|
||||
'reference',
|
||||
'tcode',
|
||||
'amount',
|
||||
trx.raw(`'IDR' AS currency`),
|
||||
trx.raw(`(select pe2.customer from posting_et pe2 where pe2.reference = pe.reference and debit_kredit = 'S' LIMIT 1) as customer`),
|
||||
trx.raw(`(select pe2.account from posting_et pe2 where pe2.reference = pe.reference and debit_kredit = 'H' LIMIT 1) as account`),
|
||||
trx.raw(`(select pe2.text from posting_et pe2 where pe2.reference = pe.reference and debit_kredit = 'S' LIMIT 1) as text1`),
|
||||
trx.raw(`(select pe2.text from posting_et pe2 where pe2.reference = pe.reference and debit_kredit = 'H' LIMIT 1) as text2`),
|
||||
])
|
||||
.where('tcode', '=', "FB70")
|
||||
.whereIn('pos_status', ["3"])
|
||||
.groupBy([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12])
|
||||
|
||||
return result
|
||||
|
||||
}
|
||||
|
||||
const setReturnSAP = async (invoice, resSAP, trx, posting = false, c_invoice_no) => {
|
||||
let t_invoice = {}
|
||||
let t_load_balance = {}
|
||||
let posting_et = {}
|
||||
if(resSAP.type == 'S'){
|
||||
// update invoice
|
||||
t_invoice = await trx('payment.t_d_invoice').update({
|
||||
c_return_sap: resSAP.data.E_DOCUMENTNUMBER
|
||||
}, ["*"])
|
||||
.where({
|
||||
c_invoice_no: c_invoice_no
|
||||
});
|
||||
|
||||
// update load balance
|
||||
t_load_balance = await trx('trx.t_d_load_balance').update({
|
||||
c_return_sap: resSAP.data.E_DOCUMENTNUMBER
|
||||
}, ['c_load_balance_no', 'c_return_sap'])
|
||||
.whereRaw(`c_load_balance_no IN (SELECT c_load_balance_no FROM payment.t_d_payment_request_topup_online WHERE c_payment = '${c_invoice_no}')`)
|
||||
|
||||
posting_et = await trx('public.posting_et').update({
|
||||
pos_status : 0,
|
||||
status0 : resSAP.type,
|
||||
no_doksap : resSAP.data.E_DOCUMENTNUMBER ? resSAP.data.E_DOCUMENTNUMBER : null,
|
||||
status1 : resSAP.message ? resSAP.message : null
|
||||
}, ['file_name','status0']).where({
|
||||
reference: c_invoice_no
|
||||
})
|
||||
|
||||
if(posting) {
|
||||
await writePaynentHistory(t_invoice[0], "SUCCESSFULLY", 102, trx)
|
||||
if (item == "H") {
|
||||
data = {
|
||||
...data,
|
||||
...{
|
||||
text: `Posting Invoice CMS ${invoice.c_invoice_no}`,
|
||||
debit_kredit: item,
|
||||
account: invoice.c_account_topup,
|
||||
customer: null,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
await writePaynentHistory(t_invoice[0], "SUCCESS TO RETRY SAP", 118, trx)
|
||||
data = {
|
||||
...data,
|
||||
...{
|
||||
text: `Posting Invoice CMS ${invoice.c_invoice_no}`,
|
||||
debit_kredit: item,
|
||||
account: null,
|
||||
customer: invoice.c_account_code_topup,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
}else {
|
||||
et.push(data);
|
||||
});
|
||||
|
||||
posting_et = await trx("public.posting_et").insert(et, [
|
||||
"indeks",
|
||||
"customer",
|
||||
"account",
|
||||
"ba",
|
||||
"fiscal_year",
|
||||
"amount",
|
||||
"no_dok",
|
||||
"text",
|
||||
"debit_kredit",
|
||||
]);
|
||||
|
||||
return posting_et[0];
|
||||
};
|
||||
|
||||
const getPostingEt = async (trx) => {
|
||||
const result = await trx("public.posting_et AS pe")
|
||||
.select([
|
||||
"doc_header_text",
|
||||
"ba",
|
||||
"doc_date",
|
||||
"posting_date",
|
||||
"fiscal_year",
|
||||
trx.raw(`TO_CHAR(doc_date::DATE, 'MM') AS fis_period`),
|
||||
"doc_type",
|
||||
"reference",
|
||||
"tcode",
|
||||
"amount",
|
||||
trx.raw(`'IDR' AS currency`),
|
||||
trx.raw(
|
||||
`(select pe2.customer from posting_et pe2 where pe2.reference = pe.reference and debit_kredit = 'S' LIMIT 1) as customer`
|
||||
),
|
||||
trx.raw(
|
||||
`(select pe2.account from posting_et pe2 where pe2.reference = pe.reference and debit_kredit = 'H' LIMIT 1) as account`
|
||||
),
|
||||
trx.raw(
|
||||
`(select pe2.text from posting_et pe2 where pe2.reference = pe.reference and debit_kredit = 'S' LIMIT 1) as text1`
|
||||
),
|
||||
trx.raw(
|
||||
`(select pe2.text from posting_et pe2 where pe2.reference = pe.reference and debit_kredit = 'H' LIMIT 1) as text2`
|
||||
),
|
||||
])
|
||||
.where("tcode", "=", "FB70")
|
||||
.whereIn("pos_status", ["3"])
|
||||
// .limit(1)
|
||||
.groupBy([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12]);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const setReturnSAP = async (
|
||||
invoice,
|
||||
resSAP,
|
||||
trx,
|
||||
posting = false,
|
||||
c_invoice_no
|
||||
) => {
|
||||
let t_invoice = {};
|
||||
let t_load_balance = {};
|
||||
let posting_et = {};
|
||||
if (resSAP.type == "S") {
|
||||
// update invoice
|
||||
t_invoice = await trx("payment.t_d_invoice")
|
||||
.update(
|
||||
{
|
||||
c_return_sap: resSAP.data.E_DOCUMENTNUMBER,
|
||||
},
|
||||
["*"]
|
||||
)
|
||||
.where({
|
||||
c_invoice_no: c_invoice_no,
|
||||
});
|
||||
|
||||
// update load balance
|
||||
t_load_balance = await trx("trx.t_d_load_balance")
|
||||
.update(
|
||||
{
|
||||
c_return_sap: resSAP.data.E_DOCUMENTNUMBER,
|
||||
},
|
||||
["c_load_balance_no", "c_return_sap"]
|
||||
)
|
||||
.whereRaw(
|
||||
`c_load_balance_no IN (SELECT c_load_balance_no FROM payment.t_d_payment_request_topup_online WHERE c_payment = '${c_invoice_no}')`
|
||||
);
|
||||
|
||||
posting_et = await trx("public.posting_et")
|
||||
.update(
|
||||
{
|
||||
pos_status: 0,
|
||||
status0: resSAP.type,
|
||||
no_doksap: resSAP.data.E_DOCUMENTNUMBER
|
||||
? resSAP.data.E_DOCUMENTNUMBER
|
||||
: null,
|
||||
status1: resSAP.message ? resSAP.message : null,
|
||||
},
|
||||
["file_name", "status0"]
|
||||
)
|
||||
.where({
|
||||
reference: c_invoice_no,
|
||||
});
|
||||
|
||||
if (posting) {
|
||||
await writePaynentHistory(t_invoice[0], "SUCCESSFULLY", 102, trx);
|
||||
} else {
|
||||
await writePaynentHistory(t_invoice[0], "SUCCESS TO RETRY SAP", 118, trx);
|
||||
}
|
||||
} else {
|
||||
let text = resSAP.message;
|
||||
let result = text.toUpperCase();
|
||||
|
||||
if(result.includes("ALREADY")){
|
||||
let result = text.toUpperCase().split('-');
|
||||
let doc_number = result[1].trim().split(" ")[0]
|
||||
if (result.includes("ALREADY")) {
|
||||
let result = text.toUpperCase().split("-");
|
||||
let doc_number = result[1].trim().split(" ")[0];
|
||||
// update invoice
|
||||
const d = new Date();
|
||||
let year = d.getFullYear();
|
||||
|
||||
posting_et = await trx('public.posting_et').update({
|
||||
pos_status : 0,
|
||||
status0 : 'S',
|
||||
no_doksap : doc_number,
|
||||
status1 : resSAP.message ? resSAP.message : null
|
||||
}, ['file_name','status0']).where({
|
||||
reference: c_invoice_no
|
||||
})
|
||||
posting_et = await trx("public.posting_et")
|
||||
.update(
|
||||
{
|
||||
pos_status: 0,
|
||||
status0: "S",
|
||||
no_doksap: doc_number,
|
||||
status1: resSAP.message ? resSAP.message : null,
|
||||
},
|
||||
["file_name", "status0"]
|
||||
)
|
||||
.where({
|
||||
reference: c_invoice_no,
|
||||
});
|
||||
|
||||
// update invoice
|
||||
t_invoice = await trx('payment.t_d_invoice').update({
|
||||
c_return_sap: doc_number
|
||||
}, ['*'])
|
||||
.where({
|
||||
c_invoice_no: c_invoice_no
|
||||
});
|
||||
|
||||
t_invoice = await trx("payment.t_d_invoice")
|
||||
.update(
|
||||
{
|
||||
c_return_sap: doc_number,
|
||||
},
|
||||
["*"]
|
||||
)
|
||||
.where({
|
||||
c_invoice_no: c_invoice_no,
|
||||
});
|
||||
|
||||
// update load balance
|
||||
t_load_balance = await trx('trx.t_d_load_balance').update({
|
||||
c_return_sap: doc_number
|
||||
}, ['c_load_balance_no', 'c_return_sap'])
|
||||
.whereRaw(`c_load_balance_no IN (SELECT c_load_balance_no FROM payment.t_d_payment_request_topup_online WHERE c_payment = '${c_invoice_no}')`)
|
||||
|
||||
if(posting) {
|
||||
await writePaynentHistory(t_invoice[0], "SUCCESSFULLY", 102, trx)
|
||||
t_load_balance = await trx("trx.t_d_load_balance")
|
||||
.update(
|
||||
{
|
||||
c_return_sap: doc_number,
|
||||
},
|
||||
["c_load_balance_no", "c_return_sap"]
|
||||
)
|
||||
.whereRaw(
|
||||
`c_load_balance_no IN (SELECT c_load_balance_no FROM payment.t_d_payment_request_topup_online WHERE c_payment = '${c_invoice_no}')`
|
||||
);
|
||||
|
||||
if (posting) {
|
||||
await writePaynentHistory(t_invoice[0], "SUCCESSFULLY", 102, trx);
|
||||
} else {
|
||||
await writePaynentHistory(t_invoice[0], "SUCCESS TO RETRY SAP", 118, trx)
|
||||
await writePaynentHistory(
|
||||
t_invoice[0],
|
||||
"SUCCESS TO RETRY SAP",
|
||||
118,
|
||||
trx
|
||||
);
|
||||
}
|
||||
|
||||
}else{
|
||||
} else {
|
||||
// update posting et
|
||||
posting_et = await trx('public.posting_et').update({
|
||||
pos_status : resSAP.type == 'S' ? 0 : 3,
|
||||
status0 : resSAP.type,
|
||||
no_doksap : resSAP.data.E_DOCUMENTNUMBER ? resSAP.data.E_DOCUMENTNUMBER : null,
|
||||
status1 : resSAP.message ? resSAP.message : null
|
||||
}, ['file_name','status0']).where({
|
||||
reference: c_invoice_no
|
||||
})
|
||||
posting_et = await trx("public.posting_et")
|
||||
.update(
|
||||
{
|
||||
pos_status: resSAP.type == "S" ? 0 : 3,
|
||||
status0: resSAP.type,
|
||||
no_doksap: resSAP.data.E_DOCUMENTNUMBER
|
||||
? resSAP.data.E_DOCUMENTNUMBER
|
||||
: null,
|
||||
status1: resSAP.message ? resSAP.message : null,
|
||||
},
|
||||
["file_name", "status0"]
|
||||
)
|
||||
.where({
|
||||
reference: c_invoice_no,
|
||||
});
|
||||
|
||||
// update invoice
|
||||
t_invoice = await trx('payment.t_d_invoice').select(['*'])
|
||||
.where({
|
||||
c_invoice_no: c_invoice_no
|
||||
t_invoice = await trx("payment.t_d_invoice").select(["*"]).where({
|
||||
c_invoice_no: c_invoice_no,
|
||||
});
|
||||
|
||||
if(posting) {
|
||||
await writePaynentHistory(t_invoice[0], `SUCCESS WITH SAP ERR: ${resSAP.message}`,102, trx)
|
||||
|
||||
if (posting) {
|
||||
await writePaynentHistory(
|
||||
t_invoice[0],
|
||||
`SUCCESS WITH SAP ERR: ${resSAP.message}`,
|
||||
102,
|
||||
trx
|
||||
);
|
||||
} else {
|
||||
await writePaynentHistory(t_invoice[0], `FAIL TO RETRY WITH SAP ERR: ${resSAP.message}`,118, trx)
|
||||
await writePaynentHistory(
|
||||
t_invoice[0],
|
||||
`FAIL TO RETRY WITH SAP ERR: ${resSAP.message}`,
|
||||
118,
|
||||
trx
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// update posting et
|
||||
|
||||
return {
|
||||
invoice : t_invoice,
|
||||
load_balance : t_load_balance,
|
||||
posting_et : posting_et
|
||||
}
|
||||
|
||||
}
|
||||
invoice: t_invoice,
|
||||
load_balance: t_load_balance,
|
||||
posting_et: posting_et,
|
||||
};
|
||||
};
|
||||
|
||||
const writePaynentHistory = async (data, message, i_log_name, trx) => {
|
||||
console.log(data)
|
||||
const result = await trx('log.t_log_invoice').insert({
|
||||
// i_log_name : 102,
|
||||
i_log_name : i_log_name,
|
||||
d_log : trx.raw('NOW()'),
|
||||
c_invoice_no : data?.c_invoice_no || '',
|
||||
c_partner_name : data?.c_partner_name || '',
|
||||
j_new_data : JSON.stringify(data),
|
||||
d_payment_date: trx.raw('NOW()'),
|
||||
c_note : message,
|
||||
c_status : 'S',
|
||||
d_created : trx.raw('NOW()'),
|
||||
m_amount : data?.amount || 0,
|
||||
m_mdr_amount : 0,
|
||||
m_mdr_net : data?.amount || 0
|
||||
console.log(data);
|
||||
const result = await trx("log.t_log_invoice").insert(
|
||||
{
|
||||
// i_log_name : 102,
|
||||
i_log_name: i_log_name,
|
||||
d_log: trx.raw("NOW()"),
|
||||
c_invoice_no: data?.c_invoice_no || "",
|
||||
c_partner_name: data?.c_partner_name || "",
|
||||
j_new_data: JSON.stringify(data),
|
||||
d_payment_date: trx.raw("NOW()"),
|
||||
c_note: message,
|
||||
c_status: "S",
|
||||
d_created: trx.raw("NOW()"),
|
||||
m_amount: data?.amount || 0,
|
||||
m_mdr_amount: 0,
|
||||
m_mdr_net: data?.amount || 0,
|
||||
},
|
||||
["i_log_name", "c_note"]
|
||||
);
|
||||
|
||||
}, ['i_log_name', 'c_note'])
|
||||
return result;
|
||||
};
|
||||
|
||||
return result
|
||||
const getParameterSetting = async (trx, code) => {
|
||||
const result = await trx("public.t_m_global_parameter_sap AS tmgps")
|
||||
.select(["c_value"])
|
||||
.where("c_code", "=", code)
|
||||
.where("c_status", "=", "A")
|
||||
.first();
|
||||
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
const getParameterSetting = async(trx, code) => {
|
||||
const getInvoice = async (code, trx) => {
|
||||
const result = await trx("payment.t_d_invoice")
|
||||
.where("c_invoice_no", "=", code)
|
||||
.first();
|
||||
|
||||
const result = await trx('public.t_m_global_parameter_sap AS tmgps').select([
|
||||
"c_value"
|
||||
])
|
||||
.where('c_code', '=', code)
|
||||
.where('c_status', '=', "A")
|
||||
.first()
|
||||
|
||||
return result
|
||||
|
||||
}
|
||||
|
||||
const getInvoice = async(code, trx) => {
|
||||
|
||||
const result = await trx('payment.t_d_invoice')
|
||||
.where('c_invoice_no', '=', code)
|
||||
.first()
|
||||
|
||||
return result
|
||||
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
generateInvoice,
|
||||
@@ -250,5 +322,5 @@ module.exports = {
|
||||
getPostingEt,
|
||||
writePaynentHistory,
|
||||
getParameterSetting,
|
||||
getInvoice
|
||||
};
|
||||
getInvoice,
|
||||
};
|
||||
|
||||
@@ -1869,6 +1869,9 @@ const loadingBalanceInsert = async (req, param) => {
|
||||
// balance
|
||||
// )} [FLAG] : ${JSON.stringify(flag)}`
|
||||
// );
|
||||
console.log("MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM");
|
||||
console.log(insertLoadingBalance);
|
||||
|
||||
if (insertLoadingBalance > 0) {
|
||||
result = {
|
||||
code: '00',
|
||||
|
||||
@@ -320,11 +320,11 @@ const insertLoadingBalance = async (
|
||||
.insert(data)
|
||||
.returning('i_load_balance')
|
||||
.then((resp) => {
|
||||
let id = resp[0];
|
||||
let id = typeof resp[0] === 'object' ? resp[0].i_load_balance : resp[0];
|
||||
let loadDetail = [];
|
||||
detail.forEach((element) => {
|
||||
loadDetail.push({
|
||||
i_load_balance: id.i_load_balance,
|
||||
i_load_balance: id ? id : id.i_load_balance,
|
||||
i_reservation_balance: element.i_reservation_balance,
|
||||
c_reservation_no: element.c_reservation_no,
|
||||
i_amount: element.i_amount,
|
||||
@@ -352,11 +352,11 @@ const insertLoadingBalance = async (
|
||||
.insert(data);
|
||||
})
|
||||
.then((history) => {
|
||||
let id = history[0];
|
||||
let id = typeof history[0] === 'object' ? history[0].i_load_balance : history[0];
|
||||
let loadDetail = [];
|
||||
detail.forEach((element) => {
|
||||
loadDetail.push({
|
||||
i_load_balance: id.i_load_balance,
|
||||
i_load_balance: id ? id : id.i_load_balance,
|
||||
i_reservation_balance: element.i_reservation_balance,
|
||||
c_reservation_no: element.c_reservation_no,
|
||||
i_amount: element.i_amount,
|
||||
@@ -413,14 +413,23 @@ const insertLoadingBalance = async (
|
||||
});
|
||||
})
|
||||
.then(trx.commit)
|
||||
.catch(trx.rollback);
|
||||
.catch((error) => {
|
||||
console.log("SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS");
|
||||
console.log(error);
|
||||
|
||||
trx.rollback
|
||||
});
|
||||
})
|
||||
.then((result) => {
|
||||
// console.log("result insertLoadingBalance", result);
|
||||
winston.logger.debug(`XXXXXXXXXXX1 : ${result}`);
|
||||
winston.logger.debug(`XXXXXXXXXXX2 : ${JSON.stringify(result)}`);
|
||||
return result.rowCount;
|
||||
})
|
||||
.catch((error) => {
|
||||
// console.log("error.message insertLoadingBalance", error.message);
|
||||
winston.logger.debug(`YYYYYYYYYYY1 : ${error}`);
|
||||
winston.logger.debug(`YYYYYYYYYYY2 : ${JSON.stringify(error)}`);
|
||||
return error.message;
|
||||
});
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,6 +20,28 @@ const getCardReplacement = (card_number) => {
|
||||
return result;
|
||||
};
|
||||
|
||||
const getCardReplacementScheduler = async () => {
|
||||
const today = new Date().toISOString().split('T')[0]; // Format: 'YYYY-MM-DD'
|
||||
|
||||
const result = await knex('trx.t_d_card_replacement')
|
||||
.select('c_card_no')
|
||||
.where('i_last_balance', null)
|
||||
.where('d_valid_date', '>=', today);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET IS CARD SALES
|
||||
const getCardSales = (card_number) => {
|
||||
let result = knex('trx.t_d_sales_kmt_temp')
|
||||
.select()
|
||||
.where('card_number', card_number)
|
||||
.orderBy('i_sales_kmt_temp', 'DESC')
|
||||
.first();
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET IS CARD ADDED TO BLACKLIST
|
||||
const getCardProduct = (card_number) => {
|
||||
let result = knex('public.t_m_card_product')
|
||||
@@ -80,11 +102,251 @@ const updateReplacement = async (i_card_replacement, dataReplacement) => {
|
||||
return result;
|
||||
};
|
||||
|
||||
// UPDATE CARD REPLACEMENT BY CARD NUMBER
|
||||
const updateReplacementByCardNumber = async (card_number, dataReplacement) => {
|
||||
let result = await knex('trx.t_d_card_replacement')
|
||||
.update(dataReplacement, ['*'])
|
||||
.where({ c_card_no: card_number });
|
||||
return result;
|
||||
};
|
||||
|
||||
// UPDATE CARD SALES
|
||||
const updateSales = async (i_sales_kmt_temp, dataSales) => {
|
||||
let result = await knex('trx.t_d_sales_kmt_temp')
|
||||
.update(dataSales, ['*'])
|
||||
.where({ i_sales_kmt_temp: i_sales_kmt_temp });
|
||||
return result;
|
||||
};
|
||||
|
||||
const insertReplacementDetail = async (dataReplacement) => {
|
||||
let result = await knex("trx.t_d_card_replacement_detail").insert(dataReplacement);
|
||||
return result;
|
||||
};
|
||||
|
||||
const insertSales = async (dataSales) => {
|
||||
let result = await knex("trx.t_d_sales_kmt_temp").insert(dataSales);
|
||||
return result;
|
||||
};
|
||||
|
||||
const getPPNCardSales = async () => {
|
||||
let result = await knex('public.t_m_global_parameter')
|
||||
.select('c_value')
|
||||
.where('c_code', 'CARD_SALES_TAX')
|
||||
.where('c_status', 'A')
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
const completingDataSalesInternal = async (ppn) => {
|
||||
let result
|
||||
await knex.transaction(async (trx) => {
|
||||
try {
|
||||
await trx.raw(`
|
||||
UPDATE trx.t_d_sales_internal AS trx
|
||||
SET
|
||||
c_material_number_sap = subquery.c_material_number_sap,
|
||||
i_card_theme = subquery.i_card_theme,
|
||||
i_tax_amount = subquery.tax,
|
||||
is_complete = subquery.is_complete
|
||||
FROM (
|
||||
SELECT DISTINCT ON (trx.t_d_sales_internal.c_card_number, t_m_card_theme.c_card_type_code, t_m_card_theme.c_card_digit_key, t_m_card_theme.c_variant_code)
|
||||
trx.t_d_sales_internal.c_card_number,
|
||||
t_m_card_theme.i_card_theme,
|
||||
t_m_card_theme.c_material_number_sap,
|
||||
trx.t_d_sales_internal.i_card_price AS card_selling_price,
|
||||
ROUND(trx.t_d_sales_internal.i_card_price * 100 / (100 + ${ppn}::float)) AS card_price_before_tax,
|
||||
ROUND((${ppn}::float / 100::float) * (ROUND(trx.t_d_sales_internal.i_card_price * 100 / (100 + ${ppn}::float)))) AS tax,
|
||||
CASE
|
||||
WHEN trx.t_d_sales_internal.c_category = 'S' THEN true
|
||||
ELSE false
|
||||
END is_complete
|
||||
FROM trx.t_d_sales_internal
|
||||
JOIN public.t_m_card_theme ON
|
||||
SUBSTRING(trx.t_d_sales_internal.c_card_number, 1, 1) = t_m_card_theme.c_card_type_code
|
||||
AND SUBSTRING(trx.t_d_sales_internal.c_card_number, 2, 2) = t_m_card_theme.c_card_digit_key
|
||||
AND SUBSTRING(trx.t_d_sales_internal.c_card_number, 4, 1) = t_m_card_theme.c_variant_code
|
||||
AND SUBSTRING(trx.t_d_sales_internal.c_card_number, 7, 2) = RIGHT(t_m_card_theme.i_year::text, 2)
|
||||
WHERE
|
||||
trx.t_d_sales_internal.is_complete is not true
|
||||
AND trx.t_d_sales_internal.i_card_price > 0
|
||||
AND trx.t_d_sales_internal.i_sales_invoice_internal is null
|
||||
ORDER BY
|
||||
trx.t_d_sales_internal.c_card_number,
|
||||
t_m_card_theme.c_card_type_code,
|
||||
t_m_card_theme.c_card_digit_key,
|
||||
t_m_card_theme.c_variant_code,
|
||||
t_m_card_theme.i_year DESC,
|
||||
trx.t_d_sales_internal.d_create ASC
|
||||
) AS subquery
|
||||
WHERE
|
||||
trx.c_card_number = subquery.c_card_number
|
||||
AND trx.i_sales_invoice_internal IS NULL
|
||||
`);
|
||||
|
||||
await trx.raw(`
|
||||
UPDATE trx.t_d_sales_internal AS trx
|
||||
SET
|
||||
c_old_material_number_sap = subquery.c_material_number_sap,
|
||||
i_old_card_theme = subquery.i_card_theme,
|
||||
i_old_tax_amount = subquery.tax,
|
||||
is_complete = subquery.is_complete
|
||||
FROM (
|
||||
SELECT DISTINCT ON (trx.t_d_sales_internal.c_old_card_number, t_m_card_theme.c_card_type_code, t_m_card_theme.c_card_digit_key, t_m_card_theme.c_variant_code)
|
||||
trx.t_d_sales_internal.c_old_card_number,
|
||||
t_m_card_theme.i_card_theme,
|
||||
t_m_card_theme.c_material_number_sap,
|
||||
trx.t_d_sales_internal.i_old_card_price AS card_selling_price,
|
||||
ROUND(trx.t_d_sales_internal.i_old_card_price * 100 / (100 + ${ppn}::float)) AS card_price_before_tax,
|
||||
ROUND((${ppn}::float / 100::float) * (ROUND(trx.t_d_sales_internal.i_old_card_price * 100 / (100 + ${ppn}::float)))) AS tax,
|
||||
CASE
|
||||
WHEN trx.t_d_sales_internal.c_category = 'S' THEN true
|
||||
WHEN trx.t_d_sales_internal.c_category IN ('N', 'W') THEN true
|
||||
ELSE false
|
||||
END is_complete
|
||||
FROM trx.t_d_sales_internal
|
||||
JOIN public.t_m_card_theme ON
|
||||
SUBSTRING(trx.t_d_sales_internal.c_old_card_number, 1, 1) = t_m_card_theme.c_card_type_code
|
||||
AND SUBSTRING(trx.t_d_sales_internal.c_old_card_number, 2, 2) = t_m_card_theme.c_card_digit_key
|
||||
AND SUBSTRING(trx.t_d_sales_internal.c_old_card_number, 4, 1) = t_m_card_theme.c_variant_code
|
||||
AND SUBSTRING(trx.t_d_sales_internal.c_old_card_number, 7, 2) = RIGHT(t_m_card_theme.i_year::text, 2)
|
||||
WHERE
|
||||
trx.t_d_sales_internal.is_complete is not true
|
||||
AND trx.t_d_sales_internal.i_old_card_price > 0
|
||||
AND trx.t_d_sales_internal.c_category IN ('N', 'W')
|
||||
AND trx.t_d_sales_internal.i_sales_invoice_internal is null
|
||||
ORDER BY
|
||||
trx.t_d_sales_internal.c_old_card_number,
|
||||
t_m_card_theme.c_card_type_code,
|
||||
t_m_card_theme.c_card_digit_key,
|
||||
t_m_card_theme.c_variant_code,
|
||||
t_m_card_theme.i_year DESC,
|
||||
trx.t_d_sales_internal.d_create ASC
|
||||
) AS subquery
|
||||
WHERE
|
||||
trx.c_old_card_number = subquery.c_old_card_number
|
||||
AND trx.i_sales_invoice_internal IS NULL
|
||||
`);
|
||||
|
||||
await trx.commit();
|
||||
|
||||
result = {
|
||||
success: true,
|
||||
message: 'Berhasil update data sales internal.'
|
||||
};
|
||||
} catch (error) {
|
||||
await trx.rollback();
|
||||
result = {
|
||||
success: false,
|
||||
message: `Gagal update data sales internal: ${error.message}`
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const completingDataSalesNewCard = async (ppn) => {
|
||||
return await knex.raw(`
|
||||
UPDATE trx.t_d_sales_internal AS trx
|
||||
SET
|
||||
c_material_number_sap = subquery.c_material_number_sap,
|
||||
i_card_theme = subquery.i_card_theme,
|
||||
i_tax_amount = subquery.tax,
|
||||
is_complete = subquery.is_complete
|
||||
FROM (
|
||||
SELECT DISTINCT ON (trx.t_d_sales_internal.c_card_number, t_m_card_theme.c_card_type_code, t_m_card_theme.c_card_digit_key, t_m_card_theme.c_variant_code)
|
||||
trx.t_d_sales_internal.c_card_number,
|
||||
t_m_card_theme.i_card_theme,
|
||||
t_m_card_theme.c_material_number_sap,
|
||||
trx.t_d_sales_internal.i_card_price AS card_selling_price,
|
||||
ROUND(trx.t_d_sales_internal.i_card_price * 100 / (100 + ${ppn}::float)) AS card_price_before_tax,
|
||||
ROUND((${ppn}::float / 100::float) * (ROUND(trx.t_d_sales_internal.i_card_price * 100 / (100 + ${ppn}::float)))) AS tax,
|
||||
CASE
|
||||
WHEN trx.t_d_sales_internal.c_category = 'S' THEN true
|
||||
ELSE false
|
||||
END is_complete
|
||||
FROM trx.t_d_sales_internal
|
||||
JOIN public.t_m_card_theme ON
|
||||
SUBSTRING(trx.t_d_sales_internal.c_card_number, 1, 1) = t_m_card_theme.c_card_type_code
|
||||
AND SUBSTRING(trx.t_d_sales_internal.c_card_number, 2, 2) = t_m_card_theme.c_card_digit_key
|
||||
AND SUBSTRING(trx.t_d_sales_internal.c_card_number, 4, 1) = t_m_card_theme.c_variant_code
|
||||
AND SUBSTRING(trx.t_d_sales_internal.c_card_number, 7, 2) = RIGHT(t_m_card_theme.i_year::text, 2)
|
||||
WHERE
|
||||
trx.t_d_sales_internal.is_complete is not true
|
||||
AND trx.t_d_sales_internal.i_card_price > 0
|
||||
AND trx.t_d_sales_internal.i_sales_invoice_internal is null
|
||||
ORDER BY
|
||||
trx.t_d_sales_internal.c_card_number,
|
||||
t_m_card_theme.c_card_type_code,
|
||||
t_m_card_theme.c_card_digit_key,
|
||||
t_m_card_theme.c_variant_code,
|
||||
t_m_card_theme.i_year DESC,
|
||||
trx.t_d_sales_internal.d_create ASC
|
||||
) AS subquery
|
||||
WHERE
|
||||
trx.c_card_number = subquery.c_card_number
|
||||
AND trx.i_sales_invoice_internal IS NULL
|
||||
`);
|
||||
};
|
||||
|
||||
const completingDataSalesOldCard = async (ppn) => {
|
||||
return await knex.raw(`
|
||||
UPDATE trx.t_d_sales_internal AS trx
|
||||
SET
|
||||
c_old_material_number_sap = subquery.c_material_number_sap,
|
||||
i_old_card_theme = subquery.i_card_theme,
|
||||
i_old_tax_amount = subquery.tax
|
||||
FROM (
|
||||
SELECT DISTINCT ON (trx.t_d_sales_internal.c_old_card_number, t_m_card_theme.c_card_type_code, t_m_card_theme.c_card_digit_key, t_m_card_theme.c_variant_code)
|
||||
trx.t_d_sales_internal.c_old_card_number,
|
||||
t_m_card_theme.i_card_theme,
|
||||
t_m_card_theme.c_material_number_sap,
|
||||
trx.t_d_sales_internal.i_old_card_price AS card_selling_price,
|
||||
ROUND(trx.t_d_sales_internal.i_old_card_price * 100 / (100 + ${ppn}::float)) AS card_price_before_tax,
|
||||
ROUND((${ppn}::float / 100::float) * (ROUND(trx.t_d_sales_internal.i_old_card_price * 100 / (100 + ${ppn}::float)))) AS tax,
|
||||
CASE
|
||||
WHEN trx.t_d_sales_internal.c_category = 'S' THEN true
|
||||
WHEN trx.t_d_sales_internal.c_category IN ('N', 'W') THEN true
|
||||
ELSE false
|
||||
END is_complete
|
||||
FROM trx.t_d_sales_internal
|
||||
JOIN public.t_m_card_theme ON
|
||||
SUBSTRING(trx.t_d_sales_internal.c_old_card_number, 1, 1) = t_m_card_theme.c_card_type_code
|
||||
AND SUBSTRING(trx.t_d_sales_internal.c_old_card_number, 2, 2) = t_m_card_theme.c_card_digit_key
|
||||
AND SUBSTRING(trx.t_d_sales_internal.c_old_card_number, 4, 1) = t_m_card_theme.c_variant_code
|
||||
AND SUBSTRING(trx.t_d_sales_internal.c_old_card_number, 7, 2) = RIGHT(t_m_card_theme.i_year::text, 2)
|
||||
WHERE
|
||||
trx.t_d_sales_internal.is_complete is not true
|
||||
AND trx.t_d_sales_internal.i_old_card_price > 0
|
||||
AND trx.t_d_sales_internal.c_category IN ('N', 'W')
|
||||
AND trx.t_d_sales_internal.i_sales_invoice_internal is null
|
||||
ORDER BY
|
||||
trx.t_d_sales_internal.c_old_card_number,
|
||||
t_m_card_theme.c_card_type_code,
|
||||
t_m_card_theme.c_card_digit_key,
|
||||
t_m_card_theme.c_variant_code,
|
||||
t_m_card_theme.i_year DESC,
|
||||
trx.t_d_sales_internal.d_create ASC
|
||||
) AS subquery
|
||||
WHERE
|
||||
trx.c_old_card_number = subquery.c_old_card_number
|
||||
AND trx.i_sales_invoice_internal IS NULL
|
||||
`);
|
||||
};
|
||||
|
||||
const updateDataSalesIsComplete = async () => {
|
||||
return await knex.raw(`
|
||||
UPDATE trx.t_d_sales_internal SET is_complete = true
|
||||
WHERE
|
||||
is_complete is not true
|
||||
AND c_material_number_sap is not null
|
||||
AND i_tax_amount is not null
|
||||
AND c_old_material_number_sap is not null
|
||||
AND i_old_tax_amount is not null
|
||||
AND c_category IN ('N', 'W')
|
||||
`);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getCardBlacklist,
|
||||
getCardReplacement,
|
||||
@@ -93,5 +355,15 @@ module.exports = {
|
||||
getLastBalanceFromCardHistory,
|
||||
getAccumulationBalanceInThisMonthFromCardHistory,
|
||||
updateReplacement,
|
||||
insertReplacementDetail
|
||||
insertReplacementDetail,
|
||||
insertSales,
|
||||
getCardSales,
|
||||
updateSales,
|
||||
getCardReplacementScheduler,
|
||||
updateReplacementByCardNumber,
|
||||
getPPNCardSales,
|
||||
completingDataSalesInternal,
|
||||
completingDataSalesNewCard,
|
||||
completingDataSalesOldCard,
|
||||
updateDataSalesIsComplete,
|
||||
};
|
||||
@@ -1823,7 +1823,58 @@ const reservation = async (req, res) => {
|
||||
|
||||
// jika proses insert data semua yang berkaitan dengan reservasi saldo mengalami kegagalan, maka lakukan rollback
|
||||
// kegagalan insert data transaksi bisa disebabkan karena data ref no yang di berikan client sudah digunakan
|
||||
if (insert.rowCount < 1) {
|
||||
if (insert.rowCount > 0) {
|
||||
// log debug
|
||||
// winston.logger.debug(
|
||||
// `${uniqueCode} [ PROCESSING RESERVATION ] inserting log for card history...`
|
||||
// );
|
||||
|
||||
// log card history
|
||||
await model.createReserveBalanceLog({
|
||||
i_log_name: 90,
|
||||
d_log: now,
|
||||
c_card_number: card_number,
|
||||
c_source: 'CMS',
|
||||
c_location: getPartner ? getPartner.partner_name : null,
|
||||
m_balance_before: balance > 0 ? balance : 0,
|
||||
m_amount: 0,
|
||||
m_balance_after: balance > 0 ? balance : 0,
|
||||
j_new_data: data,
|
||||
j_old_data: null,
|
||||
c_note: `RESERVED BALANCE ${amount} FROM ${
|
||||
getPartner ? getPartner.partner_name : null
|
||||
} SUCCESSFULLY`,
|
||||
c_status: 'S',
|
||||
d_created: now,
|
||||
i_create: null,
|
||||
c_create_username: 'HSM',
|
||||
c_create_fullname: 'HARDWARE SECURE MODULE',
|
||||
c_category: 'T',
|
||||
});
|
||||
|
||||
result = {
|
||||
code: '00',
|
||||
message: 'reservation saved successfully.',
|
||||
data: {
|
||||
reservation_number: reservationNumber,
|
||||
reservation_time: now,
|
||||
partner: getPartner ? getPartner.partner_name : null,
|
||||
merchant: getPartner ? getPartner.merchant_name : null,
|
||||
terminal: getPartner ? getPartner.terminal_name : null,
|
||||
card_number: card_number,
|
||||
reserved_amount: amount,
|
||||
issuer_fee: issuerFee,
|
||||
channel_fee: channelFee,
|
||||
},
|
||||
};
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ RESPONSE RESERVATION ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
} else {
|
||||
// log debug
|
||||
// winston.logger.debug(
|
||||
// `${uniqueCode} [ PROCESSING RESERVATION ] deleting reservation number validate...`
|
||||
@@ -1845,57 +1896,6 @@ const reservation = async (req, res) => {
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
// winston.logger.debug(
|
||||
// `${uniqueCode} [ PROCESSING RESERVATION ] inserting log for card history...`
|
||||
// );
|
||||
|
||||
// log card history
|
||||
await model.createReserveBalanceLog({
|
||||
i_log_name: 90,
|
||||
d_log: now,
|
||||
c_card_number: card_number,
|
||||
c_source: 'CMS',
|
||||
c_location: getPartner ? getPartner.partner_name : null,
|
||||
m_balance_before: balance > 0 ? balance : 0,
|
||||
m_amount: 0,
|
||||
m_balance_after: balance > 0 ? balance : 0,
|
||||
j_new_data: data,
|
||||
j_old_data: null,
|
||||
c_note: `RESERVED BALANCE ${amount} FROM ${
|
||||
getPartner ? getPartner.partner_name : null
|
||||
} SUCCESSFULLY`,
|
||||
c_status: 'S',
|
||||
d_created: now,
|
||||
i_create: null,
|
||||
c_create_username: 'HSM',
|
||||
c_create_fullname: 'HARDWARE SECURE MODULE',
|
||||
c_category: 'T',
|
||||
});
|
||||
|
||||
result = {
|
||||
code: '00',
|
||||
message: 'reservation saved successfully.',
|
||||
data: {
|
||||
reservation_number: reservationNumber,
|
||||
reservation_time: now,
|
||||
partner: getPartner ? getPartner.partner_name : null,
|
||||
merchant: getPartner ? getPartner.merchant_name : null,
|
||||
terminal: getPartner ? getPartner.terminal_name : null,
|
||||
card_number: card_number,
|
||||
reserved_amount: amount,
|
||||
issuer_fee: issuerFee,
|
||||
channel_fee: channelFee,
|
||||
},
|
||||
};
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ RESPONSE RESERVATION ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
@@ -2660,7 +2660,58 @@ const reservationV2 = async (req, res) => {
|
||||
|
||||
// jika proses insert data semua yang berkaitan dengan reservasi saldo mengalami kegagalan, maka lakukan rollback
|
||||
// kegagalan insert data transaksi bisa disebabkan karena data ref no yang di berikan client sudah digunakan
|
||||
if (insert.rowCount < 1) {
|
||||
if (insert.rowCount > 0) {
|
||||
// log debug
|
||||
// winston.logger.debug(
|
||||
// `${uniqueCode} [ PROCESSING RESERVATION-V2 ] inserting log for card history...`
|
||||
// );
|
||||
|
||||
// log card history
|
||||
await model.createReserveBalanceLog({
|
||||
i_log_name: 90,
|
||||
d_log: now,
|
||||
c_card_number: card_number,
|
||||
c_source: 'CMS',
|
||||
c_location: getPartner ? getPartner.partner_name : null,
|
||||
m_balance_before: balance > 0 ? balance : 0,
|
||||
m_amount: 0,
|
||||
m_balance_after: balance > 0 ? balance : 0,
|
||||
j_new_data: data,
|
||||
j_old_data: null,
|
||||
c_note: `RESERVED BALANCE ${amount} FROM ${
|
||||
getPartner ? getPartner.partner_name : null
|
||||
} SUCCESSFULLY`,
|
||||
c_status: 'S',
|
||||
d_created: now,
|
||||
i_create: null,
|
||||
c_create_username: 'HSM',
|
||||
c_create_fullname: 'HARDWARE SECURE MODULE',
|
||||
c_category: 'T',
|
||||
});
|
||||
|
||||
result = {
|
||||
code: '00',
|
||||
message: 'reservation saved successfully.',
|
||||
data: {
|
||||
reservation_number: reservationNumber,
|
||||
reservation_time: now,
|
||||
partner: getPartner ? getPartner.partner_name : null,
|
||||
merchant: getPartner ? getPartner.merchant_name : null,
|
||||
terminal: getPartner ? getPartner.terminal_name : null,
|
||||
card_number: card_number,
|
||||
reserved_amount: amount,
|
||||
issuer_fee: issuerFee,
|
||||
channel_fee: channelFee,
|
||||
},
|
||||
};
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ RESPONSE RESERVATION-V2 ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
} else {
|
||||
// log debug
|
||||
// winston.logger.debug(
|
||||
// `${uniqueCode} [ PROCESSING RESERVATION-V2 ] deleting reservation number validate...`
|
||||
@@ -2682,57 +2733,6 @@ const reservationV2 = async (req, res) => {
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
// winston.logger.debug(
|
||||
// `${uniqueCode} [ PROCESSING RESERVATION-V2 ] inserting log for card history...`
|
||||
// );
|
||||
|
||||
// log card history
|
||||
await model.createReserveBalanceLog({
|
||||
i_log_name: 90,
|
||||
d_log: now,
|
||||
c_card_number: card_number,
|
||||
c_source: 'CMS',
|
||||
c_location: getPartner ? getPartner.partner_name : null,
|
||||
m_balance_before: balance > 0 ? balance : 0,
|
||||
m_amount: 0,
|
||||
m_balance_after: balance > 0 ? balance : 0,
|
||||
j_new_data: data,
|
||||
j_old_data: null,
|
||||
c_note: `RESERVED BALANCE ${amount} FROM ${
|
||||
getPartner ? getPartner.partner_name : null
|
||||
} SUCCESSFULLY`,
|
||||
c_status: 'S',
|
||||
d_created: now,
|
||||
i_create: null,
|
||||
c_create_username: 'HSM',
|
||||
c_create_fullname: 'HARDWARE SECURE MODULE',
|
||||
c_category: 'T',
|
||||
});
|
||||
|
||||
result = {
|
||||
code: '00',
|
||||
message: 'reservation saved successfully.',
|
||||
data: {
|
||||
reservation_number: reservationNumber,
|
||||
reservation_time: now,
|
||||
partner: getPartner ? getPartner.partner_name : null,
|
||||
merchant: getPartner ? getPartner.merchant_name : null,
|
||||
terminal: getPartner ? getPartner.terminal_name : null,
|
||||
card_number: card_number,
|
||||
reserved_amount: amount,
|
||||
issuer_fee: issuerFee,
|
||||
channel_fee: channelFee,
|
||||
},
|
||||
};
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ RESPONSE RESERVATION-V2 ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
|
||||
@@ -17,6 +17,20 @@ router.get(
|
||||
controller.apiGenerateCashInSales
|
||||
);
|
||||
|
||||
router.get(
|
||||
"/online/cash-in-sales-internal",
|
||||
// auth.authenticateToken,
|
||||
// controller.validate("generateInvoice"),
|
||||
controller.apiGenerateCashInSalesInternal
|
||||
);
|
||||
|
||||
router.get(
|
||||
"/online/cash-in-topup-cashless-internal",
|
||||
// auth.authenticateToken,
|
||||
// controller.validate("generateInvoice"),
|
||||
controller.apiGenerateCashInTopUpCashlessInternal
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/online/cash-in/posting",
|
||||
// auth.authenticateToken,
|
||||
|
||||
@@ -51,6 +51,14 @@ router.post(
|
||||
controller.validateReplacement
|
||||
);
|
||||
|
||||
// API Validate Replacement New Card
|
||||
router.post(
|
||||
"/pos/cardreplacement/validatenewcard",
|
||||
auth.authenticateToken,
|
||||
controller.validate("validateNewCardReplacement"),
|
||||
controller.validateNewCardReplacement
|
||||
);
|
||||
|
||||
// API Replacement Confirm
|
||||
router.post(
|
||||
"/pos/cardreplacement/confirm",
|
||||
@@ -59,4 +67,45 @@ router.post(
|
||||
controller.replacementConfirm
|
||||
);
|
||||
|
||||
// API Redeem Confirm
|
||||
router.post(
|
||||
"/pos/cardredeem/confirm",
|
||||
auth.authenticateToken,
|
||||
controller.validate("confirmCardRedeem"),
|
||||
controller.confirmRedeem
|
||||
);
|
||||
|
||||
// API Sales Confirm
|
||||
router.post(
|
||||
"/pos/cardsales/confirm",
|
||||
auth.authenticateToken,
|
||||
controller.validate("confirmCardSales"),
|
||||
controller.confirmSales
|
||||
);
|
||||
|
||||
// API Sales Confirm
|
||||
router.post(
|
||||
"/pos/schedulerCTS/lastbalance",
|
||||
auth.authenticateToken,
|
||||
controller.getLastBalanceCTS
|
||||
);
|
||||
|
||||
// API Scheduler Lengkapi Data Sales Internal
|
||||
router.post(
|
||||
"/pos/sales/complete-data",
|
||||
controller.completeDataSalesInternal
|
||||
);
|
||||
|
||||
// API Scheduler Lengkapi Data Sales Internal V2
|
||||
router.post(
|
||||
"/pos/sales/complete-data-v2",
|
||||
controller.completeDataSalesInternalV2
|
||||
);
|
||||
|
||||
// API Test
|
||||
router.post(
|
||||
"/pos/test",
|
||||
controller.testAPI
|
||||
);
|
||||
|
||||
module.exports = router;
|
||||
|
||||
+8
-2
@@ -70,7 +70,10 @@ module.exports = {
|
||||
// connection: process.env.DB_URL,
|
||||
pool: {
|
||||
min: 2,
|
||||
max: 30,
|
||||
max: 100,
|
||||
idleTimeoutMillis: 30000, // ← Contoh: 30 detik idle timeout
|
||||
acquireTimeoutMillis: 20000, // Maksimal waktu tunggu koneksi dari pool
|
||||
// maxLifetimeMillis: 300000 // maksimal umur koneksi: 5 menit (300.000 ms)
|
||||
},
|
||||
migrations: {
|
||||
directory: './infrastructure/database/migrations',
|
||||
@@ -97,7 +100,10 @@ module.exports = {
|
||||
// connection: process.env.DB_URL,
|
||||
pool: {
|
||||
min: 2,
|
||||
max: 20,
|
||||
max: 100,
|
||||
idleTimeoutMillis: 30000, // ← Contoh: 30 detik idle timeout
|
||||
acquireTimeoutMillis: 20000, // Maksimal waktu tunggu koneksi dari pool
|
||||
// maxLifetimeMillis: 300000 // maksimal umur koneksi: 5 menit (300.000 ms)
|
||||
},
|
||||
migrations: {
|
||||
directory: './infrastructure/database/migrations',
|
||||
|
||||
Generated
+2608
-8414
File diff suppressed because it is too large
Load Diff
+8
-6
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "topuponline",
|
||||
"version": "1.6.0",
|
||||
"description": "handling maximum flag 255",
|
||||
"name": "onlinetopup-v1",
|
||||
"version": "1.6.3",
|
||||
"description": "update packages",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "nodemon index",
|
||||
@@ -37,11 +37,13 @@
|
||||
"moment": "^2.29.3",
|
||||
"node-cron": "^3.0.1",
|
||||
"pg": "^8.6.0",
|
||||
"pm2": "^5.2.0",
|
||||
"pm2": "^6.0.13",
|
||||
"prom-client": "^14.2.0",
|
||||
"redis": "^4.6.5",
|
||||
"response-time": "^2.3.2",
|
||||
"simple-update-notifier": "^2.0.0",
|
||||
"sticky-session": "^0.1.0",
|
||||
"superagent": "^10.2.3",
|
||||
"winston": "^3.7.2",
|
||||
"winston-daily-rotate-file": "^4.7.1",
|
||||
"winston-loki": "^6.0.6",
|
||||
@@ -50,8 +52,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "^29.0.2",
|
||||
"nodemon": "^2.0.7",
|
||||
"supertest": "^6.2.4"
|
||||
"nodemon": "^3.1.10",
|
||||
"supertest": "^7.1.3"
|
||||
},
|
||||
"jest": {
|
||||
"testEnvironment": "node",
|
||||
|
||||
Reference in New Issue
Block a user