PriceComparisonStandardsGroup / AddOns

7 stars 9 forks source link

Implementation of "ApplyToDeposit" charge #16

Open tommichaelis opened 8 years ago

tommichaelis commented 8 years ago

In the example implementation of the finance calculation, charges which are AppliedToDeposit are calculated by adding them to the premium, before doing additional calculations on the sum of the premium and the deposit charges to compute the eventual deposit. Because the full deposit is later subtracted from the loan, any deposit charges will increase the deposit, but reduce the loan amount accordingly. For example, the output from the implementation when the Deposit Charge is left at 0 is:

Standard Plan
  SinglePaymentTotal = 1000
  FinanceDeposit = 303.8970
  FinanceNumberOfInstalments = 9
  FinanceInstalmentAmount = 90.117930
  FinanceTotalPayable = 1114.958370

When the deposit charge is increased to 100:

Standard Plan
  SinglePaymentTotal = 1000
  FinanceDeposit = 333.8970
  FinanceNumberOfInstalments = 9
  FinanceInstalmentAmount = 86.48459666666666666666666667
  FinanceTotalPayable = 1112.2583700000000000000000000

So the total payable actually ends up being less. This implementation feels like it's probably broken - what should the correct implementation be?

StephenCollis commented 8 years ago

Tom, Can we have a quick call Monday to clarify your issues?

On Friday, 16 September 2016, Tom Michaelis notifications@github.com wrote:

In the example implementation https://github.com/PriceComparisonStandardsGroup/AddOns/blob/master/Finance/FinanceCalculation.md of the finance calculation, charges which are AppliedToDeposit are calculated by adding them to the premium, before doing additional calculations on the sum of the premium and the deposit charges to compute the eventual deposit. Because the full deposit is later subtracted from the loan, any deposit charges will increase the deposit, but reduce the loan amount accordingly. For example, the output from the implementation when the Deposit Charge is left at 0 is:

Standard Plan SinglePaymentTotal = 1000 FinanceDeposit = 303.8970 FinanceNumberOfInstalments = 9 FinanceInstalmentAmount = 90.117930 FinanceTotalPayable = 1114.958370

When the deposit charge is increased to 100:

Standard Plan SinglePaymentTotal = 1000 FinanceDeposit = 333.8970 FinanceNumberOfInstalments = 9 FinanceInstalmentAmount = 86.48459666666666666666666667 FinanceTotalPayable = 1112.2583700000000000000000000

So the total payable actually ends up being less. This implementation feels like it's probably broken - what should the correct implementation be?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/PriceComparisonStandardsGroup/AddOns/issues/16, or mute the thread https://github.com/notifications/unsubscribe-auth/APg4I6zNNwZHIrmm4quHpKY8BJnYtt03ks5qqpXEgaJpZM4J-7Ik .

Stephen Collis

IT Director Tel 01473 542001 Mob 07748 633867

tommichaelis commented 8 years ago

Afraid I'm out of the country this week - can we chat on Monday 26th?

Tom

On 16 September 2016 at 22:40, Stephen Collis notifications@github.com wrote:

Tom, Can we have a quick call Monday to clarify your issues?

On Friday, 16 September 2016, Tom Michaelis notifications@github.com wrote:

In the example implementation https://github.com/PriceComparisonStandardsGroup/ AddOns/blob/master/Finance/FinanceCalculation.md of the finance calculation, charges which are AppliedToDeposit are calculated by adding them to the premium, before doing additional calculations on the sum of the premium and the deposit charges to compute the eventual deposit. Because the full deposit is later subtracted from the loan, any deposit charges will increase the deposit, but reduce the loan amount accordingly. For example, the output from the implementation when the Deposit Charge is left at 0 is:

Standard Plan SinglePaymentTotal = 1000 FinanceDeposit = 303.8970 FinanceNumberOfInstalments = 9 FinanceInstalmentAmount = 90.117930 FinanceTotalPayable = 1114.958370

When the deposit charge is increased to 100:

Standard Plan SinglePaymentTotal = 1000 FinanceDeposit = 333.8970 FinanceNumberOfInstalments = 9 FinanceInstalmentAmount = 86.48459666666666666666666667 FinanceTotalPayable = 1112.2583700000000000000000000

So the total payable actually ends up being less. This implementation feels like it's probably broken - what should the correct implementation be?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/PriceComparisonStandardsGroup/AddOns/issues/16, or mute the thread https://github.com/notifications/unsubscribe-auth/ APg4I6zNNwZHIrmm4quHpKY8BJnYtt03ks5qqpXEgaJpZM4J-7Ik .

Stephen Collis

IT Director Tel 01473 542001 Mob 07748 633867

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/PriceComparisonStandardsGroup/AddOns/issues/16#issuecomment-247715631, or mute the thread https://github.com/notifications/unsubscribe-auth/ABU6FN18VP8JaZ5IpOEJYLPq8jy8GAq5ks5qqwzMgaJpZM4J-7Ik .

dsample commented 8 years ago

I agree with @tommichaelis, the following line is the only place the applyToDepositCharge is used, so for a DepositRate of 10% you'd end only be adding 10% of any applyToDepositCharge value:

decimal deposit = Math.Max(MinDeposit, ((premiumTotal + applyToDepositCharge) * DepositRate));

I would have thought the applyToDepositCharge is meant to be added to the deposit, and not become part of the deposit calculation.

decimal deposit = Math.Max(MinDeposit, (premiumTotal * DepositRate) + applyToDepositCharge);

dsample commented 8 years ago

Can we define the three charge types? I've been getting confused looking at the Spreadsheet and code example. My understanding (correct me if I'm wrong):

Using those definitions, in the spreadsheet, I see an AppliedToPremium charge in G6 (Set Up Fee) and an AppliedToLoan charge in G11 (Instalment Charge). There's no AppliedToDeposit charge in the spreadsheet, which makes it a bit strange to use as a spec for coding against, and hard to accurately answer this particular issue.

Edit: Correct the definition of AppliedToLoan from following the spreadsheet a bit more

Jquintonopengi commented 8 years ago

Opengi calculate the deposit charges by adding them on to the final deposit after other calculations have been performed, so:

Premium: £100 Deposit: 10% * £100 = £10 Loan: £90 Deposit with charge = £10 + £15 = £25

I hope that this helps.

dsample commented 8 years ago

@Jquintonopengi Thanks for confirming understanding. Do the other two definitions I give work as you'd expect too?

Jquintonopengi commented 8 years ago

Yes, I think these are correct. Here are a few worked examples of my current understanding:

In all cases: Premium: £100 Charge: £10 Deposit: 10% Interest: 10%

Applied to premium: Total before finance calculations: £100 + £10 = £110 Premium in deposit = £110 * 10% = £11 Premium to be financed = £110 – £11 = £99 Deposit = £11 Loan = £99 Interest = £99 * 10% = £9.90 Total payable = £119.90

Applied to loan: Total before finance calculations: £100 Premium in deposit = £100 * 10% = £10 Premium to be financed = £100 – £10 = £90 Deposit = £10 Loan = £90 + £10 = £100 Interest = £100 * 10% = £10 Total payable = £120

Applied to deposit: Total before finance calculations: £100 Premium in deposit = £100 * 10% = £10 Premium to be financed = £100 – £10 = £90 Deposit = £10 + £10 = £20 Loan = £90 Interest = £90 * 10% = £9.00 Total payable = £119.00

Note I don’t believe we allow deposit charges on capped plans, but I expect the charge would be added to the loan after the cap had been applied