Issue with gifting item from reopened ticket with custom rules/queries

Backstory: I’ve automated posting cigar commission sales to their respective account on settle (working just fine).

Were a ticket to be reopened, rules automatically deduct the commission from needed accounts (working just fine, too).

I don’t want someone to be able to reopen a ticket, comp a cigar, and then resettle with the commission intact (hence the removal rule). There may be genuine reasons to reopen and comp a cigar so I don’t want to disallow it.

My issue arises when settling the reopened ticket. It seems that gstatus is not updated prior to the rule calculating.

How can I set things up so that orders are updated prior to the commission rule firing?

Below are some screen shots if it helps:

Two cigars whose commission should total 100

Paid in full, ticket closed, proper amount displayed for commission and entered into proper accounts.


Reopened ticket, one cigar comped


Product comped and before settling, DB still shows two cigars for that order. The view used for cigar commissions eliminates any order with a comp or void.


When settling reopened ticket, commission for both is calculated as DB still shows two cigars.


After everything is done, DB shows just one cigar that is not comped or voided.

This leaves too much in the commission account.

Rule for calculating commission.

Thanks for any guidance one can give.

Found that After Ticket Closing still has Ticked ID set. Using that event everything seems to work well.

This is like rubber duck debugging; I love it!