Project

General

Profile

Feature #1371 » PHRBUDGETTRANSPAYROLL_20220707.sql

Tri Rizqiaty, 07/21/2022 02:51 PM

 
1
??USE [MinovaES_Bank_Kalteng_Dev]
2

3
GO
4

5
/****** Object:  StoredProcedure [dbo].[PHRBUDGETTRANSPAYROLL]    Script Date: 07/07/2022 11.39.51 ******/
6

7
SET ANSI_NULLS ON
8

9
GO
10

11
SET QUOTED_IDENTIFIER ON
12

13
GO
14

15
ALTER PROCEDURE [dbo].[PHRBUDGETTRANSPAYROLL]
16

17
(
18

19
	@EmployeeID VARCHAR(20)
20

21
	,@StartDate VARCHAR(20)
22

23
	,@EndDate VARCHAR(20)
24

25
	,@now VARCHAR(20)
26

27
	,@WageType VARCHAR(20)
28

29
)
30

31
AS
32

33

34

35
--DECLARE @EmployeeID VARCHAR(20) = '10000192' ---- I1, I2 BBGProd 1438 - 00000276 - 2020 ;  I3 TPIDev 1442 - 00000474 - 2021; BKTDev 103 - 10000164 - 2021; BKTDev 103 - 10000192 - 2023
36

37
--DECLARE @StartDate VARCHAR(20) = '20230101' 
38

39
--DECLARE @EndDate VARCHAR(20) = '20231231'
40

41
--DECLARE @now  VARCHAR(20) = '20220616'
42

43
--DECLARE @WageType VARCHAR(20) = 'MT'
44

45

46

47
DECLARE @StartDateLast VARCHAR(20) = CONVERT(NVARCHAR(8), DATEADD(YEAR, -1, @StartDate), 112)
48

49
DECLARE @EndDateLast VARCHAR(20) = CONVERT(NVARCHAR(8), DATEADD(YEAR, -1, @EndDate), 112)
50

51
DECLARE @RunPeriodYear VARCHAR(20) = LEFT(@EndDateLast,4)
52

53
DECLARE @RunPeriodMonth VARCHAR(20) = SUBSTRING(@EndDateLast,5,2)
54

55

56

57
DECLARE @TWTPayroll TABLE
58

59
(
60

61
	EmployeeID VARCHAR(20)
62

63
	,WageType VARCHAR(20)
64

65
	,Number DECIMAL(22,0)
66

67
	,Amount DECIMAL(22,2)
68

69
)
70

71

72

73
--DECLARE @TWTResult TABLE
74

75
--(
76

77
--	EmployeeID VARCHAR(20)
78

79
--	,WageType VARCHAR(20)
80

81
--	,Number DECIMAL(22,0)
82

83
--	,Amount DECIMAL(22,2)
84

85
--	,Valuation VARCHAR(20)
86

87
--)
88

89

90

91
INSERT INTO @TWTPayroll
92

93
SELECT DISTINCT tr301.EmployeeID ,tr301.WageType ,tr301.Number
94

95
				,CONVERT(DECIMAL(22,2),SUM(CAST(REPLACE(ISNULL(dbo.GetPEN(tr301.Amount), '0'), ',', '.') AS DECIMAL(22,0))/12)) AS Amount
96

97
FROM dbo.PHRPYTR0301 AS tr301
98

99
WHERE (tr301.EmployeeID = @EmployeeID OR @EmployeeID = '')
100

101
	AND (tr301.RunPeriodYear = tr301.PayPeriodYear) AND (tr301.RunPeriodMonth = tr301.PayPeriodMonth)
102

103
	AND tr301.RunPeriodYear = @RunPeriodYear
104

105
	AND tr301.WageType = @WageType
106

107
GROUP BY tr301.EmployeeID ,tr301.WageType ,tr301.Number
108

109

110

111
SELECT DISTINCT TWTPayroll.* ,'D' AS Valuation
112

113
FROM @TWTPayroll AS TWTPayroll
114

115
LEFT JOIN dbo.PHRPYCU0300 AS cu300
116

117
	ON TWTPayroll.WageType = cu300.WageTypeDefinition
118

119
	                         
(7-7/9)