Table of Contents |
---|
Summary
This article describes how prorating works in EngageIP when billing packages and services. Prorating charges occur when a package or service is being billed for a partial billing period.
...
EngageIP follows a simple formula to this calculation, but that is only to get the final result. It is important to note that all calculations of periods are done in Months.
...
In order to know the price per day the full period must be calculated, from which the number of days can be extracted. The full period is calculated based the package’s bill date, base time unit and frequency, as well as the start and end date of the proration period. The system figures out the next bill date of the package and uses this as the end of the full period. Next it looks at the start date of the prorate period and sets the start bill date as if it was available within the same month and year. Using these two dates, the start bill date and the next bill date, it figures out the number of full periods between both and compares it to the package’s base time unit and frequency. This gives the full number of periods the prorate period is within. If there is a monthly frequency greater than 1, then a calculation is performed to figure out how many periods are being occupied and converts them down into months. Once the number of full periods in months in determined, the previous bill date can be calculated based on the next bill date.
...
In order to calculate the full period some additional pieces of information must be found. First, the next bill date must be calculated. This is done by using the User Bill Day and finding the next one after the end of the prorate period.
\[
NextBillDate = Jan 1,2015
\]
...
Then, the Previous Bill Date has to be calculated. In order to do this, the beginning of the prorate period is examined and the bill date previous to that is subtracted from the Next Bill Date. This difference is then applied, along with monthly frequency to calculate the Previous Bill Date. In this example, the bill date previous to the prorate Start Date is the bill day prior to December 22, 2014, which is December 1, 2014.
\[
CurrentBillDate = Dec 1,2014
\]
\[
MonthMultipler = Diff(CurrentBillDate,NextBillDate)
\]
\[
MonthMultipler = Diff(Dec 1,2014, Jan 1,2015)
\]
\[
MonthMultipler = 1
\]
\[
PreviousBillDay = NextBillDay.AddMonths(- 1 * MonthMultipler * PackageFrequency)
\]
\[
PreviousBillDay = (Jan 1,2015).AddMonths(-1 * 1 * 1)
\]
\[
PreviousBillday = Dec 1,2014
\]
Now that the NextBillDay and the PreviousBillDay have been calculated, the number of months in the full period are just the difference in the number of months between the two dates.
\[
NumberOfFullPeriodMonths = Diff(PreviousBillday,NextBillDay) = 1
\]
...
With this value we can calculate out the amount that would have been charged if the package was being billed for the full period.
\[
PeriodAmount * NumberOfFullPeriodMonths = FullPeriodAmount
\]
...
The last few calculations involve the number of days in each period. The number of days is obtained by letting the system DateTime library do the heavy lifting.
First the system calculates the actual period days as below:
\[
NextBillDay - PreviousBillDay = NumberOfDaysInFullPeriod
\]
\[
Jan 1, 2015 - Dec 1,2014=31
\]
...
Second, the system compares the number of full days in the period to the number of days in the current month (the month in which you are physically billing the customer - todays month), and it will use the greater of the day amounts. If we are billing in December for a February prorate, the system would use 31 days of December as the number of days in a full period rather than 28 days from the actual prorate period as example.
Finally, the prorated amount can be calculated.\[
\frac{ProratePeriodsDays}{FullPeriodDays} * FullPeriodAmount = Prorate
\]\[
\frac{10}{31} * 30 = 9.6774193548387
\]
...
So the final, prorated amount rounded off is \$9.68
...