silverapp / silver

Automated billing and payments for Django with a REST API
https://www.presslabs.com/code/silver/
Other
301 stars 80 forks source link

Questions about the structure of a plan. #637

Closed Nielssie closed 2 years ago

Nielssie commented 5 years ago

I have some questions about the structure of a plan.

As far as I can see is the amount is monthly price (right?) The frequency determines the total price that will be invoiced every time. So, if the amount is 250 and the frequency is a year the amount on the invoice should be 3000

Initial I have two scenarios that I try to capture in two plans: 1) A subscription with a recurring amount every month 2) A subscription with an amount x and is valid for a certain period (say a total year) starting from a specific date. For instance, If you buy a subscription at 1 may 2019 at 250,- this subscription should be valid until 30 april 2020 and invoiced once a year for 250,-

Scenario 1) is clear and working Scenario 2) I am not sure how to tackle this one. Should I select a frequency of 1 year with an amount of 250/12 ? But what about the specific date, it looks like this is always the end of the year.

Another observation: When a subscription start at 01-01-2019 with a frequency of a year and an amount of 250 I get a unit price of 2943.55 on my invoice where I expected a price of 3000

Thanks in advance.

bogdanpetrea commented 5 years ago

Hi @Nielssie ,

The amount currency is the base price for the plan interval interval_count. Something similar is stated in the help_text of the field. If that is not descriptive enough we'll accept any improvements.

So if you have:

It means that the subscription will be invoiced 5$ every 2 days. If the interval was year instead of day, the subscription should be invoiced 5$ every 2 years. Is this different from what you are experiencing?

For simplification, subscription intervals are always aligned to the start of the first day of the interval (first day of week, of month, of year). Customizing the alignment behaviour should be possible, but it is not implemented.

Nielssie commented 5 years ago

Hello @bogdanpetrea,

Thanks for your quick reply. As I understood an interval_count means the frequency of the billing. So for your example there will be invoiced 10$ every 2 days instead of 5$

Here are some outcomes of my tests for your first part of your explanation. Outcomes that don't agree with your explanation and some amount values which I can't explain.

start_date = 2019-02-01 (today it is 2019-02-07) prebill=yes amount=EUR5, interval=day, interval_count=2 -->1.44 EUR (8 entries x 0,1785) amount=EUR5, interval=day, interval_count=1 -->1.26 EUR (7 entries x 0,1785) amount=EUR5, interval=month, interval_count=1 -->5 EUR amount=EUR5, interval=month, interval_count=2 -->10 EUR amount=EUR5, interval=year, interval_count=1 -->59.64 EUR amount=EUR5, interval=year, interval_count=2 -->59.64 EUR

start_date = 2019-01-01 (today it is 2019-02-07) prebill=yes amount=EUR5, interval=day, interval_count=1 -->6.22 EUR (31 entries x 0,1615 + 7x0,1785) amount=EUR5, interval=month, interval_count=1 -->10 EUR amount=EUR5, interval=year, interval_count=1 -->58.87 EUR (why not 60 EUR?)

start_date = 2019-02-07 (today it is 2019-02-07) prebill=yes

amount=EUR5, interval=day, interval_count=1 -->0.18 EUR (1 entry x 0,1785) -->my calculation 5 EURO/28 days=0.1785 amount=EUR5, interval=week, interval_count=1 -->0.71 EUR --> 4 days left in the week: 4 0.1785=0.71 amount=EUR5, interval=month, interval_count=1 -->3.93 EUR --> (5 EUR/28 days)22 days left in the month = 3.93 EUR amount=EUR5, interval=year, interval_count=1 -->58.87 EUR -->I would have expected: 10 month 5 EUR + 220.1785 = 53.93 ???

So it looks like the amount is a monthly price, where the calculations a made on a day price that is basted on the amount of days in a month. But I can't explain the year interval..

bogdanpetrea commented 5 years ago

Seems to be a bug in _get_proration_status_and_percent(). I've opened an issue here https://github.com/silverapp/silver/issues/638.

bogdanpetrea commented 2 years ago

Attempted fix merged in https://github.com/silverapp/silver/pull/689.