DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_FINANCE

Source


1 Package Body ota_finance as
2 /* $Header: otfin01t.pkb 115.2 99/07/16 00:52:17 porting ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ota_finance.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |-------------------------< create_finance_line >--------------------------|
12 -- ----------------------------------------------------------------------------
13 --
14 Procedure create_finance_line ( p_finance_header_id in number   default null,
15                                 p_booking_id        in number   default null,
16                                 p_currency_code     in varchar2 default null,
17                                 p_standard_amount   in number   default null,
18                                 p_unitary_amount    in number   default null,
19                                 p_money_amount      in number   default null,
20                                 p_booking_deal_id   in number   default null,
21                                 p_booking_deal_type in varchar2 default null,
22                                 p_resource_booking_id in number default null,
23                                 p_resource_allocation_id in number default null,
24                                 p_finance_line_id   out number) is
25   --
26   l_proc  varchar2(72) := g_package||'create_finance_line';
27   --
28   l_cancelled_flag       varchar2(1) := 'N';
29   l_line_type            varchar2(30);
30   l_transfer_status      varchar2(30) := 'NT';
31   l_sequence_number      number;
32   l_ovn                  number;
33   l_date_raised          date;
34   --
35 Begin
36   hr_utility.set_location('Entering:'||l_proc, 5);
37   --
38   if p_resource_booking_id is not null then
39      l_line_type := 'V';
40   elsif p_resource_allocation_id is not null then
41      l_line_type := 'R';
42   elsif p_booking_id is not null then
43      l_line_type := 'E';
44   elsif p_booking_deal_id is not null then
45      l_line_type := 'P';
46   end if;
47   --
48   ota_tfl_api_ins.ins
49                   (p_finance_line_id       => p_finance_line_id,
50                    p_finance_header_id     => p_finance_header_id,
51                    p_cancelled_flag        => l_cancelled_flag,
52                    p_date_raised           => l_date_raised,
53                    p_line_type             => l_line_type,
54                    p_transfer_status       => l_transfer_status,
55                    p_object_version_number => l_ovn,
56                    p_sequence_number       => l_sequence_number,
57                    p_currency_code         => p_currency_code,
58                    p_standard_amount       => p_standard_amount,
59                    p_unitary_amount        => p_unitary_amount,
60                    p_money_amount          => p_money_amount,
61                    p_booking_deal_id       => p_booking_deal_id,
62                    p_booking_id            => p_booking_id,
63                    p_resource_booking_id   => p_resource_booking_id,
64                    p_resource_allocation_id => p_resource_allocation_id,
65                    p_transaction_type      => 'INSERT');
66   --
67   hr_utility.set_location(' Leaving:'||l_proc, 10);
68 End create_finance_line;
69 --
70 --
71 -- ----------------------------------------------------------------------------
72 -- |-------------------------< update_finance_line >--------------------------|
73 -- ----------------------------------------------------------------------------
74 --
75 Procedure update_finance_line ( p_finance_header_id     in number default null,
76                                 p_finance_line_id       in number,
77                                 p_object_version_number in out number,
78                                 p_standard_amount       in number default null,
79                                 p_unitary_amount        in number default null,
80                                 p_money_amount          in number default null,
81                                 p_booking_deal_id       in number default null
82                               ) is
83   --
84   l_sequence_number number;
85   l_date_raised     date;
86   l_proc            varchar2(72) := g_package||'update_finance_line';
87   --
88 Begin
89   hr_utility.set_location('Entering:'||l_proc, 5);
90   --
91   ota_tfl_api_upd.upd
92                   (p_finance_line_id       => p_finance_line_id,
93                    p_finance_header_id     => p_finance_header_id,
94                    p_date_raised           => l_date_raised,
95                    p_sequence_number       => l_sequence_number,
96                    p_object_version_number => p_object_version_number,
97                    p_standard_amount       => p_standard_amount,
98                    p_unitary_amount        => p_unitary_amount,
99                    p_money_amount          => p_money_amount,
100                    p_booking_deal_id       => p_booking_deal_id,
101                    p_transaction_type      => 'UPDATE');
102   --
103   hr_utility.set_location(' Leaving:'||l_proc, 10);
104 End update_finance_line;
105 --
106 --
107 -- ----------------------------------------------------------------------------
108 -- |-----------------------< maintain_finance_line >--------------------------|
109 -- ----------------------------------------------------------------------------
110 --
111 Procedure maintain_finance_line
112              (p_finance_header_id       in     number   default null,
113               p_booking_id              in     number   default null,
114               p_currency_code           in     varchar2 default null,
115               p_object_version_number   in out number   ,
116               p_standard_amount         in     number   default null,
117               p_unitary_amount          in     number   default null,
118               p_money_amount            in     number   default null,
119               p_booking_deal_id         in     number   default null,
120               p_booking_deal_type       in     varchar2 default null,
121               p_resource_booking_id     in     number   default null,
122               p_resource_allocation_id  in     number   default null,
123               p_finance_line_id         in out number,
124               p_cancel_finance_line     in     boolean  default false) is
125   --
126   l_proc            varchar2(72) := g_package||'maintain_finance_line';
127   l_cancelled_flag  varchar2(1);
128   l_dummy           varchar2(1);
129   --
130   cursor c_finance_header_type is
131     select null
132     from   ota_finance_headers
133     where  finance_header_id = p_finance_header_id
134     and    receivable_type = 'PRE-PURCHASE USE';
135   --
136 begin
137 --
138   hr_utility.set_location(' Entering : '||l_proc, 10);
139   --
140   -- Check that if we are dealing with a pre-purchase finance line
141   -- that the agreement is also of type pre-purchase.
142   --
143   if p_booking_deal_type <> 'P' then
144     --
145     open c_finance_header_type;
146       --
147       fetch c_finance_header_type into l_dummy;
148       --
149       if c_finance_header_type%found then
150         --
151 	close c_finance_header_type;
152 	fnd_message.set_name ('OTA','OTA_13588_NOT_PRE_PURCHASE');
153 	fnd_message.raise_error;
154         --
155       end if;
156       --
157     close c_finance_header_type;
158     --
159   end if;
160   --
161   if p_cancel_finance_line then
162      --
163      if (p_booking_id is not null and
164 	ota_tdb_bus.finance_line_exists(p_booking_id,'N')) or
165 	p_resource_booking_id is not null then
166         --
167         l_cancelled_flag := 'N';
168 	--
169         ota_tfl_api_business_rules2.cancel_finance_line
170            (p_finance_line_id       => p_finance_line_id
171             ,p_cancelled_flag        => l_cancelled_flag
172             ,p_transfer_status       => ''
173             ,p_finance_header_id     => p_finance_header_id
174             ,p_object_version_number => p_object_version_number
175             ,p_validate              => FALSE);
176      end if;
177      --
178   elsif p_finance_line_id is null then
179     --
180     create_finance_line ( p_finance_header_id      => p_finance_header_id,
181                           p_booking_id             => p_booking_id,
182                           p_currency_code          => p_currency_code,
183                           p_standard_amount        => p_standard_amount,
184                           p_unitary_amount         => p_unitary_amount,
185                           p_money_amount           => p_money_amount,
186                           p_booking_deal_id        => p_booking_deal_id,
187                           p_booking_deal_type      => p_booking_deal_type,
188                           p_resource_booking_id    => p_resource_booking_id,
189                           p_resource_allocation_id => p_resource_allocation_id,
190                           p_finance_line_id        => p_finance_line_id);
191     --
192     p_object_version_number := 1;
193     --
194   else
195     --
196     update_finance_line ( p_finance_header_id     => p_finance_header_id,
197                           p_finance_line_id       => p_finance_line_id,
198                           p_object_version_number => p_object_version_number,
199                           p_standard_amount       => p_standard_amount,
200                           p_unitary_amount        => p_unitary_amount,
201                           p_money_amount          => p_money_amount,
202                           p_booking_deal_id       => p_booking_deal_id);
203     --
204   end if;
205   --
206   hr_utility.set_location(' Leaving : '||l_proc, 10);
207 end;
208 --
209 function get_deal_unit_based(p_booking_deal_id in number) return boolean is
210   --
211   l_price_list_type varchar2(30);
212   --
213   cursor get_price_list is
214     select tpl.price_list_type
215     from   ota_price_lists tpl
216            ,ota_booking_deals tbd
217     where  tbd.booking_deal_id = p_booking_deal_id
218     and    tpl.price_list_id (+) = tbd.price_list_id;
219   --
220 begin
221   open get_price_list;
222     --
223     fetch get_price_list into l_price_list_type;
224     --
225   close get_price_list;
226   --
227   return(l_price_list_type = 'T');
228   --
229 end get_deal_unit_based;
230 --
231 end ota_finance;