fix sample data

This commit is contained in:
Cihan Şentürk
2023-01-11 11:55:00 +03:00
committed by GitHub
parent a2aee0b031
commit 9e08909af3
2 changed files with 71 additions and 41 deletions

View File

@ -40,7 +40,7 @@ class Transaction extends Factory
return [
'company_id' => $this->company->id,
'type' => $this->type,
'number' => $this->getNextTransactionNumber(),
'number' => $this->getNumber(),
'account_id' => setting('default.account'),
'paid_at' => $this->faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d H:i:s'),
'amount' => $this->faker->randomFloat(2, 1, 1000),
@ -89,7 +89,7 @@ class Transaction extends Factory
{
return $this->state([
'type' => $this->getRawAttribute('type') . '-recurring',
'number' => $this->getNextTransactionNumber('-recurring'),
'number' => $this->getNumber('-recurring'),
'recurring_started_at' => $this->getRawAttribute('paid_at'),
'recurring_frequency' => 'daily',
'recurring_custom_frequency' => 'daily',
@ -101,4 +101,17 @@ class Transaction extends Factory
'real_type' => $this->getRawAttribute('type'),
]);
}
/**
* Get transaction number
*
*/
public function getNumber($suffix = '')
{
$number = $this->getNextTransactionNumber($suffix);
$this->increaseNextTransactionNumber($suffix);
return $number;
}
}