/// <summary>
 /// Set Shipment Line
 /// </summary>
 /// <param name="line">shipment line</param>
 public void SetInOutLine(MInOutLine line)
 {
     SetM_InOutLine_ID(line.GetM_InOutLine_ID());
     SetTargetQty(line.GetMovementQty());        //	Confirmations in Storage UOM
     SetConfirmedQty(GetTargetQty());            //	suggestion
     _line = line;
 }
示例#2
0
        /**
         *  Set Value Name Description
         *	@param shipment shipment
         *	@param line line
         *	@param deliveryCount
         */
        public void SetValueNameDescription(MInOut shipment, MInOutLine line, int deliveryCount)
        {
            MProduct  product = line.GetProduct();
            MBPartner partner = shipment.GetBPartner();

            SetValueNameDescription(shipment, deliveryCount, product, partner);
        }
示例#3
0
 /**
  *  After Delete
  *	@param success success
  *	@return success
  */
 protected override bool AfterDelete(bool success)
 {
     if (success)
     {
         //	Get Order and decrease invoices
         MInvoiceLine iLine          = new MInvoiceLine(GetCtx(), GetC_InvoiceLine_ID(), Get_TrxName());
         int          C_OrderLine_ID = iLine.GetC_OrderLine_ID();
         if (C_OrderLine_ID == 0)
         {
             MInOutLine ioLine = new MInOutLine(GetCtx(), GetM_InOutLine_ID(), Get_TrxName());
             C_OrderLine_ID = ioLine.GetC_OrderLine_ID();
         }
         //	No Order Found
         if (C_OrderLine_ID == 0)
         {
             return(success);
         }
         //	Find MatchPO
         MMatchPO[] mPO = MMatchPO.Get(GetCtx(), C_OrderLine_ID, GetC_InvoiceLine_ID(), Get_TrxName());
         for (int i = 0; i < mPO.Length; i++)
         {
             if (mPO[i].GetM_InOutLine_ID() == 0)
             {
                 mPO[i].Delete(true);
             }
             else
             {
                 mPO[i].SetC_InvoiceLine_ID(null);
                 mPO[i].Save();
             }
         }
     }
     return(success);
 }
示例#4
0
        /*	Set Order Line - Callout
         *	@param oldC_OrderLine_ID old BP
         *	@param newC_OrderLine_ID new BP
         *	@param windowNo window no
         */
        //@UICallout
        public void SetC_OrderLine_ID(String oldC_OrderLine_ID, String newC_OrderLine_ID, int windowNo)
        {
            if (newC_OrderLine_ID == null || newC_OrderLine_ID.Length == 0)
            {
                return;
            }
            int C_OrderLine_ID = int.Parse(newC_OrderLine_ID);

            if (C_OrderLine_ID == 0)
            {
                return;
            }
            MOrderLine ol = new MOrderLine(GetCtx(), C_OrderLine_ID, null);

            if (ol.Get_ID() != 0)
            {
                SetC_OrderLine_ID(C_OrderLine_ID);
                Decimal MovementQty = Decimal.Subtract(ol.GetQtyOrdered(), ol.GetQtyDelivered());
                SetMovementQty(MovementQty);
                SetOrderLine(ol, 0, MovementQty);
                Decimal QtyEntered = MovementQty;
                if (ol.GetQtyEntered().CompareTo(ol.GetQtyOrdered()) != 0)
                {
                    //QtyEntered = QtyEntered.multiply(ol.getQtyEntered()).divide(ol.getQtyOrdered(), 12, Decimal.ROUND_HALF_UP);
                    QtyEntered = Decimal.Divide((Decimal.Multiply(QtyEntered, ol.GetQtyEntered())), ol.GetQtyOrdered());
                }
                SetQtyEntered(QtyEntered);

                if (ol.GetParent().IsReturnTrx())
                {
                    MInOutLine ioLine = new MInOutLine(GetCtx(), ol.GetOrig_InOutLine_ID(), null);
                    SetM_Locator_ID(ioLine.GetM_Locator_ID());
                }
            }
        }
示例#5
0
        /**
         *  Get Ship lines Of Order Line
         *	@param ctx context
         *	@param C_OrderLine_ID line
         *  @param trxName transaction
         *	@return array of receipt lines2
         */
        public static MInOutLine[] Get(Ctx ctx, int C_OrderLine_ID, Trx trxName)
        {
            List <MInOutLine> list = new List <MInOutLine>();
            String            sql  = "SELECT * FROM M_InOutLine WHERE C_OrderLine_ID=" + C_OrderLine_ID;
            DataTable         dt   = null;
            IDataReader       idr  = null;

            try
            {
                idr = DataBase.DB.ExecuteReader(sql, null, trxName);
                dt  = new DataTable();
                dt.Load(idr);
                idr.Close();
                foreach (DataRow dr in dt.Rows)
                {
                    list.Add(new MInOutLine(ctx, dr, trxName));
                }
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                _log.Log(Level.SEVERE, sql, e);
            }
            finally
            {
                dt = null;
            }

            MInOutLine[] retValue = new MInOutLine[list.Count];
            retValue = list.ToArray();
            return(retValue);
        }
示例#6
0
        /**
         *  Create Confirmation or return existing one
         *	@param ship shipment
         *	@param confirmType confirmation type
         *	@param checkExisting if false, new confirmation is created
         *	@return Confirmation
         */
        public static MInOutConfirm Create(MInOut ship, String confirmType, Boolean checkExisting)
        {
            if (checkExisting)
            {
                MInOutConfirm[] confirmations = ship.GetConfirmations(false);
                for (int i = 0; i < confirmations.Length; i++)
                {
                    MInOutConfirm confirm = confirmations[i];
                    if (confirm.GetConfirmType().Equals(confirmType))
                    {
                        _log.Info("create - existing: " + confirm);
                        return(confirm);
                    }
                }
            }

            MInOutConfirm confirm1 = new MInOutConfirm(ship, confirmType);

            confirm1.Save(ship.Get_TrxName());
            MInOutLine[] shipLines = ship.GetLines(false);
            for (int i = 0; i < shipLines.Length; i++)
            {
                MInOutLine        sLine = shipLines[i];
                MInOutLineConfirm cLine = new MInOutLineConfirm(confirm1);
                cLine.SetInOutLine(sLine);
                cLine.Save(ship.Get_TrxName());
            }
            _log.Info("New: " + confirm1);
            return(confirm1);
        }
 /// <summary>
 ///     Get Shipment Line
 /// </summary>
 /// <returns>line</returns>
 public MInOutLine GetLine()
 {
     if (_line == null)
     {
         _line = new MInOutLine(GetCtx(), GetM_InOutLine_ID(), Get_TrxName());
     }
     return(_line);
 }
示例#8
0
 /**
  *  Parent Constructor
  *	@param parent parent
  *	@param M_AttributeSetInstance_ID asi
  *	@param MovementQty qty
  */
 public MInOutLineMA(MInOutLine parent, int M_AttributeSetInstance_ID, Decimal MovementQty)
     : this(parent.GetCtx(), 0, parent.Get_TrxName())
 {
     SetClientOrg(parent);
     SetM_InOutLine_ID(parent.GetM_InOutLine_ID());
     //
     SetM_AttributeSetInstance_ID(M_AttributeSetInstance_ID);
     SetMovementQty(MovementQty);
 }
示例#9
0
        /// <summary>
        /// Is Used to Get or Create  Instance of MInoutLineMA (Attribute)
        /// </summary>
        /// <param name="line"></param>
        /// <param name="M_AttributeSetInstance_ID"></param>
        /// <param name="MovementQty"></param>
        /// <param name="DateMaterialPolicy"></param>
        /// <returns></returns>
        public static MInOutLineMA GetOrCreate(MInOutLine line, int M_AttributeSetInstance_ID, Decimal MovementQty, DateTime?DateMaterialPolicy)
        {
            MInOutLineMA retValue = null;
            String       sql      = "SELECT * FROM M_InoutLineMA " +
                                    @" WHERE  M_InOutLine_ID = " + line.GetM_InOutLine_ID() +
                                    @" AND MMPolicyDate = " + GlobalVariable.TO_DATE(DateMaterialPolicy, true) + @" AND ";

            if (M_AttributeSetInstance_ID == 0)
            {
                sql += "(M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID + " OR M_AttributeSetInstance_ID IS NULL)";
            }
            else
            {
                sql += "M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID;
            }
            DataTable   dt  = null;
            IDataReader idr = null;

            try
            {
                idr = DB.ExecuteReader(sql, null, line.Get_Trx());
                dt  = new DataTable();
                dt.Load(idr);
                idr.Close();
                foreach (DataRow dr in dt.Rows)
                {
                    retValue = new MInOutLineMA(line.GetCtx(), dr, line.Get_Trx());
                }
            }
            catch (Exception ex)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                _log.Log(Level.SEVERE, sql, ex);
            }
            finally
            {
                if (idr != null)
                {
                    idr.Close();
                }
                dt = null;
            }
            if (retValue == null)
            {
                retValue = new MInOutLineMA(line, M_AttributeSetInstance_ID, MovementQty, DateMaterialPolicy);
            }
            else
            {
                retValue.SetMovementQty(Decimal.Add(retValue.GetMovementQty(), MovementQty));
            }
            return(retValue);
        }
        /// <summary>
        ///      Process Confirmation Line.
        ///     - Update InOut Line
        /// </summary>
        /// <param name="isSOTrx">sales order</param>
        /// <param name="confirmType">type</param>
        /// <returns>success</returns>
        public Boolean ProcessLine(bool isSOTrx, String confirmType)
        {
            MInOutLine line = GetLine();

            //	Customer
            if (MInOutConfirm.CONFIRMTYPE_CustomerConfirmation.Equals(confirmType))
            {
                line.SetConfirmedQty(GetConfirmedQty());
            }

            //	Drop Ship
            else if (MInOutConfirm.CONFIRMTYPE_DropShipConfirm.Equals(confirmType))
            {
            }

            //	Pick or QA
            else if (MInOutConfirm.CONFIRMTYPE_PickQAConfirm.Equals(confirmType))
            {
                line.SetTargetQty(GetTargetQty());
                line.SetMovementQty(GetConfirmedQty()); //	Entered NOT changed
                line.SetPickedQty(GetConfirmedQty());
                //
                line.SetScrappedQty(GetScrappedQty());
            }

            //	Ship or Receipt
            else if (MInOutConfirm.CONFIRMTYPE_ShipReceiptConfirm.Equals(confirmType))
            {
                line.SetTargetQty(GetTargetQty());
                Decimal qty         = GetConfirmedQty();
                Boolean isReturnTrx = line.GetParent().IsReturnTrx();

                /* In PO receipts and SO Returns, we have the responsibility
                 * for scrapped quantity
                 */
                if ((!isSOTrx && !isReturnTrx) || (isSOTrx && isReturnTrx))
                {
                    qty = Decimal.Add(qty, GetScrappedQty());
                }
                line.SetMovementQty(qty);                               //	Entered NOT changed
                //
                line.SetScrappedQty(GetScrappedQty());
                // vikas 12/28/2015 Mantis Issue (0000335)
                line.SetConfirmedQty(GetConfirmedQty());
            }
            //	Vendor
            else if (MInOutConfirm.CONFIRMTYPE_VendorConfirmation.Equals(confirmType))
            {
                line.SetConfirmedQty(GetConfirmedQty());
            }

            return(line.Save(Get_TrxName()));
        }
示例#11
0
 /// <summary>
 /// Parent Constructor
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="M_AttributeSetInstance_ID"></param>
 /// <param name="movementQty"></param>
 /// <param name="MMPloicyDate"></param>
 public MInOutLineMA(MInOutLine parent, int M_AttributeSetInstance_ID, Decimal movementQty, DateTime?MMPloicyDate)
     : this(parent.GetCtx(), 0, parent.Get_TrxName())
 {
     SetClientOrg(parent);
     SetM_InOutLine_ID(parent.GetM_InOutLine_ID());
     //
     SetM_AttributeSetInstance_ID(M_AttributeSetInstance_ID);
     SetMovementQty(movementQty);
     if (MMPloicyDate == null)
     {
         MMPloicyDate = parent.GetParent().GetMovementDate();
     }
     SetMMPolicyDate(MMPloicyDate);
 }
示例#12
0
 /// <summary>
 /// Shipment Line Constructor
 /// </summary>
 /// <param name="sLine">shipment line</param>
 /// <param name="dateTrx">optional date</param>
 /// <param name="qty">matched quantity</param>
 public MMatchPO(MInOutLine sLine, DateTime?dateTrx, Decimal qty)
     : this(sLine.GetCtx(), 0, sLine.Get_Trx())
 {
     SetClientOrg(sLine);
     SetM_InOutLine_ID(sLine.GetM_InOutLine_ID());
     SetC_OrderLine_ID(sLine.GetC_OrderLine_ID());
     if (dateTrx != null)
     {
         SetDateTrx(dateTrx);
     }
     SetM_Product_ID(sLine.GetM_Product_ID());
     SetM_AttributeSetInstance_ID(sLine.GetM_AttributeSetInstance_ID());
     SetQty(qty);
     SetProcessed(true);         //	auto
 }
示例#13
0
        /**
         *  Set Qty based on product * shipment line if exists
         */
        public void SetQty()
        {
            //	UPDATE M_Product SET SupportUnits=1 WHERE SupportUnits IS NULL OR SupportUnits<1;
            //	UPDATE A_Asset a SET Qty = (SELECT l.MovementQty * p.SupportUnits FROM M_InOutLine l, M_Product p WHERE a.M_InOutLine_ID=l.M_InOutLine_ID AND a.M_Product_ID=p.M_Product_ID) WHERE a.M_Product_ID IS NOT NULL AND a.M_InOutLine_ID IS NOT NULL;
            Decimal Qty = Env.ONE;

            if (GetM_InOutLine_ID() != 0)
            {
                MInOutLine line = new MInOutLine(GetCtx(), GetM_InOutLine_ID(), Get_TrxName());
                Qty = line.GetMovementQty();
            }
            int     multiplier = GetProduct().GetSupportUnits();
            Decimal mm         = new Decimal(multiplier);

            base.SetQty(Decimal.Multiply(Qty, mm));
        }
示例#14
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);
            }
        }
        private static VLogger _log = VLogger.GetVLogger(typeof(MPackage).FullName); //Arpit

        public static MPackage Create(MInOut shipment, MShipper shipper, DateTime?shipDate, Trx trxName)
        {
            MPackage retValue = new MPackage(shipment, shipper);

            if (shipDate != null)
            {
                retValue.SetShipDate(shipDate);
            }
            //Edited : Arpit Rai, 13 Sept,2017
            DateTime?moveDate   = Convert.ToDateTime(shipment.GetMovementDate());
            String   documentNo = shipment.GetDocumentNo();

            retValue.SetDateAcct(DateTime.Now.Date);
            retValue.SetAD_Client_ID(shipment.GetAD_Client_ID());
            retValue.SetAD_Org_ID(shipment.GetAD_Org_ID());

            if (!retValue.Save(trxName))
            {
                trxName.Rollback();
                _log.Log(Level.SEVERE, "Error While Generating Package");
            }
            //Arpit
            //	Lines
            MInOutLine[] lines = shipment.GetLines(false);
            for (int i = 0; i < lines.Length; i++)
            {
                MInOutLine   sLine = lines[i];
                MPackageLine pLine = new MPackageLine(retValue);
                //Arpit
                //pLine.SetInOutLine(sLine);
                //Changes in Below Method to create Lines and their values from Shipment/MR Lines to Package Lines
                pLine.SetInOutLine(sLine, moveDate, documentNo,
                                   retValue.GetAD_Client_ID(), retValue.GetAD_Org_ID());

                if (!pLine.Save(trxName))
                {
                    trxName.Rollback();
                    _log.Log(Level.SEVERE, "Error While Generating Package Lines");
                }
                //Arpit
            }   //	lines
            return(retValue);
        }
