You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TaxFactory.php 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Database\Factories\Setting;
  3. use App\Enums\Setting\TaxComputation;
  4. use App\Enums\Setting\TaxScope;
  5. use App\Enums\Setting\TaxType;
  6. use App\Models\Setting\Tax;
  7. use Illuminate\Database\Eloquent\Factories\Factory;
  8. /**
  9. * @extends Factory<Tax>
  10. */
  11. class TaxFactory extends Factory
  12. {
  13. /**
  14. * The name of the factory's corresponding model.
  15. */
  16. protected $model = Tax::class;
  17. /**
  18. * Define the model's default state.
  19. *
  20. * @return array<string, mixed>
  21. */
  22. public function definition(): array
  23. {
  24. return [
  25. 'description' => $this->faker->sentence,
  26. 'rate' => $this->faker->biasedNumberBetween(300, 5000) * 100, // 3% - 50%
  27. 'computation' => $this->faker->randomElement(TaxComputation::class),
  28. 'scope' => $this->faker->randomElement(TaxScope::class),
  29. 'enabled' => true,
  30. ];
  31. }
  32. public function salesTax(): self
  33. {
  34. return $this->state([
  35. 'name' => 'State Sales Tax',
  36. 'rate' => $this->faker->biasedNumberBetween(300, 1200) * 100, // 3% - 12%
  37. 'type' => TaxType::Sales,
  38. ]);
  39. }
  40. public function purchaseTax(): self
  41. {
  42. return $this->state([
  43. 'name' => 'State Purchase Tax',
  44. 'rate' => $this->faker->biasedNumberBetween(300, 1200) * 100, // 3% - 12%
  45. 'type' => TaxType::Purchase,
  46. ]);
  47. }
  48. }