[Home] [Help]
PACKAGE BODY: APPS.AST_EVENT_ORDER_PKG
Source
1 PACKAGE BODY ast_event_order_pkg AS
2 /* $Header: astevoeb.pls 115.7 2002/02/06 12:32:47 pkm ship $ */
3
4 g_qte_header_rec ASO_QUOTE_PUB.Qte_Header_Rec_Type;
5 g_qte_line_tbl ASO_QUOTE_PUB.Qte_Line_Tbl_Type;
6 g_hd_payment_tbl ASO_QUOTE_PUB.Payment_Tbl_Type;
7 g_payment_rec ASO_QUOTE_PUB.Payment_Rec_Type;
8 g_hd_shipment_tbl ASO_QUOTE_PUB.Shipment_tbl_Type;
9 g_hd_tax_detail_tbl ASO_QUOTE_PUB.Tax_Detail_Tbl_Type;
10 g_tax_detail_rec ASO_QUOTE_PUB.Tax_Detail_Rec_Type;
11 g_ln_shipment_tbl ASO_QUOTE_PUB.Shipment_Tbl_Type;
12 -- ***************************************************
13 PROCEDURE open_order (
14 p_cust_party_id IN NUMBER
15 , p_cust_account_id IN NUMBER
16 , p_currency_code IN VARCHAR2
17 , p_source_code IN VARCHAR2 DEFAULT 'ASO'
18 , p_order_type_id IN NUMBER DEFAULT 1000
19 , p_price_list_id IN NUMBER
20 , p_employee_id IN NUMBER
21 , p_invoice_party_id IN NUMBER
22 , p_invoice_party_site_id IN NUMBER
23 , p_quote_header_id IN NUMBER DEFAULT NULL
24 ) IS
25 BEGIN
26
27 -- reinitialize the order header record types
28 g_qte_header_rec := ASO_QUOTE_PUB.G_MISS_QTE_HEADER_REC;
29 g_payment_rec := ASO_QUOTE_PUB.G_MISS_Payment_REC;
30 -- assign parameters passed to the quote header record
31 g_qte_header_rec.quote_source_code := p_source_code ;
32 g_qte_header_rec.currency_code := p_currency_code ;
33 g_qte_header_rec.party_id := p_cust_party_id;
34 -- worked without Quote header id, why would have a quote header with
35 -- an event order anyway
36 IF ( p_quote_header_id IS NOT NULL ) THEN
37 g_qte_header_rec.quote_header_id := p_quote_header_id;
38 END IF;
39 g_qte_header_rec.order_type_id := p_order_type_id;
40 g_qte_header_rec.price_list_id := p_price_list_id;
41 -- employee id was set up to jtf_rs_salesreps table
42 -- the create_order check on ra_salesreps view which does not included the jtf
43 -- but return 'S'uccess
44 g_qte_header_rec.employee_person_id := p_employee_id;
45 g_qte_header_rec.cust_account_id := p_cust_account_id;
46 g_qte_header_rec.invoice_to_party_id := p_invoice_party_id;
47 g_qte_header_rec.invoice_to_party_site_id := p_invoice_party_site_id;
48 -- reinitialize the order line table types
49 g_hd_shipment_tbl := ASO_QUOTE_PUB.G_MISS_Shipment_TBL;
50 g_qte_line_tbl := ASO_QUOTE_PUB.G_MISS_QTE_LINE_TBL;
51 g_ln_shipment_tbl := ASO_QUOTE_PUB.G_MISS_Shipment_TBL;
52 g_hd_payment_tbl := ASO_QUOTE_PUB.G_MISS_Payment_TBL;
53
54 END open_order;
55 -- ***************************************************
56 PROCEDURE add_order_line (
57 p_ship_party_id IN NUMBER
58 , p_ship_party_site_id IN NUMBER
59 , p_inventory_item_id IN NUMBER
60 , p_line_list_price IN NUMBER
61 , p_quantity IN NUMBER DEFAULT 1
62 , p_discount IN NUMBER DEFAULT NULL
63 , p_discount_uom IN VARCHAR2 DEFAULT NULL
64 , p_uom_code IN VARCHAR2 DEFAULT 'Ea'
65 , p_price_list_id IN NUMBER DEFAULT NULL
66 , p_price_list_line_id IN NUMBER DEFAULT NULL
67 ) IS
68 l_line_num NUMBER ;
69 BEGIN
70 l_line_num := g_hd_shipment_tbl.COUNT + 1;
71 -- if the account is null; create_order ship to org.
72 -- complaint on ship_to_contact if passed individual party_id
73 if g_qte_header_rec.cust_account_id is not null then
74 g_hd_shipment_tbl(l_line_num).ship_to_party_id := p_ship_party_id;
75 else
76 g_hd_shipment_tbl(l_line_num).ship_to_party_id := g_qte_header_rec.party_id;
77 end if;
78 g_hd_shipment_tbl(l_line_num).ship_to_party_site_id := p_ship_party_site_id;
79 g_qte_line_tbl(l_line_num).inventory_item_id := p_inventory_item_id;
80 g_qte_line_tbl(l_line_num).quantity := p_quantity;
81 IF p_discount_uom = 'P' THEN -- percentage
82 g_qte_line_tbl(l_line_num).line_adjusted_percent := p_discount;
83 ELSIF p_discount_uom = 'A' THEN -- amount
84 g_qte_line_tbl(l_line_num).line_adjusted_amount := p_discount;
85 ELSE
86 NULL;
87 END IF;
88 g_qte_line_tbl(l_line_num).UOM_code := p_uom_code;
89 IF ( p_price_list_id IS NULL ) THEN
90 g_qte_line_tbl(l_line_num).price_list_id := g_qte_header_rec.price_list_id;
91 ELSE
92 g_qte_line_tbl(l_line_num).price_list_id := p_price_list_id;
93 END IF;
94 g_qte_line_tbl(l_line_num).line_category_code := 'ORDER';
95 g_ln_shipment_tbl(l_line_num).quantity := p_quantity;
96 g_ln_shipment_tbl(l_line_num).qte_line_index := l_line_num;
97 END add_order_line;
98 -- ***************************************************
99 PROCEDURE submit_order (
100 p_payment_term_id IN NUMBER DEFAULT NULL
101 , p_payment_amount IN NUMBER DEFAULT NULL
102 , p_payment_type IN VARCHAR2 DEFAULT NULL
103 , p_payment_option IN VARCHAR2 DEFAULT NULL
104 , p_credit_card_code IN VARCHAR2 DEFAULT NULL
105 , p_credit_card_holder_name IN VARCHAR2 DEFAULT NULL
106 , p_payment_ref_number IN VARCHAR2 DEFAULT NULL
107 , p_credit_card_approval IN VARCHAR2 DEFAULT NULL
108 , p_credit_card_expiration IN DATE DEFAULT NULL
109 , p_total_discount IN NUMBER DEFAULT NULL
110 , p_total_discount_uom IN VARCHAR2 DEFAULT NULL
111 , x_return_status OUT VARCHAR2
112 , x_order_header_rec OUT ASO_ORDER_INT.Order_Header_rec_type
113 , x_order_line_tbl OUT ASO_ORDER_INT.Order_Line_tbl_type
114 ) IS
115 l_control_rec ASO_ORDER_INT.control_rec_type;
116 l_api_ver NUMBER := 1.0;
117 l_init_msg_list VARCHAR2(1) := FND_API.G_TRUE;
118 l_commit VARCHAR2(1) := FND_API.G_TRUE;
119 x_msg_count NUMBER;
120 x_msg_data VARCHAR2(2000);
121 BEGIN
122 l_control_rec.book_flag := FND_API.G_TRUE;
123 l_control_rec.calculate_price := FND_API.G_TRUE;
124
125 -- assign payment information passed
126 IF ( p_payment_term_id IS NOT NULL ) THEN
127 g_hd_payment_tbl(1).payment_term_id := p_payment_term_id ; -- FK RA_TERMS_B
128 g_hd_payment_tbl(1).payment_type_code := p_payment_type;
129 g_hd_payment_tbl(1).payment_amount := p_payment_amount ;
130 IF ( p_credit_card_code IS NOT NULL ) THEN
131 g_hd_payment_tbl(1).credit_card_code := p_credit_card_code;
132 g_hd_payment_tbl(1).credit_card_holder_name := p_credit_card_holder_name;
133 g_hd_payment_tbl(1).credit_card_expiration_date := p_credit_card_expiration;
134 IF ( p_credit_card_approval IS NOT NULL ) THEN
135 g_hd_payment_tbl(1).credit_card_approval_code := p_credit_card_approval;
136 END IF;
137 END IF;
138 -- this has credit card number , PO number or check number
139 g_hd_payment_tbl(1).payment_ref_number := p_payment_ref_number;
140 END IF;
141
142 IF p_total_discount_uom = 'A' THEN
143 g_qte_header_rec.total_adjusted_amount := p_total_discount ;
144 ELSIF p_total_discount_uom = 'P' THEN
145 g_qte_header_rec.total_adjusted_percent := p_total_discount ;
146 END IF;
147
148 -- initialize the message stack
149 FND_MSG_PUB.Initialize;
150
151 ASO_ORDER_INT.create_order(
152 p_api_version_number => l_api_ver
153 , p_init_msg_list => l_init_msg_list
154 , p_commit => l_commit
155 , p_qte_rec => g_qte_header_rec
156 , p_header_payment_tbl => g_hd_payment_tbl
157 , p_header_shipment_tbl => g_hd_shipment_tbl
158 , p_header_tax_detail_tbl => g_hd_tax_detail_tbl
159 , p_qte_line_tbl => g_qte_line_tbl
160 , p_line_shipment_tbl => g_ln_shipment_tbl
161 , p_control_rec => l_control_rec
162 , x_order_header_rec => x_order_header_rec
163 , x_order_line_tbl => x_order_line_tbl
164 , x_return_status => x_return_status
165 , x_msg_count => x_msg_count
166 , x_msg_data => x_msg_data
167 );
168
169 END submit_order;
170 -- ***************************************************
171 END ast_event_order_pkg;