using GB5Shared.DTO.Framework.Criteria;
using GB5Shared.DTO.Framework.Login;
using GB5Shared.ResponseStandard;
using PayRollDAL.DTO.Employee;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unisoft.PayrollDAL.Employee;
namespace PayRollDAL.CustomeCode.Employee
{
public interface IEmployeeDAL
{
///
/// Retrieves employee details by employee ID and language ID.
///
/// Unique identifier of the employee.
/// Language ID used to fetch localized data.
/// User login context for authorization and auditing.
/// A JSON string containing employee details.
/// Thrown if an error occurs while fetching employee data.
Task GetEmployee(int EmployeeId, string LanguageId, LoginDTO LoginDTO);
///
/// Inserts a new employee record into the database.
///
/// Data transfer object containing employee details.
/// User login context for authorization and auditing.
/// The number of rows affected.
/// Thrown when the employee save operation fails.
Task SaveEmployee(EmployeeDTO employeeDTO, LoginDTO LoginDTO);
///
/// Counts the number of translation employee (TRM Employee) records for the given employee and language.
///
/// Data transfer object containing employee details.
/// Language ID for which the count is required.
/// User login context for authorization and auditing.
/// The total count of TRM Employee records.
/// Thrown if counting translation employees fails.
Task CountTRMEmployee(EmployeeDTO EmployeeDTO, string LanguageId, LoginDTO LoginDTO);
///
/// Updates an existing employee record in the database.
///
/// Data transfer object containing updated employee details.
/// User login context for authorization and auditing.
/// The number of rows affected.
/// Thrown when the employee update operation fails.
Task UpdateEmployee(EmployeeDTO employeeDTO, LoginDTO LoginDTO);
///
/// Retrieves the future version of an employee record for version control validation.
///
/// Unique identifier of the employee.
/// The version effective start date to validate.
/// User login context for authorization and auditing.
///
/// An representing the next version of the employee, if any; otherwise null.
///
/// Thrown when fetching the future version fails.
Task GetFutureEmployeeVersionAsync(int employeeId, DateTime versionFrom, LoginDTO loginDTO);
Task SaveOrUpdateEmployeeESIAsync(EmployeeDTO employee, LoginDTO loginDTO);
Task SaveOrUpdateEmployeePFAsync(EmployeeDTO employee, LoginDTO loginDTO);
Task CloseEmployeeESIAsync(EmployeeDTO employee, LoginDTO loginDTO);
Task CloseEmployeePFAsync(EmployeeDTO employee, LoginDTO loginDTO);
Task UpdateAttendanceAfterResignationAsync(int employeeId, DateTime resignationDate, LoginDTO LoginDTO);
Task UpdateUserStatusAfterResignationAsync(int employeeId, DateTime resignationDate, LoginDTO LoginDTO);
Task UpdateEmployeeShiftPatternAsync(EmployeeShiftPatternDTO dto, LoginDTO loginDTO);
Task UpdateEmployeeShiftPatternAsync(EmployeeShiftPatternDTO dto, LoginDTO loginDTO, DbTransaction transaction, CancellationToken ct);
///
/// Deletes an employee record from the database by employee ID.
///
///
/// Unique identifier of the employee to delete.
/// User login context for authorization and auditing.
///
/// A object indicating success or failure with a descriptive message.
///
/// Thrown if an error occurs while deleting the employee.
Task> DeleteEmployee(int EmployeeId, LoginDTO LoginDTO);
Task PostTransferEmployeeAdvance(
List PostTransferEmployeeAdvanceDTOs,
LoginDTO LoginDTO);
Task GetTransferEmployeeAdvance(LoginDTO LoginDTO);
Task SaveEmployeeSecretKey(int EmployeeId, string SecretKey, LoginDTO LoginDTO);
Task<(string Json, int Total)> GetSelectListEmployee(int firstNumber, int maxResult, CriteriaDTO criteriaDTO, LoginDTO loginDTO);
///
/// Resolves an EmployeeCode to its EmployeeId — used only by the manual raw-code-entry
/// scan path (QR codes already carry EmployeeId directly). Returns -1 if not found.
///
Task GetEmployeeIdByCode(string employeeCode, LoginDTO loginDTO);
Task DeleteEmployeeAddon(int employeeId, LoginDTO loginDTO, CancellationToken ct = default);
Task UpsertEmployeeAddon(EmployeeAddon addon, LoginDTO loginDTO, CancellationToken ct = default);
///
/// Splits the calendar gap between an employee's DateOfJoining and a given separation date
/// into years/months/days. SQL-Server-only (matches GB4); other database types return zeros.
///
Task<(int SeparationYears, int SeparationMonths, int SeparationDays)> GetDifferenceFromJoiningDate(
int employeeId, DateTime separationDate, LoginDTO loginDTO);
///
/// Flat (non-recursive) tenant-wide active-employee list with reporting-chain links,
/// used by the BLL to build the org hierarchy tree. See EmployeeQB.GET_EMPLOYEE_HIERARCHY.
///
Task> GetEmployeeHierarchy(CriteriaDTO criteriaDTO, LoginDTO loginDTO, CancellationToken ct);
///
/// Fans out to the ~11 HRMS dashboard widget queries and assembles the aggregate DTO.
/// The legacy workflow-pending-approvals widget is intentionally not populated here —
/// GB5 has no live Activiti equivalent (deferred, see migration plan).
///
Task GetHRMSDashboard(CriteriaDTO criteriaDTO, LoginDTO loginDTO, CancellationToken ct);
///
/// Paged composite employee profile report: master fields + Salary/Skill/Working/
/// Experience/Qualification/Reference sub-collections (the 6 in-scope legacy sub-reports —
/// ESI/PF/Gratuity/Appointment/BioData/Form25/Induction are deferred, see migration plan).
/// Unlike the legacy GB4 version, the master list is genuinely paged via QueryPagedAsync
/// and Total reflects the real matching count.
///
Task<(List Items, int Total)> GetEmployeeProfileReport(
int firstNumber, int maxResult, CriteriaDTO criteriaDTO, LoginDTO loginDTO, CancellationToken ct);
///
/// Migrated from GB4 EmployeeDAL.EmployeePostingSelectionList — lists TPOSTINGPOSITION
/// rows for a given employee (MM posting/allocation history), with an optional
/// FromInventory variant (distinct, no daily-attendance/timesheet enrichment).
/// GB4's CrewTimesheetActivitiHistoryDTOs drilldown enrichment is not ported (see
/// EmployeePostingSelectListDTO — the property is commented out there already).
///
Task<(List Items, int Total)> EmployeePostingSelectionList(
int firstNumber, int maxResult, CriteriaDTO criteriaDTO, LoginDTO loginDTO, CancellationToken ct);
/// GB4 Employee.svc.cs GetEmployeeVsShiftPattern — employee vs. shift pattern listing.
Task<(List Items, int Total)> GetEmployeeVsShiftPattern(
int firstNumber, int maxResult, CriteriaDTO criteriaDTO, LoginDTO loginDTO, CancellationToken ct);
///
/// GB4 Employee.svc.cs "Get/Employee/Vs/ShiftPattern/Load" — EmployeeBLL.GetEmployeeVsShiftPatternNew.
/// Distinct from GetEmployeeVsShiftPattern: per-shift-pattern-day DayType/NumberofDays rows.
///
Task<(List Items, int Total)> GetEmployeeVsShiftPatternNew(
int firstNumber, int maxResult, CriteriaDTO criteriaDTO, LoginDTO loginDTO, CancellationToken ct);
/// GB4 Employee.svc.cs GetEmployeeVersionPicklist (spelling corrected from GB4's "Verison").
Task> GetEmployeeVersionPicklist(
int firstNumber, int maxResult, CriteriaDTO criteriaDTO, LoginDTO loginDTO, CancellationToken ct);
/// GB4 Employee.svc.cs LegecyBasedEmployeeInformation — recursive legacy-code chain.
Task> LegecyBasedEmployeeInformation(
int employeeId, LoginDTO loginDTO, CancellationToken ct);
/// GB4 Employee.svc.cs GetEmployeeVersionInPayProcess.
Task> GetEmployeeVersionInPayProcess(
CriteriaDTO criteriaDTO, LoginDTO loginDTO, CancellationToken ct);
/// GB4 Employee.svc.cs GetEmployeeVersion — full parity explicit-SQL replacement of GB4's NHibernate lazy load.
Task GetEmployeeVersion(int employeeVersionId, LoginDTO loginDTO, CancellationToken ct);
/// GB4 Employee.svc.cs GetDuplicateEmployee — parameterized optional-filter query.
Task> GetDuplicateEmployee(CriteriaDTO criteriaDTO, LoginDTO loginDTO, CancellationToken ct);
/// GB4 Employee.svc.cs DeleteEmployeeVersion guard/support queries + rollback update, called inside BLL transaction.
Task GetPayProcessDoneAfterEmployeeVersion(int employeeVersionId, LoginDTO loginDTO, DbTransaction tx, CancellationToken ct);
Task GetLatestVersionAfterGivenVersion(int employeeVersionId, LoginDTO loginDTO, DbTransaction tx, CancellationToken ct);
Task GetEmployeeIdFromVersion(int employeeVersionId, LoginDTO loginDTO, DbTransaction tx, CancellationToken ct);
Task DeleteEmployeeAddonVersionByVersion(int employeeVersionId, LoginDTO loginDTO, DbTransaction tx, CancellationToken ct);
Task DeleteEmployeeVersionById(int employeeVersionId, LoginDTO loginDTO, DbTransaction tx, CancellationToken ct);
Task GetEmployeeVersionLatestId(int employeeId, LoginDTO loginDTO, DbTransaction tx, CancellationToken ct);
Task RollbackEmployeeToLatestVersion(int latestEmployeeVersionId, LoginDTO loginDTO, DbTransaction tx, CancellationToken ct);
Task RollbackEmployeeAddonToLatestVersion(int latestEmployeeVersionId, LoginDTO loginDTO, DbTransaction tx, CancellationToken ct);
}
}