Techno-Functional Dynamics 365 F&S Data Model Explanations for Reporting, Part 20 of 25: Create and Post Trade Agreement

Techno-Functional Dynamics 365 F&S Data Model Explanations for Reporting, Part 20 of 25: Create and Post Trade Agreement

Dynamics 365 Trade Agreement

Microsoft Dynamics 365 for Finance & Operations: Create Trade Agreement Journals

Dynamics 365 trade agreement is basically the journal used for changing prices or giving discounts. Prices, discounts for sales and procurement are deduced from trade agreements. Consequently, in order for your company to design the setup for trade agreements, you must first understand how price and discounts are deduced from them.

How to Create and Post a Trade Agreement in Microsoft Dynamics 365?

Functional Overview: Dynamics 365 Trade Agreement Journals

  • Open Dynamics 365 client on Internet Explorer. Go to Modules > Sales and Marketing > Price and discounts and click on Trade agreement journals. A Trade agreement journals form will be opened and all the existing journals will be in display on form.

Functional Overview

Create a New Trade Agreement

  • Click on +New button to create a new trade agreement in Microsoft Dynamics 365. In new empty record click Name drop-down and select Price then click on Default relation drop-down and select Price (Sales).

Create a New Trade Agreement

Microsoft Dynamics 365 Training Courses

Select New Trade Agreement

  • Click on Lines button while new trade agreement is selected.

Select New Trade Agreement

Journal Lines Trade Agreement

  • In ‘Journal Lines’ form, an empty line will be inserted by the system in grid. Then, click on ‘Party code type’ drop-down in the grid line, and select ‘table’.  After this is done, click Account selection and select any customer account. Lastly, in the Product code type drop-down, select Table. Finish it off by selecting any item number in item relation. 

Journal Lines

Selection of Values in D365 Trade Agreement

  • Scroll down to Details fast tab and click to expand. In Details tab, select values as mentioned below.

Selection of Values in D365 Trade Agreement

Dynamics 365 Trade Agreement – Validate All Lines

  • There are various other buttons for different tasks. Now on top of the form, click on Validate drop-down and click Validate all lines to check accuracy of journal lines. Click OK to execute validation process on journal lines.

Dynamics 365 Trade Agreement - Validate All Lines

Post Trade Agreement Journal 

  • If there is no warning or error displayed by system, click on Post button to post journal. Click OK to post journal.

Post Trade Agreement Journal

Technical Overview: Microsoft Dynamics 365 Trade Agreement

Entity Relationship Diagram: 

The ERD of a trade agreement journal creation and the posting process is given below in the diagram.

If we see closely, we realize that the PriceDiscAdmTrans table is most important table overall. In this table, lines data of journals is stored.

This table has a many-to-one relationship with PriceDiscAdmTable. PriceDiscAdmTable worked as a header table to store header information of journal like Journal name, Journal id and posting date.

PriceDiscAdmTrans table also has a many-to-one relationship with CustTable to get customer account for journal lines.

InventTable has a one-to-many relationship with PriceDiscAdmTable for item id mentioned in journal lines.

Entity Relationship Diagram

Runnable class

