Monday, 11 January 2021

AX 365 Create general journal from code x++

   LedgerJournalTable _ledgerJournalTable;

        JournalTableData _journalTableData;

        LedgerjournalTrans _ledgerjournalTrans;

       

        MCRLedgerJournal        journalTable;

        LedgerJournalTableData LedgerJournalTableData;

        NumberSeq _numberSeq;

        LedgerJournalACType _ledgerJournalACType;

        

        RecId _RecId;

        NumberSequenceTable _NumberSequenceTable;      

           


 _LedgerJournalTable.JournalName = 'Journal Name';//HpSetup::getSetup().HpCheque;

             

            _LedgerJournalTable.initFromLedgerJournalName();

            _ledgerJournalTable.Name=strJournalDesc;

            _LedgerJournalTable.insert();

            if (_ledgerJournalTable.RecId)

            {


                //_numberSeq = NumberSeq::newGetVoucherFromCode("Alloc_01");

                _RecId =  LedgerJournalName::find(HpSetup::getSetup().HpCheque).NumberSequenceTable;


                select firstonly  _NumberSequenceTable

                    where _NumberSequenceTable.RecId == _RecId;


                _numberSeq = NumberSeq::newGetVoucherFromCode(_NumberSequenceTable.NumberSequence);


                _ledgerjournalTrans.clear();

                _ledgerjournalTrans.initvalue();

                _LedgerJournalTrans.voucher = _numberSeq.voucher();

                _ledgerjournalTrans.JournalNum = _ledgerJournalTable.JournalNum;

                //_ledgerjournalTrans.Company = curext();

                _ledgerjournalTrans.TransDate = HpCheque.TransDate;

                _ledgerjournalTrans.CurrencyCode = CompanyInfoHelper::standardCurrency();

                _ledgerjournalTrans.Txt = "Transafer to cash";

                _ledgerjournalTrans.AccountType = LedgerJournalACType::Cust;

                _ledgerjournalTrans.LedgerDimension = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(HpCheque.CustAccount,LedgerJournalACType::Cust);

                _ledgerjournalTrans.OffsetAccountType = LedgerJournalACType::Bank;

                _ledgerjournalTrans.OffsetLedgerDimension = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(dialogField.value(),LedgerJournalACType::Bank) ;

                _ledgerjournalTrans.AmountCurCredit = HpCheque.TrxAmount;

                    

                _ledgerjournalTrans.insert();

No comments:

Post a Comment