laravel 8
This commit is contained in:
parent
b4e044b199
commit
1ba8835a2d
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
php: ['7.2', '7.3', '7.4']
|
||||
php: ['7.3', '7.4']
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
|
@ -16,7 +16,7 @@ Akaunting is a free, open source and online accounting software designed for sma
|
||||
|
||||
## Requirements
|
||||
|
||||
* PHP 7.2.5 or higher
|
||||
* PHP 7.3 or higher
|
||||
* Database (eg: MySQL, PostgreSQL, SQLite)
|
||||
* Web Server (eg: Apache, Nginx, IIS)
|
||||
* [Other libraries](https://akaunting.com/docs/requirements)
|
||||
|
26
app/Abstracts/Factory.php
Normal file
26
app/Abstracts/Factory.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Abstracts;
|
||||
|
||||
use App\Models\Auth\User;
|
||||
use App\Traits\Jobs;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory as BaseFactory;
|
||||
|
||||
abstract class Factory extends BaseFactory
|
||||
{
|
||||
use Jobs;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->user = User::first();
|
||||
$this->company = $this->user->companies()->first();
|
||||
|
||||
session(['company_id' => $this->company->id]);
|
||||
setting()->setExtraColumns(['company_id' => $this->company->id]);
|
||||
}
|
||||
|
||||
public function getCompanyUsers()
|
||||
{
|
||||
return $this->company->users()->enabled()->get()->pluck('id')->toArray();
|
||||
}
|
||||
}
|
@ -16,7 +16,6 @@ class $NAME$ extends Provider
|
||||
$this->loadViews();
|
||||
$this->loadTranslations();
|
||||
$this->loadMigrations();
|
||||
$this->loadFactories();
|
||||
//$this->loadConfig();
|
||||
}
|
||||
|
||||
@ -60,20 +59,6 @@ class $NAME$ extends Provider
|
||||
$this->loadMigrationsFrom(__DIR__ . '/../$MIGRATIONS_PATH$');
|
||||
}
|
||||
|
||||
/**
|
||||
* Load factories.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadFactories()
|
||||
{
|
||||
if (app()->environment('production') || !app()->runningInConsole()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->loadFactoriesFrom(__DIR__ . '/../$FACTORIES_PATH$');
|
||||
}
|
||||
|
||||
/**
|
||||
* Load config.
|
||||
*
|
||||
|
@ -12,7 +12,7 @@ use Throwable;
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of the exception types that should not be reported.
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
@ -14,7 +14,9 @@ class Kernel extends HttpKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Fruitcake\Cors\HandleCors::class,
|
||||
\MisterPhilip\MaintenanceMode\Http\Middleware\CheckForMaintenanceMode::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
@ -51,7 +53,7 @@ class Kernel extends HttpKernel
|
||||
'api' => [
|
||||
'api.auth',
|
||||
'auth.disabled',
|
||||
'throttle:60,1',
|
||||
'throttle:api',
|
||||
'permission:read-api',
|
||||
'api.company',
|
||||
'bindings',
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
@ -11,19 +12,23 @@ class RedirectIfAuthenticated
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $guard
|
||||
* @param string|null ...$guards
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
public function handle(Request $request, Closure $next, ...$guards)
|
||||
{
|
||||
if (auth()->guard($guard)->check()) {
|
||||
$user = user();
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
if ($user->contact) {
|
||||
return redirect()->route('portal.dashboard');
|
||||
foreach ($guards as $guard) {
|
||||
if (auth()->guard($guard)->check()) {
|
||||
$user = user();
|
||||
|
||||
if ($user->contact) {
|
||||
return redirect()->route('portal.dashboard');
|
||||
}
|
||||
|
||||
return redirect()->route($user->landing_page);
|
||||
}
|
||||
|
||||
return redirect()->route($user->landing_page);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
20
app/Http/Middleware/TrustHosts.php
Normal file
20
app/Http/Middleware/TrustHosts.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||
|
||||
class TrustHosts extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the host patterns that should be trusted.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function hosts()
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
];
|
||||
}
|
||||
}
|
@ -53,7 +53,7 @@ class AddAdminItems
|
||||
}
|
||||
|
||||
// Sales
|
||||
if ($user->can(['read-sales-invoices', 'read-sales-revenues', 'read-sales-customers'])) {
|
||||
if ($user->canAny(['read-sales-invoices', 'read-sales-revenues', 'read-sales-customers'])) {
|
||||
$menu->dropdown(trim(trans_choice('general.sales', 2)), function ($sub) use ($user, $attr) {
|
||||
if ($user->can('read-sales-invoices')) {
|
||||
$sub->route('invoices.index', trans_choice('general.invoices', 2), [], 10, $attr);
|
||||
@ -73,7 +73,7 @@ class AddAdminItems
|
||||
}
|
||||
|
||||
// Purchases
|
||||
if ($user->can(['read-purchases-bills', 'read-purchases-payments', 'read-purchases-vendors'])) {
|
||||
if ($user->canAny(['read-purchases-bills', 'read-purchases-payments', 'read-purchases-vendors'])) {
|
||||
$menu->dropdown(trim(trans_choice('general.purchases', 2)), function ($sub) use ($user, $attr) {
|
||||
if ($user->can('read-purchases-bills')) {
|
||||
$sub->route('bills.index', trans_choice('general.bills', 2), [], 10, $attr);
|
||||
@ -93,7 +93,7 @@ class AddAdminItems
|
||||
}
|
||||
|
||||
// Banking
|
||||
if ($user->can(['read-banking-accounts', 'read-banking-transfers', 'read-banking-transactions', 'read-banking-reconciliations'])) {
|
||||
if ($user->canAny(['read-banking-accounts', 'read-banking-transfers', 'read-banking-transactions', 'read-banking-reconciliations'])) {
|
||||
$menu->dropdown(trim(trans('general.banking')), function ($sub) use ($user, $attr) {
|
||||
if ($user->can('read-banking-accounts')) {
|
||||
$sub->route('accounts.index', trans_choice('general.accounts', 2), [], 10, $attr);
|
||||
|
29
app/Listeners/Update/V21/Version210.php
Normal file
29
app/Listeners/Update/V21/Version210.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners\Update\V20;
|
||||
|
||||
use App\Abstracts\Listeners\Update as Listener;
|
||||
use App\Events\Install\UpdateFinished as Event;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class Version210 extends Listener
|
||||
{
|
||||
const ALIAS = 'core';
|
||||
|
||||
const VERSION = '2.1.0';
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Event $event)
|
||||
{
|
||||
if ($this->skipThisUpdate($event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Artisan::call('migrate', ['--force' => true]);
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
namespace App\Models\Auth;
|
||||
|
||||
use App\Traits\Tenants;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Laratrust\Models\LaratrustPermission;
|
||||
use Laratrust\Traits\LaratrustPermissionTrait;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
@ -10,7 +11,7 @@ use Lorisleiva\LaravelSearchString\Concerns\SearchString;
|
||||
|
||||
class Permission extends LaratrustPermission
|
||||
{
|
||||
use LaratrustPermissionTrait, SearchString, Sortable, Tenants;
|
||||
use HasFactory, LaratrustPermissionTrait, SearchString, Sortable, Tenants;
|
||||
|
||||
protected $table = 'permissions';
|
||||
|
||||
@ -80,4 +81,14 @@ class Permission extends LaratrustPermission
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Permission::new();
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Models\Auth;
|
||||
|
||||
use App\Traits\Tenants;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Laratrust\Models\LaratrustRole;
|
||||
use Laratrust\Traits\LaratrustRoleTrait;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
@ -10,7 +11,7 @@ use Lorisleiva\LaravelSearchString\Concerns\SearchString;
|
||||
|
||||
class Role extends LaratrustRole
|
||||
{
|
||||
use LaratrustRoleTrait, SearchString, Sortable, Tenants;
|
||||
use HasFactory, LaratrustRoleTrait, SearchString, Sortable, Tenants;
|
||||
|
||||
protected $table = 'roles';
|
||||
|
||||
@ -40,4 +41,14 @@ class Role extends LaratrustRole
|
||||
|
||||
return $query->usingSearchString($search)->sortable($sort)->paginate($limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Role::new();
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ use App\Traits\Tenants;
|
||||
use App\Notifications\Auth\Reset;
|
||||
use App\Traits\Media;
|
||||
use Date;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
@ -15,7 +16,7 @@ use Lorisleiva\LaravelSearchString\Concerns\SearchString;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use LaratrustUserTrait, Notifiable, SearchString, SoftDeletes, Sortable, Media, Tenants;
|
||||
use HasFactory, LaratrustUserTrait, Notifiable, SearchString, SoftDeletes, Sortable, Media, Tenants;
|
||||
|
||||
protected $table = 'users';
|
||||
|
||||
@ -205,4 +206,14 @@ class User extends Authenticatable
|
||||
{
|
||||
$this->offsetUnset('company_ids');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\User::new();
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,11 @@ namespace App\Models\Banking;
|
||||
|
||||
use App\Abstracts\Model;
|
||||
use App\Traits\Transactions;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Account extends Model
|
||||
{
|
||||
use Transactions;
|
||||
use HasFactory, Transactions;
|
||||
|
||||
protected $table = 'accounts';
|
||||
|
||||
@ -91,4 +92,14 @@ class Account extends Model
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Account::new();
|
||||
}
|
||||
}
|
||||
|
@ -10,11 +10,12 @@ use App\Traits\Media;
|
||||
use App\Traits\Recurring;
|
||||
use App\Traits\Transactions;
|
||||
use Bkwld\Cloner\Cloneable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Transaction extends Model
|
||||
{
|
||||
use Cloneable, Currencies, DateTime, Media, Recurring, Transactions;
|
||||
use Cloneable, Currencies, DateTime, HasFactory, Media, Recurring, Transactions;
|
||||
|
||||
protected $table = 'transactions';
|
||||
|
||||
@ -323,4 +324,14 @@ class Transaction extends Model
|
||||
{
|
||||
return $value ?? $this->document_id ?? $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Transaction::new();
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,11 @@ namespace App\Models\Banking;
|
||||
|
||||
use App\Abstracts\Model;
|
||||
use App\Traits\Currencies;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Transfer extends Model
|
||||
{
|
||||
use Currencies;
|
||||
use HasFactory, Currencies;
|
||||
|
||||
protected $table = 'transfers';
|
||||
|
||||
@ -44,4 +45,14 @@ class Transfer extends Model
|
||||
{
|
||||
return $this->belongsTo('App\Models\Banking\Account', 'income_transaction.account_id', 'id')->withDefault(['name' => trans('general.na')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Transfer::new();
|
||||
}
|
||||
}
|
||||
|
@ -8,11 +8,12 @@ use App\Traits\Contacts;
|
||||
use App\Traits\Currencies;
|
||||
use App\Traits\Media;
|
||||
use App\Traits\Transactions;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class Contact extends Model
|
||||
{
|
||||
use Cloneable, Contacts, Currencies, Media, Notifiable, Transactions;
|
||||
use Cloneable, Contacts, Currencies, HasFactory, Media, Notifiable, Transactions;
|
||||
|
||||
protected $table = 'contacts';
|
||||
|
||||
@ -144,4 +145,14 @@ class Contact extends Model
|
||||
|
||||
return $amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Contact::new();
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,11 @@ use App\Abstracts\Model;
|
||||
use App\Traits\Currencies;
|
||||
use App\Traits\Media;
|
||||
use Bkwld\Cloner\Cloneable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Item extends Model
|
||||
{
|
||||
use Cloneable, Currencies, Media;
|
||||
use Cloneable, Currencies, HasFactory, Media;
|
||||
|
||||
protected $table = 'items';
|
||||
|
||||
@ -137,4 +138,14 @@ class Item extends Model
|
||||
|
||||
return $this->getMedia('picture')->last();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Item::new();
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,11 @@ namespace App\Models\Purchase;
|
||||
|
||||
use App\Abstracts\DocumentModel;
|
||||
use App\Traits\Purchases;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Bill extends DocumentModel
|
||||
{
|
||||
use Purchases;
|
||||
use HasFactory, Purchases;
|
||||
|
||||
protected $table = 'bills';
|
||||
|
||||
@ -108,4 +109,14 @@ class Bill extends DocumentModel
|
||||
|
||||
return ($received) ? $received->created_at : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Bill::new();
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,11 @@ namespace App\Models\Sale;
|
||||
|
||||
use App\Abstracts\DocumentModel;
|
||||
use App\Traits\Sales;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Invoice extends DocumentModel
|
||||
{
|
||||
use Sales;
|
||||
use HasFactory, Sales;
|
||||
|
||||
protected $table = 'invoices';
|
||||
|
||||
@ -115,4 +116,14 @@ class Invoice extends DocumentModel
|
||||
|
||||
return ($sent) ? $sent->created_at : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Invoice::new();
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,11 @@ namespace App\Models\Setting;
|
||||
|
||||
use App\Abstracts\Model;
|
||||
use App\Traits\Transactions;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Category extends Model
|
||||
{
|
||||
use Transactions;
|
||||
use HasFactory, Transactions;
|
||||
|
||||
protected $table = 'categories';
|
||||
|
||||
@ -130,4 +131,14 @@ class Category extends Model
|
||||
{
|
||||
return (int) $query->other()->pluck('id')->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Category::new();
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,11 @@ namespace App\Models\Setting;
|
||||
use App\Abstracts\Model;
|
||||
use App\Traits\Contacts;
|
||||
use App\Traits\Transactions;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Currency extends Model
|
||||
{
|
||||
use Contacts, Transactions;
|
||||
use Contacts, HasFactory, Transactions;
|
||||
|
||||
protected $table = 'currencies';
|
||||
|
||||
@ -163,4 +164,14 @@ class Currency extends Model
|
||||
{
|
||||
return $query->where($this->table . '.code', $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Currency::new();
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,12 @@
|
||||
namespace App\Models\Setting;
|
||||
|
||||
use App\Abstracts\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Tax extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'taxes';
|
||||
|
||||
/**
|
||||
@ -127,4 +130,14 @@ class Tax extends Model
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return \Database\Factories\Tax::new();
|
||||
}
|
||||
}
|
||||
|
@ -2,28 +2,12 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Blade;
|
||||
use Illuminate\Pagination\Paginator;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\ServiceProvider as Provider;
|
||||
use Schema;
|
||||
|
||||
class App extends Provider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
// Laravel db fix
|
||||
Schema::defaultStringLength(191);
|
||||
|
||||
// @todo Remove the if control after 1.3 update
|
||||
if (method_exists('Blade', 'withoutDoubleEncoding')) {
|
||||
Blade::withoutDoubleEncoding();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
@ -39,4 +23,17 @@ class App extends Provider
|
||||
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
// Laravel db fix
|
||||
Schema::defaultStringLength(191);
|
||||
|
||||
Paginator::useBootstrap();
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Contracts\Auth\Access\Authorizable;
|
||||
use Illuminate\Contracts\Auth\Access\Gate;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as Provider;
|
||||
|
||||
class Auth extends Provider
|
||||
@ -12,7 +14,7 @@ class Auth extends Provider
|
||||
* @var array
|
||||
*/
|
||||
protected $policies = [
|
||||
//'App\Model' => 'App\Policies\ModelPolicy',
|
||||
//'App\Models\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
@ -24,6 +26,11 @@ class Auth extends Provider
|
||||
{
|
||||
$this->registerPolicies();
|
||||
|
||||
//
|
||||
// Register permissions to Laravel Gate
|
||||
app(Gate::class)->before(function (Authorizable $user, string $ability) {
|
||||
if (method_exists($user, 'hasPermission')) {
|
||||
return $user->hasPermission($ability) ?: null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ class Event extends Provider
|
||||
'App\Listeners\Update\V20\Version2020',
|
||||
'App\Listeners\Update\V20\Version2023',
|
||||
'App\Listeners\Update\V20\Version2024',
|
||||
'App\Listeners\Update\V21\Version210',
|
||||
],
|
||||
'Illuminate\Auth\Events\Login' => [
|
||||
'App\Listeners\Auth\Login',
|
||||
|
@ -2,11 +2,23 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route as Facade;
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as Provider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route as Facade;
|
||||
|
||||
class Route extends Provider
|
||||
{
|
||||
/**
|
||||
* The path to the "home" route for your application.
|
||||
*
|
||||
* This is used by Laravel authentication to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/';
|
||||
|
||||
/**
|
||||
* This namespace is applied to your controller routes.
|
||||
*
|
||||
@ -64,6 +76,8 @@ class Route extends Provider
|
||||
*/
|
||||
protected function mapApiRoutes()
|
||||
{
|
||||
$this->configureRateLimiting();
|
||||
|
||||
Facade::prefix('api')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/api.php'));
|
||||
@ -155,4 +169,16 @@ class Route extends Provider
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/signed.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the rate limiters for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function configureRateLimiting()
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
"license": "GPL-3.0+",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"php": "^7.2.5",
|
||||
"php": "^7.3.0",
|
||||
"ext-bcmath": "*",
|
||||
"akaunting/firewall": "1.2.*",
|
||||
"akaunting/language": "1.0.*",
|
||||
@ -21,45 +21,45 @@
|
||||
"akaunting/money": "1.2.*",
|
||||
"akaunting/setting": "1.2.*",
|
||||
"akaunting/version": "1.0.*",
|
||||
"barryvdh/laravel-debugbar": "3.3.*",
|
||||
"barryvdh/laravel-debugbar": "3.5.*",
|
||||
"barryvdh/laravel-dompdf": "0.*",
|
||||
"barryvdh/laravel-ide-helper": "2.8.*",
|
||||
"bkwld/cloner": "3.7.*",
|
||||
"bkwld/cloner": "3.9.*",
|
||||
"consoletvs/charts": "6.5.*",
|
||||
"dingo/api": "3.0.*",
|
||||
"doctrine/dbal": "2.9.*",
|
||||
"fideloper/proxy": "^4.2",
|
||||
"doctrine/dbal": "2.11.*",
|
||||
"fideloper/proxy": "^4.4",
|
||||
"fruitcake/laravel-cors": "^1.0",
|
||||
"genealabs/laravel-model-caching": "0.8.*",
|
||||
"graham-campbell/markdown": "12.0.*",
|
||||
"guzzlehttp/guzzle": "^6.5",
|
||||
"genealabs/laravel-model-caching": "0.11.*",
|
||||
"graham-campbell/markdown": "13.1.*",
|
||||
"guzzlehttp/guzzle": "^7.0",
|
||||
"intervention/image": "2.5.*",
|
||||
"intervention/imagecache": "^2.4",
|
||||
"intervention/imagecache": "^2.5",
|
||||
"kyslik/column-sortable": "^6.0",
|
||||
"laracasts/flash": "3.1.*",
|
||||
"laravel/framework": "^7.0",
|
||||
"laracasts/flash": "3.2.*",
|
||||
"laravel/framework": "^8.0",
|
||||
"laravel/tinker": "^2.0",
|
||||
"laravel/ui": "^2.0",
|
||||
"laravelcollective/html": "6.1.*",
|
||||
"league/omnipay": "3.0.*",
|
||||
"laravel/ui": "^3.0",
|
||||
"laravelcollective/html": "6.2.*",
|
||||
"league/omnipay": "3.1.x-dev",
|
||||
"lorisleiva/laravel-search-string": "1.0.*",
|
||||
"maatwebsite/excel": "3.1.*",
|
||||
"misterphilip/maintenance-mode": "2.0.*",
|
||||
"monooso/unobserve": "^2.0",
|
||||
"plank/laravel-mediable": "4.2.*",
|
||||
"monooso/unobserve": "^3.0",
|
||||
"plank/laravel-mediable": "4.4.*",
|
||||
"riverskies/laravel-mobile-detect": "^1.3",
|
||||
"santigarcor/laratrust": "5.2.*",
|
||||
"santigarcor/laratrust": "6.2.*",
|
||||
"simshaun/recurr": "4.0.*",
|
||||
"staudenmeir/belongs-to-through": "^2.10",
|
||||
"staudenmeir/eloquent-has-many-deep": "^1.12"
|
||||
"staudenmeir/belongs-to-through": "^2.11",
|
||||
"staudenmeir/eloquent-has-many-deep": "^1.13"
|
||||
},
|
||||
"require-dev": {
|
||||
"beyondcode/laravel-dump-server": "^1.0",
|
||||
"facade/ignition": "^2.0",
|
||||
"beyondcode/laravel-dump-server": "^1.5",
|
||||
"facade/ignition": "^2.3",
|
||||
"fzaninotto/faker": "^1.9.1",
|
||||
"mockery/mockery": "^1.3.1",
|
||||
"nunomaduro/collision": "^4.1",
|
||||
"phpunit/phpunit": "^8.5"
|
||||
"nunomaduro/collision": "^5.0",
|
||||
"phpunit/phpunit": "^9.3"
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
@ -67,13 +67,11 @@
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"database/seeds",
|
||||
"database/factories"
|
||||
],
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"Modules\\": "modules/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeds\\": "database/seeds/",
|
||||
"Akaunting\\Module\\Commands\\": "overrides/akaunting/module/Commands/",
|
||||
"Illuminate\\Translation\\": "overrides/Illuminate/Translation/",
|
||||
"Illuminate\\View\\Concerns\\": "overrides/Illuminate/View/Concerns/",
|
||||
|
2222
composer.lock
generated
2222
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -67,30 +67,6 @@ return [
|
||||
'expiration_time' => 3600,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Use teams feature in the package
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Defines if Laratrust will use the teams feature.
|
||||
| Please check the docs to see what you need to do in case you have the package already configured.
|
||||
|
|
||||
*/
|
||||
'use_teams' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Strict check for roles/permissions inside teams
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Determines if a strict check should be done when checking if a role or permission
|
||||
| is attached inside a team.
|
||||
| If it's false, when checking a role/permission without specifying the team,
|
||||
| it will check only if the user has attached that role/permission ignoring the team.
|
||||
|
|
||||
*/
|
||||
'teams_strict_check' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laratrust User Models
|
||||
@ -132,7 +108,6 @@ return [
|
||||
* Team model
|
||||
*/
|
||||
'team' => 'App\Models\Auth\Team',
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
@ -173,7 +148,6 @@ return [
|
||||
* Permission - Role intermediate table.
|
||||
*/
|
||||
'permission_role' => 'role_permissions',
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
@ -204,7 +178,6 @@ return [
|
||||
* Role foreign key on Laratrust's role_user and permission_user tables.
|
||||
*/
|
||||
'team' => 'team_id',
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
@ -236,7 +209,8 @@ return [
|
||||
* Aborts the execution with a 403 code.
|
||||
*/
|
||||
'abort' => [
|
||||
'code' => 403
|
||||
'code' => 403,
|
||||
'message' => 'User does not have any of the necessary access rights.'
|
||||
],
|
||||
/**
|
||||
* Redirects the user to the given url.
|
||||
@ -254,14 +228,123 @@ return [
|
||||
]
|
||||
],
|
||||
|
||||
'teams' => [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Use teams feature in the package
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Defines if Laratrust will use the teams feature.
|
||||
| Please check the docs to see what you need to do in case you have the package already configured.
|
||||
|
|
||||
*/
|
||||
'enabled' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Strict check for roles/permissions inside teams
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Determines if a strict check should be done when checking if a role or permission
|
||||
| is attached inside a team.
|
||||
| If it's false, when checking a role/permission without specifying the team,
|
||||
| it will check only if the user has attached that role/permission ignoring the team.
|
||||
|
|
||||
*/
|
||||
'strict_check' => false,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laratrust Magic 'can' Method
|
||||
| Laratrust Magic 'isAbleTo' Method
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Supported cases for the magic can method (Refer to the docs).
|
||||
| Supported cases for the magic is able to method (Refer to the docs).
|
||||
| Available: camel_case|snake_case|kebab_case
|
||||
|
|
||||
*/
|
||||
'magic_can_method_case' => 'kebab_case',
|
||||
'magic_is_able_to_method_case' => 'kebab_case',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laratrust Panel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Section to manage everything related with the admin panel for the roles and permissions.
|
||||
|
|
||||
*/
|
||||
'panel' => [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laratrust Panel Register
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This manages if routes used for the admin panel should be registered.
|
||||
| Turn this value to false if you don't want to use Laratrust admin panel
|
||||
|
|
||||
*/
|
||||
'register' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laratrust Panel Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the URI path where Laratrust panel for roles and permissions
|
||||
| will be accessible from.
|
||||
|
|
||||
*/
|
||||
'path' => 'laratrust',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laratrust Panel Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The route where the go back link should point
|
||||
|
|
||||
*/
|
||||
'go_back_route' => '/',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laratrust Panel Route Middleware
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These middleware will get attached onto each Laratrust panel route.
|
||||
|
|
||||
*/
|
||||
'middleware' => ['web'],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enable permissions assignment
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Enable/Disable the permissions assignment to the users.
|
||||
|
|
||||
*/
|
||||
'assign_permissions_to_user' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Add restriction to roles in the panel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Configure which roles can not be editable, deletable and removable.
|
||||
| To add a role to the restriction, use name of the role here.
|
||||
|
|
||||
*/
|
||||
'roles_restrictions' => [
|
||||
// The user won't be able to remove roles already assigned to users.
|
||||
'not_removable' => [],
|
||||
|
||||
// The user won't be able to edit the role and the permissions assigned.
|
||||
'not_editable' => [],
|
||||
|
||||
// The user won't be able to delete the role.
|
||||
'not_deletable' => [],
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
|
@ -44,13 +44,13 @@ return [
|
||||
'single' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => 'debug',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
],
|
||||
|
||||
'daily' => [
|
||||
'driver' => 'daily',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => 'debug',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'days' => 14,
|
||||
],
|
||||
|
||||
@ -59,12 +59,12 @@ return [
|
||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||
'username' => 'Laravel Log',
|
||||
'emoji' => ':boom:',
|
||||
'level' => 'critical',
|
||||
'level' => env('LOG_LEVEL', 'critical'),
|
||||
],
|
||||
|
||||
'papertrail' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => 'debug',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => SyslogUdpHandler::class,
|
||||
'handler_with' => [
|
||||
'host' => env('PAPERTRAIL_URL'),
|
||||
@ -83,12 +83,12 @@ return [
|
||||
|
||||
'syslog' => [
|
||||
'driver' => 'syslog',
|
||||
'level' => 'debug',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
],
|
||||
|
||||
'errorlog' => [
|
||||
'driver' => 'errorlog',
|
||||
'level' => 'debug',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
],
|
||||
|
||||
'null' => [
|
||||
|
@ -42,6 +42,7 @@ return [
|
||||
'username' => env('MAIL_USERNAME'),
|
||||
'password' => env('MAIL_PASSWORD'),
|
||||
'timeout' => env('MAIL_TIMEOUT'),
|
||||
'auth_mode' => env('MAIL_AUTH_MODE'),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
|
@ -81,7 +81,7 @@ return [
|
||||
*/
|
||||
|
||||
'failed' => [
|
||||
'driver' => env('QUEUE_FAILED_DRIVER', 'database'),
|
||||
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
|
||||
'database' => env('DB_CONNECTION', 'mysql'),
|
||||
'table' => 'failed_jobs',
|
||||
],
|
||||
|
@ -92,10 +92,12 @@ return [
|
||||
| Session Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "apc", "memcached", or "dynamodb" session drivers you may
|
||||
| While using one of the framework's cache driven session backends you may
|
||||
| list a cache store that should be used for these sessions. This value
|
||||
| must match with one of the application's configured cache "stores".
|
||||
|
|
||||
| Affects: "apc", "dynamodb", "memcached", "redis"
|
||||
|
|
||||
*/
|
||||
|
||||
'store' => env('SESSION_STORE', null),
|
||||
|
@ -1,38 +1,78 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Banking\Account;
|
||||
use Faker\Generator as Faker;
|
||||
namespace Database\Factories;
|
||||
|
||||
$user = User::first();
|
||||
$company = $user->companies()->first();
|
||||
use App\Abstracts\Factory;
|
||||
use App\Models\Banking\Account as Model;
|
||||
|
||||
$factory->define(Account::class, function (Faker $faker) use ($company) {
|
||||
session(['company_id' => $company->id]);
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
class Account extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
return [
|
||||
'company_id' => $company->id,
|
||||
'name' => $faker->text(15),
|
||||
'number' => (string) $faker->iban(),
|
||||
'currency_code' => $company->currencies()->enabled()->get()->random(1)->pluck('code')->first(),
|
||||
'opening_balance' => '0',
|
||||
'bank_name' => $faker->text(15),
|
||||
'bank_phone' => $faker->phoneNumber,
|
||||
'bank_address' => $faker->address,
|
||||
'enabled' => $faker->boolean ? 1 : 0,
|
||||
];
|
||||
});
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'name' => $this->faker->text(15),
|
||||
'number' => (string) $this->faker->iban(),
|
||||
'currency_code' => $this->company->currencies()->enabled()->get()->random(1)->pluck('code')->first(),
|
||||
'opening_balance' => '0',
|
||||
'bank_name' => $this->faker->text(15),
|
||||
'bank_phone' => $this->faker->phoneNumber,
|
||||
'bank_address' => $this->faker->address,
|
||||
'enabled' => $this->faker->boolean ? 1 : 0,
|
||||
];
|
||||
}
|
||||
|
||||
$factory->state(Account::class, 'enabled', ['enabled' => 1]);
|
||||
/**
|
||||
* Indicate that the model is enabled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function enabled()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'enabled' => 1,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$factory->state(Account::class, 'disabled', ['enabled' => 0]);
|
||||
/**
|
||||
* Indicate that the model is disabled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function disabled()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'enabled' => 0,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$factory->state(Account::class, 'default_currency', function (Faker $faker) use ($company) {
|
||||
session(['company_id' => $company->id]);
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
|
||||
return [
|
||||
'currency_code' => setting('default.currency'),
|
||||
];
|
||||
});
|
||||
/**
|
||||
* Indicate that the default currency is used.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function default_currency()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'currency_code' => setting('default.currency'),
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,185 +1,274 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Abstracts\Factory;
|
||||
use App\Events\Purchase\BillCancelled;
|
||||
use App\Events\Purchase\BillCreated;
|
||||
use App\Events\Purchase\BillReceived;
|
||||
use App\Jobs\Banking\CreateDocumentTransaction;
|
||||
use App\Jobs\Purchase\UpdateBill;
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Common\Contact;
|
||||
use App\Models\Common\Item;
|
||||
use App\Models\Purchase\Bill;
|
||||
use App\Models\Purchase\Bill as Model;
|
||||
use App\Models\Setting\Tax;
|
||||
use App\Utilities\Date;
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$user = User::first();
|
||||
$company = $user->companies()->first();
|
||||
class Bill extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
$factory->define(Bill::class, function (Faker $faker) use ($company) {
|
||||
session(['company_id' => $company->id]);
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$billed_at = $this->faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d H:i:s');
|
||||
$due_at = Date::parse($billed_at)->addDays(10)->format('Y-m-d H:i:s');
|
||||
|
||||
$billed_at = $faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d H:i:s');
|
||||
$due_at = Date::parse($billed_at)->addDays(10)->format('Y-m-d H:i:s');
|
||||
$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 = factory(Contact::class)->states('enabled', 'vendor')->create();
|
||||
$statuses = ['draft', 'received', 'partial', 'paid', 'cancelled'];
|
||||
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'billed_at' => $billed_at,
|
||||
'due_at' => $due_at,
|
||||
'bill_number' => (string) $this->faker->randomNumber(5),
|
||||
'currency_code' => setting('default.currency'),
|
||||
'currency_rate' => '1',
|
||||
'notes' => $this->faker->text(5),
|
||||
'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),
|
||||
'amount' => '0',
|
||||
];
|
||||
}
|
||||
|
||||
$statuses = ['draft', 'received', 'partial', 'paid', 'cancelled'];
|
||||
|
||||
return [
|
||||
'company_id' => $company->id,
|
||||
'billed_at' => $billed_at,
|
||||
'due_at' => $due_at,
|
||||
'bill_number' => (string) $faker->randomNumber(5),
|
||||
'currency_code' => setting('default.currency'),
|
||||
'currency_rate' => '1',
|
||||
'notes' => $faker->text(5),
|
||||
'category_id' => $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' => $faker->randomElement($statuses),
|
||||
'amount' => '0',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Bill::class, 'draft', ['status' => 'draft']);
|
||||
|
||||
$factory->state(Bill::class, 'received', ['status' => 'received']);
|
||||
|
||||
$factory->state(Bill::class, 'partial', ['status' => 'partial']);
|
||||
|
||||
$factory->state(Bill::class, 'paid', ['status' => 'paid']);
|
||||
|
||||
$factory->state(Bill::class, 'cancelled', ['status' => 'cancelled']);
|
||||
|
||||
$factory->state(Bill::class, 'recurring', function (Faker $faker) {
|
||||
$frequencies = ['monthly', 'weekly'];
|
||||
|
||||
return [
|
||||
'recurring_frequency' => 'yes',
|
||||
'recurring_interval' => '1',
|
||||
'recurring_custom_frequency' => $faker->randomElement($frequencies),
|
||||
'recurring_count' => '1',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Bill::class, 'items', function (Faker $faker) use ($company) {
|
||||
session(['company_id' => $company->id]);
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
|
||||
$amount = $faker->randomFloat(2, 1, 1000);
|
||||
|
||||
$taxes = Tax::enabled()->get();
|
||||
|
||||
if ($taxes->count()) {
|
||||
$tax = $taxes->random(1)->first();
|
||||
} else {
|
||||
$tax = factory(Tax::class)->states('enabled')->create();
|
||||
}
|
||||
|
||||
$items = Item::enabled()->get();
|
||||
|
||||
if ($items->count()) {
|
||||
$item = $items->random(1)->first();
|
||||
} else {
|
||||
$item = factory(Item::class)->states('enabled')->create();
|
||||
}
|
||||
|
||||
$items = [
|
||||
[
|
||||
'name' => $item->name,
|
||||
'item_id' => $item->id,
|
||||
'tax_id' => [$tax->id],
|
||||
'quantity' => '1',
|
||||
'price' => $amount,
|
||||
'currency' => setting('default.currency'),
|
||||
]
|
||||
];
|
||||
|
||||
return [
|
||||
'items' => $items,
|
||||
'recurring_frequency' => 'no',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->afterCreating(Bill::class, function ($bill, $faker) use ($company) {
|
||||
session(['company_id' => $company->id]);
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
|
||||
$init_status = $bill->status;
|
||||
|
||||
$bill->status = 'draft';
|
||||
event(new BillCreated($bill));
|
||||
$bill->status = $init_status;
|
||||
|
||||
$amount = $faker->randomFloat(2, 1, 1000);
|
||||
|
||||
$taxes = Tax::enabled()->get();
|
||||
|
||||
if ($taxes->count()) {
|
||||
$tax = $taxes->random(1)->first();
|
||||
} else {
|
||||
$tax = factory(Tax::class)->states('enabled')->create();
|
||||
}
|
||||
|
||||
$items = Item::enabled()->get();
|
||||
|
||||
if ($items->count()) {
|
||||
$item = $items->random(1)->first();
|
||||
} else {
|
||||
$item = factory(Item::class)->states('enabled')->create();
|
||||
}
|
||||
|
||||
$items = [
|
||||
[
|
||||
'name' => $item->name,
|
||||
'item_id' => $item->id,
|
||||
'tax_id' => [$tax->id],
|
||||
'quantity' => '1',
|
||||
'price' => $amount,
|
||||
'currency' => $bill->currency_code,
|
||||
]
|
||||
];
|
||||
|
||||
$request = [
|
||||
'items' => $items,
|
||||
'recurring_frequency' => 'no',
|
||||
];
|
||||
|
||||
$updated_bill = dispatch_now(new UpdateBill($bill, $request));
|
||||
|
||||
switch ($init_status) {
|
||||
case 'received':
|
||||
event(new BillReceived($updated_bill));
|
||||
|
||||
break;
|
||||
case 'partial':
|
||||
case 'paid':
|
||||
$payment_request = [
|
||||
'paid_at' => $updated_bill->due_at,
|
||||
/**
|
||||
* Indicate that the model status is draft.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function draft()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'status' => 'draft',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
if ($init_status == 'partial') {
|
||||
$payment_request['amount'] = (int) round($amount / 3, $bill->currency->precision);
|
||||
/**
|
||||
* Indicate that the model status is received.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function received()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'status' => 'received',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model status is partial.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function partial()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'status' => 'partial',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model status is paid.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function paid()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'status' => 'paid',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model status is cancelled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function cancelled()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'status' => 'cancelled',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model is recurring.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function recurring()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
$frequencies = ['monthly', 'weekly'];
|
||||
|
||||
return [
|
||||
'recurring_frequency' => 'yes',
|
||||
'recurring_interval' => '1',
|
||||
'recurring_custom_frequency' => $this->faker->randomElement($frequencies),
|
||||
'recurring_count' => '1',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model has items.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function items()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
$amount = $this->faker->randomFloat(2, 1, 1000);
|
||||
|
||||
$taxes = Tax::enabled()->get();
|
||||
|
||||
if ($taxes->count()) {
|
||||
$tax = $taxes->random(1)->first();
|
||||
} else {
|
||||
$tax = Tax::factory()->enabled()->create();
|
||||
}
|
||||
|
||||
$transaction = dispatch_now(new CreateDocumentTransaction($updated_bill, $payment_request));
|
||||
$items = Item::enabled()->get();
|
||||
|
||||
break;
|
||||
case 'cancelled':
|
||||
event(new BillCancelled($updated_bill));
|
||||
if ($items->count()) {
|
||||
$item = $items->random(1)->first();
|
||||
} else {
|
||||
$item = Item::factory()->enabled()->create();
|
||||
}
|
||||
|
||||
break;
|
||||
$items = [
|
||||
[
|
||||
'name' => $item->name,
|
||||
'item_id' => $item->id,
|
||||
'tax_id' => [$tax->id],
|
||||
'quantity' => '1',
|
||||
'price' => $amount,
|
||||
'currency' => setting('default.currency'),
|
||||
]
|
||||
];
|
||||
|
||||
return [
|
||||
'items' => $items,
|
||||
'recurring_frequency' => 'no',
|
||||
];
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Configure the model factory.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function configure()
|
||||
{
|
||||
return $this->afterCreating(function (Model $bill) {
|
||||
$init_status = $bill->status;
|
||||
|
||||
$bill->status = 'draft';
|
||||
event(new BillCreated($bill));
|
||||
$bill->status = $init_status;
|
||||
|
||||
$amount = $this->faker->randomFloat(2, 1, 1000);
|
||||
|
||||
$taxes = Tax::enabled()->get();
|
||||
|
||||
if ($taxes->count()) {
|
||||
$tax = $taxes->random(1)->first();
|
||||
} else {
|
||||
$tax = Tax::factory()->enabled()->create();
|
||||
}
|
||||
|
||||
$items = Item::enabled()->get();
|
||||
|
||||
if ($items->count()) {
|
||||
$item = $items->random(1)->first();
|
||||
} else {
|
||||
$item = Item::factory()->enabled()->create();
|
||||
}
|
||||
|
||||
$items = [
|
||||
[
|
||||
'name' => $item->name,
|
||||
'item_id' => $item->id,
|
||||
'tax_id' => [$tax->id],
|
||||
'quantity' => '1',
|
||||
'price' => $amount,
|
||||
'currency' => $bill->currency_code,
|
||||
]
|
||||
];
|
||||
|
||||
$request = [
|
||||
'items' => $items,
|
||||
'recurring_frequency' => 'no',
|
||||
];
|
||||
|
||||
$updated_bill = $this->dispatch(new UpdateBill($bill, $request));
|
||||
|
||||
switch ($init_status) {
|
||||
case 'received':
|
||||
event(new BillReceived($updated_bill));
|
||||
|
||||
break;
|
||||
case 'partial':
|
||||
case 'paid':
|
||||
$payment_request = [
|
||||
'paid_at' => $updated_bill->due_at,
|
||||
];
|
||||
|
||||
if ($init_status == 'partial') {
|
||||
$payment_request['amount'] = (int) round($amount / 3, $bill->currency->precision);
|
||||
}
|
||||
|
||||
$transaction = dispatch_now(new CreateDocumentTransaction($updated_bill, $payment_request));
|
||||
|
||||
break;
|
||||
case 'cancelled':
|
||||
event(new BillCancelled($updated_bill));
|
||||
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,34 +1,118 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Setting\Category;
|
||||
use Faker\Generator as Faker;
|
||||
namespace Database\Factories;
|
||||
|
||||
$user = User::first();
|
||||
$company = $user->companies()->first();
|
||||
use App\Abstracts\Factory;
|
||||
use App\Models\Setting\Category as Model;
|
||||
|
||||
$factory->define(Category::class, function (Faker $faker) use ($company) {
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
class Category extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
$types = ['income', 'expense', 'item', 'other'];
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$types = ['income', 'expense', 'item', 'other'];
|
||||
|
||||
return [
|
||||
'company_id' => $company->id,
|
||||
'name' => $faker->text(15),
|
||||
'type' => $faker->randomElement($types),
|
||||
'color' => $faker->hexColor,
|
||||
'enabled' => $faker->boolean ? 1 : 0,
|
||||
];
|
||||
});
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'name' => $this->faker->text(15),
|
||||
'type' => $this->faker->randomElement($types),
|
||||
'color' => $this->faker->hexColor,
|
||||
'enabled' => $this->faker->boolean ? 1 : 0,
|
||||
];
|
||||
}
|
||||
|
||||
$factory->state(Category::class, 'enabled', ['enabled' => 1]);
|
||||
/**
|
||||
* Indicate that the model is enabled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function enabled()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'enabled' => 1,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$factory->state(Category::class, 'disabled', ['enabled' => 0]);
|
||||
/**
|
||||
* Indicate that the model is disabled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function disabled()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'enabled' => 0,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$factory->state(Category::class, 'income', ['type' => 'income']);
|
||||
/**
|
||||
* Indicate that the model type is income.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function income()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'type' => 'income',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$factory->state(Category::class, 'expense', ['type' => 'expense']);
|
||||
/**
|
||||
* Indicate that the model type is expense.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function expense()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'type' => 'expense',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$factory->state(Category::class, 'item', ['type' => 'item']);
|
||||
/**
|
||||
* Indicate that the model type is item.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function item()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'type' => 'item',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$factory->state(Category::class, 'other', ['type' => 'other']);
|
||||
/**
|
||||
* Indicate that the model type is other.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function other()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'type' => 'other',
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,38 +1,100 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Common\Contact;
|
||||
use Faker\Generator as Faker;
|
||||
namespace Database\Factories;
|
||||
|
||||
$user = User::first();
|
||||
$company = $user->companies()->first();
|
||||
use App\Abstracts\Factory;
|
||||
use App\Models\Common\Contact as Model;
|
||||
use App\Traits\Contacts;
|
||||
|
||||
$factory->define(Contact::class, function (Faker $faker) use ($company) {
|
||||
session(['company_id' => $company->id]);
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
class Contact extends Factory
|
||||
{
|
||||
use Contacts;
|
||||
|
||||
$types = ['customer', 'vendor'];
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
return [
|
||||
'company_id' => $company->id,
|
||||
'type' => $faker->randomElement($types),
|
||||
'name' => $faker->name,
|
||||
'email' => $faker->unique()->safeEmail,
|
||||
'user_id' => null,
|
||||
'tax_number' => $faker->randomNumber(9),
|
||||
'phone' => $faker->phoneNumber,
|
||||
'address' => $faker->address,
|
||||
'website' => 'https://akaunting.com',
|
||||
'currency_code' => setting('default.currency'),
|
||||
'reference' => $faker->text(5),
|
||||
'enabled' => $faker->boolean ? 1 : 0,
|
||||
];
|
||||
});
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$types = array_merge($this->getCustomerTypes(), $this->getVendorTypes());
|
||||
|
||||
$factory->state(Contact::class, 'enabled', ['enabled' => 1]);
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'type' => $this->faker->randomElement($types),
|
||||
'name' => $this->faker->name,
|
||||
'email' => $this->faker->unique()->safeEmail,
|
||||
'user_id' => null,
|
||||
'tax_number' => $this->faker->randomNumber(9),
|
||||
'phone' => $this->faker->phoneNumber,
|
||||
'address' => $this->faker->address,
|
||||
'website' => 'https://akaunting.com',
|
||||
'currency_code' => setting('default.currency'),
|
||||
'reference' => $this->faker->text(5),
|
||||
'enabled' => $this->faker->boolean ? 1 : 0,
|
||||
];
|
||||
}
|
||||
|
||||
$factory->state(Contact::class, 'disabled', ['enabled' => 0]);
|
||||
/**
|
||||
* Indicate that the model is enabled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function enabled()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'enabled' => 1,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$factory->state(Contact::class, 'customer', ['type' => 'customer']);
|
||||
/**
|
||||
* Indicate that the model is disabled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function disabled()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'enabled' => 0,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$factory->state(Contact::class, 'vendor', ['type' => 'vendor']);
|
||||
/**
|
||||
* Indicate that the model type is customer.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function customer()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'type' => 'customer',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model type is vendor.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function vendor()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'type' => 'vendor',
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,45 +1,80 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Setting\Currency;
|
||||
use Faker\Generator as Faker;
|
||||
namespace Database\Factories;
|
||||
|
||||
$user = User::first();
|
||||
$company = $user->companies()->first();
|
||||
use App\Abstracts\Factory;
|
||||
use App\Models\Setting\Currency as Model;
|
||||
|
||||
$factory->define(Currency::class, function (Faker $faker) use ($company) {
|
||||
session(['company_id' => $company->id]);
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
class Currency extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
$currencies = config('money');
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$currencies = config('money');
|
||||
|
||||
Currency::pluck('code')->each(function ($db_code) use (&$currencies) {
|
||||
unset($currencies[$db_code]);
|
||||
});
|
||||
Model::pluck('code')->each(function ($db_code) use (&$currencies) {
|
||||
unset($currencies[$db_code]);
|
||||
});
|
||||
|
||||
$random = $faker->randomElement($currencies);
|
||||
$random = $this->faker->randomElement($currencies);
|
||||
|
||||
$filtered = array_filter($currencies, function ($value) use ($random) {
|
||||
return ($value['code'] == $random['code']);
|
||||
});
|
||||
$filtered = array_filter($currencies, function ($value) use ($random) {
|
||||
return ($value['code'] == $random['code']);
|
||||
});
|
||||
|
||||
$code = key($filtered);
|
||||
$currency = $filtered[$code];
|
||||
$code = key($filtered);
|
||||
$currency = $filtered[$code];
|
||||
|
||||
return [
|
||||
'company_id' => $company->id,
|
||||
'name' => $currency['name'],
|
||||
'code' => $code,
|
||||
'rate' => $faker->randomFloat($currency['precision'], 1, 10),
|
||||
'precision' => $currency['precision'],
|
||||
'symbol' => $currency['symbol'],
|
||||
'symbol_first' => $currency['symbol_first'],
|
||||
'decimal_mark' => $currency['decimal_mark'],
|
||||
'thousands_separator' => $currency['thousands_separator'],
|
||||
'enabled' => $faker->boolean ? 1 : 0,
|
||||
];
|
||||
});
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'name' => $currency['name'],
|
||||
'code' => $code,
|
||||
'rate' => $this->faker->randomFloat($currency['precision'], 1, 10),
|
||||
'precision' => $currency['precision'],
|
||||
'symbol' => $currency['symbol'],
|
||||
'symbol_first' => $currency['symbol_first'],
|
||||
'decimal_mark' => $currency['decimal_mark'],
|
||||
'thousands_separator' => $currency['thousands_separator'],
|
||||
'enabled' => $this->faker->boolean ? 1 : 0,
|
||||
];
|
||||
}
|
||||
|
||||
$factory->state(Currency::class, 'enabled', ['enabled' => 1]);
|
||||
/**
|
||||
* Indicate that the model is enabled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function enabled()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'enabled' => 1,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$factory->state(Currency::class, 'disabled', ['enabled' => 0]);
|
||||
/**
|
||||
* Indicate that the model is disabled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function disabled()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'enabled' => 0,
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,32 +1,84 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Common\Dashboard;
|
||||
use Faker\Generator as Faker;
|
||||
namespace Database\Factories;
|
||||
|
||||
$user = User::first();
|
||||
$company = $user->companies()->first();
|
||||
use App\Abstracts\Factory;
|
||||
use App\Models\Common\Dashboard as Model;
|
||||
|
||||
$factory->define(Dashboard::class, function (Faker $faker) use ($company) {
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
class Dashboard extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
return [
|
||||
'company_id' => $company->id,
|
||||
'name' => $faker->text(15),
|
||||
'enabled' => $faker->boolean ? 1 : 0,
|
||||
];
|
||||
});
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'name' => $this->faker->text(15),
|
||||
'enabled' => $this->faker->boolean ? 1 : 0,
|
||||
];
|
||||
}
|
||||
|
||||
$factory->state(Dashboard::class, 'enabled', ['enabled' => 1]);
|
||||
/**
|
||||
* Indicate that the model is enabled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function enabled()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'enabled' => 1,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$factory->state(Dashboard::class, 'disabled', ['enabled' => 0]);
|
||||
/**
|
||||
* Indicate that the model is disabled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function disabled()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'enabled' => 0,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$factory->state(Dashboard::class, 'users', function (Faker $faker) use ($company) {
|
||||
return [
|
||||
'users' => $company->users()->enabled()->get()->pluck('id')->toArray(),
|
||||
];
|
||||
});
|
||||
/**
|
||||
* Indicate the model users.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function users()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'users' => $this->getCompanyUsers(),
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$factory->afterCreating(Dashboard::class, function ($dashboard, $faker) use ($company) {
|
||||
$dashboard->users()->attach($company->users()->enabled()->get()->pluck('id')->toArray());
|
||||
});
|
||||
/**
|
||||
* Configure the model factory.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function configure()
|
||||
{
|
||||
return $this->afterCreating(function (Model $dashboard) {
|
||||
$dashboard->users()->attach($this->getCompanyUsers());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,194 +1,295 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Abstracts\Factory;
|
||||
use App\Events\Sale\InvoiceCancelled;
|
||||
use App\Events\Sale\InvoiceCreated;
|
||||
use App\Events\Sale\InvoiceSent;
|
||||
use App\Events\Sale\InvoiceViewed;
|
||||
use App\Events\Sale\PaymentReceived;
|
||||
use App\Jobs\Sale\UpdateInvoice;
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Common\Contact;
|
||||
use App\Models\Common\Item;
|
||||
use App\Models\Sale\Invoice;
|
||||
use App\Models\Sale\Invoice as Model;
|
||||
use App\Models\Setting\Tax;
|
||||
use App\Utilities\Date;
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$user = User::first();
|
||||
$company = $user->companies()->first();
|
||||
class Invoice extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
$factory->define(Invoice::class, function (Faker $faker) use ($company) {
|
||||
session(['company_id' => $company->id]);
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$invoiced_at = $this->faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d H:i:s');
|
||||
$due_at = Date::parse($invoiced_at)->addDays(setting('invoice.payment_terms'))->format('Y-m-d H:i:s');
|
||||
|
||||
$invoiced_at = $faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d H:i:s');
|
||||
$due_at = Date::parse($invoiced_at)->addDays(setting('invoice.payment_terms'))->format('Y-m-d H:i:s');
|
||||
$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 = factory(Contact::class)->states('enabled', 'customer')->create();
|
||||
$statuses = ['draft', 'sent', 'viewed', 'partial', 'paid', 'cancelled'];
|
||||
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'invoiced_at' => $invoiced_at,
|
||||
'due_at' => $due_at,
|
||||
'invoice_number' => setting('invoice.number_prefix') . $this->faker->randomNumber(setting('invoice.number_digit')),
|
||||
'currency_code' => setting('default.currency'),
|
||||
'currency_rate' => '1',
|
||||
'notes' => $this->faker->text(5),
|
||||
'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),
|
||||
'amount' => '0',
|
||||
];
|
||||
}
|
||||
|
||||
$statuses = ['draft', 'sent', 'viewed', 'partial', 'paid', 'cancelled'];
|
||||
|
||||
return [
|
||||
'company_id' => $company->id,
|
||||
'invoiced_at' => $invoiced_at,
|
||||
'due_at' => $due_at,
|
||||
'invoice_number' => setting('invoice.number_prefix') . $faker->randomNumber(setting('invoice.number_digit')),
|
||||
'currency_code' => setting('default.currency'),
|
||||
'currency_rate' => '1',
|
||||
'notes' => $faker->text(5),
|
||||
'category_id' => $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' => $faker->randomElement($statuses),
|
||||
'amount' => '0',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Invoice::class, 'draft', ['status' => 'draft']);
|
||||
|
||||
$factory->state(Invoice::class, 'sent', ['status' => 'sent']);
|
||||
|
||||
$factory->state(Invoice::class, 'viewed', ['status' => 'viewed']);
|
||||
|
||||
$factory->state(Invoice::class, 'partial', ['status' => 'partial']);
|
||||
|
||||
$factory->state(Invoice::class, 'paid', ['status' => 'paid']);
|
||||
|
||||
$factory->state(Invoice::class, 'cancelled', ['status' => 'cancelled']);
|
||||
|
||||
$factory->state(Invoice::class, 'recurring', function (Faker $faker) {
|
||||
$frequencies = ['monthly', 'weekly'];
|
||||
|
||||
return [
|
||||
'recurring_frequency' => 'yes',
|
||||
'recurring_interval' => '1',
|
||||
'recurring_custom_frequency' => $faker->randomElement($frequencies),
|
||||
'recurring_count' => '1',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Invoice::class, 'items', function (Faker $faker) use ($company) {
|
||||
session(['company_id' => $company->id]);
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
|
||||
$amount = $faker->randomFloat(2, 1, 1000);
|
||||
|
||||
$taxes = Tax::enabled()->get();
|
||||
|
||||
if ($taxes->count()) {
|
||||
$tax = $taxes->random(1)->first();
|
||||
} else {
|
||||
$tax = factory(Tax::class)->states('enabled')->create();
|
||||
}
|
||||
|
||||
$items = Item::enabled()->get();
|
||||
|
||||
if ($items->count()) {
|
||||
$item = $items->random(1)->first();
|
||||
} else {
|
||||
$item = factory(Item::class)->states('enabled')->create();
|
||||
}
|
||||
|
||||
$items = [
|
||||
[
|
||||
'name' => $item->name,
|
||||
'item_id' => $item->id,
|
||||
'tax_id' => [$tax->id],
|
||||
'quantity' => '1',
|
||||
'price' => $amount,
|
||||
'currency' => setting('default.currency'),
|
||||
]
|
||||
];
|
||||
|
||||
return [
|
||||
'items' => $items,
|
||||
'recurring_frequency' => 'no',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->afterCreating(Invoice::class, function ($invoice, $faker) use ($company) {
|
||||
session(['company_id' => $company->id]);
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
|
||||
$init_status = $invoice->status;
|
||||
|
||||
$invoice->status = 'draft';
|
||||
event(new InvoiceCreated($invoice));
|
||||
$invoice->status = $init_status;
|
||||
|
||||
$amount = $faker->randomFloat(2, 1, 1000);
|
||||
|
||||
$taxes = Tax::enabled()->get();
|
||||
|
||||
if ($taxes->count()) {
|
||||
$tax = $taxes->random(1)->first();
|
||||
} else {
|
||||
$tax = factory(Tax::class)->states('enabled')->create();
|
||||
}
|
||||
|
||||
$items = Item::enabled()->get();
|
||||
|
||||
if ($items->count()) {
|
||||
$item = $items->random(1)->first();
|
||||
} else {
|
||||
$item = factory(Item::class)->states('enabled')->create();
|
||||
}
|
||||
|
||||
$items = [
|
||||
[
|
||||
'name' => $item->name,
|
||||
'item_id' => $item->id,
|
||||
'tax_id' => [$tax->id],
|
||||
'quantity' => '1',
|
||||
'price' => $amount,
|
||||
'currency' => $invoice->currency_code,
|
||||
]
|
||||
];
|
||||
|
||||
$request = [
|
||||
'items' => $items,
|
||||
'recurring_frequency' => 'no',
|
||||
];
|
||||
|
||||
$updated_invoice = dispatch_now(new UpdateInvoice($invoice, $request));
|
||||
|
||||
switch ($init_status) {
|
||||
case 'sent':
|
||||
event(new InvoiceSent($updated_invoice));
|
||||
|
||||
break;
|
||||
case 'viewed':
|
||||
$updated_invoice->status = 'sent';
|
||||
event(new InvoiceViewed($updated_invoice));
|
||||
$updated_invoice->status = $init_status;
|
||||
|
||||
break;
|
||||
case 'partial':
|
||||
case 'paid':
|
||||
$payment_request = [
|
||||
'paid_at' => $updated_invoice->due_at,
|
||||
/**
|
||||
* Indicate that the model status is draft.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function draft()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'status' => 'draft',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
if ($init_status == 'partial') {
|
||||
$payment_request['amount'] = (int) round($amount / 3, $invoice->currency->precision);
|
||||
/**
|
||||
* Indicate that the model status is sent.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function sent()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'status' => 'sent',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model status is viewed.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function viewed()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'status' => 'viewed',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model status is partial.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function partial()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'status' => 'partial',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model status is paid.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function paid()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'status' => 'paid',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model status is cancelled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function cancelled()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'status' => 'cancelled',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model is recurring.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function recurring()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
$frequencies = ['monthly', 'weekly'];
|
||||
|
||||
return [
|
||||
'recurring_frequency' => 'yes',
|
||||
'recurring_interval' => '1',
|
||||
'recurring_custom_frequency' => $this->faker->randomElement($frequencies),
|
||||
'recurring_count' => '1',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model has items.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function items()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
$amount = $this->faker->randomFloat(2, 1, 1000);
|
||||
|
||||
$taxes = Tax::enabled()->get();
|
||||
|
||||
if ($taxes->count()) {
|
||||
$tax = $taxes->random(1)->first();
|
||||
} else {
|
||||
$tax = Tax::factory()->enabled()->create();
|
||||
}
|
||||
|
||||
event(new PaymentReceived($updated_invoice, $payment_request));
|
||||
$items = Item::enabled()->get();
|
||||
|
||||
break;
|
||||
case 'cancelled':
|
||||
event(new InvoiceCancelled($updated_invoice));
|
||||
if ($items->count()) {
|
||||
$item = $items->random(1)->first();
|
||||
} else {
|
||||
$item = Item::factory()->enabled()->create();
|
||||
}
|
||||
|
||||
break;
|
||||
$items = [
|
||||
[
|
||||
'name' => $item->name,
|
||||
'item_id' => $item->id,
|
||||
'tax_id' => [$tax->id],
|
||||
'quantity' => '1',
|
||||
'price' => $amount,
|
||||
'currency' => setting('default.currency'),
|
||||
]
|
||||
];
|
||||
|
||||
return [
|
||||
'items' => $items,
|
||||
'recurring_frequency' => 'no',
|
||||
];
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Configure the model factory.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function configure()
|
||||
{
|
||||
return $this->afterCreating(function (Model $invoice) {
|
||||
$init_status = $invoice->status;
|
||||
|
||||
$invoice->status = 'draft';
|
||||
event(new InvoiceCreated($invoice));
|
||||
$invoice->status = $init_status;
|
||||
|
||||
$amount = $this->faker->randomFloat(2, 1, 1000);
|
||||
|
||||
$taxes = Tax::enabled()->get();
|
||||
|
||||
if ($taxes->count()) {
|
||||
$tax = $taxes->random(1)->first();
|
||||
} else {
|
||||
$tax = Tax::factory()->enabled()->create();
|
||||
}
|
||||
|
||||
$items = Item::enabled()->get();
|
||||
|
||||
if ($items->count()) {
|
||||
$item = $items->random(1)->first();
|
||||
} else {
|
||||
$item = Item::factory()->enabled()->create();
|
||||
}
|
||||
|
||||
$items = [
|
||||
[
|
||||
'name' => $item->name,
|
||||
'item_id' => $item->id,
|
||||
'tax_id' => [$tax->id],
|
||||
'quantity' => '1',
|
||||
'price' => $amount,
|
||||
'currency' => $invoice->currency_code,
|
||||
]
|
||||
];
|
||||
|
||||
$request = [
|
||||
'items' => $items,
|
||||
'recurring_frequency' => 'no',
|
||||
];
|
||||
|
||||
$updated_invoice = $this->dispatch(new UpdateInvoice($invoice, $request));
|
||||
|
||||
switch ($init_status) {
|
||||
case 'sent':
|
||||
event(new InvoiceSent($updated_invoice));
|
||||
|
||||
break;
|
||||
case 'viewed':
|
||||
$updated_invoice->status = 'sent';
|
||||
event(new InvoiceViewed($updated_invoice));
|
||||
$updated_invoice->status = $init_status;
|
||||
|
||||
break;
|
||||
case 'partial':
|
||||
case 'paid':
|
||||
$payment_request = [
|
||||
'paid_at' => $updated_invoice->due_at,
|
||||
];
|
||||
|
||||
if ($init_status == 'partial') {
|
||||
$payment_request['amount'] = (int) round($amount / 3, $invoice->currency->precision);
|
||||
}
|
||||
|
||||
event(new PaymentReceived($updated_invoice, $payment_request));
|
||||
|
||||
break;
|
||||
case 'cancelled':
|
||||
event(new InvoiceCancelled($updated_invoice));
|
||||
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +1,63 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Common\Item;
|
||||
use Faker\Generator as Faker;
|
||||
namespace Database\Factories;
|
||||
|
||||
$user = User::first();
|
||||
$company = $user->companies()->first();
|
||||
use App\Abstracts\Factory;
|
||||
use App\Models\Common\Item as Model;
|
||||
|
||||
$factory->define(Item::class, function (Faker $faker) use ($company) {
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
class Item extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
return [
|
||||
'company_id' => $company->id,
|
||||
'name' => $faker->text(15),
|
||||
'description' => $faker->text(100),
|
||||
'purchase_price' => $faker->randomFloat(2, 10, 20),
|
||||
'sale_price' => $faker->randomFloat(2, 10, 20),
|
||||
'category_id' => $company->categories()->item()->get()->random(1)->pluck('id')->first(),
|
||||
'tax_id' => null,
|
||||
'enabled' => $faker->boolean ? 1 : 0,
|
||||
];
|
||||
});
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'name' => $this->faker->text(15),
|
||||
'description' => $this->faker->text(100),
|
||||
'purchase_price' => $this->faker->randomFloat(2, 10, 20),
|
||||
'sale_price' => $this->faker->randomFloat(2, 10, 20),
|
||||
'category_id' => $this->company->categories()->item()->get()->random(1)->pluck('id')->first(),
|
||||
'tax_id' => null,
|
||||
'enabled' => $this->faker->boolean ? 1 : 0,
|
||||
];
|
||||
}
|
||||
|
||||
$factory->state(Item::class, 'enabled', ['enabled' => 1]);
|
||||
/**
|
||||
* Indicate that the model is enabled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function enabled()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'enabled' => 1,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$factory->state(Item::class, 'disabled', ['enabled' => 0]);
|
||||
/**
|
||||
* Indicate that the model is disabled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function disabled()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'enabled' => 0,
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,36 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Auth\Permission;
|
||||
use Faker\Generator as Faker;
|
||||
namespace Database\Factories;
|
||||
|
||||
$factory->define(Permission::class, function (Faker $faker) {
|
||||
$map = ['Create', 'Read', 'Update', 'Delete'];
|
||||
use App\Abstracts\Factory;
|
||||
use App\Models\Auth\Permission as Model;
|
||||
|
||||
$prefix = $faker->randomElement($map);
|
||||
$word_1 = $faker->word;
|
||||
$word_2 = $faker->word;
|
||||
class Permission extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
return [
|
||||
'name' => strtolower($prefix) . '-' . strtolower($word_1) . '-' . strtolower($word_2),
|
||||
'display_name' => $prefix . ' ' . $word_1 . ' ' . $word_2,
|
||||
'description' => $prefix . ' ' . $word_1 . ' ' . $word_2,
|
||||
];
|
||||
});
|
||||
/**
|
||||
* 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,25 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Abstracts\Factory;
|
||||
use App\Models\Auth\Permission;
|
||||
use App\Models\Auth\Role;
|
||||
use Faker\Generator as Faker;
|
||||
use App\Models\Auth\Role as Model;
|
||||
|
||||
$factory->define(Role::class, function (Faker $faker) {
|
||||
$name = $faker->word;
|
||||
class Role extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
return [
|
||||
'name' => strtolower($name),
|
||||
'display_name' => $name,
|
||||
'description' => $name,
|
||||
];
|
||||
});
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$name = $this->faker->word;
|
||||
|
||||
$factory->state(Role::class, 'permissions', function (Faker $faker) {
|
||||
return [
|
||||
'permissions' => Permission::take(50)->pluck('id')->toArray(),
|
||||
];
|
||||
});
|
||||
return [
|
||||
'name' => strtolower($name),
|
||||
'display_name' => $name,
|
||||
'description' => $name,
|
||||
];
|
||||
}
|
||||
|
||||
$factory->afterCreating(Role::class, function ($role, $faker) {
|
||||
$role->permissions()->attach(Permission::take(50)->pluck('id')->toArray());
|
||||
});
|
||||
/**
|
||||
* Indicate the model permissions.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function permissions()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'permissions' => $this->getPermissions(),
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
protected function getPermissions()
|
||||
{
|
||||
return Permission::take(50)->pluck('id')->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the model factory.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function configure()
|
||||
{
|
||||
return $this->afterCreating(function (Model $role) {
|
||||
$role->permissions()->attach($this->getPermissions());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,36 +1,132 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Setting\Tax;
|
||||
use Faker\Generator as Faker;
|
||||
namespace Database\Factories;
|
||||
|
||||
$user = User::first();
|
||||
$company = $user->companies()->first();
|
||||
use App\Abstracts\Factory;
|
||||
use App\Models\Setting\Tax as Model;
|
||||
|
||||
$factory->define(Tax::class, function (Faker $faker) use ($company) {
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
class Tax extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
$types = ['normal', 'inclusive', 'compound', 'fixed', 'withholding'];
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$types = ['normal', 'inclusive', 'compound', 'fixed', 'withholding'];
|
||||
|
||||
return [
|
||||
'company_id' => $company->id,
|
||||
'name' => $faker->text(15),
|
||||
'rate' => $faker->randomFloat(2, 10, 20),
|
||||
'type' => $faker->randomElement($types),
|
||||
'enabled' => $faker->boolean ? 1 : 0,
|
||||
];
|
||||
});
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'name' => $this->faker->text(15),
|
||||
'rate' => $this->faker->randomFloat(2, 10, 20),
|
||||
'type' => $this->faker->randomElement($types),
|
||||
'enabled' => $this->faker->boolean ? 1 : 0,
|
||||
];
|
||||
}
|
||||
|
||||
$factory->state(Tax::class, 'enabled', ['enabled' => 1]);
|
||||
/**
|
||||
* Indicate that the model is enabled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function enabled()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'enabled' => 1,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$factory->state(Tax::class, 'disabled', ['enabled' => 0]);
|
||||
/**
|
||||
* Indicate that the model is disabled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function disabled()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'enabled' => 0,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$factory->state(Tax::class, 'normal', ['type' => 'normal']);
|
||||
/**
|
||||
* Indicate that the model type is normal.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function normal()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'type' => 'normal',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$factory->state(Tax::class, 'inclusive', ['type' => 'inclusive']);
|
||||
/**
|
||||
* Indicate that the model type is inclusive.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function inclusive()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'type' => 'inclusive',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$factory->state(Tax::class, 'compound', ['type' => 'compound']);
|
||||
/**
|
||||
* Indicate that the model type is compound.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function compound()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'type' => 'compound',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$factory->state(Tax::class, 'fixed', ['type' => 'fixed']);
|
||||
/**
|
||||
* Indicate that the model type is fixed.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function fixed()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'type' => 'fixed',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$factory->state(Tax::class, 'withholding', ['type' => 'withholding']);
|
||||
/**
|
||||
* Indicate that the model type is normal.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function withholding()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'type' => 'withholding',
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,43 +1,74 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Banking\Transaction;
|
||||
use Faker\Generator as Faker;
|
||||
namespace Database\Factories;
|
||||
|
||||
$user = User::first();
|
||||
$company = $user->companies()->first();
|
||||
use App\Abstracts\Factory;
|
||||
use App\Models\Banking\Transaction as Model;
|
||||
use App\Traits\Transactions;
|
||||
|
||||
$factory->define(Transaction::class, function (Faker $faker) use ($company) {
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
class Transaction extends Factory
|
||||
{
|
||||
use Transactions;
|
||||
|
||||
$types = ['income', 'expense'];
|
||||
$type = $faker->randomElement($types);
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
return [
|
||||
'company_id' => $company->id,
|
||||
'type' => $type,
|
||||
'account_id' => setting('default.account'),
|
||||
'paid_at' => $faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d H:i:s'),
|
||||
'amount' => $faker->randomFloat(2, 1, 1000),
|
||||
'currency_code' => setting('default.currency'),
|
||||
'currency_rate' => '1.0',
|
||||
'description' => $faker->text(5),
|
||||
'category_id' => $company->categories()->type($type)->get()->random(1)->pluck('id')->first(),
|
||||
'reference' => $faker->text(5),
|
||||
'payment_method' => setting('default.payment_method'),
|
||||
];
|
||||
});
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$types = array_merge($this->getIncomeTypes(), $this->getExpenseTypes());
|
||||
$type = $this->faker->randomElement($types);
|
||||
|
||||
$factory->state(Transaction::class, 'income', function (Faker $faker) use ($company) {
|
||||
return [
|
||||
'type' => 'income',
|
||||
'category_id' => $company->categories()->income()->get()->random(1)->pluck('id')->first(),
|
||||
];
|
||||
});
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'type' => $type,
|
||||
'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),
|
||||
'currency_code' => setting('default.currency'),
|
||||
'currency_rate' => '1.0',
|
||||
'description' => $this->faker->text(5),
|
||||
'category_id' => $this->company->categories()->type($type)->get()->random(1)->pluck('id')->first(),
|
||||
'reference' => $this->faker->text(5),
|
||||
'payment_method' => setting('default.payment_method'),
|
||||
];
|
||||
}
|
||||
|
||||
$factory->state(Transaction::class, 'expense', function (Faker $faker) use ($company) {
|
||||
return [
|
||||
'type' => 'expense',
|
||||
'category_id' => $company->categories()->expense()->get()->random(1)->pluck('id')->first(),
|
||||
];
|
||||
});
|
||||
/**
|
||||
* Indicate that the model type is income.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function income()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'type' => 'income',
|
||||
'category_id' => $this->company->categories()->income()->get()->random(1)->pluck('id')->first(),
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model type is expense.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function expense()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'type' => 'expense',
|
||||
'category_id' => $this->company->categories()->expense()->get()->random(1)->pluck('id')->first(),
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,53 +1,64 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Auth\User;
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Abstracts\Factory;
|
||||
use App\Models\Banking\Account;
|
||||
use App\Models\Banking\Transaction;
|
||||
use App\Models\Banking\Transfer;
|
||||
use App\Models\Banking\Transfer as Model;
|
||||
use App\Models\Setting\Category;
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$user = User::first();
|
||||
$company = $user->companies()->first();
|
||||
class Transfer extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
$factory->define(Transfer::class, function (Faker $faker) use ($company) {
|
||||
session(['company_id' => $company->id]);
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$accounts = Account::enabled()->get();
|
||||
|
||||
$accounts = Account::enabled()->get();
|
||||
if ($accounts->count() >= 2) {
|
||||
$random = $accounts->random(2);
|
||||
|
||||
if ($accounts->count() >= 2) {
|
||||
$random = $accounts->random(2);
|
||||
$expense_account = $random->first();
|
||||
$income_account = $random->last();
|
||||
} else {
|
||||
$expense_account = $accounts->first();
|
||||
|
||||
$expense_account = $random->first();
|
||||
$income_account = $random->last();
|
||||
} else {
|
||||
$expense_account = $accounts->first();
|
||||
$income_account = Account::factory()->enabled()->default_currency()->create();
|
||||
}
|
||||
|
||||
$income_account = factory(Account::class)->states('enabled', 'default_currency')->create();
|
||||
$request = [
|
||||
'amount' => $this->faker->randomFloat(2, 1, 1000),
|
||||
'paid_at' => $this->faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d'),
|
||||
'category_id' => Category::transfer(),
|
||||
'description' => $this->faker->text(20),
|
||||
'reference' => $this->faker->text(20),
|
||||
];
|
||||
|
||||
$expense_transaction = Transaction::factory()->create(array_merge($request, [
|
||||
'type' => 'expense',
|
||||
'account_id' => $expense_account->id,
|
||||
]));
|
||||
|
||||
$income_transaction = Transaction::factory()->create(array_merge($request, [
|
||||
'type' => 'income',
|
||||
'account_id' => $income_account->id,
|
||||
]));
|
||||
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'expense_transaction_id' => $expense_transaction->id,
|
||||
'income_transaction_id' => $income_transaction->id,
|
||||
];
|
||||
}
|
||||
|
||||
$request = [
|
||||
'amount' => $faker->randomFloat(2, 1, 1000),
|
||||
'paid_at' => $faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d'),
|
||||
'category_id' => Category::transfer(),
|
||||
'description' => $faker->text(20),
|
||||
'reference' => $faker->text(20),
|
||||
];
|
||||
|
||||
$expense_transaction = factory(Transaction::class)->create(array_merge($request, [
|
||||
'type' => 'expense',
|
||||
'account_id' => $expense_account->id,
|
||||
]));
|
||||
|
||||
$income_transaction = factory(Transaction::class)->create(array_merge($request, [
|
||||
'type' => 'income',
|
||||
'account_id' => $income_account->id,
|
||||
]));
|
||||
|
||||
return [
|
||||
'company_id' => $company->id,
|
||||
'expense_transaction_id' => $expense_transaction->id,
|
||||
'income_transaction_id' => $income_transaction->id,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
@ -1,25 +1,67 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Auth\User;
|
||||
use Faker\Generator as Faker;
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Abstracts\Factory;
|
||||
use App\Models\Auth\User as Model;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
$factory->define(User::class, function (Faker $faker) {
|
||||
$password = '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi'; // password
|
||||
class User extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Model::class;
|
||||
|
||||
return [
|
||||
'name' => $faker->name,
|
||||
'email' => $faker->unique()->safeEmail,
|
||||
'password' => $password,
|
||||
'password_confirmation' => $password,
|
||||
'remember_token' => Str::random(10),
|
||||
'locale' => 'en-GB',
|
||||
'companies' => ['1'],
|
||||
'roles' => ['1'],
|
||||
'enabled' => $this->faker->boolean ? 1 : 0,
|
||||
];
|
||||
});
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$password = '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi'; // password
|
||||
|
||||
$factory->state(User::class, 'enabled', ['enabled' => 1]);
|
||||
return [
|
||||
'name' => $this->faker->name,
|
||||
'email' => $this->faker->unique()->safeEmail,
|
||||
'password' => $password,
|
||||
'password_confirmation' => $password,
|
||||
'remember_token' => Str::random(10),
|
||||
'locale' => 'en-GB',
|
||||
'companies' => ['1'],
|
||||
'roles' => ['1'],
|
||||
'enabled' => $this->faker->boolean ? 1 : 0,
|
||||
];
|
||||
}
|
||||
|
||||
$factory->state(User::class, 'disabled', ['enabled' => 0]);
|
||||
/**
|
||||
* Indicate that the model is enabled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function enabled()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'enabled' => 1,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model is disabled.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
public function disabled()
|
||||
{
|
||||
return $this->state(function (array $attributes) {
|
||||
return [
|
||||
'enabled' => 0,
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
30
database/migrations/2020_10_13_000000_core_v210.php
Normal file
30
database/migrations/2020_10_13_000000_core_v210.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?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();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -35,25 +35,25 @@ class SampleData extends Seeder
|
||||
|
||||
$bar->start();
|
||||
|
||||
factory(Contact::class, $count)->create();
|
||||
Contact::factory()->count($count)->create();
|
||||
$bar->advance();
|
||||
|
||||
factory(Category::class, $count)->create();
|
||||
Category::factory()->count($count)->create();
|
||||
$bar->advance();
|
||||
|
||||
factory(Tax::class, $small_count)->states('enabled')->create();
|
||||
Tax::factory()->count($small_count)->enabled()->create();
|
||||
$bar->advance();
|
||||
|
||||
factory(Item::class, $count)->create();
|
||||
Item::factory()->count($count)->create();
|
||||
$bar->advance();
|
||||
|
||||
factory(Account::class, $small_count)->create();
|
||||
Account::factory()->count($small_count)->create();
|
||||
$bar->advance();
|
||||
|
||||
factory(Bill::class, $count)->create();
|
||||
Bill::factory()->count($count)->create();
|
||||
$bar->advance();
|
||||
|
||||
factory(Invoice::class, $count)->create();
|
||||
Invoice::factory()->count($count)->create();
|
||||
$bar->advance();
|
||||
|
||||
$bar->finish();
|
||||
|
@ -13,11 +13,11 @@
|
||||
<directory suffix="Test.php">./modules/**/Tests/Feature</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
<directory suffix=".php">./app</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</include>
|
||||
</coverage>
|
||||
<php>
|
||||
<server name="APP_ENV" value="testing"/>
|
||||
<server name="BCRYPT_ROUNDS" value="4"/>
|
||||
|
@ -26,13 +26,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@permission('update-auth-permissions')
|
||||
@can('update-auth-permissions')
|
||||
<div class="card-footer">
|
||||
<div class="row save-buttons">
|
||||
{{ Form::saveButtons('permissions.index') }}
|
||||
</div>
|
||||
</div>
|
||||
@endpermission
|
||||
@endcan
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
@endsection
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
@section('title', trans_choice('general.permissions', 2))
|
||||
|
||||
@permission('create-auth-permissions')
|
||||
@can('create-auth-permissions')
|
||||
@section('new_button')
|
||||
<a href="{{ route('permissions.create') }}" class="btn btn-success btn-sm">{{ trans('general.add_new') }}</a>
|
||||
@endsection
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@section('content')
|
||||
<div class="card">
|
||||
@ -54,10 +54,10 @@
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
|
||||
<a class="dropdown-item" href="{{ route('permissions.edit', $item->id) }}">{{ trans('general.edit') }}</a>
|
||||
@permission('delete-auth-permissions')
|
||||
@can('delete-auth-permissions')
|
||||
<div class="dropdown-divider"></div>
|
||||
{!! Form::deleteLink($item, 'permissions.destroy') !!}
|
||||
@endpermission
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
@ -79,13 +79,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@permission('update-auth-roles')
|
||||
@can('update-auth-roles')
|
||||
<div class="card-footer">
|
||||
<div class="row save-buttons">
|
||||
{{ Form::saveButtons('roles.index') }}
|
||||
</div>
|
||||
</div>
|
||||
@endpermission
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
{!! Form::close() !!}
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
@section('title', trans_choice('general.roles', 2))
|
||||
|
||||
@permission('create-auth-roles')
|
||||
@can('create-auth-roles')
|
||||
@section('new_button')
|
||||
<a href="{{ route('roles.create') }}" class="btn btn-success btn-sm">{{ trans('general.add_new') }}</a>
|
||||
@endsection
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@section('content')
|
||||
<div class="card">
|
||||
@ -54,10 +54,10 @@
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
|
||||
<a class="dropdown-item" href="{{ route('roles.edit', $item->id) }}">{{ trans('general.edit') }}</a>
|
||||
@permission('delete-auth-roles')
|
||||
@can('delete-auth-roles')
|
||||
<div class="dropdown-divider"></div>
|
||||
{!! Form::deleteLink($item, 'roles.destroy') !!}
|
||||
@endpermission
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
@ -47,13 +47,13 @@
|
||||
{{ Form::fileGroup('picture', trans_choice('general.pictures', 1)) }}
|
||||
@endif
|
||||
|
||||
@permission('read-common-companies')
|
||||
@can('read-common-companies')
|
||||
{{ Form::multiSelectRemoteGroup('companies', trans_choice('general.companies', 2), 'user', $companies, [], ['required' => 'required', 'remote_action' => route('companies.autocomplete'), 'remote_type' => 'company']) }}
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@permission('read-auth-roles')
|
||||
@can('read-auth-roles')
|
||||
{{ Form::checkboxGroup('roles', trans_choice('general.roles', 2), $roles, 'display_name') }}
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
{{ Form::radioGroup('enabled', trans('general.enabled'), true) }}
|
||||
</div>
|
||||
|
@ -48,25 +48,25 @@
|
||||
{{ Form::fileGroup('picture', trans_choice('general.pictures', 1)) }}
|
||||
@endif
|
||||
|
||||
@permission('read-common-companies')
|
||||
@can('read-common-companies')
|
||||
{{ Form::multiSelectRemoteGroup('companies', trans_choice('general.companies', 2), 'user', $companies, $user->company_ids, ['required' => 'required', 'disabled' => (in_array('customer', $user->roles()->pluck('name')->toArray())) ? 'true' : 'false', 'remote_action' => route('companies.autocomplete'), 'remote_type' => 'company']) }}
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@permission('read-auth-roles')
|
||||
@can('read-auth-roles')
|
||||
{{ Form::checkboxGroup('roles', trans_choice('general.roles', 2), $roles, 'display_name') }}
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
{{ Form::radioGroup('enabled', trans('general.enabled'), $user->enabled) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@permission(['update-auth-users', 'update-auth-profile'])
|
||||
@canany(['update-auth-users', 'update-auth-profile'])
|
||||
<div class="card-footer">
|
||||
<div class="row save-buttons">
|
||||
{{ Form::saveButtons('users.index') }}
|
||||
</div>
|
||||
</div>
|
||||
@endpermission
|
||||
@endcanany
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
@endsection
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
@section('title', trans_choice('general.users', 2))
|
||||
|
||||
@permission('create-auth-users')
|
||||
@can('create-auth-users')
|
||||
@section('new_button')
|
||||
<a href="{{ route('users.create') }}" class="btn btn-success btn-sm">{{ trans('general.add_new') }}</a>
|
||||
@endsection
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@section('content')
|
||||
<div class="card">
|
||||
@ -88,10 +88,10 @@
|
||||
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
|
||||
<a class="dropdown-item" href="{{ route('users.edit', $item->id) }}">{{ trans('general.edit') }}</a>
|
||||
@if (user()->id != $item->id)
|
||||
@permission('delete-auth-users')
|
||||
@can('delete-auth-users')
|
||||
<div class="dropdown-divider"></div>
|
||||
{!! Form::deleteLink($item, 'users.destroy') !!}
|
||||
@endpermission
|
||||
@endcan
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
@ -38,13 +38,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@permission('update-banking-accounts')
|
||||
@can('update-banking-accounts')
|
||||
<div class="card-footer">
|
||||
<div class="row save-buttons">
|
||||
{{ Form::saveButtons('accounts.index') }}
|
||||
</div>
|
||||
</div>
|
||||
@endpermission
|
||||
@endcan
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
@endsection
|
||||
|
@ -3,9 +3,9 @@
|
||||
@section('title', trans_choice('general.accounts', 2))
|
||||
|
||||
@section('new_button')
|
||||
@permission('create-banking-accounts')
|
||||
@can('create-banking-accounts')
|
||||
<a href="{{ route('accounts.create') }}" class="btn btn-success btn-sm">{{ trans('general.add_new') }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
@ -68,10 +68,10 @@
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
|
||||
<a class="dropdown-item" href="{{ route('accounts.edit', $item->id) }}">{{ trans('general.edit') }}</a>
|
||||
@permission('delete-banking-accounts')
|
||||
@can('delete-banking-accounts')
|
||||
<div class="dropdown-divider"></div>
|
||||
{!! Form::deleteLink($item, 'accounts.destroy') !!}
|
||||
@endpermission
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
@ -107,7 +107,7 @@
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@permission('update-banking-reconciliations')
|
||||
@can('update-banking-reconciliations')
|
||||
<div class="card-footer">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
@ -131,7 +131,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
|
@ -3,9 +3,9 @@
|
||||
@section('title', trans_choice('general.reconciliations', 2))
|
||||
|
||||
@section('new_button')
|
||||
@permission('create-banking-reconciliations')
|
||||
@can('create-banking-reconciliations')
|
||||
<a href="{{ route('reconciliations.create') }}" class="btn btn-success btn-sm">{{ trans('general.add_new') }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
@ -65,10 +65,10 @@
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
|
||||
<a class="dropdown-item" href="{{ route('reconciliations.edit', $item->id) }}">{{ trans('general.edit') }}</a>
|
||||
@permission('delete-banking-reconciliations')
|
||||
@can('delete-banking-reconciliations')
|
||||
<div class="dropdown-divider"></div>
|
||||
{!! Form::deleteLink($item, 'reconciliations.destroy') !!}
|
||||
@endpermission
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
@ -3,12 +3,12 @@
|
||||
@section('title', trans_choice('general.transactions', 2))
|
||||
|
||||
@section('new_button')
|
||||
@permission('create-sales-revenues')
|
||||
@can('create-sales-revenues')
|
||||
<a href="{{ route('revenues.create') }}" class="btn btn-success btn-sm">{{ trans('general.add_income') }}</a>
|
||||
@endpermission
|
||||
@permission('create-purchases-payments')
|
||||
@endcan
|
||||
@can('create-purchases-payments')
|
||||
<a href="{{ route('payments.create') }}" class="btn btn-success btn-sm">{{ trans('general.add_expense') }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
<a href="{{ route('import.create', ['banking', 'transactions']) }}" class="btn btn-white btn-sm">{{ trans('import.import') }}</a>
|
||||
<a href="{{ route('transactions.export', request()->input()) }}" class="btn btn-white btn-sm">{{ trans('general.export') }}</a>
|
||||
@endsection
|
||||
|
@ -37,13 +37,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@permission('update-banking-transfers')
|
||||
@can('update-banking-transfers')
|
||||
<div class="card-footer">
|
||||
<div class="row save-buttons">
|
||||
{{ Form::saveButtons('transfers.index') }}
|
||||
</div>
|
||||
</div>
|
||||
@endpermission
|
||||
@endcan
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
@endsection
|
||||
|
@ -3,9 +3,9 @@
|
||||
@section('title', trans_choice('general.transfers', 2))
|
||||
|
||||
@section('new_button')
|
||||
@permission('create-banking-transfers')
|
||||
@can('create-banking-transfers')
|
||||
<a href="{{ route('transfers.create') }}" class="btn btn-success btn-sm header-button-top"><span class="fa fa-plus"></span> {{ trans('general.add_new') }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
<span><a href="{{ route('import.create', ['banking', 'transfers']) }}" class="btn btn-white btn-sm header-button-top"><span class="fa fa-upload "></span> {{ trans('import.import') }}</a></span>
|
||||
<span><a href="{{ route('transfers.export', request()->input()) }}" class="btn btn-white btn-sm header-button-top"><span class="fa fa-download"></span> {{ trans('general.export') }}</a></span>
|
||||
@endsection
|
||||
@ -59,10 +59,10 @@
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
|
||||
<a class="dropdown-item" href="{{ route('transfers.edit', $item->id) }}">{{ trans('general.edit') }}</a>
|
||||
@permission('delete-banking-transfers')
|
||||
@can('delete-banking-transfers')
|
||||
<div class="dropdown-divider"></div>
|
||||
{!! Form::deleteLink($item, 'transfers.destroy') !!}
|
||||
@endpermission
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
@ -34,13 +34,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@permission('update-common-companies')
|
||||
@can('update-common-companies')
|
||||
<div class="card-footer">
|
||||
<div class="row save-buttons">
|
||||
{{ Form::saveButtons('companies.index') }}
|
||||
</div>
|
||||
</div>
|
||||
@endpermission
|
||||
@endcan
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
@endsection
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
@section('title', trans_choice('general.companies', 2))
|
||||
|
||||
@permission('create-common-companies')
|
||||
@can('create-common-companies')
|
||||
@section('new_button')
|
||||
<a href="{{ route('companies.create') }}" class="btn btn-success btn-sm">{{ trans('general.add_new') }}</a>
|
||||
@endsection
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@section('content')
|
||||
<div class="card">
|
||||
@ -78,10 +78,10 @@
|
||||
<div class="dropdown-divider"></div>
|
||||
@endif
|
||||
<a class="dropdown-item" href="{{ route('companies.edit', $item->id) }}">{{ trans('general.edit') }}</a>
|
||||
@permission('delete-common-companies')
|
||||
@can('delete-common-companies')
|
||||
<div class="dropdown-divider"></div>
|
||||
{!! Form::deleteLink($item, 'companies.destroy') !!}
|
||||
@endpermission
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
@ -19,9 +19,9 @@
|
||||
<div class="row">
|
||||
{{ Form::textGroup('name', trans('general.name'), 'font') }}
|
||||
|
||||
@permission('read-auth-users')
|
||||
@can('read-auth-users')
|
||||
{{ Form::checkboxGroup('users', trans_choice('general.users', 2), $users, 'name') }}
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
{{ Form::radioGroup('enabled', trans('general.enabled'), true) }}
|
||||
</div>
|
||||
|
@ -20,21 +20,21 @@
|
||||
<div class="row">
|
||||
{{ Form::textGroup('name', trans('general.name'), 'font') }}
|
||||
|
||||
@permission('read-auth-users')
|
||||
@can('read-auth-users')
|
||||
{{ Form::checkboxGroup('users', trans_choice('general.users', 2), $users, 'name') }}
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
{{ Form::radioGroup('enabled', trans('general.enabled'), $dashboard->enabled) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@permission('update-common-dashboards')
|
||||
@can('update-common-dashboards')
|
||||
<div class="card-footer">
|
||||
<div class="row save-buttons">
|
||||
{{ Form::saveButtons('dashboards.index') }}
|
||||
</div>
|
||||
</div>
|
||||
@endpermission
|
||||
@endcan
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
@endsection
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
@section('title', trans_choice('general.dashboards', 2))
|
||||
|
||||
@permission('create-common-dashboards')
|
||||
@can('create-common-dashboards')
|
||||
@section('new_button')
|
||||
<a href="{{ route('dashboards.create') }}" class="btn btn-success btn-sm">{{ trans('general.add_new') }}</a>
|
||||
@endsection
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@section('content')
|
||||
<div class="card">
|
||||
@ -68,10 +68,10 @@
|
||||
<div class="dropdown-divider"></div>
|
||||
@endif
|
||||
<a class="dropdown-item" href="{{ route('dashboards.edit', $item->id) }}">{{ trans('general.edit') }}</a>
|
||||
@permission('delete-common-dashboards')
|
||||
@can('delete-common-dashboards')
|
||||
<div class="dropdown-divider"></div>
|
||||
{!! Form::deleteLink($item, 'dashboards.destroy') !!}
|
||||
@endpermission
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
@ -3,7 +3,7 @@
|
||||
@section('title', $dashboard->name)
|
||||
|
||||
@section('dashboard_action')
|
||||
@permission(['create-common-widgets', 'read-common-dashboards'])
|
||||
@canany(['create-common-widgets', 'read-common-dashboards'])
|
||||
<span class="dashboard-action">
|
||||
<div class="dropdown">
|
||||
<a class="btn btn-sm items-align-center py-2 mt--1" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
@ -11,25 +11,25 @@
|
||||
</a>
|
||||
|
||||
<div class="dropdown-menu dropdown-menu-sm-right dropdown-menu-xs-right dropdown-menu-arrow">
|
||||
@permission('create-common-widgets')
|
||||
@can('create-common-widgets')
|
||||
{!! Form::button(trans('general.title.add', ['type' => trans_choice('general.widgets', 1)]), [
|
||||
'type' => 'button',
|
||||
'class' => 'dropdown-item',
|
||||
'title' => trans('general.title.add', ['type' => trans_choice('general.widgets', 1)]),
|
||||
'@click' => 'onCreateWidget()',
|
||||
]) !!}
|
||||
@endpermission
|
||||
@permission('update-common-dashboards')
|
||||
@endcan
|
||||
@can('update-common-dashboards')
|
||||
<div class="dropdown-divider"></div>
|
||||
@permission('create-common-dashboards')
|
||||
@can('create-common-dashboards')
|
||||
<a class="dropdown-item" href="{{ route('dashboards.create') }}">{{ trans('general.title.create', ['type' => trans_choice('general.dashboards', 1)]) }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
<a class="dropdown-item" href="{{ route('dashboards.index') }}">{{ trans('general.title.manage', ['type' => trans_choice('general.dashboards', 2)]) }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
@endpermission
|
||||
@endcanany
|
||||
|
||||
@php
|
||||
$text = json_encode([
|
||||
|
@ -36,13 +36,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@permission('update-common-items')
|
||||
@can('update-common-items')
|
||||
<div class="card-footer">
|
||||
<div class="row save-buttons">
|
||||
{{ Form::saveButtons('items.index') }}
|
||||
</div>
|
||||
</div>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
|
@ -3,10 +3,10 @@
|
||||
@section('title', trans_choice('general.items', 2))
|
||||
|
||||
@section('new_button')
|
||||
@permission('create-common-items')
|
||||
@can('create-common-items')
|
||||
<a href="{{ route('items.create') }}" class="btn btn-success btn-sm">{{ trans('general.add_new') }}</a>
|
||||
<a href="{{ route('import.create', ['common', 'items']) }}" class="btn btn-white btn-sm">{{ trans('import.import') }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
<a href="{{ route('items.export', request()->input()) }}" class="btn btn-white btn-sm">{{ trans('general.export') }}</a>
|
||||
@endsection
|
||||
|
||||
@ -82,14 +82,14 @@
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
|
||||
<a class="dropdown-item" href="{{ route('items.edit', $item->id) }}">{{ trans('general.edit') }}</a>
|
||||
@permission('create-common-items')
|
||||
@can('create-common-items')
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="{{ route('items.duplicate', $item->id) }}">{{ trans('general.duplicate') }}</a>
|
||||
@endpermission
|
||||
@permission('delete-common-items')
|
||||
@endcan
|
||||
@can('delete-common-items')
|
||||
<div class="dropdown-divider"></div>
|
||||
{!! Form::deleteLink($item, 'items.destroy') !!}
|
||||
@endpermission
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
@ -67,13 +67,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@permission('update-common-reports')
|
||||
@can('update-common-reports')
|
||||
<div class="card-footer">
|
||||
<div class="row save-buttons">
|
||||
{{ Form::saveButtons('reports.index') }}
|
||||
</div>
|
||||
</div>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
|
@ -3,9 +3,9 @@
|
||||
@section('title', trans_choice('general.reports', 2))
|
||||
|
||||
@section('new_button')
|
||||
@permission('create-common-reports')
|
||||
@can('create-common-reports')
|
||||
<a href="{{ route('reports.create') }}" class="btn btn-success btn-sm">{{ trans('general.add_new') }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
<a href="{{ route('reports.clear') }}" class="btn btn-warning btn-sm">{{ trans('general.clear_cache') }}</a>
|
||||
@endsection
|
||||
|
||||
@ -26,14 +26,14 @@
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
|
||||
<a class="dropdown-item" href="{{ route('reports.edit', $report->id) }}">{{ trans('general.edit') }}</a>
|
||||
@permission('create-common-reports')
|
||||
@can('create-common-reports')
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="{{ route('reports.duplicate', $report->id) }}">{{ trans('general.duplicate') }}</a>
|
||||
@endpermission
|
||||
@permission('delete-common-reports')
|
||||
@endcan
|
||||
@can('delete-common-reports')
|
||||
<div class="dropdown-divider"></div>
|
||||
{!! Form::deleteLink($report, 'common/reports') !!}
|
||||
@endpermission
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
|
@ -83,7 +83,7 @@
|
||||
</div>
|
||||
|
||||
<div class="card-footer">
|
||||
@permission('create-modules-item')
|
||||
@can('create-modules-item')
|
||||
@if ($module->install)
|
||||
<a href="#" class="btn btn-warning btn-block" disabled="disabled">
|
||||
{{ trans('modules.pre_sale') }}
|
||||
@ -93,7 +93,7 @@
|
||||
{{ trans('modules.pre_sale') }}
|
||||
</a>
|
||||
@endif
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@if (!empty($module->purchase_desc))
|
||||
<div class="text-center mt-3">
|
||||
|
@ -219,19 +219,19 @@
|
||||
|
||||
<div class="card-footer">
|
||||
@if ($installed)
|
||||
@permission('delete-modules-item')
|
||||
@can('delete-modules-item')
|
||||
<a href="{{ route('apps.app.uninstall', $module->slug) }}" class="btn btn-block btn-danger">{{ trans('modules.button.uninstall') }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@permission('update-modules-item')
|
||||
@can('update-modules-item')
|
||||
@if ($enable)
|
||||
<a href="{{ route('apps.app.disable', $module->slug) }}" class="btn btn-block btn-warning">{{ trans('modules.button.disable') }}</a>
|
||||
@else
|
||||
<a href="{{ route('apps.app.enable', $module->slug) }}" class="btn btn-block btn-success">{{ trans('modules.button.enable') }}</a>
|
||||
@endif
|
||||
@endpermission
|
||||
@endcan
|
||||
@else
|
||||
@permission('create-modules-item')
|
||||
@can('create-modules-item')
|
||||
@if ($module->install)
|
||||
<button type="button" @click="onInstall('{{ $module->action_url }}', '{{ $module->name }}', '{{ $module->version }}')" class="btn btn-success btn-block" id="install-module">
|
||||
{{ trans('modules.install') }}
|
||||
@ -241,7 +241,7 @@
|
||||
{{ trans('modules.buy_now') }}
|
||||
</a>
|
||||
@endif
|
||||
@endpermission
|
||||
@endcan
|
||||
@endif
|
||||
|
||||
@if (!empty($module->purchase_desc))
|
||||
|
@ -9,11 +9,11 @@
|
||||
<img class="border-radius-none border-0 mr-3" alt="Akaunting" src="{{ asset('public/img/akaunting-logo-white.svg') }}">
|
||||
</span>
|
||||
<span class="nav-link-text long-texts pl-2 mwpx-100">{{ Str::limit(setting('company.name'), 22) }}</span>
|
||||
@permission('read-common-companies')
|
||||
@can('read-common-companies')
|
||||
<i class="fas fa-sort-down pl-2"></i>
|
||||
@endpermission
|
||||
@endcan
|
||||
</a>
|
||||
@permission('read-common-companies')
|
||||
@can('read-common-companies')
|
||||
<div class="dropdown-menu dropdown-menu-right menu-dropdown menu-dropdown-width">
|
||||
@foreach($companies as $com)
|
||||
<a href="{{ route('companies.switch', $com->id) }}" class="dropdown-item">
|
||||
@ -21,15 +21,15 @@
|
||||
<span>{{ Str::limit($com->name, 18) }}</span>
|
||||
</a>
|
||||
@endforeach
|
||||
@permission('update-common-companies')
|
||||
@can('update-common-companies')
|
||||
<div class="dropdown-divider"></div>
|
||||
<a href="{{ route('companies.index') }}" class="dropdown-item">
|
||||
<i class="fas fa-cogs"></i>
|
||||
<span>{{ trans('general.title.manage', ['type' => trans_choice('general.companies', 2)]) }}</span>
|
||||
</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
</div>
|
||||
@endpermission
|
||||
@endcan
|
||||
</li>
|
||||
</ul>
|
||||
<div class="ml-auto left-menu-toggle-position overflow-hidden">
|
||||
|
@ -4,7 +4,7 @@
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
@stack('navbar_search')
|
||||
|
||||
@permission('read-common-search')
|
||||
@can('read-common-search')
|
||||
<form class="navbar-search navbar-search-light form-inline mb-0" id="navbar-search-main" autocomplete="off">
|
||||
<div id="global-search" class="form-group mb-0 mr-sm-3">
|
||||
<div class="input-group input-group-alternative input-group-merge">
|
||||
@ -36,7 +36,7 @@
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</form>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
<ul class="navbar-nav align-items-center ml-md-auto">
|
||||
<li class="nav-item d-xl-none">
|
||||
@ -57,7 +57,7 @@
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@permission(['create-sales-invoices', 'create-sales-revenues', 'create-sales-invoices', 'create-purchases-bills', 'create-purchases-payments', 'create-purchases-vendors'])
|
||||
@canany(['create-sales-invoices', 'create-sales-revenues', 'create-sales-invoices', 'create-purchases-bills', 'create-purchases-payments', 'create-purchases-vendors'])
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fas fa-plus"></i>
|
||||
@ -66,75 +66,75 @@
|
||||
<div class="row shortcuts px-4">
|
||||
@stack('navbar_create_invoice')
|
||||
|
||||
@permission('create-sales-invoices')
|
||||
@can('create-sales-invoices')
|
||||
<a href="{{ route('invoices.create') }}" class="col-4 shortcut-item">
|
||||
<span class="shortcut-media avatar rounded-circle bg-gradient-info">
|
||||
<i class="fa fa-money-bill"></i>
|
||||
</span>
|
||||
<small class="text-info">{{ trans_choice('general.invoices', 1) }}</small>
|
||||
</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@stack('navbar_create_revenue')
|
||||
|
||||
@permission('create-sales-revenues')
|
||||
@can('create-sales-revenues')
|
||||
<a href="{{ route('revenues.create') }}" class="col-4 shortcut-item">
|
||||
<span class="shortcut-media avatar rounded-circle bg-gradient-info">
|
||||
<i class="fas fa-hand-holding-usd"></i>
|
||||
</span>
|
||||
<small class="text-info">{{ trans_choice('general.revenues', 1) }}</small>
|
||||
</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@stack('navbar_create_customer')
|
||||
|
||||
@permission('create-sales-customers')
|
||||
@can('create-sales-customers')
|
||||
<a href="{{ route('customers.create') }}" class="col-4 shortcut-item">
|
||||
<span class="shortcut-media avatar rounded-circle bg-gradient-info">
|
||||
<i class="fas fa-user"></i>
|
||||
</span>
|
||||
<small class="text-info">{{ trans_choice('general.customers', 1) }}</small>
|
||||
</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@stack('navbar_create_bill')
|
||||
|
||||
@permission('create-purchases-bills')
|
||||
@can('create-purchases-bills')
|
||||
<a href="{{ route('bills.create') }}" class="col-4 shortcut-item">
|
||||
<span class="shortcut-media avatar rounded-circle bg-gradient-danger">
|
||||
<i class="fa fa-shopping-cart"></i>
|
||||
</span>
|
||||
<small class="text-danger">{{ trans_choice('general.bills', 1) }}</small>
|
||||
</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@stack('navbar_create_payment')
|
||||
|
||||
@permission('create-purchases-payments')
|
||||
@can('create-purchases-payments')
|
||||
<a href="{{ route('payments.create') }}" class="col-4 shortcut-item">
|
||||
<span class="shortcut-media avatar rounded-circle bg-gradient-danger">
|
||||
<i class="fas fa-hand-holding-usd"></i>
|
||||
</span>
|
||||
<small class="text-danger">{{ trans_choice('general.payments', 1) }}</small>
|
||||
</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@stack('navbar_create_vendor_start')
|
||||
|
||||
@permission('create-purchases-vendors')
|
||||
@can('create-purchases-vendors')
|
||||
<a href="{{ route('vendors.create') }}" class="col-4 shortcut-item">
|
||||
<span class="shortcut-media avatar rounded-circle bg-gradient-danger">
|
||||
<i class="fas fa-user"></i>
|
||||
</span>
|
||||
<small class="text-danger">{{ trans_choice('general.vendors', 1) }}</small>
|
||||
</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@stack('navbar_create_vendor_end')
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
@endpermission
|
||||
@endcanany
|
||||
|
||||
@stack('navbar_notifications')
|
||||
|
||||
@ -197,7 +197,7 @@
|
||||
|
||||
@stack('navbar_updates')
|
||||
|
||||
@permission('read-install-updates')
|
||||
@can('read-install-updates')
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ route('updates.index') }}" title="{{ $updates }} Updates Available" role="button" aria-haspopup="true" aria-expanded="false">
|
||||
<span>
|
||||
@ -208,7 +208,7 @@
|
||||
@endif
|
||||
</a>
|
||||
</li>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@stack('navbar_help_start')
|
||||
|
||||
@ -251,45 +251,45 @@
|
||||
|
||||
@stack('navbar_profile_edit')
|
||||
|
||||
@permission(['read-auth-users', 'read-auth-profile'])
|
||||
@can(['read-auth-users', 'read-auth-profile'])
|
||||
<a href="{{ route('users.edit', $user->id) }}" class="dropdown-item">
|
||||
<i class="fas fa-user"></i>
|
||||
<span>{{ trans('auth.profile') }}</span>
|
||||
</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@permission(['read-auth-users', 'read-auth-roles', 'read-auth-permissions'])
|
||||
@canany(['read-auth-users', 'read-auth-roles', 'read-auth-permissions'])
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
@stack('navbar_profile_users')
|
||||
|
||||
@permission('read-auth-users')
|
||||
@can('read-auth-users')
|
||||
<a href="{{ route('users.index') }}" class="dropdown-item">
|
||||
<i class="fas fa-users"></i>
|
||||
<span>{{ trans_choice('general.users', 2) }}</span>
|
||||
</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@stack('navbar_profile_roles')
|
||||
|
||||
@permission('read-auth-roles')
|
||||
@can('read-auth-roles')
|
||||
<a href="{{ route('roles.index') }}" class="dropdown-item">
|
||||
<i class="fas fa-list"></i>
|
||||
<span>{{ trans_choice('general.roles', 2) }}</span>
|
||||
</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@stack('navbar_profile_permissions_start')
|
||||
|
||||
@permission('read-auth-permissions')
|
||||
@can('read-auth-permissions')
|
||||
<a href="{{ route('permissions.index') }}" class="dropdown-item">
|
||||
<i class="fas fa-key"></i>
|
||||
<span>{{ trans_choice('general.permissions', 2) }}</span>
|
||||
</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@stack('navbar_profile_permissions_end')
|
||||
@endpermission
|
||||
@endcanany
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
</div>
|
||||
|
||||
<div class="col-auto">
|
||||
@permission('delete-common-uploads')
|
||||
@can('delete-common-uploads')
|
||||
<a href="javascript:void();" id="remove-{{ $column_name }}" @click="onDeleteFile('{{ $file->id }}', '{{ route('uploads.destroy', $file->id) }}', '{{ trans('general.title.delete', ['type' => $column_name]) }}', '{{ trans('general.delete_confirm', ['name' => $file->basename, 'type' => $column_name]) }} ', '{{ trans('general.cancel') }}', '{{ trans('general.delete') }}')" type="button" class="btn btn-sm btn-danger text-white header-button-top">
|
||||
<i class="fas fa-times"></i>
|
||||
</a>
|
||||
@ -35,7 +35,7 @@
|
||||
<input type="hidden" name="key_{{ $file->id}}" id="file-key-{{ $file->id}}" value="{{ $options['key'] }}" />
|
||||
<input type="hidden" name="value_{{ $file->id}}" id="file-value-{{ $file->id}}" value="{{ $file->id }}" />
|
||||
@endif
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
<a href="{{ route('uploads.download', $file->id) }}" type="button" class="btn btn-sm btn-info text-white header-button-top">
|
||||
<i class="fas fa-file-download"></i>
|
||||
|
@ -67,7 +67,7 @@
|
||||
</div>
|
||||
</li>
|
||||
|
||||
@permission('read-install-updates')
|
||||
@can('read-install-updates')
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ route('updates.index') }}" title="{{ $updates }} Updates Available" role="button" aria-haspopup="true" aria-expanded="false">
|
||||
<span>
|
||||
@ -78,7 +78,7 @@
|
||||
@endif
|
||||
</a>
|
||||
</li>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
<li class="nav-item d-none d-md-block">
|
||||
<a class="nav-link" href="{{ url(trans('header.support_link')) }}" target="_blank" title="{{ trans('general.help') }}" role="button" aria-haspopup="true" aria-expanded="false">
|
||||
|
@ -1,4 +1,4 @@
|
||||
@permission(['update-common-widgets', 'delete-common-widgets'])
|
||||
@canany(['update-common-widgets', 'delete-common-widgets'])
|
||||
<div class="card-header{{ !empty($header_class) ? ' ' . $header_class : '' }}">
|
||||
<div class="row align-items-center">
|
||||
|
||||
@ -14,22 +14,22 @@
|
||||
</a>
|
||||
|
||||
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
|
||||
@permission('update-common-widgets')
|
||||
@can('update-common-widgets')
|
||||
{!! Form::button(trans('general.edit'), [
|
||||
'type' => 'button',
|
||||
'class' => 'dropdown-item',
|
||||
'title' => trans('general.edit'),
|
||||
'@click' => 'onEditWidget(' . $class->model->id . ')'
|
||||
]) !!}
|
||||
@endpermission
|
||||
@permission('delete-common-widgets')
|
||||
@endcan
|
||||
@can('delete-common-widgets')
|
||||
<div class="dropdown-divider"></div>
|
||||
{!! Form::deleteLink($class->model, 'common/widgets') !!}
|
||||
@endpermission
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endpermission
|
||||
@endcanany
|
||||
|
@ -1,4 +1,4 @@
|
||||
@permission(['update-common-widgets', 'delete-common-widgets'])
|
||||
@canany(['update-common-widgets', 'delete-common-widgets'])
|
||||
<span>
|
||||
<div class="dropdown card-action-button">
|
||||
<a class="btn btn-sm items-align-center py-2 mr-0 shadow-none--hover" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
@ -6,19 +6,19 @@
|
||||
</a>
|
||||
|
||||
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
|
||||
@permission('update-common-widgets')
|
||||
@can('update-common-widgets')
|
||||
{!! Form::button(trans('general.edit'), [
|
||||
'type' => 'button',
|
||||
'class' => 'dropdown-item',
|
||||
'title' => trans('general.edit'),
|
||||
'@click' => 'onEditWidget(' . $class->model->id . ')'
|
||||
]) !!}
|
||||
@endpermission
|
||||
@permission('delete-common-widgets')
|
||||
@endcan
|
||||
@can('delete-common-widgets')
|
||||
<div class="dropdown-divider"></div>
|
||||
{!! Form::deleteLink($class->model, 'common/widgets') !!}
|
||||
@endpermission
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
@endpermission
|
||||
@endcanany
|
||||
|
@ -38,13 +38,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@permission(['update-portal-profile'])
|
||||
@canany(['update-portal-profile'])
|
||||
<div class="card-footer">
|
||||
<div class="row save-buttons">
|
||||
{{ Form::saveButtons('portal.dashboard') }}
|
||||
</div>
|
||||
</div>
|
||||
@endpermission
|
||||
@endcanany
|
||||
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
|
@ -212,13 +212,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@permission('update-purchases-bills')
|
||||
@can('update-purchases-bills')
|
||||
<div class="card-footer">
|
||||
<div class="row save-buttons">
|
||||
{{ Form::saveButtons('bills.index') }}
|
||||
</div>
|
||||
</div>
|
||||
@endpermission
|
||||
@endcan
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
@endsection
|
||||
|
@ -3,10 +3,10 @@
|
||||
@section('title', trans_choice('general.bills', 2))
|
||||
|
||||
@section('new_button')
|
||||
@permission('create-purchases-bills')
|
||||
@can('create-purchases-bills')
|
||||
<a href="{{ route('bills.create') }}" class="btn btn-success btn-sm">{{ trans('general.add_new') }}</a>
|
||||
<a href="{{ route('import.create', ['group' => 'purchases', 'type' => 'bills']) }}" class="btn btn-white btn-sm">{{ trans('import.import') }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
<a href="{{ route('bills.export', request()->input()) }}" class="btn btn-white btn-sm">{{ trans('general.export') }}</a>
|
||||
@endsection
|
||||
|
||||
@ -73,21 +73,21 @@
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
@if ($item->status != 'cancelled')
|
||||
@permission('create-purchases-bills')
|
||||
@can('create-purchases-bills')
|
||||
<a class="dropdown-item" href="{{ route('bills.duplicate', $item->id) }}">{{ trans('general.duplicate') }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@permission('update-purchases-bills')
|
||||
@can('update-purchases-bills')
|
||||
<a class="dropdown-item" href="{{ route('bills.cancelled', $item->id) }}">{{ trans('general.cancel') }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
@endif
|
||||
|
||||
@permission('delete-purchases-bills')
|
||||
@can('delete-purchases-bills')
|
||||
<div class="dropdown-divider"></div>
|
||||
@if (!$item->reconciled)
|
||||
{!! Form::deleteLink($item, 'bills.destroy') !!}
|
||||
@endif
|
||||
@endpermission
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
@ -102,9 +102,9 @@
|
||||
|
||||
<div class="mt-3">
|
||||
@stack('timeline_body_receive_bill_body_button_received_start')
|
||||
@permission('update-purchases-bills')
|
||||
@can('update-purchases-bills')
|
||||
<a href="{{ route('bills.received', $bill->id) }}" class="btn btn-danger btn-sm btn-alone">{{ trans('bills.mark_received') }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
@stack('timeline_body_receive_bill_body_button_received_end')
|
||||
</div>
|
||||
@else
|
||||
@ -142,9 +142,9 @@
|
||||
|
||||
<div class="mt-3">
|
||||
@stack('timeline_body_get_paid_body_button_pay_start')
|
||||
@permission('update-purchases-bills')
|
||||
@can('update-purchases-bills')
|
||||
<a href="{{ route('bills.paid', $bill->id) }}" class="btn btn-white btn-sm header-button-top">{{ trans('bills.mark_paid') }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
@stack('timeline_body_get_paid_body_button_pay_end')
|
||||
|
||||
@stack('timeline_body_make_payment_body_button_payment_start')
|
||||
@ -468,9 +468,9 @@
|
||||
@if ($bill->status != 'cancelled')
|
||||
@if ($bill->status != 'paid')
|
||||
@stack('button_pay_start')
|
||||
@permission('update-purchases-bills')
|
||||
@can('update-purchases-bills')
|
||||
<a class="dropdown-item" href="{{ route('bills.paid', $bill->id) }}">{{ trans('bills.mark_paid') }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@if (empty($bill->paid) || ($bill->paid != $bill->amount))
|
||||
<button class="dropdown-item" id="button-payment" @click="onPayment">{{ trans('bills.add_payment') }}</button>
|
||||
@ -481,7 +481,7 @@
|
||||
|
||||
@stack('button_dropdown_divider_1')
|
||||
|
||||
@permission('update-purchases-bills')
|
||||
@can('update-purchases-bills')
|
||||
@stack('button_received_start')
|
||||
@if ($bill->status == 'draft')
|
||||
<a class="dropdown-item" href="{{ route('bills.received', $bill->id) }}">{{ trans('bills.mark_received') }}</a></a>
|
||||
@ -489,30 +489,30 @@
|
||||
<button type="button" class="dropdown-item" disabled="disabled">{{ trans('bills.mark_received') }}</button>
|
||||
@endif
|
||||
@stack('button_received_end')
|
||||
@endpermission
|
||||
@endcan
|
||||
@endif
|
||||
|
||||
@stack('button_pdf_start')
|
||||
<a class="dropdown-item" href="{{ route('bills.pdf', $bill->id) }}">{{ trans('bills.download_pdf') }}</a>
|
||||
@stack('button_pdf_end')
|
||||
|
||||
@permission('update-purchases-bills')
|
||||
@can('update-purchases-bills')
|
||||
@if ($bill->status != 'cancelled')
|
||||
@stack('button_cancelled_start')
|
||||
<a class="dropdown-item" href="{{ route('bills.cancelled', $bill->id) }}">{{ trans('general.cancel') }}</a>
|
||||
@stack('button_cancelled_end')
|
||||
@endif
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@stack('button_dropdown_divider_2')
|
||||
|
||||
@permission('delete-purchases-bills')
|
||||
@can('delete-purchases-bills')
|
||||
@if (!$bill->reconciled)
|
||||
@stack('button_delete_start')
|
||||
{!! Form::deleteLink($bill, 'purchases/bills') !!}
|
||||
@stack('button_delete_end')
|
||||
@endif
|
||||
@endpermission
|
||||
@endcan
|
||||
@stack('button_dropdown_end')
|
||||
</div>
|
||||
</div>
|
||||
|
@ -73,13 +73,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@permission('update-purchases-payments')
|
||||
@can('update-purchases-payments')
|
||||
<div class="card-footer">
|
||||
<div class="row save-buttons">
|
||||
{{ Form::saveButtons('payments.index') }}
|
||||
</div>
|
||||
</div>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
{{ Form::hidden('type', 'expense') }}
|
||||
{!! Form::close() !!}
|
||||
|
@ -3,10 +3,10 @@
|
||||
@section('title', trans_choice('general.payments', 2))
|
||||
|
||||
@section('new_button')
|
||||
@permission('create-purchases-payments')
|
||||
@can('create-purchases-payments')
|
||||
<a href="{{ route('payments.create') }}" class="btn btn-success btn-sm">{{ trans('general.add_new') }}</a>
|
||||
<a href="{{ route('import.create', ['group' => 'purchases', 'type' => 'payments']) }}" class="btn btn-white btn-sm">{{ trans('import.import') }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
<a href="{{ route('payments.export', request()->input()) }}" class="btn btn-white btn-sm">{{ trans('general.export') }}</a>
|
||||
@endsection
|
||||
|
||||
@ -93,15 +93,15 @@
|
||||
<div class="dropdown-divider"></div>
|
||||
@endif
|
||||
@if (empty($item->document_id))
|
||||
@permission('create-purchases-payments')
|
||||
@can('create-purchases-payments')
|
||||
<a class="dropdown-item" href="{{ route('payments.duplicate', $item->id) }}">{{ trans('general.duplicate') }}</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
@endpermission
|
||||
@endcan
|
||||
@endif
|
||||
@if (!$item->reconciled)
|
||||
@permission('delete-purchases-payments')
|
||||
@can('delete-purchases-payments')
|
||||
{!! Form::deleteLink($item, 'payments.destroy') !!}
|
||||
@endpermission
|
||||
@endcan
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
@ -40,13 +40,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@permission('update-purchases-vendors')
|
||||
@can('update-purchases-vendors')
|
||||
<div class="card-footer">
|
||||
<div class="row save-buttons">
|
||||
{{ Form::saveButtons('vendors.index') }}
|
||||
</div>
|
||||
</div>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
{{ Form::hidden('type', 'vendor') }}
|
||||
{!! Form::close() !!}
|
||||
|
@ -3,10 +3,10 @@
|
||||
@section('title', trans_choice('general.vendors', 2))
|
||||
|
||||
@section('new_button')
|
||||
@permission('create-purchases-vendors')
|
||||
@can('create-purchases-vendors')
|
||||
<a href="{{ route('vendors.create') }}" class="btn btn-success btn-sm">{{ trans('general.add_new') }}</a>
|
||||
<a href="{{ route('import.create', ['group' => 'purchases', 'type' => 'vendors']) }}" class="btn btn-white btn-sm">{{ trans('import.import') }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
<a href="{{ route('vendors.export', request()->input()) }}" class="btn btn-white btn-sm">{{ trans('general.export') }}</a>
|
||||
@endsection
|
||||
|
||||
@ -82,14 +82,14 @@
|
||||
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
|
||||
<a class="dropdown-item" href="{{ route('vendors.show', $item->id) }}">{{ trans('general.show') }}</a>
|
||||
<a class="dropdown-item" href="{{ route('vendors.edit', $item->id) }}">{{ trans('general.edit') }}</a>
|
||||
@permission('create-purchases-vendors')
|
||||
@can('create-purchases-vendors')
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="{{ route('vendors.duplicate', $item->id) }}">{{ trans('general.duplicate') }}</a>
|
||||
@endpermission
|
||||
@permission('delete-purchases-vendors')
|
||||
@endcan
|
||||
@can('delete-purchases-vendors')
|
||||
<div class="dropdown-divider"></div>
|
||||
{!! Form::deleteLink($item, 'vendors.destroy') !!}
|
||||
@endpermission
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
@ -71,13 +71,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@permission('update-sales-customers')
|
||||
@can('update-sales-customers')
|
||||
<div class="card-footer">
|
||||
<div class="row save-buttons">
|
||||
{{ Form::saveButtons('customers.index') }}
|
||||
</div>
|
||||
</div>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
{{ Form::hidden('type', 'customer') }}
|
||||
|
||||
|
@ -3,10 +3,10 @@
|
||||
@section('title', trans_choice('general.customers', 2))
|
||||
|
||||
@section('new_button')
|
||||
@permission('create-sales-customers')
|
||||
@can('create-sales-customers')
|
||||
<a href="{{ route('customers.create') }}" class="btn btn-success btn-sm">{{ trans('general.add_new') }}</a>
|
||||
<a href="{{ route('import.create', ['group' => 'sales', 'type' => 'customers']) }}" class="btn btn-white btn-sm">{{ trans('import.import') }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
<a href="{{ route('customers.export', request()->input()) }}" class="btn btn-white btn-sm header-button-top">{{ trans('general.export') }}</a>
|
||||
@endsection
|
||||
|
||||
@ -84,14 +84,14 @@
|
||||
<a class="dropdown-item" href="{{ route('customers.edit', $item->id) }}">{{ trans('general.edit') }}</a>
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
@permission('create-sales-customers')
|
||||
@can('create-sales-customers')
|
||||
<a class="dropdown-item" href="{{ route('customers.duplicate', $item->id) }}">{{ trans('general.duplicate') }}</a>
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
@endpermission
|
||||
@permission('delete-sales-customers')
|
||||
@endcan
|
||||
@can('delete-sales-customers')
|
||||
{!! Form::deleteLink($item, 'customers.destroy') !!}
|
||||
@endpermission
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
@ -214,13 +214,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@permission('update-sales-invoices')
|
||||
@can('update-sales-invoices')
|
||||
<div class="card-footer">
|
||||
<div class="row save-buttons">
|
||||
{{ Form::saveButtons('invoices.index') }}
|
||||
</div>
|
||||
</div>
|
||||
@endpermission
|
||||
@endcan
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
@endsection
|
||||
|
@ -3,10 +3,10 @@
|
||||
@section('title', trans_choice('general.invoices', 2))
|
||||
|
||||
@section('new_button')
|
||||
@permission('create-sales-invoices')
|
||||
@can('create-sales-invoices')
|
||||
<a href="{{ route('invoices.create') }}" class="btn btn-primary btn-sm btn-success header-button-top">{{ trans('general.add_new') }}</a>
|
||||
<a href="{{ route('import.create', ['group' => 'sales', 'type' => 'invoices']) }}" class="btn btn-white btn-sm header-button-top">{{ trans('import.import') }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
<a href="{{ route('invoices.export', request()->input()) }}" class="btn btn-white btn-sm header-button-top">{{ trans('general.export') }}</a>
|
||||
@endsection
|
||||
|
||||
@ -72,21 +72,21 @@
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
@if ($item->status != 'cancelled')
|
||||
@permission('create-sales-invoices')
|
||||
@can('create-sales-invoices')
|
||||
<a class="dropdown-item" href="{{ route('invoices.duplicate', $item->id) }}">{{ trans('general.duplicate') }}</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@permission('update-sales-invoices')
|
||||
@can('update-sales-invoices')
|
||||
<a class="dropdown-item" href="{{ route('invoices.cancelled', $item->id) }}">{{ trans('general.cancel') }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
@endif
|
||||
|
||||
@permission('delete-sales-invoices')
|
||||
@can('delete-sales-invoices')
|
||||
@if (!$item->reconciled)
|
||||
{!! Form::deleteLink($item, 'invoices.destroy') !!}
|
||||
@endif
|
||||
@endpermission
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
@ -100,7 +100,7 @@
|
||||
|
||||
<div class="mt-3">
|
||||
@stack('timeline_body_send_invoice_body_button_sent_start')
|
||||
@permission('update-sales-invoices')
|
||||
@can('update-sales-invoices')
|
||||
@if($invoice->status == 'draft')
|
||||
<a href="{{ route('invoices.sent', $invoice->id) }}" class="btn btn-white btn-sm header-button-top">{{ trans('invoices.mark_sent') }}</a>
|
||||
@else
|
||||
@ -108,7 +108,7 @@
|
||||
<span class="text-disabled">{{ trans('invoices.mark_sent') }}</span>
|
||||
</button>
|
||||
@endif
|
||||
@endpermission
|
||||
@endcan
|
||||
@stack('timeline_body_send_invoice_body_button_sent_end')
|
||||
|
||||
@stack('timeline_body_send_invoice_body_button_email_start')
|
||||
@ -161,9 +161,9 @@
|
||||
|
||||
<div class="mt-3">
|
||||
@stack('timeline_body_get_paid_body_button_pay_start')
|
||||
@permission('update-sales-invoices')
|
||||
@can('update-sales-invoices')
|
||||
<a href="{{ route('invoices.paid', $invoice->id) }}" class="btn btn-white btn-sm header-button-top">{{ trans('invoices.mark_paid') }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
@stack('timeline_body_get_paid_body_button_pay_end')
|
||||
|
||||
@stack('timeline_body_get_paid_body_button_payment_start')
|
||||
@ -490,9 +490,9 @@
|
||||
@if ($invoice->status != 'cancelled')
|
||||
@if ($invoice->status != 'paid')
|
||||
@stack('button_pay_start')
|
||||
@permission('update-sales-invoices')
|
||||
@can('update-sales-invoices')
|
||||
<a class="dropdown-item" href="{{ route('invoices.paid', $invoice->id) }}">{{ trans('invoices.mark_paid') }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@if (empty($invoice->paid) || ($invoice->paid != $invoice->amount))
|
||||
<button class="dropdown-item" id="button-payment" @click="onPayment">{{ trans('invoices.add_payment') }}</button>
|
||||
@ -503,7 +503,7 @@
|
||||
|
||||
@stack('button_dropdown_divider_1')
|
||||
|
||||
@permission('update-sales-invoices')
|
||||
@can('update-sales-invoices')
|
||||
@stack('button_sent_start')
|
||||
@if ($invoice->status == 'draft')
|
||||
<a class="dropdown-item" href="{{ route('invoices.sent', $invoice->id) }}">{{ trans('invoices.mark_sent') }}</a>
|
||||
@ -511,7 +511,7 @@
|
||||
<button type="button" class="dropdown-item" disabled="disabled"><span class="text-disabled">{{ trans('invoices.mark_sent') }}</span></button>
|
||||
@endif
|
||||
@stack('button_sent_end')
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@stack('button_email_start')
|
||||
@if ($invoice->contact_email)
|
||||
@ -528,23 +528,23 @@
|
||||
<a class="dropdown-item" href="{{ route('invoices.pdf', $invoice->id) }}">{{ trans('invoices.download_pdf') }}</a>
|
||||
@stack('button_pdf_end')
|
||||
|
||||
@permission('update-sales-invoices')
|
||||
@can('update-sales-invoices')
|
||||
@if ($invoice->status != 'cancelled')
|
||||
@stack('button_cancelled_start')
|
||||
<a class="dropdown-item" href="{{ route('invoices.cancelled', $invoice->id) }}">{{ trans('general.cancel') }}</a>
|
||||
@stack('button_cancelled_end')
|
||||
@endif
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@stack('button_dropdown_divider_2')
|
||||
|
||||
@permission('delete-sales-invoices')
|
||||
@can('delete-sales-invoices')
|
||||
@if (!$invoice->reconciled)
|
||||
@stack('button_delete_start')
|
||||
{!! Form::deleteLink($invoice, 'sales/invoices') !!}
|
||||
@stack('button_delete_end')
|
||||
@endif
|
||||
@endpermission
|
||||
@endcan
|
||||
@stack('button_dropdown_end')
|
||||
</div>
|
||||
</div>
|
||||
|
@ -73,13 +73,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@permission('update-sales-revenues')
|
||||
@can('update-sales-revenues')
|
||||
<div class="card-footer">
|
||||
<div class="row save-buttons">
|
||||
{{ Form::saveButtons('revenues.index') }}
|
||||
</div>
|
||||
</div>
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
{{ Form::hidden('type', 'income') }}
|
||||
{!! Form::close() !!}
|
||||
|
@ -3,10 +3,10 @@
|
||||
@section('title', trans_choice('general.revenues', 2))
|
||||
|
||||
@section('new_button')
|
||||
@permission('create-sales-revenues')
|
||||
@can('create-sales-revenues')
|
||||
<a href="{{ route('revenues.create') }}" class="btn btn-success btn-sm">{{ trans('general.add_new') }}</a>
|
||||
<a href="{{ route('import.create', ['group' => 'sales', 'type' => 'revenues']) }}" class="btn btn-white btn-sm">{{ trans('import.import') }}</a>
|
||||
@endpermission
|
||||
@endcan
|
||||
<a href="{{ route('revenues.export', request()->input()) }}" class="btn btn-white btn-sm">{{ trans('general.export') }}</a>
|
||||
@endsection
|
||||
|
||||
@ -93,15 +93,15 @@
|
||||
<div class="dropdown-divider"></div>
|
||||
@endif
|
||||
@if (empty($item->document_id))
|
||||
@permission('create-sales-revenues')
|
||||
@can('create-sales-revenues')
|
||||
<a class="dropdown-item" href="{{ route('revenues.duplicate', $item->id) }}">{{ trans('general.duplicate') }}</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
@endpermission
|
||||
@endcan
|
||||
@endif
|
||||
@if (!$item->reconciled)
|
||||
@permission('delete-sales-revenues')
|
||||
@can('delete-sales-revenues')
|
||||
{!! Form::deleteLink($item, 'revenues.destroy') !!}
|
||||
@endpermission
|
||||
@endcan
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
@ -46,13 +46,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@permission('update-settings-categories')
|
||||
@can('update-settings-categories')
|
||||
<div class="card-footer">
|
||||
<div class="row save-buttons">
|
||||
{{ Form::saveButtons('categories.index') }}
|
||||
</div>
|
||||
</div>
|
||||
@endpermission
|
||||
@endcan
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
@endsection
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
@section('title', trans_choice('general.categories', 2))
|
||||
|
||||
@permission('create-settings-categories')
|
||||
@can('create-settings-categories')
|
||||
@section('new_button')
|
||||
<a href="{{ route('categories.create') }}" class="btn btn-success btn-sm">{{ trans('general.add_new') }}</a>
|
||||
@endsection
|
||||
@endpermission
|
||||
@endcan
|
||||
|
||||
@section('content')
|
||||
<div class="card">
|
||||
@ -69,10 +69,10 @@
|
||||
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
|
||||
<a class="dropdown-item" href="{{ route('categories.edit', $item->id) }}">{{ trans('general.edit') }}</a>
|
||||
@if ($item->id != $transfer_id)
|
||||
@permission('delete-settings-categories')
|
||||
@can('delete-settings-categories')
|
||||
<div class="dropdown-divider"></div>
|
||||
{!! Form::deleteLink($item, 'categories.destroy') !!}
|
||||
@endpermission
|
||||
@endcan
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user