mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 17:06:28 +00:00
Add invoice History
This commit is contained in:
@@ -161,6 +161,12 @@ const _generateInvoice = async (invoiceDate, uniqueCode) => {
|
||||
|
||||
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(invoice[key])}`)
|
||||
|
||||
let postingEt = await model.insertPostingEt(invoice[key], trx)
|
||||
@@ -168,10 +174,6 @@ const _generateInvoice = async (invoiceDate, uniqueCode) => {
|
||||
winston.logger.info(`SCHEDULER-FB70-${uniqueCode} success insert posting et : ${JSON.stringify(postingEt)}`)
|
||||
}
|
||||
|
||||
// write payment history
|
||||
winston.logger.info(`SCHEDULER-FB70-${uniqueCode} insert payment history et : ${JSON.stringify(invoice)}`)
|
||||
let history = await model.writePaynentHistory(invoice, trx)
|
||||
winston.logger.info(`SCHEDULER-FB70-${uniqueCode} result insert payment history et : ${JSON.stringify(history)}`)
|
||||
|
||||
})
|
||||
|
||||
@@ -209,11 +211,11 @@ const _generateInvoice = async (invoiceDate, uniqueCode) => {
|
||||
|
||||
let xmlRequest = helper.generateXMLRequest('ZFMCMS_FI_001', xmlHeader, xmlItem)
|
||||
|
||||
winston.logger.info(`SCHEDULER-FB70-${uniqueCode} REQUEST posting ${invoice[key].c_invoice_no} to SAP : ${xmlRequest}`);
|
||||
winston.logger.debug(`SCHEDULER-FB70-${uniqueCode} REQUEST posting ${invoice[key].c_invoice_no} to SAP : ${xmlRequest}`);
|
||||
|
||||
const response = await helper.postingSAP(url, xmlRequest)
|
||||
|
||||
winston.logger.info(`SCHEDULER-FB70-${uniqueCode} RESPONSE posting ${invoice[key].c_invoice_no} to SAP : ${JSON.stringify(response)}`);
|
||||
winston.logger.debug(`SCHEDULER-FB70-${uniqueCode} RESPONSE posting ${invoice[key].c_invoice_no} to SAP : ${JSON.stringify(response)}`);
|
||||
|
||||
// new transaction
|
||||
await knex.transaction(async trx => {
|
||||
|
||||
@@ -126,18 +126,21 @@ const setReturnSAP = async (invoice, resSAP, trx) => {
|
||||
}
|
||||
|
||||
const writePaynentHistory = async (data, trx) => {
|
||||
|
||||
const result = await trx('public.t_log_invoice').insert({
|
||||
console.log(data)
|
||||
const result = await trx('log.t_log_invoice').insert({
|
||||
i_log_name : 27,
|
||||
d_log : trx.raw('NOW()'),
|
||||
c_invoice_no : data.c_invoice_no,
|
||||
i_partner : data.i_partner,
|
||||
c_partner_name : data.c_partner_name,
|
||||
j_new_data : trx.raw(`${JSON.stringify(data)}::jsonb`),
|
||||
c_device_type : 'WEB CMS',
|
||||
j_new_data : JSON.stringify(data),
|
||||
d_payment_date: trx.raw('NOW()'),
|
||||
c_note : 'SUKSES POSTING TO INVOICE',
|
||||
c_status : 'S',
|
||||
d_created : trx.raw('NOW()')
|
||||
d_created : trx.raw('NOW()'),
|
||||
m_amount : data.amount,
|
||||
m_mdr_amount : 0,
|
||||
m_mdr_net : data.amount
|
||||
|
||||
}, ['i_log_name', 'c_note'])
|
||||
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user