Month: May 2014

AX 2012: Manual Charges

Posted on Updated on

Once you have setup Charges Codes, you can add manual charges to Sales Order (SO) or Purchase Order (PO). The question is why do we need to add charges manually to orders if we have the auto charges functionality? Typically we add manual charges to an order if it is not a regular one, which needs some eccentric charges to be addressed. An example could be expedited orders which need to be shipped before standard delivery times. In this case we may need to charge additional amount for freight. This is where Manual Charges come to play their role.

Manual Charges for Sales Order:

Manual charges can be added to either the SO header, individual line items or both the header and the line items. To setup the manual charges to:

1. SO header, navigate to Sell tab → Charges to open Charges Transactions Form.
2. SO lines, navigate to Financials → Maintain Charges to open Charges Transactions Form.

Untitled

The fields of Charges Transactions form are described below:

Field Description
Charges codes Select Charge code. For more details read the full post Charges Codes
Transaction text Text defined in the description of the charge code
Category Describes how the charges are calculated:

  1. Fixed charges
  2. Charge for each unit
  3. Percentage of the line amount
  4. Intercompany (used for intercompany trade)
Charges value Enter the amount for this charge. It can anyone of the following depending on the category selected:

  1. Fixed amount
  2. Percentage of the order or line total
  3. Fixed amount for each unit
Currency Defaulted from the currency of the selected charge code
Keep Indicates whether the charges transactions must be retained after partial invoicing or not

 

Manual Charges for Purchase Order:

Similarly, we can add charges manually to PO header or PO lines or both depending on the scenario. To setup the manual charges to:

1. PO header, navigate to Purchase tab → Manage Charges to open Charges Transactions Form.
2. PO lines, navigate to Financials → Maintain Charges to open Charges Transactions Form.

You can see the description of Charges Transactions Form above. In Purchase Order, we can also allocate header charges to lines. We determine how this allocations should be carried out by navigating to Purchase tab → Charges → Allocate charges.

Untitled

The fields of Allocate Charges form are described below:

Field Description
Charges allocation If the header charge is fixed in nature then it can be divided using the following options:

  1. Net Amount: Allocated according to line’s net amount
  2. Quantity: Allocated according to line’s quantity of units
  3. Per line: Allocated equally among all the selected lines
Allocate charges to lines Choose lines for allocation:

  1. All lines: All lines selected
  2. Positive lines: Positive quantity lines selected
  3. Negative lines: Negative quantity lines selected
Allocate all Select if you want to include all kinds of charges in the allocation process regardless of the Debit type specified in the Charges code setup. By default, charges with Debit type of Item are included in the allocation process
Received Select to only allocate charges to received order lines
Stocked Select to only allocate charges to inventoried order lines
Show selection and clear specific lines Select to exclude specific lines from this allocation. This check box is not available if no charges are set up

Thanks for reading. Happy Daxing! 🙂

AX 2012: this vs element | When to Use What?

Posted on Updated on

In X++ we often come across an issue that we are unable to access an object member (e.g. a form method) via this keyword. Instead we CAN access the same form method via element keyword. So what’s the difference between them?

 

UntitledThe difference is of the scope. To understand how it works, let’s assume that we are standing at a button’s click method on a form and we need to access a method defined at the form level (e.g. readResourceFile() in this case). In this situation this keyword cannot access the method since its scope is only limited to the members of the current object. For example with this keyword we can access all the members of the button object. However, we can access the form-level method using the element keyword.

So element keyword has a bigger scope as compared to this keyword.

AX 2012: Create lookup in X++

Posted on Updated on

To create a lookup on a control (e.g. StringEdit control), override the lookup method of that control and copy paste the following code snippet in it. Of course, you will need to substitute datasource of the query according to your requirements.

public void lookup()
{
    Query query;
    QueryBuildDataSource datasourceModule;
    QueryBuildDataSource datasourceLanguage;
    QueryBuildRange rangeElementType;
    QueryBuildRange rangeModuleId;
    SysTableLookup sysTableLookup;
 
    query = new Query();
    datasourceLanguage = query.addDataSource(tableNum(SysModelElement));
    datasourceModule = datasourceLanguage.addDataSource(tableNum(SysModelElement));
    datasourceModule.joinMode(JoinMode::InnerJoin);
    datasourceModule.relations(false);
    datasourceModule.addLink(
        fieldNum(SysModelElement, ParentModelElement),
        fieldNum(SysModelElement, RecId));

    datasourceModule.addRange(
        fieldNum(SysModelElement, ElementType)).value(int2str(UtilElementType::LabelFile));

    datasourceModule.addRange(fieldNum(SysModelElement, Name)).value(ModuleId.text());
 
    sysTableLookup = SysTableLookup::newParameters(tableNum(SysModelElement), this);
    sysTableLookup.addLookupfield(fieldNum(SysModelElement, Name));
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}