Hi,
I'm new in Dynamics 365 for Finance and Operations.
I have to create a project invoice proposal that uses lines from a specified sales order by x code.
I try to create them with the code below, I notice that the created invoice proposal includes transactions from Fee, Expense, On-account, etc. But I wat It to include only transactions from my sales order, how could I do this?
Here is my code:
public void run(ProjInvoiceProjId _projInvoiceProjId = projInvoiceProjId, ProjId _projId = projId)
{
ProjInvoiceProjId _ProjectContractId = _projInvoiceProjId;
ProjProposalJour projProposalJour; //table which will store journal records after creating invoice proposal
ProjInvoiceChoose m_oProjInvoiceChooseNormal; //Class for creating invoice proposal
ProjFormLetter projFormLetter; //Class for posting invoice proposal
ProjProposalItem projProposalItem;
ProjInvoiceProposalInsertLines proposalInsertLines;
ProjInvoiceProposalCreateLines proposalCreateLines;
ProjInvoiceProposalCreateLinesBase proposalCreateLinesBase;
ProjInvoiceProposalCreateLinesParams proposalCreateLinesParams;
ttsbegin;
//creation of invoice proposal
m_oProjInvoiceChooseNormal = ProjInvoiceChoose::psaNew_InvoiceChoose(_ProjectContractId,_projId,dateNull(),dateNull(),true, SalesUpdate::All);
m_oProjInvoiceChooseNormal.parmSalesTable(salesTable);
m_oProjInvoiceChooseNormal.parmSalesLine(salesLine);
m_oProjInvoiceChooseNormal.parmQuerySalesLine(true);
m_oProjInvoiceChooseNormal.run();
while select forupdate projProposalJour where projProposalJour.ProjInvoiceProjId == _ProjectContractId
{
//for approving invoice proposals
projProposalJour.LineProperty = ProjLinePropertyCode::Canceled;
projProposalJour.update();
//for posting invoice proposals
projFormLetter = projFormLetter::construct(DocumentStatus::ProjectInvoice);
projFormLetter.createParmLine(projProposalJour);
projFormLetter.run();
//to get latest record
projProposalJour = projProposalJour::find(projProposalJour.ProposalId);
info(strFmt("Invoice ProposalId: %1 \t InvoiceId: %2",
projProposalJour.ProposalId, projProposalJour.ProjInvoiceId));
}
ttscommit;
}