CREATE PROCEDURE CBKTTMTOPYTOTALUANGMAKAN
(
	@EmployeeID VARCHAR(20)
	,@StartDate VARCHAR(20)
	,@EndDate VARCHAR(20)
	,@TotAttendance VARCHAR(20)
	,@WageType VARCHAR(20)
)
AS

--DECLARE @EmployeeID VARCHAR(20) = '00001000'
--DECLARE @StartDate VARCHAR(20) = '20230130'
--DECLARE @EndDate VARCHAR(20) = '20230205'
--DECLARE @TotAttendance VARCHAR(20) = '5'
--DECLARE @WageType VARCHAR(20) = '4505'

IF(@WageType <> '') BEGIN SET @WageType = @WageType END ELSE BEGIN SET @WageType = '4505' END

DECLARE @Base DECIMAL(22,0) 
SELECT DISTINCT @Base = Amount FROM dbo.PHRPYCU0303 
WHERE WageType = @WageType
	AND StartDate <= @EndDate AND EndDate >= @EndDate

DECLARE @TotUangMakan DECIMAL(22,0)
SET @TotUangMakan = @TotAttendance * @Base

SELECT @TotUangMakan AS TotUangMakan