Skip to Content Skip to Menu

Atomatic year change in invoice for early renewals

  • jabba84
  • jabba84
  • OFFLINE
  • Posts: 91
  • Thanks: 5
  • Karma: 0
11 months 2 weeks ago - 11 months 2 weeks ago #335681 by jabba84
Hello, i'm using invoices for my annual plan. The subscription ends on 31th december but members can renew 1 month in advance.
In the invoice i can wirte "Annual subscription for year [YEAR]" using the placeholder. And this is great from january to november. How can i modify the invoice that the advance pauments for early renew show the subsequent year? So in december 2023 the invoice says "Annual subscirption for year 2024" even if we are still in 2023?
Thanks

EDIT: ouch, actually i've seen that the [YEAR] placeholder works only in the invoice number format, not in the rest of the template... 

WebMaster & JoomlaLover @ www.pixed.it
Last edit: 11 months 2 weeks ago by jabba84.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48419
  • Thanks: 8274
  • Karma: 1443
11 months 2 weeks ago #335690 by krileon
[YEAR] is only available for invoice numbers. Maybe try the following?

[SUBSCRIPTION_VALIDITY_PERIOD]
[SUBSCRIPTION_VALIDITY_PERIOD_IF_RENEWED]

You can also try an inline substitution usage like the following.

[cb:date format="Y" date="[SUBSCRIPTION_SIGNUP_DATE_UTC]" /]
[cb:date format="Y" date="[SUBSCRIPTION_LAST_RENEWAL_DATE_UTC]" /]

The below would always give the current year, but it's not going to account for renewing early.

[cb:date format="Y" /]


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.

  • jabba84
  • jabba84
  • OFFLINE
  • Posts: 91
  • Thanks: 5
  • Karma: 0
11 months 2 weeks ago #335703 by jabba84

[YEAR] is only available for invoice numbers. Maybe try the following?

[SUBSCRIPTION_VALIDITY_PERIOD]
[SUBSCRIPTION_VALIDITY_PERIOD_IF_RENEWED]
Those two are not parsed, they remain [SUBSCRITION_VALIDITY_PERIOD] in the body of the invoice... do i have to set them somewhere?

You can also try an inline substitution usage like the following.

[cb:date format="Y" date="[SUBSCRIPTION_SIGNUP_DATE_UTC]" /]
[cb:date format="Y" date="[SUBSCRIPTION_LAST_RENEWAL_DATE_UTC]" /]

Those settings throw an error:
Failed to parse time string ([SUBSCRIPTION_LAST_RENEWAL_DATE_UTC]) at position 0 ([): Unexpected character

Idea: i can setup the header, the address and so on with an editor like JCE. Can i insert in the field some php code with Sourcerer by regular labs in order to echo the correct year? Are plugins interpreted here or ignored?

WebMaster & JoomlaLover @ www.pixed.it

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48419
  • Thanks: 8274
  • Karma: 1443
11 months 2 weeks ago #335704 by krileon
At the bottom of the "Invoice content and styling settings for System owner" section is "Substitutions in all fields of invoice". Those are the substitutions available. Looks like it will be rather limited as you'll only be able to get some payment and basket information and not subscription information. It's likely not possible to have what you're wanting. The following are available, but they're all relevant to the date of the payment.

[DATE_ORDERED]
[DATE_TIME_ORDERED]
[DATE_PAID]


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.

  • jabba84
  • jabba84
  • OFFLINE
  • Posts: 91
  • Thanks: 5
  • Karma: 0
11 months 2 weeks ago - 11 months 2 weeks ago #335708 by jabba84
Solved with a javascript inside one of the fields, i've done it with "sourcerer" by regular labs. Here is the script if someone need it:

Code:
{source}<div id="stringaResult"></div> <script> window.onload = function() { var span = document.querySelector('.cbregInvField'); // The invoice automatically prints the payed date inside a span with this class var date = span.textContent || span.innerText; var parts = date.split('/'); var day = parts[0]; var month = parts[1]; var year = parts[2]; var months = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']; var nameMonth = months[month - 1]; var yearQuota; if (month == 12) { yearQuota = parseInt(anno) + 1; } else { yearQuota = year; } var stringaResult = "Payed on " + day + " " + nameMonth + " " + year + " the subscription quota for year " + yearQuota + "."; document.getElementById('result').textContent = stringaResult; } </script>{/source}

WebMaster & JoomlaLover @ www.pixed.it
Last edit: 11 months 2 weeks ago by jabba84.
The following user(s) said Thank You: krileon

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

Moderators: beatnantkrileon
Powered by Kunena Forum