Beispiel #1
0
        protected virtual void CATransfer_OutAccountID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            CATransfer  transfer       = e.Row as CATransfer;
            CashAccount cashaccountOut = (CashAccount)PXSelectorAttribute.Select <CATransfer.outAccountID>(sender, e.Row);

            CurrencyInfo currinfo = CurInfoOUT.Select();

            if (cashaccountOut?.CuryRateTypeID != null)
            {
                currinfo.CuryRateTypeID = cashaccountOut.CuryRateTypeID;
            }
            else
            {
                CMSetup cmsetup = PXSelect <CMSetup> .Select(this);

                if (!string.IsNullOrEmpty(cmsetup?.CARateTypeDflt))
                {
                    currinfo.CuryRateTypeID = cmsetup.CARateTypeDflt;
                }
            }
            sender.SetDefaultExt <CATransfer.outCuryID>(transfer);
            CurInfoOUT.Update(currinfo);

            if (cashaccountOut?.Reconcile != true)
            {
                transfer.ClearedOut   = true;
                transfer.ClearDateOut = transfer.OutDate;
            }
            else
            {
                transfer.ClearedOut   = false;
                transfer.ClearDateOut = null;
            }
            CurrencyInfoAttribute.SetEffectiveDate <CATransfer.outDate, CATransfer.outCuryInfoID>(sender, e);
        }
Beispiel #2
0
        protected virtual void CATransfer_InAccountID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            CATransfer   transfer      = e.Row as CATransfer;
            CashAccount  cashaccountIn = (CashAccount)PXSelectorAttribute.Select <CATransfer.inAccountID>(sender, transfer);
            CurrencyInfo currinfo      = CurInfoIN.Select();

            if (cashaccountIn?.CuryRateTypeID != null)
            {
                currinfo.CuryRateTypeID = cashaccountIn.CuryRateTypeID;
            }
            else
            {
                CMSetup cmsetup = PXSelect <CMSetup> .Select(this);

                if (!string.IsNullOrEmpty(cmsetup?.CARateTypeDflt))
                {
                    currinfo.CuryRateTypeID = cmsetup.CARateTypeDflt;
                }
            }
            sender.SetDefaultExt <CATransfer.inCuryID>(transfer);
            CurInfoIN.Cache.RaiseFieldUpdated <CurrencyInfo.curyRateTypeID>(currinfo, null);

            if (cashaccountIn?.Reconcile != true)
            {
                transfer.ClearedIn   = true;
                transfer.ClearDateIn = transfer.InDate;
            }
            else
            {
                transfer.ClearedIn   = false;
                transfer.ClearDateIn = null;
            }
            CurrencyInfoAttribute.SetEffectiveDate <CATransfer.inDate, CATransfer.inCuryInfoID>(sender, e);
        }
 public virtual void VerifyCashAccountLinkOrMethodCanBeDeleted(CashAccount cashAccount)
 {
     if (cashAccount.UseForCorpCard == true)
     {
         throw new PXException(Messages.CashAccountLinkOrMethodCannotBeDeleted);
     }
 }
        protected virtual void CABatch_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            CABatch row = e.Row as CABatch;

            if (row == null)
            {
                return;
            }

            bool isReleased = (row.Released == true);


            PXUIFieldAttribute.SetEnabled(sender, row, false);
            PXUIFieldAttribute.SetEnabled <CABatch.batchNbr>(sender, row, true);

            bool isProcessing = row.Processing ?? false;

            PXUIFieldAttribute.SetEnabled <CABatch.processing>(sender, row, true);

            bool allowDelete = !isReleased;

            if (allowDelete)
            {
                allowDelete = !(this.ReleasedPayments.Select(row.BatchNbr).Count > 0);
            }
            sender.AllowDelete = allowDelete;

            CashAccount cashaccount  = (CashAccount)PXSelectorAttribute.Select <CABatch.cashAccountID>(sender, row);
            bool        clearEnabled = (row.Released != true) && (cashaccount != null) && (cashaccount.Reconcile == true);

            if (!isReleased)
            {
                PXUIFieldAttribute.SetEnabled <CABatch.hold>(sender, row, !isReleased);
                PXUIFieldAttribute.SetEnabled <CABatch.tranDesc>(sender, row, !isReleased);
                PXUIFieldAttribute.SetEnabled <CABatch.tranDate>(sender, row, !isReleased);
                PXUIFieldAttribute.SetEnabled <CABatch.batchSeqNbr>(sender, row, !isReleased);
                PXUIFieldAttribute.SetEnabled <CABatch.extRefNbr>(sender, row, !isReleased);
                PXUIFieldAttribute.SetEnabled <CABatch.released>(sender, row, true);

                bool hasDetails = this.BatchPayments.Select().Count > 0;
                PXUIFieldAttribute.SetEnabled <CABatch.paymentMethodID>(sender, row, !hasDetails && !isReleased);
                PXUIFieldAttribute.SetEnabled <CABatch.cashAccountID>(sender, row, !hasDetails && !isReleased);
                if (hasDetails)
                {
                    decimal?curyTotal = Decimal.Zero, total = Decimal.Zero;
                    this.CalcDetailsTotal(ref curyTotal, ref total);
                    row.DetailTotal = total;
                    row.CuryTotal   = curyTotal;
                }
            }
            PXUIFieldAttribute.SetVisible <CABatch.curyDetailTotal>(sender, row, isReleased);
            PXUIFieldAttribute.SetVisible <CABatch.curyTotal>(sender, row, !isReleased);
            PXUIFieldAttribute.SetEnabled <CABatch.exportFileName>(sender, row, isProcessing);
            PXUIFieldAttribute.SetEnabled <CABatch.exportTime>(sender, row, isProcessing);
            PXUIFieldAttribute.SetVisible <CABatch.dateSeqNbr>(sender, row, isReleased);

            this.Release.SetEnabled(!isReleased && (row.Hold == false));
            this.Export.SetEnabled(isReleased);
            //this.addExtPayment.SetEnabled(!isReleased);
        }
