Solved

Change "Closed" status on "Balanced" for Checks and Payments Item programmatically


Userlevel 4
Badge +2

Hi,

My application releases payment via this event

Is there opportunity to return Checks and Payments item status from “Closed” to “Balanced” ?

 

icon

Best answer by markusray17 6 April 2022, 20:34

View original

43 replies

Userlevel 6
Badge +5

Its difficult to say with such limited context. My best guess would be that graph.APPost.SelectSingle() is returning null(because there are no released adjustments). You can debug into the reverseApplication method to get more information.

Does the payment that you are trying to reverse the application for actually have an application?

Userlevel 4
Badge +2

@markusray17

Can you explain what adjustments it should contain ?

I need to process any Payments that were released accidently and return them back 

I checked my item 

Is there universal approach to return Payments back after they were released ?

Userlevel 6
Badge +5

When a payment is released it is really just releasing the adjustments that are under the Document to Apply tab, a payment is moved to the closed status when it no longer has an open balance on it. Released adjustments will show under the application history tab.

So what your code is supposed to be doing is setting the Current adjustment and then invoking the reverse application action. 

Assuming the payment does have an adjustment to be reversed I would check that your code is getting that record and setting it to the current value(debug and check the variable values). And if that all looks good, you can debug into the reverseApplication method to get a more exact idea of what is throwing that error. 

Userlevel 4
Badge +2

When a payment is released it is really just releasing the adjustments that are under the Document to Apply tab, a payment is moved to the closed status when it no longer has an open balance on it. Released adjustments will show under the application history tab.

So what your code is supposed to be doing is setting the Current adjustment and then invoking the reverse application action. 

Assuming the payment does have an adjustment to be reversed I would check that your code is getting that record and setting it to the current value(debug and check the variable values). And if that all looks good, you can debug into the reverseApplication method to get a more exact idea of what is throwing that error. 

@markusray17 

I checked record for setting  to the current value and it looks good. I am receiving adjustment

How exactly I should debug into the reverseApplication ? Its just throwing exception here

Userlevel 6
Badge +5

You place a breakpoint inside the ReverseApplication method in APPaymentEntry.cs then walk through that method to see what is causing the error.

Userlevel 4
Badge +2

You place a breakpoint inside the ReverseApplication method in APPaymentEntry.cs then walk through that method to see what is causing the error.

@markusray17 

I must override reverseApplication method ?

Because “go to implementation” option is not available and “go to definition” gives me this

 

Userlevel 6
Badge +5

No, you would navigate to APPaymentEntry.cs which is in the Acumatica source code and add a breakpoint at the start of the ReverseApplication method. 

Userlevel 6
Badge +5
Solution Explorer - Visual Studio
APPaymentEntry.cs

A limited subset of the Acumatica source code is kept inside the CodeRepository folder and you can use it for debugging.

The breakpoint should trigger once the action is called. From there you can just step through the method and figure out where/why the error is occurring.

Userlevel 4
Badge +2
Solution Explorer - Visual Studio
APPaymentEntry.cs

A limited subset of the Acumatica source code is kept inside the CodeRepository folder and you can use it for debugging.

The breakpoint should trigger once the action is called. From there you can just step through the method and figure out where/why the error is occurring.

Hi @markusray17 

I entered this method 

but debug do not enter here. Project is built. 

Can be problem be in moment that this method requires PXAdapter, but I do not send this object 

If problem can be in that , how I must send it here ?

Userlevel 6
Badge +5

Your breakpoints aren’t bound, that’s what that little hazard icon on them means. Calling the press method generates the adapter before calling the actual handler. If you hover over the breakpoints visual studio should tell you why they aren’t bound. I think by default Visual Studio has the “Just My Code” setting enabled that you would need to disable to debug Acumatica code.

 

Here’s an article that goes a bit more in depth: https://asiablog.acumatica.com/2016/04/debug-acumatica-code.html

Userlevel 4
Badge +2

Your breakpoints aren’t bound, that’s what that little hazard icon on them means. Calling the press method generates the adapter before calling the actual handler. If you hover over the breakpoints visual studio should tell you why they aren’t bound. I think by default Visual Studio has the “Just My Code” setting enabled that you would need to disable to debug Acumatica code.

 

Here’s an article that goes a bit more in depth: https://asiablog.acumatica.com/2016/04/debug-acumatica-code.html

it causes error in this method 

 

Userlevel 6
Badge +5

At this point you just need to do some standard debugging to figure out what is causing the issue. It would seem that something is attempting to set that field to a null value(trying to cast null as a non-nullable decimal would cause that error) . I would try and figure out where in the ReverseApplication method is triggering the event handler and track the value of that field.

Userlevel 4
Badge +2

At this point you just need to do some standard debugging to figure out what is causing the issue. It would seem that something is attempting to set that field to a null value(trying to cast null as a non-nullable decimal would cause that error) . I would try and figure out where in the ReverseApplication method is triggering the event handler and track the value of that field.

It looks like I do it in wrong way or this approach does not fit for my goal.

I can not currently debug it as usually, because when I try to check the callstack of Acumatica it gives me this 

Also in watch not all object are available for check

Is there opportunity to troubleshoot it ?

Userlevel 6
Badge +5

You would want to catch the event handler using a breakpoint. You would step through the ReverseApplication method line by line and see where it is triggering that event handler. You shouldn’t need to debug the file in your screenshot. Some values will be optimized away and not available to read. 

Userlevel 4
Badge +2

You would want to catch the event handler using a breakpoint. You would step through the ReverseApplication method line by line and see where it is triggering that event handler. You shouldn’t need to debug the file in your screenshot. Some values will be optimized away and not available to read. 

The error occurs in Adjustments.Update(adj); row. In Update method it calls this event 

 

Userlevel 7
Badge

Hi @Ivan have you been able to resolve your issue or do you still need assistance from @markusray17 ? Thank you!

Userlevel 4
Badge +2

Hi @Ivan have you been able to resolve your issue or do you still need assistance from @markusray17 ? Thank you!

Hi @Chris Hackett 

Thanks for the reply

I stopped at the stage that I described in my last comment, can’t fix it still 

 

Userlevel 4
Badge +2

Yes, it is possible.

you can invoke form Base graph like below.

Base.putonhold.Press();

Base.ReleaseFromHold.Press();

Hi @Naveen Boga 

I am trying to implement logic that we discussed, unfortunately, payment is not being removed from hold when this code is executed,

 string referenceNbr = "001985";
                APPaymentEntry graph = PXGraph.CreateInstance<APPaymentEntry>();
                graph.Document.Current = graph.Document.Search<APPayment.refNbr>(referenceNbr);
                graph.UnattendedMode = false;
                try
                {
                    graph.voidCheck.Press();
                }
                catch (PXRedirectRequiredException) { }
                // graph.Document.Current.Status = "B";
                graph.putOnHold.Press();
                graph.releaseFromHold.Press();

However, it worked for several items, for example : 001987 and 001986 were void via code if I missed part with removing from hold

But it did not worked for item 001985, can you suggest what is wrong with my code ?

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved