akaunting 3.0 (the last dance)
This commit is contained in:
@ -21,8 +21,11 @@ class Account extends Factory
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$types = ['bank', 'credit_card'];
|
||||
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'type' => $this->faker->randomElement($types),
|
||||
'name' => $this->faker->text(15),
|
||||
'number' => (string) $this->faker->iban(),
|
||||
'currency_code' => $this->company->currencies()->enabled()->get()->random(1)->pluck('code')->first(),
|
||||
|
95
database/factories/Company.php
Normal file
95
database/factories/Company.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Abstracts\Factory;
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Common\Company as Model;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class Company extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'enabled' => $this->faker->boolean ? 1 : 0,
|
||||
'created_from' => 'core::factory',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model is enabled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function enabled()
|
||||
{
|
||||
return $this->state([
|
||||
'enabled' => 1,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model is disabled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function disabled()
|
||||
{
|
||||
return $this->state([
|
||||
'enabled' => 0,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the model factory.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function configure()
|
||||
{
|
||||
return $this->afterCreating(function (Model $company) {
|
||||
$company->makeCurrent();
|
||||
|
||||
app()->setLocale('en-GB');
|
||||
|
||||
// Company seeds
|
||||
Artisan::call('company:seed', [
|
||||
'company' => $company->id
|
||||
]);
|
||||
|
||||
$user = User::first();
|
||||
|
||||
$user->companies()->attach($company->id);
|
||||
|
||||
// User seeds
|
||||
Artisan::call('user:seed', [
|
||||
'user' => $user->id,
|
||||
'company' => $company->id,
|
||||
]);
|
||||
|
||||
setting()->set([
|
||||
'company.name' => $this->faker->text(15),
|
||||
'company.address' => 'New Street 1254',
|
||||
'company.city' => 'London',
|
||||
'company.country' => $this->faker->countryCode,
|
||||
'default.currency' => 'USD',
|
||||
'default.locale' => 'en-GB',
|
||||
]);
|
||||
|
||||
setting()->save();
|
||||
});
|
||||
}
|
||||
}
|
@ -25,16 +25,18 @@ class Contact extends Factory
|
||||
public function definition()
|
||||
{
|
||||
$types = array_merge($this->getCustomerTypes(), $this->getVendorTypes());
|
||||
$countries = array_keys(trans('countries'));
|
||||
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'type' => $this->faker->randomElement($types),
|
||||
'name' => $this->faker->name,
|
||||
'email' => $this->faker->unique()->safeEmail,
|
||||
'email' => $this->faker->freeEmail,
|
||||
'user_id' => null,
|
||||
'tax_number' => $this->faker->randomNumber(9),
|
||||
'phone' => $this->faker->phoneNumber,
|
||||
'address' => $this->faker->address,
|
||||
'country' => $this->faker->randomElement($countries),
|
||||
'website' => 'https://akaunting.com',
|
||||
'currency_code' => setting('default.currency'),
|
||||
'reference' => $this->faker->text(5),
|
||||
|
@ -14,12 +14,15 @@ use App\Models\Common\Contact;
|
||||
use App\Models\Common\Item;
|
||||
use App\Models\Document\Document as Model;
|
||||
use App\Models\Setting\Tax;
|
||||
use App\Traits\Documents;
|
||||
use App\Utilities\Date;
|
||||
use App\Utilities\Overrider;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class Document extends AbstractFactory
|
||||
{
|
||||
use Documents;
|
||||
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
@ -35,7 +38,7 @@ class Document extends AbstractFactory
|
||||
public function definition()
|
||||
{
|
||||
$issued_at = $this->faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d H:i:s');
|
||||
$due_at = Date::parse($issued_at)->addDays($this->faker->randomNumber(3))->format('Y-m-d H:i:s');
|
||||
$due_at = Date::parse($issued_at)->addDays($this->faker->randomNumber(2))->format('Y-m-d H:i:s');
|
||||
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
@ -54,30 +57,28 @@ class Document extends AbstractFactory
|
||||
*/
|
||||
public function invoice(): Factory
|
||||
{
|
||||
return $this->state(function (array $attributes): array {
|
||||
$contacts = Contact::customer()->enabled()->get();
|
||||
$contacts = Contact::customer()->enabled()->get();
|
||||
|
||||
if ($contacts->count()) {
|
||||
$contact = $contacts->random(1)->first();
|
||||
} else {
|
||||
$contact = Contact::factory()->customer()->enabled()->create();
|
||||
}
|
||||
if ($contacts->count()) {
|
||||
$contact = $contacts->random(1)->first();
|
||||
} else {
|
||||
$contact = Contact::factory()->customer()->enabled()->create();
|
||||
}
|
||||
|
||||
$statuses = ['draft', 'sent', 'viewed', 'partial', 'paid', 'cancelled'];
|
||||
$statuses = ['draft', 'sent', 'viewed', 'partial', 'paid', 'cancelled'];
|
||||
|
||||
return [
|
||||
'type' => Model::INVOICE_TYPE,
|
||||
'document_number' => setting('invoice.number_prefix') . $this->faker->randomNumber(setting('invoice.number_digit')),
|
||||
'category_id' => $this->company->categories()->income()->get()->random(1)->pluck('id')->first(),
|
||||
'contact_id' => $contact->id,
|
||||
'contact_name' => $contact->name,
|
||||
'contact_email' => $contact->email,
|
||||
'contact_tax_number' => $contact->tax_number,
|
||||
'contact_phone' => $contact->phone,
|
||||
'contact_address' => $contact->address,
|
||||
'status' => $this->faker->randomElement($statuses),
|
||||
];
|
||||
});
|
||||
return $this->state([
|
||||
'type' => Model::INVOICE_TYPE,
|
||||
'document_number' => $this->getNextDocumentNumber(Model::INVOICE_TYPE),
|
||||
'category_id' => $this->company->categories()->income()->get()->random(1)->pluck('id')->first(),
|
||||
'contact_id' => $contact->id,
|
||||
'contact_name' => $contact->name,
|
||||
'contact_email' => $contact->email,
|
||||
'contact_tax_number' => $contact->tax_number,
|
||||
'contact_phone' => $contact->phone,
|
||||
'contact_address' => $contact->address,
|
||||
'status' => $this->faker->randomElement($statuses),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,30 +86,28 @@ class Document extends AbstractFactory
|
||||
*/
|
||||
public function bill(): Factory
|
||||
{
|
||||
return $this->state(function (array $attributes): array {
|
||||
$contacts = Contact::vendor()->enabled()->get();
|
||||
$contacts = Contact::vendor()->enabled()->get();
|
||||
|
||||
if ($contacts->count()) {
|
||||
$contact = $contacts->random(1)->first();
|
||||
} else {
|
||||
$contact = Contact::factory()->vendor()->enabled()->create();
|
||||
}
|
||||
if ($contacts->count()) {
|
||||
$contact = $contacts->random(1)->first();
|
||||
} else {
|
||||
$contact = Contact::factory()->vendor()->enabled()->create();
|
||||
}
|
||||
|
||||
$statuses = ['draft', 'received', 'partial', 'paid', 'cancelled'];
|
||||
$statuses = ['draft', 'received', 'partial', 'paid', 'cancelled'];
|
||||
|
||||
return [
|
||||
'type' => Model::BILL_TYPE,
|
||||
'document_number' => setting('bill.number_prefix') . $this->faker->randomNumber(setting('bill.number_digit')),
|
||||
'category_id' => $this->company->categories()->expense()->get()->random(1)->pluck('id')->first(),
|
||||
'contact_id' => $contact->id,
|
||||
'contact_name' => $contact->name,
|
||||
'contact_email' => $contact->email,
|
||||
'contact_tax_number' => $contact->tax_number,
|
||||
'contact_phone' => $contact->phone,
|
||||
'contact_address' => $contact->address,
|
||||
'status' => $this->faker->randomElement($statuses),
|
||||
];
|
||||
});
|
||||
return $this->state([
|
||||
'type' => Model::BILL_TYPE,
|
||||
'document_number' => $this->getNextDocumentNumber(Model::BILL_TYPE),
|
||||
'category_id' => $this->company->categories()->expense()->get()->random(1)->pluck('id')->first(),
|
||||
'contact_id' => $contact->id,
|
||||
'contact_name' => $contact->name,
|
||||
'contact_email' => $contact->email,
|
||||
'contact_tax_number' => $contact->tax_number,
|
||||
'contact_phone' => $contact->phone,
|
||||
'contact_address' => $contact->address,
|
||||
'status' => $this->faker->randomElement($statuses),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -202,10 +201,15 @@ class Document extends AbstractFactory
|
||||
*/
|
||||
public function recurring()
|
||||
{
|
||||
$type = $this->getRawAttribute('type') . '-recurring';
|
||||
|
||||
return $this->state([
|
||||
'type' => $type,
|
||||
'document_number' => $this->getNextDocumentNumber($type),
|
||||
'recurring_started_at' => $this->getRawAttribute('issued_at'),
|
||||
'recurring_frequency' => 'daily',
|
||||
'recurring_interval' => '1',
|
||||
'recurring_count' => '7',
|
||||
'recurring_limit_count' => '7',
|
||||
]);
|
||||
}
|
||||
|
||||
@ -216,43 +220,41 @@ class Document extends AbstractFactory
|
||||
*/
|
||||
public function items()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
$amount = $this->faker->randomFloat(2, 1, 1000);
|
||||
$amount = $this->faker->randomFloat(2, 1, 1000);
|
||||
|
||||
$taxes = Tax::enabled()->get();
|
||||
$taxes = Tax::enabled()->get();
|
||||
|
||||
if ($taxes->count()) {
|
||||
$tax = $taxes->random(1)->first();
|
||||
} else {
|
||||
$tax = Tax::factory()->enabled()->create();
|
||||
}
|
||||
if ($taxes->count()) {
|
||||
$tax = $taxes->random(1)->first();
|
||||
} else {
|
||||
$tax = Tax::factory()->enabled()->create();
|
||||
}
|
||||
|
||||
$items = Item::enabled()->get();
|
||||
$items = Item::enabled()->get();
|
||||
|
||||
if ($items->count()) {
|
||||
$item = $items->random(1)->first();
|
||||
} else {
|
||||
$item = Item::factory()->enabled()->create();
|
||||
}
|
||||
if ($items->count()) {
|
||||
$item = $items->random(1)->first();
|
||||
} else {
|
||||
$item = Item::factory()->enabled()->create();
|
||||
}
|
||||
|
||||
$items = [
|
||||
[
|
||||
'type' => $attributes['type'],
|
||||
'name' => $item->name,
|
||||
'description' => $this->faker->text,
|
||||
'item_id' => $item->id,
|
||||
'tax_ids' => [$tax->id],
|
||||
'quantity' => '1',
|
||||
'price' => $amount,
|
||||
'currency' => setting('default.currency'),
|
||||
],
|
||||
];
|
||||
$items = [
|
||||
[
|
||||
'type' => $this->getRawAttribute('type'),
|
||||
'name' => $item->name,
|
||||
'description' => $this->faker->text,
|
||||
'item_id' => $item->id,
|
||||
'tax_ids' => [$tax->id],
|
||||
'quantity' => '1',
|
||||
'price' => $amount,
|
||||
'currency' => setting('default.currency'),
|
||||
],
|
||||
];
|
||||
|
||||
return [
|
||||
'items' => $items,
|
||||
'recurring_frequency' => 'no',
|
||||
];
|
||||
});
|
||||
return $this->state([
|
||||
'items' => $items,
|
||||
'recurring_frequency' => 'no',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -291,6 +293,7 @@ class Document extends AbstractFactory
|
||||
|
||||
$items = [
|
||||
[
|
||||
'type' => $document->type,
|
||||
'name' => $item->name,
|
||||
'description' => $this->faker->text,
|
||||
'item_id' => $item->id,
|
||||
@ -327,7 +330,7 @@ class Document extends AbstractFactory
|
||||
case 'paid':
|
||||
$payment_request = [
|
||||
'paid_at' => $updated_document->due_at,
|
||||
'type' => config('type.' . $document->type . '.transaction_type'),
|
||||
'type' => config('type.document.' . $document->type . '.transaction_type'),
|
||||
];
|
||||
|
||||
if ($init_status === 'partial') {
|
||||
|
@ -21,8 +21,11 @@ class Item extends Factory
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$types = ['product', 'service'];
|
||||
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'type' => $this->faker->randomElement($types),
|
||||
'name' => $this->faker->text(15),
|
||||
'description' => $this->faker->text(100),
|
||||
'purchase_price' => $this->faker->randomFloat(2, 10, 20),
|
||||
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Abstracts\Factory;
|
||||
use App\Models\Auth\Permission as Model;
|
||||
|
||||
class Permission extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$map = ['Create', 'Read', 'Update', 'Delete'];
|
||||
|
||||
$prefix = $this->faker->randomElement($map);
|
||||
$word_1 = $this->faker->word;
|
||||
$word_2 = $this->faker->word;
|
||||
|
||||
return [
|
||||
'name' => strtolower($prefix) . '-' . strtolower($word_1) . '-' . strtolower($word_2),
|
||||
'display_name' => $prefix . ' ' . $word_1 . ' ' . $word_2,
|
||||
'description' => $prefix . ' ' . $word_1 . ' ' . $word_2,
|
||||
];
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Abstracts\Factory;
|
||||
use App\Models\Auth\Permission;
|
||||
use App\Models\Auth\Role as Model;
|
||||
|
||||
class Role extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$name = $this->faker->word;
|
||||
|
||||
return [
|
||||
'name' => strtolower($name),
|
||||
'display_name' => $name,
|
||||
'description' => $name,
|
||||
'created_from' => 'core::factory',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate the model permissions.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function permissions()
|
||||
{
|
||||
return $this->state([
|
||||
'permissions' => $this->getPermissions(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the model factory.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function configure()
|
||||
{
|
||||
return $this->afterCreating(function (Model $role) {
|
||||
$role->permissions()->attach($this->getPermissions());
|
||||
});
|
||||
}
|
||||
|
||||
protected function getPermissions()
|
||||
{
|
||||
return Permission::take(50)->pluck('id')->toArray();
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ namespace Database\Factories;
|
||||
use App\Abstracts\Factory;
|
||||
use App\Models\Banking\Transaction as Model;
|
||||
use App\Traits\Transactions;
|
||||
use App\Utilities\Date;
|
||||
|
||||
class Transaction extends Factory
|
||||
{
|
||||
@ -17,6 +18,13 @@ class Transaction extends Factory
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
/**
|
||||
* The type of the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'income';
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
@ -25,13 +33,14 @@ class Transaction extends Factory
|
||||
public function definition()
|
||||
{
|
||||
$types = array_merge($this->getIncomeTypes(), $this->getExpenseTypes());
|
||||
$type = $this->faker->randomElement($types);
|
||||
$this->type = $this->faker->randomElement($types);
|
||||
|
||||
$category_type = in_array($type, $this->getIncomeTypes()) ? 'income' : 'expense';
|
||||
$category_type = in_array($this->type, $this->getIncomeTypes()) ? 'income' : 'expense';
|
||||
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'type' => $type,
|
||||
'type' => $this->type,
|
||||
'number' => $this->getNextTransactionNumber(),
|
||||
'account_id' => setting('default.account'),
|
||||
'paid_at' => $this->faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d H:i:s'),
|
||||
'amount' => $this->faker->randomFloat(2, 1, 1000),
|
||||
@ -70,4 +79,26 @@ class Transaction extends Factory
|
||||
'category_id' => $this->company->categories()->expense()->get()->random(1)->pluck('id')->first(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model is recurring.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function recurring()
|
||||
{
|
||||
return $this->state([
|
||||
'type' => $this->getRawAttribute('type') . '-recurring',
|
||||
'number' => $this->getNextTransactionNumber('-recurring'),
|
||||
'recurring_started_at' => $this->getRawAttribute('paid_at'),
|
||||
'recurring_frequency' => 'daily',
|
||||
'recurring_custom_frequency' => 'daily',
|
||||
'recurring_interval' => '1',
|
||||
'recurring_limit' => 'date',
|
||||
'recurring_limit_date' => Date::now()->addDay(7)->format('Y-m-d'),
|
||||
'disabled_transaction_paid' => "Auto-generated",
|
||||
'disabled_transaction_number' => "Auto-generated",
|
||||
'real_type' => $this->getRawAttribute('type'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -26,13 +26,13 @@ class User extends Factory
|
||||
|
||||
return [
|
||||
'name' => $this->faker->name,
|
||||
'email' => $this->faker->unique()->safeEmail,
|
||||
'email' => $this->faker->freeEmail,
|
||||
'password' => $password,
|
||||
'password_confirmation' => $password,
|
||||
'remember_token' => Str::random(10),
|
||||
'locale' => 'en-GB',
|
||||
'companies' => ['1'],
|
||||
'roles' => ['1'],
|
||||
'roles' => '1',
|
||||
'enabled' => $this->faker->boolean ? 1 : 0,
|
||||
'created_from' => 'core::factory',
|
||||
];
|
||||
|
@ -5,6 +5,7 @@ namespace Database\Factories;
|
||||
use App\Abstracts\Factory;
|
||||
use App\Models\Common\Dashboard;
|
||||
use App\Models\Common\Widget as Model;
|
||||
use App\Utilities\Widgets;
|
||||
|
||||
class Widget extends Factory
|
||||
{
|
||||
@ -15,19 +16,6 @@ class Widget extends Factory
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
public $classes = [
|
||||
'App\Widgets\TotalIncome',
|
||||
'App\Widgets\TotalExpenses',
|
||||
'App\Widgets\TotalProfit',
|
||||
'App\Widgets\CashFlow',
|
||||
'App\Widgets\IncomeByCategory',
|
||||
'App\Widgets\ExpensesByCategory',
|
||||
'App\Widgets\AccountBalance',
|
||||
'App\Widgets\LatestIncome',
|
||||
'App\Widgets\LatestExpenses',
|
||||
'App\Widgets\Currencies',
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
@ -41,7 +29,7 @@ class Widget extends Factory
|
||||
'company_id' => $this->company->id,
|
||||
'dashboard_id' => $dashboard->id,
|
||||
'name' => $this->faker->text(15),
|
||||
'class' => $this->faker->randomElement($this->classes),
|
||||
'class' => $this->faker->randomElement(Widgets::$core_widgets),
|
||||
'created_from' => 'core::factory',
|
||||
];
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV1 extends Migration
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
@ -465,6 +465,8 @@ class CoreV1 extends Migration
|
||||
$table->string('key');
|
||||
$table->text('value')->nullable();
|
||||
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->unique(['company_id', 'key']);
|
||||
});
|
||||
@ -514,9 +516,8 @@ class CoreV1 extends Migration
|
||||
Schema::create('user_companies', function (Blueprint $table) {
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('company_id')->unsigned();
|
||||
$table->string('user_type');
|
||||
|
||||
$table->primary(['user_id', 'company_id', 'user_type']);
|
||||
$table->primary(['user_id', 'company_id']);
|
||||
});
|
||||
}
|
||||
|
||||
@ -527,44 +528,6 @@ class CoreV1 extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('accounts');
|
||||
Schema::drop('bills');
|
||||
Schema::drop('bill_histories');
|
||||
Schema::drop('bill_items');
|
||||
Schema::drop('bill_item_taxes');
|
||||
Schema::drop('bill_totals');
|
||||
Schema::drop('categories');
|
||||
Schema::drop('companies');
|
||||
Schema::drop('currencies');
|
||||
Schema::drop('invoices');
|
||||
Schema::drop('invoice_histories');
|
||||
Schema::drop('invoice_items');
|
||||
Schema::drop('invoice_item_taxes');
|
||||
Schema::drop('invoice_totals');
|
||||
Schema::drop('items');
|
||||
Schema::drop('jobs');
|
||||
Schema::drop('failed_jobs');
|
||||
Schema::drop('mediables');
|
||||
Schema::drop('media');
|
||||
Schema::drop('modules');
|
||||
Schema::drop('module_histories');
|
||||
Schema::drop('notifications');
|
||||
Schema::drop('password_resets');
|
||||
|
||||
// Cascade table first
|
||||
Schema::drop('user_permissions');
|
||||
Schema::drop('role_permissions');
|
||||
Schema::drop('permissions');
|
||||
Schema::drop('user_roles');
|
||||
Schema::drop('roles');
|
||||
|
||||
Schema::drop('reconciliations');
|
||||
Schema::drop('recurring');
|
||||
Schema::drop('sessions');
|
||||
Schema::drop('settings');
|
||||
Schema::drop('taxes');
|
||||
Schema::drop('transfers');
|
||||
Schema::drop('users');
|
||||
Schema::drop('user_companies');
|
||||
//
|
||||
}
|
||||
}
|
||||
};
|
||||
|
460
database/migrations/2019_11_16_000000_core_v2.php
Normal file
460
database/migrations/2019_11_16_000000_core_v2.php
Normal file
@ -0,0 +1,460 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// Accounts
|
||||
Schema::table('accounts', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
$table->string('created_from', 100)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
// Categories
|
||||
Schema::table('categories', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
$table->string('created_from', 100)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
// Companies
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->string('domain')->nullable()->change();
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
$table->string('created_from', 100)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
// Contacts
|
||||
Schema::create('contacts', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('type');
|
||||
$table->string('name');
|
||||
$table->string('email')->nullable();
|
||||
$table->integer('user_id')->nullable();
|
||||
$table->string('tax_number')->nullable();
|
||||
$table->string('phone')->nullable();
|
||||
$table->text('address')->nullable();
|
||||
$table->string('city')->nullable();
|
||||
$table->string('zip_code')->nullable();
|
||||
$table->string('state')->nullable();
|
||||
$table->string('country')->nullable();
|
||||
$table->string('website')->nullable();
|
||||
$table->string('currency_code');
|
||||
$table->boolean('enabled')->default(1);
|
||||
$table->string('reference')->nullable();
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id', 'type']);
|
||||
$table->unique(['company_id', 'type', 'email', 'deleted_at']);
|
||||
});
|
||||
|
||||
// Currencies
|
||||
Schema::table('currencies', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
$table->string('created_from', 100)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
// Dashboards & Widgets
|
||||
Schema::create('dashboards', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('name');
|
||||
$table->boolean('enabled')->default(1);
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id']);
|
||||
});
|
||||
|
||||
Schema::create('user_dashboards', function (Blueprint $table) {
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('dashboard_id')->unsigned();
|
||||
|
||||
$table->primary(['user_id', 'dashboard_id']);
|
||||
});
|
||||
|
||||
Schema::create('widgets', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('dashboard_id');
|
||||
$table->string('class');
|
||||
$table->string('name');
|
||||
$table->integer('sort')->default(0);
|
||||
$table->text('settings')->nullable();
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id', 'dashboard_id']);
|
||||
$table->index('class');
|
||||
});
|
||||
|
||||
// Documents
|
||||
Schema::create('documents', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('company_id');
|
||||
$table->string('type');
|
||||
$table->string('document_number');
|
||||
$table->string('order_number')->nullable();
|
||||
$table->string('status');
|
||||
$table->dateTime('issued_at');
|
||||
$table->dateTime('due_at');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->string('currency_code');
|
||||
$table->double('currency_rate', 15, 8);
|
||||
$table->unsignedInteger('category_id')->default(1);
|
||||
$table->unsignedInteger('contact_id');
|
||||
$table->string('contact_name');
|
||||
$table->string('contact_email')->nullable();
|
||||
$table->string('contact_tax_number')->nullable();
|
||||
$table->string('contact_phone')->nullable();
|
||||
$table->text('contact_address')->nullable();
|
||||
$table->string('contact_city')->nullable();
|
||||
$table->string('contact_zip_code')->nullable();
|
||||
$table->string('contact_state')->nullable();
|
||||
$table->string('contact_country')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->text('footer')->nullable();
|
||||
$table->unsignedInteger('parent_id')->default(0);
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->index('type');
|
||||
$table->unique(['document_number', 'deleted_at', 'company_id', 'type']);
|
||||
});
|
||||
|
||||
Schema::create('document_histories', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('type');
|
||||
$table->unsignedInteger('document_id');
|
||||
$table->string('status');
|
||||
$table->boolean('notify');
|
||||
$table->text('description')->nullable();
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->index('type');
|
||||
$table->index('document_id');
|
||||
});
|
||||
|
||||
Schema::create('document_items', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('company_id');
|
||||
$table->string('type');
|
||||
$table->unsignedInteger('document_id');
|
||||
$table->unsignedInteger('item_id')->nullable();
|
||||
$table->string('name');
|
||||
$table->text('description')->nullable();
|
||||
$table->string('sku')->nullable();
|
||||
$table->double('quantity', 7, 2);
|
||||
$table->double('price', 15, 4);
|
||||
$table->float('tax', 15, 4)->default('0.0000');
|
||||
$table->string('discount_type')->default('normal');
|
||||
$table->double('discount_rate', 15, 4)->default('0.0000');
|
||||
$table->double('total', 15, 4);
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->index('type');
|
||||
$table->index('document_id');
|
||||
});
|
||||
|
||||
Schema::create('document_item_taxes', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('company_id');
|
||||
$table->string('type');
|
||||
$table->unsignedInteger('document_id');
|
||||
$table->unsignedInteger('document_item_id');
|
||||
$table->unsignedInteger('tax_id');
|
||||
$table->string('name');
|
||||
$table->double('amount', 15, 4)->default('0.0000');
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->index('type');
|
||||
$table->index('document_id');
|
||||
});
|
||||
|
||||
Schema::create('document_totals', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('company_id');
|
||||
$table->string('type');
|
||||
$table->unsignedInteger('document_id');
|
||||
$table->string('code')->nullable();
|
||||
$table->string('name');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->integer('sort_order');
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->index('type');
|
||||
$table->index('document_id');
|
||||
});
|
||||
|
||||
// Email templates
|
||||
Schema::create('email_templates', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('alias');
|
||||
$table->string('class');
|
||||
$table->string('name');
|
||||
$table->string('subject');
|
||||
$table->text('body');
|
||||
$table->text('params')->nullable();
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->unique(['company_id', 'alias', 'deleted_at']);
|
||||
});
|
||||
|
||||
// Jobs
|
||||
Schema::table('failed_jobs', function (Blueprint $table) {
|
||||
$table->string('uuid')->after('id')->nullable()->unique();
|
||||
});
|
||||
|
||||
// Firewall
|
||||
Schema::create('firewall_ips', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('ip');
|
||||
$table->integer('log_id')->nullable();
|
||||
$table->boolean('blocked')->default(1);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('ip');
|
||||
$table->unique(['ip', 'deleted_at']);
|
||||
});
|
||||
|
||||
Schema::create('firewall_logs', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('ip');
|
||||
$table->string('level')->default('medium');
|
||||
$table->string('middleware');
|
||||
$table->integer('user_id')->nullable();
|
||||
$table->string('url')->nullable();
|
||||
$table->string('referrer')->nullable();
|
||||
$table->text('request')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('ip');
|
||||
});
|
||||
|
||||
// Items
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->string('sku')->nullable()->change();
|
||||
$table->integer('quantity')->default(1)->change();
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
$table->string('created_from', 100)->nullable()->after('enabled');
|
||||
|
||||
$connection = Schema::getConnection();
|
||||
$d_table = $connection->getDoctrineSchemaManager()->listTableDetails($connection->getTablePrefix() . 'items');
|
||||
|
||||
if ($d_table->hasIndex('items_company_id_sku_deleted_at_unique')) {
|
||||
// 1.3 update
|
||||
$table->dropUnique('items_company_id_sku_deleted_at_unique');
|
||||
} else {
|
||||
// 2.0 install
|
||||
$table->dropUnique(['company_id', 'sku', 'deleted_at']);
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create('item_taxes', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('item_id');
|
||||
$table->integer('tax_id')->nullable();
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id', 'item_id']);
|
||||
});
|
||||
|
||||
// Media
|
||||
Schema::table('media', function (Blueprint $table) {
|
||||
$table->unsignedInteger('company_id')->default(0)->after('id');
|
||||
$table->unsignedInteger('created_by')->nullable()->after('size');
|
||||
$table->string('created_from', 100)->nullable()->after('size');
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
Schema::table('mediables', function (Blueprint $table) {
|
||||
$table->unsignedInteger('company_id')->default(0)->after('media_id');
|
||||
$table->unsignedInteger('created_by')->nullable()->after('order');
|
||||
$table->string('created_from', 100)->nullable()->after('order');
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
// Modules
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
$table->renameColumn('status', 'enabled');
|
||||
});
|
||||
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
$table->string('created_from', 100)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('module_histories', function (Blueprint $table) {
|
||||
$table->dropColumn('category');
|
||||
});
|
||||
|
||||
Schema::table('module_histories', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('description');
|
||||
$table->string('created_from', 100)->nullable()->after('description');
|
||||
});
|
||||
|
||||
// Reconciliations
|
||||
Schema::table('reconciliations', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('reconciled');
|
||||
$table->string('created_from', 100)->nullable()->after('reconciled');
|
||||
});
|
||||
|
||||
// Recurring
|
||||
Schema::table('recurring', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('count');
|
||||
$table->string('created_from', 100)->nullable()->after('count');
|
||||
});
|
||||
|
||||
// Reports
|
||||
Schema::create('reports', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('class');
|
||||
$table->string('name');
|
||||
$table->text('description');
|
||||
$table->text('settings')->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->index('class');
|
||||
});
|
||||
|
||||
// Roles
|
||||
Schema::table('roles', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('description');
|
||||
$table->string('created_from', 100)->nullable()->after('description');
|
||||
});
|
||||
|
||||
// Taxes
|
||||
Schema::table('taxes', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
$table->string('created_from', 100)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
// Transactions
|
||||
Schema::create('transactions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('type');
|
||||
$table->dateTime('paid_at');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->string('currency_code');
|
||||
$table->double('currency_rate', 15, 8);
|
||||
$table->integer('account_id');
|
||||
$table->integer('document_id')->nullable();
|
||||
$table->integer('contact_id')->nullable();
|
||||
$table->integer('category_id')->default(1);
|
||||
$table->text('description')->nullable();
|
||||
$table->string('payment_method');
|
||||
$table->string('reference')->nullable();
|
||||
$table->integer('parent_id')->default(0);
|
||||
$table->boolean('reconciled')->default(0);
|
||||
$table->string('created_from', 100)->nullable();
|
||||
$table->unsignedInteger('created_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id', 'type']);
|
||||
$table->index('account_id');
|
||||
$table->index('category_id');
|
||||
$table->index('contact_id');
|
||||
$table->index('document_id');
|
||||
});
|
||||
|
||||
// Transfers
|
||||
Schema::table('transfers', function (Blueprint $table) {
|
||||
$table->renameColumn('payment_id', 'expense_transaction_id');
|
||||
});
|
||||
|
||||
Schema::table('transfers', function (Blueprint $table) {
|
||||
$table->renameColumn('revenue_id', 'income_transaction_id');
|
||||
});
|
||||
|
||||
Schema::table('transfers', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('income_transaction_id');
|
||||
$table->string('created_from', 100)->nullable()->after('income_transaction_id');
|
||||
});
|
||||
|
||||
// Users
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('landing_page', 70)->nullable()->default('dashboard')->after('locale');
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
$table->string('created_from', 100)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::dropIfExists('invoices');
|
||||
Schema::dropIfExists('invoice_histories');
|
||||
Schema::dropIfExists('invoice_items');
|
||||
Schema::dropIfExists('invoice_item_taxes');
|
||||
Schema::dropIfExists('invoice_statuses');
|
||||
Schema::dropIfExists('invoice_totals');
|
||||
Schema::dropIfExists('bills');
|
||||
Schema::dropIfExists('bill_histories');
|
||||
Schema::dropIfExists('bill_items');
|
||||
Schema::dropIfExists('bill_item_taxes');
|
||||
Schema::dropIfExists('bill_statuses');
|
||||
Schema::dropIfExists('bill_totals');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
@ -1,280 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV200 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// Footer column
|
||||
Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->text('footer')->nullable()->after('notes');
|
||||
});
|
||||
|
||||
// Contacts
|
||||
Schema::create('contacts', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('type');
|
||||
$table->string('name');
|
||||
$table->string('email')->nullable();
|
||||
$table->integer('user_id')->nullable();
|
||||
$table->string('tax_number')->nullable();
|
||||
$table->string('phone')->nullable();
|
||||
$table->text('address')->nullable();
|
||||
$table->string('website')->nullable();
|
||||
$table->string('currency_code', 3);
|
||||
$table->boolean('enabled');
|
||||
$table->string('reference')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id', 'type']);
|
||||
$table->unique(['company_id', 'type', 'email', 'deleted_at']);
|
||||
});
|
||||
|
||||
$rename_bills = [
|
||||
'bill_status_code' => 'status',
|
||||
'vendor_id' => 'contact_id',
|
||||
'vendor_name' => 'contact_name',
|
||||
'vendor_email' => 'contact_email',
|
||||
'vendor_tax_number' => 'contact_tax_number',
|
||||
'vendor_phone' => 'contact_phone',
|
||||
'vendor_address' => 'contact_address',
|
||||
];
|
||||
|
||||
foreach ($rename_bills as $from => $to) {
|
||||
Schema::table('bills', function (Blueprint $table) use ($from, $to) {
|
||||
$table->renameColumn($from, $to);
|
||||
});
|
||||
}
|
||||
|
||||
Schema::table('bill_histories', function (Blueprint $table) {
|
||||
$table->renameColumn('status_code', 'status');
|
||||
});
|
||||
|
||||
Schema::drop('bill_statuses');
|
||||
|
||||
$rename_invoices = [
|
||||
'invoice_status_code' => 'status',
|
||||
'customer_id' => 'contact_id',
|
||||
'customer_name' => 'contact_name',
|
||||
'customer_email' => 'contact_email',
|
||||
'customer_tax_number' => 'contact_tax_number',
|
||||
'customer_phone' => 'contact_phone',
|
||||
'customer_address' => 'contact_address',
|
||||
];
|
||||
|
||||
foreach ($rename_invoices as $from => $to) {
|
||||
Schema::table('invoices', function (Blueprint $table) use ($from, $to) {
|
||||
$table->renameColumn($from, $to);
|
||||
});
|
||||
}
|
||||
|
||||
Schema::table('invoice_histories', function (Blueprint $table) {
|
||||
$table->renameColumn('status_code', 'status');
|
||||
});
|
||||
|
||||
Schema::drop('invoice_statuses');
|
||||
|
||||
// Dashboards
|
||||
Schema::create('dashboards', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('name');
|
||||
$table->boolean('enabled')->default(1);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id']);
|
||||
});
|
||||
|
||||
Schema::create('user_dashboards', function (Blueprint $table) {
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('dashboard_id')->unsigned();
|
||||
$table->string('user_type', 20);
|
||||
|
||||
$table->primary(['user_id', 'dashboard_id', 'user_type']);
|
||||
});
|
||||
|
||||
Schema::create('widgets', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('dashboard_id');
|
||||
$table->string('class');
|
||||
$table->string('name');
|
||||
$table->integer('sort')->default(0);
|
||||
$table->text('settings')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id', 'dashboard_id']);
|
||||
});
|
||||
|
||||
// Email templates
|
||||
Schema::create('email_templates', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('alias');
|
||||
$table->string('class');
|
||||
$table->string('name');
|
||||
$table->string('subject');
|
||||
$table->text('body');
|
||||
$table->text('params')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->unique(['company_id', 'alias', 'deleted_at']);
|
||||
});
|
||||
|
||||
// Firewall
|
||||
Schema::create('firewall_ips', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('ip');
|
||||
$table->integer('log_id')->nullable();
|
||||
$table->boolean('blocked')->default(1);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('ip');
|
||||
$table->unique(['ip', 'deleted_at']);
|
||||
});
|
||||
|
||||
Schema::create('firewall_logs', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('ip');
|
||||
$table->string('level')->default('medium');
|
||||
$table->string('middleware');
|
||||
$table->integer('user_id')->nullable();
|
||||
$table->string('url')->nullable();
|
||||
$table->string('referrer')->nullable();
|
||||
$table->text('request')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('ip');
|
||||
});
|
||||
|
||||
// Reports
|
||||
Schema::create('reports', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('class');
|
||||
$table->string('name');
|
||||
$table->text('description');
|
||||
$table->text('settings')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
// Transactions
|
||||
Schema::create('transactions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('type');
|
||||
$table->dateTime('paid_at');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->string('currency_code', 3);
|
||||
$table->double('currency_rate', 15, 8);
|
||||
$table->integer('account_id');
|
||||
$table->integer('document_id')->nullable();
|
||||
$table->integer('contact_id')->nullable();
|
||||
$table->integer('category_id')->default(1);
|
||||
$table->text('description')->nullable();
|
||||
$table->string('payment_method');
|
||||
$table->string('reference')->nullable();
|
||||
$table->integer('parent_id')->default(0);
|
||||
$table->boolean('reconciled')->default(0);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id', 'type']);
|
||||
});
|
||||
|
||||
Schema::table('transfers', function (Blueprint $table) {
|
||||
$table->renameColumn('payment_id', 'expense_transaction_id');
|
||||
});
|
||||
|
||||
Schema::table('transfers', function (Blueprint $table) {
|
||||
$table->renameColumn('revenue_id', 'income_transaction_id');
|
||||
});
|
||||
|
||||
// Domain column
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->string('domain')->nullable()->change();
|
||||
});
|
||||
|
||||
// Status column
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
$table->renameColumn('status', 'enabled');
|
||||
});
|
||||
|
||||
// Sku and quantity columns
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->string('sku')->nullable()->change();
|
||||
$table->integer('quantity')->default(1)->change();
|
||||
|
||||
$connection = Schema::getConnection();
|
||||
$d_table = $connection->getDoctrineSchemaManager()->listTableDetails($connection->getTablePrefix() . 'items');
|
||||
|
||||
if ($d_table->hasIndex('items_company_id_sku_deleted_at_unique')) {
|
||||
// 1.3 update
|
||||
$table->dropUnique('items_company_id_sku_deleted_at_unique');
|
||||
} else {
|
||||
// 2.0 install
|
||||
$table->dropUnique(['company_id', 'sku', 'deleted_at']);
|
||||
}
|
||||
});
|
||||
|
||||
// Landing page column
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('landing_page', 70)->nullable()->default('dashboard')->after('locale');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->dropColumn('footer');
|
||||
});
|
||||
|
||||
Schema::drop('contacts');
|
||||
Schema::drop('dashboards');
|
||||
Schema::drop('user_dashboards');
|
||||
Schema::drop('widgets');
|
||||
Schema::drop('email_templates');
|
||||
Schema::drop('firewall_ips');
|
||||
Schema::drop('firewall_logs');
|
||||
Schema::drop('reports');
|
||||
Schema::drop('transactions');
|
||||
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->string('domain')->change();
|
||||
});
|
||||
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
$table->renameColumn('enabled', 'status');
|
||||
});
|
||||
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->string('sku')->change();
|
||||
$table->integer('quantity')->change();
|
||||
$table->unique(['company_id', 'sku', 'deleted_at']);
|
||||
});
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV208 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('invoice_items', function (Blueprint $table) {
|
||||
$table->double('discount_rate', 15, 4)->default('0.0000')->after('tax');
|
||||
$table->string('discount_type')->default('normal')->after('discount_rate');
|
||||
});
|
||||
|
||||
Schema::table('bill_items', function (Blueprint $table) {
|
||||
$table->double('discount_rate', 15, 4)->default('0.0000')->after('tax');
|
||||
$table->string('discount_type')->default('normal')->after('discount_rate');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('invoice_items', function (Blueprint $table) {
|
||||
$table->dropColumn(['discount_rate', 'discount_type']);
|
||||
});
|
||||
|
||||
Schema::table('bill_items', function (Blueprint $table) {
|
||||
$table->dropColumn(['discount_rate', 'discount_type']);
|
||||
});
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV2014 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$doc_types = ['invoice', 'bill'];
|
||||
$doc_tables = ['histories', 'items', 'item_taxes', 'totals'];
|
||||
|
||||
foreach ($doc_types as $doc_type) {
|
||||
foreach ($doc_tables as $doc_table) {
|
||||
Schema::table($doc_type . '_' . $doc_table, function (Blueprint $table) use ($doc_type) {
|
||||
$table->index($doc_type . '_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Schema::table('transactions', function (Blueprint $table) {
|
||||
$table->index('account_id');
|
||||
$table->index('category_id');
|
||||
$table->index('contact_id');
|
||||
$table->index('document_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV2017 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('module_histories', function (Blueprint $table) {
|
||||
$table->dropColumn('category');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -1,154 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV210 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('failed_jobs', function (Blueprint $table) {
|
||||
$table->string('uuid')->after('id')->nullable()->unique();
|
||||
});
|
||||
|
||||
Schema::create('documents', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('company_id');
|
||||
$table->string('type');
|
||||
$table->string('document_number');
|
||||
$table->string('order_number')->nullable();
|
||||
$table->string('status');
|
||||
$table->dateTime('issued_at');
|
||||
$table->dateTime('due_at');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->string('currency_code');
|
||||
$table->double('currency_rate', 15, 8);
|
||||
$table->unsignedInteger('category_id')->default(1);
|
||||
$table->unsignedInteger('contact_id');
|
||||
$table->string('contact_name');
|
||||
$table->string('contact_email')->nullable();
|
||||
$table->string('contact_tax_number')->nullable();
|
||||
$table->string('contact_phone')->nullable();
|
||||
$table->text('contact_address')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->text('footer')->nullable();
|
||||
$table->unsignedInteger('parent_id')->default(0);
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->index('type');
|
||||
$table->unique(['document_number', 'deleted_at', 'company_id', 'type']);
|
||||
});
|
||||
|
||||
Schema::create('document_histories', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->string('type');
|
||||
$table->unsignedInteger('document_id');
|
||||
$table->string('status');
|
||||
$table->boolean('notify');
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->index('type');
|
||||
$table->index('document_id');
|
||||
});
|
||||
|
||||
Schema::create('document_items', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('company_id');
|
||||
$table->string('type');
|
||||
$table->unsignedInteger('document_id');
|
||||
$table->unsignedInteger('item_id')->nullable();
|
||||
$table->string('name');
|
||||
$table->text('description')->nullable();
|
||||
$table->string('sku')->nullable();
|
||||
$table->double('quantity', 7, 2);
|
||||
$table->double('price', 15, 4);
|
||||
$table->float('tax', 15, 4)->default('0.0000');
|
||||
$table->string('discount_type')->default('normal');
|
||||
$table->double('discount_rate', 15, 4)->default('0.0000');
|
||||
$table->double('total', 15, 4);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->index('type');
|
||||
$table->index('document_id');
|
||||
});
|
||||
|
||||
Schema::create('document_item_taxes', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('company_id');
|
||||
$table->string('type');
|
||||
$table->unsignedInteger('document_id');
|
||||
$table->unsignedInteger('document_item_id');
|
||||
$table->unsignedInteger('tax_id');
|
||||
$table->string('name');
|
||||
$table->double('amount', 15, 4)->default('0.0000');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->index('type');
|
||||
$table->index('document_id');
|
||||
});
|
||||
|
||||
Schema::create('document_totals', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('company_id');
|
||||
$table->string('type');
|
||||
$table->unsignedInteger('document_id');
|
||||
$table->string('code')->nullable();
|
||||
$table->string('name');
|
||||
$table->double('amount', 15, 4);
|
||||
$table->integer('sort_order');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('company_id');
|
||||
$table->index('type');
|
||||
$table->index('document_id');
|
||||
});
|
||||
|
||||
Schema::create('item_taxes', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('company_id');
|
||||
$table->integer('item_id');
|
||||
$table->integer('tax_id')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['company_id', 'item_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('failed_jobs', function (Blueprint $table) {
|
||||
$table->dropColumn('uuid');
|
||||
});
|
||||
|
||||
Schema::drop('documents');
|
||||
Schema::drop('document_histories');
|
||||
Schema::drop('document_items');
|
||||
Schema::drop('document_item_taxes');
|
||||
Schema::drop('document_totals');
|
||||
Schema::drop('item_taxes');
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV219 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('reports', function (Blueprint $table) {
|
||||
$table->index('class');
|
||||
});
|
||||
|
||||
Schema::table('widgets', function (Blueprint $table) {
|
||||
$table->index('class');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV2114 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('media', function (Blueprint $table) {
|
||||
$table->unsignedInteger('company_id')->default(0)->after('id');
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
|
||||
Schema::table('mediables', function (Blueprint $table) {
|
||||
$table->unsignedInteger('company_id')->default(0)->after('media_id');
|
||||
|
||||
$table->index('company_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('media', function (Blueprint $table) {
|
||||
$table->dropColumn('company_id');
|
||||
});
|
||||
|
||||
Schema::table('mediables', function (Blueprint $table) {
|
||||
$table->dropColumn('company_id');
|
||||
});
|
||||
}
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV2117 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('accounts', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('categories', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('contacts', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('reference');
|
||||
});
|
||||
|
||||
Schema::table('currencies', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('dashboards', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('documents', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('parent_id');
|
||||
});
|
||||
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('reconciliations', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('reconciled');
|
||||
});
|
||||
|
||||
Schema::table('reports', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('settings');
|
||||
});
|
||||
|
||||
Schema::table('taxes', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('transactions', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('parent_id');
|
||||
});
|
||||
|
||||
Schema::table('transfers', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('income_transaction_id');
|
||||
});
|
||||
|
||||
Schema::table('widgets', function (Blueprint $table) {
|
||||
$table->unsignedInteger('created_by')->nullable()->after('settings');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -1,154 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV2124 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('contacts', function (Blueprint $table) {
|
||||
$table->string('country')->nullable()->after('address');
|
||||
$table->string('state')->nullable()->after('address');
|
||||
$table->string('zip_code')->nullable()->after('address');
|
||||
$table->string('city')->nullable()->after('address');
|
||||
});
|
||||
|
||||
Schema::table('accounts', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('categories', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('contacts', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('reference');
|
||||
});
|
||||
|
||||
Schema::table('currencies', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('dashboards', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('documents', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('parent_id');
|
||||
});
|
||||
|
||||
Schema::table('document_histories', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('description');
|
||||
$table->string('created_from', 30)->nullable()->after('description');
|
||||
});
|
||||
|
||||
Schema::table('document_items', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('total');
|
||||
$table->string('created_from', 30)->nullable()->after('total');
|
||||
});
|
||||
|
||||
Schema::table('document_item_taxes', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('amount');
|
||||
$table->string('created_from', 30)->nullable()->after('amount');
|
||||
});
|
||||
|
||||
Schema::table('document_totals', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('sort_order');
|
||||
$table->string('created_from', 30)->nullable()->after('sort_order');
|
||||
});
|
||||
|
||||
Schema::table('email_templates', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('params');
|
||||
$table->string('created_from', 30)->nullable()->after('params');
|
||||
});
|
||||
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('item_taxes', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('tax_id');
|
||||
$table->string('created_from', 30)->nullable()->after('tax_id');
|
||||
});
|
||||
|
||||
Schema::table('media', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('original_media_id');
|
||||
$table->string('created_from', 30)->nullable()->after('original_media_id');
|
||||
});
|
||||
|
||||
Schema::table('mediables', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('order');
|
||||
$table->string('created_from', 30)->nullable()->after('order');
|
||||
});
|
||||
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('enabled');
|
||||
$table->string('created_from', 30)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('module_histories', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('description');
|
||||
$table->string('created_from', 30)->nullable()->after('description');
|
||||
});
|
||||
|
||||
Schema::table('reconciliations', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('reconciled');
|
||||
});
|
||||
|
||||
Schema::table('recurring', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('count');
|
||||
$table->string('created_from', 30)->nullable()->after('count');
|
||||
});
|
||||
|
||||
Schema::table('reports', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('settings');
|
||||
});
|
||||
|
||||
Schema::table('roles', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('description');
|
||||
$table->string('created_from', 30)->nullable()->after('description');
|
||||
});
|
||||
|
||||
Schema::table('taxes', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('transactions', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('parent_id');
|
||||
});
|
||||
|
||||
Schema::table('transfers', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('income_transaction_id');
|
||||
});
|
||||
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('created_by', 30)->nullable()->after('enabled');
|
||||
$table->string('created_from', 30)->nullable()->after('enabled');
|
||||
});
|
||||
|
||||
Schema::table('widgets', function (Blueprint $table) {
|
||||
$table->string('created_from', 30)->nullable()->after('settings');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -1,134 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV2125 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('accounts', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('categories', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('contacts', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('currencies', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('dashboards', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('documents', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('document_histories', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('document_items', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('document_item_taxes', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('document_totals', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('email_templates', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('items', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('item_taxes', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('media', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('mediables', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('module_histories', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('reconciliations', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('recurring', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('reports', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('roles', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('taxes', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('transactions', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('transfers', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
|
||||
Schema::table('widgets', function (Blueprint $table) {
|
||||
$table->string('created_from', 100)->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV2126 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('contacts', function (Blueprint $table) {
|
||||
$table->boolean('enabled')->default(1)->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CoreV2127 extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('documents', function (Blueprint $table) {
|
||||
$table->string('contact_country')->nullable()->after('contact_address');
|
||||
$table->string('contact_state')->nullable()->after('contact_address');
|
||||
$table->string('contact_zip_code')->nullable()->after('contact_address');
|
||||
$table->string('contact_city')->nullable()->after('contact_address');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
Schema::table('user_companies', function (Blueprint $table) {
|
||||
$table->dropPrimary(['user_id', 'company_id', 'user_type']);
|
||||
$table->primary(['user_id', 'company_id']);
|
||||
});
|
||||
|
||||
Schema::table('user_companies', function (Blueprint $table) {
|
||||
$table->dropColumn('user_type');
|
||||
});
|
||||
|
||||
Schema::table('user_dashboards', function (Blueprint $table) {
|
||||
$table->dropPrimary(['user_id', 'dashboard_id', 'user_type']);
|
||||
$table->primary(['user_id', 'dashboard_id']);
|
||||
});
|
||||
|
||||
Schema::table('user_dashboards', function (Blueprint $table) {
|
||||
$table->dropColumn('user_type');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('contacts', function (Blueprint $table) {
|
||||
$table->string('currency_code')->change();
|
||||
});
|
||||
|
||||
Schema::table('transactions', function (Blueprint $table) {
|
||||
$table->string('currency_code')->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
105
database/migrations/2022_05_10_000000_core_v300.php
Normal file
105
database/migrations/2022_05_10_000000_core_v300.php
Normal file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
use App\Traits\Database;
|
||||
use Doctrine\DBAL\Types\FloatType;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
use Database;
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (! Type::hasType('double')) {
|
||||
Type::addType('double', FloatType::class);
|
||||
}
|
||||
|
||||
Schema::table('transactions', function (Blueprint $table) {
|
||||
$table->unsignedInteger('split_id')->nullable()->after('parent_id');
|
||||
|
||||
$table->foreign('split_id')->references('id')->on('transactions');
|
||||
});
|
||||
|
||||
Schema::table('categories', function (Blueprint $table) {
|
||||
$table->unsignedInteger('parent_id')->nullable()->after('enabled');
|
||||
|
||||
$table->foreign('parent_id')->references('id')->on('categories');
|
||||
});
|
||||
|
||||
Schema::table('items', function(Blueprint $table) {
|
||||
$table->dropColumn('tax_id');
|
||||
});
|
||||
|
||||
Schema::table('items', function(Blueprint $table) {
|
||||
$table->dropColumn('quantity');
|
||||
});
|
||||
|
||||
Schema::table('items', function(Blueprint $table) {
|
||||
$table->string('type')->default('product')->after('company_id');
|
||||
$table->double('sale_price', 15, 4)->nullable()->change();
|
||||
$table->double('purchase_price', 15, 4)->nullable()->change();
|
||||
});
|
||||
|
||||
Schema::table('recurring', function(Blueprint $table) {
|
||||
$table->renameColumn('count', 'limit_count')->nullable();
|
||||
});
|
||||
|
||||
Schema::table('recurring', function (Blueprint $table) {
|
||||
$table->string('status')->default('active')->after('started_at');
|
||||
$table->string('limit_by')->default('count')->after('status');
|
||||
$table->dateTime('limit_date')->nullable()->after('limit_count');
|
||||
$table->boolean('auto_send')->default(1)->after('limit_date');
|
||||
});
|
||||
|
||||
Schema::table('transactions', function (Blueprint $table) {
|
||||
$number = $table->string('number')->after('type');
|
||||
|
||||
if ($this->databaseDriverIs('sqlite')) {
|
||||
$number->nullable();
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('accounts', function(Blueprint $table) {
|
||||
$table->string('type')->default('bank')->after('company_id');
|
||||
});
|
||||
|
||||
if (! Schema::hasTable('personal_access_tokens')) {
|
||||
Schema::create('personal_access_tokens', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('tokenable');
|
||||
$table->string('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
Schema::create('user_invitations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('company_id')->unsigned();
|
||||
$table->string('token');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
@ -42,39 +42,6 @@ class Currencies extends Seeder
|
||||
'decimal_mark' => config('money.USD.decimal_mark'),
|
||||
'thousands_separator' => config('money.USD.thousands_separator'),
|
||||
],
|
||||
[
|
||||
'company_id' => $company_id,
|
||||
'name' => trans('demo.currencies.eur'),
|
||||
'code' => 'EUR',
|
||||
'rate' => '1.25',
|
||||
'precision' => config('money.EUR.precision'),
|
||||
'symbol' => config('money.EUR.symbol'),
|
||||
'symbol_first' => config('money.EUR.symbol_first'),
|
||||
'decimal_mark' => config('money.EUR.decimal_mark'),
|
||||
'thousands_separator' => config('money.EUR.thousands_separator'),
|
||||
],
|
||||
[
|
||||
'company_id' => $company_id,
|
||||
'name' => trans('demo.currencies.gbp'),
|
||||
'code' => 'GBP',
|
||||
'rate' => '1.60',
|
||||
'precision' => config('money.GBP.precision'),
|
||||
'symbol' => config('money.GBP.symbol'),
|
||||
'symbol_first' => config('money.GBP.symbol_first'),
|
||||
'decimal_mark' => config('money.GBP.decimal_mark'),
|
||||
'thousands_separator' => config('money.GBP.thousands_separator'),
|
||||
],
|
||||
[
|
||||
'company_id' => $company_id,
|
||||
'name' => trans('demo.currencies.try'),
|
||||
'code' => 'TRY',
|
||||
'rate' => '0.80',
|
||||
'precision' => config('money.TRY.precision'),
|
||||
'symbol' => config('money.TRY.symbol'),
|
||||
'symbol_first' => config('money.TRY.symbol_first'),
|
||||
'decimal_mark' => config('money.TRY.decimal_mark'),
|
||||
'thousands_separator' => config('money.TRY.thousands_separator'),
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($rows as $row) {
|
||||
|
@ -34,15 +34,13 @@ class Dashboards extends Seeder
|
||||
'company_id' => $company_id,
|
||||
'name' => trans_choice('general.dashboards', 1),
|
||||
'custom_widgets' => [
|
||||
'App\Widgets\TotalIncome',
|
||||
'App\Widgets\TotalExpenses',
|
||||
'App\Widgets\TotalProfit',
|
||||
'App\Widgets\Receivables',
|
||||
'App\Widgets\Payables',
|
||||
'App\Widgets\CashFlow',
|
||||
'App\Widgets\IncomeByCategory',
|
||||
'App\Widgets\ProfitLoss',
|
||||
'App\Widgets\ExpensesByCategory',
|
||||
'App\Widgets\AccountBalance',
|
||||
'App\Widgets\LatestIncome',
|
||||
'App\Widgets\LatestExpenses',
|
||||
'App\Widgets\BankFeeds',
|
||||
],
|
||||
'users' => $user_id,
|
||||
'created_from' => 'core::seed',
|
||||
|
@ -55,6 +55,11 @@ class EmailTemplates extends Seeder
|
||||
'class' => 'App\Notifications\Sale\Invoice',
|
||||
'name' => 'settings.email.templates.invoice_recur_admin',
|
||||
],
|
||||
[
|
||||
'alias' => 'invoice_view_admin',
|
||||
'class' => 'App\Notifications\Sale\Invoice',
|
||||
'name' => 'settings.email.templates.invoice_view_admin',
|
||||
],
|
||||
[
|
||||
'alias' => 'invoice_payment_customer',
|
||||
'class' => 'App\Notifications\Portal\PaymentReceived',
|
||||
@ -76,9 +81,14 @@ class EmailTemplates extends Seeder
|
||||
'name' => 'settings.email.templates.bill_recur_admin',
|
||||
],
|
||||
[
|
||||
'alias' => 'revenue_new_customer',
|
||||
'class' => 'App\Notifications\Sale\Revenue',
|
||||
'name' => 'settings.email.templates.revenue_new_customer',
|
||||
'alias' => 'payment_received_customer',
|
||||
'class' => 'App\Notifications\Banking\Transaction',
|
||||
'name' => 'settings.email.templates.payment_received_customer',
|
||||
],
|
||||
[
|
||||
'alias' => 'payment_made_vendor',
|
||||
'class' => 'App\Notifications\Banking\Transaction',
|
||||
'name' => 'settings.email.templates.payment_made_vendor',
|
||||
],
|
||||
];
|
||||
|
||||
|
@ -29,9 +29,7 @@ class Permissions extends Seeder
|
||||
'admin' => [
|
||||
'admin-panel' => 'r',
|
||||
'api' => 'r',
|
||||
'auth-permissions' => 'c,r,u,d',
|
||||
'auth-profile' => 'r,u',
|
||||
'auth-roles' => 'c,r,u,d',
|
||||
'auth-users' => 'c,r,u,d',
|
||||
'banking-accounts' => 'c,r,u,d',
|
||||
'banking-reconciliations' => 'c,r,u,d',
|
||||
@ -41,17 +39,14 @@ class Permissions extends Seeder
|
||||
'common-dashboards' => 'c,r,u,d',
|
||||
'common-import' => 'c',
|
||||
'common-items' => 'c,r,u,d',
|
||||
'common-notifications' => 'c,r,u,d',
|
||||
'common-reports' => 'c,r,u,d',
|
||||
'common-search' => 'r',
|
||||
'common-uploads' => 'r,d',
|
||||
'common-widgets' => 'c,r,u,d',
|
||||
'purchases-bills' => 'c,r,u,d',
|
||||
'purchases-payments' => 'c,r,u,d',
|
||||
'purchases-vendors' => 'c,r,u,d',
|
||||
'sales-customers' => 'c,r,u,d',
|
||||
'sales-invoices' => 'c,r,u,d',
|
||||
'sales-revenues' => 'c,r,u,d',
|
||||
'install-updates' => 'r,u',
|
||||
'modules-api-key' => 'c,u',
|
||||
'modules-home' => 'r',
|
||||
@ -65,26 +60,24 @@ class Permissions extends Seeder
|
||||
'reports-profit-loss' => 'r',
|
||||
'reports-tax-summary' => 'r',
|
||||
'settings-categories' => 'c,r,u,d',
|
||||
'settings-company' => 'r',
|
||||
'settings-company' => 'r,u',
|
||||
'settings-currencies' => 'c,r,u,d',
|
||||
'settings-defaults' => 'r',
|
||||
'settings-email' => 'r',
|
||||
'settings-invoice' => 'r',
|
||||
'settings-localisation' => 'r',
|
||||
'settings-defaults' => 'r,u',
|
||||
'settings-email' => 'r,u',
|
||||
'settings-email-templates' => 'r,u',
|
||||
'settings-invoice' => 'r,u',
|
||||
'settings-localisation' => 'r,u',
|
||||
'settings-modules' => 'r,u',
|
||||
'settings-settings' => 'r,u',
|
||||
'settings-schedule' => 'r',
|
||||
'settings-schedule' => 'r,u',
|
||||
'settings-taxes' => 'c,r,u,d',
|
||||
'widgets-account-balance' => 'r',
|
||||
'widgets-bank-feeds' => 'r',
|
||||
'widgets-cash-flow' => 'r',
|
||||
'widgets-expenses-by-category' => 'r',
|
||||
'widgets-income-by-category' => 'r',
|
||||
'widgets-latest-expenses' => 'r',
|
||||
'widgets-latest-income' => 'r',
|
||||
'widgets-total-expenses' => 'r',
|
||||
'widgets-total-income' => 'r',
|
||||
'widgets-total-profit' => 'r',
|
||||
'widgets-currencies' => 'r',
|
||||
'widgets-expenses-by-category' => 'r',
|
||||
'widgets-payables' => 'r',
|
||||
'widgets-profit-loss' => 'r',
|
||||
'widgets-receivables' => 'r',
|
||||
],
|
||||
'manager' => [
|
||||
'admin-panel' => 'r',
|
||||
@ -97,17 +90,14 @@ class Permissions extends Seeder
|
||||
'common-dashboards' => 'c,r,u,d',
|
||||
'common-import' => 'c',
|
||||
'common-items' => 'c,r,u,d',
|
||||
'common-notifications' => 'c,r,u,d',
|
||||
'common-reports' => 'c,r,u,d',
|
||||
'common-search' => 'r',
|
||||
'common-uploads' => 'r',
|
||||
'common-widgets' => 'c,r,u,d',
|
||||
'purchases-bills' => 'c,r,u,d',
|
||||
'purchases-payments' => 'c,r,u,d',
|
||||
'purchases-vendors' => 'c,r,u,d',
|
||||
'sales-customers' => 'c,r,u,d',
|
||||
'sales-invoices' => 'c,r,u,d',
|
||||
'sales-revenues' => 'c,r,u,d',
|
||||
'install-updates' => 'r,u',
|
||||
'notifications' => 'r,u',
|
||||
'reports-expense-summary' => 'r',
|
||||
@ -116,33 +106,54 @@ class Permissions extends Seeder
|
||||
'reports-profit-loss' => 'r',
|
||||
'reports-tax-summary' => 'r',
|
||||
'settings-categories' => 'c,r,u,d',
|
||||
'settings-company' => 'r',
|
||||
'settings-company' => 'r,u',
|
||||
'settings-currencies' => 'c,r,u,d',
|
||||
'settings-defaults' => 'r',
|
||||
'settings-email' => 'r',
|
||||
'settings-invoice' => 'r',
|
||||
'settings-localisation' => 'r',
|
||||
'settings-defaults' => 'r,u',
|
||||
'settings-email' => 'r,u',
|
||||
'settings-email-templates' => 'r,u',
|
||||
'settings-invoice' => 'r,u',
|
||||
'settings-localisation' => 'r,u',
|
||||
'settings-modules' => 'r,u',
|
||||
'settings-settings' => 'r,u',
|
||||
'settings-schedule' => 'r',
|
||||
'settings-schedule' => 'r,u',
|
||||
'settings-taxes' => 'c,r,u,d',
|
||||
'widgets-account-balance' => 'r',
|
||||
'widgets-bank-feeds' => 'r',
|
||||
'widgets-cash-flow' => 'r',
|
||||
'widgets-expenses-by-category' => 'r',
|
||||
'widgets-income-by-category' => 'r',
|
||||
'widgets-latest-expenses' => 'r',
|
||||
'widgets-latest-income' => 'r',
|
||||
'widgets-total-expenses' => 'r',
|
||||
'widgets-total-income' => 'r',
|
||||
'widgets-total-profit' => 'r',
|
||||
'widgets-currencies' => 'r',
|
||||
'widgets-expenses-by-category' => 'r',
|
||||
'widgets-payables' => 'r',
|
||||
'widgets-profit-loss' => 'r',
|
||||
'widgets-receivables' => 'r',
|
||||
],
|
||||
'customer' => [
|
||||
'client-portal' => 'r',
|
||||
'portal-invoices' => 'r,u',
|
||||
'portal-payments' => 'r,u',
|
||||
'portal-profile' => 'r,u',
|
||||
]
|
||||
],
|
||||
'accountant' => [
|
||||
'admin-panel' => 'r',
|
||||
'api' => 'r',
|
||||
'common-dashboards' => 'r',
|
||||
'common-items' => 'r',
|
||||
'purchases-bills' => 'r',
|
||||
'purchases-vendors' => 'r',
|
||||
'sales-customers' => 'r',
|
||||
'sales-invoices' => 'r',
|
||||
'banking-accounts' => 'r',
|
||||
'banking-reconciliations' => 'r',
|
||||
'banking-transactions' => 'r',
|
||||
'banking-transfers' => 'r',
|
||||
'reports-expense-summary' => 'r',
|
||||
'reports-income-summary' => 'r',
|
||||
'reports-income-expense-summary' => 'r',
|
||||
'reports-profit-loss' => 'r',
|
||||
'reports-tax-summary' => 'r',
|
||||
'modules-home' => 'r',
|
||||
'modules-item' => 'r',
|
||||
'modules-my' => 'r',
|
||||
'modules-tiles' => 'r',
|
||||
],
|
||||
];
|
||||
|
||||
$this->attachPermissionsByRoleNames($rows);
|
||||
|
@ -33,23 +33,23 @@ class Reports extends Seeder
|
||||
[
|
||||
'company_id' => $company_id,
|
||||
'class' => 'App\Reports\IncomeSummary',
|
||||
'name' => trans('reports.summary.income'),
|
||||
'name' => trans('reports.income_summary'),
|
||||
'description' => trans('demo.reports.income'),
|
||||
'settings' => ['group' => 'category', 'period' => 'monthly', 'basis' => 'accrual', 'chart' => 'line'],
|
||||
'settings' => ['group' => 'category', 'period' => 'monthly', 'basis' => 'accrual'],
|
||||
],
|
||||
[
|
||||
'company_id' => $company_id,
|
||||
'class' => 'App\Reports\ExpenseSummary',
|
||||
'name' => trans('reports.summary.expense'),
|
||||
'name' => trans('reports.expense_summary'),
|
||||
'description' => trans('demo.reports.expense'),
|
||||
'settings' => ['group' => 'category', 'period' => 'monthly', 'basis' => 'accrual', 'chart' => 'line'],
|
||||
'settings' => ['group' => 'category', 'period' => 'monthly', 'basis' => 'accrual'],
|
||||
],
|
||||
[
|
||||
'company_id' => $company_id,
|
||||
'class' => 'App\Reports\IncomeExpenseSummary',
|
||||
'name' => trans('reports.summary.income_expense'),
|
||||
'name' => trans('reports.income_expense_summary'),
|
||||
'description' => trans('demo.reports.income_expense'),
|
||||
'settings' => ['group' => 'category', 'period' => 'monthly', 'basis' => 'accrual', 'chart' => 'line'],
|
||||
'settings' => ['group' => 'category', 'period' => 'monthly', 'basis' => 'accrual'],
|
||||
],
|
||||
[
|
||||
'company_id' => $company_id,
|
||||
@ -61,7 +61,7 @@ class Reports extends Seeder
|
||||
[
|
||||
'company_id' => $company_id,
|
||||
'class' => 'App\Reports\TaxSummary',
|
||||
'name' => trans('reports.summary.tax'),
|
||||
'name' => trans('reports.tax_summary'),
|
||||
'description' => trans('demo.reports.tax'),
|
||||
'settings' => ['period' => 'quarterly', 'basis' => 'accrual'],
|
||||
],
|
||||
|
16
database/seeds/SampleData.php
Executable file → Normal file
16
database/seeds/SampleData.php
Executable file → Normal file
@ -27,6 +27,8 @@ class SampleData extends Seeder
|
||||
$count = (int) $this->command->option('count');
|
||||
$small_count = ($count <= 10) ? $count : 10;
|
||||
|
||||
$company = (int) $this->command->option('company');
|
||||
|
||||
$this->command->info('Creating sample data...');
|
||||
|
||||
$bar = $this->command->getOutput()->createProgressBar(7);
|
||||
@ -34,25 +36,25 @@ class SampleData extends Seeder
|
||||
|
||||
$bar->start();
|
||||
|
||||
Contact::factory()->count($count)->create();
|
||||
Contact::factory()->company($company)->count($count)->create();
|
||||
$bar->advance();
|
||||
|
||||
Category::factory()->count($count)->create();
|
||||
Category::factory()->company($company)->count($count)->create();
|
||||
$bar->advance();
|
||||
|
||||
Tax::factory()->count($small_count)->enabled()->create();
|
||||
Tax::factory()->company($company)->count($small_count)->enabled()->create();
|
||||
$bar->advance();
|
||||
|
||||
Item::factory()->count($count)->create();
|
||||
Item::factory()->company($company)->count($count)->create();
|
||||
$bar->advance();
|
||||
|
||||
Account::factory()->count($small_count)->create();
|
||||
Account::factory()->company($company)->count($small_count)->create();
|
||||
$bar->advance();
|
||||
|
||||
Document::factory()->bill()->count($count)->create();
|
||||
Document::factory()->company($company)->bill()->count($count)->create();
|
||||
$bar->advance();
|
||||
|
||||
Document::factory()->invoice()->count($count)->create();
|
||||
Document::factory()->company($company)->invoice()->count($count)->create();
|
||||
$bar->advance();
|
||||
|
||||
$bar->finish();
|
||||
|
@ -57,6 +57,9 @@ class TestCompany extends Seeder
|
||||
|
||||
$company->makeCurrent(true);
|
||||
|
||||
setting()->set('email.protocol', 'log');
|
||||
config(['mail.default' => setting('email.protocol')]);
|
||||
|
||||
$this->command->info('Test company created.');
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user