Feat: Adds multi currency support (#88)

This commit is contained in:
hackerESQ
2025-04-09 19:25:15 -05:00
committed by GitHub
parent 6d6f968f42
commit eae345f243
100 changed files with 17735 additions and 35761 deletions
+32 -4
View File
@@ -41,28 +41,35 @@ class TransactionFactory extends Factory
public function yearsAgo(): static
{
return $this->state(fn (array $attributes) => [
'date' => $this->faker->dateTimeBetween('-5 years', '-3 years')->format('Y-m-d'),
'date' => now()->subYears($this->faker->numberBetween(3, 5))->toDateString(),
]);
}
public function lastYear(): static
{
return $this->state(fn (array $attributes) => [
'date' => now()->subYear()->format('Y-m-d'),
'date' => now()->subYear()->toDateString(),
]);
}
public function lastMonth(): static
{
return $this->state(fn (array $attributes) => [
'date' => now()->subMonth()->format('Y-m-d'),
'date' => now()->subMonth()->toDateString(),
]);
}
public function recent(): static
{
return $this->state(fn (array $attributes) => [
'date' => $this->faker->dateTimeBetween('-2 weeks', 'now')->format('Y-m-d'),
'date' => now()->subDays($this->faker->numberBetween(3, 14))->toDateString(),
]);
}
public function date($date): static
{
return $this->state(fn (array $attributes) => [
'date' => $date,
]);
}
@@ -80,6 +87,27 @@ class TransactionFactory extends Factory
]);
}
public function currency($currency): static
{
return $this->state(fn (array $attributes) => [
'currency' => $currency,
]);
}
public function costBasis($cost_basis): static
{
return $this->state(fn (array $attributes) => [
'cost_basis' => $cost_basis,
]);
}
public function salePrice($sale_price): static
{
return $this->state(fn (array $attributes) => [
'sale_price' => $sale_price,
]);
}
public function buy(): static
{
return $this->state(fn (array $attributes) => [
+14
View File
@@ -34,6 +34,10 @@ class UserFactory extends Factory
'two_factor_recovery_codes' => null,
'remember_token' => Str::random(10),
'profile_photo_path' => null,
'options' => [
'display_currency' => 'USD',
'locale' => 'en',
],
];
}
@@ -46,4 +50,14 @@ class UserFactory extends Factory
'email_verified_at' => null,
]);
}
/**
* Indicate that the model's currency.
*/
public function currency($currency): static
{
return $this->state(fn (array $attributes) => array_merge($attributes['options'], [
'currency' => $currency,
]));
}
}