Beispiel #5
0
        protected virtual void CAExpense_CashAccountID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            CAExpense   expense     = e.Row as CAExpense;
            CashAccount cashaccount = (CashAccount)PXSelectorAttribute.Select <CAExpense.cashAccountID>(sender, e.Row);

            UpdateCuryInfoExpense(sender, expense);

            if (cashaccount?.Reconcile != true)
            {
                expense.Cleared   = true;
                expense.ClearDate = expense.TranDate;
            }
            else
            {
                expense.Cleared   = false;
                expense.ClearDate = null;
            }

            CurrencyInfo currinfo = PXSelect <CurrencyInfo, Where <CurrencyInfo.curyInfoID, Equal <Required <CAExpense.curyInfoID> >,
                                                                   And <CurrencyInfo.curyID, Equal <Required <CAExpense.curyID> > > > > .Select(this, expense.CuryInfoID, expense.CuryID);

            if (currinfo != null)
            {
                CurrencyInfoAttribute.SetEffectiveDate <CAExpense.tranDate, CAExpense.curyInfoID>(sender, e);
            }
        }
        protected virtual void CATransfer_InAccountID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            CATransfer transfer = e.Row as CATransfer;

            CashAccount cashaccountIn = (CashAccount)PXSelectorAttribute.Select <CATransfer.inAccountID>(sender, transfer);

            sender.SetDefaultExt <CATransfer.inCuryID>(transfer);

            CurrencyInfo currinfo = CurInfoIN.Select();

            if ((cashaccountIn != null) && (cashaccountIn.CuryRateTypeID != null))
            {
                currinfo.CuryRateTypeID = cashaccountIn.CuryRateTypeID;
                CurInfoIN.Cache.RaiseFieldUpdated <CurrencyInfo.curyRateTypeID>(currinfo, null);
            }

            //CalculateCuryTranIn(transfer);

            transfer.ClearedIn   = false;
            transfer.ClearDateIn = null;

            if ((cashaccountIn != null) && (cashaccountIn.Reconcile != true))
            {
                transfer.ClearedIn   = true;
                transfer.ClearDateIn = transfer.InDate;
            }
        }
        private static void ValidateCADailySummary(CATranEntryLight graph, CashAccount cashAccount, IFinPeriod period)
        {
            using (new PXConnectionScope())
            {
                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    graph.dailycache.Clear();
                    ts.Complete(graph);
                }
            }

            PXDatabase.Delete <CADailySummary>(
                new PXDataFieldRestrict(nameof(CADailySummary.CashAccountID), PXDbType.Int, 4, cashAccount.CashAccountID, PXComp.EQ),
                new PXDataFieldRestrict(nameof(CADailySummary.TranDate), PXDbType.DateTime, 8, period.StartDate, PXComp.GE));

            foreach (CATran tran in PXSelect <CATran,
                                              Where <CATran.cashAccountID, Equal <Required <CATran.cashAccountID> >,
                                                     And <CATran.tranDate, GreaterEqual <Required <CATran.tranDate> > > > > .Select(graph, cashAccount.CashAccountID, period.StartDate))
            {
                CADailyAccumulatorAttribute.RowInserted <CATran.tranDate>(graph.catrancache, tran);
            }

            graph.dailycache.Persist(PXDBOperation.Insert);
            graph.dailycache.Persist(PXDBOperation.Update);

            graph.dailycache.Persisted(false);
        }
