Project

General

Profile

Bug #2896 » PRPTPYSPTBULANANHEADER_202407251434.sql

Tri Rizqiaty, 07/25/2024 02:35 PM

 
1
??ALTER PROCEDURE [dbo].[PRPTPYSPTBULANANHEADER]
2

3
(
4

5
	@CompanyID VARCHAR(4) ,
6

7
    @PayGroup VARCHAR(8) ,
8

9
    @EmployeeArea VARCHAR(8),
10

11
	@EmployeeOffice VARCHAR(8),
12

13
	@TaxOffice VARCHAR(8),
14

15
    @PayPeriod VARCHAR(6)
16

17
)
18

19
AS
20

21

22

23
--DECLARE @CompanyID VARCHAR(4) = '1000'
24

25
--DECLARE @PayGroup VARCHAR(5) = ''
26

27
--DECLARE @EmployeeOffice VARCHAR(8) = ''
28

29
--DECLARE @CostCenter VARCHAR(8) = ''
30

31
--DECLARE @EmployeeID VARCHAR(8) = ''
32

33
--DECLARE @EmployeeArea VARCHAR(8) = ''
34

35
--DECLARE @PayPeriod VARCHAR(6) = '202401'
36

37
--DECLARE @Key1 NVARCHAR(MAX) = 'scriberion'
38

39
--DECLARE @Key2 NVARCHAR(MAX) = 'triadblank'
40

41

42

43
DECLARE @paymonth AS NVARCHAR(2)
44

45
DECLARE @payyear AS NVARCHAR(4)
46

47
DECLARE @begda AS NVARCHAR(8)
48

49
DECLARE @endda AS NVARCHAR(8)
50

51
SET @paymonth = RIGHT(@PayPeriod, 2)
52

53
SET @payyear = LEFT(@PayPeriod, 4)
54

55
SET @begda = @PayPeriod + '01'
56

57
SET @endda = CONVERT(NVARCHAR(8), DATEADD(d, -1, DATEADD(m, 1, @begda)), 112)
58

59

60

61
DECLARE @hr_tr0300 TABLE
62

63
    (
64

65
      [employee_id] [varchar](8) ,
66

67
      [pay_period_month] [varchar](2) ,
68

69
      [pay_period_year] [varchar](4) ,
70

71
      [run_period_month] [varchar](2) ,
72

73
      [run_period_year] [varchar](4) ,
74

75
      [split_indicator] [varchar](1) ,
76

77
      [start_date] [varchar](8) ,
78

79
      [end_date] [varchar](8) ,
80

81
      [data_status] [varchar](1) ,
82

83
      [company_id] [varchar](4) ,
84

85
      [cost_center] [varchar](8) ,
86

87
      [employee_area] [varchar](4) ,
88

89
      [employee_office] [varchar](4) ,
90

91
      [employee_status] [varchar](2) ,
92

93
      [employee_type] [varchar](2) ,
94

95
      [employee_subtype] [varchar](4) ,
96

97
      [payroll_group] [varchar](4) ,
98

99
      [organization] [varchar](8) ,
100

101
      [position] [varchar](8) ,
102

103
      [job] [varchar](8) ,
104

105
      [pay_type] [varchar](2) ,
106

107
      [pay_class] [varchar](2) ,
108

109
      [pay_grade] [varchar](4) ,
110

111
      [pay_area] [varchar](2)
112

113
    )
114

115

116

117
INSERT  INTO @hr_tr0300
118

119
        SELECT  EmployeeID ,
120

121
                PayPeriodMonth ,
122

123
                PayPeriodYear ,
124

125
                RunPeriodMonth ,
126

127
                RunPeriodYear ,
128

129
                SplitIndicator ,
130

131
                StartDate ,
132

133
                EndDate ,
134

135
                DataStatus ,
136

137
                CompanyID ,
138

139
                CostCenter ,
140

141
                EmployeeArea ,
142

143
                EmployeeOffice ,
144

145
                EmployeeStatus ,
146

147
                EmployeeType ,
148

149
                EmployeeSubType ,
150

151
                PayrollGroup ,
152

153
                Organization ,
154

155
                Position ,
156

157
                Job ,
158

159
                PayrollType ,
160

161
                PayrollClass ,
162

163
                PayrollGrade ,
164

165
                PayrollArea
166

167
        FROM    PHRPYTR0300 AS TR300
168

169
        WHERE   ( StartDate <= @endda )
170

171
                AND ( EndDate >= @endda )
172

173
                AND ( PayPeriodMonth = @paymonth )
174

175
                AND ( PayPeriodYear = @payyear )
176

177
                AND ( RunPeriodMonth = @paymonth )
178

179
                AND ( RunPeriodYear = @payyear )
180

181

182

183
--//-- Get Company Logo & Name
184

185
DECLARE @description VARCHAR(50)
186

187
DECLARE @logo VARCHAR(50)
188

189
SELECT  @description = COMP.CompanyDescription ,
190

191
        @logo = LOGO.FileName
192

193
FROM    dbo.PCMEPCOMPID AS COMP
194

195
        INNER JOIN @hr_tr0300 AS hr_tr0300 ON COMP.CompanyID = hr_tr0300.company_id
196

197
        LEFT JOIN dbo.SFILECATALOG LOGO ON COMP.Logo = LOGO.FileName
198

199
WHERE   COMP.CompanyID = @CompanyID 
200

201

202

203
--//-- Get Payroll Group
204

205
DECLARE @py_group_desc VARCHAR(50)
206

207
DECLARE @py_group VARCHAR(2)
208

209
SELECT  @py_group = PYGRUP.PayrollGroup ,
210

211
        @py_group_desc = PYGRUP.PayrollGroupDescription
212

213
FROM    dbo.PHRPYPGRUP AS PYGRUP
214

215
        INNER JOIN @hr_tr0300 AS hr_tr0300 ON PYGRUP.PayrollGroup = hr_tr0300.payroll_group 
216

217
		
218

219
--//--Get Employee Area
220

221
DECLARE @area_desc VARCHAR(50)
222

223
DECLARE @emp_area_id VARCHAR(50)
224

225
SELECT  @area_desc = EmployeeAreaDescription ,
226

227
        @emp_area_id = EmployeeArea
228

229
FROM    dbo.PCMEPEMPAREA AS EMPAREA
230

231
        INNER JOIN @hr_tr0300 AS hr_tr0300 ON EMPAREA.CompanyID = hr_tr0300.company_id
232

233
                                              AND EMPAREA.EmployeeArea = hr_tr0300.employee_area
234

235

236

237
SELECT  @description AS companyname ,
238

239
        @logo AS logo ,
240

241
        @py_group AS paygroup ,
242

243
        @py_group_desc AS payrollgroup
244

245

246

247

(2-2/2)