DBA Data[Home] [Help]

PACKAGE BODY: APPS.OE_PAYMENT_ASSURANCE_WF

Source


1 PACKAGE BODY OE_Payment_Assurance_WF as
2 /* $Header: OEXWMPMB.pls 120.1 2005/07/15 03:59:56 pviprana noship $ */
3 
4 PROCEDURE Start_Payment_Assurance(
5     itemtype  in varchar2,
6     itemkey   in varchar2,
7     actid     in number,
8     funcmode  in varchar2,
9     resultout in out nocopy varchar2)
10 IS
11 l_line_id  		NUMBER;
12 l_exists_prepay		VARCHAR2(1) := 'N';
13 l_return_status	VARCHAR2(30);
14 l_result_out		VARCHAR2(240);
15 l_msg_count		NUMBER;
16 l_msg_data		VARCHAR2(2000);
17 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
18 
19         --Exception Management begin
20         l_header_id NUMBER;
21         l_order_source_id 	         NUMBER;
22         l_orig_sys_document_ref          VARCHAR2(50);
23         l_orig_sys_line_ref              VARCHAR2(50);
24         l_orig_sys_shipment_ref          VARCHAR2(50);
25         l_change_sequence                VARCHAR2(50);
26         l_source_document_type_id        NUMBER;
27         l_source_document_id             NUMBER;
28         l_source_document_line_id        NUMBER;
29         --Exception Management end
30 
31 BEGIN
32 
33   --
34   -- RUN mode - normal process execution
35   --
36 
37   IF l_debug_level  > 0 THEN
38     oe_debug_pub.add(  'ENTERING OE_Payment_Assurance_WF.Start_Payment_Assurance '||ITEMTYPE||'/'||ITEMKEY , 1 ) ;
39   END IF;
40 
41   IF NOT OE_PREPAYMENT_UTIL.IS_MULTIPLE_PAYMENTS_ENABLED THEN
42     IF l_debug_level  > 0 THEN
43       oe_debug_pub.add('OEXWMPMB: multiple payments is not enabled. ', 3 ) ;
44     END IF;
45     resultout := 'COMPLETE:NOT_ELIGIBLE';
46     return;
47   END IF;
48 
49   IF (funcmode = 'RUN') then
50     OE_STANDARD_WF.Set_Msg_Context(actid);
51     l_line_id  	:= to_number(itemkey);
52 
53 
54 
55     BEGIN
56       SELECT 'Y',
57              ool.header_id,
58              ool.ORDER_SOURCE_ID,
59              ool.ORIG_SYS_DOCUMENT_REF,
60              ool.ORIG_SYS_LINE_REF,
61              ool.ORIG_SYS_SHIPMENT_REF,
62              ool.CHANGE_SEQUENCE,
63              ool.SOURCE_DOCUMENT_TYPE_ID,
64              ool.SOURCE_DOCUMENT_ID,
65              ool.SOURCE_DOCUMENT_LINE_ID
66       INTO   l_exists_prepay,
67              l_header_id,
68              l_order_source_id,
69              l_orig_sys_document_ref,
70              l_orig_sys_line_ref,
71              l_orig_sys_shipment_ref,
72              l_change_sequence,
73              l_source_document_type_id,
74              l_source_document_id,
75              l_source_document_line_id
76       FROM   oe_payments op
77             ,oe_order_lines_all ool
78       WHERE  op.payment_collection_event = 'PREPAY'
79       AND    op.header_id = ool.header_id
80       AND    ool.line_id = l_line_id
81       AND    rownum = 1;
82 
83           -- Exception Management begin Set message context
84            OE_MSG_PUB.set_msg_context(
85            p_entity_code           => 'LINE'
86           ,p_entity_id                  => l_line_id
87           ,p_header_id                  => l_header_id
88           ,p_line_id                    => l_line_id
89           ,p_order_source_id            => l_order_source_id
90           ,p_orig_sys_document_ref      => l_orig_sys_document_ref
91           ,p_orig_sys_document_line_ref => l_orig_sys_line_ref
92           ,p_orig_sys_shipment_ref      => l_orig_sys_shipment_ref
93           ,p_change_sequence            => l_change_sequence
94           ,p_source_document_type_id    => l_source_document_type_id
95           ,p_source_document_id         => l_source_document_id
96           ,p_source_document_line_id    => l_source_document_line_id );
97           --Exception Management end
98 
99     EXCEPTION WHEN NO_DATA_FOUND THEN
100 
101          SELECT
102              ool.header_id,
103              ool.ORDER_SOURCE_ID,
104              ool.ORIG_SYS_DOCUMENT_REF,
105              ool.ORIG_SYS_LINE_REF,
106              ool.ORIG_SYS_SHIPMENT_REF,
107              ool.CHANGE_SEQUENCE,
108              ool.SOURCE_DOCUMENT_TYPE_ID,
109              ool.SOURCE_DOCUMENT_ID,
110              ool.SOURCE_DOCUMENT_LINE_ID
111       INTO
112              l_header_id,
113              l_order_source_id,
114              l_orig_sys_document_ref,
115              l_orig_sys_line_ref,
116              l_orig_sys_shipment_ref,
117              l_change_sequence,
118              l_source_document_type_id,
119              l_source_document_id,
120              l_source_document_line_id
121       FROM OE_ORDER_LINES_ALL ool
122       where ool.line_id = l_line_id;
123 
124                 -- Exception Management begin Set message context
125            OE_MSG_PUB.set_msg_context(
126            p_entity_code           => 'LINE'
127           ,p_entity_id                  => l_line_id
128           ,p_header_id                  => l_header_id
129           ,p_line_id                    => l_line_id
130           ,p_order_source_id            => l_order_source_id
131           ,p_orig_sys_document_ref      => l_orig_sys_document_ref
132           ,p_orig_sys_document_line_ref => l_orig_sys_line_ref
133           ,p_orig_sys_shipment_ref      => l_orig_sys_shipment_ref
134           ,p_change_sequence            => l_change_sequence
135           ,p_source_document_type_id    => l_source_document_type_id
136           ,p_source_document_id         => l_source_document_id
137           ,p_source_document_line_id    => l_source_document_line_id );
138           --Exception Management end
139 
140 
141     END;
142 
143     --pnpl should not exit if Installment Options is 'ENABLE_PAY_NOW'
144     IF l_exists_prepay = 'N' AND
145        OE_PREPAYMENT_UTIL.Get_Installment_Options <> 'ENABLE_PAY_NOW' THEN
146       OE_STANDARD_WF.Clear_Msg_Context;
147       resultout := 'COMPLETE:NOT_ELIGIBLE';
148       IF l_debug_level  > 0 THEN
149         oe_debug_pub.add('OEXWMPMB: there is no prepayment on this order. ', 3 ) ;
150       END IF;
151       RETURN;
152     END IF;
153 
154     -- check for generic and payment assurance activity specific hold
155     OE_HOLDS_PUB.CHECK_HOLDS(p_api_version => 1.0,
156                      p_line_id => l_line_id,
157                      p_wf_item => OE_GLOBALS.G_WFI_LIN,
158                      p_wf_activity => 'PAYMENT_ASSURANCE_ACT',
159                      x_result_out => l_result_out,
160                      x_return_status => l_return_status,
161                      x_msg_count => l_msg_count,
162                      x_msg_data => l_msg_data);
163 
164     IF l_debug_level  > 0 THEN
165       oe_debug_pub.add(  'OEXWMPMB: return_status after calling Check_Holds is: '||l_return_status, 3 ) ;
166       oe_debug_pub.add(  'OEXWMPMB, result_out after calling Check_Holds is: '||l_result_out, 3 ) ;
167     END IF;
168 
169     IF ( l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
170        OE_STANDARD_WF.Save_Messages;
171        OE_STANDARD_WF.Clear_Msg_Context;
172        resultout := 'INCOMPLETE';
173        RETURN;
174     ELSIF (l_result_out = FND_API.G_TRUE ) THEN
175        resultout := 'ON_HOLD';
176        OE_Order_WF_Util.Update_Flow_Status_Code
177 		(p_line_id  		=> l_line_id,
178 		 p_flow_status_code  	=> 'PAYMENT_ASSURANCE_HOLD',
179 	 	 x_return_status  	=> l_return_status);
180 
181        IF l_debug_level  > 0 THEN
182          oe_debug_pub.add('OEXWMPMB: return status from update_flow_status_code '||l_return_status , 3 ) ;
183        END IF;
184        IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
185          RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
186        ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
187          RAISE FND_API.G_EXC_ERROR;
188        END IF;
189        OE_STANDARD_WF.Clear_Msg_Context;
190        RETURN;
191     END IF;
192 
193   IF l_debug_level  > 0 THEN
194     oe_debug_pub.add(  'Start_Payment_Assurance , line_id is: '||l_line_id, 1 ) ;
195   END IF;
196 
197     OE_PrePayment_Pvt.Process_Payment_Assurance
198 			( p_api_version_number	=> 1.0
199 			, p_line_id  		=> l_line_id
200 			, p_activity_id		=> actid
201 			, p_exists_prepay       => l_exists_prepay
202 			, x_result_out		=> resultout
203 			, x_return_status	=> l_return_status
204 			, x_msg_count		=> l_msg_count
205 			, x_msg_data		=> l_msg_data
206 			);
207 
208     IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
209       OE_STANDARD_WF.Clear_Msg_Context;
210       return;
211     ELSIF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
212       -- start data fix project
213       -- OE_STANDARD_WF.Save_Messages;
214       -- OE_STANDARD_WF.Clear_Msg_Context;
215       -- end data fix project
216       app_exception.raise_exception;
217     END IF;
218 
219 
220   END IF; -- End for 'RUN' mode
221 
222   -- CANCEL mode - activity 'compensation'
223   -- This is an event point is called with the effect of the activity must
224   -- be undone, for example when a process is reset to an earlier point
225   -- due to a loop back.
226   IF (funcmode = 'CANCEL') THEN
227      -- your cancel code goes here
228     null;
229 
230     -- no result needed
231     resultout := 'COMPLETE';
232     return;
233   END IF;
234 
235   -- Other execution modes may be created in the future.  Your
236   -- activity will indicate that it does not implement a mode
237   -- by returning null
238 
239 Exception
240   when others then
241     -- The line below records this function call in the error system
242     -- in the case of an exception.
243     wf_core.context('OE_Payment_Assurance_WF', 'Payment_Assurance_Act',
244                     itemtype, itemkey, to_char(actid), funcmode);
245     -- start data fix project
246     OE_STANDARD_WF.Add_Error_Activity_Msg(p_actid => actid,
247                                           p_itemtype => itemtype,
248                                           p_itemkey => itemkey);
249     OE_STANDARD_WF.Save_Messages;
250     OE_STANDARD_WF.Clear_Msg_Context;
251     -- end data fix project
252     raise;
253 END Start_Payment_Assurance;
254 
255 
256 Procedure Payment_Receipt(
257     itemtype  in varchar2,
258     itemkey   in varchar2,
259     actid     in number,
260     funcmode  in varchar2,
261     resultout in out nocopy varchar2)
262 IS
263 
264   l_header_id  Number;
265 l_return_status VARCHAR2(30);
266 l_result_out            VARCHAR2(240);
267 
268 l_msg_count             NUMBER;
269 
270 l_msg_data              VARCHAR2(2000);
271 
272 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
273 
274 BEGIN
275   If l_debug_level > 0 Then
276    oe_debug_pub.add('Entering OE_Payment_Assurance_WF.Payment_Receipt');
277   End If;
278   --
279   -- RUN mode - normal process execution
280   --
281   IF (funcmode = 'RUN') then
282     OE_STANDARD_WF.Set_Msg_Context(actid);
283     l_header_id   := to_number(itemkey);
284     OE_PrePayment_PVT.Print_Payment_Receipt(l_header_id,l_result_out,l_return_status);
285     IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
286       -- start data fix project
287       -- OE_STANDARD_WF.Save_Messages;
288       -- OE_STANDARD_WF.Clear_Msg_Context;
289       -- end data fix project
290       -- COMMIT;
291       app_exception.raise_exception;
292     ELSE
293       OE_STANDARD_WF.Save_Messages(p_instance_id => actid);
294     END IF;
295 
296     resultout := l_result_out;
297     OE_STANDARD_WF.Clear_Msg_Context;
298     return;
299 
300   END IF; -- End for 'RUN' mode
301 
302 -- start data fix project
303 Exception
304   when others then
305     -- The line below records this function call in the error system
306     -- in the case of an exception.
307     wf_core.context('OE_Payment_Assurance_WF', 'Payment_Receipt',
308                     itemtype, itemkey, to_char(actid), funcmode);
309     OE_STANDARD_WF.Add_Error_Activity_Msg(p_actid => actid,
310                                           p_itemtype => itemtype,
311                                           p_itemkey => itemkey);
312     OE_STANDARD_WF.Save_Messages;
313     OE_STANDARD_WF.Clear_Msg_Context;
314     raise;
315     -- end data fix project
316 
317 end Payment_Receipt;
318 
319 END OE_Payment_Assurance_WF;
320