Beispiel #8
0
        protected virtual void CASetup_RowUpdating(PXCache sender, PXRowUpdatingEventArgs e)
        {
            CASetup row = (CASetup)e.NewRow;

            if (e.NewRow == null || row == null || row.TransitAcctId == null)
            {
                return;
            }

            CashAccount cashAccount =
                PXSelect <CashAccount, Where <CashAccount.accountID, Equal <Required <CASetup.transitAcctId> > > > .Select(
                    this, row.TransitAcctId);

            if (cashAccount == null)
            {
                return;
            }
            if (cashAccount.SubID != (int)row.TransitSubID)
            {
                Sub subAccount = PXSelect <Sub, Where <Sub.subID, Equal <Required <CASetup.transitSubID> > > > .Select(
                    this, row.TransitSubID);

                sender.RaiseExceptionHandling <CASetup.transitSubID>(row, subAccount.SubCD,
                                                                     new PXSetPropertyException(Messages.WrongSubIdForCashAccount));
            }
        }
Beispiel #9
0
        protected virtual void CAEntryType_RowUpdating(PXCache sender, PXRowUpdatingEventArgs e)
        {
            CAEntryType row = e.NewRow as CAEntryType;

            if (row.AccountID != null)
            {
                Account currentAcc = PXSelect <Account, Where <Account.accountID, Equal <Required <Account.accountID> > > > .Select(this, row.AccountID);

                if (currentAcc.IsCashAccount == true)
                {
                    CashAccount cashAccount = PXSelect <CashAccount, Where <CashAccount.accountID, Equal <Required <CashAccount.accountID> >,
                                                                            And <CashAccount.subID, Equal <Required <CashAccount.subID> >,
                                                                                 And <CashAccount.branchID, Equal <Required <CashAccount.branchID> > > > > > .Select(this, row.AccountID, row.SubID, row.BranchID);

                    if (cashAccount == null)
                    {
                        string branchCD = (string)PXSelectorAttribute.GetField(sender, row, typeof(CAEntryType.branchID).Name, row.BranchID, typeof(Branch.branchCD).Name);
                        sender.RaiseExceptionHandling <CAEntryType.branchID>(row, branchCD,
                                                                             new PXSetPropertyException(Messages.NoCashAccountForBranchAndSub, PXErrorLevel.Error));
                        string subCD = (string)PXSelectorAttribute.GetField(sender, row, typeof(CAEntryType.subID).Name, row.SubID, typeof(Sub.subCD).Name);
                        sender.RaiseExceptionHandling <CAEntryType.subID>(row, subCD,
                                                                          new PXSetPropertyException(Messages.NoCashAccountForBranchAndSub, PXErrorLevel.Error));
                        e.Cancel = true;
                        return;
                    }
                }
            }
        }
        protected virtual void PaymentMethodAccount_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            PaymentMethodAccount row = (PaymentMethodAccount)e.Row;

            PXDefaultAttribute.SetPersistingCheck <PaymentMethodAccount.aPLastRefNbr>(sender, e.Row, row.APAutoNextNbr == true ? PXPersistingCheck.NullOrBlank
                                                                                                                                                                                                                                                          : PXPersistingCheck.Nothing);
            if (row.APAutoNextNbr == true && row.APLastRefNbr == null)
            {
                sender.RaiseExceptionHandling <PaymentMethodAccount.aPAutoNextNbr>(row, row.APAutoNextNbr, new PXSetPropertyException(Messages.SpecifyLastRefNbr, GL.Messages.ModuleAP));
            }

            if (row.ARAutoNextNbr == true && row.ARLastRefNbr == null)
            {
                sender.RaiseExceptionHandling <PaymentMethodAccount.aRAutoNextNbr>(row, row.ARAutoNextNbr, new PXSetPropertyException(Messages.SpecifyLastRefNbr, GL.Messages.ModuleAR));
            }

            CashAccount cashAccount = PXSelectReadonly <CashAccount,
                                                        Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > > .Select(this, row.CashAccountID);

            if (cashAccount != null && cashAccount.Active != true)
            {
                string errorMsg = string.Format(CA.Messages.CashAccountInactive, cashAccount.CashAccountCD.Trim());
                sender.RaiseExceptionHandling <PaymentMethodAccount.cashAccountID>(e.Row, cashAccount.CashAccountCD, new PXSetPropertyException(errorMsg, PXErrorLevel.Error));
            }
        }
Beispiel #11
0
        /// <summary>
        /// Handles the CA transaction detail <see cref="ICATranDetail.AccountID"/> field updated event.
        /// </summary>
        /// <param name="tranDetailsCache">The transaction details cache.</param>
        /// <param name="e">Field updated event arguments.</param>
        public static void OnAccountIdFieldUpdatedEvent(PXCache tranDetailsCache, PXFieldUpdatedEventArgs e)
        {
            ICATranDetail tranDetail = e.Row as ICATranDetail;

            if (tranDetail == null)
            {
                return;
            }

            Account glAccount = PXSelect <Account,
                                          Where <Account.accountID, Equal <Required <Account.accountID> > > >
                                .Select(tranDetailsCache.Graph, tranDetail.AccountID);

            if (glAccount?.IsCashAccount != true)
            {
                return;
            }

            CashAccount cashAccount = GetCashAccount(tranDetailsCache.Graph, glAccount.AccountID, tranDetail.SubID, tranDetail.BranchID, doSearchWithSubsetsOfArgs: true);

            if (cashAccount != null)
            {
                tranDetailsCache.SetValueExt(tranDetail, nameof(ICATranDetail.BranchID), cashAccount.BranchID);
                tranDetailsCache.SetValueExt(tranDetail, nameof(ICATranDetail.SubID), cashAccount.SubID);
            }
        }
        protected virtual void PaymentMethodAccount_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            PaymentMethodAccount row = (PaymentMethodAccount)e.Row;

            if (row == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(row.PaymentMethodID) == false)
            {
                PaymentMethod pt = PXSelect <PaymentMethod, Where <PaymentMethod.paymentMethodID, Equal <Required <PaymentMethod.paymentMethodID> > > > .Select(this, row.PaymentMethodID);

                bool enabled = (pt != null) && pt.APCreateBatchPayment == true;
                PXUIFieldAttribute.SetEnabled <PaymentMethodAccount.aPBatchLastRefNbr>(cache, row, enabled);
            }

            if (row.CashAccountID.HasValue)
            {
                CashAccount c = PXSelectReadonly <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > > .Select(this, row.CashAccountID);

                PXUIFieldAttribute.SetEnabled <PaymentMethodAccount.useForAP>(cache, row, (c != null));
            }
            bool enableAP = row.UseForAP ?? false;
            bool enableAR = row.UseForAR ?? false;

            PXUIFieldAttribute.SetEnabled <PaymentMethodAccount.aPIsDefault>(cache, e.Row, enableAP);
            PXUIFieldAttribute.SetEnabled <PaymentMethodAccount.aPAutoNextNbr>(cache, e.Row, enableAP);
            PXUIFieldAttribute.SetEnabled <PaymentMethodAccount.aPLastRefNbr>(cache, e.Row, enableAP);
            PXUIFieldAttribute.SetEnabled <PaymentMethodAccount.aRIsDefault>(cache, e.Row, enableAR);
            PXUIFieldAttribute.SetEnabled <PaymentMethodAccount.aRIsDefaultForRefund>(cache, e.Row, enableAR);
            PXUIFieldAttribute.SetEnabled <PaymentMethodAccount.aRAutoNextNbr>(cache, e.Row, enableAR);
            PXUIFieldAttribute.SetEnabled <PaymentMethodAccount.aRLastRefNbr>(cache, e.Row, enableAR);
        }
Beispiel #13
0
        protected static CashAccount GetCashAccount(CATran catran, PXGraph graph)
        {
            PXSelectBase <CashAccount> selectStatement = new PXSelectReadonly <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > >(graph);
            CashAccount cashacc = (CashAccount)selectStatement.View.SelectSingle(catran.CashAccountID);

            return(cashacc);
        }
Beispiel #14
0
        public virtual void GetRange(DateTime date, string Range, int?cashAccountID, out DateTime?RangeStart, out DateTime?RangeEnd)
        {
            switch (Range)
            {
            case "W":
                RangeStart = date.AddDays(-1 * (PXDateTime.DayOfWeekOrdinal(date.DayOfWeek) - 1));
                RangeEnd   = date.AddDays(7 - PXDateTime.DayOfWeekOrdinal(date.DayOfWeek));
                return;

            case "M":
                RangeStart = new DateTime(date.Year, date.Month, 1);
                RangeEnd   = new DateTime(date.Year, date.Month, 1).AddMonths(1).AddDays(-1);
                return;

            case "P":
                CashAccount cashAccount = PXSelect <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > > .Select(this, cashAccountID);

                int?organizationID = PXAccess.GetParentOrganizationID(cashAccount?.BranchID);
                var period         = FinPeriodRepository.FindFinPeriodByDate(date, organizationID);
                RangeStart = period?.StartDate;
                RangeEnd   = period?.EndDate;
                return;

            case "D":
            default:
                RangeStart = date;
                RangeEnd   = date;
                return;
            }
        }
        public override int Persist(Type cacheType, PXDBOperation operation)
        {
            try
            {
                return(base.Persist(cacheType, operation));
            }
            catch (PXDatabaseException e)
            {
                if (cacheType == typeof(PaymentMethodAccount) &&
                    (operation == PXDBOperation.Delete ||
                     operation == PXDBOperation.Command) &&
                    (e.ErrorCode == PXDbExceptions.DeleteForeignKeyConstraintViolation ||
                     e.ErrorCode == PXDbExceptions.DeleteReferenceConstraintViolation))
                {
                    CashAccount ca = PXSelect <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > > .
                                     Select(this, e.Keys[1]);

                    string CashAccountCD = ca.CashAccountCD;
                    throw new PXException(Messages.CannotDeletePaymentMethodAccount, e.Keys[0], CashAccountCD);
                }
                else
                {
                    throw;
                }
            }
        }
 private static void ValidateCleared(CATranEntryLight graph, CashAccount cashAccount, IFinPeriod period)
 {
     if (cashAccount.Reconcile != true)
     {
         graph.Clear();
         using (new PXConnectionScope())
         {
             using (PXTransactionScope ts = new PXTransactionScope())
             {
                 foreach (CATran catran in PXSelect <CATran, Where <CATran.cashAccountID, Equal <Required <CATran.cashAccountID> >,
                                                                    And <CATran.finPeriodID, GreaterEqual <Required <CATran.finPeriodID> > > > > .Select(graph, cashAccount.CashAccountID, period.FinPeriodID))
                 {
                     if (cashAccount.Reconcile != true && (catran.Cleared != true || catran.TranDate == null))
                     {
                         catran.Cleared   = true;
                         catran.ClearDate = catran.TranDate;
                     }
                     graph.catrancache.Update(catran);
                 }
                 graph.catrancache.Persist(PXDBOperation.Update);
                 ts.Complete(graph);
             }
             graph.catrancache.Persisted(false);
         }
     }
 }
        private static void Validate(CATranEntryLight graph, CashAccount cashAccount, CABalanceValidationPeriodFilter filter)
        {
            if (string.IsNullOrEmpty(filter.FinPeriodID))
            {
                throw new PXException(GL.Messages.Prefix + ": " + GL.Messages.ProcessingRequireFinPeriodID);
            }

            MasterFinPeriod period = PXSelect <MasterFinPeriod, Where <MasterFinPeriod.finPeriodID, Equal <Required <MasterFinPeriod.finPeriodID> > > > .Select(graph, filter.FinPeriodID);

            if (period == null)
            {
                throw new PXException(GL.Messages.ProcessingRequireFinPeriodID);
            }

            ValidateAccount(graph, cashAccount);
            graph.Clear();

            ValidateCleared(graph, cashAccount, period);
            graph.Clear();

            ValidateCAAdjustments(graph, cashAccount, period);
            graph.Clear();

            ValidateCATransfers(graph, cashAccount, period);
            graph.Clear();

            ValidateCATrans(graph, cashAccount, period);
            graph.Clear();

            ValidateCADailySummary(graph, cashAccount, period);
        }
Beispiel #18
0
        protected virtual void CAEntryType_BranchID_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e)
        {
            CAEntryType row = (CAEntryType)e.Row;

            if (row == null)
            {
                return;
            }
            if (row.CashAccountID != null)
            {
                CashAccount acct = PXSelect <CashAccount,
                                             Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > > .SelectWindowed(this, 0, 1, row.CashAccountID);

                if (acct != null)
                {
                    e.NewValue = acct.BranchID;
                    e.Cancel   = true;
                }
            }
            else
            {
                e.NewValue = null;
                e.Cancel   = true;
            }
        }
        protected virtual IStatementReader CreateReader()
        {
            IStatementReader processor             = null;
            bool             importToSingleAccount = this.CASetup.Current.ImportToSingleAccount ?? false;
            string           typeName = this.CASetup.Current.StatementImportTypeName;

            if (importToSingleAccount)
            {
                CashAccount acct = PXSelect <CashAccount, Where <CashAccount.cashAccountID, Equal <Optional <CABankTranHeader.cashAccountID> > > > .Select(this);

                if (acct != null)
                {
                    typeName = acct.StatementImportTypeName;
                }
            }

            if (string.IsNullOrEmpty(typeName))
            {
                return(processor);
            }
            try
            {
                Type processorType = System.Web.Compilation.PXBuildManager.GetType(typeName, true);
                processor = (IStatementReader)Activator.CreateInstance(processorType);
            }
            catch (Exception e)
            {
                throw new PXException(e, Messages.StatementServiceReaderCreationError, typeName);
            }
            return(processor);
        }
Beispiel #20
0
        protected void CAExpense_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            var expense = (CAExpense)e.Row;

            if (expense == null)
            {
                return;
            }

            CashAccount cashAccount = PXSelect <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CAExpense.cashAccountID> > > > .Select(this, expense.CashAccountID);

            CurrencyInfo curyInfo = PXSelect <CurrencyInfo, Where <CurrencyInfo.curyInfoID, Equal <Required <CAExpense.curyInfoID> >, And <CurrencyInfo.curyID, Equal <Required <CAExpense.curyID> > > > > .Select(this, expense.CuryInfoID, expense.CuryID);

            if (curyInfo == null)
            {
                return;
            }

            bool clearEnabled   = expense.Released != true && cashAccount?.Reconcile == true;
            bool cureRateEnable = expense.CuryID != curyInfo.BaseCuryID;

            PXUIFieldAttribute.SetEnabled <CAExpense.cleared>(sender, expense, clearEnabled);
            PXUIFieldAttribute.SetEnabled <CAExpense.adjCuryRate>(sender, expense, cureRateEnable);

            if (Transfer.Current.Released != true && Transfer.Current.OutDate > expense.TranDate)
            {
                sender.RaiseExceptionHandling <CAExpense.tranDate>(expense, expense.TranDate, new PXSetPropertyException(Messages.EarlyExpenseDate, PXErrorLevel.Warning));
            }
            else
            {
                sender.RaiseExceptionHandling <CAExpense.tranDate>(expense, expense.TranDate, null);
            }
        }
