From 7ca95e17c03510de359732c641809ebfd74df0f7 Mon Sep 17 00:00:00 2001 From: tedbearr Date: Tue, 4 Jul 2023 11:15:16 +0700 Subject: [PATCH] update cron --- server/index.js | 260 ++++++++++++++++++++++++------------------------ 1 file changed, 130 insertions(+), 130 deletions(-) diff --git a/server/index.js b/server/index.js index 9193ef4..cd24cef 100644 --- a/server/index.js +++ b/server/index.js @@ -101,150 +101,150 @@ app.use('/api/', pooling); // SCHEDULER FOR GENERATE INVOICE // =================================================== -const { - _generateInvoice, - _postingInvoice, -} = require('../application/modules/invoiceonline/invoice.controller'); +// const { +// _generateInvoice, +// _postingInvoice, +// } = require('../application/modules/invoiceonline/invoice.controller'); // GENERATE + POSTING INVOICE -cron.schedule('0 1 * * *', async () => { - try { - // let ivoiceDate = moment().add(1, 'days').format("YYYY-MM-DD"); - let ivoiceDate = moment().format('YYYY-MM-DD'); - let uniqueCode = helper.getUniqueCode(); - winston.logger.debug( - `STARTING SCHEDULER-FB70 GENERATE INVOICE ${ivoiceDate} ` - ); - const generate = await _generateInvoice(ivoiceDate, uniqueCode, false); - winston.logger.debug( - `END SCHEDULER-FB70 GENERATE INVOICE ${ivoiceDate} : ${JSON.stringify( - generate - )}` - ); - const reGenerate = await _generateInvoice(ivoiceDate, uniqueCode, true); - winston.logger.debug( - `END SCHEDULER-FB70 RE-GENERATE INVOICE THAT HAVE BEEN DELETED ${ivoiceDate} : ${JSON.stringify( - generate - )}` - ); - } catch (error) { - // create log - winston.logger.error( - `500 internal server error - backend server | ${error.message}` - ); - } -}); +// cron.schedule('0 1 * * *', async () => { +// try { +// // let ivoiceDate = moment().add(1, 'days').format("YYYY-MM-DD"); +// let ivoiceDate = moment().format('YYYY-MM-DD'); +// let uniqueCode = helper.getUniqueCode(); +// winston.logger.debug( +// `STARTING SCHEDULER-FB70 GENERATE INVOICE ${ivoiceDate} ` +// ); +// const generate = await _generateInvoice(ivoiceDate, uniqueCode, false); +// winston.logger.debug( +// `END SCHEDULER-FB70 GENERATE INVOICE ${ivoiceDate} : ${JSON.stringify( +// generate +// )}` +// ); +// const reGenerate = await _generateInvoice(ivoiceDate, uniqueCode, true); +// winston.logger.debug( +// `END SCHEDULER-FB70 RE-GENERATE INVOICE THAT HAVE BEEN DELETED ${ivoiceDate} : ${JSON.stringify( +// generate +// )}` +// ); +// } catch (error) { +// // create log +// winston.logger.error( +// `500 internal server error - backend server | ${error.message}` +// ); +// } +// }); // RE-TRY POSTING -cron.schedule('0 7 * * *', async () => { - try { - let uniqueCode = helper.getUniqueCode(); - winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`); - const posting = await _postingInvoice(uniqueCode); - winston.logger.debug( - `END SCHEDULER-FB70 RE-TRY POSTING INVOICE : ${JSON.stringify(posting)}` - ); - } catch (error) { - // create log - winston.logger.error( - `500 internal server error - backend server | ${error.message}` - ); - } -}); +// cron.schedule('0 7 * * *', async () => { +// try { +// let uniqueCode = helper.getUniqueCode(); +// winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`); +// const posting = await _postingInvoice(uniqueCode); +// winston.logger.debug( +// `END SCHEDULER-FB70 RE-TRY POSTING INVOICE : ${JSON.stringify(posting)}` +// ); +// } catch (error) { +// // create log +// winston.logger.error( +// `500 internal server error - backend server | ${error.message}` +// ); +// } +// }); -cron.schedule('0 12 * * *', async () => { - try { - let uniqueCode = helper.getUniqueCode(); - winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`); - const posting = await _postingInvoice(uniqueCode); - winston.logger.debug( - `END SCHEDULER-FB70 RE-TRY POSTING INVOICE : ${JSON.stringify(posting)}` - ); - } catch (error) { - // create log - winston.logger.error( - `500 internal server error - backend server | ${error.message}` - ); - } -}); +// cron.schedule('0 12 * * *', async () => { +// try { +// let uniqueCode = helper.getUniqueCode(); +// winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`); +// const posting = await _postingInvoice(uniqueCode); +// winston.logger.debug( +// `END SCHEDULER-FB70 RE-TRY POSTING INVOICE : ${JSON.stringify(posting)}` +// ); +// } catch (error) { +// // create log +// winston.logger.error( +// `500 internal server error - backend server | ${error.message}` +// ); +// } +// }); -cron.schedule('0 17 * * *', async () => { - try { - let uniqueCode = helper.getUniqueCode(); - winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`); - const posting = await _postingInvoice(uniqueCode); - winston.logger.debug( - `END SCHEDULER-FB70 RE-TRY POSTING INVOICE : ${JSON.stringify(posting)}` - ); - } catch (error) { - // create log - winston.logger.error( - `500 internal server error - backend server | ${error.message}` - ); - } -}); +// cron.schedule('0 17 * * *', async () => { +// try { +// let uniqueCode = helper.getUniqueCode(); +// winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`); +// const posting = await _postingInvoice(uniqueCode); +// winston.logger.debug( +// `END SCHEDULER-FB70 RE-TRY POSTING INVOICE : ${JSON.stringify(posting)}` +// ); +// } catch (error) { +// // create log +// winston.logger.error( +// `500 internal server error - backend server | ${error.message}` +// ); +// } +// }); // =================================================== // SCHEDULER FOR GENERATE INVOICE // =================================================== // cash in -const { - _generateCashIn, -} = require('../application/modules/cashin/cahsin.controller'); +// const { +// _generateCashIn, +// } = require('../application/modules/cashin/cahsin.controller'); -cron.schedule('30 7 * * *', async () => { - try { - let uniqueCode = helper.getUniqueCode(); - winston.logger.info( - `STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}` - ); - const posting = await _generateCashIn(uniqueCode); - winston.logger.info( - `END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}` - ); - } catch (error) { - // create log - winston.logger.error( - `500 SCHEDULER-FB70 internal server error - backend server | ${error.message}` - ); - } -}); +// cron.schedule('30 7 * * *', async () => { +// try { +// let uniqueCode = helper.getUniqueCode(); +// winston.logger.info( +// `STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}` +// ); +// const posting = await _generateCashIn(uniqueCode); +// winston.logger.info( +// `END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}` +// ); +// } catch (error) { +// // create log +// winston.logger.error( +// `500 SCHEDULER-FB70 internal server error - backend server | ${error.message}` +// ); +// } +// }); -cron.schedule('30 12 * * *', async () => { - try { - let uniqueCode = helper.getUniqueCode(); - winston.logger.info( - `STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}` - ); - const posting = await _generateCashIn(uniqueCode); - winston.logger.info( - `END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}` - ); - } catch (error) { - // create log - winston.logger.error( - `500 SCHEDULER-FB70 internal server error - backend server | ${error.message}` - ); - } -}); +// cron.schedule('30 12 * * *', async () => { +// try { +// let uniqueCode = helper.getUniqueCode(); +// winston.logger.info( +// `STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}` +// ); +// const posting = await _generateCashIn(uniqueCode); +// winston.logger.info( +// `END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}` +// ); +// } catch (error) { +// // create log +// winston.logger.error( +// `500 SCHEDULER-FB70 internal server error - backend server | ${error.message}` +// ); +// } +// }); -cron.schedule('30 17 * * *', async () => { - try { - let uniqueCode = helper.getUniqueCode(); - winston.logger.info( - `STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}` - ); - const posting = await _generateCashIn(uniqueCode); - winston.logger.info( - `END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}` - ); - } catch (error) { - // create log - winston.logger.error( - `500 SCHEDULER-FB70 internal server error - backend server | ${error.message}` - ); - } -}); +// cron.schedule('30 17 * * *', async () => { +// try { +// let uniqueCode = helper.getUniqueCode(); +// winston.logger.info( +// `STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}` +// ); +// const posting = await _generateCashIn(uniqueCode); +// winston.logger.info( +// `END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}` +// ); +// } catch (error) { +// // create log +// winston.logger.error( +// `500 SCHEDULER-FB70 internal server error - backend server | ${error.message}` +// ); +// } +// }); // }