Completed
Pull Request — master (#6)
by
unknown
02:24
created
src/Utils/MathFuncs.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -80,11 +80,11 @@
 block discarded – undo
80 80
             return (string)number_format((float)$roundedNumber, $precision);
81 81
         }
82 82
         
83
-         /**
84
-         * @param $roundedNumber
85
-         * @param $precision
86
-         * @return string
87
-         */
83
+            /**
84
+             * @param $roundedNumber
85
+             * @param $precision
86
+             * @return string
87
+             */
88 88
         public static function round_up($roundedNumber, $precision = 2) 
89 89
         {
90 90
             return (string)ceil((float)$roundedNumber * pow(10, $precision)) / pow(10, $precision);
Please login to merge, or discard this patch.
src/Calculators/DebtAmortizator.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
         public function getDebtSingleRepayment_Rounded() {
298 298
             // single repayment 'K = PV/((1-v^n)/i)'
299 299
             return MathFuncs::round_up(
300
-            	MathFuncs::div(
300
+                MathFuncs::div(
301 301
                 $this->debtPrincipal,
302 302
                 MathFuncs::div(
303 303
                     MathFuncs::sub(
@@ -338,33 +338,33 @@  discard block
 block discarded – undo
338 338
             return $repayments;
339 339
         }
340 340
 				
341
-				 /**
342
-         * @return array
343
-         */
341
+                    /**
342
+                     * @return array
343
+                     */
344 344
         public function getDebtRepaymentsAsArrays_Rounded()
345 345
         {
346 346
             $repayments = array();
347 347
             $i = 1;
348 348
             $balance = $this->debtPrincipal;            
349 349
             foreach ($this->debtRepayments as $repayment) {
350
-          			if($balance > $repayment->getTotalAmount()) {      
351
-										$totalAmount = MathFuncs::round_up($repayment->getTotalAmount(), 2);
352
-										$interestAmount = MathFuncs::round($repayment->getInterestAmount(), 2);
353
-										$principalAmount = MathFuncs::round($totalAmount - $interestAmount, 2);
354
-								}
355
-								else {
356
-										$interestAmount = MathFuncs::round($repayment->getInterestAmount(), 2);
357
-										$totalAmount = MathFuncs::round(MathFuncs::add($balance, $interestAmount), 2);
358
-										$principalAmount = MathFuncs::round($balance, 2);
359
-								}
350
+                        if($balance > $repayment->getTotalAmount()) {      
351
+                                        $totalAmount = MathFuncs::round_up($repayment->getTotalAmount(), 2);
352
+                                        $interestAmount = MathFuncs::round($repayment->getInterestAmount(), 2);
353
+                                        $principalAmount = MathFuncs::round($totalAmount - $interestAmount, 2);
354
+                                }
355
+                                else {
356
+                                        $interestAmount = MathFuncs::round($repayment->getInterestAmount(), 2);
357
+                                        $totalAmount = MathFuncs::round(MathFuncs::add($balance, $interestAmount), 2);
358
+                                        $principalAmount = MathFuncs::round($balance, 2);
359
+                                }
360 360
             		
361
-            		$beginningBalance = $balance;
362
-            		$endingBalance = MathFuncs::sub($balance, $principalAmount);
363
-            		$balance = MathFuncs::sub($balance, $principalAmount);
361
+                    $beginningBalance = $balance;
362
+                    $endingBalance = MathFuncs::sub($balance, $principalAmount);
363
+                    $balance = MathFuncs::sub($balance, $principalAmount);
364 364
             		
365 365
                 $repayments[$i++] = [
366
-                		"beginningBalance" => MathFuncs::round($beginningBalance, 2),
367
-                		"totalAmount" => $totalAmount,
366
+                        "beginningBalance" => MathFuncs::round($beginningBalance, 2),
367
+                        "totalAmount" => $totalAmount,
368 368
                     "principalAmount" => $principalAmount,
369 369
                     "interestAmount" => $interestAmount,
370 370
                     "endingBalance" => MathFuncs::round($endingBalance, 2)
Please login to merge, or discard this patch.