Project

General

Profile

Feature #3178 » GenerateAbsenQuotaYear.txt

shofwan shiddiq, 11/12/2024 02:48 PM

 
1
ALTER PROCEDURE GenerateAbsenQuotaYear
2
AS
3

    
4

    
5
DECLARE @AbsenceQuotaType VARCHAR (10)='1000'
6
DECLARE  @Year VARCHAR (4)=dbo.fn_formatdatetime(GETDATE(), 'yyyy')
7
DECLARE @CreateDate VARCHAR (50)=CONVERT(VARCHAR, GETDATE(), 112) + REPLACE(CONVERT(VARCHAR, GETDATE(), 108), ':', '')
8
DECLARE @OriginalQuota INT = 12
9
DECLARE @RemainQuota INT = 12
10
DECLARE @CreateBy VARCHAR (100) = 'minovais'
11
DECLARE @GenerateType VARCHAR = '1'
12

    
13
select distinct
14
	@Year+'0101' AS StartDate
15
	,@Year+'1231' AS EndDate
16
	,EmployeeID
17
	,@AbsenceQuotaType AS AbsenceQuotaType
18
	,1 AS Sequence
19
	,@Year+'0101' AS StartDeduction
20
	,@Year+'1231' AS EndDeduction
21
	,@OriginalQuota AS OriginalQuota
22
	,@RemainQuota AS RemainQuota
23
	,'' as PreviousQuota
24
	,'' as ExpiredQuota
25
	,'Generate Auto' AS Notes
26
	,@CreateBy AS CreateBy
27
	,@CreateDate AS CreateDate
28
	,@CreateBy AS ChangeBy
29
	,@CreateDate AS ChangeDate
30
	into #Result
31
	from PHRPA0002 where EmployeeStatus='01' and EndDate='99991231'
32

    
33
IF @GenerateType = '0'
34
BEGIN
35
	select * from #Result
36
END
37

    
38
IF @GenerateType ='1'
39
BEGIN
40
	delete from PHRPA0017 where left(StartDate,4) = @Year
41
	insert into PHRPA0017  select * from #Result;
42
	select * from #Result
43
END
44

    
45
drop table #Result
(1-1/2)