Compare commits

...

2 Commits

2 changed files with 34 additions and 9 deletions

View File

@ -62,13 +62,15 @@ export const createContract = async (ctx: any) => {
);
// 2. Insert the brand new active contract
const [result] = await connection.execute(
`INSERT INTO contracts (employee_id, department_id, job_id, date_joining, probation_days, status, salary_structure_id)
VALUES (?, ?, ?, ?, ?, ?, ?)`,
const [result] = await connection.execute(
`INSERT INTO contracts (employee_id, department_id, job_id, work_email, reporting_to_id, date_joining, probation_days, status, salary_structure_id)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
[
data.employeeId,
data.departmentId,
data.jobId,
data.workEmail, // <-- Added
data.reportingToId, // <-- Added
data.dateJoining,
data.probationDays,
'ACTIVE',

View File

@ -279,20 +279,43 @@ export const updateEmployee = async (ctx: any) => {
],
);
// await connection.execute(
// `UPDATE addresses
// SET door_number = ?, landmark = ?, address_line = ?, pincode = ?, district = ?, state = ?
// WHERE partner_id = ? AND address_type = ?`,
// [
// data.address.doorNumber,
// data.address.landmark,
// data.address.line,
// data.address.pincode,
// data.address.district,
// data.address.state,
// partnerId,
// data.address.type,
// ],
// );
// Upsert Address (Fixes the missing address bug)
await connection.execute(
`UPDATE addresses
SET door_number = ?, landmark = ?, address_line = ?, pincode = ?, district = ?, state = ?
WHERE partner_id = ? AND address_type = ?`,
`INSERT INTO addresses (partner_id, address_type, door_number, landmark, address_line, pincode, district, state)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE
door_number = VALUES(door_number),
landmark = VALUES(landmark),
address_line = VALUES(address_line),
pincode = VALUES(pincode),
district = VALUES(district),
state = VALUES(state)`,
[
partnerId,
data.address.type,
data.address.doorNumber,
data.address.landmark,
data.address.line,
data.address.pincode,
data.address.district,
data.address.state,
partnerId,
data.address.type,
],
]
);
await connection.commit();