mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Improve mock data quality:
This commit is contained in:
parent
3062ee4fec
commit
ccaa5c1d31
@ -14,8 +14,10 @@ namespace App\Console\Commands;
|
||||
use App\DataMapper\CompanySettings;
|
||||
use App\DataMapper\FeesAndLimits;
|
||||
use App\Events\Invoice\InvoiceWasCreated;
|
||||
use App\Factory\GroupSettingFactory;
|
||||
use App\Factory\InvoiceFactory;
|
||||
use App\Factory\InvoiceItemFactory;
|
||||
use App\Factory\SubscriptionFactory;
|
||||
use App\Helpers\Invoice\InvoiceSum;
|
||||
use App\Jobs\Company\CreateCompanyTaskStatuses;
|
||||
use App\Models\Account;
|
||||
@ -201,6 +203,54 @@ class CreateSingleAccount extends Command
|
||||
}
|
||||
|
||||
$this->createGateways($company, $user);
|
||||
|
||||
$this->createSubsData($company, $user);
|
||||
}
|
||||
|
||||
private function createSubsData($company, $user)
|
||||
{
|
||||
$gs = GroupSettingFactory::create($company->id, $user->id);
|
||||
$gs->name = "plans";
|
||||
$gs->save();
|
||||
|
||||
$p1 = Product::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'company_id' => $company->id,
|
||||
'product_key' => 'pro_plan',
|
||||
'notes' => 'The Pro Plan',
|
||||
'cost' => 10,
|
||||
'price' => 10,
|
||||
'quantity' => 1,
|
||||
]);
|
||||
|
||||
$p2 = Product::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'company_id' => $company->id,
|
||||
'product_key' => 'enterprise_plan',
|
||||
'notes' => 'The Pro Plan',
|
||||
'cost' => 10,
|
||||
'price' => 10,
|
||||
'quantity' => 1,
|
||||
]);
|
||||
|
||||
$webhook_config = [
|
||||
'post_purchase_url' => 'http://ninja.test:8000/api/admin/plan',
|
||||
'post_purchase_rest_method' => 'POST',
|
||||
];
|
||||
|
||||
$sub = SubscriptionFactory::create($company->id, $user->id);
|
||||
$sub->name = "Pro Plan";
|
||||
$sub->group_id = $gs->id;
|
||||
$sub->recurring_product_ids = "{$p1->hashed_id}";
|
||||
$sub->webhook_configuration = $webhook_config;
|
||||
$sub->save();
|
||||
|
||||
$sub = SubscriptionFactory::create($company->id, $user->id);
|
||||
$sub->name = "Enterprise Plan";
|
||||
$sub->group_id = $gs->id;
|
||||
$sub->recurring_product_ids = "{$p2->hashed_id}";
|
||||
$sub->webhook_configuration = $webhook_config;
|
||||
$sub->save();
|
||||
}
|
||||
|
||||
private function createClient($company, $user)
|
||||
|
@ -11,17 +11,21 @@
|
||||
|
||||
namespace App\Factory;
|
||||
|
||||
use App\Models\Client;
|
||||
use App\Models\GroupSetting;
|
||||
|
||||
class GroupSettingFactory
|
||||
{
|
||||
public static function create(int $company_id, int $user_id) :GroupSetting
|
||||
{
|
||||
$settings = new \stdClass;
|
||||
$settings->entity = Client::class;
|
||||
|
||||
$gs = new GroupSetting;
|
||||
$gs->name = '';
|
||||
$gs->company_id = $company_id;
|
||||
$gs->user_id = $user_id;
|
||||
$gs->settings = '{}';
|
||||
$gs->settings = $settings;
|
||||
|
||||
return $gs;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user