示例#16
0
        ///**
        // * Get Storage Info for Warehouse
        // *
        // * @param ctx
        // *            context
        // * @param M_Warehouse_ID
        // * @param M_Product_ID
        // *            product
        // * @param M_AttributeSetInstance_ID
        // *            instance
        // * @param M_AttributeSet_ID
        // *            attribute set
        // * @param allAttributeInstances
        // *            if true, all attribute set instances
        // * @param minGuaranteeDate
        // *            optional minimum guarantee date if all attribute instances
        // * @param FiFo
        // *            first in-first-out
        // * @param trx
        // *            transaction
        // * @return existing - ordered by location priority (desc) and/or guarantee
        // *         date
        // */
        //public static List<Storage.VO> GetWarehouse(Ctx ctx, int M_Warehouse_ID,
        //        int M_Product_ID, int M_AttributeSetInstance_ID,
        //        int M_AttributeSet_ID, Boolean allAttributeInstances,
        //        Timestamp minGuaranteeDate, Boolean FiFo, Boolean allocationCheck,
        //        int M_SourceZone_ID, Trx trx)
        //{
        //    if (M_Warehouse_ID == 0 || M_Product_ID == 0)
        //        return null;

        //    if (M_AttributeSet_ID == 0)
        //        allAttributeInstances = true;
        //    else
        //    {
        //        MAttributeSet mas = MAttributeSet.Get(ctx, M_AttributeSet_ID);
        //        if (!mas.isInstanceAttribute())
        //            allAttributeInstances = true;
        //    }

        //    List<Storage.VO> list = new ArrayList<Storage.VO>();
        //    // Specific Attribute Set Instance
        //    String sql = "SELECT s.M_Product_ID,s.M_Locator_ID,s.M_AttributeSetInstance_ID,"
        //            + "COALESCE(SUM(CASE WHEN QtyType LIKE 'H' THEN Qty ELSE 0 END),0) QtyOnhand,"
        //            + "COALESCE(SUM(CASE WHEN QtyType LIKE 'D' THEN Qty ELSE 0 END),0) QtyDedicated,"
        //            + "COALESCE(SUM(CASE WHEN QtyType LIKE 'A' THEN Qty ELSE 0 END),0) QtyAllocated "
        //            + "FROM M_StorageDetail s"
        //            + " INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID) "
        //            + "WHERE l.M_Warehouse_ID=?"
        //            + " AND s.M_Product_ID=?"
        //            + " AND COALESCE(s.M_AttributeSetInstance_ID,0)=? ";

        //    if (allocationCheck)
        //        sql += "AND l.IsAvailableForAllocation='Y' ";

        //    if (M_SourceZone_ID != 0)
        //        sql += "AND l.M_Locator_ID IN "
        //                + " (SELECT M_Locator_ID FROM M_ZoneLocator WHERE M_Zone_ID = ? ) ";
        //    sql += "GROUP BY l.PriorityNo, s.M_Product_ID,s.M_Locator_ID,s.M_AttributeSetInstance_ID "
        //            + "ORDER BY l.PriorityNo DESC, M_AttributeSetInstance_ID";

        //    if (!FiFo)
        //        sql += " DESC";
        //    // All Attribute Set Instances
        //    if (allAttributeInstances)
        //    {
        //        sql = "SELECT s.M_Product_ID,s.M_Locator_ID,s.M_AttributeSetInstance_ID,"
        //                + "COALESCE(SUM(CASE WHEN QtyType LIKE 'H' THEN Qty ELSE 0 END),0) QtyOnhand,"
        //                + "COALESCE(SUM(CASE WHEN QtyType LIKE 'D' THEN Qty ELSE 0 END),0) QtyDedicated,"
        //                + "COALESCE(SUM(CASE WHEN QtyType LIKE 'A' THEN Qty ELSE 0 END),0) QtyAllocated "
        //                + "FROM M_StorageDetail s"
        //                + " INNER JOIN M_Locator l ON (l.M_Locator_ID=s.M_Locator_ID)"
        //                + " LEFT OUTER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) "
        //                + "WHERE l.M_Warehouse_ID=?" + " AND s.M_Product_ID=? ";

        //        if (allocationCheck)
        //            sql += "AND l.IsAvailableForAllocation='Y' ";

        //        if (M_SourceZone_ID != 0)
        //            sql += "AND l.M_Locator_ID IN "
        //                    + " (SELECT M_Locator_ID FROM M_ZoneLocator WHERE M_Zone_ID = ? ) ";

        //        if (minGuaranteeDate != null)
        //        {
        //            sql += "AND (asi.GuaranteeDate IS NULL OR asi.GuaranteeDate>?) "
        //                    + "GROUP BY asi.GuaranteeDate, l.PriorityNo, s.M_Product_ID, s.M_Locator_ID, s.M_AttributeSetInstance_ID "
        //                    + "ORDER BY asi.GuaranteeDate, l.PriorityNo DESC, M_AttributeSetInstance_ID";
        //        }
        //        else
        //        {
        //            sql += "GROUP BY l.PriorityNo, s.M_Product_ID, s.M_Locator_ID, s.M_AttributeSetInstance_ID "
        //                    + "ORDER BY l.PriorityNo DESC, s.M_AttributeSetInstance_ID";
        //        }
        //        if (!FiFo)
        //            sql += " DESC";
        //        sql += ", COALESCE(SUM(CASE WHEN QtyType LIKE 'H' THEN Qty ELSE 0 END),0) DESC";
        //    }
        //    PreparedStatement pstmt = null;
        //    ResultSet dr = null;
        //    try
        //    {
        //        pstmt = DB.prepareStatement(sql, trx);
        //        int index = 1;
        //        pstmt.setInt(index++, M_Warehouse_ID);
        //        pstmt.setInt(index++, M_Product_ID);
        //        if (M_SourceZone_ID != 0)
        //            pstmt.setInt(index++, M_SourceZone_ID);
        //        if (!allAttributeInstances)
        //            pstmt.setInt(index++, M_AttributeSetInstance_ID);
        //        else if (minGuaranteeDate != null)
        //            pstmt.setTimestamp(index++, minGuaranteeDate);
        //        dr = pstmt.executeQuery();
        //        while (dr.next())
        //        {
        //            index = 1;
        //            int rs_M_Product_ID = dr.getInt(1);
        //            int rs_M_Locator_ID = dr.getInt(index++);
        //            int rs_M_AttributeSetInstance_ID = dr.getInt(index++);
        //            Decimal rs_QtyOnhand = dr.getBigDecimal(index++);
        //            Decimal rs_QtyDedicated = dr.getBigDecimal(index++);
        //            Decimal rs_QtyAllocated = dr.getBigDecimal(index++);
        //            list.add(new Storage.VO(rs_M_Product_ID, rs_M_Locator_ID,
        //                    rs_M_AttributeSetInstance_ID, rs_QtyOnhand,
        //                    rs_QtyDedicated, rs_QtyAllocated));
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        s_log.s_log(Level.SEVERE, sql, e);
        //    }
        //    finally
        //    {
        //        DB.closeResultSet(dr);
        //        DB.closeStatement(pstmt);
        //    }
        //    return list;
        //} // getWarehouse

        //public static List<Storage.VO> getWarehouse(Ctx ctx,
        //        int M_Warehouse_ID, int M_Product_ID,
        //        int M_AttributeSetInstance_ID, int M_AttributeSet_ID,
        //        Boolean allAttributeInstances, Timestamp minGuaranteeDate,
        //        Boolean FiFo, Trx trx)
        //{
        //    return getWarehouse(ctx, M_Warehouse_ID, M_Product_ID,
        //            M_AttributeSetInstance_ID, M_AttributeSet_ID,
        //            allAttributeInstances, minGuaranteeDate, FiFo, false, 0, trx);
        //}

        /// <summary>
        /// Trace back from storage record to original receipt line.
        /// </summary>
        /// <returns>MInOutLine or null</returns>
        public MInOutLine GetInOutLineOf()
        {
            // Don't try to trace back to receipt line for ASI=0 records
            if (GetM_AttributeSetInstance_ID() == 0)
            {
                return(null);
            }
            MInOutLine retValue = null;
            String     sql      = "SELECT * FROM M_InOutLine line "
                                  + "WHERE M_AttributeSetInstance_ID=" + GetM_AttributeSetInstance_ID()
                                  + "OR EXISTS (SELECT 1 FROM "
                                  + "M_InOutLineMA ma WHERE line.M_InOutLine_ID = ma.M_InOutLine_ID "
                                  + "AND M_AttributeSetInstance_ID=" + GetM_AttributeSetInstance_ID() + ")";

            IDataReader idr = null;

            try
            {
                idr = DB.ExecuteReader(sql, null, Get_TrxName());
                DataTable dt = new DataTable();
                dt.Load(idr);
                idr.Close();
                if (dt.Rows.Count > 0)//idr.Read())
                {
                    retValue = new MInOutLine(GetCtx(), dt.Rows[0], Get_TrxName());
                }
            }
            catch (Exception ex)
            {
                s_log.Log(Level.SEVERE, sql, ex);
            }
            finally
            {
                if (idr != null)
                {
                    idr.Close();
                    idr = null;
                }
            }

            return(retValue);
        }
