I am trying to find how the line amount is populating on sales line (Unit Price) when a trade agreement is defined for that particular item, also if i post a trade agreement with same item say Item123 twice and define the price in Trade agreement 1 as 10 and in trade agreement 2 as 20 then if i post a sales order with item123 then everytime it will auto populate the sales line as unit price as 20 only.
Also if i click on SalesOrderLine in the ribbon and navigate to Price Details (MCRPriceHistory) then i can see only 1 trade agreement line, how is this possible also how is the trade agreement journal is coming up over there?
To sum up the above paragraph, Can someone help me in understanding this & finding the related objects, classes, x++ code for below :
1. How is trade agreement journal is getting related to sales orders when we navigate to price details, how and where does the value comes from
2. How to fetch the value of all the fields in trade agreement journal line to sales line, where to add the x++ code
Please try to understand my requirement, Say i have 3 custom fields on Trade agreement journal line say Field1, Field2 and Field 3 added on PriceDiscAdmTrans.Extension, and I create a trade agreement for Item123 and give the value of Field1 = 10, Field2 = 20 and Field3 = ABC and post the journal.
I have the same fields Field1, Field2, Field 3 and JournalNumber custom fields added on SalesLine.Extension
Now when i create a sales order line with the same item which is Item123 i need these feilds on sales line to have a value autopopulated from trade agreement which will be:
Field1 = 10
Field2 = 20
Field 3 = 30
JournalNumber = ABC001 (Trade agreement journal number)
How do i achieve this using x++ code and where should i write my code which class which method??