コード例 #1
0
        /// <summary>
        /// GetOrder
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="fields"></param>
        /// <returns></returns>
        public Dictionary <String, String> GetOrder(Ctx ctx, string fields)
        {
            string[] paramValue = fields.ToString().Split(',');
            int      C_Order_ID;

            //Assign parameter value
            C_Order_ID = Util.GetValueOfInt(paramValue[0].ToString());
            MOrder order = new MOrder(ctx, C_Order_ID, null);
            // End Assign parameter value

            Dictionary <String, String> retDic = new Dictionary <string, string>();

            // Reset Orig Shipment
            retDic["C_BPartner_ID"]          = Util.GetValueOfString(order.GetC_BPartner_ID());
            retDic["C_BPartner_Location_ID"] = Util.GetValueOfString(order.GetC_BPartner_Location_ID());
            retDic["Bill_BPartner_ID"]       = Util.GetValueOfString(order.GetBill_BPartner_ID());
            retDic["Bill_Location_ID"]       = Util.GetValueOfString(order.GetBill_Location_ID());
            if (order.GetAD_User_ID() != 0)
            {
                retDic["AD_User_ID"] = Util.GetValueOfString(order.GetAD_User_ID());
            }
            if (order.GetBill_User_ID() != 0)
            {
                retDic["Bill_User_ID"] = Util.GetValueOfString(order.GetBill_User_ID());
            }
            retDic["M_PriceList_ID"]   = Util.GetValueOfString(order.GetM_PriceList_ID());
            retDic["PaymentRule"]      = order.GetPaymentRule();
            retDic["C_PaymentTerm_ID"] = Util.GetValueOfString(order.GetC_PaymentTerm_ID());
            //mTab.setValue ("DeliveryRule", X_C_Order.DELIVERYRULE_Manual);
            retDic["Bill_Location_ID"] = Util.GetValueOfString(order.GetBill_Location_ID());
            retDic["InvoiceRule"]      = order.GetInvoiceRule();
            retDic["PaymentRule"]      = order.GetPaymentRule();
            retDic["DeliveryViaRule"]  = order.GetDeliveryViaRule();
            retDic["FreightCostRule"]  = order.GetFreightCostRule();
            retDic["ID"]              = Util.GetValueOfString(order.Get_ID());
            retDic["DateOrdered"]     = Util.GetValueOfString(order.GetDateOrdered());
            retDic["POReference"]     = order.GetPOReference();
            retDic["AD_Org_ID"]       = Util.GetValueOfString(order.GetAD_Org_ID());
            retDic["DeliveryRule"]    = order.GetDeliveryRule();
            retDic["DeliveryViaRule"] = order.GetDeliveryViaRule();
            retDic["M_Shipper_ID"]    = Util.GetValueOfString(order.GetM_Shipper_ID());
            retDic["FreightAmt"]      = Util.GetValueOfString(order.GetFreightAmt());
            retDic["AD_OrgTrx_ID"]    = Util.GetValueOfString(order.GetAD_OrgTrx_ID());
            retDic["C_Activity_ID"]   = Util.GetValueOfString(order.GetC_Activity_ID());
            retDic["C_Campaign_ID"]   = Util.GetValueOfString(order.GetC_Campaign_ID());
            retDic["C_Project_ID"]    = Util.GetValueOfString(order.GetC_Project_ID());
            retDic["User1_ID"]        = Util.GetValueOfString(order.GetUser1_ID());
            retDic["User2_ID"]        = Util.GetValueOfString(order.GetUser2_ID());
            retDic["M_Warehouse_ID"]  = Util.GetValueOfString(order.GetM_Warehouse_ID());
            retDic["Orig_Order_ID"]   = Util.GetValueOfString(order.GetOrig_Order_ID());
            retDic["Orig_InOut_ID"]   = Util.GetValueOfString(order.GetOrig_InOut_ID());
            return(retDic);
        }
コード例 #2
0
        /// <summary>
        /// Create PO for Vendor
        /// </summary>
        /// <param name="C_BPartner_ID">vendor</param>
        /// <param name="so">sales order</param>
        /// <returns>MOrder</returns>
        public MOrder CreatePOForVendor(int C_BPartner_ID, MOrder so)
        {
            MOrder po = new MOrder(GetCtx(), 0, Get_TrxName());

            po.SetClientOrg(so.GetAD_Client_ID(), so.GetAD_Org_ID());
            po.SetRef_Order_ID(so.GetC_Order_ID());
            po.SetIsSOTrx(false);
            po.SetC_DocTypeTarget_ID();
            //
            po.SetDescription(so.GetDescription());
            po.SetPOReference(so.GetDocumentNo());
            po.SetPriorityRule(so.GetPriorityRule());
            po.SetSalesRep_ID(so.GetSalesRep_ID());
            po.SetM_Warehouse_ID(so.GetM_Warehouse_ID());
            //	Set Vendor
            MBPartner vendor = new MBPartner(GetCtx(), C_BPartner_ID, Get_TrxName());

            po.SetBPartner(vendor);
            //	Drop Ship
            po.SetIsDropShip(so.IsDropShip());
            if (so.IsDropShip())
            {
                po.SetShip_BPartner_ID(so.GetC_BPartner_ID());
                po.SetShip_Location_ID(so.GetC_BPartner_Location_ID());
                po.SetShip_User_ID(so.GetAD_User_ID());
            }
            //	References
            po.SetC_Activity_ID(so.GetC_Activity_ID());
            po.SetC_Campaign_ID(so.GetC_Campaign_ID());
            po.SetC_Project_ID(so.GetC_Project_ID());
            po.SetUser1_ID(so.GetUser1_ID());
            po.SetUser2_ID(so.GetUser2_ID());
            //
            po.Save();
            return(po);
        }
