Create Invoice Proposal and Post based on Project Contract using X++

Hi Friends,

This post is related to creation of Invoice proposal and then post it based on the Project Contract Id.

This will create invoice proposals based on the funding sources allocated to project contract. One thing we have to notice that we have to approve the Invoice proposal before posting the invoice proposal.

I have write code for both creation and post operation in the same method. We can write in different methods also as per the requirements.

Here is the X++ code:

//This method will create Invoice Proposals based on Project Contract and then Post those Invoice Proposals

//We can Implement Post functionality in other method based on Project Invoice Proposal Ids

//Here It will create Invoice Proposal then Approve it and then Post the same.

static void InvoiceProposalCreateAndPost(Args _args)

{

ProjInvoiceProjId _ProjectContractId = “”; //Project Contract Id for which we want to create Invoice Proposal

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

ttsBegin;

//Creation of Invoice Proposal

m_oProjInvoiceChooseNormal = ProjInvoiceChoose::PSANew_InvoiceChoose(_ProjectContractId);

m_oProjInvoiceChooseNormal.run();

while select forUpdate projProposalJour where projProposalJour.ProjInvoiceProjId == _ProjectContractId

{

//For approving Invoice proposals

projProposalJour.LineProperty = ProjLinePropertyCode::Approved;

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;

}

Please let me know if you are have any query or require further information.

Kind Regards,

Vijay Solanki.

Hey Vijay:

I have a question regarding the code which posts the invoice proposal… The method “createParmLine” in ProjFormLetter class is protected type. and we are not able to use it in a job… Do you have any other alternatives? Please respond…

Hello friends

i need x++ code for generate the invoice journal for ledger to ledger transaction…