This commit is contained in:
parent
c348a10207
commit
ec6b4a7ac8
2 changed files with 27 additions and 16 deletions
|
|
@ -98,7 +98,8 @@ async function main() {
|
|||
});
|
||||
|
||||
// Cron job for updating tenure - every day at 04:00:00
|
||||
const cronTime_Tenure = "0 0 4 * * *";
|
||||
// const cronTime_Tenure = "0 0 4 * * *";
|
||||
const cronTime_Tenure = "0 30 12 * * *"; // test 12:30
|
||||
cron.schedule(cronTime_Tenure, async () => {
|
||||
try {
|
||||
const profileSalaryController = new ProfileSalaryController();
|
||||
|
|
|
|||
|
|
@ -66,10 +66,12 @@ export class ProfileSalaryController extends Controller {
|
|||
await this.positionOfficerRepo.clear();
|
||||
const profile = await this.profileRepo.find();
|
||||
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
||||
let _currentDate = CURRENT_DATE[0].today;
|
||||
const baseCurrentDate = CURRENT_DATE[0].today;
|
||||
for await (const x of profile) {
|
||||
if (x.isLeave) {
|
||||
_currentDate = x.leaveDate ? Extension.toDateOnlyString(x.leaveDate) : _currentDate;
|
||||
// Use leave date if available and valid, otherwise use current date
|
||||
let _currentDate = baseCurrentDate;
|
||||
if (x.isLeave && x.leaveDate) {
|
||||
_currentDate = Extension.toDateOnlyString(x.leaveDate);
|
||||
}
|
||||
const position = await AppDataSource.query("CALL GetProfileSalaryPosition(?, ?)", [
|
||||
x.id,
|
||||
|
|
@ -113,11 +115,13 @@ export class ProfileSalaryController extends Controller {
|
|||
let data: any = [];
|
||||
await this.positionEmployeeRepo.clear();
|
||||
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
||||
let _currentDate = CURRENT_DATE[0].today;
|
||||
const baseCurrentDate = CURRENT_DATE[0].today;
|
||||
const profile = await this.profileEmployeeRepo.find();
|
||||
for await (const x of profile) {
|
||||
if (x?.isLeave) {
|
||||
_currentDate = x.leaveDate ? Extension.toDateOnlyString(x.leaveDate) : _currentDate;
|
||||
// Use leave date if available and valid, otherwise use current date
|
||||
let _currentDate = baseCurrentDate;
|
||||
if (x?.isLeave && x.leaveDate) {
|
||||
_currentDate = Extension.toDateOnlyString(x.leaveDate);
|
||||
}
|
||||
const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?, ?)", [
|
||||
x.id,
|
||||
|
|
@ -162,10 +166,12 @@ export class ProfileSalaryController extends Controller {
|
|||
await this.levelOfficerRepo.clear();
|
||||
const profile = await this.profileRepo.find({ relations: ["posLevel", "posType"] });
|
||||
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
||||
let _currentDate = CURRENT_DATE[0].today;
|
||||
const baseCurrentDate = CURRENT_DATE[0].today;
|
||||
for await (const x of profile) {
|
||||
if (x?.isLeave) {
|
||||
_currentDate = x.leaveDate ? Extension.toDateOnlyString(x.leaveDate) : _currentDate;
|
||||
// Use leave date if available and valid, otherwise use current date
|
||||
let _currentDate = baseCurrentDate;
|
||||
if (x?.isLeave && x.leaveDate) {
|
||||
_currentDate = Extension.toDateOnlyString(x.leaveDate);
|
||||
}
|
||||
const positionLevel = await AppDataSource.query("CALL GetProfileSalaryLevel(?, ?)", [
|
||||
x.id,
|
||||
|
|
@ -220,10 +226,12 @@ export class ProfileSalaryController extends Controller {
|
|||
await this.levelEmployeeRepo.clear();
|
||||
const profile = await this.profileEmployeeRepo.find({ relations: ["posLevel", "posType"] });
|
||||
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
||||
let _currentDate = CURRENT_DATE[0].today;
|
||||
const baseCurrentDate = CURRENT_DATE[0].today;
|
||||
for await (const x of profile) {
|
||||
if (x?.isLeave) {
|
||||
_currentDate = x.leaveDate ? Extension.toDateOnlyString(x.leaveDate) : _currentDate;
|
||||
// Use leave date if available and valid, otherwise use current date
|
||||
let _currentDate = baseCurrentDate;
|
||||
if (x?.isLeave && x.leaveDate) {
|
||||
_currentDate = Extension.toDateOnlyString(x.leaveDate);
|
||||
}
|
||||
const positionLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?, ?)", [
|
||||
x.id,
|
||||
|
|
@ -286,10 +294,12 @@ export class ProfileSalaryController extends Controller {
|
|||
},
|
||||
});
|
||||
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
||||
let _currentDate = CURRENT_DATE[0].today;
|
||||
const baseCurrentDate = CURRENT_DATE[0].today;
|
||||
for await (const x of profile) {
|
||||
if (x?.isLeave) {
|
||||
_currentDate = x.leaveDate ? Extension.toDateOnlyString(x.leaveDate) : _currentDate;
|
||||
// Use leave date if available and valid, otherwise use current date
|
||||
let _currentDate = baseCurrentDate;
|
||||
if (x?.isLeave && x.leaveDate) {
|
||||
_currentDate = Extension.toDateOnlyString(x.leaveDate);
|
||||
}
|
||||
const position = await this.positionRepo.findOne({
|
||||
where: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue