1: PACKAGE BODY OE_MARGIN_PVT AS
2: /* $Header: OEXVMRGB.pls 120.12.12020000.3 2013/02/01 10:05:32 nilegupt ship $ */
3:
4: G_CUSTOM_COST VARCHAR2(3);
5: G_SHIP_FROM_ORG_ID NUMBER:=-1;
57: --
58: l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
59: --
60: begin
61: debug('Inside oe_margin_pvt_1.cost_action',1);
62: If P_cost_level ='LINE' then
63: debug('Inside cost level- line',1);
64:
65: --MOAC PI
71: MO_GLOBAL.set_policy_context(p_access_mode => 'S', p_org_id => l_Org_Id);
72: l_prev_org_id := l_org_id;
73: End If;
74: l_request_rec.entity_id := l_line_id ;
75: l_unit_cost := Oe_Margin_Pvt.Get_Cost(p_request_rec => l_request_rec);
76: i := p_selected_records.next(i);
77: End loop;
78: --MOAC PI
79:
93: While j Is not null loop
94: l_request_rec.entity_id := l_Line_Tbl(j).line_id;
95: debug('l_request_rec.entity_id = '||l_request_rec.entity_id,1);
96: l_header_flag := TRUE;
97: l_unit_cost := Oe_Margin_Pvt.Get_Cost(p_request_rec => l_request_rec,p_line_rec => l_Line_Tbl(j), p_header_flag => l_header_flag);
98: j := l_Line_Tbl.Next(j);
99: End loop;
100: i := p_selected_records.next(i);
101: End Loop;
361: AND OEDSS.PO_RELEASE_ID IS NOT NULL;
362:
363:
364: BEGIN
365: debug('Entering Oe_Margin_Pvt.get_cost');
366:
367: --Not yet decided. We might allow user to write their
368: --own api to get a custom code...
369: IF G_CUSTOM_COST IS NOT NULL THEN
865: RAISE FND_API.G_EXC_ERROR;
866: ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
867: RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
868: END IF;
869: debug('just before return oe_margin_pvt.get_cost');
870: debug('l_unit_cost ='||l_unit_cost);
871:
872: RETURN l_unit_cost;
873:
870: debug('l_unit_cost ='||l_unit_cost);
871:
872: RETURN l_unit_cost;
873:
874: debug('Leaving Oe_Margin_Pvt.get_cost');
875:
876: EXCEPTION
877: WHEN OTHERS THEN
878: DEBUG(' OE_MARGIN_PVT:Unable to get cost:'||SQLERRM);
874: debug('Leaving Oe_Margin_Pvt.get_cost');
875:
876: EXCEPTION
877: WHEN OTHERS THEN
878: DEBUG(' OE_MARGIN_PVT:Unable to get cost:'||SQLERRM);
879: Return null;
880: END GET_COST;
881:
882: --------------------------------------------------
948: --
949: l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
950: --
951: BEGIN
952: debug('Entering Oe_Margin_Pvt.Get_Order_Margin');
953: --retrive margin calculation method perference
954: l_compute_method:=Oe_Sys_Parameters.Value('COMPUTE_MARGIN', p_org_id);
955:
956: debug(' Margin_Compute_Method:'||l_compute_method);
1001: ELSE
1002: x_order_margin_percent := l_margin_ratio * 100;
1003: END IF;
1004: -- 3756821
1005: debug('Leaving Oe_Margin_Pvt.Get_Order_Margin');
1006: RETURN;
1007:
1008: END IF;
1009:
1031: END IF;
1032: -- 3756821
1033: END IF;
1034:
1035: debug('Leaving Oe_Margin_Pvt.Get_Order_Margin');
1036:
1037: EXCEPTION
1038: WHEN ZERO_DIVIDE THEN
1039: IF l_compute_method = 'P' THEN
1036:
1037: EXCEPTION
1038: WHEN ZERO_DIVIDE THEN
1039: IF l_compute_method = 'P' THEN
1040: debug(' Oe_Margin_Pvt.Get_Order_Margin ZERO price');
1041:
1042: --Good problem to have, user has infinite margin, for sure it should
1043: --pass order margin hold check.
1044: --When null, caller will not continue margin hold/check process
1047: x_order_margin_percent:= null;
1048:
1049: ElSIF l_compute_method = 'C' THEN
1050:
1051: debug(' Oe_Margin_Pvt.Get_Order_Margin ZERO cost:');
1052: --Good problem to have, user has infinite margin, for sure should
1053: --pass order margin hold check
1054: --When null, caller will not continue margin hold/check process
1055:
1057: x_order_margin_percent:= null;
1058:
1059: ELSE
1060:
1061: debug(' Oe_Margin_Pvt.Get_Order_Margin:'||SQLERRM);
1062:
1063: END IF;
1064:
1065: WHEN OTHERS THEN
1062:
1063: END IF;
1064:
1065: WHEN OTHERS THEN
1066: debug(' Oe_Margin_Pvt.Get_Order_Margin unable get margin:'||SQLERRM);
1067: End;
1068:
1069: ----------------------------------------------
1070: PROCEDURE Margin_Hold
1086: --
1087: l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1088: --
1089: BEGIN
1090: debug('Entering Oe_Margin_Pvt.Margin_Hold');
1091:
1092: Get_Order_Margin(p_header_id=>p_header_id,
1093: x_order_margin_percent=>l_order_margin_percent,
1094: x_order_margin_amount =>l_order_margin_amount);
1185: END IF;
1186: END IF;
1187:
1188:
1189: debug('Leaving Oe_Margin_Pvt.Margin_Hold');
1190: END;
1191:
1192: --------------------------------------------------------------------
1193: --Margin should only avail for pack I
1224: l_cost:=Get_Cost(p_line_rec=>p_line_rec);
1225: x_unit_cost:=l_cost;
1226: If p_line_rec.unit_selling_price is Null Then
1227: oe_debug_pub.add('Warning:- unit selling price is null,margin not relevant');
1228: oe_debug_pub.add('Exiting oe_margin_pvt.get_line_margin');
1229: Return;
1230: End If;
1231: l_margin_amt := nvl(p_line_rec.unit_selling_price,0) - nvl(l_cost,0); --bug 5155086
1232: x_unit_margin_amount:=l_margin_amt;
1251: x_margin_percent := l_margin_amt/l_cost*100; --added * 100 for bug5155086;
1252: End If;
1253: End;
1254:
1255: End OE_MARGIN_PVT;