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

Dynamics Axapta: Sales Orders & Business Connector

Well, again folllowing my same idea of writting close to nothing and pasting code, I'll paste in some code to create a sales order from some basic data and the invoice it. I'll try to explain more in the future. AxaptaObject axSalesTable = ax.CreateAxaptaObject("AxSalesTable"); AxaptaRecord rcInventDim = ax.CreateAxaptaRecord("InventDim"); AxaptaRecord rcCustTable = ax.CreateAxaptaRecord("CustTable"); rcCustTable.ExecuteStmt("select * from %1 where %1.AccountNum == '" + MySalesOrderObject.CustAccount + "'"); if (MySalesOrderObject.CurrencyCode.Trim().Length == 0) MySalesOrderObject.CurrencyCode = rcCustTable.get_Field("Currency").ToString().Trim(); string sTaxGroup = rcCustTable.get_Field("taxgroup").ToString().Trim(); //set header level fields axSalesTable.Call("parmSalesName", MySalesOrderObject.SalesName.Trim()); axSalesTable.Call("parmCustAccount", M

Passing values between form and class

Class name is EmplDuplication and Form is EmplTable . void clicked() {    MenuFunction mf;    args args = new Args();    ;     args.record(EmplTable);     mf = new menufunction(identifierstr(EmplDuplication), MenuItemType::Action); mf.run(args); } Meanwhile, in the main() method of the EmplDuplication class, we need to put this Axapta x++ code to get the datasource: static void main(Args args) {     EmplDuplication EmplDuplication; EmplTable localEmplTable; ;     if(args.record().TableId == tablenum(EmplTable)) localEmplTable = args.record();     ... }