如何在 Acumatica 中获取交易期间和财务期间的默认值

Posted

技术标签:

【中文标题】如何在 Acumatica 中获取交易期间和财务期间的默认值【英文标题】:How to get the default value for the Transaction Period and Financial Period in Acumatica 【发布时间】:2022-01-13 00:08:33 【问题描述】:

我有一个自定义表格,我需要从日期字段和所选分支中默认填写“交易期间”和公司的“财务期间”,但我无法使其工作。我查看了几个 Acumatica 的欧文屏幕,我的做法完全一样(至少我是这么认为的),但默认情况下这两个字段没有填写。任何帮助表示赞赏。这是我的小图表,部分 DAC 和部分 ASPX。

namespace MyCustom



// Graph

public class PMCashflowProjectionEntry : PXGraph<PMCashflowProjectionEntry, PMCashflowProjection>





    [PXViewName("Projects Cashflow Projections")]

    public PXSelect<PMCashflowProjection> CashflowProjections;



    public PXSelect<PMCashflowProjectionSchedule, Where<PMCashflowProjectionSchedule.projectID, Equal<Current<PMCashflowProjection.projectID>>>> CashflowProjectionSchedules;







//Partial Header DAC

public class PMCashflowProjection : IBqlTable



    #region BranchID

    public abstract class branchID : PX.Data.BQL.BqlInt.Field<branchID>  

    protected Int32? _BranchID;

    [Branch()]

    [PXForeignReference(typeof(Field<branchID>.IsRelatedTo<Branch.branchID>))]

    [PXUIField(DisplayName = "Branch", Visibility = PXUIVisibility.SelectorVisible, Required = true, Enabled = true, Visible = true)]

    public virtual Int32? BranchID

    

        get

        

            return this._BranchID;

        

        set

        

            this._BranchID = value;

        

    

    #endregion







//Partial Detail DAC

public class PMCashflowProjectionSchedule : IBqlTable



    #region Date

    public abstract class date : PX.Data.BQL.BqlDateTime.Field<date>  

    protected DateTime? _Date;

    [PXDBDate()]

    [PXDefault(typeof(AccessInfo.businessDate), PersistingCheck = PXPersistingCheck.Nothing)]

    [PXUIField(DisplayName = "Date", Visibility = PXUIVisibility.SelectorVisible, Required = true, Enabled = true, Visible = true, IsReadOnly = false)]

    public virtual DateTime? Date

    

        get

        

            return this._Date;

        

        set

        

            this._Date = value;

        

    

    #endregion



    #region TranPeriodID

    public abstract class tranPeriodID : PX.Data.BQL.BqlString.Field<tranPeriodID>  

    protected String _TranPeriodID;

    [PXDefault()]

    [PeriodID(

        searchType: null,

        sourceType: typeof(date),

        defaultType: null,

        redefaultOnDateChanged: true)]

    [PXUIField(DisplayName = "Tran. Period", Visibility = PXUIVisibility.SelectorVisible, Required = true, Enabled = true, Visible = true)]

    public virtual String TranPeriodID

    

        get

        

            return this._TranPeriodID;

        

        set

        

            this._TranPeriodID = value;

        

    

    #endregion



    #region FinPeriodID

    public abstract class finPeriodID : PX.Data.BQL.BqlString.Field<finPeriodID>  

    protected String _FinPeriodID;

    [PXDefault()]

    [FinPeriodID(

        sourceType: typeof(date),

        branchSourceType: typeof(PMCashflowProjection.branchID),

        masterFinPeriodIDType: typeof(tranPeriodID),

        headerMasterFinPeriodIDType: typeof(tranPeriodID),

        redefaultOnDateChanged: true)]

    [PXUIField(DisplayName = "Fin. Period", Visibility = PXUIVisibility.SelectorVisible, Required = true, Enabled = true, Visible = true)]

    public virtual String FinPeriodID

    

        get

        

            return this._FinPeriodID;

        

        set

        

            this._FinPeriodID = value;

        

    

    #endregion




