简体   繁体   中英

How to confirm, pick sales order, update, pack and generate invoice of a sales order in Dynamics AX 2012 R2 through X++ code?

I am using the below code for the confirmation of a sales order and then picking it. For confirming

public void confirmSO()
{
    salesTable = SalesTable::find(salesTable.SalesId);
    salesFormletter = SalesFormletter::construct(DocumentStatus::PickingSlip);
    salesFormletter.update(salesTable, systemDateGet(), SalesUpdate::All, AccountOrder::None,
    false, false);
}

and for picking

public void pickSlip()

{
    salesTable = salesTable::find(salesTable.SalesId);
    salesFormLetter = SalesFormLetter_PickingList::newPickingList();
    salesFormLetter.transDate(systemDateGet());
    salesFormLetter.update(salesTable,
                            systemdateget(),
                            SalesUpdate::All,
                            AccountOrder::None,
                            NoYes::No,
                            NoYes::No);
}

now how to pack it? and convert its status to "Delivered" and how to generate invoice for it and change its status to "Invoiced"?

Check this code to delivered and post invoice:

//Delivered Sales Order
ttsbegin;
//update Sales Line
salesLine = SalesLine::find(_salesId, _lineNum, true); 
salesLine.SalesDeliverNow   = -1;
salesLine.setInventDeliverNow();
salesLine.doUpdate();

//Post the delivery 
salesFormLetter = SalesFormLetter::construct(DocumentStatus::PackingSlip);
salesFormLetter.progressHide();                                // Hide the progress bar. 
salesFormLetter.update(salesTable,                             // SalesTable
                       SystemDateGet(),                        // Delivery date
                       SalesUpdate::DeliverNow,                // Quantity to update (SpecQty)
                       AccountOrder::None,                     // AccountOrder
                       false,                                  // Proforma only?
                       false);                                 // Printout?
ttscommit;

//Post the Sales Order Invoice
SalesFormLetter::construct(DocumentStatus::Invoice).update(SalesTable::find(_salesId));
info("Sales order posted");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM