Posted: June 9, 2018 at 10:16 am
I have looked through quite a lot of forum threads on here regarding the sequential invoice numbering and I know it is not coming for a while (sadly).
Thus I have used what I found and created the following hook:
I thought it would work fine, until I still noticed that there are still gaps in the numbering. My current thought is that I still need to add a check on the status of the transaction (or the tickets) to ensure that we are in fact at a final stage of processing or whether we have abandoned the process, before setting and updating the invoice number in configuration.
Maybe Josh (or someone else) can point me in the right direction on the status that I could check or come up with another approach.
Thanks in advance!
The following is the idea presented by one of the developers of Event Espresso 4:
You could start saving generated invoices to the messages table when they are generated and then serve those generated invoices only when requested.
Then if the transaction is modified in anyway, that triggers the generation of a new invoice and that gets saved. Event Espresso 4 already has a database table relation between the transactions table and messages table now so it’s possible to retrieve all invoices generated for the transaction.
The tricky part to this though is that you cannot use the MSG_ID as the invoice number because the messages table is used for more than just invoices. So you’d have to work out a way for having sequential invoice IDs across all invoices in the system. One approach to this could make use the esp_extra_meta table.
thanks for getting back to me.
How would I go about that? My current understanding is that the invoices are always generated and stored in the MySQL table. By serving you mean when the user displays the invoice in the browser?
This is what I was trying to achieve with the code I pasted above. One variable is stored in the WP Config that should get incremented whenever a new invoice is generated (https://gist.github.com/pwweb/1aa78165175ce19a16989e94d9a29845#file-eventespressoinvoicenumber-php-L79).
This is probably going to sound nitpicky, but it’s important as it comes into play with what you are trying to do, in your initial post you have this:
No transaction has a status of ‘RIC’, because it’s a registration status, not a transaction status.
Its the Registration InComplete’ status and registrations have that status until that have passed the attendee information step meaning the registration now has an EE contact assigned to it so the registration object is no longer incomplete.
A transaction can not have a status of ‘Cancelled’, again that’s a registration status.
So for your function to work it sounds like you need to add a check to your function to confirm the registration has a status of ‘Approved’ (which happens when payment it complete it full, the default registration is set to ‘Approved’ or the admin manually Approves the registration) and then assigned the Invoice number to primary registrant.
You can also double up and use
I’m not sure at what point your current code would increment when a transaction is canceled?
Do you mean if the user starts a registration and then stops halfway through?
The support post ‘Sequential Invoice Numbers – yet again’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.