Project

General

Profile

Bug #1327 » PRPTCMBONUS_20220713.sql

Tri Rizqiaty, 07/20/2022 09:43 AM

 
1
??USE [MinovaES_BankKalteng_Dev]
2

3
GO
4

5
/****** Object:  StoredProcedure [dbo].[PRPTCMBONUS]    Script Date: 13/07/2022 10.13.06 ******/
6

7
SET ANSI_NULLS ON
8

9
GO
10

11
SET QUOTED_IDENTIFIER ON
12

13
GO
14

15
ALTER PROCEDURE [dbo].[PRPTCMBONUS]
16

17
(
18

19
  @CompanyID varchar(8),
20

21
  @Scenario varchar(8),
22

23
  @Year varchar(8),
24

25
  @CostCenter varchar(8),
26

27
  @Organization varchar(8),
28

29
  @EmployeeIDFrom varchar(8),
30

31
  @EmployeeIDTo varchar(8),
32

33
  @MenuID varchar(8),
34

35
  @UserID varchar(8)
36

37
)
38

39
AS
40

41

42

43
--DECLARE @Scenario VARCHAR(8)
44

45
--DECLARE @CompanyID VARCHAR(8)
46

47
--DECLARE @Year VARCHAR(8)
48

49
--DECLARE @CostCenter VARCHAR(8)
50

51
--DECLARE @Organization VARCHAR(8)
52

53
--DECLARE @EmployeeIDFrom VARCHAR(8)
54

55
--DECLARE @EmployeeIDTo VARCHAR(8)
56

57
--DECLARE @MenuID varchar(8) = 'CMR01'
58

59
--DECLARE @UserID varchar(8) = 'tri'
60

61
--SET @Scenario = '0012'
62

63
--SET @Year = '2023'
64

65
--SET @CompanyID = '1000'
66

67
--SET @CostCenter = ''
68

69
--SET @Organization = ''
70

71
--SET @EmployeeIDFrom = ''
72

73
--SET @EmployeeIDTo = ''
74

75

76

77
DECLARE @now VARCHAR(20) = dbo.fn_formatdatetime(GETDATE(), 'yyyymmdd')
78

79

80

81
DECLARE @TableResult TABLE ( EmployeeID VARCHAR(20) )
82

83
INSERT  INTO @TableResult
84

85
        EXEC dbo.GETEMPIDAUTHBYMENU @MenuID = @MenuID, -- varchar(max)
86

87
            @UserID = @UserID
88

89

90

91
SELECT DISTINCT fixcal.* 
92

93
				,pa1.FullName
94

95
				,pos.ObjectDescription AS PosDesc
96

97
				,job.ObjectDescription AS JobDesc
98

99
				,org.ObjectDescription AS OrgDesc
100

101
				,cc.ObjectDescription AS CCDesc
102

103
				,cu300.WTDefinitionDesc AS WTDesc
104

105
				,dbo.fn_formatdatetime(fixcal.PayrollDate, 'dd\mm\yyyy') AS BaseDate
106

107
FROM dbo.PHRCMTRVARIABLECAL AS fixcal
108

109
INNER JOIN @TableResult AS tableotorisasi
110

111
	ON fixcal.EmployeeID = tableotorisasi.EmployeeID
112

113
LEFT JOIN dbo.PHRPA0001 AS pa1
114

115
	ON fixcal.EmployeeID = pa1.EmployeeID
116

117
	AND pa1.StartDate <= @now AND pa1.EndDate >= @now
118

119
LEFT JOIN dbo.PHRPA0002 AS pa2
120

121
	ON fixcal.EmployeeID = pa2.EmployeeID
122

123
	AND pa2.StartDate <= @now AND pa2.EndDate >= @now
124

125
LEFT JOIN dbo.PHROM0001 AS pos
126

127
	ON pos.ObjectClass = 'P'
128

129
	AND pos.ObjectID = pa2.Position 
130

131
	AND pos.StartDate <= @now AND pos.EndDate >= @now
132

133
LEFT JOIN dbo.PHROM0001 AS job
134

135
	ON job.ObjectClass = 'J'
136

137
	AND job.ObjectID = pa2.Job 
138

139
	AND job.StartDate <= @now AND job.EndDate >= @now
140

141
LEFT JOIN dbo.PHROM0001 AS org
142

143
	ON org.ObjectClass = 'O'
144

145
	AND org.ObjectID = pa2.Organization 
146

147
	AND org.StartDate <= @now AND org.EndDate >= @now
148

149
LEFT JOIN dbo.PHROM0001 AS cc
150

151
	ON cc.ObjectClass = 'CC'
152

153
	AND cc.ObjectID = pa2.CostCenter 
154

155
	AND cc.StartDate <= @now AND cc.EndDate >= @now
156

157
LEFT JOIN dbo.PHRPYCU0300 AS cu300
158

159
	ON cu300.WageTypeDefinition = fixcal.WageTypeTarget
160

161
	AND cu300.StartDate <= @now AND cu300.EndDate >= @now
162

163
WHERE fixcal.Scenario = @Scenario
164

165
	AND LEFT(fixcal.StartDate,4) = @Year
166

167
	AND (fixcal.CompanyID = @CompanyID OR @CompanyID = '')
168

169
	AND (fixcal.Organization = @Organization OR @Organization = '')
170

171
	AND (fixcal.CostCenter = @CostCenter OR @CostCenter = '')
172

173
	AND (fixcal.EmployeeID >= @EmployeeIDFrom OR @EmployeeIDFrom = '')
174

175
	AND (fixcal.EmployeeID <= @EmployeeIDTo OR @EmployeeIDTo = '')
(13-13/17)