【问题标题】:Acumatica How to get the Cash Account Begin or Ending Balance?Acumatica 如何获得现金账户的期初或期末余额?
【发布时间】:2017-03-17 02:12:48
【问题描述】:

当我在“Founds Transfers” (CA301000) 中选择现金账户时,GL 余额可用余额 条目会更新。

这些金额来自哪里?我的意思是,我需要通过 GI 查询这些字段,但我无法弄清楚表的名称。

有什么线索吗?

【问题讨论】:

    标签: api acumatica


    【解决方案1】:

    GL 余额和可用余额字段是 CATransfer DAC 的一部分。 您不会在 CATransfer 数据库表中找到它们,因为它们是在 CATransfer DAC 运行时使用 GLBalanceAttribute 和 CashBalanceAttribute 的 FieldSelecting 事件作为未绑定字段计算的。

    您可以通过按住 Ctl+Alt 并单击该字段来查找 UI 元素的 DAC 和数据字段。

    作为参考,以下是 CATransfer Dac 中的 GLBalance 属性:

        #region InGLBalance
        public abstract class inGLBalance : PX.Data.IBqlField
        {
        }
        protected Decimal? _InGLBalance;
    
        [PXDefault(TypeCode.Decimal, "0.0", PersistingCheck = PXPersistingCheck.Nothing)]
        [PXCury(typeof(CATransfer.inCuryID))]
        [PXUIField(DisplayName = "GL Balance", Enabled = false)]
        [GLBalance(typeof(CATransfer.inAccountID), null, typeof(CATransfer.inDate))]
        public virtual Decimal? InGLBalance
        {
            get
            {
                return this._InGLBalance;
            }
            set
            {
                this._InGLBalance = value;
            }
        }
        #endregion
        #region OutGLBalance
        public abstract class outGLBalance : PX.Data.IBqlField
        {
        }
        protected Decimal? _OutGLBalance;
    
        [PXDefault(TypeCode.Decimal, "0.0", PersistingCheck = PXPersistingCheck.Nothing)]
        [PXCury(typeof(CATransfer.outCuryID))]
        [PXUIField(DisplayName = "GL Balance", Enabled = false)]
        [GLBalance(typeof(CATransfer.outAccountID), null, typeof(CATransfer.outDate))]
        public virtual Decimal? OutGLBalance
        {
            get
            {
                return this._OutGLBalance;
            }
            set
            {
                this._OutGLBalance = value;
            }
        }
        #endregion
    

    这里是计算值的 GLBalanceAttribute 类 FieldSelecting 事件:

        public virtual void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            GLSetup gLSetup = PXSelect<GLSetup>.Select(sender.Graph);
            decimal? result = 0m;
            object CashAccountID = sender.GetValue(e.Row, _CashAccount);
    
            object FinPeriodID = null;
    
            if (string.IsNullOrEmpty(_FinPeriodID))
            {
                object FinDate = sender.GetValue(e.Row, _FinDate);
                FinPeriod finPeriod = PXSelect<FinPeriod, Where<FinPeriod.startDate, LessEqual<Required<FinPeriod.startDate>>,
                                                            And<FinPeriod.endDate, Greater<Required<FinPeriod.endDate>>>>>.Select(sender.Graph, FinDate, FinDate);
                if (finPeriod != null)
                {
                    FinPeriodID = finPeriod.FinPeriodID;
                }
            }
            else
            {
                FinPeriodID = sender.GetValue(e.Row, _FinPeriodID);
            }
    
            if (CashAccountID != null && FinPeriodID != null)
            {
                // clear glhistory cache for ReleasePayments longrun
                sender.Graph.Caches<GLHistory>().ClearQueryCache();
                sender.Graph.Caches<GLHistory>().Clear();
    
                GLHistory gLHistory = PXSelectJoin<GLHistory,
                                                    InnerJoin<GLHistoryByPeriod,
                                                            On<GLHistoryByPeriod.accountID, Equal<GLHistory.accountID>,
                                                            And<GLHistoryByPeriod.branchID, Equal<GLHistory.branchID>,
                                                            And<GLHistoryByPeriod.ledgerID, Equal<GLHistory.ledgerID>,
                                                            And<GLHistoryByPeriod.subID, Equal<GLHistory.subID>,
                                                            And<GLHistoryByPeriod.lastActivityPeriod, Equal<GLHistory.finPeriodID>>>>>>,
                                                    InnerJoin<Branch,
                                                            On<Branch.branchID, Equal<GLHistory.branchID>,
                                                            And<Branch.ledgerID, Equal<GLHistory.ledgerID>>>,
                                                    InnerJoin<CashAccount,
                                                            On<GLHistoryByPeriod.branchID, Equal<CashAccount.branchID>, 
                                                            And<GLHistoryByPeriod.accountID, Equal<CashAccount.accountID>,
                                                            And<GLHistoryByPeriod.subID, Equal<CashAccount.subID>>>>,
                                                    InnerJoin<Account,
                                                            On<GLHistoryByPeriod.accountID, Equal<Account.accountID>, 
                                                            And<Match<Account, Current<AccessInfo.userName>>>>,
                                                    InnerJoin<Sub,
                                                            On<GLHistoryByPeriod.subID, Equal<Sub.subID>, And<Match<Sub, Current<AccessInfo.userName>>>>>>>>>,
                                                    Where<CashAccount.cashAccountID, Equal<Required<CashAccount.cashAccountID>>,
                                                       And<GLHistoryByPeriod.finPeriodID, Equal<Required<GLHistoryByPeriod.finPeriodID>>>
                                                     >>.Select(sender.Graph, CashAccountID, FinPeriodID);
    
                if (gLHistory != null)
                {
                    result = gLHistory.CuryFinYtdBalance;
                }
            }
            e.ReturnValue = result;
            e.Cancel = true;
        }
    } 
    

    以下是 CATransfer Dac 的 CashBalance 属性:

        #region CashBalanceIn
        public abstract class cashBalanceIn : PX.Data.IBqlField
        {
        }
        protected Decimal? _CashBalanceIn;
        [PXDefault(TypeCode.Decimal, "0.0", PersistingCheck = PXPersistingCheck.Nothing)]
        [PXCury(typeof(CATransfer.inCuryID))]
        [PXUIField(DisplayName = "Available Balance", Enabled = false)]
        [CashBalance(typeof(CATransfer.inAccountID))]
        public virtual Decimal? CashBalanceIn
        {
            get
            {
                return this._CashBalanceIn;
            }
            set
            {
                this._CashBalanceIn = value;
            }
        }
        #endregion
        #region CashBalanceOut
        public abstract class cashBalanceOut : PX.Data.IBqlField
        {
        }
        protected Decimal? _CashBalanceOut;
        [PXDefault(TypeCode.Decimal, "0.0", PersistingCheck = PXPersistingCheck.Nothing)]
        [PXCury(typeof(CATransfer.outCuryID))]
        [PXUIField(DisplayName = "Available Balance", Enabled = false)]
        [CashBalance(typeof(CATransfer.outAccountID))]
        public virtual Decimal? CashBalanceOut
        {
            get
            {
                return this._CashBalanceOut;
            }
            set
            {
                this._CashBalanceOut = value;
            }
        }
        #endregion
    

    以及计算值的CashBalanceAttribute类FieldSelecting事件:

        public virtual void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            CASetup caSetup = PXSelect<CASetup>.Select(sender.Graph);
            decimal? result = 0m;
            object CashAccountID = sender.GetValue(e.Row, _CashAccount);
    
            CADailySummary caBalance = PXSelectGroupBy<CADailySummary,
                                                         Where<CADailySummary.cashAccountID, Equal<Required<CADailySummary.cashAccountID>>>,
                                                                    Aggregate<Sum<CADailySummary.amtReleasedClearedCr,
                                                                     Sum<CADailySummary.amtReleasedClearedDr,
                                                                     Sum<CADailySummary.amtReleasedUnclearedCr,
                                                                     Sum<CADailySummary.amtReleasedUnclearedDr,
                                                                     Sum<CADailySummary.amtUnreleasedClearedCr,
                                                                     Sum<CADailySummary.amtUnreleasedClearedDr,
                                                                     Sum<CADailySummary.amtUnreleasedUnclearedCr,
                                                                     Sum<CADailySummary.amtUnreleasedUnclearedDr>>>>>>>>>>.
                                                                     Select(sender.Graph, CashAccountID);
            if ((caBalance != null) && (caBalance.CashAccountID != null))
            {
                result = caBalance.AmtReleasedClearedDr - caBalance.AmtReleasedClearedCr;
    
                if ((bool)caSetup.CalcBalDebitClearedUnreleased)
                    result += caBalance.AmtUnreleasedClearedDr;
                if ((bool)caSetup.CalcBalCreditClearedUnreleased)
                    result -= caBalance.AmtUnreleasedClearedCr;
                if ((bool)caSetup.CalcBalDebitUnclearedReleased)
                    result += caBalance.AmtReleasedUnclearedDr;
                if ((bool)caSetup.CalcBalCreditUnclearedReleased)
                    result -= caBalance.AmtReleasedUnclearedCr;
                if ((bool)caSetup.CalcBalDebitUnclearedUnreleased)
                    result += caBalance.AmtUnreleasedUnclearedDr;
                if ((bool)caSetup.CalcBalCreditUnclearedUnreleased)
                    result -= caBalance.AmtUnreleasedUnclearedCr;
            }
            e.ReturnValue = result;
            e.Cancel = true;
        }
    } 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-15
      • 1970-01-01
      • 2021-07-22
      相关资源
      最近更新 更多