部分 ASPX 示例

//Form




        <px:PXSegmentMask runat="server" ID="edBranchID" DataField="BranchID" CommitChanges="True" AutoRefresh="True" />




//Grid Clumns

        <px:PXGridColumn DataField="Date" Width="80" CommitChanges="True" ></px:PXGridColumn>

        <px:PXGridColumn DataField="TranPeriodID" Width="80" CommitChanges="True" ></px:PXGridColumn>

        <px:PXGridColumn DataField="FinPeriodID" Width="80" CommitChanges="True" ></px:PXGridColumn>



// Grid Row Template

        <px:PXDateTimeEdit runat="server" ID="edDate" DataField="Date" CommitChanges="True" AutoRefresh="True" ></px:PXDateTimeEdit>

        <px:PXMaskEdit runat="server" ID="edTranPeriodID" DataField="TranPeriodID" CommitChanges="True" Size="s" ></px:PXMaskEdit>

        <px:PXMaskEdit runat="server" ID="edFinPeriodID" DataField="FinPeriodID" CommitChanges="True" Size="s" ></px:PXMaskEdit>

【问题讨论】:

【参考方案1】:

PeriodId 属性及其后代的工作看起来有点棘手,因为它们共享缓存。如果不进行这种定制和调试,经验法则是使用这些时间段来模拟多个开箱即用 DAC 的声明。我看到这个声明与标准的两个不同之处可能会起作用:

    FinPeriodId 通常在 TranPeriodId 声明之前。它看起来很重要,因为用于 periodid 默认的源字段来自 FinPeriodId 字段上的属性规范

    在 sourceType 声明中,通常指定 DAC 名称。所以考虑使用以下语法:

    [FinPeriodID( sourceType: typeof(PMCashflowProjectionSchedule.date),

【讨论】:

【参考方案2】:

您可以使用 PXDefault 属性在页面加载时设置默认值,如果您希望允许用户更改默认值,可以将字段设置为具有 PXSelector 属性的 Selector 类型。

以下 PXDefault 属性的示例从财务期间和当前业务日期获取默认值:

[PXUIField(DisplayName = "Fin. Period", Required = true)] 
[FinPeriodIDFormatting()]
[PXDefault(typeof(SearchFor<MasterFinPeriod.finPeriodID>
    .Where<MasterFinPeriod.endDate.IsGreaterEqual<AccessInfo.businessDate.FromCurrent>
    .And<MasterFinPeriod.startDate.IsLessEqual<AccessInfo.businessDate.FromCurrent>>>),
    PersistingCheck = PXPersistingCheck.Nothing)]

[PXSelector(typeof(SearchFor<MasterFinPeriod.finPeriodID>.In<SelectFrom<MasterFinPeriod>
    .Where<MasterFinPeriod.endDate.IsLessEqual<AccessInfo.businessDate.FromCurrent>
    .And<MasterFinPeriod.finPeriodID.IsNotNull>>>
    .OrderBy<MasterFinPeriod.finPeriodID.Desc>>))]

FinPeriodIDFormatting() 属性格式为 MM-YYYY

<px:PXSelector CommitChanges="True" runat="server" ID="edTranPeriodID" DataField="TranPeriodID" ></px:PXSelector>
<px:PXSelector CommitChanges="True" runat="server" ID="edFinPeriodID" DataField="FinPeriodID" ></px:PXSelector>

【讨论】:

以上是关于如何在 Acumatica 中获取交易期间和财务期间的默认值的主要内容,如果未能解决你的问题,请参考以下文章

Sap为啥要关闭账期

Sap为啥要关闭账期

Acumatica:触发器在另一个自定义按钮上保存验证

基金加强人工智能来挖掘财务报表数据并获取交易信号-投资创新仍在继续

SAP FI 中4个特殊期间

Java精品项目前后端分离源码39期家庭财务管理系统