Beispiel #21
0
 protected static void SetCleared(CATran catran, CashAccount cashAccount)
 {
     if (cashAccount != null && cashAccount.Reconcile == false && (catran.Cleared != true || catran.TranDate == null))
     {
         catran.Cleared   = true;
         catran.ClearDate = catran.TranDate;
     }
 }
Beispiel #22
0
        protected virtual void CAEntryType_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            CAEntryType row = e.Row as CAEntryType;

            PXDefaultAttribute.SetPersistingCheck <CAEntryType.referenceID>(sender, e.Row, PXPersistingCheck.Nothing);

            if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Update)
            {
                CAAdj foundCAAdj = PXSelectReadonly <CAAdj,
                                                     Where <CAAdj.entryTypeID, Equal <Required <CAAdj.entryTypeID> > > > .
                                   Select(this, row.EntryTypeId);

                if (foundCAAdj != null)
                {
                    CAEntryType foundCAEntryType = PXSelectReadonly <CAEntryType,
                                                                     Where <CAEntryType.entryTypeId, Equal <Required <CAEntryType.entryTypeId> > > > .
                                                   Select(this, row.EntryTypeId);

                    if (foundCAEntryType != null)
                    {
                        if (row.DrCr != foundCAEntryType.DrCr)
                        {
                            if (sender.RaiseExceptionHandling <CAEntryType.drCr>(e.Row, row.DrCr, new PXSetPropertyException(Messages.CantEditDisbReceipt, PXErrorLevel.RowError, typeof(CAEntryType.drCr).Name)))
                            {
                                throw new PXRowPersistingException(typeof(CAEntryType.drCr).Name, row.DrCr, Messages.CantEditDisbReceipt, typeof(CAEntryType.drCr).Name);
                            }
                        }
                        if (row.Module != foundCAEntryType.Module)
                        {
                            if (sender.RaiseExceptionHandling <CAEntryType.module>(e.Row, row.Module, new PXSetPropertyException(Messages.CantEditModule, PXErrorLevel.RowError, typeof(CAEntryType.module).Name)))
                            {
                                throw new PXRowPersistingException(typeof(CAEntryType.module).Name, row.Module, Messages.CantEditModule, typeof(CAEntryType.module).Name);
                            }
                        }
                    }
                }
            }
            if ((e.Operation & PXDBOperation.Command) != PXDBOperation.Delete)
            {
                if (row.UseToReclassifyPayments == true && row.AccountID.HasValue)
                {
                    CashAccount cashAcct = PXSelectReadonly <CashAccount,
                                                             Where <CashAccount.accountID, Equal <Required <CashAccount.accountID> >,
                                                                    And <CashAccount.subID, Equal <Required <CashAccount.subID> > > > > .Select(this, row.AccountID, row.SubID);

                    GL.Account acct = PXSelectReadonly <Account,
                                                        Where <Account.accountID, Equal <Required <Account.accountID> > > > .Select(this, row.AccountID);

                    if (cashAcct == null || !cashAcct.AccountID.HasValue)
                    {
                        if (sender.RaiseExceptionHandling <CAEntryType.accountID>(e.Row, acct.AccountCD, new PXSetPropertyException(Messages.CAEntryTypeUsedForPaymentReclassificationMustHaveCashAccount, PXErrorLevel.Error)))
                        {
                            throw new PXRowPersistingException(typeof(CAEntryType.accountID).Name, acct.AccountCD, Messages.CAEntryTypeUsedForPaymentReclassificationMustHaveCashAccount);
                        }
                    }
                }
            }
        }
        protected virtual void CATransfer_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            CATransfer transfer = (CATransfer)e.Row;

            if (transfer == null)
            {
                return;
            }

            transfer.RGOLAmt = transfer.TranIn - transfer.TranOut;

            bool transferOnHold      = (transfer.Hold == true);
            bool transferNotReleased = (transfer.Released != true);
            bool transferReleased    = (transfer.Released == true);

            PXUIFieldAttribute.SetVisible <CATransfer.inGLBalance>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetVisible <CATransfer.outGLBalance>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetVisible <CATransfer.cashBalanceIn>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetVisible <CATransfer.cashBalanceOut>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetVisible <CATransfer.tranIDIn_CATran_batchNbr>(sender, transfer, transferReleased);
            PXUIFieldAttribute.SetVisible <CATransfer.tranIDOut_CATran_batchNbr>(sender, transfer, transferReleased);

            PXUIFieldAttribute.SetEnabled(sender, transfer, false);

            sender.AllowDelete = transferNotReleased;
            sender.AllowUpdate = transferNotReleased;
            Expenses.Cache.SetAllEditPermissions(transferNotReleased);

            CashAccount cashaccountOut = (CashAccount)PXSelectorAttribute.Select <CATransfer.outAccountID>(sender, e.Row);
            CashAccount cashaccountIn  = (CashAccount)PXSelectorAttribute.Select <CATransfer.inAccountID>(sender, e.Row);

            bool clearEnabledIn  = transferNotReleased && (cashaccountIn != null) && (cashaccountIn.Reconcile == true);
            bool clearEnabledOut = transferNotReleased && (cashaccountOut != null) && (cashaccountOut.Reconcile == true);

            PXUIFieldAttribute.SetEnabled <CATransfer.hold>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.transferNbr>(sender, transfer, true);
            PXUIFieldAttribute.SetEnabled <CATransfer.descr>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.curyTranIn>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.inAccountID>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.inDate>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.inExtRefNbr>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.curyTranOut>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.outAccountID>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.outDate>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.outExtRefNbr>(sender, transfer, transferNotReleased);
            PXUIFieldAttribute.SetEnabled <CATransfer.clearedOut>(sender, transfer, clearEnabledOut);
            PXUIFieldAttribute.SetEnabled <CATransfer.clearDateOut>(sender, transfer, clearEnabledOut && transfer.ClearedOut == true);
            PXUIFieldAttribute.SetEnabled <CATransfer.clearedIn>(sender, transfer, clearEnabledIn);
            PXUIFieldAttribute.SetEnabled <CATransfer.clearDateIn>(sender, transfer, clearEnabledIn && transfer.ClearedIn == true);

            Release.SetEnabled(transferNotReleased && !transferOnHold);
            Reverse.SetEnabled(transferReleased);

            UIState.RaiseOrHideErrorByErrorLevelPriority <CATransfer.inDate>(sender, transfer, transfer.Released != true && transfer.OutDate > transfer.InDate, Messages.EarlyInDate, PXErrorLevel.Warning);

            SetAdjRefNbrVisibility();
        }
        private void ValidateCuryID(PXCache sender, CashForecastTran row, string CuryID)
        {
            CashAccount acct = PXSelect <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > > .Select(this, filter.Current.CashAccountID);

            if (acct.CuryID != CuryID)
            {
                cashForecastTrans.Cache.RaiseExceptionHandling <CashForecastTran.curyID>(row, CuryID,
                                                                                         new PXRowPersistingException(typeof(CashForecastTran.curyID).Name, CuryID, Messages.TranCuryNotMatchAcctCury));
            }
        }
