web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

How to get trade agreement price for An Item or for customer Dynamics Ax 2012

Ali Zaidi Profile Picture Ali Zaidi 4,657

When we make trade agreement, there are 3 possibilities

  • On some products we make discounted price for all Customers.
  • On some products we make discounted for selected Customers
  • All products have discounted or fixed prices for some customers.

Third case is exceptional, but there is possibility that organization set sales prices on all items for some customers or all customer.

If we dig deep, we find that trade agreements stored in

PRICEDISCTABLE and PriceDiscAdmTrans

 

I am sharing code which just check that particular item exists in trade agreement. These both table have item variant level detail. You can extended the code according to your need. Code is running on Contoso data.

 

PRICEDISCTABLE _PRICEDISCTABLE,priceDiscTable;

PriceDiscAdmTrans  _trans;

ItemId _Item=”C10034″;

ItemId itemRelation=”C0001″;

ItemId _itemWithCustomer =”D0011″;

CustAccount  accountRelation =”US-001″;

Price _price;

PriceType  relation =PriceType::PriceSales;

NoYes _RelationExist=NoYes::No;

// Item scenerio for all customer.

//  _RelationExist= PRICEDISCTABLE::existItemRelation(PriceType::PriceSales,_Item);

 

 

/// First if  trade agreement exist for Item for all customer.

 

 

select firstonly RecId from priceDiscTable

where priceDiscTable.Relation           == relation                 &&

priceDiscTable.ItemCode           == TableGroupAll::Table  &&

priceDiscTable.ItemRelation       == itemRelation

&& priceDiscTable.AccountCode ==  TableGroupAll::All;

 

if (priceDiscTable !=null)

{

 

info (“found”);

}

 

 // trade agreement exist for particular item for particular customer

    select firstonly RecId from priceDiscTable

where priceDiscTable.Relation           == relation                 &&

priceDiscTable.AccountCode        == TableGroupAll::Table   &&

priceDiscTable.AccountRelation    == accountRelation &&

priceDiscTable.ItemCode           == TableGroupAll::Table  &&

priceDiscTable.ItemRelation       == _itemWithCustomer;

if (priceDiscTable !=null)

{

 

info (“found”);

}

 

   // third possibility is that when Customer have to all product with same price of amount.

 

 

 

      select firstonly RecId from priceDiscTable

where priceDiscTable.Relation           == relation                 &&

priceDiscTable.ItemCode           == TableGroupAll::All  &&

priceDiscTable.AccountRelation    == accountRelation &&

priceDiscTable.AccountCode ==  TableGroupAll::Table; //&&

//   priceDiscTable.AccountRelation == accountRelation;

 

 

 

 

if (priceDiscTable !=null)

{

 

info (“found”);

}

 

Hopes this helps

 

 

 

 

 

Comments

*This post is locked for comments