コード例 #3
0
        /// <summary>
        /// GetOrder
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="fields"></param>
        /// <returns></returns>
        public Dictionary <String, object> GetOrder(Ctx ctx, string fields)
        {
            string[] paramValue = fields.ToString().Split(',');
            int      C_Order_ID;

            //Assign parameter value
            C_Order_ID = Util.GetValueOfInt(paramValue[0].ToString());
            MOrder order = new MOrder(ctx, C_Order_ID, null);
            // End Assign parameter value

            Dictionary <String, object> retDic = new Dictionary <string, object>();

            // Reset Orig Shipment
            retDic["C_BPartner_ID"]          = Util.GetValueOfString(order.GetC_BPartner_ID());
            retDic["C_BPartner_Location_ID"] = Util.GetValueOfString(order.GetC_BPartner_Location_ID());
            retDic["Bill_BPartner_ID"]       = Util.GetValueOfString(order.GetBill_BPartner_ID());
            retDic["Bill_Location_ID"]       = Util.GetValueOfString(order.GetBill_Location_ID());
            if (order.GetAD_User_ID() != 0)
            {
                retDic["AD_User_ID"] = Util.GetValueOfString(order.GetAD_User_ID());
            }
            if (order.GetBill_User_ID() != 0)
            {
                retDic["Bill_User_ID"] = Util.GetValueOfString(order.GetBill_User_ID());
            }
            retDic["M_PriceList_ID"]   = Util.GetValueOfString(order.GetM_PriceList_ID());
            retDic["PaymentRule"]      = order.GetPaymentRule();
            retDic["C_PaymentTerm_ID"] = Util.GetValueOfString(order.GetC_PaymentTerm_ID());
            //mTab.setValue ("DeliveryRule", X_C_Order.DELIVERYRULE_Manual);
            retDic["Bill_Location_ID"] = Util.GetValueOfString(order.GetBill_Location_ID());
            retDic["InvoiceRule"]      = order.GetInvoiceRule();
            retDic["PaymentRule"]      = order.GetPaymentRule();
            retDic["DeliveryViaRule"]  = order.GetDeliveryViaRule();
            retDic["FreightCostRule"]  = order.GetFreightCostRule();
            retDic["ID"] = Util.GetValueOfString(order.Get_ID());
            //retDic["DateOrdered"] = Convert.ToDateTime(order.GetDateOrdered()).ToLocalTime().ToUniversalTime();
            retDic["DateOrdered"]     = DateTime.SpecifyKind(order.GetDateOrdered().Value, DateTimeKind.Utc);
            retDic["DateAcct"]        = Util.GetValueOfString(order.GetDateAcct());
            retDic["POReference"]     = order.GetPOReference();
            retDic["AD_Org_ID"]       = Util.GetValueOfString(order.GetAD_Org_ID());
            retDic["DeliveryRule"]    = order.GetDeliveryRule();
            retDic["DeliveryViaRule"] = order.GetDeliveryViaRule();
            retDic["M_Shipper_ID"]    = Util.GetValueOfString(order.GetM_Shipper_ID());
            retDic["FreightAmt"]      = Util.GetValueOfString(order.GetFreightAmt());
            retDic["AD_OrgTrx_ID"]    = Util.GetValueOfString(order.GetAD_OrgTrx_ID());
            retDic["C_Activity_ID"]   = Util.GetValueOfString(order.GetC_Activity_ID());
            retDic["C_Campaign_ID"]   = Util.GetValueOfString(order.GetC_Campaign_ID());
            retDic["C_Project_ID"]    = Util.GetValueOfString(order.GetC_Project_ID());
            retDic["User1_ID"]        = Util.GetValueOfString(order.GetUser1_ID());
            retDic["User2_ID"]        = Util.GetValueOfString(order.GetUser2_ID());
            retDic["M_Warehouse_ID"]  = Util.GetValueOfString(order.GetM_Warehouse_ID());
            retDic["Orig_Order_ID"]   = Util.GetValueOfString(order.GetOrig_Order_ID());
            retDic["Orig_InOut_ID"]   = Util.GetValueOfString(order.GetOrig_InOut_ID());
            //Added By Amit
            retDic["IsSOTrx"]                = Util.GetValueOfString(order.IsSOTrx());
            retDic["IsReturnTrx"]            = Util.GetValueOfString(order.IsReturnTrx());
            retDic["C_Payment_ID"]           = Util.GetValueOfString(order.GetPaymentMethod());
            retDic["VA009_PaymentMethod_ID"] = Util.GetValueOfString(order.GetVA009_PaymentMethod_ID());
            retDic["SalesRep_ID"]            = Util.GetValueOfString(order.GetSalesRep_ID());
            retDic["C_ProjectRef_ID"]        = Util.GetValueOfString(order.GetC_ProjectRef_ID());
            retDic["PriorityRule"]           = Util.GetValueOfString(order.GetPriorityRule());


            if (order.GetC_Currency_ID() != 0)
            {
                retDic["C_Currency_ID"] = Util.GetValueOfString(order.GetC_Currency_ID());
            }
            else
            {
                retDic["C_Currency_ID"] = "0";
            }
            //End
            // added by vivek on 09/10/2017 advised by pradeep to set drop ship checkbox value
            retDic["IsDropShip"] = Util.GetValueOfBool(order.IsDropShip()) ? "Y" : "N";

            // Added by Bharat on 30 Jan 2018 to set Inco Term from Order

            if (order.Get_ColumnIndex("C_IncoTerm_ID") > 0)
            {
                retDic["C_IncoTerm_ID"] = Util.GetValueOfString(order.GetC_IncoTerm_ID());
            }

            if (Env.IsModuleInstalled("VA077_"))
            {
                retDic["VA077_HistoricContractDate"]   = Util.GetValueOfString(order.Get_Value("VA077_HistoricContractDate"));
                retDic["VA077_ChangeStartDate"]        = Util.GetValueOfString(order.Get_Value("VA077_ChangeStartDate"));
                retDic["VA077_ContractCPStartDate"]    = Util.GetValueOfString(order.Get_Value("VA077_ContractCPStartDate"));
                retDic["VA077_ContractCPEndDate"]      = Util.GetValueOfString(order.Get_Value("VA077_ContractCPEndDate"));
                retDic["VA077_PartialAmtCatchUp"]      = Util.GetValueOfString(order.Get_Value("VA077_PartialAmtCatchUp"));
                retDic["VA077_OldAnnualContractTotal"] = Util.GetValueOfString(order.Get_Value("VA077_OldAnnualContractTotal"));
                retDic["VA077_AdditionalAnnualCharge"] = Util.GetValueOfString(order.Get_Value("VA077_AdditionalAnnualCharge"));
                retDic["VA077_NewAnnualContractTotal"] = Util.GetValueOfString(order.Get_Value("VA077_NewAnnualContractTotal"));
                retDic["VA077_SalesCoWorker"]          = Util.GetValueOfString(order.Get_Value("VA077_SalesCoWorker"));
                retDic["VA077_SalesCoWorkerPer"]       = Util.GetValueOfString(order.Get_Value("VA077_SalesCoWorkerPer"));
                retDic["VA077_TotalMarginAmt"]         = Util.GetValueOfString(order.Get_Value("VA077_TotalMarginAmt"));
                retDic["VA077_TotalPurchaseAmt"]       = Util.GetValueOfString(order.Get_Value("VA077_TotalPurchaseAmt"));
                retDic["VA077_TotalSalesAmt"]          = Util.GetValueOfString(order.Get_Value("VA077_TotalSalesAmt"));
                retDic["VA077_MarginPercent"]          = Util.GetValueOfString(order.Get_Value("VA077_MarginPercent"));
            }

            return(retDic);
        }
