简体   繁体   English

根据账单和调整中的自定义日期字段计算发票日期和折扣日期

[英]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:为此,可以使用以下步骤:

  1. Add event that you use for setting a breakpoint using a customization.添加用于使用自定义设置断点的事件。 In that case FieldUpdating is the best match.在这种情况下,FieldUpdating 是最佳匹配。
 public class APInvoiceEntry_Extension : PXGraphExtension<APInvoiceEntry> { public void APInvoice_DueDate_FieldUpdating(PXCache cache, PXFieldUpdatingEventArgs e) { } }
  1. Publish the customization.发布自定义。

  2. 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项目(管理员模式)

  3. Set a breakpoint to the event为事件设置断点

  4. Attach debugger.附加调试器。 In Visual studio Menu go to Debug -> Attach to process -> attach to IIS process (usually the name is w3wp.exe) (make sure checkbox Show processes from all users is checked)在 Visual Studio 菜单中,转到Debug -> Attach to process -> 附加到 IIS 进程(通常名称为 w3wp.exe)(确保选中“ Show processes from all users复选框)
  5. Trigger field update.触发字段更新。 In this case you can change Doc Date to trigger Due Date recalculation.在这种情况下,您可以更改文档日期以触发到期日期重新计算。
  6. When breakpoint is hit, check the Call Stack Window当断点被命中时,检查调用堆栈窗口在此处输入图片说明
  7. You can navigate through call stack double clicking on rows.您可以通过双击行浏览调用堆栈。 In that case 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看起来很有希望。
  8. Normally, you should see the code of everything that is in PX.Objects.dll, but if you don't see it, here are steps to fix it:通常,您应该会看到 PX.Objects.dll 中所有内容的代码,但如果您没有看到,请按以下步骤进行修复:
    • Make sure you set Install debugger tools when you install Acumatica ERP确保在安装 Acumatica ERP 时设置了Install debugger tools
    • Disable Enable Just My Code option in Visual Studio Settings在 Visual Studio 设置中禁用Enable Just My Code选项
    • You can manually point visual studio to source code located in SiteFolder\\App_Data\\CodeRepository\\PX.Objects您可以手动将 Visual Studio 指向位于SiteFolder\\App_Data\\CodeRepository\\PX.Objects源代码
  9. Explore the code to find a best place to override the logic.探索代码以找到覆盖逻辑的最佳位置。 In that case, the best way would be to create a new attribute derived from TermsAttribute and rewrite CalcTerms method (that way you will still be able to reuse base CalcTermsDates method)在这种情况下,最好的方法是创建一个从 TermsAttribute 派生的新属性并重写CalcTerms方法(这样您仍然可以重用基本的CalcTermsDates方法)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 套件组装-自定义日期字段 - Kit Assembly - Custom Date Field 从“账单和调整”屏幕上的按钮打开弹出的自定义Acumatica屏幕 - Open custom Acumatica screen as popup from button on Bills and Adjustments screen Acumatica-将销售订单折扣详细信息选项卡上的自定义字段中的数据复制到发票折扣详细信息选项卡上的自定义字段 - Acumatica-Copying data from custom field on the Sales order discount detail tab to custom field on the Invoice discount detail tab 支票和付款中出现空的“发票日期”错误 - Empty 'Invoice Date' error on Checks and Payments 如何强制启用帐单和调整屏幕的文档详细信息网格上的字段 - How can I force a field to be enabled on the Bills and Adjustments screen's Document Details grid 将自定义操作添加到账单和调整 (AP301000) 屏幕上操作菜单的特殊文件夹 - Adding custom action to Special Folders of action menu on Bills and Adjustments (AP301000) screen 需要在准备发票流程中使用更新的请求日期 - Need to use updated Requested Date on Prepare Invoice process Acumatica Report Writer从日期时间字段中提取日期 - Acumatica Report Writer extract date from date time field 使用webservices API更新Acumatica ERP系统屏幕发票和备忘录中的交货日期(自定义字段) - Update Delivery Date (Custom Field) in screen Invoices and Memos of Acumatica ERP System using webservices API 如何使用 BQL/FBQL(Acumatica) 按企业帐户选择最近的发票日期? - How to select most recent Invoice Date by Business Account using BQL/FBQL(Acumatica)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM