Question

How period is calculated when MONTHDIFF_ALG_30DAYS_BASE algorithm is used?

Answer

  1. A parameter MonthDiff is calculated - how many months between a month of the start date and a month of the end date

    MonthDiff = [month number of end date] - [month number of start date]

    for example, upgrade order was placed on June, 20 (StartDate), subscription next billing date is Aug, 15 (EndDate), then

    MonthDiff = 8 - 6 = 2

  2. A parameter baseDate is taken - start date of the subscription

    for example, subscription was started on May, 20, then:

    baseDate = May, 20

  3. A parameter IntermidiateDate is calculated - it is used later. Calculated as a sum StartDate + DateDiffInMonths. It also depends on number of days in BaseDate, if it is greater then number of days in current month and if StartDate equals the end of the month. In such case Intermediate date will be corrected so it is day of Intermediate date is the nearest day possible to day of BaseDate.

    Examples:

    BaseDate is December, 3:

    02.01.12 + 1 month = 02.02.12

    05.01.12 + 1 month = 05.02.12

    06.01.12 + 2 months = 06.03.12

    29.01.12 + 1 month = 29.02.12

    30.01.12 + 1 month = 29.02.12

    31.01.12 + 1 month = 29.02.12

    31.01.13 + 1 month = 28.02.13

    29.02.12 + 1 month = 29.03.12

    BaseDate is December, 31:

    29.02.12 + 1 month = 31.03.12

    29.02.12 + 2 month = 30.04.12

    30.04.12 + 1 month = 31.05.12

    02.01.12 + 1 month = 02.02.12

    BaseDate is December, 30:

    02.01.12 + 1 month = 02.02.12

    29.02.12 + 1 month = 30.03.12

    30.04.12 + 1 month = 30.05.12

    In our case IntermidiateDate = June, 20 + 2 month = August, 20

  4. A parameter startDayOfMonth is calculated - minimum between day of IntermidiateDate and 30:

    startDayOfMonth = min(dayOfMonth(IntermidiateDate),30)

    in our case startDayOfMonth = min(20,30) = 20

  5. A parameter endDayOfMonth is calculated - minimum between day of EndDate and 30:

    endDayOfMonth = min(dayOfMonth(EndDate),30)

    in our case endDayOfMonth = min (15,30) = 15

  6. A parameter fractMonthDiff - period between startDayOfMonth and endDayOfMonth:

    fractMonthDiff = (endDayOfMonth - startDayOfMonth)/30

    in our case fractMonthDiff = (15-20)/30 ~ -0,17

  7. A parameter diffInMonths is calculated - a period between the start and the end dates for which client will be billed

    diffInMonths = MonthDiff + fractMonthDiff

    in our case diffInMonths = 2 - 0,17 = 1,83 ,

    so as a result the client will be billed for 1,83 month.

Additional information

The MONTHDIFF_ALG_30DAYS_BASE algorithm is just one of the algorithms a provider can choose to calculate the number of days to be used for proration. To learn about other algorithms and how to switch between them please refer to https://kb.cloudblue.com/en/116095.

Internal content