コード例 #4
0
        }       //	doIt

        /// <summary>
        /// Process Expense Line
        /// </summary>
        /// <param name="te">header</param>
        /// <param name="tel">line</param>
        /// <param name="bp">bp</param>
        private void ProcessLine(MTimeExpense te, MTimeExpenseLine tel, MBPartner bp)
        {
            if (_order == null)
            {
                log.Info("New Order for " + bp + ", Project=" + tel.GetC_Project_ID());
                _order = new MOrder(GetCtx(), 0, Get_TrxName());
                _order.SetAD_Org_ID(tel.GetAD_Org_ID());
                _order.SetC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
                //
                _order.SetBPartner(bp);
                if (_order.GetC_BPartner_Location_ID() == 0)
                {
                    log.Log(Level.SEVERE, "No BP Location: " + bp);
                    AddLog(0, te.GetDateReport(),
                           null, "No Location: " + te.GetDocumentNo() + " " + bp.GetName());
                    _order = null;
                    return;
                }
                _order.SetM_Warehouse_ID(te.GetM_Warehouse_ID());

                ////Added By Arpit asked by Surya Sir..................29-12-2015
                //_order.SetSalesRep_ID(GetCtx().GetAD_User_ID());
                //End
                if (tel.GetC_Activity_ID() != 0)
                {
                    _order.SetC_Activity_ID(tel.GetC_Activity_ID());
                }
                if (tel.GetC_Campaign_ID() != 0)
                {
                    _order.SetC_Campaign_ID(tel.GetC_Campaign_ID());
                }
                if (tel.GetC_Project_ID() != 0)
                {
                    _order.SetC_Project_ID(tel.GetC_Project_ID());
                    //	Optionally Overwrite BP Price list from Project
                    MProject project = new MProject(GetCtx(), tel.GetC_Project_ID(), Get_TrxName());
                    if (project.GetM_PriceList_ID() != 0)
                    {
                        _order.SetM_PriceList_ID(project.GetM_PriceList_ID());
                    }
                }
                _order.SetSalesRep_ID(te.GetDoc_User_ID());
                //
                if (!_order.Save())
                {
                    throw new Exception("Cannot save Order");
                }
            }
            else
            {
                //	Update Header info
                if (tel.GetC_Activity_ID() != 0 && tel.GetC_Activity_ID() != _order.GetC_Activity_ID())
                {
                    _order.SetC_Activity_ID(tel.GetC_Activity_ID());
                }
                if (tel.GetC_Campaign_ID() != 0 && tel.GetC_Campaign_ID() != _order.GetC_Campaign_ID())
                {
                    _order.SetC_Campaign_ID(tel.GetC_Campaign_ID());
                }
                if (!_order.Save())
                {
                    new Exception("Cannot save Order");
                }
            }

            //	OrderLine
            MOrderLine ol = new MOrderLine(_order);

            //
            if (tel.GetM_Product_ID() != 0)
            {
                ol.SetM_Product_ID(tel.GetM_Product_ID(),
                                   tel.GetC_UOM_ID());
            }
            if (tel.GetS_ResourceAssignment_ID() != 0)
            {
                ol.SetS_ResourceAssignment_ID(tel.GetS_ResourceAssignment_ID());
            }
            // Set charge ID
            if (tel.GetC_Charge_ID() != 0)
            {
                ol.SetC_Charge_ID(tel.GetC_Charge_ID());
                ol.SetPriceActual(tel.GetExpenseAmt());
                ol.SetQty(tel.GetQty());
            }
            ol.SetQty(tel.GetQtyInvoiced());                    //
            ol.SetDescription(tel.GetDescription());
            //
            ol.SetC_Project_ID(tel.GetC_Project_ID());
            ol.SetC_ProjectPhase_ID(tel.GetC_ProjectPhase_ID());
            ol.SetC_ProjectTask_ID(tel.GetC_ProjectTask_ID());
            ol.SetC_Activity_ID(tel.GetC_Activity_ID());
            ol.SetC_Campaign_ID(tel.GetC_Campaign_ID());
            //
            Decimal price = tel.GetPriceInvoiced();     //

            if (price.CompareTo(Env.ZERO) != 0)
            {
                if (tel.GetC_Currency_ID() != _order.GetC_Currency_ID())
                {
                    price = MConversionRate.Convert(GetCtx(), price,
                                                    tel.GetC_Currency_ID(), _order.GetC_Currency_ID(),
                                                    _order.GetAD_Client_ID(), _order.GetAD_Org_ID());
                }
                ol.SetPrice(price);
            }
            else
            {
                ol.SetPrice();
            }
            if (tel.GetC_UOM_ID() != 0 && ol.GetC_UOM_ID() == 0)
            {
                ol.SetC_UOM_ID(tel.GetC_UOM_ID());
            }
            ol.SetTax();
            if (!ol.Save())
            {
                throw new Exception("Cannot save Order Line");
            }
            //	Update TimeExpense Line
            tel.SetC_OrderLine_ID(ol.GetC_OrderLine_ID());
            if (tel.Save())
            {
                log.Fine("Updated " + tel + " with C_OrderLine_ID");
            }
            else
            {
                log.Log(Level.SEVERE, "Not Updated " + tel + " with C_OrderLine_ID");
            }
        }       //	processLine
