Support

Home Forums Event Espresso Premium Sequential Invoice Numbers – yet again

Sequential Invoice Numbers – yet again

Posted: June 9, 2018 at 10:16 am


dhb_akademie

June 9, 2018 at 10:16 am

Dear community,
Dear Josh,

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:
https://gist.github.com/pwweb/1aa78165175ce19a16989e94d9a29845

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.
I don’t think the transaction status RIC is the right one to check for, since both incomplete and abandoned transactions have this status.

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!

Regards,

Frank


Josh

  • Support Staff

June 11, 2018 at 8:05 am

Hi Frank,

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.


dhb_akademie

June 18, 2018 at 8:15 am

Hi Josh,

thanks for getting back to me.
My general thoughts / process was to do the following:

  1. Determine if a transaction is “completed”, i.e. registration successful & no cancellation/quitting during the processing
  2. Determine the last used invoice number and increment by one
  3. Update invoice number in settings with current one for next invoice

You could start saving generated invoices to the messages table when they are generated and then serve those generated invoices only when requested.

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?
What are the hooks (i.e. AHEE__EE_***) that are available on the display message/invoice actions? I tried to dig through the code/classes but couldn’t find suitable ones.

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.

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).
However as mentioned in my initial post, I believe I got the wrong hook for that, since it also increments when the transaction is cancelled/incomplete (i.e. AHEE__EE_Registration_Processor__trigger_registration_update_notifications)
Subsequently the invoice number is stored in a custom question for the transaction for later use and printing of invoice.

Thanks,

Frank


Tony

  • Support Staff

June 19, 2018 at 12:12 pm

Hi Frank,

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:

I don’t think the transaction status RIC is the right one to check for, since both incomplete and abandoned transactions have this status.

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.

However as mentioned in my initial post, I believe I got the wrong hook for that, since it also increments when the transaction is cancelled/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 $updateParams to confirm the old_txn_status did not equal TCM (Transaction Complete) as if it did its likely an invoice number was already assigned…. or use the primary registrant object, pull the answer for your invoice question and if its empty cont increment the invoice number.

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.

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: closed

Updated by  Tony 3 months, 4 weeks ago ago

Topic Tags

Notifications

This topic is: not resolved
Do NOT follow this link or you will be banned from the site!