Prevent RecurringRepository from tampering with amounts (this should be done in the controllers, beforehand)
MODIFY
app/Http/Controllers/RecurringController.php
app/Http/Controllers/RecurringController.php
namespace App\Http\Controllers;
+use App\Helper;
use Illuminate\Http\Request;
use App\Models\Recurring;
@@ -49,7 +50,7 @@ class RecurringController extends Controller {
$request->input('end', null),
$request->input('tag', null),
$request->input('description'),
- $request->input('amount')
+ Helper::rawNumberToInteger($request->input('amount'))
);
ProcessRecurrings::dispatch();

MODIFY
app/Repositories/RecurringRepository.php
app/Repositories/RecurringRepository.php
namespace App\Repositories;
-use App\Helper;
use App\Models\Recurring;
use Exception;
@@ -37,7 +36,7 @@ class RecurringRepository
'ends_on' => $endDate,
'tag_id' => $tagId,
'description' => $description,
- 'amount' => Helper::rawNumberToInteger($amount)
+ 'amount' => $amount
]);
}
}

MODIFY
tests/Unit/RecurringRepositoryTest.php
tests/Unit/RecurringRepositoryTest.php
@@ -21,7 +21,7 @@ class RecurringRepositoryTest extends TestCase
$spaceId = 1;
$tagId = 1;
- $recurring = $this->recurringRepository->create($spaceId, 'spending', 3, null, $tagId, 'Test', 100);
+ $recurring = $this->recurringRepository->create($spaceId, 'spending', 3, null, $tagId, 'Test', 10000);
$this->assertNotNull($recurring);
$this->assertEquals(10000, $recurring->amount);

Prevent RecurringRepository from tampering with amounts (this should be done in the controllers, beforehand)