75:
76:
77: BEGIN
78:
79: aso_debug_pub.g_debug_flag := nvl(fnd_profile.value('ASO_ENABLE_DEBUG'),'N');
80:
81: -- Standard Start of API savepoint
82: SAVEPOINT ALLOCATE_SALES_CREDITS_PVT;
83:
103: --
104: -- API body
105: --
106:
107: IF aso_debug_pub.g_debug_flag = 'Y' THEN
108: aso_debug_pub.add('Allocate_Sales_Credits: Begin ',1,'Y');
109: aso_debug_pub.add('Allocate_Sales_Credits: l_auto_sales_cred_prof: '||l_auto_sales_cred_prof,1,'N');
110: aso_debug_pub.add('Allocate_Sales_Credits: l_auto_sales_team_prof: '||l_auto_sales_team_prof,1,'N');
111: aso_debug_pub.add('Allocate_Sales_Credits: p_control_rec.submit_quote_flag: '||p_control_rec.submit_quote_flag,1,'N');
104: -- API body
105: --
106:
107: IF aso_debug_pub.g_debug_flag = 'Y' THEN
108: aso_debug_pub.add('Allocate_Sales_Credits: Begin ',1,'Y');
109: aso_debug_pub.add('Allocate_Sales_Credits: l_auto_sales_cred_prof: '||l_auto_sales_cred_prof,1,'N');
110: aso_debug_pub.add('Allocate_Sales_Credits: l_auto_sales_team_prof: '||l_auto_sales_team_prof,1,'N');
111: aso_debug_pub.add('Allocate_Sales_Credits: p_control_rec.submit_quote_flag: '||p_control_rec.submit_quote_flag,1,'N');
112: aso_debug_pub.add('Allocate_Sales_Credits: p_qte_header_rec.quote_header_id: '||p_qte_header_rec.quote_header_id,1,'N');
105: --
106:
107: IF aso_debug_pub.g_debug_flag = 'Y' THEN
108: aso_debug_pub.add('Allocate_Sales_Credits: Begin ',1,'Y');
109: aso_debug_pub.add('Allocate_Sales_Credits: l_auto_sales_cred_prof: '||l_auto_sales_cred_prof,1,'N');
110: aso_debug_pub.add('Allocate_Sales_Credits: l_auto_sales_team_prof: '||l_auto_sales_team_prof,1,'N');
111: aso_debug_pub.add('Allocate_Sales_Credits: p_control_rec.submit_quote_flag: '||p_control_rec.submit_quote_flag,1,'N');
112: aso_debug_pub.add('Allocate_Sales_Credits: p_qte_header_rec.quote_header_id: '||p_qte_header_rec.quote_header_id,1,'N');
113: aso_debug_pub.add('Allocate_Sales_Credits: p_qte_header_rec.last_update_date: '||p_qte_header_rec.last_update_date,1,'N');
106:
107: IF aso_debug_pub.g_debug_flag = 'Y' THEN
108: aso_debug_pub.add('Allocate_Sales_Credits: Begin ',1,'Y');
109: aso_debug_pub.add('Allocate_Sales_Credits: l_auto_sales_cred_prof: '||l_auto_sales_cred_prof,1,'N');
110: aso_debug_pub.add('Allocate_Sales_Credits: l_auto_sales_team_prof: '||l_auto_sales_team_prof,1,'N');
111: aso_debug_pub.add('Allocate_Sales_Credits: p_control_rec.submit_quote_flag: '||p_control_rec.submit_quote_flag,1,'N');
112: aso_debug_pub.add('Allocate_Sales_Credits: p_qte_header_rec.quote_header_id: '||p_qte_header_rec.quote_header_id,1,'N');
113: aso_debug_pub.add('Allocate_Sales_Credits: p_qte_header_rec.last_update_date: '||p_qte_header_rec.last_update_date,1,'N');
114: END IF;
107: IF aso_debug_pub.g_debug_flag = 'Y' THEN
108: aso_debug_pub.add('Allocate_Sales_Credits: Begin ',1,'Y');
109: aso_debug_pub.add('Allocate_Sales_Credits: l_auto_sales_cred_prof: '||l_auto_sales_cred_prof,1,'N');
110: aso_debug_pub.add('Allocate_Sales_Credits: l_auto_sales_team_prof: '||l_auto_sales_team_prof,1,'N');
111: aso_debug_pub.add('Allocate_Sales_Credits: p_control_rec.submit_quote_flag: '||p_control_rec.submit_quote_flag,1,'N');
112: aso_debug_pub.add('Allocate_Sales_Credits: p_qte_header_rec.quote_header_id: '||p_qte_header_rec.quote_header_id,1,'N');
113: aso_debug_pub.add('Allocate_Sales_Credits: p_qte_header_rec.last_update_date: '||p_qte_header_rec.last_update_date,1,'N');
114: END IF;
115:
108: aso_debug_pub.add('Allocate_Sales_Credits: Begin ',1,'Y');
109: aso_debug_pub.add('Allocate_Sales_Credits: l_auto_sales_cred_prof: '||l_auto_sales_cred_prof,1,'N');
110: aso_debug_pub.add('Allocate_Sales_Credits: l_auto_sales_team_prof: '||l_auto_sales_team_prof,1,'N');
111: aso_debug_pub.add('Allocate_Sales_Credits: p_control_rec.submit_quote_flag: '||p_control_rec.submit_quote_flag,1,'N');
112: aso_debug_pub.add('Allocate_Sales_Credits: p_qte_header_rec.quote_header_id: '||p_qte_header_rec.quote_header_id,1,'N');
113: aso_debug_pub.add('Allocate_Sales_Credits: p_qte_header_rec.last_update_date: '||p_qte_header_rec.last_update_date,1,'N');
114: END IF;
115:
116: -- Basic Validations
109: aso_debug_pub.add('Allocate_Sales_Credits: l_auto_sales_cred_prof: '||l_auto_sales_cred_prof,1,'N');
110: aso_debug_pub.add('Allocate_Sales_Credits: l_auto_sales_team_prof: '||l_auto_sales_team_prof,1,'N');
111: aso_debug_pub.add('Allocate_Sales_Credits: p_control_rec.submit_quote_flag: '||p_control_rec.submit_quote_flag,1,'N');
112: aso_debug_pub.add('Allocate_Sales_Credits: p_qte_header_rec.quote_header_id: '||p_qte_header_rec.quote_header_id,1,'N');
113: aso_debug_pub.add('Allocate_Sales_Credits: p_qte_header_rec.last_update_date: '||p_qte_header_rec.last_update_date,1,'N');
114: END IF;
115:
116: -- Basic Validations
117: -- Check is Auto Sales Credit Alloc Prof is valid
121:
122: -- Check if security profiles are set
123: IF (NVL(FND_PROFILE.Value('ASO_API_ENABLE_SECURITY'),'N') = 'N') THEN
124:
125: IF aso_debug_pub.g_debug_flag = 'Y' THEN
126: aso_debug_pub.add('API_Enable_Sec is N ',1,'Y');
127: END IF;
128:
129: RAISE Leave_Proc;
122: -- Check if security profiles are set
123: IF (NVL(FND_PROFILE.Value('ASO_API_ENABLE_SECURITY'),'N') = 'N') THEN
124:
125: IF aso_debug_pub.g_debug_flag = 'Y' THEN
126: aso_debug_pub.add('API_Enable_Sec is N ',1,'Y');
127: END IF;
128:
129: RAISE Leave_Proc;
130:
174: END IF;
175: RAISE FND_API.G_EXC_ERROR;
176: END IF;
177:
178: IF aso_debug_pub.g_debug_flag = 'Y' THEN
179: aso_debug_pub.add('Allocate_Sales_Credits: l_qte_header_rec.Resource_Id: '||l_qte_header_rec.Resource_Id,1,'N');
180: aso_debug_pub.add('Allocate_Sales_Credits: l_qte_header_rec.Quote_Status_Id: '||l_qte_header_rec.Quote_Status_Id,1,'N');
181: aso_debug_pub.add('Allocate_Sales_Credits: l_qte_header_rec.Pricing_Status_Indicator: '||l_qte_header_rec.Pricing_Status_Indicator,1,'N');
182: END IF;
175: RAISE FND_API.G_EXC_ERROR;
176: END IF;
177:
178: IF aso_debug_pub.g_debug_flag = 'Y' THEN
179: aso_debug_pub.add('Allocate_Sales_Credits: l_qte_header_rec.Resource_Id: '||l_qte_header_rec.Resource_Id,1,'N');
180: aso_debug_pub.add('Allocate_Sales_Credits: l_qte_header_rec.Quote_Status_Id: '||l_qte_header_rec.Quote_Status_Id,1,'N');
181: aso_debug_pub.add('Allocate_Sales_Credits: l_qte_header_rec.Pricing_Status_Indicator: '||l_qte_header_rec.Pricing_Status_Indicator,1,'N');
182: END IF;
183: -- Check if Primary resource exists in the quote
176: END IF;
177:
178: IF aso_debug_pub.g_debug_flag = 'Y' THEN
179: aso_debug_pub.add('Allocate_Sales_Credits: l_qte_header_rec.Resource_Id: '||l_qte_header_rec.Resource_Id,1,'N');
180: aso_debug_pub.add('Allocate_Sales_Credits: l_qte_header_rec.Quote_Status_Id: '||l_qte_header_rec.Quote_Status_Id,1,'N');
181: aso_debug_pub.add('Allocate_Sales_Credits: l_qte_header_rec.Pricing_Status_Indicator: '||l_qte_header_rec.Pricing_Status_Indicator,1,'N');
182: END IF;
183: -- Check if Primary resource exists in the quote
184: IF l_qte_header_rec.Resource_Id IS NULL OR l_qte_header_rec.Resource_Id = FND_API.G_MISS_NUM THEN
177:
178: IF aso_debug_pub.g_debug_flag = 'Y' THEN
179: aso_debug_pub.add('Allocate_Sales_Credits: l_qte_header_rec.Resource_Id: '||l_qte_header_rec.Resource_Id,1,'N');
180: aso_debug_pub.add('Allocate_Sales_Credits: l_qte_header_rec.Quote_Status_Id: '||l_qte_header_rec.Quote_Status_Id,1,'N');
181: aso_debug_pub.add('Allocate_Sales_Credits: l_qte_header_rec.Pricing_Status_Indicator: '||l_qte_header_rec.Pricing_Status_Indicator,1,'N');
182: END IF;
183: -- Check if Primary resource exists in the quote
184: IF l_qte_header_rec.Resource_Id IS NULL OR l_qte_header_rec.Resource_Id = FND_API.G_MISS_NUM THEN
185: RAISE Leave_Proc;
189: OPEN C_Check_Qte_Ordered (l_qte_header_rec.Quote_Status_Id);
190: FETCH C_Check_Qte_Ordered INTO l_ordered;
191: CLOSE C_Check_Qte_Ordered;
192:
193: IF aso_debug_pub.g_debug_flag = 'Y' THEN
194: aso_debug_pub.add('Allocate_Sales_Credits: l_ordered: '||l_ordered,1,'N');
195: END IF;
196: IF l_ordered IS NOT NULL AND l_ordered = 'Y' THEN
197: x_return_status := FND_API.G_RET_STS_ERROR;
190: FETCH C_Check_Qte_Ordered INTO l_ordered;
191: CLOSE C_Check_Qte_Ordered;
192:
193: IF aso_debug_pub.g_debug_flag = 'Y' THEN
194: aso_debug_pub.add('Allocate_Sales_Credits: l_ordered: '||l_ordered,1,'N');
195: END IF;
196: IF l_ordered IS NOT NULL AND l_ordered = 'Y' THEN
197: x_return_status := FND_API.G_RET_STS_ERROR;
198: IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
217: OPEN C_Check_Qte_Line (P_Qte_Header_Rec.Quote_Header_Id);
218: FETCH C_Check_Qte_Line INTO l_line_exists;
219: CLOSE C_Check_Qte_Line;
220:
221: IF aso_debug_pub.g_debug_flag = 'Y' THEN
222: aso_debug_pub.add('Allocate_Sales_Credits: l_line_exists: '||l_line_exists,1,'N');
223: END IF;
224: IF l_line_exists IS NULL OR l_line_exists <> 'Y' THEN
225: x_return_status := FND_API.G_RET_STS_ERROR;
218: FETCH C_Check_Qte_Line INTO l_line_exists;
219: CLOSE C_Check_Qte_Line;
220:
221: IF aso_debug_pub.g_debug_flag = 'Y' THEN
222: aso_debug_pub.add('Allocate_Sales_Credits: l_line_exists: '||l_line_exists,1,'N');
223: END IF;
224: IF l_line_exists IS NULL OR l_line_exists <> 'Y' THEN
225: x_return_status := FND_API.G_RET_STS_ERROR;
226: IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
252: x_return_status => x_return_status,
253: x_msg_count => x_msg_count,
254: x_msg_data => x_msg_data
255: );
256: IF aso_debug_pub.g_debug_flag = 'Y' THEN
257: aso_debug_pub.add('Allocate_Sales_Credits: Assign_Sales_Team:x_return_status: '||x_return_status,1,'N');
258: END IF;
259: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
260: RAISE FND_API.G_EXC_ERROR;
253: x_msg_count => x_msg_count,
254: x_msg_data => x_msg_data
255: );
256: IF aso_debug_pub.g_debug_flag = 'Y' THEN
257: aso_debug_pub.add('Allocate_Sales_Credits: Assign_Sales_Team:x_return_status: '||x_return_status,1,'N');
258: END IF;
259: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
260: RAISE FND_API.G_EXC_ERROR;
261: END IF;
268: -- Throw error if no valid salesreps were found
269: OPEN C_Get_Sreps_Count (l_qte_header_rec.Quote_Number);
270: FETCH C_Get_Sreps_Count INTO l_sreps_count;
271:
272: IF aso_debug_pub.g_debug_flag = 'Y' THEN
273: aso_debug_pub.add('Allocate_Sales_Credits: l_sreps_count: '||l_sreps_count,1,'N');
274: END IF;
275: IF C_Get_Sreps_Count%NOTFOUND OR l_sreps_count = 0 THEN
276: x_return_status := FND_API.G_RET_STS_ERROR;
269: OPEN C_Get_Sreps_Count (l_qte_header_rec.Quote_Number);
270: FETCH C_Get_Sreps_Count INTO l_sreps_count;
271:
272: IF aso_debug_pub.g_debug_flag = 'Y' THEN
273: aso_debug_pub.add('Allocate_Sales_Credits: l_sreps_count: '||l_sreps_count,1,'N');
274: END IF;
275: IF C_Get_Sreps_Count%NOTFOUND OR l_sreps_count = 0 THEN
276: x_return_status := FND_API.G_RET_STS_ERROR;
277: IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
280: END IF;
281: CLOSE C_Get_Sreps_Count;
282: RAISE FND_API.G_EXC_ERROR;
283: END IF;
284: IF aso_debug_pub.g_debug_flag = 'Y' THEN
285: aso_debug_pub.add('Allocate_Sales_Credits: l_sreps_count: '||l_sreps_count,1,'N');
286: END IF;
287: CLOSE C_Get_Sreps_Count;
288:
281: CLOSE C_Get_Sreps_Count;
282: RAISE FND_API.G_EXC_ERROR;
283: END IF;
284: IF aso_debug_pub.g_debug_flag = 'Y' THEN
285: aso_debug_pub.add('Allocate_Sales_Credits: l_sreps_count: '||l_sreps_count,1,'N');
286: END IF;
287: CLOSE C_Get_Sreps_Count;
288:
289: IF aso_debug_pub.g_debug_flag = 'Y' THEN
285: aso_debug_pub.add('Allocate_Sales_Credits: l_sreps_count: '||l_sreps_count,1,'N');
286: END IF;
287: CLOSE C_Get_Sreps_Count;
288:
289: IF aso_debug_pub.g_debug_flag = 'Y' THEN
290: aso_debug_pub.add('Allocate_Sales_Credits: Before Get_Credits ',1,'N');
291: END IF;
292: -- Initiate Temp Tables and Call CN API
293: ASO_SALES_CREDIT_PVT.Get_Credits
286: END IF;
287: CLOSE C_Get_Sreps_Count;
288:
289: IF aso_debug_pub.g_debug_flag = 'Y' THEN
290: aso_debug_pub.add('Allocate_Sales_Credits: Before Get_Credits ',1,'N');
291: END IF;
292: -- Initiate Temp Tables and Call CN API
293: ASO_SALES_CREDIT_PVT.Get_Credits
294: (
299: x_return_status => x_return_status,
300: x_msg_count => x_msg_count,
301: x_msg_data => x_msg_data
302: );
303: IF aso_debug_pub.g_debug_flag = 'Y' THEN
304: aso_debug_pub.add('Allocate_Sales_Credits: After Get_Credits:x_return_status: '||x_return_status,1,'N');
305: END IF;
306: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
307: RAISE FND_API.G_EXC_ERROR;
300: x_msg_count => x_msg_count,
301: x_msg_data => x_msg_data
302: );
303: IF aso_debug_pub.g_debug_flag = 'Y' THEN
304: aso_debug_pub.add('Allocate_Sales_Credits: After Get_Credits:x_return_status: '||x_return_status,1,'N');
305: END IF;
306: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
307: RAISE FND_API.G_EXC_ERROR;
308: END IF;
310: RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
311: END IF;
312:
313:
314: IF aso_debug_pub.g_debug_flag = 'Y' THEN
315: aso_debug_pub.add('Allocate_Sales_Credits: Before Update Qte Hdr ',1,'N');
316: END IF;
317: -- Update quote header with the credit_update_date
318: UPDATE ASO_QUOTE_HEADERS_ALL
311: END IF;
312:
313:
314: IF aso_debug_pub.g_debug_flag = 'Y' THEN
315: aso_debug_pub.add('Allocate_Sales_Credits: Before Update Qte Hdr ',1,'N');
316: END IF;
317: -- Update quote header with the credit_update_date
318: UPDATE ASO_QUOTE_HEADERS_ALL
319: SET Credit_Update_date = sysdate,
325: RETURNING quote_header_id, last_update_date, credit_update_date, object_version_number
326: INTO x_qte_header_rec.Quote_Header_Id, x_qte_header_rec.Last_Update_Date,
327: x_qte_header_rec.credit_update_date, x_qte_header_rec.object_version_number;
328:
329: IF aso_debug_pub.g_debug_flag = 'Y' THEN
330: aso_debug_pub.add('Allocate_Sales_Credits: After Update Qte Hdr ',1,'N');
331: aso_debug_pub.add('Allocate_Sales_Credits: End ',1,'Y');
332: END IF;
333:
326: INTO x_qte_header_rec.Quote_Header_Id, x_qte_header_rec.Last_Update_Date,
327: x_qte_header_rec.credit_update_date, x_qte_header_rec.object_version_number;
328:
329: IF aso_debug_pub.g_debug_flag = 'Y' THEN
330: aso_debug_pub.add('Allocate_Sales_Credits: After Update Qte Hdr ',1,'N');
331: aso_debug_pub.add('Allocate_Sales_Credits: End ',1,'Y');
332: END IF;
333:
334: -- Change START
327: x_qte_header_rec.credit_update_date, x_qte_header_rec.object_version_number;
328:
329: IF aso_debug_pub.g_debug_flag = 'Y' THEN
330: aso_debug_pub.add('Allocate_Sales_Credits: After Update Qte Hdr ',1,'N');
331: aso_debug_pub.add('Allocate_Sales_Credits: End ',1,'Y');
332: END IF;
333:
334: -- Change START
335: -- Release 12 TAP Changes
335: -- Release 12 TAP Changes
336: -- Girish Sachdeva 8/30/2005
337: -- Adding the call to insert record in the ASO_CHANGED_QUOTES
338:
339: IF aso_debug_pub.g_debug_flag = 'Y' THEN
340: aso_debug_pub.add('ASO_SALES_CREDIT_PVT.Allocate_Sales_Credits : Calling ASO_UTILITY_PVT.UPDATE_CHANGED_QUOTES, quote number : ' || l_qte_header_rec.Quote_Number, 1, 'Y');
341: END IF;
342:
343: -- Call to insert record in ASO_CHANGED_QUOTES
336: -- Girish Sachdeva 8/30/2005
337: -- Adding the call to insert record in the ASO_CHANGED_QUOTES
338:
339: IF aso_debug_pub.g_debug_flag = 'Y' THEN
340: aso_debug_pub.add('ASO_SALES_CREDIT_PVT.Allocate_Sales_Credits : Calling ASO_UTILITY_PVT.UPDATE_CHANGED_QUOTES, quote number : ' || l_qte_header_rec.Quote_Number, 1, 'Y');
341: END IF;
342:
343: -- Call to insert record in ASO_CHANGED_QUOTES
344: ASO_UTILITY_PVT.UPDATE_CHANGED_QUOTES(l_qte_header_rec.Quote_Number);
543: OPEN C_Get_Batch_Id;
544: FETCH C_Get_Batch_Id INTO l_batch_id;
545: CLOSE C_Get_Batch_Id;
546:
547: IF aso_debug_pub.g_debug_flag = 'Y' THEN
548: aso_debug_pub.add('Get_Credits: l_batch_id: '||l_batch_id,1,'N');
549: aso_debug_pub.add('Get_Credits: l_cred_upd_lines_prof: '||l_cred_upd_lines_prof,1,'N');
550: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Cust_Account_Id: '||p_qte_header_rec.Cust_Account_Id,1,'N');
551: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Party_Id: '||p_qte_header_rec.Party_Id,1,'N');
544: FETCH C_Get_Batch_Id INTO l_batch_id;
545: CLOSE C_Get_Batch_Id;
546:
547: IF aso_debug_pub.g_debug_flag = 'Y' THEN
548: aso_debug_pub.add('Get_Credits: l_batch_id: '||l_batch_id,1,'N');
549: aso_debug_pub.add('Get_Credits: l_cred_upd_lines_prof: '||l_cred_upd_lines_prof,1,'N');
550: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Cust_Account_Id: '||p_qte_header_rec.Cust_Account_Id,1,'N');
551: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Party_Id: '||p_qte_header_rec.Party_Id,1,'N');
552: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Cust_Party_Id: '||p_qte_header_rec.Cust_Party_Id,1,'N');
545: CLOSE C_Get_Batch_Id;
546:
547: IF aso_debug_pub.g_debug_flag = 'Y' THEN
548: aso_debug_pub.add('Get_Credits: l_batch_id: '||l_batch_id,1,'N');
549: aso_debug_pub.add('Get_Credits: l_cred_upd_lines_prof: '||l_cred_upd_lines_prof,1,'N');
550: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Cust_Account_Id: '||p_qte_header_rec.Cust_Account_Id,1,'N');
551: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Party_Id: '||p_qte_header_rec.Party_Id,1,'N');
552: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Cust_Party_Id: '||p_qte_header_rec.Cust_Party_Id,1,'N');
553: aso_debug_pub.add('Get_Credits: p_qte_header_rec.sold_to_party_site_id: '||p_qte_header_rec.sold_to_party_site_id,1,'N');
546:
547: IF aso_debug_pub.g_debug_flag = 'Y' THEN
548: aso_debug_pub.add('Get_Credits: l_batch_id: '||l_batch_id,1,'N');
549: aso_debug_pub.add('Get_Credits: l_cred_upd_lines_prof: '||l_cred_upd_lines_prof,1,'N');
550: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Cust_Account_Id: '||p_qte_header_rec.Cust_Account_Id,1,'N');
551: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Party_Id: '||p_qte_header_rec.Party_Id,1,'N');
552: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Cust_Party_Id: '||p_qte_header_rec.Cust_Party_Id,1,'N');
553: aso_debug_pub.add('Get_Credits: p_qte_header_rec.sold_to_party_site_id: '||p_qte_header_rec.sold_to_party_site_id,1,'N');
554: aso_debug_pub.add('Get_Credits: attribute1: '||(NVL(p_qte_header_rec.Total_Quote_Price,0) - (NVL(p_qte_header_rec.Total_Tax,0) + NVL(p_qte_header_rec.Total_Shipping_Charge,0))),1,'N');
547: IF aso_debug_pub.g_debug_flag = 'Y' THEN
548: aso_debug_pub.add('Get_Credits: l_batch_id: '||l_batch_id,1,'N');
549: aso_debug_pub.add('Get_Credits: l_cred_upd_lines_prof: '||l_cred_upd_lines_prof,1,'N');
550: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Cust_Account_Id: '||p_qte_header_rec.Cust_Account_Id,1,'N');
551: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Party_Id: '||p_qte_header_rec.Party_Id,1,'N');
552: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Cust_Party_Id: '||p_qte_header_rec.Cust_Party_Id,1,'N');
553: aso_debug_pub.add('Get_Credits: p_qte_header_rec.sold_to_party_site_id: '||p_qte_header_rec.sold_to_party_site_id,1,'N');
554: aso_debug_pub.add('Get_Credits: attribute1: '||(NVL(p_qte_header_rec.Total_Quote_Price,0) - (NVL(p_qte_header_rec.Total_Tax,0) + NVL(p_qte_header_rec.Total_Shipping_Charge,0))),1,'N');
555: END IF;
548: aso_debug_pub.add('Get_Credits: l_batch_id: '||l_batch_id,1,'N');
549: aso_debug_pub.add('Get_Credits: l_cred_upd_lines_prof: '||l_cred_upd_lines_prof,1,'N');
550: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Cust_Account_Id: '||p_qte_header_rec.Cust_Account_Id,1,'N');
551: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Party_Id: '||p_qte_header_rec.Party_Id,1,'N');
552: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Cust_Party_Id: '||p_qte_header_rec.Cust_Party_Id,1,'N');
553: aso_debug_pub.add('Get_Credits: p_qte_header_rec.sold_to_party_site_id: '||p_qte_header_rec.sold_to_party_site_id,1,'N');
554: aso_debug_pub.add('Get_Credits: attribute1: '||(NVL(p_qte_header_rec.Total_Quote_Price,0) - (NVL(p_qte_header_rec.Total_Tax,0) + NVL(p_qte_header_rec.Total_Shipping_Charge,0))),1,'N');
555: END IF;
556:
549: aso_debug_pub.add('Get_Credits: l_cred_upd_lines_prof: '||l_cred_upd_lines_prof,1,'N');
550: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Cust_Account_Id: '||p_qte_header_rec.Cust_Account_Id,1,'N');
551: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Party_Id: '||p_qte_header_rec.Party_Id,1,'N');
552: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Cust_Party_Id: '||p_qte_header_rec.Cust_Party_Id,1,'N');
553: aso_debug_pub.add('Get_Credits: p_qte_header_rec.sold_to_party_site_id: '||p_qte_header_rec.sold_to_party_site_id,1,'N');
554: aso_debug_pub.add('Get_Credits: attribute1: '||(NVL(p_qte_header_rec.Total_Quote_Price,0) - (NVL(p_qte_header_rec.Total_Tax,0) + NVL(p_qte_header_rec.Total_Shipping_Charge,0))),1,'N');
555: END IF;
556:
557: -- Truncate temp tables
550: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Cust_Account_Id: '||p_qte_header_rec.Cust_Account_Id,1,'N');
551: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Party_Id: '||p_qte_header_rec.Party_Id,1,'N');
552: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Cust_Party_Id: '||p_qte_header_rec.Cust_Party_Id,1,'N');
553: aso_debug_pub.add('Get_Credits: p_qte_header_rec.sold_to_party_site_id: '||p_qte_header_rec.sold_to_party_site_id,1,'N');
554: aso_debug_pub.add('Get_Credits: attribute1: '||(NVL(p_qte_header_rec.Total_Quote_Price,0) - (NVL(p_qte_header_rec.Total_Tax,0) + NVL(p_qte_header_rec.Total_Shipping_Charge,0))),1,'N');
555: END IF;
556:
557: -- Truncate temp tables
558: DELETE FROM CN_SCA_LINES_INTERFACE_GTT;
560: DELETE FROM CN_SCA_HEADERS_INTERFACE_GTT;
561:
562: DELETE FROM CN_SCA_LINES_OUTPUT_GTT;
563:
564: IF aso_debug_pub.g_debug_flag = 'Y' THEN
565: aso_debug_pub.add('Get_Credits: After Truncating tables ',1,'N');
566: END IF;
567: -- Get Info to populate attributes
568: OPEN C_Get_Acct_Info (p_qte_header_rec.Cust_Account_Id);
561:
562: DELETE FROM CN_SCA_LINES_OUTPUT_GTT;
563:
564: IF aso_debug_pub.g_debug_flag = 'Y' THEN
565: aso_debug_pub.add('Get_Credits: After Truncating tables ',1,'N');
566: END IF;
567: -- Get Info to populate attributes
568: OPEN C_Get_Acct_Info (p_qte_header_rec.Cust_Account_Id);
569: FETCH C_Get_Acct_Info INTO C_Acct_Rec;
580: OPEN C_Get_Cust_Cont_Info (p_qte_header_rec.Party_Id);
581: FETCH C_Get_Cust_Cont_Info INTO C_Cust_Cont_Rec;
582: CLOSE C_Get_Cust_Cont_Info;
583:
584: IF aso_debug_pub.g_debug_flag = 'Y' THEN
585: aso_debug_pub.add('Get_Credits: Before insert header info ',1,'N');
586: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Postal_Code: '||C_Party_Site_Rec.Postal_Code,1,'N');
587: aso_debug_pub.add('Get_Credits: C_Party_Rec.Party_Name: '||C_Party_Rec.Party_Name,1,'N');
588: aso_debug_pub.add('Get_Credits: C_Cust_Cont_Rec.Phone_Area_Code: '||C_Cust_Cont_Rec.Phone_Area_Code,1,'N');
581: FETCH C_Get_Cust_Cont_Info INTO C_Cust_Cont_Rec;
582: CLOSE C_Get_Cust_Cont_Info;
583:
584: IF aso_debug_pub.g_debug_flag = 'Y' THEN
585: aso_debug_pub.add('Get_Credits: Before insert header info ',1,'N');
586: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Postal_Code: '||C_Party_Site_Rec.Postal_Code,1,'N');
587: aso_debug_pub.add('Get_Credits: C_Party_Rec.Party_Name: '||C_Party_Rec.Party_Name,1,'N');
588: aso_debug_pub.add('Get_Credits: C_Cust_Cont_Rec.Phone_Area_Code: '||C_Cust_Cont_Rec.Phone_Area_Code,1,'N');
589: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.City: '||C_Party_Site_Rec.City,1,'N');
582: CLOSE C_Get_Cust_Cont_Info;
583:
584: IF aso_debug_pub.g_debug_flag = 'Y' THEN
585: aso_debug_pub.add('Get_Credits: Before insert header info ',1,'N');
586: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Postal_Code: '||C_Party_Site_Rec.Postal_Code,1,'N');
587: aso_debug_pub.add('Get_Credits: C_Party_Rec.Party_Name: '||C_Party_Rec.Party_Name,1,'N');
588: aso_debug_pub.add('Get_Credits: C_Cust_Cont_Rec.Phone_Area_Code: '||C_Cust_Cont_Rec.Phone_Area_Code,1,'N');
589: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.City: '||C_Party_Site_Rec.City,1,'N');
590: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Country: '||C_Party_Site_Rec.Country,1,'N');
583:
584: IF aso_debug_pub.g_debug_flag = 'Y' THEN
585: aso_debug_pub.add('Get_Credits: Before insert header info ',1,'N');
586: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Postal_Code: '||C_Party_Site_Rec.Postal_Code,1,'N');
587: aso_debug_pub.add('Get_Credits: C_Party_Rec.Party_Name: '||C_Party_Rec.Party_Name,1,'N');
588: aso_debug_pub.add('Get_Credits: C_Cust_Cont_Rec.Phone_Area_Code: '||C_Cust_Cont_Rec.Phone_Area_Code,1,'N');
589: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.City: '||C_Party_Site_Rec.City,1,'N');
590: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Country: '||C_Party_Site_Rec.Country,1,'N');
591: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.State: '||C_Party_Site_Rec.State,1,'N');
584: IF aso_debug_pub.g_debug_flag = 'Y' THEN
585: aso_debug_pub.add('Get_Credits: Before insert header info ',1,'N');
586: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Postal_Code: '||C_Party_Site_Rec.Postal_Code,1,'N');
587: aso_debug_pub.add('Get_Credits: C_Party_Rec.Party_Name: '||C_Party_Rec.Party_Name,1,'N');
588: aso_debug_pub.add('Get_Credits: C_Cust_Cont_Rec.Phone_Area_Code: '||C_Cust_Cont_Rec.Phone_Area_Code,1,'N');
589: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.City: '||C_Party_Site_Rec.City,1,'N');
590: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Country: '||C_Party_Site_Rec.Country,1,'N');
591: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.State: '||C_Party_Site_Rec.State,1,'N');
592: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Province: '||C_Party_Site_Rec.Province,1,'N');
585: aso_debug_pub.add('Get_Credits: Before insert header info ',1,'N');
586: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Postal_Code: '||C_Party_Site_Rec.Postal_Code,1,'N');
587: aso_debug_pub.add('Get_Credits: C_Party_Rec.Party_Name: '||C_Party_Rec.Party_Name,1,'N');
588: aso_debug_pub.add('Get_Credits: C_Cust_Cont_Rec.Phone_Area_Code: '||C_Cust_Cont_Rec.Phone_Area_Code,1,'N');
589: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.City: '||C_Party_Site_Rec.City,1,'N');
590: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Country: '||C_Party_Site_Rec.Country,1,'N');
591: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.State: '||C_Party_Site_Rec.State,1,'N');
592: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Province: '||C_Party_Site_Rec.Province,1,'N');
593: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.County: '||C_Party_Site_Rec.County,1,'N');
586: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Postal_Code: '||C_Party_Site_Rec.Postal_Code,1,'N');
587: aso_debug_pub.add('Get_Credits: C_Party_Rec.Party_Name: '||C_Party_Rec.Party_Name,1,'N');
588: aso_debug_pub.add('Get_Credits: C_Cust_Cont_Rec.Phone_Area_Code: '||C_Cust_Cont_Rec.Phone_Area_Code,1,'N');
589: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.City: '||C_Party_Site_Rec.City,1,'N');
590: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Country: '||C_Party_Site_Rec.Country,1,'N');
591: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.State: '||C_Party_Site_Rec.State,1,'N');
592: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Province: '||C_Party_Site_Rec.Province,1,'N');
593: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.County: '||C_Party_Site_Rec.County,1,'N');
594: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Marketing_Source_Code_Id: '||p_qte_header_rec.Marketing_Source_Code_Id,1,'N');
587: aso_debug_pub.add('Get_Credits: C_Party_Rec.Party_Name: '||C_Party_Rec.Party_Name,1,'N');
588: aso_debug_pub.add('Get_Credits: C_Cust_Cont_Rec.Phone_Area_Code: '||C_Cust_Cont_Rec.Phone_Area_Code,1,'N');
589: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.City: '||C_Party_Site_Rec.City,1,'N');
590: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Country: '||C_Party_Site_Rec.Country,1,'N');
591: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.State: '||C_Party_Site_Rec.State,1,'N');
592: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Province: '||C_Party_Site_Rec.Province,1,'N');
593: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.County: '||C_Party_Site_Rec.County,1,'N');
594: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Marketing_Source_Code_Id: '||p_qte_header_rec.Marketing_Source_Code_Id,1,'N');
595: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Sales_Channel_Code: '||p_qte_header_rec.Sales_Channel_Code,1,'N');
588: aso_debug_pub.add('Get_Credits: C_Cust_Cont_Rec.Phone_Area_Code: '||C_Cust_Cont_Rec.Phone_Area_Code,1,'N');
589: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.City: '||C_Party_Site_Rec.City,1,'N');
590: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Country: '||C_Party_Site_Rec.Country,1,'N');
591: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.State: '||C_Party_Site_Rec.State,1,'N');
592: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Province: '||C_Party_Site_Rec.Province,1,'N');
593: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.County: '||C_Party_Site_Rec.County,1,'N');
594: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Marketing_Source_Code_Id: '||p_qte_header_rec.Marketing_Source_Code_Id,1,'N');
595: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Sales_Channel_Code: '||p_qte_header_rec.Sales_Channel_Code,1,'N');
596: END IF;
589: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.City: '||C_Party_Site_Rec.City,1,'N');
590: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Country: '||C_Party_Site_Rec.Country,1,'N');
591: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.State: '||C_Party_Site_Rec.State,1,'N');
592: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Province: '||C_Party_Site_Rec.Province,1,'N');
593: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.County: '||C_Party_Site_Rec.County,1,'N');
594: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Marketing_Source_Code_Id: '||p_qte_header_rec.Marketing_Source_Code_Id,1,'N');
595: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Sales_Channel_Code: '||p_qte_header_rec.Sales_Channel_Code,1,'N');
596: END IF;
597: -- Populate CN_SCA_HEADERS_INTERFACE_GTT with header info
590: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Country: '||C_Party_Site_Rec.Country,1,'N');
591: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.State: '||C_Party_Site_Rec.State,1,'N');
592: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Province: '||C_Party_Site_Rec.Province,1,'N');
593: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.County: '||C_Party_Site_Rec.County,1,'N');
594: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Marketing_Source_Code_Id: '||p_qte_header_rec.Marketing_Source_Code_Id,1,'N');
595: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Sales_Channel_Code: '||p_qte_header_rec.Sales_Channel_Code,1,'N');
596: END IF;
597: -- Populate CN_SCA_HEADERS_INTERFACE_GTT with header info
598: INSERT INTO CN_SCA_HEADERS_INTERFACE_GTT (
591: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.State: '||C_Party_Site_Rec.State,1,'N');
592: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.Province: '||C_Party_Site_Rec.Province,1,'N');
593: aso_debug_pub.add('Get_Credits: C_Party_Site_Rec.County: '||C_Party_Site_Rec.County,1,'N');
594: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Marketing_Source_Code_Id: '||p_qte_header_rec.Marketing_Source_Code_Id,1,'N');
595: aso_debug_pub.add('Get_Credits: p_qte_header_rec.Sales_Channel_Code: '||p_qte_header_rec.Sales_Channel_Code,1,'N');
596: END IF;
597: -- Populate CN_SCA_HEADERS_INTERFACE_GTT with header info
598: INSERT INTO CN_SCA_HEADERS_INTERFACE_GTT (
599: SCA_HEADERS_INTERFACE_ID,
644: p_qte_header_rec.Sales_Channel_Code );
645:
646: IF l_cred_upd_lines_prof = 'Y' THEN
647:
648: IF aso_debug_pub.g_debug_flag = 'Y' THEN
649: aso_debug_pub.add('Get_Credits: Before insert line info ',1,'N');
650: END IF;
651: -- Populate CN_SCA_HEADERS_INTERFACE_GTT with lines info
652: INSERT INTO CN_SCA_HEADERS_INTERFACE_GTT (
645:
646: IF l_cred_upd_lines_prof = 'Y' THEN
647:
648: IF aso_debug_pub.g_debug_flag = 'Y' THEN
649: aso_debug_pub.add('Get_Credits: Before insert line info ',1,'N');
650: END IF;
651: -- Populate CN_SCA_HEADERS_INTERFACE_GTT with lines info
652: INSERT INTO CN_SCA_HEADERS_INTERFACE_GTT (
653: SCA_HEADERS_INTERFACE_ID,
706: WHERE Quote_Header_Id = p_qte_header_rec.Quote_Header_Id;
707:
708: END IF;
709:
710: IF aso_debug_pub.g_debug_flag = 'Y' THEN
711: aso_debug_pub.add('Get_Credits: Before insert line interface tbl ',1,'N');
712: END IF;
713: -- Populate CN_SCA_LINES_INTERFACE_GTT
714: INSERT INTO CN_SCA_LINES_INTERFACE_GTT (
707:
708: END IF;
709:
710: IF aso_debug_pub.g_debug_flag = 'Y' THEN
711: aso_debug_pub.add('Get_Credits: Before insert line interface tbl ',1,'N');
712: END IF;
713: -- Populate CN_SCA_LINES_INTERFACE_GTT
714: INSERT INTO CN_SCA_LINES_INTERFACE_GTT (
715: SCA_LINES_INTERFACE_ID,
743: SUBSTRB(USERENV('CLIENT_INFO'),1,10))),-99));
744: */
745: --Commented Code End Yogeshwar (MOAC)
746:
747: IF aso_debug_pub.g_debug_flag = 'Y' THEN
748: select count(*) into l_dumb from CN_SCA_HEADERS_INTERFACE_GTT;
749: aso_debug_pub.add('Get_Credits: l_headers: '||l_dumb,1,'N');
750: IF l_dumb > 0 THEN
751: FOR C_Hd_Rec IN C_Hd_Inter LOOP
745: --Commented Code End Yogeshwar (MOAC)
746:
747: IF aso_debug_pub.g_debug_flag = 'Y' THEN
748: select count(*) into l_dumb from CN_SCA_HEADERS_INTERFACE_GTT;
749: aso_debug_pub.add('Get_Credits: l_headers: '||l_dumb,1,'N');
750: IF l_dumb > 0 THEN
751: FOR C_Hd_Rec IN C_Hd_Inter LOOP
752: aso_debug_pub.add('Get_Credits: tmp credit_rule_id: '||C_Hd_Rec.credit_rule_id,1,'N');
753: aso_debug_pub.add('Get_Credits: tmp process_status: '||C_Hd_Rec.process_status,1,'N');
748: select count(*) into l_dumb from CN_SCA_HEADERS_INTERFACE_GTT;
749: aso_debug_pub.add('Get_Credits: l_headers: '||l_dumb,1,'N');
750: IF l_dumb > 0 THEN
751: FOR C_Hd_Rec IN C_Hd_Inter LOOP
752: aso_debug_pub.add('Get_Credits: tmp credit_rule_id: '||C_Hd_Rec.credit_rule_id,1,'N');
753: aso_debug_pub.add('Get_Credits: tmp process_status: '||C_Hd_Rec.process_status,1,'N');
754: END LOOP;
755: END IF;
756: select count(*) into l_dumb from CN_SCA_LINES_INTERFACE_GTT;
749: aso_debug_pub.add('Get_Credits: l_headers: '||l_dumb,1,'N');
750: IF l_dumb > 0 THEN
751: FOR C_Hd_Rec IN C_Hd_Inter LOOP
752: aso_debug_pub.add('Get_Credits: tmp credit_rule_id: '||C_Hd_Rec.credit_rule_id,1,'N');
753: aso_debug_pub.add('Get_Credits: tmp process_status: '||C_Hd_Rec.process_status,1,'N');
754: END LOOP;
755: END IF;
756: select count(*) into l_dumb from CN_SCA_LINES_INTERFACE_GTT;
757: aso_debug_pub.add('Get_Credits: l_lines: '||l_dumb,1,'N');
753: aso_debug_pub.add('Get_Credits: tmp process_status: '||C_Hd_Rec.process_status,1,'N');
754: END LOOP;
755: END IF;
756: select count(*) into l_dumb from CN_SCA_LINES_INTERFACE_GTT;
757: aso_debug_pub.add('Get_Credits: l_lines: '||l_dumb,1,'N');
758: END IF;
759:
760: IF aso_debug_pub.g_debug_flag = 'Y' THEN
761: aso_debug_pub.add('Get_Credits: Before CN_SCA_CREDITS_ONLINE_PUB.Get_Sales_Credits ',1,'N');
756: select count(*) into l_dumb from CN_SCA_LINES_INTERFACE_GTT;
757: aso_debug_pub.add('Get_Credits: l_lines: '||l_dumb,1,'N');
758: END IF;
759:
760: IF aso_debug_pub.g_debug_flag = 'Y' THEN
761: aso_debug_pub.add('Get_Credits: Before CN_SCA_CREDITS_ONLINE_PUB.Get_Sales_Credits ',1,'N');
762: aso_utility_pvt.print_login_info();
763: END IF;
764: -- Call CN API to get sales credits
757: aso_debug_pub.add('Get_Credits: l_lines: '||l_dumb,1,'N');
758: END IF;
759:
760: IF aso_debug_pub.g_debug_flag = 'Y' THEN
761: aso_debug_pub.add('Get_Credits: Before CN_SCA_CREDITS_ONLINE_PUB.Get_Sales_Credits ',1,'N');
762: aso_utility_pvt.print_login_info();
763: END IF;
764: -- Call CN API to get sales credits
765: CN_SCA_CREDITS_ONLINE_PUB.Get_Sales_Credits (
770: x_return_status => x_return_status,
771: x_msg_count => x_msg_count,
772: x_msg_data => x_msg_data );
773:
774: IF aso_debug_pub.g_debug_flag = 'Y' THEN
775: aso_debug_pub.add('Get_Credits: After CN_SCA_CREDITS_ONLINE_PUB.Get_Sales_Credits: '||x_return_status,1,'N');
776: aso_utility_pvt.print_login_info();
777: END IF;
778:
771: x_msg_count => x_msg_count,
772: x_msg_data => x_msg_data );
773:
774: IF aso_debug_pub.g_debug_flag = 'Y' THEN
775: aso_debug_pub.add('Get_Credits: After CN_SCA_CREDITS_ONLINE_PUB.Get_Sales_Credits: '||x_return_status,1,'N');
776: aso_utility_pvt.print_login_info();
777: END IF;
778:
779: IF aso_debug_pub.g_debug_flag = 'Y' THEN
775: aso_debug_pub.add('Get_Credits: After CN_SCA_CREDITS_ONLINE_PUB.Get_Sales_Credits: '||x_return_status,1,'N');
776: aso_utility_pvt.print_login_info();
777: END IF;
778:
779: IF aso_debug_pub.g_debug_flag = 'Y' THEN
780: select count(*) into l_dumb from CN_SCA_LINES_OUTPUT_GTT;
781: aso_debug_pub.add('Get_Credits: l_dumb: '||l_dumb,1,'N');
782: END IF;
783: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
777: END IF;
778:
779: IF aso_debug_pub.g_debug_flag = 'Y' THEN
780: select count(*) into l_dumb from CN_SCA_LINES_OUTPUT_GTT;
781: aso_debug_pub.add('Get_Credits: l_dumb: '||l_dumb,1,'N');
782: END IF;
783: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
784: RAISE FND_API.G_EXC_ERROR;
785: END IF;
807: OPEN C_Get_Line_Total (l_batch_id);
808: FETCH C_Get_Line_Total INTO l_line_total;
809: CLOSE C_Get_Line_Total;
810:
811: IF aso_debug_pub.g_debug_flag = 'Y' THEN
812: aso_debug_pub.add('Get_Credits: l_quota_id: '||l_quota_id,1,'N');
813: aso_debug_pub.add('Get_Credits: l_non_quota_id: '||l_non_quota_id,1,'N');
814: aso_debug_pub.add('Get_Credits: l_total_rev: '||l_total_rev,1,'N');
815: aso_debug_pub.add('Get_Credits: l_hdr_total: '||l_hdr_total,1,'N');
808: FETCH C_Get_Line_Total INTO l_line_total;
809: CLOSE C_Get_Line_Total;
810:
811: IF aso_debug_pub.g_debug_flag = 'Y' THEN
812: aso_debug_pub.add('Get_Credits: l_quota_id: '||l_quota_id,1,'N');
813: aso_debug_pub.add('Get_Credits: l_non_quota_id: '||l_non_quota_id,1,'N');
814: aso_debug_pub.add('Get_Credits: l_total_rev: '||l_total_rev,1,'N');
815: aso_debug_pub.add('Get_Credits: l_hdr_total: '||l_hdr_total,1,'N');
816: aso_debug_pub.add('Get_Credits: l_line_total: '||l_line_total,1,'N');
809: CLOSE C_Get_Line_Total;
810:
811: IF aso_debug_pub.g_debug_flag = 'Y' THEN
812: aso_debug_pub.add('Get_Credits: l_quota_id: '||l_quota_id,1,'N');
813: aso_debug_pub.add('Get_Credits: l_non_quota_id: '||l_non_quota_id,1,'N');
814: aso_debug_pub.add('Get_Credits: l_total_rev: '||l_total_rev,1,'N');
815: aso_debug_pub.add('Get_Credits: l_hdr_total: '||l_hdr_total,1,'N');
816: aso_debug_pub.add('Get_Credits: l_line_total: '||l_line_total,1,'N');
817: END IF;
810:
811: IF aso_debug_pub.g_debug_flag = 'Y' THEN
812: aso_debug_pub.add('Get_Credits: l_quota_id: '||l_quota_id,1,'N');
813: aso_debug_pub.add('Get_Credits: l_non_quota_id: '||l_non_quota_id,1,'N');
814: aso_debug_pub.add('Get_Credits: l_total_rev: '||l_total_rev,1,'N');
815: aso_debug_pub.add('Get_Credits: l_hdr_total: '||l_hdr_total,1,'N');
816: aso_debug_pub.add('Get_Credits: l_line_total: '||l_line_total,1,'N');
817: END IF;
818:
811: IF aso_debug_pub.g_debug_flag = 'Y' THEN
812: aso_debug_pub.add('Get_Credits: l_quota_id: '||l_quota_id,1,'N');
813: aso_debug_pub.add('Get_Credits: l_non_quota_id: '||l_non_quota_id,1,'N');
814: aso_debug_pub.add('Get_Credits: l_total_rev: '||l_total_rev,1,'N');
815: aso_debug_pub.add('Get_Credits: l_hdr_total: '||l_hdr_total,1,'N');
816: aso_debug_pub.add('Get_Credits: l_line_total: '||l_line_total,1,'N');
817: END IF;
818:
819: -- Check if atleast some credit has been allocated
812: aso_debug_pub.add('Get_Credits: l_quota_id: '||l_quota_id,1,'N');
813: aso_debug_pub.add('Get_Credits: l_non_quota_id: '||l_non_quota_id,1,'N');
814: aso_debug_pub.add('Get_Credits: l_total_rev: '||l_total_rev,1,'N');
815: aso_debug_pub.add('Get_Credits: l_hdr_total: '||l_hdr_total,1,'N');
816: aso_debug_pub.add('Get_Credits: l_line_total: '||l_line_total,1,'N');
817: END IF;
818:
819: -- Check if atleast some credit has been allocated
820: IF (l_hdr_total IS NULL OR l_hdr_total < 1) AND
831:
832: -- Save credit diff if below 100, else diff is 0
833: l_credit_diff := 100 - l_total_rev;
834:
835: IF aso_debug_pub.g_debug_flag = 'Y' THEN
836: aso_debug_pub.add('Get_Credits: l_credit_diff: '||l_credit_diff,1,'N');
837: END IF;
838: -- Delete existing credits for the quote
839: ASO_SALES_CREDITS_PKG.Delete_Header_Row ( P_Quote_Header_Id => p_Qte_Header_Rec.Quote_Header_Id );
832: -- Save credit diff if below 100, else diff is 0
833: l_credit_diff := 100 - l_total_rev;
834:
835: IF aso_debug_pub.g_debug_flag = 'Y' THEN
836: aso_debug_pub.add('Get_Credits: l_credit_diff: '||l_credit_diff,1,'N');
837: END IF;
838: -- Delete existing credits for the quote
839: ASO_SALES_CREDITS_PKG.Delete_Header_Row ( P_Quote_Header_Id => p_Qte_Header_Rec.Quote_Header_Id );
840:
837: END IF;
838: -- Delete existing credits for the quote
839: ASO_SALES_CREDITS_PKG.Delete_Header_Row ( P_Quote_Header_Id => p_Qte_Header_Rec.Quote_Header_Id );
840:
841: IF aso_debug_pub.g_debug_flag = 'Y' THEN
842: aso_debug_pub.add('Get_Credits: After Delete_Row ',1,'N');
843: END IF;
844: -- Insert new credits for this quote
845: INSERT INTO ASO_SALES_CREDITS (
838: -- Delete existing credits for the quote
839: ASO_SALES_CREDITS_PKG.Delete_Header_Row ( P_Quote_Header_Id => p_Qte_Header_Rec.Quote_Header_Id );
840:
841: IF aso_debug_pub.g_debug_flag = 'Y' THEN
842: aso_debug_pub.add('Get_Credits: After Delete_Row ',1,'N');
843: END IF;
844: -- Insert new credits for this quote
845: INSERT INTO ASO_SALES_CREDITS (
846: CREATION_DATE,
881: AND C.Quote_Number = p_qte_header_rec.Quote_Number
882: AND B.Source_Line_Id IS NULL;
883:
884:
885: IF aso_debug_pub.g_debug_flag = 'Y' THEN
886: aso_debug_pub.add('Get_Credits: After Insert_Row to ASO_SALES_CREDITS ',1,'N');
887: END IF;
888: -- Update the primary salesrep percent in aso_sales_credits
889: IF l_credit_diff > 0 THEN
882: AND B.Source_Line_Id IS NULL;
883:
884:
885: IF aso_debug_pub.g_debug_flag = 'Y' THEN
886: aso_debug_pub.add('Get_Credits: After Insert_Row to ASO_SALES_CREDITS ',1,'N');
887: END IF;
888: -- Update the primary salesrep percent in aso_sales_credits
889: IF l_credit_diff > 0 THEN
890: OPEN C_PSRep_Credit (p_Qte_Header_Rec.Quote_Header_Id, p_Qte_Header_Rec.Resource_Id, l_quota_id);
890: OPEN C_PSRep_Credit (p_Qte_Header_Rec.Quote_Header_Id, p_Qte_Header_Rec.Resource_Id, l_quota_id);
891: FETCH C_PSRep_Credit INTO l_PSRep;
892: CLOSE C_PSRep_Credit;
893:
894: IF aso_debug_pub.g_debug_flag = 'Y' THEN
895: aso_debug_pub.add('Get_Credits: l_PSRep '||l_PSRep,1,'N');
896: END IF;
897: IF l_PSRep IS NOT NULL THEN
898:
891: FETCH C_PSRep_Credit INTO l_PSRep;
892: CLOSE C_PSRep_Credit;
893:
894: IF aso_debug_pub.g_debug_flag = 'Y' THEN
895: aso_debug_pub.add('Get_Credits: l_PSRep '||l_PSRep,1,'N');
896: END IF;
897: IF l_PSRep IS NOT NULL THEN
898:
899: UPDATE ASO_SALES_CREDITS
901: WHERE Resource_Id = l_PSRep
902: AND Sales_Credit_Type_Id = l_quota_id
903: AND Quote_Header_Id = p_Qte_Header_Rec.Quote_Header_Id;
904:
905: IF aso_debug_pub.g_debug_flag = 'Y' THEN
906: aso_debug_pub.add('Get_Credits: After Update to ASO_SALES_CREDITS PSRep ',1,'N');
907: END IF;
908: ELSE
909:
902: AND Sales_Credit_Type_Id = l_quota_id
903: AND Quote_Header_Id = p_Qte_Header_Rec.Quote_Header_Id;
904:
905: IF aso_debug_pub.g_debug_flag = 'Y' THEN
906: aso_debug_pub.add('Get_Credits: After Update to ASO_SALES_CREDITS PSRep ',1,'N');
907: END IF;
908: ELSE
909:
910: INSERT INTO ASO_SALES_CREDITS (
939: FROM ASO_QUOTE_ACCESSES A
940: WHERE A.Resource_Id = p_Qte_Header_Rec.Resource_Id
941: AND A.Quote_Number = p_qte_header_rec.Quote_Number;
942:
943: IF aso_debug_pub.g_debug_flag = 'Y' THEN
944: aso_debug_pub.add('Get_Credits: After Insert to ASO_SALES_CREDITS PSRep ',1,'N');
945: END IF;
946: END IF; -- l_PSRep
947:
940: WHERE A.Resource_Id = p_Qte_Header_Rec.Resource_Id
941: AND A.Quote_Number = p_qte_header_rec.Quote_Number;
942:
943: IF aso_debug_pub.g_debug_flag = 'Y' THEN
944: aso_debug_pub.add('Get_Credits: After Insert to ASO_SALES_CREDITS PSRep ',1,'N');
945: END IF;
946: END IF; -- l_PSRep
947:
948: END IF; -- l_credit_diff
962:
963: -- Delete existing credits for the quote
964: ASO_SALES_CREDITS_PKG.Delete_Row ( P_Quote_Line_Id => C_Get_Line_Rec.Quote_Line_Id );
965:
966: IF aso_debug_pub.g_debug_flag = 'Y' THEN
967: aso_debug_pub.add('Get_Credits: After Delete_Row ',1,'N');
968: END IF;
969: -- Insert new credits for this quote
970: INSERT INTO ASO_SALES_CREDITS (
963: -- Delete existing credits for the quote
964: ASO_SALES_CREDITS_PKG.Delete_Row ( P_Quote_Line_Id => C_Get_Line_Rec.Quote_Line_Id );
965:
966: IF aso_debug_pub.g_debug_flag = 'Y' THEN
967: aso_debug_pub.add('Get_Credits: After Delete_Row ',1,'N');
968: END IF;
969: -- Insert new credits for this quote
970: INSERT INTO ASO_SALES_CREDITS (
971: CREATION_DATE,
1005: AND A.Resource_Id = C.Resource_Id
1006: AND C.Quote_Number = p_qte_header_rec.Quote_Number
1007: AND B.Source_Line_Id = C_Get_Line_Rec.Quote_Line_Id;
1008:
1009: IF aso_debug_pub.g_debug_flag = 'Y' THEN
1010: aso_debug_pub.add('Get_Credits: After Insert_Row to ASO_SALES_CREDITS ',1,'N');
1011: END IF;
1012: -- Update the primary salesrep percent in aso_sales_credits
1013: IF l_cred_line_diff > 0 THEN
1006: AND C.Quote_Number = p_qte_header_rec.Quote_Number
1007: AND B.Source_Line_Id = C_Get_Line_Rec.Quote_Line_Id;
1008:
1009: IF aso_debug_pub.g_debug_flag = 'Y' THEN
1010: aso_debug_pub.add('Get_Credits: After Insert_Row to ASO_SALES_CREDITS ',1,'N');
1011: END IF;
1012: -- Update the primary salesrep percent in aso_sales_credits
1013: IF l_cred_line_diff > 0 THEN
1014: