Example #1
0
        protected virtual void CABankTranRule_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            var rule = e.Row as CABankTranRule;

            if (string.IsNullOrWhiteSpace(rule.BankTranDescription) && rule.CuryTranAmt == null && string.IsNullOrWhiteSpace(rule.TranCode))
            {
                throw new PXException(Messages.BankRuleTooLoose);
            }

            PXDefaultAttribute.SetPersistingCheck <CABankTranRule.documentModule>(cache, rule, rule.Action == RuleAction.CreateDocument ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);
            PXDefaultAttribute.SetPersistingCheck <CABankTranRule.documentEntryTypeID>(cache, rule, rule.Action == RuleAction.CreateDocument ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);
            PXDefaultAttribute.SetPersistingCheck <CABankTranRule.curyTranAmt>(cache, rule, rule.AmountMatchingMode != MatchingMode.None ? PXPersistingCheck.Null : PXPersistingCheck.Nothing);
            PXDefaultAttribute.SetPersistingCheck <CABankTranRule.maxCuryTranAmt>(cache, rule, rule.AmountMatchingMode == MatchingMode.Between ? PXPersistingCheck.Null : PXPersistingCheck.Nothing);

            if (rule.BankTranCashAccountID == null || rule.DocumentEntryTypeID == null)
            {
                return;
            }

            CashAccountETDetail entryTypeForAcct = PXSelect <CashAccountETDetail,
                                                             Where <CashAccountETDetail.accountID, Equal <Required <CashAccountETDetail.accountID> >,
                                                                    And <CashAccountETDetail.entryTypeID, Equal <Required <CashAccountETDetail.entryTypeID> > > > >
                                                   .Select(this, rule.BankTranCashAccountID, rule.DocumentEntryTypeID);

            if (entryTypeForAcct == null)
            {
                cache.RaiseExceptionHandling <CABankTranRule.documentEntryTypeID>(rule,
                                                                                  rule.DocumentEntryTypeID,
                                                                                  new PXSetPropertyException <CABankTranRule.documentEntryTypeID>(Messages.BankRuleEntryTypeDoesntSuitCashAccount));
            }
        }
Example #2
0
        protected virtual void CABankTranRule_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            var rule = e.Row as CABankTranRule;

            if (String.IsNullOrWhiteSpace(rule.BankTranDescription) && rule.CuryTranAmt == null && String.IsNullOrWhiteSpace(rule.TranCode))
            {
                throw new PXException(Messages.BankRuleTooLoose);
            }

            if (rule.BankTranCashAccountID != null && rule.DocumentEntryTypeID != null)
            {
                CashAccountETDetail entryTypeForAcct = PXSelect <CashAccountETDetail,
                                                                 Where <CashAccountETDetail.accountID, Equal <Required <CashAccountETDetail.accountID> >,
                                                                        And <CashAccountETDetail.entryTypeID, Equal <Required <CashAccountETDetail.entryTypeID> > > > >
                                                       .Select(this, rule.BankTranCashAccountID, rule.DocumentEntryTypeID);

                if (entryTypeForAcct == null)
                {
                    cache.RaiseExceptionHandling <CABankTranRule.documentEntryTypeID>(rule, rule.DocumentEntryTypeID,
                                                                                      new PXSetPropertyException <CABankTranRule.documentEntryTypeID>(Messages.BankRuleEntryTypeDoesntSuitCashAccount));
                }
            }
        }
Example #3
0
        /// <summary>
        /// Gets the new CA transaction detail <see cref="ICATranDetail"/> with <see cref="ICATranDetail.AccountID"/>, <see cref="ICATranDetail.SubID"/>
        /// and <see cref="ICATranDetail.BranchID"/> fields filled with default values.
        /// </summary>
        /// <typeparam name="TTransactionDetail">Type of transaction detail</typeparam>
        /// <param name="graph">The sender graph.</param>
        /// <param name="cashAccountID">The cash account ID</param>
        /// <param name="entryTypeID">The entry type ID</param>
        /// <returns/>
        public static TTransactionDetail CreateCATransactionDetailWithDefaultAccountValues <TTransactionDetail>(PXGraph graph, int?cashAccountID, string entryTypeID)
            where TTransactionDetail : ICATranDetail, new()
        {
            CashAccountETDetail acctSettings = PXSelect <CashAccountETDetail,
                                                         Where <CashAccountETDetail.accountID, Equal <Required <CashAccountETDetail.accountID> >,
                                                                And <CashAccountETDetail.entryTypeID, Equal <Required <CashAccountETDetail.entryTypeID> > > > >
                                               .Select(graph, cashAccountID, entryTypeID);

            bool allAccountValuesSet = acctSettings?.OffsetAccountID != null &&
                                       acctSettings.OffsetSubID != null &&
                                       acctSettings.OffsetBranchID != null;

            TTransactionDetail result = new TTransactionDetail
            {
                AccountID = acctSettings?.OffsetAccountID,
                SubID     = acctSettings?.OffsetSubID,
                BranchID  = acctSettings?.OffsetBranchID
            };

            if (allAccountValuesSet)
            {
                return(result);
            }

            CAEntryType entryType = PXSelect <CAEntryType,
                                              Where <CAEntryType.entryTypeId, Equal <Required <CAEntryType.entryTypeId> > > >
                                    .Select(graph, entryTypeID);

            if (entryType != null)
            {
                result.AccountID = result.AccountID ?? entryType.AccountID;
                result.SubID     = result.SubID ?? entryType.SubID;
                result.BranchID  = result.BranchID ?? entryType.BranchID;
            }

            return(result);
        }