fixed tests
This commit is contained in:
26
database/factories/Account.php
Normal file
26
database/factories/Account.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Banking\Account;
|
||||
use App\Models\Setting\Currency;
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$user = User::first();
|
||||
$company = $user->companies()->first();
|
||||
|
||||
$factory->define(Account::class, function (Faker $faker) use ($company) {
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
|
||||
return [
|
||||
'company_id' => $company->id,
|
||||
'name' => $faker->text(5),
|
||||
'number' => (string) $faker->randomNumber(2),
|
||||
'currency_code' => setting('default.currency'),
|
||||
//'currency_code' => Currency::enabled()->get()->random(1)->pluck('code')->first(),
|
||||
'opening_balance' => '0',
|
||||
'bank_name' => $faker->text(5),
|
||||
'bank_phone' => null,
|
||||
'bank_address' => null,
|
||||
'enabled' => $faker->boolean ? 1 : 0,
|
||||
];
|
||||
});
|
@ -4,9 +4,11 @@ use App\Models\Auth\User;
|
||||
use App\Models\Common\Item;
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(Item::class, function (Faker $faker) {
|
||||
$user = User::first();
|
||||
$company = $user->companies()->first();
|
||||
$user = User::first();
|
||||
$company = $user->companies()->first();
|
||||
|
||||
$factory->define(Item::class, function (Faker $faker) use ($company) {
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
|
||||
return [
|
||||
'company_id' => $company->id,
|
||||
|
@ -27,23 +27,16 @@ class Accounts extends Seeder
|
||||
$company_id = $this->command->argument('company');
|
||||
|
||||
setting()->setExtraColumns(['company_id' => $company_id]);
|
||||
setting()->forgetAll();
|
||||
|
||||
$rows = [
|
||||
[
|
||||
'company_id' => $company_id,
|
||||
'name' => trans('demo.accounts.cash'),
|
||||
'number' => '1',
|
||||
'currency_code' => 'USD',
|
||||
'bank_name' => trans('demo.accounts.cash'),
|
||||
'enabled' => '1',
|
||||
],
|
||||
];
|
||||
$account = Account::create([
|
||||
'company_id' => $company_id,
|
||||
'name' => trans('demo.accounts.cash'),
|
||||
'number' => '1',
|
||||
'currency_code' => 'USD',
|
||||
'bank_name' => trans('demo.accounts.cash'),
|
||||
'enabled' => '1',
|
||||
]);
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$account = Account::create($row);
|
||||
|
||||
setting()->set('default.account', $account->id);
|
||||
}
|
||||
setting()->set('default.account', $account->id);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user