mercoledì 22 maggio 2024
How to check/add Cust/Vend Journal transactions to Sales Tax (Italy) report
By my point of view, an helpful checkpoint, is to veify for each Sales Tax transactions the Posting-parameters.
I'm meaning: Purchase->Invoice Journals; Sales ledger-> Payment Journal and others.
In case we are facing to some transations missing in SalesTax (Italy) Report, the first check is to verify these TaxTrans data: mandatory fields
The fields are: TaxTrans. TaxBook and TaxTrans.TaxBookSection.
These fields create the link between transactions and Tax Report. table fields
Report Example
giovedì 2 maggio 2024
AX 2012 - Fixed default dimension
Con questo job possiamo ottenere i valori "fixed" sulla default dimension di un conto:
static void GetFixedDefaultDimension(Args _args)
{
Map map;
MainAccountLegalEntity MainAccountLegalEntity;
MainAccount mainAccount;
MapEnumerator enumerator;
DimensionStorageSegment DimensionStorageSegment;
DimensionAttribute DimensionAttribute;
CompanyInfo companyInfo;
companyInfo = CompanyInfo::find();
select firstOnly MainAccountLegalEntity
join mainAccount
where mainAccount.RecId == MainAccountLegalEntity.MainAccount
&& mainAccount.MainAccountId == "200100"
&& MainAccountLegalEntity.LegalEntity == companyInfo.RecId;
map = DimensionDefaultingService::getFixedDimensionsForMainAccount(MainAccountLegalEntity.MainAccount,MainAccountLegalEntity.LegalEntity);
enumerator = Map.getEnumerator();
while (enumerator.moveNext())
{
DimensionStorageSegment = enumerator.currentValue();
DimensionAttribute = DimensionAttribute::find(enumerator.currentKey());
info(strFmt("%1:%2 -- %3",DimensionAttribute.Name
,DimensionStorageSegment.parmDisplayValue()
,DimensionStorageSegment.getName()));
}
}
venerdì 12 aprile 2024
AX2012/D365- HOW TO EXTRACT ALL MAINACCOUNT ALLOCATION RULES by code X++
This article is a merely starting point.
In AX2012 / D365 we can handle the cost allocation by parameters.
Ledger allocation rules are used to automatically calculate and generate allocation journals and account entries for the allocation of ledger balances or fixed amounts. Allocation methods can be variable or fixed. The allocation is based on the transaction currency value.
- We can split the cost to different/several Financial Dimensions (in percentage); By Company etc...
Microsoft documentation:
AX2012:
https://learn.microsoft.com/en-us/dynamicsax-2012/appuser-itpro/create-an-allocation-rule
D365:
https://learn.microsoft.com/en-us/dynamics365/finance/general-ledger/ledger-allocation-rules
Data to extract:
JOB x++
By code x++ it is possible. The job below can exttract in a infolog the data:
it be can improve
Str1260 mainAccount_Name, DimFinanancial_Name;
MainAccount account;
DimensionAttributeValueSetItem valueSetItem;
DimensionAttributeValue dimAttrValue;
DimensionAttribute dimAttr;
Str1260 dimensionAttributeNames;
LedgerAllocation allocation;
DefaultDimensionView dimensionView;
DimensionAttribute dimensionAttribute;
while select allocation
{
select Name, MainAccountId from account where account.RecId == allocation.FromMainAccount;
mainAccount_Name = account.Name; // to chek the value
while select dimAttr
exists join dimAttrValue
where dimAttrValue.DimensionAttribute == dimAttr.RecId
exists join valueSetItem
where valueSetItem.DimensionAttributeValue == dimAttrValue.RecId
&& valueSetItem.DimensionAttributeValueSet == allocation.ToDefaultDimension
{
DimFinanancial_Name= dimAttr.Name; // to check the value
select firstOnly dimensionView
where dimensionView.DefaultDimension == allocation.ToDefaultDimension
join dimensionAttribute
where dimensionView.Name == dimensionAttribute.Name
&& dimensionView.Name == DimFinanancial_Name;
// OUTPUT
info(strFmt("%1;%2;%3;%4;%5",
mainAccount_Name, account.MainAccountId,
DimFinanancial_Name,dimensionView.DisplayValue,allocation.Value));
}
}
lunedì 1 aprile 2024
AX 2012 - D365FFO - Aggiungere controlli ad una form dinamicamente e gestire gli eventi (registerOverrideMethod)
In questo post vediamo come aggiungere a run time dei controlli ad una form e gestire gli eventi dei controlli.
La form di base conterrà un button group a cui aggiungeremo tre pulsanti ed un gruppo a cui aggiungeremo un enumerato ed una stringa.
Dei tre pulsanti gestiamo l'evento mouseDown (in D365 l'evento mouseDown è deprecato) per capire se il pulsante è stato premuto col pulsante destro oppure col sinistro; dell'enumerato gestiamo l'evento selectionChanged e del campo stringa l'evento modified.
Sia l'aggiunta dei controlli che gli event handler vanno aggiunti nella init della form:
public void init()
{
int i;
FormButtonControl button;
FormComboBoxControl comboBox;
FormStringControl stringControl;
super();
for(i = 0; i < 3; i++)
{
button = ButtonGroup.addControl(FormControlType::Button, strFmt("button_%1",i+1));
button.text(strFmt("%1",i+1));
button.registerOverrideMethod(methodStr(FormButtonControl, mouseDown), identifierStr(buttonMouseDown), this);
}
comboBox = ControlGroup.addControl(FormControlType::ComboBox, "InventCustVend_Combo");
comboBox.enumType(enumNum(ModuleInventCustVend));
comboBox.registerOverrideMethod(methodStr(FormComboBoxControl, selectionChange), identifierStr(ComboSelectionChange), this);
stringControl = ControlGroup.addControl(FormControlType::String, "Description_Text");
stringControl.extendedDataType(extendedTypeNum(Description));
stringControl.registerOverrideMethod(methodStr(FormStringControl, modified), identifierStr(modifiedString), this);
}
I tre event handler vanno aggiunti a livello di form: public void buttonMouseDown(int _x, int _y, int _button, boolean _Ctrl, boolean _Shift,FormButtonControl _btn)
{
switch(_button)
{
case 1:
info(strFmt("hai premuto il bottone '%1' col pulsante %2",_btn.name(),"sinistro"));
break;
case 2:
info(strFmt("hai premuto il bottone '%1' col pulsante %2",_btn.name(),"destro"));
break;
}
}
public int comboSelectionChange(FormComboBoxControl _comboBox)
{
info(strFmt("L'enumerato è cambiato %1",_comboBox.selection()));
return 1;
}
public boolean modifiedString(FormStringControl _stringControl)
{
boolean ret = true;
info(strFmt("nuovo valore '%1'",_stringControl.text()));
return ret;
}
Tutti i metodi per gestire gli eventi prendono il controllo come parametro. Se l'event prevede altri parametri standard, come nel caso mouseDown, il controllo và aggiunto come ultimo parametro.
martedì 12 marzo 2024
AX 2012 - Job per scrivere i metodi di una classe in un unico file di testo
static void LIL_Ax2012To365ClassesSourceCode(Args _args)
{
SysDictClass dictClass;
SysDictMethod dictMethod;
int i;
Source Source;
TextIo textIo;
Set methodsSet;
SetEnumerator methodsSetEnum;
str filePath;
ClassId classId;
str addSpaceToNewLineRegex;
container conFilter = ["TXT", "*.txt"];
#File
#xppTexts
classId = classNum(Tutorial_RunbaseBatch);
dictClass = new SysDictClass(classId);
for (i=1;i<=dictClass.objectMethodCnt();i++)
{
dictMethod = new SysDictMethod(UtilElementType::ClassInstanceMethod, dictClass.id(), dictClass.objectMethod(i));
if(dictMethod.name() == identifierStr(classDeclaration))
{
Source += dictMethod.getSource() + #newline;
Source = strRem(Source, "}");
}
}
methodsSet = dictClass.methods(true,true,false);
methodsSetEnum = methodsSet.getEnumerator();
methodsSetEnum.reset();
while(methodsSetEnum.moveNext())
{
dictMethod = methodsSetEnum.current();
Source += dictMethod.getSource();
Source += #newline + #newline;
}
source += "}";
filePath = WinAPI::getSaveFileName(
0,
conFilter,
"",
"@SYS56237",
".txt",
dictClass.name());
textIo = new TextIo(filePath, #IO_WRITE);
textIo.write(Source);
}