Skip to Content
0

How to calculate the total amount of TurnoverEUR , same sales org of sales order

Nov 24, 2016 at 01:35 PM

79

avatar image

Hi Experts,

How to calculate the total amount of TurnoverEUR of each item of sales order based on same sales org.

Please help on this.

I think some I need to try like this

The following code is not working…

//Payment Term and over dues Start

var salesOrderQry = CustomerQuote.QueryByElements;

var salesOrderParams = salesOrderQry.CreateSelectionParams();

salesOrderParams.Add(salesOrderQry.PartyBuyerPartyKey.PartyID.content,"I","EQ",this.CustomerCode);

var salesOrderRes = salesOrderQry.Execute(salesOrderParams);

//var SalesOrder1 = salesOrderRes.Where( n => n.);

//

if(salesOrderRes.Count() > 0 ){

// var SalesOrder1 = salesOrderRes.OrderBy(n=>n.);

var PaymentForeCastAndOverDues_Node :elementsof CustomerFactSheetExt.PaymentForeCastAndOverDues;

var FrstYear = Numeric.ParseFromString(Context.GetCurrentGlobalDateTime().GetYear());

var ThirdYear = FrstYear-2;

var TurnoverEUR = 0;

var currency ="";

var salesOrg = "";

foreach(var SalesView_tab in salesOrderRes){

var CreationYear = Numeric.ParseFromString(SalesView_tab.SystemAdministrativeData.CreationDateTime.GetYear());

//if(SalesView_tab.ZClearingDate.IsInitial() && SalesView_tab.ProcessingTypeCode.GetDescription().Contains("Invoice") ){ //open Invoice if

if(SalesView_tab.ZClearingDate.IsInitial() && SalesView_tab.ProcessingTypeCode.GetDescription().Contains("Standard Order") ){ //open Invoice if

if(SalesView_tab.SalesAndServiceBusinessArea.IsSet()){

//salesOrg = SalesView_tab.SalesAndServiceBusinessArea.SalesOrganisationID;

var salesOrgObj = OrganisationalUnit.Retrieve(SalesView_tab.SalesAndServiceBusinessArea.SalesOrganisationID);

if(salesOrgObj.NameAndAddress.GetFirst().IsSet()){

salesOrg = salesOrgObj.NameAndAddress.GetFirst().Name;

}}

PaymentForeCastAndOverDues_Node.SalesOrg = salesOrg;

var salesOrgFlag = false;

if(this.PaymentForeCastAndOverDues.Count() >= 1){

foreach(var eachPFO in this.PaymentForeCastAndOverDues){

if(eachPFO.SalesOrg.Contains(salesOrg)){

salesOrgFlag = true;

break;}

}}

if(SalesView_tab.Item.Count() > 0){ // open item cout if

foreach(var item in SalesView_tab.Item){

if(salesOrgFlag){

TurnoverEUR = TurnoverEUR + item.TurnoverEUR.content;}

}// close item

}// close item cout if

}//open Invoice if

PaymentForeCastAndOverDues_Node.Currency = currency;

PaymentForeCastAndOverDues_Node.TotalOpenAmount = TurnoverEUR.RoundToString(0);

this.PaymentForeCastAndOverDues.Create(PaymentForeCastAndOverDues_Node);

PaymentForeCastAndOverDues_Node.Clear();

}

}

Thanks

Srinivas Borra

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers