Feat: Adds multi currency support (#88)
This commit is contained in:
@@ -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) => [
|
||||
|
||||
@@ -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,
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user