Skip to content

Commit

Permalink
– updated README and tests for AnnuityCalculator
Browse files Browse the repository at this point in the history
  • Loading branch information
uruba committed Sep 8, 2015
1 parent 9dc6c68 commit ec46828
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ use FinanCalc\Utils\Time\TimeUtils;
$annuityCalculatorDirect = new DebtAmortizator(
40000,
6,
TimeUtils::getDaysFromYears(1),
TimeSpan::asDuration(1),
0.12);
```

Expand Down Expand Up @@ -281,16 +281,16 @@ The implicit type of setters'/constructors' arguments as well as getters' return

### AnnuityCalculator
namespace `FinanCalc\Calculators`
* **__construct($annuitySinglePaymentAmount, $annuityNoOfCompoundingPeriods, $annuityPeriodLength, $annuityInterest)**
* **__construct($annuitySinglePaymentAmount, $annuityNoOfCompoundingPeriods, TimeSpan $annuityPeriodLength, $annuityInterest)**
* *$annuitySinglePaymentAmount* = **'K'** – amount of each individual payment (number greater than zero)
* *$annuityNoOfCompoundingPeriods* = **'n'** – number of periods pertaining to the interest compounding; if 'n = 0', the annuity is considered a perpetuity
* *$annuityPeriodLength* = length of a single period in days (number greater than zero)
* *$annuityPeriodLength* = length of a single period as a TimeSpan object
* *$annuityInterest* = **'i'** – the interest rate *per a single payment period* by which the unpaid balance is multiplied (i.e., a decimal number typically lower than 1 and greater than 0)

##### Setters
* **setAnnuitySinglePaymentAmount($annuitySinglePaymentAmount)** – sets K
* **setAnnuityNoOfCompoundingPeriods($annuityNoOfCompoundingPeriods)** – sets n
* **setAnnuityPeriodLength($annuityPeriodLength)** – sets the length of each compounding period in days
* **setAnnuityPeriodLength(TimeSpan $annuityPeriodLength)** – sets the length of each compounding period in days
* **setAnnuityInterest($annuityInterest)** – sets i

##### Getters
Expand Down
7 changes: 7 additions & 0 deletions src/Calculators/AnnuityCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ public function getAnnuityNoOfCompoundingPeriods() {
return $this->annuityNoOfCompoundingPeriods;
}

/**
* @return TimeSpan
*/
public function getAnnuityPeriodLength() {
return $this->annuityPeriodLength;
}

/**
* @return string
*/
Expand Down
14 changes: 12 additions & 2 deletions tests/AnnuityCalculatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,14 @@ public function testMonthlyAnnuityFactory() {
);

$this->assertEquals(
1,
TimeSpan::asDuration(0,1,0),
$annuityCalculatorFactoryMonthly
->getAnnuityPeriodLength()
);

$this->assertEquals(
1,
$annuityCalculatorFactoryMonthly
->getAnnuityPeriodLengthInMonths()
);
}
Expand Down Expand Up @@ -215,9 +220,14 @@ public function testDailyAnnuityFactory() {
);

$this->assertEquals(
1,
TimeSpan::asDuration(0,0,1),
$annuityCalculatorFactoryDaily
->getAnnuityPeriodLength()
);

$this->assertEquals(
1,
$annuityCalculatorFactoryDaily
->getAnnuityPeriodLengthInDays()
);
}
Expand Down

0 comments on commit ec46828

Please sign in to comment.