Skip to main content
Solved

Error in APInvoice deleting

  • February 11, 2025
  • 7 replies
  • 71 views

Forum|alt.badge.img
  • Jr Varsity II
  • 11 replies

 

Best answer by ron

This was Canada Localization issue. I found out it was fixed in the newest build.

View original
Did this topic help you find an answer to your question?

7 replies

Forum|alt.badge.img
  • Jr Varsity I
  • 57 replies
  • February 11, 2025

Hi ​@ron 

Based on the error messages you've shared, I can see you're encountering a System.NullReferenceException during the AP Invoice deletion process. The error occurs specifically in the MoveNext() operation, suggesting an issue with record traversal during deletion.

Analysis of the Error:The stack trace shows the error is occurring in the following sequence:

APInvoiceEntry deletion process

Project Accounting module interaction (PX.Objects.CN.ProjectAccounting)

Transaction persistence layer

Possible Causes & Solutions:

1.Project-Related Links

Check if the invoice is linked to any project transactions

Verify and release any project-related holds or links before deletion

2.Transaction Dependencies

Ensure all related payment applications are properly released

Verify there are no pending GL transactions

3.Data Integrity Steps:

Release the document if it's not in Balanced status

Clear any payment applications

Check for and handle any tax adjustments

Code:

If you want to add additional validation before deletion, you can implement this code in your APInvoiceEntry extension:

public class APInvoiceEntryExt : PXGraphExtension<APInvoiceEntry>
{
    protected virtual void _(Events.RowDeleting<APInvoice> e)
    {
        var invoice = e.Row;
        if (invoice == null) return;

        // Check for related project records
        var projectTrans = PXSelect<PMTran,
            Where<PMTran.aPDocType, Equal<Required<APInvoice.docType>>,
                And<PMTran.aPRefNbr, Equal<Required<APInvoice.refNbr>>>>>
            .Select(Base, invoice.DocType, invoice.RefNbr);

        if (projectTrans.Count > 0)
        {
            throw new PXException("Cannot delete invoice with related project transactions");
        }

        // Add additional validation as needed
        var applications = PXSelect<APAdjust,
            Where<APAdjust.adjdDocType, Equal<Required<APInvoice.docType>>,
                And<APAdjust.adjdRefNbr, Equal<Required<APInvoice.refNbr>>>>>
            .Select(Base, invoice.DocType, invoice.RefNbr);

        if (applications.Count > 0)
        {
            throw new PXException("Cannot delete invoice with existing applications");
        }
    }
}

Recommended Troubleshooting Steps:

  1. First, try releasing the document if it's not already released
  2. Navigate to the Applications tab and verify no payment applications exist
  3. Check Project module for any related transactions
  4. Use the Process Records action to ensure all related records are in the correct state

This will help us provide more specific guidance for your situation.


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 11 replies
  • February 11, 2025

I think it's something with canada localization.
When i turn it off I am able to delete it.
Also one instance works correctly with same code regardless  of localization although its on upgraded build from 24.204 to 24.205.
Not really sure what exactly is problem, maybe need to escalate to acumatica directly


Forum|alt.badge.img
  • Jr Varsity I
  • 57 replies
  • February 11, 2025

Hi ​@ron,

Thank you for the additional information about the Canada localization. This is a valuable insight that helps narrow down the issue.

 

If the invoice deletion works when the Canada localization is turned off, this suggests a potential issue in the interaction between the AP Invoice deletion process and the Canadian tax reporting/calculation components.

A few observations that might help others:

The issue appears to be specific to Canada localization

The fact that it works on another instance with the same code (24.204 to 24.205) suggests it might be data or configuration related

The NullReferenceException in the stack trace shows involvement of ProjectAccounting, which might be interacting with localization-specific tax calculations

Recommendations:

Check if there are any Canadian tax details or reporting elements attached to the invoice

Compare the configuration settings between your working and non-working instances

Since this appears to be localization-specific and behaves differently across instances with the same build, it would indeed be best to escalate this to Acumatica Support for further investigation

If others encounter this issue, they should check if:

They are using Canadian localization

The issue resolves when temporarily disabling the localization

The behavior is consistent across different instances of the same build

Could you share your Canadian tax configuration settings? This might help identify specific settings that could be triggering this behavior.


darylbowman
Captain II
Forum|alt.badge.img+13

Yes, as the trace indicates, it is in the RowPersisted event handler for CA localization of that screen. It may be possible to decompile the localization and identify where the issue arises from, but it’s probably more prudent to simply submit a support case.


Forum|alt.badge.img+12
  • Acumatica Support Team
  • 866 replies
  • February 13, 2025

Hi ​@ron 

The Trace is pointing to custom object highlighted below. Not sure if this is part of Canada localization customization or any other customization. 

Regards,

 


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 11 replies
  • Answer
  • February 26, 2025

This was Canada Localization issue. I found out it was fixed in the newest build.


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2751 replies
  • February 26, 2025

Thank you for sharing the solution with the community ​@ron!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings