Project

General

Profile

Bug #3796 » ERPRPTSALESDOCDETAIL1_20251020.sql

Tri Rizqiaty, 10/20/2025 03:05 PM

 
1
??USE [MinovaES_DEMO_GolfCourse]
2

3
GO
4

5
/****** Object:  StoredProcedure [dbo].[ERPRPTSALESDOCDETAIL1]    Script Date: 20/10/2025 14.32.31 ******/
6

7
SET ANSI_NULLS ON
8

9
GO
10

11
SET QUOTED_IDENTIFIER ON
12

13
GO
14

15
ALTER PROCEDURE [dbo].[ERPRPTSALESDOCDETAIL1]
16

17

18

19
 @DocNo varchar (8),
20

21
 @DocDate varchar (10),
22

23
 @DocType varchar (8),
24

25
 @DocStatus varchar (10)
26

27

28

29
 AS
30

31

32

33
--declare @DocNo varchar (8) =''
34

35
--declare @DocDate varchar (10) =''
36

37
--declare @DocType varchar (8) =''
38

39
--declare @DocStatus varchar (10) ='10'
40

41

42

43

44

45
select distinct header.CompanyID
46

47
,compid.CompanyDescription
48

49
,header.DocNo
50

51
,header.DocDate
52

53
,header.DocStatus
54

55
,case
56

57
	when header.DocDate =null then '' 
58

59
	when header.DocDate ='' then '' 
60

61
		else dbo.fn_formatdatetime_indonesia(header.DocDate, 'DD MMMM YYYY') end as DocDateDesc
62

63
,header.CustomerID
64

65
,header.DocType
66

67
,doctype.DocTypeDesc as DocTypeDesc
68

69
,'' AS CustomerIDDesc--customer.[Description] as CustomerIDDesc
70

71
,header.ExtDocRef
72

73
,header.[Description]
74

75
from PTRSALESHEADER header
76

77
left join PCMEPCOMPID compid
78

79
	on header.CompanyID = compid.CompanyID
80

81
full outer join PTRSALESPAYTERM term 
82

83
	ON header.DocNo = term.DocNo
84

85
left join PCMBSDOCTYPE doctype 
86

87
	on header.DocType = doctype.DocType
88

89
left join PMDCUS0001 customer 
90

91
	on header.CustomerID = customer.CustomerID
92

93
where 
94

95
	(header.DocNo = @DocNo or @DocNo='') 
96

97
	and
98

99
	(header.DocDate =@DocDate or @DocDate='')
100

101
	 and
102

103
	 (header.DocType = @DocType or @DocType ='')
104

105
	 and
106

107
	  (header.DocStatus = @DocStatus or @DocStatus='')
108

109

(5-5/9)