示例#1
0
        protected virtual void EPExpenseClaimDetails_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            EPExpenseClaimDetails row = (EPExpenseClaimDetails)e.Row;

            if (row != null)
            {
                EPExpenseClaim claim = (EPExpenseClaim)PXSelect <EPExpenseClaim, Where <EPExpenseClaim.refNbr, Equal <Required <EPExpenseClaimDetails.refNbr> > > > .SelectSingleBound(this, new object[] { null }, row.RefNbr);

                bool enabledApprovalReceipt   = PXAccess.FeatureInstalled <FeaturesSet.approvalWorkflow>() && epsetup.Current.ClaimDetailsAssignmentMapID != null;
                bool legacyClaim              = row.LegacyReceipt == true && !String.IsNullOrEmpty(row.RefNbr);
                bool enabledEditReceipt       = (row.Hold == true || !enabledApprovalReceipt) && !legacyClaim;
                bool enabledRefNbr            = true;
                bool enabledEmployeeAndBranch = enabledEditReceipt && !(row.ClaimCuryInfoID == null && cache.AllowUpdate && !string.IsNullOrEmpty(row.RefNbr));
                bool enabledFinancialDetails  = (row.Rejected != true) && (row.Released != true);
                bool NonProject    = (CurrentContract.SelectSingle()?.ContractCD ?? PMSetup.DefaultNonProjectCode).Trim() == PMSetup.DefaultNonProjectCode;
                bool claimReleased = false;
                if (claim != null)
                {
                    bool enabledEditClaim = (row.HoldClaim == true);
                    enabledEditReceipt       = enabledEditReceipt && enabledEditClaim;
                    enabledRefNbr            = enabledEditClaim;
                    enabledEmployeeAndBranch = false;
                    enabledFinancialDetails  = enabledFinancialDetails && enabledEditClaim;
                    claimReleased            = claim.Released == true;
                }
                enabledRefNbr = enabledRefNbr && row.LegacyReceipt == false;

                Approval.AllowSelect = enabledApprovalReceipt;
                Delete.SetEnabled(enabledEditReceipt && claim == null);
                PXUIFieldAttribute.SetEnabled(cache, row, enabledEditReceipt);
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.claimDetailID>(cache, row, true);
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.refNbr>(cache, row, enabledRefNbr);
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.employeeID>(cache, row, enabledEmployeeAndBranch);
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.branchID>(cache, row, enabledEmployeeAndBranch);
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.expenseAccountID>(cache, row, enabledFinancialDetails);
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.expenseSubID>(cache, row, enabledFinancialDetails);
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.salesAccountID>(cache, row, enabledFinancialDetails && (row.Billable == true));
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.salesSubID>(cache, row, enabledFinancialDetails && (row.Billable == true));
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.taxCategoryID>(cache, row, enabledFinancialDetails);
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.customerID>(cache, row, NonProject && !claimReleased);
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.customerLocationID>(cache, row, NonProject && !claimReleased);
                action.SetEnabled("Submit", cache.GetStatus(row) != PXEntryStatus.Inserted && row.Hold == true);

                if (row.ContractID != null && (bool)row.Billable && row.TaskID != null)
                {
                    PMTask task = PXSelect <PMTask, Where <PMTask.taskID, Equal <Required <PMTask.taskID> > > > .Select(this, row.TaskID);

                    if (task != null && !(bool)task.VisibleInAP)
                    {
                        cache.RaiseExceptionHandling <EPExpenseClaimDetails.taskID>(e.Row, task.TaskCD, new PXSetPropertyException(PM.Messages.TaskInvisibleInModule, task.TaskCD, GL.BatchModule.AP));
                    }
                }

                CurrencyInfo info = (CurrencyInfo)PXSelect <CurrencyInfo, Where <CurrencyInfo.curyInfoID, Equal <Current <EPExpenseClaimDetails.curyInfoID> > > > .SelectSingleBound(this, new object[] { row });

                if (info != null && info.CuryRateTypeID != null && info.CuryEffDate != null && row.ExpenseDate != null && info.CuryEffDate < row.ExpenseDate)
                {
                    CurrencyRateType ratetype = (CurrencyRateType)PXSelectorAttribute.Select <CurrencyInfo.curyRateTypeID>(currencyinfo.Cache, info);
                    if (ratetype != null && ratetype.RateEffDays > 0 &&
                        ((TimeSpan)(row.ExpenseDate - info.CuryEffDate)).Days > ratetype.RateEffDays)
                    {
                        PXRateIsNotDefinedForThisDateException exc = new PXRateIsNotDefinedForThisDateException(info.CuryRateTypeID, info.BaseCuryID, info.CuryID, (DateTime)row.ExpenseDate);
                        cache.RaiseExceptionHandling <EPExpenseClaimDetails.expenseDate>(e.Row, ((EPExpenseClaimDetails)e.Row).ExpenseDate, exc);
                    }
                }
                string message = PXUIFieldAttribute.GetError <CurrencyInfo.curyID>(currencyinfo.Cache, info);
                if (string.IsNullOrEmpty(message) && info != null && info.CuryRate == null)
                {
                    message = CM.Messages.RateNotFound;
                }
                if (string.IsNullOrEmpty(message))
                {
                    cache.RaiseExceptionHandling <EPExpenseClaimDetails.curyID>(e.Row, null, null);
                }
                else
                {
                    cache.RaiseExceptionHandling <EPExpenseClaimDetails.curyID>(e.Row, null, new PXSetPropertyException(message, PXErrorLevel.Warning));
                }

                bool allowEdit = this.Accessinfo.UserID == row.CreatedByID;

                if (Employee.Current != null)
                {
                    if (!allowEdit && this.Accessinfo.UserID == Employee.Current.UserID)
                    {
                        allowEdit = true;
                    }

                    if (!allowEdit)
                    {
                        EPWingman wingMan = PXSelectJoin <EPWingman,
                                                          InnerJoin <EPEmployee, On <EPWingman.wingmanID, Equal <EPEmployee.bAccountID> > >,
                                                          Where <EPWingman.employeeID, Equal <Required <EPWingman.employeeID> >,
                                                                 And <EPEmployee.userID, Equal <Required <EPEmployee.userID> > > > > .Select(this, row.EmployeeID, Accessinfo.UserID);

                        if (wingMan != null)
                        {
                            allowEdit = true;
                        }
                    }
                }

                //Another conditions in automation steps
                if (!allowEdit)
                {
                    action.SetEnabled(MsgNotLocalizable.PutOnHold, false);
                }

                bool taxSettingsEnabled = enabledEditReceipt && (epsetup.Current.AllowMixedTaxSettingInClaims == true || CurrentClaimDetails.Current.RefNbr == null);
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.taxZoneID>(cache, row, taxSettingsEnabled);
                ValidateProjectAndProjectTask(row);

                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.taxCalcMode>(cache, row, taxSettingsEnabled);
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.taxCategoryID>(cache, row, enabledEditReceipt);

                PXUIFieldAttribute.SetVisible <EPExpenseClaimDetails.curyTipAmt>(ClaimDetails.Cache, null, epsetup.Current.NonTaxableTipItem.HasValue || (row.CuryTipAmt ?? 0) != 0);
                Taxes.Cache.SetAllEditPermissions(enabledEditReceipt);
                RaiseOrHideError <EPExpenseClaimDetails.refNbr>(cache, row, legacyClaim && row.Released == false, Messages.LegacyClaim, PXErrorLevel.Warning, row.RefNbr);
                RaiseOrHideError <EPExpenseClaimDetails.claimDetailID>(cache, row, row.LegacyReceipt == true && row.Released == false && !String.IsNullOrEmpty(row.TaxZoneID), Messages.LegacyReceipt, PXErrorLevel.Warning);

                EPEmployee employeeRow     = Employee.Select();
                string     taxZoneID       = EPClaimReceiptController.GetTaxZoneID(this, employeeRow);
                bool       notMatchtaxZone = String.IsNullOrEmpty(row.TaxZoneID) && !String.IsNullOrEmpty(taxZoneID);
                RaiseOrHideError <EPExpenseClaimDetails.taxZoneID>(cache, row, notMatchtaxZone && row.Released == false, Messages.TaxZoneEmpty, PXErrorLevel.Warning);
                if (UseTaxes.Select().Count != 0)
                {
                    cache.RaiseExceptionHandling <EPExpenseClaimDetails.curyTaxTotal>(row, row.CuryTaxTotal,
                                                                                      new PXSetPropertyException(TX.Messages.UseTaxExcludedFromTotals, PXErrorLevel.Warning));
                }
                else
                {
                    cache.RaiseExceptionHandling <EPExpenseClaimDetails.curyTaxTotal>(row, row.CuryTaxTotal, null);
                }
            }
        }
