static void ExampleLedgerJournalTaxAdjust(Args _args)
{
LedgerJOurnalTrans ledgerJournalTrans;
TaxLedgerJournalCalculate taxLedgerJournalCalculate;
TaxLedgerJournal taxLedgerJournal;
TaxRegulation taxRegulation;
;
ttsbegin;
// Find a ledgerJournalTrans record
select firstonly LedgerJournalTrans
where LedgerJournalTrans.JournalNum == "000185_010";
taxLedgerJournal = TaxLedgerJournal::construct(TaxJournalCall::Journal, ledgerJournalTrans, null);
taxRegulation = new TaxRegulation();
taxLedgerJournal.calcAndPost();
taxRegulation.setTax(taxLedgerJournal);
taxRegulation.createSumsFromTmp();
taxRegulation.allocateAmount(6.99);
taxRegulation.saveTaxRegulation();
ttscommit;
}
static void FreeTextTaxAdjust(Args _args)
{
CustInvoiceTable custInvoiceTable;
CustInvoiceCalcTax custInvoiceCalcTax;
TaxFreeInvoice taxFreeInvoice;
TaxRegulation taxRegulation;
;
ttsbegin;
select firstonly custInvoiceTable
where custInvoiceTable.InvoiceId == "Inv135";
custInvoiceCalcTax = new CustInvoiceCalcTax_Table(custInvoiceTable);
taxFreeInvoice = new TaxFreeInvoice(custInvoiceCalcTax);
taxFreeInvoice.calc();
taxRegulation = TaxRegulation::newTaxRegulation(taxFreeInvoice);
taxRegulation.allocateAmount(35.77);
taxRegulation.saveTaxRegulation();
ttscommit;
}
Saturday, February 26, 2011
X++ code for adjusting tax on journals and free text invoices
Checking to see if caller is a form
I had this requirement the other day to set the filter value on the LedgerJournalTable form when it was called from a new form that had been created.
This new form contained a JournalId field and I wanted the users to be able to right-click goto main table to open the LedgerJournalTable showing the journal record.
Because the journal may or may not be posted I needed to set the standard filter on the LedgerJournalTable form to show all journals (by default when the form is opened it shows 'Open' Journals only) So, I added some code to the init method of the LedgerJournalTable form to check the element.args().caller().name for my new form and then set the filter.
This worked a treat, except I managed to break the journal lookups in other areas of the system e.g. Vendor transactions -> Original document.
To cut a long story short the Original Documents function is a class (which does not have a name() method that also calls the LedgerJournalTable form.
To get around this issue I used the code below which checks to see if the caller is a form before calling the name() method.
This new form contained a JournalId field and I wanted the users to be able to right-click goto main table to open the LedgerJournalTable showing the journal record.
Because the journal may or may not be posted I needed to set the standard filter on the LedgerJournalTable form to show all journals (by default when the form is opened it shows 'Open' Journals only) So, I added some code to the init method of the LedgerJournalTable form to check the element.args().caller().name for my new form and then set the filter.
This worked a treat, except I managed to break the journal lookups in other areas of the system e.g. Vendor transactions -> Original document.
To cut a long story short the Original Documents function is a class (which does not have a name() method that also calls the LedgerJournalTable form.
To get around this issue I used the code below which checks to see if the caller is a form before calling the name() method.
if (element.args() && element.args().caller())
{
// Make sure this was via a form.
if(SysDictClass::is(element.args().caller(), classnum(FormRun)))
{
// Cast the caller and make sure it is the right form.
callerForm = element.args().caller();
if (callerForm.name() == formstr(LIQ_RegisterCashControlDetails))
{
allOpenPostedField.selection(AllOpenPosted::All);
}
}
}
Monday, February 21, 2011
Handling AX UTC dates in SQL Server
SELECT *, DATEADD(hour,DATEDIFF(hour,GETUTCDATE(),GETDATE()),MODIFIEDDATETIME) As ModifiedDateTime from SYSRECORDLEVELSECURITY
Wednesday, February 16, 2011
Dynamics AX 4.0 SQL 2005 OLAP issue
The client reported an issue with not being able to process OLAP cubes after returning to work after being away on holiday.
It was pretty clear from the error, what the issue was - missing OLAP client components and after a quick investigation it was discovered that the client's PC had been rebuilt with Windows 7.
But after installing the required OLAP client components we still couldn't update OLAP cubes.
The error we were now getting was:
Method 'connect' in COM object of class '{B492C386-0195-11D2-89BA-00C04FB9898D}' returned error code 0x800A0005 () which means: The connection string to repository needs to be specified in the 9.0 server properties (see ... section in msmdsrv.ini file from Analysis Services 9.0).
Upon further investigation it was discovered that the OLAP version which is stored in the AX database was reset to SQL 2000. This is apparently a known issue that sometimes happens when you try to connect to OLAP from a PC that doesn't have the client tools installed. Even if you install them later on this doesn't fix the issue. You need to go into the OLAPServer table in AX and manually set the OLAP version back to SQL 2005.
Subscribe to:
Posts (Atom)