You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Acumatica销售订单如何根据客户税区动态显示Sales Channel值

实现方案

你可以按照以下3个步骤完成调整:

1. 修改DAC字段配置

首先移除Sales Channel字段原有下拉列表相关的特性(如PXStringList/PXIntList),调整为只读的字符串字段,示例代码如下:

[PXString(10)]
[PXUIField(DisplayName = "Sales Channel", Enabled = false)] // 配置为只读,避免人工修改
public virtual string UsrSalesChannel { get; set; }
public abstract class usrSalesChannel : PX.Data.BQL.BqlString.Field<usrSalesChannel> { }

如果需要直接在DAC层完成计算逻辑,也可以追加PXDBScalar和PXFormula特性直接关联客户税区取值:

// 关联查询当前单据绑定客户的税区ID
[PXDBScalar(typeof(Search<Customer.taxZoneID, Where<Customer.bAccountID, Equal<Current<YourDocumentDac.customerID>>>>))]
// 根据税区判断返回对应显示值,将占位内容替换为你系统实际的本地税区ID和显示文本
[PXFormula(typeof(Switch<Case<Where<Customer.taxZoneID, Equal<string_aaa/*本地税区ID常量*/>>, string_ccc/*"本地"*/>, string_ddd/*"境外"*/>))]

2. (可选)通过Graph事件实现动态取值

如果希望逻辑更灵活便于后续调整,也可以在对应页面的Graph扩展类中添加FieldSelecting事件完成计算:

protected void YourDocumentDac_UsrSalesChannel_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e)
{
    if (e.Row == null) return;
    YourDocumentDac curRow = (YourDocumentDac)e.Row;
    // 查询当前关联客户的税区信息
    Customer curCustomer = PXSelect<Customer, 
        Where<Customer.bAccountID, Equal<Required<Customer.bAccountID>>>>.Select(Base, curRow.CustomerID);
    if (curCustomer == null) return;
    // 替换为你系统实际的本地税区ID判断条件
    e.ReturnValue = curCustomer.TaxZoneID == "LOCAL_TAX_ID" ? "本地" : "境外";
}

如果需要把计算后的Sales Channel值存入数据库,可追加RowPersisting事件在单据保存前自动赋值即可。

3. 调整页面控件类型

打开自定义项目编辑器,找到对应页面的Sales Channel字段配置,将原有控件类型从PXDropDown(下拉列表)改为PXTextEdit(文本框),保存后发布自定义项目即可生效。

提示:上述代码中的YourDocumentDac、UsrSalesChannel等占位符请替换为你系统实际的DAC名称、自定义字段名。

内容的提问来源于stack exchange,提问作者Tharidhi P

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.28 17:39:02