Beispiel #25
0
 protected virtual void CurrencyInfo_CuryRateTypeID_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
 {
     if (PXAccess.FeatureInstalled <FeaturesSet.multicurrency>() != true)
     {
         CashAccount cashAcc = cashaccount.Current;
         if (cashAcc != null && !string.IsNullOrEmpty(cashAcc.CuryRateTypeID))
         {
             e.NewValue = cashAcc.CuryRateTypeID;
             e.Cancel   = true;
         }
     }
 }
Beispiel #26
0
        /// <summary>
        /// Duplicates <see cref="UpdateCuryInfoExpense(PXCache, CAExpense)"/>. Should be refactored.
        /// </summary>
        public virtual void CATransfer_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            var row = (CATransfer)e.Row;

            CashAccount  cashaccountOut = (CashAccount)PXSelectorAttribute.Select <CATransfer.outAccountID>(sender, row);
            CurrencyInfo currinfoOut    = PXSelect <CurrencyInfo, Where <CurrencyInfo.curyInfoID, Equal <Required <CATransfer.outCuryInfoID> >,
                                                                         And <CurrencyInfo.curyID, Equal <Required <CATransfer.outCuryID> > > > > .Select(this, row.OutCuryInfoID, row.OutCuryID);

            if (currinfoOut == null)
            {
                return;
            }

            if (cashaccountOut?.CuryRateTypeID != null)
            {
                currinfoOut.CuryRateTypeID = cashaccountOut.CuryRateTypeID;
            }
            else
            {
                CMSetup cmsetup = PXSelect <CMSetup> .Select(this);

                if (!string.IsNullOrEmpty(cmsetup?.CARateTypeDflt))
                {
                    currinfoOut.CuryRateTypeID = cmsetup.CARateTypeDflt;
                }
            }
            CuryInfo.Update(currinfoOut);

            CashAccount  cashaccountIn = (CashAccount)PXSelectorAttribute.Select <CATransfer.outAccountID>(sender, row);
            CurrencyInfo currinfoIn    = PXSelect <CurrencyInfo, Where <CurrencyInfo.curyInfoID, Equal <Required <CATransfer.inCuryInfoID> >,
                                                                        And <CurrencyInfo.curyID, Equal <Required <CATransfer.inCuryID> > > > > .Select(this, row.InCuryInfoID, row.InCuryID);

            if (cashaccountIn == null)
            {
                return;
            }

            if (cashaccountIn?.CuryRateTypeID != null)
            {
                currinfoIn.CuryRateTypeID = cashaccountIn.CuryRateTypeID;
            }
            else
            {
                CMSetup cmsetup = PXSelect <CMSetup> .Select(this);

                if (!string.IsNullOrEmpty(cmsetup?.CARateTypeDflt))
                {
                    currinfoIn.CuryRateTypeID = cmsetup.CARateTypeDflt;
                }
            }
            CuryInfo.Update(currinfoIn);
        }
