Skip to main content

Modify InvoiceDate, TransDate .. on already posted Vendor Invoice

you have to try first run test system .



static void xxx(Args _args)

{

invoiceId NumFacturaDesde;

invoiceId NumFacturaHasta;

CustInvoiceJour _custinvoicejour;

CustInvoiceSalesLink _custinvoicesaleslink;

CustInvoiceTrans _custinvoicetrans;

LedgerTrans _ledgertrans;

CustTrans _custtrans;

CustTransOpen _custtransopen;

InventTrans _inventtrans;

TaxTrans _taxtrans;

CustBillOfExchangeInvoice _CustBillOfExchangeInvoice;

CustBillOfExchangeTrans _CustBillOfExchangeTrans;

CustSetTlement _CustSetTlement;



InvoiceDate FechaBuena;

;



//Inicializamos variables

NumFacturaDesde = '035884';

NumFacturaHasta = '035884';

FechaBuena = str2date("22.04.2005",123);



ttsbegin;

_custinvoicejour.clear();

SELECT FORUPDATE * FROM _custinvoicejour

WHERE _custinvoicejour.InvoiceId>=NumFacturaDesde &&

_custinvoicejour.InvoiceId<=NumFacturaHasta;



while(_custinvoicejour.RecId)

{

 _custinvoicesaleslink.clear();

SELECT FORUPDATE * FROM _custinvoicesaleslink

WHERE _custinvoicesaleslink.invoiceId == _custinvoicejour.InvoiceId;

while(_custinvoicesaleslink.RecId)

{

_custinvoicesaleslink.invoiceDate = FechaBuena;

_custinvoicesaleslink.update();

next _custinvoicesaleslink;

}



_custinvoicetrans.clear();

SELECT FORUPDATE * FROM _custinvoicetrans

WHERE _custinvoicetrans.InvoiceId == _custinvoicejour.InvoiceId;

while(_custinvoicetrans.RecId)

{

_custinvoicetrans.InvoiceDate = FechaBuena;

_custinvoicetrans.update();

next _custinvoicetrans;

}



_ledgertrans.clear();

SELECT FORUPDATE * FROM _ledgertrans

WHERE _ledgertrans.Voucher == _custinvoicejour.LedgerVoucher;

while(_ledgertrans.RecId)

{

_ledgertrans.TransDate = FechaBuena;

_ledgertrans.update();

next _ledgertrans;

}



_custtrans.clear();

SELECT FORUPDATE * FROM _custtrans

WHERE _custtrans.Voucher == _custinvoicejour.LedgerVoucher;

while(_custtrans.RecId)

{

SELECT FORUPDATE * FROM _custtransopen

WHERE _custtransopen.RefRecId == _custtrans.RecId;

while(_custtransopen.RecId)

{

_custtransopen.TransDate = FechaBuena;

_custtransopen.update();

next _custtransopen;

}

_custtrans.TransDate = FechaBuena;

_custtrans.update();

next _custtrans;

}



_inventtrans.clear();

SELECT FORUPDATE * FROM _inventtrans

WHERE _inventtrans.Voucher == _custinvoicejour.LedgerVoucher;

while(_inventtrans.RecId)

{

_inventtrans.DateFinancial = FechaBuena;

_inventtrans.update();

next _inventtrans;

}



_taxtrans.clear();

SELECT FORUPDATE * FROM _taxtrans

WHERE _taxtrans.Voucher == _custinvoicejour.LedgerVoucher;

while(_taxtrans.RecId)

{

_taxtrans.TransDate = FechaBuena;

_taxtrans.update();

next _taxtrans;

}



_CustBillOfExchangeInvoice.clear();

SELECT FORUPDATE * FROM _CustBillOfExchangeInvoice

WHERE _CustBillOfExchangeInvoice.InvoiceVoucher ==

_custinvoicejour.LedgerVoucher;

while(_CustBillOfExchangeInvoice.RecId)

{

_CustBillOfExchangeInvoice.TransDate = FechaBuena;

_CustBillOfExchangeInvoice.InvoiceDate = FechaBuena;

_CustBillOfExchangeInvoice.update();

next _CustBillOfExchangeInvoice;

}



_CustBillOfExchangeTrans.clear();

SELECT FORUPDATE * FROM _CustBillOfExchangeTrans

WHERE _CustBillOfExchangeTrans.Voucher == _custinvoicejour.LedgerVoucher;

while(_CustBillOfExchangeTrans.RecId)

{

_CustBillOfExchangeTrans.TransDate = FechaBuena;

_CustBillOfExchangeTrans.update();

next _CustBillOfExchangeTrans;

}



_CustSetTlement.clear();

SELECT FORUPDATE * FROM _CustSetTlement

WHERE _CustSetTlement.OffsetTransVoucher == _custinvoicejour.LedgerVoucher;

while(_CustSetTlement.RecId)

{

_CustSetTlement.TransDate = FechaBuena;

_CustSetTlement.update();

next _CustSetTlement;

}



_custinvoicejour.InvoiceDate = FechaBuena;

_custinvoicejour.update();



next _custinvoicejour;

}

ttscommit;



}

Popular posts from this blog

Mark All for Open Cust Trans and Open Vend Trans

We have situations where there are lots of open transactions that need to be settled against each other. This can be the case if auto settlement is turned off. One solution is to add a "Mark All" button to the custOpenTrans or vendOpenTrans forms. This button "checks" the mark checkbox on every line. The user can then uncheck several lines if needed and Update to settle the lines. The code below is an example of what we used on the open vendor transaction screen. The code is very similar on the AR side. One note: I used vendTable.AccountNum in the code below. That should be generalized to work with any buffer that is passed into the open trans form. void customMarkAll() { VendTransOpen localVendTransOpen; VendTrans localVendTrans; container conSum; int linesProcessed; ; //show wait cursor startLengthyOperation(); element.lock(); //remove all prior markings specOffsetVoucher.deleteSpe...

Print Report in Microsoft Dynamics AX 2009 through X++

I am trying to print sales confirmation report on a button click which I have added on Sales Order Detail form in Microsoft Dynamics AX 2009. On click event of that button, I have written following code: void clicked() {     Args                args;     ReportRun           reportRun;     SalesFormLetter     salesFormLetter;     PrintJobSettings    printJobSettings;     CustConfirmJour     custConfirmJour;     RecordSortedList    list                = new RecordSortedList(55);     SalesTable          salesTableUpdate;     ;     SELEC...

Creating Free Text Invoice through X++ code

Job: Calling class from job to run the class public void freeTextInvoicePostTestJob() { Dialog dialog; DialogField dlgCustAcc; DialogGroup dialogPeriodLengthGroup, dialogPeriodLengthGroup1; DialogField dlgLedgerAcc; ; dialog = new Dialog("Free-Text Invoice"); dialogPeriodLengthGroup1 = dialog.addGroup('Cust Table'); dlgCustAcc = dialog.addField(typeid(CustAccount)); dialogPeriodLengthGroup = dialog.addGroup('Ledger Table'); dlgLedgerAcc = dialog.addField(typeid(LedgerAccount)); if(dialog.run()) { if(dlgCustAcc.value() && dlgLedgerAcc.value() != '') FreeTxtInvoiceCreatePost::main(dlgCustAcc.value(), dlgLedgerAcc.value()); else throw error(strfmt("Either CustAccount or LedgerAccount info is missing.")); } } Class: Which creates the free text invoice class FreeTxtInvoiceCreatePost { } static void main(CustAccount _custAccount, LedgerAccount _ledgerAccount) { CustInvoiceTable custInvoiceTable; ...