Skip to Content Skip to Menu

Auto Action that will fire ONLY on the following recurring payments but not on the first one

  • krileon
  • krileon
  • ONLINE
  • Posts: 48830
  • Thanks: 8343
  • Karma: 1449
9 years 2 weeks ago #277207 by krileon

For me it is not a problem now as I've kind of turned off your invoices numbering and made my own with the 3 UPDATE queries in the autoAction I've posted above.

What you're saying is with the above it's incrementing even though increment setting is set to 0? Is it always incrementing by 1?

Now I've noticed a bigger problem: the invoicing fields are mandatory but if the user doesn't change any of the pre-populated invoicing fields nothing gets saved in the CB invoicing fields. And because I'm including them fields in the emails with your substitutions, namely:

You can use an IF substitution to condition those fields and only show them if they actually have a value. I don't know when exactly those fields are populated, but depending on the trigger used you should be able to directly access the baskets columns, which contain the invoice address information.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • ricco1
  • ricco1
  • OFFLINE
  • Posts: 310
  • Thanks: 8
  • Karma: -7
9 years 2 weeks ago #277248 by ricco1

What you're saying is with the above it's incrementing even though increment setting is set to 0? Is it always incrementing by 1?


After a lot of tests I can say that it was not working. The invoice number was not increasing, unfortunately.

I've decided to do it like you've suggested:

The below should work to allow a CB field to act as the invoice number. The CB field you'd use is a query field that calculates the invoice number. It would always need to return the next invoice number.


But I don't know how to write the query which will always calculate the next invoice number. Could you help me with this please?

For now, I've made a text field which is filled with the highest this far invoice number and I've changed my query autoAction to only update that field + 1 like so:



with this query in it:
Code:
UPDATE #__comprofiler SET cb_ttinvnum = ( SELECT cb_ttinvnum FROM ( SELECT MAX( cb_ttinvnum + 1 ) AS cb_ttinvnum FROM #__comprofiler ) AS t ) WHERE user_id = '[cb:userdata field="user_id" /]';

It iwll be very difficult for me to write the if statement that will grab either for example the value of [cb_subs_inv_first_name] or the value of [firstname] and would be very grateful if you could help me with that also.

Thank you,
ricco
Attachments:

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48830
  • Thanks: 8343
  • Karma: 1449
9 years 2 weeks ago #277264 by krileon
www.joomlapolis.com/forum/153-professional-member-support/232620-auto-action-that-will-fire-only-on-the-following-recurring-payments-but-not-on-the-first-one?limitstart=0#277032

Based off your queries in your above reply you should only need to use the below configuration within CBSubs > Settings > Display > Invoices.

Numbering of invoices: Proforma invoice number at order time, then different final invoice number once paid
Proforma Invoice number format: [NUMBER]
Increment each consecutive Proforma Invoice [NUMBER] by: 1
Invoice number format: [NUMBER]
Increment each consecutive Invoice [NUMBER] by: 1

The invoice number will then increment by 1. You can set whatever start value you like as well (see substitution descriptions). You have the increment set to 0 so it of course won't increment. Please note you are trying to make invoice numbers unique per user, which isn't correct as it means you'll have duplicate invoice numbers in your system and is not good for record keeping.

I can not help you with writing custom queries. We only provide simple examples at best, sorry.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: ricco1

Please Log in or Create an account to join the conversation.

  • ricco1
  • ricco1
  • OFFLINE
  • Posts: 310
  • Thanks: 8
  • Karma: -7
9 years 2 weeks ago #277290 by ricco1
Do you think of me as an enemy or as a customer?

Please Log in or Create an account to join the conversation.

  • ricco1
  • ricco1
  • OFFLINE
  • Posts: 310
  • Thanks: 8
  • Karma: -7
9 years 2 weeks ago - 9 years 2 weeks ago #277295 by ricco1
All is working for now as per your last suggestions. Thank you.
Last edit: 9 years 2 weeks ago by ricco1.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48830
  • Thanks: 8343
  • Karma: 1449
9 years 2 weeks ago #277326 by krileon
My suggestion was to write a database query that will give an invoice number that meets your criteria. Whether it be to count the baskets and increment that count by 1 and use that as invoice number or you could count the payments then increment that by 1 as the invoice number. That's entirely up to you. You can use the query in a CB Query Field then substitute it into the invoice number format parameters. Below are some simple example queries.

Count Baskets:
Code:
SELECT ( COUNT(*) + 1 ) FROM `#__cbsubs_payment_baskets`

Count Payments:
Code:
SELECT ( COUNT(*) + 1 ) FROM `#__cbsubs_payments`

In your case payment counting probably makes most sense as each recurring payment will increment the invoice number. If you wanted it user specific (not recommended) then the below should also work.

Count Baskets (User Specific):
Code:
SELECT ( COUNT(*) + 1 ) FROM `#__cbsubs_payment_baskets` WHERE `user_id` = '[user_id]'

Count Payments (User Specific):
Code:
SELECT ( COUNT(*) + 1 ) FROM `#__cbsubs_payments` WHERE `for_user_id` = '[user_id]'

I can not provide you with anymore more specific. I am not here to write custom code for you, sorry. We do not do that here. See my signature in every post for clarification regarding this. You will need to write your own queries to fit your specific needs. I can only provide you with simple examples.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: ricco1

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum