DBA Data[Home] [Help]

PACKAGE BODY: APPS.FA_ITC_RATES_PKG

Source


1 PACKAGE BODY FA_ITC_RATES_PKG as
2 /* $Header: faxiitcb.pls 120.6 2005/07/28 00:20:26 tkawamur ship $ */
3 
4 procedure INSERT_ROW (
5   X_ROWID in out nocopy VARCHAR2,
6   X_ITC_AMOUNT_ID in NUMBER,
7   X_TAX_YEAR in NUMBER,
8   X_LIFE_IN_MONTHS in NUMBER,
9   X_ITC_AMOUNT_RATE in NUMBER,
10   X_BASIS_REDUCTION_RATE in NUMBER,
11   X_ATTRIBUTE1 in VARCHAR2,
12   X_ATTRIBUTE2 in VARCHAR2,
13   X_ATTRIBUTE3 in VARCHAR2,
14   X_ATTRIBUTE4 in VARCHAR2,
15   X_ATTRIBUTE5 in VARCHAR2,
16   X_ATTRIBUTE6 in VARCHAR2,
17   X_ATTRIBUTE7 in VARCHAR2,
18   X_ATTRIBUTE8 in VARCHAR2,
19   X_ATTRIBUTE9 in VARCHAR2,
20   X_ATTRIBUTE10 in VARCHAR2,
21   X_ATTRIBUTE11 in VARCHAR2,
22   X_ATTRIBUTE12 in VARCHAR2,
23   X_ATTRIBUTE13 in VARCHAR2,
24   X_ATTRIBUTE14 in VARCHAR2,
25   X_ATTRIBUTE15 in VARCHAR2,
26   X_ATTRIBUTE_CATEGORY_CODE in VARCHAR2,
27   X_CREATION_DATE in DATE,
28   X_CREATED_BY in NUMBER,
29   X_LAST_UPDATE_DATE in DATE,
30   X_LAST_UPDATED_BY in NUMBER,
31   X_LAST_UPDATE_LOGIN in NUMBER,
32   p_log_level_rec    in      fa_api_types.log_level_rec_type default null) is
33 
34   CURSOR C is SELECT rowid FROM fa_itc_rates
35               WHERE itc_amount_id = X_Itc_Amount_Id;
36 
37 begin
38 
39   INSERT INTO fa_itc_rates (
40 	itc_amount_id,
41 	tax_year,
42 	life_in_months,
43 	itc_amount_rate,
44 	basis_reduction_rate,
45 	attribute1,
46 	attribute2,
47 	attribute3,
48 	attribute4,
49 	attribute5,
50 	attribute6,
51 	attribute7,
52 	attribute8,
53 	attribute9,
54 	attribute10,
55 	attribute11,
56 	attribute12,
57 	attribute13,
58 	attribute14,
59 	attribute15,
60 	attribute_category_code,
61 	creation_date,
62 	created_by,
63 	last_update_date,
64 	last_updated_by,
65 	last_update_login
66   ) VALUES (
67 	X_Itc_Amount_Id,
68 	X_Tax_Year,
69 	X_Life_In_Months,
70 	X_Itc_Amount_Rate,
71 	X_Basis_Reduction_Rate,
72 	X_Attribute1,
73 	X_Attribute2,
74 	X_Attribute3,
75 	X_Attribute4,
76 	X_Attribute5,
77 	X_Attribute6,
78 	X_Attribute7,
79 	X_Attribute8,
80 	X_Attribute9,
81 	X_Attribute10,
82 	X_Attribute11,
83 	X_Attribute12,
84 	X_Attribute13,
85 	X_Attribute14,
86 	X_Attribute15,
87 	X_Attribute_Category_Code,
88 	X_Creation_Date,
89 	X_Created_By,
90 	X_Last_Update_Date,
91 	X_Last_Updated_By,
92 	X_Last_Update_Login
93   );
94 
95   OPEN C;
96   FETCH C INTO X_Rowid;
97   if (C%NOTFOUND) then
98      CLOSE C;
99      Raise NO_DATA_FOUND;
100   end if;
101   CLOSE C;
102 
103 exception
104   when others then
105         fa_srvr_msg.add_sql_error(
106                 calling_fn => 'fa_itc_rates_pkg.insert_row'
107                 ,p_log_level_rec => p_log_level_rec);
108         raise;
109 
110 end INSERT_ROW;
111 
112 procedure LOCK_ROW (
113   X_ITC_AMOUNT_ID in NUMBER,
114   X_TAX_YEAR in NUMBER,
115   X_LIFE_IN_MONTHS in NUMBER,
116   X_ITC_AMOUNT_RATE in NUMBER,
117   X_BASIS_REDUCTION_RATE in NUMBER,
118   X_ATTRIBUTE1 in VARCHAR2,
119   X_ATTRIBUTE2 in VARCHAR2,
120   X_ATTRIBUTE3 in VARCHAR2,
121   X_ATTRIBUTE4 in VARCHAR2,
122   X_ATTRIBUTE5 in VARCHAR2,
123   X_ATTRIBUTE6 in VARCHAR2,
124   X_ATTRIBUTE7 in VARCHAR2,
125   X_ATTRIBUTE8 in VARCHAR2,
126   X_ATTRIBUTE9 in VARCHAR2,
127   X_ATTRIBUTE10 in VARCHAR2,
128   X_ATTRIBUTE11 in VARCHAR2,
129   X_ATTRIBUTE12 in VARCHAR2,
130   X_ATTRIBUTE13 in VARCHAR2,
131   X_ATTRIBUTE14 in VARCHAR2,
132   X_ATTRIBUTE15 in VARCHAR2,
133   X_ATTRIBUTE_CATEGORY_CODE in VARCHAR2,
134   p_log_level_rec    in      fa_api_types.log_level_rec_type default null) is
135   CURSOR C is
136       SELECT itc_amount_id,
137              tax_year,
138              life_in_months,
139              itc_amount_rate,
140              basis_reduction_rate,
141              attribute1,
142              attribute2,
143              attribute3,
144              attribute4,
145              attribute5,
146              attribute6,
147              attribute7,
148              attribute8,
149              attribute9,
150              attribute10,
151              attribute11,
152              attribute12,
153              attribute13,
154              attribute14,
155              attribute15,
156              attribute_category_code
157       FROM   fa_itc_rates
158       WHERE  itc_amount_id = X_Itc_Amount_Id
159       FOR UPDATE of itc_amount_id NOWAIT;
160   Recinfo C%ROWTYPE;
161 
162 begin
163 
164   OPEN C;
165   FETCH C INTO Recinfo;
166   if (C%NOTFOUND) then
167       CLOSE C;
168       FND_MESSAGE.Set_Name('FND', 'FORM_RECORD_DELETED');
169       APP_EXCEPTION.Raise_Exception;
170   end if;
171   CLOSE C;
172   if (
173           (Recinfo.Itc_Amount_Id = X_Itc_Amount_Id)
174       AND (Recinfo.Tax_Year = X_Tax_Year)
175       AND (Recinfo.Life_In_Months = X_Life_In_Months)
176       AND (Recinfo.Itc_Amount_Rate = X_Itc_Amount_Rate)
177       AND ((Recinfo.Attribute1 = X_Attribute1)
178           OR ((Recinfo.Attribute1 IS NULL)
179           AND (X_Attribute1 IS NULL)))
180       AND ((Recinfo.Attribute2 = X_Attribute2)
181           OR ((Recinfo.Attribute2 IS NULL)
182           AND (X_Attribute2 IS NULL)))
183       AND ((Recinfo.Attribute3 = X_Attribute3)
184           OR ((Recinfo.Attribute3 IS NULL)
185           AND (X_Attribute3 IS NULL)))
186       AND ((Recinfo.Attribute4 = X_Attribute4)
187           OR ((Recinfo.Attribute4 IS NULL)
188           AND (X_Attribute4 IS NULL)))
189       AND ((Recinfo.Attribute5 = X_Attribute5)
190           OR ((Recinfo.Attribute5 IS NULL)
191           AND (X_Attribute5 IS NULL)))
192       AND ((Recinfo.Attribute6 = X_Attribute6)
193           OR ((Recinfo.Attribute6 IS NULL)
194           AND (X_Attribute6 IS NULL)))
195       AND ((Recinfo.Attribute7 = X_Attribute7)
196           OR ((Recinfo.Attribute7 IS NULL)
197           AND (X_Attribute7 IS NULL)))
198       AND ((Recinfo.Attribute8 = X_Attribute8)
199           OR ((Recinfo.Attribute8 IS NULL)
200           AND (X_Attribute8 IS NULL)))
201       AND ((Recinfo.Attribute9 = X_Attribute9)
202           OR ((Recinfo.Attribute9 IS NULL)
203           AND (X_Attribute9 IS NULL)))
204       AND ((Recinfo.Attribute10 = X_Attribute10)
205           OR ((Recinfo.Attribute10 IS NULL)
206           AND (X_Attribute10 IS NULL)))
207       AND ((Recinfo.Attribute11 = X_Attribute11)
208           OR ((Recinfo.Attribute11 IS NULL)
209           AND (X_Attribute11 IS NULL)))
210       AND ((Recinfo.Attribute12 = X_Attribute12)
211           OR ((Recinfo.Attribute12 IS NULL)
212           AND (X_Attribute12 IS NULL)))
213       AND ((Recinfo.Attribute13 = X_Attribute13)
214           OR ((Recinfo.Attribute13 IS NULL)
215           AND (X_Attribute13 IS NULL)))
216       AND ((Recinfo.Attribute14 = X_Attribute14)
217           OR ((Recinfo.Attribute14 IS NULL)
218           AND (X_Attribute14 IS NULL)))
219       AND ((Recinfo.Attribute15 = X_Attribute15)
220           OR ((Recinfo.Attribute15 IS NULL)
221           AND (X_Attribute15 IS NULL)))
222       AND ((Recinfo.Attribute_Category_Code = X_Attribute_Category_Code)
223           OR ((Recinfo.Attribute_Category_Code IS NULL)
224           AND (X_Attribute_Category_Code IS NULL)))) then
225       return;
226   else
227       FND_MESSAGE.Set_Name('FND', 'FORM_RECORD_CHANGED');
228       APP_EXCEPTION.Raise_Exception;
229   end if;
230 
231 end LOCK_ROW;
232 
233 procedure UPDATE_ROW (
234   X_ITC_AMOUNT_ID in NUMBER,
235   X_TAX_YEAR in NUMBER,
236   X_LIFE_IN_MONTHS in NUMBER,
237   X_ITC_AMOUNT_RATE in NUMBER,
238   X_BASIS_REDUCTION_RATE in NUMBER,
239   X_ATTRIBUTE1 in VARCHAR2,
240   X_ATTRIBUTE2 in VARCHAR2,
241   X_ATTRIBUTE3 in VARCHAR2,
242   X_ATTRIBUTE4 in VARCHAR2,
243   X_ATTRIBUTE5 in VARCHAR2,
244   X_ATTRIBUTE6 in VARCHAR2,
245   X_ATTRIBUTE7 in VARCHAR2,
246   X_ATTRIBUTE8 in VARCHAR2,
247   X_ATTRIBUTE9 in VARCHAR2,
248   X_ATTRIBUTE10 in VARCHAR2,
249   X_ATTRIBUTE11 in VARCHAR2,
250   X_ATTRIBUTE12 in VARCHAR2,
251   X_ATTRIBUTE13 in VARCHAR2,
252   X_ATTRIBUTE14 in VARCHAR2,
253   X_ATTRIBUTE15 in VARCHAR2,
254   X_ATTRIBUTE_CATEGORY_CODE in VARCHAR2,
255   X_LAST_UPDATE_DATE in DATE,
256   X_LAST_UPDATED_BY in NUMBER,
257   X_LAST_UPDATE_LOGIN in NUMBER,
258   p_log_level_rec    in      fa_api_types.log_level_rec_type default null) is
259 
260 begin
261 
262   UPDATE fa_itc_rates
263   SET    itc_amount_id = X_Itc_Amount_Id,
264          tax_year = X_Tax_Year,
265          life_in_months = X_Life_In_Months,
266          itc_amount_rate = X_Itc_Amount_Rate,
267          basis_reduction_rate = X_Basis_Reduction_Rate,
268          attribute1 = X_Attribute1,
269          attribute2 = X_Attribute2,
270          attribute3 = X_Attribute3,
271          attribute4 = X_Attribute4,
272          attribute5 = X_Attribute5,
273          attribute6 = X_Attribute5,
274          attribute7 = X_Attribute7,
275          attribute8 = X_Attribute8,
276          attribute9 = X_Attribute9,
277          attribute10 = X_Attribute10,
278          attribute11 = X_Attribute11,
279          attribute12 = X_Attribute12,
280          attribute13 = X_Attribute13,
281          attribute14 = X_Attribute14,
282          attribute15 = X_Attribute15,
283          attribute_category_code = X_Attribute_Category_Code,
284          last_update_date = X_Last_Update_Date,
285          last_updated_by = X_Last_Updated_By,
286          last_update_login = X_Last_Update_Login
287   WHERE  itc_amount_id = X_Itc_Amount_Id;
288 
289   if (SQL%NOTFOUND) then
290      Raise NO_DATA_FOUND;
291   end if;
292 
293   exception
294     when others then
295         fa_srvr_msg.add_sql_error(
296                 calling_fn => 'fa_itc_rates_pkg.update_row'
297                 ,p_log_level_rec => p_log_level_rec);
298         raise;
299 
300 end UPDATE_ROW;
301 
302 procedure DELETE_ROW (
303   X_ITC_AMOUNT_ID in NUMBER
304  ,p_log_level_rec    in      fa_api_types.log_level_rec_type default null) is
305 
306 begin
307 
308   DELETE FROM fa_itc_rates
309   WHERE  itc_amount_id = X_Itc_Amount_Id;
310 
311   if (SQL%NOTFOUND) then
312      Raise NO_DATA_FOUND;
313   end if;
314 
315   exception
316     when others then
317         fa_srvr_msg.add_sql_error(
318                 calling_fn => 'fa_itc_rates_pkg.delete_row'
319                 ,p_log_level_rec => p_log_level_rec);
320         raise;
321 
322 end DELETE_ROW;
323 
324 procedure LOAD_ROW (
325   X_CUSTOM_MODE in VARCHAR2,
326   X_ITC_AMOUNT_ID in NUMBER,
327   X_OWNER in VARCHAR2,
328   X_LAST_UPDATE_DATE in DATE,
329   X_TAX_YEAR in NUMBER,
330   X_LIFE_IN_MONTHS in NUMBER,
331   X_ITC_AMOUNT_RATE in NUMBER,
332   X_BASIS_REDUCTION_RATE in NUMBER,
333   X_ATTRIBUTE1 in VARCHAR2,
334   X_ATTRIBUTE2 in VARCHAR2,
335   X_ATTRIBUTE3 in VARCHAR2,
336   X_ATTRIBUTE4 in VARCHAR2,
337   X_ATTRIBUTE5 in VARCHAR2,
338   X_ATTRIBUTE6 in VARCHAR2,
339   X_ATTRIBUTE7 in VARCHAR2,
340   X_ATTRIBUTE8 in VARCHAR2,
341   X_ATTRIBUTE9 in VARCHAR2,
342   X_ATTRIBUTE10 in VARCHAR2,
343   X_ATTRIBUTE11 in VARCHAR2,
344   X_ATTRIBUTE12 in VARCHAR2,
345   X_ATTRIBUTE13 in VARCHAR2,
346   X_ATTRIBUTE14 in VARCHAR2,
347   X_ATTRIBUTE15 in VARCHAR2,
348   X_ATTRIBUTE_CATEGORY_CODE in VARCHAR2,
349   p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null) is
350 
351   h_record_exists       number(15);
352 
353   user_id               number;
354   row_id                varchar2(64);
355 
356   db_last_updated_by    number;
357   db_last_update_date   date;
358 
359 begin
360 
361   user_id := fnd_load_util.owner_id (X_Owner);
362 
363   select count(*)
364   into h_record_exists
365   from fa_itc_rates
366   where itc_amount_id = X_Itc_Amount_Id;
367 
368   if (h_record_exists > 0) then
369 
370      select last_updated_by, last_update_date
371      into   db_last_updated_by, db_last_update_date
372      from fa_itc_rates
373      where itc_amount_id = X_Itc_Amount_Id;
374 
375      if (fnd_load_util.upload_test(user_id, x_last_update_date,
376                                    db_last_updated_by, db_last_update_date,
377                                    X_CUSTOM_MODE)) then
378 
379         fa_itc_rates_pkg.update_row (
380            X_Itc_Amount_Id           => X_Itc_Amount_Id,
381            X_Tax_Year                => X_Tax_Year,
382            X_Life_In_Months          => X_Life_In_Months,
383            X_Itc_Amount_Rate         => X_Itc_Amount_Rate,
384            X_Basis_Reduction_Rate    => X_Basis_Reduction_Rate,
385            X_Attribute1              => X_Attribute1,
386            X_Attribute2              => X_Attribute2,
387            X_Attribute3              => X_Attribute3,
388            X_Attribute4              => X_Attribute4,
389            X_Attribute5              => X_Attribute5,
390            X_Attribute6              => X_Attribute6,
391            X_Attribute7              => X_Attribute7,
392            X_Attribute8              => X_Attribute8,
393            X_Attribute9              => X_Attribute9,
394            X_Attribute10             => X_Attribute10,
395            X_Attribute11             => X_Attribute11,
396            X_Attribute12             => X_Attribute12,
397            X_Attribute13             => X_Attribute13,
398            X_Attribute14             => X_Attribute14,
399            X_Attribute15             => X_Attribute15,
400            X_Attribute_Category_Code => X_Attribute_Category_Code,
401            X_Last_Update_Date        => sysdate,
402            X_Last_Updated_By         => user_id,
403            X_Last_Update_Login       => 0
404            ,p_log_level_rec => p_log_level_rec);
405      end if;
406   else
407      fa_itc_rates_pkg.insert_row (
408 	X_Rowid				=> row_id,
409 	X_Itc_Amount_Id			=> X_Itc_Amount_Id,
410 	X_Tax_Year			=> X_Tax_Year,
411 	X_Life_In_Months		=> X_Life_In_Months,
412 	X_Itc_Amount_Rate		=> X_Itc_Amount_Rate,
413 	X_Basis_Reduction_Rate		=> X_Basis_Reduction_Rate,
414 	X_Attribute1			=> X_Attribute1,
415 	X_Attribute2			=> X_Attribute2,
416 	X_Attribute3			=> X_Attribute3,
417 	X_Attribute4			=> X_Attribute4,
418 	X_Attribute5			=> X_Attribute5,
419 	X_Attribute6			=> X_Attribute6,
420 	X_Attribute7			=> X_Attribute7,
421 	X_Attribute8			=> X_Attribute8,
422 	X_Attribute9			=> X_Attribute9,
423 	X_Attribute10			=> X_Attribute10,
424 	X_Attribute11			=> X_Attribute11,
425 	X_Attribute12			=> X_Attribute12,
426 	X_Attribute13			=> X_Attribute13,
427 	X_Attribute14			=> X_Attribute14,
428 	X_Attribute15			=> X_Attribute15,
429 	X_Attribute_Category_Code	=> X_Attribute_Category_Code,
430 	X_Creation_Date			=> sysdate,
431 	X_Created_By			=> user_id,
432 	x_Last_Update_Date		=> sysdate,
433 	X_Last_Updated_By		=> user_id,
434 	X_Last_Update_Login		=> 0
435 	,p_log_level_rec => p_log_level_rec);
436   end if;
437 
438 exception
439   when others then
440        FA_STANDARD_PKG.RAISE_ERROR(
441                       CALLED_FN => 'fa_itc_rates_pkg.load_row',
442                       CALLING_FN => 'upload fa_itc_rates'
443                       ,p_log_level_rec => p_log_level_rec);
444 
445 end LOAD_ROW;
446 
447 procedure LOAD_SEED_ROW (
448           x_upload_mode                 IN VARCHAR2,
449           x_custom_mode                 IN VARCHAR2,
450           x_itc_amount_id               IN NUMBER,
451           x_owner                       IN VARCHAR2,
452           x_last_update_date            IN DATE,
453           x_tax_year                    IN NUMBER,
454           x_life_in_months              IN NUMBER,
455           x_itc_amount_rate             IN NUMBER,
456           x_basis_reduction_rate        IN NUMBER,
457           x_attribute1                  IN VARCHAR2,
458           x_attribute2                  IN VARCHAR2,
459           x_attribute3                  IN VARCHAR2,
460           x_attribute4                  IN VARCHAR2,
461           x_attribute5                  IN VARCHAR2,
462           x_attribute6                  IN VARCHAR2,
463           x_attribute7                  IN VARCHAR2,
464           x_attribute8                  IN VARCHAR2,
465           x_attribute9                  IN VARCHAR2,
466           x_attribute10                 IN VARCHAR2,
467           x_attribute11                 IN VARCHAR2,
468           x_attribute12                 IN VARCHAR2,
469           x_attribute13                 IN VARCHAR2,
470           x_attribute14                 IN VARCHAR2,
471           x_attribute15                 IN VARCHAR2,
472           x_attribute_category_code     IN VARCHAR2) IS
473 
474 
475 BEGIN
476 
477       if (x_upload_mode = 'NLS') then
478          null;
479       else
480         fa_itc_rates_pkg.LOAD_ROW (
481           x_custom_mode                 => x_custom_mode,
482           x_itc_amount_id               => x_itc_amount_id,
483           x_owner                       => x_owner,
484           x_last_update_date            => x_last_update_date,
485           x_tax_year                    => x_tax_year,
486           x_life_in_months              => x_life_in_months,
487           x_itc_amount_rate             => x_itc_amount_rate,
488           x_basis_reduction_rate        => x_basis_reduction_rate,
489           x_attribute1                  => x_attribute1,
490           x_attribute2                  => x_attribute2,
491           x_attribute3                  => x_attribute3,
492           x_attribute4                  => x_attribute4,
493           x_attribute5                  => x_attribute5,
494           x_attribute6                  => x_attribute6,
495           x_attribute7                  => x_attribute7,
496           x_attribute8                  => x_attribute8,
497           x_attribute9                  => x_attribute9,
498           x_attribute10                 => x_attribute10,
499           x_attribute11                 => x_attribute11,
500           x_attribute12                 => x_attribute12,
501           x_attribute13                 => x_attribute13,
502           x_attribute14                 => x_attribute14,
503           x_attribute15                 => x_attribute15,
504           x_attribute_category_code     => x_attribute_category_code);
505       end if;
506 
507 END LOAD_SEED_ROW;
508 
509 END FA_ITC_RATES_PKG;