fix calculate
This commit is contained in:
parent
c348a10207
commit
2065801791
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
|
// 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 () => {
|
cron.schedule(cronTime_Tenure, async () => {
|
||||||
try {
|
try {
|
||||||
const profileSalaryController = new ProfileSalaryController();
|
const profileSalaryController = new ProfileSalaryController();
|
||||||
|
|
|
||||||
|
|
@ -66,10 +66,12 @@ export class ProfileSalaryController extends Controller {
|
||||||
await this.positionOfficerRepo.clear();
|
await this.positionOfficerRepo.clear();
|
||||||
const profile = await this.profileRepo.find();
|
const profile = await this.profileRepo.find();
|
||||||
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
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) {
|
for await (const x of profile) {
|
||||||
if (x.isLeave) {
|
// Use leave date if available and valid, otherwise use current date
|
||||||
_currentDate = x.leaveDate ? Extension.toDateOnlyString(x.leaveDate) : _currentDate;
|
let _currentDate = baseCurrentDate;
|
||||||
|
if (x.isLeave && x.leaveDate) {
|
||||||
|
_currentDate = Extension.toDateOnlyString(x.leaveDate);
|
||||||
}
|
}
|
||||||
const position = await AppDataSource.query("CALL GetProfileSalaryPosition(?, ?)", [
|
const position = await AppDataSource.query("CALL GetProfileSalaryPosition(?, ?)", [
|
||||||
x.id,
|
x.id,
|
||||||
|
|
@ -113,11 +115,13 @@ export class ProfileSalaryController extends Controller {
|
||||||
let data: any = [];
|
let data: any = [];
|
||||||
await this.positionEmployeeRepo.clear();
|
await this.positionEmployeeRepo.clear();
|
||||||
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
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();
|
const profile = await this.profileEmployeeRepo.find();
|
||||||
for await (const x of profile) {
|
for await (const x of profile) {
|
||||||
if (x?.isLeave) {
|
// Use leave date if available and valid, otherwise use current date
|
||||||
_currentDate = x.leaveDate ? Extension.toDateOnlyString(x.leaveDate) : _currentDate;
|
let _currentDate = baseCurrentDate;
|
||||||
|
if (x?.isLeave && x.leaveDate) {
|
||||||
|
_currentDate = Extension.toDateOnlyString(x.leaveDate);
|
||||||
}
|
}
|
||||||
const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?, ?)", [
|
const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?, ?)", [
|
||||||
x.id,
|
x.id,
|
||||||
|
|
@ -162,10 +166,12 @@ export class ProfileSalaryController extends Controller {
|
||||||
await this.levelOfficerRepo.clear();
|
await this.levelOfficerRepo.clear();
|
||||||
const profile = await this.profileRepo.find({ relations: ["posLevel", "posType"] });
|
const profile = await this.profileRepo.find({ relations: ["posLevel", "posType"] });
|
||||||
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
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) {
|
for await (const x of profile) {
|
||||||
if (x?.isLeave) {
|
// Use leave date if available and valid, otherwise use current date
|
||||||
_currentDate = x.leaveDate ? Extension.toDateOnlyString(x.leaveDate) : _currentDate;
|
let _currentDate = baseCurrentDate;
|
||||||
|
if (x?.isLeave && x.leaveDate) {
|
||||||
|
_currentDate = Extension.toDateOnlyString(x.leaveDate);
|
||||||
}
|
}
|
||||||
const positionLevel = await AppDataSource.query("CALL GetProfileSalaryLevel(?, ?)", [
|
const positionLevel = await AppDataSource.query("CALL GetProfileSalaryLevel(?, ?)", [
|
||||||
x.id,
|
x.id,
|
||||||
|
|
@ -220,10 +226,12 @@ export class ProfileSalaryController extends Controller {
|
||||||
await this.levelEmployeeRepo.clear();
|
await this.levelEmployeeRepo.clear();
|
||||||
const profile = await this.profileEmployeeRepo.find({ relations: ["posLevel", "posType"] });
|
const profile = await this.profileEmployeeRepo.find({ relations: ["posLevel", "posType"] });
|
||||||
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
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) {
|
for await (const x of profile) {
|
||||||
if (x?.isLeave) {
|
// Use leave date if available and valid, otherwise use current date
|
||||||
_currentDate = x.leaveDate ? Extension.toDateOnlyString(x.leaveDate) : _currentDate;
|
let _currentDate = baseCurrentDate;
|
||||||
|
if (x?.isLeave && x.leaveDate) {
|
||||||
|
_currentDate = Extension.toDateOnlyString(x.leaveDate);
|
||||||
}
|
}
|
||||||
const positionLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?, ?)", [
|
const positionLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?, ?)", [
|
||||||
x.id,
|
x.id,
|
||||||
|
|
@ -286,10 +294,12 @@ export class ProfileSalaryController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
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) {
|
for await (const x of profile) {
|
||||||
if (x?.isLeave) {
|
// Use leave date if available and valid, otherwise use current date
|
||||||
_currentDate = x.leaveDate ? Extension.toDateOnlyString(x.leaveDate) : _currentDate;
|
let _currentDate = baseCurrentDate;
|
||||||
|
if (x?.isLeave && x.leaveDate) {
|
||||||
|
_currentDate = Extension.toDateOnlyString(x.leaveDate);
|
||||||
}
|
}
|
||||||
const position = await this.positionRepo.findOne({
|
const position = await this.positionRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue