如何更改APInvoice类型(账单,信用调整等)的外观?

时间:2019-06-20 22:10:08

标签: acumatica

客户在将“借项调整”和“贷方调整”输入到“应付账款”时遇到了麻烦,因为他们更熟悉“借项备忘录”和“贷项备忘录”。由于他们混淆了两者,因此当他们打算输入贷方调整时,他们通常会输入借方调整。我们如何更改借项和贷项调整的外观,使其显示为贷项和借项备忘录?

我们已经跟踪了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

我的新代码如下:

APPaymentEntry:

    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
  }

CustomAPPaymentType:

  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 )
          {
          }
      }

  }

CustomAPPaymentTypeListAttribute

    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类型的当前设置保持准确,关于我出了错的地方有何建议?

1 个答案:

答案 0 :(得分:1)

您可以通过以下方式实现此目标:

警告 以下提供的自定义功能不会在整个系统中将“借方和贷方调整”标签更改为“贷方和借项通知单”,因此您需要进行修改所有DAC的属性。

  1. 首先,您需要更改基本属性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 )
            {
            }
        }
    }
    
  2. 现在您需要更改APMigrationModeDependentInvoiceTypeListAttribute中的标签,以使我继承自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);
        }
    }
    
  3. 最后一步是将此步骤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
    }
    

发布此代码后,您将看到类型下拉列表显示的是贷项和借项备忘录,如以下屏幕截图所示:

enter image description here