-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add saving and investment types for category
- Loading branch information
1 parent
1148e99
commit a8edc6d
Showing
17 changed files
with
176 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace App\GraphQL\Queries; | ||
|
||
use App\Models\Transaction; | ||
use App\Domain\Metrics\ValueMetric; | ||
|
||
class TotalInvestment extends ValueMetric | ||
{ | ||
public function ranges() | ||
{ | ||
return null; | ||
} | ||
|
||
/** | ||
* @param null $_ | ||
* @param array<string, mixed> $args | ||
*/ | ||
public function __invoke($_, array $args) | ||
{ | ||
return Transaction::investment()->sum('amount'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace App\GraphQL\Queries; | ||
|
||
use App\Models\Transaction; | ||
use App\Domain\Metrics\ValueMetric; | ||
|
||
class TotalSavings extends ValueMetric | ||
{ | ||
public function ranges() | ||
{ | ||
return null; | ||
} | ||
|
||
/** | ||
* @param null $_ | ||
* @param array<string, mixed> $args | ||
*/ | ||
public function __invoke($_, array $args) | ||
{ | ||
return Transaction::savings()->sum('amount'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"/js/app.js": "/js/app.js?id=2f34dea68d844f1d7b06", | ||
"/js/app.js": "/js/app.js?id=a851dd183cd50e896983", | ||
"/css/app.css": "/css/app.css?id=58adc592c995babafb87" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Tests\Feature; | ||
|
||
use Tests\TestCase; | ||
use App\Models\Brand; | ||
use App\Models\Category; | ||
use App\Models\Transaction; | ||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
|
||
class TotalInvestmentTest extends TestCase | ||
{ | ||
use RefreshDatabase; | ||
|
||
/** @test */ | ||
public function it_returns_correct_data() | ||
{ | ||
$investmentCategory = Category::factory()->create(['type' => Category::INVESTMENT]); | ||
|
||
$investmentBrand = Brand::factory()->create(['category_id' => $investmentCategory->id]); | ||
|
||
Transaction::factory()->create(['brand_id' => $investmentBrand->id, 'amount' => 133]); | ||
|
||
$this->graphQL(/** @lang GraphQL */ ' | ||
{ | ||
totalInvestment | ||
} | ||
')->assertJson([ | ||
'data' => [ | ||
'totalInvestment' => '"133.0"' | ||
], | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Tests\Feature; | ||
|
||
use Tests\TestCase; | ||
use App\Models\Brand; | ||
use App\Models\Category; | ||
use App\Models\Transaction; | ||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
|
||
class TotalSavingsTest extends TestCase | ||
{ | ||
use RefreshDatabase; | ||
|
||
/** @test */ | ||
public function it_returns_correct_data() | ||
{ | ||
$savingsCategory = Category::factory()->create(['type' => Category::SAVINGS]); | ||
|
||
$savingsBrand = Brand::factory()->create(['category_id' => $savingsCategory->id]); | ||
|
||
Transaction::factory()->create(['brand_id' => $savingsBrand->id, 'amount' => 133]); | ||
|
||
$this->graphQL(/** @lang GraphQL */ ' | ||
{ | ||
totalSavings | ||
} | ||
')->assertJson([ | ||
'data' => [ | ||
'totalSavings' => '"133.0"' | ||
], | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters