示例#1
0
        public void SetInoutLine(VAdvantage.Model.MInOutLine line)
        {
            int _CountDTD001 = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='DTD001_'"));

            if (_CountDTD001 > 0)
            {
                SetM_InOutLine_ID(line.GetM_InOut_ID());
                SetDTD001_TotalQty(line.GetMovementQty());
                SetM_Product_ID(line.GetM_Product_ID());
                SetM_AttributeSetInstance_ID(line.GetM_AttributeSetInstance_ID());
                decimal totalPackQty = Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT SUM(Qty) FROM M_PackageLine WHERE M_InOutLine_ID=" + GetM_InOutLine_ID()));
                SetQty(line.GetMovementQty() - totalPackQty);
                SetDTD001_AlreadyPackQty(totalPackQty);
                SetConfirmedQty(line.GetMovementQty() - totalPackQty);
                SetDTD001_ConfirmDate(System.DateTime.Now);
            }
        }
        public static bool InsertForeignCostAveragePO(Ctx ctx, MOrder order, MOrderLine orderLine, MInOutLine inoutLine, Trx trx)
        {
            int                  acctSchema_ID    = 0;
            int                  M_CostElement_ID = 0;
            int                  AD_Org_ID        = 0;
            int                  M_ASI_ID         = 0;
            MProduct             product          = null;
            MAcctSchema          acctSchema       = null;
            MCostForeignCurrency foreignCost      = null;
            dynamic              pc = null;
            String               cl = null;

            try
            {
                // if cost is calculated then not to calculate again
                if (inoutLine.IsFutureCostCalculated())
                {
                    return(true);
                }

                acctSchema_ID = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT asch.c_acctschema_id FROM c_acctschema asch INNER JOIN ad_clientinfo ci
                                    ON ci.c_acctschema1_id = asch.c_acctschema_id WHERE ci.ad_client_id  = " + order.GetAD_Client_ID()));
                acctSchema    = new MAcctSchema(ctx, acctSchema_ID, trx);

                if (acctSchema.GetC_Currency_ID() != order.GetC_Currency_ID())
                {
                    // Get Costing Element of Average PO
                    M_CostElement_ID = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT M_CostElement_ID FROM M_CostElement WHERE AD_Client_ID = "
                                                                           + order.GetAD_Client_ID() + " AND IsActive = 'Y' AND CostingMethod = 'A'"));

                    product = new MProduct(ctx, orderLine.GetM_Product_ID(), trx);

                    if (product != null && product.GetProductType() == "I" && product.GetM_Product_ID() > 0) // for Item Type product
                    {
                        pc = MProductCategory.Get(product.GetCtx(), product.GetM_Product_Category_ID());

                        // Get Costing Level
                        if (pc != null)
                        {
                            cl = pc.GetCostingLevel();
                        }
                        if (cl == null)
                        {
                            cl = acctSchema.GetCostingLevel();
                        }

                        if (cl == "C" || cl == "B")
                        {
                            AD_Org_ID = 0;
                        }
                        else
                        {
                            AD_Org_ID = order.GetAD_Org_ID();
                        }
                        if (cl != "B")
                        {
                            M_ASI_ID = 0;
                        }
                        else
                        {
                            M_ASI_ID = orderLine.GetM_AttributeSetInstance_ID();
                        }

                        foreignCost = MCostForeignCurrency.Get(product, M_ASI_ID, AD_Org_ID, M_CostElement_ID, order.GetC_BPartner_ID(), order.GetC_Currency_ID());
                        foreignCost.SetC_Order_ID(order.GetC_Order_ID());
                        foreignCost.SetCumulatedQty(Decimal.Add(foreignCost.GetCumulatedQty(), inoutLine.GetMovementQty()));
                        foreignCost.SetCumulatedAmt(Decimal.Add(foreignCost.GetCumulatedAmt(),
                                                                Decimal.Multiply(Decimal.Divide(orderLine.GetLineNetAmt(), orderLine.GetQtyOrdered()), inoutLine.GetMovementQty())));
                        if (foreignCost.GetCumulatedQty() != 0)
                        {
                            foreignCost.SetCostPerUnit(Decimal.Round(Decimal.Divide(foreignCost.GetCumulatedAmt(), foreignCost.GetCumulatedQty()), acctSchema.GetCostingPrecision()));
                        }
                        else
                        {
                            foreignCost.SetCostPerUnit(0);
                        }
                        if (!foreignCost.Save(trx))
                        {
                            ValueNamePair pp = VLogger.RetrieveError();
                            _log.Severe("Error occured during updating M_Cost_ForeignCurrency. Error name : " + pp.GetName() +
                                        " AND Error Value : " + pp.GetValue() + " , For Invoice line : " + orderLine.GetC_OrderLine_ID() +
                                        " , AND Ad_Client_ID : " + orderLine.GetAD_Client_ID());
                            return(false);
                        }
                        else
                        {
                            inoutLine.SetIsFutureCostCalculated(true);
                            if (!inoutLine.Save(trx))
                            {
                                ValueNamePair pp = VLogger.RetrieveError();
                                _log.Severe("Error occured during updating Is Foreign Cost On C_invoice. Error name : " + pp.GetName() +
                                            " AND Error Value : " + pp.GetValue() + " , For Material Receipt : " + inoutLine.GetM_InOutLine_ID() +
                                            " , AND Ad_Client_ID : " + inoutLine.GetAD_Client_ID());
                                return(false);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Log(Level.SEVERE, "", ex);
                return(false);
            }
            return(true);
        }
示例#3
0
 /// <summary>
 /// Set Shipment Line
 /// </summary>
 /// <param name="line">line</param>
 public void SetInOutLine(MInOutLine line)
 {
     SetM_InOutLine_ID(line.GetM_InOutLine_ID());
     SetQty(line.GetMovementQty());
 }
示例#4
0
        /**
         *  Shipment Constructor
         *  @param shipment shipment
         *	@param shipLine shipment line
         *	@param deliveryCount 0 or number of delivery
         */
        public MAsset(MInOut shipment, MInOutLine shipLine, int deliveryCount)
            : this(shipment.GetCtx(), 0, shipment.Get_TrxName())
        {
            SetClientOrg(shipment);

            SetValueNameDescription(shipment, shipLine, deliveryCount);
            //	Header

            // SetIsOwned(true);
            SetC_BPartner_ID(shipment.GetC_BPartner_ID());
            SetC_BPartner_Location_ID(shipment.GetC_BPartner_Location_ID());
            SetAD_User_ID(shipment.GetAD_User_ID());
            SetM_Locator_ID(shipLine.GetM_Locator_ID());
            SetIsInPosession(true);
            SetAssetServiceDate(shipment.GetDateAcct());

            //	Line
            MProduct product = shipLine.GetProduct();

            SetM_Product_ID(product.GetM_Product_ID());
            SetA_Asset_Group_ID(product.GetA_Asset_Group_ID());

            //////////////////////////////*
            //Changes for vafam
            // SetAssetServiceDate(shipment.GetMovementDate());
            //SetGuaranteeDate(TimeUtil.AddDays(shipment.GetMovementDate(), product.GetGuaranteeDays()));
            MAssetGroup _assetGroup = new MAssetGroup(GetCtx(), GetA_Asset_Group_ID(), shipment.Get_TrxName());

            if (_assetGroup.IsOwned())
            {
                SetIsOwned(true);
                //SetC_BPartner_ID(0);
            }
            if (_assetGroup.IsDepreciated())
            {
                SetIsDepreciated(true);
                SetIsFullyDepreciated(false);
            }

            //Change by Sukhwinder for setting Asset type and amortization template on Asset window, MANTIS ID:1762
            int countVA038 = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='VA038_' "));
            int countVAFAM = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='VAFAM_' "));

            if (countVA038 > 0)
            {
                Set_Value("VA038_AmortizationTemplate_ID", Utility.Util.GetValueOfInt(_assetGroup.Get_Value("VA038_AmortizationTemplate_ID")));
            }
            if (countVAFAM > 0)
            {
                Set_Value("VAFAM_AssetType", _assetGroup.Get_Value("VAFAM_AssetType").ToString());
                Set_Value("VAFAM_DepreciationType_ID", Utility.Util.GetValueOfInt(_assetGroup.Get_Value("VAFAM_DepreciationType_ID")));
            }
            ////////////////////////////////////


            //	Guarantee & Version
            SetGuaranteeDate(TimeUtil.AddDays(shipment.GetMovementDate(), product.GetGuaranteeDays()));
            SetVersionNo(product.GetVersionNo());
            if (shipLine.GetM_AttributeSetInstance_ID() != 0)           //	Instance
            {
                MAttributeSetInstance asi = new MAttributeSetInstance(GetCtx(), shipLine.GetM_AttributeSetInstance_ID(), Get_TrxName());
                SetM_AttributeSetInstance_ID(asi.GetM_AttributeSetInstance_ID());
                SetLot(asi.GetLot());
                SetSerNo(asi.GetSerNo());
            }
            SetHelp(shipLine.GetDescription());
            //	Qty
            int units = product.GetSupportUnits();

            if (units == 0)
            {
                units = 1;
            }
            if (deliveryCount != 0)             //	one asset per UOM
            {
                SetQty(shipLine.GetMovementQty(), units);
            }
            else
            {
                SetQty((Decimal)units);
            }
            SetM_InOutLine_ID(shipLine.GetM_InOutLine_ID());

            //	Activate
            MAssetGroup ag = MAssetGroup.Get(GetCtx(), GetA_Asset_Group_ID());

            if (!ag.IsCreateAsActive())
            {
                SetIsActive(false);
            }
        }
示例#5
0
        /**
         *  Shipment Constructor
         *  @param shipment shipment
         *	@param shipLine shipment line
         *	@param deliveryCount 0 or number of delivery
         */
        public MAsset(MInOut shipment, MInOutLine shipLine, int deliveryCount)
            : this(shipment.GetCtx(), 0, shipment.Get_TrxName())
        {
            SetClientOrg(shipment);

            SetValueNameDescription(shipment, shipLine, deliveryCount);
            //	Header

            // SetIsOwned(true);
            SetC_BPartner_ID(shipment.GetC_BPartner_ID());
            SetC_BPartner_Location_ID(shipment.GetC_BPartner_Location_ID());
            SetAD_User_ID(shipment.GetAD_User_ID());
            SetM_Locator_ID(shipLine.GetM_Locator_ID());
            SetIsInPosession(true);
            SetAssetServiceDate(shipment.GetDateAcct());

            //	Line
            MProduct product = shipLine.GetProduct();

            SetM_Product_ID(product.GetM_Product_ID());
            SetA_Asset_Group_ID(product.GetA_Asset_Group_ID());

            //////////////////////////////*
            //Changes for vafam
            // SetAssetServiceDate(shipment.GetMovementDate());
            //SetGuaranteeDate(TimeUtil.AddDays(shipment.GetMovementDate(), product.GetGuaranteeDays()));
            MAssetGroup _assetGroup = new MAssetGroup(GetCtx(), GetA_Asset_Group_ID(), shipment.Get_TrxName());

            if (_assetGroup.IsOwned())
            {
                SetIsOwned(true);
                //SetC_BPartner_ID(0);
            }
            if (_assetGroup.IsDepreciated())
            {
                SetIsDepreciated(true);
                SetIsFullyDepreciated(false);
            }

            //Change by Sukhwinder for setting Asset type and amortization template on Asset window, MANTIS ID:1762
            int countVA038 = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='VA038_' "));
            int countVAFAM = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='VAFAM_' "));

            if (countVA038 > 0)
            {
                Set_Value("VA038_AmortizationTemplate_ID", Utility.Util.GetValueOfInt(_assetGroup.Get_Value("VA038_AmortizationTemplate_ID")));
            }
            if (countVAFAM > 0)
            {
                Set_Value("VAFAM_AssetType", _assetGroup.Get_Value("VAFAM_AssetType").ToString());
                Set_Value("VAFAM_DepreciationType_ID", Utility.Util.GetValueOfInt(_assetGroup.Get_Value("VAFAM_DepreciationType_ID")));
            }
            ////////////////////////////////////


            //	Guarantee & Version
            SetGuaranteeDate(TimeUtil.AddDays(shipment.GetMovementDate(), product.GetGuaranteeDays()));
            SetVersionNo(product.GetVersionNo());
            if (shipLine.GetM_AttributeSetInstance_ID() != 0)           //	Instance
            {
                MAttributeSetInstance asi = new MAttributeSetInstance(GetCtx(), shipLine.GetM_AttributeSetInstance_ID(), Get_TrxName());
                SetM_AttributeSetInstance_ID(asi.GetM_AttributeSetInstance_ID());
                SetLot(asi.GetLot());
                SetSerNo(asi.GetSerNo());
            }
            SetHelp(shipLine.GetDescription());
            //	Qty
            int units = product.GetSupportUnits();

            if (units == 0)
            {
                units = 1;
            }
            if (deliveryCount != 0)             //	one asset per UOM
            {
                SetQty(shipLine.GetMovementQty(), units);
            }
            else
            {
                SetQty((Decimal)units);
            }
            SetM_InOutLine_ID(shipLine.GetM_InOutLine_ID());

            //	Activate
            MAssetGroup ag = MAssetGroup.Get(GetCtx(), GetA_Asset_Group_ID());

            if (!ag.IsCreateAsActive())
            {
                SetIsActive(false);
            }

            //Check if the Software Industry module installed, update following fields on Asset window
            if (Env.IsModuleInstalled("VA077_"))
            {
                //Set default values
                SetIsInPosession(false);
                SetIsOwned(false);
                SetIsActive(true);
                SetIsDisposed(false);

                Set_Value("VA077_SerialNo", shipLine.Get_Value("VA077_SerialNo"));
                Set_Value("VA077_CNAutodesk", shipLine.Get_Value("VA077_CNAutodesk"));
                Set_Value("VA077_RegEmail", shipLine.Get_Value("VA077_RegEmail"));
                Set_Value("VA077_IsCustAsset", "Y");
                Set_Value("VA077_OldSN", shipLine.Get_Value("VA077_OldSN"));
                Set_Value("VA077_UserRef_ID", shipLine.Get_Value("VA077_UserRef_ID"));
                Set_Value("VA077_ProductInfo", shipLine.Get_Value("VA077_ProductInfo"));
                Set_Value("VA077_ServiceContract_ID", shipLine.Get_Value("VA077_ServiceContract_ID"));
                Set_Value("AD_OrgTrx_ID", shipLine.Get_Value("AD_OrgTrx_ID"));

                if (Util.GetValueOfBool(product.Get_Value("VA077_LicenceTracked")))
                {
                    Set_Value("VA077_LicenceTracked", "Y");
                }
                else
                {
                    Set_Value("VA077_LicenceTracked", "N");
                }
            }
        }
示例#6
0
        /**
         *  Shipment Constructor
         *  @param shipment shipment
         *	@param shipLine shipment line
         *	@param deliveryCount 0 or number of delivery
         */
        public MAsset(MInOut shipment, MInOutLine shipLine, int deliveryCount)
            : this(shipment.GetCtx(), 0, shipment.Get_TrxName())
        {
            SetClientOrg(shipment);

            SetValueNameDescription(shipment, shipLine, deliveryCount);
            //	Header

            SetIsOwned(true);
            SetC_BPartner_ID(shipment.GetC_BPartner_ID());
            SetC_BPartner_Location_ID(shipment.GetC_BPartner_Location_ID());
            SetAD_User_ID(shipment.GetAD_User_ID());
            SetM_Locator_ID(shipLine.GetM_Locator_ID());
            SetIsInPosession(true);

            //	Line
            MProduct product = shipLine.GetProduct();

            SetM_Product_ID(product.GetM_Product_ID());
            SetA_Asset_Group_ID(product.GetA_Asset_Group_ID());

            //////////////////////////////*
            //Changes for vafam
            // SetAssetServiceDate(shipment.GetMovementDate());
            //SetGuaranteeDate(TimeUtil.AddDays(shipment.GetMovementDate(), product.GetGuaranteeDays()));
            MAssetGroup _assetGroup = new MAssetGroup(GetCtx(), GetA_Asset_Group_ID(), shipment.Get_TrxName());

            if (_assetGroup.IsOwned())
            {
                SetIsOwned(true);
                //SetC_BPartner_ID(0);
            }
            if (_assetGroup.IsDepreciated())
            {
                SetIsDepreciated(true);
                SetIsFullyDepreciated(false);
            }
            ////////////////////////////////////


            //	Guarantee & Version
            SetGuaranteeDate(TimeUtil.AddDays(shipment.GetMovementDate(), product.GetGuaranteeDays()));
            SetVersionNo(product.GetVersionNo());
            if (shipLine.GetM_AttributeSetInstance_ID() != 0)           //	Instance
            {
                MAttributeSetInstance asi = new MAttributeSetInstance(GetCtx(), shipLine.GetM_AttributeSetInstance_ID(), Get_TrxName());
                SetM_AttributeSetInstance_ID(asi.GetM_AttributeSetInstance_ID());
                SetLot(asi.GetLot());
                SetSerNo(asi.GetSerNo());
            }
            SetHelp(shipLine.GetDescription());
            //	Qty
            int units = product.GetSupportUnits();

            if (units == 0)
            {
                units = 1;
            }
            if (deliveryCount != 0)             //	one asset per UOM
            {
                SetQty(shipLine.GetMovementQty(), units);
            }
            else
            {
                SetQty((Decimal)units);
            }
            SetM_InOutLine_ID(shipLine.GetM_InOutLine_ID());

            //	Activate
            MAssetGroup ag = MAssetGroup.Get(GetCtx(), GetA_Asset_Group_ID());

            if (!ag.IsCreateAsActive())
            {
                SetIsActive(false);
            }
        }
示例#7
0
        /**
         *  Set Qty
         *	@param windowNo window
         *	@param columnName column
         */
        private void SetQty(int windowNo, String columnName)
        {
            int M_Product_ID = GetM_Product_ID();

            log.Log(Level.WARNING, "qty - init - M_Product_ID=" + M_Product_ID);
            Decimal MovementQty, QtyEntered;
            int     C_UOM_To_ID = GetC_UOM_ID();

            //	No Product
            if (M_Product_ID == 0)
            {
                QtyEntered = GetQtyEntered();
                SetMovementQty(QtyEntered);
            }
            //	UOM Changed - convert from Entered -> Product
            else if (columnName.Equals("C_UOM_ID"))
            {
                QtyEntered = GetQtyEntered();
                //Decimal QtyEntered1 = QtyEntered.setScale(MUOM.GetPrecision(GetCtx(), C_UOM_To_ID), Decimal.ROUND_HALF_UP);
                Decimal QtyEntered1 = Decimal.Round(QtyEntered, MUOM.GetPrecision(GetCtx(), C_UOM_To_ID), MidpointRounding.AwayFromZero);
                if (QtyEntered.CompareTo(QtyEntered1) != 0)
                {
                    log.Fine("Corrected QtyEntered Scale UOM=" + C_UOM_To_ID
                             + "; QtyEntered=" + QtyEntered + "->" + QtyEntered1);
                    QtyEntered = QtyEntered1;
                    SetQtyEntered(QtyEntered);
                }
                MovementQty = (Decimal)MUOMConversion.ConvertProductFrom(GetCtx(), M_Product_ID, C_UOM_To_ID, QtyEntered);
                if (MovementQty == null)
                {
                    MovementQty = QtyEntered;
                }
                bool conversion = QtyEntered.CompareTo(MovementQty) != 0;

                log.Fine("UOM=" + C_UOM_To_ID
                         + ", QtyEntered=" + QtyEntered
                         + " -> " + conversion
                         + " MovementQty=" + MovementQty);

                //p_changeVO.setContext(getCtx(), windowNo, "UOMConversion", conversion);
                SetMovementQty(MovementQty);
            }
            //	No UOM defined
            else if (C_UOM_To_ID == 0)
            {
                QtyEntered = GetQtyEntered();
                SetMovementQty(QtyEntered);
            }
            //	QtyEntered changed - calculate MovementQty
            else if (columnName.Equals("QtyEntered"))
            {
                QtyEntered = GetQtyEntered();
                Decimal QtyEntered1 = Decimal.Round(QtyEntered, MUOM.GetPrecision(GetCtx(), C_UOM_To_ID), MidpointRounding.AwayFromZero);
                if (QtyEntered.CompareTo(QtyEntered1) != 0)
                {
                    log.Fine("Corrected QtyEntered Scale UOM=" + C_UOM_To_ID
                             + "; QtyEntered=" + QtyEntered + "->" + QtyEntered1);
                    QtyEntered = QtyEntered1;
                    SetQtyEntered(QtyEntered);
                }
                MovementQty = (Decimal)MUOMConversion.ConvertProductFrom(GetCtx(),
                                                                         M_Product_ID, C_UOM_To_ID, QtyEntered);
                if (MovementQty == null)
                {
                    MovementQty = QtyEntered;
                }
                bool conversion = QtyEntered.CompareTo(MovementQty) != 0;

                log.Fine("UOM=" + C_UOM_To_ID
                         + ", QtyEntered=" + QtyEntered
                         + " -> " + conversion
                         + " MovementQty=" + MovementQty);

                //p_changeVO.setContext(getCtx(), windowNo, "UOMConversion", conversion);
                SetMovementQty(MovementQty);
            }
            //	MovementQty changed - calculate QtyEntered (should not happen)
            else if (columnName.Equals("MovementQty"))
            {
                MovementQty = GetMovementQty();
                int precision = MProduct.Get(GetCtx(), M_Product_ID).GetUOMPrecision();
                //Decimal MovementQty1 = MovementQty.setScale(precision, Decimal.ROUND_HALF_UP);
                Decimal MovementQty1 = Decimal.Round(MovementQty, precision, MidpointRounding.AwayFromZero);// Env.Scale(MovementQty);
                if (MovementQty.CompareTo(MovementQty1) != 0)
                {
                    log.Fine("Corrected MovementQty "
                             + MovementQty + "->" + MovementQty1);
                    MovementQty = MovementQty1;
                    SetMovementQty(MovementQty);
                }
                QtyEntered = (Decimal)MUOMConversion.ConvertProductTo(GetCtx(), M_Product_ID, C_UOM_To_ID, MovementQty);
                if (QtyEntered == null)
                {
                    QtyEntered = MovementQty;
                }
                bool conversion = MovementQty.CompareTo(QtyEntered) != 0;
                log.Fine("UOM=" + C_UOM_To_ID
                         + ", MovementQty=" + MovementQty
                         + " -> " + conversion
                         + " QtyEntered=" + QtyEntered);

                //p_changeVO.setContext(getCtx(), windowNo, "UOMConversion", conversion);
                SetQtyEntered(QtyEntered);
            }

            // RMA : Check qty returned is more than qty shipped
            bool IsReturnTrx = GetParent().IsReturnTrx();

            if (M_Product_ID != 0 && IsReturnTrx)
            {
                int        oLine_ID = GetC_OrderLine_ID();
                MOrderLine oLine    = new MOrderLine(GetCtx(), oLine_ID, null);
                if (oLine.Get_ID() != 0)
                {
                    int orig_IOLine_ID = oLine.GetOrig_InOutLine_ID();
                    if (orig_IOLine_ID != 0)
                    {
                        MInOutLine orig_IOLine = new MInOutLine(GetCtx(), orig_IOLine_ID, null);
                        Decimal    shippedQty  = orig_IOLine.GetMovementQty();
                        MovementQty = GetMovementQty();
                        if (shippedQty.CompareTo(MovementQty) < 0)
                        {
                            if (GetCtx().IsSOTrx(windowNo))
                            {
                                //   p_changeVO.addError(Msg.getMsg(getCtx(), "QtyShippedLessThanQtyReturned", shippedQty));
                            }
                            else
                            {
                                // p_changeVO.addError(Msg.getMsg(getCtx(), "QtyReceivedLessThanQtyReturned", shippedQty));
                            }

                            SetMovementQty(shippedQty);
                            MovementQty = shippedQty;
                            QtyEntered  = (Decimal)MUOMConversion.ConvertProductTo(GetCtx(), M_Product_ID,
                                                                                   C_UOM_To_ID, MovementQty);
                            if (QtyEntered == null)
                            {
                                QtyEntered = MovementQty;
                            }
                            SetQtyEntered(QtyEntered);
                            log.Fine("QtyEntered : " + QtyEntered.ToString() +
                                     "MovementQty : " + MovementQty.ToString());
                        }
                    }
                }
            }
        }
示例#8
0
        /**
         *  Split Shipment into confirmed and dispute
         *	@param original original shipment
         *	@param C_DocType_ID target DocType
         *	@param confirmLines confirm lines
         */
        private void SplitInOut(MInOut original, int C_DocType_ID, MInOutLineConfirm[] confirmLines)
        {
            MInOut split = new MInOut(original, C_DocType_ID, original.GetMovementDate());

            split.AddDescription("Splitted from " + original.GetDocumentNo());
            split.SetIsInDispute(true);

            //nnayak : Change for bug 1431337
            split.SetRef_InOut_ID(original.Get_ID());

            if (!split.Save(Get_TrxName()))
            {
                throw new Exception("Cannot save Split");
            }
            original.AddDescription("Split: " + split.GetDocumentNo());
            if (!original.Save(Get_TrxName()))
            {
                throw new Exception("Cannot update original Shipment");
            }

            //	Go through confirmations
            for (int i = 0; i < confirmLines.Length; i++)
            {
                MInOutLineConfirm confirmLine   = confirmLines[i];
                Decimal           differenceQty = confirmLine.GetDifferenceQty();
                if (differenceQty.CompareTo(Env.ZERO) == 0)
                {
                    continue;
                }
                //
                MInOutLine oldLine = confirmLine.GetLine();
                log.Fine("Qty=" + differenceQty + ", Old=" + oldLine);
                //
                MInOutLine splitLine = new MInOutLine(split);
                splitLine.SetC_OrderLine_ID(oldLine.GetC_OrderLine_ID());
                splitLine.SetC_UOM_ID(oldLine.GetC_UOM_ID());
                splitLine.SetDescription(oldLine.GetDescription());
                splitLine.SetIsDescription(oldLine.IsDescription());
                splitLine.SetLine(oldLine.GetLine());
                splitLine.SetM_AttributeSetInstance_ID(oldLine.GetM_AttributeSetInstance_ID());
                splitLine.SetM_Locator_ID(oldLine.GetM_Locator_ID());
                splitLine.SetM_Product_ID(oldLine.GetM_Product_ID());
                splitLine.SetM_Warehouse_ID(oldLine.GetM_Warehouse_ID());
                splitLine.SetRef_InOutLine_ID(oldLine.GetRef_InOutLine_ID());
                splitLine.AddDescription("Split: from " + oldLine.GetMovementQty());
                //	Qtys
                splitLine.SetQty(differenceQty);                //	Entered/Movement
                if (!splitLine.Save(Get_TrxName()))
                {
                    throw new Exception("Cannot save Split Line");
                }
                //	Old
                oldLine.AddDescription("Splitted: from " + oldLine.GetMovementQty());
                oldLine.SetQty(Decimal.Subtract(oldLine.GetMovementQty(), differenceQty));
                if (!oldLine.Save(Get_TrxName()))
                {
                    throw new Exception("Cannot save Splited Line");
                }
                //	Update Confirmation Line
                confirmLine.SetTargetQty(Decimal.Subtract(confirmLine.GetTargetQty(), differenceQty));
                confirmLine.SetDifferenceQty(Env.ZERO);
                if (!confirmLine.Save(Get_TrxName()))
                {
                    throw new Exception("Cannot save Split Confirmation");
                }
            }   //	for all confirmations

            _processMsg = "Split @M_InOut_ID@=" + split.GetDocumentNo()
                          + " - @M_InOutConfirm_ID@=";

            //	Create Dispute Confirmation
            split.ProcessIt(DocActionVariables.ACTION_PREPARE);
            //	split.createConfirmation();
            split.Save(Get_TrxName());
            MInOutConfirm[] splitConfirms = split.GetConfirmations(true);
            if (splitConfirms.Length > 0)
            {
                int index = 0;
                if (splitConfirms[index].IsProcessed())
                {
                    if (splitConfirms.Length > 1)
                    {
                        index++;        //	try just next
                    }
                    if (splitConfirms[index].IsProcessed())
                    {
                        _processMsg += splitConfirms[index].GetDocumentNo() + " processed??";
                        return;
                    }
                }
                splitConfirms[index].SetIsInDispute(true);
                splitConfirms[index].Save(Get_TrxName());
                _processMsg += splitConfirms[index].GetDocumentNo();
                //	Set Lines to unconfirmed
                MInOutLineConfirm[] splitConfirmLines = splitConfirms[index].GetLines(false);
                for (int i = 0; i < splitConfirmLines.Length; i++)
                {
                    MInOutLineConfirm splitConfirmLine = splitConfirmLines[i];
                    splitConfirmLine.SetScrappedQty(Env.ZERO);
                    splitConfirmLine.SetConfirmedQty(Env.ZERO);
                    splitConfirmLine.Save(Get_TrxName());
                }
            }
            else
            {
                _processMsg += "??";
            }
        }