Solved

Call Void action for Checks and Payment item


Userlevel 4
Badge +2

Hi,

I need to add to my application logic that will Void Checks and Payments items which have “closed” state

When I try to do this programmatically via this code

I get error in this event, which is called when I try to call Void action 

This event is located in this path : C:\Program Files\Acumatica ERP\AcumaticaDB_new\App_Data\CodeRepository\PX.Objects\AP\APPaymentEntry.cs

The reason why I get object reference in this event is that NewValue filed is null and can’t look from which place we transfer PXFieldVerifyingEventArgs object to this event, because thought all call stack from my code to this Class I receive these errors

So I can’t investigate from which place null is coming to the event

Besides, this is Acumatica code, change it in any way will be bad idea, maybe there is something that must be added in my code and will help to fix object reference in the event.

The version of Acumatica is 2021R2

Thanks in advance.

icon

Best answer by markusray17 6 July 2022, 00:00

View original

42 replies

Userlevel 6
Badge +5

I would probably recommend stepping through the VoidCheck method. It sounds like something might be going wrong there. Assuming it succeeds it would create a voiding document and set the current document to that new voiding document. That is the document you want to release. If that method skips or fails to create that document it would be attempting to release the original closed check which is why I think you are getting that error.

Userlevel 4
Badge +2

I would probably recommend stepping through the VoidCheck method. It sounds like something might be going wrong there. Assuming it succeeds it would create a voiding document and set the current document to that new voiding document. That is the document you want to release. If that method skips or fails to create that document it would be attempting to release the original closed check which is why I think you are getting that error.

@markusray17 

I entered to this method

In what part exactly document creation is happening 

Userlevel 6
Badge +5

The VoidCheck method is a method in APPaymentEntry, what you posted was the PressImpl code. You should be setting a breakpoint at the top of the VoidCheck method and then walking through it. 

Userlevel 4
Badge +2

The VoidCheck method is a method in APPaymentEntry, what you posted was the PressImpl code. You should be setting a breakpoint at the top of the VoidCheck method and then walking through it. 

@markusray17 

At this part

    APPayment voidcheck = Document.Search<APPayment.refNbr>(Document.Current.RefNbr, APPaymentType.GetVoidingAPDocType(Document.Current.DocType));

void check is null

this part gives error at that part

 

Userlevel 6
Badge +5

That’s exactly what it should be doing.

 

Try overriding the Release method on APPaymentEntry and then inspecting the invoices, something like:

        public delegate IEnumerable ReleaseDelegate(PXAdapter adapter);

[PXOverride]
public IEnumerable Release(PXAdapter adapter, ReleaseDelegate baseMethod)
{
foreach(APPayment apdoc in adapter.Get<APPayment>())
{
var inv = apdoc;
}

return baseMethod(adapter);
}

You would need to put the above code inside a graph extension for APPaymentEntry but that should allow you to inspect the apdoc variable without it being optimized away. It should be a void check with a balanced status.

Userlevel 4
Badge +2

That’s exactly what it should be doing.

 

Try overriding the Release method on APPaymentEntry and then inspecting the invoices, something like:

        public delegate IEnumerable ReleaseDelegate(PXAdapter adapter);

[PXOverride]
public IEnumerable Release(PXAdapter adapter, ReleaseDelegate baseMethod)
{
foreach(APPayment apdoc in adapter.Get<APPayment>())
{
var inv = apdoc;
}

return baseMethod(adapter);
}

You would need to put the above code inside a graph extension for APPaymentEntry but that should allow you to inspect the apdoc variable without it being optimized away. It should be a void check with a balanced status.

It will not allow me to modify ApPaymentEntry due to Acumatica project can not be fully built with all packages , I built only my solution, not Acumatica site . It gives hundred errors when I try to built Acumatica website

 

Userlevel 6
Badge +5

You shouldn’t be modifying APPaymentEntry, you would put that code into a graph extension of APPaymentEntry. If you have trouble with that the Open University has courses on extending/modifying graph logic(T210 I believe). 

Userlevel 4
Badge +2

@markusray17 

Ok

One moment to clarify - why it is needed to call release after voidcheck action ? In interface I just pressed Void button and it created copy of existing payment, why in code we must use release ?

 

Userlevel 6
Badge +5

It’s not a copy it is a voiding document. To void a check the system creates a Voided Check document that mirrors the original check, until that document is released though the original check is not voided.

Userlevel 4
Badge +2

Hi @markusray17 

I have an extended Payment entity

However the debug does not step here after action calls

 

Userlevel 6
Badge +5

You extended APReleaseProcess instead of APPaymentEntry.

Userlevel 4
Badge +2

You extended APReleaseProcess instead of APPaymentEntry.

@markusray17 It is needed to use APReleaseProcess to support my custom logic

Maybe there is again some issue with parameters as it was with voidCheck method ?

Userlevel 4
Badge +2

@markusray17

After void payment has status Hold

I tried to set balanced manually but it did not help

 

Userlevel 6
Badge +5

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.

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

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 

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