如何更改APInvoice类型(账单,信用调整等)的外观? [英] How to change the appearance of APInvoice types (Bill, Credit Adjustment, etc)?

查看:33
本文介绍了如何更改APInvoice类型(账单,信用调整等)的外观?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

A client has troubles entering in Debit Adjustments and Credit Adjustments into Payables, because they are more familiar with the terms Debit Memos and Credit Memos. Because they have confuse the two, they often enter a Debit Adjustment when they mean to enter a Credit Adjustment. How can we change the appearance of the Debit and Credit Adjustments so they appear as Credit and Debit Memos?

我们已经跟踪了APInvoice从何处获取DocType值的来源到PX.Objects\AP\Descriptor\Messages.cs文件。但是,我们不确定如何通过自定义项目访问它。

We have traced the source of where APInvoice gets the values of the DocType to the PX.Objects\AP\Descriptor\Messages.cs file. However we aren't sure how to access it via a customization project.

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等于贷记凭证。请让我们知道是否可行,以及尝试更改这些值是否存在任何已知问题,或者这不是一个好习惯。

What we want is for CreditAdj to equal "Debit Memo" and DebitAdj to equal "Credit Memo". Please let us know if this is possible and if there are any known problems with trying to change these values or if this is not a good practice.

编辑:现在,我感谢Samvel的回答,我们设法实现了标签更改,我已经尝试对APPayment做类似的事情。出现了一个问题,加载屏幕时出现错误:

错误:values数组的长度不等于标签数组的长度。
参数名称:allowedLabels

Now that I've managed to implement the label changes thanks to Samvel's answer, I've attempted to do something similar for APPayment. An issue has come up where an error appears when loading the screen:
Error: The length of the values array is not equal to the length of labels array. Parameter name: allowedLabels

我的新代码如下:

APPaymentEntry:

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:

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

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

I'm unsure on how to proceed, it seems like I either have too many 'Labels' or 'Values' but it isn't clear on which. I tried to be as accurate to the current setup for current types for APPayment, any advice on where I went wrong?

推荐答案

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

You can achieve this goal in the following way:

警告 以下提供的自定义设置不会更改借记卡和在整个系统中,Credit Adj标签都标记为贷记凭证,为此,您将需要修改所有DAC的属性。

WARNING the customization provided below doesn't change the Debit and Credit Adj labels to Credit and Debit Memo throughout the whole system, for doing that you will need to modify attributes for all the DACs.


  1. 首先,您需要更改基本属性 APInvoiceType.List 中的标签,我将从 APInvoiceType 继承如下所示:

  1. First, you need to change labels in the base attribute which is APInvoiceType.List, I will inherit from APInvoiceType for doing it like below:

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 的作用是,我将从 CustomAPInvoiceType.ListAttribute 继承,这是我在上一步中定义的,如下所示:

  • Now you need to change the labels in the APMigrationModeDependentInvoiceTypeListAttribute for doing that I will inherit from CustomAPInvoiceType.ListAttribute, which I have defined in the previous step like below:

    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

  • The last step is to apply this attribute from step 2 to DocType field, we will do it using CacheAttached event handler and 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
    }
    


  • 发布此代码后,您将看到类型下拉菜单显示的是贷项和借项通知单,如下面的屏幕快照:

    After publishing this code you will see that the Dropdown for type is showing Credit and Debit Memo like ob the screenshot below:

    这篇关于如何更改APInvoice类型(账单,信用调整等)的外观?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