This commit is contained in:
Denis Duliçi 2021-02-07 01:09:31 +03:00
parent 74ee6fd0d4
commit 53e12abe38

View File

@ -27,6 +27,8 @@ class Transaction extends Factory
$types = array_merge($this->getIncomeTypes(), $this->getExpenseTypes());
$type = $this->faker->randomElement($types);
$category_type = in_array($type, $this->getIncomeTypes()) ? 'income' : 'expense';
return [
'company_id' => $this->company->id,
'type' => $type,
@ -36,7 +38,7 @@ class Transaction extends Factory
'currency_code' => setting('default.currency'),
'currency_rate' => '1.0',
'description' => $this->faker->text(5),
'category_id' => $this->company->categories()->type($type)->get()->random(1)->pluck('id')->first(),
'category_id' => $this->company->categories()->$category_type()->get()->random(1)->pluck('id')->first(),
'reference' => $this->faker->text(5),
'payment_method' => setting('default.payment_method'),
];