示例#17
0
        /// <summary>
        /// Create one Package for Shipment
        /// </summary>
        /// <param name="shipment">shipment</param>
        /// <param name="shipper">shipper</param>
        /// <param name="shipDate">null for today</param>
        /// <returns>package</returns>
        public static MPackage Create(MInOut shipment, MShipper shipper, DateTime?shipDate)
        {
            MPackage retValue = new MPackage(shipment, shipper);

            if (shipDate != null)
            {
                retValue.SetShipDate(shipDate);
            }
            retValue.Save();
            //	Lines
            MInOutLine[] lines = shipment.GetLines(false);
            for (int i = 0; i < lines.Length; i++)
            {
                MInOutLine   sLine = lines[i];
                MPackageLine pLine = new MPackageLine(retValue);
                pLine.SetInOutLine(sLine);
                pLine.Save();
            }   //	lines
            return(retValue);
        }
 /// <summary>
 /// Set Shipment Line
 /// </summary>
 /// <param name="line">line</param>
 public void SetInOutLine(MInOutLine line, DateTime?moveDate, String DocumentNo, Int32 Client_ID, Int32 Org_ID)
 {
     SetM_InOutLine_ID(line.GetM_InOutLine_ID());
     SetQty(line.GetMovementQty());
     //Edited :Arpit Rai ,13 Sept,2017
     //to Set Client,Org,Confirm Date,Confirm Date, Scrapped Qty, Difference Qty & Reference No
     SetAD_Client_ID(Client_ID);
     SetAD_Org_ID(Org_ID);
     SetM_Product_ID(line.GetM_Product_ID());
     SetM_AttributeSetInstance_ID(line.GetM_AttributeSetInstance_ID());
     if (Util.GetValueOfInt(DB.ExecuteQuery("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='DTD001_' AND IsActive='Y'")) > 0
         )
     {
         if (moveDate != null)
         {
             SetDTD001_ConfirmDate(moveDate);
         }
         SetDTD001_ReferenceNo(DocumentNo); //Set Reference No from MR/Shipment to package Lines
     }
     SetConfirmedQty(line.GetConfirmedQty());
     SetScrappedQty(line.GetScrappedQty());
     SetDifferenceQty(Decimal.Subtract(line.GetMovementQty(), line.GetConfirmedQty() + line.GetScrappedQty()));
     //Arpit
 }
