Solved

Call Void action for Checks and Payment item



Show first post

42 replies

Userlevel 4
Badge +2

You probably have the Hold Documents on Entry option selected in the AP Preferences.

You would have to use the Remove Hold action before releasing then. 

 

The reason for extending APPaymentEntry wasn’t related to your business logic it was a temporary method to allow you intercept and debug the Release call.

This code partly solved my issue

It voided some payments if I missed removefromhold and release steps

At this screen 001989 and 001989 items were voided 

But if I leave all my code to execute payment will appear closed 

What I must change in order to make payment availble after hold ? I mean to make it open or balanced (justnot being closed)

Userlevel 6
Badge +5

There’s no reason to put the voided check on hold, you can just check if it is on hold and then if it is call the release from hold action. 

You have asked this a few times now but:

Reversing the applications will move a payment from closed → open. Voiding a payment will reverse the applications and cancel the payment moving it from closed → voided. There is no way to move a payment from closed → balanced. 

If the payment is still closed then the voiding didn’t work, judging from your screenshot the voided checks didn’t get released.

If you need to reverse payments you will likely run into an error(“document is out of balance”) I believe they are changing it in future versions but currently the system doesn’t allow AP payments with open balances. Meaning you would have to reverse and re-apply the payment at the same time in order to persist it. 

Also I have probably said it before but I would suggest you take a step back from the code and take a second to understand what you are doing and what you are trying to accomplish. You seem to be unsure on whether you want to re-open payments or cancel them and you seem to have little understanding about how the payments work in the system. I can try to point you in the right direction but your lack of understanding is likely to result in problems for you down the line. This is also one of the more complicated and sensitive parts of the system so you really don’t want any potentially critical bugs. 

Userlevel 4
Badge +2

You already added that

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

The Update and Insert methods aren’t changing the values, they raise events and event handlers modify the values. One of those event handlers is setting that value to null during:

Adjustments.Update(adj);

What I am saying is using the call stack and debugger you can see the method chain when that value is set to null and then figure out which event handler is the cause and why. 

That being said if it is working in the UI for the same record the issue is likely with the surrounding code or the context from which you are invoking the action. 

Hi @markusray17 

Previously, I checked in UI reverse application and it worked,

As I discovered now, it returns Closed state to Open, but it does not allow to save it in UI with this error 

How payment should be modified to resolve this error ?

Can this be the cause of my problem ?

Userlevel 4
Badge +2

Hi @markusray17 

Unfortunately debug does not show value for AdjdCuryRate : Cannot obtain value of the local variable or argument because it is not available at this instruction pointer, possibly because it has been optimized away.

I need to clarify this part : “Make sure you are getting the correct APPayment set as current and the correct APAdjust set.”

The Payment with which I am working is APPayment type, but what APAdjust type is responsible for ? I did not use this entity in my code which I sent.

The code is invoked via custom screen, with the help of which the payments will be reverted automatically (that is what I am trying to achieve)

After Adjustments.Update call this field was assigned to 1 

I tried  this with another payment and code worked without any errors

However item was not affected , it does not change anything 

 

Userlevel 4
Badge +2

hi @markusray17 

I am sincerely  grateful for all provided help, thank you for your professionalism and patience.

I have accomplished logic that I must have been implemented.

Best regards 

Userlevel 4
Badge +2

That would seem to be a bug on 21R2, I’d check with Acumatica and see what they say. I was able to replicate it on my 21R2 instance. The same issue doesn’t seem to be happening with ARPayments. I’m guessing there is an issue with how they are checking for documents being out of balance for APPayments.

 

It could be related to your issue, but I would expect to get the same error via code as in the UI. 

Thank you for the response, I will write to Acumatica and let you know, when I get the response

Userlevel 4
Badge +2

Hi @markusray17 

I mistakenly sent Payments and Application item instead of Checks and Payment.

With Checks and Payments same error happens for any item in same place.

However, when I do it in UI it successfully changed it from “Closed” state to “Open”

you wrote in previous response the following : “You don’t really need to see the actual value, you just need to figure out what methods are changing the value(visible in the call stack).”

1)The first method where its value changed is this

2)The second

and after that I receive error in that event 

 

Userlevel 4
Badge +2

Hi @markusray17 

The required logic has changed a little bit.

I need to use Void instead of Reverse Application.

I checked Void work in Acumatica UI for payment and it worked with no troubles, item was successfully saved.

However in code I receive same error in same place

Previously you advised to check this place : Adjustments.Update(adj);

Concerning Reverse Application it was right, the error appeared right after that place

However with Void the debug does not come here

Concerning that part : “using the call stack and debugger you can see the method chain when that value is set to null and then figure out which event handler is the cause and why.”

I cant see exactly from which place error comes due to Acumatica files are not available to view

I can only check the call stack, but it is not informative

This is my code

string referenceNbr = "001991";
 APPaymentEntry graph = PXGraph.CreateInstance<APPaymentEntry>();
  graph.Document.Current = graph.Document.Search<APPayment.refNbr>(referenceNbr);               
  graph.voidCheck.Press();

Userlevel 4
Badge +2

You are trying to view the source of the call stack for the Acumatica code which you don’t really need to do. The call stack will show the method calls leading up to the error. Attempting to inspect the source of the method calls won’t work unless you are decompiling Acumatica code. 

Presumably you already checked that the field isn’t null on the APAdjust object so something would have to be setting it to null. You can put a debug point on the DAC setter and then look at the call stack to determine where it is getting set to null. You could also create your own event and intercept it there(again looking at the call stack).

