zoaoo

博客园 首页 新随笔 联系 订阅 管理
static void CreateAndPostSales(Args _args)
{
    List                        il = new List(Types::Record);
    SalesTable                  localSalesTable;
    SalesLine                   localSalesLine;
    SalesFormLetter             salesFormLetter;
    TmpFrmVirtual               localTmpFrmVirtual;
    CustPackingSlipJour         localCustPackingSlipJour;
    ;

    ttsbegin;
    localSalesTable.clear();
    localSalesTable.initValue();
    localSalesTable.CustAccount = "C-00001";
    localSalesTable.initFromCustTable();
    localSalesTable.SalesId = NumberSeq::newGetNumFromCode("SONUM").num();
    localSalesTable.SalesPoolId = "NOR";
    localSalesTable.ReceiptDateConfirmed  = systemDateGet();
    localSalesTable.ShippingDateConfirmed = systemDateGet();
    localSalesTable.CurrencyCode = "RMB";
    localSalesTable.insert();

    localSalesLine.clear();
    localSalesLine.initValue();
    localSalesLine.initFromSalesTable(localSalesTable);
    localSalesLine.ItemId           = "100XA00125";
    localSalesLine.initFromInventTable(InventTable::find(localSalesLine.ItemId));
    localSalesLine.SalesQty         = 1;
    localSalesLine.SalesUnit        = InventTableModule::find(localSalesLine.ItemId,ModuleInventPurchSales::Invent).UnitId;
    localSalesLine.THK_2ndSalesQty  = 0;
    localSalesLine.THK_2ndSalesUnit = InventTableModule::find(localSalesLine.ItemId,ModuleInventPurchSales::Invent).THK_2ndUnit;
    localSalesLine.SalesPrice       = 1;
    localSalesLine.InventDimId      = "T06094862";
    localSalesLine.LineAmount       = localSalesLine.calcLineAmount();
    localSalesLine.ReceiptDateConfirmed     = systemDateGet();
    localSalesLine.ShippingDateConfirmed    = systemDateGet();
    localSalesLine.createLine(NoYes::No,             // Validate
                              NoYes::No,             // initFromSalesTable
                              NoYes::No,             // initFromInventTable
                              NoYes::Yes,            // calcInventQty
                              NoYes::No,             // searchMarkup
                              NoYes::No              // searchPrice
                              );

    info(strfmt("Sales %1 is created", localSalesTable.SalesId),'', SysInfoAction_TableField::newBuffer(localSalesTable));

    salesFormLetter = SalesFormLetter::construct(DocumentStatus::PackingSlip);
    salesFormLetter.getLast();
    salesFormLetter.allowEmptyTable(salesFormLetter.initAllowEmptyTable(true));
    salesFormLetter.transDate(systemdateget());
    salesFormLetter.update(localSalesTable, systemdateget(), SalesUpdate::All, AccountOrder::None, false, false);
    salesFormLetter.runShipCarrier();

    while select localCustPackingSlipJour
        where localCustPackingSlipJour.SalesId == localSalesTable.SalesId
    {
        localTmpFrmVirtual.clear();
        localTmpFrmVirtual.TableNum = tableNum(custPackingSlipJour);
        localTmpFrmVirtual.RecordNo = localCustPackingSlipJour.recid;
        localTmpFrmVirtual.insert();
        il.addEnd(localTmpFrmVirtual);
    }

    salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);
    salesFormLetter.getLast();
    salesFormLetter.allowEmptyTable(salesFormLetter.initAllowEmptyTable(true));
    salesFormLetter.transDate(systemdateget());
    salesFormLetter.setNumAndVoucher(NumberSeq::newGetNumFromCode("SOINV11").num(),NumberSeq::newGetNumFromCode("SOINV11").num());
    salesFormLetter.update(localSalesTable, systemdateget(), SalesUpdate::PackingSlip, AccountOrder::Account, false, false,false,false,il.pack());
    salesFormLetter.runShipCarrier();

    ttscommit;
}

 

posted on 2017-09-14 15:24  zoaoo  阅读(279)  评论(0编辑  收藏  举报