package com.taf.attendance.data import com.taf.attendance.model.LeaveRequest import com.taf.attendance.model.LeaveBalance // Extension functions to convert between API models and database entities fun LeaveRequest.toEntity(): LeaveRequestEntity { return LeaveRequestEntity( id = this.id, employeeName = this.employeeName, user_id = this.user_id, leaveType = this.leaveType, startDate = this.startDate, endDate = this.endDate, reason = this.reason, status = this.status, createdAt = this.createdAt, isSynced = true ) } fun LeaveRequestEntity.toLeaveRequest(): LeaveRequest { return LeaveRequest( id = this.id, employeeName = this.employeeName, user_id = this.user_id, org_id = null, leaveType = this.leaveType, startDate = this.startDate, endDate = this.endDate, reason = this.reason, status = this.status, createdAt = this.createdAt, approvedAt = null, approvedBy = null ) } fun LeaveBalance.toEntity(): LeaveBalanceEntity { return LeaveBalanceEntity( id = this.id, user_id = this.user_id, leave_type_id = this.leave_type_id, balance = this.balance, updatedAt = this.updatedAt ) } fun LeaveBalanceEntity.toLeaveBalance(): LeaveBalance { return LeaveBalance( id = this.id, employee_id = null, user_id = this.user_id, org_id = null, leave_type_id = this.leave_type_id, balance = this.balance, updatedAt = this.updatedAt ) }