Fixes for Laravel 8

This commit is contained in:
David Bomba 2020-10-01 21:34:05 +10:00
parent c65950672d
commit 3fa336946f
31 changed files with 1795 additions and 93 deletions

View File

@ -27,12 +27,19 @@ use App\Helpers\Invoice\InvoiceSum;
use App\Jobs\Quote\CreateQuoteInvitations;
use App\Listeners\Credit\CreateCreditInvitation;
use App\Listeners\Invoice\CreateInvoiceInvitation;
use App\Models\Client;
use App\Models\ClientContact;
use App\Models\CompanyToken;
use App\Models\Country;
use App\Models\Expense;
use App\Models\Payment;
use App\Models\PaymentType;
use App\Models\Product;
use App\Models\Project;
use App\Models\Task;
use App\Models\User;
use App\Models\Vendor;
use App\Models\VendorContact;
use App\Repositories\InvoiceRepository;
use App\Utils\Ninja;
use App\Utils\Traits\GeneratesCounter;
@ -105,7 +112,7 @@ class CreateTestData extends Command
$user = User::whereEmail('small@example.com')->first();
if (! $user) {
$user = factory(\App\Models\User::class)->create([
$user = User::factory()->create([
'account_id' => $account->id,
'email' => 'small@example.com',
'confirmation_code' => $this->createDbHash(config('database.default')),
@ -132,7 +139,7 @@ class CreateTestData extends Command
'settings' => null,
]);
factory(\App\Models\Product::class, 50)->create([
Product::factory()->count(50)->create([
'user_id' => $user->id,
'company_id' => $company->id,
]);
@ -200,7 +207,7 @@ class CreateTestData extends Command
$user = User::whereEmail('medium@example.com')->first();
if (! $user) {
$user = factory(\App\Models\User::class)->create([
$user = User::factory()->create([
'account_id' => $account->id,
'email' => 'medium@example.com',
'confirmation_code' => $this->createDbHash(config('database.default')),
@ -226,7 +233,7 @@ class CreateTestData extends Command
'settings' => null,
]);
factory(\App\Models\Product::class, 50)->create([
Product::factory()->count(50)->create([
'user_id' => $user->id,
'company_id' => $company->id,
]);
@ -297,7 +304,7 @@ class CreateTestData extends Command
$user = User::whereEmail('large@example.com')->first();
if (! $user) {
$user = factory(\App\Models\User::class)->create([
$user = User::factory()->create([
'account_id' => $account->id,
'email' => 'large@example.com',
'confirmation_code' => $this->createDbHash(config('database.default')),
@ -323,7 +330,7 @@ class CreateTestData extends Command
'settings' => null,
]);
factory(\App\Models\Product::class, 15000)->create([
Product::factory()->count(15000)->create([
'user_id' => $user->id,
'company_id' => $company->id,
]);
@ -383,19 +390,19 @@ class CreateTestData extends Command
// dispatch(function () use ($company, $user) {
// });
$client = factory(\App\Models\Client::class)->create([
$client = Client::factory()->create([
'user_id' => $user->id,
'company_id' => $company->id,
]);
factory(\App\Models\ClientContact::class, 1)->create([
ClientContact::factory()->create([
'user_id' => $user->id,
'client_id' => $client->id,
'company_id' => $company->id,
'is_primary' => 1,
]);
factory(\App\Models\ClientContact::class, rand(1, 5))->create([
ClientContact::factory()->count(rand(1, 5))->create([
'user_id' => $user->id,
'client_id' => $client->id,
'company_id' => $company->id,
@ -415,7 +422,7 @@ class CreateTestData extends Command
private function createExpense($client)
{
factory(\App\Models\Expense::class, rand(1, 5))->create([
Expense::factory()->count(rand(1, 5))->create([
'user_id' => $client->user->id,
'client_id' => $client->id,
'company_id' => $client->company->id,
@ -424,19 +431,19 @@ class CreateTestData extends Command
private function createVendor($client)
{
$vendor = factory(\App\Models\Vendor::class)->create([
$vendor = Vendor::factory()->create([
'user_id' => $client->user->id,
'company_id' => $client->company->id,
]);
factory(\App\Models\VendorContact::class, 1)->create([
VendorContact::factory()->create([
'user_id' => $client->user->id,
'vendor_id' => $vendor->id,
'company_id' => $client->company->id,
'is_primary' => 1,
]);
factory(\App\Models\VendorContact::class, rand(1, 5))->create([
VendorContact::factory()->count(rand(1, 5))->create([
'user_id' => $client->user->id,
'vendor_id' => $vendor->id,
'company_id' => $client->company->id,
@ -446,7 +453,7 @@ class CreateTestData extends Command
private function createTask($client)
{
$vendor = factory(\App\Models\Task::class)->create([
$vendor = Task::factory()->create([
'user_id' => $client->user->id,
'company_id' => $client->company->id,
]);
@ -454,7 +461,7 @@ class CreateTestData extends Command
private function createProject($client)
{
$vendor = factory(\App\Models\Project::class)->create([
$vendor = Project::factory()->create([
'user_id' => $client->user->id,
'company_id' => $client->company->id,
]);
@ -520,7 +527,7 @@ class CreateTestData extends Command
// }
$faker = \Faker\Factory::create();
$credit = factory(\App\Models\Credit::class)->create(['user_id' => $client->user->id, 'company_id' => $client->company->id, 'client_id' => $client->id]);
$credit = Credit::factory()->create(['user_id' => $client->user->id, 'company_id' => $client->company->id, 'client_id' => $client->id]);
$dateable = Carbon::now()->subDays(rand(0, 90));
$credit->date = $dateable;
@ -564,7 +571,7 @@ class CreateTestData extends Command
$faker = \Faker\Factory::create();
//$quote = QuoteFactory::create($client->company->id, $client->user->id);//stub the company and user_id
$quote = factory(\App\Models\Quote::class)->create(['user_id' => $client->user->id, 'company_id' => $client->company->id, 'client_id' => $client->id]);
$quote = Quote::factory()->create(['user_id' => $client->user->id, 'company_id' => $client->company->id, 'client_id' => $client->id]);
$quote->date = $faker->date();
$quote->client_id = $client->id;

View File

@ -78,7 +78,7 @@ class ImportMigrations extends Command
$account = $this->getAccount();
$company = $this->getCompany($account);
$user = factory(\App\Models\User::class)->create([
$user = User::factory()->create([
'account_id' => $account->id,
'email' => $this->faker->email,
'confirmation_code' => $this->createDbHash(config('database.default')),

View File

@ -56,7 +56,7 @@ class CreateTestCreditJob implements ShouldQueue
{
$faker = \Faker\Factory::create();
$credit = factory(\App\Models\Credit::class)->create(['user_id' => $this->client->user->id, 'company_id' => $this->client->company->id, 'client_id' => $this->client->id]);
$credit = Credit::factory()->create(['user_id' => $this->client->user->id, 'company_id' => $this->client->company->id, 'client_id' => $this->client->id]);
//$invoice = InvoiceFactory::create($this->client->company->id, $this->client->user->id);//stub the company and user_id
//$invoice->client_id = $this->client->id;

View File

@ -55,7 +55,7 @@ class CreateTestQuoteJob implements ShouldQueue
{
$faker = \Faker\Factory::create();
$quote = factory(\App\Models\Quote::class)->create(['user_id' => $this->client->user->id, 'company_id' => $this->client->company->id, 'client_id' => $this->client->id]);
$quote = Quote::factory()->create(['user_id' => $this->client->user->id, 'company_id' => $this->client->company->id, 'client_id' => $this->client->id]);
$quote->date = $faker->date();
$quote->line_items = $this->buildLineItems(rand(1, 10));

View File

@ -132,12 +132,12 @@ class PreviewController extends BaseController
{
DB::beginTransaction();
$client = factory(\App\Models\Client::class)->create([
$client = Client::factory()->create([
'user_id' => auth()->user()->id,
'company_id' => auth()->user()->company()->id,
]);
$contact = factory(\App\Models\ClientContact::class)->create([
$contact = ClientContact::factory()->create([
'user_id' => auth()->user()->id,
'company_id' => auth()->user()->company()->id,
'client_id' => $client->id,
@ -145,13 +145,13 @@ class PreviewController extends BaseController
'send_email' => true,
]);
$invoice = factory(\App\Models\Invoice::class)->create([
$invoice = Invoice::factory()->create([
'user_id' => auth()->user()->id,
'company_id' => auth()->user()->company()->id,
'client_id' => $client->id,
]);
$invitation = factory(\App\Models\InvoiceInvitation::class)->create([
$invitation = InvoiceInvitation::factory()->create([
'user_id' => auth()->user()->id,
'company_id' => auth()->user()->company()->id,
'invoice_id' => $invoice->id,

View File

@ -35,7 +35,7 @@ class InvoiceFactory extends Factory
public function definition()
{
return [
'status_id' => App\Models\Invoice::STATUS_SENT,
'status_id' => Invoice::STATUS_SENT,
'number' => $this->faker->ean13(),
'discount' => $this->faker->numberBetween(1, 10),
'is_amount_discount' => (bool) random_int(0, 1),

View File

@ -32,7 +32,7 @@ class RecurringInvoiceFactory extends Factory
public function definition()
{
return [
'status_id' => App\Models\RecurringInvoice::STATUS_ACTIVE,
'status_id' => RecurringInvoice::STATUS_ACTIVE,
'discount' => $this->faker->numberBetween(1, 10),
'is_amount_discount' => $this->faker->boolean(),
'tax_name1' => 'GST',
@ -50,7 +50,7 @@ class RecurringInvoiceFactory extends Factory
'date' => $this->faker->date(),
'due_date' => $this->faker->date(),
'line_items' => false,
'frequency_id' => App\Models\RecurringInvoice::FREQUENCY_MONTHLY,
'frequency_id' => RecurringInvoice::FREQUENCY_MONTHLY,
'last_sent_date' => now()->subMonth(),
'next_send_date' => now()->addMonthNoOverflow(),
'remaining_cycles' => $this->faker->numberBetween(1, 10),

View File

@ -10,36 +10,52 @@
*/
namespace Database\Factories;
use App\Models\QuoteInvitation;
use App\Models\RecurringQuote;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
use App\DataMapper\ClientSettings;
use App\DataMapper\CompanySettings;
use Faker\Generator as Faker;
class RecurringQuoteFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = RecurringQuote::class;
$factory->define(App\Models\RecurringQuote::class, function (Faker $faker) {
return [
'status_id' => App\Models\RecurringQuote::STATUS_DRAFT,
'number' => $faker->text(256),
'discount' => $faker->numberBetween(1, 10),
'is_amount_discount' => $faker->boolean(),
'tax_name1' => 'GST',
'tax_rate1' => 10,
'tax_name2' => 'VAT',
'tax_rate2' => 17.5,
'tax_name3' => 'THIRDTAX',
'tax_rate3' => 5,
'custom_value1' => $faker->numberBetween(1, 4),
'custom_value2' => $faker->numberBetween(1, 4),
'custom_value3' => $faker->numberBetween(1, 4),
'custom_value4' => $faker->numberBetween(1, 4),
'is_deleted' => false,
'po_number' => $faker->text(10),
'date' => $faker->date(),
'due_date' => $faker->date(),
'line_items' => false,
'frequency_id' => App\Models\RecurringQuote::FREQUENCY_MONTHLY,
'start_date' => $faker->date(),
'last_sent_date' => $faker->date(),
'next_send_date' => $faker->date(),
'remaining_cycles' => $faker->numberBetween(1, 10),
];
});
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'status_id' => RecurringQuote::STATUS_DRAFT,
'number' => $this->faker->text(256),
'discount' => $this->faker->numberBetween(1, 10),
'is_amount_discount' => $this->faker->boolean(),
'tax_name1' => 'GST',
'tax_rate1' => 10,
'tax_name2' => 'VAT',
'tax_rate2' => 17.5,
'tax_name3' => 'THIRDTAX',
'tax_rate3' => 5,
'custom_value1' => $this->faker->numberBetween(1, 4),
'custom_value2' => $this->faker->numberBetween(1, 4),
'custom_value3' => $this->faker->numberBetween(1, 4),
'custom_value4' => $this->faker->numberBetween(1, 4),
'is_deleted' => false,
'po_number' => $this->faker->text(10),
'date' => $this->faker->date(),
'due_date' => $this->faker->date(),
'line_items' => false,
'frequency_id' => RecurringQuote::FREQUENCY_MONTHLY,
'start_date' => $this->faker->date(),
'last_sent_date' => $this->faker->date(),
'next_send_date' => $this->faker->date(),
'remaining_cycles' => $this->faker->numberBetween(1, 10),
];
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,166 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\PaymentLibrary;
use App\Models\Size;
use App\Models\Timezone;
use Illuminate\Database\Seeder;
class ConstantsSeeder extends Seeder
{
public function run()
{
Size::create(['name' => '1 - 3']);
Size::create(['name' => '4 - 10']);
Size::create(['name' => '11 - 50']);
Size::create(['name' => '51 - 100']);
Size::create(['name' => '101 - 500']);
Size::create(['name' => '500+']);
PaymentLibrary::create(['name' => 'Omnipay']);
/*
d, dd: Numeric date, no leading zero and leading zero, respectively. Eg, 5, 05.
D, DD: Abbreviated and full weekday names, respectively. Eg, Mon, Monday.
m, mm: Numeric month, no leading zero and leading zero, respectively. Eg, 7, 07.
M, MM: Abbreviated and full month names, respectively. Eg, Jan, January
yy, yyyy: 2- and 4-digit years, respectively. Eg, 12, 2012.)
*/
$timezones[] = ['name'=>'Pacific/Midway', 'location', 'location' => '(GMT-11:00) Midway Island', 'utc_offset' => -39600];
$timezones[] = ['name'=>'US/Samoa', 'location' => '(GMT-11:00) Samoa', 'utc_offset' => -39600];
$timezones[] = ['name'=>'US/Hawaii', 'location' => '(GMT-10:00) Hawaii', 'utc_offset' => -36000];
$timezones[] = ['name'=>'US/Alaska', 'location' => '(GMT-09:00) Alaska', 'utc_offset' => -32400];
$timezones[] = ['name'=>'US/Pacific', 'location' => '(GMT-08:00) Pacific Time (US &amp; Canada)', 'utc_offset' => -28800];
$timezones[] = ['name'=>'America/Tijuana', 'location' => '(GMT-08:00) Tijuana', 'utc_offset' => -28800];
$timezones[] = ['name'=>'US/Arizona', 'location' => '(GMT-07:00) Arizona', 'utc_offset' => -25200];
$timezones[] = ['name'=>'US/Mountain', 'location' => '(GMT-07:00) Mountain Time (US &amp; Canada)', 'utc_offset' => -25200];
$timezones[] = ['name'=>'America/Chihuahua', 'location' => '(GMT-07:00) Chihuahua', 'utc_offset' => -25200];
$timezones[] = ['name'=>'America/Mazatlan', 'location' => '(GMT-07:00) Mazatlan', 'utc_offset' => -25200];
$timezones[] = ['name'=>'America/Mexico_City', 'location' => '(GMT-06:00) Mexico City', 'utc_offset' => -21600];
$timezones[] = ['name'=>'America/Monterrey', 'location' => '(GMT-06:00) Monterrey', 'utc_offset' => -21600];
$timezones[] = ['name'=>'Canada/Saskatchewan', 'location' => '(GMT-06:00) Saskatchewan', 'utc_offset' => -21600];
$timezones[] = ['name'=>'US/Central', 'location' => '(GMT-06:00) Central Time (US &amp; Canada)', 'utc_offset' => -21600];
$timezones[] = ['name'=>'US/Eastern', 'location' => '(GMT-05:00) Eastern Time (US &amp; Canada)', 'utc_offset' => -18000];
$timezones[] = ['name'=>'US/East-Indiana', 'location' => '(GMT-05:00) Indiana (East)', 'utc_offset' => -18000];
$timezones[] = ['name'=>'America/Bogota', 'location' => '(GMT-05:00) Bogota', 'utc_offset' => -18000];
$timezones[] = ['name'=>'America/Lima', 'location' => '(GMT-05:00) Lima', 'utc_offset' => -18000];
$timezones[] = ['name'=>'America/Caracas', 'location' => '(GMT-04:00) Caracas', 'utc_offset' => -14400];
$timezones[] = ['name'=>'Canada/Atlantic', 'location' => '(GMT-04:00) Atlantic Time (Canada)', 'utc_offset' => -14400];
$timezones[] = ['name'=>'America/La_Paz', 'location' => '(GMT-04:00) La Paz', 'utc_offset' => -14400];
$timezones[] = ['name'=>'America/Santiago', 'location' => '(GMT-04:00) Santiago', 'utc_offset' => -14400];
$timezones[] = ['name'=>'Canada/Newfoundland', 'location' => '(GMT-03:30) Newfoundland', 'utc_offset' => -12600];
$timezones[] = ['name'=>'America/Buenos_Aires', 'location' => '(GMT-03:00) Buenos Aires', 'utc_offset' => -10800];
$timezones[] = ['name'=>'America/Godthab', 'location' => '(GMT-03:00) Greenland', 'utc_offset' => -10800];
$timezones[] = ['name'=>'Atlantic/Stanley', 'location' => '(GMT-02:00) Stanley', 'utc_offset' => -7200];
$timezones[] = ['name'=>'Atlantic/Azores', 'location' => '(GMT-01:00) Azores', 'utc_offset' => -3600];
$timezones[] = ['name'=>'Atlantic/Cape_Verde', 'location' => '(GMT-01:00) Cape Verde Is.', 'utc_offset' => -3600];
$timezones[] = ['name'=>'Africa/Casablanca', 'location' => '(GMT) Casablanca', 'utc_offset' => 0];
$timezones[] = ['name'=>'Europe/Dublin', 'location' => '(GMT) Dublin', 'utc_offset' => 0];
$timezones[] = ['name'=>'Europe/Lisbon', 'location' => '(GMT) Lisbon', 'utc_offset' => 0];
$timezones[] = ['name'=>'Europe/London', 'location' => '(GMT) London', 'utc_offset' => 0];
$timezones[] = ['name'=>'Africa/Monrovia', 'location' => '(GMT) Monrovia', 'utc_offset' => 0];
$timezones[] = ['name'=>'Europe/Amsterdam', 'location' => '(GMT+01:00) Amsterdam', 'utc_offset' => 3600];
$timezones[] = ['name'=>'Europe/Belgrade', 'location' => '(GMT+01:00) Belgrade', 'utc_offset' => 3600];
$timezones[] = ['name'=>'Europe/Berlin', 'location' => '(GMT+01:00) Berlin', 'utc_offset' => 3600];
$timezones[] = ['name'=>'Europe/Bratislava', 'location' => '(GMT+01:00) Bratislava', 'utc_offset' => 3600];
$timezones[] = ['name'=>'Europe/Brussels', 'location' => '(GMT+01:00) Brussels', 'utc_offset' => 3600];
$timezones[] = ['name'=>'Europe/Budapest', 'location' => '(GMT+01:00) Budapest', 'utc_offset' => 3600];
$timezones[] = ['name'=>'Europe/Copenhagen', 'location' => '(GMT+01:00) Copenhagen', 'utc_offset' => 3600];
$timezones[] = ['name'=>'Europe/Ljubljana', 'location' => '(GMT+01:00) Ljubljana', 'utc_offset' => 3600];
$timezones[] = ['name'=>'Europe/Madrid', 'location' => '(GMT+01:00) Madrid', 'utc_offset' => 3600];
$timezones[] = ['name'=>'Europe/Paris', 'location' => '(GMT+01:00) Paris', 'utc_offset' => 3600];
$timezones[] = ['name'=>'Europe/Prague', 'location' => '(GMT+01:00) Prague', 'utc_offset' => 3600];
$timezones[] = ['name'=>'Europe/Rome', 'location' => '(GMT+01:00) Rome', 'utc_offset' => 3600];
$timezones[] = ['name'=>'Europe/Sarajevo', 'location' => '(GMT+01:00) Sarajevo', 'utc_offset' => 3600];
$timezones[] = ['name'=>'Europe/Skopje', 'location' => '(GMT+01:00) Skopje', 'utc_offset' => 3600];
$timezones[] = ['name'=>'Europe/Stockholm', 'location' => '(GMT+01:00) Stockholm', 'utc_offset' => 3600];
$timezones[] = ['name'=>'Europe/Vienna', 'location' => '(GMT+01:00) Vienna', 'utc_offset' => 3600];
$timezones[] = ['name'=>'Europe/Warsaw', 'location' => '(GMT+01:00) Warsaw', 'utc_offset' => 3600];
$timezones[] = ['name'=>'Europe/Zagreb', 'location' => '(GMT+01:00) Zagreb', 'utc_offset' => 3600];
$timezones[] = ['name'=>'Europe/Athens', 'location' => '(GMT+02:00) Athens', 'utc_offset' => 7200];
$timezones[] = ['name'=>'Europe/Bucharest', 'location' => '(GMT+02:00) Bucharest', 'utc_offset' => 7200];
$timezones[] = ['name'=>'Africa/Cairo', 'location' => '(GMT+02:00) Cairo', 'utc_offset' => 7200];
$timezones[] = ['name'=>'Africa/Harare', 'location' => '(GMT+02:00) Harare', 'utc_offset' => 7200];
$timezones[] = ['name'=>'Europe/Helsinki', 'location' => '(GMT+02:00) Helsinki', 'utc_offset' => 7200];
$timezones[] = ['name'=>'Asia/Jerusalem', 'location' => '(GMT+02:00) Jerusalem', 'utc_offset' => 7200];
$timezones[] = ['name'=>'Europe/Kiev', 'location' => '(GMT+02:00) Kyiv', 'utc_offset' => 7200];
$timezones[] = ['name'=>'Europe/Minsk', 'location' => '(GMT+02:00) Minsk', 'utc_offset' => 7200];
$timezones[] = ['name'=>'Europe/Riga', 'location' => '(GMT+02:00) Riga', 'utc_offset' => 7200];
$timezones[] = ['name'=>'Europe/Sofia', 'location' => '(GMT+02:00) Sofia', 'utc_offset' => 7200];
$timezones[] = ['name'=>'Europe/Tallinn', 'location' => '(GMT+02:00) Tallinn', 'utc_offset' => 7200];
$timezones[] = ['name'=>'Europe/Vilnius', 'location' => '(GMT+02:00) Vilnius', 'utc_offset' => 7200];
$timezones[] = ['name'=>'Europe/Istanbul', 'location' => '(GMT+03:00) Istanbul', 'utc_offset' => 10800];
$timezones[] = ['name'=>'Asia/Baghdad', 'location' => '(GMT+03:00) Baghdad', 'utc_offset' => 10800];
$timezones[] = ['name'=>'Asia/Kuwait', 'location' => '(GMT+03:00) Kuwait', 'utc_offset' => 10800];
$timezones[] = ['name'=>'Africa/Nairobi', 'location' => '(GMT+03:00) Nairobi', 'utc_offset' => 10800];
$timezones[] = ['name'=>'Asia/Riyadh', 'location' => '(GMT+03:00) Riyadh', 'utc_offset' => 10800];
$timezones[] = ['name'=>'Asia/Tehran', 'location' => '(GMT+03:30) Tehran', 'utc_offset' => 12600];
$timezones[] = ['name'=>'Europe/Moscow', 'location' => '(GMT+04:00) Moscow', 'utc_offset' => 14400];
$timezones[] = ['name'=>'Asia/Baku', 'location' => '(GMT+04:00) Baku', 'utc_offset' => 14400];
$timezones[] = ['name'=>'Europe/Volgograd', 'location' => '(GMT+04:00) Volgograd', 'utc_offset' => 14400];
$timezones[] = ['name'=>'Asia/Muscat', 'location' => '(GMT+04:00) Muscat', 'utc_offset' => 14400];
$timezones[] = ['name'=>'Asia/Tbilisi', 'location' => '(GMT+04:00) Tbilisi', 'utc_offset' => 14400];
$timezones[] = ['name'=>'Asia/Yerevan', 'location' => '(GMT+04:00) Yerevan', 'utc_offset' => 14400];
$timezones[] = ['name'=>'Asia/Kabul', 'location' => '(GMT+04:30) Kabul', 'utc_offset' => 16200];
$timezones[] = ['name'=>'Asia/Karachi', 'location' => '(GMT+05:00) Karachi', 'utc_offset' => 18000];
$timezones[] = ['name'=>'Asia/Tashkent', 'location' => '(GMT+05:00) Tashkent', 'utc_offset' => 18000];
$timezones[] = ['name'=>'Asia/Kolkata', 'location' => '(GMT+05:30) Kolkata', 'utc_offset' => 19800];
$timezones[] = ['name'=>'Asia/Kathmandu', 'location' => '(GMT+05:45) Kathmandu', 'utc_offset' => 20700];
$timezones[] = ['name'=>'Asia/Yekaterinburg', 'location' => '(GMT+06:00) Ekaterinburg', 'utc_offset' => 21600];
$timezones[] = ['name'=>'Asia/Almaty', 'location' => '(GMT+06:00) Almaty', 'utc_offset' => 21600];
$timezones[] = ['name'=>'Asia/Dhaka', 'location' => '(GMT+06:00) Dhaka', 'utc_offset' => 21600];
$timezones[] = ['name'=>'Asia/Novosibirsk', 'location' => '(GMT+07:00) Novosibirsk', 'utc_offset' => 25200];
$timezones[] = ['name'=>'Asia/Bangkok', 'location' => '(GMT+07:00) Bangkok', 'utc_offset' => 25200];
$timezones[] = ['name'=>'Asia/Ho_Chi_Minh', 'location' => '(GMT+07.00) Ho Chi Minh', 'utc_offset' => 25200];
$timezones[] = ['name'=>'Asia/Jakarta', 'location' => '(GMT+07:00) Jakarta', 'utc_offset' => 25200];
$timezones[] = ['name'=>'Asia/Krasnoyarsk', 'location' => '(GMT+08:00) Krasnoyarsk', 'utc_offset' => 28800];
$timezones[] = ['name'=>'Asia/Chongqing', 'location' => '(GMT+08:00) Chongqing', 'utc_offset' => 28800];
$timezones[] = ['name'=>'Asia/Hong_Kong', 'location' => '(GMT+08:00) Hong Kong', 'utc_offset' => 28800];
$timezones[] = ['name'=>'Asia/Kuala_Lumpur', 'location' => '(GMT+08:00) Kuala Lumpur', 'utc_offset' => 28800];
$timezones[] = ['name'=>'Australia/Perth', 'location' => '(GMT+08:00) Perth', 'utc_offset' => 28800];
$timezones[] = ['name'=>'Asia/Singapore', 'location' => '(GMT+08:00) Singapore', 'utc_offset' => 28800];
$timezones[] = ['name'=>'Asia/Taipei', 'location' => '(GMT+08:00) Taipei', 'utc_offset' => 28800];
$timezones[] = ['name'=>'Asia/Ulaanbaatar', 'location' => '(GMT+08:00) Ulaan Bataar', 'utc_offset' => 28800];
$timezones[] = ['name'=>'Asia/Urumqi', 'location' => '(GMT+08:00) Urumqi', 'utc_offset' => 28800];
$timezones[] = ['name'=>'Asia/Irkutsk', 'location' => '(GMT+09:00) Irkutsk', 'utc_offset' => 32400];
$timezones[] = ['name'=>'Asia/Seoul', 'location' => '(GMT+09:00) Seoul', 'utc_offset' => 32400];
$timezones[] = ['name'=>'Asia/Tokyo', 'location' => '(GMT+09:00) Tokyo', 'utc_offset' => 32400];
$timezones[] = ['name'=>'Australia/Adelaide', 'location' => '(GMT+09:30) Adelaide', 'utc_offset' => 34200];
$timezones[] = ['name'=>'Australia/Darwin', 'location' => '(GMT+09:30) Darwin', 'utc_offset' => 34200];
$timezones[] = ['name'=>'Asia/Yakutsk', 'location' => '(GMT+10:00) Yakutsk', 'utc_offset' => 36000];
$timezones[] = ['name'=>'Australia/Brisbane', 'location' => '(GMT+10:00) Brisbane', 'utc_offset' => 36000];
$timezones[] = ['name'=>'Australia/Canberra', 'location' => '(GMT+10:00) Canberra', 'utc_offset' => 36000];
$timezones[] = ['name'=>'Pacific/Guam', 'location' => '(GMT+10:00) Guam', 'utc_offset' => 36000];
$timezones[] = ['name'=>'Australia/Hobart', 'location' => '(GMT+10:00) Hobart', 'utc_offset' => 36000];
$timezones[] = ['name'=>'Australia/Melbourne', 'location' => '(GMT+10:00) Melbourne', 'utc_offset' => 36000];
$timezones[] = ['name'=>'Pacific/Port_Moresby', 'location' => '(GMT+10:00) Port Moresby', 'utc_offset' => 36000];
$timezones[] = ['name'=>'Australia/Sydney', 'location' => '(GMT+10:00) Sydney', 'utc_offset' => 36000];
$timezones[] = ['name'=>'Asia/Vladivostok', 'location' => '(GMT+11:00) Vladivostok', 'utc_offset' => 39600];
$timezones[] = ['name'=>'Asia/Magadan', 'location' => '(GMT+12:00) Magadan', 'utc_offset' => 43200];
$timezones[] = ['name'=>'Pacific/Auckland', 'location' => '(GMT+12:00) Auckland', 'utc_offset' => 43200];
$timezones[] = ['name'=>'Pacific/Fiji', 'location' => '(GMT+12:00) Fiji', 'utc_offset' => 43200];
$x = 1;
foreach ($timezones as $timezone) {
Timezone::create([
'id' => $x,
'name' => $timezone['name'],
'location' => $timezone['location'],
'utc_offset' => $timezone['utc_offset'],
]);
$x++;
}
}
}

View File

@ -0,0 +1,210 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\Country;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
use Webpatser\Countries\Countries;
class CountriesSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
$countries_object = new Countries;
$countries = $countries_object->getList();
foreach ($countries as $countryId => $country) {
if ($record = Country::whereCountryCode($country['country-code'])->first()) {
$record->name = $country['name'];
$record->full_name = ((isset($country['full_name'])) ? $country['full_name'] : null);
$record->save();
} else {
\Illuminate\Support\Facades\DB::table('countries')->insert([
'id' => $countryId,
'capital' => ((isset($country['capital'])) ? $country['capital'] : null),
'citizenship' => ((isset($country['citizenship'])) ? $country['citizenship'] : null),
'country_code' => $country['country-code'],
'currency' => ((isset($country['currency'])) ? $country['currency'] : null),
'currency_code' => ((isset($country['currency_code'])) ? $country['currency_code'] : null),
'currency_sub_unit' => ((isset($country['currency_sub_unit'])) ? $country['currency_sub_unit'] : null),
'full_name' => ((isset($country['full_name'])) ? $country['full_name'] : null),
'iso_3166_2' => $country['iso_3166_2'],
'iso_3166_3' => $country['iso_3166_3'],
'name' => $country['name'],
'region_code' => $country['region-code'],
'sub_region_code' => $country['sub-region-code'],
'eea' => (bool) $country['eea'],
]);
}
}
// Source: http://www.bitboost.com/ref/international-address-formats.html
// Source: https://en.wikipedia.org/wiki/Linguistic_issues_concerning_the_euro
$countries = [
'AR' => [
'swap_postal_code' => true,
],
'AT' => [ // Austria
'swap_postal_code' => true,
'swap_currency_symbol' => true,
],
'BE' => [
'swap_postal_code' => true,
],
'BG' => [ // Belgium
'swap_currency_symbol' => true,
],
'CA' => [
'thousand_separator' => ',',
'decimal_separator' => '.',
],
'CH' => [
'swap_postal_code' => true,
],
'CZ' => [ // Czech Republic
'swap_currency_symbol' => true,
],
'DE' => [ // Germany
'swap_postal_code' => true,
'swap_currency_symbol' => true,
],
'DK' => [
'swap_postal_code' => true,
],
'EE' => [ // Estonia
'swap_currency_symbol' => true,
'thousand_separator' => ' ',
],
'ES' => [ // Spain
'swap_postal_code' => true,
'swap_currency_symbol' => true,
],
'FI' => [ // Finland
'swap_postal_code' => true,
'swap_currency_symbol' => true,
],
'FR' => [ // France
'swap_postal_code' => true,
'swap_currency_symbol' => true,
],
'GR' => [ // Greece
'swap_currency_symbol' => true,
],
'HR' => [ // Croatia
'swap_currency_symbol' => true,
],
'HU' => [ // Hungary
'swap_currency_symbol' => true,
],
'GL' => [
'swap_postal_code' => true,
],
'IE' => [ // Ireland
'thousand_separator' => ',',
'decimal_separator' => '.',
],
'IL' => [
'swap_postal_code' => true,
],
'IS' => [ // Iceland
'swap_postal_code' => true,
'swap_currency_symbol' => true,
],
'IT' => [ // Italy
'swap_postal_code' => true,
'swap_currency_symbol' => true,
],
'JP' => [ // Japan
'swap_postal_code' => true,
'swap_currency_symbol' => true,
],
'LT' => [ // Lithuania
'swap_currency_symbol' => true,
],
'LU' => [
'swap_postal_code' => true,
],
'MT' => [
'thousand_separator' => ',',
'decimal_separator' => '.',
],
'MY' => [
'swap_postal_code' => true,
],
'MX' => [
'swap_postal_code' => true,
],
'NL' => [
'swap_postal_code' => true,
],
'PL' => [ // Poland
'swap_postal_code' => true,
'swap_currency_symbol' => true,
],
'PT' => [ // Portugal
'swap_postal_code' => true,
'swap_currency_symbol' => true,
],
'RO' => [ // Romania
'swap_currency_symbol' => true,
],
'SE' => [ // Sweden
'swap_postal_code' => true,
'swap_currency_symbol' => true,
],
'SI' => [ // Slovenia
'swap_currency_symbol' => true,
],
'SK' => [ // Slovakia
'swap_currency_symbol' => true,
],
'US' => [
'thousand_separator' => ',',
'decimal_separator' => '.',
],
'SR' => [ // Suriname
'swap_currency_symbol' => true,
],
'UY' => [
'swap_postal_code' => true,
],
];
foreach ($countries as $code => $data) {
$country = Country::where('iso_3166_2', '=', $code)->first();
if (isset($data['swap_postal_code'])) {
$country->swap_postal_code = true;
}
if (isset($data['swap_currency_symbol'])) {
$country->swap_currency_symbol = true;
}
if (isset($data['thousand_separator'])) {
$country->thousand_separator = $data['thousand_separator'];
}
if (isset($data['decimal_separator'])) {
$country->decimal_separator = $data['decimal_separator'];
}
$country->save();
}
$p = Country::where('country_code', 275)->first();
$p->name = 'Palestine';
$p->save();
}
}

View File

@ -0,0 +1,124 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\Currency;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
class CurrenciesSeeder extends Seeder
{
public function run()
{
Model::unguard();
// http://www.localeplanet.com/icu/currency.html
$currencies = [
['id' => 1, 'name' => 'US Dollar', 'code' => 'USD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 2, 'name' => 'British Pound', 'code' => 'GBP', 'symbol' => '£', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 3, 'name' => 'Euro', 'code' => 'EUR', 'symbol' => '€', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','],
['id' => 4, 'name' => 'South African Rand', 'code' => 'ZAR', 'symbol' => 'R', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 5, 'name' => 'Danish Krone', 'code' => 'DKK', 'symbol' => 'kr', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ',', 'swap_currency_symbol' => true],
['id' => 6, 'name' => 'Israeli Shekel', 'code' => 'ILS', 'symbol' => 'NIS ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 7, 'name' => 'Swedish Krona', 'code' => 'SEK', 'symbol' => 'kr', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ',', 'swap_currency_symbol' => true],
['id' => 8, 'name' => 'Kenyan Shilling', 'code' => 'KES', 'symbol' => 'KSh ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 9, 'name' => 'Canadian Dollar', 'code' => 'CAD', 'symbol' => 'C$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 10, 'name' => 'Philippine Peso', 'code' => 'PHP', 'symbol' => 'P ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 11, 'name' => 'Indian Rupee', 'code' => 'INR', 'symbol' => 'Rs. ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 12, 'name' => 'Australian Dollar', 'code' => 'AUD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 13, 'name' => 'Singapore Dollar', 'code' => 'SGD', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 14, 'name' => 'Norske Kroner', 'code' => 'NOK', 'symbol' => 'kr', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ',', 'swap_currency_symbol' => true],
['id' => 15, 'name' => 'New Zealand Dollar', 'code' => 'NZD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 16, 'name' => 'Vietnamese Dong', 'code' => 'VND', 'symbol' => '', 'precision' => '0', 'thousand_separator' => '.', 'decimal_separator' => ','],
['id' => 17, 'name' => 'Swiss Franc', 'code' => 'CHF', 'symbol' => '', 'precision' => '2', 'thousand_separator' => '\'', 'decimal_separator' => '.'],
['id' => 18, 'name' => 'Guatemalan Quetzal', 'code' => 'GTQ', 'symbol' => 'Q', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 19, 'name' => 'Malaysian Ringgit', 'code' => 'MYR', 'symbol' => 'RM', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 20, 'name' => 'Brazilian Real', 'code' => 'BRL', 'symbol' => 'R$', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','],
['id' => 21, 'name' => 'Thai Baht', 'code' => 'THB', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 22, 'name' => 'Nigerian Naira', 'code' => 'NGN', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 23, 'name' => 'Argentine Peso', 'code' => 'ARS', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','],
['id' => 24, 'name' => 'Bangladeshi Taka', 'code' => 'BDT', 'symbol' => 'Tk', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 25, 'name' => 'United Arab Emirates Dirham', 'code' => 'AED', 'symbol' => 'DH ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 26, 'name' => 'Hong Kong Dollar', 'code' => 'HKD', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 27, 'name' => 'Indonesian Rupiah', 'code' => 'IDR', 'symbol' => 'Rp', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 28, 'name' => 'Mexican Peso', 'code' => 'MXN', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 29, 'name' => 'Egyptian Pound', 'code' => 'EGP', 'symbol' => 'E£', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 30, 'name' => 'Colombian Peso', 'code' => 'COP', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','],
['id' => 31, 'name' => 'West African Franc', 'code' => 'XOF', 'symbol' => 'CFA ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 32, 'name' => 'Chinese Renminbi', 'code' => 'CNY', 'symbol' => 'RMB ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 33, 'name' => 'Rwandan Franc', 'code' => 'RWF', 'symbol' => 'RF ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 34, 'name' => 'Tanzanian Shilling', 'code' => 'TZS', 'symbol' => 'TSh ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 35, 'name' => 'Netherlands Antillean Guilder', 'code' => 'ANG', 'symbol' => '', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','],
['id' => 36, 'name' => 'Trinidad and Tobago Dollar', 'code' => 'TTD', 'symbol' => 'TT$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 37, 'name' => 'East Caribbean Dollar', 'code' => 'XCD', 'symbol' => 'EC$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 38, 'name' => 'Ghanaian Cedi', 'code' => 'GHS', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 39, 'name' => 'Bulgarian Lev', 'code' => 'BGN', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ' ', 'decimal_separator' => '.'],
['id' => 40, 'name' => 'Aruban Florin', 'code' => 'AWG', 'symbol' => 'Afl. ', 'precision' => '2', 'thousand_separator' => ' ', 'decimal_separator' => '.'],
['id' => 41, 'name' => 'Turkish Lira', 'code' => 'TRY', 'symbol' => 'TL ', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','],
['id' => 42, 'name' => 'Romanian New Leu', 'code' => 'RON', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 43, 'name' => 'Croatian Kuna', 'code' => 'HRK', 'symbol' => 'kn', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','],
['id' => 44, 'name' => 'Saudi Riyal', 'code' => 'SAR', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 45, 'name' => 'Japanese Yen', 'code' => 'JPY', 'symbol' => '¥', 'precision' => '0', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 46, 'name' => 'Maldivian Rufiyaa', 'code' => 'MVR', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 47, 'name' => 'Costa Rican Colón', 'code' => 'CRC', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 48, 'name' => 'Pakistani Rupee', 'code' => 'PKR', 'symbol' => 'Rs ', 'precision' => '0', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 49, 'name' => 'Polish Zloty', 'code' => 'PLN', 'symbol' => 'zł', 'precision' => '2', 'thousand_separator' => ' ', 'decimal_separator' => ',', 'swap_currency_symbol' => true],
['id' => 50, 'name' => 'Sri Lankan Rupee', 'code' => 'LKR', 'symbol' => 'LKR', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.', 'swap_currency_symbol' => true],
['id' => 51, 'name' => 'Czech Koruna', 'code' => 'CZK', 'symbol' => 'Kč', 'precision' => '2', 'thousand_separator' => ' ', 'decimal_separator' => ',', 'swap_currency_symbol' => true],
['id' => 52, 'name' => 'Uruguayan Peso', 'code' => 'UYU', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','],
['id' => 53, 'name' => 'Namibian Dollar', 'code' => 'NAD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 54, 'name' => 'Tunisian Dinar', 'code' => 'TND', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 55, 'name' => 'Russian Ruble', 'code' => 'RUB', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 56, 'name' => 'Mozambican Metical', 'code' => 'MZN', 'symbol' => 'MT', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ',', 'swap_currency_symbol' => true],
['id' => 57, 'name' => 'Omani Rial', 'code' => 'OMR', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 58, 'name' => 'Ukrainian Hryvnia', 'code' => 'UAH', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 59, 'name' => 'Macanese Pataca', 'code' => 'MOP', 'symbol' => 'MOP$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 60, 'name' => 'Taiwan New Dollar', 'code' => 'TWD', 'symbol' => 'NT$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 61, 'name' => 'Dominican Peso', 'code' => 'DOP', 'symbol' => 'RD$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 62, 'name' => 'Chilean Peso', 'code' => 'CLP', 'symbol' => '$', 'precision' => '0', 'thousand_separator' => '.', 'decimal_separator' => ','],
['id' => 63, 'name' => 'Icelandic Króna', 'code' => 'ISK', 'symbol' => 'kr', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ',', 'swap_currency_symbol' => true],
['id' => 64, 'name' => 'Papua New Guinean Kina', 'code' => 'PGK', 'symbol' => 'K', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 65, 'name' => 'Jordanian Dinar', 'code' => 'JOD', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 66, 'name' => 'Myanmar Kyat', 'code' => 'MMK', 'symbol' => 'K', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 67, 'name' => 'Peruvian Sol', 'code' => 'PEN', 'symbol' => 'S/ ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 68, 'name' => 'Botswana Pula', 'code' => 'BWP', 'symbol' => 'P', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 69, 'name' => 'Hungarian Forint', 'code' => 'HUF', 'symbol' => 'Ft', 'precision' => '0', 'thousand_separator' => '.', 'decimal_separator' => ',', 'swap_currency_symbol' => true],
['id' => 70, 'name' => 'Ugandan Shilling', 'code' => 'UGX', 'symbol' => 'USh ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 71, 'name' => 'Barbadian Dollar', 'code' => 'BBD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 72, 'name' => 'Brunei Dollar', 'code' => 'BND', 'symbol' => 'B$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 73, 'name' => 'Georgian Lari', 'code' => 'GEL', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ' ', 'decimal_separator' => ','],
['id' => 74, 'name' => 'Qatari Riyal', 'code' => 'QAR', 'symbol' => 'QR', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 75, 'name' => 'Honduran Lempira', 'code' => 'HNL', 'symbol' => 'L', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 76, 'name' => 'Surinamese Dollar', 'code' => 'SRD', 'symbol' => 'SRD', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','],
['id' => 77, 'name' => 'Bahraini Dinar', 'code' => 'BHD', 'symbol' => 'BD ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 78, 'name' => 'Venezuelan Bolivars', 'code' => 'VES', 'symbol' => 'Bs.', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','],
['id' => 79, 'name' => 'South Korean Won', 'code' => 'KRW', 'symbol' => 'W ', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','],
];
foreach ($currencies as $currency) {
$record = Currency::whereCode($currency['code'])->first();
if ($record) {
$record->name = $currency['name'];
$record->symbol = $currency['symbol'];
$record->precision = $currency['precision'];
$record->thousand_separator = $currency['thousand_separator'];
$record->decimal_separator = $currency['decimal_separator'];
if (isset($currency['swap_currency_symbol'])) {
$record->swap_currency_symbol = $currency['swap_currency_symbol'];
}
$record->save();
} else {
Currency::create($currency);
}
}
}
}

View File

@ -0,0 +1,63 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\Timezone;
use Database\Seeders\BanksSeeder;
use Database\Seeders\ConstantsSeeder;
use Database\Seeders\CountriesSeeder;
use Database\Seeders\CurrenciesSeeder;
use Database\Seeders\DateFormatsSeeder;
use Database\Seeders\DesignSeeder;
use Database\Seeders\GatewayTypesSeeder;
use Database\Seeders\IndustrySeeder;
use Database\Seeders\LanguageSeeder;
use Database\Seeders\PaymentLibrariesSeeder;
use Database\Seeders\PaymentTypesSeeder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$this->command->info('Running DatabaseSeeder');
if (Timezone::count()) {
$this->command->info('Skipping: already run');
return;
}
Model::unguard();
$this->call([
ConstantsSeeder::class,
PaymentLibrariesSeeder::class,
BanksSeeder::class,
CurrenciesSeeder::class,
LanguageSeeder::class,
CountriesSeeder::class,
IndustrySeeder::class,
PaymentTypesSeeder::class,
GatewayTypesSeeder::class,
DateFormatsSeeder::class,
DesignSeeder::class,
]);
}
}

View File

@ -0,0 +1,84 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\DateFormat;
use App\Models\DatetimeFormat;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
class DateFormatsSeeder extends Seeder
{
public function run()
{
Model::unguard();
// Date formats
$formats = [
['id' => 1, 'format' => 'd/M/Y', 'format_moment' => 'DD/MMM/YYYY', 'format_dart' => 'dd/MMM/yyyy'],
['id' => 2, 'format' => 'd-M-Y', 'format_moment' => 'DD-MMM-YYYY', 'format_dart' => 'dd-MMM-yyyy'],
['id' => 3, 'format' => 'd/F/Y', 'format_moment' => 'DD/MMMM/YYYY', 'format_dart' => 'dd/MMMM/yyyy'],
['id' => 4, 'format' => 'd-F-Y', 'format_moment' => 'DD-MMMM-YYYY', 'format_dart' => 'dd-MMMM-yyyy'],
['id' => 5, 'format' => 'M j, Y', 'format_moment' => 'MMM D, YYYY', 'format_dart' => 'MMM d, yyyy'],
['id' => 6, 'format' => 'F j, Y', 'format_moment' => 'MMMM D, YYYY', 'format_dart' => 'MMMM d, yyyy'],
['id' => 7, 'format' => 'D M j, Y', 'format_moment' => 'ddd MMM Do, YYYY', 'format_dart' => 'EEE MMM d, yyyy'],
['id' => 8, 'format' => 'Y-m-d', 'format_moment' => 'YYYY-MM-DD', 'format_dart' => 'yyyy-MM-dd'],
['id' => 9, 'format' => 'd-m-Y', 'format_moment' => 'DD-MM-YYYY', 'format_dart' => 'dd-MM-yyyy'],
['id' => 10, 'format' => 'm/d/Y', 'format_moment' => 'MM/DD/YYYY', 'format_dart' => 'MM/dd/yyyy'],
['id' => 11, 'format' => 'd.m.Y', 'format_moment' => 'D.MM.YYYY', 'format_dart' => 'dd.MM.yyyy'],
['id' => 12, 'format' => 'j. M. Y', 'format_moment' => 'DD. MMM. YYYY', 'format_dart' => 'd. MMM. yyyy'],
['id' => 13, 'format' => 'j. F Y', 'format_moment' => 'DD. MMMM YYYY', 'format_dart' => 'd. MMMM yyyy'],
['id' => 14, 'format' => 'dd/mm/yyyy', 'format_moment' => 'DD/MM/YYY', 'format_dart' => 'dd/MM/yyyy'],
];
foreach ($formats as $format) {
// use binary to support case-sensitive search
$record = DateFormat::whereRaw('BINARY `format`= ?', [$format['format']])->first();
if ($record) {
$record->format_moment = $format['format_moment'];
$record->format_dart = $format['format_dart'];
$record->save();
} else {
DateFormat::create($format);
}
}
// Date/time formats
$formats = [
['id' => 1, 'format' => 'd/M/Y g:i a', 'format_moment' => 'DD/MMM/YYYY h:mm:ss a', 'format_dart' => 'dd/MMM/yyyy h:mm a'],
['id' => 2, 'format' => 'd-M-Y g:i a', 'format_moment' => 'DD-MMM-YYYY h:mm:ss a', 'format_dart' => 'dd-MMM-yyyy h:mm a'],
['id' => 3, 'format' => 'd/F/Y g:i a', 'format_moment' => 'DD/MMMM/YYYY h:mm:ss a', 'format_dart' => 'dd/MMMM/yyyy h:mm a'],
['id' => 4, 'format' => 'd-F-Y g:i a', 'format_moment' => 'DD-MMMM-YYYY h:mm:ss a', 'format_dart' => 'dd-MMMM-yyyy h:mm a'],
['id' => 5, 'format' => 'M j, Y g:i a', 'format_moment' => 'MMM D, YYYY h:mm:ss a', 'format_dart' => 'MMM d, yyyy h:mm a'],
['id' => 6, 'format' => 'F j, Y g:i a', 'format_moment' => 'MMMM D, YYYY h:mm:ss a', 'format_dart' => 'MMMM d, yyyy h:mm a'],
['id' => 7, 'format' => 'D M jS, Y g:i a', 'format_moment' => 'ddd MMM Do, YYYY h:mm:ss a', 'format_dart' => 'EEE MMM d, yyyy h:mm a'],
['id' => 8, 'format' => 'Y-m-d g:i a', 'format_moment' => 'YYYY-MM-DD h:mm:ss a', 'format_dart' => 'yyyy-MM-dd h:mm a'],
['id' => 9, 'format' => 'd-m-Y g:i a', 'format_moment' => 'DD-MM-YYYY h:mm:ss a', 'format_dart' => 'dd-MM-yyyy h:mm a'],
['id' => 10, 'format' => 'm/d/Y g:i a', 'format_moment' => 'MM/DD/YYYY h:mm:ss a', 'format_dart' => 'MM/dd/yyyy h:mm a'],
['id' => 11, 'format' => 'd.m.Y g:i a', 'format_moment' => 'D.MM.YYYY h:mm:ss a', 'format_dart' => 'dd.MM.yyyy h:mm a'],
['id' => 12, 'format' => 'j. M. Y g:i a', 'format_moment' => 'DD. MMM. YYYY h:mm:ss a', 'format_dart' => 'd. MMM. yyyy h:mm a'],
['id' => 13, 'format' => 'j. F Y g:i a', 'format_moment' => 'DD. MMMM YYYY h:mm:ss a', 'format_dart' => 'd. MMMM yyyy h:mm a'],
['id' => 14, 'format' => 'dd/mm/yyyy g:i a', 'format_moment' => 'DD/MM/YYYY h:mm:ss a', 'format_dart' => 'dd/MM/yyyy h:mm a'],
];
foreach ($formats as $format) {
$record = DatetimeFormat::whereRaw('BINARY `format`= ?', [$format['format']])->first();
if ($record) {
$record->format_moment = $format['format_moment'];
$record->format_dart = $format['format_dart'];
$record->save();
} else {
DatetimeFormat::create($format);
}
}
}
}

View File

@ -0,0 +1,67 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\Bank;
use App\Models\Design;
use App\Services\PdfMaker\Design as PdfMakerDesign;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
class DesignSeeder extends Seeder
{
public function run()
{
Model::unguard();
$this->createDesigns();
}
private function createDesigns()
{
$designs = [
['id' => 1, 'name' => 'Plain', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
['id' => 2, 'name' => 'Clean', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
['id' => 3, 'name' => 'Bold', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
['id' => 4, 'name' => 'Modern', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
['id' => 5, 'name' => 'Business', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
['id' => 6, 'name' => 'Creative', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
['id' => 7, 'name' => 'Elegant', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
['id' => 8, 'name' => 'Hipster', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
['id' => 9, 'name' => 'Playful', 'user_id' => null, 'company_id' => null, 'is_custom' => false, 'design' => '', 'is_active' => true],
];
foreach ($designs as $design) {
$d = Design::find($design['id']);
if (! $d) {
Design::create($design);
}
}
foreach (Design::all() as $design) {
$template = new PdfMakerDesign(strtolower($design->name));
$template->document();
$design_object = new \stdClass;
$design_object->includes = $template->getSectionHTML('includes');
$design_object->header = $template->getSectionHTML('head', false);
$design_object->body = $template->getSectionHTML('body', false);
$design_object->product = $template->getSectionHTML('product-table');
$design_object->task = $template->getSectionHTML('task-table');
$design_object->footer = $template->getSectionHTML('footer', false);
$design->design = $design_object;
$design->save();
}
}
}

View File

@ -0,0 +1,50 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\GatewayType;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
class GatewayTypesSeeder extends Seeder
{
public function run()
{
Model::unguard();
$gateway_types = [
['id' => 1, 'alias' => 'credit_card', 'name' => 'Credit Card'],
['id' => 2, 'alias' => 'bank_transfer', 'name' => 'Bank Transfer'],
['id' => 3, 'alias' => 'paypal', 'name' => 'PayPal'],
['id' => 4, 'alias' => 'crypto', 'name' => 'Crypto'],
['id' => 5, 'alias' => 'dwolla', 'name' => 'Dwolla'],
['id' => 6, 'alias' => 'custom1', 'name' => 'Custom'],
['id' => 7, 'alias' => 'alipay', 'name' => 'Alipay'],
['id' => 8, 'alias' => 'sofort', 'name' => 'Sofort'],
['id' => 9, 'alias' => 'sepa', 'name' => 'SEPA'],
['id' => 10, 'alias' => 'gocardless', 'name' => 'GoCardless'],
['id' => 11, 'alias' => 'apple_pay', 'name' => 'Apple Pay'],
['id' => 12, 'alias' => 'custom2', 'name' => 'Custom'],
['id' => 13, 'alias' => 'custom3', 'name' => 'Custom'],
];
foreach ($gateway_types as $gateway_type) {
$record = GatewayType::where('alias', '=', $gateway_type['alias'])->first();
if ($record) {
$record->fill($gateway_type);
$record->save();
} else {
GatewayType::create($gateway_type);
}
}
}
}

View File

@ -0,0 +1,68 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\Industry;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
class IndustrySeeder extends Seeder
{
public function run()
{
Model::unguard();
$industries = [
['id' => 1, 'name' => 'Accounting & Legal'],
['id' => 2, 'name' => 'Advertising'],
['id' => 3, 'name' => 'Aerospace'],
['id' => 4, 'name' => 'Agriculture'],
['id' => 5, 'name' => 'Automotive'],
['id' => 6, 'name' => 'Banking & Finance'],
['id' => 7, 'name' => 'Biotechnology'],
['id' => 8, 'name' => 'Broadcasting'],
['id' => 9, 'name' => 'Business Services'],
['id' => 10, 'name' => 'Commodities & Chemicals'],
['id' => 11, 'name' => 'Communications'],
['id' => 12, 'name' => 'Computers & Hightech'],
['id' => 13, 'name' => 'Defense'],
['id' => 14, 'name' => 'Energy'],
['id' => 15, 'name' => 'Entertainment'],
['id' => 16, 'name' => 'Government'],
['id' => 17, 'name' => 'Healthcare & Life Sciences'],
['id' => 18, 'name' => 'Insurance'],
['id' => 19, 'name' => 'Manufacturing'],
['id' => 20, 'name' => 'Marketing'],
['id' => 21, 'name' => 'Media'],
['id' => 22, 'name' => 'Nonprofit & Higher Ed'],
['id' => 23, 'name' => 'Pharmaceuticals'],
['id' => 24, 'name' => 'Professional Services & Consulting'],
['id' => 25, 'name' => 'Real Estate'],
['id' => 26, 'name' => 'Retail & Wholesale'],
['id' => 27, 'name' => 'Sports'],
['id' => 28, 'name' => 'Transportation'],
['id' => 29, 'name' => 'Travel & Luxury'],
['id' => 30, 'name' => 'Other'],
['id' => 31, 'name' => 'Photography'],
['id' => 32, 'name' => 'Construction'],
['id' => 33, 'name' => 'Restaurant & Catering'],
];
foreach ($industries as $industry) {
$record = Industry::whereName($industry['name'])->first();
if (! $record) {
Industry::create($industry);
}
}
}
}

View File

@ -0,0 +1,69 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\Language;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
class LanguageSeeder extends Seeder
{
public function run()
{
Model::unguard();
// https://github.com/caouecs/Laravel-lang
// https://www.loc.gov/standards/iso639-2/php/code_list.php
$languages = [
['id' => 1, 'name' => 'English', 'locale' => 'en'],
['id' => 2, 'name' => 'Italian', 'locale' => 'it'],
['id' => 3, 'name' => 'German', 'locale' => 'de'],
['id' => 4, 'name' => 'French', 'locale' => 'fr'],
['id' => 5, 'name' => 'Portuguese - Brazilian', 'locale' => 'pt_BR'],
['id' => 6, 'name' => 'Dutch', 'locale' => 'nl'],
['id' => 7, 'name' => 'Spanish', 'locale' => 'es'],
['id' => 8, 'name' => 'Norwegian', 'locale' => 'nb_NO'],
['id' => 9, 'name' => 'Danish', 'locale' => 'da'],
['id' => 10, 'name' => 'Japanese', 'locale' => 'ja'],
['id' => 11, 'name' => 'Swedish', 'locale' => 'sv'],
['id' => 12, 'name' => 'Spanish - Spain', 'locale' => 'es_ES'],
['id' => 13, 'name' => 'French - Canada', 'locale' => 'fr_CA'],
['id' => 14, 'name' => 'Lithuanian', 'locale' => 'lt'],
['id' => 15, 'name' => 'Polish', 'locale' => 'pl'],
['id' => 16, 'name' => 'Czech', 'locale' => 'cs'],
['id' => 17, 'name' => 'Croatian', 'locale' => 'hr'],
['id' => 18, 'name' => 'Albanian', 'locale' => 'sq'],
['id' => 19, 'name' => 'Greek', 'locale' => 'el'],
['id' => 20, 'name' => 'English - United Kingdom', 'locale' => 'en_GB'],
['id' => 21, 'name' => 'Portuguese - Portugal', 'locale' => 'pt_PT'],
['id' => 22, 'name' => 'Slovenian', 'locale' => 'sl'],
['id' => 23, 'name' => 'Finnish', 'locale' => 'fi'],
['id' => 24, 'name' => 'Romanian', 'locale' => 'ro'],
['id' => 25, 'name' => 'Turkish - Turkey', 'locale' => 'tr_TR'],
['id' => 26, 'name' => 'Thai', 'locale' => 'th'],
['id' => 27, 'name' => 'Macedonian', 'locale' => 'mk_MK'],
['id' => 28, 'name' => 'Chinese - Taiwan', 'locale' => 'zh_TW'],
];
foreach ($languages as $language) {
$record = Language::whereLocale($language['locale'])->first();
if ($record) {
$record->name = $language['name'];
$record->save();
} else {
Language::create($language);
}
}
}
}

View File

@ -0,0 +1,108 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\Gateway;
use App\Models\GatewayType;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
class PaymentLibrariesSeeder extends Seeder
{
public function run()
{
Model::unguard();
$gateways = [
['id' => 1, 'name' => 'Authorize.Net', 'provider' => 'Authorize', 'sort_order' => 5, 'key' => '3b6621f970ab18887c4f6dca78d3f8bb', 'fields' => '{"apiLoginId":"","transactionKey":"","testMode":false,"developerMode":false,"liveEndpoint":"https:\/\/api2.authorize.net\/xml\/v1\/request.api","developerEndpoint":"https:\/\/apitest.authorize.net\/xml\/v1\/request.api"}
'],
['id' => 2, 'name' => 'CardSave', 'provider' => 'CardSave', 'key' => '46c5c1fed2c43acf4f379bae9c8b9f76', 'fields' => '{"merchantId":"","password":""}
'],
['id' => 3, 'name' => 'Eway Rapid', 'provider' => 'Eway_RapidShared', 'is_offsite' => true, 'key' => '944c20175bbe6b9972c05bcfe294c2c7', 'fields' => '{"apiKey":"","password":"","testMode":false}'],
['id' => 4, 'name' => 'FirstData Connect', 'provider' => 'FirstData_Connect', 'key' => '4e0ed0d34552e6cb433506d1ac03a418', 'fields' => '{"storeId":"","sharedSecret":"","testMode":false}'],
['id' => 5, 'name' => 'Migs ThreeParty', 'provider' => 'Migs_ThreeParty', 'key' => '513cdc81444c87c4b07258bc2858d3fa', 'fields' => '{"merchantId":"","merchantAccessCode":"","secureHash":""}'],
['id' => 6, 'name' => 'Migs TwoParty', 'provider' => 'Migs_TwoParty', 'key' => '99c2a271b5088951334d1302e038c01a', 'fields' => '{"merchantId":"","merchantAccessCode":"","secureHash":""}'],
['id' => 7, 'name' => 'Mollie', 'provider' => 'Mollie', 'is_offsite' => true, 'sort_order' => 8, 'key' => '1bd651fb213ca0c9d66ae3c336dc77e8', 'fields' => '{"apiKey":""}'],
['id' => 8, 'name' => 'MultiSafepay', 'provider' => 'MultiSafepay', 'key' => 'c3dec814e14cbd7d86abd92ce6789f8c', 'fields' => '{"accountId":"","siteId":"","siteCode":"","testMode":false}'],
['id' => 9, 'name' => 'Netaxept', 'provider' => 'Netaxept', 'key' => '070dffc5ca94f4e66216e44028ebd52d', 'fields' => '{"merchantId":"","password":"","testMode":false}'],
['id' => 10, 'name' => 'NetBanx', 'provider' => 'NetBanx', 'key' => '334d419939c06bd99b4dfd8a49243f0f', 'fields' => '{"accountNumber":"","storeId":"","storePassword":"","testMode":false}'],
['id' => 11, 'name' => 'PayFast', 'provider' => 'PayFast', 'is_offsite' => true, 'key' => 'd6814fc83f45d2935e7777071e629ef9', 'fields' => '{"merchantId":"","merchantKey":"","pdtKey":"","passphrase":"","testMode":false}'],
['id' => 12, 'name' => 'Payflow Pro', 'provider' => 'Payflow_Pro', 'key' => '0d97c97d227f91c5d0cb86d01e4a52c9', 'fields' => '{"username":"","password":"","vendor":"","partner":"","testMode":false}'],
['id' => 13, 'name' => 'PaymentExpress PxPay', 'provider' => 'PaymentExpress_PxPay', 'key' => 'a66b7062f4c8212d2c428209a34aa6bf', 'fields' => '{"username":"","password":"","pxPostUsername":"","pxPostPassword":"","testMode":false}', 'default_gateway_type_id' => GatewayType::PAYPAL],
['id' => 14, 'name' => 'PaymentExpress PxPost', 'provider' => 'PaymentExpress_PxPost', 'key' => '7e6fc08b89467518a5953a4839f8baba', 'fields' => '{"username":"","password":"","testMode":false}', 'default_gateway_type_id' => GatewayType::PAYPAL],
['id' => 15, 'name' => 'PayPal Express', 'provider' => 'PayPal_Express', 'is_offsite' => true, 'sort_order' => 4, 'key' => '38f2c48af60c7dd69e04248cbb24c36e', 'fields' => '{"username":"","password":"","signature":"","testMode":false,"solutionType":["Sole","Mark"],"landingPage":["Billing","Login"],"brandName":"","headerImageUrl":"","logoImageUrl":"","borderColor":""}', 'default_gateway_type_id' => GatewayType::PAYPAL],
['id' => 16, 'name' => 'PayPal Pro', 'provider' => 'PayPal_Pro', 'key' => '80af24a6a69f5c0bbec33e930ab40665', 'fields' => '{"username":"","password":"","signature":"","testMode":false}', 'default_gateway_type_id' => GatewayType::PAYPAL],
['id' => 17, 'name' => 'Pin', 'provider' => 'Pin', 'key' => '0749cb92a6b36c88bd9ff8aabd2efcab', 'fields' => '{"secretKey":"","testMode":false}'],
['id' => 18, 'name' => 'SagePay Direct', 'provider' => 'SagePay_Direct', 'key' => '4c8f4e5d0f353a122045eb9a60cc0f2d', 'fields' => '{"vendor":"","testMode":false,"referrerId":""}'],
['id' => 19, 'name' => 'SecurePay DirectPost', 'provider' => 'SecurePay_DirectPost', 'key' => '8036a5aadb2bdaafb23502da8790b6a2', 'fields' => '{"merchantId":"","transactionPassword":"","testMode":false,"enable_ach":"","enable_sofort":"","enable_apple_pay":"","enable_alipay":""}'],
['id' => 20, 'name' => 'Stripe', 'provider' => 'Stripe', 'sort_order' => 1, 'key' => 'd14dd26a37cecc30fdd65700bfb55b23', 'fields' => '{"apiKey":"", "publishableKey":""}'],
['id' => 21, 'name' => 'TargetPay Direct eBanking', 'provider' => 'TargetPay_Directebanking', 'key' => 'd14dd26a37cdcc30fdd65700bfb55b23', 'fields' => '{"subAccountId":""}'],
['id' => 22, 'name' => 'TargetPay Ideal', 'provider' => 'TargetPay_Ideal', 'key' => 'ea3b328bd72d381387281c3bd83bd97c', 'fields' => '{"subAccountId":""}'],
['id' => 23, 'name' => 'TargetPay Mr Cash', 'provider' => 'TargetPay_Mrcash', 'key' => 'a0035fc0d87c4950fb82c73e2fcb825a', 'fields' => '{"subAccountId":""}'],
['id' => 24, 'name' => 'TwoCheckout', 'provider' => 'TwoCheckout', 'is_offsite' => true, 'key' => '16dc1d3c8a865425421f64463faaf768', 'fields' => '{"accountNumber":"","secretWord":"","testMode":false}'],
['id' => 25, 'name' => 'WorldPay', 'provider' => 'WorldPay', 'key' => '43e639234f660d581ddac725ba7bcd29', 'fields' => '{"installationId":"","accountId":"","secretWord":"","callbackPassword":"","testMode":false,"noLanguageMenu":false,"fixContact":false,"hideContact":false,"hideCurrency":false,"signatureFields":"instId:amount:currency:cartId"}'],
['id' => 26, 'name' => 'moolah', 'provider' => 'AuthorizeNet_AIM', 'key' => '2f71dc17b0158ac30a7ae0839799e888', 'fields' => '{"apiLoginId":"","transactionKey":"","testMode":false,"developerMode":false,"liveEndpoint":"https:\/\/api2.authorize.net\/xml\/v1\/request.api","developerEndpoint":"https:\/\/apitest.authorize.net\/xml\/v1\/request.api"}'],
['id' => 27, 'name' => 'Alipay', 'provider' => 'Alipay_Express', 'key' => '733998ee4760b10f11fb48652571e02c', 'fields' => '{"partner":"","key":"","signType":"MD5","inputCharset":"utf-8","transport":"http","paymentType":1,"itBPay":"1d"}'],
['id' => 28, 'name' => 'Buckaroo', 'provider' => 'Buckaroo_CreditCard', 'key' => '6312879223e49c5cf92e194646bdee8f', 'fields' => '{"websiteKey":"","secretKey":"","testMode":false}'],
['id' => 29, 'name' => 'Coinbase', 'provider' => 'Coinbase', 'is_offsite' => true, 'key' => '106ef7e7da9062b0df363903b455711c', 'fields' => '{"apiKey":"","secret":"","accountId":""}'],
['id' => 30, 'name' => 'DataCash', 'provider' => 'DataCash', 'key' => 'e9a38f0896b5b82d196be3b7020c8664', 'fields' => '{"merchantId":"","password":"","testMode":false}'],
['id' => 31, 'name' => 'Pacnet', 'provider' => 'Pacnet', 'key' => '0da4e18ed44a5bd5c8ec354d0ab7b301', 'fields' => '{"username":"","sharedSecret":"","paymentRoutingNumber":"","testMode":false}'],
['id' => 32, 'name' => 'Realex', 'provider' => 'Realex_Remote', 'key' => 'd3979e62eb603fbdf1c78fe3a8ba7009', 'fields' => '{"merchantId":"","account":"","secret":"","3dSecure":0}'],
['id' => 33, 'name' => 'Sisow', 'provider' => 'Sisow', 'key' => '557d98977e7ec02dfa53de4b69b335be', 'fields' => '{"shopId":"","merchantId":""}'],
['id' => 34, 'name' => 'Skrill', 'provider' => 'Skrill', 'is_offsite' => true, 'key' => '54dc60c869a7322d87efbec5c0c25805', 'fields' => '{"email":"","notifyUrl":"","testMode":false}'],
['id' => 35, 'name' => 'BitPay', 'provider' => 'BitPay', 'is_offsite' => true, 'sort_order' => 7, 'key' => 'e4a02f0a4b235eb5e9e294730703bb74', 'fields' => '{"apiKey":"","testMode":false}'],
['id' => 36, 'name' => 'AGMS', 'provider' => 'Agms', 'key' => '1b3c6f3ccfea4f5e7eadeae188cccd7f', 'fields' => '{"username":"","password":"","apiKey":"","accountNumber":""}'],
['id' => 37, 'name' => 'Barclays', 'provider' => 'BarclaysEpdq\Essential', 'key' => '7cba6ce5c125f9cb47ea8443ae671b68', 'fields' => '{"clientId":"","testMode":false,"language":"en_US","callbackMethod":"POST"}'],
['id' => 38, 'name' => 'Cardgate', 'provider' => 'Cardgate', 'key' => 'b98cfa5f750e16cee3524b7b7e78fbf6', 'fields' => '{"merchantId":"","language":"nl","apiKey":"","siteId":"","notifyUrl":"","returnUrl":"","cancelUrl":"","testMode":false}'],
['id' => 39, 'name' => 'Checkout.com', 'provider' => 'CheckoutCom', 'key' => '3758e7f7c6f4cecf0f4f348b9a00f456', 'fields' => '{"secretApiKey":"","publicApiKey":"","testMode":false}'],
['id' => 40, 'name' => 'Creditcall', 'provider' => 'Creditcall', 'key' => 'cbc7ef7c99d31ec05492fbcb37208263', 'fields' => '{"terminalId":"","transactionKey":"","testMode":false,"verifyCvv":true,"verifyAddress":false,"verifyZip":false}'],
['id' => 41, 'name' => 'Cybersource', 'provider' => 'Cybersource', 'key' => 'e186a98d3b079028a73390bdc11bdb82', 'fields' => '{"profileId":"","secretKey":"","accessKey":"","testMode":false}'],
['id' => 42, 'name' => 'ecoPayz', 'provider' => 'Ecopayz', 'key' => '761040aca40f685d1ab55e2084b30670', 'fields' => '{"merchantId":"","merchantPassword":"","merchantAccountNumber":"","testMode":false}'],
['id' => 43, 'name' => 'Fasapay', 'provider' => 'Fasapay', 'key' => '1b2cef0e8c800204a29f33953aaf3360', 'fields' => ''],
['id' => 44, 'name' => 'Komoju', 'provider' => 'Komoju', 'key' => '7ea2d40ecb1eb69ef8c3d03e5019028a', 'fields' => '{"apiKey":"","accountId":"","paymentMethod":"credit_card","testMode":false,"locale":"en"}'],
['id' => 45, 'name' => 'Paysafecard', 'provider' => 'Paysafecard', 'key' => '70ab90cd6c5c1ab13208b3cef51c0894', 'fields' => '{"username":"","password":"","testMode":false}'],
['id' => 46, 'name' => 'Paytrace', 'provider' => 'Paytrace_CreditCard', 'key' => 'bbd736b3254b0aabed6ad7fda1298c88', 'fields' => '{"username":"","password":"","testMode":false,"endpoint":"https:\/\/paytrace.com\/api\/default.pay"}'],
['id' => 47, 'name' => 'Secure Trading', 'provider' => 'SecureTrading', 'key' => '231cb401487b9f15babe04b1ac4f7a27', 'fields' => '{"siteReference":"","username":"","password":"","applyThreeDSecure":false,"accountType":"ECOM"}'],
['id' => 48, 'name' => 'SecPay', 'provider' => 'SecPay', 'key' => 'bad8699d581d9fa040e59c0bb721a76c', 'fields' => '{"mid":"","vpnPswd":"","remotePswd":"","usageType":"","confirmEmail":"","testStatus":"true","mailCustomer":"true","additionalOptions":""}'],
['id' => 49, 'name' => 'WePay', 'provider' => 'WePay', 'is_offsite' => false, 'sort_order' => 3, 'key' => '8fdeed552015b3c7b44ed6c8ebd9e992', 'fields' => '{"accountId":"","accessToken":"","type":"goods","testMode":false,"feePayer":"payee"}'],
['id' => 50, 'name' => 'Braintree', 'provider' => 'Braintree', 'sort_order' => 3, 'key' => 'f7ec488676d310683fb51802d076d713', 'fields' => '{"merchantId":"","publicKey":"","privateKey":"","testMode":false}'],
['id' => 51, 'name' => 'FirstData Payeezy', 'provider' => 'FirstData_Payeezy', 'key' => '30334a52fb698046572c627ca10412e8', 'fields' => '{"gatewayId":"","password":"","keyId":"","hmac":"","testMode":false}'],
['id' => 52, 'name' => 'GoCardless', 'provider' => 'GoCardlessV2\Redirect', 'sort_order' => 9, 'is_offsite' => true, 'key' => 'b9886f9257f0c6ee7c302f1c74475f6c', 'fields' => '{"accessToken":"","webhookSecret":"","testMode":true}'],
['id' => 53, 'name' => 'PagSeguro', 'provider' => 'PagSeguro', 'key' => 'ef498756b54db63c143af0ec433da803', 'fields' => '{"email":"","token":"","sandbox":false}'],
['id' => 54, 'name' => 'PAYMILL', 'provider' => 'Paymill', 'key' => 'ca52f618a39367a4c944098ebf977e1c', 'fields' => '{"apiKey":""}'],
['id' => 55, 'name' => 'Custom', 'provider' => 'Custom', 'is_offsite' => true, 'sort_order' => 21, 'key' => '54faab2ab6e3223dbe848b1686490baa', 'fields' => '{"name":"","text":""}'],
];
foreach ($gateways as $gateway) {
$record = Gateway::whereName($gateway['name'])
->whereProvider($gateway['provider'])
->first();
if ($record) {
$record->fill($gateway);
$record->save();
} else {
Gateway::create($gateway);
}
}
Gateway::query()->update(['visible' => 0]);
Gateway::whereIn('id', [1,15,20,39])->update(['visible' => 1]);
Gateway::all()->each(function ($gateway){
$gateway->site_url = $gateway->getHelp();
$gateway->save();
});
}
}

View File

@ -0,0 +1,39 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\PaymentTerm;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
class PaymentTermsSeeder extends Seeder
{
public function run()
{
Model::unguard();
$paymentTerms = [
['num_days' => 0, 'name' => 'Net 0'],
['num_days' => 7, 'name' => ''],
['num_days' => 10, 'name' => ''],
['num_days' => 14, 'name' => ''],
['num_days' => 15, 'name' => ''],
['num_days' => 30, 'name' => ''],
['num_days' => 60, 'name' => ''],
['num_days' => 90, 'name' => ''],
];
foreach ($paymentTerms as $paymentTerm) {
PaymentTerm::create($paymentTerm);
}
}
}

View File

@ -0,0 +1,92 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\Models\PaymentType;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
class PaymentTypesSeeder extends Seeder
{
const BANK_LIBRARY_OFX = 1;
const GATEWAY_TYPE_CREDIT_CARD = 1;
const GATEWAY_TYPE_BANK_TRANSFER = 2;
const GATEWAY_TYPE_PAYPAL = 3;
const GATEWAY_TYPE_CRYPTO = 4;
const GATEWAY_TYPE_DWOLLA = 5;
const GATEWAY_TYPE_CUSTOM1 = 6;
const GATEWAY_TYPE_ALIPAY = 7;
const GATEWAY_TYPE_SOFORT = 8;
const GATEWAY_TYPE_SEPA = 9;
const GATEWAY_TYPE_GOCARDLESS = 10;
const GATEWAY_TYPE_APPLE_PAY = 11;
const GATEWAY_TYPE_CUSTOM2 = 12;
const GATEWAY_TYPE_CUSTOM3 = 13;
public function run()
{
Model::unguard();
$paymentTypes = [
// ['name' => 'Apply Credit'],
['name' => 'Bank Transfer', 'gateway_type_id' => self::GATEWAY_TYPE_BANK_TRANSFER],
['name' => 'Cash'],
['name' => 'Debit', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'ACH', 'gateway_type_id' => self::GATEWAY_TYPE_BANK_TRANSFER],
['name' => 'Visa Card', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'MasterCard', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'American Express', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'Discover Card', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'Diners Card', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'EuroCard', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'Nova', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'Credit Card Other', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'PayPal', 'gateway_type_id' => self::GATEWAY_TYPE_PAYPAL],
['name' => 'Google Wallet'],
['name' => 'Check'],
['name' => 'Carte Blanche', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'UnionPay', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'JCB', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'Laser', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'Maestro', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'Solo', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'Switch', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'iZettle', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'Swish', 'gateway_type_id' => self::GATEWAY_TYPE_BANK_TRANSFER],
['name' => 'Venmo'],
['name' => 'Money Order'],
['name' => 'Alipay', 'gateway_type_id' => self::GATEWAY_TYPE_ALIPAY],
['name' => 'Sofort', 'gateway_type_id' => self::GATEWAY_TYPE_SOFORT],
['name' => 'SEPA', 'gateway_type_id' => self::GATEWAY_TYPE_SEPA],
['name' => 'GoCardless', 'gateway_type_id' => self::GATEWAY_TYPE_GOCARDLESS],
['name' => 'Crypto', 'gateway_type_id' => self::GATEWAY_TYPE_CRYPTO],
];
$x = 1;
foreach ($paymentTypes as $paymentType) {
$record = PaymentType::where('name', '=', $paymentType['name'])->first();
if ($record) {
$record->id = $x;
$record->name = $paymentType['name'];
$record->gateway_type_id = ! empty($paymentType['gateway_type_id']) ? $paymentType['gateway_type_id'] : null;
$record->save();
} else {
$paymentType['id'] = $x;
PaymentType::create($paymentType);
}
$x++;
}
}
}

View File

@ -0,0 +1,373 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\DataMapper\ClientSettings;
use App\DataMapper\CompanySettings;
use App\DataMapper\DefaultSettings;
use App\Events\Invoice\InvoiceWasUpdated;
use App\Events\Payment\PaymentWasCreated;
use App\Helpers\Invoice\InvoiceSum;
use App\Helpers\Invoice\InvoiceSumInclusive;
use App\Listeners\Credit\CreateCreditInvitation;
use App\Listeners\Invoice\CreateInvoiceInvitation;
use App\Models\Account;
use App\Models\Client;
use App\Models\ClientContact;
use App\Models\CompanyGateway;
use App\Models\CompanyToken;
use App\Models\Credit;
use App\Models\GatewayType;
use App\Models\GroupSetting;
use App\Models\Invoice;
use App\Models\Payment;
use App\Models\PaymentHash;
use App\Models\PaymentType;
use App\Models\Product;
use App\Models\Quote;
use App\Models\RecurringInvoice;
use App\Models\User;
use App\Models\UserAccount;
use App\Repositories\CreditRepository;
use App\Repositories\InvoiceRepository;
use App\Repositories\QuoteRepository;
use App\Utils\Ninja;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
class RandomDataSeeder extends Seeder
{
use \App\Utils\Traits\MakesHash;
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
/* Warm up the cache !*/
$cached_tables = config('ninja.cached_tables');
foreach ($cached_tables as $name => $class) {
if (! Cache::has($name)) {
// 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);
}
}
}
$this->command->info('Running RandomDataSeeder');
Model::unguard();
$faker = \Faker\Factory::create();
$account = Account::factory()->create();
$company = Company::factory()->create([
'account_id' => $account->id,
]);
$account->default_company_id = $company->id;
$account->save();
$user = User::factory()->create([
'email' => $faker->email,
'account_id' => $account->id,
'confirmation_code' => $this->createDbHash(config('database.default')),
]);
$company_token = CompanyToken::create([
'user_id' => $user->id,
'company_id' => $company->id,
'account_id' => $account->id,
'name' => 'test token',
'token' => \Illuminate\Support\Str::random(64),
]);
$user->companies()->attach($company->id, [
'account_id' => $account->id,
'is_owner' => 1,
'is_admin' => 1,
'is_locked' => 0,
'notifications' => CompanySettings::notificationDefaults(),
'permissions' => '',
'settings' => null,
]);
$u2 = User::where('email', 'demo@invoiceninja.com')->first();
if (! $u2) {
$u2 = User::factory()->create([
'email' => 'demo@invoiceninja.com',
'password' => Hash::make('demo'),
'account_id' => $account->id,
'confirmation_code' => $this->createDbHash(config('database.default')),
]);
$company_token = CompanyToken::create([
'user_id' => $u2->id,
'company_id' => $company->id,
'account_id' => $account->id,
'name' => 'test token',
'token' => 'TOKEN',
]);
$u2->companies()->attach($company->id, [
'account_id' => $account->id,
'is_owner' => 1,
'is_admin' => 1,
'is_locked' => 0,
'notifications' => CompanySettings::notificationDefaults(),
'permissions' => '',
'settings' => null,
]);
}
$client = Client::factory()->create([
'user_id' => $user->id,
'company_id' => $company->id,
]);
ClientContact::create([
'first_name' => $faker->firstName,
'last_name' => $faker->lastName,
'email' => config('ninja.testvars.username'),
'company_id' => $company->id,
'password' => Hash::make(config('ninja.testvars.password')),
'email_verified_at' => now(),
'client_id' =>$client->id,
'user_id' => $user->id,
'is_primary' => true,
'contact_key' => \Illuminate\Support\Str::random(40),
]);
Client::factory()->create(['user_id' => $user->id, 'company_id' => $company->id])->each(function ($c) use ($user, $company) {
ClientContact::factory()->create([
'user_id' => $user->id,
'client_id' => $c->id,
'company_id' => $company->id,
'is_primary' => 1,
]);
ClientContact::factory()->count(5)->create([
'user_id' => $user->id,
'client_id' => $c->id,
'company_id' => $company->id,
]);
});
/* Product Factory */
Product::factory()->count(2)->create(['user_id' => $user->id, 'company_id' => $company->id]);
/* Invoice Factory */
Invoice::factory()->count(2)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]);
$invoices = Invoice::all();
$invoice_repo = new InvoiceRepository();
$invoices->each(function ($invoice) use ($invoice_repo, $user, $company, $client) {
$invoice_calc = null;
if ($invoice->uses_inclusive_taxes) {
$invoice_calc = new InvoiceSumInclusive($invoice);
} else {
$invoice_calc = new InvoiceSum($invoice);
}
$invoice = $invoice_calc->build()->getInvoice();
$invoice->save();
//event(new CreateInvoiceInvitation($invoice));
$invoice->service()->createInvitations()->markSent()->save();
$invoice->ledger()->updateInvoiceBalance($invoice->balance);
if (rand(0, 1)) {
$payment = App\Models\Payment::create([
'date' => now(),
'user_id' => $user->id,
'company_id' => $company->id,
'client_id' => $client->id,
'amount' => $invoice->balance,
'transaction_reference' => rand(0, 500),
'type_id' => PaymentType::CREDIT_CARD_OTHER,
'status_id' => Payment::STATUS_COMPLETED,
]);
$payment->invoices()->save($invoice);
$payment_hash = new PaymentHash;
$payment_hash->hash = Str::random(128);
$payment_hash->data = [['invoice_id' => $invoice->hashed_id, 'amount' => $invoice->balance]];
$payment_hash->fee_total = 0;
$payment_hash->fee_invoice_id = $invoice->id;
$payment_hash->save();
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));
$payment->service()->updateInvoicePayment($payment_hash);
// UpdateInvoicePayment::dispatchNow($payment, $payment->company);
}
});
/*Credits*/
Credit::factory()->count(2)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]);
$credits = Credit::cursor();
$credit_repo = new CreditRepository();
$credits->each(function ($credit) use ($credit_repo, $user, $company, $client) {
$credit_calc = null;
if ($credit->uses_inclusive_taxes) {
$credit_calc = new InvoiceSumInclusive($credit);
} else {
$credit_calc = new InvoiceSum($credit);
}
$credit = $credit_calc->build()->getCredit();
$credit->save();
//event(new CreateCreditInvitation($credit));
$credit->service()->createInvitations()->markSent()->save();
//$invoice->markSent()->save();
});
/* Recurring Invoice Factory */
RecurringInvoice::factory()->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]);
/*Credits*/
Quote::factory()->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]);
$quotes = Quote::cursor();
$quote_repo = new QuoteRepository();
$quotes->each(function ($quote) use ($quote_repo, $user, $company, $client) {
$quote_calc = null;
if ($quote->uses_inclusive_taxes) {
$quote_calc = new InvoiceSumInclusive($quote);
} else {
$quote_calc = new InvoiceSum($quote);
}
$quote = $quote_calc->build()->getQuote();
$quote->save();
//event(new CreateQuoteInvitation($quote));
$quote->service()->createInvitations()->markSent()->save();
//$invoice->markSent()->save();
});
$clients = Client::all();
foreach ($clients as $client) {
//$client->getNextClientNumber($client);
$client->id_number = $client->getNextClientNumber($client);
$client->save();
}
GroupSetting::create([
'company_id' => $company->id,
'user_id' => $user->id,
'settings' => ClientSettings::buildClientSettings(CompanySettings::defaults(), ClientSettings::defaults()),
'name' => 'Default Client Settings',
]);
if (config('ninja.testvars.stripe')) {
$cg = new CompanyGateway;
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
$cg->require_cvv = true;
$cg->show_billing_address = true;
$cg->show_shipping_address = true;
$cg->update_details = true;
$cg->config = encrypt(config('ninja.testvars.stripe'));
$cg->save();
$cg = new CompanyGateway;
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
$cg->require_cvv = true;
$cg->show_billing_address = true;
$cg->show_shipping_address = true;
$cg->update_details = true;
$cg->config = encrypt(config('ninja.testvars.stripe'));
$cg->save();
}
if (config('ninja.testvars.paypal')) {
$cg = new CompanyGateway;
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = '38f2c48af60c7dd69e04248cbb24c36e';
$cg->require_cvv = true;
$cg->show_billing_address = true;
$cg->show_shipping_address = true;
$cg->update_details = true;
$cg->config = encrypt(config('ninja.testvars.paypal'));
$cg->save();
}
if (config('ninja.testvars.checkout')) {
$cg = new CompanyGateway;
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = '3758e7f7c6f4cecf0f4f348b9a00f456';
$cg->require_cvv = true;
$cg->show_billing_address = true;
$cg->show_shipping_address = true;
$cg->update_details = true;
$cg->config = encrypt(config('ninja.testvars.checkout'));
$cg->save();
}
if (config('ninja.testvars.authorize')) {
$cg = new CompanyGateway;
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = '3b6621f970ab18887c4f6dca78d3f8bb';
$cg->require_cvv = true;
$cg->show_billing_address = true;
$cg->show_shipping_address = true;
$cg->update_details = true;
$cg->config = encrypt(config('ninja.testvars.authorize'));
$cg->save();
}
}
}

View File

@ -0,0 +1,104 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace Database\Seeders;
use App\DataMapper\CompanySettings;
use App\DataMapper\DefaultSettings;
use App\Models\Account;
use App\Models\Client;
use App\Models\ClientContact;
use App\Models\User;
use App\Models\UserAccount;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
class UsersTableSeeder extends Seeder
{
use \App\Utils\Traits\MakesHash;
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$this->command->info('Running UsersTableSeeder');
Model::unguard();
$faker = \Faker\Factory::create();
$account = Account::factory()->create();
$company = Company::factory()->create([
'account_id' => $account->id,
'domain' => 'ninja.test',
]);
$account->default_company_id = $company->id;
$account->save();
$user = User::factory()->create([
'account_id' => $account->id,
'confirmation_code' => $this->createDbHash(config('database.default')),
]);
$userPermissions = collect([
'view_invoice',
'view_client',
'edit_client',
'edit_invoice',
'create_invoice',
'create_client',
]);
$user->companies()->attach($company->id, [
'account_id' => $account->id,
'is_owner' => 1,
'is_admin' => 1,
'notifications' => CompanySettings::notificationDefaults(),
'permissions' => $userPermissions->toJson(),
'settings' => null,
'is_locked' => 0,
]);
$client = Client::factory()->create([
'user_id' => $user->id,
'company_id' => $company->id,
]);
ClientContact::create([
'first_name' => $faker->firstName,
'last_name' => $faker->lastName,
'email' => config('ninja.testvars.clientname'),
'company_id' => $company->id,
'password' => Hash::make(config('ninja.testvars.password')),
'email_verified_at' => now(),
'client_id' =>$client->id,
]);
Client::factory()->count(20)->create(['user_id' => $user->id, 'company_id' => $company->id])->each(function ($c) use ($user, $company) {
ClientContact::factory()->create([
'user_id' => $user->id,
'client_id' => $c->id,
'company_id' => $company->id,
'is_primary' => 1,
]);
ClientContact::factory()->count(10)->create([
'user_id' => $user->id,
'client_id' => $c->id,
'company_id' => $company->id,
]);
});
}
}

View File

@ -18,6 +18,8 @@ use App\Factory\InvoiceInvitationFactory;
use App\Jobs\Account\CreateAccount;
use App\Models\Account;
use App\Models\Client;
use App\Models\ClientContact;
use App\Models\Company;
use App\Models\Invoice;
use App\Models\InvoiceInvitation;
use App\Models\User;
@ -67,7 +69,7 @@ class InvitationTest extends TestCase
$user = User::where('email', 'user@example.com')->first();
if (! $user) {
$user = factory(\App\Models\User::class)->create([
$user = User::factory()->create([
'account_id' => $account->id,
'confirmation_code' => $this->createDbHash(config('database.default')),
]);
@ -94,15 +96,15 @@ class InvitationTest extends TestCase
'is_locked' => 0,
]);
factory(\App\Models\Client::class)->create(['user_id' => $user->id, 'company_id' => $company->id])->each(function ($c) use ($user, $company) {
factory(\App\Models\ClientContact::class, 1)->create([
Client::factory()->create(['user_id' => $user->id, 'company_id' => $company->id])->each(function ($c) use ($user, $company) {
ClientContact::factory()->create([
'user_id' => $user->id,
'client_id' => $c->id,
'company_id' => $company->id,
'is_primary' => 1,
]);
factory(\App\Models\ClientContact::class, 2)->create([
ClientContact::factory()->count(2)->create([
'user_id' => $user->id,
'client_id' => $c->id,
'company_id' => $company->id,
@ -111,7 +113,7 @@ class InvitationTest extends TestCase
$client = Client::whereUserId($user->id)->whereCompanyId($company->id)->first();
factory(\App\Models\Invoice::class, 5)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]);
Invoice::factory()->count(5)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]);
$invoice = Invoice::whereUserId($user->id)->whereCompanyId($company->id)->whereClientId($client->id)->first();

View File

@ -15,6 +15,7 @@ use App\DataMapper\CompanySettings;
use App\Factory\InvoiceFactory;
use App\Models\Account;
use App\Models\Client;
use App\Models\ClientContact;
use App\Models\Invoice;
use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model;
@ -51,15 +52,15 @@ class InvoiceTest extends TestCase
public function testInvoiceList()
{
factory(\App\Models\Client::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) {
factory(\App\Models\ClientContact::class, 1)->create([
Client::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) {
ClientContact::factory()->create([
'user_id' => $this->user->id,
'client_id' => $c->id,
'company_id' => $this->company->id,
'is_primary' => 1,
]);
factory(\App\Models\ClientContact::class, 1)->create([
ClientContact::factory()->create([
'user_id' => $this->user->id,
'client_id' => $c->id,
'company_id' => $this->company->id,
@ -68,7 +69,7 @@ class InvoiceTest extends TestCase
$client = Client::all()->first();
factory(\App\Models\Invoice::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]);
Invoice::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
@ -153,7 +154,7 @@ class InvoiceTest extends TestCase
public function testUniqueNumberValidation()
{
/* stub a invoice in the DB that we will use to test against later */
$invoice = factory(\App\Models\Invoice::class)->create([
$invoice = Invoice::factory()->create([
'user_id' => $this->user->id,
'client_id' => $this->client->id,
'company_id' => $this->company->id,

View File

@ -13,6 +13,7 @@ namespace Tests\Feature;
use App\DataMapper\CompanySettings;
use App\Models\Account;
use App\Models\Client;
use App\Models\Company;
use App\Models\CompanyToken;
use App\Models\User;
use App\Utils\Traits\UserSessionAttributes;
@ -140,8 +141,8 @@ class LoginTest extends TestCase
public function testApiLogin()
{
$account = factory(Account::class)->create();
$user = factory(User::class)->create([
$account = Account::factory()->create();
$user = User::factory()->create([
'account_id' => $account->id,
'email' => 'test@example.com',
'password' => \Hash::make('123456'),

View File

@ -20,6 +20,7 @@ use App\Helpers\Invoice\InvoiceSum;
use App\Models\Account;
use App\Models\Activity;
use App\Models\Client;
use App\Models\ClientContact;
use App\Models\Credit;
use App\Models\Invoice;
use App\Models\Payment;
@ -67,15 +68,15 @@ class PaymentTest extends TestCase
public function testPaymentList()
{
factory(\App\Models\Client::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) {
factory(\App\Models\ClientContact::class, 1)->create([
Client::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) {
ClientContact::factory()->create([
'user_id' => $this->user->id,
'client_id' => $c->id,
'company_id' => $this->company->id,
'is_primary' => 1,
]);
factory(\App\Models\ClientContact::class, 1)->create([
ClientContact::factory()->create([
'user_id' => $this->user->id,
'client_id' => $c->id,
'company_id' => $this->company->id,
@ -84,7 +85,7 @@ class PaymentTest extends TestCase
$client = Client::all()->first();
factory(\App\Models\Payment::class, 1)->create(
Payment::factory()->create(
['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $client->id]
);
@ -98,7 +99,7 @@ class PaymentTest extends TestCase
public function testPaymentRESTEndPoints()
{
factory(\App\Models\Payment::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]);
Payment::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]);
$Payment = Payment::all()->last();
@ -271,7 +272,7 @@ class PaymentTest extends TestCase
$client = ClientFactory::create($this->company->id, $this->user->id);
$client->save();
factory(\App\Models\ClientContact::class)->create([
ClientContact::factory()->create([
'user_id' => $this->user->id,
'client_id' => $client->id,
'company_id' =>$this->company->id,
@ -347,7 +348,7 @@ class PaymentTest extends TestCase
$client->setRelation('company', $this->company);
$client->save();
$client_contact = factory(\App\Models\ClientContact::class, 1)->create([
$client_contact = ClientContact::factory()->create([
'user_id' => $this->user->id,
'client_id' => $client->id,
'company_id' => $this->company->id,
@ -423,7 +424,7 @@ class PaymentTest extends TestCase
$client = ClientFactory::create($this->company->id, $this->user->id);
$client->save();
factory(\App\Models\ClientContact::class, 1)->create([
ClientContact::factory()->create([
'user_id' => $this->user->id,
'client_id' => $client->id,
'company_id' => $this->company->id,
@ -431,7 +432,7 @@ class PaymentTest extends TestCase
'send_email' => true,
]);
factory(\App\Models\ClientContact::class, 1)->create([
ClientContact::factory()->create([
'user_id' => $this->user->id,
'client_id' => $client->id,
'company_id' => $this->company->id,
@ -495,7 +496,7 @@ class PaymentTest extends TestCase
$client = ClientFactory::create($this->company->id, $this->user->id);
$client->save();
$contact = factory(\App\Models\ClientContact::class, 1)->create([
$contact = ClientContact::factory()->create([
'user_id' => $this->user->id,
'client_id' => $this->client->id,
'company_id' => $this->company->id,
@ -503,7 +504,7 @@ class PaymentTest extends TestCase
'send_email' => true,
]);
factory(\App\Models\ClientContact::class, 1)->create([
ClientContact::factory()->create([
'user_id' => $this->user->id,
'client_id' => $this->client->id,
'company_id' => $this->company->id,

View File

@ -14,6 +14,7 @@ use App\DataMapper\ClientSettings;
use App\DataMapper\CompanySettings;
use App\Models\Account;
use App\Models\Client;
use App\Models\ClientContact;
use App\Models\RecurringInvoice;
use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model;
@ -55,15 +56,16 @@ class RecurringInvoiceTest extends TestCase
public function testRecurringInvoiceList()
{
factory(\App\Models\Client::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) {
factory(\App\Models\ClientContact::class, 1)->create([
Client::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) {
ClientContact::factory()->create([
'user_id' => $this->user->id,
'client_id' => $c->id,
'company_id' => $this->company->id,
'is_primary' => 1,
]);
factory(\App\Models\ClientContact::class, 1)->create([
ClientContact::factory()->create([
'user_id' => $this->user->id,
'client_id' => $c->id,
'company_id' => $this->company->id,
@ -72,7 +74,7 @@ class RecurringInvoiceTest extends TestCase
$client = Client::all()->first();
factory(\App\Models\RecurringInvoice::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]);
RecurringInvoice::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
@ -84,15 +86,16 @@ class RecurringInvoiceTest extends TestCase
public function testRecurringInvoiceRESTEndPoints()
{
factory(\App\Models\Client::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) {
factory(\App\Models\ClientContact::class, 1)->create([
Client::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) {
ClientContact::factory()->create([
'user_id' => $this->user->id,
'client_id' => $c->id,
'company_id' => $this->company->id,
'is_primary' => 1,
]);
factory(\App\Models\ClientContact::class, 1)->create([
ClientContact::factory()->create([
'user_id' => $this->user->id,
'client_id' => $c->id,
'company_id' => $this->company->id,
@ -100,7 +103,7 @@ class RecurringInvoiceTest extends TestCase
});
$client = Client::all()->first();
factory(\App\Models\RecurringInvoice::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]);
RecurringInvoice::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]);
$RecurringInvoice = RecurringInvoice::where('user_id', $this->user->id)->first();
$RecurringInvoice->save();

View File

@ -55,7 +55,7 @@ class RecurringQuoteTest extends TestCase
public function testRecurringQuoteList()
{
factory(\App\Models\RecurringQuote::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]);
RecurringQuote::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
@ -67,7 +67,7 @@ class RecurringQuoteTest extends TestCase
public function testRecurringQuoteRESTEndPoints()
{
factory(\App\Models\RecurringQuote::class, 1)->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]);
RecurringQuote::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id, 'client_id' => $this->client->id]);
$RecurringQuote = RecurringQuote::where('user_id', $this->user->id)->first();
$RecurringQuote->save();

View File

@ -12,6 +12,7 @@ namespace Tests\Feature\Shop;
use App\Factory\CompanyUserFactory;
use App\Models\CompanyToken;
use App\Models\Product;
use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Routing\Middleware\ThrottleRequests;
@ -98,7 +99,7 @@ class ShopInvoiceTest extends TestCase
$this->company->enable_shop_api = true;
$this->company->save();
$product = factory(\App\Models\Product::class)->create([
$product = Product::factory()->create([
'user_id' => $this->user->id,
'company_id' => $this->company->id,
]);

View File

@ -223,7 +223,7 @@ trait MockAccountData
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
$this->invoice->client_id = $this->client->id;
// $this->invoice = factory(\App\Models\Invoice::class)->create([
// $this->invoice = Invoice::factory()->create([
// 'user_id' => $this->user->id,
// 'client_id' => $this->client->id,
// 'company_id' => $this->company->id,