Project

General

Profile

Bug #1895 » rp_prest_20221226.sql

Tri Rizqiaty, 12/26/2022 02:41 PM

 
1
??ALTER PROCEDURE [dbo].[rp_prest] --exec rp_prest '100', '00000324', '02-2010', '02-2010', 'scriberion', 'triadblank'
2

3
--	-- Add the parameters for the stored procedure here
4

5
    @EmployeeID VARCHAR(18) ,
6

7
    @RunPeriod VARCHAR(8) ,
8

9
    @PayPeriod VARCHAR(8) ,
10

11
    @Key1 NVARCHAR(MAX) ,
12

13
    @Key2 NVARCHAR(MAX) ,
14

15
    @MenuID VARCHAR(10) ,
16

17
    @UserID VARCHAR(10)
18

19
	
20

21

22

23
----WITH ENCRYPTION
24

25
AS 
26

27

28

29
--DECLARE @EmployeeID VARCHAR(8)
30

31
--DECLARE @RunPeriod VARCHAR(8)
32

33
--DECLARE @PayPeriod VARCHAR(8)
34

35
--DECLARE @Key1 NVARCHAR(MAX)
36

37
--DECLARE @Key2 NVARCHAR(MAX)
38

39
--DECLARE @UserID VARCHAR(10) = 'minovais'
40

41
--DECLARE @MenuID VARCHAR(10) = 'PA01'
42

43
--SET @EmployeeID = '00000008'
44

45
--SET @RunPeriod = '012016'
46

47
--SET @PayPeriod = '012016'
48

49
--SET @Key1 = 'scriberion'
50

51
--SET @Key2 = 'triadblank'
52

53
--BEGIN
54

55
    
56

57
--	-- SET NOCOUNT ON added to prevent extra result sets from
58

59
--	-- interfering with SELECT statements.
60

61
    SET NOCOUNT ON;
62

63

64

65
    -- Insert statements for procedure here
66

67
    DECLARE @RunPeriodMonth VARCHAR(2)
68

69
    DECLARE @RunPeriodYear VARCHAR(4)
70

71
    DECLARE @PayPeriodMonth VARCHAR(2)
72

73
    DECLARE @PayPeriodYear VARCHAR(4)
74

75
    DECLARE @begda AS NVARCHAR(8)
76

77
    DECLARE @endda AS NVARCHAR(8)
78

79
        
80

81
        ------------------ // Get Otorisasi //---------------
82

83
    DECLARE @TableResult TABLE ( EmployeeID VARCHAR(20) )
84

85
		
86

87
    INSERT  INTO @TableResult
88

89
            EXEC dbo.GETEMPIDAUTHBYMENU @MenuID = @MenuID, -- varchar(max)
90

91
                @UserID = @UserID -- varchar(max)
92

93

94

95
------------------ // End Get Otorisasi //---------------
96

97

98

99
    SET @RunPeriodMonth = LEFT(@RunPeriod, 2) --01
100

101
    SET @RunPeriodYear = RIGHT(@RunPeriod, 4) --2016
102

103
    SET @PayPeriodMonth = LEFT(@PayPeriod, 2) --01
104

105
    SET @PayPeriodYear = RIGHT(@PayPeriod, 4) --2016
106

107

108

109

110

111
    SET @begda = @RunPeriodYear + @RunPeriodMonth + '01'
112

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

115

116

117
    SELECT  c.EmployeeID ,
118

119
            pd.FullName ,
120

121
            @PayPeriod 'PayPeriod' ,
122

123
            @RunPeriod 'RunPeriod' ,
124

125
            c.WageType ,
126

127
            wt.WTDefinitionDesc ,
128

129
            wt.CalculationDescription ,
130

131
            wt.WageGroup ,
132

133
            wt.Taxable ,
134

135
            wt.Regular ,
136

137
            wt.Type ,
138

139
            wt.PreTax ,
140

141
            wt.Valuation ,
142

143
            wt.Overwrite ,
144

145
            wt.IsPesangon ,
146

147
            wt.Base ,
148

149
            wt.Percentage ,
150

151
            wt.TaxSubsidy ,
152

153
            wt.Prorate1 ,
154

155
            wt.ProrateType ,
156

157
            wt.ProrateMethod ,
158

159
            wt.DebitAcc ,
160

161
            wt.CreditAcc ,
162

163
            wt.SPTNo ,
164

165
            wt.WageTypeGenerated ,
166

167
            wt.WTGeneratedPercentage ,
168

169
            wt.Notes ,
170

171
            ISNULL(m.Number, 1) Number ,
172

173
	--m.Rate,
174

175
            CAST(ISNULL(dbo.GetPEN(m.Rate), '0') AS DECIMAL) 'Rate' ,
176

177
	--m.Amount,
178

179
                --ISNULL(dbo.GetPEN(m.Amount), '0') 'Amount' , 
180

181
            CAST(REPLACE(ISNULL(dbo.GetPEN(m.Amount), '0'), ',', '.') AS DECIMAL) 'Amount' ,
182

183
	--c.amount 'cumulative_amount',
184

185
                --ISNULL(dbo.GetPEN(c.Amount), '0') 'CumulativeAmount'
186

187
            CAST(REPLACE(ISNULL(dbo.GetPEN(c.Amount), '0'), ',', '.') AS DECIMAL) 'CumulativeAmount'
188

189
    FROM    dbo.PHRPYTR0301CUM c
190

191
            LEFT JOIN dbo.PHRPYTR0301 m ON ( m.EmployeeID = c.EmployeeID
192

193
                                             AND m.PayPeriodMonth = c.PayPeriodMonth
194

195
                                             AND m.PayPeriodYear = c.PayPeriodYear
196

197
                                             AND m.RunPeriodMonth = c.RunPeriodMonth
198

199
                                             AND m.RunPeriodYear = c.RunPeriodYear
200

201
                                             AND m.SplitIndicator = c.SplitIndicator
202

203
                                             AND m.WageType = c.WageType
204

205
                                           )
206

207
            INNER JOIN @TableResult lt ON lt.EmployeeID = c.EmployeeID
208

209
            INNER JOIN dbo.PHRPYCU0300 wt ON ( c.WageType = wt.WageTypeDefinition
210

211
                                               AND wt.StartDate <= @endda
212

213
                                               AND wt.EndDate >= @endda
214

215
                                             )
216

217
            INNER JOIN dbo.PHRPA0001 pd ON ( c.EmployeeID = pd.EmployeeID
218

219
                                             AND pd.StartDate <= @endda
220

221
                                             AND pd.EndDate >= @endda
222

223
                                           )
224

225
    WHERE   c.EmployeeID = @EmployeeID
226

227
            AND c.PayPeriodMonth = @PayPeriodMonth
228

229
            AND c.PayPeriodYear = @PayPeriodYear
230

231
            AND c.RunPeriodMonth = @RunPeriodMonth
232

233
            AND c.RunPeriodYear = @RunPeriodYear 
234

235
	--AND wt.code <> 'THP'
236

237
            AND dbo.CekObjectKey(@Key1, @Key2, 'M!N0V@2010') > 0
238

239
    ORDER BY c.EmployeeID ,
240

241
            wt.Sequence ,
242

243
            wt.WageTypeDefinition
244

245

246

247

(6-6/6)