fix bug salary / nopaid
This commit is contained in:
parent
566b4db692
commit
dd06c1f71f
5 changed files with 13 additions and 18 deletions
|
|
@ -15,15 +15,14 @@ import {
|
|||
import { AppDataSource } from "../database/data-source";
|
||||
import {
|
||||
CreateProfileSalaryEmployee,
|
||||
ProfileSalary,
|
||||
UpdateProfileSalary,
|
||||
} from "../entities/ProfileSalary";
|
||||
ProfileSalaryEmployee,
|
||||
UpdateProfileSalaryEmployee,
|
||||
} from "../entities/ProfileSalaryEmployee";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { LessThan, MoreThan } from "typeorm";
|
||||
|
||||
|
|
@ -32,13 +31,13 @@ import { LessThan, MoreThan } from "typeorm";
|
|||
@Security("bearerAuth")
|
||||
export class ProfileSalaryEmployeeController extends Controller {
|
||||
private profileRepo = AppDataSource.getRepository(ProfileEmployee);
|
||||
private salaryRepo = AppDataSource.getRepository(ProfileSalary);
|
||||
private salaryRepo = AppDataSource.getRepository(ProfileSalaryEmployee);
|
||||
private salaryHistoryRepo = AppDataSource.getRepository(ProfileSalaryHistory);
|
||||
|
||||
@Get("{profileId}")
|
||||
public async getSalary(@Path() profileId: string) {
|
||||
const record = await this.salaryRepo.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
where: { profileId: profileId },
|
||||
order: { order: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
|
|
@ -57,22 +56,22 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
@Request() req: RequestWithUser,
|
||||
@Body() body: CreateProfileSalaryEmployee,
|
||||
) {
|
||||
if (!body.profileEmployeeId) {
|
||||
if (!body.profileId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||
}
|
||||
|
||||
const profile = await this.profileRepo.findOneBy({ id: body.profileEmployeeId });
|
||||
const profile = await this.profileRepo.findOneBy({ id: body.profileId });
|
||||
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
|
||||
const dest_item = await this.salaryRepo.findOne({
|
||||
where: { profileId: body.profileEmployeeId },
|
||||
where: { profileId: body.profileId },
|
||||
order: { order: "DESC" },
|
||||
});
|
||||
|
||||
const data = new ProfileSalary();
|
||||
const data = new ProfileSalaryEmployee();
|
||||
|
||||
const meta = {
|
||||
order: dest_item == null ? 1 : dest_item.order + 1,
|
||||
|
|
@ -92,7 +91,7 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
@Patch("{salaryId}")
|
||||
public async editSalary(
|
||||
@Request() req: RequestWithUser,
|
||||
@Body() body: UpdateProfileSalary,
|
||||
@Body() body: UpdateProfileSalaryEmployee,
|
||||
@Path() salaryId: string,
|
||||
) {
|
||||
const record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue