mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-05 10:56:27 +00:00
Update
This commit is contained in:
@@ -307,8 +307,8 @@ const getPartnerRecon = async(trx) => {
|
||||
.where("tdrb.c_status", "=", "A")
|
||||
.where("tdi.c_status", "!=", "X")
|
||||
.where("tdpr.c_status", "=", "S")
|
||||
.where("tdi.c_return_sap", "LIKE", "S-%")
|
||||
|
||||
// .where("tdi.c_return_sap", "LIKE", "S-%")
|
||||
.whereNotNull("tdi.c_return_sap")
|
||||
.whereNotNull("tdrb.c_load_balance_no")
|
||||
.whereRaw(`tdrb.c_reservation_no in (SELECT c_reservation_no FROM payment.t_d_payment_recon where c_status = 'S' ) AND tdrb.c_reservation_no NOT IN (SELECT c_reservation_no FROM payment.t_d_cash_in_detail WHERE b_reversal IS NOT TRUE)`)
|
||||
.groupBy(["tdpr.c_partner_code","tdrb.c_partner_name","tdi.c_invoice_no","tdi.d_invoice_date", "tdpr.d_payment", "tmp.c_account_topup", "tmp.c_account_code_topup", "tdi.i_company", "i_holding"])
|
||||
|
||||
@@ -181,19 +181,6 @@ const _generateInvoice = async (invoiceDate, uniqueCode, repost) => {
|
||||
|
||||
if (invoice.length > 0)
|
||||
for (const key in invoice) {
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} insert payment history et : ${JSON.stringify(
|
||||
invoice
|
||||
)}`
|
||||
);
|
||||
|
||||
let history = await model.writePaynentHistory(invoice[key], trx);
|
||||
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} result insert payment history et : ${JSON.stringify(
|
||||
history
|
||||
)}`
|
||||
);
|
||||
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} insert posting et ${JSON.stringify(
|
||||
@@ -328,7 +315,7 @@ const _generateInvoice = async (invoiceDate, uniqueCode, repost) => {
|
||||
)}`
|
||||
);
|
||||
|
||||
const cms = await model.setReturnSAP(invoice[key], resSAP, trx);
|
||||
const cms = await model.setReturnSAP(invoice[key], resSAP, trx, true);
|
||||
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} RESULT CMS : ${JSON.stringify(cms)}`
|
||||
@@ -462,7 +449,8 @@ const _postingInvoice = async (uniqueCode) => {
|
||||
const cms = await model.setReturnSAP(
|
||||
{ c_invoice_no: item.reference },
|
||||
resSAP,
|
||||
trx
|
||||
trx,
|
||||
false
|
||||
);
|
||||
|
||||
winston.logger.info(
|
||||
|
||||
@@ -85,7 +85,7 @@ const getPostingEt = async(trx) => {
|
||||
|
||||
}
|
||||
|
||||
const setReturnSAP = async (invoice, resSAP, trx) => {
|
||||
const setReturnSAP = async (invoice, resSAP, trx, posting = false) => {
|
||||
let t_invoice = {}
|
||||
let t_load_balance = {}
|
||||
let posting_et = {}
|
||||
@@ -100,7 +100,7 @@ const setReturnSAP = async (invoice, resSAP, trx) => {
|
||||
|
||||
// update load balance
|
||||
t_load_balance = await trx('trx.t_d_load_balance').update({
|
||||
c_return_sap: "S-"+resSAP.data.E_DOCUMENTNUMBER
|
||||
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 = '${invoice.c_invoice_no}')`)
|
||||
|
||||
@@ -113,6 +113,18 @@ const setReturnSAP = async (invoice, resSAP, trx) => {
|
||||
reference: invoice.c_invoice_no
|
||||
})
|
||||
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} insert payment history et : ${JSON.stringify(
|
||||
invoice
|
||||
)}`
|
||||
);
|
||||
|
||||
if(posting) {
|
||||
await writePaynentHistory(invoice, "SUCCESSFULLY", trx)
|
||||
} else {
|
||||
await writePaynentHistory(invoice, "SUCCESS TO RETRY SAP", trx)
|
||||
}
|
||||
|
||||
}else {
|
||||
|
||||
let text = resSAP.message;
|
||||
@@ -136,7 +148,7 @@ const setReturnSAP = async (invoice, resSAP, trx) => {
|
||||
|
||||
// update invoice
|
||||
t_invoice = await trx('payment.t_d_invoice').update({
|
||||
c_return_sap: "S-"+doc_number
|
||||
c_return_sap: doc_number
|
||||
}, ['c_invoice_no','c_return_sap','m_amount'])
|
||||
.where({
|
||||
c_invoice_no: invoice.c_invoice_no
|
||||
@@ -144,9 +156,15 @@ const setReturnSAP = async (invoice, resSAP, trx) => {
|
||||
|
||||
// update load balance
|
||||
t_load_balance = await trx('trx.t_d_load_balance').update({
|
||||
c_return_sap: "S-"+doc_number
|
||||
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 = '${invoice.c_invoice_no}')`)
|
||||
|
||||
if(posting) {
|
||||
await writePaynentHistory(invoice, "SUCCESSFULLY", trx)
|
||||
} else {
|
||||
await writePaynentHistory(invoice, "SUCCESS TO RETRY SAP", trx)
|
||||
}
|
||||
|
||||
}else{
|
||||
// update posting et
|
||||
@@ -160,19 +178,17 @@ const setReturnSAP = async (invoice, resSAP, trx) => {
|
||||
})
|
||||
|
||||
// update invoice
|
||||
t_invoice = await trx('payment.t_d_invoice').update({
|
||||
c_return_sap: resSAP.message ? resSAP.message : null
|
||||
}, ['c_invoice_no','c_return_sap','m_amount'])
|
||||
t_invoice = await trx('payment.t_d_invoice').select(['c_invoice_no','c_return_sap','m_amount'])
|
||||
.where({
|
||||
c_invoice_no: invoice.c_invoice_no
|
||||
});
|
||||
|
||||
// update load balance
|
||||
t_load_balance = await trx('trx.t_d_load_balance').update({
|
||||
c_return_sap: resSAP.message ? resSAP.message : null
|
||||
}, ['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 = '${invoice.c_invoice_no}')`)
|
||||
|
||||
|
||||
if(posting) {
|
||||
await writePaynentHistory(invoice, `SUCCESS WITH SAP ERR: ${resSAP.message}`, trx)
|
||||
} else {
|
||||
await writePaynentHistory(invoice, `FAIL TO RETRY WITH SAP ERR: ${resSAP.message}`, trx)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -187,7 +203,7 @@ const setReturnSAP = async (invoice, resSAP, trx) => {
|
||||
|
||||
}
|
||||
|
||||
const writePaynentHistory = async (data, trx) => {
|
||||
const writePaynentHistory = async (data, message, trx) => {
|
||||
console.log(data)
|
||||
const result = await trx('log.t_log_invoice').insert({
|
||||
i_log_name : 102,
|
||||
@@ -196,7 +212,7 @@ const writePaynentHistory = async (data, trx) => {
|
||||
c_partner_name : data.c_partner_name,
|
||||
j_new_data : JSON.stringify(data),
|
||||
d_payment_date: trx.raw('NOW()'),
|
||||
c_note : 'SUCCESSFULLY',
|
||||
c_note : message,
|
||||
c_status : 'S',
|
||||
d_created : trx.raw('NOW()'),
|
||||
m_amount : data.amount,
|
||||
|
||||
+3
-3
@@ -39,10 +39,10 @@ module.exports = {
|
||||
production: {
|
||||
client: "pg",
|
||||
connection: {
|
||||
host : '10.1.201.95',
|
||||
host : '10.1.201.75',
|
||||
database: "postgres",
|
||||
user: "cms",
|
||||
password: "Cm5kc1#2021",
|
||||
user: "postgres",
|
||||
password: "inhc0mmute_cms",
|
||||
},
|
||||
// connection: process.env.DB_URL,
|
||||
pool: {
|
||||
|
||||
Reference in New Issue
Block a user