Beispiel #27
0
        protected virtual void CurrencyInfo_CuryRateTypeID_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
        {
            CashAccount acct = this.cashAccount.Current;

            if (acct != null)
            {
                if (acct != null && !string.IsNullOrEmpty(acct.CuryRateTypeID))
                {
                    e.NewValue = acct.CuryRateTypeID;
                    e.Cancel   = true;
                }
            }
        }
Beispiel #28
0
        public virtual string GenerateFileName(CABatch aBatch)
        {
            if (aBatch.CashAccountID != null && !string.IsNullOrEmpty(aBatch.PaymentMethodID))
            {
                CashAccount acct = PXSelect <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > > .Select(this, aBatch.CashAccountID);

                if (acct != null)
                {
                    return(string.Format(Messages.CABatchDefaultExportFilenameTemplate, aBatch.PaymentMethodID, acct.CashAccountCD, aBatch.TranDate.Value, aBatch.DateSeqNbr));
                }
            }
            return(string.Empty);
        }
        protected virtual void CATransfer_InDate_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            CATransfer transfer = e.Row as CATransfer;

            if (transfer.ClearedIn == true)
            {
                CashAccount cashaccountIn = (CashAccount)PXSelectorAttribute.Select <CATransfer.inAccountID>(sender, e.Row);
                if ((cashaccountIn != null) && (cashaccountIn.Reconcile != true))
                {
                    transfer.ClearDateIn = transfer.InDate;
                }
            }
        }
Beispiel #30
0
        /// <summary>
        /// Handles the CA transaction detail row updating event.
        /// </summary>
        /// <param name="tranDetailsCache">The transaction details cache.</param>
        /// <param name="e">Row updating event arguments.</param>
        public static void OnCATranDetailRowUpdatingEvent(PXCache tranDetailsCache, PXRowUpdatingEventArgs e)
        {
            ICATranDetail oldTranDetail = e.Row as ICATranDetail;
            ICATranDetail newTranDetail = e.NewRow as ICATranDetail;

            if (newTranDetail == null || tranDetailsCache == null)
            {
                return;
            }

            UpdateNewTranDetailCuryTranAmtOrCuryUnitPrice(tranDetailsCache, oldTranDetail, newTranDetail);

            if (newTranDetail.AccountID == null)
            {
                return;
            }

            Account currentAcc = PXSelect <Account,
                                           Where <Account.accountID, Equal <Required <Account.accountID> > > > .
                                 Select(tranDetailsCache.Graph, newTranDetail.AccountID);

            if (currentAcc?.IsCashAccount != true)
            {
                return;
            }

            CashAccount cashAccount = GetCashAccount(tranDetailsCache.Graph,
                                                     newTranDetail.AccountID,
                                                     newTranDetail.SubID,
                                                     newTranDetail.BranchID,
                                                     doSearchWithSubsetsOfArgs: false);

            if (cashAccount == null)
            {
                PXSetPropertyException exception = new PXSetPropertyException(Messages.NoCashAccountForBranchAndSub, PXErrorLevel.Error);
                string branchCD = (string)PXSelectorAttribute.GetField(tranDetailsCache,
                                                                       newTranDetail,
                                                                       nameof(ICATranDetail.BranchID),
                                                                       newTranDetail.BranchID,
                                                                       typeof(Branch.branchCD).Name);
                string subCD = (string)PXSelectorAttribute.GetField(tranDetailsCache,
                                                                    newTranDetail,
                                                                    nameof(ICATranDetail.SubID),
                                                                    newTranDetail.SubID,
                                                                    typeof(Sub.subCD).Name);

                tranDetailsCache.RaiseExceptionHandling(nameof(ICATranDetail.BranchID), newTranDetail, branchCD, exception);
                tranDetailsCache.RaiseExceptionHandling(nameof(ICATranDetail.SubID), newTranDetail, subCD, exception);
                e.Cancel = true;
            }
        }