文档章节

How to post receive inventory transfer order

fandyx
 fandyx
发布于 2014/12/31 13:16
字数 364
阅读 102
收藏 0
boolean postInventTransferOrderReceive()
{
    inventTransferParmTable         inventTransferParmTable;
    InventTransferMultiReceive      inventTransferMultiReceive;
    YIP_InventTransferSectionDetails table, lastReceDetails, updateRemainStatus;
    Num                             parmId;
    boolean                         ret = true;
    inventTransferJour              inventTransferJour;
    InventTransferJourLine          inventTransferJourLine;
    inventJournalTable              inventJournalTable;
    str                             errorMsg, voucherId;
    inventTransferLine              inventTransferLine, inventTransferLineUpd;
    qty                             packQty, qtyOver, qtyUnOver, minQty, maxQty, qtyActReceived,qtyLoss;
    percent                         subOverPct;
    int                             lastSectionId = YIP_InventTranferSection::getLastSectionId(this.TransferId);
    int                             fixRate;
    ;

    fixRate = YIP_InventItemCoal::exist(this.ItemId) == true ? 100 : 10;
    select count(recId) from lastReceDetails
            where lastReceDetails.InventTransId == this.InventTransId   &&
                  lastReceDetails.SectionId     == lastSectionId        &&
                  lastReceDetails.VoucherId     == "";
    if (lastReceDetails.RecId == 1)
    {
        inventTransferLine = this.inventTransferLine();
        /*
        select minof(TransferStatus) from table where table.InventTransId   == this.InventTransId;
        if (table.TransferStatus != InventTransferStatus::Received)
            throw checkFailed(strfmt("当前转移批次[%1]所有分段明细状态必须为[%2].",this.InventTransId,InventTransferStatus::Received));
            */
        packQty         = inventTransferLine.YIP_getQtyReceivedSection();
        qtyActReceived  = inventTransferLine.YIP_getQtyReceivedSection();//YIP_QtyActReceived;

        qtyOver     = packQty * inventTransferLine.OverDeliveryPct / fixRate;//超交
        qtyUnOver   = packQty * inventTransferLine.UnderDeliveryPct / fixRate;//欠交
        minQty      = packQty - qtyUnOver;
        maxQty      = packQty + qtyOver;

        subOverPct  = (qtyActReceived - packQty) / (packQty ? packQty : 1) * fixRate;

        if (subOverPct > inventTransferLine.OverDeliveryPct)
            throw checkFailed(strfmt("@SYS24920",subOverPct,inventTransferLine.OverDeliveryPct));

        subOverPct  = (packQty - qtyActReceived) / (packQty ? packQty : 1) * fixRate;

        if (subOverPct > inventTransferLine.UnderDeliveryPct)
            throw checkFailed(strfmt("@SYS24921",subOverPct, inventTransferLine.UnderDeliveryPct));

    }
    qtyActReceived = this.QtyReceive;
    if (!box::yesNo(strfmt("您确认要过账接收吗[实际收货数量(%1)]?", num2str(qtyActReceived, 1, 2, 1, 2)),
        dialogButton::No, "接收过账"))
        return false;
    try
    {
        ttsbegin;
        inventTransferLine = this.inventTransferLine(true);
        if (lastReceDetails.RecId == 1)
        {
            inventTransferLine.QtyReceiveNow    = inventTransferLine.YIP_QtyDelivery - inventTransferLine.YIP_QtyActReceived;
            inventTransferLine.YIP_QtyActReceived= inventTransferLine.YIP_getQtyReceivedSection();
        }
        else
        {
            inventTransferLine.QtyReceiveNow    = this.QtyReceive;
            inventTransferLine.YIP_QtyActReceived += this.QtyReceive;
        }
        inventTransferLine.doUpdate();

        inventTransferMultiReceive  = InventTransferMultiReceive::construct();
        parmId                      = runBaseMultiParm::getSysParmId();
        inventTransferParmTable.clear();
        inventTransferParmTable.initValue();
        inventTransferParmTable.ParmId          = parmId;
        inventTransferParmTable.TransferId      = this.TransferId;
        inventTransferParmTable.UpdateType      = InventTransferUpdateType::Receive;
        inventTransferParmTable.ReceiveUpdateQty= InventTransferReceiveUpdateQty::ReceiveNow;
        inventTransferParmTable.EditLines       = true;
        inventTransferParmTable.ExplodeLines    = true;
        inventTransferParmTable.UpdatedBy       = emplTable::userId2EmplId(curUserId());
        inventTransferParmTable.YIP_RefInventTransId    = inventTransferLine.InventTransIdReceive;
        //inventTransferParmTable.AutoReceiveQty  = NoYes::No;
        inventTransferParmTable.insert();

        //Receive
        inventTransferMultiReceive.runUpdate(inventTransferParmTable);

        if (lastReceDetails.RecId == 1)
        {
            qtyLoss = inventTransferLine.YIP_getQtyReceivedSection() - inventTransferLine.YIP_getQtyShippedSection();
            if (qtyLoss)
            {
                // update loss rate
                inventJournalTable = this.createPLInventJournalTrans(true);
                inventTransferLineUpd = this.inventTransferLine(true);
                if (inventTransferLineUpd)
                {
                    inventTransferLineUpd.YIP_LossRate  = (- qtyLoss / inventTransferLineUpd.YIP_QtyDelivery) * fixRate;
                    inventTransferLineUpd.YIP_LossProfitJournal = inventJournalTable.JournalId;
                    inventTransferLineUpd.doUpdate();
                }
            }
        }
        // update section details status
        table = YIP_InventTransferSectionDetails::findRecId(this.RecId, true);
        if (table)
        {
            select firstonly inventTransferJour
                where inventTransferJour.YIP_ParmId == inventTransferParmTable.ParmId;
            if (inventTransferJour)
            {
                table.TransferStatus    = InventTransferStatus::Received;
                table.VoucherId         = inventTransferJour.VoucherId;
                table.RemainStatus      = InventTransferRemainStatus::None;
                table.LossRate          = (table.QtyDelivery - table.QtyReceive) / table.QtyDelivery * fixRate;
                table.write();
            }
            if (lastReceDetails.RecId == 1)
            {
                update_recordset updateRemainStatus
                    setting RemainStatus = InventTransferRemainStatus::None
                    where updateRemainStatus.InventTransId  == this.InventTransId &&
                          updateRemainStatus.RemainStatus   != InventTransferRemainStatus::None;
            }
        }

        ttscommit;
    }
    catch
    {
        ret = false;
        ttsabort;
        errorMsg = aifUtil::getClrErrorMessage();
        if (errorMsg)
            error(errorMsg);
        error("catch exception.");
    }

    return ret;
}



