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

That looks mostly correct but that is the wrong graph if you are trying to reverse an application.

 

ReverseApplication is an action on the APPaymentEntry graph. You will typically call an action as

APPaymentEntry.reverseApplication.Press(adapter)

The adapter is optional you can also just call Press(). The case does matter as reverseApplication is the PXAction and ReverseApplication is the handler(you can call this directly but it is generally advisable to use the action, and calling it directly you will have to supply an adapter). 

Userlevel 6
Badge +5

It sounds like ReverseApplication is what you are looking for. Voiding will void(cancel) the payment.

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

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 7
Badge +17

Hi @Ivan  Once Document is changed to CLOSED status, you cannot change it BALANCED, you can only do VOID and create new document

.

Userlevel 7
Badge +17

Hi @Ivan  Once you click on the VOID, it will create a new VOIDED CHECK type of document against CHECK document and once you RELEASE it, the status will be changed to CLOSED

 

Userlevel 6
Badge +5

You can reverse the applications that closed the check to bring it back to an OPEN state but you cannot get it back to a BALANCED state. 

BALANCED → OPEN for AR/AP Documents involves posting to the GL at that point you would need to void(or create a canceling document) instead of deleting or changing the document. 

Voiding a check will move it to the voided status.

Userlevel 7
Badge +17

Yes, it is possible.

you can invoke form Base graph like below.

Base.putonhold.Press();

Base.ReleaseFromHold.Press();

Userlevel 6
Badge +5

Void will void the check and it creates a Voided Check document to cancel out the original check.

Via the APPaymentEntry graph the action is called ReverseApplication so yes you can invoke it programmatically. It creates an inverted application against the check that will move it from closed → open once released. You can invoke actions on graphs by using [Graph(Instance)].[Action].Press().

 

Edit: if you are making a process screen you will likely want to use PXGraph.CreateInstance to get an instance of the APPaymentEntry graph. You can then set the current document to whatever APPayment you are handling and invoke the necessary actions. 

Userlevel 6
Badge +5

ReverseApplication just reverses the currently selected application which is the adjustment that applies x amount from the check to a document(usually an AP Invoice).

If you are trying to void a check there is a voidCheck action that you can call in the same way. 

You are also not searching for APInvoice.refNbr you should be searching for APPayment.refNbr.

Userlevel 4
Badge +2

Unfortunately that error doesn’t give much information, just that something that the method was trying to reference was null. It’s not an error I’ve come across before. You can unpublish your customizations and then republish one by one to figure out which one is causing it though.

Hi @markusray17 

we updated Acumatica from 2020R2 to 2021R2

Now I am able to use code that You suggested in previous message

I have added this part

graph.APPost.Current = graph.APPost.SelectSingle();

but now I am getting Object reference

Before I did not added I did not receive any errors

please, suggest what I should fix

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

ReverseApplication just reverses the currently selected application which is the adjustment that applies x amount from the check to a document(usually an AP Invoice).

If you are trying to void a check there is a voidCheck action that you can call in the same way. 

You are also not searching for APInvoice.refNbr you should be searching for APPayment.refNbr.

Hi @markusray17 

I need to clarify one moment. My goal is to return “closed” item to “Open” state. The requirement is to return payment to previous state in case if User made the mistake and payment was not performed for definite item, so in that case Checks and Payments item must be returned and be available until the payment will be performed.

Firstly I thought it should be done via voidCheck, but now due to your response I think ReverseApplication  is what should be used. Suggest, please, which approach will be better for my aim 

Userlevel 4
Badge +2

It sounds like ReverseApplication is what you are looking for. Voiding will void(cancel) the payment.

There must be something that I am missing

After that code was executed, the payment remains being closed 

 

Userlevel 6
Badge +5

You need to set the current adjustment that is going to be reversed. I believe Acumatica just changed the naming but in 2021 R2 the view is called APPost. Its the view under the Application History tab. 

If the method doesn’t find a current application it doesn’t do anything.

 

 

Userlevel 4
Badge +2

You need to set the current adjustment that is going to be reversed. I believe Acumatica just changed the naming but in 2021 R2 the view is called APPost. Its the view under the Application History tab. 

If the method doesn’t find a current application it doesn’t do anything.

 

 

@markusray17 

The version of Acumatica is 2020R2

Can you please clarify what adjustment should be taken and where to set it ?

I did not see such parameter at Checks and Payments item fields values 

 

Userlevel 6
Badge +5

For the reverse application action to work you have to first select an application to reverse. Under the Application History tab is where you can see all the released applications. In the UI you would click one of the application rows and then click the Reverse Application button.

To accomplish this via code you would need to set the current record of the application history view to the application you want to reverse before calling reverseApplication. I don’t know the name of the view in 2020R2 but it should be easy to inspect the grid to get the view name.

Userlevel 4
Badge +2

For the reverse application action to work you have to first select an application to reverse. Under the Application History tab is where you can see all the released applications. In the UI you would click one of the application rows and then click the Reverse Application button.

To accomplish this via code you would need to set the current record of the application history view to the application you want to reverse before calling reverseApplication. I don’t know the name of the view in 2020R2 but it should be easy to inspect the grid to get the view name.

@markusray17 

At Acumatica 2020R1 I can check ReverseApplication

but at 2020R2 I receive exception when I try to check name of this Action via Customization tab

How can I troubleshoot it ?

According to your response : “To accomplish this via code you would need to set the current record of the application history view to the application you want to reverse before calling reverseApplication”

Setting current record it means transferring ReeferenceNbr of item that I need to reverse ?

What should be putted to my code from that place ? 

 

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