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