DBA Data[Home] [Help]

PACKAGE BODY: APPS.PA_EVENTS_PKG

Source


1 PACKAGE BODY PA_EVENTS_PKG as
2 /* $Header: PAXPREVB.pls 120.2 2007/02/07 10:45:13 rgandhi ship $ */
3 
4   PROCEDURE Insert_Row(X_Rowid                   IN OUT NOCOPY VARCHAR2,
5                        X_Event_Id                IN OUT NOCOPY NUMBER,
6                        X_Task_Id                        NUMBER,
7                        X_Event_Num                      NUMBER,
8                        X_Last_Update_Date               DATE,
9                        X_Last_Updated_By                NUMBER,
10                        X_Creation_Date                  DATE,
11                        X_Created_By                     NUMBER,
12                        X_Last_Update_Login              NUMBER,
13                        X_Event_Type                     VARCHAR2,
14                        X_Description                    VARCHAR2,
15                        X_Bill_Amount                    NUMBER,
16                        X_Revenue_Amount                 NUMBER,
17                        X_Revenue_Distributed_Flag       VARCHAR2,
18 		       X_Zero_Revenue_Amount_Flag       VARCHAR2 DEFAULT 'N',
19                        X_Bill_Hold_Flag                 VARCHAR2,
20                        X_Completion_Date                DATE,
21                        X_Rev_Dist_Rejection_Code        VARCHAR2,
22                        X_Attribute_Category             VARCHAR2,
23                        X_Attribute1                     VARCHAR2,
24                        X_Attribute2                     VARCHAR2,
25                        X_Attribute3                     VARCHAR2,
26                        X_Attribute4                     VARCHAR2,
27                        X_Attribute5                     VARCHAR2,
28                        X_Attribute6                     VARCHAR2,
29                        X_Attribute7                     VARCHAR2,
30                        X_Attribute8                     VARCHAR2,
31                        X_Attribute9                     VARCHAR2,
32                        X_Attribute10                    VARCHAR2,
33                        X_Project_Id                     NUMBER,
34                        X_Organization_Id                NUMBER,
35                        X_Billing_Assignment_Id          NUMBER,
36                        X_Event_Num_Reversed             NUMBER,
37                        X_Calling_Place                  VARCHAR2,
38                        X_Calling_Process                VARCHAR2,
39                        X_Bill_Trans_Currency_Code       VARCHAR2,/* All the 36 columns from here is added for MCB2 */
40                        X_Bill_Trans_Bill_Amount         NUMBER,
41                        X_Bill_Trans_rev_Amount          NUMBER,
42                        X_Project_Currency_Code          VARCHAR2,
43                        X_Project_Rate_Type              VARCHAR2,
44                        X_Project_Rate_Date              DATE,
45                        X_Project_Exchange_Rate          NUMBER,
46                        X_Project_Inv_Rate_Date          DATE,
47                        X_Project_Inv_Exchange_Rate      NUMBER,
48                        X_Project_Bill_Amount            NUMBER,
49                        X_Project_Rev_Rate_Date          DATE,
50                        X_Project_Rev_Exchange_Rate      NUMBER,
51                        X_Project_Revenue_Amount         NUMBER,
52                        X_ProjFunc_Currency_Code         VARCHAR2,
53                        X_ProjFunc_Rate_Type             VARCHAR2,
54                        X_ProjFunc_Rate_Date             DATE,
55                        X_ProjFunc_Exchange_Rate         NUMBER,
56                        X_ProjFunc_Inv_Rate_Date         DATE,
57                        X_ProjFunc_Inv_Exchange_Rate     NUMBER,
58                        X_ProjFunc_Bill_Amount           NUMBER,
59                        X_ProjFunc_Rev_Rate_Date         DATE,
60                        X_Projfunc_Rev_Exchange_Rate     NUMBER,
61                        X_ProjFunc_Revenue_Amount        NUMBER,
62                        X_Funding_Rate_Type              VARCHAR2,
63                        X_Funding_Rate_Date              DATE,
64                        X_Funding_Exchange_Rate          NUMBER,
65                        X_Invproc_Currency_Code          VARCHAR2,
66                        X_Invproc_Rate_Type              VARCHAR2,
67                        X_Invproc_Rate_Date              DATE,
68                        X_Invproc_Exchange_Rate          NUMBER,
69                        X_Revproc_Currency_Code          VARCHAR2,
70                        X_Revproc_Rate_Type              VARCHAR2,
71                        X_Revproc_Rate_Date              DATE,
72                        X_Revproc_Exchange_Rate          NUMBER,
73                        X_Inv_Gen_Rejection_Code         VARCHAR2,
74                        X_Adjusting_Revenue_Flag         VARCHAR2 DEFAULT 'N',  /* Added default for Bug 2483089 - For Bug 2261314 */
75                        X_non_updateable_flag            VARCHAR2  DEFAULT 'N',
76                        X_revenue_hold_flag              VARCHAR2  DEFAULT 'N',
77                        X_project_funding_id             NUMBER    DEFAULT NULL,
78 		--Start of changes for events amg
79                        X_product_code                   VARCHAR2 DEFAULT NULL,
80                        X_event_reference                VARCHAR2 DEFAULT NULL,
81                        X_inventory_org_id               NUMBER   DEFAULT NULL,
82                        X_inventory_item_id              NUMBER   DEFAULT NULL,
83                        X_quantity_billed                NUMBER     DEFAULT NULL,
84 			X_uom_code			VARCHAR2   DEFAULT NULL,
85 			X_unit_price			NUMBER	   DEFAULT NULL,
86                         X_reference1                    VARCHAR2   DEFAULT NULL,
87                         X_reference2                    VARCHAR2   DEFAULT NULL,
88                         X_reference3                    VARCHAR2   DEFAULT NULL,
89                         X_reference4                    VARCHAR2   DEFAULT NULL,
90                         X_reference5                    VARCHAR2   DEFAULT NULL,
91                         X_reference6                    VARCHAR2   DEFAULT NULL,
92                         X_reference7                    VARCHAR2   DEFAULT NULL,
93                         X_reference8                    VARCHAR2   DEFAULT NULL,
94                         X_reference9                    VARCHAR2   DEFAULT NULL,
95                         X_reference10                   VARCHAR2   DEFAULT NULL,
96                         X_Deliverable_Id                NUMBER     DEFAULT NULL,
97                         X_Action_Id                     NUMBER     DEFAULT NULL,
98                         X_Record_Version_Number         NUMBER     DEFAULT NULL,
99 		--End of changes for events amg
100                         X_Agreement_ID                  NUMBER     DEFAULT NULL   -- Federal Uptake
101   ) IS
102     CURSOR C IS SELECT rowid FROM PA_EVENTS
103                  WHERE project_id = X_Project_Id
104                  AND   (    (task_id = X_Task_Id)
105                         or (task_id is NULL and X_Task_Id is NULL))
106                  AND   event_num = X_Event_Num;
107     CURSOR C2 IS SELECT pa_events_s.nextval FROM sys.dual;
108 
109    BEGIN
110        if (X_Event_Id is NULL) then
111          OPEN C2;
112          FETCH C2 INTO X_Event_Id;
113          CLOSE C2;
114        end if;
115 
116 
117        INSERT INTO PA_EVENTS(
118 
119               event_id,
120               task_id,
121               event_num,
122               last_update_date,
123               last_updated_by,
124               creation_date,
125               created_by,
126               last_update_login,
127               event_type,
128               description,
129               bill_amount,
130               revenue_amount,
131               revenue_distributed_flag,
132 	      Zero_Revenue_Amount_Flag,
133               bill_hold_flag,
134               completion_date,
135               rev_dist_rejection_code,
136               attribute_category,
137               attribute1,
138               attribute2,
139               attribute3,
140               attribute4,
141               attribute5,
142               attribute6,
143               attribute7,
144               attribute8,
145               attribute9,
146               attribute10,
147               project_id,
148               organization_id,
149               billing_assignment_id,
150               event_num_reversed,
151               calling_place,
152               calling_process,
153               bill_trans_currency_code,   /* All the 36 columns from here is added for MCB2 */
154               bill_trans_bill_amount,
155               bill_trans_rev_amount,
156               project_currency_code,
157               project_rate_type,
158               project_rate_date,
159               project_exchange_rate,
160               project_inv_rate_date,
161               project_inv_exchange_rate,
162               project_bill_amount,
163               project_rev_rate_date,
164               project_rev_exchange_rate,
165               project_revenue_amount,
166               projfunc_currency_code,
167               projfunc_rate_type,
168               projfunc_rate_date,
169               projfunc_exchange_rate,
170               projfunc_inv_rate_date,
171               projfunc_inv_exchange_rate,
172               projfunc_bill_amount,
173               projfunc_rev_rate_date,
174               projfunc_rev_exchange_rate,
175               projfunc_revenue_amount,
176               funding_rate_type,
177               funding_rate_date,
178               funding_exchange_rate,
179               invproc_currency_code,
180               invproc_rate_type,
181               invproc_rate_date,
182               invproc_exchange_rate,
183               revproc_currency_code,
184               revproc_rate_type,
185               revproc_rate_date,
186               revproc_exchange_rate,
187               inv_gen_rejection_code,
188               adjusting_revenue_flag,  /* For Bug 2261314 */
189               non_updateable_flag,
190               revenue_hold_flag,
191               project_funding_id,
192 	--Start of changes for events amg
193               pm_product_code,
194               pm_event_reference,
195               inventory_org_id,
196               inventory_item_id,
197                 quantity_billed,
198                 uom_code,
199                 unit_price,
200                 reference1,
201                 reference2,
202                 reference3,
203                 reference4,
204                 reference5,
205                 reference6,
206                 reference7,
207                 reference8,
208                 reference9,
209                 reference10,
210                 deliverable_id,
211                 action_id,
212                 record_version_number,
213 
214         --End of changes for events amg.
215                 agreement_id  -- Federal Uptake
216 
217              ) VALUES (
218 
219               X_Event_Id,
220               X_Task_Id,
221               X_Event_Num,
222               X_Last_Update_Date,
223               X_Last_Updated_By,
224               X_Creation_Date,
225               X_Created_By,
226               X_Last_Update_Login,
227               X_Event_Type,
228               X_Description,
229               X_Bill_Amount,
230               X_Revenue_Amount,
231               X_Revenue_Distributed_Flag,
232 	      X_Zero_Revenue_Amount_Flag,
233               X_Bill_Hold_Flag,
234               X_Completion_Date,
235               X_Rev_Dist_Rejection_Code,
236               X_Attribute_Category,
237               X_Attribute1,
238               X_Attribute2,
239               X_Attribute3,
240               X_Attribute4,
241               X_Attribute5,
242               X_Attribute6,
243               X_Attribute7,
244               X_Attribute8,
245               X_Attribute9,
246               X_Attribute10,
247               X_Project_Id,
248               X_Organization_Id,
249               X_Billing_Assignment_Id,
250               X_Event_Num_Reversed,
251               X_Calling_Place,
252               X_Calling_Process,
253               X_Bill_Trans_Currency_Code,/* All the 36 columns from here is added for MCB2 */
254               X_Bill_Trans_Bill_Amount,
255               X_Bill_Trans_rev_Amount,
256               X_Project_Currency_Code,
257               X_Project_Rate_Type,
258               X_Project_Rate_Date,
259               X_Project_Exchange_Rate,
260               X_Project_Inv_Rate_Date,
261               X_Project_Inv_Exchange_Rate,
262               X_Project_Bill_Amount,
263               X_Project_Rev_Rate_Date,
264               X_Project_Rev_Exchange_Rate,
265               X_Project_Revenue_Amount,
266               X_ProjFunc_Currency_Code,
267               X_ProjFunc_Rate_Type,
268               X_ProjFunc_Rate_Date,
269               X_ProjFunc_Exchange_Rate,
270               X_ProjFunc_Inv_Rate_Date,
271               X_ProjFunc_Inv_Exchange_Rate,
272               X_ProjFunc_Bill_Amount,
273               X_Projfunc_Rev_Rate_Date,
274               X_Projfunc_Rev_Exchange_Rate,
275               X_ProjFunc_Revenue_Amount,
276               X_Funding_Rate_Type,
277               X_Funding_Rate_Date,
278               X_Funding_Exchange_Rate,
279               X_Invproc_Currency_Code,
280               X_Invproc_Rate_Type,
281               X_Invproc_Rate_Date,
282               X_Invproc_Exchange_Rate,
283               X_Revproc_Currency_Code,
284               X_Revproc_Rate_Type,
285               X_Revproc_Rate_Date,
286               X_Revproc_Exchange_Rate,
287               X_Inv_Gen_Rejection_Code,
288               X_Adjusting_Revenue_Flag,         /* For Bug 2261314 */
289               X_non_updateable_flag,
290               X_revenue_hold_flag,
291               X_project_funding_id,
292 	--Start of changes for events amg
293               X_product_code,
294               X_event_reference,
295               X_inventory_org_id,
296               X_inventory_item_id,
297 		X_quantity_billed,
298 		X_uom_code,
299 		X_unit_price,
300 		X_reference1,
301 		X_reference2,
302 		X_reference3,
303 		X_reference4,
304 		X_reference5,
305 		X_reference6,
306 		X_reference7,
307 		X_reference8,
308 		X_reference9,
309 		X_reference10,
310 		X_Deliverable_Id,
311 		X_Action_Id,
312 		X_Record_Version_Number,
313 
314 	--End of changes for events amg
315                 X_Agreement_ID  --Federal Uptake
316              );
317 
318     OPEN C;
319     FETCH C INTO X_Rowid;
320     if (C%NOTFOUND) then
321       CLOSE C;
322       Raise NO_DATA_FOUND;
323     end if;
324     CLOSE C;
325  /* Added the below for NOCOPY mandate */
326   EXCEPTION WHEN OTHERS THEN
327    X_Rowid := NULL;
328    X_Event_Id := NULL;
329   END Insert_Row;
330 
331 
332   PROCEDURE Lock_Row(X_Rowid                            VARCHAR2,
336                      X_Event_Type                       VARCHAR2,
333 		     X_Event_Id			        NUMBER,
334                      X_Task_Id                          NUMBER,
335                      X_Event_Num                        NUMBER,
337                      X_Description                      VARCHAR2,
338                      X_Bill_Amount                      NUMBER,
339                      X_Revenue_Amount                   NUMBER,
340                      X_Revenue_Distributed_Flag         VARCHAR2,
341 		     --X_Zero_Revenue_Amount_Flag         VARCHAR2,
342                      X_Bill_Hold_Flag                   VARCHAR2,
343                      X_Completion_Date                  DATE,
344                      X_Rev_Dist_Rejection_Code          VARCHAR2,
345                      X_Attribute_Category               VARCHAR2,
346                      X_Attribute1                       VARCHAR2,
347                      X_Attribute2                       VARCHAR2,
348                      X_Attribute3                       VARCHAR2,
349                      X_Attribute4                       VARCHAR2,
350                      X_Attribute5                       VARCHAR2,
351                      X_Attribute6                       VARCHAR2,
352                      X_Attribute7                       VARCHAR2,
353                      X_Attribute8                       VARCHAR2,
354                      X_Attribute9                       VARCHAR2,
355                      X_Attribute10                      VARCHAR2,
356                      X_Project_Id                       NUMBER,
357                      X_Organization_Id                  NUMBER,
358                      X_Billing_Assignment_Id            NUMBER,
359                      X_Event_Num_Reversed               NUMBER,
360                      X_Calling_Place                    VARCHAR2,
361                      X_Calling_Process                  VARCHAR2,
362                      X_Bill_Trans_Currency_Code         VARCHAR2,/* All the 36 columns from here is added for MCB2 */
363                      X_Bill_Trans_Bill_Amount           NUMBER,
364                      X_Bill_Trans_rev_Amount            NUMBER,
365                      X_Project_Currency_Code            VARCHAR2,
366                      X_Project_Rate_Type                VARCHAR2,
367                      X_Project_Rate_Date                DATE,
368                      X_Project_Exchange_Rate            NUMBER,
369                      X_Project_Inv_Rate_Date            DATE,
370                      X_Project_Inv_Exchange_Rate        NUMBER,
371                      X_Project_Bill_Amount              NUMBER,
372                      X_Project_Rev_Rate_Date            DATE,
373                      X_Project_Rev_Exchange_Rate        NUMBER,
374                      X_Project_Revenue_Amount           NUMBER,
375                      X_ProjFunc_Currency_Code           VARCHAR2,
376                      X_ProjFunc_Rate_Type               VARCHAR2,
377                      X_ProjFunc_Rate_Date               DATE,
378                      X_ProjFunc_Exchange_Rate           NUMBER,
379                      X_ProjFunc_Inv_Rate_Date           DATE,
380                      X_ProjFunc_Inv_Exchange_Rate       NUMBER,
381                      X_ProjFunc_Bill_Amount             NUMBER,
382                      X_ProjFunc_Rev_Rate_Date           DATE,
383                      X_Projfunc_Rev_Exchange_Rate       NUMBER,
384                      X_ProjFunc_Revenue_Amount          NUMBER,
385                      X_Funding_Rate_Type                VARCHAR2,
386                      X_Funding_Rate_Date                DATE,
387                      X_Funding_Exchange_Rate            NUMBER,
388                      X_Invproc_Currency_Code            VARCHAR2,
389                      X_Invproc_Rate_Type                VARCHAR2,
390                      X_Invproc_Rate_Date                DATE,
391                      X_Invproc_Exchange_Rate            NUMBER,
392                      X_Revproc_Currency_Code            VARCHAR2,
393                      X_Revproc_Rate_Type                VARCHAR2,
394                      X_Revproc_Rate_Date                DATE,
395                      X_Revproc_Exchange_Rate            NUMBER,
396                      X_Inv_Gen_Rejection_Code           VARCHAR2,
397                      X_Adjusting_Revenue_Flag           VARCHAR2,  /* For Bug 2261314 */
398                      X_Agreement_ID                     NUMBER DEFAULT NULL   -- Federal Uptake
399   ) IS
400     CURSOR C IS
401         SELECT A.*, B.event_type_classification
402         FROM   PA_EVENTS A, PA_EVENT_TYPES B
403         WHERE  A.rowid = X_Rowid
404 	   and A.event_type = B.event_type
405         FOR UPDATE of Project_Id NOWAIT;
406     Recinfo C%ROWTYPE;
407 
408 
409   BEGIN
410     OPEN C;
411     FETCH C INTO Recinfo;
412     if (C%NOTFOUND) then
413       CLOSE C;
414       FND_MESSAGE.Set_Name('FND', 'FORM_RECORD_DELETED');
415       APP_EXCEPTION.Raise_Exception;
416     end if;
417     CLOSE C;
418     if (
419 
420 	       (Recinfo.Event_Id = X_Event_Id)
421            AND (   (Recinfo.task_id =  X_Task_Id)
422                 OR (    (Recinfo.task_id IS NULL)
423                     AND (X_Task_Id IS NULL)))
424            AND (Recinfo.event_num =  X_Event_Num)
425            AND (RTRIM(Recinfo.event_type) =  RTRIM(X_Event_Type))
426            AND (RTRIM(Recinfo.description) = RTRIM(X_Description))
427            AND ( (Recinfo.bill_amount =  X_Bill_Amount) -- Make changes for MCB2
428               OR ( (Recinfo.bill_amount IS NULL)
429                  AND (X_Bill_Amount IS NULL)))
430            AND ( (Recinfo.revenue_amount =  X_Revenue_Amount)
434            --AND (   (RTRIM(Recinfo.Zero_Revenue_Amount_Flag) =  RTRIM(X_Zero_Revenue_Amount_Flag))
431                  OR ( (Recinfo.revenue_amount IS NULL)
432                      AND (X_Revenue_Amount IS NULL)))
433            AND (RTRIM(Recinfo.revenue_distributed_flag) =  RTRIM(X_Revenue_Distributed_Flag))
435                 --OR (    (Recinfo.Zero_Revenue_Amount_Flag IS NULL)
436                     --AND (X_Zero_Revenue_Amount_Flag IS NULL)))
437            AND (   (RTRIM(Recinfo.bill_hold_flag) =  RTRIM(X_Bill_Hold_Flag))
438                 OR (    (Recinfo.bill_hold_flag IS NULL)
439                     AND (X_Bill_Hold_Flag IS NULL)))
440            AND (   (Recinfo.completion_date =  X_Completion_Date)
441                 OR (    (Recinfo.completion_date IS NULL)
442                     AND (X_Completion_Date IS NULL)))
443            AND (   (RTRIM(Recinfo.attribute_category) =  RTRIM(X_Attribute_Category))
444                 OR (    (Recinfo.attribute_category IS NULL)
445                     AND (X_Attribute_Category IS NULL)))
446            AND (   (RTRIM(Recinfo.attribute1) =  RTRIM(X_Attribute1))
447                 OR (    (Recinfo.attribute1 IS NULL)
448                     AND (X_Attribute1 IS NULL)))
449            AND (   (RTRIM(Recinfo.attribute2) =  RTRIM(X_Attribute2))
450                 OR (    (Recinfo.attribute2 IS NULL)
451                     AND (X_Attribute2 IS NULL)))
452            AND (   (RTRIM(Recinfo.attribute3) =  RTRIM(X_Attribute3))
453                 OR (    (Recinfo.attribute3 IS NULL)
454                     AND (X_Attribute3 IS NULL)))
455            AND (   (RTRIM(Recinfo.attribute4) =  RTRIM(X_Attribute4))
456                 OR (    (Recinfo.attribute4 IS NULL)
457                     AND (X_Attribute4 IS NULL)))
458            AND (   (RTRIM(Recinfo.attribute5) =  RTRIM(X_Attribute5))
459                 OR (    (Recinfo.attribute5 IS NULL)
460                     AND (X_Attribute5 IS NULL)))
461            AND (   (RTRIM(Recinfo.attribute6) =  RTRIM(X_Attribute6))
462                 OR (    (Recinfo.attribute6 IS NULL)
463                     AND (X_Attribute6 IS NULL)))
464            AND (   (RTRIM(Recinfo.attribute7) =  RTRIM(X_Attribute7))
465                 OR (    (Recinfo.attribute7 IS NULL)
466                     AND (X_Attribute7 IS NULL)))
467            AND (   (RTRIM(Recinfo.attribute8) =  RTRIM(X_Attribute8))
468                 OR (    (Recinfo.attribute8 IS NULL)
469                     AND (X_Attribute8 IS NULL)))
470            AND (   (RTRIM(Recinfo.attribute9) =  rtrim(X_Attribute9))
471                 OR (    (Recinfo.attribute9 IS NULL)
472                     AND (X_Attribute9 IS NULL)))
473            AND (   (RTRIM(Recinfo.attribute10) =  RTRIM(X_Attribute10))
474                 OR (    (Recinfo.attribute10 IS NULL)
475                     AND (X_Attribute10 IS NULL)))
476            AND (Recinfo.project_id =  X_Project_Id)
477            AND (Recinfo.organization_id =  X_Organization_Id)
478            AND (   (Recinfo.billing_assignment_id =  X_Billing_Assignment_Id)
479                 OR (    (Recinfo.billing_assignment_id IS NULL)
480                     AND (X_Billing_Assignment_Id IS NULL))
481 		OR (	(RTRIM(Recinfo.event_type_classification) = 'AUTOMATIC')
482 		    AND (X_Billing_Assignment_Id IS NULL)))
483            AND (   (Recinfo.event_num_reversed =  X_Event_Num_Reversed)
484                 OR (    (Recinfo.event_num_reversed IS NULL)
485                     AND (X_Event_Num_Reversed IS NULL))
486 		OR (	(RTRIM(Recinfo.event_type_classification) = 'AUTOMATIC')
487                     AND (X_Event_Num_Reversed IS NULL)))
488            AND (   (RTRIM(Recinfo.calling_place) =  RTRIM(X_Calling_Place))
489                 OR (    (Recinfo.calling_place IS NULL)
490                     AND (X_Calling_Place IS NULL))
491 		OR (	(RTRIM(Recinfo.event_type_classification) = 'AUTOMATIC')
492                     AND (X_Calling_Place IS NULL)))
493            AND (   (RTRIM(Recinfo.calling_process) =  RTRIM(X_Calling_Process))
494                 OR (    (Recinfo.calling_process IS NULL)
495                     AND (X_Calling_Process IS NULL))
496 		OR (	(RTRIM(Recinfo.event_type_classification) = 'AUTOMATIC')
497                     AND (X_Calling_Process IS NULL)))
498            AND (   (RTRIM(Recinfo.bill_trans_currency_code) =  RTRIM(X_Bill_Trans_Currency_Code)) -- The following checks has been added for MCB2
499                 OR (    (Recinfo.bill_trans_currency_code IS NULL)
500                     AND (X_Bill_Trans_Currency_Code IS NULL)))
501            AND (   ((Recinfo.bill_trans_bill_amount) =  (X_Bill_Trans_Bill_Amount))
502                 OR (    (Recinfo.bill_trans_bill_amount IS NULL)
503                     AND (X_Bill_Trans_Bill_Amount IS NULL)))
504            AND (   ((Recinfo.bill_trans_rev_amount) =  (X_Bill_Trans_Rev_Amount))
505                 OR (    (Recinfo.bill_trans_rev_amount IS NULL)
506                     AND (X_Bill_Trans_Rev_Amount IS NULL)))
507            AND (   (RTRIM(Recinfo.project_currency_code) =  RTRIM(X_Project_Currency_Code))
508                 OR (    (Recinfo.project_currency_code IS NULL)
509                     AND (X_Project_Currency_Code IS NULL)))
510            AND (   (RTRIM(Recinfo.project_rate_type) =  RTRIM(X_Project_Rate_Type))
511                 OR (    (Recinfo.project_rate_type IS NULL)
512                     AND (X_Project_Rate_Type IS NULL)))
513            AND (   ((Recinfo.project_rate_date) =  (X_Project_Rate_Date))
514                 OR (    (Recinfo.project_rate_date IS NULL)
515                     AND (X_Project_Rate_Date IS NULL)))
516            AND (   ((Recinfo.project_exchange_rate) =  (X_Project_Exchange_Rate))
517                 OR (    (Recinfo.project_exchange_rate IS NULL)
518                     AND (X_Project_Exchange_Rate IS NULL)))
522            AND (   ((Recinfo.project_inv_exchange_rate) =  (X_Project_Inv_Exchange_Rate))
519            AND (   (Recinfo.project_inv_rate_date =  X_Project_Inv_Rate_Date)
520                 OR (    (Recinfo.project_inv_rate_date IS NULL)
521                     AND (X_Project_Inv_Rate_Date IS NULL)))
523                 OR (    (Recinfo.project_inv_exchange_rate IS NULL)
524                     AND (X_Project_Inv_Exchange_Rate IS NULL)))
525          AND (   ((Recinfo.Project_Bill_Amount) =  (X_Project_Bill_Amount))
526                 OR (    (Recinfo.Project_Bill_Amount IS NULL)
527                     AND (X_Project_Bill_Amount IS NULL)))
528            AND (   (Recinfo.project_rev_rate_date =  X_Project_Rev_Rate_Date)
529                 OR (    (Recinfo.project_rev_rate_date IS NULL)
530                     AND (X_Project_Rev_Rate_Date IS NULL)))
531            AND (   ((Recinfo.project_rev_exchange_rate) =  (X_Project_Rev_Exchange_Rate))
532                 OR (    (Recinfo.project_rev_exchange_rate IS NULL)
533                     AND (X_Project_Rev_Exchange_Rate IS NULL)))
534            AND (   ((Recinfo.project_revenue_amount) =  (X_Project_Revenue_Amount))
535                 OR (    (Recinfo.project_revenue_amount IS NULL)
536                     AND (X_Project_Revenue_Amount IS NULL)))
537            AND (   (RTRIM(Recinfo.projfunc_currency_code) =  RTRIM(X_ProjFunc_Currency_Code))
538                 OR (    (Recinfo.projfunc_currency_code IS NULL)
539                     AND (X_ProjFunc_Currency_Code IS NULL)))
540            AND (   (RTRIM(Recinfo.projfunc_rate_type) =  RTRIM(X_ProjFunc_Rate_Type))
541                 OR (    (Recinfo.projfunc_rate_type IS NULL)
542                     AND (X_ProjFunc_Rate_Type IS NULL)))
543            AND (   ((Recinfo.projfunc_rate_date) =  (X_ProjFunc_Rate_Date))
544                 OR (    (Recinfo.projfunc_rate_date IS NULL)
545                     AND (X_ProjFunc_Rate_Date IS NULL)))
546            AND (   ((Recinfo.projfunc_exchange_rate) =  (X_ProjFunc_Exchange_Rate))
547                 OR (    (Recinfo.projfunc_exchange_rate IS NULL)
548                     AND (X_ProjFunc_Exchange_Rate IS NULL)))
549           AND (   (Recinfo.projfunc_inv_rate_date =  X_ProjFunc_Inv_Rate_Date)
550                 OR (    (Recinfo.projfunc_inv_rate_date IS NULL)
551                     AND (X_ProjFunc_Inv_Rate_Date IS NULL)))
552            AND (   ((Recinfo.projfunc_inv_exchange_rate) =  (X_ProjFunc_Inv_Exchange_Rate))
553                 OR (    (Recinfo.projfunc_inv_exchange_rate IS NULL)
554                     AND (X_ProjFunc_Inv_Exchange_Rate IS NULL)))
555            AND (   ((Recinfo.projfunc_bill_amount) =  (X_ProjFunc_Bill_Amount))
556                 OR (    (Recinfo.projfunc_bill_amount IS NULL)
557                     AND (X_ProjFunc_Bill_Amount IS NULL)))
558            AND (   (Recinfo.projfunc_rev_rate_date =  X_ProjFunc_Rev_Rate_Date)
559                 OR (    (Recinfo.projfunc_rev_rate_date IS NULL)
560                     AND (X_ProjFunc_Rev_Rate_Date IS NULL)))
561            AND (   ((Recinfo.projfunc_rev_exchange_rate) =  (X_ProjFunc_Rev_Exchange_Rate))
562                 OR (    (Recinfo.projfunc_rev_exchange_rate IS NULL)
563                     AND (X_ProjFunc_Rev_Exchange_Rate IS NULL)))
564            AND (   ((Recinfo.projfunc_revenue_amount) =  (X_ProjFunc_Revenue_Amount))
565                 OR (    (Recinfo.projfunc_revenue_amount IS NULL)
566                     AND (X_ProjFunc_Revenue_Amount IS NULL)))
567            AND (   (RTRIM(Recinfo.funding_rate_type) =  RTRIM(X_Funding_Rate_Type))
568                 OR (    (Recinfo.Funding_Rate_Type IS NULL)
569                     AND (X_Funding_Rate_Type IS NULL)))
570            AND (   ((Recinfo.funding_rate_date) =  (X_Funding_Rate_Date))
571                 OR (    (Recinfo.funding_rate_date IS NULL)
572                     AND (X_Funding_Rate_Date IS NULL)))
573            AND (   ((Recinfo.funding_exchange_rate) =  (X_Funding_Exchange_Rate))
574                 OR (    (Recinfo.funding_exchange_rate IS NULL)
575                     AND (X_Funding_Exchange_Rate IS NULL)))
576            AND (   (RTRIM(Recinfo.invproc_currency_code) =  RTRIM(X_InvProc_Currency_Code))
577                 OR (    (Recinfo.invproc_currency_code IS NULL)
578                     AND (X_InvProc_Currency_Code IS NULL)))
579            AND (   (RTRIM(Recinfo.invproc_rate_type) =  RTRIM(X_InvProc_Rate_Type))
580                 OR (    (Recinfo.invproc_rate_type IS NULL)
581                     AND (X_InvProc_Rate_Type IS NULL)))
582            AND (   ((Recinfo.invproc_rate_date) =  (X_InvProc_Rate_Date))
583                 OR (    (Recinfo.InvProc_Rate_Date IS NULL)
584                     AND (X_InvProc_Rate_Date IS NULL)))
585            AND (   ((Recinfo.invproc_exchange_rate) =  (X_InvProc_Exchange_Rate))
586                 OR (    (Recinfo.invproc_exchange_rate IS NULL)
587                     AND (X_InvProc_Exchange_Rate IS NULL)))
588            AND (   (RTRIM(Recinfo.revproc_currency_code) =  RTRIM(X_RevProc_Currency_Code))
589                 OR (    (Recinfo.revproc_currency_code IS NULL)
590                     AND (X_RevProc_Currency_Code IS NULL)))
591            AND (   (RTRIM(Recinfo.revproc_rate_type) =  RTRIM(X_RevProc_Rate_Type))
592                 OR (    (Recinfo.revproc_rate_type IS NULL)
593                     AND (X_RevProc_Rate_Type IS NULL)))
594            AND (   ((Recinfo.revproc_rate_date) =  (X_RevProc_Rate_Date))
595                 OR (    (Recinfo.revproc_rate_date IS NULL)
596                     AND (X_RevProc_Rate_Date IS NULL)))
597            AND (   ((Recinfo.revproc_exchange_rate) =  (X_RevProc_Exchange_Rate))
598                 OR (    (Recinfo.revproc_exchange_rate IS NULL)
599                     AND (X_RevProc_Exchange_Rate IS NULL)))
603            AND (   (RTRIM(Recinfo.adjusting_revenue_flag) =  RTRIM(X_Adjusting_Revenue_Flag)) /* Bug 2261314 */
600            AND (   (RTRIM(Recinfo.inv_gen_rejection_code) =  RTRIM(X_Inv_Gen_Rejection_Code))
601                 OR (    (Recinfo.inv_gen_rejection_code IS NULL)
602                     AND (X_Inv_Gen_Rejection_Code IS NULL)))
604                 OR (    (Recinfo.adjusting_revenue_flag IS NULL)         /* Bug 2554232*/
605 	            AND (x_adjusting_Revenue_Flag IS NULL)))
606            AND (   (RTRIM(Recinfo.agreement_id) =  RTRIM(X_Agreement_ID)) --Federal Uptake
607                 OR (    (Recinfo.agreement_id IS NULL)          -- Federal Uptake
608                     AND (x_agreement_id IS NULL)))              -- Federal Uptake
609 --   pd_msg('Hello')
610       ) then
611       return;
612     else
613       FND_MESSAGE.Set_Name('FND', 'FORM_RECORD_CHANGED');
614       APP_EXCEPTION.Raise_Exception;
615     end if;
616   END Lock_Row;
617 
618 
619 
620   PROCEDURE Update_Row(X_Rowid                          VARCHAR2,
621                        X_Event_Id                       NUMBER,
622                        X_Task_Id                        NUMBER,
623                        X_Event_Num                      NUMBER,
624                        X_Last_Update_Date               DATE,
625                        X_Last_Updated_By                NUMBER,
626                        X_Last_Update_Login              NUMBER,
627                        X_Event_Type                     VARCHAR2,
628                        X_Description                    VARCHAR2,
629                        X_Bill_Amount                    NUMBER,
630                        X_Revenue_Amount                 NUMBER,
631                        X_Revenue_Distributed_Flag       VARCHAR2,
632 		       /*  X_Zero_Revenue_Amount_Flag       VARCHAR2,  */
633                        X_Bill_Hold_Flag                 VARCHAR2,
634                        X_Completion_Date                DATE,
635                        X_Rev_Dist_Rejection_Code        VARCHAR2,
636                        X_Attribute_Category             VARCHAR2,
637                        X_Attribute1                     VARCHAR2,
638                        X_Attribute2                     VARCHAR2,
639                        X_Attribute3                     VARCHAR2,
640                        X_Attribute4                     VARCHAR2,
641                        X_Attribute5                     VARCHAR2,
642                        X_Attribute6                     VARCHAR2,
643                        X_Attribute7                     VARCHAR2,
644                        X_Attribute8                     VARCHAR2,
645                        X_Attribute9                     VARCHAR2,
646                        X_Attribute10                    VARCHAR2,
647                        X_Project_Id                     NUMBER,
648                        X_Organization_Id                NUMBER,
649                        X_Billing_Assignment_Id          NUMBER,
650                        X_Event_Num_Reversed             NUMBER,
651                        X_Calling_Place                  VARCHAR2,
652                        X_Calling_Process                VARCHAR2,
653                        X_Bill_Trans_Currency_Code       VARCHAR2,/* All the 36 columns from here is added for MCB2 */
654                        X_Bill_Trans_Bill_Amount         NUMBER,
655                        X_Bill_Trans_Rev_Amount          NUMBER,
656                        X_Project_Currency_Code          VARCHAR2,
657                        X_Project_Rate_Type              VARCHAR2,
658                        X_Project_Rate_Date              DATE,
659                        X_Project_Exchange_Rate          NUMBER,
660                        X_Project_Inv_Rate_Date          DATE,
661                        X_Project_Inv_Exchange_Rate      NUMBER,
662                        X_Project_Bill_Amount            NUMBER,
663                        X_Project_Rev_Rate_Date          DATE,
664                        X_Project_Rev_Exchange_Rate      NUMBER,
665                        X_Project_Revenue_Amount         NUMBER,
666                        X_ProjFunc_Currency_Code         VARCHAR2,
667                        X_ProjFunc_Rate_Type             VARCHAR2,
668                        X_ProjFunc_Rate_Date             DATE,
669                        X_ProjFunc_Exchange_Rate         NUMBER,
670                        X_ProjFunc_Inv_Rate_Date         DATE,
671                        X_ProjFunc_Inv_Exchange_Rate     NUMBER,
672                        X_ProjFunc_Bill_Amount           NUMBER,
673                        X_ProjFunc_Rev_Rate_Date         DATE,
674                        X_ProjFunc_Rev_Exchange_Rate     NUMBER,
675                        X_ProjFunc_Revenue_Amount        NUMBER,
676                        X_Funding_Rate_Type              VARCHAR2,
677                        X_Funding_Rate_Date              DATE,
678                        X_Funding_Exchange_Rate          NUMBER,
679                        X_Invproc_Currency_Code          VARCHAR2,
680                        X_Invproc_Rate_Type              VARCHAR2,
681                        X_Invproc_Rate_Date              DATE,
682                        X_Invproc_Exchange_Rate          NUMBER,
683                        X_Revproc_Currency_Code          VARCHAR2,
684                        X_Revproc_Rate_Type              VARCHAR2,
685                        X_Revproc_Rate_Date              DATE,
686                        X_Revproc_Exchange_Rate          NUMBER,
687                        X_Inv_Gen_Rejection_Code         VARCHAR2,
691                        X_inventory_item_id              NUMBER   DEFAULT NULL,
688                        X_Adjusting_Revenue_Flag         VARCHAR2,  /* For Bug 2261314 */
689                 --Start of changes for events amg
690                        X_inventory_org_id               NUMBER   DEFAULT NULL,
692                        X_quantity_billed                NUMBER     DEFAULT NULL,
693                         X_uom_code                      VARCHAR2   DEFAULT NULL,
694                         X_unit_price                    NUMBER     DEFAULT NULL,
695                         X_reference1                    VARCHAR2   DEFAULT NULL,
696                         X_reference2                    VARCHAR2   DEFAULT NULL,
697                         X_reference3                    VARCHAR2   DEFAULT NULL,
698                         X_reference4                    VARCHAR2   DEFAULT NULL,
699                         X_reference5                    VARCHAR2   DEFAULT NULL,
700                         X_reference6                    VARCHAR2   DEFAULT NULL,
701                         X_reference7                    VARCHAR2   DEFAULT NULL,
702                         X_reference8                    VARCHAR2   DEFAULT NULL,
703                         X_reference9                    VARCHAR2   DEFAULT NULL,
704                         X_reference10                   VARCHAR2   DEFAULT NULL,
705 		--End of changes for events amg
706                         X_Agreement_ID                  NUMBER     DEFAULT NULL -- Federal Uptake
707   ) IS
708   BEGIN
709     UPDATE PA_EVENTS
710     SET
711        event_id			       =     X_Event_Id,
712        task_id                         =     X_Task_Id,
713        event_num                       =     X_Event_Num,
714        last_update_date                =     X_Last_Update_Date,
715        last_updated_by                 =     X_Last_Updated_By,
716        last_update_login               =     X_Last_Update_Login,
717        event_type                      =     X_Event_Type,
718        description                     =     X_Description,
719        bill_trans_bill_amount          =     X_Bill_Trans_Bill_Amount, /* Added for MCB2 */
720        bill_trans_rev_amount           =     X_Bill_Trans_Rev_Amount, /* Added for MCB2 */
721        /*  revenue_distributed_flag        =     X_Revenue_Distributed_Flag,  Added for bug 4114532 */
722        --Zero_Revenue_Amount_Flag        =     X_Zero_Revenue_Amount_Flag,
723        bill_hold_flag                  =     X_Bill_Hold_Flag,
724        completion_date                 =     X_Completion_Date,
725        rev_dist_rejection_code         =     X_Rev_Dist_Rejection_Code,
726        attribute_category              =     X_Attribute_Category,
727        attribute1                      =     X_Attribute1,
728        attribute2                      =     X_Attribute2,
729        attribute3                      =     X_Attribute3,
730        attribute4                      =     X_Attribute4,
731        attribute5                      =     X_Attribute5,
732        attribute6                      =     X_Attribute6,
733        attribute7                      =     X_Attribute7,
734        attribute8                      =     X_Attribute8,
735        attribute9                      =     X_Attribute9,
736        attribute10                     =     X_Attribute10,
737        project_id                      =     X_Project_Id,
738        organization_id                 =     X_Organization_Id,
739        billing_assignment_id           =     X_Billing_Assignment_Id,
740        event_num_reversed              =     X_Event_Num_Reversed,
741        calling_place                   =     X_Calling_Place,
742        calling_process                 =     X_Calling_Process,
743        bill_trans_currency_code        =     X_Bill_Trans_Currency_Code,/* Total 36 columns is added for MCB2 */
744        project_currency_code           =     X_Project_Currency_Code,
745        project_rate_type               =     X_Project_Rate_Type,
746        project_rate_date               =     X_Project_Rate_Date,
747        project_exchange_rate           =     X_Project_Exchange_Rate,
748        project_inv_rate_date           =     X_Project_Inv_Rate_Date,
749        project_inv_exchange_rate       =     X_Project_Inv_Exchange_Rate,
750        project_bill_amount             =     X_Project_Bill_Amount,
751        project_rev_rate_date           =     X_Project_Rev_Rate_Date,
752        project_rev_exchange_rate       =     X_Project_Rev_Exchange_Rate,
753        project_revenue_amount          =     X_Project_Revenue_Amount,
754        projfunc_currency_code          =     X_ProjFunc_Currency_Code,
755        projfunc_rate_type              =     X_ProjFunc_Rate_Type,
756        projfunc_rate_date              =     X_ProjFunc_Rate_Date,
757        projfunc_exchange_rate          =     X_ProjFunc_Exchange_Rate,
758        projfunc_inv_rate_date          =     X_ProjFunc_Inv_Rate_Date,
759        projfunc_inv_exchange_rate      =     X_ProjFunc_Inv_Exchange_rate,
760        projfunc_bill_amount            =     X_ProjFunc_Bill_Amount,
761        projfunc_rev_rate_date          =     X_ProjFunc_Rev_Rate_Date,
762        projfunc_rev_exchange_rate      =     X_ProjFunc_Rev_Exchange_Rate,
763        projfunc_revenue_amount         =     X_ProjFunc_Revenue_Amount,
764        funding_rate_type               =     X_Funding_Rate_Type,
765        funding_rate_date               =     X_Funding_Rate_Date,
766        funding_exchange_rate           =     X_Funding_Exchange_Rate,
767        invproc_currency_code           =     X_InvProc_Currency_Code,
768        invproc_rate_type               =     X_InvProc_Rate_Type,
772        revproc_rate_type               =     X_RevProc_Rate_Type,
769        invproc_rate_date               =     X_InvProc_Rate_Date,
770        invproc_exchange_rate           =     X_InvProc_Exchange_Rate,
771        revproc_currency_code           =     X_RevProc_Currency_Code,
773        revproc_rate_date               =     X_RevProc_Rate_Date,
774        revproc_exchange_rate           =     X_RevProc_Exchange_Rate,
775        inv_gen_rejection_code          =     X_Inv_Gen_Rejection_Code,
776        adjusting_revenue_flag          =     X_Adjusting_Revenue_Flag,   /* For Bug 2261314 */
777 	--Start of changes for events amg
778        inventory_org_id                =     X_inventory_org_id,
779        inventory_item_id               =     X_inventory_item_id,
780 	quantity_billed		       =       X_quantity_billed,
781 	uom_code		       =       X_uom_code,
782 	unit_price		       =       X_unit_price,
783 	reference1		       =       X_reference1,
784 	reference2		       =       X_reference2,
785 	reference3		       =       X_reference3,
786 	reference4		       =       X_reference4,
787 	reference5		       =       X_reference5,
788 	reference6		       =       X_reference6,
789 	reference7		       =       X_reference7,
790 	reference8		       =       X_reference8,
791 	reference9		       =       X_reference9,
792 	reference10		       =       X_reference10,
793         record_version_number          =       record_version_number + 1,
794 	--End of changes for events amg
795         agreement_id                   =       X_Agreement_ID  -- Federal Uptake
796     WHERE rowid = X_Rowid;
797 
798     if (SQL%NOTFOUND) then
799       Raise NO_DATA_FOUND;
800     end if;
801   END Update_Row;
802   PROCEDURE Delete_Row(X_Rowid VARCHAR2) IS
803   BEGIN
804     DELETE FROM PA_EVENTS
805     WHERE rowid = X_Rowid;
806 
807     if (SQL%NOTFOUND) then
808       Raise NO_DATA_FOUND;
809     end if;
810   END Delete_Row;
811 
812   FUNCTION Is_Event_Processed( X_Project_Id 		NUMBER,
813 				X_Task_Id		NUMBER,
814 				X_Event_Num		NUMBER,
815 				X_Revenue_Distributed	VARCHAR2,
816 				X_Bill_Amount		NUMBER)
817   RETURN VARCHAR2 IS
818   V_Is_Event_Processed		VARCHAR2(1) := 'N';
819   CURSOR C_Invoiced IS
820     SELECT 'Y'
821       FROM sys.dual
822      WHERE EXISTS(
823     	   SELECT 'Event is on invoice item'
824 	   FROM   pa_draft_invoice_items dii
825 	   WHERE  dii.project_id 	    = X_project_id
826 	   AND    NVL(dii.event_task_id,-1) = NVL(X_Task_Id,-1)
827 	   AND    dii.event_num		    = X_Event_Num
828 	   );
829   CURSOR C_Revenue_Distributed IS
830     SELECT 'Y'
831       FROM sys.dual
832      WHERE EXISTS(
833 	   SELECT 'Event is on Revenue dist line'
834 	   FROM    pa_cust_event_rev_dist_lines erdl
835 	   WHERE   erdl.project_id 	= X_Project_Id
836 	   AND 	   NVL(erdl.task_id,-1) = NVL(X_Task_Id,-1)
837 	   AND	   erdl.event_num 	= X_Event_Num
838 	   );
839   BEGIN
840 IF (NVl(X_Revenue_Distributed,'N') = 'Y') THEN
841 
842        -- if the event distributed flag is Yes then
843 
844       V_Is_Event_Processed := 'Y';
845       RETURN V_Is_Event_Processed;
846 
847     ELSIF  NVL(X_Bill_Amount,0) = 0 THEN
848 
849       -- if the bill amount is zero
850 
851       V_Is_Event_Processed := 'N';
852 
853       RETURN V_Is_Event_Processed;
854 
855     ELSE
856     --
857     -- Check if the event is on an invoice item
858     --
859     OPEN C_Invoiced;
860     FETCH C_Invoiced INTO V_Is_Event_Processed;
861     CLOSE C_Invoiced;
862 
863     end if;
864 
865     if (nvl(V_Is_Event_Processed,'N') = 'Y') then
866 
867       RETURN V_Is_Event_Processed;
868 
869      end if;
870 
871     --
872     -- Check if the event is on a Revenue Distribution line
873     --
874     -- OPEN C_Revenue_Distributed;
875     -- FETCH C_Revenue_Distributed INTO V_Is_Event_Processed;
876     -- CLOSE C_Revenue_Distributed;
877     RETURN nvl(V_Is_Event_Processed,'N');
878   EXCEPTION when others then
879     raise;
880   END Is_Event_Processed;
881 -----------------------------------------------------------------------------
882   function Is_Event_Billed( x_project_id        in      number,
883                           x_task_id     in      number,
884                           x_event_num   in      number,
885                           x_bill_amount in      number) return varchar2 IS
886   v_IsEventBilled       varchar2(1);
887   begin
888      IF  nvl(x_bill_amount,0) <> 0 THEN
889                 if ( x_task_id is not null ) then
890                         SELECT decode(nvl(sum(dii.amount),0),0,'N','Y')
891                         INTO v_IsEventBilled
892                         FROM pa_draft_invoice_items dii
893                         WHERE dii.project_id = x_project_id
894                                 AND dii.event_task_id    = x_task_id
895                                 AND dii.event_num  = x_event_num;
896                 else
897                         SELECT decode(nvl(sum(dii.amount),0),0,'N','Y')
898                         INTO v_IsEventBilled
899                         FROM pa_draft_invoice_items dii
900                         WHERE dii.project_id = x_project_id
901                                 AND dii.event_num  = x_event_num
902                                 AND dii.event_task_id IS NULL;
903                 end if;
904     ELSE
905                 v_IsEventBilled := 'N';
906     END IF;
907     return v_IsEventBilled;
908   exception when others then
909     raise;
910   end Is_Event_Billed;
911 ------------------------------------------------------------------------------
912 END PA_EVENTS_PKG;