// import { Injectable } from "@nestjs/common"; // import { Result } from "src/common/errors/result-error.factory"; // import { PrismaService } from "src/prisma/prisma.service"; // @Injectable() // export class BankedHoursService { // constructor(private readonly prisma: PrismaService) { } // //manage shifts with bank_code.type BANKING // bankingHours = async (employee_id: number, hours: number): Promise> => { // if (hours <= 0) return { success: false, error: 'INVALID_BANKING_HOURS' }; // try { // const result = await this.prisma.$transaction(async (tx) => { // const employee = await this.prisma.employees.findUnique({ // where: { id: employee_id }, // select: { // id: true, // paid_time_off: { // select: { // banked_hours: true // }, // }, // }, // }); // if (!employee) { // return { success: false, error: 'EMPLOYEE_NOT_FOUND' } as Result // } // if (!employee.paid_time_off) { // return { success: false, error: 'VACATION_HOURS_BANK_NOT_FOUND' } as Result // } // const new_balance = await tx.paidTimeOff.update({ // where: { employee_id: employee.id }, // data: { // banked_hours: { increment: hours }, // }, // select: { // banked_hours: true, // }, // }); // return { success: true, data: new_balance }; // }); // return result; // } catch (error) { // return { success: false, error: 'INVALID_BANKING_SHIFT' }; // } // } // //manage shifts with bank_code.type WITHDRAW_BANKED // withdrawBankedHours = async (employee_id: number, asked_hours: number): Promise> => { // if (asked_hours <= 0) return { success: false, error: 'INVALID_WITHDRAW_BANKED' }; // } // }