acumatica - 如何更改 API 发票类型(账单、信用调整等)的外观?
问题描述
客户在将借方调整和贷方调整输入应付账款时遇到了麻烦,因为他们更熟悉借方备忘录和贷方备忘录这两个术语。因为他们混淆了两者,当他们打算输入贷方调整时,他们经常输入借方调整。我们如何更改借方和贷方调整的外观,使其显示为贷方和借方备忘录?
我们已经追踪到 APInvoice 获取 DocType 值的来源到 PX.Objects\AP\Descriptor\Messages.cs 文件。但是,我们不确定如何通过自定义项目访问它。
using System;
using PX.Common;
namespace PX.Objects.AP
{
[PXLocalizable(Messages.Prefix)]
public static class Messages
{
// Add your messages here as follows (see line below):
// public const string YourMessage = "Your message here.";
#region Validation and Processing Messages
#region Translatable Strings used in the code
#region Graph Names
#region DAC Names
#region Document Type
public const string Invoice = "Bill";
public const string CreditAdj = "Credit Adj.";
public const string DebitAdj = "Debit Adj.";
public const string Check = "Check";
public const string Prepayment = "Prepayment";
public const string Refund = "Vendor Refund";
我们想要的是 CreditAdj 等于“借方备忘录”和 DebitAdj 等于“贷方备忘录”。请让我们知道这是否可行,以及尝试更改这些值是否存在任何已知问题,或者这不是一个好的做法。
编辑:由于 Samvel 的回答,现在我已经设法实现标签更改,我尝试为 APPayment 做类似的事情。加载屏幕时出现错误的问题出现:
错误:值数组的长度不等于标签数组的长度。参数名称:allowedLabels
我的新代码如下:
APP支付入口:
public class APPaymentEntry_Extension : PXGraphExtension<APPaymentEntry>
{
#region Event Handlers
[PXDBString(3, IsKey = true, IsFixed = true)]
[PXDefault]
[PXUIField(DisplayName = "Type", Visibility =
PXUIVisibility.SelectorVisible, Enabled = true, TabOrder = 0)]
[PXFieldDescription]
[CustomAPPaymentTypeList]
protected virtual void APPayment_DocType_CacheAttached(PXCache sender)
{
}
#endregion
}
自定义APPPayment类型:
public class CustomAPPaymentType : APPaymentType
{
public new static readonly string[] NewLabels = new string[]
{
"Check",
"Credit Memo",
"Prepayment",
"Vendor Refund",
"Voided Refund",
"Voided Check"
};
public new class ListAttribute : PXStringListAttribute
{
public ListAttribute() : base(APPaymentType.Values, CustomAPPaymentType.NewLabels )
{
}
}
}
自定义APPPaymentTypeListAttribute
public class CustomAPPaymentTypeListAttribute : CustomAPPaymentType.ListAttribute
{
public override void CacheAttached(PXCache sender)
{
this._AllowedValues = new string[]
{
"CHK",
"ADR",
"PPM",
"REF",
"VRF",
"VCK"
};
this._AllowedLabels = new string[]
{
"Check",
"Credit Memo",
"Prepayment",
"Vendor Refund",
"Voided Refund",
"Voided Check"
};
this._NeutralAllowedLabels = new string[]
{
"Check",
"Credit Memo",
"Prepayment",
"Vendor Refund",
"Voided Refund",
"Voided Check"
};
base.CacheAttached(sender);
}
}
我不确定如何继续,似乎我的“标签”或“值”太多,但不清楚是哪个。我试图与当前 APPayment 类型的当前设置一样准确,关于我哪里出错的任何建议?
解决方案
您可以通过以下方式实现此目标:
警告下面提供的自定义不会在整个系统中将借方和贷方调整标签更改为贷方和借方备忘录,为此您需要修改所有 DAC 的属性。
首先,您需要更改基本属性中的标签,即
APInvoiceType.List
,我将继承自APInvoiceType
,如下所示:public class CustomAPInvoiceType : APInvoiceType { public new static readonly string[] NewLabels = new string[] { "Bill", "Debit Memo", "Credit Memo", "Prepayment" }; public new class ListAttribute : PXStringListAttribute { public ListAttribute() : base(APInvoiceType.Values, CustomAPInvoiceType.NewLabels ) { } } }
现在您需要更改
APMigrationModeDependentInvoiceTypeListAttribute
我将继承自的 for中的标签CustomAPInvoiceType.ListAttribute
,我在上一步中已定义如下:public class CustomAPMigrationModeDependentInvoiceTypeListAttribute : CustomAPInvoiceType.ListAttribute { public override void CacheAttached(PXCache sender) { APSetup apsetup = (sender.Graph.Caches[typeof(APSetup)].Current as APSetup) ?? PXSelectBase<APSetup, PXSelect<APSetup>.Config>.SelectWindowed(sender.Graph, 0, 1, Array.Empty<object>()); if (apsetup != null) { bool? migrationMode = apsetup.MigrationMode; bool flag = true; if (migrationMode.GetValueOrDefault() == flag & migrationMode != null) { this._AllowedValues = new string[] { "INV", "ADR", "ACR" }; this._AllowedLabels = new string[] { "Bill", "Credit Memo", "Debit Memo" }; this._NeutralAllowedLabels = new string[] { "Bill", "Credit Memo", "Debit Memo" }; base.CacheAttached(sender); return; } } base.CacheAttached(sender); } }
最后一步是将此属性从第 2 步应用到
DocType
字段,我们将使用CacheAttached
事件处理程序和PXGraphExtension
:public class APInvoiceEntry_Extension : PXGraphExtension<APInvoiceEntry> { #region Event Handlers [PXDBString(3, IsKey = true, IsFixed = true)] [PXDefault] [PXUIField(DisplayName = "Type", Visibility = PXUIVisibility.SelectorVisible, Enabled = true, TabOrder = 0)] [PXFieldDescription] [CustomAPMigrationModeDependentInvoiceTypeList] protected virtual void APInvoice_DocType_CacheAttached(PXCache sender) { } #endregion }
发布此代码后,您将看到类型的下拉菜单显示贷方和借方备忘录,如下面的屏幕截图所示:
推荐阅读
- javascript - \n 没有在新行中呈现文本
- angular - 我可以同时映射到 Observables,通过管道传输到 mergeMap -> forkJoin 并将对象传递到 RxJs 中的下游吗?
- node.js - 如何在运行 apache 的 aws ec2 的自动分配 IP 中启用 ssl?
- python - 为什么我可以在 Pandas DataFrames 上使用 numpy 函数?
- ios - 在 iPhone 7 Plus 上实现自定义触觉(具有不同的清晰度和强度)时遇到问题
- reactjs - 无法在编辑模式下为 react-admin 上传带有 ImageField 的图像
- .net - 如何使用 .NET 检查 SerialPort 奇偶校验错误
- vespa - vespa.ai 中的自然语言处理
- javascript - 如何导出动态?
- html - 意外输入 HTML 选择表单自定义值