I would also verify that manually triggering the action isn’t causing the same error. That would indicate that something is going wrong when you are initiating the graph before calling the action.

Also I’m probably repeating myself but Voiding and Reversing the Application are not the same thing. Reversing applications will re-open the payment but not void it. Voiding the payment will reverse applications as well as cancel the payment. You are saying you want to void the payment yet you are calling ReverseApplication above. 

Hi @markusray17 

Thanks for detailed description 

I need to clarify this moment, that you mentioned in last paragraph - “Voiding and Reversing the Application are not the same thing”.

The goal that I am trying to achieve is to implement the cancelation of releasing of the payment.

I need to process case in which the payment was mistakenly released, it means that I return it back as it was before the release. Which action is suitable for it reverse or void ? I think that reverseApplication should work for that.

According to this part : “you can put a debug point on the DAC setter and then look at the call stack to determine where it is getting set to null.” what is DAC ?, I did not understand what I should do

Userlevel 6
Badge +5

You can’t turn a payment back to before it was released. You would need to void it and re-create it in that scenario, once it goes from Balanced → Open you can’t reverse that. Reversing Applications will open the payment back up by creating reversing applications, but the payment will still be released(Open status).  

DAC refers to Data Access Class which in this case would be the APAdjust class. I would strongly caution you to go through the training, at least the quickstart (T190). It’s a little dangerous to write and publish code based customizations if you don’t know the fundamentals of the platform. 

Also just a quick thought if you just need to either reverse applications or void AP payments an import scenario might be an easier solution. 

Userlevel 4
Badge +2

You can’t turn a payment back to before it was released. You would need to void it and re-create it in that scenario, once it goes from Balanced → Open you can’t reverse that. Reversing Applications will open the payment back up by creating reversing applications, but the payment will still be released(Open status).  

DAC refers to Data Access Class which in this case would be the APAdjust class. I would strongly caution you to go through the training, at least the quickstart (T190). It’s a little dangerous to write and publish code based customizations if you don’t know the fundamentals of the platform. 

Also just a quick thought if you just need to either reverse applications or void AP payments an import scenario might be an easier solution. 

@markusray17 

So for result that I described, I will need to use Void Action and after that make it open after it will be balanced, according to your first paragraph, right ?

I tried to make Void and then remove from hold in this way

B

But the error remains the same and in same place

Userlevel 6
Badge +5

No, you can’t make a released payment balanced. You would have to void it and then create a new payment. 

Userlevel 4
Badge +2

No, you can’t make a released payment balanced. You would have to void it and then create a new payment. 

Previously you wrote the following 

All the same I need to use ReverseApplication ?

Maybe it is not possible to implement what I need.

I have released Payment and I need this payment to bring back as it was before released. Make it Open.

Is it possible to implement ? What appropriate way will be for it, using Void or reverseApplication ?

Userlevel 6
Badge +5

The payment is released when it goes from Balanced to Open, after that the “Release” action is actually releasing applications not the Payment itself(which is already released). You cannot bring a payment back to the Balanced state once it is released but you can “reverse” applications(essentially adding a negative application) to re open a closed payment.

It sounds like when you are saying “released payment” you mean an application was released that closed the payment and you just need to reverse that to re-open the payment. In which case ReverseApplication would do that. 

Presumably you have a local dev environment setup for testing so I would recommend trying the actions in the UI and seeing how they work before you start coding. 

Userlevel 4
Badge +2

Okay “revers applications seems to be what I need

The problem which is appeared can be caused by Acumatica environment or inappropriate algorithm of reverseApplication action call ?

I am looking at places from which null is coming to NewValue field 

It looks like something wrong with Acumatica instance or something missed in code sample that you shared with me, because I do not do anything additional during this process

                 string referenceNbr = "001991";
                APPaymentEntry graph = PXGraph.CreateInstance<APPaymentEntry>();
                graph.Document.Current = graph.Document.Search<APPayment.refNbr>(referenceNbr);                      graph.APPost.Current = graph.APPost.SelectSingle();
                graph.reverseApplication.Press();

Is there something that missed at that part of code ?

It is strange that calling of the action became so hard 

Userlevel 4
Badge +2

You have to release the document afterwards, reverse application just creates the reversal under Documents to Apply. APAdjust is the adjustment that you are reversing(APPost is the view where you are setting the current APAdjust). 

You don’t really need to see the actual value, you just need to figure out what methods are changing the value(visible in the call stack).

Hi @markusray17 

I mistakenly sent Payments and Application item instead of Checks and Payment.

With Checks and Payments same error happens for any item in same place.

However, when I do it in UI it successfully changed it from “Closed” state to “Open”

you wrote in previous response the following : “You don’t really need to see the actual value, you just need to figure out what methods are changing the value(visible in the call stack).”

1)The first method where its value changed is this

2)The second

and after that I receive error in that event 

 

Userlevel 6
Badge +5

Do it manually in the UI and verify whether you are getting the same error or not. I would also double check your Currency settings.

It appears to be happening in the newly created adjustment so you can step through the ReverseApplication method in APPaymentEntry.cs to figure out what line is resulting in the null value. I would suspect it is happening in the Adjustments.Update call after the AdjgCuryInfoID value is set. As I said before if you set a breakpoint on the DAC field’s setter method it will trigger anytime a value is set so you can find exactly what code is setting the value to null. 

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