24 Apr 2015
Posted by: Juliano Bachesque in: X++
Olá Pessoal,
Tudo bem?
Pessoal essa semana passei por uma situação onde precisei adicionar uma referência fiscal no momento do faturamento de uma ordem de venda via código X++ no Microsoft Dynamics AX 2012 e gostaria de compartilhar com vocês caso passem pela mesma situação.
private void addFiscalReferenceAndPostSalesOrder(SalesId _salesId, EFDocAccessKey_BR _accessKey) { SalesTable salesTable; SalesParmTable salesParmTable; FiscalReferenceController_BR fiscalReferenceController; TmpFiscalReference_BR tmpFiscalReference_BR; SalesFormLetter salesFormLetter; ttsBegin; //get SalesTable salesTable = salesTable::find(_salesId, false); salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice); salesFormLetter.salesTable(salesTAble); salesFormLetter.transDate (systemDateGet()); salesFormLetter.specQty (SalesUpdate::All); salesFormLetter.createParmUpdateFromParmUpdateRecord(salesFormLetter.salesParmUpdate()); salesFormLetter.initParmSalesTable(salesTable); salesFormLetter.initParameters(salesFormLetter.salesParmUpdate(),Printout::After); salesFormLetter.initLinesQuery(); //Get salesParmTable by ParmId select forUpdate firstOnly salesParmTable where salesParmTable.ParmId == salesFormLetter.parmId(); //Add fiscal reference fiscalReferenceController = FiscalReferenceController_BR::construct(salesParmTable); tmpFiscalReference_BR.setTmpData(fiscalReferenceController.initTempTable()); tmpFiscalReference_BR.initFromReferenceMap(FiscalDocument_BR::findByAccessKey(_accessKey)); tmpFiscalReference_BR.LegalTextId = fiscalReferenceController.getDefaultLegalTextId(); tmpFiscalReference_BR.insert(); while select tmpFiscalReference_BR { fiscalReferenceController.writeTempTableRecord(tmpFiscalReference_BR); } //Post sales order salesFormLetter.run(); ttsCommit; } |
Abraços,
Juliano Bachesque
Leave a reply