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

What does this mean: "The form datasource query object does not support changing its AllowCrossCompany property after the form has executed the query."?

I have made a form with datasources vendtable and vendtrans. Inside vendtable_ds.executequery() looks like this: QueryBuildDataSource queryBuildDatasource ,queryBDS_VendTrans_Invoice; ; queryBuildDatasource = this.query().dataSourceTable(tablenum(vendtable)); queryBDS_VendTrans_Invoice = this.query().dataSourceTable(tablenum(vendtrans)); if (curext() == "MASTERCOMP") { this.query().allowCrossCompany(true); } else { this.query().allowCrossCompany(false); } //FilterVendorName = stringedit control on form if (FilterVendorName.text()) { queryBuildDatasource.addRange(fieldNum(VendTable,Name)).value(strfmt("*%1*", FilterVendorName.text())); } else { queryBuildDatasource.clearRange(fieldNum(VendTable,Name)); } //FilterInvoiceNumber = stringedit control on form if (FilterInvoiceNumber.valueStr() == "") { queryBDS_VendTrans_Invoice.enabled(false); } else { queryBDS_VendTrans_Invoice.enabled(true); queryBDS_VendTrans_In...

Credit Note [Dynamics AX] using X++

This post will help to create credit note for a sales order based on the invent lot id. All the invoices raised for a particular sales line – Lot Id will be raised back as a credit note. Information on Credit Note: A credit note or credit memorandum (memo) is a commercial document issued by a seller to a buyer. The seller usually issues a Credit Memo for the same or lower amount than the invoice, and then repays the money to the buyer or sets it off against a balance due from other transactions Below Code will help to create credit note for all the invoices raised against the sales line -lot id. Please note: This code can be customized as per your requirements. This is just a template to help creating credit note using X++ code. Please test the code before use. static void SR_CreateCreditNote_Sales(Args _args) { // Coded by Sreenath Reddy CustInvoiceTrans custInvoiceTrans; Dialog dialog = new Dialog(“Create credit note – for sales.”); DialogField dfInv...