Professional Documents
Culture Documents
[SP_PRESENT_OT_CALCULATION_DATA_INSERT_SHIFT_WISE]
@emp_id numeric
,@Company_id numeric
,@For_Date datetime
,@Working_Sec numeric
,@OT_Sec numeric
,@Min_Shift_Sec numeric = 0
,@shift_sec numeric
,@strHolidayDate varchar(500)
,@strWeekoffDate varchar(500)
,@varWagesType varchar(10) ='Daily'
,@Is_OT varchar(1) = 'Y'
,@Is_Break varchar(1) = 'N'
,@Break_Dur_Sec numeric = 0
,@Branch_ID numeric = null
,@Grade_Id numeric = null
,@Emp_Type_ID numeric = null
,@Dept_Id numeric = null
,@Desig_Id numeric = null
,@shift_ID numeric
,@OT_Limit_Sec numeric = 0
,@varHalf_WeekDay_Date varchar(50)
,@Is_Half_day Tinyint
,@Half_Dur_Sec numeric
,@Shift_End_Time varchar(10)
AS
Set Nocount on
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SET ARITHABORT ON
Declare @Count_Half numeric
declare @Total_Working_Sec numeric
Declare @Min_Working_Sec numeric
Declare @Holiday_Work_Sec numeric
Declare @Weekoff_Work_sec numeric
set @Count_Half = 0
set @Min_Working_Sec = 0 --
set @H_Ex_OT = 0
set @H_Ex_OT_SEC = 0
set @StrHalfDay = ''
set @AB_Count = 0
set @Old_working_Sec = 0
set @Temp_working_sec = 0
set @Old_Ot_Sec = 0
set @P_Day = 0
set @Half_Day = 0
set @Next_day_Work_Sec = 0
set @Old_Holiday_Work_Sec = 0
set @Fix_hours_sec = 0
set @OT_Exception_Time = '00:00'
set @Holiday_Work_Sec = 0
set @WeekOff_Work_Sec = 0
if @OT_Sec < 0
set @Working_Sec =
@Working_Sec + ( @OT_Sec * -1)
end
else if exists(select OT_Applicable from
Shift_Master_Detail where @Total_Working_Sec >=( From_hour * 3600) and
@Total_Working_Sec <= ( To_Hour * 3600 )
and
shift_ID = @shift_ID and Fix_OT_hours = 0 and Minimum_Hour =0 ) and @Is_OT
='Y'
begin
if
@is_Break = 'Y' and @Working_Sec > @Break_Dur_Sec
begin
,@working_sec = @working_sec -
( @Total_Working_Sec - @shift_sec + @Break_Dur_Sec )
from Shift_MasteR_Detail
end
else
begin
,@working_sec = @working_sec -
( @Total_Working_Sec - @shift_sec )
from Shift_MasteR_Detail
end
end
*/
--New for OT calc after shift end time Hasmukh 140610
--select @for_date
select top 1 @P_Day = Calculate_Days
,@Min_Shift_Sec= Minimum_Hour *3600 from Shift_MasteR_Detail
Where
@Total_Working_Sec >=( From_hour * 3600) and @Total_Working_Sec <= ( To_Hour *
3600 )
and shift_ID =
@shift_ID
select top 1
@OT_Sec = Case When CONVERT(CHAR(8),For_Date,8) >= @OT_Exception_Time then
Datediff(s,@Shift_End_Time,@OT_Exception_Time)
else
Datediff(s,@Shift_End_Time,CONVERT(CHAR(8),For_Date,8))
End
end
if charindex(cast(@For_Date as
varchar(11)),@varHalf_WeekDay_Date,0) > 0 and @Is_Half_day = 1 And @Is_OT ='Y'
and @working_sec > 0
begin
If @working_sec > @Half_Dur_Sec
Begin
set @working_sec = @Half_Dur_Sec
End
else
Begin
set @working_sec = @Working_Sec +
@Break_Dur_Sec
End
If @Total_Working_Sec > @Half_Dur_Sec
if @temp_date<> ''
begin
if not exists(select Emp_ID from temp_working_sec where emp_id =
@emp_id and company_id = @company_id and for_date = @temp_date)
begin
insert into
temp_working_sec(emp_id,company_id,for_date,working_sec,ot_sec,Holiday_Work_Se
c,min_shift_sec,H_day,P_day,AB_Count,H_Ex_OT_Sec,shift_sec,Total_Working_Sec ,
Branch_ID,Grade_Id,Emp_type_Id,Dept_Id,Desig_Id,Weekoff_Work_sec,Shift_ID,Week
day_OT_After_Sunset)
values(@emp_id,@company_id,@temp_date,@working_sec,@ot_sec,@Holiday_Work_Sec,@
min_shift_sec,@Half_Day,@P_Day,@Ab_Count,@H_Ex_OT_Sec,@Shift_Sec,@Total_Workin
g_Sec
,@Branch_ID,@Grade_Id,@Emp_type_Id,@Dept_Id,@Desig_Id,@Weekoff_Work_sec,@shift
_ID,0)
end
else
begin
UPDATE Temp_Working_Sec
SET Working_Sec = @working_sec, OT_Sec =
@ot_sec,
Holiday_Work_Sec = @Holiday_Work_Sec,
Min_Shift_Sec = @min_shift_sec, H_Day = @Half_Day, P_Day = @P_Day, AB_Count =
@Ab_Count,
H_Ex_OT_SEC = @H_Ex_OT_Sec, SHIFT_SEC =
@Shift_Sec, Total_Working_Sec = @Total_Working_Sec, Branch_ID = @Branch_ID,
Grade_ID = @Grade_Id, Emp_Type_ID =
@Emp_type_Id, Dept_ID = @Dept_Id, Desig_Id = @Desig_Id, WeekOff_Work_Sec =
@Weekoff_Work_sec,
Shift_ID =
@shift_ID,Weekday_OT_After_Sunset = 0
where emp_id = @emp_id and company_id = @company_id
and for_date = @temp_date
end
end
set @temp_date=''
RETURN