示例#2
0
        protected virtual void EPExpenseClaimDetails_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            EPExpenseClaimDetails row = (EPExpenseClaimDetails)e.Row;

            if (row != null)
            {
                EPExpenseClaim claim = (EPExpenseClaim)PXSelect <EPExpenseClaim, Where <EPExpenseClaim.refNbr, Equal <Required <EPExpenseClaimDetails.refNbr> > > > .SelectSingleBound(this, new object[] { null }, row.RefNbr);

                bool enabledApprovalReceipt   = PXAccess.FeatureInstalled <FeaturesSet.approvalWorkflow>() && epsetup.Current.ClaimDetailsAssignmentMapID != null;
                bool enabledEditReceipt       = row.Hold == true || !enabledApprovalReceipt;
                bool enabledRefNbr            = true;
                bool enabledEmployeeAndBranch = enabledEditReceipt && !(row.ClaimCuryInfoID == null && cache.AllowUpdate && !string.IsNullOrEmpty(row.RefNbr));
                bool enabledFinancialDetails  = (row.Rejected != true) && (row.Released != true);

                if (claim != null)
                {
                    bool enabledEditClaim = (row.HoldClaim == true);
                    enabledEditReceipt = enabledEditReceipt && enabledEditClaim;
                    EPExpenseClaimDetails receiptnBase = (EPExpenseClaimDetails)PXSelectReadonly <EPExpenseClaimDetails, Where <EPExpenseClaimDetails.claimDetailID, Equal <Required <EPExpenseClaimDetails.claimDetailID> > > > .SelectSingleBound(this, new object[] { null }, row.ClaimDetailID);

                    enabledRefNbr            = (receiptnBase?.RefNbr == null);
                    enabledEmployeeAndBranch = false;
                    enabledFinancialDetails  = enabledFinancialDetails && enabledEditClaim;
                }

                Approval.AllowSelect = enabledApprovalReceipt;
                Delete.SetEnabled(enabledEditReceipt && claim == null);
                PXUIFieldAttribute.SetEnabled(cache, row, enabledEditReceipt);
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.claimDetailID>(cache, row, true);
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.refNbr>(cache, row, enabledRefNbr);
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.employeeID>(cache, row, enabledEmployeeAndBranch);
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.branchID>(cache, row, enabledEmployeeAndBranch);
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.expenseAccountID>(cache, row, enabledFinancialDetails);
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.expenseSubID>(cache, row, enabledFinancialDetails);
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.salesAccountID>(cache, row, enabledFinancialDetails && (row.Billable == true));
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.salesSubID>(cache, row, enabledFinancialDetails && (row.Billable == true));
                PXUIFieldAttribute.SetEnabled <EPExpenseClaimDetails.taxCategoryID>(cache, row, enabledFinancialDetails);
                action.SetEnabled("Submit", cache.GetStatus(row) != PXEntryStatus.Inserted && row.Hold == true);

                if (row.ContractID != null && (bool)row.Billable && row.TaskID != null)
                {
                    PMTask task = PXSelect <PMTask, Where <PMTask.taskID, Equal <Required <PMTask.taskID> > > > .Select(this, row.TaskID);

                    if (task != null && !(bool)task.VisibleInAP)
                    {
                        cache.RaiseExceptionHandling <EPExpenseClaimDetails.taskID>(e.Row, task.TaskCD, new PXSetPropertyException(PM.Messages.TaskInvisibleInModule, task.TaskCD, GL.BatchModule.AP));
                    }
                }

                CurrencyInfo info = (CurrencyInfo)PXSelect <CurrencyInfo, Where <CurrencyInfo.curyInfoID, Equal <Current <EPExpenseClaimDetails.curyInfoID> > > > .SelectSingleBound(this, new object[] { row });

                if (info != null && info.CuryRateTypeID != null && info.CuryEffDate != null && row.ExpenseDate != null && info.CuryEffDate < row.ExpenseDate)
                {
                    CurrencyRateType ratetype = (CurrencyRateType)PXSelectorAttribute.Select <CurrencyInfo.curyRateTypeID>(currencyinfo.Cache, info);
                    if (ratetype != null && ratetype.RateEffDays > 0 &&
                        ((TimeSpan)(row.ExpenseDate - info.CuryEffDate)).Days > ratetype.RateEffDays)
                    {
                        PXRateIsNotDefinedForThisDateException exc = new PXRateIsNotDefinedForThisDateException(info.CuryRateTypeID, info.BaseCuryID, info.CuryID, (DateTime)row.ExpenseDate);
                        cache.RaiseExceptionHandling <EPExpenseClaimDetails.expenseDate>(e.Row, ((EPExpenseClaimDetails)e.Row).ExpenseDate, exc);
                    }
                }
                string message = PXUIFieldAttribute.GetError <CurrencyInfo.curyID>(currencyinfo.Cache, info);
                if (string.IsNullOrEmpty(message) && info != null && info.CuryRate == null)
                {
                    message = CM.Messages.RateNotFound;
                }
                if (string.IsNullOrEmpty(message))
                {
                    cache.RaiseExceptionHandling <EPExpenseClaimDetails.curyID>(e.Row, null, null);
                }
                else
                {
                    cache.RaiseExceptionHandling <EPExpenseClaimDetails.curyID>(e.Row, null, new PXSetPropertyException(message, PXErrorLevel.Warning));
                }
            }
        }