コード例 #5
0
        }   //	doIt

        /// <summary>
        /// Process Expense Line
        /// </summary>
        /// <param name="te">header</param>
        /// <param name="tel">line</param>
        /// <param name="bp">bp</param>
        private void ProcessLine(MTimeExpense te, MTimeExpenseLine tel, MBPartner bp)
        {
            if (_order == null)
            {
                log.Info("New Order for " + bp + ", Project=" + tel.GetC_Project_ID());
                _order = new MOrder(GetCtx(), 0, Get_TrxName());
                _order.SetAD_Org_ID(tel.GetAD_Org_ID());
                _order.SetC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
                //
                _order.SetBPartner(bp);
                if (_order.GetC_BPartner_Location_ID() == 0)
                {
                    log.Log(Level.SEVERE, "No BP Location: " + bp);
                    AddLog(0, te.GetDateReport(),
                           null, "No Location: " + te.GetDocumentNo() + " " + bp.GetName());
                    _order = null;
                    return;
                }
                _order.SetM_Warehouse_ID(te.GetM_Warehouse_ID());
                //Bhupendra: Add payment term
                // to check for if payment term is null
                if (bp.GetC_PaymentTerm_ID() == 0)
                {
                    // set the default payment method as check
                    int payTerm = GetPaymentTerm();
                    if (payTerm <= 0)
                    {
                        message = Msg.GetMsg(GetCtx(), "IsActivePaymentTerm");
                        return;
                    }
                    else
                    {
                        _order.SetC_PaymentTerm_ID(payTerm);
                    }
                }
                else
                {
                    //check weather paymentterm is active or not
                    if (Util.GetValueOfString(DB.ExecuteScalar("SELECT IsActive FROM C_PaymentTerm WHERE C_PaymentTerm_ID=" + bp.GetC_PaymentTerm_ID(), null, Get_Trx())).Equals("Y"))
                    {
                        _order.SetC_PaymentTerm_ID(bp.GetC_PaymentTerm_ID());
                    }
                    else
                    {
                        message = Msg.GetMsg(GetCtx(), "IsActivePaymentTerm");
                        return;
                    }
                }
                // Bhupendra: added a cond to check for payment method if null
                // Added by mohit - to set payment method and sales rep id.
                if (bp.GetVA009_PaymentMethod_ID() == 0)
                {
                    // set the default payment method as check
                    int paymethod = GetPaymentMethod();
                    if (paymethod <= 0)
                    {
                        message = Msg.GetMsg(GetCtx(), "IsActivePaymentMethod");
                        return;
                    }
                    else
                    {
                        _order.SetVA009_PaymentMethod_ID(paymethod);
                    }
                }
                else
                {
                    //check weather the PaymentMethod is active or not
                    if (Util.GetValueOfString(DB.ExecuteScalar("SELECT IsActive FROM VA009_PaymentMethod WHERE VA009_PaymentMethod_ID=" + bp.GetVA009_PaymentMethod_ID(), null, Get_Trx())).Equals("Y"))
                    {
                        _order.SetVA009_PaymentMethod_ID(bp.GetVA009_PaymentMethod_ID());
                    }
                    else
                    {
                        message = Msg.GetMsg(GetCtx(), "IsActivePaymentMethod");
                        return;
                    }
                }
                _order.SetSalesRep_ID(te.GetDoc_User_ID());

                ////Added By Arpit asked by Surya Sir..................29-12-2015
                //_order.SetSalesRep_ID(GetCtx().GetAD_User_ID());
                //End
                if (tel.GetC_Activity_ID() != 0)
                {
                    _order.SetC_Activity_ID(tel.GetC_Activity_ID());
                }
                if (tel.GetC_Campaign_ID() != 0)
                {
                    _order.SetC_Campaign_ID(tel.GetC_Campaign_ID());
                }
                if (tel.GetC_Project_ID() != 0)
                {
                    _order.SetC_Project_ID(tel.GetC_Project_ID());
                    //	Optionally Overwrite BP Price list from Project
                    MProject project = new MProject(GetCtx(), tel.GetC_Project_ID(), Get_TrxName());
                    if (project.GetM_PriceList_ID() != 0)
                    {
                        //check weather the PriceList is active or not
                        if (Util.GetValueOfString(DB.ExecuteScalar("SELECT IsActive FROM M_PriceList WHERE M_PriceList_ID=" + project.GetM_PriceList_ID(), null, Get_Trx())).Equals("Y"))
                        {
                            _order.SetM_PriceList_ID(project.GetM_PriceList_ID());
                        }
                        else
                        {
                            message = Msg.GetMsg(GetCtx(), "IsActivePriceList");
                            return;
                        }
                    }
                }
                else
                {
                    if (bp.GetM_PriceList_ID() != 0)
                    {
                        if (Util.GetValueOfString(DB.ExecuteScalar("SELECT IsActive FROM M_PriceList WHERE M_PriceList_ID=" + bp.GetM_PriceList_ID(), null, Get_Trx())).Equals("Y"))
                        {
                            _order.SetM_PriceList_ID(bp.GetM_PriceList_ID());
                        }
                        else
                        {
                            message = Msg.GetMsg(GetCtx(), "IsActivePriceList");
                            return;
                        }
                    }
                }
                _order.SetSalesRep_ID(te.GetDoc_User_ID());
                //
                if (!_order.Save())
                {
                    Rollback();
                    ValueNamePair pp = VLogger.RetrieveError();
                    if (pp != null)
                    {
                        message = pp.GetName();
                        //if GetName is Empty then it will check GetValue
                        if (string.IsNullOrEmpty(message))
                        {
                            message = Msg.GetMsg("", pp.GetValue());
                        }
                    }
                    if (string.IsNullOrEmpty(message))
                    {
                        message = Msg.GetMsg(GetCtx(), "CantSaveOrder");
                    }
                    return;
                    //throw new Exception("Cannot save Order");
                }
            }
            else
            {
                //	Update Header info
                if (tel.GetC_Activity_ID() != 0 && tel.GetC_Activity_ID() != _order.GetC_Activity_ID())
                {
                    _order.SetC_Activity_ID(tel.GetC_Activity_ID());
                }
                if (tel.GetC_Campaign_ID() != 0 && tel.GetC_Campaign_ID() != _order.GetC_Campaign_ID())
                {
                    _order.SetC_Campaign_ID(tel.GetC_Campaign_ID());
                }
                if (!_order.Save())
                {
                    Rollback();
                    //get error message from ValueNamePair
                    ValueNamePair pp = VLogger.RetrieveError();
                    if (pp != null)
                    {
                        message = pp.GetName();
                        //if GetName is Empty then it will check GetValue
                        if (string.IsNullOrEmpty(message))
                        {
                            message = Msg.GetMsg("", pp.GetValue());
                        }
                    }
                    //it will check message is null or not
                    if (string.IsNullOrEmpty(message))
                    {
                        message = Msg.GetMsg(GetCtx(), "CantSaveOrder");
                    }
                    return;
                    //new Exception("Cannot save Order");
                }
            }

            //	OrderLine
            MOrderLine ol = new MOrderLine(_order);

            //
            if (tel.GetM_Product_ID() != 0)
            {
                ol.SetM_Product_ID(tel.GetM_Product_ID(),
                                   tel.GetC_UOM_ID());
            }
            if (tel.GetS_ResourceAssignment_ID() != 0)
            {
                ol.SetS_ResourceAssignment_ID(tel.GetS_ResourceAssignment_ID());
            }
            // Set charge ID
            if (tel.GetC_Charge_ID() != 0)
            {
                ol.SetC_Charge_ID(tel.GetC_Charge_ID());
                ol.SetPriceActual(tel.GetExpenseAmt());
                ol.SetQty(tel.GetQty());
            }
            ol.SetQty(tel.GetQtyInvoiced());        //
            ol.SetDescription(tel.GetDescription());
            //
            ol.SetC_Project_ID(tel.GetC_Project_ID());
            ol.SetC_ProjectPhase_ID(tel.GetC_ProjectPhase_ID());
            ol.SetC_ProjectTask_ID(tel.GetC_ProjectTask_ID());
            ol.SetC_Activity_ID(tel.GetC_Activity_ID());
            ol.SetC_Campaign_ID(tel.GetC_Campaign_ID());
            //
            Decimal price = tel.GetPriceInvoiced(); //

            if (price.CompareTo(Env.ZERO) != 0)
            {
                if (tel.GetC_Currency_ID() != _order.GetC_Currency_ID())
                {
                    price = MConversionRate.Convert(GetCtx(), price,
                                                    tel.GetC_Currency_ID(), _order.GetC_Currency_ID(),
                                                    _order.GetAD_Client_ID(), _order.GetAD_Org_ID());
                }
                ol.SetPrice(price);
                // added by Bhupendra to set the entered price
                ol.SetPriceEntered(price);
            }
            else
            {
                ol.SetPrice();
            }
            if (tel.GetC_UOM_ID() != 0 && ol.GetC_UOM_ID() == 0)
            {
                ol.SetC_UOM_ID(tel.GetC_UOM_ID());
            }
            ol.SetTax();
            if (!ol.Save())
            {
                Rollback();
                //get error message from ValueNamePair
                ValueNamePair pp = VLogger.RetrieveError();
                if (pp != null)
                {
                    message = pp.GetName();
                    //if GetName is Empty then it will check GetValue
                    if (string.IsNullOrEmpty(message))
                    {
                        message = Msg.GetMsg("", pp.GetValue());
                    }
                }
                //it will check message is null or not
                if (string.IsNullOrEmpty(message))
                {
                    message = Msg.GetMsg(GetCtx(), "CantSaveOrderLine");
                }
                return;
                //throw new Exception("Cannot save Order Line");
            }
            //	Update TimeExpense Line
            tel.SetC_OrderLine_ID(ol.GetC_OrderLine_ID());
            if (tel.Save())
            {
                log.Fine("Updated " + tel + " with C_OrderLine_ID");
            }
            else
            {
                log.Log(Level.SEVERE, "Not Updated " + tel + " with C_OrderLine_ID");
            }
        }   //	processLine
