DCrake
Remembered
- Local time
- Today, 19:07
- Joined
- Jun 8, 2005
- Messages
- 8,620
Hoping not to re-invent the wheel, what I am attempting to do is to take three arguments
LowerDate, UpperDate & Value
Then depending on whether the date range crosses the financial year boundary apportion the value pro-rata based on the number of days. So lets say I have a payment for £10000 to make and I raise the payment today but the payment is in respect of rent for the next 12 months. My financial year (for brevity is 1st Jan). Therefore I calculate the number of days between 1st Sep 2010 and 30th Aug 2011 = n. Then I calculate the date diff between 1st Sep and 31st Dec = x. finally calculate the date diff between 1st Jan and 30th Aug = y.
v = Value
Year one cost = v/(x+y)*x
Year two cost = v/(x+y)*y
Thats the logic, now heres where it get complicated. What happens if the payment covers more than dips it toe into more than 2 financial years. Also need to take into account leap years so the apportionment is correct. (my client insists on this).
Has anyone been down this route before? and if so what was your solution.
LowerDate, UpperDate & Value
Then depending on whether the date range crosses the financial year boundary apportion the value pro-rata based on the number of days. So lets say I have a payment for £10000 to make and I raise the payment today but the payment is in respect of rent for the next 12 months. My financial year (for brevity is 1st Jan). Therefore I calculate the number of days between 1st Sep 2010 and 30th Aug 2011 = n. Then I calculate the date diff between 1st Sep and 31st Dec = x. finally calculate the date diff between 1st Jan and 30th Aug = y.
v = Value
Year one cost = v/(x+y)*x
Year two cost = v/(x+y)*y
Thats the logic, now heres where it get complicated. What happens if the payment covers more than dips it toe into more than 2 financial years. Also need to take into account leap years so the apportionment is correct. (my client insists on this).
Has anyone been down this route before? and if so what was your solution.