Minutes Rollover

Minutes Rollover

Hi, we are trying to create a minutes rollover because the support uses an allowance system (allowance varies from client to client). We have a form where minutes get stored for the course of 3 months because we allow minutes to roll over as far back as 3 months. Meaning if say from January to April you have remaining allowance of 30 10 45 and 100 then you would have in total to use in April of 185 minutes. then when it becomes May January if still has minutes gets wiped and it uses from February through to May.

To code this we decided to use a formula in a workflow to basically say take whatever was in the field when form was submitted into field 3 first and when that becomes a negative number then field 2 will get deducted said negative value and then field 1 will get deducted for the negative value that was in field 2 (obviously only if the value was negative we don't want it to then add positive values together in these fields) then we have another field that will tally up these values to show how many useable minutes are available.

The questions are;
  1. Is this logic sound?
  2. What would be the best way to script this?
Below are the fields that we have so far.

Also we use a fetch system for future minutes also where you can use the future 3 months allowance. To do this we are having a button that will add 1 2 or 3 months worth to the current month. Then when current month goes beyond what it would normally be then it divides the value by however many months was used and put the resulted number into each of the fields to spread it out across them. Or alternatively do something similar with previous months where it will take the next months first and work back.