3 Ocak 2014 Cuma

AXAPTA - Birden fazla alış siparişinin bazı satırlarını birleştirip PurchEditLines formunda göstermek

    Args                    args = new Args();
    PurchFormLetter         purchFormLetter;
    purchTable              purchTable;
    VendReceiptsListTrans   ListTrans;
    PurchParmLine           purchParmLine;
    PurchParmTable          purchParmTable;
    Object                  dialog;
    vendReceiptsListJour    Jour;
    boolean                 err;
    VendPackingSlipTrans    PackingTrans;
    ;
    select purchTable where purchTable.PurchId == this.PurchId; //select first purchtable record
    //-------------- prepare purchformletter class -----
    purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);
    purchFormLetter.parmSourceTable(purchTable);
    purchFormLetter.initLinesQuery();
    purchformletter.createParmUpdate();
    purchFormLetter.transDate(this.PackingSlipDate);
//    purchformletter.documentNum(
    purchformletter.chooseLines();
    //--------------- add other purchtable records -----
    while select OrigpurchId from ListTrans
        group by ListTrans.OrigPurchId
        where ListTrans.ReceiptsListId == this.ReceiptsListId && ListTrans.OrigPurchId != this.PurchId
    {
       select purchTable where purchTable.PurchId == ListTrans.OrigPurchId;
        purchformletter.updateQueryAndChooseLines(purchTable);
    }
    //---------------- delete unnecessary purchase lines --------------------
    select firstonly forupdate purchParmLine
        where purchParmLine.ParmId == purchformletter.parmId();
    if (purchParmLine.RecId == 0)
    {
        box::stop("There isn't any purchline applicable");
        return;
    }
//    box::warning("111");
    ttsbegin;
    while select forupdate purchParmLine
        where purchParmLine.ParmId == purchformletter.parmId()
    {
        select firstonly ListTrans where ListTrans.ReceiptsListId == this.ReceiptsListId && ListTrans.OrigPurchId == purchParmLine.OrigPurchId &&
                ListTrans.ItemId == purchParmLine.ItemId && purchParmLine.InventTransId == ListTrans.InventTransId;
       // info(strfmt("%1 %2",purchparmline.ItemId,listtrans.ItemId));
        //---eğer bu sipariş satırı giriş listesinde yoksa sil-------------
        if (ListTrans.RecId == 0)
        {
//            info("---sil---");
            purchParmLine.delete();
            continue;
        }
       //----miktarı giriş listesinden al----------------------------------
            purchParmLine.ReceiveNow = ListTrans.PurchQty;
            purchParmLine.InventNow  = ListTrans.PurchQty;
//            purchParmLine.modifiedReceiveNow();
            purchParmLine.setQty(DocumentStatus::PackingSlip, false, true);
            purchParmLine.setLineAmount();
            purchParmLine.update();
     }
    update_recordset purchParmTable setting num = this.packingSlipId,
                                            TransDate = this.PackingSlipDate,
                                            DocumentDate = this.PackingSlipDate
    where purchParmTable.ParmId == purchformletter.parmId();
    ttscommit;
    if (this.packingSlipId)
        purchformletter.reArrange(true); //------------ merge purchases like push rearrange button at purcheditlines form ----
    dialog = purchformletter.dialog();
    dialog.run() ;
    dialog.wait();
    if (dialog.closedOk())
    {
            purchFormLetter.proforma(false);
            purchFormLetter.printFormLetter(true);
            purchFormLetter.specQty(PurchUpdate::ReceiveNow);
            purchFormLetter.progressHide();
            purchformletter.run();
            select firstonly PackingTrans join ListTrans
                where PackingTrans.purchId == ListTrans.OrigPurchId &&
                    ListTrans.ReceiptsListId == this.ReceiptsListId;
        if (PackingTrans.RecId != 0)
        {
            ttsbegin;
            update_recordset Jour setting VendReceiptsListJourStatus = DTVendReceiptsListJourStatus::PackingSlip
                where Jour.RecId == this.RecId;
            ttscommit;
        }
    }

Hiç yorum yok:

Yorum Gönder