Thursday, October 4, 2018

Trade Agreements – How to Set Up Prices

Trade agreements in Dynamics AX 2012 allow for setting up prices and discounts for Products, Vendors, and Customers. (Or groups of Products, Vendors, and Customers). Trade agreements can be set up in a lot of different ways, with varying results.

Trade agreements are managed by setting up price/discount agreement journals.

Navigate to Sales and marketing > Journals, or to Procurement and sourcing > Journals, and select Price/discount agreement journals and select “New”.

We will be creating a price adjustment journal:

Select Price, and tab through the line. We will have a new journal with a number assigned from the number sequence: Next, click on Lines to enter the prices for individual items

There are a number of options to complete when entering adjustment lines. The first is the relation column, which determines the function of the line:

The account code determines whether a price applies to all vendors, a group of vendors, or a single vendor. The choices are “All” for all, “Group” for a group, and, very intuitively, “Table” for a single vendor. J We are assigning a price for a group:


X++ code to get the price for the Item from the Trade agreement using PurchTable buffer :

public static PurchPrice getPriceDiscAmount(VendTable       _vendTable,
                                                ItemId          _aLineItemId,
                                                InventDimId     _aLineInventDimId,
                                                TransDate       _transDate,
                                                PurchQty        _purchQty,
                                                PurchUnit       _purchUnit,
                                                CurrencyCode    _currency)
    {
        PurchTable                      purchTable;
        PurchLine                       purchLine;
        purchTable.clear();
        purchTable.initFromVendTable(_vendTable);
        purchLine.clear();
        purchLine.initFromPurchTable(purchTable);
        purchLine.ItemId        = _aLineItemId;
        purchLine.InventDimId   = _aLineInventDimId;
        purchLine.DeliveryDate  = _transDate;
        purchLine.PurchQty      = _purchQty;
        purchLine.PurchUnit     = _purchUnit;
        purchLine.CurrencyCode  = _currency;
        purchLine.initFromInventTable(InventTable::find(_aLineItemId));
        return purchLine.PurchPrice;
    }

If you want to get the price using standard priceDisc class and priceGroup :

public static Price findPurchPrice(ItemId _itemId, VendAccount _vendAccount, InventDimId _inventDimId, Qty _qty)
   
{
        PriceDisc               priceDisc
;
        InventTable inventTable
= InventTable::find(_itemId);
        VendTable vendTable
= VendTable::find(_vendAccount);
       
//InventDim               inventDimItem       = inventTable.inventItemInventSetup().inventDim();
        InventDim inventDimItem
= InventDim::find(_inventDimId);
        UnitOfMeasureSymbol     unitId             
= inventTable.inventTableModuleInvent().UnitId;
        Price                   retPrice
;

        priceDisc
= new PriceDisc(ModuleInventPurchSales::Purch, _itemId, inventDimItem, unitId, systemDateGet(), _qty , _vendAccount);

       
if (priceDisc.findPrice(_vendTable.PriceGroup))
            retPrice
= priceDisc.price();
       
else if (priceDisc.findItemPrice())
            retPrice
= priceDisc.price();

       
return retPrice;
   

} In AX 2012 you can use the standard method to get the price from the trade agreement.
static void GetPriceFromItemAndVendor(Args _args)
{
    InventTable                 inventTable = inventTable::find('10000');
    InventDim inventDim;
    ItemId ItemId;
    UnitOfMeasureSymbol UnitId;
    TransDate TransDate;
    PriceDisc PriceDisc;
    container result;

    InventDim.initFromInventTable(inventTable);
    
    ItemId = "10000";
    UnitId = "Pcs";
    TransDate = today();

    result = PriceDisc::findItemPriceAgreement(ModuleInventPurchSales::Purch, ItemId, inventDim, UnitId, TransDate, 10000, "1001",
                            "USD", "0");

}


No comments:

Post a Comment

How to enable the dimension fields based on the Item selected on the form.

[Form] public class KMTShipFromWarehouses extends FormRun {     InventDimCtrl_Frm_EditDimensions        inventDimFormSetup;     /// &l...