1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00
invoiceninja/tests/MockAccountData.php

619 lines
21 KiB
PHP
Raw Normal View History

<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Tests;
2019-09-11 07:32:47 +02:00
use App\DataMapper\ClientSettings;
2019-09-18 14:43:37 +02:00
use App\DataMapper\CompanySettings;
use App\Factory\CompanyUserFactory;
use App\Factory\CreditFactory;
use App\Factory\InvoiceFactory;
use App\Factory\InvoiceInvitationFactory;
use App\Factory\InvoiceItemFactory;
use App\Factory\InvoiceToRecurringInvoiceFactory;
use App\Helpers\Invoice\InvoiceSum;
2021-02-24 03:12:23 +01:00
use App\Jobs\Company\CreateCompanyTaskStatuses;
2020-10-01 12:49:47 +02:00
use App\Models\Account;
use App\Models\Client;
2020-08-12 03:04:15 +02:00
use App\Models\ClientContact;
2020-10-01 12:49:47 +02:00
use App\Models\Company;
2019-09-18 14:43:37 +02:00
use App\Models\CompanyGateway;
2019-10-02 12:22:10 +02:00
use App\Models\CompanyToken;
2020-10-26 10:13:00 +01:00
use App\Models\CreditInvitation;
2020-10-01 12:49:47 +02:00
use App\Models\Expense;
2020-10-13 06:08:56 +02:00
use App\Models\ExpenseCategory;
2019-09-11 07:32:47 +02:00
use App\Models\GroupSetting;
use App\Models\InvoiceInvitation;
2020-10-11 23:34:02 +02:00
use App\Models\Product;
2020-10-08 00:25:39 +02:00
use App\Models\Project;
use App\Models\Quote;
2020-10-01 12:49:47 +02:00
use App\Models\QuoteInvitation;
use App\Models\RecurringInvoice;
2020-10-12 22:42:02 +02:00
use App\Models\Task;
2020-10-20 01:01:59 +02:00
use App\Models\TaskStatus;
use App\Models\User;
2020-10-01 12:49:47 +02:00
use App\Models\Vendor;
use App\Models\VendorContact;
use App\Utils\Traits\GeneratesCounter;
use App\Utils\Traits\MakesHash;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Storage;
/**
* Class MockAccountData.
*/
trait MockAccountData
{
use MakesHash;
use GeneratesCounter;
2020-10-28 11:10:49 +01:00
/**
* @var
*/
public $account;
2020-10-28 11:10:49 +01:00
/**
* @var
*/
public $company;
2020-10-28 11:10:49 +01:00
/**
* @var
*/
public $user;
2020-10-28 11:10:49 +01:00
/**
* @var
*/
public $client;
2020-10-28 11:10:49 +01:00
/**
* @var
*/
2019-10-02 12:22:10 +02:00
public $token;
2020-10-28 11:10:49 +01:00
/**
* @var
*/
public $invoice;
2020-10-28 11:10:49 +01:00
/**
* @var
*/
public $quote;
2020-10-28 11:10:49 +01:00
/**
* @var
*/
2020-09-23 02:16:19 +02:00
public $vendor;
2020-10-28 11:10:49 +01:00
/**
* @var
*/
2020-09-23 02:46:35 +02:00
public $expense;
2020-10-28 11:10:49 +01:00
/**
* @var
*/
2020-10-12 22:42:02 +02:00
public $task;
2020-10-28 11:10:49 +01:00
/**
* @var
*/
2020-10-20 01:01:59 +02:00
public $task_status;
2020-10-28 11:10:49 +01:00
/**
* @var
*/
2020-10-13 06:08:56 +02:00
public $expense_category;
2020-10-28 11:10:49 +01:00
/**
* @var
*/
public $cu;
2020-10-28 11:10:49 +01:00
/**
*
*/
public function makeTestData()
{
config(['database.default' => config('ninja.db.default')]);
/* Warm up the cache !*/
$cached_tables = config('ninja.cached_tables');
2021-02-02 09:51:12 +01:00
$this->artisan('db:seed --force');
2021-01-26 22:42:00 +01:00
foreach ($cached_tables as $name => $class) {
// check that the table exists in case the migration is pending
if (! Schema::hasTable((new $class())->getTable())) {
continue;
}
if ($name == 'payment_terms') {
$orderBy = 'num_days';
} elseif ($name == 'fonts') {
$orderBy = 'sort_order';
} elseif (in_array($name, ['currencies', 'industries', 'languages', 'countries', 'banks'])) {
$orderBy = 'name';
} else {
$orderBy = 'id';
}
$tableData = $class::orderBy($orderBy)->get();
if ($tableData->count()) {
Cache::forever($name, $tableData);
}
}
2020-10-01 12:49:47 +02:00
$this->account = Account::factory()->create();
$this->company = Company::factory()->create([
'account_id' => $this->account->id,
]);
Storage::makeDirectory($this->company->company_key.'/documents', 0755, true);
Storage::makeDirectory($this->company->company_key.'/images', 0755, true);
2020-02-17 21:07:32 +01:00
$settings = CompanySettings::defaults();
2021-07-26 14:00:47 +02:00
$settings->company_logo = 'https://app.invoiceninja.com/favicon-v2.png';
2021-07-26 13:31:21 +02:00
// $settings->company_logo = asset('images/new_logo.png');
$settings->website = 'www.invoiceninja.com';
$settings->address1 = 'Address 1';
$settings->address2 = 'Address 2';
$settings->city = 'City';
$settings->state = 'State';
$settings->postal_code = 'Postal Code';
$settings->phone = '555-343-2323';
$settings->email = 'user@example.com';
$settings->country_id = '840';
2020-02-17 21:07:32 +01:00
$settings->vat_number = 'vat number';
$settings->id_number = 'id number';
2020-10-26 20:10:04 +01:00
$settings->use_credits_payment = 'always';
2021-01-26 22:42:00 +01:00
$settings->timezone_id = '1';
2020-10-28 11:10:49 +01:00
2020-02-17 21:07:32 +01:00
$this->company->settings = $settings;
$this->company->save();
$this->account->default_company_id = $this->company->id;
$this->account->save();
2021-01-26 22:42:00 +01:00
$user = User::whereEmail('user@example.com')->first();
2021-01-26 22:42:00 +01:00
if (! $user) {
$user = User::factory()->create([
2021-05-26 03:32:01 +02:00
'account_id' => $this->account->id,
'confirmation_code' => $this->createDbHash(config('database.default')),
'email' => 'user@example.com',
]);
}
2021-01-26 22:42:00 +01:00
$user->password = Hash::make('ALongAndBriliantPassword');
2021-06-21 07:02:28 +02:00
2021-01-26 22:42:00 +01:00
$user_id = $user->id;
$this->user = $user;
2020-06-27 04:35:11 +02:00
2021-02-24 03:12:23 +01:00
CreateCompanyTaskStatuses::dispatchNow($this->company, $this->user);
2021-01-26 22:42:00 +01:00
$this->cu = CompanyUserFactory::create($user->id, $this->company->id, $this->account->id);
$this->cu->is_owner = true;
$this->cu->is_admin = true;
$this->cu->save();
$this->token = \Illuminate\Support\Str::random(64);
2019-10-02 12:22:10 +02:00
$company_token = new CompanyToken;
2021-01-26 22:42:00 +01:00
$company_token->user_id = $user->id;
$company_token->company_id = $this->company->id;
$company_token->account_id = $this->account->id;
$company_token->name = 'test token';
$company_token->token = $this->token;
$company_token->is_system = true;
$company_token->save();
2019-10-02 12:22:10 +02:00
2021-01-26 22:42:00 +01:00
//todo create one token with token name TOKEN - use firstOrCreate
2020-10-11 23:34:02 +02:00
Product::factory()->create([
2021-01-26 22:42:00 +01:00
'user_id' => $user_id,
2020-10-11 23:34:02 +02:00
'company_id' => $this->company->id,
]);
2020-10-28 11:10:49 +01:00
2020-10-01 12:49:47 +02:00
$this->client = Client::factory()->create([
2021-01-26 22:42:00 +01:00
'user_id' => $user_id,
2020-02-17 21:07:32 +01:00
'company_id' => $this->company->id,
2020-09-23 02:46:35 +02:00
]);
2020-02-17 21:07:32 +01:00
Storage::makeDirectory($this->company->company_key.'/'.$this->client->client_hash.'/invoices', 0755, true);
Storage::makeDirectory($this->company->company_key.'/'.$this->client->client_hash.'/credits', 0755, true);
Storage::makeDirectory($this->company->company_key.'/'.$this->client->client_hash.'/quotes', 0755, true);
2020-10-01 12:49:47 +02:00
$contact = ClientContact::factory()->create([
2021-01-26 22:42:00 +01:00
'user_id' => $user_id,
'client_id' => $this->client->id,
'company_id' => $this->company->id,
'is_primary' => 1,
'send_email' => true,
2020-09-23 02:46:35 +02:00
]);
2020-10-01 12:49:47 +02:00
$contact2 = ClientContact::factory()->create([
2021-01-26 22:42:00 +01:00
'user_id' => $user_id,
'client_id' => $this->client->id,
'company_id' => $this->company->id,
'send_email' => true,
2020-09-23 02:46:35 +02:00
]);
2020-08-12 03:04:15 +02:00
2020-10-01 12:49:47 +02:00
$this->vendor = Vendor::factory()->create([
2021-01-26 22:42:00 +01:00
'user_id' => $user_id,
2020-09-23 02:16:19 +02:00
'company_id' => $this->company->id,
]);
2020-10-01 12:49:47 +02:00
$vendor_contact = VendorContact::factory()->create([
2021-01-26 22:42:00 +01:00
'user_id' => $user_id,
2020-09-23 02:16:19 +02:00
'vendor_id' => $this->vendor->id,
'company_id' => $this->company->id,
'is_primary' => 1,
'send_email' => true,
2020-09-23 02:46:35 +02:00
]);
2020-09-23 02:16:19 +02:00
2020-10-01 12:49:47 +02:00
$vendor_contact2 = VendorContact::factory()->create([
2021-01-26 22:42:00 +01:00
'user_id' => $user_id,
2020-09-23 02:16:19 +02:00
'vendor_id' => $this->vendor->id,
'company_id' => $this->company->id,
'send_email' => true,
2020-09-23 02:46:35 +02:00
]);
2020-10-08 00:25:39 +02:00
$this->project = Project::factory()->create([
2021-01-26 22:42:00 +01:00
'user_id' => $user_id,
2020-10-08 00:25:39 +02:00
'company_id' => $this->company->id,
]);
2020-10-01 12:49:47 +02:00
$this->expense = Expense::factory()->create([
2021-01-26 22:42:00 +01:00
'user_id' => $user_id,
2020-09-23 02:46:35 +02:00
'company_id' => $this->company->id,
]);
2020-09-23 02:16:19 +02:00
2020-10-12 22:42:02 +02:00
$this->task = Task::factory()->create([
2021-01-26 22:42:00 +01:00
'user_id' => $user_id,
2020-10-12 22:42:02 +02:00
'company_id' => $this->company->id,
]);
2021-02-24 03:12:23 +01:00
$this->task->status_id = TaskStatus::where('company_id', $this->company->id)->first()->id;
$this->task->save();
2021-06-21 07:02:28 +02:00
2020-10-13 06:08:56 +02:00
$this->expense_category = ExpenseCategory::factory()->create([
2021-01-26 22:42:00 +01:00
'user_id' => $user_id,
2020-10-13 06:08:56 +02:00
'company_id' => $this->company->id,
]);
2020-10-20 01:01:59 +02:00
$this->task_status = TaskStatus::factory()->create([
2021-01-26 22:42:00 +01:00
'user_id' => $user_id,
2020-10-20 01:01:59 +02:00
'company_id' => $this->company->id,
]);
2019-09-11 07:32:47 +02:00
$gs = new GroupSetting;
$gs->name = 'Test';
$gs->company_id = $this->client->company_id;
2019-09-19 07:50:05 +02:00
$gs->settings = ClientSettings::buildClientSettings($this->company->settings, $this->client->settings);
$gs_settings = $gs->settings;
$gs_settings->website = 'http://staging.invoicing.co';
$gs->settings = $gs_settings;
2019-09-11 07:32:47 +02:00
$gs->save();
$this->client->group_settings_id = $gs->id;
$this->client->save();
2021-01-26 22:42:00 +01:00
$this->invoice = InvoiceFactory::create($this->company->id, $user_id); //stub the company and user_id
$this->invoice->client_id = $this->client->id;
$this->invoice->line_items = $this->buildLineItems();
$this->invoice->uses_inclusive_taxes = false;
$this->invoice->save();
$this->invoice_calc = new InvoiceSum($this->invoice);
$this->invoice_calc->build();
$this->invoice = $this->invoice_calc->getInvoice();
$this->invoice->setRelation('client', $this->client);
$this->invoice->setRelation('company', $this->company);
$this->invoice->save();
2021-07-03 05:47:15 +02:00
$this->invoice->load("client");
2020-10-01 12:49:47 +02:00
InvoiceInvitation::factory()->create([
2021-01-26 22:42:00 +01:00
'user_id' => $this->invoice->user_id,
'company_id' => $this->company->id,
'client_contact_id' => $contact->id,
'invoice_id' => $this->invoice->id,
]);
2020-10-01 12:49:47 +02:00
InvoiceInvitation::factory()->create([
2021-01-26 22:42:00 +01:00
'user_id' => $this->invoice->user_id,
'company_id' => $this->company->id,
'client_contact_id' => $contact2->id,
'invoice_id' => $this->invoice->id,
]);
2021-07-03 06:37:06 +02:00
$this->invoice->fresh()->service()->markSent();
// $this->invoice->service()->markSent();
2020-10-01 12:49:47 +02:00
$this->quote = Quote::factory()->create([
2021-01-26 22:42:00 +01:00
'user_id' => $user_id,
'client_id' => $this->client->id,
'company_id' => $this->company->id,
]);
$this->quote->line_items = $this->buildLineItems();
$this->quote->uses_inclusive_taxes = false;
$this->quote->save();
$this->quote_calc = new InvoiceSum($this->quote);
$this->quote_calc->build();
$this->quote = $this->quote_calc->getQuote();
$this->quote->status_id = Quote::STATUS_SENT;
$this->quote->number = $this->getNextQuoteNumber($this->client);
//$this->quote->service()->createInvitations()->markSent();
2020-10-01 12:49:47 +02:00
QuoteInvitation::factory()->create([
2021-01-26 22:42:00 +01:00
'user_id' => $user_id,
'company_id' => $this->company->id,
'client_contact_id' => $contact->id,
'quote_id' => $this->quote->id,
]);
2020-10-01 12:49:47 +02:00
QuoteInvitation::factory()->create([
2021-01-26 22:42:00 +01:00
'user_id' => $user_id,
'company_id' => $this->company->id,
'client_contact_id' => $contact2->id,
'quote_id' => $this->quote->id,
]);
$this->quote->setRelation('client', $this->client);
$this->quote->setRelation('company', $this->company);
$this->quote->save();
2021-01-26 22:42:00 +01:00
$this->credit = CreditFactory::create($this->company->id, $user_id);
$this->credit->client_id = $this->client->id;
$this->credit->line_items = $this->buildLineItems();
$this->credit->amount = 10;
$this->credit->balance = 10;
2021-07-02 08:36:14 +02:00
// $this->credit->due_date = now()->addDays(200);
2020-10-15 11:41:59 +02:00
$this->credit->tax_name1 = '';
$this->credit->tax_name2 = '';
$this->credit->tax_name3 = '';
$this->credit->tax_rate1 = 0;
$this->credit->tax_rate2 = 0;
$this->credit->tax_rate3 = 0;
2020-10-28 11:10:49 +01:00
$this->credit->uses_inclusive_taxes = false;
$this->credit->save();
2020-10-26 10:13:00 +01:00
$this->credit_calc = new InvoiceSum($this->credit);
$this->credit_calc->build();
$this->credit = $this->credit_calc->getCredit();
2020-10-08 05:31:02 +02:00
$this->client->service()->adjustCreditBalance($this->credit->balance)->save();
$this->credit->ledger()->updateCreditBalance($this->credit->balance)->save();
2020-10-26 10:13:00 +01:00
$this->credit->number = $this->getNextCreditNumber($this->client);
CreditInvitation::factory()->create([
2021-01-26 22:42:00 +01:00
'user_id' => $user_id,
2020-10-26 10:13:00 +01:00
'company_id' => $this->company->id,
'client_contact_id' => $contact->id,
'credit_id' => $this->credit->id,
]);
CreditInvitation::factory()->create([
2021-01-26 22:42:00 +01:00
'user_id' => $user_id,
2020-10-26 10:13:00 +01:00
'company_id' => $this->company->id,
'client_contact_id' => $contact2->id,
'credit_id' => $this->credit->id,
]);
$invitations = CreditInvitation::whereCompanyId($this->credit->company_id)
->whereCreditId($this->credit->id);
$this->credit->setRelation('invitations', $invitations);
$this->credit->service()->markSent();
$this->credit->setRelation('client', $this->client);
$this->credit->setRelation('company', $this->company);
$this->credit->save();
$contacts = $this->invoice->client->contacts;
$contacts->each(function ($contact) {
$invitation = InvoiceInvitation::whereCompanyId($this->invoice->company_id)
->whereClientContactId($contact->id)
->whereInvoiceId($this->invoice->id)
->first();
if (! $invitation && $contact->send_email) {
$ii = InvoiceInvitationFactory::create($this->invoice->company_id, $this->invoice->user_id);
$ii->invoice_id = $this->invoice->id;
$ii->client_contact_id = $contact->id;
$ii->save();
} elseif ($invitation && ! $contact->send_email) {
$invitation->delete();
}
});
2020-02-15 12:49:31 +01:00
$invitations = InvoiceInvitation::whereCompanyId($this->invoice->company_id)
->whereInvoiceId($this->invoice->id);
$this->invoice->setRelation('invitations', $invitations);
$this->invoice->save();
$this->invoice->ledger()->updateInvoiceBalance($this->invoice->amount);
// UpdateCompanyLedgerWithInvoice::dispatchNow($this->invoice, $this->invoice->amount, $this->invoice->company);
2019-05-16 07:36:53 +02:00
2021-02-16 11:23:32 +01:00
$user_id = $this->invoice->user_id;
$recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice);
2021-02-16 11:23:32 +01:00
$recurring_invoice->user_id = $user_id;
2019-09-22 12:25:05 +02:00
$recurring_invoice->next_send_date = Carbon::now();
$recurring_invoice->status_id = RecurringInvoice::STATUS_ACTIVE;
$recurring_invoice->remaining_cycles = 2;
2020-09-13 12:20:11 +02:00
$recurring_invoice->next_send_date = Carbon::now();
$recurring_invoice->save();
$recurring_invoice->number = $this->getNextRecurringInvoiceNumber($this->invoice->client, $this->invoice);
$recurring_invoice->save();
$recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice);
2021-02-16 11:23:32 +01:00
$recurring_invoice->user_id = $user_id;
2019-09-22 12:25:05 +02:00
$recurring_invoice->next_send_date = Carbon::now()->addMinutes(2);
$recurring_invoice->status_id = RecurringInvoice::STATUS_ACTIVE;
$recurring_invoice->remaining_cycles = 2;
2020-09-13 12:20:11 +02:00
$recurring_invoice->next_send_date = Carbon::now();
$recurring_invoice->save();
$recurring_invoice->number = $this->getNextRecurringInvoiceNumber($this->invoice->client, $this->invoice);
$recurring_invoice->save();
$recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice);
2021-02-16 11:23:32 +01:00
$recurring_invoice->user_id = $user_id;
2019-09-22 12:25:05 +02:00
$recurring_invoice->next_send_date = Carbon::now()->addMinutes(10);
$recurring_invoice->status_id = RecurringInvoice::STATUS_ACTIVE;
$recurring_invoice->remaining_cycles = 2;
2020-09-13 12:20:11 +02:00
$recurring_invoice->next_send_date = Carbon::now();
$recurring_invoice->save();
$recurring_invoice->number = $this->getNextRecurringInvoiceNumber($this->invoice->client, $this->invoice);
$recurring_invoice->save();
$recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice);
2021-02-16 11:23:32 +01:00
$recurring_invoice->user_id = $user_id;
2019-09-22 12:25:05 +02:00
$recurring_invoice->next_send_date = Carbon::now()->addMinutes(15);
$recurring_invoice->status_id = RecurringInvoice::STATUS_ACTIVE;
$recurring_invoice->remaining_cycles = 2;
2020-09-13 12:20:11 +02:00
$recurring_invoice->next_send_date = Carbon::now();
$recurring_invoice->save();
$recurring_invoice->number = $this->getNextRecurringInvoiceNumber($this->invoice->client, $this->invoice);
$recurring_invoice->save();
$recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice);
2021-02-16 11:23:32 +01:00
$recurring_invoice->user_id = $user_id;
2019-09-22 12:25:05 +02:00
$recurring_invoice->next_send_date = Carbon::now()->addMinutes(20);
$recurring_invoice->status_id = RecurringInvoice::STATUS_ACTIVE;
$recurring_invoice->remaining_cycles = 2;
2020-09-13 12:20:11 +02:00
$recurring_invoice->next_send_date = Carbon::now();
$recurring_invoice->save();
$recurring_invoice->number = $this->getNextRecurringInvoiceNumber($this->invoice->client, $this->invoice);
$recurring_invoice->save();
$recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice);
2021-02-16 11:23:32 +01:00
$recurring_invoice->user_id = $user_id;
2019-09-22 12:25:05 +02:00
$recurring_invoice->next_send_date = Carbon::now()->addDays(10);
$recurring_invoice->status_id = RecurringInvoice::STATUS_ACTIVE;
$recurring_invoice->remaining_cycles = 2;
2020-09-14 04:57:18 +02:00
$recurring_invoice->next_send_date = Carbon::now()->addDays(10);
$recurring_invoice->save();
$recurring_invoice->number = $this->getNextRecurringInvoiceNumber($this->invoice->client, $this->invoice);
$recurring_invoice->save();
2019-09-18 14:43:37 +02:00
$gs = new GroupSetting;
$gs->company_id = $this->company->id;
2021-01-26 22:42:00 +01:00
$gs->user_id = $user_id;
2019-09-19 07:50:05 +02:00
$gs->settings = ClientSettings::buildClientSettings(CompanySettings::defaults(), ClientSettings::defaults());
2019-09-18 14:43:37 +02:00
$gs->name = 'Default Client Settings';
$gs->save();
if (config('ninja.testvars.stripe')) {
2020-07-07 16:50:51 +02:00
$data = [];
$data[1]['min_limit'] = 234;
$data[1]['max_limit'] = 65317;
$data[1]['fee_amount'] = 0.00;
$data[1]['fee_percent'] = 0.000;
$data[1]['fee_tax_name1'] = '';
$data[1]['fee_tax_rate1'] = '';
$data[1]['fee_tax_name2'] = '';
$data[1]['fee_tax_rate2'] = '';
$data[1]['fee_tax_name3'] = '';
$data[1]['fee_tax_rate3'] = 0;
2021-01-08 11:19:26 +01:00
$data[1]['fee_cap'] = '';
$data[1]['is_enabled'] = true;
2021-06-21 07:02:28 +02:00
2019-09-18 14:43:37 +02:00
$cg = new CompanyGateway;
$cg->company_id = $this->company->id;
2021-01-26 22:42:00 +01:00
$cg->user_id = $user_id;
$cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
2019-09-18 14:43:37 +02:00
$cg->require_cvv = true;
$cg->require_billing_address = true;
$cg->require_shipping_address = true;
2019-09-18 14:43:37 +02:00
$cg->update_details = true;
$cg->config = encrypt(config('ninja.testvars.stripe'));
2020-07-07 16:50:51 +02:00
$cg->fees_and_limits = $data;
2019-09-18 14:43:37 +02:00
$cg->save();
$cg = new CompanyGateway;
$cg->company_id = $this->company->id;
2021-01-26 22:42:00 +01:00
$cg->user_id = $user_id;
$cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
2019-09-18 14:43:37 +02:00
$cg->require_cvv = true;
$cg->require_billing_address = true;
$cg->require_shipping_address = true;
2019-09-18 14:43:37 +02:00
$cg->update_details = true;
2020-07-07 16:50:51 +02:00
$cg->fees_and_limits = $data;
2019-09-18 14:43:37 +02:00
$cg->config = encrypt(config('ninja.testvars.stripe'));
$cg->save();
}
2021-07-03 05:47:15 +02:00
$this->client = $this->client->fresh();
$this->invoice = $this->invoice->fresh();
}
2019-09-18 14:43:37 +02:00
2020-10-28 11:10:49 +01:00
/**
* @return array
*/
private function buildLineItems()
{
$line_items = [];
$item = InvoiceItemFactory::create();
$item->quantity = 1;
$item->cost = 10;
$item->task_id = $this->encodePrimaryKey($this->task->id);
$item->expense_id = $this->encodePrimaryKey($this->expense->id);
$line_items[] = $item;
return $line_items;
}
}