Esempio n. 1
0
        protected override bool AfterDelete(bool success)
        {
            Tuple <String, String, String> mInfo = null;

            if (Env.HasModulePrefix("DTD001_", out mInfo))
            {
                if (GetM_RequisitionLine_ID() != 0)
                {
                    VAdvantage.Model.MRequisitionLine requisition = new VAdvantage.Model.MRequisitionLine(GetCtx(), GetM_RequisitionLine_ID(), null);
                    requisition.SetDTD001_ReservedQty(requisition.GetDTD001_ReservedQty() - qtyReserved);
                    if (!requisition.Save())
                    {
                        return(false);
                    }
                    storage = VAdvantage.Model.MStorage.Get(GetCtx(), GetM_Locator_ID(), GetM_Product_ID(), GetM_AttributeSetInstance_ID(), null);
                    if (storage == null)
                    {
                        storage = VAdvantage.Model.MStorage.GetCreate(GetCtx(), GetM_Locator_ID(), GetM_Product_ID(), 0, null);
                    }
                    storage.SetQtyReserved(storage.GetQtyReserved() - qtyReserved);
                    if (!storage.Save())
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Esempio n. 2
0
        protected override bool AfterSave(bool newRecord, bool success)
        {
            Tuple <String, String, String> mInfo = null;

            if (Env.HasModulePrefix("DTD001_", out mInfo))
            {
                if (!newRecord && GetM_RequisitionLine_ID() != 0 && GetConfirmedQty() == 0)
                {
                    VAdvantage.Model.MRequisitionLine requisition = new VAdvantage.Model.MRequisitionLine(GetCtx(), GetM_RequisitionLine_ID(), null);
                    requisition.SetDTD001_ReservedQty(requisition.GetDTD001_ReservedQty() + (GetMovementQty() - qtyReserved));
                    if (!requisition.Save())
                    {
                        return(false);
                    }
                    storage = VAdvantage.Model.MStorage.Get(GetCtx(), GetM_Locator_ID(), GetM_Product_ID(), GetM_AttributeSetInstance_ID(), null);
                    if (storage == null)
                    {
                        storage = VAdvantage.Model.MStorage.GetCreate(GetCtx(), GetM_Locator_ID(), GetM_Product_ID(), 0, null);
                    }
                    storage.SetQtyReserved(storage.GetQtyReserved() + (GetMovementQty() - qtyReserved));
                    if (!storage.Save())
                    {
                        return(false);
                    }
                }
                //vikas 11/21/2014
                _mvlNewAttId = GetM_AttributeSetInstance_ID();
                if (_mvlOldAttId != _mvlNewAttId && !newRecord && GetM_RequisitionLine_ID() != 0)
                {
                    //  Set QtyReserved On Storage Correspng to New attributesetinstc_id
                    storage = VAdvantage.Model.MStorage.Get(GetCtx(), GetM_Locator_ID(), GetM_Product_ID(), GetM_AttributeSetInstance_ID(), null);
                    if (storage == null)
                    {
                        storage = VAdvantage.Model.MStorage.GetCreate(GetCtx(), GetM_Locator_ID(), GetM_Product_ID(), 0, null);
                    }
                    storage.SetQtyReserved(storage.GetQtyReserved() + qtyReserved);
                    if (!storage.Save())
                    {
                        return(false);
                    }

                    storage = VAdvantage.Model.MStorage.Get(GetCtx(), GetM_Locator_ID(), GetM_Product_ID(), _mvlOldAttId, null);
                    if (storage == null)
                    {
                        storage = VAdvantage.Model.MStorage.GetCreate(GetCtx(), GetM_Locator_ID(), GetM_Product_ID(), 0, null);
                    }
                    storage.SetQtyReserved(storage.GetQtyReserved() - qtyReserved);
                    if (!storage.Save())
                    {
                        return(false);
                    }
                }//vikas

                if (newRecord && GetM_RequisitionLine_ID() != 0 && GetDescription() != "RC")
                {
                    VAdvantage.Model.MRequisitionLine requisition = new VAdvantage.Model.MRequisitionLine(GetCtx(), GetM_RequisitionLine_ID(), null);
                    requisition.SetDTD001_ReservedQty(requisition.GetDTD001_ReservedQty() + GetMovementQty());
                    if (!requisition.Save())
                    {
                        return(false);
                    }
                    storage = VAdvantage.Model.MStorage.Get(GetCtx(), GetM_Locator_ID(), GetM_Product_ID(), GetM_AttributeSetInstance_ID(), null);
                    if (storage == null)
                    {
                        storage = VAdvantage.Model.MStorage.GetCreate(GetCtx(), GetM_Locator_ID(), GetM_Product_ID(), 0, null);
                    }
                    storage.SetQtyReserved(storage.GetQtyReserved() + GetMovementQty());
                    if (!storage.Save())
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Esempio n. 3
0
        /// <summary>
        /// Complete Document
        /// </summary>
        /// <returns>new status (Complete, In Progress, Invalid, Waiting ..)</returns>
        public String CompleteIt()
        {
            //	Re-Check
            if (!_justPrepared)
            {
                String status = PrepareIt();
                if (!DocActionVariables.STATUS_INPROGRESS.Equals(status))
                {
                    return(status);
                }
            }
            //	Implicit Approval
            if (!IsApproved())
            {
                ApproveIt();
            }
            log.Info("CompleteIt - " + ToString());
            //
            MMovement move = new MMovement(GetCtx(), GetM_Movement_ID(), Get_TrxName());

            MMovementLineConfirm[] lines = GetLines(false);
            for (int i = 0; i < lines.Length; i++)
            {
                MMovementLineConfirm confirm = lines[i];
                confirm.Set_TrxName(Get_TrxName());
                if (!confirm.ProcessLine())
                {
                    _processMsg = "ShipLine not saved - " + confirm;
                    return(DocActionVariables.STATUS_INVALID);
                }
                if (confirm.IsFullyConfirmed())
                {
                    confirm.SetProcessed(true);
                    confirm.Save(Get_TrxName());
                }
                else
                {
                    if (CreateDifferenceDoc(move, confirm))
                    {
                        confirm.SetProcessed(true);
                        confirm.Save(Get_TrxName());
                    }
                    else
                    {
                        log.Log(Level.SEVERE, "completeIt - Scrapped=" + confirm.GetScrappedQty()
                                + " - Difference=" + confirm.GetDifferenceQty());

                        _processMsg = "Differnce Doc not created";
                        return(DocActionVariables.STATUS_INVALID);
                    }
                }
            }   //	for all lines

            if (_inventoryInfo != null)
            {
                _processMsg = " @M_Inventory_ID@: " + _inventoryInfo;
                AddDescription(Msg.Translate(GetCtx(), "M_Inventory_ID")
                               + ": " + _inventoryInfo);
            }
            //Amit 21-nov-2014 (Reduce reserved quantity from requisition and warehouse distribution center)
            Tuple <String, String, String> mInfo = null;

            if (Env.HasModulePrefix("DTD001_", out mInfo))
            {
                MMovementLine movementLine = null;
                VAdvantage.Model.MRequisitionLine requisitionLine = null;
                VAdvantage.Model.MStorage         storage         = null;
                for (int i = 0; i < lines.Length; i++)
                {
                    MMovementLineConfirm confirm = lines[i];
                    if (confirm.GetDifferenceQty() > 0)
                    {
                        movementLine = new MMovementLine(GetCtx(), confirm.GetM_MovementLine_ID(), Get_Trx());
                        if (movementLine.GetM_RequisitionLine_ID() > 0)
                        {
                            requisitionLine = new VAdvantage.Model.MRequisitionLine(GetCtx(), movementLine.GetM_RequisitionLine_ID(), Get_Trx());
                            requisitionLine.SetDTD001_ReservedQty(decimal.Subtract(requisitionLine.GetDTD001_ReservedQty(), confirm.GetDifferenceQty()));
                            if (!requisitionLine.Save(Get_Trx()))
                            {
                                _processMsg = Msg.GetMsg(GetCtx(), "DTD001_ReqNotUpdate");
                                // _processMsg = "Requisitionline not updated";
                                return(DocActionVariables.STATUS_INVALID);
                            }
                            storage = VAdvantage.Model.MStorage.Get(GetCtx(), movementLine.GetM_Locator_ID(), movementLine.GetM_Product_ID(), movementLine.GetM_AttributeSetInstance_ID(), Get_Trx());
                            if (storage == null)
                            {
                                storage = VAdvantage.Model.MStorage.Get(GetCtx(), movementLine.GetM_Locator_ID(), movementLine.GetM_Product_ID(), 0, Get_Trx());
                            }
                            storage.SetQtyReserved(decimal.Subtract(storage.GetQtyReserved(), confirm.GetDifferenceQty()));
                            if (!storage.Save(Get_Trx()))
                            {
                                _processMsg = Msg.GetMsg(GetCtx(), "DTD001_StorageNotUpdate");
                                //_processMsg = "Storage From not updated (MA)";
                                return(DocActionVariables.STATUS_INVALID);
                            }
                        }
                    }
                }
            }
            //Amit
            SetProcessed(true);
            SetDocAction(DOCACTION_Close);
            return(DocActionVariables.STATUS_COMPLETED);
        }