© 著作权归作者所有

fandyx
粉丝 0
博文 39
码字总数 11111
作品 0
东莞
技术主管
私信 提问
后端开发实践系列——事件驱动架构(EDA)编码实践

在本系列的前两篇文章中,笔者分别讲到了后端项目的代码模板和DDD编码实践,在本文中,我将继续以编码实践的方式分享如何落地事件驱动架构。 单纯地讲事件驱动架构(Event Driven Architectur...

ThoughtWorks
08/21
0
0
A simple IOCP Server/Client Class

//….pContext->m_ContextLock.Lock();If(pContext->m_bSomeData)pContext->m_iSomeData=0;pContext->m_ContextLock.Unlock();//… //… code code .. pContext2-> m_ContextLock.Lock();//......

啊莱
2006/01/24
0
0
springMVC笔记系列(7)——HiddenHttpMethodFilter过滤器

什么是REST?首先来段介绍吧。 REST: 即 Representational State Transfer。 (资源)表现层状态转化。 是目前最流行的一种互联网软件架构。它结构清晰、符合标准、易于理解、 扩展方便,所...

HappyBKs
2015/05/19
2.3K
7
crystalspace3d实体系统

origin:CEL设计 Entity System In this section the basic ideas and details behind CEL are described and explained. What are Entities? Every object in the game is represented by an......

tizzybec
2014/12/17
4
0
Continuous Monitoring With TICK Stack

Monitoring your system is required. It helps you detect any issues before they cause any major downtime that affect your customers and damage your business reputation. It also h......

Mohamed Labouardy
2017/12/22
0
0

没有更多内容

加载失败,请刷新页面

加载更多

nginx学习之模块

1、 stub_status模块: 用于展示nginx处理连接时的状态。 配置语法如下: Syntax:stub_status;Default:默认没有配置Context:server、location 可以编辑default.conf,加上如下配置: ...

码农实战
33分钟前
4
0
MySQL,必须掌握的6个知识点

目录 一、索引B+ Tree 原理 MySQL 索引 索引优化 索引的优点 索引的使用条件 二、查询性能优化使用 Explain 进行分析 优化数据访问 重构查询方式 三、存储引擎InnoDB MyISAM 比较 四、数据类...

李红欧巴
37分钟前
4
0
堆”和“栈

C++作为一款C语言的升级版本,具有非常强大的功能。它不但能够支持各种程序设计风格,而且还具有C语言的所有功能。我们在这里为大家介绍的是其中一个比较重要的内容,C++内存区域的基本介绍。...

SibylY
48分钟前
4
0
总结:Https

一、介绍 简单理解,https即在http协议的基础上,增加了SSL协议,保障数据传输的安全性。 它由以前的http—–>tcp,改为http——>SSL—–>tcp;https采用了共享密钥加密+公开密钥加密的方式 ...

浮躁的码农
51分钟前
6
0
数据库表与表之间的一对一、一对多、多对多关系

表1 foreign key 表2 多对一:表 1 的多条记录对应表 2 的一条记录 利用foreign key的原理我们可以制作两张表的多对多,一对一关系 多对多: 表1的多条记录可以对应表2的一条记录 表2的多条记...

Garphy
今天
7
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部