Skip to content

Commit

Permalink
Merge pull request #74 from hisabi-app/feat/update-budget-schema
Browse files Browse the repository at this point in the history
feature: update budget schema
  • Loading branch information
saleem-hadad authored Apr 22, 2024
2 parents 9a33e1c + 6c760a8 commit f6dc9e5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/Models/Budget.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function getEndAtDateAttribute()
return $this->getCurrentWindowStartAndEndDates()[1]->format('Y-m-d');
}

public function getTotalAccumulatedTransactionsAmountAttribute()
public function getTotalTransactionsAmountAttribute()
{
$categories = $this->categories()->with('transactions')->get();
[$startAt, $endAt] = $this->getCurrentWindowStartAndEndDates();
Expand Down
3 changes: 2 additions & 1 deletion graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ type Category {

type Budget {
id: ID!
name: String!
amount: Float!
totalAccumulatedTransactionsAmount: Float!
totalTransactionsAmount: Float!
startAtDate: String!
endAtDate: String!
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Models/Budgets/BudgetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function it_belongs_to_categories()
}

/** @test */
public function it_has_total_categories_transactions_amount()
public function it_has_total_transactions_amount()
{
$category = Category::factory()->create();
$brand = Brand::factory()->create(['category_id' => $category->id]);
Expand All @@ -42,7 +42,7 @@ public function it_has_total_categories_transactions_amount()
$category->transactions()->create(['amount' => 200, 'brand_id' => $brand->id]);
$category->transactions()->create(['amount' => 200, 'brand_id' => $brand->id, 'created_at' => now()->addDays(2)]);

$this->assertEquals(300, $sut->totalAccumulatedTransactionsAmount);
$this->assertEquals(300, $sut->totalTransactionsAmount);
}

/** @test */
Expand Down

0 comments on commit f6dc9e5

Please sign in to comment.