1 PACKAGE po_auto_header_process_pvt AUTHID CURRENT_USER AS
2 /* $Header: PO_AUTO_HEADER_PROCESS_PVT.pls 120.0 2010/02/28 14:11:24 ssreekum noship $ */
3
4 /* ============================================================================
5 **
6 ** NAME
7 ** PO_AUTO_HEADER_PROCESS_PVT.pls
8 **
9 ** DESCRIPTION
10 ** This package contains logic for AutoCreate Header processing stage
11 ** This API calls the subroutines to handle the derivation, defaulting,
12 ** validation and insert/update of the Headers.
13 **
14 ** - Fetch data from po_headers_interface
15 ** - Derive Header
16 ** - Default Header
17 ** - Validate Header
18 ** - Insert into po_headers_draft_all
19 ** - For Global Agreement insert into org_assignments
20 **
21 ** The procedures of this package are called from PO_AUTOCREATE_MAINPROC_PVT.process_header
22 **
23 ** HISTORY
24 ** 06/11/09 bisdas Created
25 ==============================================================================*/
26
27
28
29 /* ----------------------------------------------------
30 ----------------- PUBLIC PROCEDURES ----------------
31 ---------------------------------------------------- */
32
33 /* ============================================================================
34 NAME: fetch_headers
35 DESC: Fetch header details into header record type
36
37 ARGS: OUT : x_headers PO_AUTOCREATE_TYPES.headers_rec_type (Record variable to hold the header info)
38
39 Algorithm: Based on the in parameters select the interface record(s) into
40 the header record type.
41
42 ==============================================================================*/
43
44 PROCEDURE fetch_headers ( p_interface_header_id IN NUMBER,
45 x_headers OUT NOCOPY PO_AUTOCREATE_TYPES.headers_rec_type);
46
47 /* ============================================================================
48 NAME: derive_and_default_headers
49 DESC: Perform derive logic on header records from Interface table.
50
51 * Get the vendor details (po_vendors_sv.get_vendor_info
52 * Get the vendor site info (po_vendor_sites_sv.get_vendor_site_info)
53 (These values needs to be transferred to validation logic)
54 * Derive Pay On Code
55 * Derive Rate (get_rate_for_req_price)
56 * Derive ship to and bill to
57 * Default amount tolerance values for GBPA
58
59 ARGS: IN OUT : x_headers PO_AUTOCREATE_TYPES.headers_rec_type
60 Record variable to hold the header info
61
62 NOTE: If possible use the procedures from PDOI
63 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64 - PO_PDOI_HEADER_PROCESS_PVT.derive_rate_type_code
65 - PO_PDOI_HEADER_PROCESS_PVT.derive_agent_id
66 - PO_PDOI_HEADER_PROCESS_PVT.derive_location_id
67 - PO_PDOI_HEADER_PROCESS_PVT.derive_terms_id
68 - PO_PDOI_HEADER_PROCESS_PVT.derive_vendor_id
69 - PO_PDOI_HEADER_PROCESS_PVT.derive_vendor_site_id
70 - PO_PDOI_HEADER_PROCESS_PVT.derive_vendor_contact_id
71 - PO_PDOI_HEADER_PROCESS_PVT.derive_style_id
72 - PO_PDOI_HEADER_PROCESS_PVT.derive_from_header_id
73
74 Use the procedure PO_PDOI_UTL.generate_ordered_num_list to create
75 the index table. For Header set the length of index table
76 (l_index_tbl) to 1.
77 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
78
79 ==============================================================================*/
80
81 PROCEDURE derive_and_default_headers ( x_headers IN OUT NOCOPY PO_AUTOCREATE_TYPES.headers_rec_type);
82
83
84 /* ============================================================================
85 NAME: Validate_header
86 DESC: Validate header attributes.
87
88 1. Validate the following attributes.
89 freight_carrier
90 fob
91 freight_terms
92 ap_terms
93
94 First validate the vendor site attribute. If it is valid use it.
95 Otherwise, validate the vendor attribute. If it is valid then use
96 that. if that is also not valid, then leave the value to be null.
97
98 2. validate ship to location and bill to location
99
100 ARGS: IN OUT : x_headers PO_AUTOCREATE_TYPES.headers_rec_type -Record variable to hold the header info
101
102 NOTE: Use the following check to validate ship_to and bill_to locations:
103 select 'Y' into x_is_valid
104 from hr_locations_all
105 where location_id = x_valid_ship_to/ x_valid_bill_to
106 and NVL(ship_to_site_flag, 'N') = 'Y'
107 and NVL(trunc(inactive_date),trunc(SYSDATE)+1) > trunc(SYSDATE);
108
109 ==============================================================================*/
110
111 PROCEDURE validate_header ( x_headers IN OUT NOCOPY PO_AUTOCREATE_TYPES.headers_rec_type);
112
113
114 /* ============================================================================
115 NAME: merge_to_headers_draft
116 DESC: Insert/update header records into po_headers_draft_all table.
117
118 ARGS: IN OUT : x_headers PO_AUTOCREATE_TYPES.headers_rec_type
119
120 NOTE: if NEW DOCUMENT
121 1. Create a draft record
122 2. Create headers_draft record
123 else if ADD TO DOCUMENT
124 if there is no draft already exists for this document
125 1. create a new draft record.
126 2. popuate the headers draft from the main table.
127 3. update (if required) the headers draft using headers_rec_type
128 else if there is a draft already exists
129 1. update (if required) the draft record.
130 2. update (if required) the headers draft record using headers_rec_type
131 end;
132 end;
133
134 ===========================================================================*/
135
136 PROCEDURE merge_to_headers_draft ( x_headers IN OUT NOCOPY PO_AUTOCREATE_TYPES.headers_rec_type);
137
138 /* ============================================================================
139 NAME: merge_to_org_assign_draft
140 DESC: Insert rows into po_ga_org_assign draft table;
141 This applies only to global blanket
142
143 ARGS: IN OUT : x_headers PO_AUTOCREATE_TYPES.headers_rec_type
144
145 NOTE: if NEW DOCUMENT
146 1. Create a ga_org_assignments_draft record.
147 end;
148 There would not be an ADD TO scenario for GBPA. So the rest of the
149 if-else is not required.
150
151 ==============================================================================*/
152
153 PROCEDURE merge_to_org_assign_draft ( x_headers IN OUT NOCOPY PO_AUTOCREATE_TYPES.headers_rec_type);
154
155 END PO_AUTO_HEADER_PROCESS_PVT;