[英]Calculate Invoice Date and Discount Date based on Custom Date field in Bills and Adjustments
I have created a custom date field 'Invoice Date' in Bills and Adjustments.我在账单和调整中创建了一个自定义日期字段“发票日期”。 In Bils and Adjustments, Due Date and Cash Discount Date calculated based on DocDate and selected TermsID.
在账单和调整中,到期日和现金折扣日期根据 DocDate 和选定的条款 ID 计算。
But instead of DocDate, I would like to use the date from my custom field 'Invoice Date' for the calculation of Due Date and Cash Discount Date.但我想使用自定义字段“发票日期”中的日期而不是 DocDate 来计算到期日期和现金折扣日期。
I tried searching for DocDate and TermsID's field updated event in the APInvoiceEntry graph and also tried to find the PXFormula attribute in CacheAttached for Due Date and Cash Discount date in the graph.我尝试在 APInvoiceEntry 图中搜索 DocDate 和 TermsID 的字段更新事件,还尝试在图中的到期日期和现金折扣日期的 CacheAttached 中查找 PXFormula 属性。 Moreover, I also looked at APInvoice DAC to find the formula for Due Date and Cash Discount Date but couldn't find anywhere.
此外,我还查看了 APInvoice DAC 以找到到期日期和现金折扣日期的公式,但找不到任何地方。 I tried to find methods in DiscountEngine class as well, but no luck.
我也试图在 DiscountEngine 类中找到方法,但没有运气。
Thank you.谢谢你。
TL;DR TL; 博士
Create a new attribute derived from TermsAttribute and rewrite CalcTerms
method.创建一个从 termAttribute 派生的新属性并重写
CalcTerms
方法。 Replace attribute on TermsID
field.替换
TermsID
字段上的属性。
Proper Answer正确答案
The most robust way to understand the logic that updates some field is to use debugger.理解更新某些字段的逻辑的最可靠方法是使用调试器。 To do that can use the following steps:
为此,可以使用以下步骤:
public class APInvoiceEntry_Extension : PXGraphExtension<APInvoiceEntry> { public void APInvoice_DueDate_FieldUpdating(PXCache cache, PXFieldUpdatingEventArgs e) { } }
Publish the customization.发布自定义。
Open the code in Visual Studio在 Visual Studio 中打开代码
A. If you use runtime code (built in code editor in customization project), go to SiteFolder\\App_RuntimeCode
and open the needed file in visual studio (administrator mode). A. 如果您使用运行时代码(自定义项目中内置代码编辑器),请转到
SiteFolder\\App_RuntimeCode
并在 Visual Studio(管理员模式)中打开所需的文件。
B. If you use Extension library, open your Visual studio project (administrator mode) B.如果你使用扩展库,打开你的Visual Studio项目(管理员模式)
Set a breakpoint to the event为事件设置断点
Debug
-> Attach to process
-> attach to IIS process (usually the name is w3wp.exe) (make sure checkbox Show processes from all users
is checked)Debug
-> Attach to process
-> 附加到 IIS 进程(通常名称为 w3wp.exe)(确保选中“ Show processes from all users
复选框)PX.Objects.dll!PX.Objects.CS.TermsAttribute.CalcTerms(PX.Data.PXCache sender, PX.Data.PXFieldUpdatedEventArgs e) Line 3461
looks promising.PX.Objects.dll!PX.Objects.CS.TermsAttribute.CalcTerms(PX.Data.PXCache sender, PX.Data.PXFieldUpdatedEventArgs e) Line 3461
看起来很有希望。Install debugger tools
when you install Acumatica ERPInstall debugger tools
Enable Just My Code
option in Visual Studio SettingsEnable Just My Code
选项SiteFolder\\App_Data\\CodeRepository\\PX.Objects
SiteFolder\\App_Data\\CodeRepository\\PX.Objects
源代码CalcTerms
method (that way you will still be able to reuse base CalcTermsDates
method)CalcTerms
方法(这样您仍然可以重用基本的CalcTermsDates
方法)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.