1 PACKAGE BODY OE_DEFAULT_HEADER_PAYMENT AS
2 /* $Header: OEXDHPMB.pls 120.3 2006/03/06 23:02:48 ksurendr noship $ */
3
4 -- Global constant holding the package name
5 G_PKG_NAME CONSTANT VARCHAR2(30) := 'OE_Default_Header_Payment';
6
7 g_header_payment_rec OE_AK_HEADER_PAYMENTS_V%ROWTYPE;
8
9 PROCEDURE Attributes
10 ( p_x_Header_Payment_rec IN OUT NOCOPY OE_Order_PUB.Header_Payment_Rec_Type
11 , p_old_Header_Payment_rec IN OE_Order_PUB.Header_Payment_Rec_Type
12 , p_iteration IN NUMBER := 1
13 )
14 IS
15 l_old_header_Payment_rec OE_AK_HEADER_PAYMENTS_V%ROWTYPE;
16 l_operation VARCHAR2(30);
17 l_action NUMBER;
18 --
19 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
20 --
21 l_org_id number := 0;
22 l_payment_type_code varchar2(30) := NULL;
23 l_old_payment_type_code varchar2(30) := NULL;
24 l_defer varchar2(1) := NULL;
25
26 BEGIN
27 IF l_debug_level > 0 THEN
28 oe_debug_pub.add( 'ENTER OE_DEFAULT_HEADER_PAYMENT.ATTRIBUTES' ) ;
29 END IF;
30
31 l_operation := p_x_header_payment_rec.operation;
32
33 IF (p_x_Header_Payment_rec.payment_number = FND_API.G_MISS_NUM
34 OR p_x_Header_Payment_rec.payment_number IS NULL)
35 AND l_operation = OE_GLOBALS.G_OPR_CREATE
36 THEN
37 p_x_Header_Payment_rec.payment_number
38 := Get_Payment_Number(p_x_Header_Payment_rec.header_id);
39 END IF;
40
41 -- Due to incompatibilities in the record type structure
42 -- copy the data to a rowtype record format
43
44 OE_Header_Payment_UTIL.API_Rec_To_Rowtype_Rec
45 (p_header_payment_rec => p_x_header_payment_rec
46 ,x_rowtype_rec => g_header_payment_rec);
47 OE_Header_Payment_UTIL.API_Rec_To_Rowtype_Rec
48 (p_header_payment_rec => p_old_header_payment_rec
49 ,x_rowtype_rec => l_old_header_payment_rec);
50
51
52 -- For some fields, get hardcoded defaults based on the operation
53 IF l_operation = OE_GLOBALS.G_OPR_CREATE THEN
54
55 g_header_payment_rec.payment_level_code := 'ORDER';
56
57 END IF;
58 -- call the default handler framework to default the missing attributes
59 IF l_debug_level > 0 THEN
60 oe_debug_pub.add('In defaulting4');
61
62 oe_debug_pub.add('OEXDHPMB -- trxn_extension_id is: '||p_x_header_payment_rec.trxn_extension_id);
63 oe_debug_pub.add('g_header_payment_rec.credit_card_number...'||g_header_payment_rec.credit_card_number);
64 oe_debug_pub.add('g_header_payment_rec.credit_card_code...'||g_header_payment_rec.credit_card_code);
65 -- bug 5001819
66 IF OE_GLOBALS.G_UI_FLAG THEN
67 oe_debug_pub.add('G ui flag True');
68
69 ELSE
70 oe_debug_pub.add('Gui flag false');
71 END IF;
72 END IF;
73 --bug 5020737
74 --Checking the UI flag here since defaulting was happening when
75 --other products were passing the trxn extension id alone and the
76 --other credit card attributes were set as G_MISS values. When
77 --the call comes from OM, defaulting would need to happen.
78 IF p_x_header_payment_rec.trxn_extension_id IS NOT NULL AND
79 NOT OE_GLOBALS.Equal(p_x_header_payment_rec.trxn_extension_id,FND_API.G_MISS_NUM)
80 AND NOT OE_GLOBALS.G_UI_FLAG AND p_x_header_payment_rec.operation = OE_GLOBALS.G_OPR_CREATE
81 THEN
82 IF OE_GLOBALS.Equal(g_header_payment_rec.credit_Card_number,FND_API.G_MISS_CHAR) THEN --bug 5020737
83 g_header_payment_rec.credit_card_number := null;
84 END IF;
85
86 IF OE_GLOBALS.Equal(g_header_payment_rec.credit_card_code,FND_API.G_MISS_CHAR) THEN --bug 5020737
87 g_header_payment_rec.credit_card_code := null;
88 END IF;
89
90 IF OE_GLOBALS.Equal(g_header_payment_rec.credit_card_holder_name,FND_API.G_MISS_CHAR) THEN --bug 5020737
91 g_header_payment_rec.credit_card_holder_name := null;
92 END IF;
93
94 IF OE_GLOBALS.Equal(g_header_payment_rec.credit_card_expiration_date,FND_API.G_MISS_DATE) THEN --bug 5020737
95 g_header_payment_rec.credit_card_expiration_date := null;
96 END IF;
97
98 END IF;
99 --bug 5020737
100 IF l_debug_level > 0 THEN
101 oe_debug_pub.add('g_header_payment_rec.credit_card_number...'||g_header_payment_rec.credit_card_number);
102 oe_debug_pub.add('g_header_payment_rec.credit_card_code...'||g_header_payment_rec.credit_card_code);
103 END IF;
104 ONT_HEADER_Payment_Def_Hdlr.Default_Record
105 (p_x_rec => g_header_payment_rec
106 ,p_in_old_rec => l_old_header_payment_rec);
107 IF l_debug_level > 0 THEN
108 oe_debug_pub.add('g_header_payment_rec.credit_card_number...'||g_header_payment_rec.credit_card_number);
109 oe_debug_pub.add('g_header_payment_rec.credit_card_code...'||g_header_payment_rec.credit_card_code);
110 oe_debug_pub.add('In defaulting5');
111 END IF;
112 -- copy the data back to a format that is compatible with the API architecture
113
114 OE_Header_Payment_UTIL.RowType_Rec_to_API_Rec
115 (p_record => g_header_Payment_rec
116 ,x_api_rec => p_x_header_Payment_rec);
117
118 IF l_debug_level > 0 THEN
119 oe_debug_pub.add( 'CALL CONVERT_MISS_TO_NULL' ) ;
120 END IF;
121 OE_HEADER_Payment_UTIL.Convert_Miss_To_Null
122 (p_x_header_Payment_rec);
123
124 /* code change for defer_payment_processing_flag */
125
126 l_org_id := OE_GLOBALS.G_ORG_ID;
127 l_payment_type_code := p_x_header_Payment_rec.payment_type_code;
128 l_old_payment_type_code := p_old_header_Payment_rec.payment_type_code;
129
130 if l_org_id is null then
131 OE_GLOBALS.Set_Context;
132 l_org_id := OE_GLOBALS.G_ORG_ID;
133 end if;
134
135 Begin
136 --bug3504713 commenting the following condition and adding a new condition
137 -- if p_x_header_Payment_rec.defer_payment_processing_flag is null
138 if NOT OE_GLOBALS.EQUAL(l_payment_type_code,l_old_payment_type_code)
139 and l_payment_type_code is not null
140 and (
141 (OE_GLOBALS.EQUAL(p_x_header_Payment_rec.defer_payment_processing_flag,
142 p_old_header_Payment_rec.defer_payment_processing_flag)
143 and p_x_header_Payment_rec.operation = OE_GLOBALS.G_OPR_UPDATE)
144 or
145 (nvl(p_x_header_Payment_rec.defer_payment_processing_flag,
146 FND_API.G_MISS_CHAR) = FND_API.G_MISS_CHAR
147 and p_x_header_Payment_rec.operation = OE_GLOBALS.G_OPR_CREATE)
148 or
149 (nvl(p_old_header_Payment_rec.defer_payment_processing_flag,
150 FND_API.G_MISS_CHAR) <> FND_API.G_MISS_CHAR
151 and p_x_header_Payment_rec.operation = OE_GLOBALS.G_OPR_CREATE)
152 )
153 then
154
155 select defer_payment_processing_flag into l_defer
156 from oe_payment_types_all
157 where payment_type_code = l_payment_type_code
158 and nvl(org_id, -99) = nvl(l_org_id, -99);
159
160 IF l_debug_level > 0 THEN
161 oe_debug_pub.add( 'Defaulting the defer_payment_processing_flag. ' ) ;
162 END IF;
163
164 p_x_header_Payment_rec.defer_payment_processing_flag := l_defer;
165
166 end if;
167
168 Exception
169 when others then
170 p_x_header_Payment_rec.defer_payment_processing_flag := 'N';
171
172 End;
173
174 /* end of code change for defer payment processing flag */
175
176 IF (p_x_Header_Payment_rec.lock_control = FND_API.G_MISS_NUM) THEN
177 p_x_Header_Payment_rec.lock_control := NULL;
178 END IF;
179
180 IF l_debug_level > 0 THEN
181 oe_debug_pub.add( 'EXIT OE_DEFAULT_HEADER_PAYMENT.ATTRIBUTES' ) ;
182 END IF;
183
184 EXCEPTION
185
186 WHEN FND_API.G_EXC_ERROR THEN
187
188 RAISE FND_API.G_EXC_ERROR;
189
190 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
191
192 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
193
194 WHEN OTHERS THEN
195
196 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
197 THEN
198 OE_MSG_PUB.Add_Exc_Msg
199 ( G_PKG_NAME
200 , 'Attributes'
201 );
202 END IF;
203 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
204
205 END Attributes;
206
207 FUNCTION Get_Payment_Number
208 (p_header_id IN NUMBER)
209 RETURN NUMBER
210 IS
211 l_payment_number NUMBER := NULL;
212 l_exists_null_number VARCHAR2(1) := 'N';
213 --
214 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
215 --
216 BEGIN
217
218 IF l_debug_level > 0 THEN
219 oe_debug_pub.add( 'In OE_Default_Header_Payment: FUNCTION Get_Payment_Number' ) ;
220 oe_debug_pub.add( 'header_id is: '||p_header_id ) ;
221 END IF;
222
223 IF p_header_id IS NOT NULL
224 AND p_header_id <> FND_API.G_MISS_NUM THEN
225 BEGIN
226 SELECT 'Y'
227 INTO l_exists_null_number
228 FROM oe_payments
229 WHERE payment_number is null
230 AND header_id = p_header_id
231 AND line_id is null
232 AND rownum = 1;
233 EXCEPTION WHEN NO_DATA_FOUND THEN
234 l_exists_null_number := 'N';
235 END;
236
237 IF l_exists_null_number = 'N' THEN
238 SELECT NVL(MAX(PAYMENT_NUMBER)+1,1)
239 INTO l_payment_number
240 FROM OE_PAYMENTS
241 WHERE HEADER_ID = p_header_id
242 AND LINE_ID IS NULL;
243 ELSE
244 SELECT MAX(NVL(PAYMENT_NUMBER, 1))+1
245 INTO l_payment_number
246 FROM OE_PAYMENTS
247 WHERE HEADER_ID = p_header_id
248 AND LINE_ID IS NULL;
249 END IF;
250
251 END IF;
252
253 RETURN (l_payment_number);
254
255 EXCEPTION
256
257 WHEN OTHERS THEN
258
259 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
260 THEN
261 OE_MSG_PUB.Add_Exc_Msg
262 ( G_PKG_NAME ,
263 'Get_Payment_Number'
264 );
265 END IF;
266
267 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
268
269 END Get_Payment_Number;
270
271 END OE_Default_Header_Payment ;