/// <summary>
        ///  Load Document Details
        /// </summary>
        /// <returns>error message or null</returns>
        public override String LoadDocumentDetails()
        {
            SetC_Currency_ID(NO_CURRENCY);
            MInOut inout = (MInOut)GetPO();

            SetDateDoc(inout.GetMovementDate());
            //
            _MatchRequirementR = X_AD_ClientInfo.MATCHREQUIREMENTR_None;
            if (!inout.IsSOTrx())
            {
                _MatchRequirementR = MClientInfo.Get(GetCtx(), inout.GetAD_Client_ID())
                                     .GetMatchRequirementR();
                String mr = inout.GetMatchRequirementR();
                if (mr == null)
                {
                    inout.SetMatchRequirementR(_MatchRequirementR);
                }
                else
                {
                    _MatchRequirementR = mr;
                }
            }

            //	Contained Objects
            _lines = LoadLines(inout);
            log.Fine("Lines=" + _lines.Length);
            if (_matchProblem == null || _matchProblem.Length == 0)
            {
                return(null);
            }
            return(_matchProblem.Substring(1).Trim());
        }
示例#2
0
        public JsonResult PostByNewLogic(int AD_Client_ID)
        {
            Ctx    ctx = Session["ctx"] as Ctx;
            string res = "No";

            MClientInfo info = MClientInfo.Get(ctx, AD_Client_ID);
            MAcctSchema ass  = new MAcctSchema(ctx, info.GetC_AcctSchema1_ID(), null);

            if (ass.GetFRPT_LocAcct_ID() > 0)
            {
                res = "Yes";
            }

            return(Json(new { result = res }, JsonRequestBehavior.AllowGet));
        }
示例#3
0
        /// <summary>
        /// Update ProductPO PriceLastInv
        /// </summary>
        /// <param name="as1">accounting schema</param>
        private void UpdateProductPO(MAcctSchema as1)
        {
            MClientInfo ci = MClientInfo.Get(GetCtx(), as1.GetAD_Client_ID());

            if (ci.GetC_AcctSchema1_ID() != as1.GetC_AcctSchema_ID())
            {
                return;
            }

            StringBuilder sql = new StringBuilder(
                "UPDATE M_Product_PO po "
                + "SET PriceLastInv = "
                //	select
                + "(SELECT currencyConvert(il.PriceActual,i.C_Currency_ID,po.C_Currency_ID,i.DateInvoiced,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID) "
                + "FROM C_Invoice i, C_InvoiceLine il "
                + "WHERE i.C_Invoice_ID=il.C_Invoice_ID"
                + " AND po.M_Product_ID=il.M_Product_ID AND po.C_BPartner_ID=i.C_BPartner_ID");

            //jz + " AND ROWNUM=1 AND i.C_Invoice_ID=").Append(get_ID()).Append(") ")
            if (DataBase.DB.IsOracle()) //jz
            {
                sql.Append(" AND ROWNUM=1 ");
            }
            else
            {
                sql.Append(" AND i.UPDATED IN (SELECT MAX(i1.UPDATED) "
                           + "FROM C_Invoice i1, C_InvoiceLine il1 "
                           + "WHERE i1.C_Invoice_ID=il1.C_Invoice_ID"
                           + " AND po.M_Product_ID=il1.M_Product_ID AND po.C_BPartner_ID=i1.C_BPartner_ID")
                .Append("  AND i1.C_Invoice_ID=").Append(Get_ID()).Append(") ");
            }
            sql.Append("  AND i.C_Invoice_ID=").Append(Get_ID()).Append(") ")
            //	update
            .Append("WHERE EXISTS (SELECT * "
                    + "FROM C_Invoice i, C_InvoiceLine il "
                    + "WHERE i.C_Invoice_ID=il.C_Invoice_ID"
                    + " AND po.M_Product_ID=il.M_Product_ID AND po.C_BPartner_ID=i.C_BPartner_ID"
                    + " AND i.C_Invoice_ID=").Append(Get_ID()).Append(")");

            int no = DataBase.DB.ExecuteQuery(sql.ToString(), null, GetTrx());

            log.Fine("Updated=" + no);
        }
示例#4
0
        /// <summary>
        /// Update ProductPO PriceLastPO
        /// </summary>
        /// <param name="as1">accounting schema</param>
        private void UpdateProductPO(MAcctSchema as1)
        {
            MClientInfo ci = MClientInfo.Get(GetCtx(), as1.GetAD_Client_ID());

            if (ci.GetC_AcctSchema1_ID() != as1.GetC_AcctSchema_ID())
            {
                return;
            }

            StringBuilder sql = new StringBuilder(
                "UPDATE M_Product_PO po "
                + "SET PriceLastPO = (SELECT currencyConvert(ol.PriceActual,ol.C_Currency_ID,po.C_Currency_ID,o.DateOrdered,o.C_ConversionType_ID,o.AD_Client_ID,o.AD_Org_ID) "
                + "FROM C_Order o, C_OrderLine ol "
                + "WHERE o.C_Order_ID=ol.C_Order_ID"
                + " AND po.M_Product_ID=ol.M_Product_ID AND po.C_BPartner_ID=o.C_BPartner_ID");

            //	AND ROWNUM=1 AND o.C_Order_ID=").Append(get_ID()).Append(") ")
            if (DataBase.DB.IsOracle()) //jz
            {
                sql.Append(" AND ROWNUM=1 ");
            }
            else
            {
                sql.Append(" AND o.UPDATED IN (SELECT MAX(o1.UPDATED) "
                           + "FROM C_Order o1, C_OrderLine ol1 "
                           + "WHERE o1.C_Order_ID=ol1.C_Order_ID"
                           + " AND po.M_Product_ID=ol1.M_Product_ID AND po.C_BPartner_ID=o1.C_BPartner_ID")
                .Append("  AND o1.C_Order_ID=").Append(Get_ID()).Append(") ");
            }

            sql.Append(" AND o.C_Order_ID=").Append(Get_ID()).Append(") ")
            .Append("WHERE EXISTS (SELECT * "
                    + "FROM C_Order o, C_OrderLine ol "
                    + "WHERE o.C_Order_ID=ol.C_Order_ID"
                    + " AND po.M_Product_ID=ol.M_Product_ID AND po.C_BPartner_ID=o.C_BPartner_ID"
                    + " AND o.C_Order_ID=").Append(Get_ID()).Append(")");
            int no = DataBase.DB.ExecuteQuery(sql.ToString(), null, GetTrx());

            log.Fine("Updated=" + no);
        }