update cron

This commit is contained in:
tedbearr
2023-07-04 11:15:16 +07:00
parent b07e9eda89
commit 7ca95e17c0
+130 -130
View File
@@ -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}`
// );
// }
// });
// }