Solved

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



Show first post

43 replies

Userlevel 6
Badge +5

no setting the current record on a view means 

[GRAPH NAME].[VIEW NAME].Current = [Record]

That is what you are doing with the Document view when you 

graph.Document.Current = graph.Document.Search<APPayment.refNbr>(referenceNbr);

So assuming the view name is APPost you would need something like(this would just select the first record of the view).

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

 

If you are getting an error when trying to inspect the action/grid then you have something else going on. I would check the trace(there should be more detailed error messages there) and look through your customizations to find which one is causing the issue.

Userlevel 4
Badge +2

no setting the current record on a view means 

[GRAPH NAME].[VIEW NAME].Current = [Record]

That is what you are doing with the Document view when you 

graph.Document.Current = graph.Document.Search<APPayment.refNbr>(referenceNbr);

So assuming the view name is APPost you would need something like(this would just select the first record of the view).

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

 

If you are getting an error when trying to inspect the action/grid then you have something else going on. I would check the trace(there should be more detailed error messages there) and look through your customizations to find which one is causing the issue.

@markusray17 

Thanks for provided code

can you help with this error , I checked it at stack trace as you have suggested 

 

Userlevel 6
Badge +5

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.

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 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.

I cancelled all customization projects but it did not help

Is there any chance to reload this button in endpoint ?

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 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 ?

Userlevel 4
Badge +2

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

.

Hi @Naveen Boga 

If I make it void once, will be it possible to to close it after void ?

Userlevel 4
Badge +2

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

 

 

now it looks real it implement, I checked void option, all data is saved after void action

Firstly it makes “Hold” status 

After that I can remove it from hold

is it possible to call Void and remove Hold status programmatically ?

Userlevel 4
Badge +2

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.

Hi @markusray17 

It looks good. Is it possible to call Void and bring item back to OPEN state programmatically ?

I have code that is executed according to automation schedule, that will open folder and checks files which will have list of Checks and Payment Items that must be returned to Open status.

 

Userlevel 4
Badge +2

Yes, it is possible.

you can invoke form Base graph like below.

Base.putonhold.Press();

Base.ReleaseFromHold.Press();

@Naveen Boga 

In previous comment where I replied to markusray17 I described that I need it to call from code that is called by Acumatica Automation Schedule that will open folder and check files which will have list of Checks and Payment Items that must be returned to Open status. I think it will not be available to call Base graph and there should be list of parameters for Void methods where I define which Item to process ( For example send ReferenceNbr to parameters in method)

 

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

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. 

Hi @markusray17 

Can you provide help with this part :

“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. ”

I wrote the following way, where I send to graph instance ReferenceNbr of item that must be Voided

 string referenceNbr = "023675";
                APInvoiceEntry graph = PXGraph.CreateInstance<APInvoiceEntry>();
                graph.Document.Current = graph.Document.Search<APInvoice.refNbr>(referenceNbr);
                graph.ReverseApplication();

That is how it should be done, firstly I send reference Nbe to instance and after that I call the action, right ?

Userlevel 4
Badge +2

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). 

@markusray17 

I changed type of graph as you mentioned

Will such code make this item “Void” ?

                string referenceNbr = "001571";
                APPaymentEntry graph = PXGraph.CreateInstance<APPaymentEntry>();
                graph.Document.Current = graph.Document.Search<APInvoice.refNbr>(referenceNbr);          
                graph.reverseApplication.Press();

 

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