We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It should allow the record to be updated.
Controller and model code below:
async updateById( @param.path.number('id') id: number, @requestBody({ content: { 'application/json': { schema: getModelSchemaRef(EmployeeSalaryPackage, { partial: true }), }, }, }) employeeSalaryPackage: EmployeeSalaryPackage, ): Promise<void> { const existingSalaryPackage: EmployeeSalaryPackage = await this.employeeSalaryPackageRepository.findById(id); let effective_date: string = ''; let end_date: string | undefined = ''; if (employeeSalaryPackage.effective_date || employeeSalaryPackage.end_date) { effective_date = (employeeSalaryPackage.effective_date) ? employeeSalaryPackage.effective_date : existingSalaryPackage.effective_date; end_date = (employeeSalaryPackage.end_date) ? employeeSalaryPackage.end_date : existingSalaryPackage.end_date if (end_date && end_date < effective_date) { throw new HttpErrors.BadRequest('End date cannot be less than effective date') } const overlappingSalaryPackage = await this.employeeSalaryPackageRepository.findOverlappingPackage(existingSalaryPackage.employee_id, effective_date, end_date, id) console.log(overlappingSalaryPackage); if (overlappingSalaryPackage) { throw new HttpErrors.Conflict('Overlapping salary package exists') } } if (employeeSalaryPackage.current_package) { employeeSalaryPackage.monthly_cost = employeeSalaryPackage.current_package / 12; employeeSalaryPackage.hourly_cost = employeeSalaryPackage.monthly_cost / 160; } await this.employeeSalaryPackageRepository.replaceById(id, employeeSalaryPackage); } import { model, property } from '@loopback/repository'; import { UserModifiableEntity } from '.'; import { Currency } from '../modules/employee/currency.enum'; @model({ name: 'employee_salary_package', }) export class EmployeeSalaryPackage extends UserModifiableEntity { @property({ type: 'number', id: true, }) id?: number; @property({ type: 'number', required: true, }) employee_id: number; @property({ type: 'number', required: true, }) current_package: number; @property({ type: 'string', required: true, }) currency: Currency; @property({ type: 'string', required: true, }) effective_date: string; @property({ type: 'string', }) end_date?: string; @property({ type: 'number' }) monthly_cost: number; @property({ type: 'number' }) hourly_cost: number; constructor(data?: Partial<EmployeeSalaryPackage>) { super(data); } } export interface EmployeeSalaryPackageRelations { // describe navigational properties here } export type EmployeeSalaryPackageWithRelations = EmployeeSalaryPackage & EmployeeSalaryPackageRelations;
linux x64 10.13.0 ├── @loopback/[email protected] ├── @loopback/[email protected] ├── @loopback/[email protected] ├── @loopback/[email protected] ├── @loopback/[email protected] ├── @loopback/[email protected] ├── @loopback/[email protected] ├── @loopback/[email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] └── [email protected]
#2652 #1722
The text was updated successfully, but these errors were encountered:
My bad, I mistakenly replace the repository function from updateById to replaceById and that was causing this issue.
updateById
replaceById
Sorry, something went wrong.
No branches or pull requests
Steps to reproduce
Current Behavior
Expected Behavior
It should allow the record to be updated.
Additional information
Controller and model code below:
linux x64 10.13.0
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
Related Issues
#2652
#1722
The text was updated successfully, but these errors were encountered: