Article ID: 121051, created on Apr 12, 2014, last review on Jul 17, 2015

  • Applies to:
  • Business Automation

Question

How PBA calculates periods in orders using default algorithm (MONTHDIFF_ALG_ORIGINAL)?

Answer

When calculating the duration of a period such values as period start and end dates, number of days in the month when subscription was purchased, as well as some intermediate values calculated basing on the initial data, are taken into account.

The following variables are used for calculations :

  1. BaseDate

    Subscription ordering date; the value will be used in further calculations.

  2. BaseMonth

    BaseDate is the day of BaseMonth month. The number of days in the BaseMonth is important for further calculations.

  3. FromDate

    Start date of the period we calculate. In case of refunds, the subscription cancelation or downgrade date is taken as this date.

  4. ToDate

    End date of the period we calculate. In case of refunds the date up to which the subscription was paid is used as a value.

    If Before Billing Period billing model is used - this is the next Billing date.

    If Before Subscription Period billing model is used - this is the subscription Expiration date.

  5. DateDiffInMonths

    The interval in months between FromDate date and ToDate date. For the dates in the DD.MM.YY format, only months of the dates are taken into account, i.e., MM. For example, for May 30, 2011 and June 02, 2011 dates the difference in months would be 1 month.

  6. IntermediateDate

    Intermediate date used later. Calculated as a sum FromDate + DateDiffInMonths. It also depends on number of days in BaseDate, if it is greater then number of days in current month and if FromDate 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

  7. DaysInMonth

    The number of days in the BaseMonth.

  8. FractMonthDiff

    Difference in months, a fraction. First, the difference between (the day of month taken from ToDate) and (the day of month taken from IntermediateDate) is calculated. Then the result is divided by the DaysInMonth value. The FractMonthDiff value is stored as a simple fraction such as x/y; it may also possess a negative value. If the day of a subscription purchase (DD) is greater than the day (DD) of subscription cancelation, the value of FractMonthDiff will be a positive value.

  9. DiffInMonths

    The target value, i.e., the duration of the period we calculate. The DiffInMonths value is calculated as a sum of DateDiffInMonth + FractMonthDiff. For example, 1 + (-2/31) = 29/31. The resulting value is rounded upward with an accuracy to two decimal places according to the mathematical rules. Then this rounded value is used for further calculation of amounts. In the example above (29 days of the 31 calendar days) the result is 0.93548387... After rounding, the target value will be 0.94.

Below the examples of period calculation under the conditions of different billing period types are provided.

Example 1

  • A customer purchases a 1-year subscription on May 14, 2012 and cancels it on January 31, 2013.
  • How long would be the refund period?

Calculation is made under the following conditions:

  • Billing period type = Monthly on Statement Cycle Date; 1st day of every month.
  • Subscription is charged = Before Billing Period.

Calculation:

BaseDate - subscription purchase date: May14, 2012

BaseMonth - base month: May

FromDate - subscription cancellation date: January 31, 2013

ToDate - next billing day: February 1, 2013

DateDiffInMonths - difference in months: (February - January) = (2 - 1) = 1 month.

IntermediateDate - intermediate date: January 31, 2013 + 1 month = February 28, 2013.

DaysInMonths - number of days in base month: since May is the base month, the value is 31 days.

FractMonthDiff - difference in months, fraction: (day of month from ToDate - day of month from IntermediateDate) / DaysInMonth:

(1 - 28)/31 = -27/31

DiffInMonths - duration of the period we calculate: the sum DateDiffInMonth + FractMonthDiff:

1 + (-27/31) = 4/31 = 0.1290325..., or 0.13 after rounding.

So, a customer should be refunded for the period of 0.13 month.

Example 2

  • A customer purchases 1-year subscription on May 14, 2012 and cancels it on January 31, 2013.
  • How long would be the refund period?

Calculation is made under the following conditions:

    • Billing period type = Monthly on Statement Cycle Date; 1st day of every month.
  • Subscription is charged = Before Subscription Period.

Calculation:

BaseDate - subscription purchase date: May 14, 2012

BaseMonth - base month: May

FromDate - subscription cancelation date: January 31, 2013

ToDate - subscription expiration date: May 14, 2013

DateDiffInMonths - difference in months: (May - January) = (5 - 1) = 4 months.

IntermediateDate - intermediate date: January 31, 2013 + 4 months = May 31, 2013.

DaysInMonths - number of days in base month: since May is the base month, the value is 31 days.

FractMonthDiff - difference in months, fraction.

(day of month from ToDate - day of month from IntermediateDate) / DaysInMonth

(14 - 31)/31 = -17/31

DiffInMonths - duration of the period we calculate: the sum DateDiffInMonth + FractMonthDiff

4 + (-17/31) = 107/31 = 3.4516129..., or 3.45 after rounding.

So the customer should be refunded for the period of 3.45 months.

Example 3

  • A customer purchases 1-year subscription on May 14, 2012 and cancels it on February 3, 2013.
  • How long would be the refund period?

Calculation is made under the following conditions:

  • Billing period type = Monthly on Statement Cycle Date; 1st day of every month.
  • Subscription is charged = Before Subscription Period.

Calculation:

BaseDate - subscription purchase date: May 14, 2012

BaseMonth - base month: May

FromDate - subscription cancelation date: February 3, 2013

ToDate - subscription expiration date: May 14, 2013

DateDiffInMonths - difference in months: (May - February ) = (5 - 2) = 3 months.

IntermediateDate - intermediate date: February 3, 2013 + 3 months = May 3, 2013.

DaysInMonths - number of days in base month: since May is the base month, the value is 31 days.

FractMonthDiff - difference in months, fraction.

(day of month from ToDate - day of month from IntermediateDate) / DaysInMonth

(14 - 3)/31 = 11/31

DiffInMonths - duration of the period we calculate: the sum DateDiffInMonth + FractMonthDiff:

3 + (11/31) = 104/31 = 3.3548387..., or 3.35 after rounding.

So the customer should be refunded for the period of 3.35 months.

Additional information

The MONTHDIFF_ALG_ORIGINAL 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.odin.com/en/116095.

Search Words

Billing process

total price switch plan

duration

how pba calculates period

pba total price switch plan

198398b282069eaf2d94a6af87dcb3ff caea8340e2d186a540518d08602aa065 e12cea1d47a3125d335d68e6d4e15e07

Email subscription for changes to this article
Save as PDF