#### Subscriptions and paid functions

Yes! Let's see an example.

For example, on January 01, 2019 your company subscribed to the "Business" package (5 people, annually payments). The cost of the "Business" package is $50 per 1 person for 1 year. Total for an annual subscription - $250.

After a month (on February 01, 2019), you decided to change your subscription to Enterprise. You also decided to reduce the number of people from 5 to 3, and also switch to a monthly payment. The cost of the Enterprise package is $10 for 1 person for 1 month. Total subscription costs $30 per month.

Don’t worry - your money for a subscription will not be lost, instead, the date of the next payment for the new subscription will be calculated. Let's calculate how much money for the old annual subscription was "used" for the past month.

31 days of January passed, which is 31/365 = 8.5% of the year. This means that 8.5% of $250 was used ($21.25). This means that "your unused balance" $250 - $21.25 = $228.75.

For how many full months on a new subscription ($30 / month) will these funds be enough? To obtain this value, it is necessary to find the integer part of the fraction 228.75 / 30. We get 7 full months, which cost 7 * 30 = $210. Fractional part is 228.75-210 = $18.75

Let's calculate what month will be on the calendar after full 7 months from the date of package change (recall, the date of package change in the current example is 2019-02-01). It will be September 2019.

Now let's calculate what day in September the money for the new package should be debited. There are 30 days in September. The cost of a new subscription is $30/month, which means the number of paid days can be calculated as follows:

30 days -> $30

X days -> $18.75

X = 30 * 18.75 / 30 = 18.75 = ~ 19.

So, the current “unused balance” for the new subscription will last until September 19, 2019. The next payment for the new subscription will be made on September 19, 2019.