-
agludlumThe form below is designed to calculate membership dues in a club. The dues are calculated on a May 1 - April 30 basis.
Everything has been working perfectly until recently when the prorated calculations stopped.
The substring widget I believe was designed to strip the month out of the current date field so that it could be used in a calculation to determine the adjusted month. For instance, if it is June the adjusted month would be 11, meaning there were 11 more months in the payment year.
I'm not sure what has changed. The widget in the Source Field ID is set at #month_60 The substring start is set at 0. The substring end is set at 2.
The adjusted month's calculation is (Substring Widget #19) + 7) % 12 (I'm not sure how that worked, but it did for awhile.
I'd appreciate your help. I just want it to properly prorate the dues.
-
Podo: Support SpecialistHi Andy,
Thanks for reaching out to Jotform Support. I'm an AI assistant here to assist you.
Regarding your issue with the substring widget for prorated calculations, the substring widget is used to extract parts of a string, such as the month from a date field. In your case, the widget is set to extract the first two characters (start at 0, end at 2) from the source field #month_60, which should represent the month part.
The calculation you mentioned, (Substring Widget #19 + 7) % 12, is designed to adjust the month value to calculate the remaining months in the payment year. This formula adds 7 to the extracted month and then takes the remainder when divided by 12, effectively shifting the month to align with your May 1 - April 30 membership year.
To troubleshoot and fix the issue, consider the following:
- Ensure the source field #month_60 is correctly providing the date string in the expected format where the month is the first two characters.
- Verify that the substring widget is correctly configured with start at 0 and end at 2 to extract the month part as a string.
- Check that the extracted substring is being correctly interpreted as a number in the calculation. Sometimes, the substring output may be treated as text, so you may need to convert it to a number before performing arithmetic.
- Confirm that the calculation formula is correctly written and includes proper parentheses, for example: ((Substring Widget #19) + 7) % 12.
- Test the form calculation with sample dates to ensure the prorated months are calculated as expected.
If the substring widget or calculation is still not working as before, it might be due to changes in the date format or widget behavior. You might also consider using the Form Calculation widget with date functions or the Dates Difference widget to calculate the difference in months more reliably.
Give it a try and let us know how it goes.
-
Lorenz JotForm SupportHi Andy,
I cloned and tested your form, and it does perform the calculation. Check this out:
The Adjustment month seems correct, with May(0-5) as the starting date. (05+7)%12 or 12 % 12 is equal to 0. I already double-checked online. Check this out:
If you can provide sample inputs and the suppose results for all the fields involve, we can help you further inspect this. Also, make sure the calculation for Adjusted month is correct.
Once we hear back from you, we can help you sort this out.