PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
tablepress / libraries / vendor / PhpSpreadsheet / Calculation / Financial / CashFlow / Constant / Periodic / InterestAndPrincipal.php

InterestAndPrincipal.php in TablePress – Tables in WordPress made easy 3.4, at libraries/vendor/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/InterestAndPrincipal.php

45 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TablePress\PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\Constant\Periodic;
4
5 use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Financial\Constants as FinancialConstants;
6
7 class InterestAndPrincipal
8 {
9 protected float $interest;
10
11 protected float $principal;
12
13 public function __construct(
14 float $rate = 0.0,
15 int $period = 0,
16 int $numberOfPeriods = 0,
17 float $presentValue = 0,
18 float $futureValue = 0,
19 int $type = FinancialConstants::PAYMENT_END_OF_PERIOD
20 ) {
21 $payment = Payments::annuity($rate, $numberOfPeriods, $presentValue, $futureValue, $type);
22 $capital = $presentValue;
23 $interest = 0.0;
24 $principal = 0.0;
25 for ($i = 1; $i <= $period; ++$i) {
26 $interest = ($type === FinancialConstants::PAYMENT_BEGINNING_OF_PERIOD && $i == 1) ? 0 : -$capital * $rate;
27 $principal = (float) $payment - $interest;
28 $capital += $principal;
29 }
30
31 $this->interest = $interest;
32 $this->principal = $principal;
33 }
34
35 public function interest(): float
36 {
37 return $this->interest;
38 }
39
40 public function principal(): float
41 {
42 return $this->principal;
43 }
44 }
45