Skip to content

Commit

Permalink
Merge pull request #77 from hisabi-app/fix/remaining-to-spend-logic
Browse files Browse the repository at this point in the history
fix remaining to spend logic
  • Loading branch information
saleem-hadad authored Apr 22, 2024
2 parents 8101b99 + 04f95db commit 8e1c7c4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/Models/Budget.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getTotalSpentPercentageAttribute(): string
*/
public function getTotalMarginPerDayAttribute(): string
{
$days = now()->diffInDays($this->end_at);
$days = now()->diffInDays($this->end_at_date);
$remainingAmount = $this->amount - $this->totalTransactionsAmount;

if($days < 0 || $remainingAmount <= 0) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Models/Budgets/BudgetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function it_has_totalMarginPerDay_should_return_correct_value()
{
$category = Category::factory()->create();
$brand = Brand::factory()->create(['category_id' => $category->id]);
$sut = Budget::factory()->create(['start_at' => now()->subDays(1), 'end_at' => now()->addDays(3), 'amount' => 700]);
$sut = Budget::factory()->create(['start_at' => now(), 'period' => 3, 'reoccurrence' => Budget::DAILY, 'amount' => 700]);
$sut->categories()->attach($category);

$category->transactions()->create(['amount' => 600, 'brand_id' => $brand->id]);
Expand Down

0 comments on commit 8e1c7c4

Please sign in to comment.