Quantcast
Channel: Microsoft Dynamics 365 Community
Viewing all articles
Browse latest Browse all 17314

Adicionar Textos de notas fiscais na ordem de venda

$
0
0

Olá Pessoal,
Tudo bem?

Hoje adicionar um texto de nota fiscal a uma ordem de venda via X++. Estou compartilhando com vocês caso precisem algum dia.

publicvoid generateDocumentReferenceExternal(SalesTable _salesTable, FiscalDocumentTextID_BR _textID){
    DocuRef                         docuRefLocal;
    DocuRefExt_BR                   docuRefExt_BRLocal;
    FiscalDocumentSourceText_BR     fiscalDocumentSourceTextLocal;
 
    if(_textID){
        fiscalDocumentSourceTextLocal = FiscalDocumentSourceText_BR::findByTextID(_textID);
 
        if(fiscalDocumentSourceTextLocal){try{ttsBegin;
 
                docuRefLocal.RefTableId=   _salesTable.TableId;
                docuRefLocal.RefRecId=   _salesTable.RecId;
                docuRefLocal.RefCompanyId=   _salesTable.dataAreaId;
                docuRefLocal.TypeId=   BrazilParameters::find().FiscalDocumentTextDocuTypeId;
                docuRefLocal.initFromFiscalDocumentSourceText_BR(fiscalDocumentSourceTextLocal);
                docuRefLocal.insert();
 
                docuRefExt_BRLocal.DocuRef=  docuRefLocal.RecId;
                docuRefExt_BRLocal.Type=   FiscalDocumentTextType_BR::UserDef;
                docuRefExt_BRLocal.initFromFiscalDocumentSourceText(fiscalDocumentSourceTextLocal);
                docuRefExt_BRLocal.insert();
 
                docuRefExt_BRLocal.initProcessReference();
 
                ttsCommit;
 
            }
            catch
            {throw error(strFmt("Falha ao tentar gerar texto de nota fiscal para a ordem de venda %1", _salesTable.SalesId));
            } 
        }} 
}

Viewing all articles
Browse latest Browse all 17314

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>