zoukankan      html  css  js  c++  java
  • How to remove Marking and cannal remaining delivery quantity on Sales order From

    THK_blockSalesLines method from salesTable table

    // VAR Changed on 11 Oct 2011 at 11:02:29 by THK7519
    static void THK_blockSalesLines(SalesId _salesId, boolean _block = true)
    {
        #avifiles
        SalesLine               salesLine;
        SysOperationProgress    progress;
        int                     i;
        boolean                 updated;
        ;

        ttsbegin;

        select count(recId) from salesLine
            where salesLine.SalesId == _salesId;

        progress    = SysOperationProgress::newGeneral(#aviupdate, "Stopping SO lines", salesLine.RecId);

        while select forupdate salesLine
            where salesLine.SalesId == _salesId
        {
            i++;

            progress.setText(strfmt('Line %1, Item : %2',i,salesLine.ItemId));
            progress.incCount();



            if (_block)
            {
                TradeInterCompany::removeMarking(salesLine, null);

                // VAR Changed on 11 Oct 2011 at 11:02:29 by THK7519 Begin
                updated = SalesLine::THK_CannalRemainSOLineQty(salesLine);
                // VAR Changed on 11 Oct 2011 at 11:02:29 by THK7519 End

            }
            salesLine.Blocked   = _block;
            salesLine.update();
        }
        if(updated)
            ttscommit;
        else
            ttsabort;
    }

    THK_CannalRemainSOLineQty method from salesLine table

    // VAR Changed on 10 Oct 2011 at 21:18:49 by THK7519
    static boolean THK_CannalRemainSOLineQty(SalesLine    callerSalesLine)
    {
        FormDataSource  FormDataSource;
        InventQty       diffRemainSalesPhysical;
        InventQty       diffRemainInventPhysical;
        SalesLine       salesLineLocal = SalesLine::findRecId(callerSalesLine.RecId);
        InventQty       THK_2nddiffRemainSalesPhysical;
        InventQty       THK_2nddiffRemainInventPhysical;
    ;
        ttsbegin;

        diffRemainSalesPhysical                     = salesLineLocal.RemainSalesPhysical  - 0;
        diffRemainInventPhysical                    = salesLineLocal.RemainInventPhysical - 0;
        callerSalesLine.RemainSalesPhysical         = 0;
        callerSalesLine.RemainInventPhysical        = 0;
        THK_2nddiffRemainSalesPhysical              = salesLineLocal.THK_2ndRemainSalesPhysical  - 0;
        THK_2nddiffRemainInventPhysical             = salesLineLocal.THK_2ndRemainInventPhysical - 0;
        callerSalesLine.THK_2ndRemainSalesPhysical  = 0;
        callerSalesLine.THK_2ndRemainInventPhysical = 0;

        if (callerSalesLine.validateWrite() && callerSalesLine.salesTable().checkUpdate())
        {
            InterCompanyUpdateRemPhys::synchronize(callerSalesLine,
                                                   diffRemainInventPhysical,
                                                   diffRemainSalesPhysical,
                                                   InterCompanySkipUpdate::No,
                                                   THK_2nddiffRemainInventPhysical,
                                                   THK_2nddiffRemainSalesPhysical);
            callerSalesLine.write();
        }
        else
        {
            ttsabort;
            return false;
        }
        ttscommit;
        return true;
    }

    static method removeMarking from TradeInterCompany in class

    static void removeMarking(SalesLine  _salesLine, Object _formRun)
    {
        InventMovement                  movement = InventMovement::construct(_salesLine);
        InventTrans                     inventTrans;
        SalesTable                      salesTable;
        SalesLine                       salesLine;
        PurchTable                      purchTable;
        PurchLine                       purchLine;
        InterCompanyPurchSalesReference interCompanyPurchSalesReference;
        boolean                         inventTransFound;
        ;
        ttsbegin;

        salesTable = _salesLine.salesTable(true);
        purchLine  = PurchLine::findInventTransId(_salesLine.InventRefTransId,true);
        purchTable = PurchTable::find(_salesLine.InventRefId,true);

        while select forupdate inventTrans
              index hint TransIdIdx
              where inventTrans.InventTransId    == movement.transId()
              &&    inventTrans.TransChildType   == movement.transChildType()
              &&    inventTrans.TransChildRefId  == movement.transChildRefId()
              &&    inventTrans.StatusReceipt    == StatusReceipt::None
              &&    inventTrans.StatusIssue      >  StatusIssue::None
              &&    inventTrans.InventRefTransId
        {
            inventTransFound = true;

            if (inventTrans.InventRefTransId)
            {                                                                                                       // VAR Changed on 30 Jun 2009 by thk05 for add 2nd unit
                InventTrans::deleteMarking(inventTrans.InventRefTransId,inventTrans.InventTransId,-inventTrans.Qty,-inventTrans.THK_2ndQty,true,null,null,false,true);
                inventTrans.InventRefTransId    = '';
            }

            if (inventTrans.StatusIssue >= StatusIssue::ReservPhysical)
                inventTrans.StatusIssue = StatusIssue::OnOrder;
            inventTrans.update();

            if (movement.inventRefTransId())
            {
                movement.setInventRefFields(InventRefType::None,'','');
                movement.updateDoBuffer();
            }
        }

        if (purchLine)
        {
            purchLine.ItemRefType        = InventRefType::None;
            purchLine.InventRefId        = '';
            purchLine.InventRefTransId   = '';
            purchLine.InterCompanyOrigin = InterCompanyOrigin::Source;
            purchLine.update();
        }

        if (!inventTransFound)
        {
            salesLine = SalesLine::findInventTransId(_salesLine.InventTransId,true);
            if (salesLine)
            {
                salesLine.InventRefType    = InventRefType::None;
                salesLine.InventRefId      = '';
                salesLine.InventRefTransId = '';
                salesLine.update();
            }
        }

        if (purchTable)
        {
            select firstonly purchLine
                   index hint PurchLineIdx
                   where purchLine.PurchId     == purchTable.PurchId
                   &&    purchLine.ItemRefType == InventRefType::Sales
                   &&    purchLine.InventRefId == salesTable.SalesId;
            if (!purchLine)
            {
                delete_from interCompanyPurchSalesReference
                       index hint SalesPurchIdx
                       where interCompanyPurchSalesReference.SalesId == salesTable.SalesId
                       &&    interCompanyPurchSalesReference.PurchId == purchTable.PurchId;

                purchTable.InterCompanyOriginalSalesId     = '';
                purchTable.InterCompanyOriginalCustAccount = '';
                purchTable.InterCompanyOrigin = InterCompanyOrigin::Source;
                purchTable.update();

                salesTable.InterCompanyAutoCreateOrders = false;
                salesTable.update();
            }
        }

        ttscommit;

        if (_formRun) // VAR Changed on 22 Jul 2010 at 12:26:03 by 4054 - U045
            _formRun.doRefresh();
    }
  • 相关阅读:
    在线漏洞检测网站
    渗透测试工具库
    端口利用解析
    Linux安全脚本
    Linux常见系统故障
    Oracle
    Redis和MongoDB区别
    MHA在监控和故障转移时都做了什么
    Oracle 11g Dataguard参数详解
    Oracle
  • 原文地址:https://www.cnblogs.com/Fandyx/p/2277736.html
Copyright © 2011-2022 走看看