DBA Data[Home] [Help]

PACKAGE BODY: APPS.PON_TRANSFORM_BIDDING_PKG

Source


1 PACKAGE BODY PON_TRANSFORM_BIDDING_PKG AS
2 -- $Header: PONTFBDB.pls 120.4 2006/08/02 10:46:35 rpatel noship $
3 --
4 
5 --
6 -- BID TOTAL ERROR CODES
7 --
8 BID_TOTAL_WARNING NUMBER := -1;
9 --
10 --
11 
12 -- LOGGING FEATURE
13 --
14 -- global variables used for logging
15 --
16 g_fnd_debug     CONSTANT VARCHAR2(1)  := NVL(FND_PROFILE.VALUE('AFLOG_ENABLED'),'N');
17 g_module_prefix CONSTANT VARCHAR2(35) := 'pon.plsql.transformBiddingPkg.';
18 --
19 --private helper procedure for logging
20 PROCEDURE print_log(p_module   IN    VARCHAR2,
21                    p_message  IN    VARCHAR2)
22 IS
23 BEGIN
24    IF (g_fnd_debug = 'Y') THEN
25       IF (FND_LOG.level_statement >= FND_LOG.g_current_runtime_level) THEN
26          FND_LOG.string(log_level => FND_LOG.level_statement,
27                         module  =>  g_module_prefix || p_module,
28                         message  => p_message);
29       END IF;
30    END IF;
31 END;
32 
33 
34 -- ------------------------------------------------------------------------
35 -- find_user_site
36 --
37 -- given auction_header_id, tpid, tpcid, this will find the site
38 -- to use for transformation.
39 --
40 -- question: what if this supplier was not invited to the negotiation?
41 -- he will not have any price factor values to use...
42 -- ------------------------------------------------------------------------
43 
44 FUNCTION find_user_site
45 	(p_auction_header_id 	IN pon_bid_headers.auction_header_id%TYPE,
46 	 p_tpid 				IN pon_bid_headers.trading_partner_id%TYPE,
47 	 p_tpcid				IN pon_bid_headers.trading_partner_contact_id%TYPE)
48 	RETURN NUMBER
49 IS
50 	v_site_id				pon_bid_headers.vendor_site_id%TYPE;
51 	v_num_invited_sites		NUMBER;
52 BEGIN
53 
54 	SELECT vendor_site_id
55 	INTO v_site_id
56 	FROM (SELECT vendor_site_id
57 		  FROM pon_bidding_parties
58 		  WHERE auction_header_id = p_auction_header_id
59 			AND trading_partner_id = p_tpid
60 		  ORDER BY vendor_site_code)
61 	WHERE rownum=1;
62 
63 	RETURN v_site_id;
64 
65 EXCEPTION
66 
67 	WHEN NO_DATA_FOUND THEN
68 		RETURN NULL;
69 
70 END find_user_site;
71 
72 
73 -- -----------------------------------------------------
74 -- check_est_qty_on_all_bid_lines
75 --
76 -- Indirectly used to check whether bid total can be computed for blanket negotiations
77 --
78 -- Estimated quantity needs to be set for all lines that were bidded on to
79 -- compute the bid total
80 -- ----------------------------------------------------------------
81 
82 FUNCTION check_est_qty_on_all_bid_lines
83                (p_auction_header_id IN NUMBER,
84                 p_bid_number        IN NUMBER) RETURN VARCHAR2
85 
86 IS
87 
88   v_has_est_qty_on_all_bid_lines VARCHAR2(1);
89 
90 BEGIN
91 
92   v_has_est_qty_on_all_bid_lines := 'Y';
93 
94   SELECT 'N'
95   INTO   v_has_est_qty_on_all_bid_lines
96   FROM   dual
97   WHERE  EXISTS (SELECT null
98                  FROM   pon_bid_item_prices pbip,
99                         pon_auction_item_prices_all paip
100                  WHERE  pbip.auction_header_id = p_auction_header_id AND
101                         pbip.bid_number = p_bid_number AND
102                         nvl(pbip.has_bid_flag, 'N') = 'Y' AND
103                         pbip.auction_header_id = paip.auction_header_id AND
104                         pbip.line_number = paip.line_number AND
105                         paip.group_type in ('LOT', 'LINE', 'GROUP_LINE') AND
106                         paip.order_type_lookup_code <> 'FIXED PRICE' AND
107                         paip.quantity is null);
108 
109   RETURN v_has_est_qty_on_all_bid_lines;
110 
111 EXCEPTION
112 
113      WHEN NO_DATA_FOUND THEN
114              RETURN 'Y';
115 
116 
117 END check_est_qty_on_all_bid_lines;
118 
119 -- --------------------------------------------------------------
120 --
121 -- calculate_supplier_bid_total
122 --
123 -- Calculates the bid total in the buyer's currency for a supplier's view
124 --
125 -- The buyer_bid_total can be used when a bid has been submitted for a
126 -- TRANSFORMED auction
127 --
128 -- -------------------------------------------------------------
129 
130 FUNCTION calculate_supplier_bid_total
131              (p_auction_header_id    IN NUMBER,
132               p_bid_number           IN NUMBER,
133               p_outcome              IN pon_auction_headers_all.contract_type%TYPE,
134               p_supplier_view_type   IN pon_auction_headers_all.supplier_view_type%TYPE,
135               p_tpid                 IN NUMBER,
136               p_site                 IN NUMBER) RETURN NUMBER
137 
138 IS
139 
140   v_bid_total NUMBER;
141 
142 BEGIN
143 
144   IF (p_supplier_view_type = 'TRANSFORMED') THEN
145 
146     SELECT sum(decode(paip.order_type_lookup_code, 'FIXED PRICE', 1,
147                       decode(p_outcome, 'STANDARD', nvl(pbip.quantity, 0), paip.quantity)) *
148                nvl(pbip.price,0)) bid_total
149     INTO   v_bid_total
150     FROM   pon_bid_item_prices pbip,
151            pon_auction_item_prices_all paip
152     WHERE  pbip.auction_header_id = p_auction_header_id AND
153            pbip.bid_number = p_bid_number AND
154            nvl(pbip.has_bid_flag, 'N') = 'Y' AND
155            pbip.auction_header_id = paip.auction_header_id AND
156            pbip.line_number = paip.line_number AND
157            paip.group_type in ('LOT', 'LINE', 'GROUP_LINE');
158 
159   ELSE -- UNTRANSFORMED
160 
161     SELECT sum(decode(paip.order_type_lookup_code, 'FIXED PRICE', 1,
162                       decode(p_outcome, 'STANDARD', nvl(pbip.quantity, 0), paip.quantity)) *
163                nvl(untransform_one_price(paip.auction_header_id, paip.line_number, pbip.price,
164                                          paip.quantity, p_tpid, p_site),0)) bid_total
165     INTO   v_bid_total
166     FROM   pon_bid_item_prices pbip,
167            pon_auction_item_prices_all paip
168     WHERE  pbip.auction_header_id = p_auction_header_id AND
169            pbip.bid_number = p_bid_number AND
170            nvl(pbip.has_bid_flag, 'N') = 'Y' AND
171            pbip.auction_header_id = paip.auction_header_id AND
172            pbip.line_number = paip.line_number AND
173            paip.group_type in ('LOT', 'LINE', 'GROUP_LINE');
174 
175   END IF;
176 
177   RETURN v_bid_total;
178 
179 END calculate_supplier_bid_total;
180 
181 --------------------------------------------
182 --
183 -- returns the bid total in the buyer's currency
184 --
185 -------------------------------------------
186 
187 
188 FUNCTION calculate_bid_total
189               (p_auction_header_id IN NUMBER,
190                p_bid_number        IN NUMBER,
191                p_tpid              IN NUMBER,
192                p_site              IN NUMBER) RETURN NUMBER
193 
194 IS
195 
196   v_buyer_tpid                     NUMBER;
197   v_outcome                        pon_auction_headers_all.contract_type%TYPE;
198   v_supplier_view_type             pon_auction_headers_all.supplier_view_type%TYPE;
199   v_bid_status                     pon_bid_headers.bid_status%TYPE;
200   v_buyer_bid_total                NUMBER;
201   v_has_est_qty_on_all_bid_lines   VARCHAR2(1);
202   v_doctype_group_name        VARCHAR2(80);
203 
204 BEGIN
205 
206   IF (p_bid_number is NULL) THEN
207     RETURN NULL;
208   END IF;
209 
210   SELECT auh.trading_partner_id, auh.contract_type, auh.supplier_view_type,dt.doctype_group_name
211     INTO v_buyer_tpid, v_outcome, v_supplier_view_type,v_doctype_group_name
212     FROM pon_auction_headers_all auh, pon_auc_doctypes dt
213    WHERE auction_header_id = p_auction_header_id
214      AND auh.doctype_id = dt.doctype_id;
215 
216 
217   SELECT bid_status, buyer_bid_total
218   INTO   v_bid_status, v_buyer_bid_total
219   FROM   pon_bid_headers
220   WHERE  auction_header_id = p_auction_header_id AND
221          bid_number = p_bid_number;
222 
223   -- Check to see if we can use buyer_bid_total
224   -- 1) The buyer_bid_total column is set at publish time...
225   --    and thus is only useful after publish time
226   -- 2) buyer_bid_total is the bid's total in the buyer's view
227   -- 3) A buyer and supplier will see the same total whe the supplier view is TRANSFORMED
228   -- 4) A buyer can only see the total for non-draft bids
229 
230   IF ( (p_tpid = v_buyer_tpid) OR
231        (v_bid_status <> 'DRAFT' AND v_supplier_view_type = 'TRANSFORMED') ) THEN
232 
233       IF (v_buyer_bid_total is NULL) THEN
234         RETURN BID_TOTAL_WARNING;
235       ELSE
236         RETURN v_buyer_bid_total;
237       END IF;
238 
239   END IF;
240 
241 
242   IF (v_bid_status = 'DRAFT') THEN
243 
244     IF ((v_doctype_group_name = 'REQUEST_FOR_INFORMATION') OR (v_outcome = 'BLANKET' OR v_outcome = 'CONTRACT')) THEN
245 
246       v_has_est_qty_on_all_bid_lines := check_est_qty_on_all_bid_lines(p_auction_header_id, p_bid_number);
247 
248       IF (v_has_est_qty_on_all_bid_lines = 'N') THEN
249         RETURN BID_TOTAL_WARNING;
250       END IF;
251 
252     END IF;
253 
254 
255     RETURN calculate_supplier_bid_total(p_auction_header_id,
256                                         p_bid_number,
257                                         v_outcome,
258                                         v_supplier_view_type,
259                                         p_tpid,
260                                         p_site);
261 
262   ELSE -- Submitted bid in an UNTRANSFORMED auction
263 
264     IF (v_buyer_bid_total is NULL) THEN
265       RETURN BID_TOTAL_WARNING;
266     ELSE
267       RETURN calculate_supplier_bid_total(p_auction_header_id,
268                                           p_bid_number,
269                                           v_outcome,
270                                           v_supplier_view_type,
271                                           p_tpid,
272                                           p_site);
273     END IF;
274 
275   END IF;
276 
277 END calculate_bid_total;
278 
279 -- ------------------------------------------------------------------------
280 -- calculate_price
281 --
282 -- called from the VO sql query itself, this will takes one price
283 -- and transforms it if necessary.
284 -- ------------------------------------------------------------------------
285 FUNCTION calculate_price
286 	(p_auction_header_id 	IN NUMBER,
287 	 p_line_number			IN NUMBER,
288 	 p_price				IN NUMBER,
289 	 p_quantity				IN NUMBER,
290 	 p_tpid 				IN NUMBER,
291 	 p_site					IN NUMBER)
292 	RETURN NUMBER
293 IS
294 BEGIN
295 	return calculate_price(p_auction_header_id, p_line_number, p_price,
296 						   p_quantity, p_tpid, -1, p_site, null);
297 END calculate_price;
298 
299 
300 FUNCTION calculate_price
301 	(p_auction_header_id 	IN NUMBER,
302 	 p_line_number			IN NUMBER,
303 	 p_price				IN NUMBER,
304 	 p_quantity				IN NUMBER,
305 	 p_tpid 				IN NUMBER,
306 	 p_tpcid				IN NUMBER,
307 	 p_site					IN NUMBER)
308 	RETURN NUMBER
309 IS
310 BEGIN
311   return calculate_price(p_auction_header_id, p_line_number, p_price,
312                          p_quantity, p_tpid, p_tpcid, p_site, null);
313 END calculate_price;
314 
315 
316 FUNCTION calculate_price
317 	(p_auction_header_id 	IN NUMBER,
318 	 p_line_number			IN NUMBER,
319 	 p_price				IN NUMBER,
320 	 p_quantity				IN NUMBER,
321 	 p_tpid 				IN NUMBER,
322 	 p_tpcid				IN NUMBER,
323 	 p_site					IN NUMBER,
324          p_requested_supplier_id                IN NUMBER)
325 	RETURN NUMBER
326 IS
327 	v_supplier_view_type	pon_auction_headers_all.supplier_view_type%TYPE;
328 	v_buyer_tpid			pon_auction_headers_all.trading_partner_id %TYPE;
329 
330 BEGIN
331 
332 	-- QUESTION: do I have to worry about the case where the following query
333 	-- returns NO rows??
334 
335 	SELECT supplier_view_type, trading_partner_id
336 	INTO v_supplier_view_type, v_buyer_tpid
337 	FROM pon_auction_headers_all
338 	WHERE auction_header_id = p_auction_header_id;
339 
340 	IF v_supplier_view_type = 'TRANSFORMED' OR
341 		v_buyer_tpid = p_tpid OR
342 		p_site IS NULL THEN
343 		RETURN p_price;
344 
345 	ELSE
346 		RETURN untransform_one_price(p_auction_header_id, p_line_number,
347 									p_price, p_quantity, p_tpid, p_site, p_requested_supplier_id);
348 	END IF;
349 
350 END calculate_price;
351 
352 
353 -- ------------------------------------------------------------------------
354 -- untransform_one_price
355 --
356 -- this utility function just transforms one price
357 -- ------------------------------------------------------------------------
358 
359 FUNCTION untransform_one_price
360 	(p_auction_header_id 	IN NUMBER,
361 	 p_line_number			IN NUMBER,
362 	 p_price				IN NUMBER,
363 	 p_quantity 			IN NUMBER,
364 	 p_tpid 				IN NUMBER,
365 	 p_site_id				IN NUMBER)
366 	RETURN NUMBER
367 IS
368 BEGIN
369   return untransform_one_price(p_auction_header_id, p_line_number, p_price,
370                                p_quantity, p_tpid, p_site_id, null);
371 END untransform_one_price;
372 
373 
374 FUNCTION untransform_one_price
375 	(p_auction_header_id 	IN NUMBER,
376 	 p_line_number			IN NUMBER,
377 	 p_price				IN NUMBER,
378 	 p_quantity 			IN NUMBER,
379 	 p_tpid 				IN NUMBER,
380 	 p_site_id				IN NUMBER,
381          p_requested_supplier_id                IN NUMBER)
382 	RETURN NUMBER
383 IS
384 	v_percentage			pon_pf_supplier_formula.percentage%TYPE;
385 	v_unit					pon_pf_supplier_formula.unit_price%TYPE;
386 	v_amount				pon_pf_supplier_formula.fixed_amount%TYPE;
387 	v_quantity				NUMBER;
388 
389 BEGIN
390 
391 	SELECT unit_price, fixed_amount, percentage
392 	INTO v_unit, v_amount, v_percentage
393 	FROM pon_pf_supplier_formula
394 	WHERE auction_header_id = p_auction_header_id
395 		AND line_number = p_line_number
396 		AND ((trading_partner_id = p_tpid AND
397                       vendor_site_id = p_site_id)
398                      OR requested_supplier_id = p_requested_supplier_id);
399 
400 	v_quantity := p_quantity;
401 	IF v_quantity IS NULL OR
402 		v_quantity = 0 THEN
403 		v_quantity := 1;
404 	END IF;
405 
406 	RETURN ((p_price - v_unit - v_amount/v_quantity) / v_percentage);
407 
408 EXCEPTION
409 
410 	WHEN NO_DATA_FOUND THEN
411 		RETURN p_price;
412 
413 END untransform_one_price;
414 --
415 --
416 -- ------------------------------------------------------------------------
417 -- calculate_quote_amount
418 -- In case of Regular line, lot, group line, lot line:
419 -- calculated as sum of line totals, which are quantity * bid price for each line
420 -- In case of GROUP:
421 -- calculated as sum of all group line totals,
422 -- which are group line quantity * group line bid price for each group lineline
423 -- ------------------------------------------------------------------------
424 
425 FUNCTION calculate_quote_amount
426 	(p_auction_header_id 	IN pon_bid_headers.auction_header_id%TYPE,
427  	 p_line_number			IN pon_auction_item_prices_all.line_number%TYPE,
428 	 p_bid_number			IN pon_bid_headers.bid_number%TYPE,
429 	 p_supplier_view_type	IN pon_auction_headers_all.supplier_view_type%TYPE,
430 	 p_buyer_tpid			IN pon_auction_headers_all.trading_partner_id%TYPE,
431 	 p_tpid 				IN pon_bid_headers.trading_partner_id%TYPE,
432 	 p_site					IN pon_bid_headers.vendor_site_id%TYPE)
433 	RETURN NUMBER
434 IS
435     v_quote_amount             NUMBER;
436     v_group_type                    pon_auction_item_prices_all.group_type%TYPE;
437 BEGIN
438      SELECT group_type
439 	 INTO v_group_type
440      FROM pon_auction_item_prices_all
441      WHERE auction_header_id = p_auction_header_id
442            AND line_number = p_line_number;
443 
444 	-- Transformed View: no need to reverse-transform prices
445 	IF (p_supplier_view_type = 'TRANSFORMED' OR
446 		p_buyer_tpid = p_tpid OR
447 		p_site IS NULL) THEN
448 
449 
450            SELECT DECODE (al.group_type, 'GROUP', bl.group_amount,
451                       nvl(bl.quantity, decode(al.ORDER_TYPE_LOOKUP_CODE, 'FIXED PRICE', 1, al.quantity)) * bl.price)
452            INTO v_quote_amount
453            FROM pon_bid_item_prices bl, pon_auction_item_prices_all al
454            WHERE bl.bid_number = p_bid_number
455            AND bl.line_number = p_line_number
456            AND bl.auction_header_id = al.auction_header_id
457            AND bl.line_number = al.line_number;
458 
462 	   -- Untransformed View and GROUP Line Type
459 	-- Untransformed View: we must reverse-transform prices
460 	ELSE
461 
463 	   IF (v_group_type = 'GROUP') THEN
464               -- Supplier does not see group amount in untransformed view
465               v_quote_amount := NULL;
466            -- Untransformed View and LOT or LINE Line Type
467            ELSE
468 			SELECT
469                          nvl(bl.quantity, decode(al.ORDER_TYPE_LOOKUP_CODE, 'FIXED PRICE', 1, al.quantity))
470 		       * nvl(PON_TRANSFORM_BIDDING_PKG.untransform_one_price(p_auction_header_id,
471 bl.line_number, bl.price, al.quantity, p_tpid, p_site), 0)
472         		INTO v_quote_amount
473         		FROM pon_bid_item_prices bl, pon_auction_item_prices_all al
474         		WHERE bl.bid_number = p_bid_number
475         		AND bl.line_number = p_line_number
476         		AND al.auction_header_id = bl.auction_header_id
477 			AND al.line_number = bl.line_number;
478 
479 	   END IF;
480      END IF;
481 
482      RETURN v_quote_amount;
483 
484 END calculate_quote_amount;
485 --
486 --
487 -- -----------------------------------------------------------------------
488 -- has_pf_values_defined
489 --
490 -- given a buyer price factor, determines if values have been entered for this trading partner/site
491 --
492 -- ----------------------------------------------------------------------
493 
494 FUNCTION has_pf_values_defined
495          (p_auction_header_id    IN NUMBER,
496           p_line_number          IN NUMBER,
497           p_pf_seq_number        IN NUMBER,
498           p_trading_partner_id   IN NUMBER,
499           p_vendor_site_id       IN NUMBER) RETURN VARCHAR2
500 IS
501 BEGIN
502   return  has_pf_values_defined(p_auction_header_id, p_line_number,
503                 p_pf_seq_number, p_trading_partner_id, p_vendor_site_id, null);
504 END has_pf_values_defined;
505 
506 
507 FUNCTION has_pf_values_defined
508          (p_auction_header_id    IN NUMBER,
509           p_line_number          IN NUMBER,
510           p_pf_seq_number        IN NUMBER,
511           p_trading_partner_id   IN NUMBER,
512           p_vendor_site_id       IN NUMBER,
513           p_requested_supplier_id IN NUMBER) RETURN VARCHAR2
514 IS
515    v_supplier_seq_number NUMBER;
516    v_has_pf_values_defined VARCHAR2(1);
517 
518 BEGIN
519 
520    select sequence
521    into   v_supplier_seq_number
522    from   pon_bidding_parties
523    where  auction_header_id = p_auction_header_id and
524           ((trading_partner_id = p_trading_partner_id and
525             vendor_site_id = p_vendor_site_id) OR
526            requested_supplier_id = p_requested_supplier_id);
527 
528    select 'Y'
529    into   v_has_pf_values_defined
530    from   pon_pf_supplier_values
531    where  auction_header_id = p_auction_header_id and
532           line_number = p_line_number and
533           pf_seq_number = p_pf_seq_number and
534           supplier_seq_number = v_supplier_seq_number;
535 
536 
537    RETURN v_has_pf_values_defined;
538 
539 EXCEPTION
540 
541         WHEN NO_DATA_FOUND THEN
542                 RETURN 'N';
543 
544 END has_pf_values_defined;
545 --
546 --
547 PROCEDURE GET_DISPLAY_CURRENCY_INFO (p_auction_header_id            IN  NUMBER,
548                                      p_trading_partner_id           IN  NUMBER,
549                                      p_vendor_site_id               IN  NUMBER,
550                                      p_trading_partner_contact_id   IN  NUMBER,
551                                      p_is_buyer                     IN  VARCHAR2,
552                                      x_currency                     OUT NOCOPY VARCHAR2,
553                                      x_rate                         OUT NOCOPY NUMBER,
554                                      x_precision                    OUT NOCOPY NUMBER,
555                                      x_currency_precision           OUT NOCOPY NUMBER,
556                                      x_site_id                      OUT NOCOPY NUMBER,
557                                      x_bid_number                   OUT NOCOPY NUMBER,
558                                      x_bid_status                   OUT NOCOPY VARCHAR2) IS
559 
560 BEGIN
561 
562 
563   --
564   -- Default currency information from negotiation
565   --
566 
567 
568   select ah.currency_code, 1 rate, ah.number_price_decimals, fc.precision, -1 site_id, -1 bid_number, null
569   into   x_currency, x_rate, x_precision, x_currency_precision, x_site_id, x_bid_number, x_bid_status
570   from   pon_auction_headers_all ah,
571          fnd_currencies fc
572   where  ah.auction_header_id = p_auction_header_id and
573          ah.currency_code = fc.currency_code;
574 
575 
576   --
577   -- For suppliers, check if we can get currency information from a bid (query goes across all amendments)
578   --
579 
580 
581   IF (p_is_buyer = 'N') THEN
582 
583 
584     BEGIN
585 
586        select vendor_site_id, bid_currency_code, rate, number_price_decimals, precision
587        into   x_site_id, x_currency, x_rate, x_precision, x_currency_precision
588        from (select   bh.vendor_site_id, bh.bid_currency_code, bh.rate, bh.number_price_decimals, fc.precision
589              from     pon_bid_headers bh,
590                       pon_auction_headers_all ah,
591                       fnd_currencies fc
592              where    ah.auction_header_id_orig_amend = (select auction_header_id_orig_amend
593                                                          from   pon_auction_headers_all
594                                                          where  auction_header_id = p_auction_header_id) and
595                       bh.auction_header_id = ah.auction_header_id and
596                       bh.trading_partner_id = p_trading_partner_id and
597                       bh.vendor_site_id like nvl(to_char(p_vendor_site_id), '%') and
598                       bh.trading_partner_contact_id = p_trading_partner_contact_id and
599                       bh.bid_currency_code = fc.currency_code
600              order by ah.amendment_number desc,
601                       decode(bh.bid_status, 'DRAFT', 9, 'ACTIVE', 8, 'RESUBMISSION' , 7, 'DISQUALIFIED', 6, 'ARCHIVED', 4, 'ARCHIVED_DRAFT', 3) desc,
602                       bh.publish_date desc)
603        where rownum = 1;
604 
605     EXCEPTION
606 
607             --
608             -- If there is no bid for a supplier, the negotiation's currency will be used
609             -- Also, we will select the default site
610             --
611             WHEN NO_DATA_FOUND THEN
612 
613                 if (p_vendor_site_id is null) then -- look in invitees table, if there is a site
614                   x_site_id := PON_TRANSFORM_BIDDING_PKG.FIND_USER_SITE(p_auction_header_id, p_trading_partner_id, p_trading_partner_contact_id);
615 
616                 else
617                   x_site_id := p_vendor_site_id;
618 
619                 end if;
620 
621                 if (x_site_id is null) then -- if still null (can happen when supplier was not invited)
622                   x_site_id := -1;
623                  end if;
624 
625     END;
626 
627 
628     BEGIN
629 
630        select bid_number, bid_status
631        into   x_bid_number, x_bid_status
632        from (select   bh.bid_number, bh.bid_status
633              from     pon_bid_headers bh,
634                       pon_auction_headers_all ah
635              where    ah.auction_header_id_orig_amend = (select auction_header_id_orig_amend
636                                                          from   pon_auction_headers_all
637                                                          where  auction_header_id = p_auction_header_id) and
638                       bh.auction_header_id = ah.auction_header_id and
639                       bh.trading_partner_id = p_trading_partner_id and
640                       bh.vendor_site_id = x_site_id
641              order by ah.amendment_number desc,
642                       decode(bh.bid_status, 'DRAFT', 9, 'ACTIVE', 8, 'RESUBMISSION' , 7, 'DISQUALIFIED', 6, 'ARCHIVED', 4, 'ARCHIVED_DRAFT', 3) desc,
643                       bh.publish_date desc)
644        where rownum = 1;
645 
646     EXCEPTION
647 
648             WHEN NO_DATA_FOUND THEN
649                 x_bid_number := -1;
650                 x_bid_status := null;
651      END;
652 
653 
654 
655   END IF;
656 
657 END GET_DISPLAY_CURRENCY_INFO;
658 --
659 --
660 --
661 END  PON_TRANSFORM_BIDDING_PKG;