Skip to content

Commit

Permalink
Add debt column
Browse files Browse the repository at this point in the history
  • Loading branch information
manelgavalda committed May 9, 2024
1 parent cd28059 commit 8191985
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/Models/Total.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Total extends Model
protected $guarded = [];

protected $casts = [
'debt' => 'float',
'price' => 'float',
'balance' => 'float',
'price_eur' => 'float',
Expand Down
1 change: 1 addition & 0 deletions app/Services/SupabaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function getHistoricalBalances()
->reverse()->values();

return [
'debt' => $balances->pluck('debt')->toArray(),
'prices' => $balances->pluck('price')->toArray(), // eth_price
'ethereum' => $balances->pluck('balance')->toArray(), // total_usd / eth_price
'btc_prices' => $balances->pluck('btc_price')->toArray(), // btc_price
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function up(): void
$table->string('price');
$table->string('balance');
$table->string('price_eur');
$table->string('debt')->nullable();
$table->string('btc_price')->nullable();
$table->string('btc_price_eur')->nullable();
$table->timestamps();
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/SupabaseServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function createEntries($type) {
$dates = $this->balances['dates'];

expect(end($dates))->toBe('Nov 08 2024');
expect(end($this->balances['debt']))->toBe(5000.0);
expect(end($this->balances['prices']))->toBe(2000.0);
expect(end($this->balances['bitcoin']))->toBe(200.0);
expect(end($this->balances['ethereum']))->toBe(2000.0);
Expand Down
1 change: 1 addition & 0 deletions tests/responses/totals.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[
{
"debt": 5000,
"price": 2000,
"price_eur": 1900,
"balance": 2000,
Expand Down

0 comments on commit 8191985

Please sign in to comment.