Compare commits

...

2 Commits

2 changed files with 34 additions and 9 deletions

View File

@ -63,12 +63,14 @@ export const createContract = async (ctx: any) => {
// 2. Insert the brand new active contract // 2. Insert the brand new active contract
const [result] = await connection.execute( const [result] = await connection.execute(
`INSERT INTO contracts (employee_id, department_id, job_id, date_joining, probation_days, status, salary_structure_id) `INSERT INTO contracts (employee_id, department_id, job_id, work_email, reporting_to_id, date_joining, probation_days, status, salary_structure_id)
VALUES (?, ?, ?, ?, ?, ?, ?)`, VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
[ [
data.employeeId, data.employeeId,
data.departmentId, data.departmentId,
data.jobId, data.jobId,
data.workEmail, // <-- Added
data.reportingToId, // <-- Added
data.dateJoining, data.dateJoining,
data.probationDays, data.probationDays,
'ACTIVE', '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( await connection.execute(
`UPDATE addresses `INSERT INTO addresses (partner_id, address_type, door_number, landmark, address_line, pincode, district, state)
SET door_number = ?, landmark = ?, address_line = ?, pincode = ?, district = ?, state = ? VALUES (?, ?, ?, ?, ?, ?, ?, ?)
WHERE partner_id = ? AND address_type = ?`, 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.doorNumber,
data.address.landmark, data.address.landmark,
data.address.line, data.address.line,
data.address.pincode, data.address.pincode,
data.address.district, data.address.district,
data.address.state, data.address.state,
partnerId, ]
data.address.type,
],
); );
await connection.commit(); await connection.commit();