コード例 #6
0
        /// <summary>
        /// Create PO for Vendor
        /// </summary>
        /// <param name="C_BPartner_ID">vendor</param>
        /// <param name="so">sales order</param>
        /// <returns>MOrder</returns>
        public MOrder CreatePOForVendor(int C_BPartner_ID, MOrder so, string _shipDrop)
        {
            MOrder po = new MOrder(GetCtx(), 0, Get_TrxName());

            po.SetClientOrg(so.GetAD_Client_ID(), so.GetAD_Org_ID());
            po.SetRef_Order_ID(so.GetC_Order_ID());
            po.SetIsSOTrx(false);
            // method edited to set unreleased document type for PO
            po.SetC_DocTypeTarget_ID(false);
            //
            po.SetDescription(so.GetDescription());
            po.SetPOReference(so.GetDocumentNo());
            po.SetPriorityRule(so.GetPriorityRule());
            po.SetSalesRep_ID(so.GetSalesRep_ID());
            // Code Commented by Vivek Kumar on 20/09/2017 Assigned By Pradeep for drop shipment
            //po.SetM_Warehouse_ID(so.GetM_Warehouse_ID());
            //	Set Vendor
            MBPartner vendor = new MBPartner(GetCtx(), C_BPartner_ID, Get_TrxName());

            if (Env.IsModuleInstalled("VA009_"))
            {
                // Set PO Payment Method from Vendor
                if (Util.GetValueOfInt(vendor.GetVA009_PO_PaymentMethod_ID()) > 0)
                {
                    po.SetVA009_PaymentMethod_ID(Util.GetValueOfInt(vendor.GetVA009_PO_PaymentMethod_ID()));
                }
                else
                {
                    if (string.IsNullOrEmpty(messageErrorOrSetting.ToString()))
                    {
                        messageErrorOrSetting.Append(Msg.GetMsg(GetCtx(), "VIS_PaymentMethodNotDefined") + " : " + vendor.GetName());
                    }
                    else
                    {
                        messageErrorOrSetting.Append(" , " + Msg.GetMsg(GetCtx(), "VIS_PaymentMethodNotDefined") + " : " + vendor.GetName());
                    }
                    po = null;
                    return(po);
                }
            }

            //JID_1252: If Vendor do not have Po Pricelist bind. System should give message.
            if (vendor.GetPO_PriceList_ID() > 0)
            {
                po.SetM_PriceList_ID(vendor.GetPO_PriceList_ID());
            }
            else
            {
                if (string.IsNullOrEmpty(messageErrorOrSetting.ToString()))
                {
                    messageErrorOrSetting.Append(Msg.GetMsg(GetCtx(), "VIS_VendorPrcListNotDefine") + " : " + vendor.GetName());
                }
                else
                {
                    messageErrorOrSetting.Append(" , " + Msg.GetMsg(GetCtx(), "VIS_VendorPrcListNotDefine") + " : " + vendor.GetName());
                }
                po = null;
                return(po);
            }

            // JID_1262: If Payment Term is not bind BP, BP Group and No Default Payment Term. System do not create PO neither give message.
            if (vendor.GetPO_PaymentTerm_ID() > 0)
            {
                po.SetC_PaymentTerm_ID(vendor.GetPO_PaymentTerm_ID());
            }
            else
            {
                if (string.IsNullOrEmpty(messageErrorOrSetting.ToString()))
                {
                    messageErrorOrSetting.Append(Msg.GetMsg(GetCtx(), "VIS_VendorPaytemNotDefine") + " : " + vendor.GetName());
                }
                else
                {
                    messageErrorOrSetting.Append(" , " + Msg.GetMsg(GetCtx(), "VIS_VendorPaytemNotDefine") + " : " + vendor.GetName());
                }
                po = null;
                return(po);
            }

            po.SetBPartner(vendor);

            // Code Commented by Vivek Kumar on 20/09/2017 Assigned By Pradeep  for drop shipment
            //	Drop Ship
            //po.SetIsDropShip(so.IsDropShip());
            //if (so.IsDropShip())
            //{
            //    po.SetShip_BPartner_ID(so.GetC_BPartner_ID());
            //    po.SetShip_Location_ID(so.GetC_BPartner_Location_ID());
            //    po.SetShip_User_ID(so.GetAD_User_ID());
            //}

            if (_shipDrop == "Y")
            {
                po.SetIsDropShip(true);
                po.SetShipToPartner_ID(so.GetC_BPartner_ID());
                po.SetShipToLocation_ID(so.GetC_BPartner_Location_ID());
                int _Warehouse_ID = Util.GetValueOfInt(DB.ExecuteScalar("Select M_WareHouse_ID From M_Warehouse Where AD_Org_ID=" + so.GetAD_Org_ID() + " AND Isdropship='Y' AND IsActive='Y'"));
                if (_Warehouse_ID >= 0)
                {
                    po.SetM_Warehouse_ID(_Warehouse_ID);
                }
            }

            // Added by Bharat on 29 Jan 2018 to set Inco Term from Order

            if (po.Get_ColumnIndex("C_IncoTerm_ID") > 0)
            {
                po.SetC_IncoTerm_ID(so.GetC_IncoTerm_ID());
            }
            //	References
            po.SetC_Activity_ID(so.GetC_Activity_ID());
            po.SetC_Campaign_ID(so.GetC_Campaign_ID());
            po.SetC_Project_ID(so.GetC_Project_ID());
            po.SetUser1_ID(so.GetUser1_ID());
            po.SetUser2_ID(so.GetUser2_ID());
            //
            po.Save();
            return(po);
        }
