diff --git a/_ide_helper_custom.php b/_ide_helper_custom.php index 57714df9b396..bfe7b673dd79 100644 --- a/_ide_helper_custom.php +++ b/_ide_helper_custom.php @@ -14,4 +14,4 @@ namespace Illuminate\Contracts\Mail return true; } } -} \ No newline at end of file +} diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index 859abe405cd7..202bbd554e50 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -12,7 +12,6 @@ namespace App\Console\Commands; use App; -use App\DataMapper\ClientSettings; use App\Factory\ClientContactFactory; use App\Factory\VendorContactFactory; use App\Jobs\Company\CreateCompanyToken; diff --git a/app/Console/Commands/CreateSingleAccount.php b/app/Console/Commands/CreateSingleAccount.php index df64204634eb..07a1355fb103 100644 --- a/app/Console/Commands/CreateSingleAccount.php +++ b/app/Console/Commands/CreateSingleAccount.php @@ -11,54 +11,53 @@ namespace App\Console\Commands; -use stdClass; -use Carbon\Carbon; -use Faker\Factory; -use App\Models\Task; -use App\Models\User; -use App\Utils\Ninja; -use App\Models\Quote; -use App\Models\Client; -use App\Models\Credit; -use App\Models\Vendor; +use App\DataMapper\ClientRegistrationFields; +use App\DataMapper\CompanySettings; +use App\DataMapper\FeesAndLimits; +use App\Events\Invoice\InvoiceWasCreated; +use App\Events\RecurringInvoice\RecurringInvoiceWasCreated; +use App\Factory\GroupSettingFactory; +use App\Factory\InvoiceFactory; +use App\Factory\InvoiceItemFactory; +use App\Factory\RecurringInvoiceFactory; +use App\Factory\SubscriptionFactory; +use App\Helpers\Invoice\InvoiceSum; +use App\Jobs\Company\CreateCompanyTaskStatuses; +use App\Libraries\MultiDB; use App\Models\Account; +use App\Models\BankIntegration; +use App\Models\BankTransaction; +use App\Models\BankTransactionRule; +use App\Models\Client; +use App\Models\ClientContact; use App\Models\Company; +use App\Models\CompanyGateway; +use App\Models\CompanyToken; use App\Models\Country; +use App\Models\Credit; use App\Models\Expense; -use App\Models\Gateway; use App\Models\Invoice; use App\Models\Product; use App\Models\Project; -use App\Models\TaxRate; -use App\Libraries\MultiDB; -use App\Models\TaskStatus; -use App\Models\CompanyToken; -use App\Models\ClientContact; -use App\Models\VendorContact; -use App\Models\CompanyGateway; -use App\Factory\InvoiceFactory; -use App\Models\BankIntegration; -use App\Models\BankTransaction; -use App\Utils\Traits\MakesHash; -use Illuminate\Console\Command; +use App\Models\Quote; use App\Models\RecurringInvoice; -use App\DataMapper\FeesAndLimits; -use App\DataMapper\CompanySettings; -use App\Factory\InvoiceItemFactory; -use App\Helpers\Invoice\InvoiceSum; -use App\Models\BankTransactionRule; -use App\Factory\GroupSettingFactory; -use App\Factory\SubscriptionFactory; -use Illuminate\Support\Facades\Hash; -use Illuminate\Support\Facades\Cache; -use App\Utils\Traits\GeneratesCounter; -use Illuminate\Support\Facades\Schema; +use App\Models\Task; +use App\Models\TaskStatus; +use App\Models\TaxRate; +use App\Models\User; +use App\Models\Vendor; +use App\Models\VendorContact; use App\Repositories\InvoiceRepository; -use App\Factory\RecurringInvoiceFactory; -use App\Events\Invoice\InvoiceWasCreated; -use App\DataMapper\ClientRegistrationFields; -use App\Jobs\Company\CreateCompanyTaskStatuses; -use App\Events\RecurringInvoice\RecurringInvoiceWasCreated; +use App\Utils\Ninja; +use App\Utils\Traits\GeneratesCounter; +use App\Utils\Traits\MakesHash; +use Carbon\Carbon; +use Faker\Factory; +use Illuminate\Console\Command; +use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\Hash; +use Illuminate\Support\Facades\Schema; +use stdClass; class CreateSingleAccount extends Command { @@ -508,7 +507,7 @@ class CreateSingleAccount extends Command private function createTask($client) { - $time_log = $this->createTimeLog(rand(1,20)); + $time_log = $this->createTimeLog(rand(1, 20)); $status = TaskStatus::where('company_id', $client->company_id)->get()->random(); return Task::factory()->create([ @@ -517,8 +516,8 @@ class CreateSingleAccount extends Command 'time_log' => $time_log, 'description' => $this->faker->paragraph, 'status_id' => $status->id ?? null, - 'number' => rand(10000,100000000), - 'rate' => rand(1,150), + 'number' => rand(10000, 100000000), + 'rate' => rand(1, 150), 'client_id' => $client->id ]); } @@ -537,7 +536,7 @@ class CreateSingleAccount extends Command Carbon::now()->addSeconds($min)->timestamp, Carbon::now()->addSeconds($min += $rando)->timestamp, $this->faker->sentence, - rand(0,1) === 0 ? false : true + rand(0, 1) === 0 ? false : true ]; $min += 300; @@ -552,9 +551,9 @@ class CreateSingleAccount extends Command 'user_id' => $client->user->id, 'company_id' => $client->company->id, 'client_id' => $client->id, - 'due_date' => now()->addSeconds(rand(100000,1000000))->format('Y-m-d'), - 'budgeted_hours' => rand(100,1000), - 'task_rate' => rand(1,200), + 'due_date' => now()->addSeconds(rand(100000, 1000000))->format('Y-m-d'), + 'budgeted_hours' => rand(100, 1000), + 'task_rate' => rand(1, 200), ]); for($x=0; $x < rand(2, 5); $x++) { diff --git a/app/Console/Commands/MobileLocalization.php b/app/Console/Commands/MobileLocalization.php index 6692c5281a84..3065ca27360c 100644 --- a/app/Console/Commands/MobileLocalization.php +++ b/app/Console/Commands/MobileLocalization.php @@ -63,7 +63,7 @@ class MobileLocalization extends Command { $resources =(array)$this->getResources(); - if(is_iterable($resources)){ + if(is_iterable($resources)) { foreach ($resources as $key => $val) { $transKey = "texts.{$key}"; if (trans($transKey) == $transKey) { diff --git a/app/DataMapper/Tax/BaseRule.php b/app/DataMapper/Tax/BaseRule.php index acb16f0e95c7..6cc552e5d217 100644 --- a/app/DataMapper/Tax/BaseRule.php +++ b/app/DataMapper/Tax/BaseRule.php @@ -219,7 +219,7 @@ class BaseRule implements RuleInterface try { $this->invoice->saveQuietly(); - }catch(\Exception $e) { + } catch(\Exception $e) { } } diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index e993581e5af2..a3fb052ec297 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -223,8 +223,8 @@ class Handler extends ExceptionHandler return response()->json(['message' => $exception->getMessage()], 500); } elseif ($exception instanceof ThrottleRequestsException && $request->expectsJson()) { return response()->json(['message'=>'Too many requests'], 429); - // } elseif ($exception instanceof FatalThrowableError && $request->expectsJson()) { - // return response()->json(['message'=>'Fatal error'], 500); //@deprecated + // } elseif ($exception instanceof FatalThrowableError && $request->expectsJson()) { + // return response()->json(['message'=>'Fatal error'], 500); //@deprecated } elseif ($exception instanceof AuthorizationException && $request->expectsJson()) { return response()->json(['message'=> $exception->getMessage()], 401); } elseif ($exception instanceof TokenMismatchException) { diff --git a/app/Export/CSV/BaseExport.php b/app/Export/CSV/BaseExport.php index 55b931550cf0..34c735789c33 100644 --- a/app/Export/CSV/BaseExport.php +++ b/app/Export/CSV/BaseExport.php @@ -760,7 +760,7 @@ class BaseExport return $transformed_payment[$column]; } elseif (array_key_exists(str_replace("payment.", "", $column), $transformed_payment)) { return $transformed_payment[$column]; - } + } // nlog("export: Could not resolve payment key: {$column}"); diff --git a/app/Export/CSV/ClientExport.php b/app/Export/CSV/ClientExport.php index 6579ed3f04fc..3eb0cf0de130 100644 --- a/app/Export/CSV/ClientExport.php +++ b/app/Export/CSV/ClientExport.php @@ -11,17 +11,17 @@ namespace App\Export\CSV; +use App\Export\Decorators\Decorator; +use App\Libraries\MultiDB; +use App\Models\Client; +use App\Models\Company; +use App\Transformers\ClientContactTransformer; +use App\Transformers\ClientTransformer; use App\Utils\Ninja; use App\Utils\Number; -use App\Models\Client; -use League\Csv\Writer; -use App\Models\Company; -use App\Libraries\MultiDB; -use Illuminate\Support\Facades\App; -use App\Export\Decorators\Decorator; -use App\Transformers\ClientTransformer; use Illuminate\Database\Eloquent\Builder; -use App\Transformers\ClientContactTransformer; +use Illuminate\Support\Facades\App; +use League\Csv\Writer; class ClientExport extends BaseExport { diff --git a/app/Export/CSV/PaymentExport.php b/app/Export/CSV/PaymentExport.php index 86ee229bfd5f..a74fe4c2eb4b 100644 --- a/app/Export/CSV/PaymentExport.php +++ b/app/Export/CSV/PaymentExport.php @@ -11,15 +11,15 @@ namespace App\Export\CSV; -use App\Utils\Ninja; -use League\Csv\Writer; +use App\Export\Decorators\Decorator; +use App\Libraries\MultiDB; use App\Models\Company; use App\Models\Payment; -use App\Libraries\MultiDB; -use Illuminate\Support\Facades\App; use App\Transformers\PaymentTransformer; +use App\Utils\Ninja; use Illuminate\Database\Eloquent\Builder; -use App\Export\Decorators\Decorator; +use Illuminate\Support\Facades\App; +use League\Csv\Writer; class PaymentExport extends BaseExport { diff --git a/app/Export/Decorators/ClientDecorator.php b/app/Export/Decorators/ClientDecorator.php index e05abac51b3a..6fb1b70b8486 100644 --- a/app/Export/Decorators/ClientDecorator.php +++ b/app/Export/Decorators/ClientDecorator.php @@ -21,10 +21,9 @@ class ClientDecorator extends Decorator implements DecoratorInterface { $client = false; - if($entity instanceof Client){ + if($entity instanceof Client) { $client = $entity; - } - elseif($entity->client) { + } elseif($entity->client) { $client = $entity->client; } @@ -35,126 +34,192 @@ class ClientDecorator extends Decorator implements DecoratorInterface return ''; } - public function name(Client $client) { - return $client->present()->name(); - } - public function number(Client $client) { - return $client->number ?? ''; - } - public function user(Client $client) { - return $client->user->present()->name(); - } - public function assigned_user(Client $client) { - return $client->assigned_user ? $client->user->present()->name() : ''; - } - public function balance(Client $client) { - return $client->balance ?? 0; - } - public function paid_to_date(Client $client) { - return $client->paid_to_date ?? 0; - } - public function currency_id(Client $client) { - return $client->currency() ? $client->currency()->code : $client->company->currency()->code; - } - public function website(Client $client) { - return $client->website ?? ''; - } - public function private_notes(Client $client) { - return $client->private_notes ?? ''; - } - public function industry_id(Client $client) { - return $client->industry ? ctrans("texts.industry_{$client->industry->name}") : ''; - } - public function size_id(Client $client) { - return $client->size ? ctrans("texts.size_{$client->size->name}") : ''; - } - public function phone(Client $client) { - return $client->phone ?? ''; - } - public function address1(Client $client) { - return $client->address1 ?? ''; - } - public function address2(Client $client) { - return $client->address2 ?? ''; - } - public function city(Client $client) { - return $client->city ?? ''; - } - public function state(Client $client) { - return $client->state ?? ''; - } - public function postal_code(Client $client) { - return $client->postal_code ?? ''; - } - public function country_id(Client $client) { - return $client->country ? ctrans("texts.country_{$client->country->name}") : ''; - } - public function shipping_address1(Client $client) { - return $client->shipping_address1 ?? ''; - } - public function shipping_address2(Client $client) { - return $client->shipping_address2 ?? ''; - } - public function shipping_city(Client $client) { - return $client->shipping_city ?? ''; - } - public function shipping_state(Client $client) { - return $client->shipping_state ?? ''; - } - public function shipping_postal_code(Client $client) { - return $client->shipping_postal_code ?? ''; - } - public function shipping_country_id(Client $client) { - return $client->shipping_country ? ctrans("texts.country_{$client->shipping_country->name}") : ''; - } - public function payment_terms(Client $client) { - return $client?->settings?->payment_terms ?? $client->company->settings->payment_terms; - } - public function vat_number(Client $client) { - return $client->vat_number ?? ''; - } - public function id_number(Client $client) { - return $client->id_number ?? ''; - } - public function public_notes(Client $client) { - return $client->public_notes ?? ''; - } - public function custom_value1(Client $client) { - return $client->custom_value1 ?? ''; - } - public function custom_value2(Client $client) { - return $client->custom_value2 ?? ''; - } - public function custom_value3(Client $client) { - return $client->custom_value3 ?? ''; - } - public function custom_value4(Client $client) { - return $client->custom_value4 ?? ''; - } - public function payment_balance(Client $client) { - return $client->payment_balance ?? 0; - } - public function credit_balance(Client $client) { - return $client->credit_balance ?? 0; - } - public function classification(Client $client) { - ctrans("texts.{$client->classification}") ?? ''; + public function name(Client $client) + { + return $client->present()->name(); + } + + public function number(Client $client) + { + return $client->number ?? ''; + } + + public function user(Client $client) + { + return $client->user->present()->name(); + } + + public function assigned_user(Client $client) + { + return $client->assigned_user ? $client->user->present()->name() : ''; + } + + public function balance(Client $client) + { + return $client->balance ?? 0; + } + + public function paid_to_date(Client $client) + { + return $client->paid_to_date ?? 0; + } + + public function currency_id(Client $client) + { + return $client->currency() ? $client->currency()->code : $client->company->currency()->code; + } + + public function website(Client $client) + { + return $client->website ?? ''; + } + + public function private_notes(Client $client) + { + return $client->private_notes ?? ''; + } + + public function industry_id(Client $client) + { + return $client->industry ? ctrans("texts.industry_{$client->industry->name}") : ''; + } + + public function size_id(Client $client) + { + return $client->size ? ctrans("texts.size_{$client->size->name}") : ''; + } + + public function phone(Client $client) + { + return $client->phone ?? ''; + } + + public function address1(Client $client) + { + return $client->address1 ?? ''; + } + + public function address2(Client $client) + { + return $client->address2 ?? ''; + } + + public function city(Client $client) + { + return $client->city ?? ''; + } + + public function state(Client $client) + { + return $client->state ?? ''; + } + + public function postal_code(Client $client) + { + return $client->postal_code ?? ''; + } + + public function country_id(Client $client) + { + return $client->country ? ctrans("texts.country_{$client->country->name}") : ''; + } + + public function shipping_address1(Client $client) + { + return $client->shipping_address1 ?? ''; + } + + public function shipping_address2(Client $client) + { + return $client->shipping_address2 ?? ''; + } + + public function shipping_city(Client $client) + { + return $client->shipping_city ?? ''; + } + + public function shipping_state(Client $client) + { + return $client->shipping_state ?? ''; + } + + public function shipping_postal_code(Client $client) + { + return $client->shipping_postal_code ?? ''; + } + + public function shipping_country_id(Client $client) + { + return $client->shipping_country ? ctrans("texts.country_{$client->shipping_country->name}") : ''; + } + + public function payment_terms(Client $client) + { + return $client?->settings?->payment_terms ?? $client->company->settings->payment_terms; + } + + public function vat_number(Client $client) + { + return $client->vat_number ?? ''; + } + + public function id_number(Client $client) + { + return $client->id_number ?? ''; + } + + public function public_notes(Client $client) + { + return $client->public_notes ?? ''; + } + + public function custom_value1(Client $client) + { + return $client->custom_value1 ?? ''; + } + + public function custom_value2(Client $client) + { + return $client->custom_value2 ?? ''; + } + + public function custom_value3(Client $client) + { + return $client->custom_value3 ?? ''; + } + + public function custom_value4(Client $client) + { + return $client->custom_value4 ?? ''; + } + + public function payment_balance(Client $client) + { + return $client->payment_balance ?? 0; + } + + public function credit_balance(Client $client) + { + return $client->credit_balance ?? 0; + } + + public function classification(Client $client) + { + ctrans("texts.{$client->classification}") ?? ''; + } + + public function status(Client $client) + { + if ($client->is_deleted) { + return ctrans('texts.deleted'); } - public function status(Client $client) - { - if ($client->is_deleted) { - return ctrans('texts.deleted'); - } - - if ($client->deleted_at) { - return ctrans('texts.archived'); - } - - return ctrans('texts.active'); + if ($client->deleted_at) { + return ctrans('texts.archived'); } - - + return ctrans('texts.active'); + } } diff --git a/app/Export/Decorators/ContactDecorator.php b/app/Export/Decorators/ContactDecorator.php index deb5413b02f6..ae8ba8e5dcfd 100644 --- a/app/Export/Decorators/ContactDecorator.php +++ b/app/Export/Decorators/ContactDecorator.php @@ -33,28 +33,36 @@ class ContactDecorator implements DecoratorInterface } - public function phone(ClientContact $contact) { + public function phone(ClientContact $contact) + { return $contact->phone ?? ''; } - public function first_name(ClientContact $contact) { + public function first_name(ClientContact $contact) + { return $contact->first_name ?? ''; } - public function last_name(ClientContact $contact) { + public function last_name(ClientContact $contact) + { return $contact->last_name ?? ''; } - public function email(ClientContact $contact) { + public function email(ClientContact $contact) + { return $contact->email ?? ''; } - public function custom_value1(ClientContact $contact) { + public function custom_value1(ClientContact $contact) + { return $contact->custom_value1 ?? ''; } - public function custom_value2(ClientContact $contact) { + public function custom_value2(ClientContact $contact) + { return $contact->custom_value2 ?? ''; } - public function custom_value3(ClientContact $contact) { + public function custom_value3(ClientContact $contact) + { return $contact->custom_value3 ?? ''; } - public function custom_value4(ClientContact $contact) { + public function custom_value4(ClientContact $contact) + { return $contact->custom_value4 ?? ''; } diff --git a/app/Export/Decorators/CreditDecorator.php b/app/Export/Decorators/CreditDecorator.php index bc7a689da9f7..67a6341c5769 100644 --- a/app/Export/Decorators/CreditDecorator.php +++ b/app/Export/Decorators/CreditDecorator.php @@ -33,91 +33,120 @@ class CreditDecorator implements DecoratorInterface } - public function number(Credit $credit ) { + public function number(Credit $credit) + { return $credit->number ?? ''; } - public function amount(Credit $credit ) { + public function amount(Credit $credit) + { return $credit->amount ?? 0; } - public function balance(Credit $credit ) { + public function balance(Credit $credit) + { return $credit->balance ?? 0; } - public function paid_to_date(Credit $credit ) { + public function paid_to_date(Credit $credit) + { return $credit->paid_to_date ?? 0; } - public function po_number(Credit $credit ) { + public function po_number(Credit $credit) + { return $credit->po_number ?? ''; } - public function date(Credit $credit ) { + public function date(Credit $credit) + { return $credit->date ?? ''; } - public function due_date(Credit $credit ) { + public function due_date(Credit $credit) + { return $credit->due_date ?? ''; } - public function terms(Credit $credit ) { + public function terms(Credit $credit) + { return $credit->terms ?? ''; } - public function discount(Credit $credit ) { + public function discount(Credit $credit) + { return $credit->discount ?? 0; } - public function footer(Credit $credit ) { + public function footer(Credit $credit) + { return $credit->footer ?? ''; } - public function status(Credit $credit ) { + public function status(Credit $credit) + { return $credit->stringStatus($credit->status_id); } - public function public_notes(Credit $credit ) { + public function public_notes(Credit $credit) + { return $credit->public_notes ?? ''; } - public function private_notes(Credit $credit ) { + public function private_notes(Credit $credit) + { return $credit->private_notes ?? ''; } - public function uses_inclusive_taxes(Credit $credit ) { + public function uses_inclusive_taxes(Credit $credit) + { return $credit->uses_inclusive_taxes ? ctrans('texts.yes') : ctrans('texts.no'); } - public function is_amount_discount(Credit $credit ) { + public function is_amount_discount(Credit $credit) + { return $credit->is_amount_discount ? ctrans('texts.yes') : ctrans('texts.no'); } - public function partial(Credit $credit ) { + public function partial(Credit $credit) + { return $credit->partial ?? 0; } - public function partial_due_date(Credit $credit ) { + public function partial_due_date(Credit $credit) + { return $credit->partial_due_date ?? ''; } - public function custom_surcharge1(Credit $credit ) { + public function custom_surcharge1(Credit $credit) + { return $credit->custom_surcharge1 ?? 0; } - public function custom_surcharge2(Credit $credit ) { + public function custom_surcharge2(Credit $credit) + { return $credit->custom_surcharge2 ?? 0; } - public function custom_surcharge3(Credit $credit ) { + public function custom_surcharge3(Credit $credit) + { return $credit->custom_surcharge3 ?? 0; } - public function custom_surcharge4(Credit $credit ) { + public function custom_surcharge4(Credit $credit) + { return $credit->custom_surcharge4 ?? 0; } - public function custom_value1(Credit $credit ) { + public function custom_value1(Credit $credit) + { return $credit->custom_value1 ?? ''; } - public function custom_value2(Credit $credit ) { + public function custom_value2(Credit $credit) + { return $credit->custom_value2 ?? ''; } - public function custom_value3(Credit $credit ) { + public function custom_value3(Credit $credit) + { return $credit->custom_value3 ?? ''; } - public function custom_value4(Credit $credit ) { + public function custom_value4(Credit $credit) + { return $credit->custom_value4 ?? ''; } - public function exchange_rate(Credit $credit ) { + public function exchange_rate(Credit $credit) + { return $credit->exchange_rate ?? 0; } - public function total_taxes(Credit $credit ) { + public function total_taxes(Credit $credit) + { return $credit->total_taxes ?? 0; } - public function assigned_user_id(Credit $credit ) { + public function assigned_user_id(Credit $credit) + { return $credit->assigned_user ? $credit->assigned_user->present()->name(): ''; } - public function user_id(Credit $credit ) { + public function user_id(Credit $credit) + { return $credit->user ? $credit->user->present()->name(): ''; } diff --git a/app/Export/Decorators/Decorator.php b/app/Export/Decorators/Decorator.php index 7891caa3594b..a551053fced8 100644 --- a/app/Export/Decorators/Decorator.php +++ b/app/Export/Decorators/Decorator.php @@ -11,22 +11,8 @@ namespace App\Export\Decorators; - -use App\Models\Task; -use App\Models\Quote; -use App\Models\Client; -use App\Models\Credit; -use App\Models\Vendor; -use App\Models\Expense; -use App\Models\Invoice; -use App\Models\Payment; -use App\Models\Product; -use App\Models\Project; -use App\Models\PurchaseOrder; -use App\Models\RecurringInvoice; -use App\Export\Decorators\DecoratorInterface; - -class Decorator implements DecoratorInterface{ +class Decorator implements DecoratorInterface +{ public function __construct() { diff --git a/app/Export/Decorators/DecoratorInterface.php b/app/Export/Decorators/DecoratorInterface.php index cd8b6fa03597..483732205384 100644 --- a/app/Export/Decorators/DecoratorInterface.php +++ b/app/Export/Decorators/DecoratorInterface.php @@ -11,6 +11,7 @@ namespace App\Export\Decorators; -interface DecoratorInterface { +interface DecoratorInterface +{ public function transform(string $key, mixed $entity): mixed; } diff --git a/app/Export/Decorators/ExpenseDecorator.php b/app/Export/Decorators/ExpenseDecorator.php index e01b993a0482..22bb798a4a7c 100644 --- a/app/Export/Decorators/ExpenseDecorator.php +++ b/app/Export/Decorators/ExpenseDecorator.php @@ -33,100 +33,132 @@ class ExpenseDecorator implements DecoratorInterface } - public function amount(Expense $expense) { + public function amount(Expense $expense) + { return $expense->amount ?? 0; } - public function category_id(Expense $expense) { + public function category_id(Expense $expense) + { return $expense->category ? $expense->category->name : ''; } - public function client_id(Expense $expense) { + public function client_id(Expense $expense) + { return $expense->client ? $expense->client->present()->name() : ''; } - public function custom_value1(Expense $expense) { + public function custom_value1(Expense $expense) + { return $expense->custom_value1 ?? ''; } - public function custom_value2(Expense $expense) { + public function custom_value2(Expense $expense) + { return $expense->custom_value2 ?? ''; } - public function custom_value3(Expense $expense) { + public function custom_value3(Expense $expense) + { return $expense->custom_value3 ?? ''; } - public function custom_value4(Expense $expense) { + public function custom_value4(Expense $expense) + { return $expense->custom_value4 ?? ''; } - public function currency_id(Expense $expense) { + public function currency_id(Expense $expense) + { return $expense->currency ? $expense->currency->code : $expense->company->currency()->code; } - public function date(Expense $expense) { + public function date(Expense $expense) + { return $expense->date ?? ''; } - public function exchange_rate(Expense $expense) { + public function exchange_rate(Expense $expense) + { return $expense->exchange_rate ?? 0; } - public function foreign_amount(Expense $expense) { + public function foreign_amount(Expense $expense) + { return $expense->foreign_amount ?? 0; } - public function invoice_currency_id(Expense $expense) { + public function invoice_currency_id(Expense $expense) + { return $expense->invoice_currency ? $expense->invoice_currency->code : $expense->company->currency()->code; } - public function payment_date(Expense $expense) { + public function payment_date(Expense $expense) + { return $expense->payment_date ?? ''; } - public function number(Expense $expense) { + public function number(Expense $expense) + { return $expense->number ?? ''; } - public function payment_type_id(Expense $expense) { + public function payment_type_id(Expense $expense) + { return $expense->payment_type ? $expense->payment_type->name : ''; } - public function private_notes(Expense $expense) { + public function private_notes(Expense $expense) + { return $expense->private_notes ?? ''; } - public function project_id(Expense $expense) { + public function project_id(Expense $expense) + { return $expense->project ? $expense->project->name : ''; } - public function public_notes(Expense $expense) { + public function public_notes(Expense $expense) + { return $expense->public_notes ?? ''; } - public function tax_amount1(Expense $expense) { + public function tax_amount1(Expense $expense) + { return $expense->tax_amount1 ?? 0; } - public function tax_amount2(Expense $expense) { + public function tax_amount2(Expense $expense) + { return $expense->tax_amount2 ?? 0; } - public function tax_amount3(Expense $expense) { + public function tax_amount3(Expense $expense) + { return $expense->tax_amount3 ?? 0; } - public function tax_name1(Expense $expense) { + public function tax_name1(Expense $expense) + { return $expense->tax_name1 ?? ''; } - public function tax_name2(Expense $expense) { + public function tax_name2(Expense $expense) + { return $expense->tax_name2 ?? ''; } - public function tax_name3(Expense $expense) { + public function tax_name3(Expense $expense) + { return $expense->tax_name3 ?? ''; } - public function tax_rate1(Expense $expense) { + public function tax_rate1(Expense $expense) + { return $expense->tax_rate1 ?? 0; } - public function tax_rate2(Expense $expense) { + public function tax_rate2(Expense $expense) + { return $expense->tax_rate2 ?? 0; } - public function tax_rate3(Expense $expense) { + public function tax_rate3(Expense $expense) + { return $expense->tax_rate3 ?? 0; } - public function transaction_reference(Expense $expense) { + public function transaction_reference(Expense $expense) + { return $expense->transaction_reference ?? ''; } - public function vendor_id(Expense $expense) { + public function vendor_id(Expense $expense) + { return $expense->vendor ? $expense->vendor->name : ''; } - public function invoice_id(Expense $expense) { + public function invoice_id(Expense $expense) + { return $expense->invoice ? $expense->invoice->number : ''; } - public function user(Expense $expense) { + public function user(Expense $expense) + { return $expense->user ? $expense->user->present()->name() : ''; } - public function assigned_user(Expense $expense) { + public function assigned_user(Expense $expense) + { return $expense->assigned_user ? $expense->assigned_user->present()->name() : ''; } diff --git a/app/Export/Decorators/InvoiceDecorator.php b/app/Export/Decorators/InvoiceDecorator.php index 1865a9876837..bea2f6678541 100644 --- a/app/Export/Decorators/InvoiceDecorator.php +++ b/app/Export/Decorators/InvoiceDecorator.php @@ -33,119 +33,153 @@ class InvoiceDecorator extends Decorator implements DecoratorInterface } - - public function number(Invoice $invoice) { - return $invoice->number ?? ''; - } - public function amount(Invoice $invoice) { - return $invoice->amount ?? 0; - } - public function balance(Invoice $invoice) { - return $invoice->balance ?? 0; - } - public function paid_to_date(Invoice $invoice) { - return $invoice->paid_to_date ?? 0; - } - public function po_number(Invoice $invoice) { - return $invoice->po_number ?? ''; - } - public function date(Invoice $invoice) { - return $invoice->date ?? ''; - } - public function due_date(Invoice $invoice) { - return $invoice->due_date ?? ''; - } - public function terms(Invoice $invoice) { - return $invoice->terms ?? ''; - } - public function footer(Invoice $invoice) { - return $invoice->footer ?? ''; - } - public function status(Invoice $invoice) { - return $invoice->stringStatus($invoice->status_id); - } - public function public_notes(Invoice $invoice) { - return $invoice->public_notes ?? ''; - } - public function private_notes(Invoice $invoice) { - return $invoice->private_notes ?? ''; - } - public function uses_inclusive_taxes(Invoice $invoice) { - return $invoice->uses_inclusive_taxes ? ctrans('texts.yes') : ctrans('texts.no'); - } - public function is_amount_discount(Invoice $invoice) { - return $invoice->is_amount_discount ? ctrans('texts.yes') : ctrans('texts.no'); - } - public function discount(Invoice $invoice) { - return $invoice->discount ?? 0; - } - public function partial(Invoice $invoice) { - return $invoice->partial ?? 0; - } - public function partial_due_date(Invoice $invoice) { - return $invoice->partial_due_date ?? ''; - } - public function custom_surcharge1(Invoice $invoice) { - return $invoice->custom_surcharge1 ?? 0; - } - public function custom_surcharge2(Invoice $invoice) { - return $invoice->custom_surcharge2 ?? 0; - } - public function custom_surcharge3(Invoice $invoice) { - return $invoice->custom_surcharge3 ?? 0; - } - public function custom_surcharge4(Invoice $invoice) { - return $invoice->custom_surcharge4 ?? 0; - } - public function exchange_rate(Invoice $invoice) { - return $invoice->exchange_rate ?? 0; - } - public function total_taxes(Invoice $invoice) { - return $invoice->total_taxes ?? 0; - } - public function assigned_user_id(Invoice $invoice) { - return $invoice->assigned_user ? $invoice->assigned_user->present()->name(): ''; - } - public function user_id(Invoice $invoice) { - return $invoice->user ? $invoice->user->present()->name(): ''; - } - public function custom_value1(Invoice $invoice) { - return $invoice->custom_value1 ?? ''; - } - public function custom_value2(Invoice $invoice) { - return $invoice->custom_value2 ?? ''; - } - public function custom_value3(Invoice $invoice) { - return $invoice->custom_value3 ?? ''; - } - public function custom_value4(Invoice $invoice) { - return $invoice->custom_value4 ?? ''; - } - public function tax_name1(Invoice $invoice) { - return $invoice->tax_name1 ?? ''; - } - public function tax_name2(Invoice $invoice) { - return $invoice->tax_name2 ?? ''; - } - public function tax_name3(Invoice $invoice) { - return $invoice->tax_name3 ?? ''; - } - public function tax_rate1(Invoice $invoice) { - return $invoice->tax_rate1 ?? 0; - } - public function tax_rate2(Invoice $invoice) { - return $invoice->tax_rate2 ?? 0; - } - public function tax_rate3(Invoice $invoice) { - return $invoice->tax_rate3 ?? 0; - } - public function recurring_id(Invoice $invoice) { - return $invoice->recurring_invoice ? $invoice->recurring_invoice->number : ''; - } - public function auto_bill_enabled(Invoice $invoice) { - return $invoice->auto_bill_enabled ? ctrans('texts.yes') : ctrans('texts.no'); - } + public function number(Invoice $invoice) + { + return $invoice->number ?? ''; + } + public function amount(Invoice $invoice) + { + return $invoice->amount ?? 0; + } + public function balance(Invoice $invoice) + { + return $invoice->balance ?? 0; + } + public function paid_to_date(Invoice $invoice) + { + return $invoice->paid_to_date ?? 0; + } + public function po_number(Invoice $invoice) + { + return $invoice->po_number ?? ''; + } + public function date(Invoice $invoice) + { + return $invoice->date ?? ''; + } + public function due_date(Invoice $invoice) + { + return $invoice->due_date ?? ''; + } + public function terms(Invoice $invoice) + { + return $invoice->terms ?? ''; + } + public function footer(Invoice $invoice) + { + return $invoice->footer ?? ''; + } + public function status(Invoice $invoice) + { + return $invoice->stringStatus($invoice->status_id); + } + public function public_notes(Invoice $invoice) + { + return $invoice->public_notes ?? ''; + } + public function private_notes(Invoice $invoice) + { + return $invoice->private_notes ?? ''; + } + public function uses_inclusive_taxes(Invoice $invoice) + { + return $invoice->uses_inclusive_taxes ? ctrans('texts.yes') : ctrans('texts.no'); + } + public function is_amount_discount(Invoice $invoice) + { + return $invoice->is_amount_discount ? ctrans('texts.yes') : ctrans('texts.no'); + } + public function discount(Invoice $invoice) + { + return $invoice->discount ?? 0; + } + public function partial(Invoice $invoice) + { + return $invoice->partial ?? 0; + } + public function partial_due_date(Invoice $invoice) + { + return $invoice->partial_due_date ?? ''; + } + public function custom_surcharge1(Invoice $invoice) + { + return $invoice->custom_surcharge1 ?? 0; + } + public function custom_surcharge2(Invoice $invoice) + { + return $invoice->custom_surcharge2 ?? 0; + } + public function custom_surcharge3(Invoice $invoice) + { + return $invoice->custom_surcharge3 ?? 0; + } + public function custom_surcharge4(Invoice $invoice) + { + return $invoice->custom_surcharge4 ?? 0; + } + public function exchange_rate(Invoice $invoice) + { + return $invoice->exchange_rate ?? 0; + } + public function total_taxes(Invoice $invoice) + { + return $invoice->total_taxes ?? 0; + } + public function assigned_user_id(Invoice $invoice) + { + return $invoice->assigned_user ? $invoice->assigned_user->present()->name(): ''; + } + public function user_id(Invoice $invoice) + { + return $invoice->user ? $invoice->user->present()->name(): ''; + } + public function custom_value1(Invoice $invoice) + { + return $invoice->custom_value1 ?? ''; + } + public function custom_value2(Invoice $invoice) + { + return $invoice->custom_value2 ?? ''; + } + public function custom_value3(Invoice $invoice) + { + return $invoice->custom_value3 ?? ''; + } + public function custom_value4(Invoice $invoice) + { + return $invoice->custom_value4 ?? ''; + } + public function tax_name1(Invoice $invoice) + { + return $invoice->tax_name1 ?? ''; + } + public function tax_name2(Invoice $invoice) + { + return $invoice->tax_name2 ?? ''; + } + public function tax_name3(Invoice $invoice) + { + return $invoice->tax_name3 ?? ''; + } + public function tax_rate1(Invoice $invoice) + { + return $invoice->tax_rate1 ?? 0; + } + public function tax_rate2(Invoice $invoice) + { + return $invoice->tax_rate2 ?? 0; + } + public function tax_rate3(Invoice $invoice) + { + return $invoice->tax_rate3 ?? 0; + } + public function recurring_id(Invoice $invoice) + { + return $invoice->recurring_invoice ? $invoice->recurring_invoice->number : ''; + } + public function auto_bill_enabled(Invoice $invoice) + { + return $invoice->auto_bill_enabled ? ctrans('texts.yes') : ctrans('texts.no'); + } } - - diff --git a/app/Export/Decorators/PaymentDecorator.php b/app/Export/Decorators/PaymentDecorator.php index f9af06b182c1..791d1c01848a 100644 --- a/app/Export/Decorators/PaymentDecorator.php +++ b/app/Export/Decorators/PaymentDecorator.php @@ -13,7 +13,8 @@ namespace App\Export\Decorators; use App\Models\Payment; -class PaymentDecorator extends Decorator implements DecoratorInterface{ +class PaymentDecorator extends Decorator implements DecoratorInterface +{ private $entity_key = 'payment'; @@ -21,20 +22,17 @@ class PaymentDecorator extends Decorator implements DecoratorInterface{ { $payment = false; - if($entity instanceof Payment){ + if($entity instanceof Payment) { $payment = $entity; - } - elseif($entity->payment) { + } elseif($entity->payment) { $payment = $entity->payment; } - if($key == 'amount' && (!$entity instanceof Payment)){ + if($key == 'amount' && (!$entity instanceof Payment)) { return $entity->payments()->exists() ? $entity->payments()->withoutTrashed()->sum('paymentables.amount') : ctrans('texts.unpaid'); - } - elseif($key == 'refunded' && (!$entity instanceof Payment)) { + } elseif($key == 'refunded' && (!$entity instanceof Payment)) { return $entity->payments()->exists() ? $entity->payments()->withoutTrashed()->sum('paymentables.refunded') : ''; - } - elseif($key == 'applied' && (!$entity instanceof Payment)) { + } elseif($key == 'applied' && (!$entity instanceof Payment)) { $refunded = $entity->payments()->withoutTrashed()->sum('paymentables.refunded'); $amount = $entity->payments()->withoutTrashed()->sum('paymentables.amount'); return $entity->payments()->withoutTrashed()->exists() ? ($amount - $refunded) : ''; @@ -47,96 +45,119 @@ class PaymentDecorator extends Decorator implements DecoratorInterface{ return ''; } - public function date(Payment $payment) { + public function date(Payment $payment) + { return $payment->date ?? ''; } - public function amount(Payment $payment) { + public function amount(Payment $payment) + { return $payment->amount ?? ''; } - public function refunded(Payment $payment) { + public function refunded(Payment $payment) + { return $payment->refunded ?? ''; } - public function applied(Payment $payment) { + public function applied(Payment $payment) + { return $payment->applied ?? ''; } - public function transaction_reference(Payment $payment) { + public function transaction_reference(Payment $payment) + { return $payment->transaction_reference ?? ''; } - public function currency(Payment $payment) { + public function currency(Payment $payment) + { return $payment->currency()->exists() ? $payment->currency->code : $payment->company->currency()->code; } - public function exchange_rate(Payment $payment) { + public function exchange_rate(Payment $payment) + { return $payment->exchange_rate ?? 1; } - public function number(Payment $payment) { + public function number(Payment $payment) + { return $payment->number ?? ''; } - public function method(Payment $payment) { + public function method(Payment $payment) + { return $payment->translatedType(); } - public function status(Payment $payment) { + public function status(Payment $payment) + { return $payment->stringStatus($payment->status_id); } - public function private_notes(Payment $payment) { + public function private_notes(Payment $payment) + { return strip_tags($payment->private_notes) ?? ''; } - public function custom_value1(Payment $payment) { + public function custom_value1(Payment $payment) + { return $payment->custom_value1 ?? ''; } - public function custom_value2(Payment $payment) { + public function custom_value2(Payment $payment) + { return $payment->custom_value2 ?? ''; } - public function custom_value3(Payment $payment) { + public function custom_value3(Payment $payment) + { return $payment->custom_value3 ?? ''; } - public function custom_value4(Payment $payment) { + public function custom_value4(Payment $payment) + { return $payment->custom_value4 ?? ''; } - public function user_id(Payment $payment) { + public function user_id(Payment $payment) + { return $payment->user ? $payment->user->present()->name() : ''; } - public function assigned_user_id(Payment $payment) { + public function assigned_user_id(Payment $payment) + { return $payment->assigned_user ? $payment->assigned_user->present()->name() : ''; } - public function project_id(Payment $payment) { + public function project_id(Payment $payment) + { return $payment->project()->exists() ? $payment->project->name : ''; } /////////////////////////////////////////////////// - public function vendor_id(Payment $payment){ + public function vendor_id(Payment $payment) + { return $payment->vendor()->exists() ? $payment->vendor->name : ''; } - public function exchange_currency(Payment $payment){ + public function exchange_currency(Payment $payment) + { return $payment->exchange_currency()->exists() ? $payment->exchange_currency->code : ''; } - public function gateway_type_id(Payment $payment) { + public function gateway_type_id(Payment $payment) + { return $payment->gateway_type ? $payment->gateway_type->name : 'Unknown Type'; } - public function client_id(Payment $payment) { + public function client_id(Payment $payment) + { return $payment->client->present()->name(); } - public function type_id(Payment $payment) { + public function type_id(Payment $payment) + { return $payment->translatedType(); } -} \ No newline at end of file +} diff --git a/app/Export/Decorators/ProductDecorator.php b/app/Export/Decorators/ProductDecorator.php index 5f99d8414400..ad0dc6b81e39 100644 --- a/app/Export/Decorators/ProductDecorator.php +++ b/app/Export/Decorators/ProductDecorator.php @@ -27,9 +27,9 @@ class ProductDecorator implements DecoratorInterface if($product && method_exists($this, $key)) { return $this->{$key}($product); - } - elseif($product->{$key}) + } elseif($product->{$key}) { return $product->{$key} ?? ''; + } return ''; @@ -46,11 +46,12 @@ class ProductDecorator implements DecoratorInterface public const PRODUCT_TYPE_ZERO_RATED = 8; public const PRODUCT_TYPE_REVERSE_TAX = 9; */ - public function tax_category(Product $product) { + public function tax_category(Product $product) + { $category = ctrans('texts.physical_goods'); - match($product->tax_id){ + match($product->tax_id) { 1 => $category = ctrans('texts.physical_goods'), 2 => $category = ctrans('texts.services'), 3 => $category = ctrans('texts.digital_products'), @@ -67,6 +68,3 @@ class ProductDecorator implements DecoratorInterface } } - - - diff --git a/app/Export/Decorators/PurchaseOrderDecorator.php b/app/Export/Decorators/PurchaseOrderDecorator.php index e87df1f02226..362f155174da 100644 --- a/app/Export/Decorators/PurchaseOrderDecorator.php +++ b/app/Export/Decorators/PurchaseOrderDecorator.php @@ -27,20 +27,22 @@ class PurchaseOrderDecorator extends Decorator implements DecoratorInterface if($purchase_order && method_exists($this, $key)) { return $this->{$key}($purchase_order); - } - elseif($purchase_order->{$key}) + } elseif($purchase_order->{$key}) { return $purchase_order->{$key} ?? ''; + } return ''; } - public function status(PurchaseOrder $purchase_order) { + public function status(PurchaseOrder $purchase_order) + { return $purchase_order->stringStatus($purchase_order->status_id); } - public function currency_id(PurchaseOrder $purchase_order) { + public function currency_id(PurchaseOrder $purchase_order) + { return $purchase_order->currency ? $purchase_order->currency->code : $purchase_order->company->currency()->code; } - + } diff --git a/app/Export/Decorators/QuoteDecorator.php b/app/Export/Decorators/QuoteDecorator.php index 24e5297bc6e1..8e44e5792129 100644 --- a/app/Export/Decorators/QuoteDecorator.php +++ b/app/Export/Decorators/QuoteDecorator.php @@ -35,21 +35,29 @@ class QuoteDecorator extends Decorator implements DecoratorInterface } - public function status(Quote $quote) { + public function status(Quote $quote) + { return $quote->stringStatus($quote->status_id); } - public function uses_inclusive_taxes(Quote $quote) { + + public function uses_inclusive_taxes(Quote $quote) + { return $quote->uses_inclusive_taxes ? ctrans('texts.yes') : ctrans('texts.no'); } - public function is_amount_discount(Quote $quote) { + + public function is_amount_discount(Quote $quote) + { return $quote->is_amount_discount ? ctrans('texts.yes') : ctrans('texts.no'); } - public function assigned_user_id(Quote $quote) { + + public function assigned_user_id(Quote $quote) + { return $quote->assigned_user ? $quote->assigned_user->present()->name() : ''; } - public function user_id(Quote $quote) { + + public function user_id(Quote $quote) + { return $quote->user->present()->name(); } } - diff --git a/app/Export/Decorators/RecurringInvoiceDecorator.php b/app/Export/Decorators/RecurringInvoiceDecorator.php index b32bda1456cf..cfda7f23b656 100644 --- a/app/Export/Decorators/RecurringInvoiceDecorator.php +++ b/app/Export/Decorators/RecurringInvoiceDecorator.php @@ -35,28 +35,43 @@ class RecurringInvoiceDecorator extends Decorator implements DecoratorInterface } - public function status(RecurringInvoice $recurring_invoice) { + public function status(RecurringInvoice $recurring_invoice) + { return $recurring_invoice->stringStatus($recurring_invoice->status_id); } - public function uses_inclusive_taxes(RecurringInvoice $recurring_invoice) { + + public function uses_inclusive_taxes(RecurringInvoice $recurring_invoice) + { return $recurring_invoice->uses_inclusive_taxes ? ctrans('texts.yes') : ctrans('texts.no'); } - public function is_amount_discount(RecurringInvoice $recurring_invoice) { + + public function is_amount_discount(RecurringInvoice $recurring_invoice) + { return $recurring_invoice->is_amount_discount ? ctrans('texts.yes') : ctrans('texts.no'); } - public function assigned_user_id(RecurringInvoice $recurring_invoice) { + + public function assigned_user_id(RecurringInvoice $recurring_invoice) + { return $recurring_invoice->assigned_user ? $recurring_invoice->assigned_user->present()->name() : ''; } - public function user_id(RecurringInvoice $recurring_invoice) { + + public function user_id(RecurringInvoice $recurring_invoice) + { return $recurring_invoice->user->present()->name() ?? ''; } - public function frequency_id(RecurringInvoice $recurring_invoice) { + + public function frequency_id(RecurringInvoice $recurring_invoice) + { return $recurring_invoice->frequency_id ? $recurring_invoice->frequencyForKey($recurring_invoice->frequency_id) : ''; } - public function auto_bill(RecurringInvoice $recurring_invoice) { + + public function auto_bill(RecurringInvoice $recurring_invoice) + { return $recurring_invoice->auto_bill ? ctrans("texts.{$recurring_invoice->auto_bill}") : ''; } - public function auto_bill_enabled(RecurringInvoice $recurring_invoice) { + + public function auto_bill_enabled(RecurringInvoice $recurring_invoice) + { return $recurring_invoice->auto_bill_enabled ? ctrans('texts.yes') : ctrans('texts.no'); } diff --git a/app/Export/Decorators/TaskDecorator.php b/app/Export/Decorators/TaskDecorator.php index 7c51c2a6629d..32a81e6a7097 100644 --- a/app/Export/Decorators/TaskDecorator.php +++ b/app/Export/Decorators/TaskDecorator.php @@ -11,10 +11,10 @@ namespace App\Export\Decorators; -use Carbon\Carbon; +use App\Models\DateFormat; use App\Models\Task; use App\Models\Timezone; -use App\Models\DateFormat; +use Carbon\Carbon; class TaskDecorator extends Decorator implements DecoratorInterface { @@ -38,7 +38,8 @@ class TaskDecorator extends Decorator implements DecoratorInterface } - public function start_date(Task $task){ + public function start_date(Task $task) + { $timezone = Timezone::find($task->company->settings->timezone_id); $timezone_name = 'US/Eastern'; @@ -57,7 +58,7 @@ class TaskDecorator extends Decorator implements DecoratorInterface $date_format_default = $date_format->format; } - if(is_array($logs)){ + if(is_array($logs)) { $item = $logs[0]; return Carbon::createFromTimeStamp($item[0])->setTimezone($timezone_name)->format($date_format_default); } @@ -66,7 +67,8 @@ class TaskDecorator extends Decorator implements DecoratorInterface } - public function end_date(Task $task){ + public function end_date(Task $task) + { $timezone = Timezone::find($task->company->settings->timezone_id); $timezone_name = 'US/Eastern'; @@ -93,13 +95,18 @@ class TaskDecorator extends Decorator implements DecoratorInterface return ''; } - public function duration(Task $task){ + public function duration(Task $task) + { return $task->calcDuration(); } - public function status_id(Task $task){ + + public function status_id(Task $task) + { return $task->status()->exists() ? $task->status->name : ''; } - public function project_id(Task $task){ + + public function project_id(Task $task) + { return $task->project()->exists() ? $task->project->name : ''; } diff --git a/app/Export/Decorators/VendorContactDecorator.php b/app/Export/Decorators/VendorContactDecorator.php index 70b90de45353..d92175334163 100644 --- a/app/Export/Decorators/VendorContactDecorator.php +++ b/app/Export/Decorators/VendorContactDecorator.php @@ -27,13 +27,13 @@ class VendorContactDecorator implements DecoratorInterface if($contact && method_exists($this, $key)) { return $this->{$key}($contact); - } - elseif($contact->{$key}) + } elseif($contact->{$key}) { return $contact->{$key} ?? ''; + } return ''; } - + } diff --git a/app/Export/Decorators/VendorDecorator.php b/app/Export/Decorators/VendorDecorator.php index b31abbf2ccbe..8443172d3892 100644 --- a/app/Export/Decorators/VendorDecorator.php +++ b/app/Export/Decorators/VendorDecorator.php @@ -35,16 +35,23 @@ class VendorDecorator extends Decorator implements DecoratorInterface } - public function country_id(Vendor $vendor){ + public function country_id(Vendor $vendor) + { return $vendor->country ? $vendor->country->name : ''; } - public function name(Vendor $vendor){ + + public function name(Vendor $vendor) + { return $vendor->present()->name(); } - public function currency(Vendor $vendor){ + + public function currency(Vendor $vendor) + { return $vendor->currency_id ? $vendor->currency()->code : $vendor->company->currency()->code; } - public function classification(Vendor $vendor) { + + public function classification(Vendor $vendor) + { ctrans("texts.{$vendor->classification}") ?? ''; } diff --git a/app/Factory/CompanyFactory.php b/app/Factory/CompanyFactory.php index a09dcb914dd5..0f68ec941896 100644 --- a/app/Factory/CompanyFactory.php +++ b/app/Factory/CompanyFactory.php @@ -11,13 +11,13 @@ namespace App\Factory; -use App\Utils\Ninja; -use App\Models\Company; -use App\Libraries\MultiDB; -use App\Utils\Traits\MakesHash; -use App\DataMapper\Tax\TaxModel; -use App\DataMapper\CompanySettings; use App\DataMapper\ClientRegistrationFields; +use App\DataMapper\CompanySettings; +use App\DataMapper\Tax\TaxModel; +use App\Libraries\MultiDB; +use App\Models\Company; +use App\Utils\Ninja; +use App\Utils\Traits\MakesHash; class CompanyFactory { diff --git a/app/Filters/CreditFilters.php b/app/Filters/CreditFilters.php index a4dd3f33bf46..74465a466f1b 100644 --- a/app/Filters/CreditFilters.php +++ b/app/Filters/CreditFilters.php @@ -107,13 +107,13 @@ class CreditFilters extends QueryFilters return $this->builder; } - return $this->builder->where(function ($query){ - $query->whereIn('status_id', [Credit::STATUS_SENT, Credit::STATUS_PARTIAL]) - ->where('balance', '>', 0) - ->where(function ($q){ - $q->whereNull('due_date')->orWhere('due_date', '>', now()); - }); - }); + return $this->builder->where(function ($query) { + $query->whereIn('status_id', [Credit::STATUS_SENT, Credit::STATUS_PARTIAL]) + ->where('balance', '>', 0) + ->where(function ($q) { + $q->whereNull('due_date')->orWhere('due_date', '>', now()); + }); + }); } public function number(string $number = ''): Builder diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 73b5cfa4b58d..ef6a5db29b6e 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -527,10 +527,9 @@ class LoginController extends BaseController if (request()->has('id_token')) { $user = $google->getTokenResponse(request()->input('id_token')); - }elseif(request()->has('access_token')){ + } elseif(request()->has('access_token')) { $user = $google->harvestUser(request()->input('access_token')); - } - else { + } else { return response()->json(['message' => 'Illegal request'], 403); } diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index c16fd8bd0203..333cdbd7b598 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -11,37 +11,37 @@ namespace App\Http\Controllers; -use App\Utils\Ninja; -use App\Models\Client; -use App\Models\Account; -use App\Models\Company; -use App\Models\SystemLog; -use Postmark\PostmarkClient; -use Illuminate\Http\Response; -use App\Factory\ClientFactory; -use App\Filters\ClientFilters; -use App\Utils\Traits\MakesHash; -use App\Utils\Traits\Uploadable; -use App\Utils\Traits\BulkOptions; -use App\Jobs\Client\UpdateTaxData; -use App\Utils\Traits\SavesDocuments; -use App\Repositories\ClientRepository; use App\Events\Client\ClientWasCreated; use App\Events\Client\ClientWasUpdated; -use App\Transformers\ClientTransformer; -use Illuminate\Support\Facades\Storage; -use App\Services\Template\TemplateAction; -use App\Jobs\PostMark\ProcessPostmarkWebhook; +use App\Factory\ClientFactory; +use App\Filters\ClientFilters; use App\Http\Requests\Client\BulkClientRequest; -use App\Http\Requests\Client\EditClientRequest; -use App\Http\Requests\Client\ShowClientRequest; -use App\Http\Requests\Client\PurgeClientRequest; -use App\Http\Requests\Client\StoreClientRequest; use App\Http\Requests\Client\CreateClientRequest; +use App\Http\Requests\Client\DestroyClientRequest; +use App\Http\Requests\Client\EditClientRequest; +use App\Http\Requests\Client\PurgeClientRequest; +use App\Http\Requests\Client\ReactivateClientEmailRequest; +use App\Http\Requests\Client\ShowClientRequest; +use App\Http\Requests\Client\StoreClientRequest; use App\Http\Requests\Client\UpdateClientRequest; use App\Http\Requests\Client\UploadClientRequest; -use App\Http\Requests\Client\DestroyClientRequest; -use App\Http\Requests\Client\ReactivateClientEmailRequest; +use App\Jobs\Client\UpdateTaxData; +use App\Jobs\PostMark\ProcessPostmarkWebhook; +use App\Models\Account; +use App\Models\Client; +use App\Models\Company; +use App\Models\SystemLog; +use App\Repositories\ClientRepository; +use App\Services\Template\TemplateAction; +use App\Transformers\ClientTransformer; +use App\Utils\Ninja; +use App\Utils\Traits\BulkOptions; +use App\Utils\Traits\MakesHash; +use App\Utils\Traits\SavesDocuments; +use App\Utils\Traits\Uploadable; +use Illuminate\Http\Response; +use Illuminate\Support\Facades\Storage; +use Postmark\PostmarkClient; /** * Class ClientController. @@ -218,7 +218,7 @@ class ClientController extends BaseController $clients = Client::withTrashed() ->company() ->whereIn('id', $request->ids) - ->get(); + ->get(); if($action == 'template' && $user->can('view', $clients->first())) { @@ -387,7 +387,7 @@ class ClientController extends BaseController /** @var \Postmark\Models\DynamicResponseModel $response */ $response = $postmark->activateBounce((int)$bounce_id); - if($response && $response?->Message == 'OK' && !$response->Bounce->Inactive && $response->Bounce->Email){ + if($response && $response?->Message == 'OK' && !$response->Bounce->Inactive && $response->Bounce->Email) { $email = $response->Bounce->Email; //remove email from quarantine. //@TODO diff --git a/app/Http/Controllers/ClientPortal/InvitationController.php b/app/Http/Controllers/ClientPortal/InvitationController.php index 15533c7c2cdb..9daef9d92a6e 100644 --- a/app/Http/Controllers/ClientPortal/InvitationController.php +++ b/app/Http/Controllers/ClientPortal/InvitationController.php @@ -168,7 +168,7 @@ class InvitationController extends Controller set_time_limit(45); // if (Ninja::isHosted()) { - return $this->returnRawPdf($entity, $invitation_key); + return $this->returnRawPdf($entity, $invitation_key); // } // return redirect('client/'.$entity.'/'.$invitation_key.'/download_pdf'); diff --git a/app/Http/Controllers/ClientPortal/InvoiceController.php b/app/Http/Controllers/ClientPortal/InvoiceController.php index 871642b2747a..5cf617be6b19 100644 --- a/app/Http/Controllers/ClientPortal/InvoiceController.php +++ b/app/Http/Controllers/ClientPortal/InvoiceController.php @@ -30,7 +30,6 @@ use Illuminate\Contracts\View\Factory; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Cache; -use Illuminate\Support\Facades\Storage; use Illuminate\View\View; class InvoiceController extends Controller diff --git a/app/Http/Controllers/CompanyGatewayController.php b/app/Http/Controllers/CompanyGatewayController.php index 990a886f906b..96b91e30b467 100644 --- a/app/Http/Controllers/CompanyGatewayController.php +++ b/app/Http/Controllers/CompanyGatewayController.php @@ -201,15 +201,15 @@ class CompanyGatewayController extends BaseController $company_gateway->fill($request->all()); $company_gateway->save(); - /*Always ensure at least one fees and limits object is set per gateway*/ + /*Always ensure at least one fees and limits object is set per gateway*/ $gateway_types = $company_gateway->driver(new Client)->getAvailableMethods(); $fees_and_limits = $company_gateway->fees_and_limits; - foreach($gateway_types as $key => $gateway_type) - { - if(!property_exists($fees_and_limits, $key)) + foreach($gateway_types as $key => $gateway_type) { + if(!property_exists($fees_and_limits, $key)) { $fees_and_limits->{$key} = new FeesAndLimits; + } } $company_gateway->fees_and_limits = $fees_and_limits; diff --git a/app/Http/Controllers/CreditController.php b/app/Http/Controllers/CreditController.php index 439c986f19e9..9ad71d06756c 100644 --- a/app/Http/Controllers/CreditController.php +++ b/app/Http/Controllers/CreditController.php @@ -11,36 +11,36 @@ namespace App\Http\Controllers; -use App\Utils\Ninja; -use App\Models\Client; -use App\Models\Credit; -use App\Models\Account; -use App\Models\Invoice; -use Illuminate\Http\Response; -use App\Factory\CreditFactory; -use App\Filters\CreditFilters; -use App\Jobs\Credit\ZipCredits; -use App\Utils\Traits\MakesHash; -use App\Jobs\Entity\EmailEntity; -use App\Factory\CloneCreditFactory; -use App\Services\PdfMaker\PdfMerge; -use Illuminate\Support\Facades\App; -use App\Utils\Traits\SavesDocuments; -use App\Repositories\CreditRepository; use App\Events\Credit\CreditWasCreated; use App\Events\Credit\CreditWasUpdated; -use App\Transformers\CreditTransformer; -use Illuminate\Support\Facades\Storage; -use App\Services\Template\TemplateAction; +use App\Factory\CloneCreditFactory; +use App\Factory\CreditFactory; +use App\Filters\CreditFilters; +use App\Http\Requests\Credit\ActionCreditRequest; use App\Http\Requests\Credit\BulkCreditRequest; +use App\Http\Requests\Credit\CreateCreditRequest; +use App\Http\Requests\Credit\DestroyCreditRequest; use App\Http\Requests\Credit\EditCreditRequest; use App\Http\Requests\Credit\ShowCreditRequest; use App\Http\Requests\Credit\StoreCreditRequest; -use App\Http\Requests\Credit\ActionCreditRequest; -use App\Http\Requests\Credit\CreateCreditRequest; use App\Http\Requests\Credit\UpdateCreditRequest; use App\Http\Requests\Credit\UploadCreditRequest; -use App\Http\Requests\Credit\DestroyCreditRequest; +use App\Jobs\Credit\ZipCredits; +use App\Jobs\Entity\EmailEntity; +use App\Models\Account; +use App\Models\Client; +use App\Models\Credit; +use App\Models\Invoice; +use App\Repositories\CreditRepository; +use App\Services\PdfMaker\PdfMerge; +use App\Services\Template\TemplateAction; +use App\Transformers\CreditTransformer; +use App\Utils\Ninja; +use App\Utils\Traits\MakesHash; +use App\Utils\Traits\SavesDocuments; +use Illuminate\Http\Response; +use Illuminate\Support\Facades\App; +use Illuminate\Support\Facades\Storage; /** * Class CreditController. diff --git a/app/Http/Controllers/EmailController.php b/app/Http/Controllers/EmailController.php index f5f74685b476..5bdcdb8ac712 100644 --- a/app/Http/Controllers/EmailController.php +++ b/app/Http/Controllers/EmailController.php @@ -71,8 +71,9 @@ class EmailController extends BaseController if ($request->cc_email && (Ninja::isSelfHost() || $user->account->isPaidHostedClient())) { - foreach($request->cc_email as $email) + foreach($request->cc_email as $email) { $mo->cc[] = new Address($email); + } } diff --git a/app/Http/Controllers/ExpenseController.php b/app/Http/Controllers/ExpenseController.php index c70959f86e66..08571e09613d 100644 --- a/app/Http/Controllers/ExpenseController.php +++ b/app/Http/Controllers/ExpenseController.php @@ -11,28 +11,28 @@ namespace App\Http\Controllers; -use App\Utils\Ninja; -use App\Models\Account; -use App\Models\Expense; -use Illuminate\Http\Response; -use App\Factory\ExpenseFactory; -use App\Filters\ExpenseFilters; -use App\Utils\Traits\MakesHash; -use App\Utils\Traits\Uploadable; -use App\Utils\Traits\BulkOptions; -use App\Utils\Traits\SavesDocuments; -use App\Repositories\ExpenseRepository; -use App\Transformers\ExpenseTransformer; use App\Events\Expense\ExpenseWasCreated; use App\Events\Expense\ExpenseWasUpdated; +use App\Factory\ExpenseFactory; +use App\Filters\ExpenseFilters; use App\Http\Requests\Expense\BulkExpenseRequest; +use App\Http\Requests\Expense\CreateExpenseRequest; +use App\Http\Requests\Expense\DestroyExpenseRequest; use App\Http\Requests\Expense\EditExpenseRequest; use App\Http\Requests\Expense\ShowExpenseRequest; use App\Http\Requests\Expense\StoreExpenseRequest; -use App\Http\Requests\Expense\CreateExpenseRequest; use App\Http\Requests\Expense\UpdateExpenseRequest; use App\Http\Requests\Expense\UploadExpenseRequest; -use App\Http\Requests\Expense\DestroyExpenseRequest; +use App\Models\Account; +use App\Models\Expense; +use App\Repositories\ExpenseRepository; +use App\Transformers\ExpenseTransformer; +use App\Utils\Ninja; +use App\Utils\Traits\BulkOptions; +use App\Utils\Traits\MakesHash; +use App\Utils\Traits\SavesDocuments; +use App\Utils\Traits\Uploadable; +use Illuminate\Http\Response; /** * Class ExpenseController. diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 6e6fee2c7f3e..477ab8111d2a 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -528,7 +528,7 @@ class InvoiceController extends BaseController $filename = $invoices->first()->getFileName(); - return response()->streamDownload(function () use($invoices) { + return response()->streamDownload(function () use ($invoices) { echo $invoices->first()->service()->getInvoicePdf(); }, $filename, ['Content-Type' => 'application/pdf']); } diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php index d413c7029612..10b8af7dcb38 100644 --- a/app/Http/Controllers/PaymentController.php +++ b/app/Http/Controllers/PaymentController.php @@ -11,27 +11,27 @@ namespace App\Http\Controllers; -use App\Utils\Ninja; -use App\Models\Account; -use App\Models\Payment; -use Illuminate\Http\Response; +use App\Events\Payment\PaymentWasUpdated; use App\Factory\PaymentFactory; use App\Filters\PaymentFilters; -use App\Utils\Traits\MakesHash; -use App\Utils\Traits\SavesDocuments; -use App\Repositories\PaymentRepository; -use App\Transformers\PaymentTransformer; -use App\Events\Payment\PaymentWasUpdated; -use App\Services\Template\TemplateAction; +use App\Http\Requests\Payment\BulkActionPaymentRequest; +use App\Http\Requests\Payment\CreatePaymentRequest; +use App\Http\Requests\Payment\DestroyPaymentRequest; use App\Http\Requests\Payment\EditPaymentRequest; +use App\Http\Requests\Payment\RefundPaymentRequest; use App\Http\Requests\Payment\ShowPaymentRequest; use App\Http\Requests\Payment\StorePaymentRequest; -use App\Http\Requests\Payment\CreatePaymentRequest; -use App\Http\Requests\Payment\RefundPaymentRequest; use App\Http\Requests\Payment\UpdatePaymentRequest; use App\Http\Requests\Payment\UploadPaymentRequest; -use App\Http\Requests\Payment\DestroyPaymentRequest; -use App\Http\Requests\Payment\BulkActionPaymentRequest; +use App\Models\Account; +use App\Models\Payment; +use App\Repositories\PaymentRepository; +use App\Services\Template\TemplateAction; +use App\Transformers\PaymentTransformer; +use App\Utils\Ninja; +use App\Utils\Traits\MakesHash; +use App\Utils\Traits\SavesDocuments; +use Illuminate\Http\Response; /** * Class PaymentController. @@ -519,7 +519,7 @@ class PaymentController extends BaseController if($action == 'template' && $user->can('view', $payments->first())) { $hash_or_response = request()->boolean('send_email') ? 'email sent' : \Illuminate\Support\Str::uuid(); -nlog($payments->pluck('hashed_id')->toArray()); + nlog($payments->pluck('hashed_id')->toArray()); TemplateAction::dispatch( $payments->pluck('hashed_id')->toArray(), $request->template_id, diff --git a/app/Http/Controllers/PreviewController.php b/app/Http/Controllers/PreviewController.php index 0359f5fa0076..e98f65c1f980 100644 --- a/app/Http/Controllers/PreviewController.php +++ b/app/Http/Controllers/PreviewController.php @@ -11,33 +11,31 @@ namespace App\Http\Controllers; -use App\Utils\Ninja; -use App\Models\Client; -use App\Models\Invoice; -use App\Utils\HtmlEngine; -use Twig\Error\SyntaxError; -use App\Jobs\Util\PreviewPdf; -use App\Models\ClientContact; -use App\Services\Pdf\PdfMock; -use App\Utils\Traits\MakesHash; -use App\Services\Pdf\PdfService; -use App\Utils\PhantomJS\Phantom; -use App\Models\InvoiceInvitation; -use App\Services\PdfMaker\Design; -use App\Utils\HostedPDF\NinjaPdf; -use Illuminate\Support\Facades\DB; -use App\Services\PdfMaker\PdfMaker; -use Illuminate\Support\Facades\App; -use App\Utils\Traits\MakesInvoiceHtml; -use Turbo124\Beacon\Facades\LightLogs; -use App\Utils\Traits\Pdf\PageNumbering; -use Illuminate\Support\Facades\Response; use App\DataMapper\Analytics\LivePreview; -use App\Services\Template\TemplateService; use App\Http\Requests\Preview\DesignPreviewRequest; -use App\Services\PdfMaker\Design as PdfDesignModel; -use App\Services\PdfMaker\Design as PdfMakerDesign; use App\Http\Requests\Preview\PreviewInvoiceRequest; +use App\Jobs\Util\PreviewPdf; +use App\Models\Client; +use App\Models\ClientContact; +use App\Models\Invoice; +use App\Models\InvoiceInvitation; +use App\Services\Pdf\PdfMock; +use App\Services\Pdf\PdfService; +use App\Services\PdfMaker\Design; +use App\Services\PdfMaker\PdfMaker; +use App\Services\Template\TemplateService; +use App\Utils\HostedPDF\NinjaPdf; +use App\Utils\HtmlEngine; +use App\Utils\Ninja; +use App\Utils\PhantomJS\Phantom; +use App\Utils\Traits\MakesHash; +use App\Utils\Traits\MakesInvoiceHtml; +use App\Utils\Traits\Pdf\PageNumbering; +use Illuminate\Support\Facades\App; +use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Response; +use Turbo124\Beacon\Facades\LightLogs; +use Twig\Error\SyntaxError; class PreviewController extends BaseController { diff --git a/app/Http/Controllers/PreviewPurchaseOrderController.php b/app/Http/Controllers/PreviewPurchaseOrderController.php index cdc0ff98de76..e0dbd3343029 100644 --- a/app/Http/Controllers/PreviewPurchaseOrderController.php +++ b/app/Http/Controllers/PreviewPurchaseOrderController.php @@ -11,33 +11,33 @@ namespace App\Http\Controllers; -use App\Utils\Ninja; -use App\Models\Client; -use App\Models\Vendor; -use App\Libraries\MultiDB; -use App\Jobs\Util\PreviewPdf; -use App\Models\PurchaseOrder; -use App\Models\VendorContact; -use App\Utils\Traits\MakesHash; -use App\Utils\VendorHtmlEngine; -use App\Services\Pdf\PdfService; -use App\Utils\PhantomJS\Phantom; -use App\Services\PdfMaker\Design; -use App\Utils\HostedPDF\NinjaPdf; -use Illuminate\Support\Facades\DB; -use App\Services\PdfMaker\PdfMaker; -use Illuminate\Support\Facades\App; -use App\Factory\PurchaseOrderFactory; -use App\Utils\Traits\MakesInvoiceHtml; -use Turbo124\Beacon\Facades\LightLogs; -use App\Models\PurchaseOrderInvitation; -use App\Utils\Traits\Pdf\PageNumbering; -use Illuminate\Support\Facades\Response; use App\DataMapper\Analytics\LivePreview; +use App\Factory\PurchaseOrderFactory; +use App\Http\Requests\Preview\PreviewPurchaseOrderRequest; +use App\Jobs\Util\PreviewPdf; +use App\Libraries\MultiDB; +use App\Models\Client; +use App\Models\PurchaseOrder; +use App\Models\PurchaseOrderInvitation; +use App\Models\Vendor; +use App\Models\VendorContact; use App\Repositories\PurchaseOrderRepository; +use App\Services\Pdf\PdfService; +use App\Services\PdfMaker\Design; use App\Services\PdfMaker\Design as PdfDesignModel; use App\Services\PdfMaker\Design as PdfMakerDesign; -use App\Http\Requests\Preview\PreviewPurchaseOrderRequest; +use App\Services\PdfMaker\PdfMaker; +use App\Utils\HostedPDF\NinjaPdf; +use App\Utils\Ninja; +use App\Utils\PhantomJS\Phantom; +use App\Utils\Traits\MakesHash; +use App\Utils\Traits\MakesInvoiceHtml; +use App\Utils\Traits\Pdf\PageNumbering; +use App\Utils\VendorHtmlEngine; +use Illuminate\Support\Facades\App; +use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Response; +use Turbo124\Beacon\Facades\LightLogs; class PreviewPurchaseOrderController extends BaseController { diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 79dc2c3b8a66..d57b023f6d61 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -11,25 +11,25 @@ namespace App\Http\Controllers; -use App\Models\Account; -use App\Models\Project; -use Illuminate\Http\Response; use App\Factory\ProjectFactory; use App\Filters\ProjectFilters; -use App\Utils\Traits\MakesHash; -use App\Utils\Traits\SavesDocuments; -use App\Utils\Traits\GeneratesCounter; -use App\Repositories\ProjectRepository; -use App\Transformers\ProjectTransformer; -use App\Services\Template\TemplateAction; +use App\Http\Requests\Project\BulkProjectRequest; +use App\Http\Requests\Project\CreateProjectRequest; +use App\Http\Requests\Project\DestroyProjectRequest; use App\Http\Requests\Project\EditProjectRequest; use App\Http\Requests\Project\ShowProjectRequest; use App\Http\Requests\Project\StoreProjectRequest; -use App\Http\Requests\Project\CreateProjectRequest; use App\Http\Requests\Project\UpdateProjectRequest; use App\Http\Requests\Project\UploadProjectRequest; -use App\Http\Requests\Project\DestroyProjectRequest; -use App\Http\Requests\Project\BulkProjectRequest; +use App\Models\Account; +use App\Models\Project; +use App\Repositories\ProjectRepository; +use App\Services\Template\TemplateAction; +use App\Transformers\ProjectTransformer; +use App\Utils\Traits\GeneratesCounter; +use App\Utils\Traits\MakesHash; +use App\Utils\Traits\SavesDocuments; +use Illuminate\Http\Response; /** * Class ProjectController. diff --git a/app/Http/Controllers/PurchaseOrderController.php b/app/Http/Controllers/PurchaseOrderController.php index 61fa572c5bfe..f25294bb6e1b 100644 --- a/app/Http/Controllers/PurchaseOrderController.php +++ b/app/Http/Controllers/PurchaseOrderController.php @@ -11,34 +11,34 @@ namespace App\Http\Controllers; -use App\Utils\Ninja; -use App\Models\Client; -use App\Models\Account; -use App\Models\PurchaseOrder; -use Illuminate\Http\Response; -use App\Utils\Traits\MakesHash; -use App\Jobs\Entity\CreateRawPdf; -use App\Services\PdfMaker\PdfMerge; -use App\Utils\Traits\SavesDocuments; -use App\Factory\PurchaseOrderFactory; -use App\Filters\PurchaseOrderFilters; -use Illuminate\Support\Facades\Storage; -use App\Services\Template\TemplateAction; -use App\Jobs\PurchaseOrder\ZipPurchaseOrders; -use App\Repositories\PurchaseOrderRepository; -use App\Jobs\PurchaseOrder\PurchaseOrderEmail; -use App\Transformers\PurchaseOrderTransformer; use App\Events\PurchaseOrder\PurchaseOrderWasCreated; use App\Events\PurchaseOrder\PurchaseOrderWasUpdated; +use App\Factory\PurchaseOrderFactory; +use App\Filters\PurchaseOrderFilters; +use App\Http\Requests\PurchaseOrder\ActionPurchaseOrderRequest; use App\Http\Requests\PurchaseOrder\BulkPurchaseOrderRequest; +use App\Http\Requests\PurchaseOrder\CreatePurchaseOrderRequest; +use App\Http\Requests\PurchaseOrder\DestroyPurchaseOrderRequest; use App\Http\Requests\PurchaseOrder\EditPurchaseOrderRequest; use App\Http\Requests\PurchaseOrder\ShowPurchaseOrderRequest; use App\Http\Requests\PurchaseOrder\StorePurchaseOrderRequest; -use App\Http\Requests\PurchaseOrder\ActionPurchaseOrderRequest; -use App\Http\Requests\PurchaseOrder\CreatePurchaseOrderRequest; use App\Http\Requests\PurchaseOrder\UpdatePurchaseOrderRequest; use App\Http\Requests\PurchaseOrder\UploadPurchaseOrderRequest; -use App\Http\Requests\PurchaseOrder\DestroyPurchaseOrderRequest; +use App\Jobs\Entity\CreateRawPdf; +use App\Jobs\PurchaseOrder\PurchaseOrderEmail; +use App\Jobs\PurchaseOrder\ZipPurchaseOrders; +use App\Models\Account; +use App\Models\Client; +use App\Models\PurchaseOrder; +use App\Repositories\PurchaseOrderRepository; +use App\Services\PdfMaker\PdfMerge; +use App\Services\Template\TemplateAction; +use App\Transformers\PurchaseOrderTransformer; +use App\Utils\Ninja; +use App\Utils\Traits\MakesHash; +use App\Utils\Traits\SavesDocuments; +use Illuminate\Http\Response; +use Illuminate\Support\Facades\Storage; class PurchaseOrderController extends BaseController { diff --git a/app/Http/Controllers/QuoteController.php b/app/Http/Controllers/QuoteController.php index b8fd4bae7fad..adb36637667a 100644 --- a/app/Http/Controllers/QuoteController.php +++ b/app/Http/Controllers/QuoteController.php @@ -11,41 +11,41 @@ namespace App\Http\Controllers; -use App\Utils\Ninja; -use App\Models\Quote; -use App\Models\Client; -use App\Models\Account; -use App\Models\Invoice; -use App\Models\Project; -use Illuminate\Http\Request; -use App\Factory\QuoteFactory; -use App\Filters\QuoteFilters; -use App\Jobs\Quote\ZipQuotes; -use Illuminate\Http\Response; -use App\Utils\Traits\MakesHash; -use App\Factory\CloneQuoteFactory; -use App\Services\PdfMaker\PdfMerge; -use Illuminate\Support\Facades\App; -use App\Utils\Traits\SavesDocuments; use App\Events\Quote\QuoteWasCreated; use App\Events\Quote\QuoteWasUpdated; -use App\Repositories\QuoteRepository; -use App\Transformers\QuoteTransformer; -use App\Utils\Traits\GeneratesCounter; -use Illuminate\Support\Facades\Storage; -use App\Transformers\InvoiceTransformer; -use App\Transformers\ProjectTransformer; -use App\Services\Template\TemplateAction; +use App\Factory\CloneQuoteFactory; use App\Factory\CloneQuoteToInvoiceFactory; +use App\Factory\QuoteFactory; +use App\Filters\QuoteFilters; +use App\Http\Requests\Quote\ActionQuoteRequest; +use App\Http\Requests\Quote\BulkActionQuoteRequest; +use App\Http\Requests\Quote\CreateQuoteRequest; +use App\Http\Requests\Quote\DestroyQuoteRequest; use App\Http\Requests\Quote\EditQuoteRequest; use App\Http\Requests\Quote\ShowQuoteRequest; use App\Http\Requests\Quote\StoreQuoteRequest; -use App\Http\Requests\Quote\ActionQuoteRequest; -use App\Http\Requests\Quote\CreateQuoteRequest; use App\Http\Requests\Quote\UpdateQuoteRequest; use App\Http\Requests\Quote\UploadQuoteRequest; -use App\Http\Requests\Quote\DestroyQuoteRequest; -use App\Http\Requests\Quote\BulkActionQuoteRequest; +use App\Jobs\Quote\ZipQuotes; +use App\Models\Account; +use App\Models\Client; +use App\Models\Invoice; +use App\Models\Project; +use App\Models\Quote; +use App\Repositories\QuoteRepository; +use App\Services\PdfMaker\PdfMerge; +use App\Services\Template\TemplateAction; +use App\Transformers\InvoiceTransformer; +use App\Transformers\ProjectTransformer; +use App\Transformers\QuoteTransformer; +use App\Utils\Ninja; +use App\Utils\Traits\GeneratesCounter; +use App\Utils\Traits\MakesHash; +use App\Utils\Traits\SavesDocuments; +use Illuminate\Http\Request; +use Illuminate\Http\Response; +use Illuminate\Support\Facades\App; +use Illuminate\Support\Facades\Storage; /** * Class QuoteController. @@ -854,7 +854,7 @@ class QuoteController extends BaseController $headers = array_merge($headers, ['Content-Disposition' => 'inline']); } - return response()->streamDownload(function () use ($quote,$contact) { + return response()->streamDownload(function () use ($quote, $contact) { echo $quote->service()->getQuotePdf($contact); }, $quote->getFileName(), $headers); diff --git a/app/Http/Controllers/Reports/ARDetailReportController.php b/app/Http/Controllers/Reports/ARDetailReportController.php index 1d3183a41d29..3eecd27cac2a 100644 --- a/app/Http/Controllers/Reports/ARDetailReportController.php +++ b/app/Http/Controllers/Reports/ARDetailReportController.php @@ -11,12 +11,12 @@ namespace App\Http\Controllers\Reports; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; -use App\Jobs\Report\PreviewReport; -use App\Services\Report\ARDetailReport; use App\Http\Controllers\BaseController; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Services\Report\ARDetailReport; +use App\Utils\Traits\MakesHash; class ARDetailReportController extends BaseController { diff --git a/app/Http/Controllers/Reports/ARSummaryReportController.php b/app/Http/Controllers/Reports/ARSummaryReportController.php index 0898c9e408ae..9b1ff6d25f61 100644 --- a/app/Http/Controllers/Reports/ARSummaryReportController.php +++ b/app/Http/Controllers/Reports/ARSummaryReportController.php @@ -11,12 +11,12 @@ namespace App\Http\Controllers\Reports; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; -use App\Jobs\Report\PreviewReport; use App\Http\Controllers\BaseController; -use App\Services\Report\ARSummaryReport; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Services\Report\ARSummaryReport; +use App\Utils\Traits\MakesHash; class ARSummaryReportController extends BaseController { diff --git a/app/Http/Controllers/Reports/ClientBalanceReportController.php b/app/Http/Controllers/Reports/ClientBalanceReportController.php index d3b1859dd07c..d5dfb8cb4870 100644 --- a/app/Http/Controllers/Reports/ClientBalanceReportController.php +++ b/app/Http/Controllers/Reports/ClientBalanceReportController.php @@ -11,12 +11,12 @@ namespace App\Http\Controllers\Reports; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; -use App\Jobs\Report\PreviewReport; use App\Http\Controllers\BaseController; -use App\Services\Report\ClientBalanceReport; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Services\Report\ClientBalanceReport; +use App\Utils\Traits\MakesHash; class ClientBalanceReportController extends BaseController { diff --git a/app/Http/Controllers/Reports/ClientSalesReportController.php b/app/Http/Controllers/Reports/ClientSalesReportController.php index 612986f42123..545c89bb6ea8 100644 --- a/app/Http/Controllers/Reports/ClientSalesReportController.php +++ b/app/Http/Controllers/Reports/ClientSalesReportController.php @@ -11,12 +11,12 @@ namespace App\Http\Controllers\Reports; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; -use App\Jobs\Report\PreviewReport; use App\Http\Controllers\BaseController; -use App\Services\Report\ClientSalesReport; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Services\Report\ClientSalesReport; +use App\Utils\Traits\MakesHash; class ClientSalesReportController extends BaseController { diff --git a/app/Http/Controllers/Reports/ProductSalesReportController.php b/app/Http/Controllers/Reports/ProductSalesReportController.php index a2b8902db852..796adfd1e492 100644 --- a/app/Http/Controllers/Reports/ProductSalesReportController.php +++ b/app/Http/Controllers/Reports/ProductSalesReportController.php @@ -11,14 +11,14 @@ namespace App\Http\Controllers\Reports; -use App\Models\Client; -use Illuminate\Http\Response; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; -use App\Jobs\Report\PreviewReport; use App\Export\CSV\ProductSalesExport; use App\Http\Controllers\BaseController; use App\Http\Requests\Report\ProductSalesReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Models\Client; +use App\Utils\Traits\MakesHash; +use Illuminate\Http\Response; class ProductSalesReportController extends BaseController { diff --git a/app/Http/Controllers/Reports/ProfitAndLossController.php b/app/Http/Controllers/Reports/ProfitAndLossController.php index 18e575dd8d7c..7d52865eb927 100644 --- a/app/Http/Controllers/Reports/ProfitAndLossController.php +++ b/app/Http/Controllers/Reports/ProfitAndLossController.php @@ -11,14 +11,14 @@ namespace App\Http\Controllers\Reports; -use App\Models\Client; -use Illuminate\Http\Response; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; -use App\Jobs\Report\PreviewReport; -use App\Services\Report\ProfitLoss; use App\Http\Controllers\BaseController; use App\Http\Requests\Report\ProfitLossRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Models\Client; +use App\Services\Report\ProfitLoss; +use App\Utils\Traits\MakesHash; +use Illuminate\Http\Response; class ProfitAndLossController extends BaseController { diff --git a/app/Http/Controllers/Reports/TaxSummaryReportController.php b/app/Http/Controllers/Reports/TaxSummaryReportController.php index 08b978a0037d..590234159f7a 100644 --- a/app/Http/Controllers/Reports/TaxSummaryReportController.php +++ b/app/Http/Controllers/Reports/TaxSummaryReportController.php @@ -11,12 +11,12 @@ namespace App\Http\Controllers\Reports; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; -use App\Jobs\Report\PreviewReport; use App\Http\Controllers\BaseController; -use App\Services\Report\TaxSummaryReport; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Services\Report\TaxSummaryReport; +use App\Utils\Traits\MakesHash; class TaxSummaryReportController extends BaseController { diff --git a/app/Http/Controllers/Reports/UserSalesReportController.php b/app/Http/Controllers/Reports/UserSalesReportController.php index c26e7dd35d3e..cb904ad76783 100644 --- a/app/Http/Controllers/Reports/UserSalesReportController.php +++ b/app/Http/Controllers/Reports/UserSalesReportController.php @@ -11,12 +11,12 @@ namespace App\Http\Controllers\Reports; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; -use App\Jobs\Report\PreviewReport; use App\Http\Controllers\BaseController; -use App\Services\Report\UserSalesReport; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Services\Report\UserSalesReport; +use App\Utils\Traits\MakesHash; class UserSalesReportController extends BaseController { diff --git a/app/Http/Controllers/SubdomainController.php b/app/Http/Controllers/SubdomainController.php index 910662d618cd..3800935ac85c 100644 --- a/app/Http/Controllers/SubdomainController.php +++ b/app/Http/Controllers/SubdomainController.php @@ -27,7 +27,7 @@ class SubdomainController extends BaseController public function index() { if (!MultiDB::checkDomainAvailable(request()->input('subdomain'))) { - return response()->json(['message' => ctrans('texts.subdomain_is_not_available')], 401); + return response()->json(['message' => ctrans('texts.subdomain_is_not_available')], 401); } return response()->json(['message' => 'Domain available'], 200); diff --git a/app/Http/Controllers/TaskController.php b/app/Http/Controllers/TaskController.php index dd7200cf1fa0..f3b0f37549dd 100644 --- a/app/Http/Controllers/TaskController.php +++ b/app/Http/Controllers/TaskController.php @@ -11,31 +11,31 @@ namespace App\Http\Controllers; -use App\Models\Task; -use App\Utils\Ninja; -use App\Models\Account; -use App\Models\TaskStatus; -use App\Factory\TaskFactory; -use App\Filters\TaskFilters; -use Illuminate\Http\Response; -use App\Utils\Traits\MakesHash; -use App\Utils\Traits\Uploadable; -use App\Utils\Traits\BulkOptions; use App\Events\Task\TaskWasCreated; use App\Events\Task\TaskWasUpdated; -use App\Repositories\TaskRepository; -use App\Utils\Traits\SavesDocuments; -use App\Transformers\TaskTransformer; -use App\Services\Template\TemplateAction; +use App\Factory\TaskFactory; +use App\Filters\TaskFilters; use App\Http\Requests\Task\BulkTaskRequest; +use App\Http\Requests\Task\CreateTaskRequest; +use App\Http\Requests\Task\DestroyTaskRequest; use App\Http\Requests\Task\EditTaskRequest; use App\Http\Requests\Task\ShowTaskRequest; use App\Http\Requests\Task\SortTaskRequest; use App\Http\Requests\Task\StoreTaskRequest; -use App\Http\Requests\Task\CreateTaskRequest; use App\Http\Requests\Task\UpdateTaskRequest; use App\Http\Requests\Task\UploadTaskRequest; -use App\Http\Requests\Task\DestroyTaskRequest; +use App\Models\Account; +use App\Models\Task; +use App\Models\TaskStatus; +use App\Repositories\TaskRepository; +use App\Services\Template\TemplateAction; +use App\Transformers\TaskTransformer; +use App\Utils\Ninja; +use App\Utils\Traits\BulkOptions; +use App\Utils\Traits\MakesHash; +use App\Utils\Traits\SavesDocuments; +use App\Utils\Traits\Uploadable; +use Illuminate\Http\Response; /** * Class TaskController. diff --git a/app/Http/Controllers/VendorPortal/PurchaseOrderController.php b/app/Http/Controllers/VendorPortal/PurchaseOrderController.php index fb70c248b793..7ed0ffdcaa03 100644 --- a/app/Http/Controllers/VendorPortal/PurchaseOrderController.php +++ b/app/Http/Controllers/VendorPortal/PurchaseOrderController.php @@ -11,23 +11,23 @@ namespace App\Http\Controllers\VendorPortal; -use App\Utils\Ninja; -use Illuminate\View\View; -use App\Models\PurchaseOrder; -use App\Utils\Traits\MakesHash; -use App\Utils\Traits\MakesDates; -use App\Jobs\Entity\CreateRawPdf; -use App\Http\Controllers\Controller; -use App\Jobs\Invoice\InjectSignature; -use Illuminate\Support\Facades\Cache; -use Illuminate\Contracts\View\Factory; -use App\Models\PurchaseOrderInvitation; use App\Events\Misc\InvitationWasViewed; -use App\Events\PurchaseOrder\PurchaseOrderWasViewed; use App\Events\PurchaseOrder\PurchaseOrderWasAccepted; +use App\Events\PurchaseOrder\PurchaseOrderWasViewed; +use App\Http\Controllers\Controller; +use App\Http\Requests\VendorPortal\PurchaseOrders\ProcessPurchaseOrdersInBulkRequest; use App\Http\Requests\VendorPortal\PurchaseOrders\ShowPurchaseOrderRequest; use App\Http\Requests\VendorPortal\PurchaseOrders\ShowPurchaseOrdersRequest; -use App\Http\Requests\VendorPortal\PurchaseOrders\ProcessPurchaseOrdersInBulkRequest; +use App\Jobs\Entity\CreateRawPdf; +use App\Jobs\Invoice\InjectSignature; +use App\Models\PurchaseOrder; +use App\Models\PurchaseOrderInvitation; +use App\Utils\Ninja; +use App\Utils\Traits\MakesDates; +use App\Utils\Traits\MakesHash; +use Illuminate\Contracts\View\Factory; +use Illuminate\Support\Facades\Cache; +use Illuminate\View\View; class PurchaseOrderController extends Controller { diff --git a/app/Http/Middleware/Locale.php b/app/Http/Middleware/Locale.php index 3cbf90217dc7..253c442360ac 100644 --- a/app/Http/Middleware/Locale.php +++ b/app/Http/Middleware/Locale.php @@ -67,9 +67,9 @@ class Locale * @return mixed */ public function handle($request, Closure $next) - { + { /*LOCALE SET */ - if ($request->has('lang') && in_array($request->input('lang','en'), $this->locales) ) { + if ($request->has('lang') && in_array($request->input('lang', 'en'), $this->locales)) { $locale = $request->input('lang'); App::setLocale($locale); } elseif (auth()->guard('contact')->user()) { diff --git a/app/Http/Middleware/VendorLocale.php b/app/Http/Middleware/VendorLocale.php index 6da86375ad0a..5fd327f00bba 100644 --- a/app/Http/Middleware/VendorLocale.php +++ b/app/Http/Middleware/VendorLocale.php @@ -17,48 +17,48 @@ use Illuminate\Support\Facades\App; class VendorLocale { - private array $locales = [ - 'en', - 'it', - 'de', - 'fr', - 'pt_BR', - 'nl', - 'es', - 'nb_NO', - 'da', - 'ja', - 'sv', - 'es_ES', - 'fr_CA', - 'lt', - 'pl', - 'cs', - 'hr', - 'sq', - 'el', - 'en_GB', - 'pt_PT', - 'sl', - 'fi', - 'ro', - 'tr_TR', - 'th', - 'mk_MK', - 'zh_TW', - 'ru_RU', - 'ar', - 'fa', - 'lv_LV', - 'sr', - 'sk', - 'et', - 'bg', - 'he', - 'km_KH', - 'hu', - 'fr_CH', - ]; + private array $locales = [ + 'en', + 'it', + 'de', + 'fr', + 'pt_BR', + 'nl', + 'es', + 'nb_NO', + 'da', + 'ja', + 'sv', + 'es_ES', + 'fr_CA', + 'lt', + 'pl', + 'cs', + 'hr', + 'sq', + 'el', + 'en_GB', + 'pt_PT', + 'sl', + 'fi', + 'ro', + 'tr_TR', + 'th', + 'mk_MK', + 'zh_TW', + 'ru_RU', + 'ar', + 'fa', + 'lv_LV', + 'sr', + 'sk', + 'et', + 'bg', + 'he', + 'km_KH', + 'hu', + 'fr_CH', + ]; /** * Handle an incoming request. * @@ -74,7 +74,7 @@ class VendorLocale } /*LOCALE SET */ - if ($request->has('lang') && in_array($request->input('lang','en'), $this->locales) ) { + if ($request->has('lang') && in_array($request->input('lang', 'en'), $this->locales)) { $locale = $request->input('lang'); App::setLocale($locale); } elseif (auth()->guard('vendor')->user()) { diff --git a/app/Http/Requests/CompanyGateway/StoreCompanyGatewayRequest.php b/app/Http/Requests/CompanyGateway/StoreCompanyGatewayRequest.php index d007de24275f..26b08f85929d 100644 --- a/app/Http/Requests/CompanyGateway/StoreCompanyGatewayRequest.php +++ b/app/Http/Requests/CompanyGateway/StoreCompanyGatewayRequest.php @@ -11,7 +11,6 @@ namespace App\Http\Requests\CompanyGateway; -use App\DataMapper\FeesAndLimits; use App\Http\Requests\Request; use App\Http\ValidationRules\ValidCompanyGatewayFeesAndLimitsRule; use App\Models\Gateway; diff --git a/app/Http/Requests/Design/UpdateDesignRequest.php b/app/Http/Requests/Design/UpdateDesignRequest.php index f51185e4b8cd..ec5cb5dece4c 100644 --- a/app/Http/Requests/Design/UpdateDesignRequest.php +++ b/app/Http/Requests/Design/UpdateDesignRequest.php @@ -11,8 +11,8 @@ namespace App\Http\Requests\Design; -use App\Models\Account; use App\Http\Requests\Request; +use App\Models\Account; use App\Utils\Traits\ChecksEntityStatus; class UpdateDesignRequest extends Request diff --git a/app/Http/Requests/Email/SendEmailRequest.php b/app/Http/Requests/Email/SendEmailRequest.php index 7ab733014f5d..69eb19f90167 100644 --- a/app/Http/Requests/Email/SendEmailRequest.php +++ b/app/Http/Requests/Email/SendEmailRequest.php @@ -74,12 +74,12 @@ class SendEmailRequest extends Request $input['entity'] = "App\Models\\".ucfirst(Str::camel($input['entity'])); } - if(isset($input['cc_email'])){ - $input['cc_email'] = collect(explode(",", $input['cc_email']))->map(function($email){ + if(isset($input['cc_email'])) { + $input['cc_email'] = collect(explode(",", $input['cc_email']))->map(function ($email) { return trim($email); - })->filter(function($email){ + })->filter(function ($email) { return filter_var($email, FILTER_VALIDATE_EMAIL); - })->slice(0,4)->toArray(); + })->slice(0, 4)->toArray(); } $this->replace($input); diff --git a/app/Http/Requests/Invoice/BulkInvoiceRequest.php b/app/Http/Requests/Invoice/BulkInvoiceRequest.php index e7d947d6fc93..c46fe6db8069 100644 --- a/app/Http/Requests/Invoice/BulkInvoiceRequest.php +++ b/app/Http/Requests/Invoice/BulkInvoiceRequest.php @@ -12,7 +12,6 @@ namespace App\Http\Requests\Invoice; use App\Http\Requests\Request; -use App\Models\Payment; class BulkInvoiceRequest extends Request { diff --git a/app/Http/Requests/Payment/StorePaymentRequest.php b/app/Http/Requests/Payment/StorePaymentRequest.php index 75769fda1a5f..efc9aeca14e4 100644 --- a/app/Http/Requests/Payment/StorePaymentRequest.php +++ b/app/Http/Requests/Payment/StorePaymentRequest.php @@ -97,7 +97,7 @@ class StorePaymentRequest extends Request } if (! isset($input['idempotency_key'])) { - $input['idempotency_key'] = substr(sha1(json_encode($input)).time()."{$input['date']}{$input['amount']}{$user->id}",0,64); + $input['idempotency_key'] = substr(sha1(json_encode($input)).time()."{$input['date']}{$input['amount']}{$user->id}", 0, 64); } $this->replace($input); diff --git a/app/Http/Requests/Preview/PreviewPurchaseOrderRequest.php b/app/Http/Requests/Preview/PreviewPurchaseOrderRequest.php index e7075e1a0bb8..4ec935f7de4e 100644 --- a/app/Http/Requests/Preview/PreviewPurchaseOrderRequest.php +++ b/app/Http/Requests/Preview/PreviewPurchaseOrderRequest.php @@ -11,12 +11,12 @@ namespace App\Http\Requests\Preview; -use App\Models\Vendor; -use App\Models\PurchaseOrder; use App\Http\Requests\Request; -use App\Utils\Traits\MakesHash; -use App\Utils\Traits\CleanLineItems; +use App\Models\PurchaseOrder; use App\Models\PurchaseOrderInvitation; +use App\Models\Vendor; +use App\Utils\Traits\CleanLineItems; +use App\Utils\Traits\MakesHash; class PreviewPurchaseOrderRequest extends Request { diff --git a/app/Http/Requests/Task/StoreTaskRequest.php b/app/Http/Requests/Task/StoreTaskRequest.php index d9ddff121d4e..12d61e9441cf 100644 --- a/app/Http/Requests/Task/StoreTaskRequest.php +++ b/app/Http/Requests/Task/StoreTaskRequest.php @@ -56,8 +56,9 @@ class StoreTaskRequest extends Request $rules['time_log'] = ['bail',function ($attribute, $values, $fail) { - if(is_string($values)) + if(is_string($values)) { $values = json_decode($values, true); + } if(!is_array($values)) { $fail('The '.$attribute.' must be a valid array.'); @@ -119,7 +120,7 @@ class StoreTaskRequest extends Request } } - if(!isset($input['time_log']) || empty($input['time_log']) || $input['time_log'] == '{}'){ + if(!isset($input['time_log']) || empty($input['time_log']) || $input['time_log'] == '{}') { $input['time_log'] = json_encode([]); } diff --git a/app/Import/Transformer/BaseTransformer.php b/app/Import/Transformer/BaseTransformer.php index 843330ac87db..03928b2fa698 100644 --- a/app/Import/Transformer/BaseTransformer.php +++ b/app/Import/Transformer/BaseTransformer.php @@ -77,7 +77,7 @@ class BaseTransformer } public function getString($data, $field) - { + { return isset($data[$field]) && $data[$field] ? trim($data[$field]) : ''; } @@ -677,8 +677,9 @@ class BaseTransformer */ public function getProjectId($name, $clientId = null) { - if(strlen($name) == 0) + if(strlen($name) == 0) { return null; + } $project = Project::query()->where('company_id', $this->company->id) ->where('is_deleted', false) diff --git a/app/Import/Transformer/Csv/TaskTransformer.php b/app/Import/Transformer/Csv/TaskTransformer.php index 9ebf8c6d449a..690eb1ec8790 100644 --- a/app/Import/Transformer/Csv/TaskTransformer.php +++ b/app/Import/Transformer/Csv/TaskTransformer.php @@ -11,8 +11,8 @@ namespace App\Import\Transformer\Csv; -use App\Models\TaskStatus; use App\Import\Transformer\BaseTransformer; +use App\Models\TaskStatus; /** * Class TaskTransformer. @@ -29,10 +29,11 @@ class TaskTransformer extends BaseTransformer { $this->stubbed_timestamp = time(); - if(count($task_items_data) == count($task_items_data, COUNT_RECURSIVE)) + if(count($task_items_data) == count($task_items_data, COUNT_RECURSIVE)) { $task_data = $task_items_data; - else + } else { $task_data = reset($task_items_data); + } $clientId = $this->getClient( $this->getString($task_data, 'client.name'), @@ -79,12 +80,13 @@ class TaskTransformer extends BaseTransformer $notes = $item['task.notes'] ?? ''; - if(isset($item['task.is_billable']) && is_string($item['task.is_billable']) && in_array($item['task.is_billable'], ['yes', 'true', '1'])) + if(isset($item['task.is_billable']) && is_string($item['task.is_billable']) && in_array($item['task.is_billable'], ['yes', 'true', '1'])) { $is_billable = true; - elseif(isset($item['task.is_billable']) && is_bool($item['task.is_billable'])) + } elseif(isset($item['task.is_billable']) && is_bool($item['task.is_billable'])) { $is_billable = $item['task.is_billable']; - else + } else { $is_billable = false; + } if(isset($item['task.start_date']) && isset($item['task.end_date'])) { @@ -148,8 +150,7 @@ class TaskTransformer extends BaseTransformer private function getTaskStatusId($item): ?int { - if(isset($item['task.status'])) - { + if(isset($item['task.status'])) { $name = strtolower(trim($item['task.status'])); $ts = TaskStatus::query()->where('company_id', $this->company->id) @@ -159,9 +160,10 @@ class TaskTransformer extends BaseTransformer ]) ->first(); - if($ts) - return $ts->id; - } + if($ts) { + return $ts->id; + } + } return TaskStatus::where('company_id', $this->company->id) ->where('is_deleted', false) diff --git a/app/Jobs/Company/CompanyImport.php b/app/Jobs/Company/CompanyImport.php index fc5219b31901..7c84d721b1e9 100644 --- a/app/Jobs/Company/CompanyImport.php +++ b/app/Jobs/Company/CompanyImport.php @@ -16,7 +16,6 @@ use App\Exceptions\NonExistingMigrationFile; use App\Factory\ClientContactFactory; use App\Jobs\Mail\NinjaMailerJob; use App\Jobs\Mail\NinjaMailerObject; -use App\Jobs\Ninja\TaskScheduler; use App\Libraries\MultiDB; use App\Mail\Import\CompanyImportFailure; use App\Mail\Import\ImportCompleted; @@ -218,7 +217,7 @@ class CompanyImport implements ShouldQueue 'baseline' => [], '5.7.35' => [ Payment::class => [ - 'refund_meta', + 'refund_meta', 'category_id', ], User::class => [ @@ -462,7 +461,7 @@ class CompanyImport implements ShouldQueue $this->company->save(); - return $this; + return $this; } private function purgeCompanyData() @@ -1367,8 +1366,9 @@ class CompanyImport implements ShouldQueue private function filterVersionProps($class, array $obj_array): array { - if($this->current_app_version == $this->import_version) + if($this->current_app_version == $this->import_version) { return $obj_array; + } $version_index = 0; $index = 0; @@ -1390,9 +1390,9 @@ class CompanyImport implements ShouldQueue return $collection->slice($version_index)->pluck($class)->filter(); }); - return collect($obj_array)->diffKeys($filters->flatten()->flip())->toArray(); + return collect($obj_array)->diffKeys($filters->flatten()->flip())->toArray(); - } + } private function genericNewClassImport($class, $unset, $transforms, $object_property) { @@ -1415,7 +1415,7 @@ class CompanyImport implements ShouldQueue $obj_array['gateway_key'] = 'd14dd26a37cecc30fdd65700bfb55b23'; } - if(!isset($obj_array['fees_and_limits'])){ + if(!isset($obj_array['fees_and_limits'])) { $obj_array['fees_and_limits'] = \json_encode([]); } } @@ -1467,16 +1467,16 @@ class CompanyImport implements ShouldQueue /** @var \stdClass $parameters */ $parameters = $obj_array['parameters']; - if(isset($parameters->clients)){ + if(isset($parameters->clients)) { $parameters->clients = - collect($parameters->clients)->map(function ($client_hash){ + collect($parameters->clients)->map(function ($client_hash) { return $this->encodePrimaryKey($this->transformId('clients', $client_hash)); })->toArray(); } - if(isset($parameters->entity_id)){ + if(isset($parameters->entity_id)) { $parameters->entity_id = $this->encodePrimaryKey($this->transformId($parameters->entity."s", $parameters->entity_id)); } @@ -1485,7 +1485,7 @@ class CompanyImport implements ShouldQueue $new_obj = new $class(); $new_obj->company_id = $this->company->id; - $obj_array = $this->filterVersionProps($class,$obj_array); + $obj_array = $this->filterVersionProps($class, $obj_array); $new_obj->fill($obj_array); diff --git a/app/Jobs/Company/CreateCompany.php b/app/Jobs/Company/CreateCompany.php index 984c29993cd2..5ca76e3071ed 100644 --- a/app/Jobs/Company/CreateCompany.php +++ b/app/Jobs/Company/CreateCompany.php @@ -14,7 +14,6 @@ namespace App\Jobs\Company; use App\DataMapper\ClientRegistrationFields; use App\DataMapper\CompanySettings; use App\DataMapper\Tax\TaxModel; -use App\Factory\TaxRateFactory; use App\Libraries\MultiDB; use App\Models\Company; use App\Models\Country; diff --git a/app/Jobs/Cron/UpdateCalculatedFields.php b/app/Jobs/Cron/UpdateCalculatedFields.php index 77a629fce31d..6413a36a90bc 100644 --- a/app/Jobs/Cron/UpdateCalculatedFields.php +++ b/app/Jobs/Cron/UpdateCalculatedFields.php @@ -79,9 +79,9 @@ class UpdateCalculatedFields $project->tasks->each(function ($task) use (&$duration) { - if(is_iterable(json_decode($task->time_log) )) { + if(is_iterable(json_decode($task->time_log))) { - foreach(json_decode($task->time_log) as $log) { + foreach(json_decode($task->time_log) as $log) { $start_time = $log[0]; $end_time = $log[1] == 0 ? time() : $log[1]; diff --git a/app/Jobs/Entity/CreateRawPdf.php b/app/Jobs/Entity/CreateRawPdf.php index 57e214784071..47a8f288b6b0 100644 --- a/app/Jobs/Entity/CreateRawPdf.php +++ b/app/Jobs/Entity/CreateRawPdf.php @@ -11,23 +11,23 @@ namespace App\Jobs\Entity; -use App\Models\Quote; -use App\Models\Credit; -use App\Models\Invoice; -use App\Models\PurchaseOrder; -use App\Models\QuoteInvitation; -use App\Utils\Traits\MakesHash; -use App\Models\CreditInvitation; -use App\Models\RecurringInvoice; -use App\Services\Pdf\PdfService; -use App\Models\InvoiceInvitation; -use App\Utils\Traits\Pdf\PdfMaker; -use App\Utils\Traits\NumberFormatter; -use App\Utils\Traits\MakesInvoiceHtml; -use App\Models\PurchaseOrderInvitation; -use App\Utils\Traits\Pdf\PageNumbering; use App\Exceptions\FilePermissionsFailure; +use App\Models\Credit; +use App\Models\CreditInvitation; +use App\Models\Invoice; +use App\Models\InvoiceInvitation; +use App\Models\PurchaseOrder; +use App\Models\PurchaseOrderInvitation; +use App\Models\Quote; +use App\Models\QuoteInvitation; +use App\Models\RecurringInvoice; use App\Models\RecurringInvoiceInvitation; +use App\Services\Pdf\PdfService; +use App\Utils\Traits\MakesHash; +use App\Utils\Traits\MakesInvoiceHtml; +use App\Utils\Traits\NumberFormatter; +use App\Utils\Traits\Pdf\PageNumbering; +use App\Utils\Traits\Pdf\PdfMaker; class CreateRawPdf { @@ -63,7 +63,7 @@ class CreateRawPdf } elseif ($invitation instanceof RecurringInvoiceInvitation) { $this->entity = $invitation->recurring_invoice; $this->entity_string = 'recurring_invoice'; - } elseif ($invitation instanceof PurchaseOrderInvitation){ + } elseif ($invitation instanceof PurchaseOrderInvitation) { $this->entity = $invitation->purchase_order; $this->entity_string = 'purchase_order'; } @@ -72,8 +72,9 @@ class CreateRawPdf private function resolveType(): string { - if($this->type) + if($this->type) { return $this->type; + } $type = 'product'; diff --git a/app/Jobs/Expense/VendorExpenseNotify.php b/app/Jobs/Expense/VendorExpenseNotify.php index 16a6b83a33d0..805bb5dfe731 100644 --- a/app/Jobs/Expense/VendorExpenseNotify.php +++ b/app/Jobs/Expense/VendorExpenseNotify.php @@ -11,21 +11,21 @@ namespace App\Jobs\Expense; +use App\Libraries\MultiDB; +use App\Models\Activity; +use App\Models\Expense; +use App\Models\VendorContact; +use App\Repositories\ActivityRepository; +use App\Services\Email\Email; +use App\Services\Email\EmailObject; use App\Utils\Ninja; use App\Utils\Number; -use App\Models\Expense; -use App\Models\Activity; -use App\Libraries\MultiDB; -use App\Models\VendorContact; -use App\Services\Email\Email; -use Illuminate\Bus\Queueable; -use App\Services\Email\EmailObject; -use Illuminate\Queue\SerializesModels; -use App\Repositories\ActivityRepository; use App\Utils\Traits\MakesDates; -use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Queue\SerializesModels; class VendorExpenseNotify implements ShouldQueue { @@ -41,9 +41,9 @@ class VendorExpenseNotify implements ShouldQueue { MultiDB::setDB($this->db); - $this->expense->vendor->contacts->filter(function(VendorContact $contact){ + $this->expense->vendor->contacts->filter(function (VendorContact $contact) { return $contact->send_email && $contact->email; - })->each(function(VendorContact $contact){ + })->each(function (VendorContact $contact) { $this->notify($contact); }); } @@ -96,4 +96,4 @@ class VendorExpenseNotify implements ShouldQueue $activity_repo->save($fields, $this->expense, Ninja::eventVars()); } -} \ No newline at end of file +} diff --git a/app/Jobs/Ledger/ClientLedgerBalanceUpdate.php b/app/Jobs/Ledger/ClientLedgerBalanceUpdate.php index 58f41ff61221..aee2b08e1aa7 100644 --- a/app/Jobs/Ledger/ClientLedgerBalanceUpdate.php +++ b/app/Jobs/Ledger/ClientLedgerBalanceUpdate.php @@ -89,7 +89,7 @@ class ClientLedgerBalanceUpdate implements ShouldQueue $company_ledger->balance = ($parent_ledger ? $parent_ledger->balance : 0) + $company_ledger->adjustment; $company_ledger->save(); - }); + }); // nlog("finished job {$uuid}"); } diff --git a/app/Jobs/Ledger/UpdateLedger.php b/app/Jobs/Ledger/UpdateLedger.php index 48605c75a766..308a05367505 100644 --- a/app/Jobs/Ledger/UpdateLedger.php +++ b/app/Jobs/Ledger/UpdateLedger.php @@ -14,11 +14,11 @@ namespace App\Jobs\Ledger; use App\Libraries\MultiDB; use App\Models\CompanyLedger; use Illuminate\Bus\Queueable; -use Illuminate\Queue\SerializesModels; -use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\Middleware\WithoutOverlapping; +use Illuminate\Queue\SerializesModels; //@deprecated class UpdateLedger implements ShouldQueue @@ -51,20 +51,21 @@ class UpdateLedger implements ShouldQueue nlog($cl->company_ledgerable->company_ledger()->count()); - if(!$cl) + if(!$cl) { return; + } $entity = $cl->company_ledgerable; $balance = $entity->calc()->getBalance(); $cl->adjustment = $ledger_item ? $balance : ($balance - $this->start_amount); - $parent_ledger = CompanyLedger::query() - ->where('id', '<', $cl->id) - ->where('company_id', $cl->company_id) - ->where('client_id', $cl->client_id) - ->where('balance', '!=', 0) - ->orderBy('id', 'DESC') - ->first(); + $parent_ledger = CompanyLedger::query() + ->where('id', '<', $cl->id) + ->where('company_id', $cl->company_id) + ->where('client_id', $cl->client_id) + ->where('balance', '!=', 0) + ->orderBy('id', 'DESC') + ->first(); $cl->balance = ($parent_ledger ? $parent_ledger->balance : 0) + $cl->adjustment; $cl->save(); diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index 3b8211f4ba86..60c3b7fbd81c 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -24,7 +24,6 @@ use App\Models\Invoice; use App\Models\Payment; use App\Models\SystemLog; use App\Models\User; -use App\Repositories\ActivityRepository; use App\Utils\Ninja; use App\Utils\Traits\MakesHash; use GuzzleHttp\Exception\ClientException; diff --git a/app/Jobs/Ninja/SystemMaintenance.php b/app/Jobs/Ninja/SystemMaintenance.php index 7b5243016fb2..30e60bda13b5 100644 --- a/app/Jobs/Ninja/SystemMaintenance.php +++ b/app/Jobs/Ninja/SystemMaintenance.php @@ -159,4 +159,4 @@ class SystemMaintenance implements ShouldQueue // } -} \ No newline at end of file +} diff --git a/app/Jobs/Payment/EmailPayment.php b/app/Jobs/Payment/EmailPayment.php index 31e83bc9efff..455b4161ca35 100644 --- a/app/Jobs/Payment/EmailPayment.php +++ b/app/Jobs/Payment/EmailPayment.php @@ -111,7 +111,7 @@ class EmailPayment implements ShouldQueue $invoice = $this->payment->invoices->first(); - $invoice->invitations->each(function ($invite) use ($email_builder){ + $invoice->invitations->each(function ($invite) use ($email_builder) { $nmo = new NinjaMailerObject; $nmo->mailable = new TemplateEmail($email_builder, $invite->contact, $invite); diff --git a/app/Jobs/PurchaseOrder/ZipPurchaseOrders.php b/app/Jobs/PurchaseOrder/ZipPurchaseOrders.php index 10699dcbc115..9955f8925873 100644 --- a/app/Jobs/PurchaseOrder/ZipPurchaseOrders.php +++ b/app/Jobs/PurchaseOrder/ZipPurchaseOrders.php @@ -11,21 +11,21 @@ namespace App\Jobs\PurchaseOrder; -use App\Models\User; -use App\Models\Company; -use App\Libraries\MultiDB; -use App\Jobs\Util\UnlinkFile; -use Illuminate\Bus\Queueable; use App\Jobs\Entity\CreateRawPdf; use App\Jobs\Mail\NinjaMailerJob; use App\Jobs\Mail\NinjaMailerObject; +use App\Jobs\Util\UnlinkFile; +use App\Libraries\MultiDB; use App\Mail\DownloadPurchaseOrders; -use Illuminate\Queue\SerializesModels; +use App\Models\Company; use App\Models\PurchaseOrderInvitation; -use Illuminate\Support\Facades\Storage; -use Illuminate\Queue\InteractsWithQueue; +use App\Models\User; +use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Queue\SerializesModels; +use Illuminate\Support\Facades\Storage; class ZipPurchaseOrders implements ShouldQueue { diff --git a/app/Jobs/Report/PreviewReport.php b/app/Jobs/Report/PreviewReport.php index 43fd133e888e..6fd2f4fb0406 100644 --- a/app/Jobs/Report/PreviewReport.php +++ b/app/Jobs/Report/PreviewReport.php @@ -39,10 +39,11 @@ class PreviewReport implements ShouldQueue /** @var \App\Export\CSV\CreditExport $export */ $export = new $this->report_class($this->company, $this->request); - if(isset($this->request['output']) && $this->request['output'] == 'json') + if(isset($this->request['output']) && $this->request['output'] == 'json') { $report = $export->returnJson(); - else + } else { $report = $export->run(); + } // nlog($report); diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index 1fa0d357d6c6..13b2448093c8 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -364,23 +364,27 @@ class Import implements ShouldQueue if (isset($data['plan_expires'])) { unset($data['plan_expires']); } - } - else { + } else { - if(isset($data['plan'])) + if(isset($data['plan'])) { $account->plan = $data['plan']; + } - if (isset($data['plan_term'])) + if (isset($data['plan_term'])) { $account->plan_term = $data['plan_term']; + } - if (isset($data['plan_paid'])) + if (isset($data['plan_paid'])) { $account->plan_paid = $data['plan_paid']; + } - if (isset($data['plan_started'])) + if (isset($data['plan_started'])) { $account->plan_started = $data['plan_started']; + } - if (isset($data['plan_expires'])) + if (isset($data['plan_expires'])) { $account->plan_expires = $data['plan_expires']; + } } diff --git a/app/Jobs/Util/VersionCheck.php b/app/Jobs/Util/VersionCheck.php index 76b177836eba..f8e8219d73e7 100644 --- a/app/Jobs/Util/VersionCheck.php +++ b/app/Jobs/Util/VersionCheck.php @@ -11,20 +11,20 @@ namespace App\Jobs\Util; -use Carbon\Carbon; -use App\Utils\Ninja; -use App\Models\Client; -use App\Models\Vendor; -use App\Models\Account; -use Illuminate\Support\Str; -use App\Models\ClientContact; -use Illuminate\Bus\Queueable; use App\Factory\ClientContactFactory; use App\Factory\VendorContactFactory; -use Illuminate\Queue\SerializesModels; -use Illuminate\Queue\InteractsWithQueue; +use App\Models\Account; +use App\Models\Client; +use App\Models\ClientContact; +use App\Models\Vendor; +use App\Utils\Ninja; +use Carbon\Carbon; +use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Queue\SerializesModels; +use Illuminate\Support\Str; class VersionCheck implements ShouldQueue { @@ -81,7 +81,7 @@ class VersionCheck implements ShouldQueue $c->send_email = false; $c->saveQuietly(); - }); + }); ClientContact::query() ->whereNull('contact_key') @@ -91,7 +91,7 @@ class VersionCheck implements ShouldQueue Client::doesntHave('contacts') ->cursor() - ->each(function ($client){ + ->each(function ($client) { $new_contact = ClientContactFactory::create($client->company_id, $client->user_id); $new_contact->client_id = $client->id; @@ -104,14 +104,14 @@ class VersionCheck implements ShouldQueue Vendor::doesntHave('contacts') ->cursor() - ->each(function ($vendor){ + ->each(function ($vendor) { $new_contact = VendorContactFactory::create($vendor->company_id, $vendor->user_id); $new_contact->vendor_id = $vendor->id; $new_contact->contact_key = Str::random(40); $new_contact->is_primary = true; $new_contact->save(); - }); + }); } diff --git a/app/Jobs/Vendor/CreatePurchaseOrderPdf.php b/app/Jobs/Vendor/CreatePurchaseOrderPdf.php index 59777bed2a91..f4669a7b49bd 100644 --- a/app/Jobs/Vendor/CreatePurchaseOrderPdf.php +++ b/app/Jobs/Vendor/CreatePurchaseOrderPdf.php @@ -11,29 +11,29 @@ namespace App\Jobs\Vendor; -use App\Utils\Ninja; -use App\Models\Design; -use App\Libraries\MultiDB; -use Illuminate\Bus\Queueable; -use App\Utils\Traits\MakesHash; -use App\Utils\VendorHtmlEngine; -use App\Services\Pdf\PdfService; -use App\Utils\PhantomJS\Phantom; -use App\Utils\HostedPDF\NinjaPdf; -use App\Utils\Traits\Pdf\PdfMaker; -use Illuminate\Support\Facades\App; -use App\Utils\Traits\NumberFormatter; -use App\Utils\Traits\MakesInvoiceHtml; -use Illuminate\Queue\SerializesModels; -use App\Utils\Traits\Pdf\PageNumbering; -use Illuminate\Support\Facades\Storage; -use Illuminate\Queue\InteractsWithQueue; use App\Exceptions\FilePermissionsFailure; -use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Foundation\Bus\Dispatchable; +use App\Libraries\MultiDB; +use App\Models\Design; +use App\Services\Pdf\PdfService; use App\Services\PdfMaker\Design as PdfDesignModel; use App\Services\PdfMaker\Design as PdfMakerDesign; use App\Services\PdfMaker\PdfMaker as PdfMakerService; +use App\Utils\HostedPDF\NinjaPdf; +use App\Utils\Ninja; +use App\Utils\PhantomJS\Phantom; +use App\Utils\Traits\MakesHash; +use App\Utils\Traits\MakesInvoiceHtml; +use App\Utils\Traits\NumberFormatter; +use App\Utils\Traits\Pdf\PageNumbering; +use App\Utils\Traits\Pdf\PdfMaker; +use App\Utils\VendorHtmlEngine; +use Illuminate\Bus\Queueable; +use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Queue\SerializesModels; +use Illuminate\Support\Facades\App; +use Illuminate\Support\Facades\Storage; /** @deprecated 26-10-2023 5.7.30x */ class CreatePurchaseOrderPdf implements ShouldQueue diff --git a/app/Libraries/OAuth/Providers/Google.php b/app/Libraries/OAuth/Providers/Google.php index ce55554c983a..c2b5249313ef 100644 --- a/app/Libraries/OAuth/Providers/Google.php +++ b/app/Libraries/OAuth/Providers/Google.php @@ -3,6 +3,7 @@ namespace App\Libraries\OAuth\Providers; use Google_Client; + class Google implements ProviderInterface { public function getTokenResponse($token) @@ -38,8 +39,7 @@ class Google implements ProviderInterface try { $userInfo = $oauth2->userinfo->get(); - } - catch (\Exception $e) { + } catch (\Exception $e) { return false; } diff --git a/app/Listeners/LogResponseReceived.php b/app/Listeners/LogResponseReceived.php index 77dff2029936..28cb12e24fcf 100644 --- a/app/Listeners/LogResponseReceived.php +++ b/app/Listeners/LogResponseReceived.php @@ -11,23 +11,15 @@ namespace App\Listeners; -use App\Utils\Ninja; -use App\Libraries\MultiDB; -use App\Mail\User\UserAdded; -use Illuminate\Support\Carbon; -use App\Jobs\Mail\NinjaMailerJob; -use Illuminate\Support\Facades\App; -use App\Jobs\Mail\NinjaMailerObject; -use Illuminate\Queue\SerializesModels; -use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; +use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Http\Client\Events\ResponseReceived; +use Illuminate\Queue\SerializesModels; class LogResponseReceived { - use Dispatchable, InteractsWithSockets, SerializesModels; + use Dispatchable, InteractsWithSockets, SerializesModels; /** * Create the event listener. diff --git a/app/Mail/Engine/PurchaseOrderEmailEngine.php b/app/Mail/Engine/PurchaseOrderEmailEngine.php index b1f4a3bb3032..0d5b7e5321fa 100644 --- a/app/Mail/Engine/PurchaseOrderEmailEngine.php +++ b/app/Mail/Engine/PurchaseOrderEmailEngine.php @@ -11,17 +11,17 @@ namespace App\Mail\Engine; -use App\Utils\Ninja; -use App\Utils\Number; -use App\Models\Vendor; +use App\DataMapper\EmailTemplateDefaults; +use App\Jobs\Entity\CreateRawPdf; use App\Models\Account; use App\Models\PurchaseOrder; +use App\Models\Vendor; +use App\Utils\Ninja; +use App\Utils\Number; use App\Utils\Traits\MakesHash; use App\Utils\VendorHtmlEngine; -use App\Jobs\Entity\CreateRawPdf; use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\URL; -use App\DataMapper\EmailTemplateDefaults; class PurchaseOrderEmailEngine extends BaseEmailEngine { diff --git a/app/Models/Company.php b/app/Models/Company.php index 9b3096be8bff..8f37c7d063bc 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -11,22 +11,21 @@ namespace App\Models; -use App\Utils\Ninja; use App\Casts\EncryptedCast; -use App\Models\VendorContact; -use App\Utils\Traits\AppSetup; -use App\Utils\Traits\MakesHash; use App\DataMapper\CompanySettings; -use Illuminate\Support\Facades\App; -use Illuminate\Support\Facades\Cache; -use Laracasts\Presenter\PresentableTrait; -use App\Utils\Traits\CompanySettingsSaver; -use Illuminate\Notifications\Notification; use App\Models\Presenters\CompanyPresenter; use App\Services\Company\CompanyService; use App\Services\Notification\NotificationService; -use Illuminate\Database\Eloquent\Relations\HasMany; +use App\Utils\Ninja; +use App\Utils\Traits\AppSetup; +use App\Utils\Traits\CompanySettingsSaver; +use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Notifications\Notification; +use Illuminate\Support\Facades\App; +use Illuminate\Support\Facades\Cache; +use Laracasts\Presenter\PresentableTrait; /** * App\Models\Company diff --git a/app/Models/Document.php b/app/Models/Document.php index 5d4ab5923cb2..08835291f584 100644 --- a/app/Models/Document.php +++ b/app/Models/Document.php @@ -11,7 +11,6 @@ namespace App\Models; -use App\Helpers\Document\WithTypeHelpers; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Facades\Storage; @@ -211,8 +210,9 @@ class Document extends BaseModel $image = $this->getFile(); $catch_image = $image; - if(!extension_loaded('imagick')) + if(!extension_loaded('imagick')) { return $catch_image; + } try { $file = base64_encode($image); @@ -224,8 +224,7 @@ class Document extends BaseModel return $img->getImageBlob(); - } - catch(\Exception $e){ + } catch(\Exception $e) { nlog($e->getMessage()); return $catch_image; diff --git a/app/Models/Gateway.php b/app/Models/Gateway.php index d811ea7ed064..53d628836cc2 100644 --- a/app/Models/Gateway.php +++ b/app/Models/Gateway.php @@ -90,7 +90,7 @@ class Gateway extends StaticModel if ($this->id == 1) { $link = 'http://reseller.authorize.net/application/?id=5560364'; - } elseif (in_array($this->id,[15,60,61])) { + } elseif (in_array($this->id, [15,60,61])) { $link = 'https://www.paypal.com/us/cgi-bin/webscr?cmd=_login-api-run'; } elseif ($this->id == 24) { $link = 'https://www.2checkout.com/referral?r=2c37ac2298'; diff --git a/app/Models/Task.php b/app/Models/Task.php index 332c8a67f582..368eae40d55b 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -164,11 +164,13 @@ class Task extends BaseModel public function stringStatus() { - if($this->invoice_id) + if($this->invoice_id) { return '
'.ctrans('texts.invoiced').'
'; + } - if($this->status) + if($this->status) { return '
' . $this->status?->name ?? ''; + } return ''; @@ -255,18 +257,20 @@ class Task extends BaseModel public function processLogs() { - return - collect(json_decode($this->time_log,true))->map(function ($log){ + return + collect(json_decode($this->time_log, true))->map(function ($log) { $parent_entity = $this->client ?? $this->company; - if($log[0]) + if($log[0]) { $log[0] = Carbon::createFromTimestamp($log[0])->format($parent_entity->date_format().' H:i:s'); + } - if($log[1] && $log[1] != 0) + if($log[1] && $log[1] != 0) { $log[1] = Carbon::createFromTimestamp($log[1])->format($parent_entity->date_format().' H:i:s'); - else + } else { $log[1] = ctrans('texts.running'); + } return $log; })->toArray(); @@ -276,28 +280,27 @@ class Task extends BaseModel public function processLogsExpandedNotation() { - return - collect(json_decode($this->time_log,true))->map(function ($log){ + return + collect(json_decode($this->time_log, true))->map(function ($log) { $parent_entity = $this->client ?? $this->company; $logged = []; - if($log[0] && $log[1] !=0 ) { + if($log[0] && $log[1] !=0) { $duration = $log[1] - $log[0]; - } - else { + } else { $duration = 0; } - if($log[0]) + if($log[0]) { $logged['start_date_raw'] = $log[0]; - $logged['start_date'] = Carbon::createFromTimestamp($log[0])->setTimeZone($this->company->timezone()->name)->format($parent_entity->date_format().' H:i:s'); + } + $logged['start_date'] = Carbon::createFromTimestamp($log[0])->setTimeZone($this->company->timezone()->name)->format($parent_entity->date_format().' H:i:s'); if($log[1] && $log[1] != 0) { $logged['end_date_raw'] = $log[1]; $logged['end_date'] = Carbon::createFromTimestamp($log[1])->setTimeZone($this->company->timezone()->name)->format($parent_entity->date_format().' H:i:s'); - } - else{ + } else { $logged['end_date_raw'] = 0; $logged['end_date'] = ctrans('texts.running'); } diff --git a/app/PaymentDrivers/Authorize/AuthorizeCustomer.php b/app/PaymentDrivers/Authorize/AuthorizeCustomer.php index a72fe5efe59d..4dd677aeebf6 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCustomer.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCustomer.php @@ -99,7 +99,7 @@ class AuthorizeCustomer $client = $client_gateway_token->client; } elseif ($client_contact = ClientContact::where('company_id', $company->id)->where('email', $profile['email'])->first()) { $client = $client_contact->client; - // nlog("found client through contact"); + // nlog("found client through contact"); } else { // nlog("creating client"); diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index ad9493865c99..8a324094779f 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -749,19 +749,19 @@ class BaseDriver extends AbstractPaymentDriver $invoices_string = str_replace(["*","<",">","'",'"'], "-", $invoices_string); -// 2023-11-02 - improve the statement descriptor for string + // 2023-11-02 - improve the statement descriptor for string -$company_name = $this->client->company->present()->name(); -$company_name = str_replace(["*","<",">","'",'"'], "-", $company_name); + $company_name = $this->client->company->present()->name(); + $company_name = str_replace(["*","<",">","'",'"'], "-", $company_name); -if(ctype_digit(substr($company_name, 0, 1))) { - $company_name = "I" . $company_name; -} + if(ctype_digit(substr($company_name, 0, 1))) { + $company_name = "I" . $company_name; + } -$company_name = substr($company_name, 0, 11); -$descriptor = "{$company_name} {$invoices_string}"; -$descriptor = substr($descriptor, 0, 22); -return $descriptor; + $company_name = substr($company_name, 0, 11); + $descriptor = "{$company_name} {$invoices_string}"; + $descriptor = substr($descriptor, 0, 22); + return $descriptor; } /** diff --git a/app/PaymentDrivers/GoCardlessPaymentDriver.php b/app/PaymentDrivers/GoCardlessPaymentDriver.php index 6ab26b96fe1c..00db105fa717 100644 --- a/app/PaymentDrivers/GoCardlessPaymentDriver.php +++ b/app/PaymentDrivers/GoCardlessPaymentDriver.php @@ -406,7 +406,7 @@ class GoCardlessPaymentDriver extends BaseDriver if(!in_array($mandate->status, ['pending_submission', 'submitted', 'active','pending_customer_approval'])) { - // if ($mandate->status !== 'active') { + // if ($mandate->status !== 'active') { throw new \Exception(ctrans('texts.gocardless_mandate_not_ready')); } } catch (\Exception $exception) { diff --git a/app/PaymentDrivers/PayPalPPCPPaymentDriver.php b/app/PaymentDrivers/PayPalPPCPPaymentDriver.php index 2684aaa1cec4..739f80463a7d 100644 --- a/app/PaymentDrivers/PayPalPPCPPaymentDriver.php +++ b/app/PaymentDrivers/PayPalPPCPPaymentDriver.php @@ -21,7 +21,6 @@ use App\Models\SystemLog; use App\Utils\Traits\MakesHash; use Carbon\Carbon; use Illuminate\Support\Facades\Http; -use Omnipay\Omnipay; use Str; class PayPalPPCPPaymentDriver extends BaseDriver @@ -65,7 +64,7 @@ class PayPalPPCPPaymentDriver extends BaseDriver ]; /** - * Return an array of + * Return an array of * enabled gateway payment methods * * @return array @@ -74,9 +73,9 @@ class PayPalPPCPPaymentDriver extends BaseDriver { return collect($this->company_gateway->fees_and_limits) - ->filter(function ($fee){ + ->filter(function ($fee) { return $fee->is_enabled; - })->map(function ($fee, $key){ + })->map(function ($fee, $key) { return (int)$key; })->toArray(); @@ -86,7 +85,7 @@ class PayPalPPCPPaymentDriver extends BaseDriver { $method = PaymentType::PAYPAL; - match($gateway_type_id){ + match($gateway_type_id) { "1" => $method = PaymentType::CREDIT_CARD_OTHER, "3" => $method = PaymentType::PAYPAL, "25" => $method = PaymentType::VENMO, @@ -132,7 +131,7 @@ class PayPalPPCPPaymentDriver extends BaseDriver /** * Initialize the Paypal gateway. - * + * * Attempt to generate and return the access token. * * @return self @@ -145,8 +144,9 @@ class PayPalPPCPPaymentDriver extends BaseDriver $secret = config('ninja.paypal.secret'); $client_id = config('ninja.paypal.client_id'); - if($this->access_token && $this->token_expiry && $this->token_expiry->isFuture()) + if($this->access_token && $this->token_expiry && $this->token_expiry->isFuture()) { return $this; + } $response = Http::withBasicAuth($client_id, $secret) ->withHeaders(['Content-Type' => 'application/x-www-form-urlencoded']) @@ -194,7 +194,7 @@ class PayPalPPCPPaymentDriver extends BaseDriver private function checkPaymentsReceivable(): self { - if($this->company_gateway->getConfigField('status') != 'activated'){ + if($this->company_gateway->getConfigField('status') != 'activated') { if (class_exists(\Modules\Admin\Services\PayPal\PayPalService::class)) { $pp = new \Modules\Admin\Services\PayPal\PayPalService($this->company_gateway->company, $this->company_gateway->user); @@ -203,8 +203,9 @@ class PayPalPPCPPaymentDriver extends BaseDriver $this->company_gateway = $this->company_gateway->fresh(); $config = $this->company_gateway->getConfig(); - if($config->status == 'activated') + if($config->status == 'activated') { return $this; + } } @@ -241,8 +242,9 @@ class PayPalPPCPPaymentDriver extends BaseDriver $r = $this->gatewayRequest('/v1/identity/generate-token', 'post', ['body' => '']); - if($r->successful()) + if($r->successful()) { return $r->json()['client_token']; + } throw new PaymentFailed('Unable to gain client token from Paypal. Check your configuration', 401); @@ -278,8 +280,9 @@ class PayPalPPCPPaymentDriver extends BaseDriver } else { - if(isset($response['headers']) ?? false) + if(isset($response['headers']) ?? false) { unset($response['headers']); + } SystemLogger::dispatch( ['response' => $response], @@ -360,7 +363,7 @@ class PayPalPPCPPaymentDriver extends BaseDriver $invoice = Invoice::withTrashed()->find($this->decodePrimaryKey($_invoice->invoice_id)); - $description = collect($invoice->line_items)->map(function ($item){ + $description = collect($invoice->line_items)->map(function ($item) { return $item->notes; })->implode("\n"); @@ -405,7 +408,7 @@ class PayPalPPCPPaymentDriver extends BaseDriver ]; - if($shipping = $this->getShippingAddress()){ + if($shipping = $this->getShippingAddress()) { $order['purchase_units'][0] = $shipping; } @@ -417,9 +420,9 @@ class PayPalPPCPPaymentDriver extends BaseDriver } - private function getBillingAddress(): array + private function getBillingAddress(): array { - return + return [ "address_line_1" => $this->client->address1, "address_line_2" => $this->client->address2, @@ -432,10 +435,10 @@ class PayPalPPCPPaymentDriver extends BaseDriver private function getShippingAddress(): ?array { - return $this->company_gateway->require_shipping_address ? + return $this->company_gateway->require_shipping_address ? [ "shipping" => [ - "address" => + "address" => [ "address_line_1" => $this->client->shipping_address1, "address_line_2" => $this->client->shipping_address2, @@ -481,4 +484,4 @@ class PayPalPPCPPaymentDriver extends BaseDriver { } -} \ No newline at end of file +} diff --git a/app/Repositories/ExpenseRepository.php b/app/Repositories/ExpenseRepository.php index 307ccdaeecf4..d2fed634748a 100644 --- a/app/Repositories/ExpenseRepository.php +++ b/app/Repositories/ExpenseRepository.php @@ -12,16 +12,16 @@ namespace App\Repositories; -use App\Models\Expense; -use Illuminate\Support\Carbon; use App\Factory\ExpenseFactory; +use App\Jobs\Expense\VendorExpenseNotify; +use App\Libraries\Currency\Conversion\CurrencyApi; +use App\Models\Expense; use App\Models\ExpenseCategory; use App\Utils\Traits\GeneratesCounter; -use Illuminate\Database\QueryException; -use App\Jobs\Expense\VendorExpenseNotify; -use Illuminate\Database\Eloquent\Collection; use Carbon\Exceptions\InvalidFormatException; -use App\Libraries\Currency\Conversion\CurrencyApi; +use Illuminate\Database\Eloquent\Collection; +use Illuminate\Database\QueryException; +use Illuminate\Support\Carbon; /** * ExpenseRepository. @@ -48,8 +48,7 @@ class ExpenseRepository extends BaseRepository if(isset($data['payment_date']) && $data['payment_date'] == $expense->payment_date) { //do nothing - } - elseif(isset($data['payment_date']) && strlen($data['payment_date']) > 1 && $user->company()->notify_vendor_when_paid && ($data['vendor_id'] || $expense->vendor_id)) { + } elseif(isset($data['payment_date']) && strlen($data['payment_date']) > 1 && $user->company()->notify_vendor_when_paid && ($data['vendor_id'] || $expense->vendor_id)) { nlog("ping"); $this->notify_vendor = true; } @@ -62,16 +61,17 @@ class ExpenseRepository extends BaseRepository if (empty($expense->number)) { $expense = $this->findAndSaveNumber($expense); - } - else + } else { $expense->saveQuietly(); + } if (array_key_exists('documents', $data)) { $this->saveDocuments($data['documents'], $expense); } - if($this->notify_vendor) + if($this->notify_vendor) { VendorExpenseNotify::dispatch($expense, $expense->company->db); + } return $expense; } @@ -188,13 +188,13 @@ class ExpenseRepository extends BaseRepository { $ec = ExpenseCategory::withTrashed()->find($category_id); - $expenses->when($ec) - ->each(function ($expense) use($ec){ + $expenses->when($ec) + ->each(function ($expense) use ($ec) { - $expense->category_id = $ec->id; - $expense->save(); + $expense->category_id = $ec->id; + $expense->save(); - }); + }); } } diff --git a/app/Repositories/VendorRepository.php b/app/Repositories/VendorRepository.php index 51a2a5d960df..9f4c20a978fe 100644 --- a/app/Repositories/VendorRepository.php +++ b/app/Repositories/VendorRepository.php @@ -55,7 +55,7 @@ class VendorRepository extends BaseRepository if ($vendor->number == '' || ! $vendor->number) { $vendor->number = $this->getNextVendorNumber($vendor); - } + } $vendor->saveQuietly(); diff --git a/app/Services/Client/ClientService.php b/app/Services/Client/ClientService.php index cdb9b5f5394c..2b7f76335539 100644 --- a/app/Services/Client/ClientService.php +++ b/app/Services/Client/ClientService.php @@ -11,17 +11,16 @@ namespace App\Services\Client; -use Carbon\Carbon; -use App\Utils\Number; use App\Models\Client; use App\Models\Credit; use App\Models\Invoice; use App\Models\Payment; use App\Services\Email\Email; -use App\Utils\Traits\MakesDates; -use Illuminate\Support\Facades\DB; use App\Services\Email\EmailObject; +use App\Utils\Number; +use App\Utils\Traits\MakesDates; use Illuminate\Mail\Mailables\Address; +use Illuminate\Support\Facades\DB; class ClientService { @@ -65,7 +64,7 @@ class ClientService /** * Seeing too many race conditions under heavy load here. - * + * * @param float $amount * @return ClientService */ diff --git a/app/Services/Client/PaymentMethod.php b/app/Services/Client/PaymentMethod.php index 348df82a5904..d343e7fb466c 100644 --- a/app/Services/Client/PaymentMethod.php +++ b/app/Services/Client/PaymentMethod.php @@ -80,25 +80,25 @@ class PaymentMethod return array_search($model->id, $transformed_ids); // this closure sorts for us }); - //2023-10-11 - Roll back, do not show any gateways, if they have been archived upstream. - //removing this logic now to prevent any - // if($this->gateways->count() == 0 && count($transformed_ids) >=1) { + //2023-10-11 - Roll back, do not show any gateways, if they have been archived upstream. + //removing this logic now to prevent any + // if($this->gateways->count() == 0 && count($transformed_ids) >=1) { - // /** - // * This is a fallback in case a user archives some gateways that have been ordered preferentially. - // * - // * If the user archives a parent gateway upstream, it may leave a client setting in a state where no payment gateways are available. - // * - // * In this case we fall back to all gateways. - // */ - // $this->gateways = CompanyGateway::query() - // ->with('gateway') - // ->where('company_id', $this->client->company_id) - // ->where('gateway_key', '!=', '54faab2ab6e3223dbe848b1686490baa') - // ->whereNull('deleted_at') - // ->where('is_deleted', false)->get(); + // /** + // * This is a fallback in case a user archives some gateways that have been ordered preferentially. + // * + // * If the user archives a parent gateway upstream, it may leave a client setting in a state where no payment gateways are available. + // * + // * In this case we fall back to all gateways. + // */ + // $this->gateways = CompanyGateway::query() + // ->with('gateway') + // ->where('company_id', $this->client->company_id) + // ->where('gateway_key', '!=', '54faab2ab6e3223dbe848b1686490baa') + // ->whereNull('deleted_at') + // ->where('is_deleted', false)->get(); - // } + // } } else { $this->gateways = CompanyGateway::query() diff --git a/app/Services/Client/Statement.php b/app/Services/Client/Statement.php index 1721b6f56236..ef591ce4a04e 100644 --- a/app/Services/Client/Statement.php +++ b/app/Services/Client/Statement.php @@ -434,16 +434,15 @@ class Statement ->where('balance', '>', 0) ->where('is_deleted', 0); - if($range == '0'){ - $query->where(function ($q) use($to, $from){ - $q->whereBetween('due_date', [$to, $from])->orWhereNull('due_date'); - }); - } - else { - $query->whereBetween('due_date', [$to, $from]); - } + if($range == '0') { + $query->where(function ($q) use ($to, $from) { + $q->whereBetween('due_date', [$to, $from])->orWhereNull('due_date'); + }); + } else { + $query->whereBetween('due_date', [$to, $from]); + } - $amount = $query->sum('balance'); + $amount = $query->sum('balance'); return Number::formatMoney($amount, $this->client); } diff --git a/app/Services/Company/CompanyService.php b/app/Services/Company/CompanyService.php index 49d8cb5cb7fc..cee1c37d8a93 100644 --- a/app/Services/Company/CompanyService.php +++ b/app/Services/Company/CompanyService.php @@ -11,11 +11,12 @@ namespace App\Services\Company; -use App\Models\User; -use App\Models\Company; use App\Factory\TaxRateFactory; +use App\Models\Company; +use App\Models\User; -class CompanyService{ +class CompanyService +{ public function __construct(public Company $company) { @@ -67,10 +68,10 @@ class CompanyService{ $tax_rate->save(); } - }catch(\Exception $e){ + } catch(\Exception $e) { nlog($e->getMessage()); } } -} \ No newline at end of file +} diff --git a/app/Services/Email/Email.php b/app/Services/Email/Email.php index 7bcc488f50b0..fa7cd008e33a 100644 --- a/app/Services/Email/Email.php +++ b/app/Services/Email/Email.php @@ -273,15 +273,15 @@ class Email implements ShouldQueue $message = $e->getMessage(); - if (stripos($e->getMessage(), 'code 300') || stripos($e->getMessage(), 'code 413')) { - $message = "Either Attachment too large, or recipient has been suppressed."; + if (stripos($e->getMessage(), 'code 300') || stripos($e->getMessage(), 'code 413')) { + $message = "Either Attachment too large, or recipient has been suppressed."; - $this->fail(); - $this->logMailError($e->getMessage(), $this->company->clients()->first()); - $this->cleanUpMailers(); + $this->fail(); + $this->logMailError($e->getMessage(), $this->company->clients()->first()); + $this->cleanUpMailers(); - return; - } + return; + } if (stripos($e->getMessage(), 'code 406')) { diff --git a/app/Services/Email/EmailDefaults.php b/app/Services/Email/EmailDefaults.php index 35413125db18..d643a26686d6 100644 --- a/app/Services/Email/EmailDefaults.php +++ b/app/Services/Email/EmailDefaults.php @@ -293,7 +293,7 @@ class EmailDefaults } /** Purchase Order / Invoice / Credit / Quote PDF */ - if ($this->email->email_object->settings->pdf_email_attachment){ + if ($this->email->email_object->settings->pdf_email_attachment) { $pdf = ((new CreateRawPdf($this->email->email_object->invitation))->handle()); $this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode($pdf), 'name' => $this->email->email_object->entity->numberFormatter().'.pdf']]); } diff --git a/app/Services/Invoice/HandleCancellation.php b/app/Services/Invoice/HandleCancellation.php index 206d1391e0bc..0abd802c8c07 100644 --- a/app/Services/Invoice/HandleCancellation.php +++ b/app/Services/Invoice/HandleCancellation.php @@ -74,7 +74,7 @@ class HandleCancellation extends AbstractService $this->invoice->client->service()->updateBalance($adjustment)->save(); -$this->invoice->client->service()->calculateBalance(); + $this->invoice->client->service()->calculateBalance(); /* Pop the cancellation out of the backup*/ diff --git a/app/Services/Ledger/LedgerService.php b/app/Services/Ledger/LedgerService.php index 2a589191d8b2..a55902ff9cde 100644 --- a/app/Services/Ledger/LedgerService.php +++ b/app/Services/Ledger/LedgerService.php @@ -11,11 +11,10 @@ namespace App\Services\Ledger; -use App\Models\Activity; -use App\Models\CompanyLedger; -use App\Jobs\Ledger\UpdateLedger; use App\Factory\CompanyLedgerFactory; use App\Jobs\Ledger\ClientLedgerBalanceUpdate; +use App\Models\Activity; +use App\Models\CompanyLedger; class LedgerService { @@ -45,8 +44,9 @@ class LedgerService public function updateInvoiceBalance($adjustment, $notes = '') { - if($adjustment == 0) + if($adjustment == 0) { return $this; + } // $timestamp = \Carbon\Carbon::createFromTimestamp($this->entity->updated_at)->format('ymdhhmmssSS'); // $hash = sha1($adjustment.$notes.$this->entity->status_id.$this->entity->client_id.$this->entity->amount.$this->entity->balance.$this->entity->company_id.Activity::UPDATE_INVOICE); diff --git a/app/Services/Payment/RefundPayment.php b/app/Services/Payment/RefundPayment.php index 82e2781e40a6..3d59466a850b 100644 --- a/app/Services/Payment/RefundPayment.php +++ b/app/Services/Payment/RefundPayment.php @@ -149,7 +149,7 @@ class RefundPayment $fields->user_id = $this->payment->user_id; $fields->company_id = $this->payment->company_id; $fields->activity_type_id = Activity::REFUNDED_PAYMENT; - $fields->client_id = $this->payment->client_id; + $fields->client_id = $this->payment->client_id; // $fields->credit_id // TODO $fields->notes = $notes; diff --git a/app/Services/Pdf/PdfConfiguration.php b/app/Services/Pdf/PdfConfiguration.php index a5783fbb4a8c..4dfd3f88acfc 100644 --- a/app/Services/Pdf/PdfConfiguration.php +++ b/app/Services/Pdf/PdfConfiguration.php @@ -330,7 +330,7 @@ class PdfConfiguration } } - /** + /** * Formats a given value based on the clients currency. * * @param float $value The number to be formatted diff --git a/app/Services/Pdf/PdfMock.php b/app/Services/Pdf/PdfMock.php index bc20ee18eaf8..83ff27e40938 100644 --- a/app/Services/Pdf/PdfMock.php +++ b/app/Services/Pdf/PdfMock.php @@ -483,8 +483,8 @@ class PdfMock '_rate3' => '', '$taxes' => '$40.00', '$total' => '$10.00', - '$refund' => '', - '$refunded' => '', + '$refund' => '', + '$refunded' => '', '$phone' => ' ', '$terms' => 'Default company invoice terms', '$from' => 'Bob Jones', diff --git a/app/Services/Pdf/PdfService.php b/app/Services/Pdf/PdfService.php index f879d4d23165..4d516078c391 100644 --- a/app/Services/Pdf/PdfService.php +++ b/app/Services/Pdf/PdfService.php @@ -11,20 +11,20 @@ namespace App\Services\Pdf; -use App\Models\Company; -use App\Models\Invoice; -use App\Utils\HtmlEngine; -use App\Models\QuoteInvitation; -use App\Utils\VendorHtmlEngine; -use App\Models\CreditInvitation; -use App\Utils\PhantomJS\Phantom; -use App\Models\InvoiceInvitation; -use App\Utils\HostedPDF\NinjaPdf; -use App\Utils\Traits\Pdf\PdfMaker; use App\Jobs\Invoice\CreateEInvoice; +use App\Models\Company; +use App\Models\CreditInvitation; +use App\Models\Invoice; +use App\Models\InvoiceInvitation; use App\Models\PurchaseOrderInvitation; -use App\Utils\Traits\Pdf\PageNumbering; +use App\Models\QuoteInvitation; use App\Models\RecurringInvoiceInvitation; +use App\Utils\HostedPDF\NinjaPdf; +use App\Utils\HtmlEngine; +use App\Utils\PhantomJS\Phantom; +use App\Utils\Traits\Pdf\PageNumbering; +use App\Utils\Traits\Pdf\PdfMaker; +use App\Utils\VendorHtmlEngine; use horstoeko\zugferd\ZugferdDocumentPdfBuilder; class PdfService @@ -179,8 +179,9 @@ class PdfService */ private function checkEInvoice(string $pdf): string { - if(!$this->config->entity instanceof Invoice) + if(!$this->config->entity instanceof Invoice) { return $pdf; + } $e_invoice_type = $this->config->settings->e_invoice_type; diff --git a/app/Services/Report/TaxSummaryReport.php b/app/Services/Report/TaxSummaryReport.php index 453e8bcc1a14..08a0a1d95287 100644 --- a/app/Services/Report/TaxSummaryReport.php +++ b/app/Services/Report/TaxSummaryReport.php @@ -85,8 +85,9 @@ class TaxSummaryReport extends BaseExport $this->csv->insertOne([ctrans('texts.tax_summary')]); $this->csv->insertOne([ctrans('texts.created_on'),' ',$this->translateDate(now()->format('Y-m-d'), $this->company->date_format(), $this->company->locale())]); - if($this->input['date_range'] != 'all') + if($this->input['date_range'] != 'all') { $this->csv->insertOne([ctrans('texts.date_range'),' ',$this->translateDate($this->start_date, $this->company->date_format(), $this->company->locale()),' - ',$this->translateDate($this->end_date, $this->company->date_format(), $this->company->locale())]); + } diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index e2e331b3f6dd..7c3eb2e88ff9 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -789,8 +789,8 @@ class SubscriptionService //do nothing } elseif ($last_invoice->balance > 0) { $last_invoice = null; - // $pro_rata_charge_amount = $this->calculateProRataCharge($last_invoice, $old_subscription); - // nlog("pro rata charge = {$pro_rata_charge_amount}"); + // $pro_rata_charge_amount = $this->calculateProRataCharge($last_invoice, $old_subscription); + // nlog("pro rata charge = {$pro_rata_charge_amount}"); } else { $pro_rata_refund_amount = $this->calculateProRataRefund($last_invoice, $old_subscription) * -1; nlog("pro rata refund = {$pro_rata_refund_amount}"); diff --git a/app/Services/Template/TemplateAction.php b/app/Services/Template/TemplateAction.php index e54ee199885f..bf78b3b83948 100644 --- a/app/Services/Template/TemplateAction.php +++ b/app/Services/Template/TemplateAction.php @@ -104,7 +104,7 @@ class TemplateAction implements ShouldQueue ->where('company_id', $this->company->id) ->get(); - // nlog($result->toArray()); + // nlog($result->toArray()); if($result->count() <= 1) { $data[$key] = collect($result); diff --git a/app/Services/Template/TemplateService.php b/app/Services/Template/TemplateService.php index ed0aeb4169e0..4c8134d76e48 100644 --- a/app/Services/Template/TemplateService.php +++ b/app/Services/Template/TemplateService.php @@ -11,32 +11,32 @@ namespace App\Services\Template; -use App\Models\User; -use App\Models\Quote; -use App\Utils\Number; -use Twig\Error\Error; use App\Models\Client; +use App\Models\Company; use App\Models\Credit; use App\Models\Design; -use App\Models\Vendor; -use App\Models\Company; use App\Models\Invoice; use App\Models\Payment; use App\Models\Project; -use App\Utils\HtmlEngine; -use Twig\Error\LoaderError; -use Twig\Error\SyntaxError; -use Twig\Error\RuntimeError; use App\Models\PurchaseOrder; -use App\Utils\VendorHtmlEngine; -use Twig\Sandbox\SecurityError; +use App\Models\Quote; use App\Models\RecurringInvoice; +use App\Models\User; +use App\Models\Vendor; +use App\Utils\HostedPDF\NinjaPdf; +use App\Utils\HtmlEngine; +use App\Utils\Number; use App\Utils\PaymentHtmlEngine; use App\Utils\Traits\MakesDates; -use App\Utils\HostedPDF\NinjaPdf; use App\Utils\Traits\Pdf\PdfMaker; -use Twig\Extra\Intl\IntlExtension; +use App\Utils\VendorHtmlEngine; use League\CommonMark\CommonMarkConverter; +use Twig\Error\Error; +use Twig\Error\LoaderError; +use Twig\Error\RuntimeError; +use Twig\Error\SyntaxError; +use Twig\Extra\Intl\IntlExtension; +use Twig\Sandbox\SecurityError; class TemplateService { @@ -104,8 +104,9 @@ class TemplateService $filter = new \Twig\TwigFilter('sum', function (?array $array, ?string $column) { - if(!is_array($array)) + if(!is_array($array)) { return 0; + } return array_sum(array_column($array, $column)); }); @@ -161,7 +162,7 @@ class TemplateService } public function addGlobal(array $var): self - { + { $this->global_vars = array_merge($this->global_vars, $var); return $this; @@ -1493,4 +1494,4 @@ class TemplateService return $this; } -} \ No newline at end of file +} diff --git a/app/Services/Vendor/VendorService.php b/app/Services/Vendor/VendorService.php index 100438957feb..f0d2a7f68ac3 100644 --- a/app/Services/Vendor/VendorService.php +++ b/app/Services/Vendor/VendorService.php @@ -18,4 +18,4 @@ class VendorService public function __construct(public Vendor $vendor) { } -} \ No newline at end of file +} diff --git a/config/broadcasting.php b/config/broadcasting.php index b5e1decc60ca..7267bbce6608 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -32,9 +32,9 @@ return [ 'pusher' => [ 'driver' => 'pusher', - 'key' => env('PUSHER_APP_KEY',''), - 'secret' => env('PUSHER_APP_SECRET',''), - 'app_id' => env('PUSHER_APP_ID',''), + 'key' => env('PUSHER_APP_KEY', ''), + 'secret' => env('PUSHER_APP_SECRET', ''), + 'app_id' => env('PUSHER_APP_ID', ''), 'options' => [ 'host' => env('PUSHER_HOST', 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com'), 'port' => env('PUSHER_PORT', 443), diff --git a/config/database.php b/config/database.php index ec0694c4110c..32dedf815481 100644 --- a/config/database.php +++ b/config/database.php @@ -237,4 +237,4 @@ return [ * $strategy->disableLoadBalancing(); * return new Predis\Connection\Replication\SentinelReplication($strategy); *}]; - */ \ No newline at end of file + */ diff --git a/config/liap.php b/config/liap.php index 2205309b88f5..4483546d3ffa 100644 --- a/config/liap.php +++ b/config/liap.php @@ -1,19 +1,19 @@ env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => env('APP_VERSION','5.7.54'), - 'app_tag' => env('APP_TAG','5.7.54'), + 'app_version' => env('APP_VERSION', '5.7.54'), + 'app_tag' => env('APP_TAG', '5.7.54'), 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', false), @@ -197,7 +197,7 @@ return [ 'ninja_default_company_gateway_id' => env('NINJA_COMPANY_GATEWAY_ID', null), 'ninja_hosted_secret' => env('NINJA_HOSTED_SECRET', ''), 'ninja_hosted_header' =>env('NINJA_HEADER', ''), - 'ninja_connect_secret' => env('NINJA_CONNECT_SECRET',''), + 'ninja_connect_secret' => env('NINJA_CONNECT_SECRET', ''), 'internal_queue_enabled' => env('INTERNAL_QUEUE_ENABLED', true), 'ninja_apple_api_key' => env('APPLE_API_KEY', false), 'ninja_apple_private_key' => env('APPLE_PRIVATE_KEY', false), @@ -218,7 +218,7 @@ return [ 'dev_mode' => env("YODLEE_DEV_MODE", false), 'config_name' => env("YODLEE_CONFIG_NAME", false), ], - 'licenses' => env('LICENSES',false), + 'licenses' => env('LICENSES', false), 'google_application_credentials' => env("GOOGLE_APPLICATION_CREDENTIALS", false), 'shopify' => [ 'client_id' => env('SHOPIFY_CLIENT_ID', null), diff --git a/database/factories/CompanyFactory.php b/database/factories/CompanyFactory.php index 05ba6aa1b8c9..9d2c61a38504 100644 --- a/database/factories/CompanyFactory.php +++ b/database/factories/CompanyFactory.php @@ -11,9 +11,9 @@ namespace Database\Factories; -use App\Utils\Traits\MakesHash; -use App\DataMapper\Tax\TaxModel; use App\DataMapper\CompanySettings; +use App\DataMapper\Tax\TaxModel; +use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Factories\Factory; class CompanyFactory extends Factory diff --git a/database/factories/InvoiceFactory.php b/database/factories/InvoiceFactory.php index 0724a776b324..713fc07350ad 100644 --- a/database/factories/InvoiceFactory.php +++ b/database/factories/InvoiceFactory.php @@ -37,8 +37,8 @@ class InvoiceFactory extends Factory //'tax_rate3' => 5, 'custom_value1' => $this->faker->date(), 'custom_value2' => rand(0, 1) ? 'yes' : 'no', - 'custom_value3' => $this->faker->numberBetween(1,4), - 'custom_value4' => $this->faker->numberBetween(1,4), + 'custom_value3' => $this->faker->numberBetween(1, 4), + 'custom_value4' => $this->faker->numberBetween(1, 4), 'is_deleted' => false, 'po_number' => $this->faker->text(10), 'date' => $this->faker->date(), diff --git a/database/factories/QuoteFactory.php b/database/factories/QuoteFactory.php index 7b3ea5865afe..67a5ef43f5f9 100644 --- a/database/factories/QuoteFactory.php +++ b/database/factories/QuoteFactory.php @@ -11,8 +11,8 @@ namespace Database\Factories; -use App\Models\Quote; use App\Factory\InvoiceItemFactory; +use App\Models\Quote; use Illuminate\Database\Eloquent\Factories\Factory; class QuoteFactory extends Factory diff --git a/database/migrations/2022_16_12_54687_add_stripe_bacs.php b/database/migrations/2022_16_12_54687_add_stripe_bacs.php index a454e483e29b..61c8677bbdb0 100644 --- a/database/migrations/2022_16_12_54687_add_stripe_bacs.php +++ b/database/migrations/2022_16_12_54687_add_stripe_bacs.php @@ -3,8 +3,6 @@ use App\Models\GatewayType; use App\Models\PaymentType; use Illuminate\Database\Migrations\Migration; -use Illuminate\Database\Schema\Blueprint; -use Illuminate\Support\Facades\Schema; return new class extends Migration { /** @@ -16,8 +14,7 @@ return new class extends Migration { { $pt = PaymentType::find(49); - if(!$pt) - { + if(!$pt) { $type = new PaymentType(); $type->id = 49; $type->name = 'BACS'; @@ -27,8 +24,7 @@ return new class extends Migration { $gt = GatewayType::find(24); - if(!$gt) - { + if(!$gt) { $type = new GatewayType(); $type->id = 24; $type->alias = 'bacs'; diff --git a/database/migrations/2023_02_28_064453_update_designs.php b/database/migrations/2023_02_28_064453_update_designs.php index 6795de26613f..9b6265db822b 100644 --- a/database/migrations/2023_02_28_064453_update_designs.php +++ b/database/migrations/2023_02_28_064453_update_designs.php @@ -1,19 +1,16 @@ cursor()->each(function ($company){ + Company::query()->cursor()->each(function ($company) { $crfs = $company->client_registration_fields; if(!$crfs) { - $crfs = ClientRegistrationFields::generate(); + $crfs = ClientRegistrationFields::generate(); } - foreach($crfs as $key => $crf) - { + foreach($crfs as $key => $crf) { $crfs[$key]['visible'] = $crfs[$key]['required']; } diff --git a/database/migrations/2023_03_09_121033_add_payment_balance_to_clients_table.php b/database/migrations/2023_03_09_121033_add_payment_balance_to_clients_table.php index 9e7809629270..f12b578f24ae 100644 --- a/database/migrations/2023_03_09_121033_add_payment_balance_to_clients_table.php +++ b/database/migrations/2023_03_09_121033_add_payment_balance_to_clients_table.php @@ -1,12 +1,11 @@ settings; - if(!property_exists($settings, 'show_task_item_description')) + if(!property_exists($settings, 'show_task_item_description')) { $company->saveSettings((array)$company->settings, $company); + } }); diff --git a/database/migrations/2023_03_13_156872_add_e_invoice_type_to_clients_table.php b/database/migrations/2023_03_13_156872_add_e_invoice_type_to_clients_table.php index ad5129219784..641218492ace 100644 --- a/database/migrations/2023_03_13_156872_add_e_invoice_type_to_clients_table.php +++ b/database/migrations/2023_03_13_156872_add_e_invoice_type_to_clients_table.php @@ -1,11 +1,10 @@ boolean('tax_data'); }); - Schema::table('products', function (Blueprint $table){ + Schema::table('products', function (Blueprint $table) { $table->unsignedInteger('tax_id')->nullable(); // the product tax constant }); - Schema::table('clients', function (Blueprint $table){ + Schema::table('clients', function (Blueprint $table) { $table->boolean('tax_data'); }); - Schema::table('schedulers', function (Blueprint $table){ + Schema::table('schedulers', function (Blueprint $table) { $table->dropUnique('schedulers_company_id_name_unique'); }); diff --git a/database/migrations/2023_03_24_054758_add_client_is_exempt_from_taxes.php b/database/migrations/2023_03_24_054758_add_client_is_exempt_from_taxes.php index 63996ffd11e8..15b32e5567ba 100644 --- a/database/migrations/2023_03_24_054758_add_client_is_exempt_from_taxes.php +++ b/database/migrations/2023_03_24_054758_add_client_is_exempt_from_taxes.php @@ -1,19 +1,17 @@ unsignedInteger('current_hours')->nullable(); }); - Schema::table('bank_transactions', function(Illuminate\Database\Schema\Blueprint $table) { + Schema::table('bank_transactions', function (Illuminate\Database\Schema\Blueprint $table) { $table->text('expense_id')->default('')->change(); }); @@ -71,7 +69,7 @@ return new class extends Migration }); -//payment types from 34 + //payment types from 34 if(Ninja::isSelfHost()) { diff --git a/database/migrations/2023_04_20_215159_drop_e_invoice_type_column.php b/database/migrations/2023_04_20_215159_drop_e_invoice_type_column.php index ad2adcfd18ea..11c594a4583b 100644 --- a/database/migrations/2023_04_20_215159_drop_e_invoice_type_column.php +++ b/database/migrations/2023_04_20_215159_drop_e_invoice_type_column.php @@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class extends Migration -{ +return new class extends Migration { /** * Run the migrations. * diff --git a/database/migrations/2023_04_27_045639_add_kmher_language.php b/database/migrations/2023_04_27_045639_add_kmher_language.php index 69e7fb433cb3..1aec787e1ccc 100644 --- a/database/migrations/2023_04_27_045639_add_kmher_language.php +++ b/database/migrations/2023_04_27_045639_add_kmher_language.php @@ -1,14 +1,13 @@ 38, 'name' => 'Khmer', 'locale' => 'km_KH']); } - if (Schema::hasColumn('companies', 'enable_e_invoice')) - { + if (Schema::hasColumn('companies', 'enable_e_invoice')) { Schema::table('companies', function (Blueprint $table) { $table->dropColumn('enable_e_invoice'); }); } - Company::query()->cursor()->each(function ($company){ + Company::query()->cursor()->each(function ($company) { $company->tax_data = new TaxModel(); $company->save(); }); diff --git a/database/migrations/2023_05_03_023956_add_shopify_user_id.php b/database/migrations/2023_05_03_023956_add_shopify_user_id.php index 77ef774d233f..a66983baa243 100644 --- a/database/migrations/2023_05_03_023956_add_shopify_user_id.php +++ b/database/migrations/2023_05_03_023956_add_shopify_user_id.php @@ -1,12 +1,10 @@ unsignedBigInteger('shopify_user_id')->index()->nullable(); }); - Schema::table('companies', function(Illuminate\Database\Schema\Blueprint $table){ - $table->string('shopify_name')->index()->nullable(); - $table->string('shopify_access_token')->index()->nullable(); + Schema::table('companies', function (Illuminate\Database\Schema\Blueprint $table) { + $table->string('shopify_name')->index()->nullable(); + $table->string('shopify_access_token')->index()->nullable(); }); } diff --git a/database/migrations/2023_06_04_064713_project_and_task_columns_for_company_model.php b/database/migrations/2023_06_04_064713_project_and_task_columns_for_company_model.php index 4f98a9981b9b..dad3c6cf2e5c 100644 --- a/database/migrations/2023_06_04_064713_project_and_task_columns_for_company_model.php +++ b/database/migrations/2023_06_04_064713_project_and_task_columns_for_company_model.php @@ -1,11 +1,9 @@ clientId = ""; diff --git a/database/migrations/2023_07_06_063512_update_designs.php b/database/migrations/2023_07_06_063512_update_designs.php index d3e7318c64c1..4f887bc2056b 100644 --- a/database/migrations/2023_07_06_063512_update_designs.php +++ b/database/migrations/2023_07_06_063512_update_designs.php @@ -1,11 +1,8 @@ 40, 'name' => 'French - Swiss', 'locale' => 'fr_CH']); - } + if (! $language) { + Language::create(['id' => 40, 'name' => 'French - Swiss', 'locale' => 'fr_CH']); + } } diff --git a/database/migrations/2023_07_12_074829_add_thai_baht_currency_symbol.php b/database/migrations/2023_07_12_074829_add_thai_baht_currency_symbol.php index fe959e037436..3f8ed8e3d9c4 100644 --- a/database/migrations/2023_07_12_074829_add_thai_baht_currency_symbol.php +++ b/database/migrations/2023_07_12_074829_add_thai_baht_currency_symbol.php @@ -2,11 +2,8 @@ use App\Models\Currency; use Illuminate\Database\Migrations\Migration; -use Illuminate\Database\Schema\Blueprint; -use Illuminate\Support\Facades\Schema; -return new class extends Migration -{ +return new class extends Migration { /** * Run the migrations. * diff --git a/database/migrations/2023_07_18_214607_add_start_date_column_to_tasks.php b/database/migrations/2023_07_18_214607_add_start_date_column_to_tasks.php index 74b4a86ae689..8178b4d91540 100644 --- a/database/migrations/2023_07_18_214607_add_start_date_column_to_tasks.php +++ b/database/migrations/2023_07_18_214607_add_start_date_column_to_tasks.php @@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class extends Migration -{ +return new class extends Migration { /** * Run the migrations. * @@ -17,7 +16,7 @@ return new class extends Migration $table->date('calculated_start_date')->nullable(); }); - Schema::table('webhooks', function (Blueprint $table){ + Schema::table('webhooks', function (Blueprint $table) { $table->text('target_url')->change(); }); } diff --git a/database/migrations/2023_07_22_234329_change_currency_format_for_indonesian_rupiah.php b/database/migrations/2023_07_22_234329_change_currency_format_for_indonesian_rupiah.php index 20316a338f63..17ef6578d948 100644 --- a/database/migrations/2023_07_22_234329_change_currency_format_for_indonesian_rupiah.php +++ b/database/migrations/2023_07_22_234329_change_currency_format_for_indonesian_rupiah.php @@ -1,11 +1,8 @@ where('code', 'IDR')->first(); - if($ir){ + if($ir) { $ir->thousand_separator = '.'; $ir->decimal_separator = ','; $ir->save(); diff --git a/database/migrations/2023_08_06_070205_create_view_dashboard_permission_migration.php b/database/migrations/2023_08_06_070205_create_view_dashboard_permission_migration.php index 472f6b92c5f5..9bce8e97b71b 100644 --- a/database/migrations/2023_08_06_070205_create_view_dashboard_permission_migration.php +++ b/database/migrations/2023_08_06_070205_create_view_dashboard_permission_migration.php @@ -1,11 +1,8 @@ clientId = ""; diff --git a/database/migrations/2023_10_18_061415_add_user_notification_suppression.php b/database/migrations/2023_10_18_061415_add_user_notification_suppression.php index 4c01624a02ac..e46eea9f93b6 100644 --- a/database/migrations/2023_10_18_061415_add_user_notification_suppression.php +++ b/database/migrations/2023_10_18_061415_add_user_notification_suppression.php @@ -1,12 +1,11 @@ 'الشركة ', 'name' => 'الاسم', 'website' => 'الموقع الإلكتروني', @@ -5164,8 +5164,6 @@ $LANG = array( 'payment_receipt' => 'إيصال الدفع رقم :number', 'load_template_description' => 'سيتم تطبيق القالب على ما يلي:', 'run_template' => 'تشغيل القالب', -); +]; return $LANG; - -?> diff --git a/lang/bg/texts.php b/lang/bg/texts.php index 9d24d643a31f..661cceef6cbd 100644 --- a/lang/bg/texts.php +++ b/lang/bg/texts.php @@ -1,6 +1,6 @@ 'Организация', 'name' => 'Име', 'website' => 'Уебсайт', @@ -5168,8 +5168,6 @@ $LANG = array( 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/ca/texts.php b/lang/ca/texts.php index e553026fb5d8..d435f1212733 100644 --- a/lang/ca/texts.php +++ b/lang/ca/texts.php @@ -1,6 +1,6 @@ 'Organització', 'name' => 'Nom', 'website' => 'Lloc web', @@ -5167,8 +5167,6 @@ $LANG = array( 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/cs/texts.php b/lang/cs/texts.php index 7423ca953f9b..55ce3e77ec0e 100644 --- a/lang/cs/texts.php +++ b/lang/cs/texts.php @@ -1,6 +1,6 @@ 'Organizace', 'name' => 'Název', 'website' => 'Web', @@ -5189,8 +5189,6 @@ $LANG = array( 'payment_receipt' => 'Payment Receipt # :number', 'load_template_description' => 'The template will be applied to following:', 'run_template' => 'Run template', -); +]; return $LANG; - -?> diff --git a/lang/da/texts.php b/lang/da/texts.php index bd4322e7b186..be84ac59e75a 100644 --- a/lang/da/texts.php +++ b/lang/da/texts.php @@ -1,6 +1,6 @@ 'Organisation', 'name' => 'Navn', 'website' => 'Hjemmeside', @@ -5188,8 +5188,6 @@ $LANG = array( 'payment_receipt' => 'Betaling # :number', 'load_template_description' => 'Skabelonen vil blive anvendt på følgende:', 'run_template' => 'Kør skabelon', -); +]; return $LANG; - -?> diff --git a/lang/de/texts.php b/lang/de/texts.php index ce76b57d2167..72dd18a0e444 100644 --- a/lang/de/texts.php +++ b/lang/de/texts.php @@ -1,6 +1,6 @@ 'Unternehmen', 'name' => 'Name', 'website' => 'Webseite', @@ -5193,8 +5193,6 @@ Leistungsempfängers', 'payment_receipt' => 'Zahlungsbeleg #:number', 'load_template_description' => 'Das Template wird auf Folgendes angewendet:', 'run_template' => 'Template anwenden', -); +]; return $LANG; - -?> diff --git a/lang/el/texts.php b/lang/el/texts.php index f097a8f03974..18e8f6d5fc3f 100644 --- a/lang/el/texts.php +++ b/lang/el/texts.php @@ -1,6 +1,6 @@ 'Οργανισμός', 'name' => 'Επωνυμία', 'website' => 'Ιστοσελίδα', @@ -5167,8 +5167,6 @@ email που είναι συνδεδεμένη με το λογαριασμό σ 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/en/texts.php b/lang/en/texts.php index d1a4d812ad26..719df08a74c9 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -1,6 +1,6 @@ 'Organization', 'name' => 'Name', 'website' => 'Website', @@ -5217,8 +5217,6 @@ $LANG = array( 'vendor_notification_subject' => 'Confirmation of payment :amount sent to :vendor', 'vendor_notification_body' => 'Payment processed for :amount dated :payment_date.
[Transaction Reference: :transaction_reference]', -); +]; return $LANG; - -?> diff --git a/lang/en_GB/texts.php b/lang/en_GB/texts.php index c687b7b8d9cd..5827f8302a98 100644 --- a/lang/en_GB/texts.php +++ b/lang/en_GB/texts.php @@ -1,6 +1,6 @@ 'Organisation', 'name' => 'Name', 'website' => 'Website', @@ -5046,9 +5046,7 @@ $LANG = array( 'oauth_mail' => 'OAuth / Mail', 'preferences' => 'Preferences', 'analytics' => 'Analytics', -); +]; return $LANG; - -?> diff --git a/lang/es/texts.php b/lang/es/texts.php index 449457bc2997..6506bef29699 100644 --- a/lang/es/texts.php +++ b/lang/es/texts.php @@ -1,6 +1,6 @@ 'Empresa', 'name' => 'Nombre', 'website' => 'Sitio Web', @@ -5187,8 +5187,6 @@ $LANG = array( 'payment_receipt' => 'Recibo de pago # :number', 'load_template_description' => 'La plantilla se aplicará a lo siguiente:', 'run_template' => 'Ejecutar plantilla', -); +]; return $LANG; - -?> diff --git a/lang/es_ES/texts.php b/lang/es_ES/texts.php index 8b8904e3f243..87808e044b5f 100644 --- a/lang/es_ES/texts.php +++ b/lang/es_ES/texts.php @@ -1,6 +1,6 @@ 'Organización', 'name' => 'Nombre', 'website' => 'Página Web', @@ -5180,8 +5180,6 @@ De lo contrario, este campo deberá dejarse en blanco.', 'payment_receipt' => 'Recibo de pago Nº :number', 'load_template_description' => 'La plantilla se aplicará a lo siguiente:', 'run_template' => 'Ejecutar plantilla', -); +]; return $LANG; - -?> diff --git a/lang/et/texts.php b/lang/et/texts.php index 371e8532fa72..bcf86c7fc05d 100644 --- a/lang/et/texts.php +++ b/lang/et/texts.php @@ -1,6 +1,6 @@ 'Organisatsioon', 'name' => 'Nimi', 'website' => 'Kodulehekülg', @@ -5163,8 +5163,6 @@ $LANG = array( 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/fa/texts.php b/lang/fa/texts.php index 008aaa2ff484..84785d6a817d 100644 --- a/lang/fa/texts.php +++ b/lang/fa/texts.php @@ -1,6 +1,6 @@ 'شرکت', 'name' => 'نام', 'website' => 'وب سایت', @@ -5167,8 +5167,6 @@ $LANG = array( 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/fi/texts.php b/lang/fi/texts.php index eebbcafc8d18..f87a93252989 100644 --- a/lang/fi/texts.php +++ b/lang/fi/texts.php @@ -1,6 +1,6 @@ 'Yritys', 'name' => 'Nimi', 'website' => 'Kotisivu', @@ -5167,8 +5167,6 @@ Kun saat summat, palaa tälle maksutapasivulle ja klikkaa "Saata loppuun todenta 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/fr/texts.php b/lang/fr/texts.php index 01965074c9df..3a19a150c597 100644 --- a/lang/fr/texts.php +++ b/lang/fr/texts.php @@ -1,6 +1,6 @@ 'Entreprise', 'name' => 'Nom', 'website' => 'Site Web', @@ -5183,8 +5183,6 @@ Lorsque les montant apparaîtront sur votre relevé, veuillez revenir sur cette 'payment_receipt' => 'Reçu de paiement # :number', 'load_template_description' => 'Le modèle sera appliqué aux éléments suivants :', 'run_template' => 'Exécuter le modèle', -); +]; return $LANG; - -?> diff --git a/lang/fr_CA/texts.php b/lang/fr_CA/texts.php index 8730e383b55c..90e13dbd051d 100644 --- a/lang/fr_CA/texts.php +++ b/lang/fr_CA/texts.php @@ -1,6 +1,6 @@ 'Entreprise', 'name' => 'Nom', 'website' => 'Site web', @@ -5205,8 +5205,6 @@ Lorsque les montant apparaîtront sur votre relevé, veuillez revenir sur cette 'payment_email_all_contacts' => 'Courriel de paiement à tous les contacts', 'payment_email_all_contacts_help' => 'Envoi un courriel de paiement à tous les contacts lorsqu\'activé', 'add_line' => 'Ajouter une ligne', -); +]; return $LANG; - -?> diff --git a/lang/fr_CH/texts.php b/lang/fr_CH/texts.php index 94af38da6b9c..a14376496fba 100644 --- a/lang/fr_CH/texts.php +++ b/lang/fr_CH/texts.php @@ -1,6 +1,6 @@ 'Entreprise', 'name' => 'Nom', 'website' => 'Site web', @@ -5205,8 +5205,6 @@ Lorsque les montant apparaîtront sur votre relevé, veuillez revenir sur cette 'payment_email_all_contacts' => 'Email de paiement à tous les contacts', 'payment_email_all_contacts_help' => 'Sends the payment email to all contacts when enabled', 'add_line' => 'Ajouter une ligne', -); +]; return $LANG; - -?> diff --git a/lang/he/texts.php b/lang/he/texts.php index 2aedfb736b05..8c660affe496 100644 --- a/lang/he/texts.php +++ b/lang/he/texts.php @@ -1,6 +1,6 @@ 'ארגון ', 'name' => 'שם', 'website' => 'אתר אינטרנט', @@ -5159,8 +5159,6 @@ $LANG = array( 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/hr/texts.php b/lang/hr/texts.php index 58e7bd4507a8..a2aab7667c3a 100644 --- a/lang/hr/texts.php +++ b/lang/hr/texts.php @@ -1,6 +1,6 @@ 'Organizacija', 'name' => 'Ime', 'website' => 'Web', @@ -5168,8 +5168,6 @@ Nevažeći kontakt email', 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/hu/texts.php b/lang/hu/texts.php index 7dfe109d544e..086cc9cd5b39 100644 --- a/lang/hu/texts.php +++ b/lang/hu/texts.php @@ -1,6 +1,6 @@ 'Szervezet', 'name' => 'Név', 'website' => 'Weboldal', @@ -5145,8 +5145,6 @@ adva :date', 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/it/texts.php b/lang/it/texts.php index fea917dd03c5..7029eeec60e2 100644 --- a/lang/it/texts.php +++ b/lang/it/texts.php @@ -1,6 +1,6 @@ 'Organizzazione', 'name' => 'Nome', 'website' => 'Sito web', @@ -5174,8 +5174,6 @@ $LANG = array( 'payment_receipt' => 'Payment Receipt # :number', 'load_template_description' => 'The template will be applied to following:', 'run_template' => 'Run template', -); +]; return $LANG; - -?> diff --git a/lang/ja/texts.php b/lang/ja/texts.php index 9ba5d559b854..c470d1c749cb 100644 --- a/lang/ja/texts.php +++ b/lang/ja/texts.php @@ -1,6 +1,6 @@ '組織', 'name' => '名前', 'website' => 'WEBサイト', @@ -5167,8 +5167,6 @@ $LANG = array( 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/km_KH/texts.php b/lang/km_KH/texts.php index c7e7486a8448..5e36bea255a6 100644 --- a/lang/km_KH/texts.php +++ b/lang/km_KH/texts.php @@ -1,6 +1,6 @@ 'អង្គការ', 'name' => 'ឈ្មោះ', 'website' => 'គេហទំព័រ', @@ -5141,8 +5141,6 @@ $LANG = array( 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/lt/texts.php b/lang/lt/texts.php index 7ae78811daaa..f19f128bf6ce 100644 --- a/lang/lt/texts.php +++ b/lang/lt/texts.php @@ -1,6 +1,6 @@ 'Įmonė', 'name' => 'Pavadinimas', 'website' => 'Internetinis puslapis', @@ -5158,8 +5158,6 @@ $LANG = array( 'unlinked_transaction' => 'Successfully unlinked transaction', 'view_dashboard_permission' => 'Allow user to access the dashboard, data is limited to available permissions', 'marked_sent_credits' => 'Successfully marked credits sent', -); +]; return $LANG; - -?> diff --git a/lang/lv_LV/texts.php b/lang/lv_LV/texts.php index a64686d823af..0783afaf3c69 100644 --- a/lang/lv_LV/texts.php +++ b/lang/lv_LV/texts.php @@ -1,6 +1,6 @@ 'Uzņēmums', 'name' => 'Nosaukums', 'website' => 'Mājas lapa', @@ -5167,8 +5167,6 @@ $LANG = array( 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/mk_MK/texts.php b/lang/mk_MK/texts.php index 50e294aef385..860a5a22224d 100644 --- a/lang/mk_MK/texts.php +++ b/lang/mk_MK/texts.php @@ -1,6 +1,6 @@ 'Организација', 'name' => 'Име', 'website' => 'Веб Страна', @@ -5168,8 +5168,6 @@ $LANG = array( 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/nb_NO/texts.php b/lang/nb_NO/texts.php index 5084463028ad..5760c702ea98 100644 --- a/lang/nb_NO/texts.php +++ b/lang/nb_NO/texts.php @@ -1,6 +1,6 @@ 'Organisasjon', 'name' => 'Navn', 'website' => 'Nettside', @@ -5158,8 +5158,6 @@ $LANG = array( 'unlinked_transaction' => 'Successfully unlinked transaction', 'view_dashboard_permission' => 'Allow user to access the dashboard, data is limited to available permissions', 'marked_sent_credits' => 'Successfully marked credits sent', -); +]; return $LANG; - -?> diff --git a/lang/nl/texts.php b/lang/nl/texts.php index bbfb547bcca9..4142baba94fb 100644 --- a/lang/nl/texts.php +++ b/lang/nl/texts.php @@ -1,6 +1,6 @@ 'Organisatie', 'name' => 'Bedrijfsnaam', 'website' => 'Website', @@ -5161,8 +5161,6 @@ Email: :email
', 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/pl/texts.php b/lang/pl/texts.php index 151e4aec37ba..5624afc5a1dd 100644 --- a/lang/pl/texts.php +++ b/lang/pl/texts.php @@ -1,6 +1,6 @@ 'Organizacja', 'name' => 'Nazwa', 'website' => 'Strona internetowa', @@ -5165,8 +5165,6 @@ Gdy przelewy zostaną zaksięgowane na Twoim koncie, wróć do tej strony i klik 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/pt_BR/texts.php b/lang/pt_BR/texts.php index 5979a00f3e58..cdb7dcda443c 100644 --- a/lang/pt_BR/texts.php +++ b/lang/pt_BR/texts.php @@ -1,6 +1,6 @@ 'Empresa', 'name' => 'Nome', 'website' => 'Website', @@ -5161,8 +5161,6 @@ Quando tiver as quantias, volte a esta página de formas de pagamento e clique " 'in_stock_quantity' => 'Quantidade em estoque', 'vendor_contact' => 'Contato do fornecedor', -); +]; return $LANG; - -?> diff --git a/lang/pt_PT/texts.php b/lang/pt_PT/texts.php index ce21112cfb52..3e6a454d5a01 100644 --- a/lang/pt_PT/texts.php +++ b/lang/pt_PT/texts.php @@ -1,6 +1,6 @@ 'Organização', 'name' => 'Nome', 'website' => 'Site', @@ -5164,8 +5164,6 @@ O envio de E-mails foi suspenso. Será retomado às 23:00 UTC.', 'in_stock_quantity' => 'Quantidade em estoque', 'vendor_contact' => 'Contato do fornecedor', -); +]; return $LANG; - -?> diff --git a/lang/ro/texts.php b/lang/ro/texts.php index 36d63911627b..805227e6ebb5 100644 --- a/lang/ro/texts.php +++ b/lang/ro/texts.php @@ -1,6 +1,6 @@ 'Organizație', 'name' => 'Nume', 'website' => 'Site web', @@ -5168,8 +5168,6 @@ Odată ce sumele au ajuns la dumneavoastră, reveniți la pagina cu metode de pl 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/ru_RU/texts.php b/lang/ru_RU/texts.php index 83acddde5bd5..ebc38f5b8bbc 100644 --- a/lang/ru_RU/texts.php +++ b/lang/ru_RU/texts.php @@ -1,6 +1,6 @@ 'Организация', 'name' => 'Название', 'website' => 'Веб-сайт', @@ -5159,8 +5159,6 @@ $LANG = array( 'unlinked_transaction' => 'Successfully unlinked transaction', 'view_dashboard_permission' => 'Allow user to access the dashboard, data is limited to available permissions', 'marked_sent_credits' => 'Successfully marked credits sent', -); +]; return $LANG; - -?> diff --git a/lang/sk/texts.php b/lang/sk/texts.php index 4badfa9b3700..9ed740b9bd38 100644 --- a/lang/sk/texts.php +++ b/lang/sk/texts.php @@ -1,6 +1,6 @@ 'Organizácia', 'name' => 'Meno', 'website' => 'Web', @@ -5151,8 +5151,6 @@ Nemôžete nájsť faktúru? Potrebujete poradiť? Radi Vám pomôžeme 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/sl/texts.php b/lang/sl/texts.php index de7bfb8bb0e6..c5678f3c429c 100644 --- a/lang/sl/texts.php +++ b/lang/sl/texts.php @@ -1,6 +1,6 @@ 'Organizacija', 'name' => 'Ime', 'website' => 'Spletna stran', @@ -5167,8 +5167,6 @@ Ko imate zneske, se vrnite na to stran plačilnega sredstva in kliknite na "Comp 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/sq/texts.php b/lang/sq/texts.php index 0909eb662240..2ede1bf28784 100644 --- a/lang/sq/texts.php +++ b/lang/sq/texts.php @@ -1,6 +1,6 @@ 'Organizata', 'name' => 'Emri', 'website' => 'Website', @@ -5165,8 +5165,6 @@ Pasi të keni pranuar shumat, kthehuni në faqen e metodave të pagesës dhe kli 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/sr/texts.php b/lang/sr/texts.php index dc4b91cfcb97..0539598d2796 100644 --- a/lang/sr/texts.php +++ b/lang/sr/texts.php @@ -1,6 +1,6 @@ 'Organizacija', 'name' => 'Ime', 'website' => 'Sajt', @@ -5167,8 +5167,6 @@ Kada budete imali iznose, vratite se na ovu stranicu sa načinima plaćanja i k 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/sv/texts.php b/lang/sv/texts.php index 866d01bb12ea..c354db0b9ecd 100644 --- a/lang/sv/texts.php +++ b/lang/sv/texts.php @@ -1,6 +1,6 @@ 'Organisation', 'name' => 'Namn', 'website' => 'Hemsida', @@ -5174,8 +5174,6 @@ Den här funktionen kräver att en produkt skapas och en betalningsgateway är k 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/th/texts.php b/lang/th/texts.php index ab4a464d3d17..58b2ae0813c4 100644 --- a/lang/th/texts.php +++ b/lang/th/texts.php @@ -1,6 +1,6 @@ 'องค์กร', 'name' => 'ชื่อ', 'website' => 'เว็บไซต์', @@ -5168,8 +5168,6 @@ $LANG = array( 'in_stock_quantity' => 'Stock quantity', 'vendor_contact' => 'Vendor Contact', -); +]; return $LANG; - -?> diff --git a/lang/tr_TR/texts.php b/lang/tr_TR/texts.php index 2a5bccd99801..a729ea0e6333 100644 --- a/lang/tr_TR/texts.php +++ b/lang/tr_TR/texts.php @@ -1,6 +1,6 @@ 'Şirket', 'name' => 'Ünvan', 'website' => 'Web adresi', @@ -5157,8 +5157,6 @@ adresine gönderildi. Müthiş tüm özelliklerin kilidini açmak için lütfen 'unlinked_transaction' => 'Successfully unlinked transaction', 'view_dashboard_permission' => 'Allow user to access the dashboard, data is limited to available permissions', 'marked_sent_credits' => 'Successfully marked credits sent', -); +]; return $LANG; - -?> diff --git a/lang/zh_TW/texts.php b/lang/zh_TW/texts.php index 73ab17b7262f..01ca845c6a23 100644 --- a/lang/zh_TW/texts.php +++ b/lang/zh_TW/texts.php @@ -1,6 +1,6 @@ '組織', 'name' => '姓名', 'website' => '網站', @@ -5186,8 +5186,6 @@ $LANG = array( 'payment_receipt' => '付款收據 # :number', 'load_template_description' => '此模板將應用於以下領域:', 'run_template' => '運行模板', -); +]; return $LANG; - -?> diff --git a/routes/api.php b/routes/api.php index e9a685cbf870..4d648054e298 100644 --- a/routes/api.php +++ b/routes/api.php @@ -10,110 +10,110 @@ | is assigned the "api" middleware group. Enjoy building your API! | */ -use Illuminate\Support\Facades\Route; -use App\Http\Controllers\BaseController; -use App\Http\Controllers\PingController; -use App\Http\Controllers\TaskController; -use App\Http\Controllers\UserController; -use App\Http\Controllers\ChartController; -use App\Http\Controllers\EmailController; -use App\Http\Controllers\QuoteController; -use App\Http\Controllers\TokenController; -use App\Http\Controllers\ClientController; -use App\Http\Controllers\CreditController; -use App\Http\Controllers\DesignController; -use App\Http\Controllers\ExportController; -use App\Http\Controllers\FilterController; -use App\Http\Controllers\ImportController; -use App\Http\Controllers\LogoutController; -use App\Http\Controllers\SearchController; -use App\Http\Controllers\StaticController; -use App\Http\Controllers\StripeController; -use App\Http\Controllers\TwilioController; -use App\Http\Controllers\VendorController; use App\Http\Controllers\AccountController; -use App\Http\Controllers\CompanyController; -use App\Http\Controllers\ExpenseController; -use App\Http\Controllers\InvoiceController; -use App\Http\Controllers\LicenseController; -use App\Http\Controllers\PaymentController; -use App\Http\Controllers\PreviewController; -use App\Http\Controllers\ProductController; -use App\Http\Controllers\ProjectController; -use App\Http\Controllers\TaxRateController; -use App\Http\Controllers\WebCronController; -use App\Http\Controllers\WebhookController; use App\Http\Controllers\ActivityController; -use App\Http\Controllers\DocumentController; -use App\Http\Controllers\PostMarkController; -use App\Http\Controllers\TemplateController; -use App\Http\Controllers\MigrationController; -use App\Http\Controllers\SchedulerController; -use App\Http\Controllers\SubdomainController; -use App\Http\Controllers\SystemLogController; -use App\Http\Controllers\TwoFactorController; +use App\Http\Controllers\Auth\ForgotPasswordController; use App\Http\Controllers\Auth\LoginController; -use App\Http\Controllers\ImportJsonController; -use App\Http\Controllers\SelfUpdateController; -use App\Http\Controllers\TaskStatusController; +use App\Http\Controllers\Auth\PasswordTimeoutController; use App\Http\Controllers\Bank\YodleeController; -use App\Http\Controllers\CompanyUserController; -use App\Http\Controllers\PaymentTermController; -use App\Http\Controllers\EmailHistoryController; -use App\Http\Controllers\GroupSettingController; -use App\Http\Controllers\OneTimeTokenController; -use App\Http\Controllers\SubscriptionController; -use App\Http\Controllers\CompanyLedgerController; -use App\Http\Controllers\PurchaseOrderController; -use App\Http\Controllers\TaskSchedulerController; -use App\Http\Controllers\CompanyGatewayController; -use App\Http\Controllers\PaymentWebhookController; -use App\Http\Controllers\RecurringQuoteController; use App\Http\Controllers\BankIntegrationController; use App\Http\Controllers\BankTransactionController; +use App\Http\Controllers\BankTransactionRuleController; +use App\Http\Controllers\BaseController; +use App\Http\Controllers\ChartController; +use App\Http\Controllers\ClientController; +use App\Http\Controllers\ClientGatewayTokenController; use App\Http\Controllers\ClientStatementController; -use App\Http\Controllers\ExpenseCategoryController; -use App\Http\Controllers\HostedMigrationController; -use App\Http\Controllers\TemplatePreviewController; +use App\Http\Controllers\CompanyController; +use App\Http\Controllers\CompanyGatewayController; +use App\Http\Controllers\CompanyLedgerController; +use App\Http\Controllers\CompanyUserController; use App\Http\Controllers\ConnectedAccountController; +use App\Http\Controllers\CreditController; +use App\Http\Controllers\DesignController; +use App\Http\Controllers\DocumentController; +use App\Http\Controllers\EmailController; +use App\Http\Controllers\EmailHistoryController; +use App\Http\Controllers\ExpenseCategoryController; +use App\Http\Controllers\ExpenseController; +use App\Http\Controllers\ExportController; +use App\Http\Controllers\FilterController; +use App\Http\Controllers\GroupSettingController; +use App\Http\Controllers\HostedMigrationController; +use App\Http\Controllers\ImportController; +use App\Http\Controllers\ImportJsonController; +use App\Http\Controllers\InAppPurchase\AppleController; +use App\Http\Controllers\InvoiceController; +use App\Http\Controllers\LicenseController; +use App\Http\Controllers\LogoutController; +use App\Http\Controllers\MigrationController; +use App\Http\Controllers\OneTimeTokenController; +use App\Http\Controllers\PaymentController; +use App\Http\Controllers\PaymentNotificationWebhookController; +use App\Http\Controllers\PaymentTermController; +use App\Http\Controllers\PaymentWebhookController; +use App\Http\Controllers\PingController; +use App\Http\Controllers\PostMarkController; +use App\Http\Controllers\PreviewController; +use App\Http\Controllers\PreviewPurchaseOrderController; +use App\Http\Controllers\ProductController; +use App\Http\Controllers\ProjectController; +use App\Http\Controllers\ProtectedDownloadController; +use App\Http\Controllers\PurchaseOrderController; +use App\Http\Controllers\QuoteController; use App\Http\Controllers\RecurringExpenseController; use App\Http\Controllers\RecurringInvoiceController; -use App\Http\Controllers\ProtectedDownloadController; -use App\Http\Controllers\ClientGatewayTokenController; -use App\Http\Controllers\Reports\TaskReportController; -use App\Http\Controllers\Auth\ForgotPasswordController; -use App\Http\Controllers\BankTransactionRuleController; -use App\Http\Controllers\InAppPurchase\AppleController; -use App\Http\Controllers\Reports\QuoteReportController; -use App\Http\Controllers\Auth\PasswordTimeoutController; -use App\Http\Controllers\PreviewPurchaseOrderController; +use App\Http\Controllers\RecurringQuoteController; +use App\Http\Controllers\Reports\ActivityReportController; +use App\Http\Controllers\Reports\ARDetailReportController; +use App\Http\Controllers\Reports\ARSummaryReportController; +use App\Http\Controllers\Reports\ClientBalanceReportController; +use App\Http\Controllers\Reports\ClientContactReportController; use App\Http\Controllers\Reports\ClientReportController; +use App\Http\Controllers\Reports\ClientSalesReportController; use App\Http\Controllers\Reports\CreditReportController; -use App\Http\Controllers\Reports\ReportExportController; -use App\Http\Controllers\Reports\VendorReportController; +use App\Http\Controllers\Reports\DocumentReportController; use App\Http\Controllers\Reports\ExpenseReportController; +use App\Http\Controllers\Reports\InvoiceItemReportController; use App\Http\Controllers\Reports\InvoiceReportController; use App\Http\Controllers\Reports\PaymentReportController; use App\Http\Controllers\Reports\ProductReportController; -use App\Http\Controllers\Reports\ProfitAndLossController; -use App\Http\Controllers\Reports\ReportPreviewController; -use App\Http\Controllers\Reports\ActivityReportController; -use App\Http\Controllers\Reports\ARDetailReportController; -use App\Http\Controllers\Reports\DocumentReportController; -use App\Http\Controllers\Reports\ARSummaryReportController; -use App\Http\Controllers\Reports\QuoteItemReportController; -use App\Http\Controllers\Reports\UserSalesReportController; -use App\Http\Controllers\Reports\TaxSummaryReportController; -use App\Http\Controllers\Support\Messages\SendingController; -use App\Http\Controllers\Reports\ClientSalesReportController; -use App\Http\Controllers\Reports\InvoiceItemReportController; -use App\Http\Controllers\PaymentNotificationWebhookController; use App\Http\Controllers\Reports\ProductSalesReportController; -use App\Http\Controllers\Reports\ClientBalanceReportController; -use App\Http\Controllers\Reports\ClientContactReportController; -use App\Http\Controllers\Reports\PurchaseOrderReportController; -use App\Http\Controllers\Reports\RecurringInvoiceReportController; +use App\Http\Controllers\Reports\ProfitAndLossController; use App\Http\Controllers\Reports\PurchaseOrderItemReportController; +use App\Http\Controllers\Reports\PurchaseOrderReportController; +use App\Http\Controllers\Reports\QuoteItemReportController; +use App\Http\Controllers\Reports\QuoteReportController; +use App\Http\Controllers\Reports\RecurringInvoiceReportController; +use App\Http\Controllers\Reports\ReportExportController; +use App\Http\Controllers\Reports\ReportPreviewController; +use App\Http\Controllers\Reports\TaskReportController; +use App\Http\Controllers\Reports\TaxSummaryReportController; +use App\Http\Controllers\Reports\UserSalesReportController; +use App\Http\Controllers\Reports\VendorReportController; +use App\Http\Controllers\SchedulerController; +use App\Http\Controllers\SearchController; +use App\Http\Controllers\SelfUpdateController; +use App\Http\Controllers\StaticController; +use App\Http\Controllers\StripeController; +use App\Http\Controllers\SubdomainController; +use App\Http\Controllers\SubscriptionController; +use App\Http\Controllers\Support\Messages\SendingController; +use App\Http\Controllers\SystemLogController; +use App\Http\Controllers\TaskController; +use App\Http\Controllers\TaskSchedulerController; +use App\Http\Controllers\TaskStatusController; +use App\Http\Controllers\TaxRateController; +use App\Http\Controllers\TemplateController; +use App\Http\Controllers\TemplatePreviewController; +use App\Http\Controllers\TokenController; +use App\Http\Controllers\TwilioController; +use App\Http\Controllers\TwoFactorController; +use App\Http\Controllers\UserController; +use App\Http\Controllers\VendorController; +use App\Http\Controllers\WebCronController; +use App\Http\Controllers\WebhookController; +use Illuminate\Support\Facades\Route; Route::group(['middleware' => ['throttle:api', 'api_secret_check']], function () { Route::post('api/v1/signup', [AccountController::class, 'store'])->name('signup.submit'); @@ -427,4 +427,4 @@ Route::post('api/v1/yodlee/balance', [YodleeController::class, 'balanceWebhook'] Route::get('api/v1/protected_download/{hash}', [ProtectedDownloadController::class, 'index'])->name('protected_download')->middleware('throttle:300,1'); -Route::fallback([BaseController::class, 'notFound'])->middleware('throttle:404'); \ No newline at end of file +Route::fallback([BaseController::class, 'notFound'])->middleware('throttle:404'); diff --git a/routes/client.php b/routes/client.php index 61c0aeb7e6c7..3d8e154912bd 100644 --- a/routes/client.php +++ b/routes/client.php @@ -1,22 +1,21 @@ name('client.catchall')->middleware(['domain_db', 'contact_account','locale', 'throttle:portal']); //catch all diff --git a/routes/console.php b/routes/console.php index 41e4c31bb126..b92aafff798d 100644 --- a/routes/console.php +++ b/routes/console.php @@ -1,6 +1,5 @@ create([ - 'company_id' => $this->company->id, - 'user_id' => $this->user->id, - 'matches_on_all' => false, - 'auto_convert' => true, - 'applies_to' => 'DEBIT', - 'client_id' => $this->client->id, - 'vendor_id' => $this->vendor->id, - 'rules' => [ - [ - 'search_key' => 'description', - 'operator' => 'contains', - 'value' => 'asdddfd', - ] - ] - ]); + public function testMatchingBankTransactionExpenseContainsMiss() + { + $br = BankTransactionRule::factory()->create([ + 'company_id' => $this->company->id, + 'user_id' => $this->user->id, + 'matches_on_all' => false, + 'auto_convert' => true, + 'applies_to' => 'DEBIT', + 'client_id' => $this->client->id, + 'vendor_id' => $this->vendor->id, + 'rules' => [ + [ + 'search_key' => 'description', + 'operator' => 'contains', + 'value' => 'asdddfd', + ] + ] + ]); - $bi = BankIntegration::factory()->create([ - 'company_id' => $this->company->id, - 'user_id' => $this->user->id, - 'account_id' => $this->account->id, - ]); + $bi = BankIntegration::factory()->create([ + 'company_id' => $this->company->id, + 'user_id' => $this->user->id, + 'account_id' => $this->account->id, + ]); - $bt = BankTransaction::factory()->create([ - 'bank_integration_id' => $bi->id, - 'company_id' => $this->company->id, - 'user_id' => $this->user->id, - 'description' => 'Something asd bizarre', - 'base_type' => 'DEBIT', - 'amount' => 100 - ]); + $bt = BankTransaction::factory()->create([ + 'bank_integration_id' => $bi->id, + 'company_id' => $this->company->id, + 'user_id' => $this->user->id, + 'description' => 'Something asd bizarre', + 'base_type' => 'DEBIT', + 'amount' => 100 + ]); - $bt->service()->processRules(); + $bt->service()->processRules(); - $bt = $bt->fresh(); + $bt = $bt->fresh(); - $this->assertEmpty($bt->expense_id); - } + $this->assertEmpty($bt->expense_id); + } public function testMatchingBankTransactionExpenseContains() diff --git a/tests/Feature/Bank/BankTransactionTest.php b/tests/Feature/Bank/BankTransactionTest.php index e6aff6d22c82..93176928f4df 100644 --- a/tests/Feature/Bank/BankTransactionTest.php +++ b/tests/Feature/Bank/BankTransactionTest.php @@ -12,16 +12,16 @@ namespace Tests\Feature\Bank; -use Tests\TestCase; -use App\Models\Expense; -use App\Models\Invoice; -use Tests\MockAccountData; -use App\Factory\InvoiceFactory; -use App\Models\BankTransaction; -use App\Factory\InvoiceItemFactory; use App\Factory\BankIntegrationFactory; use App\Factory\BankTransactionFactory; +use App\Factory\InvoiceFactory; +use App\Factory\InvoiceItemFactory; +use App\Models\BankTransaction; +use App\Models\Expense; +use App\Models\Invoice; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Tests\MockAccountData; +use Tests\TestCase; class BankTransactionTest extends TestCase { diff --git a/tests/Feature/Bank/YodleeApiTest.php b/tests/Feature/Bank/YodleeApiTest.php index 2cbd504c48bc..1abf733603ec 100644 --- a/tests/Feature/Bank/YodleeApiTest.php +++ b/tests/Feature/Bank/YodleeApiTest.php @@ -156,58 +156,58 @@ class YodleeApiTest extends TestCase $this->assertEquals('Automotive Expenses', $x->highLevelCategoryName); } -// public function testFunctionalMatching() -// { + // public function testFunctionalMatching() + // { -// $yodlee = new Yodlee('sbMem62e1e69547bfb1'); + // $yodlee = new Yodlee('sbMem62e1e69547bfb1'); -// $accounts = $yodlee->getAccounts(); + // $accounts = $yodlee->getAccounts(); -// foreach($accounts as $account) -// { + // foreach($accounts as $account) + // { -// if(!BankIntegration::where('bank_account_id', $account['id'])->where('company_id', $this->company->id)->exists()) -// { -// $bank_integration = new BankIntegration(); -// $bank_integration->company_id = $this->company->id; -// $bank_integration->account_id = $this->company->account_id; -// $bank_integration->user_id = $this->user->id; -// $bank_integration->bank_account_id = $account['id']; -// $bank_integration->bank_account_type = $account['account_type']; -// $bank_integration->bank_account_name = $account['account_name']; -// $bank_integration->bank_account_status = $account['account_status']; -// $bank_integration->bank_account_number = $account['account_number']; -// $bank_integration->provider_id = $account['provider_id']; -// $bank_integration->provider_name = $account['provider_name']; -// $bank_integration->nickname = $account['nickname']; -// $bank_integration->balance = $account['current_balance']; -// $bank_integration->currency = $account['account_currency']; - -// $bank_integration->save(); + // if(!BankIntegration::where('bank_account_id', $account['id'])->where('company_id', $this->company->id)->exists()) + // { + // $bank_integration = new BankIntegration(); + // $bank_integration->company_id = $this->company->id; + // $bank_integration->account_id = $this->company->account_id; + // $bank_integration->user_id = $this->user->id; + // $bank_integration->bank_account_id = $account['id']; + // $bank_integration->bank_account_type = $account['account_type']; + // $bank_integration->bank_account_name = $account['account_name']; + // $bank_integration->bank_account_status = $account['account_status']; + // $bank_integration->bank_account_number = $account['account_number']; + // $bank_integration->provider_id = $account['provider_id']; + // $bank_integration->provider_name = $account['provider_name']; + // $bank_integration->nickname = $account['nickname']; + // $bank_integration->balance = $account['current_balance']; + // $bank_integration->currency = $account['account_currency']; + + // $bank_integration->save(); -// ProcessBankTransactions::dispatchSync('sbMem62e1e69547bfb1', $bank_integration); + // ProcessBankTransactions::dispatchSync('sbMem62e1e69547bfb1', $bank_integration); -// } -// } + // } + // } -// $this->assertGreaterThan(0, BankIntegration::count()); -// $this->assertGreaterThan(0, BankTransaction::count()); + // $this->assertGreaterThan(0, BankIntegration::count()); + // $this->assertGreaterThan(0, BankTransaction::count()); -// $this->invoice->company_id = $this->company->id; -// $this->invoice->number = "XXXXXX8501"; -// $this->invoice->save(); + // $this->invoice->company_id = $this->company->id; + // $this->invoice->number = "XXXXXX8501"; + // $this->invoice->save(); -// BankService::dispatchSync($this->company->id, $this->company->db); - -// $bt = BankTransaction::where('invoice_ids', $this->invoice->hashed_id)->first(); + // BankService::dispatchSync($this->company->id, $this->company->db); + + // $bt = BankTransaction::where('invoice_ids', $this->invoice->hashed_id)->first(); -// nlog(BankTransaction::where('company_id', $this->company->id)->pluck('invoice_ids')); + // nlog(BankTransaction::where('company_id', $this->company->id)->pluck('invoice_ids')); -// $this->assertNotNull($bt); + // $this->assertNotNull($bt); -// $this->assertEquals(BankTransaction::STATUS_MATCHED, $bt->status_id); + // $this->assertEquals(BankTransaction::STATUS_MATCHED, $bt->status_id); -// } + // } public function testDataMatching() @@ -275,179 +275,179 @@ class YodleeApiTest extends TestCase $this->assertNotNull($access_token); } -/** + /** - [transactionCategory] => Array - ( - [0] => stdClass Object - ( - [id] => 1 - [source] => SYSTEM - [classification] => PERSONAL - [category] => Uncategorized - [type] => UNCATEGORIZE - [highLevelCategoryId] => 10000017 - [highLevelCategoryName] => Uncategorized - [defaultCategoryName] => Uncategorized - [defaultHighLevelCategoryName] => Uncategorized - ) + [transactionCategory] => Array + ( + [0] => stdClass Object + ( + [id] => 1 + [source] => SYSTEM + [classification] => PERSONAL + [category] => Uncategorized + [type] => UNCATEGORIZE + [highLevelCategoryId] => 10000017 + [highLevelCategoryName] => Uncategorized + [defaultCategoryName] => Uncategorized + [defaultHighLevelCategoryName] => Uncategorized + ) - [1] => stdClass Object - ( - [id] => 2 - [source] => SYSTEM - [classification] => PERSONAL - [category] => Automotive/Fuel - [type] => EXPENSE - [detailCategory] => Array - ( - [0] => stdClass Object - ( - [id] => 1041 - [name] => Registration/Licensing - ) + [1] => stdClass Object + ( + [id] => 2 + [source] => SYSTEM + [classification] => PERSONAL + [category] => Automotive/Fuel + [type] => EXPENSE + [detailCategory] => Array + ( + [0] => stdClass Object + ( + [id] => 1041 + [name] => Registration/Licensing + ) - [1] => stdClass Object - ( - [id] => 1145 - [name] => Automotive - ) + [1] => stdClass Object + ( + [id] => 1145 + [name] => Automotive + ) - [2] => stdClass Object - ( - [id] => 1218 - [name] => Auto Fees/Penalties - ) + [2] => stdClass Object + ( + [id] => 1218 + [name] => Auto Fees/Penalties + ) - [3] => stdClass Object - ( - [id] => 1260 - [name] => Car Appraisers - ) + [3] => stdClass Object + ( + [id] => 1260 + [name] => Car Appraisers + ) - [4] => stdClass Object - ( - [id] => 1261 - [name] => Car Dealers - ) + [4] => stdClass Object + ( + [id] => 1261 + [name] => Car Dealers + ) - [5] => stdClass Object - ( - [id] => 1262 - [name] => Car Dealers and Leasing - ) + [5] => stdClass Object + ( + [id] => 1262 + [name] => Car Dealers and Leasing + ) - [6] => stdClass Object - ( - [id] => 1263 - [name] => Car Parts and Accessories - ) + [6] => stdClass Object + ( + [id] => 1263 + [name] => Car Parts and Accessories + ) - [7] => stdClass Object - ( - [id] => 1264 - [name] => Car Wash and Detail - ) + [7] => stdClass Object + ( + [id] => 1264 + [name] => Car Wash and Detail + ) - [8] => stdClass Object - ( - [id] => 1265 - [name] => Classic and Antique Car - ) + [8] => stdClass Object + ( + [id] => 1265 + [name] => Classic and Antique Car + ) - [9] => stdClass Object - ( - [id] => 1267 - [name] => Maintenance and Repair - ) + [9] => stdClass Object + ( + [id] => 1267 + [name] => Maintenance and Repair + ) - [10] => stdClass Object - ( - [id] => 1268 - [name] => Motorcycles/Mopeds/Scooters - ) + [10] => stdClass Object + ( + [id] => 1268 + [name] => Motorcycles/Mopeds/Scooters + ) - [11] => stdClass Object - ( - [id] => 1269 - [name] => Oil and Lube - ) + [11] => stdClass Object + ( + [id] => 1269 + [name] => Oil and Lube + ) - [12] => stdClass Object - ( - [id] => 1270 - [name] => Motorcycle Repair - ) + [12] => stdClass Object + ( + [id] => 1270 + [name] => Motorcycle Repair + ) - [13] => stdClass Object - ( - [id] => 1271 - [name] => RVs and Motor Homes - ) + [13] => stdClass Object + ( + [id] => 1271 + [name] => RVs and Motor Homes + ) - [14] => stdClass Object - ( - [id] => 1272 - [name] => Motorcycle Sales - ) + [14] => stdClass Object + ( + [id] => 1272 + [name] => Motorcycle Sales + ) - [15] => stdClass Object - ( - [id] => 1273 - [name] => Salvage Yards - ) + [15] => stdClass Object + ( + [id] => 1273 + [name] => Salvage Yards + ) - [16] => stdClass Object - ( - [id] => 1274 - [name] => Smog Check - ) + [16] => stdClass Object + ( + [id] => 1274 + [name] => Smog Check + ) - [17] => stdClass Object - ( - [id] => 1275 - [name] => Tires - ) + [17] => stdClass Object + ( + [id] => 1275 + [name] => Tires + ) - [18] => stdClass Object - ( - [id] => 1276 - [name] => Towing - ) + [18] => stdClass Object + ( + [id] => 1276 + [name] => Towing + ) - [19] => stdClass Object - ( - [id] => 1277 - [name] => Transmissions - ) + [19] => stdClass Object + ( + [id] => 1277 + [name] => Transmissions + ) - [20] => stdClass Object - ( - [id] => 1278 - [name] => Used Cars - ) + [20] => stdClass Object + ( + [id] => 1278 + [name] => Used Cars + ) - [21] => stdClass Object - ( - [id] => 1240 - [name] => e-Charging - ) + [21] => stdClass Object + ( + [id] => 1240 + [name] => e-Charging + ) - [22] => stdClass Object - ( - [id] => 1266 - [name] => Gas Stations - ) + [22] => stdClass Object + ( + [id] => 1266 + [name] => Gas Stations + ) - ) + ) - [highLevelCategoryId] => 10000003 - [highLevelCategoryName] => Automotive Expenses - [defaultCategoryName] => Automotive Expenses - [defaultHighLevelCategoryName] => Automotive Expenses - ) + [highLevelCategoryId] => 10000003 + [highLevelCategoryName] => Automotive Expenses + [defaultCategoryName] => Automotive Expenses + [defaultHighLevelCategoryName] => Automotive Expenses + ) -*/ + */ public function testGetCategories() @@ -460,107 +460,107 @@ class YodleeApiTest extends TestCase } -/** -[2022-08-05 01:29:45] local.INFO: stdClass Object -( - [account] => Array - ( - [0] => stdClass Object - ( - [CONTAINER] => bank - [providerAccountId] => 11308693 - [accountName] => My CD - 8878 - [accountStatus] => ACTIVE - [accountNumber] => xxxx8878 - [aggregationSource] => USER - [isAsset] => 1 - [balance] => stdClass Object - ( - [currency] => USD - [amount] => 49778.07 - ) + /** + [2022-08-05 01:29:45] local.INFO: stdClass Object + ( + [account] => Array + ( + [0] => stdClass Object + ( + [CONTAINER] => bank + [providerAccountId] => 11308693 + [accountName] => My CD - 8878 + [accountStatus] => ACTIVE + [accountNumber] => xxxx8878 + [aggregationSource] => USER + [isAsset] => 1 + [balance] => stdClass Object + ( + [currency] => USD + [amount] => 49778.07 + ) - [id] => 12331861 - [includeInNetWorth] => 1 - [providerId] => 18769 - [providerName] => Dag Site Captcha - [isManual] => - [currentBalance] => stdClass Object - ( - [currency] => USD - [amount] => 49778.07 - ) + [id] => 12331861 + [includeInNetWorth] => 1 + [providerId] => 18769 + [providerName] => Dag Site Captcha + [isManual] => + [currentBalance] => stdClass Object + ( + [currency] => USD + [amount] => 49778.07 + ) - [accountType] => CD - [displayedName] => LORETTA - [createdDate] => 2022-07-28T06:55:33Z - [lastUpdated] => 2022-07-28T06:56:09Z - [dataset] => Array - ( - [0] => stdClass Object - ( - [name] => BASIC_AGG_DATA - [additionalStatus] => AVAILABLE_DATA_RETRIEVED - [updateEligibility] => ALLOW_UPDATE - [lastUpdated] => 2022-07-28T06:55:50Z - [lastUpdateAttempt] => 2022-07-28T06:55:50Z - ) + [accountType] => CD + [displayedName] => LORETTA + [createdDate] => 2022-07-28T06:55:33Z + [lastUpdated] => 2022-07-28T06:56:09Z + [dataset] => Array + ( + [0] => stdClass Object + ( + [name] => BASIC_AGG_DATA + [additionalStatus] => AVAILABLE_DATA_RETRIEVED + [updateEligibility] => ALLOW_UPDATE + [lastUpdated] => 2022-07-28T06:55:50Z + [lastUpdateAttempt] => 2022-07-28T06:55:50Z + ) - ) + ) - ) - [1] => stdClass Object - ( - [CONTAINER] => bank - [providerAccountId] => 11308693 - [accountName] => Joint Savings - 7159 - [accountStatus] => ACTIVE - [accountNumber] => xxxx7159 - [aggregationSource] => USER - [isAsset] => 1 - [balance] => stdClass Object - ( - [currency] => USD - [amount] => 186277.45 - ) + ) + [1] => stdClass Object + ( + [CONTAINER] => bank + [providerAccountId] => 11308693 + [accountName] => Joint Savings - 7159 + [accountStatus] => ACTIVE + [accountNumber] => xxxx7159 + [aggregationSource] => USER + [isAsset] => 1 + [balance] => stdClass Object + ( + [currency] => USD + [amount] => 186277.45 + ) - [id] => 12331860 - [includeInNetWorth] => 1 - [providerId] => 18769 - [providerName] => Dag Site Captcha - [isManual] => - [availableBalance] => stdClass Object - ( - [currency] => USD - [amount] => 186277.45 - ) + [id] => 12331860 + [includeInNetWorth] => 1 + [providerId] => 18769 + [providerName] => Dag Site Captcha + [isManual] => + [availableBalance] => stdClass Object + ( + [currency] => USD + [amount] => 186277.45 + ) - [currentBalance] => stdClass Object - ( - [currency] => USD - [amount] => 186277.45 - ) + [currentBalance] => stdClass Object + ( + [currency] => USD + [amount] => 186277.45 + ) - [accountType] => SAVINGS - [displayedName] => LYDIA - [createdDate] => 2022-07-28T06:55:33Z - [classification] => PERSONAL - [lastUpdated] => 2022-07-28T06:56:09Z - [dataset] => Array - ( - [0] => stdClass Object - ( - [name] => BASIC_AGG_DATA - [additionalStatus] => AVAILABLE_DATA_RETRIEVED - [updateEligibility] => ALLOW_UPDATE - [lastUpdated] => 2022-07-28T06:55:50Z - [lastUpdateAttempt] => 2022-07-28T06:55:50Z - ) + [accountType] => SAVINGS + [displayedName] => LYDIA + [createdDate] => 2022-07-28T06:55:33Z + [classification] => PERSONAL + [lastUpdated] => 2022-07-28T06:56:09Z + [dataset] => Array + ( + [0] => stdClass Object + ( + [name] => BASIC_AGG_DATA + [additionalStatus] => AVAILABLE_DATA_RETRIEVED + [updateEligibility] => ALLOW_UPDATE + [lastUpdated] => 2022-07-28T06:55:50Z + [lastUpdateAttempt] => 2022-07-28T06:55:50Z + ) - ) + ) - ) -*/ + ) + */ public function testGetAccounts() { $yodlee = new Yodlee('sbMem62e1e69547bfb1'); @@ -571,51 +571,51 @@ class YodleeApiTest extends TestCase } -/** -[2022-08-05 01:36:34] local.INFO: stdClass Object -( - [transaction] => Array - ( - [0] => stdClass Object - ( - [CONTAINER] => bank - [id] => 103953585 - [amount] => stdClass Object - ( - [amount] => 480.66 - [currency] => USD - ) + /** + [2022-08-05 01:36:34] local.INFO: stdClass Object + ( + [transaction] => Array + ( + [0] => stdClass Object + ( + [CONTAINER] => bank + [id] => 103953585 + [amount] => stdClass Object + ( + [amount] => 480.66 + [currency] => USD + ) - [categoryType] => UNCATEGORIZE - [categoryId] => 1 - [category] => Uncategorized - [categorySource] => SYSTEM - [highLevelCategoryId] => 10000017 - [createdDate] => 2022-08-04T21:50:17Z - [lastUpdated] => 2022-08-04T21:50:17Z - [description] => stdClass Object - ( - [original] => CHEROKEE NATION TAX TA TAHLEQUAH OK - ) + [categoryType] => UNCATEGORIZE + [categoryId] => 1 + [category] => Uncategorized + [categorySource] => SYSTEM + [highLevelCategoryId] => 10000017 + [createdDate] => 2022-08-04T21:50:17Z + [lastUpdated] => 2022-08-04T21:50:17Z + [description] => stdClass Object + ( + [original] => CHEROKEE NATION TAX TA TAHLEQUAH OK + ) - [isManual] => - [sourceType] => AGGREGATED - [date] => 2022-08-03 - [transactionDate] => 2022-08-03 - [postDate] => 2022-08-03 - [status] => POSTED - [accountId] => 12331794 - [runningBalance] => stdClass Object - ( - [amount] => 480.66 - [currency] => USD - ) + [isManual] => + [sourceType] => AGGREGATED + [date] => 2022-08-03 + [transactionDate] => 2022-08-03 + [postDate] => 2022-08-03 + [status] => POSTED + [accountId] => 12331794 + [runningBalance] => stdClass Object + ( + [amount] => 480.66 + [currency] => USD + ) - [checkNumber] => 998 - ) + [checkNumber] => 998 + ) - */ + */ public function testGetTransactions() { diff --git a/tests/Feature/BankTransactionApiTest.php b/tests/Feature/BankTransactionApiTest.php index a79cd8e50747..a0a6868ac890 100644 --- a/tests/Feature/BankTransactionApiTest.php +++ b/tests/Feature/BankTransactionApiTest.php @@ -11,15 +11,15 @@ namespace Tests\Feature; -use Tests\TestCase; -use App\Models\Expense; -use Tests\MockAccountData; use App\Models\BankIntegration; use App\Models\BankTransaction; +use App\Models\Expense; use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Facades\Session; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Support\Facades\Session; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test diff --git a/tests/Feature/BankTransactionRuleApiTest.php b/tests/Feature/BankTransactionRuleApiTest.php index 59edbda2e15b..843b6241cbb5 100644 --- a/tests/Feature/BankTransactionRuleApiTest.php +++ b/tests/Feature/BankTransactionRuleApiTest.php @@ -41,24 +41,24 @@ class BankTransactionRuleApiTest extends TestCase Model::reguard(); } -/* -$rules = [ - 'name' => 'bail|required|string', - 'rules' => 'bail|array', - 'auto_convert' => 'bail|sometimes|bool', - 'matches_on_all' => 'bail|sometimes|bool', - 'applies_to' => 'bail|sometimes|bool', -]; + /* + $rules = [ + 'name' => 'bail|required|string', + 'rules' => 'bail|array', + 'auto_convert' => 'bail|sometimes|bool', + 'matches_on_all' => 'bail|sometimes|bool', + 'applies_to' => 'bail|sometimes|bool', + ]; -if(isset($this->category_id)) - $rules['category_id'] = 'bail|sometimes|exists:expense_categories,id,'.auth()->user()->company()->id.',is_deleted,0'; + if(isset($this->category_id)) + $rules['category_id'] = 'bail|sometimes|exists:expense_categories,id,'.auth()->user()->company()->id.',is_deleted,0'; -if(isset($this->vendor_id)) - $rules['vendor_id'] = 'bail|sometimes|exists:vendors,id,company_id,'.auth()->user()->company()->id.',is_deleted,0'; + if(isset($this->vendor_id)) + $rules['vendor_id'] = 'bail|sometimes|exists:vendors,id,company_id,'.auth()->user()->company()->id.',is_deleted,0'; -if(isset($this->client_id)) - $rules['client_id'] = 'bail|sometimes|exists:clients,id,company_id,'.auth()->user()->company()->id.',is_deleted,0'; -*/ + if(isset($this->client_id)) + $rules['client_id'] = 'bail|sometimes|exists:clients,id,company_id,'.auth()->user()->company()->id.',is_deleted,0'; + */ public function testBankRuleCategoryIdValidation() { $data = [ diff --git a/tests/Feature/BaseApiTest.php b/tests/Feature/BaseApiTest.php index 5f2de469f053..bc8e95815ec6 100644 --- a/tests/Feature/BaseApiTest.php +++ b/tests/Feature/BaseApiTest.php @@ -391,9 +391,9 @@ class BaseApiTest extends TestCase // public function testGeneratingClassName() // { - // $this->assertEquals('user', Str::snake(User::class)); + // $this->assertEquals('user', Str::snake(User::class)); - // $this->assertEquals('user',lcfirst(class_basename(Str::snake(User::class)))); + // $this->assertEquals('user',lcfirst(class_basename(Str::snake(User::class)))); // } diff --git a/tests/Feature/ClassificationTest.php b/tests/Feature/ClassificationTest.php index 5a08c8cfca03..9f9544f2219d 100644 --- a/tests/Feature/ClassificationTest.php +++ b/tests/Feature/ClassificationTest.php @@ -11,10 +11,10 @@ namespace Tests\Feature; -use Tests\TestCase; -use Tests\MockUnitData; use App\Utils\Traits\MakesHash; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Tests\MockUnitData; +use Tests\TestCase; /** * @test @@ -217,4 +217,4 @@ class ClassificationTest extends TestCase $this->assertEquals('', $arr['data']['settings']['classification']); } -} \ No newline at end of file +} diff --git a/tests/Feature/ClientPortal/CreditsTest.php b/tests/Feature/ClientPortal/CreditsTest.php index ce401c2986bc..070733967b78 100644 --- a/tests/Feature/ClientPortal/CreditsTest.php +++ b/tests/Feature/ClientPortal/CreditsTest.php @@ -108,7 +108,7 @@ class CreditsTest extends TestCase ->assertSee('testing-number-02') ->assertSee('testing-number-03'); - $user->forceDelete(); + $user->forceDelete(); } public function testShowingCreditsWithNullDueDate() @@ -177,7 +177,7 @@ class CreditsTest extends TestCase ->assertSee('testing-number-02') ->assertSee('testing-number-03'); - $account->delete(); + $account->delete(); } } diff --git a/tests/Feature/ClientTest.php b/tests/Feature/ClientTest.php index 89b49d945c6a..54f1e1054504 100644 --- a/tests/Feature/ClientTest.php +++ b/tests/Feature/ClientTest.php @@ -70,27 +70,27 @@ class ClientTest extends TestCase $data = [ "contacts" => [ [ - "email" => "tenda@gmail.com", - "first_name" => "Tenda", - "is_primary" => True, - "last_name" => "Bavuma", - "password" => null, - "send_email" => True + "email" => "tenda@gmail.com", + "first_name" => "Tenda", + "is_primary" => true, + "last_name" => "Bavuma", + "password" => null, + "send_email" => true ], - ], - "country_id" => "356", - "display_name" => "Tenda Bavuma", - "name" => "Tenda Bavuma", - "shipping_country_id" => "356", + ], + "country_id" => "356", + "display_name" => "Tenda Bavuma", + "name" => "Tenda Bavuma", + "shipping_country_id" => "356", ]; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/clients', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/clients', $data); - $response->assertStatus(200); + $response->assertStatus(200); } public function testClientMergeContactDrop() @@ -98,41 +98,41 @@ class ClientTest extends TestCase $c = Client::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id]); - ClientContact::factory()->create([ - 'user_id' => $this->user->id, - 'client_id' => $c->id, - 'company_id' => $this->company->id, - 'is_primary' => 1, - ]); + ClientContact::factory()->create([ + 'user_id' => $this->user->id, + 'client_id' => $c->id, + 'company_id' => $this->company->id, + 'is_primary' => 1, + ]); - ClientContact::factory()->create([ - 'user_id' => $this->user->id, - 'client_id' => $c->id, - 'company_id' => $this->company->id, - ]); + ClientContact::factory()->create([ + 'user_id' => $this->user->id, + 'client_id' => $c->id, + 'company_id' => $this->company->id, + ]); $c1 = Client::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id]); - ClientContact::factory()->create([ - 'user_id' => $this->user->id, - 'client_id' => $c1->id, - 'company_id' => $this->company->id, - 'is_primary' => 1, - ]); + ClientContact::factory()->create([ + 'user_id' => $this->user->id, + 'client_id' => $c1->id, + 'company_id' => $this->company->id, + 'is_primary' => 1, + ]); - ClientContact::factory()->create([ - 'user_id' => $this->user->id, - 'client_id' => $c1->id, - 'company_id' => $this->company->id, - ]); + ClientContact::factory()->create([ + 'user_id' => $this->user->id, + 'client_id' => $c1->id, + 'company_id' => $this->company->id, + ]); - ClientContact::factory()->create([ - 'user_id' => $this->user->id, - 'client_id' => $c1->id, - 'company_id' => $this->company->id, - 'email' => '' - ]); + ClientContact::factory()->create([ + 'user_id' => $this->user->id, + 'client_id' => $c1->id, + 'company_id' => $this->company->id, + 'email' => '' + ]); $this->assertEquals(2, $c->contacts->count()); diff --git a/tests/Feature/CompanySettingsTest.php b/tests/Feature/CompanySettingsTest.php index a95934bec6f0..f2316e60b27b 100644 --- a/tests/Feature/CompanySettingsTest.php +++ b/tests/Feature/CompanySettingsTest.php @@ -10,17 +10,15 @@ */ namespace Tests\Feature; -use Tests\TestCase; -use App\Models\Company; -use App\Models\Activity; -use Tests\MockAccountData; -use App\Utils\Traits\MakesHash; use App\DataMapper\CompanySettings; +use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Model; +use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Session; use Illuminate\Validation\ValidationException; -use Illuminate\Foundation\Testing\RefreshDatabase; -use Illuminate\Foundation\Testing\DatabaseTransactions; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test diff --git a/tests/Feature/CompanyTest.php b/tests/Feature/CompanyTest.php index 6204e86ad835..91e412812951 100644 --- a/tests/Feature/CompanyTest.php +++ b/tests/Feature/CompanyTest.php @@ -11,19 +11,19 @@ namespace Tests\Feature; -use Tests\TestCase; -use App\Models\Company; -use App\Models\TaxRate; -use Tests\MockAccountData; -use App\Models\CompanyToken; -use App\Utils\Traits\MakesHash; -use Illuminate\Http\UploadedFile; use App\DataMapper\CompanySettings; -use Illuminate\Support\Facades\Log; -use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Facades\Session; use App\Http\Middleware\PasswordProtection; +use App\Models\Company; +use App\Models\CompanyToken; +use App\Models\TaxRate; +use App\Utils\Traits\MakesHash; +use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Http\UploadedFile; +use Illuminate\Support\Facades\Log; +use Illuminate\Support\Facades\Session; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -86,7 +86,7 @@ class CompanyTest extends TestCase 'X-API-TOKEN' => $this->token, ])->putJson('/api/v1/companies/'.$this->encodePrimaryKey($this->company->id), $company_update); - $response->assertStatus(200); + $response->assertStatus(200); $arr = $response->json(); diff --git a/tests/Feature/CreditTest.php b/tests/Feature/CreditTest.php index dd2fc2800771..cdf9e7b65de9 100644 --- a/tests/Feature/CreditTest.php +++ b/tests/Feature/CreditTest.php @@ -44,7 +44,7 @@ class CreditTest extends TestCase public function testApplicableFilters() { - Credit::where('company_id',$this->company->id)->cursor()->each(function ($c){ $c->forceDelete(); }); + Credit::where('company_id', $this->company->id)->cursor()->each(function ($c) { $c->forceDelete(); }); $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), diff --git a/tests/Feature/DesignApiTest.php b/tests/Feature/DesignApiTest.php index cfa46bfd2b5f..48811d7f7a00 100644 --- a/tests/Feature/DesignApiTest.php +++ b/tests/Feature/DesignApiTest.php @@ -11,19 +11,14 @@ namespace Tests\Feature; -use Tests\TestCase; -use App\Models\Design; -use Tests\MockAccountData; use App\Factory\DesignFactory; +use App\Models\Design; use App\Utils\Traits\MakesHash; -use App\Events\Design\DesignWasCreated; -use App\Events\Design\DesignWasDeleted; -use App\Events\Design\DesignWasUpdated; use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Facades\Session; -use App\Events\Design\DesignWasArchived; -use App\Events\Design\DesignWasRestored; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Support\Facades\Session; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test diff --git a/tests/Feature/DocumentsApiTest.php b/tests/Feature/DocumentsApiTest.php index 6d474df51c45..2c46c6b2effb 100644 --- a/tests/Feature/DocumentsApiTest.php +++ b/tests/Feature/DocumentsApiTest.php @@ -11,13 +11,13 @@ namespace Tests\Feature; -use Tests\TestCase; use App\Models\Document; -use Tests\MockAccountData; use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Facades\Session; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Support\Facades\Session; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test diff --git a/tests/Feature/EInvoice/FacturaeTest.php b/tests/Feature/EInvoice/FacturaeTest.php index 2d4053126341..6909a79fc2a6 100644 --- a/tests/Feature/EInvoice/FacturaeTest.php +++ b/tests/Feature/EInvoice/FacturaeTest.php @@ -11,14 +11,12 @@ namespace Tests\Feature\EInvoice; -use Tests\TestCase; -use Tests\MockAccountData; -use Illuminate\Support\Facades\Storage; use App\Services\Invoice\EInvoice\FacturaEInvoice; -use Illuminate\Routing\Middleware\ThrottleRequests; use Illuminate\Foundation\Testing\DatabaseTransactions; - -use function Amp\Iterator\toArray; +use Illuminate\Routing\Middleware\ThrottleRequests; +use Illuminate\Support\Facades\Storage; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -53,64 +51,64 @@ class FacturaeTest extends TestCase } -// protected function validateInvoiceXML($path, $validateSignature=false) { -// // Prepare file to upload -// if (function_exists('curl_file_create')) { -// $postFile = curl_file_create($path); -// } else { -// $postFile = "@" . realpath($path); -// } + // protected function validateInvoiceXML($path, $validateSignature=false) { + // // Prepare file to upload + // if (function_exists('curl_file_create')) { + // $postFile = curl_file_create($path); + // } else { + // $postFile = "@" . realpath($path); + // } -// // Send upload request -// $ch = curl_init(); -// curl_setopt_array($ch, array( -// CURLOPT_RETURNTRANSFER => true, -// CURLOPT_FOLLOWLOCATION => true, -// CURLOPT_URL => "http://plataforma.firma-e.com/VisualizadorFacturae/index2.jsp", -// CURLOPT_POST => 1, -// CURLOPT_POSTFIELDS => array( -// "referencia" => $postFile, -// "valContable" => "on", -// "valFirma" => $validateSignature ? "on" : "off", -// "aceptarCondiciones" => "on", -// "submit" => "Siguiente" -// ), -// CURLOPT_COOKIEJAR => base_path()."/cookie.txt" -// )); -// $res = curl_exec($ch); -// curl_close($ch); -// unset($ch); + // // Send upload request + // $ch = curl_init(); + // curl_setopt_array($ch, array( + // CURLOPT_RETURNTRANSFER => true, + // CURLOPT_FOLLOWLOCATION => true, + // CURLOPT_URL => "http://plataforma.firma-e.com/VisualizadorFacturae/index2.jsp", + // CURLOPT_POST => 1, + // CURLOPT_POSTFIELDS => array( + // "referencia" => $postFile, + // "valContable" => "on", + // "valFirma" => $validateSignature ? "on" : "off", + // "aceptarCondiciones" => "on", + // "submit" => "Siguiente" + // ), + // CURLOPT_COOKIEJAR => base_path()."/cookie.txt" + // )); + // $res = curl_exec($ch); + // curl_close($ch); + // unset($ch); -// nlog($res); + // nlog($res); -// if (strpos($res, "window.open('facturae.jsp'") === false) { -// $this->expectException(\UnexpectedValueException::class); -// } + // if (strpos($res, "window.open('facturae.jsp'") === false) { + // $this->expectException(\UnexpectedValueException::class); + // } -// // Fetch results -// $ch = curl_init(); -// curl_setopt_array($ch, array( -// CURLOPT_RETURNTRANSFER => true, -// CURLOPT_FOLLOWLOCATION => true, -// CURLOPT_URL => "http://plataforma.firma-e.com/VisualizadorFacturae/facturae.jsp", -// CURLOPT_COOKIEFILE => base_path()."/cookie.txt" -// )); -// $res = curl_exec($ch); -// curl_close($ch); -// unset($ch); + // // Fetch results + // $ch = curl_init(); + // curl_setopt_array($ch, array( + // CURLOPT_RETURNTRANSFER => true, + // CURLOPT_FOLLOWLOCATION => true, + // CURLOPT_URL => "http://plataforma.firma-e.com/VisualizadorFacturae/facturae.jsp", + // CURLOPT_COOKIEFILE => base_path()."/cookie.txt" + // )); + // $res = curl_exec($ch); + // curl_close($ch); + // unset($ch); -// nlog($res); + // nlog($res); -// // Validate results -// $this->assertNotEmpty($res, 'Invalid Validator Response'); -// $this->assertNotEmpty(strpos($res, 'euro_ok.png'), 'Invalid XML Format'); -// if ($validateSignature) { -// $this->assertNotEmpty(strpos($res, '>Nivel de Firma Válido<'), 'Invalid Signature'); -// } -// if (strpos($res, '>Sellos de Tiempo<') !== false) { -// $this->assertNotEmpty(strpos($res, '>XAdES_T<'), 'Invalid Timestamp'); -// } -// } + // // Validate results + // $this->assertNotEmpty($res, 'Invalid Validator Response'); + // $this->assertNotEmpty(strpos($res, 'euro_ok.png'), 'Invalid XML Format'); + // if ($validateSignature) { + // $this->assertNotEmpty(strpos($res, '>Nivel de Firma Válido<'), 'Invalid Signature'); + // } + // if (strpos($res, '>Sellos de Tiempo<') !== false) { + // $this->assertNotEmpty(strpos($res, '>XAdES_T<'), 'Invalid Timestamp'); + // } + // } // private function validateInvoiceXML($path) // { @@ -134,4 +132,4 @@ class FacturaeTest extends TestCase // } -} \ No newline at end of file +} diff --git a/tests/Feature/EInvoice/FatturaPATest.php b/tests/Feature/EInvoice/FatturaPATest.php index 11e1ccdee0bb..dfe243f55823 100644 --- a/tests/Feature/EInvoice/FatturaPATest.php +++ b/tests/Feature/EInvoice/FatturaPATest.php @@ -45,4 +45,4 @@ class FatturaPATest extends TestCase $this->assertnotNull($xml); } -} \ No newline at end of file +} diff --git a/tests/Feature/ExpenseApiTest.php b/tests/Feature/ExpenseApiTest.php index 5a8b8d7b7908..8ffb2ab43d98 100644 --- a/tests/Feature/ExpenseApiTest.php +++ b/tests/Feature/ExpenseApiTest.php @@ -11,16 +11,16 @@ namespace Tests\Feature; -use Tests\TestCase; -use App\Models\Expense; -use Tests\MockAccountData; use App\Models\BankIntegration; use App\Models\BankTransaction; +use App\Models\Expense; use App\Models\ExpenseCategory; use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Facades\Session; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Support\Facades\Session; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test diff --git a/tests/Feature/Export/ArDetailReportTest.php b/tests/Feature/Export/ArDetailReportTest.php index 5b5c599162ac..cfd3ddc6d899 100644 --- a/tests/Feature/Export/ArDetailReportTest.php +++ b/tests/Feature/Export/ArDetailReportTest.php @@ -22,7 +22,6 @@ use App\Services\Report\ARDetailReport; use App\Utils\Traits\AppSetup; use App\Utils\Traits\MakesHash; use Illuminate\Routing\Middleware\ThrottleRequests; -use Tests\MockAccountData; use Tests\TestCase; /** diff --git a/tests/Feature/Export/ArSummaryReportTest.php b/tests/Feature/Export/ArSummaryReportTest.php index dffde40f87a9..874ecc6a6f01 100644 --- a/tests/Feature/Export/ArSummaryReportTest.php +++ b/tests/Feature/Export/ArSummaryReportTest.php @@ -18,7 +18,6 @@ use App\Models\Client; use App\Models\Company; use App\Models\Invoice; use App\Models\User; -use App\Services\Report\ARDetailReport; use App\Services\Report\ARSummaryReport; use App\Utils\Traits\MakesHash; use Illuminate\Routing\Middleware\ThrottleRequests; diff --git a/tests/Feature/Export/ClientBalanceReportTest.php b/tests/Feature/Export/ClientBalanceReportTest.php index 875b9139d56c..9e995147f4f8 100644 --- a/tests/Feature/Export/ClientBalanceReportTest.php +++ b/tests/Feature/Export/ClientBalanceReportTest.php @@ -18,7 +18,6 @@ use App\Models\Client; use App\Models\Company; use App\Models\Invoice; use App\Models\User; -use App\Services\Report\ARSummaryReport; use App\Services\Report\ClientBalanceReport; use App\Utils\Traits\MakesHash; use Illuminate\Routing\Middleware\ThrottleRequests; diff --git a/tests/Feature/Export/ClientSalesReportTest.php b/tests/Feature/Export/ClientSalesReportTest.php index 00aff14dbebd..98820c7bce9d 100644 --- a/tests/Feature/Export/ClientSalesReportTest.php +++ b/tests/Feature/Export/ClientSalesReportTest.php @@ -11,18 +11,17 @@ namespace Tests\Feature\Export; -use Tests\TestCase; -use App\Models\User; -use App\Models\Client; -use App\Models\Account; -use App\Models\Company; -use App\Models\Invoice; -use App\Utils\Traits\MakesHash; use App\DataMapper\CompanySettings; use App\Factory\InvoiceItemFactory; +use App\Models\Account; +use App\Models\Client; +use App\Models\Company; +use App\Models\Invoice; +use App\Models\User; use App\Services\Report\ClientSalesReport; -use App\Services\Report\ClientBalanceReport; +use App\Utils\Traits\MakesHash; use Illuminate\Routing\Middleware\ThrottleRequests; +use Tests\TestCase; /** * @test diff --git a/tests/Feature/Export/ReportApiTest.php b/tests/Feature/Export/ReportApiTest.php index 9a8354b13c8b..9e021bcc8461 100644 --- a/tests/Feature/Export/ReportApiTest.php +++ b/tests/Feature/Export/ReportApiTest.php @@ -11,12 +11,10 @@ namespace Tests\Feature\Export; -use Tests\TestCase; -use Tests\MockAccountData; use App\Utils\Traits\MakesHash; -use Illuminate\Support\Facades\Event; use Illuminate\Routing\Middleware\ThrottleRequests; -use Illuminate\Foundation\Testing\Concerns\InteractsWithExceptionHandling; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -162,4 +160,4 @@ class ReportApiTest extends TestCase } -} \ No newline at end of file +} diff --git a/tests/Feature/Export/ReportCsvGenerationTest.php b/tests/Feature/Export/ReportCsvGenerationTest.php index eb868ea852d1..0168c9fa5455 100644 --- a/tests/Feature/Export/ReportCsvGenerationTest.php +++ b/tests/Feature/Export/ReportCsvGenerationTest.php @@ -11,28 +11,27 @@ namespace Tests\Feature\Export; -use Tests\TestCase; -use App\Models\User; -use App\Models\Client; -use App\Models\Credit; -use League\Csv\Reader; -use App\Models\Account; -use App\Models\Company; -use App\Models\Expense; -use App\Models\Invoice; -use App\Models\CompanyToken; -use App\Models\ClientContact; -use App\Export\CSV\TaskExport; -use App\Utils\Traits\MakesHash; -use App\Export\CSV\VendorExport; +use App\DataMapper\CompanySettings; use App\Export\CSV\PaymentExport; use App\Export\CSV\ProductExport; -use App\DataMapper\CompanySettings; -use App\DataMapper\InvoiceItem; +use App\Export\CSV\TaskExport; +use App\Export\CSV\VendorExport; use App\Factory\CompanyUserFactory; use App\Factory\InvoiceItemFactory; -use Illuminate\Support\Facades\Http; +use App\Models\Account; +use App\Models\Client; +use App\Models\ClientContact; +use App\Models\Company; +use App\Models\CompanyToken; +use App\Models\Credit; +use App\Models\Expense; +use App\Models\Invoice; +use App\Models\User; +use App\Utils\Traits\MakesHash; use Illuminate\Routing\Middleware\ThrottleRequests; +use Illuminate\Support\Facades\Http; +use League\Csv\Reader; +use Tests\TestCase; /** * @test @@ -59,8 +58,9 @@ class ReportCsvGenerationTest extends TestCase $this->buildData(); - if (config('ninja.testvars.travis') !== false) + if (config('ninja.testvars.travis') !== false) { $this->markTestSkipped('Skip test no company gateways installed'); + } } @@ -354,7 +354,7 @@ class ReportCsvGenerationTest extends TestCase $query = Invoice::query(); - $query->where(function ($q) use($products){ + $query->where(function ($q) use ($products) { foreach($products as $product) { $q->orWhereJsonContains('line_items', ['product_key' => $product]); } @@ -364,8 +364,8 @@ class ReportCsvGenerationTest extends TestCase $query = Invoice::query(); - $query->where(function ($q){ - $q->orWhereJsonContains('line_items', ['product_key' => 'bob the builder']); + $query->where(function ($q) { + $q->orWhereJsonContains('line_items', ['product_key' => 'bob the builder']); }); $this->assertEquals(1, $query->count()); @@ -400,46 +400,46 @@ class ReportCsvGenerationTest extends TestCase $q->forceDelete(); - Invoice::factory()->create( - [ - 'company_id' => $this->company->id, - 'user_id' => $this->user->id, - 'client_id' => $this->client->id, - 'line_items' => $line_items - ] - ); + Invoice::factory()->create( + [ + 'company_id' => $this->company->id, + 'user_id' => $this->user->id, + 'client_id' => $this->client->id, + 'line_items' => $line_items + ] + ); - $item = InvoiceItemFactory::create(); - $item->product_key = 'bob the builder'; + $item = InvoiceItemFactory::create(); + $item->product_key = 'bob the builder'; - $line_items = []; + $line_items = []; - $line_items[] = $item; + $line_items[] = $item; - $q = Invoice::whereJsonContains('line_items', ['product_key' => 'bob the builder']); + $q = Invoice::whereJsonContains('line_items', ['product_key' => 'bob the builder']); - $this->assertEquals(0, $q->count()); + $this->assertEquals(0, $q->count()); - Invoice::factory()->create( - [ - 'company_id' => $this->company->id, - 'user_id' => $this->user->id, - 'client_id' => $this->client->id, - 'line_items' => $line_items - ] - ); + Invoice::factory()->create( + [ + 'company_id' => $this->company->id, + 'user_id' => $this->user->id, + 'client_id' => $this->client->id, + 'line_items' => $line_items + ] + ); - $this->assertEquals(1, $q->count()); + $this->assertEquals(1, $q->count()); - $q = Invoice::whereJsonContains('line_items', ['product_key' => 'Bob the builder']); - $this->assertEquals(0, $q->count()); + $q = Invoice::whereJsonContains('line_items', ['product_key' => 'Bob the builder']); + $this->assertEquals(0, $q->count()); - $q = Invoice::whereJsonContains('line_items', ['product_key' => 'bob']); - $this->assertEquals(0, $q->count()); + $q = Invoice::whereJsonContains('line_items', ['product_key' => 'bob']); + $this->assertEquals(0, $q->count()); - $q->forceDelete(); + $q->forceDelete(); - Invoice::withTrashed()->cursor()->each(function ($i){ $i->forceDelete();}); + Invoice::withTrashed()->cursor()->each(function ($i) { $i->forceDelete();}); } public function testVendorCsvGeneration() @@ -1274,7 +1274,7 @@ class ReportCsvGenerationTest extends TestCase $response->assertStatus(200); $arr = $response->json(); $hash = $arr['message']; - $response = $this->poll($hash); + $response = $this->poll($hash); $csv = $response->body(); $this->assertEquals('bob', $this->getFirstValueByColumn($csv, 'Client Name')); diff --git a/tests/Feature/Export/ReportPreviewTest.php b/tests/Feature/Export/ReportPreviewTest.php index 5d8c77291bb3..3aaffd171931 100644 --- a/tests/Feature/Export/ReportPreviewTest.php +++ b/tests/Feature/Export/ReportPreviewTest.php @@ -11,26 +11,26 @@ namespace Tests\Feature\Export; -use Tests\TestCase; -use App\Models\Client; -use App\Models\Expense; -use App\Models\Document; -use Tests\MockAccountData; -use App\Export\CSV\QuoteExport; -use App\Utils\Traits\MakesHash; +use App\Export\CSV\ActivityExport; use App\Export\CSV\ClientExport; -use App\Export\CSV\CreditExport; use App\Export\CSV\ContactExport; +use App\Export\CSV\CreditExport; +use App\Export\CSV\DocumentExport; use App\Export\CSV\ExpenseExport; use App\Export\CSV\InvoiceExport; use App\Export\CSV\PaymentExport; use App\Export\CSV\ProductExport; -use App\Export\CSV\ActivityExport; -use App\Export\CSV\DocumentExport; -use App\Jobs\Report\PreviewReport; -use Illuminate\Support\Facades\Cache; use App\Export\CSV\PurchaseOrderExport; +use App\Export\CSV\QuoteExport; +use App\Jobs\Report\PreviewReport; +use App\Models\Client; +use App\Models\Document; +use App\Models\Expense; +use App\Utils\Traits\MakesHash; use Illuminate\Routing\Middleware\ThrottleRequests; +use Illuminate\Support\Facades\Cache; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -335,7 +335,7 @@ class ReportPreviewTest extends TestCase $r = Cache::pull('123'); $this->assertNotNull($r); -//nlog($r); + //nlog($r); } public function testDocumentJsonExport() @@ -366,7 +366,7 @@ class ReportPreviewTest extends TestCase $r = Cache::pull('123'); $this->assertNotNull($r); -//nlog($r); + //nlog($r); } public function testClientExportJson() @@ -494,4 +494,4 @@ class ReportPreviewTest extends TestCase } -} \ No newline at end of file +} diff --git a/tests/Feature/Export/TaxSummaryReportTest.php b/tests/Feature/Export/TaxSummaryReportTest.php index e4387f1cca42..c3f94b126b17 100644 --- a/tests/Feature/Export/TaxSummaryReportTest.php +++ b/tests/Feature/Export/TaxSummaryReportTest.php @@ -18,7 +18,6 @@ use App\Models\Client; use App\Models\Company; use App\Models\Invoice; use App\Models\User; -use App\Services\Report\ARDetailReport; use App\Services\Report\TaxSummaryReport; use App\Utils\Traits\MakesHash; use Illuminate\Routing\Middleware\ThrottleRequests; diff --git a/tests/Feature/Export/UserSalesReportTest.php b/tests/Feature/Export/UserSalesReportTest.php index bff92d6a34bb..2be1a220237e 100644 --- a/tests/Feature/Export/UserSalesReportTest.php +++ b/tests/Feature/Export/UserSalesReportTest.php @@ -11,21 +11,19 @@ namespace Tests\Feature\Export; -use Tests\TestCase; -use App\Models\User; -use App\Models\Client; -use App\Models\Account; -use App\Models\Company; -use App\Models\Invoice; -use App\Utils\Traits\AppSetup; -use App\Utils\Traits\MakesHash; use App\DataMapper\CompanySettings; use App\Factory\InvoiceItemFactory; -use Illuminate\Support\Facades\Cache; -use App\Export\CSV\ProductSalesExport; -use Illuminate\Support\Facades\Schema; +use App\Models\Account; +use App\Models\Client; +use App\Models\Company; +use App\Models\Invoice; +use App\Models\User; use App\Services\Report\UserSalesReport; +use App\Utils\Traits\MakesHash; use Illuminate\Routing\Middleware\ThrottleRequests; +use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\Schema; +use Tests\TestCase; /** * @test diff --git a/tests/Feature/GroupSettingTest.php b/tests/Feature/GroupSettingTest.php index 98bad3daa703..fb03abcc2984 100644 --- a/tests/Feature/GroupSettingTest.php +++ b/tests/Feature/GroupSettingTest.php @@ -11,13 +11,12 @@ namespace Tests\Feature; -use Tests\TestCase; -use Tests\MockAccountData; +use App\DataMapper\Settings\SettingsData; use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Session; -use App\DataMapper\Settings\SettingsData; -use Spatie\LaravelData\Support\Wrapping\WrapExecutionType; +use Tests\MockAccountData; +use Tests\TestCase; class GroupSettingTest extends TestCase { @@ -114,7 +113,7 @@ class GroupSettingTest extends TestCase $arr = $response->json(); - $this->assertEquals("", (string)NULL); + $this->assertEquals("", (string)null); $this->assertNotNull($arr['data']['settings']['tax_name1']); } diff --git a/tests/Feature/Import/CSV/TaskImportTest.php b/tests/Feature/Import/CSV/TaskImportTest.php index 4ebfaaa6cc61..4979d636f372 100644 --- a/tests/Feature/Import/CSV/TaskImportTest.php +++ b/tests/Feature/Import/CSV/TaskImportTest.php @@ -11,19 +11,15 @@ namespace Tests\Feature\Import\CSV; -use Tests\TestCase; -use App\Models\Task; -use App\Models\Client; -use App\Models\Vendor; -use App\Models\Invoice; -use App\Utils\TruthSource; -use Tests\MockAccountData; -use Illuminate\Support\Str; use App\Import\Providers\Csv; -use App\Utils\Traits\MakesHash; -use Illuminate\Support\Facades\Cache; use App\Import\Transformer\BaseTransformer; +use App\Models\Task; +use App\Utils\Traits\MakesHash; use Illuminate\Routing\Middleware\ThrottleRequests; +use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Str; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -109,8 +105,7 @@ class TaskImportTest extends TestCase $time_log = json_decode($task->time_log); - foreach($time_log as $log) - { + foreach($time_log as $log) { $this->assertFalse($log[3]); } @@ -165,4 +160,4 @@ class TaskImportTest extends TestCase } -} \ No newline at end of file +} diff --git a/tests/Feature/InvoiceEmailTest.php b/tests/Feature/InvoiceEmailTest.php index 23ba03236086..a41ec3cd812e 100644 --- a/tests/Feature/InvoiceEmailTest.php +++ b/tests/Feature/InvoiceEmailTest.php @@ -11,16 +11,16 @@ namespace Tests\Feature; -use Tests\TestCase; -use App\Models\SystemLog; -use Tests\MockAccountData; use App\Jobs\Entity\EmailEntity; +use App\Models\SystemLog; use App\Utils\Traits\GeneratesCounter; use Illuminate\Database\Eloquent\Model; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\Bus; use Illuminate\Support\Facades\Session; use Illuminate\Validation\ValidationException; -use Illuminate\Foundation\Testing\DatabaseTransactions; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -103,7 +103,7 @@ class InvoiceEmailTest extends TestCase ->orderBy('id', 'DESC') ->count(); - $this->assertEquals(1, $count); + $this->assertEquals(1, $count); } public function testEntityEmailHistory() diff --git a/tests/Feature/InvoiceTest.php b/tests/Feature/InvoiceTest.php index a40ef6b25d84..f17351c9749d 100644 --- a/tests/Feature/InvoiceTest.php +++ b/tests/Feature/InvoiceTest.php @@ -11,18 +11,18 @@ namespace Tests\Feature; -use Tests\TestCase; +use App\Helpers\Invoice\InvoiceSum; use App\Models\Client; +use App\Models\ClientContact; use App\Models\Invoice; use App\Models\Project; -use Tests\MockAccountData; -use App\Models\ClientContact; -use App\Utils\Traits\MakesHash; -use App\Helpers\Invoice\InvoiceSum; use App\Repositories\InvoiceRepository; +use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Facades\Session; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Support\Facades\Session; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test diff --git a/tests/Feature/LiveDesignTest.php b/tests/Feature/LiveDesignTest.php index 7dc750f10902..946b796db1aa 100644 --- a/tests/Feature/LiveDesignTest.php +++ b/tests/Feature/LiveDesignTest.php @@ -11,13 +11,13 @@ namespace Tests\Feature; -use Tests\TestCase; use App\Models\Design; -use App\Utils\HtmlEngine; -use Tests\MockAccountData; use App\Models\InvoiceInvitation; -use Illuminate\Routing\Middleware\ThrottleRequests; +use App\Utils\HtmlEngine; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Routing\Middleware\ThrottleRequests; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -62,7 +62,7 @@ class LiveDesignTest extends TestCase $data = $engine->generateLabelsAndValues(); - $this->assertIsArray($data); + $this->assertIsArray($data); nlog($data); } diff --git a/tests/Feature/MultiPaymentDeleteTest.php b/tests/Feature/MultiPaymentDeleteTest.php index 8a13b2ec5f25..72c5e3640ac6 100644 --- a/tests/Feature/MultiPaymentDeleteTest.php +++ b/tests/Feature/MultiPaymentDeleteTest.php @@ -129,7 +129,7 @@ class MultiPaymentDeleteTest extends TestCase $this->assertEquals(325, $invoice->client->balance); //payment 163 -// + // $data = [ 'amount' => 163.0, 'client_id' => $this->encodePrimaryKey($client->id), @@ -300,7 +300,7 @@ class MultiPaymentDeleteTest extends TestCase $this->assertEquals(325, $invoice->client->fresh()->paid_to_date); // delete payment 3 -// + // // $data = [ diff --git a/tests/Feature/Ninja/PlanTest.php b/tests/Feature/Ninja/PlanTest.php index 12e27a6a8e01..a468152c6466 100644 --- a/tests/Feature/Ninja/PlanTest.php +++ b/tests/Feature/Ninja/PlanTest.php @@ -11,18 +11,17 @@ namespace Tests\Feature\Ninja; -use Carbon\Carbon; -use Tests\TestCase; +use App\Factory\SubscriptionFactory; use App\Models\Account; use App\Models\License; -use Tests\MockAccountData; -use App\Utils\Traits\MakesHash; use App\Models\RecurringInvoice; -use App\Factory\SubscriptionFactory; -use Illuminate\Support\Facades\Http; +use App\Utils\Traits\MakesHash; +use Carbon\Carbon; use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Facades\Session; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Support\Facades\Session; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test diff --git a/tests/Feature/PaymentTest.php b/tests/Feature/PaymentTest.php index c51af9b87ad5..cba90ac705d5 100644 --- a/tests/Feature/PaymentTest.php +++ b/tests/Feature/PaymentTest.php @@ -355,16 +355,16 @@ class PaymentTest extends TestCase ]; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/payments/', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/payments/', $data); // } catch (ValidationException $e) { // $message = json_decode($e->validator->getMessageBag(), 1); $response->assertStatus(422); - // $this->assertTrue(array_key_exists('client_id', $message)); + // $this->assertTrue(array_key_exists('client_id', $message)); // } } @@ -409,13 +409,13 @@ class PaymentTest extends TestCase $response = null; // try { - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/payments?include=invoices,paymentables', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/payments?include=invoices,paymentables', $data); // } catch (ValidationException $e) { - // $message = json_decode($e->validator->getMessageBag(), 1); - // $this->assertNotNull($message); + // $message = json_decode($e->validator->getMessageBag(), 1); + // $this->assertNotNull($message); // } @@ -471,17 +471,17 @@ class PaymentTest extends TestCase $response = false; // try { - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/payments?include=invoices', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/payments?include=invoices', $data); // } catch (ValidationException $e) { - // $message = json_decode($e->validator->getMessageBag(), 1); - // $this->assertNotNull($message); + // $message = json_decode($e->validator->getMessageBag(), 1); + // $this->assertNotNull($message); // } // if ($response) { - $response->assertStatus(200); + $response->assertStatus(200); // } } @@ -603,12 +603,12 @@ class PaymentTest extends TestCase $response = false; // try { - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/payments?include=invoices', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/payments?include=invoices', $data); // } catch (ValidationException $e) { - // $message = json_decode($e->validator->getMessageBag(), 1); + // $message = json_decode($e->validator->getMessageBag(), 1); // } $arr = $response->json(); @@ -755,15 +755,15 @@ class PaymentTest extends TestCase ]; // try { - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/payments?include=invoices', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/payments?include=invoices', $data); // } catch (ValidationException $e) { - // $message = json_decode($e->validator->getMessageBag(), 1); - $response->assertStatus(422); + // $message = json_decode($e->validator->getMessageBag(), 1); + $response->assertStatus(422); - // $this->assertTrue(array_key_exists('amount', $message)); + // $this->assertTrue(array_key_exists('amount', $message)); // } } @@ -810,26 +810,26 @@ class PaymentTest extends TestCase $response = false; // try { - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/payments?include=invoices', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/payments?include=invoices', $data); // } catch (ValidationException $e) { - // $message = json_decode($e->validator->getMessageBag(), 1); + // $message = json_decode($e->validator->getMessageBag(), 1); - // $this->assertTrue(array_key_exists('amount', $message)); + // $this->assertTrue(array_key_exists('amount', $message)); // } // if ($response) { - $response->assertStatus(200); + $response->assertStatus(200); - $invoice = Invoice::find($this->decodePrimaryKey($invoice->hashed_id)); + $invoice = Invoice::find($this->decodePrimaryKey($invoice->hashed_id)); - $this->assertEquals($invoice->balance, 8); + $this->assertEquals($invoice->balance, 8); - $payment = $invoice->payments()->first(); + $payment = $invoice->payments()->first(); - $this->assertEquals($payment->applied, 2); + $this->assertEquals($payment->applied, 2); // } } @@ -877,18 +877,18 @@ class PaymentTest extends TestCase $response = false; // try { - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->putJson('/api/v1/payments/'.$this->encodePrimaryKey($payment->id), $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->putJson('/api/v1/payments/'.$this->encodePrimaryKey($payment->id), $data); // } catch (ValidationException $e) { - // $message = json_decode($e->validator->getMessageBag(), 1); + // $message = json_decode($e->validator->getMessageBag(), 1); - // $this->assertTrue(array_key_exists('invoices', $message)); + // $this->assertTrue(array_key_exists('invoices', $message)); // }/ // if ($response) { - $response->assertStatus(200); + $response->assertStatus(200); // } } @@ -941,19 +941,19 @@ class PaymentTest extends TestCase $response = false; // try { - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->putJson('/api/v1/payments/'.$this->encodePrimaryKey($payment->id), $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->putJson('/api/v1/payments/'.$this->encodePrimaryKey($payment->id), $data); // } catch (ValidationException $e) { - // $message = json_decode($e->validator->getMessageBag(), 1); - // \Log::error(print_r($e->validator->getMessageBag(), 1)); + // $message = json_decode($e->validator->getMessageBag(), 1); + // \Log::error(print_r($e->validator->getMessageBag(), 1)); - // $this->assertTrue(array_key_exists('invoices', $message)); + // $this->assertTrue(array_key_exists('invoices', $message)); // } // if ($response) { - $response->assertStatus(422); + $response->assertStatus(422); // } } @@ -1000,13 +1000,13 @@ class PaymentTest extends TestCase $response = false; // try { - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/payments/', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/payments/', $data); // } catch (ValidationException $e) { - // $message = json_decode($e->validator->getMessageBag(), 1); - // \Log::error(print_r($e->validator->getMessageBag(), 1)); + // $message = json_decode($e->validator->getMessageBag(), 1); + // \Log::error(print_r($e->validator->getMessageBag(), 1)); // } $response->assertStatus(200); @@ -1435,7 +1435,7 @@ class PaymentTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/payments?include=invoices', $data); + ])->postJson('/api/v1/payments?include=invoices', $data); $arr = $response->json(); $response->assertStatus(200); diff --git a/tests/Feature/PaymentV2Test.php b/tests/Feature/PaymentV2Test.php index 22a5b83919e5..399246b06080 100644 --- a/tests/Feature/PaymentV2Test.php +++ b/tests/Feature/PaymentV2Test.php @@ -11,20 +11,20 @@ namespace Tests\Feature; -use Tests\TestCase; +use App\Factory\InvoiceItemFactory; use App\Models\Client; +use App\Models\ClientContact; use App\Models\Credit; use App\Models\Invoice; use App\Models\Payment; -use Tests\MockAccountData; -use App\Models\ClientContact; use App\Utils\Traits\MakesHash; -use App\Factory\InvoiceItemFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Routing\Middleware\ThrottleRequests; use Illuminate\Support\Facades\Session; use Illuminate\Validation\ValidationException; -use Illuminate\Routing\Middleware\ThrottleRequests; -use Illuminate\Foundation\Testing\DatabaseTransactions; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -59,7 +59,7 @@ class PaymentV2Test extends TestCase public function testUsingDraftCreditsForPayments() { - $invoice = Invoice::factory()->create([ + $invoice = Invoice::factory()->create([ 'company_id' => $this->company->id, 'user_id' => $this->user->id, 'client_id' => $this->client->id, @@ -111,10 +111,10 @@ class PaymentV2Test extends TestCase $response = null; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/payments?include=invoices', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/payments?include=invoices', $data); $arr = $response->json(); $response->assertStatus(200); @@ -261,7 +261,7 @@ class PaymentV2Test extends TestCase } -public function testStorePaymentWithCreditsThenDeletingInvoicesAndThenPayments() + public function testStorePaymentWithCreditsThenDeletingInvoicesAndThenPayments() { $client = Client::factory()->create(['company_id' =>$this->company->id, 'user_id' => $this->user->id, 'balance' => 100, 'paid_to_date' => 0]); ClientContact::factory()->create([ @@ -428,4 +428,4 @@ public function testStorePaymentWithCreditsThenDeletingInvoicesAndThenPayments() } -} \ No newline at end of file +} diff --git a/tests/Feature/Payments/DeletePaymentTest.php b/tests/Feature/Payments/DeletePaymentTest.php index 59cc6ae490fe..6d87757d4464 100644 --- a/tests/Feature/Payments/DeletePaymentTest.php +++ b/tests/Feature/Payments/DeletePaymentTest.php @@ -11,18 +11,12 @@ namespace Tests\Feature\Payments; -use App\Factory\InvoiceFactory; -use App\Helpers\Invoice\InvoiceSum; -use App\Models\Client; -use App\Models\Credit; use App\Models\Invoice; -use App\Models\Payment; use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Routing\Middleware\ThrottleRequests; use Illuminate\Support\Facades\Session; -use Illuminate\Validation\ValidationException; use Tests\MockUnitData; use Tests\TestCase; @@ -58,8 +52,8 @@ class DeletePaymentTest extends TestCase Invoice::factory() ->count(10) ->create([ - 'user_id' => $this->user->id, - 'company_id' => $this->company->id, + 'user_id' => $this->user->id, + 'company_id' => $this->company->id, 'client_id' => $this->client->id, 'amount' => 101, 'balance' => 101, @@ -69,7 +63,7 @@ class DeletePaymentTest extends TestCase $i = Invoice::where('amount', 101)->where('status_id', 2)->take(1)->get(); - $invoices = $i->map(function ($i){ + $invoices = $i->map(function ($i) { return [ 'invoice_id' => $i->hashed_id, 'amount' => $i->amount, @@ -111,4 +105,4 @@ class DeletePaymentTest extends TestCase }); } -} \ No newline at end of file +} diff --git a/tests/Feature/ProductTest.php b/tests/Feature/ProductTest.php index bc41769e644c..7a709e398d33 100644 --- a/tests/Feature/ProductTest.php +++ b/tests/Feature/ProductTest.php @@ -73,8 +73,7 @@ class ProductTest extends TestCase 'X-API-TOKEN' => $this->token, ])->post('/api/v1/products/bulk', $update) ->assertStatus(200); - } - catch(\Exception $e){ + } catch(\Exception $e) { } diff --git a/tests/Feature/PurchaseOrderTest.php b/tests/Feature/PurchaseOrderTest.php index 4a5dfe798499..b855933fdae3 100644 --- a/tests/Feature/PurchaseOrderTest.php +++ b/tests/Feature/PurchaseOrderTest.php @@ -11,20 +11,19 @@ namespace Tests\Feature; -use Tests\TestCase; -use App\Utils\Ninja; -use App\Models\Activity; -use Tests\MockAccountData; -use Illuminate\Support\Str; -use App\Models\PurchaseOrder; -use App\Utils\Traits\MakesHash; -use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Facades\Session; -use App\Repositories\ActivityRepository; use App\Events\PurchaseOrder\PurchaseOrderWasCreated; use App\Events\PurchaseOrder\PurchaseOrderWasUpdated; -use App\Events\PurchaseOrder\PurchaseOrderWasAccepted; +use App\Models\Activity; +use App\Models\PurchaseOrder; +use App\Repositories\ActivityRepository; +use App\Utils\Ninja; +use App\Utils\Traits\MakesHash; +use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Support\Facades\Session; +use Illuminate\Support\Str; +use Tests\MockAccountData; +use Tests\TestCase; class PurchaseOrderTest extends TestCase { diff --git a/tests/Feature/QuoteTest.php b/tests/Feature/QuoteTest.php index 35605558207c..2b0f4e70266d 100644 --- a/tests/Feature/QuoteTest.php +++ b/tests/Feature/QuoteTest.php @@ -11,19 +11,19 @@ namespace Tests\Feature; -use Tests\TestCase; -use App\Models\Quote; -use App\Models\Client; -use App\Models\Project; -use Tests\MockAccountData; -use App\Models\ClientContact; -use App\Utils\Traits\MakesHash; use App\DataMapper\ClientSettings; use App\Exceptions\QuoteConversion; +use App\Models\Client; +use App\Models\ClientContact; +use App\Models\Project; +use App\Models\Quote; +use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Facades\Session; -use Illuminate\Routing\Middleware\ThrottleRequests; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Routing\Middleware\ThrottleRequests; +use Illuminate\Support\Facades\Session; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test diff --git a/tests/Feature/RecurringExpenseApiTest.php b/tests/Feature/RecurringExpenseApiTest.php index 3c863c047e18..6a302c3b49fa 100644 --- a/tests/Feature/RecurringExpenseApiTest.php +++ b/tests/Feature/RecurringExpenseApiTest.php @@ -11,16 +11,16 @@ namespace Tests\Feature; -use Tests\TestCase; -use Tests\MockAccountData; -use Illuminate\Support\Str; -use App\Utils\Traits\MakesHash; -use App\Models\RecurringInvoice; -use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Facades\Session; use App\Jobs\Cron\RecurringExpensesCron; -use Illuminate\Validation\ValidationException; +use App\Models\RecurringInvoice; +use App\Utils\Traits\MakesHash; +use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Support\Facades\Session; +use Illuminate\Support\Str; +use Illuminate\Validation\ValidationException; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -47,7 +47,7 @@ class RecurringExpenseApiTest extends TestCase Model::reguard(); } - public function testRecurringExpenseGenerationWithCurrencyConversion() + public function testRecurringExpenseGenerationWithCurrencyConversion() { $r = \App\Models\RecurringExpense::factory()->create([ 'user_id' => $this->user->id, @@ -67,7 +67,7 @@ class RecurringExpenseApiTest extends TestCase (new RecurringExpensesCron())->handle(); - $expense = \App\Models\Expense::where('recurring_expense_id', $r->id)->orderBy('id','desc')->first(); + $expense = \App\Models\Expense::where('recurring_expense_id', $r->id)->orderBy('id', 'desc')->first(); $this->assertEquals($r->amount, $expense->amount); $this->assertEquals($r->currency_id, $expense->currency_id); @@ -76,7 +76,7 @@ class RecurringExpenseApiTest extends TestCase } - public function testRecurringExpenseGenerationNullForeignCurrency() + public function testRecurringExpenseGenerationNullForeignCurrency() { $r = \App\Models\RecurringExpense::factory()->create([ 'user_id' => $this->user->id, @@ -95,7 +95,7 @@ class RecurringExpenseApiTest extends TestCase (new RecurringExpensesCron())->handle(); - $expense = \App\Models\Expense::where('recurring_expense_id', $r->id)->orderBy('id','desc')->first(); + $expense = \App\Models\Expense::where('recurring_expense_id', $r->id)->orderBy('id', 'desc')->first(); $this->assertEquals($r->amount, $expense->amount); $this->assertEquals($r->currency_id, $expense->currency_id); @@ -103,7 +103,7 @@ class RecurringExpenseApiTest extends TestCase } - public function testRecurringExpenseGeneration() + public function testRecurringExpenseGeneration() { $r = \App\Models\RecurringExpense::factory()->create([ 'user_id' => $this->user->id, @@ -121,7 +121,7 @@ class RecurringExpenseApiTest extends TestCase (new RecurringExpensesCron())->handle(); - $expense = \App\Models\Expense::where('recurring_expense_id', $r->id)->orderBy('id','desc')->first(); + $expense = \App\Models\Expense::where('recurring_expense_id', $r->id)->orderBy('id', 'desc')->first(); $this->assertEquals($r->amount, $expense->amount); $this->assertEquals($r->currency_id, $expense->currency_id); diff --git a/tests/Feature/RecurringInvoiceTest.php b/tests/Feature/RecurringInvoiceTest.php index b70b2f22ee9a..8f2c3e5e7fa9 100644 --- a/tests/Feature/RecurringInvoiceTest.php +++ b/tests/Feature/RecurringInvoiceTest.php @@ -18,10 +18,10 @@ use App\Factory\RecurringInvoiceToInvoiceFactory; use App\Jobs\RecurringInvoice\UpdateRecurring; use App\Models\Client; use App\Models\ClientContact; +use App\Models\Product; use App\Models\RecurringInvoice; use App\Utils\Helpers; use App\Utils\Traits\MakesHash; -use App\Models\Product; use Carbon\Carbon; use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Testing\DatabaseTransactions; @@ -275,12 +275,12 @@ class RecurringInvoiceTest extends TestCase 'product_key' => 'pink', ]); - $p2 = Product::factory()->create([ - 'company_id' => $this->company->id, - 'user_id' => $this->user->id, - 'cost' => 20, - 'price' => 20, - 'product_key' => 'floyd', + $p2 = Product::factory()->create([ + 'company_id' => $this->company->id, + 'user_id' => $this->user->id, + 'cost' => 20, + 'price' => 20, + 'product_key' => 'floyd', ]); $recurring_invoice = RecurringInvoiceFactory::create($this->company->id, $this->user->id); diff --git a/tests/Feature/RefundTest.php b/tests/Feature/RefundTest.php index a187fe49cb5d..3b5b246da49c 100644 --- a/tests/Feature/RefundTest.php +++ b/tests/Feature/RefundTest.php @@ -11,22 +11,22 @@ namespace Tests\Feature; -use Tests\TestCase; -use App\Models\Credit; -use App\Models\Invoice; -use App\Models\Payment; -use Tests\MockAccountData; -use App\Models\ClientContact; use App\Factory\ClientFactory; use App\Factory\CreditFactory; use App\Factory\InvoiceFactory; -use App\Utils\Traits\MakesHash; use App\Helpers\Invoice\InvoiceSum; +use App\Models\ClientContact; +use App\Models\Credit; +use App\Models\Invoice; +use App\Models\Payment; +use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Model; +use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Routing\Middleware\ThrottleRequests; use Illuminate\Support\Facades\Session; use Illuminate\Validation\ValidationException; -use Illuminate\Routing\Middleware\ThrottleRequests; -use Illuminate\Foundation\Testing\DatabaseTransactions; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -123,10 +123,10 @@ class RefundTest extends TestCase $response = false; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/payments/refund', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/payments/refund', $data); $arr = $response->json(); @@ -219,11 +219,11 @@ class RefundTest extends TestCase 'date' => '2020/12/12', ]; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/payments/refund', $data); - $response->assertStatus(422); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/payments/refund', $data); + $response->assertStatus(422); } @@ -294,7 +294,7 @@ class RefundTest extends TestCase $i = $this->invoice->fresh(); $this->assertEquals(0, $i->balance); - $this->assertEquals(round($this->invoice->amount,2), round($i->paid_to_date,2)); + $this->assertEquals(round($this->invoice->amount, 2), round($i->paid_to_date, 2)); $data = [ 'id' => $this->encodePrimaryKey($payment->id), diff --git a/tests/Feature/ReminderTest.php b/tests/Feature/ReminderTest.php index 6e2ee4fd28f8..f3fe49fe714a 100644 --- a/tests/Feature/ReminderTest.php +++ b/tests/Feature/ReminderTest.php @@ -11,23 +11,23 @@ namespace Tests\Feature; -use Tests\TestCase; -use App\Models\User; -use App\Models\Client; -use App\Models\Account; -use App\Models\Company; -use App\Models\Invoice; -use Tests\MockAccountData; -use App\Models\CompanyToken; -use App\Models\ClientContact; -use App\Jobs\Util\ReminderJob; -use Illuminate\Support\Carbon; -use App\Utils\Traits\MakesHash; use App\DataMapper\CompanySettings; use App\Factory\CompanyUserFactory; +use App\Jobs\Util\ReminderJob; +use App\Models\Account; +use App\Models\Client; +use App\Models\ClientContact; +use App\Models\Company; +use App\Models\CompanyToken; +use App\Models\Invoice; +use App\Models\User; +use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Model; -use Illuminate\Routing\Middleware\ThrottleRequests; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Routing\Middleware\ThrottleRequests; +use Illuminate\Support\Carbon; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -89,8 +89,7 @@ class ReminderTest extends TestCase 'email' => $this->faker->unique()->safeEmail(), ]); - if(!$settings) - { + if(!$settings) { $settings = CompanySettings::defaults(); $settings->client_online_payment_notification = false; $settings->client_manual_payment_notification = false; @@ -247,29 +246,29 @@ class ReminderTest extends TestCase $this->assertEquals(101, $fee->cost); $this->assertEquals('Fee added '.now()->format('d/M/Y'), $fee->notes); - $this->travelTo(now()->addDay()->startOfDay()->addHour()); + $this->travelTo(now()->addDay()->startOfDay()->addHour()); - (new ReminderJob())->handle(); - $this->invoice = $this->invoice->fresh(); - $this->assertNotNull($this->invoice->reminder2_sent); - $this->assertNotNull($this->invoice->reminder_last_sent); + (new ReminderJob())->handle(); + $this->invoice = $this->invoice->fresh(); + $this->assertNotNull($this->invoice->reminder2_sent); + $this->assertNotNull($this->invoice->reminder_last_sent); - $fee = collect($this->invoice->line_items)->where('cost', 102)->first(); + $fee = collect($this->invoice->line_items)->where('cost', 102)->first(); - $this->assertEquals(102, $fee->cost); - $this->assertEquals('Fee added '.now()->format('d/M/Y'), $fee->notes); + $this->assertEquals(102, $fee->cost); + $this->assertEquals('Fee added '.now()->format('d/M/Y'), $fee->notes); - $this->travelTo(now()->addDay()->startOfDay()->addHour()); + $this->travelTo(now()->addDay()->startOfDay()->addHour()); - (new ReminderJob())->handle(); - $this->invoice = $this->invoice->fresh(); - $this->assertNotNull($this->invoice->reminder3_sent); - $this->assertNotNull($this->invoice->reminder_last_sent); + (new ReminderJob())->handle(); + $this->invoice = $this->invoice->fresh(); + $this->assertNotNull($this->invoice->reminder3_sent); + $this->assertNotNull($this->invoice->reminder_last_sent); - $fee = collect($this->invoice->line_items)->where('cost', 103)->first(); + $fee = collect($this->invoice->line_items)->where('cost', 103)->first(); - $this->assertEquals(103, $fee->cost); - $this->assertEquals('Fee added '.now()->format('d/M/Y'), $fee->notes); + $this->assertEquals(103, $fee->cost); + $this->assertEquals('Fee added '.now()->format('d/M/Y'), $fee->notes); $this->travelBack(); @@ -337,7 +336,7 @@ class ReminderTest extends TestCase } - if(!$x){ + if(!$x) { $this->invoice = $this->invoice->fresh(); $this->assertNull($this->invoice->reminder1_sent); $this->assertNull($this->invoice->reminder_last_sent); diff --git a/tests/Feature/Scheduler/ScheduleEntityTest.php b/tests/Feature/Scheduler/ScheduleEntityTest.php index 3bb8e36d8140..05b1ec9904c9 100644 --- a/tests/Feature/Scheduler/ScheduleEntityTest.php +++ b/tests/Feature/Scheduler/ScheduleEntityTest.php @@ -11,17 +11,13 @@ namespace Tests\Feature\Scheduler; -use Carbon\Carbon; -use Tests\TestCase; -use App\Models\Client; -use App\Models\Scheduler; -use Tests\MockAccountData; -use App\Utils\Traits\MakesHash; use App\Models\RecurringInvoice; -use App\Factory\SchedulerFactory; +use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Facades\Session; use Illuminate\Routing\Middleware\ThrottleRequests; +use Illuminate\Support\Facades\Session; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -96,7 +92,7 @@ class ScheduleEntityTest extends TestCase } - public function testSchedulerStore4() + public function testSchedulerStore4() { $data = [ @@ -119,4 +115,4 @@ class ScheduleEntityTest extends TestCase } -} \ No newline at end of file +} diff --git a/tests/Feature/Scheduler/SchedulerTest.php b/tests/Feature/Scheduler/SchedulerTest.php index faeaaa573947..56b70ab5c230 100644 --- a/tests/Feature/Scheduler/SchedulerTest.php +++ b/tests/Feature/Scheduler/SchedulerTest.php @@ -11,22 +11,22 @@ namespace Tests\Feature\Scheduler; -use Carbon\Carbon; -use Tests\TestCase; -use App\Models\Client; -use App\Models\Scheduler; -use Tests\MockAccountData; -use App\Utils\Traits\MakesHash; -use App\Models\RecurringInvoice; -use App\Factory\SchedulerFactory; -use App\Services\Scheduler\EmailReport; -use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Facades\Session; use App\DataMapper\Schedule\EmailStatement; -use Illuminate\Validation\ValidationException; +use App\Factory\SchedulerFactory; +use App\Models\Client; +use App\Models\RecurringInvoice; +use App\Models\Scheduler; +use App\Services\Scheduler\EmailReport; use App\Services\Scheduler\EmailStatementService; -use Illuminate\Routing\Middleware\ThrottleRequests; +use App\Utils\Traits\MakesHash; +use Carbon\Carbon; +use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Routing\Middleware\ThrottleRequests; +use Illuminate\Support\Facades\Session; +use Illuminate\Validation\ValidationException; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -83,7 +83,7 @@ class SchedulerTest extends TestCase 'X-API-TOKEN' => $this->token, ])->postJson('/api/v1/task_schedulers', $data); - $response->assertStatus(422); + $response->assertStatus(422); } @@ -114,8 +114,7 @@ class SchedulerTest extends TestCase ])->postJson('/api/v1/task_schedulers', $data); $response->assertStatus(200); - } - catch(\Exception $e){ + } catch(\Exception $e) { nlog($e->getMessage()); } @@ -162,8 +161,7 @@ class SchedulerTest extends TestCase ])->postJson('/api/v1/task_schedulers', $data); $response->assertStatus(200); - } - catch(\Exception $e){ + } catch(\Exception $e) { nlog($e->getMessage()); } @@ -208,8 +206,7 @@ class SchedulerTest extends TestCase ])->postJson('/api/v1/task_schedulers', $data); $response->assertStatus(200); - } - catch(\Exception $e){ + } catch(\Exception $e) { nlog($e->getMessage()); } @@ -385,7 +382,7 @@ class SchedulerTest extends TestCase 'X-API-TOKEN' => $this->token, ])->postJson('/api/v1/task_schedulers', $data); - $response->assertStatus(422); + $response->assertStatus(422); @@ -410,7 +407,7 @@ class SchedulerTest extends TestCase 'X-API-TOKEN' => $this->token, ])->postJson('/api/v1/task_schedulers', $data); - $response->assertStatus(422); + $response->assertStatus(422); } diff --git a/tests/Feature/Search/SearchApiTest.php b/tests/Feature/Search/SearchApiTest.php index e04804e721b7..5a8318f46335 100644 --- a/tests/Feature/Search/SearchApiTest.php +++ b/tests/Feature/Search/SearchApiTest.php @@ -11,11 +11,10 @@ namespace Tests\Feature\Search; -use Tests\TestCase; -use Tests\MockAccountData; -use Illuminate\Validation\ValidationException; -use Illuminate\Routing\Middleware\ThrottleRequests; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Routing\Middleware\ThrottleRequests; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -58,4 +57,4 @@ class SearchApiTest extends TestCase } -} \ No newline at end of file +} diff --git a/tests/Feature/TaskApiTest.php b/tests/Feature/TaskApiTest.php index f9ce62a62f34..b4a0a06e2ee5 100644 --- a/tests/Feature/TaskApiTest.php +++ b/tests/Feature/TaskApiTest.php @@ -12,16 +12,16 @@ namespace Tests\Feature; use App\DataMapper\ClientSettings; -use Tests\TestCase; -use App\Models\Task; use App\Models\Client; use App\Models\Project; -use Tests\MockAccountData; +use App\Models\Task; use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Model; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\Session; use Illuminate\Validation\ValidationException; -use Illuminate\Foundation\Testing\DatabaseTransactions; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -219,8 +219,8 @@ class TaskApiTest extends TestCase public function testTaskTimelogParse() { $data = [ - "description" => "xx", - "rate" => "6574", + "description" => "xx", + "rate" => "6574", "time_log" => "[[Oct 31, 2023 12:00 am,Oct 31, 2023 1:00 am]]" ]; @@ -434,12 +434,11 @@ class TaskApiTest extends TestCase $logs = [ '[[1680302433,1680387960,"",true]]', '[[1680715620,1680722820,"",true],[1680729660,1680737460,"",true]]', - '[[1681156840,1681158000,"",true]]', + '[[1681156840,1681158000,"",true]]', '[[1680035007,1680036807,"",true]]', ]; - foreach($logs as $log) - { + foreach($logs as $log) { $this->assertTrue($this->checkTimeLog(json_decode($log))); } @@ -462,8 +461,7 @@ class TaskApiTest extends TestCase "[[1681156881,0]]", ]; - foreach($logs as $log) - { + foreach($logs as $log) { $this->assertTrue($this->checkTimeLog(json_decode($log))); } @@ -725,12 +723,12 @@ class TaskApiTest extends TestCase 'time_log' => $this->faker->firstName(), ]; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/tasks', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/tasks', $data); - $response->assertStatus(422); + $response->assertStatus(422); } diff --git a/tests/Feature/TaxRateApiTest.php b/tests/Feature/TaxRateApiTest.php index e8175ea78948..f52f48745d36 100644 --- a/tests/Feature/TaxRateApiTest.php +++ b/tests/Feature/TaxRateApiTest.php @@ -11,15 +11,14 @@ namespace Tests\Feature; -use Tests\TestCase; -use App\Models\Company; use App\Models\TaxRate; -use Tests\MockAccountData; use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Model; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\Session; use Illuminate\Validation\ValidationException; -use Illuminate\Foundation\Testing\DatabaseTransactions; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test diff --git a/tests/Feature/Template/TemplateTest.php b/tests/Feature/Template/TemplateTest.php index 446362f10076..6df4507bca59 100644 --- a/tests/Feature/Template/TemplateTest.php +++ b/tests/Feature/Template/TemplateTest.php @@ -11,30 +11,30 @@ namespace Tests\Feature\Template; -use Tests\TestCase; -use App\Utils\Ninja; -use App\Utils\Number; +use App\Jobs\Entity\CreateRawPdf; use App\Models\Credit; use App\Models\Design; use App\Models\Invoice; use App\Models\Payment; use App\Models\Project; -use App\Utils\HtmlEngine; -use Tests\MockAccountData; -use App\Utils\Traits\MakesDates; -use App\Jobs\Entity\CreateRawPdf; -use App\Services\PdfMaker\PdfMaker; -use Illuminate\Support\Facades\App; -use App\Services\Template\TemplateMock; -use App\Services\Template\TemplateService; use App\Services\PdfMaker\Design as PdfDesignModel; use App\Services\PdfMaker\Design as PdfMakerDesign; -use Illuminate\Routing\Middleware\ThrottleRequests; +use App\Services\PdfMaker\PdfMaker; +use App\Services\Template\TemplateMock; +use App\Services\Template\TemplateService; +use App\Utils\HtmlEngine; +use App\Utils\Ninja; +use App\Utils\Number; +use App\Utils\Traits\MakesDates; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Routing\Middleware\ThrottleRequests; +use Illuminate\Support\Facades\App; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test - * @covers + * @covers */ class TemplateTest extends TestCase { @@ -74,7 +74,7 @@ class TemplateTest extends TestCase '; - private string $nested_body = ' + private string $nested_body = ' $company.name @@ -108,7 +108,7 @@ class TemplateTest extends TestCase '; - private string $payments_body = ' + private string $payments_body = ' CoName: $company.name ClName: $client.name InNumber: $invoice.number @@ -262,7 +262,7 @@ class TemplateTest extends TestCase public function testNegativeDivAttribute() { - $dom = new \DOMDocument(); + $dom = new \DOMDocument(); @$dom->loadHTML(mb_convert_encoding($this->stack, 'HTML-ENTITIES', 'UTF-8')); $node = $dom->getElementById('company-details'); @@ -324,9 +324,9 @@ class TemplateTest extends TestCase 'balance' => 100, ]); - $invoices = Invoice::orderBy('id','desc')->where('client_id', $this->client->id)->take(10)->get()->map(function($c){ + $invoices = Invoice::orderBy('id', 'desc')->where('client_id', $this->client->id)->take(10)->get()->map(function ($c) { return $c->service()->markSent()->applyNumber()->save(); - })->map(function ($i){ + })->map(function ($i) { return ['invoice_id' => $i->hashed_id, 'amount' => rand(0, $i->balance)]; })->toArray(); @@ -339,7 +339,7 @@ class TemplateTest extends TestCase 'balance' => 50, ]); - $credits = Credit::orderBy('id', 'desc')->where('client_id', $this->client->id)->take(2)->get()->map(function($c){ + $credits = Credit::orderBy('id', 'desc')->where('client_id', $this->client->id)->take(2)->get()->map(function ($c) { return $c->service()->markSent()->applyNumber()->save(); })->map(function ($i) { return ['credit_id' => $i->hashed_id, 'amount' => rand(0, $i->balance)]; @@ -365,10 +365,10 @@ class TemplateTest extends TestCase $start = microtime(true); - $p = Payment::with('client','invoices','paymentables','credits') + $p = Payment::with('client', 'invoices', 'paymentables', 'credits') ->where('id', $this->decodePrimaryKey($arr['data']['id'])) ->cursor() - ->map(function ($payment){ + ->map(function ($payment) { $this->transformPayment($payment); @@ -383,15 +383,15 @@ class TemplateTest extends TestCase \DB::enableQueryLog(); - $invoices = Invoice::with('client','payments.client','payments.paymentables','payments.credits','credits.client') - ->orderBy('id','desc') + $invoices = Invoice::with('client', 'payments.client', 'payments.paymentables', 'payments.credits', 'credits.client') + ->orderBy('id', 'desc') ->where('client_id', $this->client->id) ->take(10) ->get() - ->map(function($invoice){ + ->map(function ($invoice) { $payments = []; - $payments = $invoice->payments->map(function ($payment){ + $payments = $invoice->payments->map(function ($payment) { // nlog(microtime(true)); return $this->transformPayment($payment); })->toArray(); @@ -460,7 +460,7 @@ class TemplateTest extends TestCase private function transformPayment(Payment $payment): array { - $data = []; + $data = []; $credits = $payment->credits->map(function ($credit) use ($payment) { return [ @@ -543,12 +543,12 @@ class TemplateTest extends TestCase 'balance' => 100, ]); - $i = Invoice::orderBy('id','desc') + $i = Invoice::orderBy('id', 'desc') ->where('client_id', $this->client->id) ->where('status_id', 2) ->cursor() - ->each(function ($i){ - $i->service()->applyPaymentAmount(random_int(1,100)); + ->each(function ($i) { + $i->service()->applyPaymentAmount(random_int(1, 100)); }); $invoices = Invoice::withTrashed() @@ -561,35 +561,35 @@ class TemplateTest extends TestCase ->orderBy('date', 'ASC') ->cursor(); - $invoices->each(function ($i){ + $invoices->each(function ($i) { - $rand = [1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,24,25,32,49,50]; + $rand = [1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,24,25,32,49,50]; - $i->payments()->each(function ($p) use ($rand){ - shuffle($rand); - $p->type_id = $rand[0]; - $p->save(); + $i->payments()->each(function ($p) use ($rand) { + shuffle($rand); + $p->type_id = $rand[0]; + $p->save(); - }); }); + }); - $design_model = Design::find(2); + $design_model = Design::find(2); - $replicated_design = $design_model->replicate(); - $replicated_design->company_id = $this->company->id; - $replicated_design->user_id = $this->user->id; - $design = $replicated_design->design; - $design->body .= $this->payments_body; - $replicated_design->design = $design; - $replicated_design->is_custom = true; - $replicated_design->is_template =true; - $replicated_design->entities = 'client'; - $replicated_design->save(); + $replicated_design = $design_model->replicate(); + $replicated_design->company_id = $this->company->id; + $replicated_design->user_id = $this->user->id; + $design = $replicated_design->design; + $design->body .= $this->payments_body; + $replicated_design->design = $design; + $replicated_design->is_custom = true; + $replicated_design->is_template =true; + $replicated_design->entities = 'client'; + $replicated_design->save(); - $data['invoices'] = $invoices; - $ts = $replicated_design->service()->build($data); + $data['invoices'] = $invoices; + $ts = $replicated_design->service()->build($data); - $this->assertNotNull($ts->getHtml()); + $this->assertNotNull($ts->getHtml()); } @@ -764,15 +764,15 @@ class TemplateTest extends TestCase $design->user_id = $this->invoice->user_id; $design->company_id = $this->invoice->company_id; - $design_object = new \stdClass; - $design_object->includes = ''; - $design_object->header = ''; - $design_object->body = $this->body; - $design_object->product = ''; - $design_object->task = ''; - $design_object->footer = ''; + $design_object = new \stdClass; + $design_object->includes = ''; + $design_object->header = ''; + $design_object->body = $this->body; + $design_object->product = ''; + $design_object->task = ''; + $design_object->footer = ''; - $design->design = $design_object; + $design->design = $design_object; $design->save(); @@ -827,4 +827,4 @@ class TemplateTest extends TestCase nlog("Twig Solo Gen Time: ". $end - $start); } -} \ No newline at end of file +} diff --git a/tests/Feature/UpdatePaymentTest.php b/tests/Feature/UpdatePaymentTest.php index 9b7054b7f563..603416ef1238 100644 --- a/tests/Feature/UpdatePaymentTest.php +++ b/tests/Feature/UpdatePaymentTest.php @@ -11,18 +11,17 @@ namespace Tests\Feature; -use Carbon\Carbon; -use Tests\TestCase; -use App\Models\Client; -use Tests\MockAccountData; use App\Factory\InvoiceFactory; -use App\Utils\Traits\MakesHash; use App\Helpers\Invoice\InvoiceSum; +use App\Models\Client; +use App\Utils\Traits\MakesHash; +use Carbon\Carbon; +use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Routing\Middleware\ThrottleRequests; use Illuminate\Support\Facades\Session; use Illuminate\Validation\ValidationException; -use Illuminate\Foundation\Testing\WithoutEvents; -use Illuminate\Routing\Middleware\ThrottleRequests; -use Illuminate\Foundation\Testing\DatabaseTransactions; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -60,7 +59,7 @@ class UpdatePaymentTest extends TestCase $this->assertNotNull($payment); - $payment->paymentables()->each(function ($pivot){ + $payment->paymentables()->each(function ($pivot) { $this->assertTrue(Carbon::createFromTimestamp($pivot->created_at)->isToday()); }); diff --git a/tests/Feature/UserTest.php b/tests/Feature/UserTest.php index b030e4b3bf53..180a1fef8706 100644 --- a/tests/Feature/UserTest.php +++ b/tests/Feature/UserTest.php @@ -11,21 +11,21 @@ namespace Tests\Feature; -use Tests\TestCase; -use App\Models\User; -use App\Models\Account; -use App\Models\Company; -use Tests\MockAccountData; -use App\Models\CompanyUser; -use App\Models\CompanyToken; use App\DataMapper\CompanySettings; use App\Factory\CompanyUserFactory; -use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Facades\Session; use App\Http\Middleware\PasswordProtection; -use Illuminate\Validation\ValidationException; -use Illuminate\Routing\Middleware\ThrottleRequests; +use App\Models\Account; +use App\Models\Company; +use App\Models\CompanyToken; +use App\Models\CompanyUser; +use App\Models\User; +use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Routing\Middleware\ThrottleRequests; +use Illuminate\Support\Facades\Session; +use Illuminate\Validation\ValidationException; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -284,7 +284,7 @@ class UserTest extends TestCase public function testDisconnectUserOauthMailer() { - $user = + $user = User::factory()->create([ 'account_id' => $this->account->id, 'email' => $this->faker->safeEmail(), diff --git a/tests/Feature/VendorApiTest.php b/tests/Feature/VendorApiTest.php index f42178a26a10..386a691e9b5f 100644 --- a/tests/Feature/VendorApiTest.php +++ b/tests/Feature/VendorApiTest.php @@ -11,16 +11,16 @@ namespace Tests\Feature; -use Tests\TestCase; -use App\Utils\Ninja; -use Tests\MockAccountData; -use App\Utils\Traits\MakesHash; -use Illuminate\Support\Facades\Event; -use Illuminate\Database\Eloquent\Model; -use Illuminate\Support\Facades\Session; use App\Events\Vendor\VendorContactLoggedIn; -use Illuminate\Validation\ValidationException; +use App\Utils\Ninja; +use App\Utils\Traits\MakesHash; +use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Support\Facades\Event; +use Illuminate\Support\Facades\Session; +use Illuminate\Validation\ValidationException; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -63,7 +63,7 @@ class VendorApiTest extends TestCase $this->assertEquals('hewwo', $arr['data']['name']); $this->assertEquals(1, count($arr['data']['contacts'])); - } + } public function testVendorLoggedInEvents() { @@ -111,7 +111,7 @@ class VendorApiTest extends TestCase } public function testVendorLocaleEnCompanyFallback() - { + { $settings = $this->company->settings; $settings->language_id = '2'; diff --git a/tests/Feature/WebhookAPITest.php b/tests/Feature/WebhookAPITest.php index 2d62be234cab..4ca7a1d659c3 100644 --- a/tests/Feature/WebhookAPITest.php +++ b/tests/Feature/WebhookAPITest.php @@ -11,7 +11,6 @@ namespace Tests\Feature; -use App\Jobs\Util\WebhookSingle; use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Testing\DatabaseTransactions; @@ -49,33 +48,33 @@ class WebhookAPITest extends TestCase public function testWebhookRetry() { - $data = [ - 'target_url' => 'http://hook.com', - 'event_id' => 1, //create client - 'format' => 'JSON', - 'headers' => [] - ]; + $data = [ + 'target_url' => 'http://hook.com', + 'event_id' => 1, //create client + 'format' => 'JSON', + 'headers' => [] + ]; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson("/api/v1/webhooks", $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson("/api/v1/webhooks", $data); - $response->assertStatus(200); + $response->assertStatus(200); - $arr = $response->json(); + $arr = $response->json(); - $data = [ - 'entity' => 'client', - 'entity_id' => $this->client->hashed_id, - ]; + $data = [ + 'entity' => 'client', + 'entity_id' => $this->client->hashed_id, + ]; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson("/api/v1/webhooks/".$arr['data']['id']."/retry", $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson("/api/v1/webhooks/".$arr['data']['id']."/retry", $data); - $response->assertStatus(200); + $response->assertStatus(200); } diff --git a/tests/Integration/CompanyLedgerTest.php b/tests/Integration/CompanyLedgerTest.php index 09ef9929590c..b64d8e33e184 100644 --- a/tests/Integration/CompanyLedgerTest.php +++ b/tests/Integration/CompanyLedgerTest.php @@ -11,24 +11,24 @@ namespace Tests\Integration; -use Tests\TestCase; -use App\Models\User; -use App\Models\Client; +use App\DataMapper\CompanySettings; +use App\DataMapper\InvoiceItem; +use App\Factory\CompanyUserFactory; +use App\Jobs\Ledger\UpdateLedger; use App\Models\Account; +use App\Models\Client; +use App\Models\ClientContact; use App\Models\Company; +use App\Models\CompanyLedger; +use App\Models\CompanyToken; use App\Models\Invoice; use App\Models\Payment; -use App\Models\CompanyToken; -use App\Models\ClientContact; -use App\Models\CompanyLedger; -use App\DataMapper\InvoiceItem; +use App\Models\User; use App\Utils\Traits\MakesHash; -use App\Jobs\Ledger\UpdateLedger; -use App\DataMapper\CompanySettings; -use App\Factory\CompanyUserFactory; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\Hash; use Illuminate\Validation\ValidationException; -use Illuminate\Foundation\Testing\DatabaseTransactions; +use Tests\TestCase; /** @test*/ class CompanyLedgerTest extends TestCase diff --git a/tests/Integration/DTO/AccountSummaryTest.php b/tests/Integration/DTO/AccountSummaryTest.php index d42046920369..eb1f92aeb198 100644 --- a/tests/Integration/DTO/AccountSummaryTest.php +++ b/tests/Integration/DTO/AccountSummaryTest.php @@ -141,4 +141,4 @@ class AccountSummaryTest extends TestCase $this->assertEquals($dto->id, 19315); } -} \ No newline at end of file +} diff --git a/tests/Integration/EventTest.php b/tests/Integration/EventTest.php index e26560691042..3bcbbaff5313 100644 --- a/tests/Integration/EventTest.php +++ b/tests/Integration/EventTest.php @@ -11,79 +11,79 @@ namespace Tests\Integration; -use Tests\TestCase; -use App\Models\Quote; -use App\Models\Invoice; -use Tests\MockAccountData; -use App\Models\PurchaseOrder; -use App\Utils\Traits\MakesHash; -use App\Events\Task\TaskWasCreated; -use App\Events\Task\TaskWasDeleted; -use App\Events\Task\TaskWasUpdated; -use App\Events\User\UserWasCreated; -use App\Events\User\UserWasDeleted; -use App\Events\User\UserWasUpdated; -use App\Events\Task\TaskWasArchived; -use App\Events\Task\TaskWasRestored; -use App\Events\User\UserWasArchived; -use App\Events\User\UserWasRestored; -use App\Events\Quote\QuoteWasCreated; -use App\Events\Quote\QuoteWasDeleted; -use App\Events\Quote\QuoteWasUpdated; -use Illuminate\Support\Facades\Event; -use App\Events\Quote\QuoteWasApproved; -use App\Events\Quote\QuoteWasArchived; -use App\Events\Quote\QuoteWasRestored; +use App\Events\Client\ClientWasArchived; use App\Events\Client\ClientWasCreated; use App\Events\Client\ClientWasDeleted; +use App\Events\Client\ClientWasRestored; use App\Events\Client\ClientWasUpdated; +use App\Events\Credit\CreditWasArchived; use App\Events\Credit\CreditWasCreated; use App\Events\Credit\CreditWasDeleted; -use App\Events\Credit\CreditWasUpdated; -use App\Events\Vendor\VendorWasCreated; -use App\Events\Vendor\VendorWasDeleted; -use App\Events\Vendor\VendorWasUpdated; -use Illuminate\Database\Eloquent\Model; -use App\Events\Client\ClientWasArchived; -use App\Events\Client\ClientWasRestored; -use App\Events\Credit\CreditWasArchived; use App\Events\Credit\CreditWasRestored; -use App\Events\Vendor\VendorWasArchived; -use App\Events\Vendor\VendorWasRestored; +use App\Events\Credit\CreditWasUpdated; +use App\Events\Expense\ExpenseWasArchived; use App\Events\Expense\ExpenseWasCreated; use App\Events\Expense\ExpenseWasDeleted; +use App\Events\Expense\ExpenseWasRestored; use App\Events\Expense\ExpenseWasUpdated; +use App\Events\Invoice\InvoiceWasArchived; use App\Events\Invoice\InvoiceWasCreated; use App\Events\Invoice\InvoiceWasDeleted; +use App\Events\Invoice\InvoiceWasRestored; use App\Events\Invoice\InvoiceWasUpdated; +use App\Events\Payment\PaymentWasArchived; use App\Events\Payment\PaymentWasCreated; use App\Events\Payment\PaymentWasDeleted; -use App\Events\Payment\PaymentWasUpdated; -use App\Events\Expense\ExpenseWasArchived; -use App\Events\Expense\ExpenseWasRestored; -use App\Events\Invoice\InvoiceWasArchived; -use App\Events\Invoice\InvoiceWasRestored; -use App\Events\Payment\PaymentWasArchived; use App\Events\Payment\PaymentWasRestored; -use App\Http\Middleware\PasswordProtection; -use Illuminate\Validation\ValidationException; -use App\Events\Subscription\SubscriptionWasCreated; -use App\Events\Subscription\SubscriptionWasDeleted; -use App\Events\Subscription\SubscriptionWasUpdated; -use Illuminate\Routing\Middleware\ThrottleRequests; -use App\Events\Subscription\SubscriptionWasArchived; -use App\Events\Subscription\SubscriptionWasRestored; +use App\Events\Payment\PaymentWasUpdated; +use App\Events\PurchaseOrder\PurchaseOrderWasArchived; use App\Events\PurchaseOrder\PurchaseOrderWasCreated; use App\Events\PurchaseOrder\PurchaseOrderWasDeleted; -use App\Events\PurchaseOrder\PurchaseOrderWasUpdated; -use App\Events\PurchaseOrder\PurchaseOrderWasArchived; use App\Events\PurchaseOrder\PurchaseOrderWasRestored; -use Illuminate\Foundation\Testing\DatabaseTransactions; +use App\Events\PurchaseOrder\PurchaseOrderWasUpdated; +use App\Events\Quote\QuoteWasApproved; +use App\Events\Quote\QuoteWasArchived; +use App\Events\Quote\QuoteWasCreated; +use App\Events\Quote\QuoteWasDeleted; +use App\Events\Quote\QuoteWasRestored; +use App\Events\Quote\QuoteWasUpdated; +use App\Events\RecurringInvoice\RecurringInvoiceWasArchived; use App\Events\RecurringInvoice\RecurringInvoiceWasCreated; use App\Events\RecurringInvoice\RecurringInvoiceWasDeleted; -use App\Events\RecurringInvoice\RecurringInvoiceWasUpdated; -use App\Events\RecurringInvoice\RecurringInvoiceWasArchived; use App\Events\RecurringInvoice\RecurringInvoiceWasRestored; +use App\Events\RecurringInvoice\RecurringInvoiceWasUpdated; +use App\Events\Subscription\SubscriptionWasArchived; +use App\Events\Subscription\SubscriptionWasCreated; +use App\Events\Subscription\SubscriptionWasDeleted; +use App\Events\Subscription\SubscriptionWasRestored; +use App\Events\Subscription\SubscriptionWasUpdated; +use App\Events\Task\TaskWasArchived; +use App\Events\Task\TaskWasCreated; +use App\Events\Task\TaskWasDeleted; +use App\Events\Task\TaskWasRestored; +use App\Events\Task\TaskWasUpdated; +use App\Events\User\UserWasArchived; +use App\Events\User\UserWasCreated; +use App\Events\User\UserWasDeleted; +use App\Events\User\UserWasRestored; +use App\Events\User\UserWasUpdated; +use App\Events\Vendor\VendorWasArchived; +use App\Events\Vendor\VendorWasCreated; +use App\Events\Vendor\VendorWasDeleted; +use App\Events\Vendor\VendorWasRestored; +use App\Events\Vendor\VendorWasUpdated; +use App\Http\Middleware\PasswordProtection; +use App\Models\Invoice; +use App\Models\PurchaseOrder; +use App\Models\Quote; +use App\Utils\Traits\MakesHash; +use Illuminate\Database\Eloquent\Model; +use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Routing\Middleware\ThrottleRequests; +use Illuminate\Support\Facades\Event; +use Illuminate\Validation\ValidationException; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test diff --git a/tests/Integration/FileUploadValidationTest.php b/tests/Integration/FileUploadValidationTest.php index 68cd436739ec..8ffb69b816fe 100644 --- a/tests/Integration/FileUploadValidationTest.php +++ b/tests/Integration/FileUploadValidationTest.php @@ -11,7 +11,6 @@ namespace Tests\Integration; -use App\Models\Company; use App\Utils\Traits\MakesHash; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Http\UploadedFile; @@ -148,4 +147,4 @@ class FileUploadValidationTest extends TestCase } -} \ No newline at end of file +} diff --git a/tests/Integration/UpdateCompanyUserTest.php b/tests/Integration/UpdateCompanyUserTest.php index 0f9abb8cf59c..4515f2854169 100644 --- a/tests/Integration/UpdateCompanyUserTest.php +++ b/tests/Integration/UpdateCompanyUserTest.php @@ -47,7 +47,7 @@ class UpdateCompanyUserTest extends TestCase 'react_settings' => [ 'show_pdf_preview' => true, 'react_notification_link' => false - ], + ], ]; $response = null; diff --git a/tests/MockAccountData.php b/tests/MockAccountData.php index 25eef773c06a..703b008e356f 100644 --- a/tests/MockAccountData.php +++ b/tests/MockAccountData.php @@ -11,58 +11,58 @@ namespace Tests; -use App\Models\Task; -use App\Models\User; -use App\Models\Quote; -use App\Models\Client; -use App\Models\Credit; -use App\Models\Vendor; -use App\Models\Account; -use App\Models\Company; -use App\Models\Expense; -use App\Models\Payment; -use App\Models\Product; -use App\Models\Project; -use App\Models\TaxRate; -use App\Models\Scheduler; -use App\Models\TaskStatus; -use App\Utils\TruthSource; -use App\Models\CompanyToken; -use App\Models\GroupSetting; -use App\Models\ClientContact; -use App\Models\VendorContact; -use App\Factory\CreditFactory; -use App\Models\CompanyGateway; -use App\Models\RecurringQuote; -use Illuminate\Support\Carbon; -use App\Factory\InvoiceFactory; -use App\Models\BankIntegration; -use App\Models\BankTransaction; -use App\Models\ExpenseCategory; -use App\Models\QuoteInvitation; -use App\Utils\Traits\MakesHash; -use App\Models\CreditInvitation; -use App\Models\RecurringExpense; -use App\Models\RecurringInvoice; -use App\Models\InvoiceInvitation; +use App\DataMapper\ClientRegistrationFields; use App\DataMapper\ClientSettings; use App\DataMapper\CompanySettings; use App\Factory\CompanyUserFactory; -use App\Factory\InvoiceItemFactory; -use App\Helpers\Invoice\InvoiceSum; -use App\Models\BankTransactionRule; -use Illuminate\Support\Facades\Hash; -use App\Factory\PurchaseOrderFactory; -use Illuminate\Support\Facades\Cache; -use App\Utils\Traits\GeneratesCounter; -use Illuminate\Support\Facades\Schema; -use App\Models\PurchaseOrderInvitation; -use Illuminate\Support\Facades\Artisan; -use Illuminate\Support\Facades\Storage; +use App\Factory\CreditFactory; +use App\Factory\InvoiceFactory; use App\Factory\InvoiceInvitationFactory; -use App\DataMapper\ClientRegistrationFields; -use App\Jobs\Company\CreateCompanyTaskStatuses; +use App\Factory\InvoiceItemFactory; use App\Factory\InvoiceToRecurringInvoiceFactory; +use App\Factory\PurchaseOrderFactory; +use App\Helpers\Invoice\InvoiceSum; +use App\Jobs\Company\CreateCompanyTaskStatuses; +use App\Models\Account; +use App\Models\BankIntegration; +use App\Models\BankTransaction; +use App\Models\BankTransactionRule; +use App\Models\Client; +use App\Models\ClientContact; +use App\Models\Company; +use App\Models\CompanyGateway; +use App\Models\CompanyToken; +use App\Models\Credit; +use App\Models\CreditInvitation; +use App\Models\Expense; +use App\Models\ExpenseCategory; +use App\Models\GroupSetting; +use App\Models\InvoiceInvitation; +use App\Models\Payment; +use App\Models\Product; +use App\Models\Project; +use App\Models\PurchaseOrderInvitation; +use App\Models\Quote; +use App\Models\QuoteInvitation; +use App\Models\RecurringExpense; +use App\Models\RecurringInvoice; +use App\Models\RecurringQuote; +use App\Models\Scheduler; +use App\Models\Task; +use App\Models\TaskStatus; +use App\Models\TaxRate; +use App\Models\User; +use App\Models\Vendor; +use App\Models\VendorContact; +use App\Utils\Traits\GeneratesCounter; +use App\Utils\Traits\MakesHash; +use App\Utils\TruthSource; +use Illuminate\Support\Carbon; +use Illuminate\Support\Facades\Artisan; +use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\Hash; +use Illuminate\Support\Facades\Schema; +use Illuminate\Support\Facades\Storage; /** * Class MockAccountData. diff --git a/tests/MockUnitData.php b/tests/MockUnitData.php index fcf7c3e1841f..98368268c981 100644 --- a/tests/MockUnitData.php +++ b/tests/MockUnitData.php @@ -11,16 +11,16 @@ namespace Tests; -use App\Models\User; -use App\Models\Client; -use App\Models\Vendor; -use App\Models\Account; -use App\Models\Company; -use App\Models\CompanyToken; -use App\Models\ClientContact; use App\DataMapper\CompanySettings; use App\DataMapper\DefaultSettings; use App\Factory\InvoiceItemFactory; +use App\Models\Account; +use App\Models\Client; +use App\Models\ClientContact; +use App\Models\Company; +use App\Models\CompanyToken; +use App\Models\User; +use App\Models\Vendor; /** * Class MockUnitData. diff --git a/tests/Pdf/PdfServiceTest.php b/tests/Pdf/PdfServiceTest.php index 625783cef598..1eec2d40ae3e 100644 --- a/tests/Pdf/PdfServiceTest.php +++ b/tests/Pdf/PdfServiceTest.php @@ -14,7 +14,6 @@ namespace Tests\Pdf; use App\Services\Pdf\PdfConfiguration; use App\Services\Pdf\PdfService; -use Beganovich\Snappdf\Snappdf; use Tests\MockAccountData; use Tests\TestCase; @@ -36,8 +35,9 @@ class PdfServiceTest extends TestCase public function testPdfGeneration() { - if(config('ninja.testvars.travis')) + if(config('ninja.testvars.travis')) { $this->markTestSkipped(); + } $invitation = $this->invoice->invitations->first(); @@ -111,4 +111,4 @@ class PdfServiceTest extends TestCase } -} \ No newline at end of file +} diff --git a/tests/Pdf/PdfmockTest.php b/tests/Pdf/PdfmockTest.php index 940969783831..4bbc8c2cd9ed 100644 --- a/tests/Pdf/PdfmockTest.php +++ b/tests/Pdf/PdfmockTest.php @@ -12,20 +12,18 @@ namespace Tests\Pdf; -use Tests\TestCase; -use App\Models\Design; +use App\DataMapper\CompanySettings; use App\Models\Account; use App\Models\Company; use App\Models\Country; -use App\Models\Invoice; use App\Models\Currency; -use Tests\MockAccountData; -use App\Services\Pdf\PdfMock; -use Beganovich\Snappdf\Snappdf; +use App\Models\Design; +use App\Models\Invoice; use App\Services\Pdf\PdfBuilder; -use App\Services\Pdf\PdfService; -use App\DataMapper\CompanySettings; use App\Services\Pdf\PdfConfiguration; +use App\Services\Pdf\PdfMock; +use App\Services\Pdf\PdfService; +use Tests\TestCase; /** * @test @@ -40,7 +38,7 @@ class PdfmockTest extends TestCase } - public function testPdfInstance () + public function testPdfInstance() { $data = [ 'settings' => CompanySettings::defaults(), @@ -52,7 +50,7 @@ class PdfmockTest extends TestCase $account = Account::factory()->make(); $company->setRelation('account', $account); - $entity = (new \App\Services\Pdf\PdfMock($data,$company))->build()->initEntity(); + $entity = (new \App\Services\Pdf\PdfMock($data, $company))->build()->initEntity(); $this->assertInstanceOf(Invoice::class, $entity); $this->assertNotNull($entity->client); diff --git a/tests/TestCase.php b/tests/TestCase.php index df4697ddbf7c..2932d4a69d65 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,7 +2,6 @@ namespace Tests; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\TestCase as BaseTestCase; abstract class TestCase extends BaseTestCase diff --git a/tests/Unit/ArrayFiltersTest.php b/tests/Unit/ArrayFiltersTest.php index 5351ad1c09d7..ca3de4d7ccff 100644 --- a/tests/Unit/ArrayFiltersTest.php +++ b/tests/Unit/ArrayFiltersTest.php @@ -11,10 +11,10 @@ namespace Tests\Unit; -use Tests\TestCase; -use App\Models\User; use App\Models\Design; use App\Models\Payment; +use App\Models\User; +use Tests\TestCase; /** * @test @@ -27,13 +27,13 @@ class ArrayFiltersTest extends TestCase 'baseline' =>[], '5.7.34' => [ Payment::class => [ - 'is_deleted', + 'is_deleted', 'amount', ] ], '5.7.35' => [ Payment::class => [ - 'date', + 'date', 'transaction_reference', ], User::class => [ @@ -47,13 +47,13 @@ class ArrayFiltersTest extends TestCase ], '5.7.36' => [ Payment::class => [ - 'type_id', + 'type_id', 'status_id', ], ], '5.7.37' => [ Payment::class => [ - 'currency_id', + 'currency_id', 'hashed_id', ], ], @@ -83,10 +83,8 @@ class ArrayFiltersTest extends TestCase $index = 0; $version_index = 0; - foreach($this->version_keys as $key => $value) - { - if($version == $key) - { + foreach($this->version_keys as $key => $value) { + if($version == $key) { $version_index = $index; } @@ -104,7 +102,7 @@ class ArrayFiltersTest extends TestCase $this->assertEquals(4, $x->count()); } - public function testPaymentUnsetPropsScenario2() + public function testPaymentUnsetPropsScenario2() { $p = Payment::factory()->make()->toArray(); @@ -116,10 +114,8 @@ class ArrayFiltersTest extends TestCase $index = 0; $version_index = 0; - foreach($this->version_keys as $key => $value) - { - if($version == $key) - { + foreach($this->version_keys as $key => $value) { + if($version == $key) { $version_index = $index; } @@ -133,8 +129,9 @@ class ArrayFiltersTest extends TestCase $filters = collect($this->version_keys) ->map(function ($value, $key) use ($version, &$version_index, &$index) { - if($version == $key) + if($version == $key) { $version_index = $index; + } $index++; return $value; @@ -150,7 +147,7 @@ class ArrayFiltersTest extends TestCase $this->assertEquals(2, $x->count()); } - public function testWhenScenario() + public function testWhenScenario() { $p = Payment::factory()->make()->toArray(); @@ -159,8 +156,9 @@ class ArrayFiltersTest extends TestCase $filters = collect($this->version_keys) ->map(function ($value, $key) use ($version, &$version_index, &$index) { - if($version == $key) + if($version == $key) { $version_index = $index; + } $index++; return $value; @@ -172,7 +170,7 @@ class ArrayFiltersTest extends TestCase $this->assertEquals(3, $filters->count()); } - public function testWhenScenario2() + public function testWhenScenario2() { $p = Payment::factory()->make()->toArray(); @@ -183,7 +181,7 @@ class ArrayFiltersTest extends TestCase ->map(function ($value, $key) use ($version, &$version_index, &$index) { if($version == $key) { $version_index = $index; - nlog("version = {$version_index}"); + nlog("version = {$version_index}"); } $index++; return $value; @@ -203,26 +201,26 @@ class ArrayFiltersTest extends TestCase $index = 0; $version_index = 0; - $filters = collect($this->version_keys) - ->map(function ($value, $key) use (&$version_index, &$index) { - if($this->import_version == $key) { - $version_index = $index; - } + $filters = collect($this->version_keys) + ->map(function ($value, $key) use (&$version_index, &$index) { + if($this->import_version == $key) { + $version_index = $index; + } - $index++; - return $value; + $index++; + return $value; - }) - ->when($version_index == 0, function ($collection){ - return collect([]); - }) - ->when($version_index > 0, function ($collection) use (&$version_index, $class) { - return $collection->slice($version_index)->pluck($class)->filter(); - }); + }) + ->when($version_index == 0, function ($collection) { + return collect([]); + }) + ->when($version_index > 0, function ($collection) use (&$version_index, $class) { + return $collection->slice($version_index)->pluck($class)->filter(); + }); - return collect($obj_array)->diffKeys($filters->flatten()->flip())->toArray(); + return collect($obj_array)->diffKeys($filters->flatten()->flip())->toArray(); - // return $filters->count() > 0 ? collect($obj_array)->diffKeys($filters->flatten()->flip())->toArray() : $obj_array; + // return $filters->count() > 0 ? collect($obj_array)->diffKeys($filters->flatten()->flip())->toArray() : $obj_array; } diff --git a/tests/Unit/CheckDataTest.php b/tests/Unit/CheckDataTest.php index 2de8f3d26416..a81a464b5ebf 100644 --- a/tests/Unit/CheckDataTest.php +++ b/tests/Unit/CheckDataTest.php @@ -11,21 +11,19 @@ namespace Tests\Unit; -use Tests\TestCase; -use App\Models\User; -use App\Utils\Ninja; -use App\Models\Client; +use App\DataMapper\CompanySettings; +use App\Factory\CompanyUserFactory; use App\Models\Account; +use App\Models\Client; +use App\Models\ClientContact; use App\Models\Company; +use App\Models\CompanyToken; use App\Models\Invoice; use App\Models\Payment; use App\Models\Paymentable; -use Illuminate\Support\Str; -use App\Models\CompanyToken; -use App\Models\ClientContact; -use App\DataMapper\CompanySettings; -use App\Factory\CompanyUserFactory; +use App\Models\User; use Illuminate\Routing\Middleware\ThrottleRequests; +use Tests\TestCase; /** * @test @@ -141,7 +139,7 @@ class CheckDataTest extends TestCase }); - Payment::with('paymentables')->cursor()->each(function($payment){ + Payment::with('paymentables')->cursor()->each(function ($payment) { $this->assertNotNull($payment->paymentables()->where('paymentable_type', \App\Models\Credit::class)->get() ->sum(\DB::raw('amount')->getValue(\DB::connection()->getQueryGrammar()))); }); @@ -168,8 +166,8 @@ class CheckDataTest extends TestCase ]); $clients_refactor = \DB::table('clients') - ->leftJoin('client_contacts', function ($join){ - $join->on('client_contacts.client_id', '=', 'clients.id'); + ->leftJoin('client_contacts', function ($join) { + $join->on('client_contacts.client_id', '=', 'clients.id'); }) ->get(['clients.id', \DB::raw('count(client_contacts.id) as contact_count')]); diff --git a/tests/Unit/ClientSettingsTest.php b/tests/Unit/ClientSettingsTest.php index e0200d021628..5d520811d5ae 100644 --- a/tests/Unit/ClientSettingsTest.php +++ b/tests/Unit/ClientSettingsTest.php @@ -73,10 +73,10 @@ class ClientSettingsTest extends TestCase $response = false; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/clients/', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/clients/', $data); $response->assertStatus(200); @@ -232,10 +232,10 @@ class ClientSettingsTest extends TestCase $response = false; - $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), - 'X-API-TOKEN' => $this->token, - ])->postJson('/api/v1/clients/', $data); + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/clients/', $data); $response->assertStatus(422); diff --git a/tests/Unit/CompanyDocumentsTest.php b/tests/Unit/CompanyDocumentsTest.php index 0675197caccf..a4e6e490bdfe 100644 --- a/tests/Unit/CompanyDocumentsTest.php +++ b/tests/Unit/CompanyDocumentsTest.php @@ -66,47 +66,47 @@ class CompanyDocumentsTest extends TestCase // $this->assertFalse(Storage::exists($document->url)); } -// public function testSignedRoutes() -// { + // public function testSignedRoutes() + // { -// $company_key = $this->company->company_key; + // $company_key = $this->company->company_key; -// $original_count = Document::whereCompanyId($this->company->id)->count(); + // $original_count = Document::whereCompanyId($this->company->id)->count(); -// $image = UploadedFile::fake()->image('avatar.jpg'); + // $image = UploadedFile::fake()->image('avatar.jpg'); -// $document = (new UploadFile( -// $image, -// UploadFile::IMAGE, -// $this->user, -// $this->company, -// $this->invoice))->handle(); + // $document = (new UploadFile( + // $image, + // UploadFile::IMAGE, + // $this->user, + // $this->company, + // $this->invoice))->handle(); -// $this->assertNotNull($document); + // $this->assertNotNull($document); -// // $url = \Illuminate\Support\Facades\URL::signedRoute('api.documents.show', ['document' => $document->hashed_id]); -// $url = \Illuminate\Support\Facades\URL::signedRoute('documents.public_download', ['document_hash' => $document->hash]); - -// nlog($url); + // // $url = \Illuminate\Support\Facades\URL::signedRoute('api.documents.show', ['document' => $document->hashed_id]); + // $url = \Illuminate\Support\Facades\URL::signedRoute('documents.public_download', ['document_hash' => $document->hash]); + + // nlog($url); -// $response = $this->withHeaders([ -// 'X-API-SECRET' => config('ninja.api_secret'), -// 'X-API-TOKEN' => $this->token, -// ])->get($url); + // $response = $this->withHeaders([ + // 'X-API-SECRET' => config('ninja.api_secret'), + // 'X-API-TOKEN' => $this->token, + // ])->get($url); -// $content = $response->streamedContent(); -// nlog($content); + // $content = $response->streamedContent(); + // nlog($content); -// $response->assertStatus(200); + // $response->assertStatus(200); -// $arr = $response->json(); + // $arr = $response->json(); -// $this->assertFalse($arr); + // $this->assertFalse($arr); -// } + // } } diff --git a/tests/Unit/DatesTest.php b/tests/Unit/DatesTest.php index 56cda7834226..3f5ca6e2d4dd 100644 --- a/tests/Unit/DatesTest.php +++ b/tests/Unit/DatesTest.php @@ -102,8 +102,9 @@ class DatesTest extends TestCase $fin_year_start = now()->createFromDate(now()->year, $first_month_of_year, 1); - if(now()->lt($fin_year_start)) + if(now()->lt($fin_year_start)) { $fin_year_start->subYear(); + } $fin_year_end = $fin_year_start->copy()->addYear()->subDay(); @@ -122,8 +123,9 @@ class DatesTest extends TestCase $fin_year_start = now()->createFromDate(now()->year, $first_month_of_year, 1); - if(now()->lt($fin_year_start)) + if(now()->lt($fin_year_start)) { $fin_year_start->subYear(); + } $fin_year_end = $fin_year_start->copy()->addYear()->subDay(); @@ -142,8 +144,9 @@ class DatesTest extends TestCase $fin_year_start = now()->createFromDate(now()->year, $first_month_of_year, 1); - if(now()->lt($fin_year_start)) + if(now()->lt($fin_year_start)) { $fin_year_start->subYear(); + } $fin_year_end = $fin_year_start->copy()->addYear()->subDay(); @@ -163,8 +166,9 @@ class DatesTest extends TestCase $fin_year_start = now()->createFromDate(now()->year, $first_month_of_year, 1); - if(now()->lt($fin_year_start)) + if(now()->lt($fin_year_start)) { $fin_year_start->subYear(); + } $fin_year_end = $fin_year_start->copy()->addYear()->subDay(); diff --git a/tests/Unit/EInvoiceTest.php b/tests/Unit/EInvoiceTest.php index 658bedba9828..7f0925d1cdff 100644 --- a/tests/Unit/EInvoiceTest.php +++ b/tests/Unit/EInvoiceTest.php @@ -9,13 +9,13 @@ * @license https://www.elastic.co/licensing/elastic-license */ -use Tests\TestCase; -use Tests\MockAccountData; use App\Jobs\Entity\CreateRawPdf; use App\Jobs\Invoice\CreateEInvoice; use horstoeko\zugferd\ZugferdDocumentReader; -use Illuminate\Routing\Middleware\ThrottleRequests; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Routing\Middleware\ThrottleRequests; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -45,29 +45,29 @@ class EInvoiceTest extends TestCase $this->assertIsString($e_invoice); } - /** - * @throws Exception - */ - public function testValidityofXMLFile() - { - $this->company->e_invoice_type = "EN16931"; - $this->invoice->client->routing_id = 'DE123456789'; - $this->invoice->client->save(); + /** + * @throws Exception + */ + public function testValidityofXMLFile() + { + $this->company->e_invoice_type = "EN16931"; + $this->invoice->client->routing_id = 'DE123456789'; + $this->invoice->client->save(); - $e_invoice = (new CreateEInvoice($this->invoice))->handle(); - $document = ZugferdDocumentReader::readAndGuessFromContent($e_invoice); - $document->getDocumentInformation($documentno, $documenttypecode, $documentdate, $documentcurrency, $taxcurrency, $taxname, $documentlangeuage, $rest); - $this->assertEquals($this->invoice->number, $documentno); - } + $e_invoice = (new CreateEInvoice($this->invoice))->handle(); + $document = ZugferdDocumentReader::readAndGuessFromContent($e_invoice); + $document->getDocumentInformation($documentno, $documenttypecode, $documentdate, $documentcurrency, $taxcurrency, $taxname, $documentlangeuage, $rest); + $this->assertEquals($this->invoice->number, $documentno); + } - /** - * @throws Exception - */ - public function checkEmbededPDFFile() - { - $pdf = (new CreateRawPdf($this->invoice->invitations()->first()))->handle(); - $document = ZugferdDocumentReader::readAndGuessFromContent($pdf); - $document->getDocumentInformation($documentno, $documenttypecode, $documentdate, $documentcurrency, $taxcurrency, $taxname, $documentlangeuage, $rest); - $this->assertEquals($this->invoice->number, $documentno); - } + /** + * @throws Exception + */ + public function checkEmbededPDFFile() + { + $pdf = (new CreateRawPdf($this->invoice->invitations()->first()))->handle(); + $document = ZugferdDocumentReader::readAndGuessFromContent($pdf); + $document->getDocumentInformation($documentno, $documenttypecode, $documentdate, $documentcurrency, $taxcurrency, $taxname, $documentlangeuage, $rest); + $this->assertEquals($this->invoice->number, $documentno); + } } diff --git a/tests/Unit/InvoiceItemTest.php b/tests/Unit/InvoiceItemTest.php index 67fa80662e5e..6b736f4005e5 100644 --- a/tests/Unit/InvoiceItemTest.php +++ b/tests/Unit/InvoiceItemTest.php @@ -11,13 +11,13 @@ namespace Tests\Unit; -use Tests\TestCase; -use Tests\MockAccountData; use App\DataMapper\InvoiceItem; use App\Factory\InvoiceFactory; use App\Factory\InvoiceItemFactory; use App\Helpers\Invoice\InvoiceItemSum; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test diff --git a/tests/Unit/InvoiceTest.php b/tests/Unit/InvoiceTest.php index 5becdabb8055..1a60d8f2ec29 100644 --- a/tests/Unit/InvoiceTest.php +++ b/tests/Unit/InvoiceTest.php @@ -11,15 +11,15 @@ namespace Tests\Unit; -use Tests\TestCase; -use App\Models\Invoice; -use Tests\MockAccountData; use App\DataMapper\InvoiceItem; use App\Factory\InvoiceFactory; use App\Factory\InvoiceItemFactory; use App\Helpers\Invoice\InvoiceSum; use App\Helpers\Invoice\InvoiceSumInclusive; +use App\Models\Invoice; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -55,7 +55,7 @@ class InvoiceTest extends TestCase { $item = InvoiceItemFactory::create(); $item->quantity = 1; - $item->cost = 50; + $item->cost = 50; $line_items[] = $item; $this->invoice->partial = 5; diff --git a/tests/Unit/LateFeeTest.php b/tests/Unit/LateFeeTest.php index b89fa0ff13d5..718592a7a19d 100644 --- a/tests/Unit/LateFeeTest.php +++ b/tests/Unit/LateFeeTest.php @@ -11,20 +11,19 @@ namespace Tests\Unit; -use Tests\TestCase; -use App\Models\User; -use App\Models\Client; +use App\DataMapper\CompanySettings; +use App\DataMapper\InvoiceItem; +use App\Factory\ClientGatewayTokenFactory; +use App\Factory\InvoiceItemFactory; +use App\Jobs\Util\ReminderJob; use App\Models\Account; +use App\Models\Client; use App\Models\Company; use App\Models\Invoice; -use Tests\MockAccountData; -use App\Jobs\Util\ReminderJob; -use App\DataMapper\InvoiceItem; -use App\DataMapper\FeesAndLimits; -use App\DataMapper\CompanySettings; -use App\Factory\InvoiceItemFactory; -use App\Factory\ClientGatewayTokenFactory; +use App\Models\User; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -134,7 +133,7 @@ class LateFeeTest extends TestCase 'discount' => 0, ]); - $i->each(function($invoice){ + $i->each(function ($invoice) { $this->assertGreaterThan(1, count($invoice->line_items)); }); @@ -153,7 +152,7 @@ class LateFeeTest extends TestCase $invoices = $i->map(function ($invoice) { - $line_items = $invoice->line_items; + $line_items = $invoice->line_items; $item = new InvoiceItem; $item->type_id = '3'; @@ -176,7 +175,7 @@ class LateFeeTest extends TestCase return $invoice; }); - $invoices = Invoice::whereIn('id', $ids)->cursor()->map(function ($invoice){ + $invoices = Invoice::whereIn('id', $ids)->cursor()->map(function ($invoice) { $this->assertGreaterThan(0, count($invoice->line_items)); $invoice->service()->removeUnpaidGatewayFees(); diff --git a/tests/Unit/PasswordTimeoutTest.php b/tests/Unit/PasswordTimeoutTest.php index fc3e13e081e1..0a899258c127 100644 --- a/tests/Unit/PasswordTimeoutTest.php +++ b/tests/Unit/PasswordTimeoutTest.php @@ -11,10 +11,10 @@ namespace Tests\Unit; -use Tests\TestCase; -use Tests\MockAccountData; -use Illuminate\Support\Facades\Cache; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Support\Facades\Cache; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test diff --git a/tests/Unit/PaymentTypeTest.php b/tests/Unit/PaymentTypeTest.php index 326e972627ad..bbe01f0175c0 100644 --- a/tests/Unit/PaymentTypeTest.php +++ b/tests/Unit/PaymentTypeTest.php @@ -11,9 +11,9 @@ namespace Tests\Unit; -use Tests\TestCase; use App\Models\PaymentType; use Illuminate\Support\Facades\Lang; +use Tests\TestCase; /** * @test @@ -32,8 +32,7 @@ class PaymentTypeTest extends TestCase { $payment_type_class = new PaymentType; - foreach($payment_type_class->type_names as $type) - { + foreach($payment_type_class->type_names as $type) { $this->assertTrue(Lang::has("texts.{$type}")); } } diff --git a/tests/Unit/RecurringDatesTest.php b/tests/Unit/RecurringDatesTest.php index e4c89c4b0415..189e2c35538b 100644 --- a/tests/Unit/RecurringDatesTest.php +++ b/tests/Unit/RecurringDatesTest.php @@ -11,21 +11,20 @@ namespace Tests\Unit; -use Tests\TestCase; -use App\Models\User; -use App\Models\Client; -use App\Models\Account; -use App\Models\Company; -use Tests\MockAccountData; -use App\Models\ClientContact; -use Illuminate\Support\Carbon; -use App\Utils\Traits\MakesHash; -use App\Models\RecurringInvoice; use App\DataMapper\CompanySettings; use App\DataMapper\DefaultSettings; use App\Factory\RecurringInvoiceFactory; -use App\Factory\InvoiceToRecurringInvoiceFactory; +use App\Models\Account; +use App\Models\Client; +use App\Models\ClientContact; +use App\Models\Company; +use App\Models\RecurringInvoice; +use App\Models\User; +use App\Utils\Traits\MakesHash; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Support\Carbon; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test @@ -100,8 +99,8 @@ class RecurringDatesTest extends TestCase ]); $recurring_invoice = RecurringInvoice::factory()->create([ - 'user_id' => $user->id, - 'company_id' => $company->id, + 'user_id' => $user->id, + 'company_id' => $company->id, 'client_id' => $client->id, 'frequency_id' => RecurringInvoice::FREQUENCY_DAILY, 'next_send_date' => now()->format('Y-m-d'), @@ -196,8 +195,8 @@ class RecurringDatesTest extends TestCase $recurring_invoice = RecurringInvoice::factory()->create([ - 'user_id' => $user->id, - 'company_id' => $company->id, + 'user_id' => $user->id, + 'company_id' => $company->id, 'client_id' => $client->id, 'frequency_id' => RecurringInvoice::FREQUENCY_DAILY, 'next_send_date' => now()->format('Y-m-d'), @@ -281,8 +280,8 @@ class RecurringDatesTest extends TestCase $recurring_invoice = RecurringInvoice::factory()->create([ - 'user_id' => $user->id, - 'company_id' => $company->id, + 'user_id' => $user->id, + 'company_id' => $company->id, 'client_id' => $client->id, 'frequency_id' => RecurringInvoice::FREQUENCY_DAILY, 'next_send_date' => now()->format('Y-m-d'), @@ -394,7 +393,7 @@ class RecurringDatesTest extends TestCase public function testDailyFrequencyCalc2() { - $account = Account::factory()->create(); + $account = Account::factory()->create(); $settings = CompanySettings::defaults(); $settings->entity_send_time = '23'; diff --git a/tests/Unit/RecurringExpenseCloneTest.php b/tests/Unit/RecurringExpenseCloneTest.php index 52487601036d..3c6d589d4297 100644 --- a/tests/Unit/RecurringExpenseCloneTest.php +++ b/tests/Unit/RecurringExpenseCloneTest.php @@ -11,14 +11,14 @@ namespace Tests\Unit; -use Tests\TestCase; -use App\Models\User; -use App\Models\Client; -use App\Models\Account; -use App\Models\Company; -use App\Utils\Traits\AppSetup; use App\Factory\RecurringExpenseFactory; use App\Factory\RecurringExpenseToExpenseFactory; +use App\Models\Account; +use App\Models\Client; +use App\Models\Company; +use App\Models\User; +use App\Utils\Traits\AppSetup; +use Tests\TestCase; /** * @test diff --git a/tests/Unit/Tax/EuTaxTest.php b/tests/Unit/Tax/EuTaxTest.php index 309d4a02933c..1c822d67e6b4 100644 --- a/tests/Unit/Tax/EuTaxTest.php +++ b/tests/Unit/Tax/EuTaxTest.php @@ -887,7 +887,7 @@ class EuTaxTest extends TestCase } - //tests with valid vat. + //tests with valid vat. public function testDeToEUWithValidVat() { $settings = CompanySettings::defaults(); diff --git a/tests/Unit/Tax/SumTaxTest.php b/tests/Unit/Tax/SumTaxTest.php index b30b3d1ca8cf..e064ffb856c9 100644 --- a/tests/Unit/Tax/SumTaxTest.php +++ b/tests/Unit/Tax/SumTaxTest.php @@ -11,23 +11,23 @@ namespace Tests\Unit\Tax; -use Tests\TestCase; +use App\DataMapper\CompanySettings; +use App\DataMapper\InvoiceItem; +use App\DataMapper\Tax\TaxData; +use App\DataMapper\Tax\TaxModel; +use App\DataMapper\Tax\ZipTax\Response; +use App\Factory\InvoiceFactory; use App\Models\Client; use App\Models\Company; use App\Models\Invoice; use App\Models\Product; -use Tests\MockAccountData; -use App\DataMapper\InvoiceItem; -use App\DataMapper\Tax\TaxData; -use App\Factory\InvoiceFactory; -use App\DataMapper\Tax\TaxModel; -use App\DataMapper\CompanySettings; -use App\DataMapper\Tax\ZipTax\Response; -use Illuminate\Routing\Middleware\ThrottleRequests; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Routing\Middleware\ThrottleRequests; +use Tests\MockAccountData; +use Tests\TestCase; /** - * @test + * @test */ class SumTaxTest extends TestCase { @@ -86,7 +86,7 @@ class SumTaxTest extends TestCase $this->makeTestData(); - $this->response = new Response($this->resp); + $this->response = new Response($this->resp); } @@ -107,7 +107,7 @@ class SumTaxTest extends TestCase 'settings' => $settings, 'tax_data' => $tax_data, 'calculate_taxes' => false, - 'origin_tax_data' => new Response($this->resp), + 'origin_tax_data' => new Response($this->resp), ]); $client = Client::factory()->create([ @@ -152,7 +152,7 @@ class SumTaxTest extends TestCase { $settings = CompanySettings::defaults(); - $settings->country_id = '840'; + $settings->country_id = '840'; $settings->currency_id = '1'; $tax_data = new TaxModel(); @@ -264,7 +264,7 @@ class SumTaxTest extends TestCase public function testSumOfTaxes() { - $sum = + $sum = $this->response->stateSalesTax + $this->response->citySalesTax + $this->response->countySalesTax + @@ -273,4 +273,4 @@ class SumTaxTest extends TestCase $this->assertEquals(0.0875, $sum); } -} \ No newline at end of file +} diff --git a/tests/Unit/Tax/TaxConfigTest.php b/tests/Unit/Tax/TaxConfigTest.php index 459c36240391..ae6cea8c7806 100644 --- a/tests/Unit/Tax/TaxConfigTest.php +++ b/tests/Unit/Tax/TaxConfigTest.php @@ -12,12 +12,12 @@ namespace Tests\Unit\Tax; use App\DataProviders\USStates; -use Tests\TestCase; use App\Models\Client; -use Tests\MockAccountData; use App\Services\Tax\Providers\TaxProvider; -use Illuminate\Routing\Middleware\ThrottleRequests; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Routing\Middleware\ThrottleRequests; +use Tests\MockAccountData; +use Tests\TestCase; /** * @test App\Services\Tax\Providers\EuTax @@ -39,8 +39,9 @@ class TaxConfigTest extends TestCase $this->makeTestData(); - if(!config('services.tax.zip_tax.key')) + if(!config('services.tax.zip_tax.key')) { $this->markTestSkipped('No API keys to test with.'); + } } public TaxProvider $tp; @@ -72,4 +73,4 @@ class TaxConfigTest extends TestCase } -} \ No newline at end of file +} diff --git a/tests/Unit/Tax/UsTaxTest.php b/tests/Unit/Tax/UsTaxTest.php index 15a0c10f1d5a..f0bbc994f514 100644 --- a/tests/Unit/Tax/UsTaxTest.php +++ b/tests/Unit/Tax/UsTaxTest.php @@ -11,21 +11,20 @@ namespace Tests\Unit\Tax; -use Tests\TestCase; +use App\DataMapper\CompanySettings; +use App\DataMapper\Tax\TaxModel; +use App\DataMapper\Tax\ZipTax\Response; use App\Models\Client; use App\Models\Company; use App\Models\Invoice; use App\Models\Product; -use Tests\MockAccountData; -use App\DataMapper\Tax\DE\Rule; -use App\DataMapper\Tax\TaxModel; -use App\DataMapper\CompanySettings; -use App\DataMapper\Tax\ZipTax\Response; -use Illuminate\Routing\Middleware\ThrottleRequests; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Routing\Middleware\ThrottleRequests; +use Tests\MockAccountData; +use Tests\TestCase; /** - * @test + * @test */ class UsTaxTest extends TestCase { @@ -880,209 +879,209 @@ class UsTaxTest extends TestCase public function testForeignTaxesEnabledWithExemptProduct() { - $settings = CompanySettings::defaults(); - $settings->country_id = '840'; // germany + $settings = CompanySettings::defaults(); + $settings->country_id = '840'; // germany - $tax_data = new TaxModel(); - $tax_data->seller_subregion = 'CA'; - $tax_data->regions->US->has_sales_above_threshold = true; - $tax_data->regions->US->tax_all_subregions = true; - $tax_data->regions->EU->has_sales_above_threshold = true; - $tax_data->regions->EU->tax_all_subregions = true; - $tax_data->regions->EU->subregions->DE->tax_rate = 21; + $tax_data = new TaxModel(); + $tax_data->seller_subregion = 'CA'; + $tax_data->regions->US->has_sales_above_threshold = true; + $tax_data->regions->US->tax_all_subregions = true; + $tax_data->regions->EU->has_sales_above_threshold = true; + $tax_data->regions->EU->tax_all_subregions = true; + $tax_data->regions->EU->subregions->DE->tax_rate = 21; - $company = Company::factory()->create([ - 'account_id' => $this->account->id, - 'settings' => $settings, - 'tax_data' => $tax_data, - 'calculate_taxes' => true, - 'origin_tax_data' => new Response($this->mock_response), - ]); + $company = Company::factory()->create([ + 'account_id' => $this->account->id, + 'settings' => $settings, + 'tax_data' => $tax_data, + 'calculate_taxes' => true, + 'origin_tax_data' => new Response($this->mock_response), + ]); - $client = Client::factory()->create([ - 'user_id' => $this->user->id, - 'company_id' => $company->id, - 'country_id' => 276, - 'shipping_country_id' => 276, - 'has_valid_vat_number' => false, - 'postal_code' => 'xx', - 'is_tax_exempt' => false, - ]); + $client = Client::factory()->create([ + 'user_id' => $this->user->id, + 'company_id' => $company->id, + 'country_id' => 276, + 'shipping_country_id' => 276, + 'has_valid_vat_number' => false, + 'postal_code' => 'xx', + 'is_tax_exempt' => false, + ]); - $invoice = Invoice::factory()->create([ - 'company_id' => $company->id, - 'client_id' => $client->id, - 'status_id' => 1, - 'user_id' => $this->user->id, - 'uses_inclusive_taxes' => false, - 'discount' => 0, - 'line_items' => [ - [ - 'product_key' => 'Test', - 'notes' => 'Test', - 'cost' => 100, - 'quantity' => 1, - 'tax_name1' => '', - 'tax_rate1' => 0, - 'tax_name2' => '', - 'tax_rate2' => 0, - 'tax_name3' => '', - 'tax_rate3' => 0, - 'type_id' => '1', - 'tax_id' => Product::PRODUCT_TYPE_EXEMPT, - ], + $invoice = Invoice::factory()->create([ + 'company_id' => $company->id, + 'client_id' => $client->id, + 'status_id' => 1, + 'user_id' => $this->user->id, + 'uses_inclusive_taxes' => false, + 'discount' => 0, + 'line_items' => [ + [ + 'product_key' => 'Test', + 'notes' => 'Test', + 'cost' => 100, + 'quantity' => 1, + 'tax_name1' => '', + 'tax_rate1' => 0, + 'tax_name2' => '', + 'tax_rate2' => 0, + 'tax_name3' => '', + 'tax_rate3' => 0, + 'type_id' => '1', + 'tax_id' => Product::PRODUCT_TYPE_EXEMPT, ], - 'tax_rate1' => 0, - 'tax_rate2' => 0, - 'tax_rate3' => 0, - 'tax_name1' => '', - 'tax_name2' => '', - 'tax_name3' => '', - 'tax_data' => new Response($this->mock_response), - ]); + ], + 'tax_rate1' => 0, + 'tax_rate2' => 0, + 'tax_rate3' => 0, + 'tax_name1' => '', + 'tax_name2' => '', + 'tax_name3' => '', + 'tax_data' => new Response($this->mock_response), + ]); - $invoice = $invoice->calc()->getInvoice()->service()->markSent()->save(); + $invoice = $invoice->calc()->getInvoice()->service()->markSent()->save(); - $this->assertEquals(100, $invoice->amount); + $this->assertEquals(100, $invoice->amount); } public function testForeignTaxesDisabled() { - $settings = CompanySettings::defaults(); - $settings->country_id = '840'; // germany + $settings = CompanySettings::defaults(); + $settings->country_id = '840'; // germany - $tax_data = new TaxModel(); - $tax_data->seller_subregion = 'CA'; - $tax_data->regions->US->has_sales_above_threshold = true; - $tax_data->regions->US->tax_all_subregions = true; - $tax_data->regions->EU->has_sales_above_threshold = true; - $tax_data->regions->EU->tax_all_subregions = false; - $tax_data->regions->EU->subregions->DE->tax_rate = 21; + $tax_data = new TaxModel(); + $tax_data->seller_subregion = 'CA'; + $tax_data->regions->US->has_sales_above_threshold = true; + $tax_data->regions->US->tax_all_subregions = true; + $tax_data->regions->EU->has_sales_above_threshold = true; + $tax_data->regions->EU->tax_all_subregions = false; + $tax_data->regions->EU->subregions->DE->tax_rate = 21; - $company = Company::factory()->create([ - 'account_id' => $this->account->id, - 'settings' => $settings, - 'tax_data' => $tax_data, - 'calculate_taxes' => true, - 'origin_tax_data' => new Response($this->mock_response), - ]); + $company = Company::factory()->create([ + 'account_id' => $this->account->id, + 'settings' => $settings, + 'tax_data' => $tax_data, + 'calculate_taxes' => true, + 'origin_tax_data' => new Response($this->mock_response), + ]); - $client = Client::factory()->create([ - 'user_id' => $this->user->id, - 'company_id' => $company->id, - 'country_id' => 276, - 'shipping_country_id' => 276, - 'has_valid_vat_number' => false, - 'postal_code' => 'xx', - ]); + $client = Client::factory()->create([ + 'user_id' => $this->user->id, + 'company_id' => $company->id, + 'country_id' => 276, + 'shipping_country_id' => 276, + 'has_valid_vat_number' => false, + 'postal_code' => 'xx', + ]); - $invoice = Invoice::factory()->create([ - 'company_id' => $company->id, - 'client_id' => $client->id, - 'status_id' => 1, - 'user_id' => $this->user->id, - 'uses_inclusive_taxes' => false, - 'discount' => 0, - 'line_items' => [ - [ - 'product_key' => 'Test', - 'notes' => 'Test', - 'cost' => 100, - 'quantity' => 1, - 'tax_name1' => '', - 'tax_rate1' => 0, - 'tax_name2' => '', - 'tax_rate2' => 0, - 'tax_name3' => '', - 'tax_rate3' => 0, - 'type_id' => '1', - 'tax_id' => Product::PRODUCT_TYPE_PHYSICAL, - ], + $invoice = Invoice::factory()->create([ + 'company_id' => $company->id, + 'client_id' => $client->id, + 'status_id' => 1, + 'user_id' => $this->user->id, + 'uses_inclusive_taxes' => false, + 'discount' => 0, + 'line_items' => [ + [ + 'product_key' => 'Test', + 'notes' => 'Test', + 'cost' => 100, + 'quantity' => 1, + 'tax_name1' => '', + 'tax_rate1' => 0, + 'tax_name2' => '', + 'tax_rate2' => 0, + 'tax_name3' => '', + 'tax_rate3' => 0, + 'type_id' => '1', + 'tax_id' => Product::PRODUCT_TYPE_PHYSICAL, ], - 'tax_rate1' => 0, - 'tax_rate2' => 0, - 'tax_rate3' => 0, - 'tax_name1' => '', - 'tax_name2' => '', - 'tax_name3' => '', - 'tax_data' => new Response($this->mock_response), - ]); + ], + 'tax_rate1' => 0, + 'tax_rate2' => 0, + 'tax_rate3' => 0, + 'tax_name1' => '', + 'tax_name2' => '', + 'tax_name3' => '', + 'tax_data' => new Response($this->mock_response), + ]); - $invoice = $invoice->calc()->getInvoice()->service()->markSent()->save(); + $invoice = $invoice->calc()->getInvoice()->service()->markSent()->save(); - $this->assertEquals(100, $invoice->amount); + $this->assertEquals(100, $invoice->amount); } public function testForeignTaxesEnabled() { - $settings = CompanySettings::defaults(); - $settings->country_id = '840'; // germany + $settings = CompanySettings::defaults(); + $settings->country_id = '840'; // germany - $tax_data = new TaxModel(); - $tax_data->seller_subregion = 'CA'; - $tax_data->regions->US->has_sales_above_threshold = true; - $tax_data->regions->US->tax_all_subregions = true; - $tax_data->regions->EU->has_sales_above_threshold = true; - $tax_data->regions->EU->tax_all_subregions = true; - $tax_data->regions->EU->subregions->DE->tax_rate = 21; + $tax_data = new TaxModel(); + $tax_data->seller_subregion = 'CA'; + $tax_data->regions->US->has_sales_above_threshold = true; + $tax_data->regions->US->tax_all_subregions = true; + $tax_data->regions->EU->has_sales_above_threshold = true; + $tax_data->regions->EU->tax_all_subregions = true; + $tax_data->regions->EU->subregions->DE->tax_rate = 21; - $company = Company::factory()->create([ - 'account_id' => $this->account->id, - 'settings' => $settings, - 'tax_data' => $tax_data, - 'calculate_taxes' => true, - 'origin_tax_data' => new Response($this->mock_response), - ]); + $company = Company::factory()->create([ + 'account_id' => $this->account->id, + 'settings' => $settings, + 'tax_data' => $tax_data, + 'calculate_taxes' => true, + 'origin_tax_data' => new Response($this->mock_response), + ]); - $client = Client::factory()->create([ - 'user_id' => $this->user->id, - 'company_id' => $company->id, - 'country_id' => 276, - 'shipping_country_id' => 276, - 'has_valid_vat_number' => false, - 'postal_code' => 'xx', - 'tax_data' => new Response($this->mock_response), - ]); + $client = Client::factory()->create([ + 'user_id' => $this->user->id, + 'company_id' => $company->id, + 'country_id' => 276, + 'shipping_country_id' => 276, + 'has_valid_vat_number' => false, + 'postal_code' => 'xx', + 'tax_data' => new Response($this->mock_response), + ]); - $invoice = Invoice::factory()->create([ - 'company_id' => $company->id, - 'client_id' => $client->id, - 'status_id' => 1, - 'user_id' => $this->user->id, - 'uses_inclusive_taxes' => false, - 'discount' => 0, - 'line_items' => [ - [ - 'product_key' => 'Test', - 'notes' => 'Test', - 'cost' => 100, - 'quantity' => 1, - 'tax_name1' => '', - 'tax_rate1' => 0, - 'tax_name2' => '', - 'tax_rate2' => 0, - 'tax_name3' => '', - 'tax_rate3' => 0, - 'type_id' => '1', - 'tax_id' => Product::PRODUCT_TYPE_PHYSICAL, - ], + $invoice = Invoice::factory()->create([ + 'company_id' => $company->id, + 'client_id' => $client->id, + 'status_id' => 1, + 'user_id' => $this->user->id, + 'uses_inclusive_taxes' => false, + 'discount' => 0, + 'line_items' => [ + [ + 'product_key' => 'Test', + 'notes' => 'Test', + 'cost' => 100, + 'quantity' => 1, + 'tax_name1' => '', + 'tax_rate1' => 0, + 'tax_name2' => '', + 'tax_rate2' => 0, + 'tax_name3' => '', + 'tax_rate3' => 0, + 'type_id' => '1', + 'tax_id' => Product::PRODUCT_TYPE_PHYSICAL, ], - 'tax_rate1' => 0, - 'tax_rate2' => 0, - 'tax_rate3' => 0, - 'tax_name1' => '', - 'tax_name2' => '', - 'tax_name3' => '', - 'tax_data' => new Response($this->mock_response), - ]); + ], + 'tax_rate1' => 0, + 'tax_rate2' => 0, + 'tax_rate3' => 0, + 'tax_name1' => '', + 'tax_name2' => '', + 'tax_name3' => '', + 'tax_data' => new Response($this->mock_response), + ]); - $invoice = $invoice->calc()->getInvoice()->service()->markSent()->save(); + $invoice = $invoice->calc()->getInvoice()->service()->markSent()->save(); - $this->assertEquals(121, $invoice->amount); + $this->assertEquals(121, $invoice->amount); }