[sourcecode language=”c-sharp”] class ib_CreateTradeAgreement
{
/// <summary>
/// Runs the class with the specified arguments.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{
PriceDiscAdmTable priceDiscAdmTable;
PriceDiscAdmTrans priceDiscAdmTrans;
PriceDiscAdmCheckPost priceDiscAdmCheckPost = new PriceDiscAdmCheckPost(false);
PriceDiscAdmName priceDiscAdmName = PriceDiscAdmName::find(‘Pric’);
try
{
// Create Journal number
ttsbegin;
priceDiscAdmTable.clear();
priceDiscAdmTable.initFromPriceDiscAdmName(priceDiscAdmName);
priceDiscAdmTable.insert();
ttscommit;

// Create Journal line
ttsbegin;
priceDiscAdmTrans.clear();
priceDiscAdmTrans.JournalNum = priceDiscAdmTable.JournalNum;
priceDiscAdmTrans.AccountCode = PriceDiscPartyCodeType::Table;
priceDiscAdmTrans.AccountRelation = "001122";
priceDiscAdmTrans.ItemCode = PriceDiscProductCodeType::Table;
priceDiscAdmTrans.ItemRelation = "1000";
priceDiscAdmTrans.LineNum = 1;
priceDiscAdmTrans.Currency = "USD";
priceDiscAdmTrans.InventDimId = "AllBank";
priceDiscAdmTrans.Markup = 1150;
priceDiscAdmTrans.PriceUnit = 1;
priceDiscAdmTrans.relation = PriceType::PriceSales;
priceDiscAdmTrans.FromDate = 01\10\2020;
priceDiscAdmTrans.ToDate = 30\10\2020;
priceDiscAdmTrans.insert();
ttscommit;
//Check if journal created
if(priceDiscAdmTable && priceDiscAdmTrans)
{
Info(strFmt(‘Created Journal number %1’, priceDiscAdmTable.JournalNum));
if(!priceDiscAdmCheckPost.checkJournal()) //Determines whether the price and discount agreement journal contains warnings.
{
priceDiscAdmCheckPost.initJournalNum(priceDiscAdmTrans.JournalNum);
priceDiscAdmCheckPost.run(); //Checks and posts the price and discount agreement journal.
Info(strFmt(‘Posted Journal number %1’, priceDiscAdmTable.JournalNum));
}
}
}
catch(Exception::CLRError)
{
error(enum2Str(Exception::CLRError));
}
}

}

[/sourcecode]

This table has all the major information related to trade agreement i.e. account number, item id, price, from date and to date.

From this table, we can generate multiple reports.

Some of the examples are mentioned below:

  1. Get price of a specific item/item group for customer/customer group.
  2. Get discounts applied on specific item/item groups for customer/customer group.

We have listed some important fields for you below; with data type and description: 

Field Data Type Description
AccountCode Enum Selected party code type in journal lines stored in this field.
AccountRelation String Selected customer/vendor account stored in this field.
ItemCode Enum Product code type stored in this field.
ItemRelation String Item id used in journal lines stored in this field.
Module Enum Module name for which journal is created stored in this field.
PriceUnit Real Price Unit stored in this field on which price will be applied.
Relation Enum Relation of the journal line e.g. sales or purchase stored in this field.
JournalNum String Related Journal number stored in this field.
FromDate Date Start date of journal effectiveness stored in this field.
ToDate Date End date of journal effectiveness stored in this field.

PriceDiscAdmTable: 

This table works as a header table in the trade agreement process.

In this table, header information like Journal name, Journal number and posting date are stored with default relation. Some important fields with data type and description mentioned below:

Field Data Type Description
DefaultRelation Enum Default relation of journal mentioned in this field.
JournalName String Journal name stored in this field.
JournalNum String Journal number stored in this field.
Posted Enum Journal posted status stored in this field.
PostedDate Date Journal posting date stored in this field.

Overview: Create and Post Trade Agreement Dynamics 365 Data Model Tutorial

Overall in this post Create and Post Trade Agreement Dynamics 365 Data Model Tutorial, we have:

  • covered create and post trade agreement journals in Dynamics 365 F&S
  • reviewed the technical side of create and post trade agreement journals
  • discussed two major tables: PriceDiscAdmTrans and PriceDiscAdmTable
  • discussed ways in which to use both tables

In addition, we sincerely hope that you enjoyed part 20 of our exciting series on Microsoft Dynamics 365 Data Model. In short we aim to provide quality service at all times. Moreover, if you need to reach me, you know how to get in touch by reaching out to me here.  – Brandon Ahmad, founder of Instructor Brandon and Dynatuners.

Videos