コード例 #7
0
        /// <summary>
        /// Create PO for Vendor
        /// </summary>
        /// <param name="C_BPartner_ID">vendor</param>
        /// <param name="so">sales order</param>
        /// <returns>MOrder</returns>
        public MOrder CreatePOForVendor(int C_BPartner_ID, MOrder so, string _shipDrop)
        {
            MOrder po = new MOrder(GetCtx(), 0, Get_TrxName());

            po.SetClientOrg(so.GetAD_Client_ID(), so.GetAD_Org_ID());
            po.SetRef_Order_ID(so.GetC_Order_ID());
            po.SetIsSOTrx(false);
            // method edited to set unreleased document type for PO
            po.SetC_DocTypeTarget_ID(false);
            //
            po.SetDescription(so.GetDescription());
            po.SetPOReference(so.GetDocumentNo());
            po.SetPriorityRule(so.GetPriorityRule());
            po.SetSalesRep_ID(so.GetSalesRep_ID());
            // Code Commented by Vivek Kumar on 20/09/2017 Assigned By Pradeep for drop shipment
            //po.SetM_Warehouse_ID(so.GetM_Warehouse_ID());
            //	Set Vendor
            MBPartner vendor = new MBPartner(GetCtx(), C_BPartner_ID, Get_TrxName());

            if (Env.IsModuleInstalled("VA009_"))
            {
                // Set PO Payment Method from Vendor
                if (Util.GetValueOfInt(vendor.GetVA009_PO_PaymentMethod_ID()) > 0)
                {
                    po.SetVA009_PaymentMethod_ID(Util.GetValueOfInt(vendor.GetVA009_PO_PaymentMethod_ID()));
                }
                else
                {
                    if (string.IsNullOrEmpty(messageErrorOrSetting.ToString()))
                    {
                        messageErrorOrSetting.Append(Msg.GetMsg(GetCtx(), "VIS_PaymentMethodNotDefined") + " : " + vendor.GetName());
                    }
                    else
                    {
                        messageErrorOrSetting.Append(" , " + Msg.GetMsg(GetCtx(), "VIS_PaymentMethodNotDefined") + " : " + vendor.GetName());
                    }
                    po = null;
                    return(po);
                }
            }

            //JID_1252: If Vendor do not have Po Pricelist bind. System should give message.
            if (vendor.GetPO_PriceList_ID() > 0)
            {
                po.SetM_PriceList_ID(vendor.GetPO_PriceList_ID());
            }
            else
            {
                if (string.IsNullOrEmpty(messageErrorOrSetting.ToString()))
                {
                    messageErrorOrSetting.Append(Msg.GetMsg(GetCtx(), "VIS_VendorPrcListNotDefine") + " : " + vendor.GetName());
                }
                else
                {
                    messageErrorOrSetting.Append(" , " + Msg.GetMsg(GetCtx(), "VIS_VendorPrcListNotDefine") + " : " + vendor.GetName());
                }
                po = null;
                return(po);
            }

            // JID_1262: If Payment Term is not bind BP, BP Group and No Default Payment Term. System do not create PO neither give message.
            if (vendor.GetPO_PaymentTerm_ID() > 0)
            {
                po.SetC_PaymentTerm_ID(vendor.GetPO_PaymentTerm_ID());
            }
            else
            {
                if (string.IsNullOrEmpty(messageErrorOrSetting.ToString()))
                {
                    messageErrorOrSetting.Append(Msg.GetMsg(GetCtx(), "VIS_VendorPaytemNotDefine") + " : " + vendor.GetName());
                }
                else
                {
                    messageErrorOrSetting.Append(" , " + Msg.GetMsg(GetCtx(), "VIS_VendorPaytemNotDefine") + " : " + vendor.GetName());
                }
                po = null;
                return(po);
            }

            po.SetBPartner(vendor);

            // Code Commented by Vivek Kumar on 20/09/2017 Assigned By Pradeep  for drop shipment
            //	Drop Ship
            //po.SetIsDropShip(so.IsDropShip());
            //if (so.IsDropShip())
            //{
            //    po.SetShip_BPartner_ID(so.GetC_BPartner_ID());
            //    po.SetShip_Location_ID(so.GetC_BPartner_Location_ID());
            //    po.SetShip_User_ID(so.GetAD_User_ID());
            //}

            if (_shipDrop == "Y")
            {
                po.SetIsDropShip(true);
                po.SetShipToPartner_ID(so.GetC_BPartner_ID());
                po.SetShipToLocation_ID(so.GetC_BPartner_Location_ID());
                int _Warehouse_ID = Util.GetValueOfInt(DB.ExecuteScalar("Select M_WareHouse_ID From M_Warehouse Where AD_Org_ID=" + so.GetAD_Org_ID() + " AND Isdropship='Y' AND IsActive='Y'"));
                if (_Warehouse_ID >= 0)
                {
                    po.SetM_Warehouse_ID(_Warehouse_ID);
                }
            }

            // Added by Bharat on 29 Jan 2018 to set Inco Term from Order

            if (po.Get_ColumnIndex("C_IncoTerm_ID") > 0)
            {
                po.SetC_IncoTerm_ID(so.GetC_IncoTerm_ID());
            }
            //	References
            po.SetC_Activity_ID(so.GetC_Activity_ID());
            po.SetC_Campaign_ID(so.GetC_Campaign_ID());
            po.SetC_Project_ID(so.GetC_Project_ID());
            po.SetUser1_ID(so.GetUser1_ID());
            po.SetUser2_ID(so.GetUser2_ID());

            //Set VA077 values on header level
            if (Env.IsModuleInstalled("VA077_"))
            {
                //Get the org count of legal entity org
                string sql    = @"SELECT Count(AD_Org_ID) FROM AD_Org WHERE IsActive='Y' 
                           AND (IsProfitCenter ='Y' OR IsCostCenter ='Y') AND 
                           AD_Client_Id=" + so.GetAD_Client_ID() + @" AND LegalEntityOrg = " + so.GetAD_Org_ID();
                int    result = Util.GetValueOfInt(DB.ExecuteScalar(sql));
                if (result > 0)
                {
                    po.SetVA077_IsLegalEntity(true);
                }
            }

            // Handle error done by rakesh kumar on 17/Mar/2021
            if (!po.Save())
            {
                ValueNamePair pp  = VLogger.RetrieveError();
                string        msg = string.Empty;
                if (pp != null)
                {
                    msg = pp.GetName();
                    //if GetName is Empty then it will check GetValue
                    if (string.IsNullOrEmpty(msg))
                    {
                        msg = Msg.GetMsg("", pp.GetValue());
                    }
                }
                if (string.IsNullOrEmpty(msg))
                {
                    msg = Msg.GetMsg(GetCtx(), "RecordNotSaved");
                }


                log.Info("CreatePOfromSO : Not Saved. Error Value : " + msg);
                AddLog(0, null, null, msg + " : @DocumentNo@ : " + so.GetDocumentNo());
            }
            return(po);
        }