如何通过X ++代码确认,选择销售订单,更新,打包并生成Dynamics AX 2012 R2中销售订单的发票?

时间:2016-08-19 05:46:34

标签: axapta dynamics-ax-2012 x++

我使用以下代码确认销售订单然后选择它。 确认

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

和选择

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);
}

现在怎么收拾它?并将其状态转换为" Delivered"以及如何为其生成发票并将其状态更改为"已开票"?

1 个答案:

答案 0 :(得分:1)

检查此代码是否已发送并过帐发票:

//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");