示例#19
0
        /// <summary>
        /// Before Delete
        /// </summary>
        /// <returns>true if acct was deleted</returns>
        protected override bool BeforeDelete()
        {
            if (IsPosted())
            {
                if (!MPeriod.IsOpen(GetCtx(), GetDateTrx(), MDocBaseType.DOCBASETYPE_MATCHPO))
                {
                    return(false);
                }
                SetPosted(false);
                return(true);// MFactAcct.Delete(Table_ID, Get_ID(), Get_Trx()) >= 0;
            }

            //JID_0162: System should allow to delete the Matched PO of PO and MR with complete status only.
            if (GetC_OrderLine_ID() != 0)
            {
                MOrderLine line = new MOrderLine(GetCtx(), GetC_OrderLine_ID(), Get_TrxName());
                MOrder     ord  = new MOrder(GetCtx(), line.GetC_Order_ID(), Get_TrxName());
                if (ord.GetDocStatus() != DocumentEngine.ACTION_COMPLETE)
                {
                    log.SaveError("Error", Msg.GetMsg(GetCtx(), "Order/ShipmentNotCompleted"));
                    return(false);
                }
            }

            if (GetM_InOutLine_ID() != 0)
            {
                MInOutLine line = new MInOutLine(GetCtx(), GetM_InOutLine_ID(), Get_TrxName());
                MInOut     ino  = new MInOut(GetCtx(), line.GetM_InOut_ID(), Get_TrxName());
                if (ino.GetDocStatus() != DocumentEngine.ACTION_COMPLETE)
                {
                    log.SaveError("Error", Msg.GetMsg(GetCtx(), "Order/ShipmentNotCompleted"));
                    return(false);
                }
            }
            return(true);
        }
示例#20
0
 /**
  *  Before Save
  *	@param newRecord new
  *	@return true
  */
 protected override bool BeforeSave(bool newRecord)
 {
     //	Set Trx Date
     if (GetDateTrx() == null)
     {
         SetDateTrx(new DateTime(CommonFunctions.CurrentTimeMillis()));
     }
     //	Set Acct Date
     if (GetDateAcct() == null)
     {
         DateTime?ts = GetNewerDateAcct();
         if (ts == null)
         {
             ts = GetDateTrx();
         }
         SetDateAcct(ts);
     }
     if (GetM_AttributeSetInstance_ID() == 0 && GetM_InOutLine_ID() != 0)
     {
         MInOutLine iol = new MInOutLine(GetCtx(), GetM_InOutLine_ID(), Get_TrxName());
         SetM_AttributeSetInstance_ID(iol.GetM_AttributeSetInstance_ID());
     }
     return(true);
 }
        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);
        }
示例#22
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());
                        }
                    }
                }
            }
        }
示例#23
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);
            }
        }
示例#24
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");
                }
            }
        }
示例#25
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());
 }
示例#26
0
        /**
         *  Find/Create PO(Inv) Match
         *	@param iLine invoice line
         *	@param sLine receipt line
         *	@param dateTrx date
         *	@param qty qty
         *	@return Match Record
         */
        public static MMatchPO Create(MInvoiceLine iLine, MInOutLine sLine, DateTime?dateTrx, Decimal qty)
        {
            Trx trxName        = null;
            Ctx ctx            = null;
            int C_OrderLine_ID = 0;

            if (iLine != null)
            {
                trxName        = iLine.Get_Trx();
                ctx            = iLine.GetCtx();
                C_OrderLine_ID = iLine.GetC_OrderLine_ID();
            }
            if (sLine != null)
            {
                trxName        = sLine.Get_Trx();
                ctx            = sLine.GetCtx();
                C_OrderLine_ID = sLine.GetC_OrderLine_ID();
            }

            MMatchPO retValue = null;
            String   sql      = "SELECT * FROM M_MatchPO WHERE C_OrderLine_ID=" + C_OrderLine_ID;
            //		ArrayList list = new ArrayList();
            DataSet ds = null;

            try
            {
                ds = DataBase.DB.ExecuteDataset(sql, null, trxName);
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    MMatchPO mpo = new MMatchPO(ctx, dr, trxName);
                    if (qty.CompareTo(mpo.GetQty()) == 0)
                    {
                        if (iLine != null)
                        {
                            if (mpo.GetC_InvoiceLine_ID() == 0 ||
                                mpo.GetC_InvoiceLine_ID() == iLine.GetC_InvoiceLine_ID())
                            {
                                mpo.SetC_InvoiceLine_ID(iLine);
                                if (iLine.GetM_AttributeSetInstance_ID() != 0)
                                {
                                    if (mpo.GetM_AttributeSetInstance_ID() == 0)
                                    {
                                        mpo.SetM_AttributeSetInstance_ID(iLine.GetM_AttributeSetInstance_ID());
                                    }
                                    else if (mpo.GetM_AttributeSetInstance_ID() != iLine.GetM_AttributeSetInstance_ID())
                                    {
                                        continue;
                                    }
                                }
                            }
                            else
                            {
                                continue;
                            }
                        }
                        if (sLine != null)
                        {
                            if (mpo.GetM_InOutLine_ID() == 0 ||
                                mpo.GetM_InOutLine_ID() == sLine.GetM_InOutLine_ID())
                            {
                                mpo.SetM_InOutLine_ID(sLine.GetM_InOutLine_ID());
                                if (sLine.GetM_AttributeSetInstance_ID() != 0)
                                {
                                    if (mpo.GetM_AttributeSetInstance_ID() == 0)
                                    {
                                        mpo.SetM_AttributeSetInstance_ID(sLine.GetM_AttributeSetInstance_ID());
                                    }
                                    else if (mpo.GetM_AttributeSetInstance_ID() != sLine.GetM_AttributeSetInstance_ID())
                                    {
                                        continue;
                                    }
                                }
                            }
                            else
                            {
                                continue;
                            }
                        }
                        retValue = mpo;
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                s_log.Log(Level.SEVERE, sql, e);
            }
            //	Create New
            if (retValue == null)
            {
                if (sLine != null)
                {
                    retValue = new MMatchPO(sLine, dateTrx, qty);
                    if (iLine != null)
                    {
                        retValue.SetC_InvoiceLine_ID(iLine);
                    }
                }
                else if (iLine != null)
                {
                    retValue = new MMatchPO(iLine, dateTrx, qty);
                }
            }
            return(retValue);
        }
示例#27
0
        /**
         *  Create Difference Document
         *  @param inout shipment/receipt
         *	@param confirm confirm line
         *	@return true if created
         */
        private bool CreateDifferenceDoc(MInOut inout, MInOutLineConfirm confirm)
        {
            if (_processMsg == null)
            {
                _processMsg = "";
            }
            else if (_processMsg.Length > 0)
            {
                _processMsg += "; ";
            }
            //	Credit Memo if linked Document
            if (Env.Signum(confirm.GetDifferenceQty()) != 0 &&
                !inout.IsSOTrx() && !inout.IsReturnTrx() && inout.GetRef_InOut_ID() != 0)
            {
                log.Info("Difference=" + confirm.GetDifferenceQty());
                if (_creditMemo == null)
                {
                    _creditMemo = new MInvoice(inout, null);
                    _creditMemo.SetDescription(Msg.Translate(GetCtx(),
                                                             "M_InOutConfirm_ID") + " " + GetDocumentNo());
                    _creditMemo.SetC_DocTypeTarget_ID(MDocBaseType.DOCBASETYPE_APCREDITMEMO);
                    if (!_creditMemo.Save(Get_TrxName()))
                    {
                        _processMsg += "Credit Memo not created";
                        return(false);
                    }
                    SetC_Invoice_ID(_creditMemo.GetC_Invoice_ID());
                }
                MInvoiceLine line = new MInvoiceLine(_creditMemo);
                line.SetShipLine(confirm.GetLine());
                line.SetQty(confirm.GetDifferenceQty());        //	Entered/Invoiced
                if (!line.Save(Get_TrxName()))
                {
                    _processMsg += "Credit Memo Line not created";
                    return(false);
                }
                confirm.SetC_InvoiceLine_ID(line.GetC_InvoiceLine_ID());
            }

            //	Create Inventory Difference
            if (Env.Signum(confirm.GetScrappedQty()) != 0)
            {
                log.Info("Scrapped=" + confirm.GetScrappedQty());
                if (_inventory == null)
                {
                    MWarehouse wh = MWarehouse.Get(GetCtx(), inout.GetM_Warehouse_ID());
                    _inventory = new MInventory(wh);
                    _inventory.SetDescription(Msg.Translate(GetCtx(),
                                                            "M_InOutConfirm_ID") + " " + GetDocumentNo());
                    if (!_inventory.Save(Get_TrxName()))
                    {
                        _processMsg += "Inventory not created";
                        return(false);
                    }
                    SetM_Inventory_ID(_inventory.GetM_Inventory_ID());
                }
                MInOutLine     ioLine = confirm.GetLine();
                MInventoryLine line   = new MInventoryLine(_inventory,
                                                           ioLine.GetM_Locator_ID(), ioLine.GetM_Product_ID(),
                                                           ioLine.GetM_AttributeSetInstance_ID(),
                                                           confirm.GetScrappedQty(), Env.ZERO);
                if (!line.Save(Get_TrxName()))
                {
                    _processMsg += "Inventory Line not created";
                    return(false);
                }
                confirm.SetM_InventoryLine_ID(line.GetM_InventoryLine_ID());
            }

            //
            if (!confirm.Save(Get_TrxName()))
            {
                _processMsg += "Confirmation Line not saved";
                return(false);
            }
            return(true);
        }
示例#28
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);
            }
        }
示例#29
0
        /// <summary>
        /// Before Save
        /// </summary>
        /// <param name="newRecord">new</param>
        /// <returns>true</returns>
        protected override bool BeforeSave(bool newRecord)
        {
            //	Set Trx Date
            if (GetDateTrx() == null)
            {
                SetDateTrx(DateTime.Now);
            }
            //	Set Acct Date
            if (GetDateAcct() == null)
            {
                DateTime?ts = GetNewerDateAcct();
                if (ts == null)
                {
                    ts = GetDateTrx();
                }
                SetDateAcct((DateTime?)ts);
            }
            //	Set ASI from Receipt
            if (GetM_AttributeSetInstance_ID() == 0 && GetM_InOutLine_ID() != 0)
            {
                MInOutLine iol = new MInOutLine(GetCtx(), GetM_InOutLine_ID(), Get_Trx());
                SetM_AttributeSetInstance_ID(iol.GetM_AttributeSetInstance_ID());
            }

            //	Find OrderLine
            if (GetC_OrderLine_ID() == 0)
            {
                MInvoiceLine il = null;
                if (GetC_InvoiceLine_ID() != 0)
                {
                    il = GetInvoiceLine();
                    if (il.GetC_OrderLine_ID() != 0)
                    {
                        SetC_OrderLine_ID(il.GetC_OrderLine_ID());
                    }
                }       //	get from invoice
                if (GetC_OrderLine_ID() == 0 && GetM_InOutLine_ID() != 0)
                {
                    MInOutLine iol = new MInOutLine(GetCtx(), GetM_InOutLine_ID(), Get_Trx());
                    if (iol.GetC_OrderLine_ID() != 0)
                    {
                        SetC_OrderLine_ID(iol.GetC_OrderLine_ID());
                        if (il != null)
                        {
                            il.SetC_OrderLine_ID(iol.GetC_OrderLine_ID());
                            il.Save();
                        }
                    }
                } //	get from shipment
            }     //	find order line

            //	Price Match Approval
            if (GetC_OrderLine_ID() != 0 &&
                GetC_InvoiceLine_ID() != 0 &&
                (newRecord ||
                 Is_ValueChanged("C_OrderLine_ID") || Is_ValueChanged("C_InvoiceLine_ID")))
            {
                Decimal poPrice    = GetOrderLine().GetPriceActual();
                Decimal invPrice   = GetInvoiceLine().GetPriceActual();
                Decimal difference = Decimal.Subtract(poPrice, invPrice);
                if (Math.Sign(difference) != 0)
                {
                    difference = Decimal.Multiply(difference, GetQty());
                    SetPriceMatchDifference(difference);
                    //	Approval
                    //MBPGroup group = MBPGroup.getOfBPartner(GetCtx(), GetOrderLine().GetC_BPartner_ID());
                    Decimal mt = 0; //group.getPriceMatchTolerance();
                    if (Math.Sign(mt) != 0)
                    {
                        Decimal poAmt        = Decimal.Multiply(poPrice, GetQty());
                        Decimal maxTolerance = Decimal.Multiply(poAmt, mt);
                        //maxTolerance = Math.Abs(maxTolerance)
                        //    .divide(Env.ONEHUNDRED, 2, Decimal.ROUND_HALF_UP);
                        maxTolerance = Decimal.Divide(Math.Abs(maxTolerance), Env.ONEHUNDRED);
                        difference   = Math.Abs(difference);
                        bool ok = difference.CompareTo(maxTolerance) <= 0;
                        //log.config("Difference=" + GetPriceMatchDifference()
                        //    + ", Max=" + maxTolerance + " => " + ok);
                        SetIsApproved(ok);
                    }
                }
                else
                {
                    SetPriceMatchDifference(difference);
                    SetIsApproved(true);
                }
            }

            return(true);
        }
        /// <summary>
        ///      Process Confirmation Line.
        ///     - Update InOut Line
        /// </summary>
        /// <param name="isSOTrx">sales order</param>
        /// <param name="confirmType">type</param>
        /// <returns>success</returns>
        public Boolean ProcessLine(bool isSOTrx, String confirmType)
        {
            MInOutLine line = GetLine();

            //	Customer
            if (MInOutConfirm.CONFIRMTYPE_CustomerConfirmation.Equals(confirmType))
            {
                line.SetConfirmedQty(GetConfirmedQty());
            }

            //	Drop Ship
            else if (MInOutConfirm.CONFIRMTYPE_DropShipConfirm.Equals(confirmType))
            {
            }

            //	Pick or QA
            else if (MInOutConfirm.CONFIRMTYPE_PickQAConfirm.Equals(confirmType))
            {
                line.SetTargetQty(GetTargetQty());
                line.SetMovementQty(GetConfirmedQty()); //	Entered NOT changed
                line.SetPickedQty(GetConfirmedQty());
                //
                line.SetScrappedQty(GetScrappedQty());
            }

            //	Ship or Receipt
            else if (MInOutConfirm.CONFIRMTYPE_ShipReceiptConfirm.Equals(confirmType))
            {
                //Arpit
                if (GetDifferenceQty() > 0)
                {
                    GetCtx().SetContext("DifferenceQty_", VAdvantage.Utility.Util.GetValueOfString(GetDifferenceQty()));
                }
                MProduct _pro = new MProduct(GetCtx(), line.GetM_Product_ID(), Get_TrxName());
                if (_pro.GetC_UOM_ID() != line.GetC_UOM_ID())
                {
                    decimal?pc = null;
                    pc = MUOMConversion.ConvertProductFrom(GetCtx(), line.GetM_Product_ID(), GetC_UOM_ID(), GetTargetQty());
                    line.SetTargetQty(Util.GetValueOfDecimal(pc));  //TargetQty

                    Decimal qty         = GetConfirmedQty();
                    Boolean isReturnTrx = line.GetParent().IsReturnTrx();

                    /* In PO receipts and SO Returns, we have the responsibility
                     * for scrapped quantity
                     */
                    if ((!isSOTrx && !isReturnTrx) || (isSOTrx && isReturnTrx))
                    {
                        qty = Decimal.Add(qty, GetScrappedQty());
                    }
                    pc = MUOMConversion.ConvertProductFrom(GetCtx(), line.GetM_Product_ID(), GetC_UOM_ID(), qty);
                    line.SetMovementQty(Util.GetValueOfDecimal(pc)); //MovementQty

                    pc = MUOMConversion.ConvertProductFrom(GetCtx(), line.GetM_Product_ID(), GetC_UOM_ID(), GetScrappedQty());
                    line.SetScrappedQty(Util.GetValueOfDecimal(pc));  //ScrappedQty

                    pc = MUOMConversion.ConvertProductFrom(GetCtx(), line.GetM_Product_ID(), GetC_UOM_ID(), GetConfirmedQty());
                    line.SetConfirmedQty(Util.GetValueOfDecimal(pc)); //confirm Qty
                }
                else
                {
                    line.SetTargetQty(GetTargetQty());
                    Decimal qty         = GetConfirmedQty();
                    Boolean isReturnTrx = line.GetParent().IsReturnTrx();

                    /* In PO receipts and SO Returns, we have the responsibility
                     * for scrapped quantity
                     */
                    if ((!isSOTrx && !isReturnTrx) || (isSOTrx && isReturnTrx))
                    {
                        qty = Decimal.Add(qty, GetScrappedQty());
                    }
                    line.SetMovementQty(qty);                           //	Entered NOT changed
                    //
                    line.SetScrappedQty(GetScrappedQty());
                    // vikas 12/28/2015 Mantis Issue (0000335)
                    line.SetConfirmedQty(GetConfirmedQty());
                }
            }
            //	Vendor
            else if (MInOutConfirm.CONFIRMTYPE_VendorConfirmation.Equals(confirmType))
            {
                line.SetConfirmedQty(GetConfirmedQty());
            }

            return(line.Save(Get_TrxName()));
        }