diff --git a/app/Casts/EncryptedCast.php b/app/Casts/EncryptedCast.php index 7be926072c3a..a8c11f3ad397 100644 --- a/app/Casts/EncryptedCast.php +++ b/app/Casts/EncryptedCast.php @@ -16,12 +16,12 @@ use Illuminate\Contracts\Database\Eloquent\CastsAttributes; class EncryptedCast implements CastsAttributes { public function get($model, string $key, $value, array $attributes) - { + { return is_string($value) && strlen($value) > 1 ? decrypt($value) : null; } public function set($model, string $key, $value, array $attributes) - { + { return [$key => ! is_null($value) ? encrypt($value) : null]; } } diff --git a/app/Console/Commands/BackupUpdate.php b/app/Console/Commands/BackupUpdate.php index 9a827b68d19a..b6f1cb4f5baf 100644 --- a/app/Console/Commands/BackupUpdate.php +++ b/app/Console/Commands/BackupUpdate.php @@ -11,13 +11,13 @@ namespace App\Console\Commands; -use App\Utils\Ninja; +use App\Libraries\MultiDB; use App\Models\Backup; use App\Models\Client; use App\Models\Company; use App\Models\Document; -use App\Libraries\MultiDB; use App\Models\GroupSetting; +use App\Utils\Ninja; use Illuminate\Console\Command; use Illuminate\Support\Facades\Storage; @@ -56,8 +56,9 @@ class BackupUpdate extends Command { //always return state to first DB - if(Ninja::isSelfHost()) + if(Ninja::isSelfHost()) { return; + } $current_db = config('database.default'); diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index 7c5a3f21bb42..89492f8fe2b8 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -12,38 +12,37 @@ namespace App\Console\Commands; use App; -use Exception; -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\Models\Account; -use App\Models\Company; -use App\Models\Contact; -use App\Models\Invoice; -use App\Models\Payment; -use App\Models\CompanyUser; -use Illuminate\Support\Str; -use App\Models\CompanyToken; -use App\Models\ClientContact; -use App\Models\CompanyLedger; -use App\Models\PurchaseOrder; -use App\Models\VendorContact; -use App\Models\BankTransaction; -use App\Models\QuoteInvitation; -use Illuminate\Console\Command; -use App\Models\CreditInvitation; -use App\Models\RecurringInvoice; -use App\Models\InvoiceInvitation; use App\DataMapper\ClientSettings; -use Illuminate\Support\Facades\DB; -use Illuminate\Support\Facades\Mail; use App\Factory\ClientContactFactory; use App\Factory\VendorContactFactory; use App\Jobs\Company\CreateCompanyToken; +use App\Models\Account; +use App\Models\BankTransaction; +use App\Models\Client; +use App\Models\ClientContact; +use App\Models\Company; +use App\Models\CompanyLedger; +use App\Models\CompanyToken; +use App\Models\CompanyUser; +use App\Models\Contact; +use App\Models\Credit; +use App\Models\CreditInvitation; +use App\Models\Invoice; +use App\Models\InvoiceInvitation; +use App\Models\Payment; +use App\Models\PurchaseOrder; +use App\Models\Quote; +use App\Models\QuoteInvitation; +use App\Models\RecurringInvoice; use App\Models\RecurringInvoiceInvitation; +use App\Models\User; +use App\Models\Vendor; +use App\Models\VendorContact; +use App\Utils\Ninja; +use Illuminate\Console\Command; +use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Mail; +use Illuminate\Support\Str; use Symfony\Component\Console\Input\InputOption; /* @@ -185,8 +184,7 @@ class CheckData extends Command if ($cu->company && $cu->user) { (new CreateCompanyToken($cu->company, $cu->user, 'System'))->handle(); - } - else { + } else { // $cu->forceDelete(); } } @@ -445,7 +443,7 @@ class CheckData extends Command QuoteInvitation::where('deleted_at', "0000-00-00 00:00:00.000000")->withTrashed()->update(['deleted_at' => null]); CreditInvitation::where('deleted_at', "0000-00-00 00:00:00.000000")->withTrashed()->update(['deleted_at' => null]); - InvoiceInvitation::where('sent_date', '0000-00-00 00:00:00')->cursor()->each(function ($ii){ + InvoiceInvitation::where('sent_date', '0000-00-00 00:00:00')->cursor()->each(function ($ii) { $ii->sent_date = null; $ii->saveQuietly(); }); @@ -619,7 +617,7 @@ class CheckData extends Command } $this->logMessage("{$this->wrong_paid_to_dates} clients with incorrect paid to dates"); - } + } private function clientBalanceQuery() { @@ -1028,7 +1026,7 @@ class CheckData extends Command { $this->logMessage("checking bank transactions"); - BankTransaction::with('payment')->withTrashed()->where('invoice_ids', ',,,,,,,,')->cursor()->each(function ($bt){ + BankTransaction::with('payment')->withTrashed()->where('invoice_ids', ',,,,,,,,')->cursor()->each(function ($bt) { if($bt->payment->exists()) { @@ -1052,7 +1050,7 @@ class CheckData extends Command if ($this->option('fix') == 'true') { - $q->cursor()->each(function ($c){ + $q->cursor()->each(function ($c) { $c->send_email = false; $c->saveQuietly(); diff --git a/app/Console/Commands/CreateAccount.php b/app/Console/Commands/CreateAccount.php index d2ff960b2019..d56433d42b32 100644 --- a/app/Console/Commands/CreateAccount.php +++ b/app/Console/Commands/CreateAccount.php @@ -20,7 +20,6 @@ use App\Models\Account; use App\Models\Company; use App\Models\CompanyToken; use App\Models\User; -use App\Repositories\InvoiceRepository; use App\Utils\Traits\GeneratesCounter; use App\Utils\Traits\MakesHash; use Illuminate\Console\Command; diff --git a/app/Console/Commands/CreateSingleAccount.php b/app/Console/Commands/CreateSingleAccount.php index 481ce0ba647b..33196439f736 100644 --- a/app/Console/Commands/CreateSingleAccount.php +++ b/app/Console/Commands/CreateSingleAccount.php @@ -11,52 +11,52 @@ 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\Invoice; use App\Models\Product; use App\Models\Project; -use App\Models\TaxRate; -use App\Libraries\MultiDB; -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\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 { @@ -460,7 +460,7 @@ class CreateSingleAccount extends Command $settings = $client->settings; $settings->currency_id = "1"; -// $settings->use_credits_payment = "always"; + // $settings->use_credits_payment = "always"; $client->settings = $settings; diff --git a/app/Console/Commands/CreateTestData.php b/app/Console/Commands/CreateTestData.php index ca8417573ce7..b882c9af6d32 100644 --- a/app/Console/Commands/CreateTestData.php +++ b/app/Console/Commands/CreateTestData.php @@ -496,7 +496,7 @@ class CreateTestData extends Command $invoice = InvoiceFactory::create($client->company->id, $client->user->id); //stub the company and user_id $invoice->client_id = $client->id; -// $invoice->date = $faker->date(); + // $invoice->date = $faker->date(); $dateable = Carbon::now()->subDays(rand(0, 90)); $invoice->date = $dateable; diff --git a/app/Console/Commands/ImportMigrations.php b/app/Console/Commands/ImportMigrations.php index 9e227c72bd3c..57d25844cb83 100644 --- a/app/Console/Commands/ImportMigrations.php +++ b/app/Console/Commands/ImportMigrations.php @@ -18,7 +18,6 @@ use App\Exceptions\ProcessingMigrationArchiveFailed; use App\Exceptions\ResourceDependencyMissing; use App\Exceptions\ResourceNotAvailableForMigration; use App\Jobs\Util\Import; -use App\Jobs\Util\StartMigration; use App\Mail\MigrationFailed; use App\Models\Account; use App\Models\Company; diff --git a/app/Console/Commands/ReactBuilder.php b/app/Console/Commands/ReactBuilder.php index d56a4565529e..d40a2503236f 100644 --- a/app/Console/Commands/ReactBuilder.php +++ b/app/Console/Commands/ReactBuilder.php @@ -52,8 +52,7 @@ class ReactBuilder extends Command try { $directoryIterator = new \RecursiveDirectoryIterator(public_path('react/v'.config('ninja.app_version').'/'), \RecursiveDirectoryIterator::SKIP_DOTS); - } - catch (\Exception $e) { + } catch (\Exception $e) { $this->error('React files not found'); return; } diff --git a/app/Console/Commands/SendRemindersCron.php b/app/Console/Commands/SendRemindersCron.php index 8328611b836c..ab55404fec2c 100644 --- a/app/Console/Commands/SendRemindersCron.php +++ b/app/Console/Commands/SendRemindersCron.php @@ -174,7 +174,7 @@ class SendRemindersCron extends Command $invoice->calc()->getInvoice()->save(); $invoice->fresh(); // $invoice->service()->deletePdf()->save(); - if ($invoice->client->getSetting('enable_e_invoice')){ + if ($invoice->client->getSetting('enable_e_invoice')) { $invoice->service()->deleteEInvoice()->save(); } diff --git a/app/Console/Commands/SendTestEmails.php b/app/Console/Commands/SendTestEmails.php index 5a113e8f2f58..9895355ac962 100644 --- a/app/Console/Commands/SendTestEmails.php +++ b/app/Console/Commands/SendTestEmails.php @@ -11,17 +11,10 @@ namespace App\Console\Commands; -use Faker\Factory; -use App\Models\User; -use App\Models\Account; -use App\Models\Company; -use App\Mail\TestMailServer; -use Illuminate\Console\Command; -use App\Jobs\Mail\NinjaMailerJob; -use App\DataMapper\CompanySettings; -use App\DataMapper\DefaultSettings; use App\Jobs\Mail\NinjaMailerObject; -use App\Mail\Migration\MaxCompanies; +use App\Mail\TestMailServer; +use App\Models\User; +use Illuminate\Console\Command; use Illuminate\Support\Facades\Mail; class SendTestEmails extends Command diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index c66cdc40e5a9..f67dc4af685b 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -11,29 +11,29 @@ namespace App\Console; -use App\Utils\Ninja; -use App\Models\Account; -use App\Jobs\Ninja\QueueSize; -use App\Jobs\Util\DiskCleanup; -use App\Jobs\Util\ReminderJob; use App\Jobs\Cron\AutoBillCron; -use App\Jobs\Util\VersionCheck; -use App\Jobs\Ninja\TaskScheduler; -use App\Jobs\Util\SchedulerCheck; -use App\Jobs\Ninja\CheckACHStatus; -use App\Jobs\Cron\SubscriptionCron; -use App\Jobs\Ninja\AdjustEmailQuota; -use App\Jobs\Ninja\CompanySizeCheck; -use App\Jobs\Ninja\SystemMaintenance; -use App\Jobs\Quote\QuoteCheckExpired; -use App\Jobs\Util\UpdateExchangeRates; -use App\Jobs\Ninja\BankTransactionSync; use App\Jobs\Cron\RecurringExpensesCron; use App\Jobs\Cron\RecurringInvoicesCron; +use App\Jobs\Cron\SubscriptionCron; use App\Jobs\Cron\UpdateCalculatedFields; -use Illuminate\Console\Scheduling\Schedule; use App\Jobs\Invoice\InvoiceCheckLateWebhook; +use App\Jobs\Ninja\AdjustEmailQuota; +use App\Jobs\Ninja\BankTransactionSync; +use App\Jobs\Ninja\CheckACHStatus; +use App\Jobs\Ninja\CompanySizeCheck; +use App\Jobs\Ninja\QueueSize; +use App\Jobs\Ninja\SystemMaintenance; +use App\Jobs\Ninja\TaskScheduler; +use App\Jobs\Quote\QuoteCheckExpired; use App\Jobs\Subscription\CleanStaleInvoiceOrder; +use App\Jobs\Util\DiskCleanup; +use App\Jobs\Util\ReminderJob; +use App\Jobs\Util\SchedulerCheck; +use App\Jobs\Util\UpdateExchangeRates; +use App\Jobs\Util\VersionCheck; +use App\Models\Account; +use App\Utils\Ninja; +use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; class Kernel extends ConsoleKernel diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index f1cd82c56d4a..814dc4038382 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -497,11 +497,11 @@ class CompanySettings extends BaseSettings 'payment_receipt_design_id' => 'string', 'payment_refund_design_id' => 'string', 'classification' => 'string', - 'enable_e_invoice' => 'bool', + 'enable_e_invoice' => 'bool', 'classification' => 'string', 'default_expense_payment_type_id' => 'string', - 'e_invoice_type' => 'string', - 'mailgun_endpoint' => 'string', + 'e_invoice_type' => 'string', + 'mailgun_endpoint' => 'string', 'client_initiated_payments' => 'bool', 'client_initiated_payments_minimum' => 'float', 'sync_invoice_quote_columns' => 'bool', diff --git a/app/DataMapper/DefaultSettings.php b/app/DataMapper/DefaultSettings.php index 6451370cf620..e87fdf7993d4 100644 --- a/app/DataMapper/DefaultSettings.php +++ b/app/DataMapper/DefaultSettings.php @@ -34,4 +34,4 @@ class DefaultSettings extends BaseSettings ]; } -} \ No newline at end of file +} diff --git a/app/DataMapper/FreeCompanySettings.php b/app/DataMapper/FreeCompanySettings.php index 9866862a96e9..0ffe60f8658a 100644 --- a/app/DataMapper/FreeCompanySettings.php +++ b/app/DataMapper/FreeCompanySettings.php @@ -44,7 +44,7 @@ class FreeCompanySettings extends BaseSettings public $date_format_id = ''; -// public $enabled_item_tax_rates = 0; + // public $enabled_item_tax_rates = 0; public $expense_number_pattern = ''; public $expense_number_counter = 1; diff --git a/app/DataMapper/Settings/SettingsData.php b/app/DataMapper/Settings/SettingsData.php index 4d99cccff18b..2584a565403e 100644 --- a/app/DataMapper/Settings/SettingsData.php +++ b/app/DataMapper/Settings/SettingsData.php @@ -10,7 +10,7 @@ */ namespace App\DataMapper\Settings; -class SettingsData +class SettingsData { public bool $auto_archive_invoice = false; // @implemented @@ -469,27 +469,28 @@ class SettingsData public function cast(mixed $object) { - if(is_array($object)) + if(is_array($object)) { $object = (object)$object; + } if (is_object($object)) { foreach ($object as $key => $value) { - try{ + try { settype($object->{$key}, gettype($this->{$key})); - } - catch(\Exception | \Error | \Throwable $e){ + } catch(\Exception | \Error | \Throwable $e) { - if(property_exists($this, $key)) + if(property_exists($this, $key)) { $object->{$key} = $this->{$key}; - else + } else { unset($object->{$key}); + } } // if(!property_exists($this, $key)) { // unset($object->{$key}); - // } + // } // elseif(is_array($object->{$key}) && gettype($this->{$key} != 'array')){ // $object->{$key} = $this->{$key}; // } @@ -512,4 +513,4 @@ class SettingsData { return (array)$this->object; } -} \ No newline at end of file +} diff --git a/app/DataMapper/Tax/BaseRule.php b/app/DataMapper/Tax/BaseRule.php index ba8169734547..18886623261a 100644 --- a/app/DataMapper/Tax/BaseRule.php +++ b/app/DataMapper/Tax/BaseRule.php @@ -11,11 +11,11 @@ namespace App\DataMapper\Tax; +use App\DataMapper\Tax\ZipTax\Response; +use App\DataProviders\USStates; use App\Models\Client; use App\Models\Invoice; use App\Models\Product; -use App\DataProviders\USStates; -use App\DataMapper\Tax\ZipTax\Response; class BaseRule implements RuleInterface { @@ -66,7 +66,7 @@ class BaseRule implements RuleInterface 'SK', // Slovakia ]; - public array $region_codes = [ + public array $region_codes = [ 'AT' => 'EU', // Austria 'BE' => 'EU', // Belgium 'BG' => 'EU', // Bulgaria @@ -147,8 +147,9 @@ class BaseRule implements RuleInterface $this->resolveRegions(); - if(!$this->isTaxableRegion()) + if(!$this->isTaxableRegion()) { return $this; + } $this->configTaxData(); @@ -173,26 +174,26 @@ class BaseRule implements RuleInterface /** Harvest the client_region */ /** If the tax data is already set and the invoice is marked as sent, do not adjust the rates */ - if($this->invoice->tax_data && $this->invoice->status_id > 1) + if($this->invoice->tax_data && $this->invoice->status_id > 1) { return $this; + } /** * Origin - Company Tax Data * Destination - Client Tax Data - * + * */ $tax_data = false; - if($this->seller_region == 'US' && $this->client_region == 'US'){ + if($this->seller_region == 'US' && $this->client_region == 'US') { $company = $this->invoice->company; /** If no company tax data has been configured, lets do that now. */ /** We should never encounter this scenario */ - if(!$company->origin_tax_data) - { - $this->should_calc_tax = false; + if(!$company->origin_tax_data) { + $this->should_calc_tax = false; return $this; } @@ -201,8 +202,7 @@ class BaseRule implements RuleInterface $tax_data = $company->origin_tax_data; - } - elseif($this->client->tax_data){ + } elseif($this->client->tax_data) { $tax_data = $this->client->tax_data; @@ -215,8 +215,9 @@ class BaseRule implements RuleInterface $this->invoice->tax_data = $tax_data; - if(\DB::transactionLevel() == 0) + if(\DB::transactionLevel() == 0) { $this->invoice->saveQuietly(); + } } return $this; @@ -234,7 +235,7 @@ class BaseRule implements RuleInterface $this->client_region = $this->region_codes[$this->client->country->iso_3166_2]; - match($this->client_region){ + match($this->client_region) { 'US' => $this->client_subregion = isset($this->invoice?->client?->tax_data?->geoState) ? $this->invoice->client->tax_data->geoState : $this->getUSState(), 'EU' => $this->client_subregion = $this->client->country->iso_3166_2, 'AU' => $this->client_subregion = 'AU', @@ -251,8 +252,9 @@ class BaseRule implements RuleInterface $states = USStates::$states; - if(isset($states[$this->client->state])) + if(isset($states[$this->client->state])) { return $this->client->state; + } return USStates::getState(strlen($this->client->postal_code) > 1 ? $this->client->postal_code : $this->client->shipping_postal_code); @@ -263,7 +265,7 @@ class BaseRule implements RuleInterface public function isTaxableRegion(): bool { - return $this->client->company->tax_data->regions->{$this->client_region}->tax_all_subregions || + return $this->client->company->tax_data->regions->{$this->client_region}->tax_all_subregions || (property_exists($this->client->company->tax_data->regions->{$this->client_region}->subregions, $this->client_subregion) && $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->apply_tax); } @@ -277,8 +279,7 @@ class BaseRule implements RuleInterface return $this; - } - elseif($this->client_region == 'AU'){ //these are defaults and are only stubbed out for now, for AU we can actually remove these + } elseif($this->client_region == 'AU') { //these are defaults and are only stubbed out for now, for AU we can actually remove these $this->tax_rate1 = $this->client->company->tax_data->regions->AU->subregions->AU->tax_rate; $this->tax_name1 = $this->client->company->tax_data->regions->AU->subregions->AU->tax_name; diff --git a/app/DataMapper/Tax/DE/Rule.php b/app/DataMapper/Tax/DE/Rule.php index 8214188c369f..5296674618ca 100644 --- a/app/DataMapper/Tax/DE/Rule.php +++ b/app/DataMapper/Tax/DE/Rule.php @@ -11,12 +11,12 @@ namespace App\DataMapper\Tax\DE; -use App\Models\Product; use App\DataMapper\Tax\BaseRule; use App\DataMapper\Tax\RuleInterface; +use App\Models\Product; class Rule extends BaseRule implements RuleInterface -{ +{ /** @var string $seller_region */ public string $seller_region = 'EU'; @@ -67,7 +67,7 @@ class Rule extends BaseRule implements RuleInterface return $this->taxExempt($item); } - match(intval($item->tax_id)){ + match(intval($item->tax_id)) { Product::PRODUCT_TYPE_EXEMPT => $this->taxExempt($item), Product::PRODUCT_TYPE_DIGITAL => $this->taxDigital($item), Product::PRODUCT_TYPE_SERVICE => $this->taxService($item), @@ -220,39 +220,28 @@ class Rule extends BaseRule implements RuleInterface // nlog("tax exempt"); $this->tax_rate = 0; $this->reduced_tax_rate = 0; - } - elseif($this->client_subregion != $this->client->company->tax_data->seller_subregion && in_array($this->client_subregion, $this->eu_country_codes) && $this->client->vat_number && $this->eu_business_tax_exempt) - // elseif($this->client_subregion != $this->client->company->tax_data->seller_subregion && in_array($this->client_subregion, $this->eu_country_codes) && $this->client->has_valid_vat_number && $this->eu_business_tax_exempt) - { + } elseif($this->client_subregion != $this->client->company->tax_data->seller_subregion && in_array($this->client_subregion, $this->eu_country_codes) && $this->client->vat_number && $this->eu_business_tax_exempt) { + // elseif($this->client_subregion != $this->client->company->tax_data->seller_subregion && in_array($this->client_subregion, $this->eu_country_codes) && $this->client->has_valid_vat_number && $this->eu_business_tax_exempt) // nlog("euro zone and tax exempt"); $this->tax_rate = 0; $this->reduced_tax_rate = 0; - } - elseif(!in_array($this->client_subregion, $this->eu_country_codes) && ($this->foreign_consumer_tax_exempt || $this->foreign_business_tax_exempt)) //foreign + tax exempt - { + } elseif(!in_array($this->client_subregion, $this->eu_country_codes) && ($this->foreign_consumer_tax_exempt || $this->foreign_business_tax_exempt)) { //foreign + tax exempt // nlog("foreign and tax exempt"); $this->tax_rate = 0; $this->reduced_tax_rate = 0; - } - elseif(!in_array($this->client_subregion, $this->eu_country_codes)) - { + } elseif(!in_array($this->client_subregion, $this->eu_country_codes)) { $this->defaultForeign(); - } - elseif(in_array($this->client_subregion, $this->eu_country_codes) && !$this->client->vat_number) //eu country / no valid vat - { - if(($this->client->company->tax_data->seller_subregion != $this->client_subregion) && $this->client->company->tax_data->regions->EU->has_sales_above_threshold) - { + } elseif(in_array($this->client_subregion, $this->eu_country_codes) && !$this->client->vat_number) { //eu country / no valid vat + if(($this->client->company->tax_data->seller_subregion != $this->client_subregion) && $this->client->company->tax_data->regions->EU->has_sales_above_threshold) { // nlog("eu zone with sales above threshold"); $this->tax_rate = $this->client->company->tax_data->regions->EU->subregions->{$this->client->country->iso_3166_2}->tax_rate; $this->reduced_tax_rate = $this->client->company->tax_data->regions->EU->subregions->{$this->client->country->iso_3166_2}->reduced_tax_rate; - } - else { + } else { // nlog("EU with intra-community supply ie DE to DE"); $this->tax_rate = $this->client->company->tax_data->regions->EU->subregions->{$this->client->company->country()->iso_3166_2}->tax_rate; $this->reduced_tax_rate = $this->client->company->tax_data->regions->EU->subregions->{$this->client->company->country()->iso_3166_2}->reduced_tax_rate; } - } - else { + } else { // nlog("default tax"); $this->tax_rate = $this->client->company->tax_data->regions->EU->subregions->{$this->client->company->country()->iso_3166_2}->tax_rate; $this->reduced_tax_rate = $this->client->company->tax_data->regions->EU->subregions->{$this->client->company->country()->iso_3166_2}->reduced_tax_rate; @@ -262,4 +251,4 @@ class Rule extends BaseRule implements RuleInterface } -} \ No newline at end of file +} diff --git a/app/DataMapper/Tax/RuleInterface.php b/app/DataMapper/Tax/RuleInterface.php index e4ff2c0e2da9..73994de7222b 100644 --- a/app/DataMapper/Tax/RuleInterface.php +++ b/app/DataMapper/Tax/RuleInterface.php @@ -36,4 +36,4 @@ interface RuleInterface public function override($item); public function calculateRates(); -} \ No newline at end of file +} diff --git a/app/DataMapper/Tax/TaxData.php b/app/DataMapper/Tax/TaxData.php index c1696ef2a43e..945a3d0a463f 100644 --- a/app/DataMapper/Tax/TaxData.php +++ b/app/DataMapper/Tax/TaxData.php @@ -15,7 +15,7 @@ use App\DataMapper\Tax\ZipTax\Response; /** * InvoiceTaxData - * + * * Definition for the invoice tax data structure */ class TaxData diff --git a/app/DataMapper/Tax/TaxModel.php b/app/DataMapper/Tax/TaxModel.php index 8fd686e88ff7..ca6d41a3f4a8 100644 --- a/app/DataMapper/Tax/TaxModel.php +++ b/app/DataMapper/Tax/TaxModel.php @@ -11,7 +11,7 @@ namespace App\DataMapper\Tax; -class TaxModel +class TaxModel { /** @var string $seller_subregion */ @@ -32,10 +32,11 @@ class TaxModel public function __construct(public ?TaxModel $model = null) { - if(!$this->model) + if(!$this->model) { $this->regions = $this->init(); - else + } else { $this->regions = $model; + } } @@ -79,7 +80,7 @@ class TaxModel * * @return self */ - private function auSubRegions(): self + private function auSubRegions(): self { $this->regions->AU->subregions = new \stdClass(); @@ -387,7 +388,7 @@ class TaxModel $this->regions->EU->subregions->EE = new \stdClass(); $this->regions->EU->subregions->EE->tax_rate = 20; - $this->regions->EU->subregions->EE->tax_name = 'KM'; + $this->regions->EU->subregions->EE->tax_name = 'KM'; $this->regions->EU->subregions->EE->reduced_tax_rate = 9; $this->regions->EU->subregions->EE->apply_tax = false; diff --git a/app/DataMapper/Tax/US/Rule.php b/app/DataMapper/Tax/US/Rule.php index e880027201ea..0a7179113b80 100644 --- a/app/DataMapper/Tax/US/Rule.php +++ b/app/DataMapper/Tax/US/Rule.php @@ -74,7 +74,7 @@ class Rule extends BaseRule implements RuleInterface Product::PRODUCT_TYPE_SHIPPING => $this->taxShipping($item), Product::PRODUCT_TYPE_PHYSICAL => $this->taxPhysical($item), Product::PRODUCT_TYPE_REDUCED_TAX => $this->taxReduced($item), - Product::PRODUCT_TYPE_OVERRIDE_TAX => $this->override($item), + Product::PRODUCT_TYPE_OVERRIDE_TAX => $this->override($item), Product::PRODUCT_TYPE_ZERO_RATED => $this->zeroRated($item), default => $this->default($item), }; @@ -117,10 +117,9 @@ class Rule extends BaseRule implements RuleInterface */ public function taxService($item): self { - if(in_array($this->tax_data?->txbService,['Y','L'])) { + if(in_array($this->tax_data?->txbService, ['Y','L'])) { $this->default($item); - } - else { + } else { $this->taxExempt($item); } @@ -224,4 +223,4 @@ class Rule extends BaseRule implements RuleInterface return $this; } -} \ No newline at end of file +} diff --git a/app/DataMapper/Tax/ZipTax/Response.php b/app/DataMapper/Tax/ZipTax/Response.php index 4a8e03634355..a64f27540264 100644 --- a/app/DataMapper/Tax/ZipTax/Response.php +++ b/app/DataMapper/Tax/ZipTax/Response.php @@ -53,7 +53,7 @@ class Response * "district5SalesTax" => 0, * "district5UseTax" => 0, * "originDestination" => "D", - * + * * ]; * */ @@ -114,4 +114,3 @@ class Response } } - diff --git a/app/DataProviders/USStates.php b/app/DataProviders/USStates.php index 4809df8439c1..75c205978626 100644 --- a/app/DataProviders/USStates.php +++ b/app/DataProviders/USStates.php @@ -33868,18 +33868,21 @@ class USStates public static function getState(?string $zip = '90210'): string { - if(isset(self::$zip_code_map[$zip])) + if(isset(self::$zip_code_map[$zip])) { return self::$zip_code_map[$zip]; + } $prefix_state = self::getStateFromThreeDigitPrefix($zip); - if($prefix_state) + if($prefix_state) { return $prefix_state; + } $zippo_response = self::getStateFromZippo($zip); - if($zippo_response) + if($zippo_response) { return $zippo_response; + } throw new \Exception('Zip code not found'); } @@ -33905,8 +33908,9 @@ class USStates $response = Http::get("https://api.zippopotam.us/us/{$zip}"); - if($response->failed()) + if($response->failed()) { return false; + } $data = $response->object(); @@ -33921,7 +33925,7 @@ class USStates public static function getStateFromThreeDigitPrefix($zip): mixed { - /* 000 to 999 */ + /* 000 to 999 */ $zip_by_state = [ '--', '--', '--', '--', '--', 'NY', 'PR', 'PR', 'VI', 'PR', 'MA', 'MA', 'MA', 'MA', 'MA', 'MA', 'MA', 'MA', 'MA', 'MA', 'MA', 'MA', 'MA', 'MA', 'MA', 'MA', @@ -34004,7 +34008,7 @@ class USStates $prefix = substr($zip, 0, 3); $index = intval($prefix); - /* converts prefix to integer */ + /* converts prefix to integer */ return $zip_by_state[$index] == "--" ? false : $zip_by_state[$index]; } diff --git a/app/Events/Account/AccountCreated.php b/app/Events/Account/AccountCreated.php index 0761cdf4b9ed..4cd6d46ee0cf 100644 --- a/app/Events/Account/AccountCreated.php +++ b/app/Events/Account/AccountCreated.php @@ -49,9 +49,9 @@ class AccountCreated // * // * @return Channel|array // */ - public function broadcastOn() - { + public function broadcastOn() + { return []; - // return new PrivateChannel('channel-name'); - } + // return new PrivateChannel('channel-name'); + } } diff --git a/app/Events/Account/StripeConnectFailure.php b/app/Events/Account/StripeConnectFailure.php index fd6f5a5d5738..ebe501512b17 100644 --- a/app/Events/Account/StripeConnectFailure.php +++ b/app/Events/Account/StripeConnectFailure.php @@ -12,11 +12,9 @@ namespace App\Events\Account; use App\Models\Company; -use Illuminate\Broadcasting\Channel; -use Illuminate\Queue\SerializesModels; -use Illuminate\Broadcasting\PrivateChannel; -use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; +use Illuminate\Foundation\Events\Dispatchable; +use Illuminate\Queue\SerializesModels; /** * Class StripeConnectFailure. diff --git a/app/Events/Client/ClientWasArchived.php b/app/Events/Client/ClientWasArchived.php index aca000b8e594..46aac9cba8f1 100644 --- a/app/Events/Client/ClientWasArchived.php +++ b/app/Events/Client/ClientWasArchived.php @@ -15,7 +15,6 @@ use App\Models\Client; use App\Models\Company; use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; @@ -54,8 +53,8 @@ class ClientWasArchived // * // * @return Channel|array // */ - public function broadcastOn() - { + public function broadcastOn() + { return []; - } + } } diff --git a/app/Events/Company/CompanyDocumentsDeleted.php b/app/Events/Company/CompanyDocumentsDeleted.php index 2c8f11c4f27f..831a4958d1af 100644 --- a/app/Events/Company/CompanyDocumentsDeleted.php +++ b/app/Events/Company/CompanyDocumentsDeleted.php @@ -14,7 +14,6 @@ namespace App\Events\Company; use App\Models\Company; use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; @@ -42,8 +41,8 @@ class CompanyDocumentsDeleted * * @return Channel|array */ - public function broadcastOn() - { -return []; - } + public function broadcastOn() + { + return []; + } } diff --git a/app/Events/Contact/ContactLoggedIn.php b/app/Events/Contact/ContactLoggedIn.php index 0e98a54449c6..e2fa77103f64 100644 --- a/app/Events/Contact/ContactLoggedIn.php +++ b/app/Events/Contact/ContactLoggedIn.php @@ -14,7 +14,6 @@ namespace App\Events\Contact; use App\Models\ClientContact; use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; @@ -50,8 +49,8 @@ class ContactLoggedIn * * @return Channel|array */ - public function broadcastOn() - { + public function broadcastOn() + { return []; - } + } } diff --git a/app/Events/Design/DesignWasArchived.php b/app/Events/Design/DesignWasArchived.php index 1dd9105c7c63..a3745552b245 100644 --- a/app/Events/Design/DesignWasArchived.php +++ b/app/Events/Design/DesignWasArchived.php @@ -15,7 +15,6 @@ use App\Models\Company; use App\Models\Design; use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; @@ -35,8 +34,8 @@ class DesignWasArchived * * @return Channel|array */ - public function broadcastOn() - { + public function broadcastOn() + { return []; - } + } } diff --git a/app/Events/Design/DesignWasCreated.php b/app/Events/Design/DesignWasCreated.php index 213eb9882461..7cbf9aeec76e 100644 --- a/app/Events/Design/DesignWasCreated.php +++ b/app/Events/Design/DesignWasCreated.php @@ -11,10 +11,10 @@ namespace App\Events\Design; -use App\Models\Design; use App\Models\Company; -use Illuminate\Queue\SerializesModels; +use App\Models\Design; use Illuminate\Broadcasting\PrivateChannel; +use Illuminate\Queue\SerializesModels; /** * Class DesignWasCreated. @@ -32,8 +32,8 @@ class DesignWasCreated * * @return PrivateChannel|array */ - public function broadcastOn() - { + public function broadcastOn() + { return []; - } + } } diff --git a/app/Events/Design/DesignWasDeleted.php b/app/Events/Design/DesignWasDeleted.php index d9142724a074..fe21e1864604 100644 --- a/app/Events/Design/DesignWasDeleted.php +++ b/app/Events/Design/DesignWasDeleted.php @@ -11,10 +11,10 @@ namespace App\Events\Design; -use App\Models\Design; use App\Models\Company; -use Illuminate\Queue\SerializesModels; +use App\Models\Design; use Illuminate\Broadcasting\PrivateChannel; +use Illuminate\Queue\SerializesModels; /** * Class DesignWasDeleted. @@ -32,8 +32,8 @@ class DesignWasDeleted * * @return PrivateChannel|array */ - public function broadcastOn() - { + public function broadcastOn() + { return []; - } + } } diff --git a/app/Events/Design/DesignWasRestored.php b/app/Events/Design/DesignWasRestored.php index 6daa2c2545ba..c237d1f2c9c1 100644 --- a/app/Events/Design/DesignWasRestored.php +++ b/app/Events/Design/DesignWasRestored.php @@ -11,10 +11,10 @@ namespace App\Events\Design; -use App\Models\Design; use App\Models\Company; -use Illuminate\Queue\SerializesModels; +use App\Models\Design; use Illuminate\Broadcasting\PrivateChannel; +use Illuminate\Queue\SerializesModels; /** * Class DesignWasRestored. @@ -32,8 +32,8 @@ class DesignWasRestored * * @return PrivateChannel|array */ - public function broadcastOn() - { + public function broadcastOn() + { return []; - } + } } diff --git a/app/Events/Design/DesignWasUpdated.php b/app/Events/Design/DesignWasUpdated.php index 3b215fdff2bf..bf18bd88cf25 100644 --- a/app/Events/Design/DesignWasUpdated.php +++ b/app/Events/Design/DesignWasUpdated.php @@ -11,10 +11,10 @@ namespace App\Events\Design; -use App\Models\Design; use App\Models\Company; -use Illuminate\Queue\SerializesModels; +use App\Models\Design; use Illuminate\Broadcasting\PrivateChannel; +use Illuminate\Queue\SerializesModels; /** * Class DesignWasUpdated. @@ -32,8 +32,8 @@ class DesignWasUpdated * * @return PrivateChannel|array */ - public function broadcastOn() - { + public function broadcastOn() + { return []; - } + } } diff --git a/app/Events/Document/DocumentWasArchived.php b/app/Events/Document/DocumentWasArchived.php index 229e7d6c1673..edfa4bea8572 100644 --- a/app/Events/Document/DocumentWasArchived.php +++ b/app/Events/Document/DocumentWasArchived.php @@ -15,7 +15,6 @@ use App\Models\Company; use App\Models\Document; use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; diff --git a/app/Events/Payment/Methods/MethodDeleted.php b/app/Events/Payment/Methods/MethodDeleted.php index 5e80e20f8aea..f205d872c8ac 100644 --- a/app/Events/Payment/Methods/MethodDeleted.php +++ b/app/Events/Payment/Methods/MethodDeleted.php @@ -15,7 +15,6 @@ use App\Models\ClientGatewayToken; use App\Models\Company; use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; @@ -51,8 +50,8 @@ class MethodDeleted * * @return Channel|array */ - public function broadcastOn() - { + public function broadcastOn() + { return []; - } + } } diff --git a/app/Events/Payment/PaymentWasEmailed.php b/app/Events/Payment/PaymentWasEmailed.php index 284d52de4880..767918ab0388 100644 --- a/app/Events/Payment/PaymentWasEmailed.php +++ b/app/Events/Payment/PaymentWasEmailed.php @@ -11,12 +11,12 @@ namespace App\Events\Payment; +use App\Models\ClientContact; use App\Models\Company; use App\Models\Payment; -use App\Models\ClientContact; -use Illuminate\Queue\SerializesModels; -use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; +use Illuminate\Foundation\Events\Dispatchable; +use Illuminate\Queue\SerializesModels; /** * Class PaymentWasEmailed. diff --git a/app/Events/PurchaseOrder/PurchaseOrderWasViewed.php b/app/Events/PurchaseOrder/PurchaseOrderWasViewed.php index a144639a6872..c9555bd90cea 100644 --- a/app/Events/PurchaseOrder/PurchaseOrderWasViewed.php +++ b/app/Events/PurchaseOrder/PurchaseOrderWasViewed.php @@ -12,7 +12,6 @@ namespace App\Events\PurchaseOrder; use App\Models\Company; -use App\Models\PurchaseOrder; use App\Models\PurchaseOrderInvitation; use Illuminate\Queue\SerializesModels; diff --git a/app/Events/Quote/QuoteWasEmailed.php b/app/Events/Quote/QuoteWasEmailed.php index 5792167c42d9..ef8055edd465 100644 --- a/app/Events/Quote/QuoteWasEmailed.php +++ b/app/Events/Quote/QuoteWasEmailed.php @@ -12,7 +12,6 @@ namespace App\Events\Quote; use App\Models\Company; -use App\Models\Quote; use App\Models\QuoteInvitation; use Illuminate\Queue\SerializesModels; diff --git a/app/Events/Subscription/SubscriptionWasCreated.php b/app/Events/Subscription/SubscriptionWasCreated.php index 9d1616defb28..fff93b1507f0 100644 --- a/app/Events/Subscription/SubscriptionWasCreated.php +++ b/app/Events/Subscription/SubscriptionWasCreated.php @@ -5,7 +5,6 @@ namespace App\Events\Subscription; use App\Models\Company; use App\Models\Subscription; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; @@ -45,8 +44,8 @@ class SubscriptionWasCreated * * @return \Illuminate\Broadcasting\Channel|array */ - public function broadcastOn() - { + public function broadcastOn() + { return []; - } + } } diff --git a/app/Events/User/UserLoggedIn.php b/app/Events/User/UserLoggedIn.php index f3b55c2a1c71..bddb7104ec2f 100644 --- a/app/Events/User/UserLoggedIn.php +++ b/app/Events/User/UserLoggedIn.php @@ -15,7 +15,6 @@ use App\Models\Company; use App\Models\User; use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; @@ -35,8 +34,8 @@ class UserLoggedIn * * @return Channel|array */ - public function broadcastOn() - { + public function broadcastOn() + { return []; - } + } } diff --git a/app/Events/User/UserWasArchived.php b/app/Events/User/UserWasArchived.php index 51657baffbfc..cb7077668f30 100644 --- a/app/Events/User/UserWasArchived.php +++ b/app/Events/User/UserWasArchived.php @@ -15,7 +15,6 @@ use App\Models\Company; use App\Models\User; use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; @@ -35,8 +34,8 @@ class UserWasArchived * * @return Channel|array */ - public function broadcastOn() - { + public function broadcastOn() + { return []; - } + } } diff --git a/app/Events/User/UserWasCreated.php b/app/Events/User/UserWasCreated.php index c4bba8784678..5d30fa5261eb 100644 --- a/app/Events/User/UserWasCreated.php +++ b/app/Events/User/UserWasCreated.php @@ -15,7 +15,6 @@ use App\Models\Company; use App\Models\User; use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; @@ -35,8 +34,8 @@ class UserWasCreated * * @return Channel|array */ - public function broadcastOn() - { + public function broadcastOn() + { return []; - } + } } diff --git a/app/Events/User/UserWasDeleted.php b/app/Events/User/UserWasDeleted.php index cae639e2088d..d7323d78d563 100644 --- a/app/Events/User/UserWasDeleted.php +++ b/app/Events/User/UserWasDeleted.php @@ -15,7 +15,6 @@ use App\Models\Company; use App\Models\User; use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; @@ -54,8 +53,8 @@ class UserWasDeleted * * @return Channel|array */ - public function broadcastOn() - { + public function broadcastOn() + { return []; - } + } } diff --git a/app/Events/User/UserWasRestored.php b/app/Events/User/UserWasRestored.php index 2d722fd189a0..196a73e4513c 100644 --- a/app/Events/User/UserWasRestored.php +++ b/app/Events/User/UserWasRestored.php @@ -15,7 +15,6 @@ use App\Models\Company; use App\Models\User; use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; @@ -54,8 +53,8 @@ class UserWasRestored * * @return Channel|array */ - public function broadcastOn() - { + public function broadcastOn() + { return []; - } + } } diff --git a/app/Events/User/UserWasUpdated.php b/app/Events/User/UserWasUpdated.php index a4eda9752c79..ef495814a736 100644 --- a/app/Events/User/UserWasUpdated.php +++ b/app/Events/User/UserWasUpdated.php @@ -15,7 +15,6 @@ use App\Models\Company; use App\Models\User; use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; @@ -54,8 +53,8 @@ class UserWasUpdated * * @return Channel|array */ - public function broadcastOn() - { + public function broadcastOn() + { return []; - } + } } diff --git a/app/Events/Vendor/VendorContactLoggedIn.php b/app/Events/Vendor/VendorContactLoggedIn.php index 2422af1023a5..9a0ddad94821 100644 --- a/app/Events/Vendor/VendorContactLoggedIn.php +++ b/app/Events/Vendor/VendorContactLoggedIn.php @@ -14,9 +14,9 @@ namespace App\Events\Vendor; use App\Models\Company; use App\Models\VendorContact; use Illuminate\Broadcasting\Channel; -use Illuminate\Queue\SerializesModels; -use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; +use Illuminate\Foundation\Events\Dispatchable; +use Illuminate\Queue\SerializesModels; /** * Class VendorContactLoggedIn. diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 4e8f339a3916..e993581e5af2 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -11,31 +11,31 @@ namespace App\Exceptions; -use Throwable; -use PDOException; use App\Utils\Ninja; -use Sentry\State\Scope; -use Illuminate\Support\Arr; -use Illuminate\Http\Request; -use InvalidArgumentException; -use Sentry\Laravel\Integration; -use Illuminate\Support\Facades\Schema; use Aws\Exception\CredentialsException; use GuzzleHttp\Exception\ConnectException; -use Illuminate\Auth\AuthenticationException; -use League\Flysystem\UnableToCreateDirectory; -use Illuminate\Session\TokenMismatchException; -use Illuminate\Validation\ValidationException; use Illuminate\Auth\Access\AuthorizationException; -use Illuminate\Queue\MaxAttemptsExceededException; -use Illuminate\Http\Exceptions\ThrottleRequestsException; -use Symfony\Component\Process\Exception\RuntimeException; +use Illuminate\Auth\AuthenticationException; +use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundException; use Illuminate\Database\Eloquent\RelationNotFoundException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; +use Illuminate\Http\Exceptions\ThrottleRequestsException; +use Illuminate\Http\Request; +use Illuminate\Queue\MaxAttemptsExceededException; +use Illuminate\Session\TokenMismatchException; +use Illuminate\Support\Arr; +use Illuminate\Support\Facades\Schema; +use Illuminate\Validation\ValidationException; +use InvalidArgumentException; +use League\Flysystem\UnableToCreateDirectory; +use PDOException; +use Sentry\Laravel\Integration; +use Sentry\State\Scope; use Symfony\Component\Console\Exception\CommandNotFoundException; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; -use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundException; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Symfony\Component\Process\Exception\RuntimeException; +use Throwable; class Handler extends ExceptionHandler { @@ -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/Exceptions/PaymentRefundFailed.php b/app/Exceptions/PaymentRefundFailed.php index 28e00858e867..9ba3a922fb30 100644 --- a/app/Exceptions/PaymentRefundFailed.php +++ b/app/Exceptions/PaymentRefundFailed.php @@ -13,8 +13,8 @@ namespace App\Exceptions; use Exception; -use Illuminate\Http\Request; use Illuminate\Http\JsonResponse; +use Illuminate\Http\Request; class PaymentRefundFailed extends Exception { diff --git a/app/Exceptions/QuoteConversion.php b/app/Exceptions/QuoteConversion.php index ceafdf8b499a..a2e11e6374ef 100644 --- a/app/Exceptions/QuoteConversion.php +++ b/app/Exceptions/QuoteConversion.php @@ -13,8 +13,8 @@ namespace App\Exceptions; use Exception; -use Illuminate\Http\Request; use Illuminate\Http\JsonResponse; +use Illuminate\Http\Request; class QuoteConversion extends Exception { diff --git a/app/Exceptions/YodleeApiException.php b/app/Exceptions/YodleeApiException.php index b56eedced3bd..c8150d18cbca 100644 --- a/app/Exceptions/YodleeApiException.php +++ b/app/Exceptions/YodleeApiException.php @@ -13,8 +13,8 @@ namespace App\Exceptions; use Exception; -use Illuminate\Http\Request; use Illuminate\Http\JsonResponse; +use Illuminate\Http\Request; class YodleeApiException extends Exception { diff --git a/app/Export/CSV/ActivityExport.php b/app/Export/CSV/ActivityExport.php index 3cd1c8963273..e738f6371a27 100644 --- a/app/Export/CSV/ActivityExport.php +++ b/app/Export/CSV/ActivityExport.php @@ -11,17 +11,17 @@ namespace App\Export\CSV; -use App\Models\Task; -use App\Utils\Ninja; -use League\Csv\Writer; -use App\Models\Company; -use App\Models\Activity; use App\Libraries\MultiDB; +use App\Models\Activity; +use App\Models\Company; use App\Models\DateFormat; +use App\Models\Task; +use App\Transformers\ActivityTransformer; +use App\Utils\Ninja; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\App; -use Illuminate\Database\Eloquent\Builder; -use App\Transformers\ActivityTransformer; +use League\Csv\Writer; class ActivityExport extends BaseExport { @@ -53,44 +53,44 @@ class ActivityExport extends BaseExport $headerdisplay = $this->buildHeader(); - $header = collect($this->input['report_keys'])->map(function ($key, $value) use($headerdisplay){ - return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; - })->toArray(); + $header = collect($this->input['report_keys'])->map(function ($key, $value) use ($headerdisplay) { + return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; + })->toArray(); - $report = $query->cursor() - ->map(function ($resource) { - $row = $this->buildActivityRow($resource); - return $this->processMetaData($row, $resource); - })->toArray(); + $report = $query->cursor() + ->map(function ($resource) { + $row = $this->buildActivityRow($resource); + return $this->processMetaData($row, $resource); + })->toArray(); return array_merge(['columns' => $header], $report); } private function buildActivityRow(Activity $activity): array { - return [ - Carbon::parse($activity->created_at)->format($this->date_format), - ctrans("texts.activity_{$activity->activity_type_id}",[ - 'payment_amount' => $activity->payment ? $activity->payment->amount : '', - 'adjustment' => $activity->payment ? $activity->payment->refunded : '', - 'client' => $activity->client ? $activity->client->present()->name() : '', - 'contact' => $activity->contact ? $activity->contact->present()->name() : '', - 'quote' => $activity->quote ? $activity->quote->number : '', - 'user' => $activity->user ? $activity->user->present()->name() : 'System', - 'expense' => $activity->expense ? $activity->expense->number : '', - 'invoice' => $activity->invoice ? $activity->invoice->number : '', - 'recurring_invoice' => $activity->recurring_invoice ? $activity->recurring_invoice->number : '', - 'payment' => $activity->payment ? $activity->payment->number : '', - 'credit' => $activity->credit ? $activity->credit->number : '', - 'task' => $activity->task ? $activity->task->number : '', - 'vendor' => $activity->vendor ? $activity->vendor->present()->name() : '', - 'purchase_order' => $activity->purchase_order ? $activity->purchase_order->number : '', - 'subscription' => $activity->subscription ? $activity->subscription->name : '', - 'vendor_contact' => $activity->vendor_contact ? $activity->vendor_contact->present()->name() : '', - 'recurring_expense' => $activity->recurring_expense ? $activity->recurring_expense->number : '', - ]), - $activity->ip, + return [ + Carbon::parse($activity->created_at)->format($this->date_format), + ctrans("texts.activity_{$activity->activity_type_id}", [ + 'payment_amount' => $activity->payment ? $activity->payment->amount : '', + 'adjustment' => $activity->payment ? $activity->payment->refunded : '', + 'client' => $activity->client ? $activity->client->present()->name() : '', + 'contact' => $activity->contact ? $activity->contact->present()->name() : '', + 'quote' => $activity->quote ? $activity->quote->number : '', + 'user' => $activity->user ? $activity->user->present()->name() : 'System', + 'expense' => $activity->expense ? $activity->expense->number : '', + 'invoice' => $activity->invoice ? $activity->invoice->number : '', + 'recurring_invoice' => $activity->recurring_invoice ? $activity->recurring_invoice->number : '', + 'payment' => $activity->payment ? $activity->payment->number : '', + 'credit' => $activity->credit ? $activity->credit->number : '', + 'task' => $activity->task ? $activity->task->number : '', + 'vendor' => $activity->vendor ? $activity->vendor->present()->name() : '', + 'purchase_order' => $activity->purchase_order ? $activity->purchase_order->number : '', + 'subscription' => $activity->subscription ? $activity->subscription->name : '', + 'vendor_contact' => $activity->vendor_contact ? $activity->vendor_contact->present()->name() : '', + 'recurring_expense' => $activity->recurring_expense ? $activity->recurring_expense->number : '', + ]), + $activity->ip, ]; } @@ -169,6 +169,6 @@ class ActivityExport extends BaseExport } return $clean_row; - } + } } diff --git a/app/Export/CSV/BaseExport.php b/app/Export/CSV/BaseExport.php index fa6ab80ef33f..74474b98c789 100644 --- a/app/Export/CSV/BaseExport.php +++ b/app/Export/CSV/BaseExport.php @@ -11,30 +11,28 @@ namespace App\Export\CSV; -use App\Models\Activity; -use App\Models\Quote; -use App\Utils\Number; use App\Models\Client; -use App\Models\Credit; -use App\Utils\Helpers; +use App\Models\ClientContact; use App\Models\Company; +use App\Models\Credit; +use App\Models\Document; use App\Models\Expense; use App\Models\Invoice; use App\Models\Payment; -use App\Models\Document; -use League\Fractal\Manager; -use App\Models\ClientContact; -use App\Models\PurchaseOrder; -use App\Models\RecurringInvoice; -use Illuminate\Support\Carbon; -use App\Utils\Traits\MakesHash; -use App\Transformers\TaskTransformer; -use App\Transformers\PaymentTransformer; -use Illuminate\Database\Eloquent\Builder; -use League\Fractal\Serializer\ArraySerializer; use App\Models\Product; +use App\Models\PurchaseOrder; +use App\Models\Quote; +use App\Models\RecurringInvoice; use App\Models\Task; use App\Models\Vendor; +use App\Transformers\PaymentTransformer; +use App\Transformers\TaskTransformer; +use App\Utils\Helpers; +use App\Utils\Traits\MakesHash; +use Illuminate\Database\Eloquent\Builder; +use Illuminate\Support\Carbon; +use League\Fractal\Manager; +use League\Fractal\Serializer\ArraySerializer; class BaseExport { @@ -172,7 +170,7 @@ class BaseExport 'recurring_invoice' => 'invoice.recurring_id', ]; - protected array $recurring_invoice_report_keys = [ + protected array $recurring_invoice_report_keys = [ "invoice_number" => "recurring_invoice.number", "amount" => "recurring_invoice.amount", "balance" => "recurring_invoice.balance", @@ -446,8 +444,7 @@ class BaseExport $client = Client::withTrashed()->find($this->input['client_id']); $this->client_description = $client->present()->name; return $query->where('client_id', $this->input['client_id']); - } - elseif(isset($this->input['clients']) && count($this->input['clients']) > 0) { + } elseif(isset($this->input['clients']) && count($this->input['clients']) > 0) { $this->client_description = 'Multiple Clients'; return $query->whereIn('client_id', $this->input['clients']); @@ -459,8 +456,9 @@ class BaseExport { $parts = explode(".", $key); - if(!is_array($parts) || count($parts) < 2) + if(!is_array($parts) || count($parts) < 2) { return ''; + } $value = ''; @@ -497,8 +495,9 @@ class BaseExport private function resolveVendorContactKey($column, $entity, $transformer) { - if(!$entity->vendor) + if(!$entity->vendor) { return ""; + } $primary_contact = $entity->vendor->primary_contact()->first() ?? $entity->vendor->contacts()->first(); @@ -510,18 +509,21 @@ class BaseExport private function resolveExpenseKey($column, $entity, $transformer) { - if($column == 'user' && $entity?->expense?->user) + if($column == 'user' && $entity?->expense?->user) { return $entity->expense->user->present()->name() ?? ' '; + } - if($column == 'assigned_user' && $entity?->expense?->assigned_user) + if($column == 'assigned_user' && $entity?->expense?->assigned_user) { return $entity->expense->assigned_user->present()->name() ?? ' '; + } if($column == 'category' && $entity->expense) { return $entity->expense->category?->name ?? ' '; } - if($entity instanceof Expense) + if($entity instanceof Expense) { return ''; + } $transformed_entity = $transformer->includeExpense($entity); @@ -529,11 +531,13 @@ class BaseExport $manager->setSerializer(new ArraySerializer()); $transformed_entity = $manager->createData($transformed_entity)->toArray(); - if(array_key_exists($column, $transformed_entity)) - return $transformed_entity[$column]; + if(array_key_exists($column, $transformed_entity)) { + return $transformed_entity[$column]; + } - if(property_exists($entity, $column)) + if(property_exists($entity, $column)) { return $entity?->{$column} ?? ''; + } nlog("export: Could not resolve expense key: {$column}"); @@ -560,8 +564,9 @@ class BaseExport private function resolveVendorKey($column, $entity, $transformer) { - if(!$entity->vendor) + if(!$entity->vendor) { return ''; + } $transformed_entity = $transformer->includeVendor($entity); @@ -569,24 +574,29 @@ class BaseExport $manager->setSerializer(new ArraySerializer()); $transformed_entity = $manager->createData($transformed_entity)->toArray(); - if($column == 'name') + if($column == 'name') { return $entity->vendor->present()->name() ?: ''; + } - if($column == 'user_id') + if($column == 'user_id') { return $entity->vendor->user->present()->name() ?: ''; + } - if($column == 'country_id') + if($column == 'country_id') { return $entity->vendor->country ? ctrans("texts.country_{$entity->vendor->country->name}") : ''; + } if ($column == 'currency_id') { return $entity->vendor->currency() ? $entity->vendor->currency()->code : $entity->company->currency()->code; } - if($column == 'status') + if($column == 'status') { return $entity->stringStatus($entity->status_id) ?: ''; + } - if(array_key_exists($column, $transformed_entity)) + if(array_key_exists($column, $transformed_entity)) { return $transformed_entity[$column]; + } // nlog("export: Could not resolve vendor key: {$column}"); @@ -598,8 +608,9 @@ class BaseExport private function resolveClientKey($column, $entity, $transformer) { - if(!$entity->client) + if(!$entity->client) { return ''; + } $transformed_client = $transformer->includeClient($entity); @@ -607,36 +618,46 @@ class BaseExport $manager->setSerializer(new ArraySerializer()); $transformed_client = $manager->createData($transformed_client)->toArray(); - if(in_array($column, ['client.name', 'name'])) + if(in_array($column, ['client.name', 'name'])) { return $transformed_client['display_name']; + } - if(in_array($column, ['client.user_id', 'user_id'])) + if(in_array($column, ['client.user_id', 'user_id'])) { return $entity->client->user->present()->name(); + } - if(in_array($column, ['client.assigned_user_id', 'assigned_user_id'])) + if(in_array($column, ['client.assigned_user_id', 'assigned_user_id'])) { return $entity->client->assigned_user->present()->name(); + } - if(in_array($column, ['client.country_id', 'country_id'])) + if(in_array($column, ['client.country_id', 'country_id'])) { return $entity->client->country ? ctrans("texts.country_{$entity->client->country->name}") : ''; + } - if(in_array($column, ['client.shipping_country_id', 'shipping_country_id'])) + if(in_array($column, ['client.shipping_country_id', 'shipping_country_id'])) { return $entity->client->shipping_country ? ctrans("texts.country_{$entity->client->shipping_country->name}") : ''; + } - if(in_array($column, ['client.size_id', 'size_id'])) + if(in_array($column, ['client.size_id', 'size_id'])) { return $entity->client->size?->name ?? ''; + } - if(in_array($column, ['client.industry_id', 'industry_id'])) + if(in_array($column, ['client.industry_id', 'industry_id'])) { return $entity->client->industry?->name ?? ''; + } - if (in_array($column, ['client.currency_id', 'currency_id'])) + if (in_array($column, ['client.currency_id', 'currency_id'])) { return $entity->client->currency() ? $entity->client->currency()->code : $entity->company->currency()->code; + } - if(in_array($column, ['payment_terms', 'client.payment_terms'])) + if(in_array($column, ['payment_terms', 'client.payment_terms'])) { return $entity->client->getSetting('payment_terms'); + } - if(array_key_exists($column, $transformed_client)) + if(array_key_exists($column, $transformed_client)) { return $transformed_client[$column]; + } // nlog("export: Could not resolve client key: {$column}"); @@ -650,8 +671,9 @@ class BaseExport $transformed_entity = $transformer->transform($entity); - if($column == 'status') + if($column == 'status') { return $entity->stringStatus($entity->status_id); + } return ''; } @@ -682,16 +704,19 @@ class BaseExport $manager->setSerializer(new ArraySerializer()); $transformed_invoices = $manager->createData($transformed_invoices)->toArray(); - if(!isset($transformed_invoices['App\\Models\\Invoice'])) + if(!isset($transformed_invoices['App\\Models\\Invoice'])) { return ''; + } $transformed_invoices = $transformed_invoices['App\\Models\\Invoice']; - if(count($transformed_invoices) == 1 && array_key_exists($column, $transformed_invoices[0])) + if(count($transformed_invoices) == 1 && array_key_exists($column, $transformed_invoices[0])) { return $transformed_invoices[0][$column]; + } - if(count($transformed_invoices) > 1 && array_key_exists($column, $transformed_invoices[0])) + if(count($transformed_invoices) > 1 && array_key_exists($column, $transformed_invoices[0])) { return implode(', ', array_column($transformed_invoices, $column)); + } return ""; @@ -700,8 +725,9 @@ class BaseExport if($transformer instanceof TaskTransformer && ($entity->invoice ?? false)) { $transformed_invoice = $transformer->includeInvoice($entity); - if(!$transformed_invoice) + if(!$transformed_invoice) { return ''; + } $manager = new Manager(); $manager->setSerializer(new ArraySerializer()); @@ -721,7 +747,7 @@ class BaseExport private function resolvePaymentKey($column, $entity, $transformer) { - if($entity instanceof Payment){ + if($entity instanceof Payment) { $transformed_payment = $transformer->transform($entity); @@ -737,8 +763,9 @@ class BaseExport } - if($column == 'amount') + if($column == 'amount') { return $entity->payments()->exists() ? $entity->payments()->withoutTrashed()->sum('paymentables.amount') : ctrans('texts.unpaid'); + } if($column == 'refunded') { return $entity->payments()->exists() ? $entity->payments()->withoutTrashed()->sum('paymentables.refunded') : ''; @@ -753,24 +780,28 @@ class BaseExport $payment = $entity->payments()->withoutTrashed()->first(); - if(!$payment) + if(!$payment) { return ''; + } - if($column == 'method') + if($column == 'method') { return $payment->translatedType(); + } - if($column == 'currency') + if($column == 'currency') { return $payment?->currency?->code ?? ''; + } $payment_transformer = new PaymentTransformer(); $transformed_payment = $payment_transformer->transform($payment); - if($column == 'status'){ + if($column == 'status') { return $payment->stringStatus($transformed_payment['status_id']); } - if(array_key_exists($column, $transformed_payment)) + if(array_key_exists($column, $transformed_payment)) { return $transformed_payment[$column]; + } return ''; @@ -782,8 +813,9 @@ class BaseExport $status_parameters = explode(',', $status); - if(in_array('all', $status_parameters)) + if(in_array('all', $status_parameters)) { return $query; + } $query->where(function ($nested) use ($status_parameters) { @@ -816,9 +848,9 @@ class BaseExport ->orWhere('partial_due_date', '<', Carbon::now()); } - if(in_array('viewed', $status_parameters)){ + if(in_array('viewed', $status_parameters)) { - $nested->whereHas('invitations', function ($q){ + $nested->whereHas('invitations', function ($q) { $q->whereNotNull('viewed_date')->whereNotNull('deleted_at'); }); @@ -884,8 +916,9 @@ class BaseExport $first_month_of_year = $this->company->getSetting('first_month_of_year') ?? 1; $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->subYearNoOverflow(); + } $this->start_date = $fin_year_start->format('Y-m-d'); $this->end_date = $fin_year_start->copy()->addYear()->subDay()->format('Y-m-d'); @@ -896,8 +929,9 @@ class BaseExport $fin_year_start = now()->createFromDate(now()->year, $first_month_of_year, 1); $fin_year_start->subYearNoOverflow(); - if(now()->subYear()->lt($fin_year_start)) + if(now()->subYear()->lt($fin_year_start)) { $fin_year_start->subYearNoOverflow(); + } $this->start_date = $fin_year_start->format('Y-m-d'); $this->end_date = $fin_year_start->copy()->addYear()->subDay()->format('Y-m-d'); @@ -914,7 +948,7 @@ class BaseExport } /** - * Returns the merged array of + * Returns the merged array of * the entity with the matching * item report keys * @@ -979,8 +1013,9 @@ class BaseExport $prefix = ctrans('texts.expense')." "; $key = array_search($value, $this->expense_report_keys); - if(!$key && $value == 'expense.category') - $key = 'category'; + if(!$key && $value == 'expense.category') { + $key = 'category'; + } } if(!$key) { @@ -1024,42 +1059,36 @@ class BaseExport $key = str_replace('product.', '', $key); $key = str_replace('task.', '', $key); - if(stripos($value, 'custom_value') !== false) - { + if(stripos($value, 'custom_value') !== false) { $parts = explode(".", $value); - if(count($parts) == 2 && in_array($parts[0], ['credit','quote','invoice','purchase_order','recurring_invoice'])){ + if(count($parts) == 2 && in_array($parts[0], ['credit','quote','invoice','purchase_order','recurring_invoice'])) { $entity = "invoice".substr($parts[1], -1); $prefix = ctrans("texts.".$parts[0]); $fallback = "custom_value".substr($parts[1], -1); $custom_field_label = $helper->makeCustomField($this->company->custom_fields, $entity); - if(strlen($custom_field_label) > 1) + if(strlen($custom_field_label) > 1) { $header[] = $custom_field_label; - else { + } else { $header[] = $prefix . " ". ctrans("texts.{$fallback}"); } - } - elseif(count($parts) == 2 && (stripos($parts[0], 'vendor_contact') !== false || stripos($parts[0], 'contact') !== false)) { + } elseif(count($parts) == 2 && (stripos($parts[0], 'vendor_contact') !== false || stripos($parts[0], 'contact') !== false)) { $parts[0] = str_replace('vendor_contact', 'contact', $parts[0]); $entity = "contact".substr($parts[1], -1); $custom_field_string = strlen($helper->makeCustomField($this->company->custom_fields, $entity)) > 1 ? $helper->makeCustomField($this->company->custom_fields, $entity) : ctrans("texts.{$parts[1]}"); $header[] = ctrans("texts.{$parts[0]}") . " " . $custom_field_string; - } - elseif(count($parts) == 2 && in_array(substr($original_key, 0, -1), ['credit','quote','invoice','purchase_order','recurring_invoice','task'])){ - $custom_field_string = strlen($helper->makeCustomField($this->company->custom_fields, "product".substr($original_key,-1))) > 1 ? $helper->makeCustomField($this->company->custom_fields, "product".substr($original_key,-1)) : ctrans("texts.{$parts[1]}"); + } elseif(count($parts) == 2 && in_array(substr($original_key, 0, -1), ['credit','quote','invoice','purchase_order','recurring_invoice','task'])) { + $custom_field_string = strlen($helper->makeCustomField($this->company->custom_fields, "product".substr($original_key, -1))) > 1 ? $helper->makeCustomField($this->company->custom_fields, "product".substr($original_key, -1)) : ctrans("texts.{$parts[1]}"); $header[] = ctrans("texts.{$parts[0]}") . " " . $custom_field_string; - } - else{ + } else { $header[] = "{$prefix}" . ctrans("texts.{$key}"); } - } - else - { + } else { $header[] = "{$prefix}" . ctrans("texts.{$key}"); } } @@ -1104,7 +1133,7 @@ class BaseExport $value = 'image'; } - if($value == 'tax_id') { + if($value == 'tax_id') { $column_key = 'tax_category'; $value = 'tax_category'; } @@ -1119,7 +1148,7 @@ class BaseExport } return $clean_row; - } + } public function processItemMetaData(array $row, $resource): array { @@ -1146,11 +1175,13 @@ class BaseExport $column_key = $value; - if($value == 'type_id' || $value == 'item.type_id') + if($value == 'type_id' || $value == 'item.type_id') { $column_key = 'type'; + } - if($value == 'tax_id' || $value == 'item.tax_id') + if($value == 'tax_id' || $value == 'item.tax_id') { $column_key = 'tax_category'; + } $clean_row[$key]['entity'] = $report_keys[0]; $clean_row[$key]['id'] = $report_keys[1] ?? $report_keys[0]; @@ -1162,6 +1193,6 @@ class BaseExport } return $clean_row; - } + } } diff --git a/app/Export/CSV/ClientExport.php b/app/Export/CSV/ClientExport.php index 16f9ca154d70..29178f5236e8 100644 --- a/app/Export/CSV/ClientExport.php +++ b/app/Export/CSV/ClientExport.php @@ -11,16 +11,16 @@ namespace App\Export\CSV; +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\Transformers\ClientTransformer; use Illuminate\Database\Eloquent\Builder; -use App\Transformers\ClientContactTransformer; +use Illuminate\Support\Facades\App; +use League\Csv\Writer; class ClientExport extends BaseExport { @@ -92,9 +92,9 @@ class ClientExport extends BaseExport $headerdisplay = $this->buildHeader(); - $header = collect($this->input['report_keys'])->map(function ($key, $value) use($headerdisplay){ - return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; - })->toArray(); + $header = collect($this->input['report_keys'])->map(function ($key, $value) use ($headerdisplay) { + return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; + })->toArray(); $report = $query->cursor() ->map(function ($client) { @@ -126,7 +126,7 @@ class ClientExport extends BaseExport $query = $this->addDateRange($query); - return $query; + return $query; } @@ -191,10 +191,11 @@ class ClientExport extends BaseExport $clean_row[$key]['value'] = $row[$column_key]; $clean_row[$key]['identifier'] = $value; - if(in_array($clean_row[$key]['id'], ['paid_to_date', 'balance', 'credit_balance','payment_balance'])) + if(in_array($clean_row[$key]['id'], ['paid_to_date', 'balance', 'credit_balance','payment_balance'])) { $clean_row[$key]['display_value'] = Number::formatMoney($row[$column_key], $resource); - else + } else { $clean_row[$key]['display_value'] = $row[$column_key]; + } } diff --git a/app/Export/CSV/ContactExport.php b/app/Export/CSV/ContactExport.php index e07cf64d328d..558c69331958 100644 --- a/app/Export/CSV/ContactExport.php +++ b/app/Export/CSV/ContactExport.php @@ -88,9 +88,9 @@ class ContactExport extends BaseExport $headerdisplay = $this->buildHeader(); - $header = collect($this->input['report_keys'])->map(function ($key, $value) use($headerdisplay){ - return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; - })->toArray(); + $header = collect($this->input['report_keys'])->map(function ($key, $value) use ($headerdisplay) { + return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; + })->toArray(); $report = $query->cursor() ->map(function ($contact) { diff --git a/app/Export/CSV/CreditExport.php b/app/Export/CSV/CreditExport.php index c5c05f3c23e2..d0a29ea3c780 100644 --- a/app/Export/CSV/CreditExport.php +++ b/app/Export/CSV/CreditExport.php @@ -11,15 +11,15 @@ namespace App\Export\CSV; +use App\Libraries\MultiDB; +use App\Models\Company; +use App\Models\Credit; +use App\Transformers\CreditTransformer; use App\Utils\Ninja; use App\Utils\Number; -use App\Models\Credit; -use League\Csv\Writer; -use App\Models\Company; -use App\Libraries\MultiDB; -use Illuminate\Support\Facades\App; -use App\Transformers\CreditTransformer; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Support\Facades\App; +use League\Csv\Writer; class CreditExport extends BaseExport { @@ -43,9 +43,9 @@ class CreditExport extends BaseExport $headerdisplay = $this->buildHeader(); - $header = collect($this->input['report_keys'])->map(function ($key, $value) use($headerdisplay){ - return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; - })->toArray(); + $header = collect($this->input['report_keys'])->map(function ($key, $value) use ($headerdisplay) { + return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; + })->toArray(); $report = $query->cursor() ->map(function ($credit) { @@ -70,10 +70,11 @@ class CreditExport extends BaseExport $clean_row[$key]['value'] = $row[$column_key]; $clean_row[$key]['identifier'] = $value; - if(in_array($clean_row[$key]['id'], ['paid_to_date','total_taxes','amount', 'balance', 'partial', 'refunded', 'applied','unit_cost','cost','price'])) + if(in_array($clean_row[$key]['id'], ['paid_to_date','total_taxes','amount', 'balance', 'partial', 'refunded', 'applied','unit_cost','cost','price'])) { $clean_row[$key]['display_value'] = Number::formatMoney($row[$column_key], $resource->client); - else + } else { $clean_row[$key]['display_value'] = $row[$column_key]; + } } @@ -139,10 +140,9 @@ class CreditExport extends BaseExport $entity[$keyval] = $transformed_credit[$credit_key]; } elseif (isset($transformed_credit[$keyval])) { $entity[$keyval] = $transformed_credit[$keyval]; - } elseif(isset($transformed_credit[$searched_credit_key])){ + } elseif(isset($transformed_credit[$searched_credit_key])) { $entity[$keyval] = $transformed_credit[$searched_credit_key]; - } - else { + } else { $entity[$keyval] = $this->resolveKey($keyval, $credit, $this->credit_transformer); } diff --git a/app/Export/CSV/DocumentExport.php b/app/Export/CSV/DocumentExport.php index cc4482c063d3..a5518da707bc 100644 --- a/app/Export/CSV/DocumentExport.php +++ b/app/Export/CSV/DocumentExport.php @@ -49,9 +49,9 @@ class DocumentExport extends BaseExport $headerdisplay = $this->buildHeader(); - $header = collect($this->input['report_keys'])->map(function ($key, $value) use($headerdisplay){ - return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; - })->toArray(); + $header = collect($this->input['report_keys'])->map(function ($key, $value) use ($headerdisplay) { + return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; + })->toArray(); $report = $query->cursor() ->map(function ($document) { diff --git a/app/Export/CSV/ExpenseExport.php b/app/Export/CSV/ExpenseExport.php index 7b51401629b7..ee8d5bf0c729 100644 --- a/app/Export/CSV/ExpenseExport.php +++ b/app/Export/CSV/ExpenseExport.php @@ -43,9 +43,9 @@ class ExpenseExport extends BaseExport $headerdisplay = $this->buildHeader(); - $header = collect($this->input['report_keys'])->map(function ($key, $value) use($headerdisplay){ - return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; - })->toArray(); + $header = collect($this->input['report_keys'])->map(function ($key, $value) use ($headerdisplay) { + return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; + })->toArray(); $report = $query->cursor() ->map(function ($resource) { diff --git a/app/Export/CSV/InvoiceExport.php b/app/Export/CSV/InvoiceExport.php index 4dc4ee3d8b94..4773ec3aa2de 100644 --- a/app/Export/CSV/InvoiceExport.php +++ b/app/Export/CSV/InvoiceExport.php @@ -11,16 +11,14 @@ namespace App\Export\CSV; -use App\Utils\Ninja; -use App\Utils\Number; -use League\Csv\Writer; +use App\Libraries\MultiDB; use App\Models\Company; use App\Models\Invoice; -use App\Libraries\MultiDB; -use App\Export\CSV\BaseExport; -use Illuminate\Support\Facades\App; use App\Transformers\InvoiceTransformer; +use App\Utils\Ninja; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Support\Facades\App; +use League\Csv\Writer; class InvoiceExport extends BaseExport { @@ -74,9 +72,9 @@ class InvoiceExport extends BaseExport $headerdisplay = $this->buildHeader(); - $header = collect($this->input['report_keys'])->map(function ($key, $value) use($headerdisplay){ - return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; - })->toArray(); + $header = collect($this->input['report_keys'])->map(function ($key, $value) use ($headerdisplay) { + return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; + })->toArray(); $report = $query->cursor() ->map(function ($resource) { diff --git a/app/Export/CSV/InvoiceItemExport.php b/app/Export/CSV/InvoiceItemExport.php index ba2dc00da4f5..8ccc8a39ff55 100644 --- a/app/Export/CSV/InvoiceItemExport.php +++ b/app/Export/CSV/InvoiceItemExport.php @@ -82,9 +82,9 @@ class InvoiceItemExport extends BaseExport $headerdisplay = $this->buildHeader(); - $header = collect($this->input['report_keys'])->map(function ($key, $value) use($headerdisplay){ - return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; - })->toArray(); + $header = collect($this->input['report_keys'])->map(function ($key, $value) use ($headerdisplay) { + return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; + })->toArray(); $query->cursor() @@ -131,7 +131,7 @@ class InvoiceItemExport extends BaseExport $transformed_items = []; foreach ($invoice->line_items as $item) { - $item_array = []; + $item_array = []; foreach (array_values(array_intersect($this->input['report_keys'], $this->item_report_keys)) as $key) { //items iterator produces item array @@ -139,16 +139,17 @@ class InvoiceItemExport extends BaseExport $tmp_key = str_replace("item.", "", $key); - if($tmp_key == 'type_id') + if($tmp_key == 'type_id') { $tmp_key = 'type'; + } - if($tmp_key == 'tax_id') + if($tmp_key == 'tax_id') { $tmp_key = 'tax_category'; + } if (property_exists($item, $tmp_key)) { $item_array[$key] = $item->{$tmp_key}; - } - else { + } else { $item_array[$key] = ''; } } @@ -174,15 +175,15 @@ class InvoiceItemExport extends BaseExport $parts = explode('.', $key); - if(is_array($parts) && $parts[0] == 'item') + if(is_array($parts) && $parts[0] == 'item') { continue; + } if (is_array($parts) && $parts[0] == 'invoice' && array_key_exists($parts[1], $transformed_invoice)) { $entity[$key] = $transformed_invoice[$parts[1]]; - }else if (array_key_exists($key, $transformed_invoice)) { + } elseif (array_key_exists($key, $transformed_invoice)) { $entity[$key] = $transformed_invoice[$key]; - } - else { + } else { $entity[$key] = $this->resolveKey($key, $invoice, $this->invoice_transformer); } } diff --git a/app/Export/CSV/ProductExport.php b/app/Export/CSV/ProductExport.php index d36c31b54e60..7963cb76be6c 100644 --- a/app/Export/CSV/ProductExport.php +++ b/app/Export/CSV/ProductExport.php @@ -41,14 +41,14 @@ class ProductExport extends BaseExport $headerdisplay = $this->buildHeader(); - $header = collect($this->input['report_keys'])->map(function ($key, $value) use($headerdisplay){ - return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; - })->toArray(); + $header = collect($this->input['report_keys'])->map(function ($key, $value) use ($headerdisplay) { + return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; + })->toArray(); $report = $query->cursor() ->map(function ($resource) { $row = $this->buildRow($resource); - return $this->processMetaData($row, $resource); + return $this->processMetaData($row, $resource); })->toArray(); return array_merge(['columns' => $header], $report); diff --git a/app/Export/CSV/PurchaseOrderExport.php b/app/Export/CSV/PurchaseOrderExport.php index 45e8a6adb1b7..5f2ba4fbc1e2 100644 --- a/app/Export/CSV/PurchaseOrderExport.php +++ b/app/Export/CSV/PurchaseOrderExport.php @@ -11,15 +11,14 @@ namespace App\Export\CSV; -use App\Utils\Ninja; -use App\Utils\Number; -use League\Csv\Writer; -use App\Models\Company; use App\Libraries\MultiDB; +use App\Models\Company; use App\Models\PurchaseOrder; -use Illuminate\Support\Facades\App; use App\Transformers\PurchaseOrderTransformer; +use App\Utils\Ninja; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Support\Facades\App; +use League\Csv\Writer; class PurchaseOrderExport extends BaseExport { @@ -116,9 +115,9 @@ class PurchaseOrderExport extends BaseExport $headerdisplay = $this->buildHeader(); - $header = collect($this->input['report_keys'])->map(function ($key, $value) use($headerdisplay){ - return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; - })->toArray(); + $header = collect($this->input['report_keys'])->map(function ($key, $value) use ($headerdisplay) { + return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; + })->toArray(); $report = $query->cursor() ->map(function ($resource) { diff --git a/app/Export/CSV/PurchaseOrderItemExport.php b/app/Export/CSV/PurchaseOrderItemExport.php index 3738ec5b6dd0..1351be356296 100644 --- a/app/Export/CSV/PurchaseOrderItemExport.php +++ b/app/Export/CSV/PurchaseOrderItemExport.php @@ -11,14 +11,14 @@ namespace App\Export\CSV; -use App\Utils\Ninja; -use League\Csv\Writer; -use App\Models\Company; use App\Libraries\MultiDB; +use App\Models\Company; use App\Models\PurchaseOrder; -use Illuminate\Support\Facades\App; -use Illuminate\Database\Eloquent\Builder; use App\Transformers\PurchaseOrderTransformer; +use App\Utils\Ninja; +use Illuminate\Database\Eloquent\Builder; +use Illuminate\Support\Facades\App; +use League\Csv\Writer; class PurchaseOrderItemExport extends BaseExport { @@ -74,21 +74,21 @@ class PurchaseOrderItemExport extends BaseExport $headerdisplay = $this->buildHeader(); - $header = collect($this->input['report_keys'])->map(function ($key, $value) use($headerdisplay){ - return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; - })->toArray(); + $header = collect($this->input['report_keys'])->map(function ($key, $value) use ($headerdisplay) { + return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; + })->toArray(); $query->cursor() ->each(function ($resource) { - $this->iterateItems($resource); + $this->iterateItems($resource); - foreach($this->storage_array as $row) { - $this->storage_item_array[] = $this->processItemMetaData($row, $resource); - } + foreach($this->storage_array as $row) { + $this->storage_item_array[] = $this->processItemMetaData($row, $resource); + } - $this->storage_array = []; + $this->storage_array = []; - }); + }); return array_merge(['columns' => $header], $this->storage_item_array); } diff --git a/app/Export/CSV/QuoteItemExport.php b/app/Export/CSV/QuoteItemExport.php index 0db08629c664..fe8cbb593a71 100644 --- a/app/Export/CSV/QuoteItemExport.php +++ b/app/Export/CSV/QuoteItemExport.php @@ -76,23 +76,23 @@ class QuoteItemExport extends BaseExport $headerdisplay = $this->buildHeader(); - $header = collect($this->input['report_keys'])->map(function ($key, $value) use($headerdisplay){ - return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; - })->toArray(); + $header = collect($this->input['report_keys'])->map(function ($key, $value) use ($headerdisplay) { + return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; + })->toArray(); - $query->cursor() - ->each(function ($resource) { - $this->iterateItems($resource); + $query->cursor() + ->each(function ($resource) { + $this->iterateItems($resource); - foreach($this->storage_array as $row) { - $this->storage_item_array[] = $this->processItemMetaData($row, $resource); - } + foreach($this->storage_array as $row) { + $this->storage_item_array[] = $this->processItemMetaData($row, $resource); + } - $this->storage_array = []; + $this->storage_array = []; - }); + }); - return array_merge(['columns' => $header], $this->storage_item_array); + return array_merge(['columns' => $header], $this->storage_item_array); } @@ -103,7 +103,7 @@ class QuoteItemExport extends BaseExport //load the CSV document from a string $this->csv = Writer::createFromString(); - $query = $this->init(); + $query = $this->init(); //insert the header $this->csv->insertOne($this->buildHeader()); @@ -127,7 +127,7 @@ class QuoteItemExport extends BaseExport $transformed_items = []; foreach ($quote->line_items as $item) { - $item_array = []; + $item_array = []; foreach (array_values(array_intersect($this->input['report_keys'], $this->item_report_keys)) as $key) { //items iterator produces item array @@ -135,16 +135,17 @@ class QuoteItemExport extends BaseExport $tmp_key = str_replace("item.", "", $key); - if($tmp_key == 'type_id') + if($tmp_key == 'type_id') { $tmp_key = 'type'; + } - if($tmp_key == 'tax_id') + if($tmp_key == 'tax_id') { $tmp_key = 'tax_category'; + } if (property_exists($item, $tmp_key)) { $item_array[$key] = $item->{$tmp_key}; - } - else { + } else { $item_array[$key] = ''; } } diff --git a/app/Export/CSV/RecurringInvoiceExport.php b/app/Export/CSV/RecurringInvoiceExport.php index 3234b0674337..b88601ba997b 100644 --- a/app/Export/CSV/RecurringInvoiceExport.php +++ b/app/Export/CSV/RecurringInvoiceExport.php @@ -88,9 +88,9 @@ class RecurringInvoiceExport extends BaseExport $headerdisplay = $this->buildHeader(); - $header = collect($this->input['report_keys'])->map(function ($key, $value) use($headerdisplay){ - return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; - })->toArray(); + $header = collect($this->input['report_keys'])->map(function ($key, $value) use ($headerdisplay) { + return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; + })->toArray(); $report = $query->cursor() ->map(function ($resource) { diff --git a/app/Export/CSV/TaskExport.php b/app/Export/CSV/TaskExport.php index b2eb6425c527..7d8271d86003 100644 --- a/app/Export/CSV/TaskExport.php +++ b/app/Export/CSV/TaskExport.php @@ -101,17 +101,16 @@ class TaskExport extends BaseExport $headerdisplay = $this->buildHeader(); - $header = collect($this->input['report_keys'])->map(function ($key, $value) use($headerdisplay){ - return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; - })->toArray(); + $header = collect($this->input['report_keys'])->map(function ($key, $value) use ($headerdisplay) { + return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; + })->toArray(); $query->cursor() ->each(function ($resource) { $this->buildRow($resource); - foreach($this->storage_array as $row) - { + foreach($this->storage_array as $row) { $this->storage_item_array[] = $this->processMetaData($row, $resource); } diff --git a/app/Export/CSV/VendorExport.php b/app/Export/CSV/VendorExport.php index 062c09187d30..259f53c59c72 100644 --- a/app/Export/CSV/VendorExport.php +++ b/app/Export/CSV/VendorExport.php @@ -12,8 +12,8 @@ namespace App\Export\CSV; use App\Libraries\MultiDB; -use App\Models\Vendor; use App\Models\Company; +use App\Models\Vendor; use App\Transformers\VendorContactTransformer; use App\Transformers\VendorTransformer; use App\Utils\Ninja; @@ -73,9 +73,9 @@ class VendorExport extends BaseExport $headerdisplay = $this->buildHeader(); - $header = collect($this->input['report_keys'])->map(function ($key, $value) use($headerdisplay){ - return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; - })->toArray(); + $header = collect($this->input['report_keys'])->map(function ($key, $value) use ($headerdisplay) { + return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; + })->toArray(); $report = $query->cursor() ->map(function ($resource) { diff --git a/app/Factory/CompanyFactory.php b/app/Factory/CompanyFactory.php index 52324d698a5a..b48904b6d3b2 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/Factory/InvoiceItemFactory.php b/app/Factory/InvoiceItemFactory.php index 153c5baf2527..f81872dc8cdb 100644 --- a/app/Factory/InvoiceItemFactory.php +++ b/app/Factory/InvoiceItemFactory.php @@ -63,7 +63,7 @@ class InvoiceItemFactory $item->line_total = $item->quantity * $item->cost; $item->is_amount_discount = true; $item->discount = $faker->numberBetween(1, 10); - $item->notes = str_replace(['"',"'"],['',""], $faker->realText(20)); + $item->notes = str_replace(['"',"'"], ['',""], $faker->realText(20)); $item->product_key = $faker->word(); // $item->custom_value1 = $faker->realText(10); // $item->custom_value2 = $faker->realText(10); diff --git a/app/Factory/RecurringExpenseToExpenseFactory.php b/app/Factory/RecurringExpenseToExpenseFactory.php index 921130ac9118..4d6bff4c4cc1 100644 --- a/app/Factory/RecurringExpenseToExpenseFactory.php +++ b/app/Factory/RecurringExpenseToExpenseFactory.php @@ -248,10 +248,10 @@ class RecurringExpenseToExpenseFactory $final_date = now()->addMonths($output-now()->month); $output = \sprintf( - '%s %s', - $final_date->translatedFormat('F'), - $final_date->year, - ); + '%s %s', + $final_date->translatedFormat('F'), + $final_date->year, + ); } $value = preg_replace( diff --git a/app/Factory/UserFactory.php b/app/Factory/UserFactory.php index 9b15037f625c..c8fbc4f4d3d4 100644 --- a/app/Factory/UserFactory.php +++ b/app/Factory/UserFactory.php @@ -27,7 +27,7 @@ class UserFactory $user->last_login = now(); $user->failed_logins = 0; $user->signature = ''; - $user->theme_id = 0; + $user->theme_id = 0; $user->user_logged_in_notification = true; return $user; diff --git a/app/Filters/BankTransactionFilters.php b/app/Filters/BankTransactionFilters.php index 15c02a7b9768..11d27df79025 100644 --- a/app/Filters/BankTransactionFilters.php +++ b/app/Filters/BankTransactionFilters.php @@ -53,19 +53,19 @@ class BankTransactionFilters extends QueryFilters } -/** - * Filter based on client status. - * - * Statuses we need to handle - * - all - * - unmatched - * - matched - * - converted - * - deposits - * - withdrawals - * - * @return Builder - */ + /** + * Filter based on client status. + * + * Statuses we need to handle + * - all + * - unmatched + * - matched + * - converted + * - deposits + * - withdrawals + * + * @return Builder + */ public function client_status(string $value = ''): Builder { if (strlen($value) == 0) { diff --git a/app/Filters/CreditFilters.php b/app/Filters/CreditFilters.php index bd17e34819a5..a69daa60ddd4 100644 --- a/app/Filters/CreditFilters.php +++ b/app/Filters/CreditFilters.php @@ -144,7 +144,7 @@ class CreditFilters extends QueryFilters return $this->builder->company(); } -// return $this->builder->whereCompanyId(auth()->user()->company()->id); + // return $this->builder->whereCompanyId(auth()->user()->company()->id); } /** diff --git a/app/Filters/DesignFilters.php b/app/Filters/DesignFilters.php index e1abed8c9a1b..bd489b05c41f 100644 --- a/app/Filters/DesignFilters.php +++ b/app/Filters/DesignFilters.php @@ -77,7 +77,7 @@ class DesignFilters extends QueryFilters /** @var \App\Models\User $user */ $user = auth()->user(); - return $this->builder->where(function ($query) use($user){ + return $this->builder->where(function ($query) use ($user) { $query->where('company_id', $user->company()->id)->orWhere('company_id', null)->orderBy('id', 'asc'); }); } diff --git a/app/Filters/ExpenseFilters.php b/app/Filters/ExpenseFilters.php index a2ddc98e3cd0..264be55d037e 100644 --- a/app/Filters/ExpenseFilters.php +++ b/app/Filters/ExpenseFilters.php @@ -40,8 +40,8 @@ class ExpenseFilters extends QueryFilters ->orWhere('custom_value3', 'like', '%'.$filter.'%') ->orWhere('custom_value4', 'like', '%'.$filter.'%') ->orWhereHas('category', function ($q) use ($filter) { - $q->where('name', 'like', '%'.$filter.'%'); - }); + $q->where('name', 'like', '%'.$filter.'%'); + }); }); } @@ -125,9 +125,9 @@ class ExpenseFilters extends QueryFilters $search_key = $split[0] == 'client' ? 'client_id' : 'project_id'; - return $this->builder->whereHas('invoice', function ($query) use ($search_key, $split){ - $query->where($search_key, $this->decodePrimaryKey($split[1])) - ->whereIn('status_id', [\App\Models\Invoice::STATUS_DRAFT, \App\Models\Invoice::STATUS_SENT, \App\Models\Invoice::STATUS_PARTIAL]); + return $this->builder->whereHas('invoice', function ($query) use ($search_key, $split) { + $query->where($search_key, $this->decodePrimaryKey($split[1])) + ->whereIn('status_id', [\App\Models\Invoice::STATUS_DRAFT, \App\Models\Invoice::STATUS_SENT, \App\Models\Invoice::STATUS_PARTIAL]); }); } diff --git a/app/Filters/InvoiceFilters.php b/app/Filters/InvoiceFilters.php index 91e426192fde..58af558b99b8 100644 --- a/app/Filters/InvoiceFilters.php +++ b/app/Filters/InvoiceFilters.php @@ -11,14 +11,13 @@ namespace App\Filters; -use RuntimeException; use App\Models\Client; use App\Models\Invoice; -use App\Filters\QueryFilters; -use InvalidArgumentException; -use Illuminate\Support\Carbon; use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Support\Carbon; +use InvalidArgumentException; +use RuntimeException; /** * InvoiceFilters. @@ -241,15 +240,13 @@ class InvoiceFilters extends QueryFilters return $this->builder; } - try{ + try { $start_date = Carbon::parse($parts[1]); $end_date = Carbon::parse($parts[2]); return $this->builder->whereBetween($parts[0], [$start_date, $end_date]); - } - - catch(\Exception $e){ + } catch(\Exception $e) { return $this->builder; } diff --git a/app/Filters/PaymentFilters.php b/app/Filters/PaymentFilters.php index bc16744d4be8..dbdb839bde88 100644 --- a/app/Filters/PaymentFilters.php +++ b/app/Filters/PaymentFilters.php @@ -12,9 +12,8 @@ namespace App\Filters; use App\Models\Payment; -use Illuminate\Support\Carbon; use Illuminate\Database\Eloquent\Builder; -use Illuminate\Contracts\Database\Eloquent\Builder as EloquentBuilder; +use Illuminate\Support\Carbon; /** * PaymentFilters. @@ -37,39 +36,39 @@ class PaymentFilters extends QueryFilters return $this->builder->where(function ($query) use ($filter) { $query->where('amount', 'like', '%'.$filter.'%') ->orWhere('date', 'like', '%'.$filter.'%') - ->orWhere('number','like', '%'.$filter.'%') + ->orWhere('number', 'like', '%'.$filter.'%') ->orWhere('transaction_reference', 'like', '%'.$filter.'%') ->orWhere('custom_value1', 'like', '%'.$filter.'%') ->orWhere('custom_value2', 'like', '%'.$filter.'%') ->orWhere('custom_value3', 'like', '%'.$filter.'%') ->orWhere('custom_value4', 'like', '%'.$filter.'%') ->orWhereHas('client', function ($q) use ($filter) { - $q->where('name', 'like', '%'.$filter.'%'); - }) + $q->where('name', 'like', '%'.$filter.'%'); + }) ->orWhereHas('client.contacts', function ($q) use ($filter) { - $q->where('first_name', 'like', '%'.$filter.'%') - ->orWhere('last_name', 'like', '%'.$filter.'%') - ->orWhere('email', 'like', '%'.$filter.'%'); - }); + $q->where('first_name', 'like', '%'.$filter.'%') + ->orWhere('last_name', 'like', '%'.$filter.'%') + ->orWhere('email', 'like', '%'.$filter.'%'); + }); }); } - /** - * Filter based on client status. - * - * Statuses we need to handle - * - all - * - pending - * - cancelled - * - failed - * - completed - * - partially refunded - * - refunded - * - * @param string $value The payment status as seen by the client - * @return Builder - */ + /** + * Filter based on client status. + * + * Statuses we need to handle + * - all + * - pending + * - cancelled + * - failed + * - completed + * - partially refunded + * - refunded + * + * @param string $value The payment status as seen by the client + * @return Builder + */ public function client_status(string $value = ''): Builder { if (strlen($value) == 0) { @@ -190,15 +189,13 @@ class PaymentFilters extends QueryFilters return $this->builder; } - try{ + try { $start_date = Carbon::parse($parts[1]); $end_date = Carbon::parse($parts[2]); return $this->builder->whereBetween($parts[0], [$start_date, $end_date]); - } - - catch(\Exception $e){ + } catch(\Exception $e) { return $this->builder; } diff --git a/app/Filters/PurchaseOrderFilters.php b/app/Filters/PurchaseOrderFilters.php index 8948a619f451..0d5c1244987a 100644 --- a/app/Filters/PurchaseOrderFilters.php +++ b/app/Filters/PurchaseOrderFilters.php @@ -145,7 +145,7 @@ class PurchaseOrderFilters extends QueryFilters return $this->builder->company(); } -// return $this->builder->whereCompanyId(auth()->user()->company()->id); + // return $this->builder->whereCompanyId(auth()->user()->company()->id); } /** diff --git a/app/Filters/QuoteFilters.php b/app/Filters/QuoteFilters.php index 220960a219d8..c28d0450cbfd 100644 --- a/app/Filters/QuoteFilters.php +++ b/app/Filters/QuoteFilters.php @@ -42,10 +42,10 @@ class QuoteFilters extends QueryFilters $q->where('name', 'like', '%'.$filter.'%'); }) ->orWhereHas('client.contacts', function ($q) use ($filter) { - $q->where('first_name', 'like', '%'.$filter.'%') - ->orWhere('last_name', 'like', '%'.$filter.'%') - ->orWhere('email', 'like', '%'.$filter.'%'); - }); + $q->where('first_name', 'like', '%'.$filter.'%') + ->orWhere('last_name', 'like', '%'.$filter.'%') + ->orWhere('email', 'like', '%'.$filter.'%'); + }); }); } @@ -146,7 +146,7 @@ class QuoteFilters extends QueryFilters return $this->builder; } - if($sort_col[0] == 'client_id'){ + if($sort_col[0] == 'client_id') { return $this->builder->orderBy(\App\Models\Client::select('name') ->whereColumn('clients.id', 'quotes.client_id'), $sort_col[1]); diff --git a/app/Filters/RecurringInvoiceFilters.php b/app/Filters/RecurringInvoiceFilters.php index 71fcca9d101f..81060eed6123 100644 --- a/app/Filters/RecurringInvoiceFilters.php +++ b/app/Filters/RecurringInvoiceFilters.php @@ -34,20 +34,20 @@ class RecurringInvoiceFilters extends QueryFilters } return $this->builder->where(function ($query) use ($filter) { - $query->where('date', 'like', '%'.$filter.'%') - ->orWhere('amount', 'like', '%'.$filter.'%') - ->orWhere('custom_value1', 'like', '%'.$filter.'%') - ->orWhere('custom_value2', 'like', '%'.$filter.'%') - ->orWhere('custom_value3', 'like', '%'.$filter.'%') - ->orWhere('custom_value4', 'like', '%'.$filter.'%') - ->orWhereHas('client', function ($q) use ($filter) { - $q->where('name', 'like', '%'.$filter.'%'); - }) - ->orWhereHas('client.contacts', function ($q) use ($filter) { - $q->where('first_name', 'like', '%'.$filter.'%') - ->orWhere('last_name', 'like', '%'.$filter.'%') - ->orWhere('email', 'like', '%'.$filter.'%'); - }); + $query->where('date', 'like', '%'.$filter.'%') + ->orWhere('amount', 'like', '%'.$filter.'%') + ->orWhere('custom_value1', 'like', '%'.$filter.'%') + ->orWhere('custom_value2', 'like', '%'.$filter.'%') + ->orWhere('custom_value3', 'like', '%'.$filter.'%') + ->orWhere('custom_value4', 'like', '%'.$filter.'%') + ->orWhereHas('client', function ($q) use ($filter) { + $q->where('name', 'like', '%'.$filter.'%'); + }) + ->orWhereHas('client.contacts', function ($q) use ($filter) { + $q->where('first_name', 'like', '%'.$filter.'%') + ->orWhere('last_name', 'like', '%'.$filter.'%') + ->orWhere('email', 'like', '%'.$filter.'%'); + }); }); } diff --git a/app/Filters/TaskFilters.php b/app/Filters/TaskFilters.php index 481fb4429902..eb3ca35c414b 100644 --- a/app/Filters/TaskFilters.php +++ b/app/Filters/TaskFilters.php @@ -41,16 +41,16 @@ class TaskFilters extends QueryFilters ->orWhere('custom_value3', 'like', '%'.$filter.'%') ->orWhere('custom_value4', 'like', '%'.$filter.'%') ->orWhereHas('project', function ($q) use ($filter) { - $q->where('name', 'like', '%'.$filter.'%'); - }) + $q->where('name', 'like', '%'.$filter.'%'); + }) ->orWhereHas('client', function ($q) use ($filter) { - $q->where('name', 'like', '%'.$filter.'%'); - }) + $q->where('name', 'like', '%'.$filter.'%'); + }) ->orWhereHas('client.contacts', function ($q) use ($filter) { - $q->where('first_name', 'like', '%'.$filter.'%') - ->orWhere('last_name', 'like', '%'.$filter.'%') - ->orWhere('email', 'like', '%'.$filter.'%'); - }); + $q->where('first_name', 'like', '%'.$filter.'%') + ->orWhere('last_name', 'like', '%'.$filter.'%') + ->orWhere('email', 'like', '%'.$filter.'%'); + }); }); } @@ -136,7 +136,7 @@ class TaskFilters extends QueryFilters $status_parameters = explode(',', $value); - if(count($status_parameters) >= 1){ + if(count($status_parameters) >= 1) { $this->builder->where(function ($query) use ($status_parameters) { $query->whereIn('status_id', $this->transformKeys($status_parameters))->whereNull('invoice_id'); diff --git a/app/Helpers/Bank/Yodlee/DTO/AccountSummary.php b/app/Helpers/Bank/Yodlee/DTO/AccountSummary.php index 346496411f4a..d7357c9fe3e1 100644 --- a/app/Helpers/Bank/Yodlee/DTO/AccountSummary.php +++ b/app/Helpers/Bank/Yodlee/DTO/AccountSummary.php @@ -11,10 +11,9 @@ namespace App\Helpers\Bank\Yodlee\DTO; -use Spatie\LaravelData\Data; -use Spatie\LaravelData\Attributes\MapInputName; -use Spatie\LaravelData\Attributes\MapOutputName; use Illuminate\Support\Collection; +use Spatie\LaravelData\Attributes\MapInputName; +use Spatie\LaravelData\Data; /** * [ @@ -72,40 +71,40 @@ use Illuminate\Support\Collection; */ class AccountSummary extends Data { - public ?int $id; + public ?int $id; - #[MapInputName('CONTAINER')] - public ?string $account_type = ''; + #[MapInputName('CONTAINER')] + public ?string $account_type = ''; - #[MapInputName('accountName')] - public ?string $account_name = ''; + #[MapInputName('accountName')] + public ?string $account_name = ''; - #[MapInputName('accountStatus')] - public ?string $account_status = ''; + #[MapInputName('accountStatus')] + public ?string $account_status = ''; - #[MapInputName('accountNumber')] - public ?string $account_number = ''; + #[MapInputName('accountNumber')] + public ?string $account_number = ''; - #[MapInputName('providerAccountId')] - public int $provider_account_id; + #[MapInputName('providerAccountId')] + public int $provider_account_id; - #[MapInputName('providerId')] - public ?string $provider_id = ''; + #[MapInputName('providerId')] + public ?string $provider_id = ''; - #[MapInputName('providerName')] - public ?string $provider_name = ''; + #[MapInputName('providerName')] + public ?string $provider_name = ''; - public ?string $nickname = ''; + public ?string $nickname = ''; - public ?float $current_balance = 0; - public ?string $account_currency = ''; + public ?float $current_balance = 0; + public ?string $account_currency = ''; - public static function prepareForPipeline(Collection $properties) : Collection - { + public static function prepareForPipeline(Collection $properties) : Collection + { - $properties->put('current_balance', $properties['currentBalance']['amount'] ?? 0); - $properties->put('account_currency', $properties['currentBalance']['currency'] ?? 0); + $properties->put('current_balance', $properties['currentBalance']['amount'] ?? 0); + $properties->put('account_currency', $properties['currentBalance']['currency'] ?? 0); - return $properties; - } -} \ No newline at end of file + return $properties; + } +} diff --git a/app/Helpers/Bank/Yodlee/Transformer/AccountTransformer.php b/app/Helpers/Bank/Yodlee/Transformer/AccountTransformer.php index ceb1417c7530..9c44c3784b99 100644 --- a/app/Helpers/Bank/Yodlee/Transformer/AccountTransformer.php +++ b/app/Helpers/Bank/Yodlee/Transformer/AccountTransformer.php @@ -88,20 +88,19 @@ class AccountTransformer implements AccountTransformerInterface if(property_exists($account, 'currentBalance')) { $current_balance = $account->currentBalance->amount ?? 0; $account_currency = $account->currentBalance->currency ?? ''; - } - elseif(property_exists($account, 'balance')){ + } elseif(property_exists($account, 'balance')) { $current_balance = $account->balance->amount ?? 0; $account_currency = $account->balance->currency ?? ''; } $account_status = $account->accountStatus; - if(property_exists($account, 'dataset')){ + if(property_exists($account, 'dataset')) { $dataset = $account->dataset[0]; $status = false; $update = false; - match($dataset->additionalStatus ?? ''){ + match($dataset->additionalStatus ?? '') { 'LOGIN_IN_PROGRESS' => $status = 'Data retrieval in progress.', 'USER_INPUT_REQUIRED' => $status = 'Please reconnect your account, authentication required.', 'LOGIN_SUCCESS' => $status = 'Data retrieval in progress', @@ -113,24 +112,23 @@ class AccountTransformer implements AccountTransformerInterface 'PARTIAL_DATA_RETRIEVED' => $status = 'Partial data update failed.', 'PARTIAL_DATA_RETRIEVED_REM_SCHED' => $status = 'Partial data update failed.', 'SUCCESS' => $status = 'All accounts added or updated successfully.', - default => $status = false + default => $status = false }; - if($status){ + if($status) { $account_status = $status; } - match($dataset->updateEligibility ?? ''){ + match($dataset->updateEligibility ?? '') { 'ALLOW_UPDATE' => $update = 'Account connection stable.', 'ALLOW_UPDATE_WITH_CREDENTIALS' => $update = 'Please reconnect your account with updated credentials.', 'DISALLOW_UPDATE' => $update = 'Update not available due to technical issues.', default => $update = false, }; - if($status && $update){ + if($status && $update) { $account_status = $status . ' - ' . $update; - } - elseif($update){ + } elseif($update) { $account_status = $update; } diff --git a/app/Helpers/Bank/Yodlee/Transformer/IncomeTransformer.php b/app/Helpers/Bank/Yodlee/Transformer/IncomeTransformer.php index 48966aa20382..73f9e7fe31d0 100644 --- a/app/Helpers/Bank/Yodlee/Transformer/IncomeTransformer.php +++ b/app/Helpers/Bank/Yodlee/Transformer/IncomeTransformer.php @@ -127,12 +127,14 @@ class IncomeTransformer implements BankRevenueInterface foreach ($transaction->transaction as $transaction) { //do not store duplicate / pending transactions - if (property_exists($transaction, 'status') && $transaction->status == 'PENDING') + if (property_exists($transaction, 'status') && $transaction->status == 'PENDING') { continue; + } //some object do no store amounts ignore these - if(!property_exists($transaction, 'amount')) + if(!property_exists($transaction, 'amount')) { continue; + } $data[] = $this->transformTransaction($transaction); } diff --git a/app/Helpers/Bank/Yodlee/Yodlee.php b/app/Helpers/Bank/Yodlee/Yodlee.php index f8294becd97e..6b15e1b2d56f 100644 --- a/app/Helpers/Bank/Yodlee/Yodlee.php +++ b/app/Helpers/Bank/Yodlee/Yodlee.php @@ -300,7 +300,7 @@ class Yodlee /** * updateEligibility - * + * * ALLOW_UPDATE * ALLOW_UPDATE_WITH_CREDENTIALS * DISALLOW_UPDATE @@ -308,7 +308,7 @@ class Yodlee /** * additionalStatus - * + * * LOGIN_IN_PROGRESS * DATA_RETRIEVAL_IN_PROGRESS * ACCT_SUMMARY_RECEIVED @@ -339,7 +339,7 @@ class Yodlee * CONSENT_REVOKED * INCORRECT_OAUTH_TOKEN * MIGRATION_IN_PROGRESS - */ + */ /** * IN_PROGRESS LOGIN_IN_PROGRESS Provider login is in progress. @@ -356,12 +356,12 @@ class Yodlee * SUCCESS All accounts under the provider was added or updated successfully. */ - /** - * updateEligibility - * - * ALLOW_UPDATE The status indicates that the account is eligible for the next update and applies to both MFA and non-MFA accounts. For MFA-based accounts, the user may have to provide the MFA details during account refresh. - * ALLOW_UPDATE_WITH_CREDENTIALS The status indicates updating or refreshing the account by directing the user to edit the provided credentials. - * DISALLOW_UPDATE The status indicates the account is not eligible for the update or refresh process due to a site issue or a technical error. - */ + /** + * updateEligibility + * + * ALLOW_UPDATE The status indicates that the account is eligible for the next update and applies to both MFA and non-MFA accounts. For MFA-based accounts, the user may have to provide the MFA details during account refresh. + * ALLOW_UPDATE_WITH_CREDENTIALS The status indicates updating or refreshing the account by directing the user to edit the provided credentials. + * DISALLOW_UPDATE The status indicates the account is not eligible for the update or refresh process due to a site issue or a technical error. + */ } diff --git a/app/Helpers/Epc/EpcQrGenerator.php b/app/Helpers/Epc/EpcQrGenerator.php index 965e2dad1f13..a8f4f1518e97 100644 --- a/app/Helpers/Epc/EpcQrGenerator.php +++ b/app/Helpers/Epc/EpcQrGenerator.php @@ -64,7 +64,7 @@ class EpcQrGenerator } catch(\Exception $e) { nlog("EPC QR failure => ".$e->getMessage()); return ''; - } catch( InvalidArgumentException $e) { + } catch(InvalidArgumentException $e) { nlog("EPC QR failure => ".$e->getMessage()); return ''; } diff --git a/app/Helpers/Invoice/InvoiceItemSum.php b/app/Helpers/Invoice/InvoiceItemSum.php index b1f7fa9e6471..c7d444b9c522 100644 --- a/app/Helpers/Invoice/InvoiceItemSum.php +++ b/app/Helpers/Invoice/InvoiceItemSum.php @@ -11,16 +11,16 @@ namespace App\Helpers\Invoice; -use App\Models\Quote; +use App\DataMapper\BaseSettings; +use App\DataMapper\InvoiceItem; +use App\DataMapper\Tax\RuleInterface; use App\Models\Client; use App\Models\Credit; use App\Models\Invoice; use App\Models\PurchaseOrder; -use App\Models\RecurringQuote; -use App\DataMapper\InvoiceItem; -use App\DataMapper\BaseSettings; +use App\Models\Quote; use App\Models\RecurringInvoice; -use App\DataMapper\Tax\RuleInterface; +use App\Models\RecurringQuote; use App\Utils\Traits\NumberFormatter; class InvoiceItemSum @@ -125,7 +125,7 @@ class InvoiceItemSum private RuleInterface $rule; - public function __construct( RecurringInvoice | Invoice | Quote | Credit | PurchaseOrder | RecurringQuote $invoice) + public function __construct(RecurringInvoice | Invoice | Quote | Credit | PurchaseOrder | RecurringQuote $invoice) { $this->tax_collection = collect([]); @@ -175,14 +175,15 @@ class InvoiceItemSum return $this; } - if (in_array($this->client->company->country()->iso_3166_2, $this->tax_jurisdictions) ) { //only calculate for supported tax jurisdictions + if (in_array($this->client->company->country()->iso_3166_2, $this->tax_jurisdictions)) { //only calculate for supported tax jurisdictions $class = "App\DataMapper\Tax\\".$this->client->company->country()->iso_3166_2."\\Rule"; $this->rule = new $class(); - if($this->rule->regionWithNoTaxCoverage($this->client->country->iso_3166_2)) - return $this; + if($this->rule->regionWithNoTaxCoverage($this->client->country->iso_3166_2)) { + return $this; + } $this->rule ->setEntity($this->invoice) @@ -399,7 +400,7 @@ class InvoiceItemSum $item_tax = 0; //$amount = $this->item->line_total - ($this->item->line_total * ($this->invoice->discount / $this->sub_total)); - $amount = ($this->sub_total > 0) ? $this->item->line_total - ($this->invoice->discount * ( $this->item->line_total / $this->sub_total)) : 0; + $amount = ($this->sub_total > 0) ? $this->item->line_total - ($this->invoice->discount * ($this->item->line_total / $this->sub_total)) : 0; $item_tax_rate1_total = $this->calcAmountLineTax($this->item->tax_rate1, $amount); diff --git a/app/Helpers/Invoice/InvoiceItemSumInclusive.php b/app/Helpers/Invoice/InvoiceItemSumInclusive.php index 7198abbfe8d1..7ca6fb5e2717 100644 --- a/app/Helpers/Invoice/InvoiceItemSumInclusive.php +++ b/app/Helpers/Invoice/InvoiceItemSumInclusive.php @@ -11,14 +11,14 @@ namespace App\Helpers\Invoice; -use App\Models\Quote; +use App\DataMapper\Tax\RuleInterface; use App\Models\Client; use App\Models\Credit; use App\Models\Invoice; use App\Models\PurchaseOrder; -use App\Models\RecurringQuote; +use App\Models\Quote; use App\Models\RecurringInvoice; -use App\DataMapper\Tax\RuleInterface; +use App\Models\RecurringQuote; use App\Utils\Traits\NumberFormatter; class InvoiceItemSumInclusive @@ -404,14 +404,15 @@ class InvoiceItemSumInclusive return $this; } - if (in_array($this->client->company->country()->iso_3166_2, $this->tax_jurisdictions) ) { //only calculate for supported tax jurisdictions + if (in_array($this->client->company->country()->iso_3166_2, $this->tax_jurisdictions)) { //only calculate for supported tax jurisdictions $class = "App\DataMapper\Tax\\".$this->client->company->country()->iso_3166_2."\\Rule"; $this->rule = new $class(); - if($this->rule->regionWithNoTaxCoverage($this->client->country->iso_3166_2)) - return $this; + if($this->rule->regionWithNoTaxCoverage($this->client->country->iso_3166_2)) { + return $this; + } $this->rule ->setEntity($this->invoice) diff --git a/app/Helpers/Invoice/InvoiceSum.php b/app/Helpers/Invoice/InvoiceSum.php index 3f32ed486f78..3767de76c451 100644 --- a/app/Helpers/Invoice/InvoiceSum.php +++ b/app/Helpers/Invoice/InvoiceSum.php @@ -11,15 +11,15 @@ namespace App\Helpers\Invoice; -use App\Models\Quote; -use App\Utils\Number; use App\Models\Credit; use App\Models\Invoice; use App\Models\PurchaseOrder; -use App\Models\RecurringQuote; +use App\Models\Quote; use App\Models\RecurringInvoice; -use Illuminate\Support\Collection; +use App\Models\RecurringQuote; +use App\Utils\Number; use App\Utils\Traits\NumberFormatter; +use Illuminate\Support\Collection; class InvoiceSum { diff --git a/app/Helpers/Invoice/InvoiceSumInclusive.php b/app/Helpers/Invoice/InvoiceSumInclusive.php index 69410f54db9e..3043607fdfd9 100644 --- a/app/Helpers/Invoice/InvoiceSumInclusive.php +++ b/app/Helpers/Invoice/InvoiceSumInclusive.php @@ -11,15 +11,14 @@ namespace App\Helpers\Invoice; -use App\Models\Quote; use App\Models\Credit; use App\Models\Invoice; use App\Models\PurchaseOrder; -use App\Models\RecurringQuote; +use App\Models\Quote; use App\Models\RecurringInvoice; -use Illuminate\Support\Collection; +use App\Models\RecurringQuote; use App\Utils\Traits\NumberFormatter; -use App\Helpers\Invoice\InvoiceItemSumInclusive; +use Illuminate\Support\Collection; class InvoiceSumInclusive { diff --git a/app/Helpers/SwissQr/SwissQrGenerator.php b/app/Helpers/SwissQr/SwissQrGenerator.php index d8c1ad77304c..fa02a550bef4 100644 --- a/app/Helpers/SwissQr/SwissQrGenerator.php +++ b/app/Helpers/SwissQr/SwissQrGenerator.php @@ -57,7 +57,7 @@ class SwissQrGenerator // - with specified amount // - with human-readable additional information // - using your QR-IBAN - // + // // Likely the most common use-case in the business world. // Create a new instance of QrBill, containing default headers with fixed values @@ -83,7 +83,7 @@ class SwissQrGenerator // Add debtor information // Who has to pay the invoice? This part is optional. - // + // // Notice how you can use two different styles of addresses: CombinedAddress or StructuredAddress // They are interchangeable for creditor as well as debtor. $qrBill->setUltimateDebtor( @@ -121,7 +121,7 @@ class SwissQrGenerator $array = str_split($tempInvoiceNumber); foreach ($array as $char) { if (is_numeric($char)) { - // + // } else { if ($char) { $char = strtolower($char); diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 591041c31c66..52a2d8532962 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -11,17 +11,17 @@ namespace App\Http\Controllers; -use App\Models\Account; -use App\Libraries\MultiDB; -use App\Utils\TruthSource; -use App\Models\CompanyUser; -use Illuminate\Http\Response; -use App\Jobs\Account\CreateAccount; -use App\Transformers\AccountTransformer; -use App\Transformers\CompanyUserTransformer; -use Illuminate\Foundation\Bus\DispatchesJobs; use App\Http\Requests\Account\CreateAccountRequest; use App\Http\Requests\Account\UpdateAccountRequest; +use App\Jobs\Account\CreateAccount; +use App\Libraries\MultiDB; +use App\Models\Account; +use App\Models\CompanyUser; +use App\Transformers\AccountTransformer; +use App\Transformers\CompanyUserTransformer; +use App\Utils\TruthSource; +use Illuminate\Foundation\Bus\DispatchesJobs; +use Illuminate\Http\Response; class AccountController extends BaseController { diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index 2b377c7f5ef6..5e7e6068d60f 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -11,19 +11,19 @@ namespace App\Http\Controllers; -use stdClass; -use App\Utils\Ninja; -use App\Models\Activity; -use Illuminate\Http\Request; -use App\Utils\Traits\MakesHash; -use App\Utils\PhantomJS\Phantom; -use App\Utils\HostedPDF\NinjaPdf; -use App\Utils\Traits\Pdf\PdfMaker; -use App\Utils\Traits\Pdf\PageNumbering; -use Illuminate\Support\Facades\Storage; -use App\Transformers\ActivityTransformer; -use App\Http\Requests\Activity\ShowActivityRequest; use App\Http\Requests\Activity\DownloadHistoricalEntityRequest; +use App\Http\Requests\Activity\ShowActivityRequest; +use App\Models\Activity; +use App\Transformers\ActivityTransformer; +use App\Utils\HostedPDF\NinjaPdf; +use App\Utils\Ninja; +use App\Utils\PhantomJS\Phantom; +use App\Utils\Traits\MakesHash; +use App\Utils\Traits\Pdf\PageNumbering; +use App\Utils\Traits\Pdf\PdfMaker; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Storage; +use stdClass; class ActivityController extends BaseController { diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 4d2ad56329ad..afd98dcafb3b 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -11,13 +11,13 @@ namespace App\Http\Controllers\Auth; +use App\Http\Controllers\Controller; +use App\Libraries\MultiDB; use App\Models\Account; use App\Models\Company; -use App\Libraries\MultiDB; -use Illuminate\Http\Request; -use App\Http\Controllers\Controller; -use Illuminate\Support\Facades\Password; use Illuminate\Foundation\Auth\SendsPasswordResetEmails; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Password; class ForgotPasswordController extends Controller { @@ -90,7 +90,7 @@ class ForgotPasswordController extends Controller $account = Account::find($account_id); } - $is_react = request()->has('react') ? true : false; + $is_react = request()->has('react') ? true : false; return $this->render('auth.passwords.request', ['root' => 'themes', 'account' => $account, 'is_react' => $is_react]); } diff --git a/app/Http/Controllers/Auth/PasswordTimeoutController.php b/app/Http/Controllers/Auth/PasswordTimeoutController.php index 4ce83fa46b1c..614a48487ee5 100644 --- a/app/Http/Controllers/Auth/PasswordTimeoutController.php +++ b/app/Http/Controllers/Auth/PasswordTimeoutController.php @@ -25,4 +25,3 @@ class PasswordTimeoutController extends Controller return $cached ? response()->json(['message' => 'Password is valid'], 200) : response()->json(['message' => 'Invalid Password'], 412); } } - diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index 0cf124ebd900..27039fcb9060 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -111,8 +111,9 @@ class ResetPasswordController extends Controller { auth()->logout(); - if(request()->has('react') || request()->hasHeader('X-React')) + if(request()->has('react') || request()->hasHeader('X-React')) { return redirect(config('ninja.react_url').'/#/login'); + } return redirect('/'); } @@ -130,11 +131,11 @@ class ResetPasswordController extends Controller return new JsonResponse(['message' => trans($response)], 200); } - if($request->hasHeader('X-REACT') || $request->has('react')){ + if($request->hasHeader('X-REACT') || $request->has('react')) { return redirect(config('ninja.react_url').'/#/login'); + } else { + return redirect('/#/login'); } - else - return redirect('/#/login'); return redirect($this->redirectPath()) ->with('status', trans($response)); diff --git a/app/Http/Controllers/Bank/YodleeController.php b/app/Http/Controllers/Bank/YodleeController.php index bf4f1fc368cf..30e322a74891 100644 --- a/app/Http/Controllers/Bank/YodleeController.php +++ b/app/Http/Controllers/Bank/YodleeController.php @@ -12,13 +12,13 @@ namespace App\Http\Controllers\Bank; use App\Helpers\Bank\Yodlee\DTO\AccountSummary; -use Illuminate\Http\Request; -use App\Models\BankIntegration; use App\Helpers\Bank\Yodlee\Yodlee; use App\Http\Controllers\BaseController; -use App\Jobs\Bank\ProcessBankTransactions; -use App\Http\Requests\Yodlee\YodleeAuthRequest; use App\Http\Requests\Yodlee\YodleeAdminRequest; +use App\Http\Requests\Yodlee\YodleeAuthRequest; +use App\Jobs\Bank\ProcessBankTransactions; +use App\Models\BankIntegration; +use Illuminate\Http\Request; class YodleeController extends BaseController { @@ -100,69 +100,69 @@ class YodleeController extends BaseController } - /** - * Process Yodlee Refresh Webhook. - * - * - * @OA\Post( - * path="/api/v1/yodlee/refresh", - * operationId="yodleeRefreshWebhook", - * tags={"yodlee"}, - * summary="Processing webhooks from Yodlee", - * description="Notifies the system when a data point can be refreshed", - * @OA\Parameter(ref="#/components/parameters/X-API-TOKEN"), - * @OA\Parameter(ref="#/components/parameters/X-Requested-With"), - * @OA\Parameter(ref="#/components/parameters/include"), - * @OA\Response( - * response=200, - * description="", - * @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"), - * @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"), - * @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"), - * @OA\JsonContent(ref="#/components/schemas/Credit"), - * ), - * @OA\Response( - * response=422, - * description="Validation error", - * @OA\JsonContent(ref="#/components/schemas/ValidationError"), - * - * ), - * @OA\Response( - * response="default", - * description="Unexpected Error", - * @OA\JsonContent(ref="#/components/schemas/Error"), - * ), - * ) - */ + /** + * Process Yodlee Refresh Webhook. + * + * + * @OA\Post( + * path="/api/v1/yodlee/refresh", + * operationId="yodleeRefreshWebhook", + * tags={"yodlee"}, + * summary="Processing webhooks from Yodlee", + * description="Notifies the system when a data point can be refreshed", + * @OA\Parameter(ref="#/components/parameters/X-API-TOKEN"), + * @OA\Parameter(ref="#/components/parameters/X-Requested-With"), + * @OA\Parameter(ref="#/components/parameters/include"), + * @OA\Response( + * response=200, + * description="", + * @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"), + * @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"), + * @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"), + * @OA\JsonContent(ref="#/components/schemas/Credit"), + * ), + * @OA\Response( + * response=422, + * description="Validation error", + * @OA\JsonContent(ref="#/components/schemas/ValidationError"), + * + * ), + * @OA\Response( + * response="default", + * description="Unexpected Error", + * @OA\JsonContent(ref="#/components/schemas/Error"), + * ), + * ) + */ - /* - { - "event":{ - "info":"REFRESH.PROCESS_COMPLETED", - "loginName":"fri21", - "data":{ - "providerAccount":[ - { - "id":10995860, - "providerId":16441, - "isManual":false, - "createdDate":"2017-12-22T05:47:35Z", - "aggregationSource":"USER", - "status":"SUCCESS", - "requestId":"NSyMGo+R4dktywIu3hBIkc3PgWA=", - "dataset":[ - { - "name":"BASIC_AGG_DATA", - "additionalStatus":"AVAILABLE_DATA_RETRIEVED", - "updateEligibility":"ALLOW_UPDATE", - "lastUpdated":"2017-12-22T05:48:16Z", - "lastUpdateAttempt":"2017-12-22T05:48:16Z" - } - ] - } - ] + /* + { + "event":{ + "info":"REFRESH.PROCESS_COMPLETED", + "loginName":"fri21", + "data":{ + "providerAccount":[ + { + "id":10995860, + "providerId":16441, + "isManual":false, + "createdDate":"2017-12-22T05:47:35Z", + "aggregationSource":"USER", + "status":"SUCCESS", + "requestId":"NSyMGo+R4dktywIu3hBIkc3PgWA=", + "dataset":[ + { + "name":"BASIC_AGG_DATA", + "additionalStatus":"AVAILABLE_DATA_RETRIEVED", + "updateEligibility":"ALLOW_UPDATE", + "lastUpdated":"2017-12-22T05:48:16Z", + "lastUpdateAttempt":"2017-12-22T05:48:16Z" + } + ] + } + ] + } } - } }*/ public function refreshWebhook(Request $request) { @@ -177,28 +177,28 @@ class YodleeController extends BaseController // return response()->json(['message' => 'Unauthorized'], 403); } -/* -{ - "event":{ - "notificationId":"63c73475-4db5-49ef-8553-8303337ca7c3", - "info":"LATEST_BALANCE_UPDATES", - "loginName":"user1", - "data":{ - "providerAccountId":658552, - "latestBalanceEvent":[ - { - "accountId":12345, - "status":"SUCCESS" - }, - { - "accountId":12346, - "status":"FAILED" - } - ] - } - } -} -*/ + /* + { + "event":{ + "notificationId":"63c73475-4db5-49ef-8553-8303337ca7c3", + "info":"LATEST_BALANCE_UPDATES", + "loginName":"user1", + "data":{ + "providerAccountId":658552, + "latestBalanceEvent":[ + { + "accountId":12345, + "status":"SUCCESS" + }, + { + "accountId":12346, + "status":"FAILED" + } + ] + } + } + } + */ public function balanceWebhook(Request $request) { nlog("yodlee refresh"); @@ -211,29 +211,29 @@ class YodleeController extends BaseController // return response()->json(['message' => 'Unauthorized'], 403); } -/* -{ - "event":{ - "data":[ - { - "autoRefresh":{ - "additionalStatus":"SCHEDULED", - "status":"ENABLED" - }, - "accountIds":[ - 1112645899, - 1112645898 - ], - "loginName":"YSL1555332811628", - "providerAccountId":11381459 - } - ], - "notificationTime":"2019-06-14T04:49:39Z", - "notificationId":"4e672150-156048777", - "info":"AUTO_REFRESH_UPDATES" - } -} -*/ + /* + { + "event":{ + "data":[ + { + "autoRefresh":{ + "additionalStatus":"SCHEDULED", + "status":"ENABLED" + }, + "accountIds":[ + 1112645899, + 1112645898 + ], + "loginName":"YSL1555332811628", + "providerAccountId":11381459 + } + ], + "notificationTime":"2019-06-14T04:49:39Z", + "notificationId":"4e672150-156048777", + "info":"AUTO_REFRESH_UPDATES" + } + } + */ public function refreshUpdatesWebhook(Request $request) { //notifies a user if there are problems with yodlee accessing the data @@ -248,27 +248,27 @@ class YodleeController extends BaseController } -/* -"event": { - "notificationId": "64b7ed1a-1530523285", - "info": "DATA_UPDATES.USER_DATA", - "data": { - "userCount": 1, - "fromDate": "2017-11-10T10:18:44Z", - "toDate": "2017-11-10T11:18:43Z", - "userData": [{ - "user": { - "loginName": "YSL1484052178554" - }, - "links": [{ - "methodType": "GET", - "rel": "getUserData", - "href": "dataExtracts/userData?fromDate=2017-11-10T10:18:44Z&toDate=2017-11-10T11:18:43Z&loginName=YSL1484052178554" + /* + "event": { + "notificationId": "64b7ed1a-1530523285", + "info": "DATA_UPDATES.USER_DATA", + "data": { + "userCount": 1, + "fromDate": "2017-11-10T10:18:44Z", + "toDate": "2017-11-10T11:18:43Z", + "userData": [{ + "user": { + "loginName": "YSL1484052178554" + }, + "links": [{ + "methodType": "GET", + "rel": "getUserData", + "href": "dataExtracts/userData?fromDate=2017-11-10T10:18:44Z&toDate=2017-11-10T11:18:43Z&loginName=YSL1484052178554" + }] }] - }] + } } -} -*/ + */ public function dataUpdatesWebhook(Request $request) { //this is the main hook we use for notifications @@ -292,8 +292,9 @@ class YodleeController extends BaseController ->where('account_id', $account_number) ->exists(); - if(!$bank_integration) + if(!$bank_integration) { return response()->json(['message' => 'Account does not exist.'], 400); + } $yodlee = new Yodlee($user->account->bank_integration_account_id); diff --git a/app/Http/Controllers/BankIntegrationController.php b/app/Http/Controllers/BankIntegrationController.php index 3e404ff73f6b..b2d3a33a9ae8 100644 --- a/app/Http/Controllers/BankIntegrationController.php +++ b/app/Http/Controllers/BankIntegrationController.php @@ -11,26 +11,25 @@ namespace App\Http\Controllers; -use Illuminate\Http\Request; -use Illuminate\Http\Response; -use App\Models\BankIntegration; -use App\Utils\Traits\MakesHash; -use Illuminate\Http\JsonResponse; -use App\Helpers\Bank\Yodlee\Yodlee; -use Illuminate\Support\Facades\Cache; use App\Factory\BankIntegrationFactory; use App\Filters\BankIntegrationFilters; -use App\Jobs\Bank\ProcessBankTransactions; -use App\Repositories\BankIntegrationRepository; -use App\Transformers\BankIntegrationTransformer; +use App\Helpers\Bank\Yodlee\Yodlee; +use App\Http\Requests\BankIntegration\AdminBankIntegrationRequest; use App\Http\Requests\BankIntegration\BulkBankIntegrationRequest; +use App\Http\Requests\BankIntegration\CreateBankIntegrationRequest; +use App\Http\Requests\BankIntegration\DestroyBankIntegrationRequest; use App\Http\Requests\BankIntegration\EditBankIntegrationRequest; use App\Http\Requests\BankIntegration\ShowBankIntegrationRequest; -use App\Http\Requests\BankIntegration\AdminBankIntegrationRequest; use App\Http\Requests\BankIntegration\StoreBankIntegrationRequest; -use App\Http\Requests\BankIntegration\CreateBankIntegrationRequest; use App\Http\Requests\BankIntegration\UpdateBankIntegrationRequest; -use App\Http\Requests\BankIntegration\DestroyBankIntegrationRequest; +use App\Jobs\Bank\ProcessBankTransactions; +use App\Models\BankIntegration; +use App\Repositories\BankIntegrationRepository; +use App\Transformers\BankIntegrationTransformer; +use App\Utils\Traits\MakesHash; +use Illuminate\Http\JsonResponse; +use Illuminate\Http\Response; +use Illuminate\Support\Facades\Cache; class BankIntegrationController extends BaseController { @@ -109,7 +108,7 @@ class BankIntegrationController extends BaseController * @param CreateBankIntegrationRequest $request * @return Response * - * + * */ public function create(CreateBankIntegrationRequest $request) { @@ -210,12 +209,11 @@ class BankIntegrationController extends BaseController $accounts = $yodlee->getAccounts(); foreach ($accounts as $account) { - if ($bi = BankIntegration::withTrashed()->where('bank_account_id', $account['id'])->where('company_id', $user->company()->id)->first()){ - $bi->balance = $account['current_balance']; - $bi->currency = $account['account_currency']; - $bi->save(); - } - else { + if ($bi = BankIntegration::withTrashed()->where('bank_account_id', $account['id'])->where('company_id', $user->company()->id)->first()) { + $bi->balance = $account['current_balance']; + $bi->currency = $account['account_currency']; + $bi->save(); + } else { $bank_integration = new BankIntegration(); $bank_integration->company_id = $user->company()->id; $bank_integration->account_id = $user->account_id; @@ -293,7 +291,7 @@ class BankIntegrationController extends BaseController /** @var \App\Models\User $user */ $user = auth()->user(); - $user->account->bank_integrations->each(function ($bank_integration) use ($user){ + $user->account->bank_integrations->each(function ($bank_integration) use ($user) { (new ProcessBankTransactions($user->account->bank_integration_account_id, $bank_integration))->handle(); }); diff --git a/app/Http/Controllers/BankTransactionRuleController.php b/app/Http/Controllers/BankTransactionRuleController.php index a17cf4cfe76c..b34043e48f28 100644 --- a/app/Http/Controllers/BankTransactionRuleController.php +++ b/app/Http/Controllers/BankTransactionRuleController.php @@ -11,20 +11,20 @@ namespace App\Http\Controllers; -use App\Utils\Traits\MakesHash; -use App\Models\BankTransactionRule; use App\Factory\BankTransactionRuleFactory; use App\Filters\BankTransactionRuleFilters; -use App\Repositories\BankTransactionRuleRepository; -use App\Transformers\BankTransactionRuleTransformer; use App\Http\Requests\BankTransactionRule\BulkBankTransactionRuleRequest; +use App\Http\Requests\BankTransactionRule\CreateBankTransactionRuleRequest; +use App\Http\Requests\BankTransactionRule\DestroyBankTransactionRuleRequest; use App\Http\Requests\BankTransactionRule\EditBankTransactionRuleRequest; use App\Http\Requests\BankTransactionRule\ShowBankTransactionRuleRequest; use App\Http\Requests\BankTransactionRule\StoreBankTransactionRuleRequest; -use App\Http\Requests\BankTransactionRule\CreateBankTransactionRuleRequest; use App\Http\Requests\BankTransactionRule\UpdateBankTransactionRuleRequest; -use App\Http\Requests\BankTransactionRule\DestroyBankTransactionRuleRequest; +use App\Models\BankTransactionRule; +use App\Repositories\BankTransactionRuleRepository; use App\Services\Bank\BankMatchingService; +use App\Transformers\BankTransactionRuleTransformer; +use App\Utils\Traits\MakesHash; class BankTransactionRuleController extends BaseController { diff --git a/app/Http/Controllers/BaseController.php b/app/Http/Controllers/BaseController.php index a8f43eae85a3..2d5d41c24e3a 100644 --- a/app/Http/Controllers/BaseController.php +++ b/app/Http/Controllers/BaseController.php @@ -531,7 +531,7 @@ class BaseController extends Controller $paginator = $query->paginate($limit); /** @phpstan-ignore-next-line **/ - $query = $paginator->getCollection(); + $query = $paginator->getCollection(); $resource = new Collection($query, $transformer, $this->entity_type); @@ -889,7 +889,7 @@ class BaseController extends Controller $resource = new Collection($query, $transformer, $this->entity_type); $resource->setPaginator(new IlluminatePaginatorAdapter($paginator)); - } + } // else { // $resource = new Collection($query, $transformer, $this->entity_type); @@ -924,10 +924,9 @@ class BaseController extends Controller if ($this->entity_type == BankIntegration::class && !$user->isSuperUser() && $user->hasIntersectPermissions(['create_bank_transaction','edit_bank_transaction','view_bank_transaction'])) { $query->exclude(["balance"]); } //allows us to selective display bank integrations back to the user if they can view / create bank transactions but without the bank balance being present in the response - elseif($this->entity_type == TaxRate::class && $user->hasIntersectPermissions(['create_invoice','edit_invoice','create_quote','edit_quote','create_purchase_order','edit_purchase_order'])){ + elseif($this->entity_type == TaxRate::class && $user->hasIntersectPermissions(['create_invoice','edit_invoice','create_quote','edit_quote','create_purchase_order','edit_purchase_order'])) { // need to show tax rates if the user has the ability to create documents. - } - else { + } else { $query->where('user_id', '=', $user->id); } } elseif (in_array($this->entity_type, [Design::class, GroupSetting::class, PaymentTerm::class, TaskStatus::class])) { diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index 1dfff875d34d..158688ba5544 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -11,36 +11,36 @@ 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\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\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. @@ -74,10 +74,10 @@ class ClientController extends BaseController } /** - * + * * @param ClientFilters $filters * @return Response - * + * */ public function index(ClientFilters $filters) { @@ -275,15 +275,15 @@ class ClientController extends BaseController //todo add an event here using the client name as reference for purge event } -/** - * Update the specified resource in storage. - * - * @param PurgeClientRequest $request - * @param Client $client - * @param string $mergeable_client - * @return \Illuminate\Http\JsonResponse - * - */ + /** + * Update the specified resource in storage. + * + * @param PurgeClientRequest $request + * @param Client $client + * @param string $mergeable_client + * @return \Illuminate\Http\JsonResponse + * + */ public function merge(PurgeClientRequest $request, Client $client, string $mergeable_client) { @@ -313,8 +313,9 @@ class ClientController extends BaseController */ public function updateTaxData(PurgeClientRequest $request, Client $client) { - if($client->company->account->isPaid()) + if($client->company->account->isPaid()) { (new UpdateTaxData($client, $client->company))->handle(); + } return $this->itemResponse($client->fresh()); } @@ -331,8 +332,8 @@ class ClientController extends BaseController /** @var \App\Models\User $user */ $user = auth()->user(); - if(stripos($bounce_id, '-') !== false){ - $log = + if(stripos($bounce_id, '-') !== false) { + $log = SystemLog::query() ->where('company_id', $user->company()->id) ->where('type_id', SystemLog::TYPE_WEBHOOK_RESPONSE) @@ -343,16 +344,16 @@ class ClientController extends BaseController $resolved_bounce_id = false; - if($log && ($log?->log['ID'] ?? false)){ + if($log && ($log?->log['ID'] ?? false)) { $resolved_bounce_id = $log->log['ID'] ?? false; } - if(!$resolved_bounce_id){ + if(!$resolved_bounce_id) { $ppwebhook = new ProcessPostmarkWebhook([]); $resolved_bounce_id = $ppwebhook->getBounceId($bounce_id); } - if(!$resolved_bounce_id){ + if(!$resolved_bounce_id) { return response()->json(['message' => 'Bounce ID not found'], 400); } @@ -367,8 +368,7 @@ class ClientController extends BaseController return response()->json(['message' => 'Success'], 200); - } - catch(\Exception $e){ + } catch(\Exception $e) { return response()->json(['message' => $e->getMessage(), 400]); diff --git a/app/Http/Controllers/ClientPortal/ContactHashLoginController.php b/app/Http/Controllers/ClientPortal/ContactHashLoginController.php index 8501131833a6..abcef260ffc0 100644 --- a/app/Http/Controllers/ClientPortal/ContactHashLoginController.php +++ b/app/Http/Controllers/ClientPortal/ContactHashLoginController.php @@ -11,11 +11,10 @@ namespace App\Http\Controllers\ClientPortal; -use Auth; -use App\Models\RecurringInvoice; use App\Http\Controllers\Controller; -use Illuminate\Support\Facades\Redirect; use App\Http\ViewComposers\PortalComposer; +use App\Models\RecurringInvoice; +use Illuminate\Support\Facades\Redirect; class ContactHashLoginController extends Controller { diff --git a/app/Http/Controllers/ClientPortal/InvitationController.php b/app/Http/Controllers/ClientPortal/InvitationController.php index cc19d8b5a1f1..8f62169b0e4f 100644 --- a/app/Http/Controllers/ClientPortal/InvitationController.php +++ b/app/Http/Controllers/ClientPortal/InvitationController.php @@ -11,28 +11,27 @@ namespace App\Http\Controllers\ClientPortal; -use App\Utils\Ninja; -use App\Models\Client; -use App\Models\Payment; -use Illuminate\Support\Str; -use Illuminate\Http\Request; -use App\Models\ClientContact; -use App\Models\QuoteInvitation; -use App\Utils\Traits\MakesHash; -use App\Models\CreditInvitation; -use App\Utils\Traits\MakesDates; -use App\Jobs\Entity\CreateRawPdf; -use App\Models\InvoiceInvitation; -use App\Events\Quote\QuoteWasViewed; -use App\Http\Controllers\Controller; -use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Facades\Hash; -use App\Events\Credit\CreditWasViewed; use App\Events\Contact\ContactLoggedIn; -use App\Models\PurchaseOrderInvitation; +use App\Events\Credit\CreditWasViewed; use App\Events\Invoice\InvoiceWasViewed; use App\Events\Misc\InvitationWasViewed; +use App\Events\Quote\QuoteWasViewed; +use App\Http\Controllers\Controller; +use App\Jobs\Entity\CreateRawPdf; +use App\Models\ClientContact; +use App\Models\CreditInvitation; +use App\Models\InvoiceInvitation; +use App\Models\Payment; +use App\Models\PurchaseOrderInvitation; +use App\Models\QuoteInvitation; use App\Services\ClientPortal\InstantPayment; +use App\Utils\Ninja; +use App\Utils\Traits\MakesDates; +use App\Utils\Traits\MakesHash; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Hash; +use Illuminate\Support\Str; /** * Class InvitationController. @@ -101,7 +100,7 @@ class InvitationController extends Controller if (empty($client_contact->email)) { $client_contact->email = Str::random(15) . "@example.com"; $client_contact->save(); - } + } if (request()->has('client_hash') && request()->input('client_hash') == $invitation->contact->client->client_hash) { request()->session()->invalidate(); @@ -214,7 +213,7 @@ class InvitationController extends Controller } - public function handlePasswordSet(Request $request) + public function handlePasswordSet(Request $request) { $entity_obj = 'App\Models\\'.ucfirst(Str::camel($request->entity_type)).'Invitation'; $key = $request->entity_type.'_id'; diff --git a/app/Http/Controllers/ClientPortal/InvoiceController.php b/app/Http/Controllers/ClientPortal/InvoiceController.php index cc882291af7d..e293eacbbd11 100644 --- a/app/Http/Controllers/ClientPortal/InvoiceController.php +++ b/app/Http/Controllers/ClientPortal/InvoiceController.php @@ -11,29 +11,27 @@ namespace App\Http\Controllers\ClientPortal; -use App\Utils\Ninja; -use App\Utils\Number; -use App\Models\Invoice; -use Illuminate\View\View; -use Illuminate\Http\Request; -use App\Models\QuoteInvitation; -use App\Utils\Traits\MakesHash; -use App\Models\CreditInvitation; -use App\Utils\Traits\MakesDates; -use App\Models\InvoiceInvitation; -use App\Http\Controllers\Controller; -use Illuminate\Http\RedirectResponse; -use Illuminate\Support\Facades\Cache; -use Illuminate\Contracts\View\Factory; -use App\Models\PurchaseOrderInvitation; -use Illuminate\Support\Facades\Storage; use App\Events\Invoice\InvoiceWasViewed; use App\Events\Misc\InvitationWasViewed; -use App\Models\RecurringInvoiceInvitation; -use App\Jobs\Vendor\CreatePurchaseOrderPdf; +use App\Http\Controllers\Controller; +use App\Http\Requests\ClientPortal\Invoices\ProcessInvoicesInBulkRequest; use App\Http\Requests\ClientPortal\Invoices\ShowInvoiceRequest; use App\Http\Requests\ClientPortal\Invoices\ShowInvoicesRequest; -use App\Http\Requests\ClientPortal\Invoices\ProcessInvoicesInBulkRequest; +use App\Models\CreditInvitation; +use App\Models\Invoice; +use App\Models\InvoiceInvitation; +use App\Models\QuoteInvitation; +use App\Models\RecurringInvoiceInvitation; +use App\Utils\Ninja; +use App\Utils\Number; +use App\Utils\Traits\MakesDates; +use App\Utils\Traits\MakesHash; +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 { @@ -88,14 +86,14 @@ class InvoiceController extends Controller { $data = Cache::get($hash); - if(!$data){ + if(!$data) { usleep(200000); $data = Cache::get($hash); } $invitation = false; - match($data['entity_type'] ?? false){ + match($data['entity_type'] ?? false) { 'invoice' => $invitation = InvoiceInvitation::withTrashed()->find($data['invitation_id']), 'quote' => $invitation = QuoteInvitation::withTrashed()->find($data['invitation_id']), 'credit' => $invitation = CreditInvitation::withTrashed()->find($data['invitation_id']), diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php index 841a61a105aa..81b560ab19df 100644 --- a/app/Http/Controllers/ClientPortal/PaymentController.php +++ b/app/Http/Controllers/ClientPortal/PaymentController.php @@ -27,7 +27,6 @@ use App\Services\Subscription\SubscriptionService; use App\Utils\Traits\MakesDates; use App\Utils\Traits\MakesHash; use Illuminate\Contracts\View\Factory; -use Illuminate\Database\Eloquent\Collection; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\View\View; diff --git a/app/Http/Controllers/ClientPortal/QuoteController.php b/app/Http/Controllers/ClientPortal/QuoteController.php index 6e12701bb680..98cb3cd871d3 100644 --- a/app/Http/Controllers/ClientPortal/QuoteController.php +++ b/app/Http/Controllers/ClientPortal/QuoteController.php @@ -12,22 +12,21 @@ namespace App\Http\Controllers\ClientPortal; -use App\Utils\Ninja; -use App\Models\Quote; -use Illuminate\View\View; -use Illuminate\Http\Request; -use App\Models\QuoteInvitation; -use App\Utils\Traits\MakesHash; +use App\Events\Misc\InvitationWasViewed; use App\Events\Quote\QuoteWasViewed; use App\Http\Controllers\Controller; -use App\Jobs\Invoice\InjectSignature; -use Illuminate\Contracts\View\Factory; -use Illuminate\Support\Facades\Storage; -use App\Events\Misc\InvitationWasViewed; -use Symfony\Component\HttpFoundation\BinaryFileResponse; +use App\Http\Requests\ClientPortal\Quotes\ProcessQuotesInBulkRequest; use App\Http\Requests\ClientPortal\Quotes\ShowQuoteRequest; use App\Http\Requests\ClientPortal\Quotes\ShowQuotesRequest; -use App\Http\Requests\ClientPortal\Quotes\ProcessQuotesInBulkRequest; +use App\Jobs\Invoice\InjectSignature; +use App\Models\Quote; +use App\Models\QuoteInvitation; +use App\Utils\Ninja; +use App\Utils\Traits\MakesHash; +use Illuminate\Contracts\View\Factory; +use Illuminate\Http\Request; +use Illuminate\View\View; +use Symfony\Component\HttpFoundation\BinaryFileResponse; class QuoteController extends Controller { @@ -123,7 +122,7 @@ class QuoteController extends Controller $client_contact = auth()->user(); $quote_invitations = QuoteInvitation::query() - ->with('quote','company') + ->with('quote', 'company') ->whereIn('quote_id', $ids) ->where('client_contact_id', $client_contact->id) ->withTrashed() diff --git a/app/Http/Controllers/ClientPortal/StatementController.php b/app/Http/Controllers/ClientPortal/StatementController.php index 7ed81d48fed3..d5bbafb024be 100644 --- a/app/Http/Controllers/ClientPortal/StatementController.php +++ b/app/Http/Controllers/ClientPortal/StatementController.php @@ -23,7 +23,7 @@ class StatementController extends Controller /** * Show the statement in the client portal. * - * @return \Illuminate\View\View + * @return \Illuminate\View\View */ public function index(): View { diff --git a/app/Http/Controllers/ClientPortal/TempRouteController.php b/app/Http/Controllers/ClientPortal/TempRouteController.php index b1f71a837063..4efe5b9b637f 100644 --- a/app/Http/Controllers/ClientPortal/TempRouteController.php +++ b/app/Http/Controllers/ClientPortal/TempRouteController.php @@ -11,7 +11,6 @@ namespace App\Http\Controllers\ClientPortal; -use Auth; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Redirect; diff --git a/app/Http/Controllers/ClientStatementController.php b/app/Http/Controllers/ClientStatementController.php index 375234c6d016..fe10335b815b 100644 --- a/app/Http/Controllers/ClientStatementController.php +++ b/app/Http/Controllers/ClientStatementController.php @@ -11,10 +11,10 @@ namespace App\Http\Controllers; +use App\Http\Requests\Statements\CreateStatementRequest; use App\Utils\Traits\MakesHash; use App\Utils\Traits\Pdf\PdfMaker; use Illuminate\Support\Facades\Response; -use App\Http\Requests\Statements\CreateStatementRequest; class ClientStatementController extends BaseController { diff --git a/app/Http/Controllers/CompanyController.php b/app/Http/Controllers/CompanyController.php index ede5c1b92d21..6c476ab979c6 100644 --- a/app/Http/Controllers/CompanyController.php +++ b/app/Http/Controllers/CompanyController.php @@ -11,39 +11,38 @@ namespace App\Http\Controllers; -use Str; -use App\Utils\Ninja; -use App\Models\Account; -use App\Models\Company; -use App\Models\CompanyUser; -use Illuminate\Http\Response; -use App\Utils\Traits\MakesHash; -use App\Utils\Traits\Uploadable; -use App\Jobs\Mail\NinjaMailerJob; -use App\DataMapper\CompanySettings; -use App\Jobs\Company\CreateCompany; -use App\Jobs\Company\CompanyTaxRate; -use App\Jobs\Mail\NinjaMailerObject; -use App\Mail\Company\CompanyDeleted; -use App\Utils\Traits\SavesDocuments; -use Turbo124\Beacon\Facades\LightLogs; -use App\Repositories\CompanyRepository; -use Illuminate\Support\Facades\Storage; -use App\Jobs\Company\CreateCompanyToken; -use App\Transformers\CompanyTransformer; use App\DataMapper\Analytics\AccountDeleted; -use App\Transformers\CompanyUserTransformer; -use Illuminate\Foundation\Bus\DispatchesJobs; -use App\Jobs\Company\CreateCompanyPaymentTerms; -use App\Jobs\Company\CreateCompanyTaskStatuses; +use App\DataMapper\CompanySettings; +use App\Http\Requests\Company\CreateCompanyRequest; +use App\Http\Requests\Company\DefaultCompanyRequest; +use App\Http\Requests\Company\DestroyCompanyRequest; use App\Http\Requests\Company\EditCompanyRequest; use App\Http\Requests\Company\ShowCompanyRequest; use App\Http\Requests\Company\StoreCompanyRequest; -use App\Http\Requests\Company\CreateCompanyRequest; use App\Http\Requests\Company\UpdateCompanyRequest; use App\Http\Requests\Company\UploadCompanyRequest; -use App\Http\Requests\Company\DefaultCompanyRequest; -use App\Http\Requests\Company\DestroyCompanyRequest; +use App\Jobs\Company\CompanyTaxRate; +use App\Jobs\Company\CreateCompany; +use App\Jobs\Company\CreateCompanyPaymentTerms; +use App\Jobs\Company\CreateCompanyTaskStatuses; +use App\Jobs\Company\CreateCompanyToken; +use App\Jobs\Mail\NinjaMailerJob; +use App\Jobs\Mail\NinjaMailerObject; +use App\Mail\Company\CompanyDeleted; +use App\Models\Account; +use App\Models\Company; +use App\Models\CompanyUser; +use App\Repositories\CompanyRepository; +use App\Transformers\CompanyTransformer; +use App\Transformers\CompanyUserTransformer; +use App\Utils\Ninja; +use App\Utils\Traits\MakesHash; +use App\Utils\Traits\SavesDocuments; +use App\Utils\Traits\Uploadable; +use Illuminate\Foundation\Bus\DispatchesJobs; +use Illuminate\Http\Response; +use Illuminate\Support\Facades\Storage; +use Turbo124\Beacon\Facades\LightLogs; /** * Class CompanyController. @@ -427,7 +426,7 @@ class CompanyController extends BaseController $this->saveDocuments($request->input('documents'), $company, $request->input('is_public', true)); } - if($request->has('e_invoice_certificate') && !is_null($request->file("e_invoice_certificate"))){ + if($request->has('e_invoice_certificate') && !is_null($request->file("e_invoice_certificate"))) { $company->e_invoice_certificate = base64_encode($request->file("e_invoice_certificate")->get()); @@ -684,16 +683,15 @@ class CompanyController extends BaseController public function updateOriginTaxData(DefaultCompanyRequest $request, Company $company) { - if($company->settings->country_id == "840" && !$company?->account->isFreeHostedClient()) - { + if($company->settings->country_id == "840" && !$company?->account->isFreeHostedClient()) { try { (new CompanyTaxRate($company))->handle(); } catch(\Exception $e) { return response()->json(['message' => 'There was a problem updating the tax rates. Please try again.'], 400); } - } - else + } else { return response()->json(['message' => 'Tax configuration not available due to settings / plan restriction.'], 400); + } return $this->itemResponse($company->fresh()); } @@ -707,7 +705,7 @@ class CompanyController extends BaseController $logo = strlen($company->settings->company_logo) > 5 ? $company->settings->company_logo : 'https://pdf.invoicing.co/favicon-v2.png'; $headers = ['Content-Disposition' => 'inline']; - return response()->streamDownload(function () use ($logo){ + return response()->streamDownload(function () use ($logo) { echo @file_get_contents($logo); }, 'logo.png', $headers); diff --git a/app/Http/Controllers/CompanyGatewayController.php b/app/Http/Controllers/CompanyGatewayController.php index 5e9fed6bfd81..9914327f526c 100644 --- a/app/Http/Controllers/CompanyGatewayController.php +++ b/app/Http/Controllers/CompanyGatewayController.php @@ -213,8 +213,7 @@ class CompanyGatewayController extends BaseController if (in_array($company_gateway->gateway_key, $this->stripe_keys)) { StripeWebhook::dispatch($company_gateway->company->company_key, $company_gateway->id); - } - elseif($company_gateway->gateway_key == $this->checkout_key) { + } elseif($company_gateway->gateway_key == $this->checkout_key) { CheckoutSetupWebhook::dispatch($company_gateway->company->company_key, $company_gateway->id); } diff --git a/app/Http/Controllers/CompanyUserController.php b/app/Http/Controllers/CompanyUserController.php index 69de122d5f4b..e020807da7e5 100644 --- a/app/Http/Controllers/CompanyUserController.php +++ b/app/Http/Controllers/CompanyUserController.php @@ -11,14 +11,14 @@ namespace App\Http\Controllers; -use App\Models\User; -use App\Models\CompanyUser; -use Illuminate\Http\Response; -use App\Transformers\UserTransformer; -use App\Transformers\CompanyUserTransformer; -use Illuminate\Database\Eloquent\ModelNotFoundException; -use App\Http\Requests\CompanyUser\UpdateCompanyUserRequest; use App\Http\Requests\CompanyUser\UpdateCompanyUserPreferencesRequest; +use App\Http\Requests\CompanyUser\UpdateCompanyUserRequest; +use App\Models\CompanyUser; +use App\Models\User; +use App\Transformers\CompanyUserTransformer; +use App\Transformers\UserTransformer; +use Illuminate\Database\Eloquent\ModelNotFoundException; +use Illuminate\Http\Response; class CompanyUserController extends BaseController { @@ -115,7 +115,7 @@ class CompanyUserController extends BaseController $auth_user = auth()->user(); $company = $auth_user->company(); - $company_user = CompanyUser::query()->where('user_id', $user->id)->where('company_id',$company->id)->first(); + $company_user = CompanyUser::query()->where('user_id', $user->id)->where('company_id', $company->id)->first(); if (! $company_user) { throw new ModelNotFoundException(ctrans('texts.company_user_not_found')); diff --git a/app/Http/Controllers/CreditController.php b/app/Http/Controllers/CreditController.php index 9ab4db36bdff..24db27876e92 100644 --- a/app/Http/Controllers/CreditController.php +++ b/app/Http/Controllers/CreditController.php @@ -11,35 +11,35 @@ 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\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\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. @@ -386,7 +386,7 @@ class CreditController extends BaseController $credit->service() ->triggeredActions($request); - // ->deletePdf(); + // ->deletePdf(); /** @var \App\Models\User $user**/ $user = auth()->user(); @@ -527,7 +527,7 @@ class CreditController extends BaseController */ if ($action == 'bulk_download' && $credits->count() > 1) { - $credits->each(function ($credit) use($user){ + $credits->each(function ($credit) use ($user) { if ($user->cannot('view', $credit)) { return response()->json(['message' => ctrans('text.access_denied')]); } diff --git a/app/Http/Controllers/DocumentController.php b/app/Http/Controllers/DocumentController.php index 70d4b1e8a1b4..9d822aee1310 100644 --- a/app/Http/Controllers/DocumentController.php +++ b/app/Http/Controllers/DocumentController.php @@ -145,7 +145,7 @@ class DocumentController extends BaseController * @return Response */ public function update(UpdateDocumentRequest $request, Document $document) - { + { $document->fill($request->all()); $document->save(); diff --git a/app/Http/Controllers/EmailHistoryController.php b/app/Http/Controllers/EmailHistoryController.php index f29f1a79bd9d..493becc50d83 100644 --- a/app/Http/Controllers/EmailHistoryController.php +++ b/app/Http/Controllers/EmailHistoryController.php @@ -33,7 +33,7 @@ class EmailHistoryController extends BaseController ->cursor() ->filter(function ($system_log) { return (isset($system_log->log['history']) && isset($system_log->log['history']['events']) && count($system_log->log['history']['events']) >=1) !== false; - })->map(function ($system_log) { + })->map(function ($system_log) { return $system_log->log['history']; })->values()->all(); @@ -59,7 +59,7 @@ class EmailHistoryController extends BaseController ->cursor() ->filter(function ($system_log) { return ($system_log->log['history'] && isset($system_log->log['history']['events']) && count($system_log->log['history']['events']) >=1) !== false; - })->map(function ($system_log) { + })->map(function ($system_log) { return $system_log->log['history']; })->values()->all(); diff --git a/app/Http/Controllers/ExpenseCategoryController.php b/app/Http/Controllers/ExpenseCategoryController.php index 36c47b9ba13f..0c43f649aad8 100644 --- a/app/Http/Controllers/ExpenseCategoryController.php +++ b/app/Http/Controllers/ExpenseCategoryController.php @@ -24,7 +24,6 @@ use App\Models\ExpenseCategory; use App\Repositories\BaseRepository; use App\Transformers\ExpenseCategoryTransformer; use App\Utils\Traits\MakesHash; -use Illuminate\Http\Request; use Illuminate\Http\Response; /** @@ -138,7 +137,7 @@ class ExpenseCategoryController extends BaseController /** * Store a newly created resource in storage. * - * @param StoreExpenseCategoryRequest $request + * @param StoreExpenseCategoryRequest $request * @return Response * * diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php index f459a2733386..55038c989527 100644 --- a/app/Http/Controllers/ExportController.php +++ b/app/Http/Controllers/ExportController.php @@ -11,12 +11,12 @@ namespace App\Http\Controllers; -use Illuminate\Support\Str; -use Illuminate\Http\Response; -use App\Utils\Traits\MakesHash; -use App\Jobs\Company\CompanyExport; -use Illuminate\Support\Facades\Cache; use App\Http\Requests\Export\StoreExportRequest; +use App\Jobs\Company\CompanyExport; +use App\Utils\Traits\MakesHash; +use Illuminate\Http\Response; +use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Str; class ExportController extends BaseController { diff --git a/app/Http/Controllers/GroupSettingController.php b/app/Http/Controllers/GroupSettingController.php index ff22b55242c3..cdd3d94c5004 100644 --- a/app/Http/Controllers/GroupSettingController.php +++ b/app/Http/Controllers/GroupSettingController.php @@ -140,8 +140,9 @@ class GroupSettingController extends BaseController public function update(UpdateGroupSettingRequest $request, GroupSetting $group_setting) { /** Need this to prevent settings from being overwritten */ - if(!$request->file('company_logo')) + if(!$request->file('company_logo')) { $group_setting = $this->group_setting_repo->save($request->all(), $group_setting); + } $this->uploadLogo($request->file('company_logo'), $group_setting->company, $group_setting); diff --git a/app/Http/Controllers/ImportController.php b/app/Http/Controllers/ImportController.php index 2871bc41e7b5..e8b82a48593c 100644 --- a/app/Http/Controllers/ImportController.php +++ b/app/Http/Controllers/ImportController.php @@ -108,7 +108,7 @@ class ImportController extends Controller { $hints = []; - $translated_keys = collect($available_keys)->map(function ($value,$key){ + $translated_keys = collect($available_keys)->map(function ($value, $key) { $parts = explode(".", $value); $index = $parts[0]; @@ -121,16 +121,14 @@ class ImportController extends Controller foreach($headers as $key => $value) { - foreach($translated_keys as $tkey => $tvalue) - { + foreach($translated_keys as $tkey => $tvalue) { if($this->testMatch($value, $tvalue['label'])) { $hit = $tvalue['key']; $hints[$key] = $hit; unset($translated_keys[$tkey]); break; - } - else { + } else { $hints[$key] = null; } @@ -140,14 +138,12 @@ class ImportController extends Controller } //second pass using the index of the translation here - foreach($headers as $key => $value) - { + foreach($headers as $key => $value) { if(isset($hints[$key])) { continue; } - foreach($translated_keys as $tkey => $tvalue) - { + foreach($translated_keys as $tkey => $tvalue) { if($this->testMatch($value, $tvalue['index'])) { $hit = $tvalue['key']; $hints[$key] = $hit; @@ -164,7 +160,7 @@ class ImportController extends Controller } private function testMatch($haystack, $needle): bool - { + { return stripos($haystack, $needle) !== false; } @@ -256,7 +252,7 @@ class ImportController extends Controller if (substr_count(strstr($csvfile, "\n", true), $delimiter) >= $count) { $count = substr_count(strstr($csvfile, "\n", true), $delimiter); - $bestDelimiter = $delimiter; + $bestDelimiter = $delimiter; } } diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 6322dfc9ee69..22a1fdcb373c 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -12,40 +12,40 @@ namespace App\Http\Controllers; -use App\Utils\Ninja; -use App\Models\Quote; -use App\Models\Account; -use App\Models\Invoice; -use App\Jobs\Cron\AutoBill; -use Illuminate\Http\Response; -use App\Factory\InvoiceFactory; -use App\Filters\InvoiceFilters; -use App\Utils\Traits\MakesHash; -use App\Jobs\Invoice\ZipInvoices; -use App\Services\PdfMaker\PdfMerge; -use Illuminate\Support\Facades\App; -use App\Factory\CloneInvoiceFactory; -use App\Jobs\Invoice\BulkInvoiceJob; -use App\Utils\Traits\SavesDocuments; -use App\Jobs\Invoice\UpdateReminders; -use App\Transformers\QuoteTransformer; -use App\Repositories\InvoiceRepository; -use Illuminate\Support\Facades\Storage; -use App\Transformers\InvoiceTransformer; use App\Events\Invoice\InvoiceWasCreated; use App\Events\Invoice\InvoiceWasUpdated; -use App\Services\Template\TemplateAction; +use App\Factory\CloneInvoiceFactory; use App\Factory\CloneInvoiceToQuoteFactory; +use App\Factory\InvoiceFactory; +use App\Filters\InvoiceFilters; +use App\Http\Requests\Invoice\ActionInvoiceRequest; use App\Http\Requests\Invoice\BulkInvoiceRequest; +use App\Http\Requests\Invoice\CreateInvoiceRequest; +use App\Http\Requests\Invoice\DestroyInvoiceRequest; use App\Http\Requests\Invoice\EditInvoiceRequest; use App\Http\Requests\Invoice\ShowInvoiceRequest; use App\Http\Requests\Invoice\StoreInvoiceRequest; -use App\Http\Requests\Invoice\ActionInvoiceRequest; -use App\Http\Requests\Invoice\CreateInvoiceRequest; use App\Http\Requests\Invoice\UpdateInvoiceRequest; -use App\Http\Requests\Invoice\UploadInvoiceRequest; -use App\Http\Requests\Invoice\DestroyInvoiceRequest; use App\Http\Requests\Invoice\UpdateReminderRequest; +use App\Http\Requests\Invoice\UploadInvoiceRequest; +use App\Jobs\Cron\AutoBill; +use App\Jobs\Invoice\BulkInvoiceJob; +use App\Jobs\Invoice\UpdateReminders; +use App\Jobs\Invoice\ZipInvoices; +use App\Models\Account; +use App\Models\Invoice; +use App\Models\Quote; +use App\Repositories\InvoiceRepository; +use App\Services\PdfMaker\PdfMerge; +use App\Services\Template\TemplateAction; +use App\Transformers\InvoiceTransformer; +use App\Transformers\QuoteTransformer; +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 InvoiceController. @@ -505,7 +505,7 @@ class InvoiceController extends BaseController */ if ($action == 'bulk_download' && $invoices->count() > 1) { - $invoices->each(function ($invoice) use($user) { + $invoices->each(function ($invoice) use ($user) { if ($user->cannot('view', $invoice)) { nlog('access denied'); @@ -538,18 +538,20 @@ class InvoiceController extends BaseController }, 'print.pdf', ['Content-Type' => 'application/pdf']); } - if($action == 'template' && $user->can('view', $invoices->first())){ + if($action == 'template' && $user->can('view', $invoices->first())) { $hash_or_response = $request->boolean('send_email') ? 'email sent' : \Illuminate\Support\Str::uuid(); - TemplateAction::dispatch($ids, - $request->template_id, - Invoice::class, - $user->id, - $user->company(), - $user->company()->db, - $hash_or_response, - $request->boolean('send_email')); + TemplateAction::dispatch( + $ids, + $request->template_id, + Invoice::class, + $user->id, + $user->company(), + $user->company()->db, + $hash_or_response, + $request->boolean('send_email') + ); return response()->json(['message' => $hash_or_response], 200); } diff --git a/app/Http/Controllers/LicenseController.php b/app/Http/Controllers/LicenseController.php index ec130115ba96..659aa77d9ab5 100644 --- a/app/Http/Controllers/LicenseController.php +++ b/app/Http/Controllers/LicenseController.php @@ -90,7 +90,7 @@ class LicenseController extends BaseController if(substr($license_key, 0, 3) == 'v5_') { return $this->v5ClaimLicense($license_key, $product_id); - } + } $url = config('ninja.license_url')."/claim_license?license_key={$license_key}&product_id={$product_id}&get_date=true"; $data = trim(CurlUtils::get($url)); diff --git a/app/Http/Controllers/MigrationController.php b/app/Http/Controllers/MigrationController.php index 217d29ed5e64..c0bce2fe34ed 100644 --- a/app/Http/Controllers/MigrationController.php +++ b/app/Http/Controllers/MigrationController.php @@ -261,8 +261,9 @@ class MigrationController extends BaseController { nlog('Starting Migration'); - if($request->has('silent_migration')) + if($request->has('silent_migration')) { $this->silent_migration = true; + } if ($request->companies) { //handle Laravel 5.5 UniHTTP @@ -318,8 +319,9 @@ class MigrationController extends BaseController $nmo->settings = $user->account->companies()->first()->settings; $nmo->to_user = $user; - if(!$this->silent_migration) + if(!$this->silent_migration) { NinjaMailerJob::dispatch($nmo, true); + } return; } elseif ($existing_company && $company_count > 10) { @@ -329,8 +331,9 @@ class MigrationController extends BaseController $nmo->settings = $user->account->companies()->first()->settings; $nmo->to_user = $user; - if(!$this->silent_migration) + if(!$this->silent_migration) { NinjaMailerJob::dispatch($nmo, true); + } return; } @@ -350,8 +353,9 @@ class MigrationController extends BaseController $nmo->settings = $user->account->companies()->first(); $nmo->to_user = $user; - if(!$this->silent_migration) + if(!$this->silent_migration) { NinjaMailerJob::dispatch($nmo, true); + } return response()->json([ '_id' => Str::uuid(), diff --git a/app/Http/Controllers/OneTimeTokenController.php b/app/Http/Controllers/OneTimeTokenController.php index 70d32d42cd17..6c37479b7e4b 100644 --- a/app/Http/Controllers/OneTimeTokenController.php +++ b/app/Http/Controllers/OneTimeTokenController.php @@ -11,15 +11,14 @@ namespace App\Http\Controllers; -use App\Models\User; -use App\Models\Company; -use App\Libraries\MultiDB; -use Illuminate\Support\Str; -use Illuminate\Http\Response; -use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Facades\Cache; -use App\Http\Requests\OneTimeToken\OneTimeTokenRequest; use App\Http\Requests\OneTimeToken\OneTimeRouterRequest; +use App\Http\Requests\OneTimeToken\OneTimeTokenRequest; +use App\Libraries\MultiDB; +use App\Models\Company; +use App\Models\User; +use Illuminate\Http\Response; +use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Str; class OneTimeTokenController extends BaseController { diff --git a/app/Http/Controllers/PaymentTermController.php b/app/Http/Controllers/PaymentTermController.php index a4992ca040d3..5c8b5ad90ad0 100644 --- a/app/Http/Controllers/PaymentTermController.php +++ b/app/Http/Controllers/PaymentTermController.php @@ -11,19 +11,19 @@ namespace App\Http\Controllers; -use App\Models\PaymentTerm; -use Illuminate\Http\Response; -use App\Utils\Traits\MakesHash; use App\Factory\PaymentTermFactory; use App\Filters\PaymentTermFilters; -use App\Repositories\PaymentTermRepository; -use App\Transformers\PaymentTermTransformer; +use App\Http\Requests\PaymentTerm\CreatePaymentTermRequest; +use App\Http\Requests\PaymentTerm\DestroyPaymentTermRequest; use App\Http\Requests\PaymentTerm\EditPaymentTermRequest; use App\Http\Requests\PaymentTerm\ShowPaymentTermRequest; use App\Http\Requests\PaymentTerm\StorePaymentTermRequest; -use App\Http\Requests\PaymentTerm\CreatePaymentTermRequest; use App\Http\Requests\PaymentTerm\UpdatePaymentTermRequest; -use App\Http\Requests\PaymentTerm\DestroyPaymentTermRequest; +use App\Models\PaymentTerm; +use App\Repositories\PaymentTermRepository; +use App\Transformers\PaymentTermTransformer; +use App\Utils\Traits\MakesHash; +use Illuminate\Http\Response; class PaymentTermController extends BaseController { diff --git a/app/Http/Controllers/PreviewController.php b/app/Http/Controllers/PreviewController.php index cd64d5da4f0e..5bef76e3063d 100644 --- a/app/Http/Controllers/PreviewController.php +++ b/app/Http/Controllers/PreviewController.php @@ -11,45 +11,33 @@ namespace App\Http\Controllers; -use App\Utils\Ninja; -use App\Models\Quote; -use App\Models\Client; -use App\Models\Credit; -use App\Models\Invoice; -use App\Utils\HtmlEngine; -use App\Libraries\MultiDB; -use Twig\Error\SyntaxError; -use App\Factory\QuoteFactory; -use App\Jobs\Util\PreviewPdf; -use App\Models\ClientContact; -use App\Services\Pdf\PdfMock; -use App\Factory\CreditFactory; -use App\Factory\InvoiceFactory; -use App\Utils\Traits\MakesHash; -use App\Models\RecurringInvoice; -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\Repositories\QuoteRepository; -use Illuminate\Support\Facades\Cache; -use App\Repositories\CreditRepository; -use App\Utils\Traits\MakesInvoiceHtml; -use Turbo124\Beacon\Facades\LightLogs; -use App\Repositories\InvoiceRepository; -use App\Utils\Traits\Pdf\PageNumbering; -use App\Factory\RecurringInvoiceFactory; -use Illuminate\Support\Facades\Response; use App\DataMapper\Analytics\LivePreview; -use App\Services\Template\TemplateService; -use App\Repositories\RecurringInvoiceRepository; use App\Http\Requests\Preview\DesignPreviewRequest; +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\PdfMaker\Design; use App\Services\PdfMaker\Design as PdfDesignModel; use App\Services\PdfMaker\Design as PdfMakerDesign; -use App\Http\Requests\Preview\PreviewInvoiceRequest; +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\Cache; +use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Response; +use Turbo124\Beacon\Facades\LightLogs; +use Twig\Error\SyntaxError; class PreviewController extends BaseController { @@ -59,24 +47,24 @@ class PreviewController extends BaseController public function __construct() { - parent::__construct(); + parent::__construct(); } private function purgeCache() - { + { Cache::pull("preview_".auth()->user()->id); } /** * Refactor - 2023-10-19 - * + * * New method does not require Transactions. * * @param PreviewInvoiceRequest $request * @return mixed */ public function live(PreviewInvoiceRequest $request): mixed - { + { if (Ninja::isHosted() && !in_array($request->getHost(), ['preview.invoicing.co','staging.invoicing.co'])) { return response()->json(['message' => 'This server cannot handle this request.'], 400); @@ -108,8 +96,9 @@ class PreviewController extends BaseController $invitation->{$request->entity} = $entity_obj; } - if(empty($entity_obj->design_id)) + if(empty($entity_obj->design_id)) { $entity_obj->design_id = intval($this->decodePrimaryKey($settings->{$entity_prop."_design_id"})); + } /** Generate variables */ $html = new HtmlEngine($invitation); @@ -152,8 +141,9 @@ class PreviewController extends BaseController /** Generate HTML */ $html = $maker->getCompiledHTML(true); - if (request()->query('html') == 'true') + if (request()->query('html') == 'true') { return $html; + } //if phantom js...... inject here.. if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') { @@ -169,8 +159,9 @@ class PreviewController extends BaseController $pdf = (new NinjaPdf())->build($html); $numbered_pdf = $this->pageNumbering($pdf, $company); - if ($numbered_pdf) + if ($numbered_pdf) { $pdf = $numbered_pdf; + } return $pdf; } @@ -187,9 +178,9 @@ class PreviewController extends BaseController return response()->streamDownload(function () use ($pdf) { echo $pdf; }, 'preview.pdf', [ - 'Content-Disposition' => 'inline', - 'Content-Type' => 'application/pdf', - 'Cache-Control:' => 'no-cache', + 'Content-Disposition' => 'inline', + 'Content-Type' => 'application/pdf', + 'Cache-Control:' => 'no-cache', 'Server-Timing' => microtime(true)-$start ]); @@ -200,7 +191,7 @@ class PreviewController extends BaseController * Returns the mocked PDF for the invoice design preview. * * Only used in Settings > Invoice Design as a general overview - * + * * @param DesignPreviewRequest $request * @return mixed */ @@ -225,14 +216,15 @@ class PreviewController extends BaseController /** * Returns a template filled with entity variables. - * + * * Used in the Custom Designer to preview design changes * @return mixed */ public function show() { - if(request()->has('template')) + if(request()->has('template')) { return $this->template(); + } if (request()->has('entity') && request()->has('entity_id') && @@ -308,8 +300,9 @@ class PreviewController extends BaseController $pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true)); $numbered_pdf = $this->pageNumbering($pdf, $company); - if ($numbered_pdf) + if ($numbered_pdf) { $pdf = $numbered_pdf; + } return $pdf; @@ -340,16 +333,14 @@ class PreviewController extends BaseController /** @var \App\Models\Company $company */ $company = $user->company(); - $design_object = json_decode(json_encode(request()->input('design')),1); + $design_object = json_decode(json_encode(request()->input('design')), 1); $ts = (new TemplateService()); try { - $ts->setCompany($company) - ->setTemplate($design_object) - ->mock(); - } - catch(SyntaxError $e) - { + $ts->setCompany($company) + ->setTemplate($design_object) + ->mock(); + } catch(SyntaxError $e) { // return response()->json(['message' => 'Twig syntax is invalid.', 'errors' => new \stdClass], 422); @@ -558,8 +549,7 @@ class PreviewController extends BaseController ->build(); DB::connection($company->db)->rollBack(); - } - catch(\Exception $e){ + } catch(\Exception $e) { DB::connection($company->db)->rollBack(); return response()->json(['message' => $e->getMessage()], 400); } diff --git a/app/Http/Controllers/PreviewPurchaseOrderController.php b/app/Http/Controllers/PreviewPurchaseOrderController.php index 660ea5f6e9e6..de086a030af3 100644 --- a/app/Http/Controllers/PreviewPurchaseOrderController.php +++ b/app/Http/Controllers/PreviewPurchaseOrderController.php @@ -260,24 +260,24 @@ class PreviewPurchaseOrderController extends BaseController /** @var \App\Models\User $user */ $user = auth()->user(); - //if phantom js...... inject here.. - if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') { - return (new Phantom)->convertHtmlToPdf($maker->getCompiledHTML(true)); - } + //if phantom js...... inject here.. + if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') { + return (new Phantom)->convertHtmlToPdf($maker->getCompiledHTML(true)); + } - if (config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja') { - $pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true)); + if (config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja') { + $pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true)); - $numbered_pdf = $this->pageNumbering($pdf, $user->company()); + $numbered_pdf = $this->pageNumbering($pdf, $user->company()); - if ($numbered_pdf) { - $pdf = $numbered_pdf; - } - - return $pdf; + if ($numbered_pdf) { + $pdf = $numbered_pdf; } - $file_path = (new PreviewPdf($maker->getCompiledHTML(true), $company))->handle(); + return $pdf; + } + + $file_path = (new PreviewPdf($maker->getCompiledHTML(true), $company))->handle(); if (Ninja::isHosted()) { diff --git a/app/Http/Controllers/ProductController.php b/app/Http/Controllers/ProductController.php index cc2784f5c0bb..c6bf1acc3619 100644 --- a/app/Http/Controllers/ProductController.php +++ b/app/Http/Controllers/ProductController.php @@ -467,7 +467,7 @@ class ProductController extends BaseController $products = Product::withTrashed()->whereIn('id', $ids); - if($action == 'set_tax_id'){ + if($action == 'set_tax_id') { $tax_id = $request->input('tax_id'); diff --git a/app/Http/Controllers/ProtectedDownloadController.php b/app/Http/Controllers/ProtectedDownloadController.php index 014527bace14..51c90774197f 100644 --- a/app/Http/Controllers/ProtectedDownloadController.php +++ b/app/Http/Controllers/ProtectedDownloadController.php @@ -11,10 +11,8 @@ namespace App\Http\Controllers; -use App\Utils\Ninja; -use Illuminate\Http\Request; -use App\Jobs\Util\UnlinkFile; use App\Exceptions\SystemError; +use Illuminate\Http\Request; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Storage; diff --git a/app/Http/Controllers/PurchaseOrderController.php b/app/Http/Controllers/PurchaseOrderController.php index fa469a9d6d6e..51f0d744b404 100644 --- a/app/Http/Controllers/PurchaseOrderController.php +++ b/app/Http/Controllers/PurchaseOrderController.php @@ -11,33 +11,32 @@ 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\Services\PdfMaker\PdfMerge; -use Illuminate\Support\Facades\App; -use App\Utils\Traits\SavesDocuments; -use App\Factory\PurchaseOrderFactory; -use App\Filters\PurchaseOrderFilters; -use Illuminate\Support\Facades\Storage; -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\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\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 { @@ -501,7 +500,7 @@ class PurchaseOrderController extends BaseController * Download Purchase Order/s */ if ($action == 'bulk_download' && $purchase_orders->count() >= 1) { - $purchase_orders->each(function ($purchase_order) use ($user){ + $purchase_orders->each(function ($purchase_order) use ($user) { if ($user->cannot('view', $purchase_order)) { return response()->json(['message' => ctrans('text.access_denied')]); } diff --git a/app/Http/Controllers/QuoteController.php b/app/Http/Controllers/QuoteController.php index 915e325ed76f..94f3218d73f8 100644 --- a/app/Http/Controllers/QuoteController.php +++ b/app/Http/Controllers/QuoteController.php @@ -11,41 +11,40 @@ 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\Factory\CloneQuoteFactory; use App\Factory\CloneQuoteToInvoiceFactory; -use App\Factory\CloneQuoteToProjectFactory; +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\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. @@ -398,7 +397,7 @@ class QuoteController extends BaseController $quote->service() ->triggeredActions($request); - // ->deletePdf(); + // ->deletePdf(); event(new QuoteWasUpdated($quote, $quote->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); @@ -536,7 +535,7 @@ class QuoteController extends BaseController * Download Quote/s */ if ($action == 'bulk_download' && $quotes->count() >= 1) { - $quotes->each(function ($quote) use($user){ + $quotes->each(function ($quote) use ($user) { if ($user->cannot('view', $quote)) { return response()->json(['message'=> ctrans('texts.access_denied')]); } @@ -687,7 +686,7 @@ class QuoteController extends BaseController return $this->itemResponse($quote->service()->convertToProject()); - case 'convert': + case 'convert': case 'convert_to_invoice': $this->entity_type = Invoice::class; diff --git a/app/Http/Controllers/RecurringInvoiceController.php b/app/Http/Controllers/RecurringInvoiceController.php index 12c3f9dad0e1..aae571d71dcb 100644 --- a/app/Http/Controllers/RecurringInvoiceController.php +++ b/app/Http/Controllers/RecurringInvoiceController.php @@ -11,28 +11,28 @@ namespace App\Http\Controllers; -use App\Utils\Ninja; -use App\Models\Account; -use Illuminate\Http\Response; -use App\Utils\Traits\MakesHash; -use App\Models\RecurringInvoice; -use App\Utils\Traits\SavesDocuments; -use App\Factory\RecurringInvoiceFactory; -use App\Filters\RecurringInvoiceFilters; -use App\Jobs\RecurringInvoice\UpdateRecurring; -use App\Repositories\RecurringInvoiceRepository; -use App\Transformers\RecurringInvoiceTransformer; use App\Events\RecurringInvoice\RecurringInvoiceWasCreated; use App\Events\RecurringInvoice\RecurringInvoiceWasUpdated; +use App\Factory\RecurringInvoiceFactory; +use App\Filters\RecurringInvoiceFilters; +use App\Http\Requests\RecurringInvoice\ActionRecurringInvoiceRequest; use App\Http\Requests\RecurringInvoice\BulkRecurringInvoiceRequest; +use App\Http\Requests\RecurringInvoice\CreateRecurringInvoiceRequest; +use App\Http\Requests\RecurringInvoice\DestroyRecurringInvoiceRequest; use App\Http\Requests\RecurringInvoice\EditRecurringInvoiceRequest; use App\Http\Requests\RecurringInvoice\ShowRecurringInvoiceRequest; use App\Http\Requests\RecurringInvoice\StoreRecurringInvoiceRequest; -use App\Http\Requests\RecurringInvoice\ActionRecurringInvoiceRequest; -use App\Http\Requests\RecurringInvoice\CreateRecurringInvoiceRequest; use App\Http\Requests\RecurringInvoice\UpdateRecurringInvoiceRequest; use App\Http\Requests\RecurringInvoice\UploadRecurringInvoiceRequest; -use App\Http\Requests\RecurringInvoice\DestroyRecurringInvoiceRequest; +use App\Jobs\RecurringInvoice\UpdateRecurring; +use App\Models\Account; +use App\Models\RecurringInvoice; +use App\Repositories\RecurringInvoiceRepository; +use App\Transformers\RecurringInvoiceTransformer; +use App\Utils\Ninja; +use App\Utils\Traits\MakesHash; +use App\Utils\Traits\SavesDocuments; +use Illuminate\Http\Response; /** * Class RecurringInvoiceController. diff --git a/app/Http/Controllers/RecurringQuoteController.php b/app/Http/Controllers/RecurringQuoteController.php index 348440c234a1..725980110a34 100644 --- a/app/Http/Controllers/RecurringQuoteController.php +++ b/app/Http/Controllers/RecurringQuoteController.php @@ -578,8 +578,8 @@ class RecurringQuoteController extends BaseController { switch ($action) { case 'clone_to_recurring_quote': - // $recurring_invoice = CloneRecurringQuoteFactory::create($recurring_invoice, auth()->user()->id); - // return $this->itemResponse($recurring_invoice); + // $recurring_invoice = CloneRecurringQuoteFactory::create($recurring_invoice, auth()->user()->id); + // return $this->itemResponse($recurring_invoice); break; case 'clone_to_quote': // $quote = CloneRecurringQuoteToQuoteFactory::create($recurring_invoice, auth()->user()->id); diff --git a/app/Http/Controllers/Reports/ARDetailReportController.php b/app/Http/Controllers/Reports/ARDetailReportController.php index 4f6c460e7a31..1d3784822299 100644 --- a/app/Http/Controllers/Reports/ARDetailReportController.php +++ b/app/Http/Controllers/Reports/ARDetailReportController.php @@ -11,11 +11,11 @@ namespace App\Http\Controllers\Reports; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; -use App\Services\Report\ARDetailReport; use App\Http\Controllers\BaseController; use App\Http\Requests\Report\GenericReportRequest; +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/ActivityReportController.php b/app/Http/Controllers/Reports/ActivityReportController.php index ed241a9e38f2..1a10c131865e 100644 --- a/app/Http/Controllers/Reports/ActivityReportController.php +++ b/app/Http/Controllers/Reports/ActivityReportController.php @@ -11,12 +11,12 @@ namespace App\Http\Controllers\Reports; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; use App\Export\CSV\ActivityExport; -use App\Jobs\Report\PreviewReport; use App\Http\Controllers\BaseController; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Utils\Traits\MakesHash; class ActivityReportController extends BaseController { diff --git a/app/Http/Controllers/Reports/ClientBalanceReportController.php b/app/Http/Controllers/Reports/ClientBalanceReportController.php index 0202af3d2f68..c29b0a213a10 100644 --- a/app/Http/Controllers/Reports/ClientBalanceReportController.php +++ b/app/Http/Controllers/Reports/ClientBalanceReportController.php @@ -11,12 +11,11 @@ namespace App\Http\Controllers\Reports; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; use App\Http\Controllers\BaseController; -use App\Services\Report\ARSummaryReport; -use App\Services\Report\ClientBalanceReport; use App\Http\Requests\Report\GenericReportRequest; +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/ClientContactReportController.php b/app/Http/Controllers/Reports/ClientContactReportController.php index e29eefe195f2..002573c0eea8 100644 --- a/app/Http/Controllers/Reports/ClientContactReportController.php +++ b/app/Http/Controllers/Reports/ClientContactReportController.php @@ -11,13 +11,13 @@ namespace App\Http\Controllers\Reports; -use Illuminate\Http\Response; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; use App\Export\CSV\ContactExport; -use App\Jobs\Report\PreviewReport; use App\Http\Controllers\BaseController; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Utils\Traits\MakesHash; +use Illuminate\Http\Response; class ClientContactReportController extends BaseController { diff --git a/app/Http/Controllers/Reports/ClientReportController.php b/app/Http/Controllers/Reports/ClientReportController.php index bcbc2c02d98d..a0421f5288d0 100644 --- a/app/Http/Controllers/Reports/ClientReportController.php +++ b/app/Http/Controllers/Reports/ClientReportController.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\Export\CSV\ClientExport; -use App\Jobs\Report\SendToAdmin; -use App\Jobs\Report\PreviewReport; use App\Http\Controllers\BaseController; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Models\Client; +use App\Utils\Traits\MakesHash; +use Illuminate\Http\Response; class ClientReportController extends BaseController { diff --git a/app/Http/Controllers/Reports/ClientSalesReportController.php b/app/Http/Controllers/Reports/ClientSalesReportController.php index 056b157775b3..63c0ac69fe3c 100644 --- a/app/Http/Controllers/Reports/ClientSalesReportController.php +++ b/app/Http/Controllers/Reports/ClientSalesReportController.php @@ -11,12 +11,11 @@ namespace App\Http\Controllers\Reports; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; use App\Http\Controllers\BaseController; -use App\Services\Report\ClientSalesReport; -use App\Services\Report\ClientBalanceReport; use App\Http\Requests\Report\GenericReportRequest; +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/DocumentReportController.php b/app/Http/Controllers/Reports/DocumentReportController.php index d0cd939c86a7..e7db3f74186c 100644 --- a/app/Http/Controllers/Reports/DocumentReportController.php +++ b/app/Http/Controllers/Reports/DocumentReportController.php @@ -11,13 +11,13 @@ namespace App\Http\Controllers\Reports; -use Illuminate\Http\Response; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; use App\Export\CSV\DocumentExport; -use App\Jobs\Report\PreviewReport; use App\Http\Controllers\BaseController; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Utils\Traits\MakesHash; +use Illuminate\Http\Response; class DocumentReportController extends BaseController { diff --git a/app/Http/Controllers/Reports/ExpenseReportController.php b/app/Http/Controllers/Reports/ExpenseReportController.php index f1276cdaffdd..2cd849891f1f 100644 --- a/app/Http/Controllers/Reports/ExpenseReportController.php +++ b/app/Http/Controllers/Reports/ExpenseReportController.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\Export\CSV\ExpenseExport; -use App\Jobs\Report\PreviewReport; use App\Http\Controllers\BaseController; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Models\Client; +use App\Utils\Traits\MakesHash; +use Illuminate\Http\Response; class ExpenseReportController extends BaseController { diff --git a/app/Http/Controllers/Reports/InvoiceItemReportController.php b/app/Http/Controllers/Reports/InvoiceItemReportController.php index a124171cc66e..3bb534b7f0e8 100644 --- a/app/Http/Controllers/Reports/InvoiceItemReportController.php +++ b/app/Http/Controllers/Reports/InvoiceItemReportController.php @@ -11,13 +11,13 @@ namespace App\Http\Controllers\Reports; -use Illuminate\Http\Response; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; -use App\Jobs\Report\PreviewReport; use App\Export\CSV\InvoiceItemExport; use App\Http\Controllers\BaseController; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Utils\Traits\MakesHash; +use Illuminate\Http\Response; class InvoiceItemReportController extends BaseController { diff --git a/app/Http/Controllers/Reports/InvoiceReportController.php b/app/Http/Controllers/Reports/InvoiceReportController.php index c00687fb6885..fea397431be5 100644 --- a/app/Http/Controllers/Reports/InvoiceReportController.php +++ b/app/Http/Controllers/Reports/InvoiceReportController.php @@ -11,13 +11,13 @@ namespace App\Http\Controllers\Reports; -use Illuminate\Http\Response; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; use App\Export\CSV\InvoiceExport; -use App\Jobs\Report\PreviewReport; use App\Http\Controllers\BaseController; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Utils\Traits\MakesHash; +use Illuminate\Http\Response; class InvoiceReportController extends BaseController { diff --git a/app/Http/Controllers/Reports/PaymentReportController.php b/app/Http/Controllers/Reports/PaymentReportController.php index cca6925ef98a..92611439bcfd 100644 --- a/app/Http/Controllers/Reports/PaymentReportController.php +++ b/app/Http/Controllers/Reports/PaymentReportController.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\Export\CSV\PaymentExport; -use App\Jobs\Report\PreviewReport; use App\Http\Controllers\BaseController; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Models\Client; +use App\Utils\Traits\MakesHash; +use Illuminate\Http\Response; class PaymentReportController extends BaseController { diff --git a/app/Http/Controllers/Reports/ProductReportController.php b/app/Http/Controllers/Reports/ProductReportController.php index 664bd51a698f..5eda138752ed 100644 --- a/app/Http/Controllers/Reports/ProductReportController.php +++ b/app/Http/Controllers/Reports/ProductReportController.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\Export\CSV\ProductExport; -use App\Jobs\Report\PreviewReport; use App\Http\Controllers\BaseController; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Models\Client; +use App\Utils\Traits\MakesHash; +use Illuminate\Http\Response; class ProductReportController extends BaseController { diff --git a/app/Http/Controllers/Reports/PurchaseOrderItemReportController.php b/app/Http/Controllers/Reports/PurchaseOrderItemReportController.php index 71509576f582..2ad7ff67a5ec 100644 --- a/app/Http/Controllers/Reports/PurchaseOrderItemReportController.php +++ b/app/Http/Controllers/Reports/PurchaseOrderItemReportController.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\Export\CSV\PurchaseOrderItemExport; +use App\Http\Controllers\BaseController; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Utils\Traits\MakesHash; class PurchaseOrderItemReportController extends BaseController { diff --git a/app/Http/Controllers/Reports/PurchaseOrderReportController.php b/app/Http/Controllers/Reports/PurchaseOrderReportController.php index 5899b20cfcef..06aeba50a7f0 100644 --- a/app/Http/Controllers/Reports/PurchaseOrderReportController.php +++ b/app/Http/Controllers/Reports/PurchaseOrderReportController.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\Export\CSV\PurchaseOrderExport; use App\Http\Controllers\BaseController; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Utils\Traits\MakesHash; class PurchaseOrderReportController extends BaseController { diff --git a/app/Http/Controllers/Reports/QuoteItemReportController.php b/app/Http/Controllers/Reports/QuoteItemReportController.php index 78295f1ddc7c..926107744c70 100644 --- a/app/Http/Controllers/Reports/QuoteItemReportController.php +++ b/app/Http/Controllers/Reports/QuoteItemReportController.php @@ -11,13 +11,13 @@ namespace App\Http\Controllers\Reports; -use Illuminate\Http\Response; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; -use App\Jobs\Report\PreviewReport; use App\Export\CSV\QuoteItemExport; use App\Http\Controllers\BaseController; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Utils\Traits\MakesHash; +use Illuminate\Http\Response; class QuoteItemReportController extends BaseController { diff --git a/app/Http/Controllers/Reports/QuoteReportController.php b/app/Http/Controllers/Reports/QuoteReportController.php index 9034b1a939c4..d7030f1f9d3a 100644 --- a/app/Http/Controllers/Reports/QuoteReportController.php +++ b/app/Http/Controllers/Reports/QuoteReportController.php @@ -11,13 +11,13 @@ namespace App\Http\Controllers\Reports; -use Illuminate\Http\Response; use App\Export\CSV\QuoteExport; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; -use App\Jobs\Report\PreviewReport; use App\Http\Controllers\BaseController; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Utils\Traits\MakesHash; +use Illuminate\Http\Response; class QuoteReportController extends BaseController { diff --git a/app/Http/Controllers/Reports/RecurringInvoiceReportController.php b/app/Http/Controllers/Reports/RecurringInvoiceReportController.php index 26eb279106f2..811f72ecb4b9 100644 --- a/app/Http/Controllers/Reports/RecurringInvoiceReportController.php +++ b/app/Http/Controllers/Reports/RecurringInvoiceReportController.php @@ -11,13 +11,12 @@ namespace App\Http\Controllers\Reports; -use Illuminate\Http\Response; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; -use App\Jobs\Report\PreviewReport; -use App\Http\Controllers\BaseController; use App\Export\CSV\RecurringInvoiceExport; +use App\Http\Controllers\BaseController; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Utils\Traits\MakesHash; class RecurringInvoiceReportController extends BaseController { diff --git a/app/Http/Controllers/Reports/ReportPreviewController.php b/app/Http/Controllers/Reports/ReportPreviewController.php index 82f55bc2f4df..1bb559552c0c 100644 --- a/app/Http/Controllers/Reports/ReportPreviewController.php +++ b/app/Http/Controllers/Reports/ReportPreviewController.php @@ -11,10 +11,10 @@ namespace App\Http\Controllers\Reports; -use App\Utils\Traits\MakesHash; -use Illuminate\Support\Facades\Cache; use App\Http\Controllers\BaseController; use App\Http\Requests\Report\ReportPreviewRequest; +use App\Utils\Traits\MakesHash; +use Illuminate\Support\Facades\Cache; class ReportPreviewController extends BaseController { @@ -30,10 +30,11 @@ class ReportPreviewController extends BaseController $report = Cache::get($hash); - if(!$report) + if(!$report) { return response()->json(['message' => 'Still working.....'], 409); + } - if($report){ + if($report) { Cache::forget($hash); diff --git a/app/Http/Controllers/Reports/TaskReportController.php b/app/Http/Controllers/Reports/TaskReportController.php index 8339a909bcb0..970a5e7699ec 100644 --- a/app/Http/Controllers/Reports/TaskReportController.php +++ b/app/Http/Controllers/Reports/TaskReportController.php @@ -11,13 +11,13 @@ namespace App\Http\Controllers\Reports; -use Illuminate\Http\Response; use App\Export\CSV\TaskExport; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; -use App\Jobs\Report\PreviewReport; use App\Http\Controllers\BaseController; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Utils\Traits\MakesHash; +use Illuminate\Http\Response; class TaskReportController extends BaseController { diff --git a/app/Http/Controllers/Reports/TaxSummaryReportController.php b/app/Http/Controllers/Reports/TaxSummaryReportController.php index 776fa988d694..b199eadcc1f2 100644 --- a/app/Http/Controllers/Reports/TaxSummaryReportController.php +++ b/app/Http/Controllers/Reports/TaxSummaryReportController.php @@ -11,12 +11,11 @@ namespace App\Http\Controllers\Reports; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; use App\Http\Controllers\BaseController; -use App\Services\Report\TaxSummaryReport; -use App\Services\Report\ClientSalesReport; use App\Http\Requests\Report\GenericReportRequest; +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 582eb4e71727..2d80995791aa 100644 --- a/app/Http/Controllers/Reports/UserSalesReportController.php +++ b/app/Http/Controllers/Reports/UserSalesReportController.php @@ -11,12 +11,11 @@ namespace App\Http\Controllers\Reports; -use App\Utils\Traits\MakesHash; -use App\Jobs\Report\SendToAdmin; use App\Http\Controllers\BaseController; -use App\Services\Report\UserSalesReport; -use App\Services\Report\TaxSummaryReport; use App\Http\Requests\Report\GenericReportRequest; +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/Reports/VendorReportController.php b/app/Http/Controllers/Reports/VendorReportController.php index bfd0f3b2298e..50dbf6380650 100644 --- a/app/Http/Controllers/Reports/VendorReportController.php +++ b/app/Http/Controllers/Reports/VendorReportController.php @@ -11,12 +11,12 @@ namespace App\Http\Controllers\Reports; -use App\Utils\Traits\MakesHash; use App\Export\CSV\VendorExport; -use App\Jobs\Report\SendToAdmin; -use App\Jobs\Report\PreviewReport; use App\Http\Controllers\BaseController; use App\Http\Requests\Report\GenericReportRequest; +use App\Jobs\Report\PreviewReport; +use App\Jobs\Report\SendToAdmin; +use App\Utils\Traits\MakesHash; class VendorReportController extends BaseController { diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index cd985b44c721..7699e8c3d60a 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -54,25 +54,25 @@ class SearchController extends Controller ->take(1000) ->get(); - foreach($clients as $client) { - $this->clients[] = [ - 'name' => $client->present()->name(), - 'type' => '/client', - 'id' => $client->hashed_id, - 'path' => "/clients/{$client->hashed_id}/edit" - ]; + foreach($clients as $client) { + $this->clients[] = [ + 'name' => $client->present()->name(), + 'type' => '/client', + 'id' => $client->hashed_id, + 'path' => "/clients/{$client->hashed_id}/edit" + ]; - $client->contacts->each(function ($contact) { - $this->client_contacts[] = [ - 'name' => $contact->present()->search_display(), - 'type' => '/client_contact', - 'id' => $contact->hashed_id, - 'path' => "/clients/{$contact->hashed_id}" - ]; + $client->contacts->each(function ($contact) { + $this->client_contacts[] = [ + 'name' => $contact->present()->search_display(), + 'type' => '/client_contact', + 'id' => $contact->hashed_id, + 'path' => "/clients/{$contact->hashed_id}" + ]; - }); - } + }); + } } @@ -92,16 +92,16 @@ class SearchController extends Controller }) ->orderBy('id', 'desc') ->take(3000) - ->get(); + ->get(); - foreach($invoices as $invoice) { - $this->invoices[] = [ - 'name' => $invoice->client->present()->name() . ' - ' . $invoice->number, - 'type' => '/invoice', - 'id' => $invoice->hashed_id, - 'path' => "/invoices/{$invoice->hashed_id}/edit" - ]; - } + foreach($invoices as $invoice) { + $this->invoices[] = [ + 'name' => $invoice->client->present()->name() . ' - ' . $invoice->number, + 'type' => '/invoice', + 'id' => $invoice->hashed_id, + 'path' => "/invoices/{$invoice->hashed_id}/edit" + ]; + } } diff --git a/app/Http/Controllers/SelfUpdateController.php b/app/Http/Controllers/SelfUpdateController.php index 75d2442fcdae..651d884ac30a 100644 --- a/app/Http/Controllers/SelfUpdateController.php +++ b/app/Http/Controllers/SelfUpdateController.php @@ -11,14 +11,14 @@ namespace App\Http\Controllers; -use App\Utils\Ninja; +use App\Exceptions\FilePermissionsFailure; use App\Models\Company; +use App\Utils\Ninja; use App\Utils\Traits\AppSetup; +use App\Utils\Traits\ClientGroupSettingsSaver; +use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Storage; -use App\Exceptions\FilePermissionsFailure; -use Illuminate\Foundation\Bus\DispatchesJobs; -use App\Utils\Traits\ClientGroupSettingsSaver; class SelfUpdateController extends BaseController { @@ -72,8 +72,7 @@ class SelfUpdateController extends BaseController if (copy($this->getDownloadUrl(), storage_path("app/{$this->filename}"))) { nlog('Copied file from URL'); } - } - catch(\Exception $e) { + } catch(\Exception $e) { nlog($e->getMessage()); return response()->json(['message' => 'File exists on the server, however there was a problem downloading and copying to the local filesystem'], 500); } @@ -121,18 +120,19 @@ class SelfUpdateController extends BaseController { Company::query() ->cursor() - ->each(function ($company){ + ->each(function ($company) { - $settings = $company->settings; + $settings = $company->settings; - if(property_exists($settings->pdf_variables, 'purchase_order_details')) - return; + if(property_exists($settings->pdf_variables, 'purchase_order_details')) { + return; + } - $pdf_variables = $settings->pdf_variables; - $pdf_variables->purchase_order_details = []; - $settings->pdf_variables = $pdf_variables; - $company->settings = $settings; - $company->save(); + $pdf_variables = $settings->pdf_variables; + $pdf_variables->purchase_order_details = []; + $settings->pdf_variables = $pdf_variables; + $company->settings = $settings; + $company->save(); }); } diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.php index c849e7348092..e7ac3a610799 100644 --- a/app/Http/Controllers/SetupController.php +++ b/app/Http/Controllers/SetupController.php @@ -121,8 +121,7 @@ class SetupController extends Controller unset($env_values['DB_DATABASE']); unset($env_values['DB_USERNAME']); unset($env_values['DB_PASSWORD']); - } - else { + } else { config(['database.connections.mysql.host' => $request->input('db_host')]); config(['database.connections.mysql.port' => $request->input('db_port')]); diff --git a/app/Http/Controllers/Shop/ProfileController.php b/app/Http/Controllers/Shop/ProfileController.php index 975ca5cf34af..4239baeaa217 100644 --- a/app/Http/Controllers/Shop/ProfileController.php +++ b/app/Http/Controllers/Shop/ProfileController.php @@ -28,7 +28,7 @@ class ProfileController extends BaseController public function show(Request $request) { - /** @var \App\Models\Company $company */ + /** @var \App\Models\Company $company */ $company = Company::where('company_key', $request->header('X-API-COMPANY-KEY'))->first(); if (! $company->enable_shop_api) { diff --git a/app/Http/Controllers/StripeConnectController.php b/app/Http/Controllers/StripeConnectController.php index edb97e486d14..3a5f9ddd8e0f 100644 --- a/app/Http/Controllers/StripeConnectController.php +++ b/app/Http/Controllers/StripeConnectController.php @@ -123,7 +123,7 @@ class StripeConnectController extends BaseController $company_gateway->setConfig($payload); $company_gateway->save(); - try{ + try { $stripe = $company_gateway->driver()->init(); $a = \Stripe\Account::retrieve($response->stripe_user_id, $stripe->stripe_connect_auth); @@ -131,8 +131,7 @@ class StripeConnectController extends BaseController $company_gateway->label = substr("Stripe - {$a->business_name}", 0, 250); $company_gateway->save(); } - } - catch(\Exception $e){ + } catch(\Exception $e) { nlog("could not harvest stripe company name"); } diff --git a/app/Http/Controllers/TaskController.php b/app/Http/Controllers/TaskController.php index 1d722b86a2f6..a66c64424f6c 100644 --- a/app/Http/Controllers/TaskController.php +++ b/app/Http/Controllers/TaskController.php @@ -327,7 +327,7 @@ class TaskController extends BaseController * ) */ public function create(CreateTaskRequest $request) - { + { /** @var \App\Models\User $user */ $user = auth()->user(); @@ -506,7 +506,7 @@ class TaskController extends BaseController $tasks->each(function ($task, $key) use ($action) { /** @var \App\Models\User $user */ - $user = auth()->user(); + $user = auth()->user(); if ($user->can('edit', $task)) { $this->task_repo->{$action}($task); } @@ -633,7 +633,7 @@ class TaskController extends BaseController /** @var \App\Models\User $user */ $user = auth()->user(); - collect($task_statuses)->each(function ($task_status_hashed_id, $key) use($user){ + collect($task_statuses)->each(function ($task_status_hashed_id, $key) use ($user) { $task_status = TaskStatus::query()->where('id', $this->decodePrimaryKey($task_status_hashed_id)) ->where('company_id', $user->company()->id) ->withTrashed() diff --git a/app/Http/Controllers/TaskSchedulerController.php b/app/Http/Controllers/TaskSchedulerController.php index 24e19e955991..e206ca8e4e2c 100644 --- a/app/Http/Controllers/TaskSchedulerController.php +++ b/app/Http/Controllers/TaskSchedulerController.php @@ -22,7 +22,6 @@ use App\Models\Scheduler; use App\Repositories\SchedulerRepository; use App\Transformers\SchedulerTransformer; use App\Utils\Traits\MakesHash; -use Symfony\Component\HttpFoundation\Request; class TaskSchedulerController extends BaseController { diff --git a/app/Http/Controllers/TaskStatusController.php b/app/Http/Controllers/TaskStatusController.php index 836dc9f88a30..db3d79f40645 100644 --- a/app/Http/Controllers/TaskStatusController.php +++ b/app/Http/Controllers/TaskStatusController.php @@ -11,20 +11,20 @@ namespace App\Http\Controllers; -use App\Models\TaskStatus; -use Illuminate\Http\Response; -use App\Utils\Traits\MakesHash; use App\Factory\TaskStatusFactory; use App\Filters\TaskStatusFilters; -use App\Repositories\TaskStatusRepository; -use App\Transformers\TaskStatusTransformer; +use App\Http\Requests\TaskStatus\ActionTaskStatusRequest; +use App\Http\Requests\TaskStatus\CreateTaskStatusRequest; +use App\Http\Requests\TaskStatus\DestroyTaskStatusRequest; use App\Http\Requests\TaskStatus\EditTaskStatusRequest; use App\Http\Requests\TaskStatus\ShowTaskStatusRequest; use App\Http\Requests\TaskStatus\StoreTaskStatusRequest; -use App\Http\Requests\TaskStatus\ActionTaskStatusRequest; -use App\Http\Requests\TaskStatus\CreateTaskStatusRequest; use App\Http\Requests\TaskStatus\UpdateTaskStatusRequest; -use App\Http\Requests\TaskStatus\DestroyTaskStatusRequest; +use App\Models\TaskStatus; +use App\Repositories\TaskStatusRepository; +use App\Transformers\TaskStatusTransformer; +use App\Utils\Traits\MakesHash; +use Illuminate\Http\Response; class TaskStatusController extends BaseController { @@ -135,8 +135,9 @@ class TaskStatusController extends BaseController $reorder = $task_status->isDirty('status_order'); $task_status->save(); - if ($reorder) + if ($reorder) { $this->task_status_repo->reorder($task_status); + } return $this->itemResponse($task_status->fresh()); @@ -148,7 +149,7 @@ class TaskStatusController extends BaseController * @param DestroyTaskStatusRequest $request * @param TaskStatus $task_status * @return Response - * + * * @throws \Exception */ public function destroy(DestroyTaskStatusRequest $request, TaskStatus $task_status) diff --git a/app/Http/Controllers/TemplatePreviewController.php b/app/Http/Controllers/TemplatePreviewController.php index 76a15ab42cc6..2cfd05ed8ab9 100644 --- a/app/Http/Controllers/TemplatePreviewController.php +++ b/app/Http/Controllers/TemplatePreviewController.php @@ -11,11 +11,10 @@ namespace App\Http\Controllers; +use App\Http\Requests\Report\ReportPreviewRequest; use App\Utils\Traits\MakesHash; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Storage; -use App\Http\Controllers\BaseController; -use App\Http\Requests\Report\ReportPreviewRequest; class TemplatePreviewController extends BaseController { diff --git a/app/Http/Controllers/Traits/VerifiesUserEmail.php b/app/Http/Controllers/Traits/VerifiesUserEmail.php index 7b26c9de3962..f5796c51e9ed 100644 --- a/app/Http/Controllers/Traits/VerifiesUserEmail.php +++ b/app/Http/Controllers/Traits/VerifiesUserEmail.php @@ -36,7 +36,7 @@ trait VerifiesUserEmail if (! $user) { return $this->render('auth.confirmed', [ - 'root' => 'themes', + 'root' => 'themes', 'message' => ctrans('texts.wrong_confirmation'), 'redirect_url' => request()->has('react') ? config('ninja.react_url')."/#/" : url('/')]); } diff --git a/app/Http/Controllers/TwilioController.php b/app/Http/Controllers/TwilioController.php index d6bf7488d931..39b7f726372c 100644 --- a/app/Http/Controllers/TwilioController.php +++ b/app/Http/Controllers/TwilioController.php @@ -11,13 +11,13 @@ namespace App\Http\Controllers; -use App\Models\User; -use Twilio\Rest\Client; -use App\Libraries\MultiDB; use App\Http\Requests\Twilio\Confirm2faRequest; use App\Http\Requests\Twilio\ConfirmSmsRequest; use App\Http\Requests\Twilio\Generate2faRequest; use App\Http\Requests\Twilio\GenerateSmsRequest; +use App\Libraries\MultiDB; +use App\Models\User; +use Twilio\Rest\Client; class TwilioController extends BaseController { diff --git a/app/Http/Controllers/TwoFactorController.php b/app/Http/Controllers/TwoFactorController.php index 9ba490a6f1b2..2d86469f9dd8 100644 --- a/app/Http/Controllers/TwoFactorController.php +++ b/app/Http/Controllers/TwoFactorController.php @@ -11,11 +11,11 @@ namespace App\Http\Controllers; +use App\Http\Requests\TwoFactor\EnableTwoFactorRequest; use App\Models\User; +use App\Transformers\UserTransformer; use App\Utils\Ninja; use PragmaRX\Google2FA\Google2FA; -use App\Transformers\UserTransformer; -use App\Http\Requests\TwoFactor\EnableTwoFactorRequest; class TwoFactorController extends BaseController { @@ -30,10 +30,9 @@ class TwoFactorController extends BaseController if ($user->google_2fa_secret) { return response()->json(['message' => '2FA already enabled'], 400); - } elseif(Ninja::isSelfHost()){ + } elseif(Ninja::isSelfHost()) { - } - elseif (! $user->phone) { + } elseif (! $user->phone) { return response()->json(['message' => ctrans('texts.set_phone_for_two_factor')], 400); } elseif (! $user->isVerified()) { return response()->json(['message' => 'Please confirm your account first'], 400); diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 2c785dbc849e..03f9f0584d8a 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -11,31 +11,31 @@ namespace App\Http\Controllers; -use App\Models\User; -use App\Utils\Ninja; -use App\Models\CompanyUser; -use App\Factory\UserFactory; -use App\Filters\UserFilters; -use Illuminate\Http\Response; -use App\Utils\Traits\MakesHash; use App\Events\User\UserWasCreated; use App\Events\User\UserWasDeleted; use App\Events\User\UserWasUpdated; -use App\Jobs\User\UserEmailChanged; -use App\Repositories\UserRepository; -use App\Transformers\UserTransformer; -use App\Jobs\Company\CreateCompanyToken; -use App\Http\Requests\User\BulkUserRequest; -use App\Http\Requests\User\EditUserRequest; -use App\Http\Requests\User\ShowUserRequest; -use App\Http\Requests\User\StoreUserRequest; -use App\Http\Requests\User\CreateUserRequest; -use App\Http\Requests\User\UpdateUserRequest; -use App\Http\Requests\User\DestroyUserRequest; -use App\Http\Requests\User\ReconfirmUserRequest; +use App\Factory\UserFactory; +use App\Filters\UserFilters; use App\Http\Controllers\Traits\VerifiesUserEmail; +use App\Http\Requests\User\BulkUserRequest; +use App\Http\Requests\User\CreateUserRequest; +use App\Http\Requests\User\DestroyUserRequest; use App\Http\Requests\User\DetachCompanyUserRequest; use App\Http\Requests\User\DisconnectUserMailerRequest; +use App\Http\Requests\User\EditUserRequest; +use App\Http\Requests\User\ReconfirmUserRequest; +use App\Http\Requests\User\ShowUserRequest; +use App\Http\Requests\User\StoreUserRequest; +use App\Http\Requests\User\UpdateUserRequest; +use App\Jobs\Company\CreateCompanyToken; +use App\Jobs\User\UserEmailChanged; +use App\Models\CompanyUser; +use App\Models\User; +use App\Repositories\UserRepository; +use App\Transformers\UserTransformer; +use App\Utils\Ninja; +use App\Utils\Traits\MakesHash; +use Illuminate\Http\Response; /** * Class UserController. @@ -235,7 +235,7 @@ class UserController extends BaseController $return_user_collection = collect(); /** @var \App\Models\User $logged_in_user */ - $logged_in_user = auth()->user(); + $logged_in_user = auth()->user(); $users->each(function ($user, $key) use ($logged_in_user, $action, $return_user_collection) { if ($logged_in_user->can('edit', $user)) { diff --git a/app/Http/Controllers/VendorPortal/InvitationController.php b/app/Http/Controllers/VendorPortal/InvitationController.php index 7ce6ae394d01..e0666ecfe109 100644 --- a/app/Http/Controllers/VendorPortal/InvitationController.php +++ b/app/Http/Controllers/VendorPortal/InvitationController.php @@ -11,17 +11,17 @@ namespace App\Http\Controllers\VendorPortal; -use App\Utils\Ninja; -use Illuminate\Support\Str; -use App\Utils\Traits\MakesHash; -use App\Utils\Traits\MakesDates; -use Illuminate\Support\Facades\App; -use App\Http\Controllers\Controller; -use Illuminate\Support\Facades\Auth; -use App\Models\PurchaseOrderInvitation; use App\Events\Misc\InvitationWasViewed; -use App\Jobs\Vendor\CreatePurchaseOrderPdf; use App\Events\PurchaseOrder\PurchaseOrderWasViewed; +use App\Http\Controllers\Controller; +use App\Jobs\Vendor\CreatePurchaseOrderPdf; +use App\Models\PurchaseOrderInvitation; +use App\Utils\Ninja; +use App\Utils\Traits\MakesDates; +use App\Utils\Traits\MakesHash; +use Illuminate\Support\Facades\App; +use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Str; /** * Class InvitationController. diff --git a/app/Http/Controllers/VendorPortal/PurchaseOrderController.php b/app/Http/Controllers/VendorPortal/PurchaseOrderController.php index 74d66f0542fd..9fe4e285b269 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\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\Jobs\Vendor\CreatePurchaseOrderPdf; -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\Invoice\InjectSignature; +use App\Jobs\Vendor\CreatePurchaseOrderPdf; +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 { @@ -184,7 +184,7 @@ class PurchaseOrderController extends Controller } event(new PurchaseOrderWasAccepted($purchase_order, auth()->guard('vendor')->user(), $purchase_order->company, Ninja::eventVars())); - }); + }); if ($purchase_count_query->count() == 1) { $purchase_order = $purchase_count_query->first(); diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 171626827189..6a53796f3bd0 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -11,53 +11,52 @@ namespace App\Http; -use App\Utils\Ninja; -use App\Http\Middleware\Cors; -use App\Http\Middleware\SetDb; -use App\Http\Middleware\Locale; -use App\Http\Middleware\SetWebDb; -use App\Http\Middleware\UrlSetDb; -use App\Http\Middleware\TokenAuth; -use App\Http\Middleware\SetEmailDb; -use App\Http\Middleware\VerifyHash; -use App\Http\Middleware\SetInviteDb; -use App\Http\Middleware\TrimStrings; -use App\Http\Middleware\Authenticate; -use App\Http\Middleware\ContactSetDb; -use App\Http\Middleware\QueryLogging; -use App\Http\Middleware\TrustProxies; -use App\Http\Middleware\UserVerified; -use App\Http\Middleware\VendorLocale; -use App\Http\Middleware\PhantomSecret; -use App\Http\Middleware\SetDocumentDb; use App\Http\Middleware\ApiSecretCheck; +use App\Http\Middleware\Authenticate; +use App\Http\Middleware\CheckClientExistence; +use App\Http\Middleware\CheckForMaintenanceMode; +use App\Http\Middleware\ClientPortalEnabled; use App\Http\Middleware\ContactAccount; -use App\Http\Middleware\EncryptCookies; -use App\Http\Middleware\SessionDomains; use App\Http\Middleware\ContactKeyLogin; use App\Http\Middleware\ContactRegister; -use App\Http\Middleware\SetDomainNameDb; -use App\Http\Middleware\VerifyCsrfToken; +use App\Http\Middleware\ContactSetDb; use App\Http\Middleware\ContactTokenAuth; -use Illuminate\Auth\Middleware\Authorize; -use App\Http\Middleware\SetDbByCompanyKey; -use App\Http\Middleware\ValidateSignature; +use App\Http\Middleware\Cors; +use App\Http\Middleware\EncryptCookies; +use App\Http\Middleware\Locale; use App\Http\Middleware\PasswordProtection; -use App\Http\Middleware\ClientPortalEnabled; -use App\Http\Middleware\CheckClientExistence; -use App\Http\Middleware\VendorContactKeyLogin; -use Illuminate\Http\Middleware\SetCacheHeaders; -use Illuminate\Session\Middleware\StartSession; -use App\Http\Middleware\CheckForMaintenanceMode; +use App\Http\Middleware\PhantomSecret; +use App\Http\Middleware\QueryLogging; use App\Http\Middleware\RedirectIfAuthenticated; -use Illuminate\Foundation\Http\Kernel as HttpKernel; -use Illuminate\Auth\Middleware\EnsureEmailIsVerified; -use Illuminate\Routing\Middleware\SubstituteBindings; -use Illuminate\View\Middleware\ShareErrorsFromSession; +use App\Http\Middleware\SessionDomains; +use App\Http\Middleware\SetDb; +use App\Http\Middleware\SetDbByCompanyKey; +use App\Http\Middleware\SetDocumentDb; +use App\Http\Middleware\SetDomainNameDb; +use App\Http\Middleware\SetEmailDb; +use App\Http\Middleware\SetInviteDb; +use App\Http\Middleware\SetWebDb; +use App\Http\Middleware\TokenAuth; +use App\Http\Middleware\TrimStrings; +use App\Http\Middleware\TrustProxies; +use App\Http\Middleware\UrlSetDb; +use App\Http\Middleware\UserVerified; +use App\Http\Middleware\ValidateSignature; +use App\Http\Middleware\VendorContactKeyLogin; +use App\Http\Middleware\VendorLocale; +use App\Http\Middleware\VerifyCsrfToken; +use App\Http\Middleware\VerifyHash; use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth; -use Illuminate\Foundation\Http\Middleware\ValidatePostSize; +use Illuminate\Auth\Middleware\Authorize; +use Illuminate\Auth\Middleware\EnsureEmailIsVerified; use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse; +use Illuminate\Foundation\Http\Kernel as HttpKernel; use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull; +use Illuminate\Foundation\Http\Middleware\ValidatePostSize; +use Illuminate\Http\Middleware\SetCacheHeaders; +use Illuminate\Routing\Middleware\SubstituteBindings; +use Illuminate\Session\Middleware\StartSession; +use Illuminate\View\Middleware\ShareErrorsFromSession; class Kernel extends HttpKernel { diff --git a/app/Http/Livewire/BillingPortalPurchase.php b/app/Http/Livewire/BillingPortalPurchase.php index f8e625e03cf8..caa9b4b19571 100644 --- a/app/Http/Livewire/BillingPortalPurchase.php +++ b/app/Http/Livewire/BillingPortalPurchase.php @@ -23,7 +23,6 @@ use App\Models\Invoice; use App\Models\Subscription; use App\Repositories\ClientContactRepository; use App\Repositories\ClientRepository; -use App\Services\Subscription\SubscriptionService; use App\Utils\Ninja; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Cache; diff --git a/app/Http/Livewire/PdfSlot.php b/app/Http/Livewire/PdfSlot.php index 9638eafe2d02..f785f5f67cda 100644 --- a/app/Http/Livewire/PdfSlot.php +++ b/app/Http/Livewire/PdfSlot.php @@ -12,21 +12,21 @@ namespace App\Http\Livewire; -use App\Utils\Number; -use Livewire\Component; -use App\Utils\HtmlEngine; +use App\Jobs\Invoice\CreateEInvoice; +use App\Jobs\Vendor\CreatePurchaseOrderPdf; use App\Libraries\MultiDB; -use Illuminate\Support\Str; -use App\Models\QuoteInvitation; -use App\Utils\VendorHtmlEngine; use App\Models\CreditInvitation; use App\Models\InvoiceInvitation; -use App\Jobs\Invoice\CreateEInvoice; -use Illuminate\Support\Facades\Cache; use App\Models\PurchaseOrderInvitation; +use App\Models\QuoteInvitation; use App\Models\RecurringInvoiceInvitation; -use App\Jobs\Vendor\CreatePurchaseOrderPdf; use App\Services\PdfMaker\Designs\Utilities\DesignHelpers; +use App\Utils\HtmlEngine; +use App\Utils\Number; +use App\Utils\VendorHtmlEngine; +use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Str; +use Livewire\Component; class PdfSlot extends Component { @@ -70,7 +70,7 @@ class PdfSlot extends Component public function getPdf() { - if(!$this->invitation){ + if(!$this->invitation) { $this->entity->service()->createInvitations(); $this->invitation = $this->entity->invitations()->first(); } @@ -95,10 +95,11 @@ class PdfSlot extends Component $file_name = $this->entity->numberFormatter().'.pdf'; - if($this->entity instanceof \App\Models\PurchaseOrder) + if($this->entity instanceof \App\Models\PurchaseOrder) { $file = (new CreatePurchaseOrderPdf($this->invitation, $this->invitation->company->db))->rawPdf(); - else + } else { $file = (new \App\Jobs\Entity\CreateRawPdf($this->invitation))->handle(); + } $headers = ['Content-Type' => 'application/pdf']; @@ -133,7 +134,7 @@ class PdfSlot extends Component $this->show_line_total = in_array('$product.line_total', $this->settings->pdf_variables->product_columns); $this->show_quantity = in_array('$product.quantity', $this->settings->pdf_variables->product_columns); - if($this->entity_type == 'quote' && !$this->settings->sync_invoice_quote_columns ){ + if($this->entity_type == 'quote' && !$this->settings->sync_invoice_quote_columns) { $this->show_cost = in_array('$product.unit_cost', $this->settings->pdf_variables->product_quote_columns); $this->show_quantity = in_array('$product.quantity', $this->settings->pdf_variables->product_quote_columns); $this->show_line_total = in_array('$product.line_total', $this->settings->pdf_variables->product_quote_columns); @@ -200,21 +201,22 @@ class PdfSlot extends Component $entity_details = ""; if($this->entity_type == 'invoice' || $this->entity_type == 'recurring_invoice') { - foreach($this->settings->pdf_variables->invoice_details as $variable) + foreach($this->settings->pdf_variables->invoice_details as $variable) { $entity_details .= "

{$variable}_label

{$variable}

"; + } - } - elseif($this->entity_type == 'quote'){ - foreach($this->settings->pdf_variables->quote_details ?? [] as $variable) + } elseif($this->entity_type == 'quote') { + foreach($this->settings->pdf_variables->quote_details ?? [] as $variable) { $entity_details .= "

{$variable}_label

{$variable}

"; - } - elseif($this->entity_type == 'credit') { - foreach($this->settings->pdf_variables->credit_details ?? [] as $variable) + } + } elseif($this->entity_type == 'credit') { + foreach($this->settings->pdf_variables->credit_details ?? [] as $variable) { $entity_details .= "

{$variable}_label

{$variable}

"; - } - elseif($this->entity_type == 'purchase_order'){ - foreach($this->settings->pdf_variables->purchase_order_details ?? [] as $variable) + } + } elseif($this->entity_type == 'purchase_order') { + foreach($this->settings->pdf_variables->purchase_order_details ?? [] as $variable) { $entity_details .= "

{$variable}_label

{$variable}

"; + } } return $this->convertVariables($entity_details); @@ -242,12 +244,11 @@ class PdfSlot extends Component $user_details = ""; if($this->entity_type == 'purchase_order') { - foreach(array_slice($this->settings->pdf_variables->vendor_details,1) as $variable) { + foreach(array_slice($this->settings->pdf_variables->vendor_details, 1) as $variable) { $user_details .= "

{$variable}

"; } - } - else{ - foreach(array_slice($this->settings->pdf_variables->client_details,1) as $variable) { + } else { + foreach(array_slice($this->settings->pdf_variables->client_details, 1) as $variable) { $user_details .= "

{$variable}

"; } } @@ -260,7 +261,7 @@ class PdfSlot extends Component $product_items = collect($this->entity->line_items)->filter(function ($item) { return $item->type_id == 1 || $item->type_id == 6 || $item->type_id == 5; - })->map(function ($item){ + })->map(function ($item) { $notes = strlen($item->notes) > 4 ? $item->notes : $item->product_key; @@ -279,7 +280,7 @@ class PdfSlot extends Component { $task_items = collect($this->entity->line_items)->filter(function ($item) { return $item->type_id == 2; - })->map(function ($item){ + })->map(function ($item) { return [ 'quantity' => $item->quantity, 'cost' => Number::formatMoney($item->cost, $this->entity->client ?: $this->entity->vendor), diff --git a/app/Http/Livewire/TasksTable.php b/app/Http/Livewire/TasksTable.php index f229db889f46..fa3f45df6ee2 100644 --- a/app/Http/Livewire/TasksTable.php +++ b/app/Http/Livewire/TasksTable.php @@ -39,11 +39,11 @@ class TasksTable extends Component ->where('is_deleted', false) ->where('client_id', auth()->guard('contact')->user()->client_id); - if ( auth()->guard('contact')->user()->client->getSetting('show_all_tasks_client_portal') === 'invoiced') { + if (auth()->guard('contact')->user()->client->getSetting('show_all_tasks_client_portal') === 'invoiced') { $query = $query->whereNotNull('invoice_id'); } - if ( auth()->guard('contact')->user()->client->getSetting('show_all_tasks_client_portal') === 'uninvoiced') { + if (auth()->guard('contact')->user()->client->getSetting('show_all_tasks_client_portal') === 'uninvoiced') { $query = $query->whereNull('invoice_id'); } diff --git a/app/Http/Middleware/PasswordProtection.php b/app/Http/Middleware/PasswordProtection.php index 4450ec321079..d34c817f2a74 100644 --- a/app/Http/Middleware/PasswordProtection.php +++ b/app/Http/Middleware/PasswordProtection.php @@ -38,7 +38,7 @@ class PasswordProtection ]; /** @var \App\Models\User auth()->user() */ - $user = auth()->user(); + $user = auth()->user(); $timeout = $user->company()->default_password_timeout; if ($timeout == 0) { @@ -59,11 +59,9 @@ class PasswordProtection Cache::put(auth()->user()->hashed_id.'_'.auth()->user()->account_id.'_logged_in', Str::random(64), $timeout); return $next($request); - } - elseif(strlen(auth()->user()->oauth_provider_id) > 2 && !auth()->user()->company()->oauth_password_required){ + } elseif(strlen(auth()->user()->oauth_provider_id) > 2 && !auth()->user()->company()->oauth_password_required) { return $next($request); - } - elseif ($request->header('X-API-OAUTH-PASSWORD') && strlen($request->header('X-API-OAUTH-PASSWORD')) >=1) { + } elseif ($request->header('X-API-OAUTH-PASSWORD') && strlen($request->header('X-API-OAUTH-PASSWORD')) >=1) { //user is attempting to reauth with OAuth - check the token value //todo expand this to include all OAuth providers if (auth()->user()->oauth_provider_id == 'google') { diff --git a/app/Http/Middleware/QueryLogging.php b/app/Http/Middleware/QueryLogging.php index e6aa71a7b863..39fac1a5a650 100644 --- a/app/Http/Middleware/QueryLogging.php +++ b/app/Http/Middleware/QueryLogging.php @@ -47,8 +47,9 @@ class QueryLogging public function terminate($request, $response) { - if (! Ninja::isHosted() || ! config('beacon.enabled')) + if (! Ninja::isHosted() || ! config('beacon.enabled')) { return; + } // hide requests made by debugbar if (strstr($request->url(), '_debugbar') === false) { diff --git a/app/Http/Middleware/TokenAuth.php b/app/Http/Middleware/TokenAuth.php index e73ccb00fcab..227d47a3804a 100644 --- a/app/Http/Middleware/TokenAuth.php +++ b/app/Http/Middleware/TokenAuth.php @@ -31,7 +31,7 @@ class TokenAuth public function handle($request, Closure $next) { if ($request->header('X-API-TOKEN') && ($company_token = CompanyToken::with([ - 'user' => [ + 'user' => [ 'account', ], 'company'])->where('token', $request->header('X-API-TOKEN'))->first())) { $user = $company_token->user; diff --git a/app/Http/Middleware/ValidateSignature.php b/app/Http/Middleware/ValidateSignature.php index 6308b308624b..deb5f45679ca 100644 --- a/app/Http/Middleware/ValidateSignature.php +++ b/app/Http/Middleware/ValidateSignature.php @@ -11,7 +11,6 @@ namespace App\Http\Middleware; - use Closure; use Illuminate\Routing\Exceptions\InvalidSignatureException; diff --git a/app/Http/Middleware/VendorContactKeyLogin.php b/app/Http/Middleware/VendorContactKeyLogin.php index e73a32554662..407665e59f8d 100644 --- a/app/Http/Middleware/VendorContactKeyLogin.php +++ b/app/Http/Middleware/VendorContactKeyLogin.php @@ -11,14 +11,14 @@ namespace App\Http\Middleware; +use App\Libraries\MultiDB; +use App\Models\Vendor; +use App\Models\VendorContact; use Auth; use Closure; -use App\Models\Vendor; -use App\Libraries\MultiDB; -use Illuminate\Support\Str; use Illuminate\Http\Request; -use App\Models\VendorContact; use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Str; class VendorContactKeyLogin { diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php index 115de351c796..cbbd75224b6a 100644 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ b/app/Http/Middleware/VerifyCsrfToken.php @@ -12,7 +12,6 @@ namespace App\Http\Middleware; use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware; -use Illuminate\Session\TokenMismatchException; class VerifyCsrfToken extends Middleware { diff --git a/app/Http/Requests/Activity/ShowActivityRequest.php b/app/Http/Requests/Activity/ShowActivityRequest.php index 219844f35dbe..a2a13eae6f47 100644 --- a/app/Http/Requests/Activity/ShowActivityRequest.php +++ b/app/Http/Requests/Activity/ShowActivityRequest.php @@ -40,8 +40,9 @@ class ShowActivityRequest extends Request { $input = $this->all(); - if(isset($input['entity_id'])) + if(isset($input['entity_id'])) { $input['entity_id'] = $this->decodePrimaryKey($input['entity_id']); + } $this->replace($input); diff --git a/app/Http/Requests/ClientPortal/Invoices/ProcessInvoicesInBulkRequest.php b/app/Http/Requests/ClientPortal/Invoices/ProcessInvoicesInBulkRequest.php index 73724da000c3..7f855ef8de94 100644 --- a/app/Http/Requests/ClientPortal/Invoices/ProcessInvoicesInBulkRequest.php +++ b/app/Http/Requests/ClientPortal/Invoices/ProcessInvoicesInBulkRequest.php @@ -33,7 +33,7 @@ class ProcessInvoicesInBulkRequest extends FormRequest { $input = $this->all(); - if(isset($input['invoices'])){ + if(isset($input['invoices'])) { $input['invoices'] = array_unique($input['invoices']); } diff --git a/app/Http/Requests/Company/UpdateCompanyRequest.php b/app/Http/Requests/Company/UpdateCompanyRequest.php index 9f64e4a284db..4ffa0e33093d 100644 --- a/app/Http/Requests/Company/UpdateCompanyRequest.php +++ b/app/Http/Requests/Company/UpdateCompanyRequest.php @@ -63,8 +63,9 @@ class UpdateCompanyRequest extends Request $rules['portal_domain'] = 'sometimes|url'; } - if (Ninja::isHosted()) + if (Ninja::isHosted()) { $rules['subdomain'] = ['nullable', 'regex:/^[a-zA-Z0-9.-]+[a-zA-Z0-9]$/', new ValidSubdomain()]; + } return $rules; } diff --git a/app/Http/Requests/Document/StoreDocumentRequest.php b/app/Http/Requests/Document/StoreDocumentRequest.php index f31504615dfe..7c3d4356f60f 100644 --- a/app/Http/Requests/Document/StoreDocumentRequest.php +++ b/app/Http/Requests/Document/StoreDocumentRequest.php @@ -40,8 +40,9 @@ class StoreDocumentRequest extends Request { $input = $this->all(); - if(isset($input['is_public'])) + if(isset($input['is_public'])) { $input['is_public'] = $this->toBoolean($input['is_public']); + } $this->replace($input); } diff --git a/app/Http/Requests/Document/UpdateDocumentRequest.php b/app/Http/Requests/Document/UpdateDocumentRequest.php index bfa876eca2bc..3dcf677a6ac8 100644 --- a/app/Http/Requests/Document/UpdateDocumentRequest.php +++ b/app/Http/Requests/Document/UpdateDocumentRequest.php @@ -44,8 +44,9 @@ class UpdateDocumentRequest extends Request { $input = $this->all(); - if(isset($input['is_public'])) + if(isset($input['is_public'])) { $input['is_public'] = $this->toBoolean($input['is_public']); + } $this->replace($input); } diff --git a/app/Http/Requests/Email/ClientEmailHistoryRequest.php b/app/Http/Requests/Email/ClientEmailHistoryRequest.php index 45d60b458b99..24d96a6e0b21 100644 --- a/app/Http/Requests/Email/ClientEmailHistoryRequest.php +++ b/app/Http/Requests/Email/ClientEmailHistoryRequest.php @@ -13,7 +13,6 @@ namespace App\Http\Requests\Email; use App\Http\Requests\Request; use App\Utils\Traits\MakesHash; -use Illuminate\Support\Str; class ClientEmailHistoryRequest extends Request { diff --git a/app/Http/Requests/Email/EntityEmailHistoryRequest.php b/app/Http/Requests/Email/EntityEmailHistoryRequest.php index 2c506e653dd6..61bdf9403353 100644 --- a/app/Http/Requests/Email/EntityEmailHistoryRequest.php +++ b/app/Http/Requests/Email/EntityEmailHistoryRequest.php @@ -11,9 +11,9 @@ namespace App\Http\Requests\Email; -use Illuminate\Support\Str; use App\Http\Requests\Request; use App\Utils\Traits\MakesHash; +use Illuminate\Support\Str; use Illuminate\Validation\Rule; class EntityEmailHistoryRequest extends Request diff --git a/app/Http/Requests/Email/SendEmailRequest.php b/app/Http/Requests/Email/SendEmailRequest.php index d917742dfac3..53a48cc52891 100644 --- a/app/Http/Requests/Email/SendEmailRequest.php +++ b/app/Http/Requests/Email/SendEmailRequest.php @@ -108,8 +108,7 @@ class SendEmailRequest extends Request if ($entity_obj && ($company->id == $entity_obj->company_id) && $user->can('edit', $entity_obj)) { return true; } - } - else { + } else { $this->error_message = "Invalid entity or entity_id"; } diff --git a/app/Http/Requests/GroupSetting/StoreGroupSettingRequest.php b/app/Http/Requests/GroupSetting/StoreGroupSettingRequest.php index d35e7ac2bc78..b39f11533add 100644 --- a/app/Http/Requests/GroupSetting/StoreGroupSettingRequest.php +++ b/app/Http/Requests/GroupSetting/StoreGroupSettingRequest.php @@ -11,13 +11,13 @@ namespace App\Http\Requests\GroupSetting; -use App\Models\Account; -use App\Models\GroupSetting; -use App\Http\Requests\Request; use App\DataMapper\ClientSettings; use App\DataMapper\CompanySettings; use App\DataMapper\Settings\SettingsData; +use App\Http\Requests\Request; use App\Http\ValidationRules\ValidClientGroupSettingsRule; +use App\Models\Account; +use App\Models\GroupSetting; class StoreGroupSettingRequest extends Request { @@ -52,8 +52,7 @@ class StoreGroupSettingRequest extends Request if (array_key_exists('settings', $input)) { $input['settings'] = $this->filterSaveableSettings($input['settings']); - } - else { + } else { $input['settings'] = (array)ClientSettings::defaults(); } diff --git a/app/Http/Requests/GroupSetting/UpdateGroupSettingRequest.php b/app/Http/Requests/GroupSetting/UpdateGroupSettingRequest.php index a264d74c018d..ebb6f550fb3d 100644 --- a/app/Http/Requests/GroupSetting/UpdateGroupSettingRequest.php +++ b/app/Http/Requests/GroupSetting/UpdateGroupSettingRequest.php @@ -11,9 +11,9 @@ namespace App\Http\Requests\GroupSetting; -use App\Http\Requests\Request; use App\DataMapper\CompanySettings; use App\DataMapper\Settings\SettingsData; +use App\Http\Requests\Request; use App\Http\ValidationRules\ValidClientGroupSettingsRule; class UpdateGroupSettingRequest extends Request diff --git a/app/Http/Requests/Invoice/UpdateInvoiceRequest.php b/app/Http/Requests/Invoice/UpdateInvoiceRequest.php index a21c98a988ea..25c7c2fb2fb4 100644 --- a/app/Http/Requests/Invoice/UpdateInvoiceRequest.php +++ b/app/Http/Requests/Invoice/UpdateInvoiceRequest.php @@ -31,7 +31,7 @@ class UpdateInvoiceRequest extends Request * @return bool */ public function authorize() : bool - { + { /** @var \App\Models\User $user */ $user = auth()->user(); diff --git a/app/Http/Requests/Invoice/UploadInvoiceRequest.php b/app/Http/Requests/Invoice/UploadInvoiceRequest.php index 45d97b079900..1da7f3e829ca 100644 --- a/app/Http/Requests/Invoice/UploadInvoiceRequest.php +++ b/app/Http/Requests/Invoice/UploadInvoiceRequest.php @@ -12,7 +12,6 @@ namespace App\Http\Requests\Invoice; use App\Http\Requests\Request; -use Illuminate\Http\UploadedFile; class UploadInvoiceRequest extends Request { diff --git a/app/Http/Requests/Payment/RefundPaymentRequest.php b/app/Http/Requests/Payment/RefundPaymentRequest.php index 5f0a8381d5fa..5a6f71d4cb99 100644 --- a/app/Http/Requests/Payment/RefundPaymentRequest.php +++ b/app/Http/Requests/Payment/RefundPaymentRequest.php @@ -58,7 +58,7 @@ class RefundPaymentRequest extends Request if (isset($input['credits'])) { unset($input['credits']); // foreach($input['credits'] as $key => $credit) - // $input['credits'][$key]['credit_id'] = $this->decodePrimaryKey($credit['credit_id']); + // $input['credits'][$key]['credit_id'] = $this->decodePrimaryKey($credit['credit_id']); } $this->replace($input); diff --git a/app/Http/Requests/Payment/UpdatePaymentRequest.php b/app/Http/Requests/Payment/UpdatePaymentRequest.php index 02b465638efe..113bf9493236 100644 --- a/app/Http/Requests/Payment/UpdatePaymentRequest.php +++ b/app/Http/Requests/Payment/UpdatePaymentRequest.php @@ -82,8 +82,8 @@ class UpdatePaymentRequest extends Request if (isset($input['invoices']) && is_array($input['invoices']) !== false) { foreach ($input['invoices'] as $key => $value) { - if(isset($input['invoices'][$key]['invoice_id'])){ - // if (array_key_exists('invoice_id', $input['invoices'][$key])) { + if(isset($input['invoices'][$key]['invoice_id'])) { + // if (array_key_exists('invoice_id', $input['invoices'][$key])) { $input['invoices'][$key]['invoice_id'] = $this->decodePrimaryKey($value['invoice_id']); } } diff --git a/app/Http/Requests/Preview/PreviewInvoiceRequest.php b/app/Http/Requests/Preview/PreviewInvoiceRequest.php index 57bd0cf22ef0..d69d231c05b5 100644 --- a/app/Http/Requests/Preview/PreviewInvoiceRequest.php +++ b/app/Http/Requests/Preview/PreviewInvoiceRequest.php @@ -11,19 +11,19 @@ namespace App\Http\Requests\Preview; -use App\Models\Quote; +use App\Http\Requests\Request; use App\Models\Client; use App\Models\Credit; +use App\Models\CreditInvitation; use App\Models\Invoice; -use App\Http\Requests\Request; +use App\Models\InvoiceInvitation; +use App\Models\Quote; use App\Models\QuoteInvitation; +use App\Models\RecurringInvoice; +use App\Models\RecurringInvoiceInvitation; +use App\Utils\Traits\CleanLineItems; use App\Utils\Traits\MakesHash; use Illuminate\Validation\Rule; -use App\Models\CreditInvitation; -use App\Models\RecurringInvoice; -use App\Models\InvoiceInvitation; -use App\Utils\Traits\CleanLineItems; -use App\Models\RecurringInvoiceInvitation; class PreviewInvoiceRequest extends Request { @@ -55,7 +55,7 @@ class PreviewInvoiceRequest extends Request return [ 'number' => 'nullable', 'entity' => 'bail|sometimes|in:invoice,quote,credit,recurring_invoice', - 'entity_id' => ['bail','sometimes','integer',Rule::exists($this->entity_plural, 'id')->where('is_deleted',0)->where('company_id', $user->company()->id)], + 'entity_id' => ['bail','sometimes','integer',Rule::exists($this->entity_plural, 'id')->where('is_deleted', 0)->where('company_id', $user->company()->id)], 'client_id' => ['required', Rule::exists(Client::class, 'id')->where('is_deleted', 0)->where('company_id', $user->company()->id)], ]; @@ -76,8 +76,9 @@ class PreviewInvoiceRequest extends Request $input['balance'] = 0; $input['number'] = isset($input['number']) ? $input['number'] : ctrans('texts.live_preview').' #'.rand(0, 1000); - if($input['entity_id'] ?? false) + if($input['entity_id'] ?? false) { $input['entity_id'] = $this->decodePrimaryKey($input['entity_id'], true); + } $this->convertEntityPlural($input['entity'] ?? 'invoice'); @@ -88,26 +89,29 @@ class PreviewInvoiceRequest extends Request { $invitation = false; - if(! $this->entity_id ?? false) + if(! $this->entity_id ?? false) { return $this->stubInvitation(); + } - match($this->entity){ - 'invoice' => $invitation = InvoiceInvitation::withTrashed()->where('invoice_id', $this->entity_id)->first(), - 'quote' => $invitation = QuoteInvitation::withTrashed()->where('quote_id', $this->entity_id)->first(), - 'credit' => $invitation = CreditInvitation::withTrashed()->where('credit_id', $this->entity_id)->first(), - 'recurring_invoice' => $invitation = RecurringInvoiceInvitation::withTrashed()->where('recurring_invoice_id', $this->entity_id)->first(), + match($this->entity) { + 'invoice' => $invitation = InvoiceInvitation::withTrashed()->where('invoice_id', $this->entity_id)->first(), + 'quote' => $invitation = QuoteInvitation::withTrashed()->where('quote_id', $this->entity_id)->first(), + 'credit' => $invitation = CreditInvitation::withTrashed()->where('credit_id', $this->entity_id)->first(), + 'recurring_invoice' => $invitation = RecurringInvoiceInvitation::withTrashed()->where('recurring_invoice_id', $this->entity_id)->first(), }; - if($invitation) + if($invitation) { return $invitation; + } $invitation = $this->stubInvitation(); } public function getClient(): ?Client { - if(!$this->client) + if(!$this->client) { $this->client = Client::query()->with('contacts', 'company', 'user')->withTrashed()->find($this->client_id); + } return $this->client; } @@ -147,7 +151,7 @@ class PreviewInvoiceRequest extends Request { $entity = false; - match($this->entity){ + match($this->entity) { 'invoice' => $entity = Invoice::factory()->make(['client_id' => $client->id,'user_id' => $client->user_id, 'company_id' => $client->company_id]), 'quote' => $entity = Quote::factory()->make(['client_id' => $client->id,'user_id' => $client->user_id, 'company_id' => $client->company_id]), 'credit' => $entity = Credit::factory()->make(['client_id' => $client->id,'user_id' => $client->user_id, 'company_id' => $client->company_id]), diff --git a/app/Http/Requests/PurchaseOrder/UploadPurchaseOrderRequest.php b/app/Http/Requests/PurchaseOrder/UploadPurchaseOrderRequest.php index 746e17abf11e..8d290a696a89 100644 --- a/app/Http/Requests/PurchaseOrder/UploadPurchaseOrderRequest.php +++ b/app/Http/Requests/PurchaseOrder/UploadPurchaseOrderRequest.php @@ -44,7 +44,7 @@ class UploadPurchaseOrderRequest extends Request $rules['file'] = $this->file_validation; } - $rules['is_public'] = 'sometimes|boolean'; + $rules['is_public'] = 'sometimes|boolean'; return $rules; } diff --git a/app/Http/Requests/Quote/BulkActionQuoteRequest.php b/app/Http/Requests/Quote/BulkActionQuoteRequest.php index c9f41313a568..cb77becc069a 100644 --- a/app/Http/Requests/Quote/BulkActionQuoteRequest.php +++ b/app/Http/Requests/Quote/BulkActionQuoteRequest.php @@ -34,7 +34,7 @@ class BulkActionQuoteRequest extends Request 'action' => 'sometimes|in:convert_to_invoice,convert_to_project,email,bulk_download,bulk_print,clone_to_invoice,approve,download,restore,archive,delete,send_email,mark_sent', ]; - if (in_array($input['action'], ['convert,convert_to_invoice']) ) { + if (in_array($input['action'], ['convert,convert_to_invoice'])) { $rules['action'] = [new ConvertableQuoteRule()]; } diff --git a/app/Http/Requests/Task/StoreTaskRequest.php b/app/Http/Requests/Task/StoreTaskRequest.php index 8f97f3ab5e90..5ae5e13dd481 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, 1); + } if(!is_array($values)) { return $fail('The '.$attribute.' is invalid. Must be an array.'); diff --git a/app/Http/Requests/Task/UpdateTaskRequest.php b/app/Http/Requests/Task/UpdateTaskRequest.php index d0ab48a2980d..7779dc0340df 100644 --- a/app/Http/Requests/Task/UpdateTaskRequest.php +++ b/app/Http/Requests/Task/UpdateTaskRequest.php @@ -120,10 +120,10 @@ class UpdateTaskRequest extends Request $input['color'] = ''; } - if(isset($input['project_id']) && isset($input['client_id'])){ + if(isset($input['project_id']) && isset($input['client_id'])) { $search_project_with_client = Project::withTrashed()->where('id', $input['project_id'])->where('client_id', $input['client_id'])->company()->doesntExist(); - if($search_project_with_client){ + if($search_project_with_client) { unset($input['project_id']); } diff --git a/app/Http/Requests/Task/UploadTaskRequest.php b/app/Http/Requests/Task/UploadTaskRequest.php index 6b7d96ef048b..088ec573c344 100644 --- a/app/Http/Requests/Task/UploadTaskRequest.php +++ b/app/Http/Requests/Task/UploadTaskRequest.php @@ -53,8 +53,9 @@ class UploadTaskRequest extends Request { $input = $this->all(); - if(isset($input['is_public'])) + if(isset($input['is_public'])) { $input['is_public'] = $this->toBoolean($input['is_public']); + } $this->replace($input); } diff --git a/app/Http/Requests/TaskScheduler/StoreSchedulerRequest.php b/app/Http/Requests/TaskScheduler/StoreSchedulerRequest.php index c0fc0c9d6061..312e073099fe 100644 --- a/app/Http/Requests/TaskScheduler/StoreSchedulerRequest.php +++ b/app/Http/Requests/TaskScheduler/StoreSchedulerRequest.php @@ -14,7 +14,6 @@ namespace App\Http\Requests\TaskScheduler; use App\Http\Requests\Request; use App\Http\ValidationRules\Scheduler\ValidClientIds; use App\Utils\Traits\MakesHash; -use Illuminate\Validation\Rule; class StoreSchedulerRequest extends Request { @@ -60,7 +59,7 @@ class StoreSchedulerRequest extends Request $input['next_run_client'] = $input['next_run']; } - if($input['template'] == 'email_record'){ + if($input['template'] == 'email_record') { $input['frequency_id'] = 0; } diff --git a/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php b/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php index 24dea23f0ac9..6a7750320f41 100644 --- a/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php +++ b/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php @@ -12,7 +12,6 @@ namespace App\Http\Requests\TaskScheduler; use App\Http\Requests\Request; use App\Http\ValidationRules\Scheduler\ValidClientIds; -use Illuminate\Validation\Rule; class UpdateSchedulerRequest extends Request { diff --git a/app/Http/Requests/TaskStatus/UpdateTaskStatusRequest.php b/app/Http/Requests/TaskStatus/UpdateTaskStatusRequest.php index e7a0b757c9ef..c1f2bb31aefe 100644 --- a/app/Http/Requests/TaskStatus/UpdateTaskStatusRequest.php +++ b/app/Http/Requests/TaskStatus/UpdateTaskStatusRequest.php @@ -13,7 +13,6 @@ namespace App\Http\Requests\TaskStatus; use App\Http\Requests\Request; use App\Utils\Traits\MakesHash; -use Illuminate\Validation\Rule; class UpdateTaskStatusRequest extends Request { diff --git a/app/Http/Requests/User/BulkUserRequest.php b/app/Http/Requests/User/BulkUserRequest.php index c07032f4f2e6..f0893654e5f4 100644 --- a/app/Http/Requests/User/BulkUserRequest.php +++ b/app/Http/Requests/User/BulkUserRequest.php @@ -11,10 +11,10 @@ namespace App\Http\Requests\User; -use App\Utils\Ninja; use App\Http\Requests\Request; -use Illuminate\Auth\Access\AuthorizationException; use App\Http\ValidationRules\Ninja\CanRestoreUserRule; +use App\Utils\Ninja; +use Illuminate\Auth\Access\AuthorizationException; class BulkUserRequest extends Request { @@ -25,8 +25,9 @@ class BulkUserRequest extends Request */ public function authorize() : bool { - if($this->action == 'delete' && in_array(auth()->user()->hashed_id, $this->ids)) + if($this->action == 'delete' && in_array(auth()->user()->hashed_id, $this->ids)) { return false; + } return auth()->user()->isAdmin(); } diff --git a/app/Http/Requests/User/DisconnectUserMailerRequest.php b/app/Http/Requests/User/DisconnectUserMailerRequest.php index 881276e4dca3..ffe07871e84a 100644 --- a/app/Http/Requests/User/DisconnectUserMailerRequest.php +++ b/app/Http/Requests/User/DisconnectUserMailerRequest.php @@ -23,7 +23,7 @@ class DisconnectUserMailerRequest extends Request * @return bool */ public function authorize() : bool - { + { return auth()->user()->id == $this->user->id || auth()->user()->isAdmin(); } diff --git a/app/Http/Requests/Vendor/UploadVendorRequest.php b/app/Http/Requests/Vendor/UploadVendorRequest.php index a9263fb979be..f1219bd6d640 100644 --- a/app/Http/Requests/Vendor/UploadVendorRequest.php +++ b/app/Http/Requests/Vendor/UploadVendorRequest.php @@ -50,8 +50,9 @@ class UploadVendorRequest extends Request { $input = $this->all(); - if(isset($input['is_public'])) + if(isset($input['is_public'])) { $input['is_public'] = $this->toBoolean($input['is_public']); + } $this->replace($input); } diff --git a/app/Http/Requests/Webhook/UpdateWebhookRequest.php b/app/Http/Requests/Webhook/UpdateWebhookRequest.php index d8fd2ed783cd..a02890d55d44 100644 --- a/app/Http/Requests/Webhook/UpdateWebhookRequest.php +++ b/app/Http/Requests/Webhook/UpdateWebhookRequest.php @@ -49,7 +49,7 @@ class UpdateWebhookRequest extends Request } // if(isset($input['headers']) && count($input['headers']) == 0) - // $input['headers'] = null; + // $input['headers'] = null; $this->replace($input); } diff --git a/app/Http/ValidationRules/Credit/ValidCreditsRules.php b/app/Http/ValidationRules/Credit/ValidCreditsRules.php index d02097df2159..8c43fed21685 100644 --- a/app/Http/ValidationRules/Credit/ValidCreditsRules.php +++ b/app/Http/ValidationRules/Credit/ValidCreditsRules.php @@ -76,7 +76,7 @@ class ValidCreditsRules implements Rule return false; } - if($cred->status_id == Credit::STATUS_DRAFT){ + if($cred->status_id == Credit::STATUS_DRAFT) { $cred->service()->markSent()->save(); $cred = $cred->fresh(); } diff --git a/app/Http/ValidationRules/Payment/ValidRefundableRequest.php b/app/Http/ValidationRules/Payment/ValidRefundableRequest.php index 6de59ca0b9ca..49530bca72a1 100644 --- a/app/Http/ValidationRules/Payment/ValidRefundableRequest.php +++ b/app/Http/ValidationRules/Payment/ValidRefundableRequest.php @@ -11,7 +11,6 @@ namespace App\Http\ValidationRules\Payment; -use App\Models\Credit; use App\Models\Invoice; use App\Models\Payment; use App\Utils\Traits\MakesHash; diff --git a/app/Http/ValidationRules/PaymentAppliedValidAmount.php b/app/Http/ValidationRules/PaymentAppliedValidAmount.php index 2958f04229cf..f64f72d2b1fa 100644 --- a/app/Http/ValidationRules/PaymentAppliedValidAmount.php +++ b/app/Http/ValidationRules/PaymentAppliedValidAmount.php @@ -91,7 +91,7 @@ class PaymentAppliedValidAmount implements Rule } } - if(count($this->input['invoices']) >=1 && $payment->status_id == Payment::STATUS_PENDING){ + if(count($this->input['invoices']) >=1 && $payment->status_id == Payment::STATUS_PENDING) { $this->message = 'Cannot apply a payment until the status is completed.'; return false; } diff --git a/app/Http/ValidationRules/Project/ValidProjectForClient.php b/app/Http/ValidationRules/Project/ValidProjectForClient.php index 46f3b1a8c881..188d94c93931 100644 --- a/app/Http/ValidationRules/Project/ValidProjectForClient.php +++ b/app/Http/ValidationRules/Project/ValidProjectForClient.php @@ -53,7 +53,7 @@ class ValidProjectForClient implements Rule return; } - if(!isset($this->input['client_id'])){ + if(!isset($this->input['client_id'])) { $this->message = 'No Client ID provided.'; return false; } diff --git a/app/Http/ValidationRules/ValidAmount.php b/app/Http/ValidationRules/ValidAmount.php index 4438b935ad9b..2f219f17b86f 100644 --- a/app/Http/ValidationRules/ValidAmount.php +++ b/app/Http/ValidationRules/ValidAmount.php @@ -27,7 +27,7 @@ class ValidAmount implements Rule { return is_numeric((string) $value); //return filter_var((string)$value, FILTER_VALIDATE_FLOAT); -// return preg_match('^(?=.)([+-]?([0-9]*)(\.([0-9]+))?)$^', (string)$value); + // return preg_match('^(?=.)([+-]?([0-9]*)(\.([0-9]+))?)$^', (string)$value); // return trim($value, '-1234567890.,') === ''; } diff --git a/app/Import/Providers/BaseImport.php b/app/Import/Providers/BaseImport.php index e401e85aa058..f5396e7efd6b 100644 --- a/app/Import/Providers/BaseImport.php +++ b/app/Import/Providers/BaseImport.php @@ -11,31 +11,31 @@ namespace App\Import\Providers; -use App\Models\User; -use App\Models\Quote; -use League\Csv\Reader; -use App\Models\Company; -use App\Models\Invoice; -use League\Csv\Statement; -use App\Factory\QuoteFactory; use App\Factory\ClientFactory; -use Illuminate\Support\Carbon; use App\Factory\InvoiceFactory; use App\Factory\PaymentFactory; +use App\Factory\QuoteFactory; +use App\Factory\RecurringInvoiceFactory; +use App\Http\Requests\Quote\StoreQuoteRequest; use App\Import\ImportException; use App\Jobs\Mail\NinjaMailerJob; use App\Jobs\Mail\NinjaMailerObject; -use App\Utils\Traits\CleanLineItems; -use App\Repositories\QuoteRepository; -use Illuminate\Support\Facades\Cache; -use App\Repositories\ClientRepository; use App\Mail\Import\CsvImportCompleted; +use App\Models\Company; +use App\Models\Invoice; +use App\Models\Quote; +use App\Models\User; +use App\Repositories\ClientRepository; use App\Repositories\InvoiceRepository; use App\Repositories\PaymentRepository; -use App\Factory\RecurringInvoiceFactory; -use Illuminate\Support\Facades\Validator; -use App\Http\Requests\Quote\StoreQuoteRequest; +use App\Repositories\QuoteRepository; use App\Repositories\RecurringInvoiceRepository; +use App\Utils\Traits\CleanLineItems; +use Illuminate\Support\Carbon; +use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\Validator; +use League\Csv\Reader; +use League\Csv\Statement; class BaseImport { @@ -482,8 +482,9 @@ class BaseImport nlog($invoice_data); $saveable_invoice_data = $invoice_data; - if(array_key_exists('payments', $saveable_invoice_data)) + if(array_key_exists('payments', $saveable_invoice_data)) { unset($saveable_invoice_data['payments']); + } $invoice_repository->save($saveable_invoice_data, $invoice); @@ -524,8 +525,7 @@ class BaseImport $payment_date = Carbon::parse($payment->date); - if(!$payment_date->isToday()) - { + if(!$payment_date->isToday()) { $payment->paymentables()->update(['created_at' => $payment_date]); @@ -743,8 +743,9 @@ class BaseImport } - if($user) + if($user) { return $user->id; + } $user = User::whereRaw("account_id = ? AND CONCAT_WS(' ', first_name, last_name) like ?", [$this->company->account_id, '%'.$user_hash.'%']) ->first(); diff --git a/app/Import/Providers/Csv.php b/app/Import/Providers/Csv.php index 8615328203a3..9e29d5af9f41 100644 --- a/app/Import/Providers/Csv.php +++ b/app/Import/Providers/Csv.php @@ -11,44 +11,44 @@ namespace App\Import\Providers; -use App\Factory\QuoteFactory; +use App\Factory\BankTransactionFactory; use App\Factory\ClientFactory; -use App\Factory\VendorFactory; use App\Factory\ExpenseFactory; use App\Factory\InvoiceFactory; use App\Factory\PaymentFactory; use App\Factory\ProductFactory; -use App\Utils\Traits\MakesHash; -use App\Repositories\QuoteRepository; -use App\Repositories\ClientRepository; -use App\Repositories\VendorRepository; -use App\Factory\BankTransactionFactory; -use App\Repositories\ExpenseRepository; -use App\Repositories\InvoiceRepository; -use App\Repositories\PaymentRepository; -use App\Repositories\ProductRepository; +use App\Factory\QuoteFactory; use App\Factory\RecurringInvoiceFactory; -use App\Services\Bank\BankMatchingService; -use App\Http\Requests\Quote\StoreQuoteRequest; -use App\Repositories\BankTransactionRepository; +use App\Factory\VendorFactory; +use App\Http\Requests\BankTransaction\StoreBankTransactionRequest; use App\Http\Requests\Client\StoreClientRequest; -use App\Http\Requests\Vendor\StoreVendorRequest; -use App\Import\Transformer\Bank\BankTransformer; -use App\Import\Transformer\Csv\QuoteTransformer; -use App\Repositories\RecurringInvoiceRepository; -use App\Import\Transformer\Csv\ClientTransformer; -use App\Import\Transformer\Csv\VendorTransformer; use App\Http\Requests\Expense\StoreExpenseRequest; use App\Http\Requests\Invoice\StoreInvoiceRequest; use App\Http\Requests\Payment\StorePaymentRequest; use App\Http\Requests\Product\StoreProductRequest; +use App\Http\Requests\Quote\StoreQuoteRequest; +use App\Http\Requests\RecurringInvoice\StoreRecurringInvoiceRequest; +use App\Http\Requests\Vendor\StoreVendorRequest; +use App\Import\Transformer\Bank\BankTransformer; +use App\Import\Transformer\Csv\ClientTransformer; use App\Import\Transformer\Csv\ExpenseTransformer; use App\Import\Transformer\Csv\InvoiceTransformer; use App\Import\Transformer\Csv\PaymentTransformer; use App\Import\Transformer\Csv\ProductTransformer; +use App\Import\Transformer\Csv\QuoteTransformer; use App\Import\Transformer\Csv\RecurringInvoiceTransformer; -use App\Http\Requests\BankTransaction\StoreBankTransactionRequest; -use App\Http\Requests\RecurringInvoice\StoreRecurringInvoiceRequest; +use App\Import\Transformer\Csv\VendorTransformer; +use App\Repositories\BankTransactionRepository; +use App\Repositories\ClientRepository; +use App\Repositories\ExpenseRepository; +use App\Repositories\InvoiceRepository; +use App\Repositories\PaymentRepository; +use App\Repositories\ProductRepository; +use App\Repositories\QuoteRepository; +use App\Repositories\RecurringInvoiceRepository; +use App\Repositories\VendorRepository; +use App\Services\Bank\BankMatchingService; +use App\Utils\Traits\MakesHash; class Csv extends BaseImport implements ImportInterface { diff --git a/app/Import/Transformer/BaseTransformer.php b/app/Import/Transformer/BaseTransformer.php index f651e164aafe..31c05ceb16a5 100644 --- a/app/Import/Transformer/BaseTransformer.php +++ b/app/Import/Transformer/BaseTransformer.php @@ -11,27 +11,27 @@ namespace App\Import\Transformer; -use App\Models\Quote; -use App\Utils\Number; +use App\Factory\ClientFactory; +use App\Factory\ExpenseCategoryFactory; +use App\Factory\ProjectFactory; +use App\Factory\VendorFactory; use App\Models\Client; -use App\Models\Vendor; +use App\Models\ClientContact; use App\Models\Country; use App\Models\Expense; +use App\Models\ExpenseCategory; use App\Models\Invoice; +use App\Models\PaymentType; use App\Models\Product; use App\Models\Project; -use App\Models\TaxRate; -use App\Models\PaymentType; -use App\Models\ClientContact; -use App\Factory\ClientFactory; -use App\Factory\VendorFactory; -use Illuminate\Support\Carbon; -use App\Factory\ProjectFactory; -use App\Models\ExpenseCategory; +use App\Models\Quote; use App\Models\RecurringInvoice; -use Illuminate\Support\Facades\Cache; +use App\Models\TaxRate; +use App\Models\Vendor; use App\Repositories\ClientRepository; -use App\Factory\ExpenseCategoryFactory; +use App\Utils\Number; +use Illuminate\Support\Carbon; +use Illuminate\Support\Facades\Cache; /** * Class BaseTransformer. @@ -47,8 +47,9 @@ class BaseTransformer public function parseDate($date) { - if(stripos($date,"/") !== false && $this->company->settings->country_id != 840) + if(stripos($date, "/") !== false && $this->company->settings->country_id != 840) { $date = str_replace('/', '-', $date); + } try { $parsed_date = Carbon::parse($date); @@ -331,10 +332,11 @@ class BaseTransformer */ public function getFloatOrOne($data, $field) { - if (array_key_exists($field, $data)) + if (array_key_exists($field, $data)) { return Number::parseStringFloat($data[$field]) > 0 ? Number::parseStringFloat($data[$field]) : 1; + } - return 1; + return 1; } @@ -637,8 +639,9 @@ class BaseTransformer ]) ->first(); - if($ec) + if($ec) { return $ec->id; + } $ec = \App\Factory\ExpenseCategoryFactory::create($this->company->id, $this->company->owner()->id); $ec->name = $name; diff --git a/app/Import/Transformer/Csv/InvoiceTransformer.php b/app/Import/Transformer/Csv/InvoiceTransformer.php index 1399990a2a9e..38980311eae1 100644 --- a/app/Import/Transformer/Csv/InvoiceTransformer.php +++ b/app/Import/Transformer/Csv/InvoiceTransformer.php @@ -167,7 +167,7 @@ class InvoiceTransformer extends BaseTransformer ), ], ]; - } + } // elseif ( // isset($transformed['amount']) && // isset($transformed['balance']) && diff --git a/app/Import/Transformer/Csv/RecurringInvoiceTransformer.php b/app/Import/Transformer/Csv/RecurringInvoiceTransformer.php index d4c2a17bdffd..2f924da831d6 100644 --- a/app/Import/Transformer/Csv/RecurringInvoiceTransformer.php +++ b/app/Import/Transformer/Csv/RecurringInvoiceTransformer.php @@ -11,10 +11,10 @@ namespace App\Import\Transformer\Csv; -use App\Models\Invoice; use App\Import\ImportException; -use App\Models\RecurringInvoice; use App\Import\Transformer\BaseTransformer; +use App\Models\Invoice; +use App\Models\RecurringInvoice; /** * Class RecurringInvoiceTransformer. @@ -134,10 +134,12 @@ class RecurringInvoiceTransformer extends BaseTransformer // ] ?? Invoice::STATUS_SENT, 'auto_bill' => $this->getAutoBillFlag( $this->getString($invoice_data, 'invoice.auto_bill') - ), - 'frequency_id' => $this->getFrequency(isset($invoice_data['invoice.frequency_id']) ? $invoice_data['invoice.frequency_id'] : 'monthly' ), - 'remaining_cycles' => $this->getRemainingCycles(isset($invoice_data['invoice.remaining_cycles']) ? $invoice_data['invoice.remaining_cycles'] : -1 + 'frequency_id' => $this->getFrequency( + isset($invoice_data['invoice.frequency_id']) ? $invoice_data['invoice.frequency_id'] : 'monthly' + ), + 'remaining_cycles' => $this->getRemainingCycles( + isset($invoice_data['invoice.remaining_cycles']) ? $invoice_data['invoice.remaining_cycles'] : -1 ), // 'archived' => $status === 'archived', ]; diff --git a/app/Import/Transformer/Invoice2Go/InvoiceTransformer.php b/app/Import/Transformer/Invoice2Go/InvoiceTransformer.php index ce790aa25497..e6ad42416a80 100644 --- a/app/Import/Transformer/Invoice2Go/InvoiceTransformer.php +++ b/app/Import/Transformer/Invoice2Go/InvoiceTransformer.php @@ -63,8 +63,7 @@ class InvoiceTransformer extends BaseTransformer $client_id = null; - if($this->hasClient($this->getString($invoice_data, 'Name') || $this->getContact($this->getString($invoice_data, 'EmailRecipient')))) - { + if($this->hasClient($this->getString($invoice_data, 'Name') || $this->getContact($this->getString($invoice_data, 'EmailRecipient')))) { $client_id = $this->getClient($this->getString($invoice_data, 'Name'), $this->getString($invoice_data, 'EmailRecipient')); diff --git a/app/Import/Transformer/Zoho/ClientTransformer.php b/app/Import/Transformer/Zoho/ClientTransformer.php index 084964149873..b63891b5b37e 100644 --- a/app/Import/Transformer/Zoho/ClientTransformer.php +++ b/app/Import/Transformer/Zoho/ClientTransformer.php @@ -31,8 +31,7 @@ class ClientTransformer extends BaseTransformer if(isset($data[$client_id_proxy]) && $this->hasClientIdNumber($data[$client_id_proxy])) { throw new ImportException('Client ID already exists => '. $data[$client_id_proxy]); - } - elseif (isset($data['Company Name']) && $this->hasClient($data['Company Name'])) { + } elseif (isset($data['Company Name']) && $this->hasClient($data['Company Name'])) { throw new ImportException('Client already exists => '. $data['Company Name']); } diff --git a/app/Import/Transformer/Zoho/InvoiceTransformer.php b/app/Import/Transformer/Zoho/InvoiceTransformer.php index faae4fffa2ae..704c82008e56 100644 --- a/app/Import/Transformer/Zoho/InvoiceTransformer.php +++ b/app/Import/Transformer/Zoho/InvoiceTransformer.php @@ -141,7 +141,6 @@ class InvoiceTransformer extends BaseTransformer 'postal_code' => $this->getString($invoice_data, 'Billing Code'), 'country_id' => $this->getCountryId($this->getString($invoice_data, 'Billing Country')), ], - \App\Factory\ClientFactory::create( $this->company->id, $this->company->owner()->id diff --git a/app/Jobs/Bank/MatchBankTransactions.php b/app/Jobs/Bank/MatchBankTransactions.php index 518926734c99..b0453fb4c7c8 100644 --- a/app/Jobs/Bank/MatchBankTransactions.php +++ b/app/Jobs/Bank/MatchBankTransactions.php @@ -182,7 +182,7 @@ class MatchBankTransactions implements ShouldQueue return $this; } - private function coalesceExpenses($expense): string + private function coalesceExpenses($expense): string { if (!$this->bt->expense_id || strlen($this->bt->expense_id) < 1) { diff --git a/app/Jobs/Bank/ProcessBankTransactions.php b/app/Jobs/Bank/ProcessBankTransactions.php index d6b6d8582ab7..2d621799dea9 100644 --- a/app/Jobs/Bank/ProcessBankTransactions.php +++ b/app/Jobs/Bank/ProcessBankTransactions.php @@ -11,20 +11,20 @@ namespace App\Jobs\Bank; -use App\Models\Company; +use App\Helpers\Bank\Yodlee\Transformer\AccountTransformer; +use App\Helpers\Bank\Yodlee\Yodlee; use App\Libraries\MultiDB; -use Illuminate\Bus\Queueable; use App\Models\BankIntegration; use App\Models\BankTransaction; -use App\Helpers\Bank\Yodlee\Yodlee; -use Illuminate\Queue\SerializesModels; -use Illuminate\Queue\InteractsWithQueue; +use App\Models\Company; +use App\Notifications\Ninja\GenericNinjaAdminNotification; use App\Services\Bank\BankMatchingService; +use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Events\Dispatchable; +use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\Middleware\WithoutOverlapping; -use App\Notifications\Ninja\GenericNinjaAdminNotification; -use App\Helpers\Bank\Yodlee\Transformer\AccountTransformer; +use Illuminate\Queue\SerializesModels; class ProcessBankTransactions implements ShouldQueue { @@ -116,8 +116,7 @@ class ProcessBankTransactions implements ShouldQueue } } - } - catch(\Exception $e) { + } catch(\Exception $e) { nlog("YODLEE: unable to update account summary for {$this->bank_integration->bank_account_id} => ". $e->getMessage()); } diff --git a/app/Jobs/Client/CheckVat.php b/app/Jobs/Client/CheckVat.php index 49d5f17d2a37..a51a6ce1c0f0 100644 --- a/app/Jobs/Client/CheckVat.php +++ b/app/Jobs/Client/CheckVat.php @@ -11,18 +11,17 @@ namespace App\Jobs\Client; +use App\Libraries\MultiDB; use App\Models\Client; use App\Models\Company; -use App\Libraries\MultiDB; -use Illuminate\Bus\Queueable; -use App\DataProviders\USStates; -use App\Utils\Traits\MakesHash; use App\Services\Tax\TaxService; -use Illuminate\Queue\SerializesModels; -use Illuminate\Queue\InteractsWithQueue; +use App\Utils\Traits\MakesHash; +use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\Middleware\WithoutOverlapping; +use Illuminate\Queue\SerializesModels; class CheckVat implements ShouldQueue { diff --git a/app/Jobs/Client/UpdateTaxData.php b/app/Jobs/Client/UpdateTaxData.php index 89a25bdd865c..c27733c06683 100644 --- a/app/Jobs/Client/UpdateTaxData.php +++ b/app/Jobs/Client/UpdateTaxData.php @@ -11,18 +11,17 @@ namespace App\Jobs\Client; -use App\DataMapper\Tax\ZipTax\Response; +use App\DataProviders\USStates; +use App\Libraries\MultiDB; use App\Models\Client; use App\Models\Company; -use App\Libraries\MultiDB; -use Illuminate\Bus\Queueable; -use App\DataProviders\USStates; use App\Utils\Traits\MakesHash; -use Illuminate\Queue\SerializesModels; -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\Middleware\WithoutOverlapping; +use Illuminate\Queue\SerializesModels; class UpdateTaxData implements ShouldQueue { @@ -52,8 +51,9 @@ class UpdateTaxData implements ShouldQueue { MultiDB::setDb($this->company->db); - if($this->company->account->isFreeHostedClient() || $this->client->country_id != 840) + if($this->company->account->isFreeHostedClient() || $this->client->country_id != 840) { return; + } $tax_provider = new \App\Services\Tax\Providers\TaxProvider($this->company, $this->client); @@ -69,7 +69,7 @@ class UpdateTaxData implements ShouldQueue } - }catch(\Exception $e){ + } catch(\Exception $e) { nlog("problem getting tax data => ".$e->getMessage()); } @@ -87,4 +87,4 @@ class UpdateTaxData implements ShouldQueue } -} \ No newline at end of file +} diff --git a/app/Jobs/Company/CompanyExport.php b/app/Jobs/Company/CompanyExport.php index 1a3bfc43b22b..b58e20f26a50 100644 --- a/app/Jobs/Company/CompanyExport.php +++ b/app/Jobs/Company/CompanyExport.php @@ -11,30 +11,29 @@ namespace App\Jobs\Company; -use App\Models\User; -use App\Utils\Ninja; -use App\Models\Company; -use App\Libraries\MultiDB; -use Illuminate\Support\Str; -use App\Mail\DownloadBackup; -use App\Jobs\Util\UnlinkFile; -use App\Models\VendorContact; -use Illuminate\Bus\Queueable; -use App\Models\QuoteInvitation; -use App\Utils\Traits\MakesHash; -use App\Models\CreditInvitation; use App\Jobs\Mail\NinjaMailerJob; -use App\Models\InvoiceInvitation; -use Illuminate\Support\Facades\App; use App\Jobs\Mail\NinjaMailerObject; -use Illuminate\Support\Facades\Cache; -use Illuminate\Queue\SerializesModels; +use App\Jobs\Util\UnlinkFile; +use App\Libraries\MultiDB; +use App\Mail\DownloadBackup; +use App\Models\Company; +use App\Models\CreditInvitation; +use App\Models\InvoiceInvitation; use App\Models\PurchaseOrderInvitation; -use Illuminate\Support\Facades\Storage; -use Illuminate\Queue\InteractsWithQueue; +use App\Models\QuoteInvitation; use App\Models\RecurringInvoiceInvitation; +use App\Models\User; +use App\Models\VendorContact; +use App\Utils\Ninja; +use App\Utils\Traits\MakesHash; +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\Cache; +use Illuminate\Support\Facades\Storage; class CompanyExport implements ShouldQueue { @@ -461,13 +460,15 @@ class CompanyExport implements ShouldQueue Storage::disk(config('filesystems.default'))->put('backups/'.$file_name, file_get_contents($zip_path)); - if(file_exists($zip_path)) - unlink($zip_path); + if(file_exists($zip_path)) { + unlink($zip_path); + } - if(Ninja::isSelfHost()) + if(Ninja::isSelfHost()) { $storage_path = 'backups/'.$file_name; - else + } else { $storage_path = Storage::disk(config('filesystems.default'))->path('backups/'.$file_name); + } $url = Cache::get($this->hash); @@ -492,8 +493,9 @@ class CompanyExport implements ShouldQueue if (Ninja::isHosted()) { sleep(3); - if(file_exists($zip_path)) + if(file_exists($zip_path)) { unlink($zip_path); + } } } } diff --git a/app/Jobs/Company/CompanyTaxRate.php b/app/Jobs/Company/CompanyTaxRate.php index 886704fa358e..9bb1eb470be4 100644 --- a/app/Jobs/Company/CompanyTaxRate.php +++ b/app/Jobs/Company/CompanyTaxRate.php @@ -11,17 +11,17 @@ namespace App\Jobs\Company; -use App\Models\Company; -use App\Libraries\MultiDB; -use Illuminate\Bus\Queueable; -use App\DataProviders\USStates; -use Illuminate\Queue\SerializesModels; use App\DataMapper\Tax\ZipTax\Response; -use Illuminate\Queue\InteractsWithQueue; +use App\DataProviders\USStates; +use App\Libraries\MultiDB; +use App\Models\Company; use App\Services\Tax\Providers\TaxProvider; +use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\Middleware\WithoutOverlapping; +use Illuminate\Queue\SerializesModels; class CompanyTaxRate implements ShouldQueue { @@ -53,21 +53,21 @@ class CompanyTaxRate implements ShouldQueue /** State must be calculated else default to the company state for taxes */ if(array_key_exists($this->company->settings->state, USStates::get())) { $calculated_state = $this->company->settings->state; - } - else { + } else { - try{ + try { $calculated_state = USStates::getState($this->company->settings->postal_code); - } - catch(\Exception $e){ + } catch(\Exception $e) { nlog("could not calculate state from postal code => {$this->company->settings->postal_code} or from state {$this->company->settings->state}"); } - if(!$calculated_state && $this->company->tax_data?->seller_subregion) + if(!$calculated_state && $this->company->tax_data?->seller_subregion) { $calculated_state = $this->company->tax_data?->seller_subregion; + } - if(!$calculated_state) + if(!$calculated_state) { return; + } } @@ -93,7 +93,8 @@ class CompanyTaxRate implements ShouldQueue return [new WithoutOverlapping($this->company->id)]; } - public function failed($e){ + public function failed($e) + { nlog($e->getMessage()); } -} \ No newline at end of file +} diff --git a/app/Jobs/Company/CreateCompany.php b/app/Jobs/Company/CreateCompany.php index 90bddda49244..a9377fa47817 100644 --- a/app/Jobs/Company/CreateCompany.php +++ b/app/Jobs/Company/CreateCompany.php @@ -11,16 +11,16 @@ namespace App\Jobs\Company; -use App\Utils\Ninja; +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; -use App\Libraries\MultiDB; +use App\Utils\Ninja; use App\Utils\Traits\MakesHash; -use App\DataMapper\Tax\TaxModel; -use App\DataMapper\CompanySettings; use Illuminate\Foundation\Bus\Dispatchable; -use App\DataMapper\ClientRegistrationFields; -use App\Factory\TaxRateFactory; class CreateCompany { @@ -55,7 +55,7 @@ class CreateCompany $settings->name = isset($this->request['name']) ? $this->request['name'] : ''; - if($country_id = $this->resolveCountry()){ + if($country_id = $this->resolveCountry()) { $settings->country_id = $country_id; } @@ -95,33 +95,34 @@ class CreateCompany * * @return string */ - private function resolveCountry(): string + private function resolveCountry(): string { - try{ + try { $ip = request()->ip(); - if(request()->hasHeader('cf-ipcountry')){ + if(request()->hasHeader('cf-ipcountry')) { $c = Country::where('iso_3166_2', request()->header('cf-ipcountry'))->first(); - if($c) + if($c) { return (string)$c->id; + } } $details = json_decode(file_get_contents("http://ip-api.com/json/{$ip}")); - if($details && property_exists($details, 'countryCode')){ + if($details && property_exists($details, 'countryCode')) { $c = Country::where('iso_3166_2', $details->countryCode)->first(); - if($c) + if($c) { return (string)$c->id; + } } - } - catch(\Exception $e){ + } catch(\Exception $e) { nlog("Could not resolve country => {$e->getMessage()}"); } @@ -163,8 +164,7 @@ class CreateCompany return $company; - } - catch(\Exception $e){ + } catch(\Exception $e) { nlog("SETUP: could not complete setup for Spanish Locale"); } @@ -206,8 +206,7 @@ class CreateCompany return $company; - } - catch(\Exception $e){ + } catch(\Exception $e) { nlog($e->getMessage()); nlog("SETUP: could not complete setup for Australian Locale"); } diff --git a/app/Jobs/Cron/AutoBill.php b/app/Jobs/Cron/AutoBill.php index 5376571d7ced..cc48b9142341 100644 --- a/app/Jobs/Cron/AutoBill.php +++ b/app/Jobs/Cron/AutoBill.php @@ -11,14 +11,14 @@ namespace App\Jobs\Cron; -use App\Models\Invoice; -use App\Libraries\MultiDB; -use Illuminate\Bus\Queueable; use App\Jobs\Entity\EmailEntity; -use Illuminate\Queue\SerializesModels; -use Illuminate\Queue\InteractsWithQueue; +use App\Libraries\MultiDB; +use App\Models\Invoice; +use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Queue\SerializesModels; class AutoBill implements ShouldQueue { @@ -60,8 +60,7 @@ class AutoBill implements ShouldQueue } catch (\Exception $e) { nlog("Failed to capture payment for {$this->invoice_id} ->".$e->getMessage()); - if($this->send_email_on_failure && $invoice) - { + if($this->send_email_on_failure && $invoice) { $invoice->invitations->each(function ($invitation) use ($invoice) { if ($invitation->contact && ! $invitation->contact->trashed() && strlen($invitation->contact->email) >= 1 && $invoice->client->getSetting('auto_email_invoice')) { diff --git a/app/Jobs/Cron/AutoBillCron.php b/app/Jobs/Cron/AutoBillCron.php index cf2c5f987f5b..ff3c2c295591 100644 --- a/app/Jobs/Cron/AutoBillCron.php +++ b/app/Jobs/Cron/AutoBillCron.php @@ -11,11 +11,11 @@ namespace App\Jobs\Cron; -use App\Models\Invoice; use App\Libraries\MultiDB; +use App\Models\Invoice; +use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Auth; -use Illuminate\Foundation\Bus\Dispatchable; class AutoBillCron { diff --git a/app/Jobs/Cron/RecurringExpensesCron.php b/app/Jobs/Cron/RecurringExpensesCron.php index 55eee07e5bb5..3b38aafb0c9c 100644 --- a/app/Jobs/Cron/RecurringExpensesCron.php +++ b/app/Jobs/Cron/RecurringExpensesCron.php @@ -11,16 +11,16 @@ namespace App\Jobs\Cron; -use App\Utils\Ninja; +use App\Events\Expense\ExpenseWasCreated; +use App\Factory\RecurringExpenseToExpenseFactory; use App\Libraries\MultiDB; -use Illuminate\Support\Carbon; use App\Models\RecurringExpense; use App\Models\RecurringInvoice; -use Illuminate\Support\Facades\Auth; +use App\Utils\Ninja; use App\Utils\Traits\GeneratesCounter; -use App\Events\Expense\ExpenseWasCreated; use Illuminate\Foundation\Bus\Dispatchable; -use App\Factory\RecurringExpenseToExpenseFactory; +use Illuminate\Support\Carbon; +use Illuminate\Support\Facades\Auth; class RecurringExpensesCron { @@ -105,8 +105,9 @@ class RecurringExpensesCron $expense = RecurringExpenseToExpenseFactory::create($recurring_expense); $expense->saveQuietly(); - if($expense->company->mark_expenses_paid) + if($expense->company->mark_expenses_paid) { $expense->payment_date = now()->format('Y-m-d'); + } $expense->number = $this->getNextExpenseNumber($expense); $expense->saveQuietly(); diff --git a/app/Jobs/Cron/RecurringInvoicesCron.php b/app/Jobs/Cron/RecurringInvoicesCron.php index edd57acf265d..895a172a79c6 100644 --- a/app/Jobs/Cron/RecurringInvoicesCron.php +++ b/app/Jobs/Cron/RecurringInvoicesCron.php @@ -11,13 +11,13 @@ namespace App\Jobs\Cron; -use App\Models\Invoice; -use App\Libraries\MultiDB; -use Illuminate\Support\Carbon; -use App\Models\RecurringInvoice; -use Illuminate\Support\Facades\Auth; -use Illuminate\Foundation\Bus\Dispatchable; use App\Jobs\RecurringInvoice\SendRecurring; +use App\Libraries\MultiDB; +use App\Models\Invoice; +use App\Models\RecurringInvoice; +use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Support\Carbon; +use Illuminate\Support\Facades\Auth; class RecurringInvoicesCron { diff --git a/app/Jobs/Cron/SubscriptionCron.php b/app/Jobs/Cron/SubscriptionCron.php index c77a62769521..efa1da9c24e3 100644 --- a/app/Jobs/Cron/SubscriptionCron.php +++ b/app/Jobs/Cron/SubscriptionCron.php @@ -11,11 +11,11 @@ namespace App\Jobs\Cron; -use App\Models\Invoice; use App\Libraries\MultiDB; -use Illuminate\Support\Facades\Auth; +use App\Models\Invoice; use App\Utils\Traits\SubscriptionHooker; use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Support\Facades\Auth; class SubscriptionCron { diff --git a/app/Jobs/Cron/UpdateCalculatedFields.php b/app/Jobs/Cron/UpdateCalculatedFields.php index 865d3ed1238b..a5337255ecb8 100644 --- a/app/Jobs/Cron/UpdateCalculatedFields.php +++ b/app/Jobs/Cron/UpdateCalculatedFields.php @@ -11,11 +11,10 @@ namespace App\Jobs\Cron; -use App\Models\Payment; -use App\Models\Project; use App\Libraries\MultiDB; -use Illuminate\Support\Facades\Auth; +use App\Models\Project; use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Support\Facades\Auth; class UpdateCalculatedFields { @@ -43,15 +42,15 @@ class UpdateCalculatedFields if (! config('ninja.db.multi_db_enabled')) { - Project::query()->with('tasks')->whereHas('tasks', function ($query){ - $query->where('updated_at', '>', now()->subHours(2)); + Project::query()->with('tasks')->whereHas('tasks', function ($query) { + $query->where('updated_at', '>', now()->subHours(2)); }) ->cursor() ->each(function ($project) { $project->current_hours = $this->calculateDuration($project); $project->save(); - }); + }); @@ -61,14 +60,14 @@ class UpdateCalculatedFields MultiDB::setDB($db); - Project::query()->with('tasks')->whereHas('tasks', function ($query){ + Project::query()->with('tasks')->whereHas('tasks', function ($query) { $query->where('updated_at', '>', now()->subHours(2)); - }) - ->cursor() - ->each(function ($project) { - $project->current_hours = $this->calculateDuration($project); - $project->save(); - }); + }) + ->cursor() + ->each(function ($project) { + $project->current_hours = $this->calculateDuration($project); + $project->save(); + }); } } @@ -80,16 +79,16 @@ class UpdateCalculatedFields $project->tasks->each(function ($task) use (&$duration) { - if(is_iterable($task->time_log)) { - foreach(json_decode($task->time_log) as $log) { + if(is_iterable($task->time_log)) { + foreach(json_decode($task->time_log) as $log) { - $start_time = $log[0]; - $end_time = $log[1] == 0 ? time() : $log[1]; + $start_time = $log[0]; + $end_time = $log[1] == 0 ? time() : $log[1]; - $duration += $end_time - $start_time; + $duration += $end_time - $start_time; + } } - } }); @@ -97,7 +96,3 @@ class UpdateCalculatedFields } } - - - - diff --git a/app/Jobs/Entity/CreateRawPdf.php b/app/Jobs/Entity/CreateRawPdf.php index 04c624238706..6f6592ac03c4 100644 --- a/app/Jobs/Entity/CreateRawPdf.php +++ b/app/Jobs/Entity/CreateRawPdf.php @@ -11,34 +11,34 @@ namespace App\Jobs\Entity; -use App\Utils\Ninja; -use App\Models\Quote; +use App\Exceptions\FilePermissionsFailure; +use App\Jobs\Invoice\CreateEInvoice; use App\Models\Credit; +use App\Models\CreditInvitation; use App\Models\Design; use App\Models\Invoice; -use App\Utils\HtmlEngine; -use App\Models\QuoteInvitation; -use App\Utils\Traits\MakesHash; -use App\Models\CreditInvitation; -use App\Models\RecurringInvoice; -use App\Services\Pdf\PdfService; -use App\Utils\PhantomJS\Phantom; use App\Models\InvoiceInvitation; -use App\Utils\HostedPDF\NinjaPdf; -use App\Utils\Traits\Pdf\PdfMaker; -use Illuminate\Support\Facades\App; -use App\Jobs\Invoice\CreateEInvoice; -use App\Utils\Traits\NumberFormatter; -use App\Utils\Traits\MakesInvoiceHtml; -use App\Utils\Traits\Pdf\PageNumbering; -use App\Exceptions\FilePermissionsFailure; +use App\Models\Quote; +use App\Models\QuoteInvitation; +use App\Models\RecurringInvoice; use App\Models\RecurringInvoiceInvitation; -use horstoeko\zugferd\ZugferdDocumentPdfBuilder; +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\HtmlEngine; +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 horstoeko\zugferd\ZugferdDocumentPdfBuilder; +use Illuminate\Support\Facades\App; -class CreateRawPdf +class CreateRawPdf { use NumberFormatter, MakesInvoiceHtml, PdfMaker, MakesHash, PageNumbering; @@ -224,8 +224,9 @@ class CreateRawPdf */ private function checkEInvoice(string $pdf): string { - if(!$this->entity instanceof Invoice || !$this->company->getSetting('enable_e_invoice')) + if(!$this->entity instanceof Invoice || !$this->company->getSetting('enable_e_invoice')) { return $pdf; + } $e_invoice_type = $this->entity->client->getSetting('e_invoice_type'); diff --git a/app/Jobs/Entity/EmailEntity.php b/app/Jobs/Entity/EmailEntity.php index 41473f1b8fd1..f25d101e1658 100644 --- a/app/Jobs/Entity/EmailEntity.php +++ b/app/Jobs/Entity/EmailEntity.php @@ -11,7 +11,6 @@ namespace App\Jobs\Entity; -use App\Events\Invoice\InvoiceWasEmailedAndFailed; use App\Jobs\Mail\NinjaMailerJob; use App\Jobs\Mail\NinjaMailerObject; use App\Libraries\MultiDB; diff --git a/app/Jobs/Invoice/CheckGatewayFee.php b/app/Jobs/Invoice/CheckGatewayFee.php index e7a978427045..3f79e41bcfa5 100644 --- a/app/Jobs/Invoice/CheckGatewayFee.php +++ b/app/Jobs/Invoice/CheckGatewayFee.php @@ -11,14 +11,14 @@ namespace App\Jobs\Invoice; -use App\Models\Invoice; use App\Libraries\MultiDB; +use App\Models\Invoice; 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; class CheckGatewayFee implements ShouldQueue { diff --git a/app/Jobs/Invoice/CreateEInvoice.php b/app/Jobs/Invoice/CreateEInvoice.php index c68662c4b108..b3f64776ea38 100644 --- a/app/Jobs/Invoice/CreateEInvoice.php +++ b/app/Jobs/Invoice/CreateEInvoice.php @@ -12,17 +12,17 @@ namespace App\Jobs\Invoice; -use App\Utils\Ninja; use App\Models\Invoice; -use horstoeko\zugferd\ZugferdDocumentBuilder; -use Illuminate\Bus\Queueable; -use Illuminate\Support\Facades\App; -use Illuminate\Queue\SerializesModels; -use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Foundation\Bus\Dispatchable; use App\Services\Invoice\EInvoice\FacturaEInvoice; use App\Services\Invoice\EInvoice\ZugferdEInvoice; +use App\Utils\Ninja; +use horstoeko\zugferd\ZugferdDocumentBuilder; +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; class CreateEInvoice implements ShouldQueue { diff --git a/app/Jobs/Invoice/InjectSignature.php b/app/Jobs/Invoice/InjectSignature.php index b296b43e6f6c..7f161b653140 100644 --- a/app/Jobs/Invoice/InjectSignature.php +++ b/app/Jobs/Invoice/InjectSignature.php @@ -4,10 +4,10 @@ namespace App\Jobs\Invoice; use App\Models\PurchaseOrder; 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\SerializesModels; class InjectSignature implements ShouldQueue { @@ -34,19 +34,20 @@ class InjectSignature implements ShouldQueue { $invitation = false; - if($this->entity instanceof PurchaseOrder){ + if($this->entity instanceof PurchaseOrder) { $invitation = $this->entity->invitations()->where('vendor_contact_id', $this->contact_id)->first(); - if(!$invitation) + if(!$invitation) { $invitation = $this->entity->invitations->first(); + } - } - else { + } else { $invitation = $this->entity->invitations()->where('client_contact_id', $this->contact_id)->first(); - if(!$invitation) + if(!$invitation) { $invitation = $this->entity->invitations->first(); + } } if (! $invitation) { diff --git a/app/Jobs/Invoice/InvoiceWorkflowSettings.php b/app/Jobs/Invoice/InvoiceWorkflowSettings.php index 615b43ad925f..999497108994 100644 --- a/app/Jobs/Invoice/InvoiceWorkflowSettings.php +++ b/app/Jobs/Invoice/InvoiceWorkflowSettings.php @@ -12,7 +12,6 @@ namespace App\Jobs\Invoice; -use App\Models\Client; use App\Models\Invoice; use App\Repositories\BaseRepository; use Illuminate\Bus\Queueable; diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index eed243b27d91..9fc9acf1363d 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -492,7 +492,7 @@ class NinjaMailerJob implements ShouldQueue */ private function preFlightChecksFail(): bool { - /* Always send regardless */ + /* Always send regardless */ if($this->override) { return false; } diff --git a/app/Jobs/Ninja/CheckACHStatus.php b/app/Jobs/Ninja/CheckACHStatus.php index 371681cf7336..32cf8bd78921 100644 --- a/app/Jobs/Ninja/CheckACHStatus.php +++ b/app/Jobs/Ninja/CheckACHStatus.php @@ -11,14 +11,14 @@ namespace App\Jobs\Ninja; -use App\Models\Payment; use App\Libraries\MultiDB; -use Illuminate\Bus\Queueable; use App\Models\ClientGatewayToken; -use Illuminate\Queue\SerializesModels; -use Illuminate\Queue\InteractsWithQueue; +use App\Models\Payment; +use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Queue\SerializesModels; class CheckACHStatus implements ShouldQueue { @@ -77,7 +77,7 @@ class CheckACHStatus implements ShouldQueue }); Payment::where('status_id', 1) - ->whereHas('company_gateway', function ($q){ + ->whereHas('company_gateway', function ($q) { $q->whereIn('gateway_key', ['d14dd26a47cecc30fdd65700bfb67b34', 'd14dd26a37cecc30fdd65700bfb55b23']); }) ->cursor() @@ -124,4 +124,4 @@ class CheckACHStatus implements ShouldQueue } } -} \ No newline at end of file +} diff --git a/app/Jobs/Ninja/CheckCompanyData.php b/app/Jobs/Ninja/CheckCompanyData.php index 9899bdff7746..c26827ad9947 100644 --- a/app/Jobs/Ninja/CheckCompanyData.php +++ b/app/Jobs/Ninja/CheckCompanyData.php @@ -11,7 +11,6 @@ namespace App\Jobs\Ninja; -use App\Models\ClientContact; use App\Models\Company; use App\Models\CompanyLedger; use App\Models\Credit; diff --git a/app/Jobs/Ninja/TaskScheduler.php b/app/Jobs/Ninja/TaskScheduler.php index 307ffb07bf18..dfb76169939e 100644 --- a/app/Jobs/Ninja/TaskScheduler.php +++ b/app/Jobs/Ninja/TaskScheduler.php @@ -11,14 +11,14 @@ namespace App\Jobs\Ninja; -use App\Models\Scheduler; use App\Libraries\MultiDB; +use App\Models\Scheduler; use Illuminate\Bus\Queueable; -use Illuminate\Support\Facades\Auth; -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\SerializesModels; +use Illuminate\Support\Facades\Auth; //@rebuild it class TaskScheduler implements ShouldQueue diff --git a/app/Jobs/Payment/EmailPayment.php b/app/Jobs/Payment/EmailPayment.php index 3222c889043a..f8729f707eab 100644 --- a/app/Jobs/Payment/EmailPayment.php +++ b/app/Jobs/Payment/EmailPayment.php @@ -78,14 +78,15 @@ class EmailPayment implements ShouldQueue if ($this->payment->invoices && $this->payment->invoices->count() >= 1) { - if($this->contact){ + if($this->contact) { $invitation = $this->payment->invoices->first()->invitations()->where('client_contact_id', $this->contact->id)->first(); - } - else + } else { $invitation = $this->payment->invoices->first()->invitations()->first(); + } - if($invitation) + if($invitation) { $nmo->invitation = $invitation; + } } diff --git a/app/Jobs/Payment/EmailRefundPayment.php b/app/Jobs/Payment/EmailRefundPayment.php index 05d726ba3074..1ec374ab1b44 100644 --- a/app/Jobs/Payment/EmailRefundPayment.php +++ b/app/Jobs/Payment/EmailRefundPayment.php @@ -91,8 +91,9 @@ class EmailRefundPayment implements ShouldQueue $invitation = $this->payment->invoices->first()->invitations()->first(); } - if($invitation) + if($invitation) { $nmo->invitation = $invitation; + } } diff --git a/app/Jobs/PostMark/ProcessPostmarkWebhook.php b/app/Jobs/PostMark/ProcessPostmarkWebhook.php index 25f2d57c8cda..e2eae3bb8aed 100644 --- a/app/Jobs/PostMark/ProcessPostmarkWebhook.php +++ b/app/Jobs/PostMark/ProcessPostmarkWebhook.php @@ -11,24 +11,24 @@ namespace App\Jobs\PostMark; -use App\Models\SystemLog; -use App\Libraries\MultiDB; -use Postmark\PostmarkClient; -use Illuminate\Bus\Queueable; +use App\DataMapper\Analytics\Mail\EmailBounce; +use App\DataMapper\Analytics\Mail\EmailSpam; use App\Jobs\Util\SystemLogger; -use App\Models\QuoteInvitation; +use App\Libraries\MultiDB; use App\Models\CreditInvitation; use App\Models\InvoiceInvitation; -use Illuminate\Queue\SerializesModels; -use Turbo124\Beacon\Facades\LightLogs; use App\Models\PurchaseOrderInvitation; -use Illuminate\Queue\InteractsWithQueue; +use App\Models\QuoteInvitation; use App\Models\RecurringInvoiceInvitation; +use App\Models\SystemLog; +use App\Notifications\Ninja\EmailSpamNotification; +use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; -use App\DataMapper\Analytics\Mail\EmailSpam; -use App\DataMapper\Analytics\Mail\EmailBounce; -use App\Notifications\Ninja\EmailSpamNotification; +use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Queue\SerializesModels; +use Postmark\PostmarkClient; +use Turbo124\Beacon\Facades\LightLogs; class ProcessPostmarkWebhook implements ShouldQueue { @@ -62,7 +62,7 @@ class ProcessPostmarkWebhook implements ShouldQueue ->where('company_id', $this->invitation->company_id) ->where('type_id', SystemLog::TYPE_WEBHOOK_RESPONSE) ->whereJsonContains('log', ['MessageID' => $message_id]) - ->orderBy('id','desc') + ->orderBy('id', 'desc') ->first(); } @@ -108,42 +108,42 @@ class ProcessPostmarkWebhook implements ShouldQueue } } -// { -// "Metadata": { -// "example": "value", -// "example_2": "value" -// }, -// "RecordType": "Open", -// "FirstOpen": true, -// "Client": { -// "Name": "Chrome 35.0.1916.153", -// "Company": "Google", -// "Family": "Chrome" -// }, -// "OS": { -// "Name": "OS X 10.7 Lion", -// "Company": "Apple Computer, Inc.", -// "Family": "OS X 10" -// }, -// "Platform": "WebMail", -// "UserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36", -// "ReadSeconds": 5, -// "Geo": { -// "CountryISOCode": "RS", -// "Country": "Serbia", -// "RegionISOCode": "VO", -// "Region": "Autonomna Pokrajina Vojvodina", -// "City": "Novi Sad", -// "Zip": "21000", -// "Coords": "45.2517,19.8369", -// "IP": "188.2.95.4" -// }, -// "MessageID": "00000000-0000-0000-0000-000000000000", -// "MessageStream": "outbound", -// "ReceivedAt": "2022-02-06T06:37:48Z", -// "Tag": "welcome-email", -// "Recipient": "john@example.com" -// } + // { + // "Metadata": { + // "example": "value", + // "example_2": "value" + // }, + // "RecordType": "Open", + // "FirstOpen": true, + // "Client": { + // "Name": "Chrome 35.0.1916.153", + // "Company": "Google", + // "Family": "Chrome" + // }, + // "OS": { + // "Name": "OS X 10.7 Lion", + // "Company": "Apple Computer, Inc.", + // "Family": "OS X 10" + // }, + // "Platform": "WebMail", + // "UserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36", + // "ReadSeconds": 5, + // "Geo": { + // "CountryISOCode": "RS", + // "Country": "Serbia", + // "RegionISOCode": "VO", + // "Region": "Autonomna Pokrajina Vojvodina", + // "City": "Novi Sad", + // "Zip": "21000", + // "Coords": "45.2517,19.8369", + // "IP": "188.2.95.4" + // }, + // "MessageID": "00000000-0000-0000-0000-000000000000", + // "MessageStream": "outbound", + // "ReceivedAt": "2022-02-06T06:37:48Z", + // "Tag": "welcome-email", + // "Recipient": "john@example.com" + // } private function processOpen() { @@ -154,7 +154,7 @@ class ProcessPostmarkWebhook implements ShouldQueue $sl = $this->getSystemLog($this->request['MessageID']); - if($sl){ + if($sl) { $this->updateSystemLog($sl, $data); return; } @@ -169,20 +169,20 @@ class ProcessPostmarkWebhook implements ShouldQueue ))->handle(); } -// { -// "RecordType": "Delivery", -// "ServerID": 23, -// "MessageStream": "outbound", -// "MessageID": "00000000-0000-0000-0000-000000000000", -// "Recipient": "john@example.com", -// "Tag": "welcome-email", -// "DeliveredAt": "2021-02-21T16:34:52Z", -// "Details": "Test delivery webhook details", -// "Metadata": { -// "example": "value", -// "example_2": "value" -// } -// } + // { + // "RecordType": "Delivery", + // "ServerID": 23, + // "MessageStream": "outbound", + // "MessageID": "00000000-0000-0000-0000-000000000000", + // "Recipient": "john@example.com", + // "Tag": "welcome-email", + // "DeliveredAt": "2021-02-21T16:34:52Z", + // "Details": "Test delivery webhook details", + // "Metadata": { + // "example": "value", + // "example_2": "value" + // } + // } private function processDelivery() { $this->invitation->email_status = 'delivered'; @@ -207,31 +207,31 @@ class ProcessPostmarkWebhook implements ShouldQueue ))->handle(); } -// { -// "Metadata": { -// "example": "value", -// "example_2": "value" -// }, -// "RecordType": "Bounce", -// "ID": 42, -// "Type": "HardBounce", -// "TypeCode": 1, -// "Name": "Hard bounce", -// "Tag": "Test", -// "MessageID": "00000000-0000-0000-0000-000000000000", -// "ServerID": 1234, -// "MessageStream": "outbound", -// "Description": "The server was unable to deliver your message (ex: unknown user, mailbox not found).", -// "Details": "Test bounce details", -// "Email": "john@example.com", -// "From": "sender@example.com", -// "BouncedAt": "2021-02-21T16:34:52Z", -// "DumpAvailable": true, -// "Inactive": true, -// "CanActivate": true, -// "Subject": "Test subject", -// "Content": "Test content" -// } + // { + // "Metadata": { + // "example": "value", + // "example_2": "value" + // }, + // "RecordType": "Bounce", + // "ID": 42, + // "Type": "HardBounce", + // "TypeCode": 1, + // "Name": "Hard bounce", + // "Tag": "Test", + // "MessageID": "00000000-0000-0000-0000-000000000000", + // "ServerID": 1234, + // "MessageStream": "outbound", + // "Description": "The server was unable to deliver your message (ex: unknown user, mailbox not found).", + // "Details": "Test bounce details", + // "Email": "john@example.com", + // "From": "sender@example.com", + // "BouncedAt": "2021-02-21T16:34:52Z", + // "DumpAvailable": true, + // "Inactive": true, + // "CanActivate": true, + // "Subject": "Test subject", + // "Content": "Test content" + // } private function processBounce() { @@ -261,31 +261,31 @@ class ProcessPostmarkWebhook implements ShouldQueue // $this->invitation->company->notification(new EmailBounceNotification($this->invitation->company->account))->ninja(); } -// { -// "Metadata": { -// "example": "value", -// "example_2": "value" -// }, -// "RecordType": "SpamComplaint", -// "ID": 42, -// "Type": "SpamComplaint", -// "TypeCode": 100001, -// "Name": "Spam complaint", -// "Tag": "Test", -// "MessageID": "00000000-0000-0000-0000-000000000000", -// "ServerID": 1234, -// "MessageStream": "outbound", -// "Description": "The subscriber explicitly marked this message as spam.", -// "Details": "Test spam complaint details", -// "Email": "john@example.com", -// "From": "sender@example.com", -// "BouncedAt": "2021-02-21T16:34:52Z", -// "DumpAvailable": true, -// "Inactive": true, -// "CanActivate": false, -// "Subject": "Test subject", -// "Content": "Test content" -// } + // { + // "Metadata": { + // "example": "value", + // "example_2": "value" + // }, + // "RecordType": "SpamComplaint", + // "ID": 42, + // "Type": "SpamComplaint", + // "TypeCode": 100001, + // "Name": "Spam complaint", + // "Tag": "Test", + // "MessageID": "00000000-0000-0000-0000-000000000000", + // "ServerID": 1234, + // "MessageStream": "outbound", + // "Description": "The subscriber explicitly marked this message as spam.", + // "Details": "Test spam complaint details", + // "Email": "john@example.com", + // "From": "sender@example.com", + // "BouncedAt": "2021-02-21T16:34:52Z", + // "DumpAvailable": true, + // "Inactive": true, + // "CanActivate": false, + // "Subject": "Test subject", + // "Content": "Test content" + // } private function processSpamComplaint() { $this->invitation->email_status = 'spam'; @@ -367,9 +367,9 @@ class ProcessPostmarkWebhook implements ShouldQueue private function fetchMessage(): array { - if(strlen($this->request['MessageID']) < 1){ + if(strlen($this->request['MessageID']) < 1) { return $this->default_response; - } + } try { @@ -401,8 +401,7 @@ class ProcessPostmarkWebhook implements ShouldQueue 'events' => $events, ]; - } - catch (\Exception $e) { + } catch (\Exception $e) { return $this->default_response; diff --git a/app/Jobs/PurchaseOrder/ZipPurchaseOrders.php b/app/Jobs/PurchaseOrder/ZipPurchaseOrders.php index 00ee4aa39a27..8c1f85ccd15b 100644 --- a/app/Jobs/PurchaseOrder/ZipPurchaseOrders.php +++ b/app/Jobs/PurchaseOrder/ZipPurchaseOrders.php @@ -14,7 +14,6 @@ namespace App\Jobs\PurchaseOrder; use App\Jobs\Mail\NinjaMailerJob; use App\Jobs\Mail\NinjaMailerObject; use App\Jobs\Util\UnlinkFile; -use App\Jobs\Vendor\CreatePurchaseOrderPdf; use App\Libraries\MultiDB; use App\Mail\DownloadPurchaseOrders; use App\Models\Company; diff --git a/app/Jobs/Quote/ZipQuotes.php b/app/Jobs/Quote/ZipQuotes.php index 352be947858a..c4ce22fa6698 100644 --- a/app/Jobs/Quote/ZipQuotes.php +++ b/app/Jobs/Quote/ZipQuotes.php @@ -11,20 +11,20 @@ namespace App\Jobs\Quote; -use App\Models\User; -use App\Models\Company; -use App\Libraries\MultiDB; -use App\Mail\DownloadQuotes; -use App\Jobs\Util\UnlinkFile; -use Illuminate\Bus\Queueable; -use App\Models\QuoteInvitation; use App\Jobs\Mail\NinjaMailerJob; use App\Jobs\Mail\NinjaMailerObject; -use Illuminate\Queue\SerializesModels; -use Illuminate\Support\Facades\Storage; -use Illuminate\Queue\InteractsWithQueue; +use App\Jobs\Util\UnlinkFile; +use App\Libraries\MultiDB; +use App\Mail\DownloadQuotes; +use App\Models\Company; +use App\Models\QuoteInvitation; +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 ZipQuotes implements ShouldQueue { diff --git a/app/Jobs/RecurringInvoice/SendRecurring.php b/app/Jobs/RecurringInvoice/SendRecurring.php index 3c98c00a4387..b2247a93f747 100644 --- a/app/Jobs/RecurringInvoice/SendRecurring.php +++ b/app/Jobs/RecurringInvoice/SendRecurring.php @@ -11,24 +11,24 @@ namespace App\Jobs\RecurringInvoice; -use Carbon\Carbon; -use App\Utils\Ninja; -use App\Models\Invoice; -use App\Jobs\Cron\AutoBill; -use Illuminate\Bus\Queueable; -use App\Utils\Traits\MakesHash; -use App\Jobs\Entity\EmailEntity; -use App\Models\RecurringInvoice; -use App\Utils\Traits\GeneratesCounter; -use Illuminate\Queue\SerializesModels; -use Turbo124\Beacon\Facades\LightLogs; -use Illuminate\Queue\InteractsWithQueue; +use App\DataMapper\Analytics\SendRecurringFailure; use App\Events\Invoice\InvoiceWasCreated; use App\Factory\InvoiceInvitationFactory; +use App\Factory\RecurringInvoiceToInvoiceFactory; +use App\Jobs\Cron\AutoBill; +use App\Jobs\Entity\EmailEntity; +use App\Models\Invoice; +use App\Models\RecurringInvoice; +use App\Utils\Ninja; +use App\Utils\Traits\GeneratesCounter; +use App\Utils\Traits\MakesHash; +use Carbon\Carbon; +use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; -use App\Factory\RecurringInvoiceToInvoiceFactory; -use App\DataMapper\Analytics\SendRecurringFailure; +use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Queue\SerializesModels; +use Turbo124\Beacon\Facades\LightLogs; class SendRecurring implements ShouldQueue { @@ -115,11 +115,10 @@ class SendRecurring implements ShouldQueue AutoBill::dispatch($invoice->id, $this->db, true)->delay(rand(1, 2)); //04-08-2023 edge case to support where online payment notifications are not enabled - if(!$invoice->client->getSetting('client_online_payment_notification')){ + if(!$invoice->client->getSetting('client_online_payment_notification')) { $this->sendRecurringEmails($invoice); } - } - elseif ($invoice->auto_bill_enabled && $invoice->client->getSetting('auto_bill_date') == 'on_due_date' && $invoice->client->getSetting('auto_email_invoice') && ($invoice->due_date && Carbon::parse($invoice->due_date)->startOfDay()->lte(now()->startOfDay()))) { + } elseif ($invoice->auto_bill_enabled && $invoice->client->getSetting('auto_bill_date') == 'on_due_date' && $invoice->client->getSetting('auto_email_invoice') && ($invoice->due_date && Carbon::parse($invoice->due_date)->startOfDay()->lte(now()->startOfDay()))) { nlog("attempting to autobill {$invoice->number}"); AutoBill::dispatch($invoice->id, $this->db, true)->delay(rand(1, 2)); @@ -128,8 +127,7 @@ class SendRecurring implements ShouldQueue $this->sendRecurringEmails($invoice); } - } - elseif ($invoice->client->getSetting('auto_email_invoice')) { + } elseif ($invoice->client->getSetting('auto_email_invoice')) { $this->sendRecurringEmails($invoice); } @@ -138,7 +136,7 @@ class SendRecurring implements ShouldQueue /** * Sends the recurring invoice emails to * the designated contacts - * + * * @param Invoice $invoice * @return void */ @@ -199,4 +197,4 @@ class SendRecurring implements ShouldQueue nlog(print_r($exception->getMessage(), 1)); } -} \ No newline at end of file +} diff --git a/app/Jobs/Report/PreviewReport.php b/app/Jobs/Report/PreviewReport.php index 9651b64de603..959e110ea608 100644 --- a/app/Jobs/Report/PreviewReport.php +++ b/app/Jobs/Report/PreviewReport.php @@ -11,15 +11,15 @@ namespace App\Jobs\Report; -use App\Models\Company; use App\Libraries\MultiDB; +use App\Models\Company; use Illuminate\Bus\Queueable; -use Illuminate\Support\Facades\Cache; -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; +use Illuminate\Support\Facades\Cache; class PreviewReport implements ShouldQueue { diff --git a/app/Jobs/Report/SendToAdmin.php b/app/Jobs/Report/SendToAdmin.php index ca7e5c881299..e2cba7525da6 100644 --- a/app/Jobs/Report/SendToAdmin.php +++ b/app/Jobs/Report/SendToAdmin.php @@ -20,8 +20,8 @@ use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Queue\SerializesModels; use Illuminate\Queue\Middleware\WithoutOverlapping; +use Illuminate\Queue\SerializesModels; class SendToAdmin implements ShouldQueue { diff --git a/app/Jobs/Subscription/CleanStaleInvoiceOrder.php b/app/Jobs/Subscription/CleanStaleInvoiceOrder.php index b182a8831c1f..43ff28a56b3d 100644 --- a/app/Jobs/Subscription/CleanStaleInvoiceOrder.php +++ b/app/Jobs/Subscription/CleanStaleInvoiceOrder.php @@ -59,11 +59,11 @@ class CleanStaleInvoiceOrder implements ShouldQueue ->whereBetween('created_at', [now()->subHours(1), now()->subMinutes(10)]) ->where('balance', '>', 0) ->cursor() - ->each(function ($invoice){ + ->each(function ($invoice) { - if (collect($invoice->line_items)->contains('type_id', 3)) { - $invoice->service()->removeUnpaidGatewayFees(); - } + if (collect($invoice->line_items)->contains('type_id', 3)) { + $invoice->service()->removeUnpaidGatewayFees(); + } }); diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index bfb09f42abec..db4f2fe38bfd 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -11,89 +11,85 @@ namespace App\Jobs\Util; -use Exception; -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\Models\Company; -use App\Models\Expense; -use App\Models\Invoice; -use App\Models\Payment; -use App\Models\Product; -use App\Models\Project; -use App\Models\TaxRate; -use App\Models\Activity; -use App\Models\Document; -use App\Libraries\MultiDB; -use App\Models\TaskStatus; -use App\Models\PaymentTerm; -use Illuminate\Support\Str; -use App\Factory\UserFactory; -use App\Factory\QuoteFactory; -use App\Models\ClientContact; -use Illuminate\Bus\Queueable; +use App\DataMapper\Analytics\MigrationFailure; +use App\DataMapper\CompanySettings; +use App\Exceptions\ClientHostedMigrationException; +use App\Exceptions\MigrationValidatorFailed; +use App\Exceptions\ResourceDependencyMissing; use App\Factory\ClientFactory; +use App\Factory\CompanyLedgerFactory; use App\Factory\CreditFactory; -use App\Factory\VendorFactory; -use App\Models\CompanyGateway; -use Illuminate\Support\Carbon; use App\Factory\InvoiceFactory; use App\Factory\PaymentFactory; use App\Factory\ProductFactory; +use App\Factory\QuoteFactory; +use App\Factory\RecurringInvoiceFactory; use App\Factory\TaxRateFactory; -use App\Jobs\Util\VersionCheck; -use App\Models\ExpenseCategory; -use App\Utils\Traits\MakesHash; -use App\Mail\MigrationCompleted; -use App\Models\RecurringExpense; -use App\Models\RecurringInvoice; -use App\Utils\Traits\Uploadable; +use App\Factory\UserFactory; +use App\Factory\VendorFactory; +use App\Http\Requests\Company\UpdateCompanyRequest; +use App\Http\ValidationRules\ValidCompanyGatewayFeesAndLimitsRule; +use App\Http\ValidationRules\ValidUserForCompany; +use App\Jobs\Company\CreateCompanyToken; use App\Jobs\Mail\NinjaMailerJob; -use Illuminate\Http\UploadedFile; -use App\Models\ClientGatewayToken; -use Illuminate\Support\Facades\DB; -use App\DataMapper\CompanySettings; -use Illuminate\Support\Facades\App; use App\Jobs\Mail\NinjaMailerObject; use App\Jobs\Ninja\CheckCompanyData; -use App\Repositories\UserRepository; -use App\Utils\Traits\CleanLineItems; -use App\Utils\Traits\SavesDocuments; -use Illuminate\Support\Facades\Mail; -use App\Factory\CompanyLedgerFactory; -use App\Repositories\ClientRepository; -use App\Repositories\CreditRepository; -use App\Repositories\VendorRepository; -use Illuminate\Queue\SerializesModels; -use Turbo124\Beacon\Facades\LightLogs; -use App\Repositories\CompanyRepository; -use App\Repositories\ProductRepository; -use App\Factory\RecurringInvoiceFactory; -use App\Jobs\Company\CreateCompanyToken; -use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Support\Facades\Validator; -use Modules\Admin\Jobs\Account\NinjaUser; -use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Foundation\Bus\Dispatchable; -use App\DataMapper\ClientRegistrationFields; -use App\Exceptions\MigrationValidatorFailed; -use App\Exceptions\ResourceDependencyMissing; -use App\Repositories\ClientContactRepository; -use App\Repositories\VendorContactRepository; -use App\DataMapper\Analytics\MigrationFailure; +use App\Libraries\MultiDB; use App\Mail\Migration\StripeConnectMigration; -use App\Http\ValidationRules\ValidUserForCompany; -use App\Exceptions\ClientHostedMigrationException; -use App\Http\Requests\Company\UpdateCompanyRequest; -use Illuminate\Queue\Middleware\WithoutOverlapping; -use App\Utils\Traits\CompanyGatewayFeesAndLimitsSaver; +use App\Mail\MigrationCompleted; +use App\Models\Activity; +use App\Models\Client; +use App\Models\ClientContact; +use App\Models\ClientGatewayToken; +use App\Models\Company; +use App\Models\CompanyGateway; +use App\Models\Credit; +use App\Models\Document; +use App\Models\Expense; +use App\Models\ExpenseCategory; +use App\Models\Invoice; +use App\Models\Payment; +use App\Models\PaymentTerm; +use App\Models\Product; +use App\Models\Project; +use App\Models\Quote; +use App\Models\RecurringExpense; +use App\Models\RecurringInvoice; +use App\Models\Task; +use App\Models\TaskStatus; +use App\Models\TaxRate; +use App\Models\User; +use App\Models\Vendor; +use App\Repositories\ClientContactRepository; +use App\Repositories\ClientRepository; +use App\Repositories\CompanyRepository; +use App\Repositories\CreditRepository; use App\Repositories\Migration\InvoiceMigrationRepository; use App\Repositories\Migration\PaymentMigrationRepository; -use App\Http\ValidationRules\ValidCompanyGatewayFeesAndLimitsRule; +use App\Repositories\ProductRepository; +use App\Repositories\UserRepository; +use App\Repositories\VendorContactRepository; +use App\Repositories\VendorRepository; +use App\Utils\Ninja; +use App\Utils\Traits\CleanLineItems; +use App\Utils\Traits\CompanyGatewayFeesAndLimitsSaver; +use App\Utils\Traits\MakesHash; +use App\Utils\Traits\SavesDocuments; +use App\Utils\Traits\Uploadable; +use Exception; +use Illuminate\Bus\Queueable; +use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Http\UploadedFile; +use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Queue\Middleware\WithoutOverlapping; +use Illuminate\Queue\SerializesModels; +use Illuminate\Support\Carbon; +use Illuminate\Support\Facades\App; +use Illuminate\Support\Facades\Mail; +use Illuminate\Support\Facades\Validator; +use Illuminate\Support\Str; +use Turbo124\Beacon\Facades\LightLogs; class Import implements ShouldQueue { @@ -266,8 +262,9 @@ class Import implements ShouldQueue $t = app('translator'); $t->replace(Ninja::transformTranslations($this->company->settings)); - if(!$this->silent_migration) + if(!$this->silent_migration) { Mail::to($this->user->email, $this->user->name())->send(new MigrationCompleted($this->company->id, $this->company->db, implode("
", $check_data))); + } } catch(\Exception $e) { nlog($e->getMessage()); @@ -399,7 +396,7 @@ class Import implements ShouldQueue if (Ninja::isHosted()) { - $data['subdomain'] = str_replace("_","",$data['subdomain']); + $data['subdomain'] = str_replace("_", "", $data['subdomain']); if (!MultiDB::checkDomainAvailable($data['subdomain'])) { $data['subdomain'] = MultiDB::randomSubdomainGenerator(); @@ -1186,8 +1183,7 @@ class Import implements ShouldQueue CreditFactory::create($this->company->id, $modified['user_id']) ); - if($credit->status_id == 4) - { + if($credit->status_id == 4) { $client = $credit->client; $client->balance -= $credit->balance; @@ -1616,8 +1612,9 @@ class Import implements ShouldQueue $nmo->settings = $this->company->settings; $nmo->to_user = $this->user; - if(!$this->silent_migration) + if(!$this->silent_migration) { NinjaMailerJob::dispatch($nmo, true); + } $modified['gateway_key'] = 'd14dd26a47cecc30fdd65700bfb67b34'; } @@ -1824,7 +1821,7 @@ class Import implements ShouldQueue private function processActivities(array $data): void { - Activity::query()->where('company_id', $this->company->id)->cursor()->each(function ($a){ + Activity::query()->where('company_id', $this->company->id)->cursor()->each(function ($a) { $a->forceDelete(); nlog("deleting {$a->id}"); }); @@ -1837,55 +1834,54 @@ class Import implements ShouldQueue $modified['company_id'] = $this->company->id; $modified['user_id'] = $this->processUserId($resource); -try { - if (isset($modified['client_id'])) { - $modified['client_id'] = $this->transformId('clients', $resource['client_id']); - } + try { + if (isset($modified['client_id'])) { + $modified['client_id'] = $this->transformId('clients', $resource['client_id']); + } - if (isset($modified['invoice_id'])) { - $modified['invoice_id'] = $this->transformId('invoices', $resource['invoice_id']); - } + if (isset($modified['invoice_id'])) { + $modified['invoice_id'] = $this->transformId('invoices', $resource['invoice_id']); + } - if (isset($modified['quote_id'])) { - $modified['quote_id'] = $this->transformId('quotes', $resource['quote_id']); - } + if (isset($modified['quote_id'])) { + $modified['quote_id'] = $this->transformId('quotes', $resource['quote_id']); + } - if (isset($modified['recurring_invoice_id'])) { - $modified['recurring_invoice_id'] = $this->transformId('recurring_invoices', $resource['recurring_invoice_id']); - } + if (isset($modified['recurring_invoice_id'])) { + $modified['recurring_invoice_id'] = $this->transformId('recurring_invoices', $resource['recurring_invoice_id']); + } - if (isset($modified['payment_id'])) { - $modified['payment_id'] = $this->transformId('payments', $resource['payment_id']); - } + if (isset($modified['payment_id'])) { + $modified['payment_id'] = $this->transformId('payments', $resource['payment_id']); + } - if (isset($modified['credit_id'])) { - $modified['credit_id'] = $this->transformId('credits', $resource['credit_id']); - } + if (isset($modified['credit_id'])) { + $modified['credit_id'] = $this->transformId('credits', $resource['credit_id']); + } - if (isset($modified['expense_id'])) { - $modified['expense_id'] = $this->transformId('expenses', $resource['expense_id']); - } + if (isset($modified['expense_id'])) { + $modified['expense_id'] = $this->transformId('expenses', $resource['expense_id']); + } - if (isset($modified['task_id'])) { - $modified['task_id'] = $this->transformId('tasks', $resource['task_id']); - } + if (isset($modified['task_id'])) { + $modified['task_id'] = $this->transformId('tasks', $resource['task_id']); + } - if (isset($modified['client_contact_id'])) { - $modified['client_contact_id'] = $this->transformId('client_contacts', $resource['client_contact_id']); - } + if (isset($modified['client_contact_id'])) { + $modified['client_contact_id'] = $this->transformId('client_contacts', $resource['client_contact_id']); + } - $modified['updated_at'] = $modified['created_at']; + $modified['updated_at'] = $modified['created_at']; - /** @var \App\Models\Activity $act **/ - $act = Activity::make($modified); + /** @var \App\Models\Activity $act **/ + $act = Activity::make($modified); - $act->save(['timestamps' => false]); -} -catch (\Exception $e) { + $act->save(['timestamps' => false]); + } catch (\Exception $e) { -nlog("could not import activity: {$e->getMessage()}"); + nlog("could not import activity: {$e->getMessage()}"); -} + } } diff --git a/app/Jobs/Util/ReminderJob.php b/app/Jobs/Util/ReminderJob.php index 6c0521bfe361..6974e5825910 100644 --- a/app/Jobs/Util/ReminderJob.php +++ b/app/Jobs/Util/ReminderJob.php @@ -11,22 +11,22 @@ namespace App\Jobs\Util; -use App\Utils\Ninja; -use App\Models\Invoice; -use App\Libraries\MultiDB; -use Illuminate\Bus\Queueable; -use Illuminate\Support\Carbon; use App\DataMapper\InvoiceItem; use App\Factory\InvoiceFactory; use App\Jobs\Entity\EmailEntity; +use App\Libraries\MultiDB; +use App\Models\Invoice; +use App\Utils\Ninja; use App\Utils\Traits\MakesDates; -use Illuminate\Support\Facades\App; use App\Utils\Traits\MakesReminders; -use Illuminate\Support\Facades\Auth; -use Illuminate\Queue\SerializesModels; -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; +use Illuminate\Support\Carbon; +use Illuminate\Support\Facades\App; +use Illuminate\Support\Facades\Auth; class ReminderJob implements ShouldQueue { @@ -129,8 +129,9 @@ class ReminderJob implements ShouldQueue $invoice->service()->touchReminder($reminder_template)->save(); $fees = $this->calcLateFee($invoice, $reminder_template); - if($invoice->isLocked()) + if($invoice->isLocked()) { return $this->addFeeToNewInvoice($invoice, $reminder_template, $fees); + } $invoice = $this->setLateFee($invoice, $fees[0], $fees[1]); @@ -312,4 +313,4 @@ class ReminderJob implements ShouldQueue return $invoice; } -} \ No newline at end of file +} diff --git a/app/Jobs/Util/StartMigration.php b/app/Jobs/Util/StartMigration.php index 432b1c1b8be4..06d30fbf1877 100644 --- a/app/Jobs/Util/StartMigration.php +++ b/app/Jobs/Util/StartMigration.php @@ -11,27 +11,27 @@ namespace App\Jobs\Util; -use ZipArchive; -use App\Models\User; -use App\Utils\Ninja; -use App\Models\Company; -use App\Libraries\MultiDB; -use App\Mail\MigrationFailed; -use Illuminate\Bus\Queueable; -use Illuminate\Support\Facades\App; -use Illuminate\Support\Facades\Mail; -use Illuminate\Support\Facades\Cache; -use Illuminate\Queue\SerializesModels; -use Illuminate\Support\Facades\Storage; -use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Foundation\Bus\Dispatchable; +use App\Exceptions\ClientHostedMigrationException; use App\Exceptions\MigrationValidatorFailed; use App\Exceptions\NonExistingMigrationFile; -use App\Exceptions\ResourceDependencyMissing; -use App\Exceptions\ClientHostedMigrationException; use App\Exceptions\ProcessingMigrationArchiveFailed; +use App\Exceptions\ResourceDependencyMissing; use App\Exceptions\ResourceNotAvailableForMigration; +use App\Libraries\MultiDB; +use App\Mail\MigrationFailed; +use App\Models\Company; +use App\Models\User; +use App\Utils\Ninja; +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\Cache; +use Illuminate\Support\Facades\Mail; +use Illuminate\Support\Facades\Storage; +use ZipArchive; class StartMigration implements ShouldQueue { @@ -141,8 +141,9 @@ class StartMigration implements ShouldQueue app('sentry')->captureException($e); } - if(!$this->silent_migration) + if(!$this->silent_migration) { Mail::to($this->user->email, $this->user->name())->send(new MigrationFailed($e, $this->company, $e->getMessage())); + } if (Ninja::isHosted()) { $migration_failed = new MigrationFailed($e, $this->company, $e->getMessage()); diff --git a/app/Listeners/Account/StripeConnectFailureListener.php b/app/Listeners/Account/StripeConnectFailureListener.php index 12ff3f94b412..3002acdd9d52 100644 --- a/app/Listeners/Account/StripeConnectFailureListener.php +++ b/app/Listeners/Account/StripeConnectFailureListener.php @@ -11,13 +11,13 @@ namespace App\Listeners\Account; -use App\Utils\Ninja; -use App\Libraries\MultiDB; use App\Jobs\Mail\NinjaMailerJob; use App\Jobs\Mail\NinjaMailerObject; -use Illuminate\Support\Facades\Cache; +use App\Libraries\MultiDB; use App\Mail\Ninja\StripeConnectFailed; +use App\Utils\Ninja; use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Support\Facades\Cache; class StripeConnectFailureListener implements ShouldQueue { @@ -39,8 +39,7 @@ class StripeConnectFailureListener implements ShouldQueue { MultiDB::setDb($event->db); - if (Ninja::isHosted() && is_null(Cache::get("stripe_connect_notification:{$event->company->company_key}"))) - { + if (Ninja::isHosted() && is_null(Cache::get("stripe_connect_notification:{$event->company->company_key}"))) { $nmo = new NinjaMailerObject(); $nmo->mailable = new StripeConnectFailed($event->company->owner(), $event->company); diff --git a/app/Listeners/Activity/PaymentCreatedActivity.php b/app/Listeners/Activity/PaymentCreatedActivity.php index 12ed24c288b4..be114e0a094a 100644 --- a/app/Listeners/Activity/PaymentCreatedActivity.php +++ b/app/Listeners/Activity/PaymentCreatedActivity.php @@ -39,15 +39,16 @@ class PaymentCreatedActivity implements ShouldQueue * @return void */ public function handle($event) - { + { MultiDB::setDb($event->company->db); $payment = $event->payment; $invoice_id = null; - if($payment->invoices()->exists()) + if($payment->invoices()->exists()) { $invoice_id = $payment->invoices()->first()->id; + } $user_id = array_key_exists('user_id', $event->event_vars) ? $event->event_vars['user_id'] : $event->payment->user_id; diff --git a/app/Listeners/Invoice/InvoiceReminderEmailActivity.php b/app/Listeners/Invoice/InvoiceReminderEmailActivity.php index 9b41a3b096b6..9fce655b838b 100644 --- a/app/Listeners/Invoice/InvoiceReminderEmailActivity.php +++ b/app/Listeners/Invoice/InvoiceReminderEmailActivity.php @@ -46,7 +46,7 @@ class InvoiceReminderEmailActivity implements ShouldQueue $user_id = array_key_exists('user_id', $event->event_vars) ? $event->event_vars['user_id'] : $event->invitation->invoice->user_id; - $reminder = match($event->template){ + $reminder = match($event->template) { 'reminder1' => 63, 'reminder2' => 64, 'reminder3' => 65, diff --git a/app/Listeners/Payment/PaymentNotification.php b/app/Listeners/Payment/PaymentNotification.php index f46c228b836e..f9a33e0b3712 100644 --- a/app/Listeners/Payment/PaymentNotification.php +++ b/app/Listeners/Payment/PaymentNotification.php @@ -11,16 +11,16 @@ namespace App\Listeners\Payment; -use App\Utils\Ninja; -use App\Libraries\MultiDB; +use App\DataMapper\Analytics\RevenueTrack; use App\Jobs\Mail\NinjaMailer; use App\Jobs\Mail\NinjaMailerJob; use App\Jobs\Mail\NinjaMailerObject; +use App\Libraries\MultiDB; use App\Mail\Admin\EntityPaidObject; -use Turbo124\Beacon\Facades\LightLogs; -use App\DataMapper\Analytics\RevenueTrack; -use Illuminate\Contracts\Queue\ShouldQueue; +use App\Utils\Ninja; use App\Utils\Traits\Notifications\UserNotifies; +use Illuminate\Contracts\Queue\ShouldQueue; +use Turbo124\Beacon\Facades\LightLogs; class PaymentNotification implements ShouldQueue { @@ -59,7 +59,7 @@ class PaymentNotification implements ShouldQueue } /* Manual Payment Notifications */ - if($payment->is_manual){ + if($payment->is_manual) { foreach ($payment->company->company_users as $company_user) { $user = $company_user->user; @@ -175,7 +175,7 @@ class PaymentNotification implements ShouldQueue * @param string $url */ private function sendAnalytics($url) - { + { $data = mb_convert_encoding($url, 'UTF-8'); // $data = utf8_encode($data); $curl = curl_init(); diff --git a/app/Listeners/User/UpdateUserLastLogin.php b/app/Listeners/User/UpdateUserLastLogin.php index 94e20512eefc..c1eec95de915 100644 --- a/app/Listeners/User/UpdateUserLastLogin.php +++ b/app/Listeners/User/UpdateUserLastLogin.php @@ -11,17 +11,17 @@ namespace App\Listeners\User; -use App\Models\SystemLog; -use App\Libraries\MultiDB; -use App\Jobs\Util\SystemLogger; -use App\Mail\User\UserLoggedIn; use App\Jobs\Mail\NinjaMailerJob; use App\Jobs\Mail\NinjaMailerObject; -use Illuminate\Support\Facades\Cache; -use Illuminate\Queue\SerializesModels; +use App\Jobs\Util\SystemLogger; +use App\Libraries\MultiDB; +use App\Mail\User\UserLoggedIn; +use App\Models\SystemLog; +use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Events\Dispatchable; -use Illuminate\Broadcasting\InteractsWithSockets; +use Illuminate\Queue\SerializesModels; +use Illuminate\Support\Facades\Cache; class UpdateUserLastLogin implements ShouldQueue { diff --git a/app/Listeners/Vendor/UpdateVendorContactLastLogin.php b/app/Listeners/Vendor/UpdateVendorContactLastLogin.php index 272b7144b1f7..d583a2fb8c31 100644 --- a/app/Listeners/Vendor/UpdateVendorContactLastLogin.php +++ b/app/Listeners/Vendor/UpdateVendorContactLastLogin.php @@ -12,9 +12,8 @@ namespace App\Listeners\Vendor; use App\Libraries\MultiDB; -use Illuminate\Contracts\Queue\ShouldQueue; -class UpdateVendorContactLastLogin +class UpdateVendorContactLastLogin { /** * Create the event listener. diff --git a/app/Mail/Admin/AccountCreatedObject.php b/app/Mail/Admin/AccountCreatedObject.php index 2b18adf01644..9ce319658075 100644 --- a/app/Mail/Admin/AccountCreatedObject.php +++ b/app/Mail/Admin/AccountCreatedObject.php @@ -11,9 +11,9 @@ namespace App\Mail\Admin; +use App\Models\Company; use App\Models\User; use App\Utils\Ninja; -use App\Models\Company; use Illuminate\Support\Facades\App; class AccountCreatedObject diff --git a/app/Mail/Admin/AutoBillingFailureObject.php b/app/Mail/Admin/AutoBillingFailureObject.php index a937aecf25b9..01a1f2823bd0 100644 --- a/app/Mail/Admin/AutoBillingFailureObject.php +++ b/app/Mail/Admin/AutoBillingFailureObject.php @@ -17,6 +17,7 @@ use App\Utils\Ninja; use App\Utils\Traits\MakesHash; use Illuminate\Support\Facades\App; use stdClass; + //@deprecated class AutoBillingFailureObject { diff --git a/app/Mail/Engine/CreditEmailEngine.php b/app/Mail/Engine/CreditEmailEngine.php index 75b34299da67..e927fe287ecf 100644 --- a/app/Mail/Engine/CreditEmailEngine.php +++ b/app/Mail/Engine/CreditEmailEngine.php @@ -123,7 +123,7 @@ class CreditEmailEngine extends BaseEmailEngine //attach third party documents if ($this->client->getSetting('document_email_attachment') !== false && $this->credit->company->account->hasFeature(Account::FEATURE_DOCUMENTS)) { // Storage::url - $this->credit->documents()->where('is_public',true)->cursor()->each(function($document) { + $this->credit->documents()->where('is_public', true)->cursor()->each(function ($document) { if ($document->size > $this->max_attachment_size) { $this->setAttachmentLinks([" $document->hash]) ."'>". $document->name .""]); } else { @@ -131,7 +131,7 @@ class CreditEmailEngine extends BaseEmailEngine } }); - $this->credit->company->documents()->where('is_public',true)->cursor()->each(function($document) { + $this->credit->company->documents()->where('is_public', true)->cursor()->each(function ($document) { if ($document->size > $this->max_attachment_size) { $this->setAttachmentLinks([" $document->hash]) ."'>". $document->name .""]); } else { diff --git a/app/Mail/Engine/InvoiceEmailEngine.php b/app/Mail/Engine/InvoiceEmailEngine.php index 42ca22ac65f0..ac7cad34263f 100644 --- a/app/Mail/Engine/InvoiceEmailEngine.php +++ b/app/Mail/Engine/InvoiceEmailEngine.php @@ -135,7 +135,7 @@ class InvoiceEmailEngine extends BaseEmailEngine //attach third party documents if ($this->client->getSetting('document_email_attachment') !== false && $this->invoice->company->account->hasFeature(Account::FEATURE_DOCUMENTS)) { if ($this->invoice->recurring_invoice()->exists()) { - $this->invoice->recurring_invoice->documents()->where('is_public',true)->cursor()->each(function ($document) { + $this->invoice->recurring_invoice->documents()->where('is_public', true)->cursor()->each(function ($document) { if ($document->size > $this->max_attachment_size) { $this->setAttachmentLinks([" $document->hash]) ."'>". $document->name .""]); } else { @@ -145,7 +145,7 @@ class InvoiceEmailEngine extends BaseEmailEngine } // Storage::url - $this->invoice->documents()->where('is_public',true)->cursor()->each(function ($document) { + $this->invoice->documents()->where('is_public', true)->cursor()->each(function ($document) { if ($document->size > $this->max_attachment_size) { $this->setAttachmentLinks([" $document->hash]) ."'>". $document->name .""]); } else { @@ -153,7 +153,7 @@ class InvoiceEmailEngine extends BaseEmailEngine } }); - $this->invoice->company->documents()->where('is_public',true)->cursor()->each(function ($document) { + $this->invoice->company->documents()->where('is_public', true)->cursor()->each(function ($document) { if ($document->size > $this->max_attachment_size) { $this->setAttachmentLinks([" $document->hash]) ."'>". $document->name .""]); } else { @@ -175,7 +175,7 @@ class InvoiceEmailEngine extends BaseEmailEngine ->where('invoice_documents', 1) ->cursor() ->each(function ($expense) { - $expense->documents()->where('is_public',true)->cursor()->each(function ($document) { + $expense->documents()->where('is_public', true)->cursor()->each(function ($document) { if ($document->size > $this->max_attachment_size) { $this->setAttachmentLinks([" $document->hash]) ."'>". $document->name .""]); } else { diff --git a/app/Mail/Engine/PaymentEmailEngine.php b/app/Mail/Engine/PaymentEmailEngine.php index a3f303f714d9..39f3fe9afc72 100644 --- a/app/Mail/Engine/PaymentEmailEngine.php +++ b/app/Mail/Engine/PaymentEmailEngine.php @@ -11,18 +11,17 @@ namespace App\Mail\Engine; -use App\Utils\Ninja; -use App\Utils\Number; -use App\Utils\Helpers; +use App\DataMapper\EmailTemplateDefaults; +use App\Jobs\Entity\CreateRawPdf; use App\Models\Account; use App\Models\Payment; +use App\Services\Template\TemplateAction; +use App\Utils\Helpers; +use App\Utils\Ninja; +use App\Utils\Number; use App\Utils\Traits\MakesDates; -use App\Jobs\Entity\CreateRawPdf; use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\URL; -use Illuminate\Support\Facades\Storage; -use App\DataMapper\EmailTemplateDefaults; -use App\Services\Template\TemplateAction; class PaymentEmailEngine extends BaseEmailEngine { @@ -134,10 +133,9 @@ class PaymentEmailEngine extends BaseEmailEngine } - $this->payment->invoices->each(function ($invoice) use($template_in_use){ + $this->payment->invoices->each(function ($invoice) use ($template_in_use) { - if(!$template_in_use) - { + if(!$template_in_use) { $pdf = ((new CreateRawPdf($invoice->invitations->first()))->handle()); $file_name = $invoice->numberFormatter().'.pdf'; $this->setAttachments([['file' => base64_encode($pdf), 'name' => $file_name]]); @@ -145,7 +143,7 @@ class PaymentEmailEngine extends BaseEmailEngine //attach invoice documents also to payments if ($this->client->getSetting('document_email_attachment') !== false) { - $invoice->documents()->where('is_public', true)->cursor()->each(function ($document){ + $invoice->documents()->where('is_public', true)->cursor()->each(function ($document) { if ($document->size > $this->max_attachment_size) { $this->setAttachmentLinks([" $document->hash]) ."'>". $document->name .""]); } else { @@ -398,7 +396,7 @@ class PaymentEmailEngine extends BaseEmailEngine private function formatInvoiceReferencesSubject() { - $invoice_list = ''; + $invoice_list = ''; foreach ($this->payment->invoices as $invoice) { if (strlen($invoice->po_number) > 1) { @@ -409,8 +407,8 @@ class PaymentEmailEngine extends BaseEmailEngine } - if(strlen($invoice_list) < 4){ - $invoice_list = Number::formatMoney($this->payment->amount, $this->client) ?: ' '; + if(strlen($invoice_list) < 4) { + $invoice_list = Number::formatMoney($this->payment->amount, $this->client) ?: ' '; } @@ -418,7 +416,8 @@ class PaymentEmailEngine extends BaseEmailEngine } - private function formatInvoiceNumbersRaw(){ + private function formatInvoiceNumbersRaw() + { return collect($this->payment->invoices->pluck('number')->toArray())->implode(', '); diff --git a/app/Mail/Ninja/StripeConnectFailed.php b/app/Mail/Ninja/StripeConnectFailed.php index 4c935cdf291f..1e11c0430606 100644 --- a/app/Mail/Ninja/StripeConnectFailed.php +++ b/app/Mail/Ninja/StripeConnectFailed.php @@ -11,12 +11,12 @@ namespace App\Mail\Ninja; -use App\Models\User; use App\Models\Company; +use App\Models\User; use Illuminate\Mail\Mailable; use Illuminate\Mail\Mailables\Content; -use Illuminate\Mail\Mailables\Headers; use Illuminate\Mail\Mailables\Envelope; +use Illuminate\Mail\Mailables\Headers; class StripeConnectFailed extends Mailable { diff --git a/app/Mail/RecurringInvoice/ClientContactRequestCancellationObject.php b/app/Mail/RecurringInvoice/ClientContactRequestCancellationObject.php index ab1011b08b9f..debd00b9d611 100644 --- a/app/Mail/RecurringInvoice/ClientContactRequestCancellationObject.php +++ b/app/Mail/RecurringInvoice/ClientContactRequestCancellationObject.php @@ -11,10 +11,10 @@ namespace App\Mail\RecurringInvoice; -use App\Utils\Ninja; -use App\Models\Company; use App\Models\ClientContact; +use App\Models\Company; use App\Models\RecurringInvoice; +use App\Utils\Ninja; use Illuminate\Support\Facades\App; class ClientContactRequestCancellationObject diff --git a/app/Mail/TestMailServer.php b/app/Mail/TestMailServer.php index 917a1fa9f039..1dd8ff783f5e 100644 --- a/app/Mail/TestMailServer.php +++ b/app/Mail/TestMailServer.php @@ -11,9 +11,7 @@ namespace App\Mail; -use Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; -use Illuminate\Queue\SerializesModels; class TestMailServer extends Mailable { diff --git a/app/Mail/VendorTemplateEmail.php b/app/Mail/VendorTemplateEmail.php index bdfb818b0091..f51ea3f74c88 100644 --- a/app/Mail/VendorTemplateEmail.php +++ b/app/Mail/VendorTemplateEmail.php @@ -11,11 +11,11 @@ namespace App\Mail; -use App\Utils\Ninja; use App\Models\VendorContact; -use Illuminate\Mail\Mailable; -use App\Utils\VendorHtmlEngine; use App\Services\PdfMaker\Designs\Utilities\DesignHelpers; +use App\Utils\Ninja; +use App\Utils\VendorHtmlEngine; +use Illuminate\Mail\Mailable; class VendorTemplateEmail extends Mailable { diff --git a/app/Models/Account.php b/app/Models/Account.php index d0f7feaefd41..8bc8039a0ea0 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -86,7 +86,7 @@ use Laracasts\Presenter\PresentableTrait; * @method static \Illuminate\Database\Eloquent\Builder|BaseModel scope() * @method static \Illuminate\Database\Eloquent\Builder|Account first() * @method static \Illuminate\Database\Eloquent\Builder|Account with() - * @method static \Illuminate\Database\Eloquent\Builder|Account count() + * @method static \Illuminate\Database\Eloquent\Builder|Account count() * @method static \Illuminate\Database\Eloquent\Builder|Account where($query) * @property-read \Illuminate\Database\Eloquent\Collection $bank_integrations * @property-read \Illuminate\Database\Eloquent\Collection $companies @@ -270,7 +270,7 @@ class Account extends BaseModel case self::FEATURE_REMOVE_CREATED_BY: return ! empty($plan_details); // A plan is required even for self-hosted users - // Enterprise; No Trial allowed; grandfathered for old pro users + // Enterprise; No Trial allowed; grandfathered for old pro users case self::FEATURE_USERS:// Grandfathered for old Pro users if ($plan_details && $plan_details['trial']) { // Do they have a non-trial plan? @@ -584,8 +584,9 @@ class Account extends BaseModel if ($plan_expires->gt(now())) { $diff = $plan_expires->diffInDays(); - if ($diff > 14) + if ($diff > 14) { return 0; + } return $diff; } diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 1b9d89ce59d7..772c234e695a 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -13,7 +13,6 @@ namespace App\Models; use App\Utils\Number; use App\Utils\Traits\MakesHash; -use Illuminate\Database\Eloquent\Relations\BelongsTo; /** * App\Models\Activity @@ -399,25 +398,29 @@ class Activity extends StaticModel ':balance', ':number', ':payment_amount', - ':gateway', - ':adjustment' + ':gateway', + ':adjustment' ]; - $found_variables = array_intersect(explode(" ",trans("texts.activity_{$this->activity_type_id}")), $intersect); + $found_variables = array_intersect(explode(" ", trans("texts.activity_{$this->activity_type_id}")), $intersect); $replacements = []; - foreach($found_variables as $var) + foreach($found_variables as $var) { $replacements = array_merge($replacements, $this->matchVar($var)); + } - if($this->client) + if($this->client) { $replacements['client'] = ['label' => $this?->client?->present()->name() ?? '', 'hashed_id' => $this->client->hashed_id ?? '']; + } - if($this->vendor) + if($this->vendor) { $replacements['vendor'] = ['label' => $this?->vendor?->present()->name() ?? '', 'hashed_id' => $this->vendor->hashed_id ?? '']; + } - if($this->activity_type_id == 4 && $this->recurring_invoice) + if($this->activity_type_id == 4 && $this->recurring_invoice) { $replacements['recurring_invoice'] = ['label' => $this?->recurring_invoice?->number ?? '', 'hashed_id' => $this->recurring_invoice->hashed_id ?? '']; + } $replacements['activity_type_id'] = $this->activity_type_id; $replacements['id'] = $this->id; @@ -449,7 +452,7 @@ class Activity extends StaticModel ':recurring_invoice' => $translation = [substr($variable, 1) =>[ 'label' => $this?->recurring_invoice?->number ??'', 'hashed_id' => $this->recurring_invoice->hashed_id ?? '']], ':recurring_expense' => $translation = [substr($variable, 1) => [ 'label' => $this?->recurring_expense?->number ??'', 'hashed_id' => $this->recurring_expense->hashed_id ?? '']], ':payment_amount' => $translation = [substr($variable, 1) =>[ 'label' => Number::formatMoney($this?->payment?->amount, $this?->payment?->client) ?? '', 'hashed_id' => '']], - ':adjustment' => $translation = [substr($variable, 1) =>[ 'label' => Number::formatMoney($this?->payment?->refunded, $this?->payment?->client) ?? '', 'hashed_id' => '']], + ':adjustment' => $translation = [substr($variable, 1) =>[ 'label' => Number::formatMoney($this?->payment?->refunded, $this?->payment?->client) ?? '', 'hashed_id' => '']], ':ip' => $translation = [ 'ip' => $this->ip ?? ''], ':contact' => $translation = $this->resolveContact(), default => $translation = [], diff --git a/app/Models/BankTransaction.php b/app/Models/BankTransaction.php index 3139ae436d4a..c3a7321e5c50 100644 --- a/app/Models/BankTransaction.php +++ b/app/Models/BankTransaction.php @@ -11,9 +11,8 @@ namespace App\Models; -use App\Models\Expense; -use App\Utils\Traits\MakesHash; use App\Services\Bank\BankService; +use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\SoftDeletes; /** diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index c8e4eb6a0356..976584842f14 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -11,17 +11,17 @@ namespace App\Models; -use Illuminate\Support\Str; -use Illuminate\Support\Carbon; -use App\Utils\Traits\MakesHash; use App\Jobs\Entity\CreateRawPdf; use App\Jobs\Util\WebhookHandler; -use App\Models\Traits\Excludable; -use Illuminate\Database\Eloquent\Model; use App\Jobs\Vendor\CreatePurchaseOrderPdf; +use App\Models\Traits\Excludable; +use App\Utils\Traits\MakesHash; use App\Utils\Traits\UserSessionAttributes; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundException; +use Illuminate\Support\Carbon; +use Illuminate\Support\Str; /** * Class BaseModel @@ -37,7 +37,7 @@ use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundExceptio * @property int $assigned_user_id * @method BaseModel service() * @property \App\Models\Company $company - * @method static BaseModel find($value) + * @method static BaseModel find($value) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel company() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel|Illuminate\Database\Eloquent\Relations\BelongsTo|\Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo|\App\Models\Company company() * @method static \Illuminate\Database\Eloquent\Builder|BaseModel|Illuminate\Database\Eloquent\Relations\HasMany|BaseModel orderBy() @@ -68,7 +68,7 @@ use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundExceptio * @method static \Illuminate\Database\Eloquent\Builder|BaseModel|\Illuminate\Database\Query\Builder withoutTrashed() * @mixin \Eloquent * @mixin \Illuminate\Database\Eloquent\Builder - * + * * @property \Illuminate\Support\Collection $tax_map * @property array $total_tax_map */ @@ -237,10 +237,10 @@ class BaseModel extends Model return $this->numberFormatter().'.'.$extension; } - /** - * @param string $extension - * @return string - */ + /** + * @param string $extension + * @return string + */ public function getEFileName($extension = 'pdf') { return ctrans("texts.e_invoice"). "_" . $this->numberFormatter().'.'.$extension; @@ -303,8 +303,9 @@ class BaseModel extends Model throw new \Exception('Hard fail, could not create an invitation.'); } - if($this instanceof \App\Models\PurchaseOrder) + if($this instanceof \App\Models\PurchaseOrder) { return "data:application/pdf;base64,".base64_encode((new CreatePurchaseOrderPdf($invitation, $invitation->company->db))->rawPdf()); + } return "data:application/pdf;base64,".base64_encode((new CreateRawPdf($invitation))->handle()); diff --git a/app/Models/Client.php b/app/Models/Client.php index a056a103493f..689578df8385 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -11,26 +11,24 @@ namespace App\Models; -use App\Models\GatewayType; -use App\Utils\Traits\AppSetup; -use App\Utils\Traits\MakesHash; -use App\Utils\Traits\MakesDates; -use App\DataMapper\FeesAndLimits; -use App\Models\Traits\Excludable; use App\DataMapper\ClientSettings; use App\DataMapper\CompanySettings; -use Illuminate\Support\Facades\Cache; -use App\Services\Client\ClientService; -use App\Utils\Traits\GeneratesCounter; -use Laracasts\Presenter\PresentableTrait; -use App\Models\Presenters\ClientPresenter; -use Illuminate\Database\Eloquent\SoftDeletes; -use App\Utils\Traits\ClientGroupSettingsSaver; +use App\DataMapper\FeesAndLimits; use App\Libraries\Currency\Conversion\CurrencyApi; -use Illuminate\Database\Eloquent\Relations\HasMany; -use Illuminate\Database\Eloquent\Relations\BelongsTo; -use Illuminate\Database\Eloquent\Relations\MorphMany; +use App\Models\Presenters\ClientPresenter; +use App\Models\Traits\Excludable; +use App\Services\Client\ClientService; +use App\Utils\Traits\AppSetup; +use App\Utils\Traits\ClientGroupSettingsSaver; +use App\Utils\Traits\GeneratesCounter; +use App\Utils\Traits\MakesDates; +use App\Utils\Traits\MakesHash; use Illuminate\Contracts\Translation\HasLocalePreference; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Support\Facades\Cache; +use Laracasts\Presenter\PresentableTrait; /** * App\Models\Client @@ -474,9 +472,9 @@ class Client extends BaseModel implements HasLocalePreference return $this->settings->{$setting}; } elseif (is_bool($this->settings->{$setting})) { return $this->settings->{$setting}; - } elseif (is_int($this->settings->{$setting})) { + } elseif (is_int($this->settings->{$setting})) { return $this->settings->{$setting}; - } elseif(is_float($this->settings->{$setting})) { + } elseif(is_float($this->settings->{$setting})) { return $this->settings->{$setting}; } } @@ -768,7 +766,7 @@ class Client extends BaseModel implements HasLocalePreference return $defaults; } - public function timezone_offset() :int + public function timezone_offset() :int { $offset = 0; diff --git a/app/Models/Company.php b/app/Models/Company.php index 8d097d3b8baa..1815c6dd1e0c 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -11,20 +11,20 @@ namespace App\Models; -use App\Utils\Ninja; use App\Casts\EncryptedCast; -use App\Utils\Traits\AppSetup; -use App\Utils\Traits\MakesHash; use App\DataMapper\CompanySettings; +use App\Models\Presenters\CompanyPresenter; +use App\Services\Notification\NotificationService; +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; -use App\Utils\Traits\CompanySettingsSaver; -use Illuminate\Notifications\Notification; -use App\Models\Presenters\CompanyPresenter; -use App\Services\Notification\NotificationService; -use Illuminate\Database\Eloquent\Relations\HasMany; -use Illuminate\Database\Eloquent\Relations\BelongsTo; /** * App\Models\Company @@ -621,7 +621,7 @@ class Company extends BaseModel return $item->id == $this->getSetting('country_id'); })->first(); -// return $this->belongsTo(Country::class); + // return $this->belongsTo(Country::class); // return Country::find($this->settings->country_id); } @@ -838,7 +838,7 @@ class Company extends BaseModel ->firstOrFail(); } - public function domain(): string + public function domain(): string { if (Ninja::isHosted()) { if ($this->portal_mode == 'domain' && strlen($this->portal_domain) > 3) { @@ -945,8 +945,9 @@ class Company extends BaseModel public function getInvoiceCert() { - if($this->e_invoice_certificate) + if($this->e_invoice_certificate) { return base64_decode($this->e_invoice_certificate); + } return false; } diff --git a/app/Models/CompanyGateway.php b/app/Models/CompanyGateway.php index 8525a88eb80e..ccb25724ef9f 100644 --- a/app/Models/CompanyGateway.php +++ b/app/Models/CompanyGateway.php @@ -62,7 +62,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static \Illuminate\Database\Eloquent\Builder|CompanyGateway withTrashed() * @method static \Illuminate\Database\Eloquent\Builder|CompanyGateway withoutTrashed() * @property-read \Illuminate\Database\Eloquent\Collection $client_gateway_tokens - * @method static CompanyGateway find($value) + * @method static CompanyGateway find($value) * @mixin \Eloquent */ class CompanyGateway extends BaseModel diff --git a/app/Models/CompanyUser.php b/app/Models/CompanyUser.php index 347365a63ddb..dd022aad5930 100644 --- a/app/Models/CompanyUser.php +++ b/app/Models/CompanyUser.php @@ -11,10 +11,9 @@ namespace App\Models; -use Illuminate\Database\Eloquent\SoftDeletes; -use Illuminate\Database\Eloquent\Relations\Pivot; -use Awobaz\Compoships\Exceptions\InvalidUsageException; use Awobaz\Compoships\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\Pivot; +use Illuminate\Database\Eloquent\SoftDeletes; /** * App\Models\CompanyUser @@ -149,7 +148,7 @@ class CompanyUser extends Pivot /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ - public function user() + public function user() { return $this->belongsTo(User::class)->withTrashed(); } @@ -179,7 +178,7 @@ class CompanyUser extends Pivot } /** - * @return HasMany + * @return HasMany */ public function tokens() { @@ -206,4 +205,4 @@ class CompanyUser extends Pivot return isset($this->react_settings->react_notification_link) && $this->react_settings->react_notification_link; } -} \ No newline at end of file +} diff --git a/app/Models/Country.php b/app/Models/Country.php index 97efa4375f6e..6b3f2f2f5bf8 100644 --- a/app/Models/Country.php +++ b/app/Models/Country.php @@ -81,8 +81,8 @@ class Country extends StaticModel { return trans('texts.country_'.$this->name); } - public function getID() :string - { - return $this->id; - } + public function getID() :string + { + return $this->id; + } } diff --git a/app/Models/Credit.php b/app/Models/Credit.php index 6ba2d7b18b53..d55a729c27cd 100644 --- a/app/Models/Credit.php +++ b/app/Models/Credit.php @@ -11,20 +11,18 @@ namespace App\Models; -use App\Utils\Ninja; -use Illuminate\Support\Carbon; -use App\Utils\Traits\MakesHash; -use App\Utils\Traits\MakesDates; use App\Helpers\Invoice\InvoiceSum; -use App\Utils\Traits\MakesReminders; +use App\Helpers\Invoice\InvoiceSumInclusive; +use App\Models\Presenters\CreditPresenter; use App\Services\Credit\CreditService; use App\Services\Ledger\LedgerService; -use Illuminate\Support\Facades\Storage; +use App\Utils\Traits\MakesDates; +use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesInvoiceValues; -use Laracasts\Presenter\PresentableTrait; -use App\Models\Presenters\CreditPresenter; -use App\Helpers\Invoice\InvoiceSumInclusive; +use App\Utils\Traits\MakesReminders; use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Support\Carbon; +use Laracasts\Presenter\PresentableTrait; /** * App\Models\Credit @@ -122,7 +120,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property-read \Illuminate\Database\Eloquent\Collection $invitations * @property-read \Illuminate\Database\Eloquent\Collection $invoices * @property-read \Illuminate\Database\Eloquent\Collection $payments - * + * * @mixin \Eloquent */ class Credit extends BaseModel diff --git a/app/Models/Expense.php b/app/Models/Expense.php index 314e3961eb66..fa7078a8418a 100644 --- a/app/Models/Expense.php +++ b/app/Models/Expense.php @@ -225,16 +225,17 @@ class Expense extends BaseModel public function stringStatus() { - if($this->is_deleted) + if($this->is_deleted) { return ctrans('texts.deleted'); - elseif($this->payment_date) - return ctrans('texts.paid'); - elseif($this->invoice_id) + } elseif($this->payment_date) { + return ctrans('texts.paid'); + } elseif($this->invoice_id) { return ctrans('texts.invoiced'); - elseif($this->should_be_invoiced) + } elseif($this->should_be_invoiced) { return ctrans('texts.pending'); - elseif($this->trashed()) + } elseif($this->trashed()) { return ctrans('texts.archived'); + } return ctrans('texts.logged'); } diff --git a/app/Models/GatewayType.php b/app/Models/GatewayType.php index bc207c4955ac..bcce2d84d424 100644 --- a/app/Models/GatewayType.php +++ b/app/Models/GatewayType.php @@ -163,4 +163,3 @@ class GatewayType extends StaticModel } } } - diff --git a/app/Models/GroupSetting.php b/app/Models/GroupSetting.php index 1a8bd5f093f5..190721c64a2a 100644 --- a/app/Models/GroupSetting.php +++ b/app/Models/GroupSetting.php @@ -11,11 +11,10 @@ namespace App\Models; -use App\Models\Filterable; use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundException; +use Illuminate\Database\Eloquent\SoftDeletes; /** * App\Models\GroupSetting diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 928b49525c58..2d9a5babc397 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -11,23 +11,22 @@ namespace App\Models; -use App\Utils\Ninja; -use Illuminate\Support\Carbon; -use App\Utils\Traits\MakesDates; +use App\Events\Invoice\InvoiceReminderWasEmailed; +use App\Events\Invoice\InvoiceWasEmailed; use App\Helpers\Invoice\InvoiceSum; +use App\Helpers\Invoice\InvoiceSumInclusive; +use App\Models\Presenters\EntityPresenter; +use App\Services\Invoice\InvoiceService; +use App\Services\Ledger\LedgerService; +use App\Utils\Ninja; +use App\Utils\Traits\Invoice\ActionsInvoice; +use App\Utils\Traits\MakesDates; +use App\Utils\Traits\MakesInvoiceValues; use App\Utils\Traits\MakesReminders; use App\Utils\Traits\NumberFormatter; -use App\Services\Ledger\LedgerService; -use Illuminate\Support\Facades\Storage; -use App\Services\Invoice\InvoiceService; -use App\Utils\Traits\MakesInvoiceValues; -use App\Events\Invoice\InvoiceWasEmailed; -use Laracasts\Presenter\PresentableTrait; -use App\Models\Presenters\EntityPresenter; -use App\Helpers\Invoice\InvoiceSumInclusive; -use App\Utils\Traits\Invoice\ActionsInvoice; use Illuminate\Database\Eloquent\SoftDeletes; -use App\Events\Invoice\InvoiceReminderWasEmailed; +use Illuminate\Support\Carbon; +use Laracasts\Presenter\PresentableTrait; /** * App\Models\Invoice @@ -320,7 +319,7 @@ class Invoice extends BaseModel */ public function net_payments(): \Illuminate\Database\Eloquent\Relations\MorphToMany { - return $this->morphToMany(Payment::class, 'paymentable')->withTrashed()->where('is_deleted',0)->withPivot('amount', 'refunded', 'deleted_at')->withTimestamps(); + return $this->morphToMany(Payment::class, 'paymentable')->withTrashed()->where('is_deleted', 0)->withPivot('amount', 'refunded', 'deleted_at')->withTimestamps(); } /** @@ -677,7 +676,7 @@ class Invoice extends BaseModel { $tax_type = ''; - match(intval($id)){ + match(intval($id)) { Product::PRODUCT_TYPE_PHYSICAL => $tax_type = ctrans('texts.physical_goods'), Product::PRODUCT_TYPE_SERVICE => $tax_type = ctrans('texts.services'), Product::PRODUCT_TYPE_DIGITAL => $tax_type = ctrans('texts.digital_products'), @@ -728,7 +727,7 @@ class Invoice extends BaseModel $schedule_2 = ctrans("texts.{$settings->schedule_reminder2}"); //after due date etc or disabled $label_2 = ctrans('texts.reminder2'); - $sends_email_3 = $settings->enable_reminder2 ? $send_email_enabled : $send_email_disabled; + $sends_email_3 = $settings->enable_reminder2 ? $send_email_enabled : $send_email_disabled; $days_3 = $settings->num_days_reminder3 . " " . ctrans('texts.days'); $schedule_3 = ctrans("texts.{$settings->schedule_reminder3}"); //after due date etc or disabled $label_3 = ctrans('texts.reminder3'); @@ -737,25 +736,29 @@ class Invoice extends BaseModel $days_endless = \App\Models\RecurringInvoice::frequencyForKey($settings->endless_reminder_frequency_id); $label_endless = ctrans('texts.reminder_endless'); - if($schedule_1 == ctrans('texts.disabled') || $settings->schedule_reminder1 == 'disabled' || $settings->schedule_reminder1 == '') + if($schedule_1 == ctrans('texts.disabled') || $settings->schedule_reminder1 == 'disabled' || $settings->schedule_reminder1 == '') { $reminder_schedule .= "{$label_1}: " . ctrans('texts.disabled') ."
"; - else + } else { $reminder_schedule .= "{$label_1}: {$days_1} {$schedule_1} [{$sends_email_1}]
"; + } - if($schedule_2 == ctrans('texts.disabled') || $settings->schedule_reminder2 == 'disabled' || $settings->schedule_reminder2 == '') + if($schedule_2 == ctrans('texts.disabled') || $settings->schedule_reminder2 == 'disabled' || $settings->schedule_reminder2 == '') { $reminder_schedule .= "{$label_2}: " . ctrans('texts.disabled') ."
"; - else + } else { $reminder_schedule .= "{$label_2}: {$days_2} {$schedule_2} [{$sends_email_2}]
"; + } - if($schedule_3 == ctrans('texts.disabled') || $settings->schedule_reminder3 == 'disabled' || $settings->schedule_reminder3 == '') + if($schedule_3 == ctrans('texts.disabled') || $settings->schedule_reminder3 == 'disabled' || $settings->schedule_reminder3 == '') { $reminder_schedule .= "{$label_3}: " . ctrans('texts.disabled') ."
"; - else + } else { $reminder_schedule .= "{$label_3}: {$days_3} {$schedule_3} [{$sends_email_3}]
"; + } - if($sends_email_endless == ctrans('texts.disabled') || $settings->endless_reminder_frequency_id == '0' || $settings->endless_reminder_frequency_id == '') + if($sends_email_endless == ctrans('texts.disabled') || $settings->endless_reminder_frequency_id == '0' || $settings->endless_reminder_frequency_id == '') { $reminder_schedule .= "{$label_endless}: " . ctrans('texts.disabled') ."
"; - else + } else { $reminder_schedule .= "{$label_endless}: {$days_endless} [{$sends_email_endless}]
"; + } return $reminder_schedule; diff --git a/app/Models/InvoiceInvitation.php b/app/Models/InvoiceInvitation.php index eff3ab15915f..2f5c6c08a1df 100644 --- a/app/Models/InvoiceInvitation.php +++ b/app/Models/InvoiceInvitation.php @@ -11,13 +11,10 @@ namespace App\Models; -use App\Events\Invoice\InvoiceWasUpdated; -use App\Utils\Ninja; use App\Utils\Traits\Inviteable; use App\Utils\Traits\MakesDates; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Carbon; -use Illuminate\Support\Facades\Storage; /** * App\Models\InvoiceInvitation diff --git a/app/Models/Payment.php b/app/Models/Payment.php index 41e36c74bbf2..1f80aaed0a91 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -15,13 +15,12 @@ use App\Events\Payment\PaymentWasRefunded; use App\Events\Payment\PaymentWasVoided; use App\Services\Ledger\LedgerService; use App\Services\Payment\PaymentService; -use App\Utils\Ninja; +use App\Utils\Ninja; use App\Utils\Number; use App\Utils\Traits\Inviteable; use App\Utils\Traits\MakesDates; use App\Utils\Traits\MakesHash; use App\Utils\Traits\Payment\Refundable; -use Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; /** diff --git a/app/Models/PaymentHash.php b/app/Models/PaymentHash.php index a870489ce02f..ded9e912f38c 100644 --- a/app/Models/PaymentHash.php +++ b/app/Models/PaymentHash.php @@ -38,13 +38,13 @@ class PaymentHash extends Model 'data' => 'object', ]; - /** - * @class \App\Models\PaymentHash $this - * @property \App\Models\PaymentHash $data - * @property \App\Modes\PaymentHash $hash 32 char length AlphaNum - * @class \stdClass $data - * @property string $raw_value - */ + /** + * @class \App\Models\PaymentHash $this + * @property \App\Models\PaymentHash $data + * @property \App\Modes\PaymentHash $hash 32 char length AlphaNum + * @class \stdClass $data + * @property string $raw_value + */ /** diff --git a/app/Models/Presenters/EntityPresenter.php b/app/Models/Presenters/EntityPresenter.php index 01cfbc3063ea..8176df996596 100644 --- a/app/Models/Presenters/EntityPresenter.php +++ b/app/Models/Presenters/EntityPresenter.php @@ -16,7 +16,7 @@ use Laracasts\Presenter\Presenter; /** * Class EntityPresenter. - * + * * @property \App\Models\Company | \App\Models\Client | \App\Models\ClientContact | \App\Models\Vendor | \App\Models\VendorContact $entity * @property \App\Models\Client $client * @property \App\Models\Company $company diff --git a/app/Models/Presenters/InvoicePresenter.php b/app/Models/Presenters/InvoicePresenter.php index d2d806f976c1..f9125a6786b2 100644 --- a/app/Models/Presenters/InvoicePresenter.php +++ b/app/Models/Presenters/InvoicePresenter.php @@ -23,7 +23,7 @@ use App\Utils\Traits\MakesDates; * * Shortcuts to other presenters are here to facilitate * a clean UI / UX - * + * * @property \App\Models\Invoice $entity */ class InvoicePresenter extends EntityPresenter diff --git a/app/Models/Presenters/UserPresenter.php b/app/Models/Presenters/UserPresenter.php index 68c5722581c6..10677add63b0 100644 --- a/app/Models/Presenters/UserPresenter.php +++ b/app/Models/Presenters/UserPresenter.php @@ -18,7 +18,7 @@ class UserPresenter extends EntityPresenter { /** * Returns the first and last names concatenated. - * + * * @return string */ public function name(): string diff --git a/app/Models/Project.php b/app/Models/Project.php index a256b3e74fac..be9784d0a83a 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -2,7 +2,6 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; use Laracasts\Presenter\PresentableTrait; diff --git a/app/Models/PurchaseOrder.php b/app/Models/PurchaseOrder.php index 6048d378f970..0ac0ce6070be 100644 --- a/app/Models/PurchaseOrder.php +++ b/app/Models/PurchaseOrder.php @@ -13,13 +13,10 @@ namespace App\Models; use App\Helpers\Invoice\InvoiceSum; use App\Helpers\Invoice\InvoiceSumInclusive; -use App\Jobs\Vendor\CreatePurchaseOrderPdf; use App\Services\PurchaseOrder\PurchaseOrderService; -use App\Utils\Ninja; use App\Utils\Traits\MakesDates; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Carbon; -use Illuminate\Support\Facades\Storage; /** * App\Models\PurchaseOrder @@ -237,7 +234,7 @@ class PurchaseOrder extends BaseModel /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ - public function vendor(): \Illuminate\Database\Eloquent\Relations\BelongsTo + public function vendor(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(Vendor::class)->withTrashed(); } @@ -361,7 +358,7 @@ class PurchaseOrder extends BaseModel { $tax_type = ''; - match(intval($id)){ + match(intval($id)) { Product::PRODUCT_TYPE_PHYSICAL => $tax_type = ctrans('texts.physical_goods'), Product::PRODUCT_TYPE_SERVICE => $tax_type = ctrans('texts.services'), Product::PRODUCT_TYPE_DIGITAL => $tax_type = ctrans('texts.digital_products'), diff --git a/app/Models/PurchaseOrderInvitation.php b/app/Models/PurchaseOrderInvitation.php index 8599090ed286..31fbf151aacb 100644 --- a/app/Models/PurchaseOrderInvitation.php +++ b/app/Models/PurchaseOrderInvitation.php @@ -15,7 +15,6 @@ use App\Utils\Ninja; use App\Utils\Traits\Inviteable; use App\Utils\Traits\MakesDates; use Carbon\Carbon; -use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Str; @@ -194,5 +193,5 @@ class PurchaseOrderInvitation extends BaseModel return config('ninja.react_url')."/#/{$entity_type}s/{$this->{$entity_type}->hashed_id}/edit"; } - + } diff --git a/app/Models/Quote.php b/app/Models/Quote.php index 054690249095..f6e0ceb9b1ed 100644 --- a/app/Models/Quote.php +++ b/app/Models/Quote.php @@ -15,14 +15,12 @@ use App\Helpers\Invoice\InvoiceSum; use App\Helpers\Invoice\InvoiceSumInclusive; use App\Models\Presenters\QuotePresenter; use App\Services\Quote\QuoteService; -use App\Utils\Ninja; use App\Utils\Traits\MakesDates; use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesInvoiceValues; use App\Utils\Traits\MakesReminders; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Carbon; -use Illuminate\Support\Facades\Storage; use Laracasts\Presenter\PresentableTrait; /** @@ -108,7 +106,7 @@ use Laracasts\Presenter\PresentableTrait; * @property-read \Illuminate\Database\Eloquent\Collection $documents * @property-read \Illuminate\Database\Eloquent\Collection $history * @property-read \Illuminate\Database\Eloquent\Collection $invitations - * + * * @mixin \Eloquent * @mixin \Illuminate\Database\Eloquent\Builder */ diff --git a/app/Models/QuoteInvitation.php b/app/Models/QuoteInvitation.php index 34e01ea5cbbe..65aef2e2556a 100644 --- a/app/Models/QuoteInvitation.php +++ b/app/Models/QuoteInvitation.php @@ -15,7 +15,6 @@ use App\Utils\Traits\Inviteable; use App\Utils\Traits\MakesDates; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Carbon; -use Illuminate\Support\Facades\Storage; /** * App\Models\QuoteInvitation diff --git a/app/Models/RecurringQuote.php b/app/Models/RecurringQuote.php index 8652c8edca6d..24af3f9a2464 100644 --- a/app/Models/RecurringQuote.php +++ b/app/Models/RecurringQuote.php @@ -482,9 +482,9 @@ class RecurringQuote extends BaseModel { $invoice_calc = null; - if ($this->uses_inclusive_taxes) { + if ($this->uses_inclusive_taxes) { $invoice_calc = new InvoiceSumInclusive($this); - } else { + } else { $invoice_calc = new InvoiceSum($this); } diff --git a/app/Models/Scheduler.php b/app/Models/Scheduler.php index b3aa8bc9abd5..bff76f4d6f4a 100644 --- a/app/Models/Scheduler.php +++ b/app/Models/Scheduler.php @@ -11,9 +11,6 @@ namespace App\Models; -use App\Models\Company; -use App\Models\BaseModel; -use App\Models\RecurringInvoice; use App\Services\Scheduler\SchedulerService; use Illuminate\Database\Eloquent\SoftDeletes; diff --git a/app/Models/Task.php b/app/Models/Task.php index be0c86135e8a..9bbab1d15a79 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -229,11 +229,13 @@ class Task extends BaseModel public function getRate(): float { - if($this->project && $this->project->task_rate > 0) + if($this->project && $this->project->task_rate > 0) { return $this->project->task_rate; + } - if($this->client) + if($this->client) { return $this->client->getSetting('default_task_rate'); + } return $this->company->settings->default_task_rate ?? 0; } diff --git a/app/Models/Traits/Excludable.php b/app/Models/Traits/Excludable.php index e31011793648..e95e71eb253f 100644 --- a/app/Models/Traits/Excludable.php +++ b/app/Models/Traits/Excludable.php @@ -35,10 +35,10 @@ trait Excludable /** * Exclude an array of elements from the result. - * + * * @method static \Illuminate\Database\Eloquent\Builder exclude($columns) * @method static \Illuminate\Database\Eloquent\Builder exclude($columns) - * + * * @param \Illuminate\Database\Eloquent\Builder $query * @param array $columns * diff --git a/app/Models/User.php b/app/Models/User.php index aec9b0e787d5..d6c023b61269 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -11,26 +11,25 @@ namespace App\Models; -use App\Models\Company; -use App\Utils\TruthSource; use App\Jobs\Mail\NinjaMailer; -use Illuminate\Support\Carbon; -use App\Utils\Traits\MakesHash; use App\Jobs\Mail\NinjaMailerJob; -use App\Services\User\UserService; -use App\Utils\Traits\UserSettings; -use Illuminate\Support\Facades\App; use App\Jobs\Mail\NinjaMailerObject; use App\Mail\Admin\ResetPasswordObject; -use Illuminate\Database\Eloquent\Model; use App\Models\Presenters\UserPresenter; -use Illuminate\Notifications\Notifiable; -use Laracasts\Presenter\PresentableTrait; +use App\Services\User\UserService; +use App\Utils\Traits\MakesHash; use App\Utils\Traits\UserSessionAttributes; -use Illuminate\Database\Eloquent\SoftDeletes; +use App\Utils\Traits\UserSettings; +use App\Utils\TruthSource; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Foundation\Auth\User as Authenticatable; +use Illuminate\Notifications\Notifiable; +use Illuminate\Support\Carbon; +use Illuminate\Support\Facades\App; +use Laracasts\Presenter\PresentableTrait; /** * App\Models\User @@ -664,8 +663,9 @@ class User extends Authenticatable implements MustVerifyEmail { $locale = $this->language->locale ?? null; - if($locale) + if($locale) { App::setLocale($locale); + } return $locale; } diff --git a/app/Notifications/Admin/EntitySentNotification.php b/app/Notifications/Admin/EntitySentNotification.php index 5033d813d1fd..1aab61930798 100644 --- a/app/Notifications/Admin/EntitySentNotification.php +++ b/app/Notifications/Admin/EntitySentNotification.php @@ -12,7 +12,6 @@ namespace App\Notifications\Admin; use App\Utils\Number; -use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; @@ -67,7 +66,7 @@ class EntitySentNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Admin/EntityViewedNotification.php b/app/Notifications/Admin/EntityViewedNotification.php index 69f7b7e0033c..6fa39e757f7a 100644 --- a/app/Notifications/Admin/EntityViewedNotification.php +++ b/app/Notifications/Admin/EntityViewedNotification.php @@ -12,7 +12,6 @@ namespace App\Notifications\Admin; use App\Utils\Number; -use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; @@ -67,7 +66,7 @@ class EntityViewedNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Admin/NewPaymentNotification.php b/app/Notifications/Admin/NewPaymentNotification.php index 70694ccc0d6c..5867382f4c24 100644 --- a/app/Notifications/Admin/NewPaymentNotification.php +++ b/app/Notifications/Admin/NewPaymentNotification.php @@ -12,7 +12,6 @@ namespace App\Notifications\Admin; use App\Utils\Number; -use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; @@ -57,7 +56,7 @@ class NewPaymentNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * + * */ public function toMail($notifiable) { diff --git a/app/Notifications/ClientContactRequestCancellation.php b/app/Notifications/ClientContactRequestCancellation.php index 618dee18906c..6384f0d638d6 100644 --- a/app/Notifications/ClientContactRequestCancellation.php +++ b/app/Notifications/ClientContactRequestCancellation.php @@ -14,7 +14,6 @@ namespace App\Notifications; use Closure; use Illuminate\Bus\Queueable; use Illuminate\Foundation\Bus\Dispatchable; -use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; use Illuminate\Queue\InteractsWithQueue; @@ -63,7 +62,7 @@ class ClientContactRequestCancellation extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * + * */ public function toMail($notifiable) { diff --git a/app/Notifications/ClientContactResetPassword.php b/app/Notifications/ClientContactResetPassword.php index 2ba6593fb39d..4f048de0ec19 100644 --- a/app/Notifications/ClientContactResetPassword.php +++ b/app/Notifications/ClientContactResetPassword.php @@ -14,7 +14,6 @@ namespace App\Notifications; use Closure; use Illuminate\Bus\Queueable; use Illuminate\Foundation\Bus\Dispatchable; -use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; @@ -63,7 +62,7 @@ class ClientContactResetPassword extends Notification * Build the mail representation of the notification. * * @param mixed $notifiable - * + * */ public function toMail($notifiable) { diff --git a/app/Notifications/NewAccountCreated.php b/app/Notifications/NewAccountCreated.php index 845aecad8c34..163a0625e211 100644 --- a/app/Notifications/NewAccountCreated.php +++ b/app/Notifications/NewAccountCreated.php @@ -13,7 +13,6 @@ namespace App\Notifications; use Illuminate\Bus\Queueable; use Illuminate\Foundation\Bus\Dispatchable; -use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; use Illuminate\Queue\InteractsWithQueue; @@ -57,7 +56,7 @@ class NewAccountCreated extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/ClientAccountNotFound.php b/app/Notifications/Ninja/ClientAccountNotFound.php index 84087991f618..519c4f5e111d 100644 --- a/app/Notifications/Ninja/ClientAccountNotFound.php +++ b/app/Notifications/Ninja/ClientAccountNotFound.php @@ -11,7 +11,6 @@ namespace App\Notifications\Ninja; -use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; @@ -42,7 +41,7 @@ class ClientAccountNotFound extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/DomainFailureNotification.php b/app/Notifications/Ninja/DomainFailureNotification.php index 2e4dc99059c5..26b33f99e33e 100644 --- a/app/Notifications/Ninja/DomainFailureNotification.php +++ b/app/Notifications/Ninja/DomainFailureNotification.php @@ -11,7 +11,6 @@ namespace App\Notifications\Ninja; -use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; @@ -45,7 +44,7 @@ class DomainFailureNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/DomainRenewalFailureNotification.php b/app/Notifications/Ninja/DomainRenewalFailureNotification.php index 719a93d5e152..dfb189253d8a 100644 --- a/app/Notifications/Ninja/DomainRenewalFailureNotification.php +++ b/app/Notifications/Ninja/DomainRenewalFailureNotification.php @@ -11,7 +11,6 @@ namespace App\Notifications\Ninja; -use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; @@ -45,7 +44,7 @@ class DomainRenewalFailureNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/EmailBounceNotification.php b/app/Notifications/Ninja/EmailBounceNotification.php index 796a1f6368f0..4ae6966d725a 100644 --- a/app/Notifications/Ninja/EmailBounceNotification.php +++ b/app/Notifications/Ninja/EmailBounceNotification.php @@ -11,7 +11,6 @@ namespace App\Notifications\Ninja; -use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; @@ -44,7 +43,7 @@ class EmailBounceNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/EmailQuotaNotification.php b/app/Notifications/Ninja/EmailQuotaNotification.php index 8ef6cbf6ac51..45f4fe79d24c 100644 --- a/app/Notifications/Ninja/EmailQuotaNotification.php +++ b/app/Notifications/Ninja/EmailQuotaNotification.php @@ -11,7 +11,6 @@ namespace App\Notifications\Ninja; -use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; @@ -44,7 +43,7 @@ class EmailQuotaNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/EmailSpamNotification.php b/app/Notifications/Ninja/EmailSpamNotification.php index ca355ca87141..e4cd98b6c5b4 100644 --- a/app/Notifications/Ninja/EmailSpamNotification.php +++ b/app/Notifications/Ninja/EmailSpamNotification.php @@ -11,7 +11,6 @@ namespace App\Notifications\Ninja; -use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; diff --git a/app/Notifications/Ninja/GenericNinjaAdminNotification.php b/app/Notifications/Ninja/GenericNinjaAdminNotification.php index 7b40141aa22a..ee211d29e542 100644 --- a/app/Notifications/Ninja/GenericNinjaAdminNotification.php +++ b/app/Notifications/Ninja/GenericNinjaAdminNotification.php @@ -56,7 +56,7 @@ class GenericNinjaAdminNotification extends Notification public function toSlack($notifiable) { - $content = ''; + $content = ''; foreach($this->message_array as $message) { $content .= $message . "\n"; diff --git a/app/Notifications/Ninja/GmailCredentialNotification.php b/app/Notifications/Ninja/GmailCredentialNotification.php index 0bc8226e1e5d..893c5cc09a5d 100644 --- a/app/Notifications/Ninja/GmailCredentialNotification.php +++ b/app/Notifications/Ninja/GmailCredentialNotification.php @@ -11,7 +11,6 @@ namespace App\Notifications\Ninja; -use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; @@ -44,7 +43,7 @@ class GmailCredentialNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/NewAccountCreated.php b/app/Notifications/Ninja/NewAccountCreated.php index 77d570caa415..7e0636f4c3e7 100644 --- a/app/Notifications/Ninja/NewAccountCreated.php +++ b/app/Notifications/Ninja/NewAccountCreated.php @@ -13,7 +13,6 @@ namespace App\Notifications\Ninja; use Illuminate\Bus\Queueable; use Illuminate\Foundation\Bus\Dispatchable; -use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; use Illuminate\Queue\InteractsWithQueue; @@ -57,7 +56,7 @@ class NewAccountCreated extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/NewAccountNotification.php b/app/Notifications/Ninja/NewAccountNotification.php index 2b215897686a..2d7afdebe8cf 100644 --- a/app/Notifications/Ninja/NewAccountNotification.php +++ b/app/Notifications/Ninja/NewAccountNotification.php @@ -13,7 +13,6 @@ namespace App\Notifications\Ninja; use App\Models\Account; use App\Models\Client; -use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; @@ -50,7 +49,7 @@ class NewAccountNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/RenewalFailureNotification.php b/app/Notifications/Ninja/RenewalFailureNotification.php index 6d9adfc865ad..8231395b4f65 100644 --- a/app/Notifications/Ninja/RenewalFailureNotification.php +++ b/app/Notifications/Ninja/RenewalFailureNotification.php @@ -11,7 +11,6 @@ namespace App\Notifications\Ninja; -use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; @@ -42,7 +41,7 @@ class RenewalFailureNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/SpamNotification.php b/app/Notifications/Ninja/SpamNotification.php index d81e7909713b..bf895e89defb 100644 --- a/app/Notifications/Ninja/SpamNotification.php +++ b/app/Notifications/Ninja/SpamNotification.php @@ -11,7 +11,6 @@ namespace App\Notifications\Ninja; -use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; @@ -45,7 +44,7 @@ class SpamNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/UserQualityNotification.php b/app/Notifications/Ninja/UserQualityNotification.php index 4e1780665e5d..0a8dfc89f9b3 100644 --- a/app/Notifications/Ninja/UserQualityNotification.php +++ b/app/Notifications/Ninja/UserQualityNotification.php @@ -12,7 +12,6 @@ namespace App\Notifications\Ninja; use App\Models\User; -use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; @@ -49,7 +48,7 @@ class UserQualityNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * + * */ public function toMail($notifiable) { diff --git a/app/Notifications/Ninja/WePayFailureNotification.php b/app/Notifications/Ninja/WePayFailureNotification.php index e11e321c46ba..4af13a2b88fe 100644 --- a/app/Notifications/Ninja/WePayFailureNotification.php +++ b/app/Notifications/Ninja/WePayFailureNotification.php @@ -11,7 +11,6 @@ namespace App\Notifications\Ninja; -use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; @@ -44,7 +43,7 @@ class WePayFailureNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * + * */ public function toMail($notifiable) { diff --git a/app/Notifications/ResetPasswordNotification.php b/app/Notifications/ResetPasswordNotification.php index f3fc5497d45a..84a16d032fae 100644 --- a/app/Notifications/ResetPasswordNotification.php +++ b/app/Notifications/ResetPasswordNotification.php @@ -3,13 +3,12 @@ namespace App\Notifications; use Illuminate\Bus\Queueable; -use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; //@deprecated class ResetPasswordNotification extends Notification { -// use Queueable; + // use Queueable; public $token; @@ -38,7 +37,7 @@ class ResetPasswordNotification extends Notification * Get the mail representation of the notification. * * @param mixed $notifiable - * + * */ public function toMail($notifiable) { diff --git a/app/Observers/ClientObserver.php b/app/Observers/ClientObserver.php index e33316e1833a..902e111e535d 100644 --- a/app/Observers/ClientObserver.php +++ b/app/Observers/ClientObserver.php @@ -11,44 +11,44 @@ namespace App\Observers; +use App\Jobs\Client\CheckVat; +use App\Jobs\Client\UpdateTaxData; +use App\Jobs\Util\WebhookHandler; use App\Models\Client; use App\Models\Webhook; -use App\Jobs\Client\CheckVat; -use App\Jobs\Util\WebhookHandler; -use App\Jobs\Client\UpdateTaxData; class ClientObserver { public $afterCommit = true; private $eu_country_codes = [ - 'AT' => '40', - 'BE' => '56', - 'BG' => '100', - 'CY' => '196', - 'CZ' => '203', - 'DE' => '276', - 'DK' => '208', - 'EE' => '233', - 'ES' => '724', - 'FI' => '246', - 'FR' => '250', - 'GR' => '300', - 'HR' => '191', - 'HU' => '348', - 'IE' => '372', - 'IT' => '380', - 'LT' => '440', - 'LU' => '442', - 'LV' => '428', - 'MT' => '470', - 'NL' => '528', - 'PL' => '616', - 'PT' => '620', - 'RO' => '642', - 'SE' => '752', - 'SI' => '705', - 'SK' => '703', + 'AT' => '40', + 'BE' => '56', + 'BG' => '100', + 'CY' => '196', + 'CZ' => '203', + 'DE' => '276', + 'DK' => '208', + 'EE' => '233', + 'ES' => '724', + 'FI' => '246', + 'FR' => '250', + 'GR' => '300', + 'HR' => '191', + 'HU' => '348', + 'IE' => '372', + 'IT' => '380', + 'LT' => '440', + 'LU' => '442', + 'LV' => '428', + 'MT' => '470', + 'NL' => '528', + 'PL' => '616', + 'PT' => '620', + 'RO' => '642', + 'SE' => '752', + 'SI' => '705', + 'SK' => '703', ]; /** diff --git a/app/Observers/CompanyObserver.php b/app/Observers/CompanyObserver.php index 15ed25274945..28dda997c878 100644 --- a/app/Observers/CompanyObserver.php +++ b/app/Observers/CompanyObserver.php @@ -36,8 +36,9 @@ class CompanyObserver */ public function updated(Company $company) { - if (Ninja::isHosted() && $company->portal_mode == 'domain' && $company->isDirty('portal_domain')) + if (Ninja::isHosted() && $company->portal_mode == 'domain' && $company->isDirty('portal_domain')) { \Modules\Admin\Jobs\Domain\CustomDomain::dispatch($company->getOriginal('portal_domain'), $company)->onQueue('domain'); + } } diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreateCustomer.php b/app/PaymentDrivers/Authorize/AuthorizeCreateCustomer.php index 8a65fc375a3f..c1ad0e744db4 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreateCustomer.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreateCustomer.php @@ -12,15 +12,15 @@ namespace App\PaymentDrivers\Authorize; +use App\Exceptions\GenericPaymentDriverFailure; use App\Models\Client; use App\PaymentDrivers\AuthorizePaymentDriver; -use App\Exceptions\GenericPaymentDriverFailure; +use net\authorize\api\contract\v1\CreateCustomerProfileRequest; use net\authorize\api\contract\v1\CustomerAddressType; use net\authorize\api\contract\v1\CustomerProfileType; use net\authorize\api\contract\v1\GetCustomerProfileRequest; -use net\authorize\api\controller\GetCustomerProfileController; -use net\authorize\api\contract\v1\CreateCustomerProfileRequest; use net\authorize\api\controller\CreateCustomerProfileController; +use net\authorize\api\controller\GetCustomerProfileController; /** * Class BaseDriver. @@ -137,27 +137,27 @@ class AuthorizeCreateCustomer } // This is how we can harvest client profiles and attach them within Invoice Ninja -// $request = new net\authorize\api\contract\v1\GetCustomerProfileRequest(); -// $request->setMerchantAuthentication($driver->merchant_authentication); -// $request->setCustomerProfileId($gateway_customer_reference); -// $controller = new net\authorize\api\controller\GetCustomerProfileController($request); -// $response = $controller->executeWithApiResponse($driver->mode()); + // $request = new net\authorize\api\contract\v1\GetCustomerProfileRequest(); + // $request->setMerchantAuthentication($driver->merchant_authentication); + // $request->setCustomerProfileId($gateway_customer_reference); + // $controller = new net\authorize\api\controller\GetCustomerProfileController($request); + // $response = $controller->executeWithApiResponse($driver->mode()); -// if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) -// { -// echo "GetCustomerProfile SUCCESS : " . "\n"; -// $profileSelected = $response->getProfile(); -// $paymentProfilesSelected = $profileSelected->getPaymentProfiles(); -// echo "Profile Has " . count($paymentProfilesSelected). " Payment Profiles" . "\n"; + // if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + // { + // echo "GetCustomerProfile SUCCESS : " . "\n"; + // $profileSelected = $response->getProfile(); + // $paymentProfilesSelected = $profileSelected->getPaymentProfiles(); + // echo "Profile Has " . count($paymentProfilesSelected). " Payment Profiles" . "\n"; -// foreach ($profileSelected->getPaymentProfiles() as $paymentProfile) { -// echo "\nCustomer Profile ID: " . $paymentProfile->getCustomerProfileId() . "\n"; -// echo "Payment profile ID: " . $paymentProfile->getCustomerPaymentProfileId() . "\n"; -// echo "Credit Card Number: " . $paymentProfile->getPayment()->getCreditCard()->getCardNumber() . "\n"; -// if ($paymentProfile->getBillTo() != null) { -// echo "First Name in Billing Address: " . $paymentProfile->getBillTo()->getFirstName() . "\n"; -// } -// } + // foreach ($profileSelected->getPaymentProfiles() as $paymentProfile) { + // echo "\nCustomer Profile ID: " . $paymentProfile->getCustomerProfileId() . "\n"; + // echo "Payment profile ID: " . $paymentProfile->getCustomerPaymentProfileId() . "\n"; + // echo "Credit Card Number: " . $paymentProfile->getPayment()->getCreditCard()->getCardNumber() . "\n"; + // if ($paymentProfile->getBillTo() != null) { + // echo "First Name in Billing Address: " . $paymentProfile->getBillTo()->getFirstName() . "\n"; + // } + // } } // $request = new net\authorize\api\contract\v1\GetCustomerProfileIdsRequest(); @@ -174,7 +174,7 @@ class AuthorizeCreateCustomer // $request->setCustomerProfileId($customer_profile_id); // $controller = new net\authorize\api\controller\GetCustomerProfileController($request); // $response = $controller->executeWithApiResponse($auth->mode()); - + // $profileSelected = $response->getProfile(); // if($profileSelected->getEmail() == 'katnandan@gmail.com') diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index e1cbb863ce40..be6dd72bca9a 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -12,21 +12,20 @@ namespace App\PaymentDrivers\Authorize; -use App\Models\Payment; -use App\Models\SystemLog; +use App\Exceptions\PaymentFailed; +use App\Jobs\Util\SystemLogger; +use App\Models\ClientGatewayToken; use App\Models\GatewayType; +use App\Models\Payment; use App\Models\PaymentHash; use App\Models\PaymentType; -use App\Jobs\Util\SystemLogger; -use App\Utils\Traits\MakesHash; -use App\Exceptions\PaymentFailed; -use App\Models\ClientGatewayToken; +use App\Models\SystemLog; use App\PaymentDrivers\AuthorizePaymentDriver; -use App\PaymentDrivers\Authorize\AuthorizeTransaction; -use net\authorize\api\contract\v1\DeleteCustomerProfileRequest; -use net\authorize\api\controller\DeleteCustomerProfileController; +use App\Utils\Traits\MakesHash; use net\authorize\api\contract\v1\DeleteCustomerPaymentProfileRequest; +use net\authorize\api\contract\v1\DeleteCustomerProfileRequest; use net\authorize\api\controller\DeleteCustomerPaymentProfileController; +use net\authorize\api\controller\DeleteCustomerProfileController; /** * Class AuthorizeCreditCard. @@ -118,7 +117,7 @@ class AuthorizeCreditCard // $response = $controller->executeWithApiResponse($this->authorize->mode()); // if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) // { - // nlog("SUCCESS: Delete Customer Payment Profile SUCCESS"); + // nlog("SUCCESS: Delete Customer Payment Profile SUCCESS"); // } // else // nlog("unable to delete profile {$customer_profile_id}"); diff --git a/app/PaymentDrivers/Authorize/AuthorizeCustomer.php b/app/PaymentDrivers/Authorize/AuthorizeCustomer.php index 3e51b270db8e..a72fe5efe59d 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"); @@ -139,7 +139,7 @@ class AuthorizeCustomer continue; } -// $expiry = $payment_profile->getPayment()->getCreditCard()->getExpirationDate(); + // $expiry = $payment_profile->getPayment()->getCreditCard()->getExpirationDate(); $payment_meta = new \stdClass; $payment_meta->exp_month = 'xx'; diff --git a/app/PaymentDrivers/Authorize/AuthorizeTransaction.php b/app/PaymentDrivers/Authorize/AuthorizeTransaction.php index 20f184a17fe2..b727bf374525 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeTransaction.php +++ b/app/PaymentDrivers/Authorize/AuthorizeTransaction.php @@ -13,17 +13,15 @@ namespace App\PaymentDrivers\Authorize; use App\Models\Invoice; -use App\Utils\Traits\MakesHash; -use net\authorize\api\contract\v1\OrderType; use App\PaymentDrivers\AuthorizePaymentDriver; +use App\Utils\Traits\MakesHash; +use net\authorize\api\contract\v1\CreateTransactionRequest; +use net\authorize\api\contract\v1\ExtendedAmountType; +use net\authorize\api\contract\v1\OpaqueDataType; +use net\authorize\api\contract\v1\OrderType; use net\authorize\api\contract\v1\PaymentType; use net\authorize\api\contract\v1\SettingType; -use net\authorize\api\contract\v1\OpaqueDataType; -use net\authorize\api\contract\v1\ExtendedAmountType; -use net\authorize\api\contract\v1\PaymentProfileType; use net\authorize\api\contract\v1\TransactionRequestType; -use net\authorize\api\contract\v1\CreateTransactionRequest; -use net\authorize\api\contract\v1\CustomerProfilePaymentType; use net\authorize\api\controller\CreateTransactionController; /** @@ -110,7 +108,7 @@ class AuthorizeTransaction $billto->setPhoneNumber(substr($this->authorize->client->phone, 0, 20)); } -//Assign to the transactionRequest field + //Assign to the transactionRequest field $transactionRequestType = new TransactionRequestType(); $transactionRequestType->setTransactionType('authCaptureTransaction'); @@ -123,8 +121,9 @@ class AuthorizeTransaction $transactionRequestType->setPayment($paymentOne); $transactionRequestType->setCurrencyCode($this->authorize->client->currency()->code); - if($billto) + if($billto) { $transactionRequestType->setBillTo($billto); + } $request = new CreateTransactionRequest(); $request->setMerchantAuthentication($this->authorize->merchant_authentication); diff --git a/app/PaymentDrivers/Authorize/RefundTransaction.php b/app/PaymentDrivers/Authorize/RefundTransaction.php index 998ffbad33a9..a667598a0ec0 100644 --- a/app/PaymentDrivers/Authorize/RefundTransaction.php +++ b/app/PaymentDrivers/Authorize/RefundTransaction.php @@ -12,16 +12,16 @@ namespace App\PaymentDrivers\Authorize; +use App\Jobs\Util\SystemLogger; use App\Models\Payment; use App\Models\SystemLog; -use App\Jobs\Util\SystemLogger; use App\PaymentDrivers\AuthorizePaymentDriver; -use net\authorize\api\contract\v1\PaymentType; -use net\authorize\api\contract\v1\CreditCardType; -use net\authorize\api\contract\v1\PaymentProfileType; -use net\authorize\api\contract\v1\TransactionRequestType; use net\authorize\api\contract\v1\CreateTransactionRequest; +use net\authorize\api\contract\v1\CreditCardType; use net\authorize\api\contract\v1\CustomerProfilePaymentType; +use net\authorize\api\contract\v1\PaymentProfileType; +use net\authorize\api\contract\v1\PaymentType; +use net\authorize\api\contract\v1\TransactionRequestType; use net\authorize\api\controller\CreateTransactionController; /** diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 7919cbe23882..9631b3b97c66 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -15,7 +15,6 @@ use App\Events\Invoice\InvoiceWasPaid; use App\Events\Payment\PaymentWasCreated; use App\Exceptions\PaymentFailed; use App\Factory\PaymentFactory; -use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; use App\Jobs\Mail\NinjaMailer; use App\Jobs\Mail\NinjaMailerJob; use App\Jobs\Mail\NinjaMailerObject; @@ -59,7 +58,7 @@ class BaseDriver extends AbstractPaymentDriver /** * The Client * - * @var \App\Models\Client|null $client + * @var \App\Models\Client|null $client */ public $client; @@ -733,19 +732,21 @@ class BaseDriver extends AbstractPaymentDriver $t->replace(Ninja::transformTranslations($this->client->getMergedSettings())); App::setLocale($this->client->company->locale()); - if (! $this->payment_hash || !$this->client) + if (! $this->payment_hash || !$this->client) { return 'Descriptor'; + } $invoices_string = \implode(', ', collect($this->payment_hash->invoices())->pluck('invoice_number')->toArray()) ?: null; - if (!$invoices_string) + if (!$invoices_string) { return str_replace(["*","<",">","'",'"'], "", $this->client->company->present()->name()); + } $invoices_string = str_replace(["*","<",">","'",'"'], "-", $invoices_string); $invoices_string = "I-".$invoices_string; - $invoices_string = substr($invoices_string,0,22); + $invoices_string = substr($invoices_string, 0, 22); $invoices_string = str_pad($invoices_string, 5, ctrans('texts.invoice'), STR_PAD_LEFT); @@ -769,7 +770,7 @@ class BaseDriver extends AbstractPaymentDriver $invoices_string = \implode(', ', collect($this->payment_hash->invoices())->pluck('invoice_number')->toArray()) ?: null; $amount = Number::formatMoney($this->payment_hash?->amount_with_fee() ?? 0, $this->client); - if($abbreviated && $invoices_string){ + if($abbreviated && $invoices_string) { return $invoices_string; } elseif ($abbreviated || ! $invoices_string) { return ctrans('texts.gateway_payment_text_no_invoice', [ diff --git a/app/PaymentDrivers/Braintree/ACH.php b/app/PaymentDrivers/Braintree/ACH.php index da8e220d3a65..5dbbb56e650e 100644 --- a/app/PaymentDrivers/Braintree/ACH.php +++ b/app/PaymentDrivers/Braintree/ACH.php @@ -42,8 +42,7 @@ class ACH implements MethodInterface try { $data['gateway'] = $this->braintree; $data['client_token'] = $this->braintree->gateway->clientToken()->generate(); - } - catch(\Exception $e){ + } catch(\Exception $e) { throw new PaymentFailed("Unable to generate client token, check your Braintree credentials. Error: " . $e->getMessage(), 500); diff --git a/app/PaymentDrivers/CheckoutCom/CheckoutSetupWebhook.php b/app/PaymentDrivers/CheckoutCom/CheckoutSetupWebhook.php index d35d07bd22ed..5c61547d217f 100644 --- a/app/PaymentDrivers/CheckoutCom/CheckoutSetupWebhook.php +++ b/app/PaymentDrivers/CheckoutCom/CheckoutSetupWebhook.php @@ -11,28 +11,21 @@ namespace App\PaymentDrivers\CheckoutCom; -use App\Models\Payment; -use App\Models\SystemLog; use App\Libraries\MultiDB; -use App\Models\GatewayType; -use App\Models\PaymentHash; -use App\Models\PaymentType; -use Illuminate\Bus\Queueable; use App\Models\CompanyGateway; -use App\Jobs\Util\SystemLogger; -use Checkout\CheckoutApiException; -use Illuminate\Queue\SerializesModels; -use App\PaymentDrivers\Stripe\Utilities; -use Illuminate\Queue\InteractsWithQueue; -use App\PaymentDrivers\CheckoutCom\Webhook; -use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Foundation\Bus\Dispatchable; -use Checkout\CheckoutAuthorizationException; -use Checkout\Workflows\CreateWorkflowRequest; use App\PaymentDrivers\CheckoutComPaymentDriver; +use App\PaymentDrivers\Stripe\Utilities; +use Checkout\CheckoutApiException; +use Checkout\CheckoutAuthorizationException; use Checkout\Workflows\Actions\WebhookSignature; use Checkout\Workflows\Actions\WebhookWorkflowActionRequest; use Checkout\Workflows\Conditions\EventWorkflowConditionRequest; +use Checkout\Workflows\CreateWorkflowRequest; +use Illuminate\Bus\Queueable; +use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Queue\SerializesModels; class CheckoutSetupWebhook implements ShouldQueue { @@ -68,8 +61,9 @@ class CheckoutSetupWebhook implements ShouldQueue return $workflow['name'] == $this->authentication_webhook_name; }); - if($wf) + if($wf) { return; + } $this->createAuthenticationWorkflow(); } diff --git a/app/PaymentDrivers/CheckoutCom/CheckoutWebhook.php b/app/PaymentDrivers/CheckoutCom/CheckoutWebhook.php index c7c1069c63ff..2d162f9e8e79 100644 --- a/app/PaymentDrivers/CheckoutCom/CheckoutWebhook.php +++ b/app/PaymentDrivers/CheckoutCom/CheckoutWebhook.php @@ -11,20 +11,20 @@ namespace App\PaymentDrivers\CheckoutCom; -use App\Models\Payment; -use App\Models\SystemLog; +use App\Jobs\Util\SystemLogger; use App\Libraries\MultiDB; +use App\Models\CompanyGateway; use App\Models\GatewayType; +use App\Models\Payment; use App\Models\PaymentHash; use App\Models\PaymentType; -use Illuminate\Bus\Queueable; -use App\Models\CompanyGateway; -use App\Jobs\Util\SystemLogger; -use Illuminate\Queue\SerializesModels; +use App\Models\SystemLog; use App\PaymentDrivers\Stripe\Utilities; -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 CheckoutWebhook implements ShouldQueue { @@ -48,10 +48,11 @@ class CheckoutWebhook implements ShouldQueue $this->company_gateway = CompanyGateway::withTrashed()->find($this->company_gateway_id); - if(!isset($this->webhook_array['type'])) + if(!isset($this->webhook_array['type'])) { nlog("Checkout Webhook type not set"); + } - match($this->webhook_array['type']){ + match($this->webhook_array['type']) { 'payment_approved' => $this->paymentApproved(), }; @@ -62,7 +63,7 @@ class CheckoutWebhook implements ShouldQueue * "id":"evt_dli6ty4qo5vuxle5wklf5gwbwy","type":"payment_approved","version":"1.0.33","created_on":"2023-07-21T10:03:07.1555904Z", * "data":{"id":"pay_oqwbsd22kvpuvd35y5fhbdawxa","action_id":"act_buviezur7zsurnsorcgfn63e44","reference":"0014","amount":584168,"auth_code":"113059","currency":"USD","customer":{"id":"cus_6n4yt4q5kf4unn36o5qpbevxhe","email":"cypress@example.com"}, * "metadata":{"udf1":"Invoice Ninja","udf2":"ofhgiGjyQXbsbUwygURfYFT2C3E7iY7U"},"payment_type":"Regular","processed_on":"2023-07-21T10:02:57.4678165Z","processing":{"acquirer_transaction_id":"645272142084717830381","retrieval_reference_number":"183042259107"},"response_code":"10000","response_summary":"Approved","risk":{"flagged":false,"score":0},"3ds":{"version":"2.2.0","challenged":true,"challenge_indicator":"no_preference","exemption":"none","eci":"05","cavv":"AAABAVIREQAAAAAAAAAAAAAAAAA=","xid":"74afa3ac-25d3-4d95-b815-cefbdd7c8270","downgraded":false,"enrolled":"Y","authentication_response":"Y","flow_type":"challenged"},"scheme_id":"114455763095262", - * "source":{"id":"src_ghavmefpetjellmteqwj5jjcli","type":"card","billing_address":{},"expiry_month":10,"expiry_year":2025,"scheme":"VISA","last_4":"4242","fingerprint":"BD864B08D0B098DD83052A038FD2BA967DF2D48E375AAEEF54E37BC36B385E9A","bin":"424242","card_type":"CREDIT","card_category":"CONSUMER","issuer_country":"GB","product_id":"F","product_type":"Visa Classic","avs_check":"G","cvv_check":"Y"},"balances":{"total_authorized":584168,"total_voided":0,"available_to_void":584168,"total_captured":0,"available_to_capture":584168,"total_refunded":0,"available_to_refund":0},"event_links":{"payment":"https://api.sandbox.checkout.com/payments/pay_oqwbsd22kvpuvd35y5fhbdawxa","payment_actions":"https://api.sandbox.checkout.com/payments/pay_oqwbsd22kvpuvd35y5fhbdawxa/actions","capture":"https://api.sandbox.checkout.com/payments/pay_oqwbsd22kvpuvd35y5fhbdawxa/captures","void":"https://api.sandbox.checkout.com/payments/pay_oqwbsd22kvpuvd35y5fhbdawxa/voids"}},"_links":{"self":{"href":"https://api.sandbox.checkout.com/workflows/events/evt_dli6ty4qo5vuxle5wklf5gwbwy"},"subject":{"href":"https://api.sandbox.checkout.com/workflows/events/subject/pay_oqwbsd22kvpuvd35y5fhbdawxa"},"payment":{"href":"https://api.sandbox.checkout.com/payments/pay_oqwbsd22kvpuvd35y5fhbdawxa"},"payment_actions":{"href":"https://api.sandbox.checkout.com/payments/pay_oqwbsd22kvpuvd35y5fhbdawxa/actions"},"capture":{"href":"https://api.sandbox.checkout.com/payments/pay_oqwbsd22kvpuvd35y5fhbdawxa/captures"},"void":{"href":"https://api.sandbox.checkout.com/payments/pay_oqwbsd22kvpuvd35y5fhbdawxa/voids"}}} + * "source":{"id":"src_ghavmefpetjellmteqwj5jjcli","type":"card","billing_address":{},"expiry_month":10,"expiry_year":2025,"scheme":"VISA","last_4":"4242","fingerprint":"BD864B08D0B098DD83052A038FD2BA967DF2D48E375AAEEF54E37BC36B385E9A","bin":"424242","card_type":"CREDIT","card_category":"CONSUMER","issuer_country":"GB","product_id":"F","product_type":"Visa Classic","avs_check":"G","cvv_check":"Y"},"balances":{"total_authorized":584168,"total_voided":0,"available_to_void":584168,"total_captured":0,"available_to_capture":584168,"total_refunded":0,"available_to_refund":0},"event_links":{"payment":"https://api.sandbox.checkout.com/payments/pay_oqwbsd22kvpuvd35y5fhbdawxa","payment_actions":"https://api.sandbox.checkout.com/payments/pay_oqwbsd22kvpuvd35y5fhbdawxa/actions","capture":"https://api.sandbox.checkout.com/payments/pay_oqwbsd22kvpuvd35y5fhbdawxa/captures","void":"https://api.sandbox.checkout.com/payments/pay_oqwbsd22kvpuvd35y5fhbdawxa/voids"}},"_links":{"self":{"href":"https://api.sandbox.checkout.com/workflows/events/evt_dli6ty4qo5vuxle5wklf5gwbwy"},"subject":{"href":"https://api.sandbox.checkout.com/workflows/events/subject/pay_oqwbsd22kvpuvd35y5fhbdawxa"},"payment":{"href":"https://api.sandbox.checkout.com/payments/pay_oqwbsd22kvpuvd35y5fhbdawxa"},"payment_actions":{"href":"https://api.sandbox.checkout.com/payments/pay_oqwbsd22kvpuvd35y5fhbdawxa/actions"},"capture":{"href":"https://api.sandbox.checkout.com/payments/pay_oqwbsd22kvpuvd35y5fhbdawxa/captures"},"void":{"href":"https://api.sandbox.checkout.com/payments/pay_oqwbsd22kvpuvd35y5fhbdawxa/voids"}}} */ private function paymentApproved() @@ -71,10 +72,11 @@ class CheckoutWebhook implements ShouldQueue $payment = Payment::query()->withTrashed()->where('transaction_reference', $payment_object['id'])->first(); - if($payment && $payment->status_id == Payment::STATUS_COMPLETED) + if($payment && $payment->status_id == Payment::STATUS_COMPLETED) { return; + } - if($payment){ + if($payment) { $payment->status_id = Payment::STATUS_COMPLETED; $payment->save(); return; @@ -89,8 +91,8 @@ class CheckoutWebhook implements ShouldQueue $driver = $this->company_gateway->driver($payment_hash->fee_invoice->client)->init()->setPaymentMethod(); $payment_hash->data = array_merge((array) $payment_hash->data, $this->webhook_array); // @phpstan-ignore-line - $payment_hash->save(); - $driver->setPaymentHash($payment_hash); + $payment_hash->save(); + $driver->setPaymentHash($payment_hash); // @phpstan-ignore-line $data = [ diff --git a/app/PaymentDrivers/CheckoutCom/CreditCard.php b/app/PaymentDrivers/CheckoutCom/CreditCard.php index 8a0166eb0cdb..5436ce35ba1e 100644 --- a/app/PaymentDrivers/CheckoutCom/CreditCard.php +++ b/app/PaymentDrivers/CheckoutCom/CreditCard.php @@ -12,25 +12,25 @@ namespace App\PaymentDrivers\CheckoutCom; -use App\Models\SystemLog; -use Illuminate\View\View; -use App\Models\GatewayType; -use Illuminate\Http\Request; -use App\Jobs\Util\SystemLogger; -use App\Utils\Traits\MakesHash; use App\Exceptions\PaymentFailed; +use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; +use App\Jobs\Util\SystemLogger; use App\Models\ClientGatewayToken; +use App\Models\GatewayType; +use App\Models\SystemLog; +use App\PaymentDrivers\CheckoutComPaymentDriver; +use App\PaymentDrivers\Common\MethodInterface; +use App\Utils\Traits\MakesHash; use Checkout\CheckoutApiException; -use Illuminate\Contracts\View\Factory; use Checkout\CheckoutArgumentException; use Checkout\CheckoutAuthorizationException; -use Checkout\Payments\Request\PaymentRequest; -use App\PaymentDrivers\Common\MethodInterface; -use App\PaymentDrivers\CheckoutComPaymentDriver; -use Checkout\Payments\Previous\Source\RequestTokenSource; -use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; use Checkout\Payments\Previous\PaymentRequest as PreviousPaymentRequest; +use Checkout\Payments\Previous\Source\RequestTokenSource; +use Checkout\Payments\Request\PaymentRequest; use Checkout\Payments\Request\Source\RequestTokenSource as SourceRequestTokenSource; +use Illuminate\Contracts\View\Factory; +use Illuminate\Http\Request; +use Illuminate\View\View; class CreditCard implements MethodInterface { @@ -125,8 +125,7 @@ class CreditCard implements MethodInterface if (isset($e->error_details['error_codes']) ?? false) { $error_details = end($e->error_details['error_codes']); - } - else { + } else { $error_details = $e->getMessage(); } diff --git a/app/PaymentDrivers/CheckoutCom/Utilities.php b/app/PaymentDrivers/CheckoutCom/Utilities.php index 73b0710a6296..296f506740cd 100644 --- a/app/PaymentDrivers/CheckoutCom/Utilities.php +++ b/app/PaymentDrivers/CheckoutCom/Utilities.php @@ -12,13 +12,12 @@ namespace App\PaymentDrivers\CheckoutCom; -use stdClass; -use Exception; -use App\Models\SystemLog; -use App\Models\GatewayType; -use App\Jobs\Util\SystemLogger; use App\Exceptions\PaymentFailed; -use Checkout\Payments\PaymentType; +use App\Jobs\Util\SystemLogger; +use App\Models\GatewayType; +use App\Models\SystemLog; +use Exception; +use stdClass; trait Utilities { diff --git a/app/PaymentDrivers/CheckoutCom/Webhook.php b/app/PaymentDrivers/CheckoutCom/Webhook.php index 8fc5744762b7..2fd3ab51c0cb 100644 --- a/app/PaymentDrivers/CheckoutCom/Webhook.php +++ b/app/PaymentDrivers/CheckoutCom/Webhook.php @@ -12,25 +12,9 @@ namespace App\PaymentDrivers\CheckoutCom; -use App\Exceptions\PaymentFailed; -use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; -use App\Jobs\Util\SystemLogger; -use App\Models\ClientGatewayToken; -use App\Models\GatewayType; -use App\Models\SystemLog; use App\PaymentDrivers\CheckoutComPaymentDriver; -use App\PaymentDrivers\Common\MethodInterface; -use App\Utils\Traits\MakesHash; use Checkout\CheckoutApiException; -use Checkout\CheckoutArgumentException; use Checkout\CheckoutAuthorizationException; -use Checkout\Payments\Four\Request\PaymentRequest; -use Checkout\Payments\Four\Request\Source\RequestTokenSource; -use Checkout\Payments\PaymentRequest as PaymentsPaymentRequest; -use Checkout\Payments\Source\RequestTokenSource as SourceRequestTokenSource; -use Illuminate\Contracts\View\Factory; -use Illuminate\Http\Request; -use Illuminate\View\View; class Webhook { @@ -86,4 +70,4 @@ class Webhook } -} \ No newline at end of file +} diff --git a/app/PaymentDrivers/CheckoutComPaymentDriver.php b/app/PaymentDrivers/CheckoutComPaymentDriver.php index 8c6c92b6af02..7f4fea2ab793 100644 --- a/app/PaymentDrivers/CheckoutComPaymentDriver.php +++ b/app/PaymentDrivers/CheckoutComPaymentDriver.php @@ -148,7 +148,7 @@ class CheckoutComPaymentDriver extends BaseDriver /** * Process different view depending on payment type - * + * * @param int $gateway_type_id The gateway type * @return string The view string */ diff --git a/app/PaymentDrivers/GoCardless/ACH.php b/app/PaymentDrivers/GoCardless/ACH.php index 2f1c5f6a0bff..78258f9ab268 100644 --- a/app/PaymentDrivers/GoCardless/ACH.php +++ b/app/PaymentDrivers/GoCardless/ACH.php @@ -142,7 +142,7 @@ class ACH implements MethodInterface * Show the payment page for ACH. * * @param array $data - * @return \Illuminate\View\View + * @return \Illuminate\View\View */ public function paymentView(array $data): View { diff --git a/app/PaymentDrivers/GoCardless/DirectDebit.php b/app/PaymentDrivers/GoCardless/DirectDebit.php index 48274891e818..f27696d8627d 100644 --- a/app/PaymentDrivers/GoCardless/DirectDebit.php +++ b/app/PaymentDrivers/GoCardless/DirectDebit.php @@ -97,8 +97,8 @@ class DirectDebit implements MethodInterface * } * } * } - * - * + * + * */ public function billingRequestFlows(array $data) { @@ -170,7 +170,7 @@ class DirectDebit implements MethodInterface public function authorizeResponse(Request $request) { - try{ + try { $billing_request = $this->go_cardless->gateway->billingRequests()->get($request->billing_request); @@ -194,8 +194,7 @@ class DirectDebit implements MethodInterface return redirect()->route('client.payment_methods.show', $payment_method->hashed_id); - } - catch (\Exception $exception) { + } catch (\Exception $exception) { return $this->processUnsuccessfulAuthorization($exception); } @@ -242,7 +241,7 @@ class DirectDebit implements MethodInterface * Payment view for Direct Debit. * * @param array $data - * @return \Illuminate\View\View + * @return \Illuminate\View\View */ public function paymentView(array $data): View { diff --git a/app/PaymentDrivers/GoCardless/SEPA.php b/app/PaymentDrivers/GoCardless/SEPA.php index 458b34d9e225..793f1f2b9f1f 100644 --- a/app/PaymentDrivers/GoCardless/SEPA.php +++ b/app/PaymentDrivers/GoCardless/SEPA.php @@ -141,7 +141,7 @@ class SEPA implements MethodInterface * Payment view for SEPA. * * @param array $data - * @return \Illuminate\View\View + * @return \Illuminate\View\View */ public function paymentView(array $data): View { diff --git a/app/PaymentDrivers/GoCardlessPaymentDriver.php b/app/PaymentDrivers/GoCardlessPaymentDriver.php index bd461197f663..3201890465bc 100644 --- a/app/PaymentDrivers/GoCardlessPaymentDriver.php +++ b/app/PaymentDrivers/GoCardlessPaymentDriver.php @@ -103,8 +103,7 @@ class GoCardlessPaymentDriver extends BaseDriver 'access_token' => $this->company_gateway->getConfigField('accessToken'), 'environment' => $this->company_gateway->getConfigField('testMode') ? \GoCardlessPro\Environment::SANDBOX : \GoCardlessPro\Environment::LIVE, ]); - } - catch(\GoCardlessPro\Core\Exception\AuthenticationException $e){ + } catch(\GoCardlessPro\Core\Exception\AuthenticationException $e) { throw new \Exception('GoCardless: Invalid Access Token', 403); diff --git a/app/PaymentDrivers/Mollie/Bancontact.php b/app/PaymentDrivers/Mollie/Bancontact.php index 8aaed1bd615a..6af012b2f3b0 100644 --- a/app/PaymentDrivers/Mollie/Bancontact.php +++ b/app/PaymentDrivers/Mollie/Bancontact.php @@ -40,7 +40,7 @@ class Bancontact implements MethodInterface * Show the authorization page for Bancontact. * * @param array $data - * @return \Illuminate\View\View + * @return \Illuminate\View\View */ public function authorizeView(array $data): View { diff --git a/app/PaymentDrivers/Mollie/BankTransfer.php b/app/PaymentDrivers/Mollie/BankTransfer.php index 01cfc9c3c718..83d9ced223bc 100644 --- a/app/PaymentDrivers/Mollie/BankTransfer.php +++ b/app/PaymentDrivers/Mollie/BankTransfer.php @@ -43,7 +43,7 @@ class BankTransfer implements MethodInterface * Show the authorization page for bank transfer. * * @param array $data - * @return \Illuminate\View\View + * @return \Illuminate\View\View */ public function authorizeView(array $data): View { diff --git a/app/PaymentDrivers/Mollie/IDEAL.php b/app/PaymentDrivers/Mollie/IDEAL.php index 3e40df10b049..f14eaeb08303 100644 --- a/app/PaymentDrivers/Mollie/IDEAL.php +++ b/app/PaymentDrivers/Mollie/IDEAL.php @@ -40,7 +40,7 @@ class IDEAL implements MethodInterface * Show the authorization page for iDEAL. * * @param array $data - * @return \Illuminate\View\View + * @return \Illuminate\View\View */ public function authorizeView(array $data): View { diff --git a/app/PaymentDrivers/Mollie/KBC.php b/app/PaymentDrivers/Mollie/KBC.php index 6d34591064bc..c5020cdd4983 100644 --- a/app/PaymentDrivers/Mollie/KBC.php +++ b/app/PaymentDrivers/Mollie/KBC.php @@ -40,7 +40,7 @@ class KBC implements MethodInterface * Show the authorization page for KBC. * * @param array $data - * @return \Illuminate\View\View + * @return \Illuminate\View\View */ public function authorizeView(array $data): View { diff --git a/app/PaymentDrivers/PayPalExpressPaymentDriver.php b/app/PaymentDrivers/PayPalExpressPaymentDriver.php index 72c05a6030b8..7f34936bfca2 100644 --- a/app/PaymentDrivers/PayPalExpressPaymentDriver.php +++ b/app/PaymentDrivers/PayPalExpressPaymentDriver.php @@ -129,8 +129,7 @@ class PayPalExpressPaymentDriver extends BaseDriver if ($response->isCancelled() && $this->client->getSetting('enable_client_portal')) { return redirect()->route('client.invoices.index')->with('warning', ctrans('texts.status_cancelled')); - } - elseif($response->isCancelled() && !$this->client->getSetting('enable_client_portal')){ + } elseif($response->isCancelled() && !$this->client->getSetting('enable_client_portal')) { redirect()->route('client.invoices.show', ['invoice' => $this->payment_hash->fee_invoice])->with('warning', ctrans('texts.status_cancelled')); } diff --git a/app/PaymentDrivers/PayPalRestPaymentDriver.php b/app/PaymentDrivers/PayPalRestPaymentDriver.php index f60c4e3b1762..efcdba1bfa9d 100644 --- a/app/PaymentDrivers/PayPalRestPaymentDriver.php +++ b/app/PaymentDrivers/PayPalRestPaymentDriver.php @@ -12,15 +12,15 @@ namespace App\PaymentDrivers; -use Omnipay\Omnipay; -use App\Models\Invoice; -use App\Models\SystemLog; -use App\Models\GatewayType; -use App\Models\PaymentType; -use App\Jobs\Util\SystemLogger; -use App\Utils\Traits\MakesHash; use App\Exceptions\PaymentFailed; +use App\Jobs\Util\SystemLogger; +use App\Models\GatewayType; +use App\Models\Invoice; +use App\Models\PaymentType; +use App\Models\SystemLog; +use App\Utils\Traits\MakesHash; use Illuminate\Support\Facades\Http; +use Omnipay\Omnipay; class PayPalRestPaymentDriver extends BaseDriver { @@ -87,8 +87,9 @@ class PayPalRestPaymentDriver extends BaseDriver public function setPaymentMethod($payment_method_id) { - if(!$payment_method_id) + if(!$payment_method_id) { return $this; + } $this->paypal_payment_method = $this->funding_options[$payment_method_id]; @@ -131,18 +132,18 @@ class PayPalRestPaymentDriver extends BaseDriver { $enums = [ - 3 => 'paypal', - 1 => 'card', - 25 => 'venmo', - // 9 => 'sepa', - // 12 => 'bancontact', - // 17 => 'eps', - // 15 => 'giropay', - // 13 => 'ideal', - // 26 => 'mercadopago', - // 27 => 'mybank', - // 28 => 'paylater', - // 16 => 'p24', + 3 => 'paypal', + 1 => 'card', + 25 => 'venmo', + // 9 => 'sepa', + // 12 => 'bancontact', + // 17 => 'eps', + // 15 => 'giropay', + // 13 => 'ideal', + // 26 => 'mercadopago', + // 27 => 'mybank', + // 28 => 'paylater', + // 16 => 'p24', // 7 => 'sofort' ]; @@ -167,7 +168,7 @@ class PayPalRestPaymentDriver extends BaseDriver $response = json_decode($request['gateway_response'], true); - if($response['status'] == 'COMPLETED' && isset($response['purchase_units'])){ + if($response['status'] == 'COMPLETED' && isset($response['purchase_units'])) { $data = [ 'payment_type' => PaymentType::PAYPAL, @@ -189,8 +190,7 @@ class PayPalRestPaymentDriver extends BaseDriver return redirect()->route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)]); - } - else { + } else { SystemLogger::dispatch( ['response' => $response], @@ -211,8 +211,9 @@ class PayPalRestPaymentDriver 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); @@ -235,9 +236,9 @@ class PayPalRestPaymentDriver extends BaseDriver "email_address" => $this->client->present()->email(), "address" => [ "address_line_1" => $this->client->address1, - "address_line_2" => $this->client->address2, - "admin_area_1" => $this->client->city, - "admin_area_2" => $this->client->state, + "address_line_2" => $this->client->address2, + "admin_area_1" => $this->client->city, + "admin_area_2" => $this->client->state, "postal_code" => $this->client->postal_code, "country_code" => $this->client->country->iso_3166_2, ] @@ -282,8 +283,9 @@ class PayPalRestPaymentDriver extends BaseDriver ->withHeaders($this->getHeaders($headers)) ->{$verb}("{$this->api_endpoint_url}{$uri}", $data); - if($r->successful()) + if($r->successful()) { return $r; + } throw new PaymentFailed("Gateway failure - {$r->body()}", 401); @@ -428,5 +430,5 @@ class PayPalRestPaymentDriver extends BaseDriver return 0; } - + } diff --git a/app/PaymentDrivers/PaytracePaymentDriver.php b/app/PaymentDrivers/PaytracePaymentDriver.php index b55e8857c169..830d7aecab2c 100644 --- a/app/PaymentDrivers/PaytracePaymentDriver.php +++ b/app/PaymentDrivers/PaytracePaymentDriver.php @@ -11,19 +11,19 @@ namespace App\PaymentDrivers; +use App\Exceptions\SystemError; +use App\Http\Requests\Payments\PaymentWebhookRequest; +use App\Jobs\Util\SystemLogger; +use App\Models\ClientGatewayToken; +use App\Models\GatewayType; use App\Models\Invoice; use App\Models\Payment; -use App\Utils\CurlUtils; -use App\Models\SystemLog; -use App\Models\GatewayType; use App\Models\PaymentHash; use App\Models\PaymentType; -use App\Exceptions\SystemError; -use App\Jobs\Util\SystemLogger; -use App\Utils\Traits\MakesHash; -use App\Models\ClientGatewayToken; +use App\Models\SystemLog; use App\PaymentDrivers\PayTrace\CreditCard; -use App\Http\Requests\Payments\PaymentWebhookRequest; +use App\Utils\CurlUtils; +use App\Utils\Traits\MakesHash; class PaytracePaymentDriver extends BaseDriver { diff --git a/app/PaymentDrivers/Razorpay/Hosted.php b/app/PaymentDrivers/Razorpay/Hosted.php index 1d5b42358a7d..694d55c9ee50 100644 --- a/app/PaymentDrivers/Razorpay/Hosted.php +++ b/app/PaymentDrivers/Razorpay/Hosted.php @@ -41,7 +41,7 @@ class Hosted implements MethodInterface * Show the authorization page for Razorpay. * * @param array $data - * @return \Illuminate\View\View + * @return \Illuminate\View\View */ public function authorizeView(array $data): View { @@ -63,7 +63,7 @@ class Hosted implements MethodInterface * Payment view for the Razorpay. * * @param array $data - * @return \Illuminate\View\View + * @return \Illuminate\View\View */ public function paymentView(array $data): View { diff --git a/app/PaymentDrivers/Square/CreditCard.php b/app/PaymentDrivers/Square/CreditCard.php index 080356edc357..55b11b98f62d 100644 --- a/app/PaymentDrivers/Square/CreditCard.php +++ b/app/PaymentDrivers/Square/CreditCard.php @@ -12,23 +12,22 @@ namespace App\PaymentDrivers\Square; +use App\Exceptions\PaymentFailed; +use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; +use App\Jobs\Util\SystemLogger; +use App\Models\ClientGatewayToken; +use App\Models\GatewayType; use App\Models\Invoice; use App\Models\Payment; -use App\Models\SystemLog; -use Illuminate\View\View; -use App\Models\GatewayType; use App\Models\PaymentType; -use Illuminate\Support\Str; -use Illuminate\Http\Request; -use Square\Http\ApiResponse; -use App\Jobs\Util\SystemLogger; -use App\Utils\Traits\MakesHash; -use App\Exceptions\PaymentFailed; -use App\Models\ClientGatewayToken; -use Illuminate\Http\RedirectResponse; -use App\PaymentDrivers\SquarePaymentDriver; +use App\Models\SystemLog; use App\PaymentDrivers\Common\MethodInterface; -use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; +use App\PaymentDrivers\SquarePaymentDriver; +use App\Utils\Traits\MakesHash; +use Illuminate\Http\RedirectResponse; +use Illuminate\Http\Request; +use Illuminate\View\View; +use Square\Http\ApiResponse; class CreditCard implements MethodInterface { @@ -43,7 +42,7 @@ class CreditCard implements MethodInterface * Authorization page for credit card. * * @param array $data - * @return \Illuminate\View\View + * @return \Illuminate\View\View */ public function authorizeView($data): View { @@ -125,7 +124,7 @@ class CreditCard implements MethodInterface if ($request->shouldUseToken()) { $body->setCustomerId($cgt->gateway_customer_reference); - }elseif ($request->has('verificationToken') && $request->input('verificationToken')) { + } elseif ($request->has('verificationToken') && $request->input('verificationToken')) { $body->setVerificationToken($request->input('verificationToken')); } @@ -135,7 +134,7 @@ class CreditCard implements MethodInterface $body = json_decode($response->getBody()); - if($request->store_card){ + if($request->store_card) { $this->createCard($body->payment->id); } @@ -232,8 +231,7 @@ class CreditCard implements MethodInterface return $this->square_driver->processInternallyFailedPayment($this->square_driver, $e); } - } - else { + } else { throw new PaymentFailed($body->errors[0]->detail, 500); } diff --git a/app/PaymentDrivers/Square/SquareWebhook.php b/app/PaymentDrivers/Square/SquareWebhook.php index 67d656e8c926..42757f8a1125 100644 --- a/app/PaymentDrivers/Square/SquareWebhook.php +++ b/app/PaymentDrivers/Square/SquareWebhook.php @@ -11,22 +11,22 @@ namespace App\PaymentDrivers\Square; -use App\Models\Payment; -use App\Models\SystemLog; +use App\Jobs\Mail\PaymentFailedMailer; +use App\Jobs\Util\SystemLogger; use App\Libraries\MultiDB; +use App\Models\CompanyGateway; use App\Models\GatewayType; +use App\Models\Payment; use App\Models\PaymentHash; use App\Models\PaymentType; -use Illuminate\Bus\Queueable; -use App\Models\CompanyGateway; -use App\Jobs\Util\SystemLogger; -use App\Jobs\Mail\PaymentFailedMailer; -use Illuminate\Queue\SerializesModels; -use App\PaymentDrivers\Stripe\Utilities; -use Illuminate\Queue\InteractsWithQueue; +use App\Models\SystemLog; use App\PaymentDrivers\SquarePaymentDriver; +use App\PaymentDrivers\Stripe\Utilities; +use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Queue\SerializesModels; class SquareWebhook implements ShouldQueue { @@ -43,13 +43,13 @@ class SquareWebhook implements ShouldQueue public \Square\SquareClient $square; private array $source_type = [ - 'CARD' => PaymentType::CREDIT_CARD_OTHER, - 'BANK_ACCOUNT' => PaymentType::ACH, - 'WALLET' => PaymentType::CREDIT_CARD_OTHER, - 'BUY_NOW_PAY_LATER' => PaymentType::CREDIT_CARD_OTHER, - 'SQUARE_ACCOUNT' => PaymentType::CREDIT_CARD_OTHER, - 'CASH' => PaymentType::CASH, - 'EXTERNAL' =>PaymentType::CREDIT_CARD_OTHER + 'CARD' => PaymentType::CREDIT_CARD_OTHER, + 'BANK_ACCOUNT' => PaymentType::ACH, + 'WALLET' => PaymentType::CREDIT_CARD_OTHER, + 'BUY_NOW_PAY_LATER' => PaymentType::CREDIT_CARD_OTHER, + 'SQUARE_ACCOUNT' => PaymentType::CREDIT_CARD_OTHER, + 'CASH' => PaymentType::CASH, + 'EXTERNAL' =>PaymentType::CREDIT_CARD_OTHER ]; public function __construct(public array $webhook_array, public string $company_key, public int $company_gateway_id) @@ -71,7 +71,7 @@ class SquareWebhook implements ShouldQueue $payment_status = false; - match($status){ + match($status) { 'APPROVED' => $payment_status = false, 'COMPLETED' => $payment_status = Payment::STATUS_COMPLETED, 'PENDING' => $payment_status = Payment::STATUS_PENDING, @@ -80,7 +80,7 @@ class SquareWebhook implements ShouldQueue default => $payment_status = false, }; - if(!$payment_status){ + if(!$payment_status) { nlog("Square Webhook - Payment Status Not Found or not worthy of processing"); nlog($this->webhook_array); } @@ -88,13 +88,13 @@ class SquareWebhook implements ShouldQueue $payment = $this->retrieveOrCreatePayment($payment_id, $payment_status); /** If the status was pending and now is reporting as Failed / Cancelled - process failure path */ - if($payment->status_id == Payment::STATUS_PENDING && in_array($payment_status, [Payment::STATUS_CANCELLED, Payment::STATUS_FAILED])){ + if($payment->status_id == Payment::STATUS_PENDING && in_array($payment_status, [Payment::STATUS_CANCELLED, Payment::STATUS_FAILED])) { $payment->service()->deletePayment(); if ($this->driver->payment_hash) { $error = ctrans('texts.client_payment_failure_body', [ 'invoice' => implode(',', $payment->invoices->pluck('number')->toArray()), - 'amount' => array_sum(array_column($this->driver->payment_hash->invoices(), 'amount')) + $this->driver->payment_hash->fee_total, + 'amount' => array_sum(array_column($this->driver->payment_hash->invoices(), 'amount')) + $this->driver->payment_hash->fee_total, ]); } else { $error = 'Payment for '.$payment->client->present()->name()." for {$payment->amount} failed"; @@ -107,8 +107,7 @@ class SquareWebhook implements ShouldQueue $error ); - } - elseif($payment->status_id == Payment::STATUS_PENDING && in_array($payment_status, [Payment::STATUS_COMPLETED, Payment::STATUS_COMPLETED])){ + } elseif($payment->status_id == Payment::STATUS_PENDING && in_array($payment_status, [Payment::STATUS_COMPLETED, Payment::STATUS_COMPLETED])) { $payment->status_id = Payment::STATUS_COMPLETED; $payment->save(); } @@ -130,7 +129,7 @@ class SquareWebhook implements ShouldQueue nlog("searching square for payment"); - if($apiResponse->isSuccess()){ + if($apiResponse->isSuccess()) { nlog("Searching by payment hash"); @@ -166,11 +165,10 @@ class SquareWebhook implements ShouldQueue return $payment; - } - else{ + } else { nlog("Square Webhook - Payment not found: {$payment_reference}"); nlog($apiResponse->getErrors()); return null; } } -} \ No newline at end of file +} diff --git a/app/PaymentDrivers/SquarePaymentDriver.php b/app/PaymentDrivers/SquarePaymentDriver.php index 5e6e3ecbb738..a52f0e44ad39 100644 --- a/app/PaymentDrivers/SquarePaymentDriver.php +++ b/app/PaymentDrivers/SquarePaymentDriver.php @@ -11,22 +11,22 @@ namespace App\PaymentDrivers; +use App\Http\Requests\Payments\PaymentWebhookRequest; +use App\Jobs\Util\SystemLogger; +use App\Models\ClientGatewayToken; +use App\Models\GatewayType; use App\Models\Invoice; use App\Models\Payment; -use App\Models\SystemLog; -use App\Models\GatewayType; use App\Models\PaymentHash; use App\Models\PaymentType; -use App\Jobs\Util\SystemLogger; -use App\Utils\Traits\MakesHash; -use Square\Utils\WebhooksHelper; -use App\Models\ClientGatewayToken; -use Square\Models\WebhookSubscription; +use App\Models\SystemLog; use App\PaymentDrivers\Square\CreditCard; use App\PaymentDrivers\Square\SquareWebhook; -use Square\Models\CreateWebhookSubscriptionRequest; -use App\Http\Requests\Payments\PaymentWebhookRequest; +use App\Utils\Traits\MakesHash; use Square\Models\Builders\RefundPaymentRequestBuilder; +use Square\Models\CreateWebhookSubscriptionRequest; +use Square\Models\WebhookSubscription; +use Square\Utils\WebhooksHelper; class SquarePaymentDriver extends BaseDriver { @@ -128,7 +128,7 @@ class SquarePaymentDriver extends BaseDriver $status = $refundPaymentResponse->getRefund()->getStatus(); - if(in_array($status, ['COMPLETED', 'PENDING'])){ + if(in_array($status, ['COMPLETED', 'PENDING'])) { $transaction_reference = $refundPaymentResponse->getRefund()->getId(); @@ -153,8 +153,7 @@ class SquarePaymentDriver extends BaseDriver ); return $data; - } - elseif(in_array($status, ['REJECTED', 'FAILED'])) { + } elseif(in_array($status, ['REJECTED', 'FAILED'])) { $transaction_reference = $refundPaymentResponse->getRefund()->getId(); @@ -194,17 +193,17 @@ class SquarePaymentDriver extends BaseDriver 'code' => $error->getCode(), ]; - SystemLogger::dispatch( - [ - 'server_response' => $data, - 'data' => request()->all() - ], - SystemLog::CATEGORY_GATEWAY_RESPONSE, - SystemLog::EVENT_GATEWAY_FAILURE, - SystemLog::TYPE_SQUARE, - $this->client, - $this->client->company - ); + SystemLogger::dispatch( + [ + 'server_response' => $data, + 'data' => request()->all() + ], + SystemLog::CATEGORY_GATEWAY_RESPONSE, + SystemLog::EVENT_GATEWAY_FAILURE, + SystemLog::TYPE_SQUARE, + $this->client, + $this->client->company + ); return $data; } @@ -234,7 +233,7 @@ class SquarePaymentDriver extends BaseDriver $body->setCustomerId($cgt->gateway_customer_reference); $body->setAmountMoney($amount_money); $body->setReferenceId($payment_hash->hash); - $body->setNote(substr($description,0,500)); + $body->setNote(substr($description, 0, 500)); $response = $this->square->getPaymentsApi()->createPayment($body); $body = json_decode($response->getBody()); @@ -292,10 +291,10 @@ class SquarePaymentDriver extends BaseDriver if ($api_response->isSuccess()) { //array of WebhookSubscription objects - foreach($api_response->getResult()->getSubscriptions() ?? [] as $subscription) - { - if($subscription->getName() == 'Invoice_Ninja_Webhook_Subscription') - return $subscription->getId(); + foreach($api_response->getResult()->getSubscriptions() ?? [] as $subscription) { + if($subscription->getName() == 'Invoice_Ninja_Webhook_Subscription') { + return $subscription->getId(); + } } } else { @@ -327,8 +326,9 @@ class SquarePaymentDriver extends BaseDriver public function createWebhooks(): void { - if($this->checkWebhooks()) + if($this->checkWebhooks()) { return; + } $this->init(); @@ -367,7 +367,7 @@ class SquarePaymentDriver extends BaseDriver $signature_key = $this->company_gateway->getConfigField('signatureKey'); $notification_url = $this->company_gateway->webhookUrl(); - $body = ''; + $body = ''; $handle = fopen('php://input', 'r'); while(!feof($handle)) { $body .= fread($handle, 1024); @@ -394,8 +394,8 @@ class SquarePaymentDriver extends BaseDriver //getsubscriptionid here $subscription_id = $this->checkWebhooks(); - if(!$subscription_id){ - nlog('No Subscription Found'); + if(!$subscription_id) { + nlog('No Subscription Found'); return; } diff --git a/app/PaymentDrivers/Stripe/ACH.php b/app/PaymentDrivers/Stripe/ACH.php index cf31a8a6dd26..de2c4f3cf68f 100644 --- a/app/PaymentDrivers/Stripe/ACH.php +++ b/app/PaymentDrivers/Stripe/ACH.php @@ -193,8 +193,9 @@ class ACH $meta = $token->meta; - if(isset($meta->state) && $meta->state == 'unauthorized') + if(isset($meta->state) && $meta->state == 'unauthorized') { return redirect()->route('client.payment_methods.show', $token->hashed_id); + } } if (count($data['tokens']) == 0) { @@ -595,8 +596,9 @@ class ACH 'company_id' => $this->stripe->client->company_id, ])->first(); - if($token) + if($token) { return $token; + } return $this->stripe->storeGatewayToken($data, ['gateway_customer_reference' => $customer->id]); } catch (Exception $e) { diff --git a/app/PaymentDrivers/Stripe/Jobs/ChargeRefunded.php b/app/PaymentDrivers/Stripe/Jobs/ChargeRefunded.php index d0393dd2e752..a3628e7d44e9 100644 --- a/app/PaymentDrivers/Stripe/Jobs/ChargeRefunded.php +++ b/app/PaymentDrivers/Stripe/Jobs/ChargeRefunded.php @@ -11,18 +11,18 @@ namespace App\PaymentDrivers\Stripe\Jobs; -use App\Models\Company; -use App\Models\Payment; use App\Libraries\MultiDB; -use App\Models\PaymentHash; -use Illuminate\Bus\Queueable; +use App\Models\Company; use App\Models\CompanyGateway; -use Illuminate\Queue\SerializesModels; +use App\Models\Payment; +use App\Models\PaymentHash; use App\PaymentDrivers\Stripe\Utilities; -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\Middleware\WithoutOverlapping; +use Illuminate\Queue\SerializesModels; class ChargeRefunded implements ShouldQueue { @@ -93,10 +93,10 @@ class ChargeRefunded implements ShouldQueue if($payment->status_id == Payment::STATUS_COMPLETED) { $invoice_collection = $payment->paymentables - ->where('paymentable_type','invoices') - ->map(function ($pivot){ + ->where('paymentable_type', 'invoices') + ->map(function ($pivot) { return [ - 'invoice_id' => $pivot->paymentable_id, + 'invoice_id' => $pivot->paymentable_id, 'amount' => $pivot->amount - $pivot->refunded ]; }); @@ -106,15 +106,14 @@ class ChargeRefunded implements ShouldQueue $invoice_collection = $payment->paymentables ->where('paymentable_type', 'invoices') - ->map(function ($pivot) use ($amount_refunded){ + ->map(function ($pivot) use ($amount_refunded) { return [ 'invoice_id' => $pivot->paymentable_id, 'amount' => $amount_refunded ]; }); - } - elseif($invoice_collection->sum('amount') != $amount_refunded) { + } elseif($invoice_collection->sum('amount') != $amount_refunded) { //too many edges cases at this point, return early return; } diff --git a/app/PaymentDrivers/Stripe/SEPA.php b/app/PaymentDrivers/Stripe/SEPA.php index 1023d8ff6580..cd999ba76e64 100644 --- a/app/PaymentDrivers/Stripe/SEPA.php +++ b/app/PaymentDrivers/Stripe/SEPA.php @@ -11,15 +11,15 @@ namespace App\PaymentDrivers\Stripe; -use App\Models\Payment; -use App\Models\SystemLog; -use App\Models\GatewayType; -use App\Models\PaymentType; -use App\Jobs\Util\SystemLogger; use App\Exceptions\PaymentFailed; -use App\Models\ClientGatewayToken; -use App\PaymentDrivers\StripePaymentDriver; use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; +use App\Jobs\Util\SystemLogger; +use App\Models\ClientGatewayToken; +use App\Models\GatewayType; +use App\Models\Payment; +use App\Models\PaymentType; +use App\Models\SystemLog; +use App\PaymentDrivers\StripePaymentDriver; class SEPA { diff --git a/app/PaymentDrivers/Stripe/UpdatePaymentMethods.php b/app/PaymentDrivers/Stripe/UpdatePaymentMethods.php index 58ff84400fcc..5b7239f50fca 100644 --- a/app/PaymentDrivers/Stripe/UpdatePaymentMethods.php +++ b/app/PaymentDrivers/Stripe/UpdatePaymentMethods.php @@ -208,24 +208,24 @@ class UpdatePaymentMethods switch ($type_id) { case GatewayType::CREDIT_CARD: - /** - * @class \Stripe\PaymentMethod $method - * @property \Stripe\StripeObject $card - * @class \Stripe\StripeObject $card - * @property string $exp_year - * @property string $exp_month - * @property string $brand - * @property string $last4 - */ + /** + * @class \Stripe\PaymentMethod $method + * @property \Stripe\StripeObject $card + * @class \Stripe\StripeObject $card + * @property string $exp_year + * @property string $exp_month + * @property string $brand + * @property string $last4 + */ - $payment_meta = new \stdClass; - $payment_meta->exp_month = (string) $method->card->exp_month; - $payment_meta->exp_year = (string) $method->card->exp_year; - $payment_meta->brand = (string) $method->card->brand; - $payment_meta->last4 = (string) $method->card->last4; - $payment_meta->type = GatewayType::CREDIT_CARD; + $payment_meta = new \stdClass; + $payment_meta->exp_month = (string) $method->card->exp_month; + $payment_meta->exp_year = (string) $method->card->exp_year; + $payment_meta->brand = (string) $method->card->brand; + $payment_meta->last4 = (string) $method->card->last4; + $payment_meta->type = GatewayType::CREDIT_CARD; - return $payment_meta; + return $payment_meta; case GatewayType::ALIPAY: case GatewayType::SOFORT: diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index a80c09789dcd..e4b75a023a3c 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -345,7 +345,7 @@ class StripePaymentDriver extends BaseDriver if ($this->company_gateway->require_billing_address) { $fields[] = ['name' => 'client_address_line_1', 'label' => ctrans('texts.address1'), 'type' => 'text', 'validation' => 'required']; -// $fields[] = ['name' => 'client_address_line_2', 'label' => ctrans('texts.address2'), 'type' => 'text', 'validation' => 'nullable']; + // $fields[] = ['name' => 'client_address_line_2', 'label' => ctrans('texts.address2'), 'type' => 'text', 'validation' => 'nullable']; $fields[] = ['name' => 'client_city', 'label' => ctrans('texts.city'), 'type' => 'text', 'validation' => 'required']; $fields[] = ['name' => 'client_state', 'label' => ctrans('texts.state'), 'type' => 'text', 'validation' => 'required']; $fields[] = ['name' => 'client_country_id', 'label' => ctrans('texts.country'), 'type' => 'text', 'validation' => 'required']; @@ -357,7 +357,7 @@ class StripePaymentDriver extends BaseDriver if ($this->company_gateway->require_shipping_address) { $fields[] = ['name' => 'client_shipping_address_line_1', 'label' => ctrans('texts.shipping_address1'), 'type' => 'text', 'validation' => 'required']; -// $fields[] = ['name' => 'client_shipping_address_line_2', 'label' => ctrans('texts.shipping_address2'), 'type' => 'text', 'validation' => 'sometimes']; + // $fields[] = ['name' => 'client_shipping_address_line_2', 'label' => ctrans('texts.shipping_address2'), 'type' => 'text', 'validation' => 'sometimes']; $fields[] = ['name' => 'client_shipping_city', 'label' => ctrans('texts.shipping_city'), 'type' => 'text', 'validation' => 'required']; $fields[] = ['name' => 'client_shipping_state', 'label' => ctrans('texts.shipping_state'), 'type' => 'text', 'validation' => 'required']; $fields[] = ['name' => 'client_shipping_postal_code', 'label' => ctrans('texts.shipping_postal_code'), 'type' => 'text', 'validation' => 'required']; @@ -783,8 +783,9 @@ class StripePaymentDriver extends BaseDriver ->where('token', $request->data['object']['payment_method']) ->first(); - if($clientgateway) + if($clientgateway) { $clientgateway->delete(); + } return response()->json([], 200); } elseif ($request->data['object']['status'] == "pending") { diff --git a/app/PaymentDrivers/WePay/ACH.php b/app/PaymentDrivers/WePay/ACH.php index 945924ffc341..3835b9630baf 100644 --- a/app/PaymentDrivers/WePay/ACH.php +++ b/app/PaymentDrivers/WePay/ACH.php @@ -113,7 +113,7 @@ class ACH } /* If the bank transfer token is PENDING - we need to verify!! */ -// + // public function verificationView(ClientGatewayToken $token) { diff --git a/app/PaymentDrivers/WePayPaymentDriver.php b/app/PaymentDrivers/WePayPaymentDriver.php index ec521443850b..9bb9a44cfc6b 100644 --- a/app/PaymentDrivers/WePayPaymentDriver.php +++ b/app/PaymentDrivers/WePayPaymentDriver.php @@ -89,7 +89,7 @@ class WePayPaymentDriver extends BaseDriver * Setup the gateway * * @param array $data user_id + company - * @return \Illuminate\View\View + * @return \Illuminate\View\View */ public function setup(array $data) { @@ -330,7 +330,7 @@ class WePayPaymentDriver extends BaseDriver if ($this->company_gateway->require_billing_address) { $fields[] = ['name' => 'client_address_line_1', 'label' => ctrans('texts.address1'), 'type' => 'text', 'validation' => 'required']; -// $fields[] = ['name' => 'client_address_line_2', 'label' => ctrans('texts.address2'), 'type' => 'text', 'validation' => 'nullable']; + // $fields[] = ['name' => 'client_address_line_2', 'label' => ctrans('texts.address2'), 'type' => 'text', 'validation' => 'nullable']; $fields[] = ['name' => 'client_city', 'label' => ctrans('texts.city'), 'type' => 'text', 'validation' => 'required']; $fields[] = ['name' => 'client_state', 'label' => ctrans('texts.state'), 'type' => 'text', 'validation' => 'required']; $fields[] = ['name' => 'client_country_id', 'label' => ctrans('texts.country'), 'type' => 'text', 'validation' => 'required']; @@ -338,7 +338,7 @@ class WePayPaymentDriver extends BaseDriver if ($this->company_gateway->require_shipping_address) { $fields[] = ['name' => 'client_shipping_address_line_1', 'label' => ctrans('texts.shipping_address1'), 'type' => 'text', 'validation' => 'required']; -// $fields[] = ['name' => 'client_shipping_address_line_2', 'label' => ctrans('texts.shipping_address2'), 'type' => 'text', 'validation' => 'sometimes']; + // $fields[] = ['name' => 'client_shipping_address_line_2', 'label' => ctrans('texts.shipping_address2'), 'type' => 'text', 'validation' => 'sometimes']; $fields[] = ['name' => 'client_shipping_city', 'label' => ctrans('texts.shipping_city'), 'type' => 'text', 'validation' => 'required']; $fields[] = ['name' => 'client_shipping_state', 'label' => ctrans('texts.shipping_state'), 'type' => 'text', 'validation' => 'required']; $fields[] = ['name' => 'client_shipping_postal_code', 'label' => ctrans('texts.shipping_postal_code'), 'type' => 'text', 'validation' => 'required']; diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 089287512bfd..0b4a78cc1527 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -11,25 +11,23 @@ namespace App\Providers; -use App\Utils\Ninja; -use Livewire\Livewire; +use App\Helpers\Mail\GmailTransport; +use App\Helpers\Mail\Office365MailTransport; +use App\Http\Middleware\SetDomainNameDb; use App\Models\Invoice; use App\Models\Proposal; +use App\Utils\Ninja; use App\Utils\TruthSource; +use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Mail\Mailer; +use Illuminate\Queue\Events\JobProcessing; use Illuminate\Support\Facades\App; -use App\Helpers\Mail\GmailTransport; -use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Blade; +use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Queue; use Illuminate\Support\Facades\Schema; -use Illuminate\Support\Facades\Artisan; use Illuminate\Support\ServiceProvider; -use App\Http\Middleware\SetDomainNameDb; -use Illuminate\Queue\Events\JobProcessing; -use App\Helpers\Mail\Office365MailTransport; -use Illuminate\Support\Facades\ParallelTesting; -use Illuminate\Database\Eloquent\Relations\Relation; +use Livewire\Livewire; class AppServiceProvider extends ServiceProvider { @@ -105,7 +103,7 @@ class AppServiceProvider extends ServiceProvider Mailer::macro('mailgun_config', function (string $secret, string $domain, string $endpoint = 'api.mailgun.net') { // @phpstan-ignore /** @phpstan-ignore-next-line **/ - Mailer::setSymfonyTransport(app('mail.manager')->createSymfonyTransport([ + Mailer::setSymfonyTransport(app('mail.manager')->createSymfonyTransport([ 'transport' => 'mailgun', 'secret' => $secret, 'domain' => $domain, diff --git a/app/Providers/ClientPortalServiceProvider.php b/app/Providers/ClientPortalServiceProvider.php index a4ac3c02d904..9c781b417b32 100644 --- a/app/Providers/ClientPortalServiceProvider.php +++ b/app/Providers/ClientPortalServiceProvider.php @@ -14,7 +14,7 @@ class ClientPortalServiceProvider extends ServiceProvider */ public function register() { - app()->bind('customMessage', function () { + app()->bind('customMessage', function () { return new CustomMessage(); }); diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 9a2d4754af0f..8c4448b2304a 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -11,271 +11,268 @@ namespace App\Providers; -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\Events\Account\AccountCreated; +use App\Events\Account\StripeConnectFailure; +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\Company\CompanyDocumentsDeleted; +use App\Events\Contact\ContactLoggedIn; +use App\Events\Credit\CreditWasArchived; +use App\Events\Credit\CreditWasCreated; +use App\Events\Credit\CreditWasDeleted; +use App\Events\Credit\CreditWasEmailed; +use App\Events\Credit\CreditWasEmailedAndFailed; +use App\Events\Credit\CreditWasMarkedSent; +use App\Events\Credit\CreditWasRestored; +use App\Events\Credit\CreditWasUpdated; +use App\Events\Credit\CreditWasViewed; +use App\Events\Design\DesignWasArchived; +use App\Events\Design\DesignWasDeleted; +use App\Events\Design\DesignWasRestored; +use App\Events\Design\DesignWasUpdated; +use App\Events\Document\DocumentWasArchived; +use App\Events\Document\DocumentWasCreated; +use App\Events\Document\DocumentWasDeleted; +use App\Events\Document\DocumentWasRestored; +use App\Events\Document\DocumentWasUpdated; +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\InvoiceReminderWasEmailed; +use App\Events\Invoice\InvoiceWasArchived; +use App\Events\Invoice\InvoiceWasCancelled; +use App\Events\Invoice\InvoiceWasCreated; +use App\Events\Invoice\InvoiceWasDeleted; +use App\Events\Invoice\InvoiceWasEmailed; +use App\Events\Invoice\InvoiceWasEmailedAndFailed; +use App\Events\Invoice\InvoiceWasMarkedSent; +use App\Events\Invoice\InvoiceWasPaid; +use App\Events\Invoice\InvoiceWasRestored; +use App\Events\Invoice\InvoiceWasReversed; +use App\Events\Invoice\InvoiceWasUpdated; +use App\Events\Invoice\InvoiceWasViewed; +use App\Events\Misc\InvitationWasViewed; +use App\Events\Payment\PaymentWasArchived; +use App\Events\Payment\PaymentWasCreated; +use App\Events\Payment\PaymentWasDeleted; +use App\Events\Payment\PaymentWasEmailed; +use App\Events\Payment\PaymentWasEmailedAndFailed; +use App\Events\Payment\PaymentWasRefunded; +use App\Events\Payment\PaymentWasRestored; +use App\Events\Payment\PaymentWasUpdated; +use App\Events\Payment\PaymentWasVoided; +use App\Events\PurchaseOrder\PurchaseOrderWasAccepted; +use App\Events\PurchaseOrder\PurchaseOrderWasArchived; +use App\Events\PurchaseOrder\PurchaseOrderWasCreated; +use App\Events\PurchaseOrder\PurchaseOrderWasDeleted; +use App\Events\PurchaseOrder\PurchaseOrderWasEmailed; +use App\Events\PurchaseOrder\PurchaseOrderWasRestored; +use App\Events\PurchaseOrder\PurchaseOrderWasUpdated; +use App\Events\PurchaseOrder\PurchaseOrderWasViewed; +use App\Events\Quote\QuoteWasApproved; +use App\Events\Quote\QuoteWasArchived; +use App\Events\Quote\QuoteWasCreated; +use App\Events\Quote\QuoteWasDeleted; +use App\Events\Quote\QuoteWasEmailed; +use App\Events\Quote\QuoteWasRestored; +use App\Events\Quote\QuoteWasUpdated; +use App\Events\Quote\QuoteWasViewed; +use App\Events\RecurringExpense\RecurringExpenseWasArchived; +use App\Events\RecurringExpense\RecurringExpenseWasCreated; +use App\Events\RecurringExpense\RecurringExpenseWasDeleted; +use App\Events\RecurringExpense\RecurringExpenseWasRestored; +use App\Events\RecurringExpense\RecurringExpenseWasUpdated; +use App\Events\RecurringInvoice\RecurringInvoiceWasArchived; +use App\Events\RecurringInvoice\RecurringInvoiceWasCreated; +use App\Events\RecurringInvoice\RecurringInvoiceWasDeleted; +use App\Events\RecurringInvoice\RecurringInvoiceWasRestored; +use App\Events\RecurringInvoice\RecurringInvoiceWasUpdated; +use App\Events\RecurringQuote\RecurringQuoteWasArchived; +use App\Events\RecurringQuote\RecurringQuoteWasCreated; +use App\Events\RecurringQuote\RecurringQuoteWasDeleted; +use App\Events\RecurringQuote\RecurringQuoteWasRestored; +use App\Events\RecurringQuote\RecurringQuoteWasUpdated; +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\UserLoggedIn; +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\VendorContactLoggedIn; +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\Listeners\Account\StripeConnectFailureListener; +use App\Listeners\Activity\ArchivedClientActivity; +use App\Listeners\Activity\ClientUpdatedActivity; +use App\Listeners\Activity\CreatedClientActivity; +use App\Listeners\Activity\CreatedCreditActivity; +use App\Listeners\Activity\CreatedExpenseActivity; +use App\Listeners\Activity\CreatedQuoteActivity; +use App\Listeners\Activity\CreatedSubscriptionActivity; +use App\Listeners\Activity\CreatedTaskActivity; +use App\Listeners\Activity\CreatedVendorActivity; +use App\Listeners\Activity\CreditArchivedActivity; +use App\Listeners\Activity\DeleteClientActivity; +use App\Listeners\Activity\DeleteCreditActivity; +use App\Listeners\Activity\ExpenseArchivedActivity; +use App\Listeners\Activity\ExpenseDeletedActivity; +use App\Listeners\Activity\ExpenseRestoredActivity; +use App\Listeners\Activity\ExpenseUpdatedActivity; +use App\Listeners\Activity\PaymentArchivedActivity; +use App\Listeners\Activity\PaymentCreatedActivity; +use App\Listeners\Activity\PaymentDeletedActivity; +use App\Listeners\Activity\PaymentRefundedActivity; +use App\Listeners\Activity\PaymentUpdatedActivity; +use App\Listeners\Activity\PaymentVoidedActivity; +use App\Listeners\Activity\QuoteUpdatedActivity; +use App\Listeners\Activity\RestoreClientActivity; +use App\Listeners\Activity\SubscriptionArchivedActivity; +use App\Listeners\Activity\SubscriptionDeletedActivity; +use App\Listeners\Activity\SubscriptionRestoredActivity; +use App\Listeners\Activity\SubscriptionUpdatedActivity; +use App\Listeners\Activity\TaskArchivedActivity; +use App\Listeners\Activity\TaskDeletedActivity; +use App\Listeners\Activity\TaskRestoredActivity; +use App\Listeners\Activity\TaskUpdatedActivity; +use App\Listeners\Activity\UpdatedCreditActivity; +use App\Listeners\Activity\VendorArchivedActivity; +use App\Listeners\Activity\VendorDeletedActivity; +use App\Listeners\Activity\VendorRestoredActivity; +use App\Listeners\Activity\VendorUpdatedActivity; +use App\Listeners\Contact\UpdateContactLastLogin; +use App\Listeners\Credit\CreditCreatedNotification; +use App\Listeners\Credit\CreditEmailedNotification; +use App\Listeners\Credit\CreditRestoredActivity; +use App\Listeners\Credit\CreditViewedActivity; +use App\Listeners\Document\DeleteCompanyDocuments; +use App\Listeners\Invoice\CreateInvoiceActivity; +use App\Listeners\Invoice\InvoiceArchivedActivity; +use App\Listeners\Invoice\InvoiceCancelledActivity; +use App\Listeners\Invoice\InvoiceCreatedNotification; +use App\Listeners\Invoice\InvoiceDeletedActivity; +use App\Listeners\Invoice\InvoiceEmailActivity; +use App\Listeners\Invoice\InvoiceEmailedNotification; +use App\Listeners\Invoice\InvoiceEmailFailedActivity; +use App\Listeners\Invoice\InvoiceFailedEmailNotification; +use App\Listeners\Invoice\InvoicePaidActivity; +use App\Listeners\Invoice\InvoiceReminderEmailActivity; +use App\Listeners\Invoice\InvoiceRestoredActivity; +use App\Listeners\Invoice\InvoiceReversedActivity; +use App\Listeners\Invoice\InvoiceViewedActivity; +use App\Listeners\Invoice\UpdateInvoiceActivity; +use App\Listeners\Mail\MailSentListener; +use App\Listeners\Misc\InvitationViewedListener; +use App\Listeners\Payment\PaymentBalanceActivity; +use App\Listeners\Payment\PaymentEmailedActivity; +use App\Listeners\Payment\PaymentEmailFailureActivity; +use App\Listeners\Payment\PaymentNotification; +use App\Listeners\Payment\PaymentRestoredActivity; +use App\Listeners\PurchaseOrder\CreatePurchaseOrderActivity; +use App\Listeners\PurchaseOrder\PurchaseOrderAcceptedActivity; +use App\Listeners\PurchaseOrder\PurchaseOrderAcceptedListener; +use App\Listeners\PurchaseOrder\PurchaseOrderArchivedActivity; +use App\Listeners\PurchaseOrder\PurchaseOrderCreatedListener; +use App\Listeners\PurchaseOrder\PurchaseOrderDeletedActivity; +use App\Listeners\PurchaseOrder\PurchaseOrderEmailActivity; +use App\Listeners\PurchaseOrder\PurchaseOrderEmailedNotification; +use App\Listeners\PurchaseOrder\PurchaseOrderRestoredActivity; +use App\Listeners\PurchaseOrder\PurchaseOrderViewedActivity; +use App\Listeners\PurchaseOrder\UpdatePurchaseOrderActivity; +use App\Listeners\Quote\QuoteApprovedActivity; +use App\Listeners\Quote\QuoteApprovedNotification; +use App\Listeners\Quote\QuoteApprovedWebhook; +use App\Listeners\Quote\QuoteArchivedActivity; +use App\Listeners\Quote\QuoteCreatedNotification; +use App\Listeners\Quote\QuoteDeletedActivity; +use App\Listeners\Quote\QuoteEmailActivity; +use App\Listeners\Quote\QuoteEmailedNotification; +use App\Listeners\Quote\QuoteRestoredActivity; +use App\Listeners\Quote\QuoteViewedActivity; +use App\Listeners\Quote\ReachWorkflowSettings; +use App\Listeners\RecurringExpense\CreatedRecurringExpenseActivity; +use App\Listeners\RecurringExpense\RecurringExpenseArchivedActivity; +use App\Listeners\RecurringExpense\RecurringExpenseDeletedActivity; +use App\Listeners\RecurringExpense\RecurringExpenseRestoredActivity; +use App\Listeners\RecurringExpense\RecurringExpenseUpdatedActivity; +use App\Listeners\RecurringInvoice\CreateRecurringInvoiceActivity; +use App\Listeners\RecurringInvoice\RecurringInvoiceArchivedActivity; +use App\Listeners\RecurringInvoice\RecurringInvoiceDeletedActivity; +use App\Listeners\RecurringInvoice\RecurringInvoiceRestoredActivity; +use App\Listeners\RecurringInvoice\UpdateRecurringInvoiceActivity; +use App\Listeners\RecurringQuote\CreateRecurringQuoteActivity; +use App\Listeners\RecurringQuote\RecurringQuoteArchivedActivity; +use App\Listeners\RecurringQuote\RecurringQuoteDeletedActivity; +use App\Listeners\RecurringQuote\RecurringQuoteRestoredActivity; +use App\Listeners\RecurringQuote\UpdateRecurringQuoteActivity; +use App\Listeners\SendVerificationNotification; +use App\Listeners\User\ArchivedUserActivity; +use App\Listeners\User\CreatedUserActivity; +use App\Listeners\User\DeletedUserActivity; +use App\Listeners\User\RestoredUserActivity; +use App\Listeners\User\UpdatedUserActivity; +use App\Listeners\User\UpdateUserLastLogin; +use App\Listeners\Vendor\UpdateVendorContactLastLogin; use App\Models\Account; +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\Expense; use App\Models\Invoice; use App\Models\Payment; use App\Models\Product; use App\Models\Project; use App\Models\Proposal; -use App\Models\CompanyToken; -use App\Models\Subscription; -use App\Models\ClientContact; use App\Models\PurchaseOrder; +use App\Models\Quote; +use App\Models\Subscription; +use App\Models\Task; +use App\Models\User; +use App\Models\Vendor; use App\Models\VendorContact; -use App\Models\CompanyGateway; -use App\Observers\TaskObserver; -use App\Observers\UserObserver; -use App\Observers\QuoteObserver; -use App\Events\User\UserLoggedIn; -use App\Observers\ClientObserver; -use App\Observers\CreditObserver; -use App\Observers\VendorObserver; use App\Observers\AccountObserver; +use App\Observers\ClientContactObserver; +use App\Observers\ClientObserver; +use App\Observers\CompanyGatewayObserver; use App\Observers\CompanyObserver; +use App\Observers\CompanyTokenObserver; +use App\Observers\CreditObserver; use App\Observers\ExpenseObserver; use App\Observers\InvoiceObserver; use App\Observers\PaymentObserver; use App\Observers\ProductObserver; use App\Observers\ProjectObserver; -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\Observers\ProposalObserver; -use App\Events\Quote\QuoteWasViewed; -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\QuoteWasEmailed; -use App\Events\Quote\QuoteWasUpdated; -use App\Events\Account\AccountCreated; -use App\Events\Credit\CreditWasViewed; -use App\Events\Invoice\InvoiceWasPaid; -use App\Events\Quote\QuoteWasApproved; -use App\Events\Quote\QuoteWasArchived; -use App\Events\Quote\QuoteWasRestored; -use App\Events\Client\ClientWasCreated; -use App\Events\Client\ClientWasDeleted; -use App\Events\Client\ClientWasUpdated; -use App\Events\Contact\ContactLoggedIn; -use App\Events\Credit\CreditWasCreated; -use App\Events\Credit\CreditWasDeleted; -use App\Events\Credit\CreditWasEmailed; -use App\Events\Credit\CreditWasUpdated; -use App\Events\Design\DesignWasDeleted; -use App\Events\Design\DesignWasUpdated; -use App\Events\Vendor\VendorWasCreated; -use App\Events\Vendor\VendorWasDeleted; -use App\Events\Vendor\VendorWasUpdated; -use App\Observers\CompanyTokenObserver; -use App\Observers\SubscriptionObserver; -use Illuminate\Mail\Events\MessageSent; -use App\Events\Client\ClientWasArchived; -use App\Events\Client\ClientWasRestored; -use App\Events\Credit\CreditWasArchived; -use App\Events\Credit\CreditWasRestored; -use App\Events\Design\DesignWasArchived; -use App\Events\Design\DesignWasRestored; -use App\Events\Invoice\InvoiceWasViewed; -use App\Events\Misc\InvitationWasViewed; -use App\Events\Payment\PaymentWasVoided; -use App\Events\Vendor\VendorWasArchived; -use App\Events\Vendor\VendorWasRestored; -use App\Events\Account\StripeConnectFailure; -use App\Listeners\Mail\MailSentListener; -use App\Observers\ClientContactObserver; use App\Observers\PurchaseOrderObserver; +use App\Observers\QuoteObserver; +use App\Observers\SubscriptionObserver; +use App\Observers\TaskObserver; +use App\Observers\UserObserver; use App\Observers\VendorContactObserver; -use App\Events\Expense\ExpenseWasCreated; -use App\Events\Expense\ExpenseWasDeleted; -use App\Events\Expense\ExpenseWasUpdated; -use App\Events\Invoice\InvoiceWasCreated; -use App\Events\Invoice\InvoiceWasDeleted; -use App\Events\Invoice\InvoiceWasEmailed; -use App\Events\Invoice\InvoiceWasUpdated; -use App\Events\Payment\PaymentWasCreated; -use App\Events\Payment\PaymentWasDeleted; -use App\Events\Payment\PaymentWasEmailed; -use App\Events\Payment\PaymentWasUpdated; -use App\Observers\CompanyGatewayObserver; -use App\Events\Credit\CreditWasMarkedSent; -use App\Events\Expense\ExpenseWasArchived; -use App\Events\Expense\ExpenseWasRestored; -use App\Events\Invoice\InvoiceWasArchived; -use App\Events\Invoice\InvoiceWasRestored; -use App\Events\Invoice\InvoiceWasReversed; -use App\Events\Payment\PaymentWasArchived; -use App\Events\Payment\PaymentWasRefunded; -use App\Events\Payment\PaymentWasRestored; -use Illuminate\Mail\Events\MessageSending; -use App\Events\Document\DocumentWasCreated; -use App\Events\Document\DocumentWasDeleted; -use App\Events\Document\DocumentWasUpdated; -use App\Events\Invoice\InvoiceWasCancelled; -use App\Listeners\Quote\QuoteEmailActivity; -use App\Listeners\User\CreatedUserActivity; -use App\Listeners\User\DeletedUserActivity; -use App\Listeners\User\UpdatedUserActivity; -use App\Listeners\User\UpdateUserLastLogin; -use App\Events\Document\DocumentWasArchived; -use App\Events\Document\DocumentWasRestored; -use App\Events\Invoice\InvoiceWasMarkedSent; -use App\Events\Vendor\VendorContactLoggedIn; -use App\Listeners\Quote\QuoteViewedActivity; -use App\Listeners\User\ArchivedUserActivity; -use App\Listeners\User\RestoredUserActivity; -use App\Listeners\Quote\QuoteApprovedWebhook; -use App\Listeners\Quote\QuoteDeletedActivity; -use App\Listeners\Credit\CreditViewedActivity; -use App\Listeners\Invoice\InvoicePaidActivity; -use App\Listeners\Payment\PaymentNotification; -use App\Listeners\Quote\QuoteApprovedActivity; -use App\Listeners\Quote\QuoteArchivedActivity; -use App\Listeners\Quote\QuoteRestoredActivity; -use App\Listeners\Quote\ReachWorkflowSettings; -use App\Events\Company\CompanyDocumentsDeleted; -use App\Listeners\Activity\CreatedTaskActivity; -use App\Listeners\Activity\TaskDeletedActivity; -use App\Listeners\Activity\TaskUpdatedActivity; -use App\Listeners\Invoice\InvoiceEmailActivity; -use App\Listeners\SendVerificationNotification; -use App\Events\Credit\CreditWasEmailedAndFailed; -use App\Listeners\Activity\CreatedQuoteActivity; -use App\Listeners\Activity\DeleteClientActivity; -use App\Listeners\Activity\DeleteCreditActivity; -use App\Listeners\Activity\QuoteUpdatedActivity; -use App\Listeners\Activity\TaskArchivedActivity; -use App\Listeners\Activity\TaskRestoredActivity; -use App\Listeners\Credit\CreditRestoredActivity; -use App\Listeners\Invoice\CreateInvoiceActivity; -use App\Listeners\Invoice\InvoiceViewedActivity; -use App\Listeners\Invoice\UpdateInvoiceActivity; -use App\Listeners\Misc\InvitationViewedListener; -use App\Events\Invoice\InvoiceReminderWasEmailed; -use App\Listeners\Activity\ClientUpdatedActivity; -use App\Listeners\Activity\CreatedClientActivity; -use App\Listeners\Activity\CreatedCreditActivity; -use App\Listeners\Activity\CreatedVendorActivity; -use App\Listeners\Activity\PaymentVoidedActivity; -use App\Listeners\Activity\RestoreClientActivity; -use App\Listeners\Activity\UpdatedCreditActivity; -use App\Listeners\Activity\VendorDeletedActivity; -use App\Listeners\Activity\VendorUpdatedActivity; -use App\Listeners\Contact\UpdateContactLastLogin; -use App\Listeners\Invoice\InvoiceDeletedActivity; -use App\Listeners\Payment\PaymentBalanceActivity; -use App\Listeners\Payment\PaymentEmailedActivity; -use App\Listeners\Quote\QuoteCreatedNotification; -use App\Listeners\Quote\QuoteEmailedNotification; -use App\Events\Invoice\InvoiceWasEmailedAndFailed; -use App\Events\Payment\PaymentWasEmailedAndFailed; -use App\Listeners\Activity\ArchivedClientActivity; -use App\Listeners\Activity\CreatedExpenseActivity; -use App\Listeners\Activity\CreditArchivedActivity; -use App\Listeners\Activity\ExpenseDeletedActivity; -use App\Listeners\Activity\ExpenseUpdatedActivity; -use App\Listeners\Activity\PaymentCreatedActivity; -use App\Listeners\Activity\PaymentDeletedActivity; -use App\Listeners\Activity\PaymentUpdatedActivity; -use App\Listeners\Activity\VendorArchivedActivity; -use App\Listeners\Activity\VendorRestoredActivity; -use App\Listeners\Document\DeleteCompanyDocuments; -use App\Listeners\Invoice\InvoiceArchivedActivity; -use App\Listeners\Invoice\InvoiceRestoredActivity; -use App\Listeners\Invoice\InvoiceReversedActivity; -use App\Listeners\Payment\PaymentRestoredActivity; -use App\Listeners\Quote\QuoteApprovedNotification; -use SocialiteProviders\Apple\AppleExtendSocialite; -use SocialiteProviders\Manager\SocialiteWasCalled; -use App\Events\Subscription\SubscriptionWasCreated; -use App\Events\Subscription\SubscriptionWasDeleted; -use App\Events\Subscription\SubscriptionWasUpdated; -use App\Listeners\Activity\ExpenseArchivedActivity; -use App\Listeners\Activity\ExpenseRestoredActivity; -use App\Listeners\Activity\PaymentArchivedActivity; -use App\Listeners\Activity\PaymentRefundedActivity; -use App\Listeners\Credit\CreditCreatedNotification; -use App\Listeners\Credit\CreditEmailedNotification; -use App\Listeners\Invoice\InvoiceCancelledActivity; -use App\Events\PurchaseOrder\PurchaseOrderWasViewed; -use App\Events\Subscription\SubscriptionWasArchived; -use App\Events\Subscription\SubscriptionWasRestored; -use App\Events\PurchaseOrder\PurchaseOrderWasCreated; -use App\Events\PurchaseOrder\PurchaseOrderWasDeleted; -use App\Events\PurchaseOrder\PurchaseOrderWasEmailed; -use App\Events\PurchaseOrder\PurchaseOrderWasUpdated; -use App\Listeners\Invoice\InvoiceCreatedNotification; -use App\Listeners\Invoice\InvoiceEmailedNotification; -use App\Listeners\Invoice\InvoiceEmailFailedActivity; -use App\Events\PurchaseOrder\PurchaseOrderWasAccepted; -use App\Events\PurchaseOrder\PurchaseOrderWasArchived; -use App\Events\PurchaseOrder\PurchaseOrderWasRestored; -use App\Listeners\Payment\PaymentEmailFailureActivity; -use App\Listeners\Vendor\UpdateVendorContactLastLogin; -use App\Events\RecurringQuote\RecurringQuoteWasCreated; -use App\Events\RecurringQuote\RecurringQuoteWasDeleted; -use App\Events\RecurringQuote\RecurringQuoteWasUpdated; -use App\Listeners\Account\StripeConnectFailureListener; -use App\Listeners\Activity\CreatedSubscriptionActivity; -use App\Listeners\Activity\SubscriptionDeletedActivity; -use App\Listeners\Activity\SubscriptionUpdatedActivity; -use App\Listeners\Invoice\InvoiceReminderEmailActivity; -use App\Events\RecurringQuote\RecurringQuoteWasArchived; -use App\Events\RecurringQuote\RecurringQuoteWasRestored; -use App\Listeners\Activity\SubscriptionArchivedActivity; -use App\Listeners\Activity\SubscriptionRestoredActivity; -use App\Listeners\Invoice\InvoiceFailedEmailNotification; -use SocialiteProviders\Microsoft\MicrosoftExtendSocialite; -use App\Events\RecurringExpense\RecurringExpenseWasCreated; -use App\Events\RecurringExpense\RecurringExpenseWasDeleted; -use App\Events\RecurringExpense\RecurringExpenseWasUpdated; -use App\Events\RecurringInvoice\RecurringInvoiceWasCreated; -use App\Events\RecurringInvoice\RecurringInvoiceWasDeleted; -use App\Events\RecurringInvoice\RecurringInvoiceWasUpdated; -use App\Listeners\PurchaseOrder\PurchaseOrderEmailActivity; -use App\Events\RecurringExpense\RecurringExpenseWasArchived; -use App\Events\RecurringExpense\RecurringExpenseWasRestored; -use App\Events\RecurringInvoice\RecurringInvoiceWasArchived; -use App\Events\RecurringInvoice\RecurringInvoiceWasRestored; -use App\Listeners\PurchaseOrder\CreatePurchaseOrderActivity; -use App\Listeners\PurchaseOrder\PurchaseOrderViewedActivity; -use App\Listeners\PurchaseOrder\UpdatePurchaseOrderActivity; -use App\Listeners\PurchaseOrder\PurchaseOrderCreatedListener; -use App\Listeners\PurchaseOrder\PurchaseOrderDeletedActivity; -use App\Listeners\PurchaseOrder\PurchaseOrderAcceptedActivity; -use App\Listeners\PurchaseOrder\PurchaseOrderAcceptedListener; -use App\Listeners\PurchaseOrder\PurchaseOrderArchivedActivity; -use App\Listeners\PurchaseOrder\PurchaseOrderRestoredActivity; -use App\Listeners\RecurringQuote\CreateRecurringQuoteActivity; -use App\Listeners\RecurringQuote\UpdateRecurringQuoteActivity; -use App\Listeners\RecurringQuote\RecurringQuoteDeletedActivity; -use App\Listeners\RecurringQuote\RecurringQuoteArchivedActivity; -use App\Listeners\RecurringQuote\RecurringQuoteRestoredActivity; -use App\Listeners\PurchaseOrder\PurchaseOrderEmailedNotification; -use App\Listeners\RecurringInvoice\CreateRecurringInvoiceActivity; -use App\Listeners\RecurringInvoice\UpdateRecurringInvoiceActivity; -use App\Listeners\RecurringExpense\CreatedRecurringExpenseActivity; -use App\Listeners\RecurringExpense\RecurringExpenseDeletedActivity; -use App\Listeners\RecurringExpense\RecurringExpenseUpdatedActivity; -use App\Listeners\RecurringInvoice\RecurringInvoiceDeletedActivity; -use App\Listeners\RecurringExpense\RecurringExpenseArchivedActivity; -use App\Listeners\RecurringExpense\RecurringExpenseRestoredActivity; -use App\Listeners\RecurringInvoice\RecurringInvoiceArchivedActivity; -use App\Listeners\RecurringInvoice\RecurringInvoiceRestoredActivity; +use App\Observers\VendorObserver; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; +use Illuminate\Mail\Events\MessageSending; +use Illuminate\Mail\Events\MessageSent; class EventServiceProvider extends ServiceProvider { diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 3d9dc442150b..8884c9d29cf8 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -11,17 +11,17 @@ namespace App\Providers; -use App\Utils\Ninja; -use App\Models\Scheduler; -use Illuminate\Http\Request; -use App\Utils\Traits\MakesHash; -use Illuminate\Support\Facades\Route; -use Illuminate\Cache\RateLimiting\Limit; -use Illuminate\Support\Facades\RateLimiter; use App\Http\Middleware\ThrottleRequestsWithPredis; -use Illuminate\Routing\Middleware\ThrottleRequests; +use App\Models\Scheduler; +use App\Utils\Ninja; +use App\Utils\Traits\MakesHash; +use Illuminate\Cache\RateLimiting\Limit; use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundException; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; +use Illuminate\Http\Request; +use Illuminate\Routing\Middleware\ThrottleRequests; +use Illuminate\Support\Facades\RateLimiter; +use Illuminate\Support\Facades\Route; class RouteServiceProvider extends ServiceProvider { @@ -36,7 +36,7 @@ class RouteServiceProvider extends ServiceProvider { parent::boot(); - if (Ninja::isHosted() && !config('ninja.testvars.travis')){ + if (Ninja::isHosted() && !config('ninja.testvars.travis')) { app('router')->aliasMiddleware('throttle', ThrottleRequestsWithPredis::class); } else { app('router')->aliasMiddleware('throttle', ThrottleRequests::class); diff --git a/app/Repositories/ActivityRepository.php b/app/Repositories/ActivityRepository.php index 23b6425c6b04..88648aa3134b 100644 --- a/app/Repositories/ActivityRepository.php +++ b/app/Repositories/ActivityRepository.php @@ -11,23 +11,23 @@ namespace App\Repositories; -use App\Models\User; -use App\Models\Quote; +use App\Models\Activity; use App\Models\Backup; +use App\Models\CompanyToken; use App\Models\Credit; use App\Models\Design; use App\Models\Invoice; -use App\Models\Activity; -use App\Utils\HtmlEngine; -use App\Models\CompanyToken; use App\Models\PurchaseOrder; -use App\Utils\Traits\MakesHash; -use App\Utils\VendorHtmlEngine; +use App\Models\Quote; use App\Models\RecurringInvoice; -use App\Utils\Traits\MakesInvoiceHtml; +use App\Models\User; use App\Services\PdfMaker\Design as PdfDesignModel; use App\Services\PdfMaker\Design as PdfMakerDesign; use App\Services\PdfMaker\PdfMaker as PdfMakerService; +use App\Utils\HtmlEngine; +use App\Utils\Traits\MakesHash; +use App\Utils\Traits\MakesInvoiceHtml; +use App\Utils\VendorHtmlEngine; /** * Class for activity repository. @@ -52,8 +52,9 @@ class ActivityRepository extends BaseRepository $activity->{$key} = $value; } - if($entity->company) + if($entity->company) { $activity->account_id = $entity->company->account_id; + } if ($token_id = $this->getTokenId($event_vars)) { $activity->token_id = $token_id; @@ -97,8 +98,7 @@ class ActivityRepository extends BaseRepository return; } - if(get_class($entity) == PurchaseOrder::class) - { + if(get_class($entity) == PurchaseOrder::class) { $backup = new Backup(); $entity->load('client'); diff --git a/app/Repositories/BankIntegrationRepository.php b/app/Repositories/BankIntegrationRepository.php index bd4bfb2b2d99..431ce460779e 100644 --- a/app/Repositories/BankIntegrationRepository.php +++ b/app/Repositories/BankIntegrationRepository.php @@ -11,9 +11,9 @@ namespace App\Repositories; -use App\Utils\Ninja; -use App\Models\BankIntegration; use App\Helpers\Bank\Yodlee\Yodlee; +use App\Models\BankIntegration; +use App\Utils\Ninja; /** * Class for bank integration repository. @@ -30,21 +30,20 @@ class BankIntegrationRepository extends BaseRepository return $bank_integration->fresh(); } - /** - * Removes the bank integration from Yodlee - * - * @param BankIntegration $bank_integration - * - * @return BankIntegration $bank_integration - */ + /** + * Removes the bank integration from Yodlee + * + * @param BankIntegration $bank_integration + * + * @return BankIntegration $bank_integration + */ public function delete($bank_integration) :BankIntegration { if ($bank_integration->is_deleted) { return $bank_integration; } - if(Ninja::isHosted()) - { + if(Ninja::isHosted()) { $account = $bank_integration->account; @@ -54,8 +53,7 @@ class BankIntegrationRepository extends BaseRepository try { $yodlee->deleteAccount($bank_integration->bank_account_id); - } - catch(\Exception $e){ + } catch(\Exception $e) { } diff --git a/app/Repositories/BankTransactionRepository.php b/app/Repositories/BankTransactionRepository.php index 66e54d3ff9f9..3326d50a5803 100644 --- a/app/Repositories/BankTransactionRepository.php +++ b/app/Repositories/BankTransactionRepository.php @@ -11,9 +11,9 @@ namespace App\Repositories; -use App\Models\Expense; -use App\Models\BankTransaction; use App\Jobs\Bank\MatchBankTransactions; +use App\Models\BankTransaction; +use App\Models\Expense; /** * Class for bank transaction repository. @@ -50,14 +50,14 @@ class BankTransactionRepository extends BaseRepository public function unlink($bt) { - if($bt->payment()->exists()){ + if($bt->payment()->exists()) { $bt->payment->transaction_id = null; $bt->payment_id = null; } $e = Expense::query()->whereIn('id', $this->transformKeys(explode(",", $bt->expense_id))) ->cursor() - ->each(function ($expense){ + ->each(function ($expense) { $expense->transaction_id = null; $expense->saveQuietly(); diff --git a/app/Repositories/BaseRepository.php b/app/Repositories/BaseRepository.php index f392d24f3693..68ccb310cf9a 100644 --- a/app/Repositories/BaseRepository.php +++ b/app/Repositories/BaseRepository.php @@ -11,19 +11,19 @@ namespace App\Repositories; -use App\Utils\Ninja; -use App\Models\Quote; -use App\Models\Client; -use App\Models\Credit; -use App\Utils\Helpers; -use App\Models\Company; -use App\Models\Invoice; -use App\Models\ClientContact; -use App\Utils\Traits\MakesHash; -use App\Models\RecurringInvoice; use App\Jobs\Client\UpdateTaxData; -use App\Utils\Traits\SavesDocuments; use App\Jobs\Product\UpdateOrCreateProduct; +use App\Models\Client; +use App\Models\ClientContact; +use App\Models\Company; +use App\Models\Credit; +use App\Models\Invoice; +use App\Models\Quote; +use App\Models\RecurringInvoice; +use App\Utils\Helpers; +use App\Utils\Ninja; +use App\Utils\Traits\MakesHash; +use App\Utils\Traits\SavesDocuments; class BaseRepository { @@ -312,8 +312,9 @@ class BaseRepository } /** If the client does not have tax_data - then populate this now */ - if($client->country_id == 840 && !$client->tax_data && $model->company->calculate_taxes && !$model->company->account->isFreeHostedClient()) + if($client->country_id == 840 && !$client->tax_data && $model->company->calculate_taxes && !$model->company->account->isFreeHostedClient()) { UpdateTaxData::dispatch($client, $client->company); + } } diff --git a/app/Repositories/InvoiceRepository.php b/app/Repositories/InvoiceRepository.php index f3d4a4e6d481..2cbe775e6990 100644 --- a/app/Repositories/InvoiceRepository.php +++ b/app/Repositories/InvoiceRepository.php @@ -98,8 +98,9 @@ class InvoiceRepository extends BaseRepository $invoice = $invoice->service()->handleRestore()->save(); /* If the reverse did not succeed due to rules, then do not restore / unarchive */ - if($invoice->is_deleted) + if($invoice->is_deleted) { return $invoice; + } parent::restore($invoice); diff --git a/app/Repositories/Migration/PaymentMigrationRepository.php b/app/Repositories/Migration/PaymentMigrationRepository.php index f8f6f686b799..6fb6b3455c26 100644 --- a/app/Repositories/Migration/PaymentMigrationRepository.php +++ b/app/Repositories/Migration/PaymentMigrationRepository.php @@ -156,7 +156,7 @@ class PaymentMigrationRepository extends BaseRepository $payment->credits->each(function ($cre) use ($credit_totals) { $cre->pivot->amount = $credit_totals; - $cre->pivot->save(); + $cre->pivot->save(); $cre->paid_to_date += $credit_totals; $cre->balance -= $credit_totals; @@ -195,7 +195,7 @@ class PaymentMigrationRepository extends BaseRepository /** * If the client is paying in a currency other than * the company currency, we need to set a record. - * + * * @param array$data * @param \App\Models\Payment $payment * @return \App\Models\Payment diff --git a/app/Repositories/PaymentRepository.php b/app/Repositories/PaymentRepository.php index ab9cec50c333..14023367459c 100644 --- a/app/Repositories/PaymentRepository.php +++ b/app/Repositories/PaymentRepository.php @@ -11,20 +11,20 @@ namespace App\Repositories; -use App\Utils\Ninja; +use App\Events\Payment\PaymentWasCreated; +use App\Events\Payment\PaymentWasDeleted; +use App\Jobs\Credit\ApplyCreditPayment; +use App\Libraries\Currency\Conversion\CurrencyApi; use App\Models\Client; use App\Models\Credit; use App\Models\Invoice; use App\Models\Payment; use App\Models\Paymentable; -use Illuminate\Http\Request; -use Illuminate\Support\Carbon; +use App\Utils\Ninja; use App\Utils\Traits\MakesHash; use App\Utils\Traits\SavesDocuments; -use App\Jobs\Credit\ApplyCreditPayment; -use App\Events\Payment\PaymentWasCreated; -use App\Events\Payment\PaymentWasDeleted; -use App\Libraries\Currency\Conversion\CurrencyApi; +use Illuminate\Http\Request; +use Illuminate\Support\Carbon; /** * PaymentRepository. @@ -148,7 +148,7 @@ class PaymentRepository extends BaseRepository if ($invoice) { - //25-06-2023 + //25-06-2023 $paymentable = new Paymentable(); $paymentable->payment_id = $payment->id; diff --git a/app/Repositories/TaskRepository.php b/app/Repositories/TaskRepository.php index cb7e5e979f4f..3bc2661e2718 100644 --- a/app/Repositories/TaskRepository.php +++ b/app/Repositories/TaskRepository.php @@ -140,7 +140,7 @@ class TaskRepository extends BaseRepository private function harvestStartDate($time_log, $task) { - if(isset($time_log[0][0])){ + if(isset($time_log[0][0])) { return \Carbon\Carbon::createFromTimestamp($time_log[0][0])->addSeconds($task->company->utc_offset()); } diff --git a/app/Repositories/TaskStatusRepository.php b/app/Repositories/TaskStatusRepository.php index 34a1f8e63642..d586c5cc9758 100644 --- a/app/Repositories/TaskStatusRepository.php +++ b/app/Repositories/TaskStatusRepository.php @@ -64,7 +64,7 @@ class TaskStatusRepository extends BaseRepository ->where('id', '!=', $task_status->id) ->orderByRaw('ISNULL(status_order), status_order ASC') ->cursor() - ->each(function ($ts, $key) use($task_status){ + ->each(function ($ts, $key) use ($task_status) { if($ts->status_order < $task_status->status_order) { $ts->status_order--; diff --git a/app/Services/Bank/ProcessBankRules.php b/app/Services/Bank/ProcessBankRules.php index f5dd8a9f9ab7..4657b7a8e11d 100644 --- a/app/Services/Bank/ProcessBankRules.php +++ b/app/Services/Bank/ProcessBankRules.php @@ -139,7 +139,7 @@ class ProcessBankRules extends AbstractService } } - private function coalesceExpenses($expense): string + private function coalesceExpenses($expense): string { if (!$this->bank_transaction->expense_id || strlen($this->bank_transaction->expense_id) < 1) { diff --git a/app/Services/Chart/ChartService.php b/app/Services/Chart/ChartService.php index 3378c998aeec..181518792113 100644 --- a/app/Services/Chart/ChartService.php +++ b/app/Services/Chart/ChartService.php @@ -11,10 +11,10 @@ namespace App\Services\Chart; -use App\Models\User; use App\Models\Client; use App\Models\Company; use App\Models\Expense; +use App\Models\User; use Illuminate\Support\Facades\Cache; class ChartService diff --git a/app/Services/Chart/ChartServiceLegacy.php b/app/Services/Chart/ChartServiceLegacy.php index 372d89ddb919..84e53cec935c 100644 --- a/app/Services/Chart/ChartServiceLegacy.php +++ b/app/Services/Chart/ChartServiceLegacy.php @@ -15,7 +15,6 @@ use App\Models\Client; use App\Models\Company; use App\Models\Expense; use Illuminate\Support\Facades\Cache; -use App\Services\Chart\ChartQueriesLegacy; class ChartServiceLegacy { diff --git a/app/Services/Client/ClientService.php b/app/Services/Client/ClientService.php index 8aabdbcbf487..f7d35ba7639b 100644 --- a/app/Services/Client/ClientService.php +++ b/app/Services/Client/ClientService.php @@ -18,7 +18,6 @@ use App\Services\Email\Email; use App\Services\Email\EmailObject; use App\Utils\Number; use App\Utils\Traits\MakesDates; -use Carbon\Carbon; use Illuminate\Mail\Mailables\Address; use Illuminate\Support\Facades\DB; @@ -50,7 +49,7 @@ class ClientService DB::connection(config('database.default'))->rollBack(); } - } catch(\Exception $exception){ + } catch(\Exception $exception) { nlog("DB ERROR " . $exception->getMessage()); DB::connection(config('database.default'))->rollBack(); @@ -78,7 +77,7 @@ class ClientService DB::connection(config('database.default'))->rollBack(); } - } catch(\Exception $exception){ + } catch(\Exception $exception) { nlog("DB ERROR " . $exception->getMessage()); if (DB::connection(config('database.default'))->transactionLevel() > 0) { @@ -97,15 +96,14 @@ class ClientService $this->client->paid_to_date += $amount; $this->client->saveQuietly(); }, 2); - } - catch (\Throwable $throwable) { + } catch (\Throwable $throwable) { nlog("DB ERROR " . $throwable->getMessage()); if (DB::connection(config('database.default'))->transactionLevel() > 0) { DB::connection(config('database.default'))->rollBack(); } - } catch(\Exception $exception){ + } catch(\Exception $exception) { nlog("DB ERROR " . $exception->getMessage()); if (DB::connection(config('database.default'))->transactionLevel() > 0) { @@ -233,7 +231,7 @@ class ClientService $cc_contacts = $this->client ->contacts() ->where('send_email', true) - ->where('email', '!=', $email) + ->where('email', '!=', $email) ->get(); foreach ($cc_contacts as $contact) { diff --git a/app/Services/Client/PaymentMethod.php b/app/Services/Client/PaymentMethod.php index e9cd452dc9b8..e74874ad01eb 100644 --- a/app/Services/Client/PaymentMethod.php +++ b/app/Services/Client/PaymentMethod.php @@ -65,8 +65,9 @@ class PaymentMethod if ($company_gateways || $company_gateways == '0') { $transformed_ids = $this->transformKeys(explode(',', $company_gateways)); - if($company_gateways == '0') + if($company_gateways == '0') { $transformed_ids = []; + } $this->gateways = $this->client ->company diff --git a/app/Services/Client/Statement.php b/app/Services/Client/Statement.php index 0ad64947b8ba..4c86a5675e24 100644 --- a/app/Services/Client/Statement.php +++ b/app/Services/Client/Statement.php @@ -12,26 +12,26 @@ namespace App\Services\Client; -use App\Utils\Number; +use App\Factory\InvoiceFactory; +use App\Factory\InvoiceInvitationFactory; +use App\Factory\InvoiceItemFactory; use App\Models\Client; use App\Models\Credit; use App\Models\Design; use App\Models\Invoice; use App\Models\Payment; -use App\Utils\HtmlEngine; -use Illuminate\Support\Carbon; -use App\Factory\InvoiceFactory; -use App\Utils\Traits\MakesHash; -use App\Utils\PhantomJS\Phantom; -use App\Utils\HostedPDF\NinjaPdf; -use Illuminate\Support\Facades\DB; -use App\Factory\InvoiceItemFactory; -use App\Services\PdfMaker\PdfMaker; -use App\Factory\InvoiceInvitationFactory; -use Illuminate\Database\Eloquent\Builder; use App\Services\PdfMaker\Design as PdfMakerDesign; +use App\Services\PdfMaker\PdfMaker; +use App\Utils\HostedPDF\NinjaPdf; +use App\Utils\HtmlEngine; +use App\Utils\Number; +use App\Utils\PhantomJS\Phantom; use App\Utils\Traits\MakesDates; +use App\Utils\Traits\MakesHash; use App\Utils\Traits\Pdf\PdfMaker as PdfMakerTrait; +use Illuminate\Database\Eloquent\Builder; +use Illuminate\Support\Carbon; +use Illuminate\Support\Facades\DB; class Statement { @@ -68,7 +68,7 @@ class Statement $variables['labels']['$end_date_label'] = ctrans('texts.end_date'); return $this->templateStatement($variables); - } + } $variables = $html->generateLabelsAndValues(); @@ -124,7 +124,7 @@ class Statement \DB::connection(config('database.default'))->rollBack(); } - $pdf = $this->convertToPdf($html); + $pdf = $this->convertToPdf($html); $maker = null; $state = null; @@ -134,10 +134,11 @@ class Statement private function templateStatement($variables) { - if(isset($this->options['template'])) + if(isset($this->options['template'])) { $statement_design_id = $this->options['template']; - else + } else { $statement_design_id = $this->client->getSetting('statement_design_id'); + } $template = Design::where('id', $this->decodePrimaryKey($statement_design_id)) ->where('company_id', $this->client->company_id) @@ -350,7 +351,7 @@ class Statement protected function getCredits(): Builder { return Credit::withTrashed() - ->with('client.country','invoice') + ->with('client.country', 'invoice') ->where('is_deleted', false) ->where('company_id', $this->client->company_id) ->where('client_id', $this->client->id) diff --git a/app/Services/ClientPortal/InstantPayment.php b/app/Services/ClientPortal/InstantPayment.php index 909e4f003a3d..3484122541d8 100644 --- a/app/Services/ClientPortal/InstantPayment.php +++ b/app/Services/ClientPortal/InstantPayment.php @@ -178,7 +178,7 @@ class InstantPayment $contact_id = auth()->guard('contact')->user() ? auth()->guard('contact')->user()->id : null; - $invoices->each(function ($invoice) use($contact_id) { + $invoices->each(function ($invoice) use ($contact_id) { InjectSignature::dispatch($invoice, $contact_id, $this->request->signature, request()->getClientIp()); }); } diff --git a/app/Services/Credit/CreditService.php b/app/Services/Credit/CreditService.php index 365a9d1f2176..a6c5bbcdef69 100644 --- a/app/Services/Credit/CreditService.php +++ b/app/Services/Credit/CreditService.php @@ -11,14 +11,14 @@ namespace App\Services\Credit; -use App\Utils\Ninja; +use App\Factory\PaymentFactory; use App\Models\Credit; use App\Models\Payment; use App\Models\PaymentType; -use App\Factory\PaymentFactory; -use App\Utils\Traits\MakesHash; use App\Repositories\CreditRepository; use App\Repositories\PaymentRepository; +use App\Utils\Ninja; +use App\Utils\Traits\MakesHash; use Illuminate\Support\Facades\Storage; class CreditService diff --git a/app/Services/Credit/SendEmail.php b/app/Services/Credit/SendEmail.php index f17f5f902dc7..9c2fd948afa2 100644 --- a/app/Services/Credit/SendEmail.php +++ b/app/Services/Credit/SendEmail.php @@ -11,10 +11,10 @@ namespace App\Services\Credit; -use App\Utils\Ninja; -use App\Models\ClientContact; -use App\Jobs\Entity\EmailEntity; use App\Events\Credit\CreditWasEmailed; +use App\Jobs\Entity\EmailEntity; +use App\Models\ClientContact; +use App\Utils\Ninja; class SendEmail { diff --git a/app/Services/Email/AdminEmail.php b/app/Services/Email/AdminEmail.php index abf1771d8cde..2a245337fa72 100644 --- a/app/Services/Email/AdminEmail.php +++ b/app/Services/Email/AdminEmail.php @@ -19,18 +19,13 @@ use App\Jobs\Util\SystemLogger; use App\Libraries\Google\Google; use App\Libraries\MultiDB; use App\Models\Client; -use App\Models\ClientContact; use App\Models\Company; use App\Models\Invoice; use App\Models\Payment; use App\Models\SystemLog; use App\Models\User; -use App\Models\Vendor; -use App\Models\VendorContact; -use App\Utils\HtmlEngine; use App\Utils\Ninja; use App\Utils\Traits\MakesHash; -use App\Utils\VendorHtmlEngine; use GuzzleHttp\Exception\ClientException; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; diff --git a/app/Services/Email/AdminEmailMailable.php b/app/Services/Email/AdminEmailMailable.php index 94cfc53a83c6..f0e18158d175 100644 --- a/app/Services/Email/AdminEmailMailable.php +++ b/app/Services/Email/AdminEmailMailable.php @@ -11,13 +11,11 @@ namespace App\Services\Email; -use App\Models\Document; use Illuminate\Mail\Attachment; use Illuminate\Mail\Mailable; use Illuminate\Mail\Mailables\Content; use Illuminate\Mail\Mailables\Envelope; use Illuminate\Mail\Mailables\Headers; -use Illuminate\Support\Facades\URL; class AdminEmailMailable extends Mailable { diff --git a/app/Services/Email/Email.php b/app/Services/Email/Email.php index 1bde5e2a19f6..bd4095849020 100644 --- a/app/Services/Email/Email.php +++ b/app/Services/Email/Email.php @@ -322,13 +322,13 @@ class Email implements ShouldQueue $this->cleanUpMailers(); } - /** - * On the hosted platform we scan all outbound email for - * spam. This sequence processes the filters we use on all - * emails. - * - * @return bool - */ + /** + * On the hosted platform we scan all outbound email for + * spam. This sequence processes the filters we use on all + * emails. + * + * @return bool + */ public function preFlightChecksFail(): bool { /* Always send if disabled */ @@ -426,7 +426,7 @@ class Email implements ShouldQueue return false; } - /** + /** * Sets the mail driver to use and applies any specific configuration * the the mailable */ @@ -466,7 +466,7 @@ class Email implements ShouldQueue return $this; } - /** + /** * Allows configuration of multiple mailers * per company for use by self hosted users */ diff --git a/app/Services/Email/EmailDefaults.php b/app/Services/Email/EmailDefaults.php index bf02092819b3..4c7b9319c12c 100644 --- a/app/Services/Email/EmailDefaults.php +++ b/app/Services/Email/EmailDefaults.php @@ -11,22 +11,22 @@ namespace App\Services\Email; -use App\Models\Task; -use App\Utils\Ninja; -use App\Models\Quote; -use App\Models\Credit; +use App\DataMapper\EmailTemplateDefaults; +use App\Jobs\Entity\CreateRawPdf; +use App\Jobs\Invoice\CreateUbl; +use App\Jobs\Vendor\CreatePurchaseOrderPdf; use App\Models\Account; +use App\Models\Credit; use App\Models\Expense; use App\Models\Invoice; use App\Models\PurchaseOrder; -use App\Jobs\Invoice\CreateUbl; +use App\Models\Quote; +use App\Models\Task; +use App\Utils\Ninja; use App\Utils\Traits\MakesHash; -use App\Jobs\Entity\CreateRawPdf; -use Illuminate\Support\Facades\App; use Illuminate\Mail\Mailables\Address; -use App\DataMapper\EmailTemplateDefaults; +use Illuminate\Support\Facades\App; use League\CommonMark\CommonMarkConverter; -use App\Jobs\Vendor\CreatePurchaseOrderPdf; class EmailDefaults { @@ -255,7 +255,7 @@ class EmailDefaults if (strlen($this->email->email_object->settings->bcc_email) > 1) { if (Ninja::isHosted() && $this->email->company->account->isPaid()) { $bccs = array_slice(explode(',', str_replace(' ', '', $this->email->email_object->settings->bcc_email)), 0, 5); - } else { + } else { $bccs = (explode(',', str_replace(' ', '', $this->email->email_object->settings->bcc_email))); } } @@ -323,8 +323,9 @@ class EmailDefaults if ($this->email->email_object->settings->enable_e_invoice && $this->email->email_object->entity instanceof Invoice) { $xml_string = $this->email->email_object->entity->service()->getEInvoice(); - if($xml_string) + if($xml_string) { $this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode($xml_string), 'name' => explode(".", $this->email->email_object->entity->getFileName('xml'))[0]."-e_invoice.xml"]]); + } } if (!$this->email->email_object->settings->document_email_attachment || !$this->email->company->account->hasFeature(Account::FEATURE_DOCUMENTS)) { @@ -364,7 +365,7 @@ class EmailDefaults ->where('invoice_documents', 1) ->cursor() ->each(function ($expense) { - $this->email->email_object->documents = array_merge($this->email->email_object->documents, $expense->documents()->where('is_public',true)->pluck('id')->toArray()); + $this->email->email_object->documents = array_merge($this->email->email_object->documents, $expense->documents()->where('is_public', true)->pluck('id')->toArray()); }); } @@ -372,7 +373,7 @@ class EmailDefaults Task::query()->whereIn('id', $this->transformKeys($task_ids)) ->cursor() ->each(function ($task) { - $this->email->email_object->documents = array_merge($this->email->email_object->documents, $task->documents()->where('is_public',true)->pluck('id')->toArray()); + $this->email->email_object->documents = array_merge($this->email->email_object->documents, $task->documents()->where('is_public', true)->pluck('id')->toArray()); }); } } diff --git a/app/Services/Email/EmailMailable.php b/app/Services/Email/EmailMailable.php index 8c7c2c5e4362..dffb081a1d69 100644 --- a/app/Services/Email/EmailMailable.php +++ b/app/Services/Email/EmailMailable.php @@ -96,7 +96,7 @@ class EmailMailable extends Mailable $documents = Document::query()->whereIn('id', $this->email_object->documents) ->where('size', '<', $this->max_attachment_size) - ->where('is_public',1) + ->where('is_public', 1) ->cursor() ->map(function ($document) { return Attachment::fromData(fn () => $document->getFile(), $document->name); diff --git a/app/Services/Invoice/ApplyPaymentAmount.php b/app/Services/Invoice/ApplyPaymentAmount.php index 468e4524c216..5b96c5102958 100644 --- a/app/Services/Invoice/ApplyPaymentAmount.php +++ b/app/Services/Invoice/ApplyPaymentAmount.php @@ -81,7 +81,7 @@ class ApplyPaymentAmount extends AbstractService $invoice_service->checkReminderStatus(); } - if($this->invoice->balance == 0){ + if($this->invoice->balance == 0) { $this->invoice->next_send_date = null; } diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php index 19a366fdc507..c16fe0c6eeef 100644 --- a/app/Services/Invoice/AutoBillInvoice.php +++ b/app/Services/Invoice/AutoBillInvoice.php @@ -11,21 +11,20 @@ namespace App\Services\Invoice; -use App\Utils\Ninja; +use App\Events\Invoice\InvoiceWasPaid; +use App\Events\Payment\PaymentWasCreated; +use App\Factory\PaymentFactory; +use App\Libraries\MultiDB; use App\Models\Client; +use App\Models\ClientGatewayToken; use App\Models\Credit; use App\Models\Invoice; use App\Models\Payment; -use App\Libraries\MultiDB; use App\Models\PaymentHash; use App\Models\PaymentType; -use Illuminate\Support\Str; -use App\DataMapper\InvoiceItem; -use App\Factory\PaymentFactory; use App\Services\AbstractService; -use App\Models\ClientGatewayToken; -use App\Events\Invoice\InvoiceWasPaid; -use App\Events\Payment\PaymentWasCreated; +use App\Utils\Ninja; +use Illuminate\Support\Str; class AutoBillInvoice extends AbstractService { @@ -230,7 +229,7 @@ class AutoBillInvoice extends AbstractService event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars())); //if we have paid the invoice in full using credits, then we need to fire the event - if($this->invoice->balance == 0){ + if($this->invoice->balance == 0) { event(new InvoiceWasPaid($this->invoice, $payment, $payment->company, Ninja::eventVars())); diff --git a/app/Services/Invoice/EInvoice/FacturaEInvoice.php b/app/Services/Invoice/EInvoice/FacturaEInvoice.php index 4ec4ca779e65..24371ad2a2f5 100644 --- a/app/Services/Invoice/EInvoice/FacturaEInvoice.php +++ b/app/Services/Invoice/EInvoice/FacturaEInvoice.php @@ -13,14 +13,13 @@ namespace App\Services\Invoice\EInvoice; use App\Models\Invoice; use App\Models\PaymentType; -use josemmo\Facturae\Facturae; use App\Services\AbstractService; +use Illuminate\Support\Facades\Storage; +use josemmo\Facturae\Facturae; +use josemmo\Facturae\FacturaeCentre; use josemmo\Facturae\FacturaeItem; use josemmo\Facturae\FacturaeParty; -use josemmo\Facturae\FacturaeCentre; use josemmo\Facturae\FacturaePayment; -use Illuminate\Support\Facades\Storage; -use josemmo\Facturae\Common\FacturaeSigner; class FacturaEInvoice extends AbstractService { @@ -193,14 +192,11 @@ class FacturaEInvoice extends AbstractService { $facturae_centres = []; - if($this->invoice->client->custom_value1 == 'yes') - { + if($this->invoice->client->custom_value1 == 'yes') { - foreach($this->invoice->client->contacts()->whereNotNull('custom_value1')->whereNull('deleted_at')->cursor() as $contact) - { + foreach($this->invoice->client->contacts()->whereNotNull('custom_value1')->whereNull('deleted_at')->cursor() as $contact) { - if(in_array($contact->custom_value1, array_keys($this->centre_codes))) - { + if(in_array($contact->custom_value1, array_keys($this->centre_codes))) { $facturae_centres[] = new FacturaeCentre([ 'role' => $this->centre_codes[$contact->custom_value1], 'code' => $contact->custom_value2, @@ -221,7 +217,7 @@ class FacturaEInvoice extends AbstractService $transaction_reference = (isset($this->invoice->custom_value1) && strlen($this->invoice->custom_value1) > 2) ? substr($this->invoice->custom_value1, 0, 20) : null; $contract_reference = (isset($this->invoice->custom_value2) && strlen($this->invoice->custom_value2) > 2) ? $this->invoice->custom_value2: null; - $this->fac->setReferences($po, $transaction_reference, $contract_reference); + $this->fac->setReferences($po, $transaction_reference, $contract_reference); return $this; } @@ -237,15 +233,16 @@ class FacturaEInvoice extends AbstractService private function setLegalTerms(): self { - $this->fac->addLegalLiteral(substr($this->invoice->public_notes,0,250)); + $this->fac->addLegalLiteral(substr($this->invoice->public_notes, 0, 250)); return $this; } private function setBillingPeriod(): self { - if(!$this->invoice->custom_value3) + if(!$this->invoice->custom_value3) { return $this; + } try { if (\Carbon\Carbon::createFromFormat('Y-m-d', $this->invoice->custom_value3)->format('Y-m-d') === $this->invoice->custom_value3 && @@ -253,8 +250,7 @@ class FacturaEInvoice extends AbstractService ) { $this->fac->setBillingPeriod(\Carbon\Carbon::parse($this->invoice->custom_value3)->format('Y-m-d'), \Carbon\Carbon::parse($this->invoice->custom_value4)->format('Y-m-d')); } - } - catch(\Exception $e) { + } catch(\Exception $e) { nlog($e->getMessage()); } @@ -263,7 +259,7 @@ class FacturaEInvoice extends AbstractService private function setPayments(): self { - $this->invoice->payments()->each(function ($payment){ + $this->invoice->payments()->each(function ($payment) { $payment_data = [ "dueDate" => \Carbon\Carbon::parse($payment->date)->format('Y-m-d'), @@ -280,7 +276,7 @@ class FacturaEInvoice extends AbstractService } /** - * + * * FacturaePayment::TYPE_CASH Cash * FacturaePayment::TYPE_DEBIT Domiciled receipt * FacturaePayment::TYPE_RECEIPT Receipt @@ -309,7 +305,7 @@ class FacturaEInvoice extends AbstractService $data = []; $method = FacturaePayment::TYPE_CARD; - match($payment->type_id){ + match($payment->type_id) { PaymentType::BANK_TRANSFER => $method = FacturaePayment::TYPE_TRANSFER , PaymentType::CASH => $method = FacturaePayment::TYPE_CASH , PaymentType::ACH => $method = FacturaePayment::TYPE_TRANSFER , @@ -361,9 +357,8 @@ class FacturaEInvoice extends AbstractService $data['method'] = $method; - if($method == FacturaePayment::TYPE_TRANSFER) - { - $data['iban'] = $payment->custom_value1; + if($method == FacturaePayment::TYPE_TRANSFER) { + $data['iban'] = $payment->custom_value1; $data['bic'] = $payment->custom_value2; } @@ -420,8 +415,9 @@ class FacturaEInvoice extends AbstractService } - if(count($data) == 0) + if(count($data) == 0) { $data[Facturae::TAX_IVA] = 0; + } return $data; } @@ -468,8 +464,9 @@ class FacturaEInvoice extends AbstractService { $company = $this->invoice->company; - if($company->getSetting('classification') == 'individual') + if($company->getSetting('classification') == 'individual') { return $this->setIndividualSeller(); + } $seller = new FacturaeParty([ "isLegalEntity" => true, @@ -548,18 +545,18 @@ class FacturaEInvoice extends AbstractService $buyer = new FacturaeParty([ "isLegalEntity" => $this->invoice->client->classification === 'individual' ? false : true, "taxNumber" => $this->invoice->client->vat_number, - "name" => substr($this->invoice->client->present()->name(),0, 40), - "firstSurname" => substr($this->invoice->client->present()->first_name(),0, 40), - "lastSurname" => substr($this->invoice->client->present()->last_name(),0, 40), - "address" => substr($this->invoice->client->address1,0, 80), - "postCode" => substr($this->invoice->client->postal_code,0,5), - "town" => substr($this->invoice->client->city,0, 50), - "province" => substr($this->invoice->client->state,0, 20), + "name" => substr($this->invoice->client->present()->name(), 0, 40), + "firstSurname" => substr($this->invoice->client->present()->first_name(), 0, 40), + "lastSurname" => substr($this->invoice->client->present()->last_name(), 0, 40), + "address" => substr($this->invoice->client->address1, 0, 80), + "postCode" => substr($this->invoice->client->postal_code, 0, 5), + "town" => substr($this->invoice->client->city, 0, 50), + "province" => substr($this->invoice->client->state, 0, 20), "countryCode" => $this->invoice->client->country->iso_3166_3, // Se asume España si se omite - "email" => substr($this->invoice->client->present()->email(),0, 60), - "phone" => substr($this->invoice->client->present()->phone(),0, 15), + "email" => substr($this->invoice->client->present()->email(), 0, 60), + "phone" => substr($this->invoice->client->present()->phone(), 0, 15), "fax" => "", - "website" => substr($this->invoice->client->present()->website(), 0 ,60), + "website" => substr($this->invoice->client->present()->website(), 0, 60), "contactPeople" => substr($this->invoice->client->present()->first_name()." ".$this->invoice->client->present()->last_name(), 0, 40), 'centres' => $this->setFace(), // "cnoCnae" => "04791", // Clasif. Nacional de Act. Económicas @@ -577,8 +574,9 @@ class FacturaEInvoice extends AbstractService $ssl_cert = $this->invoice->company->getInvoiceCert(); $ssl_passphrase = $this->invoice->company->getSslPassPhrase(); - if($ssl_cert) + if($ssl_cert) { $this->fac->sign($ssl_cert, null, $ssl_passphrase); + } return $this; } diff --git a/app/Services/Invoice/EInvoice/FatturaPA.php b/app/Services/Invoice/EInvoice/FatturaPA.php index 9d2dbe69a26e..0540275ae60d 100644 --- a/app/Services/Invoice/EInvoice/FatturaPA.php +++ b/app/Services/Invoice/EInvoice/FatturaPA.php @@ -11,9 +11,10 @@ namespace App\Services\Invoice\EInvoice; -use SimpleXMLElement; use App\Models\Invoice; use App\Services\AbstractService; +use SimpleXMLElement; + /* @@ -69,12 +70,14 @@ class FatturaPA extends AbstractService return $this->addHeader()->getXml(); } - public function addHeader() { + public function addHeader() + { $this->xml->addChild('FatturaElettronicaHeader'); return $this; } - public function addTrasmissioneData($idPaese, $idCodice, $progressivoInvio, $formatoTrasmissione, $codiceDestinatario) { + public function addTrasmissioneData($idPaese, $idCodice, $progressivoInvio, $formatoTrasmissione, $codiceDestinatario) + { $datiTrasmissione = $this->xml->FatturaElettronicaHeader->addChild('DatiTrasmissione'); $idTrasmittente = $datiTrasmissione->addChild('IdTrasmittente'); $idTrasmittente->addChild('IdPaese', $idPaese); @@ -85,24 +88,29 @@ class FatturaPA extends AbstractService return $this; } - public function addCedentePrestatore($data) { + public function addCedentePrestatore($data) + { // Add CedentePrestatore data } - public function addCessionarioCommittente($data) { + public function addCessionarioCommittente($data) + { // Add CessionarioCommittente data } - public function addBody() { + public function addBody() + { $this->xml->addChild('FatturaElettronicaBody'); return $this; } - public function addDatiGenerali($data) { + public function addDatiGenerali($data) + { // Add DatiGenerali data } - public function addLineItem($data) { + public function addLineItem($data) + { if (!isset($this->xml->FatturaElettronicaBody->DatiBeniServizi)) { $this->xml->FatturaElettronicaBody->addChild('DatiBeniServizi'); } @@ -121,7 +129,8 @@ class FatturaPA extends AbstractService return $this; } - public function addDatiPagamento($data) { + public function addDatiPagamento($data) + { // Add DatiPagamento data } diff --git a/app/Services/Invoice/EInvoice/ZugferdEInvoice.php b/app/Services/Invoice/EInvoice/ZugferdEInvoice.php index 539e78f6e270..56e0e7161107 100644 --- a/app/Services/Invoice/EInvoice/ZugferdEInvoice.php +++ b/app/Services/Invoice/EInvoice/ZugferdEInvoice.php @@ -14,11 +14,9 @@ namespace App\Services\Invoice\EInvoice; use App\Models\Invoice; use App\Models\Product; use App\Services\AbstractService; -use horstoeko\zugferd\ZugferdProfiles; -use Illuminate\Support\Facades\Storage; -use horstoeko\zugferd\ZugferdDocumentBuilder; -use horstoeko\zugferd\ZugferdDocumentPdfBuilder; use horstoeko\zugferd\codelists\ZugferdDutyTaxFeeCategories; +use horstoeko\zugferd\ZugferdDocumentBuilder; +use horstoeko\zugferd\ZugferdProfiles; class ZugferdEInvoice extends AbstractService { @@ -58,13 +56,13 @@ class ZugferdEInvoice extends AbstractService ->setDocumentBuyerContact($client->primary_contact()->first()->first_name . " " . $client->primary_contact()->first()->last_name, "", $client->primary_contact()->first()->phone, "", $client->primary_contact()->first()->email) ->addDocumentPaymentTerm(ctrans("texts.xinvoice_payable", ['payeddue' => date_create($this->invoice->date ?? now()->format('Y-m-d'))->diff(date_create($this->invoice->due_date ?? now()->format('Y-m-d')))->format("%d"), 'paydate' => $this->invoice->due_date])); - if (!empty($this->invoice->public_notes)) { + if (!empty($this->invoice->public_notes)) { $this->xrechnung->addDocumentNote($this->invoice->public_notes); } - if (empty($this->invoice->number)){ - $this->xrechnung->setDocumentInformation("DRAFT", "380", date_create($this->invoice->date ?? now()->format('Y-m-d')), $this->invoice->client->getCurrencyCode()); + if (empty($this->invoice->number)) { + $this->xrechnung->setDocumentInformation("DRAFT", "380", date_create($this->invoice->date ?? now()->format('Y-m-d')), $this->invoice->client->getCurrencyCode()); } else { - $this->xrechnung->setDocumentInformation($this->invoice->number, "380", date_create($this->invoice->date ?? now()->format('Y-m-d')), $this->invoice->client->getCurrencyCode()); + $this->xrechnung->setDocumentInformation($this->invoice->number, "380", date_create($this->invoice->date ?? now()->format('Y-m-d')), $this->invoice->client->getCurrencyCode()); } if (!empty($this->invoice->po_number)) { $this->xrechnung->setDocumentBuyerOrderReferencedDocument($this->invoice->po_number); @@ -75,7 +73,7 @@ class ZugferdEInvoice extends AbstractService } else { $this->xrechnung->setDocumentBuyerReference($client->routing_id); } - if (!empty($client->shipping_address1) && $client->shipping_country->exists()){ + if (!empty($client->shipping_address1) && $client->shipping_country->exists()) { $this->xrechnung->setDocumentShipToAddress($client->shipping_address1, $client->shipping_address2, "", $client->shipping_postal_code, $client->shipping_city, $client->shipping_country->iso_3166_2, $client->shipping_state); } @@ -95,19 +93,16 @@ class ZugferdEInvoice extends AbstractService $this->xrechnung->addNewPosition($index) ->setDocumentPositionGrossPrice($item->gross_line_total) ->setDocumentPositionNetPrice($item->line_total); - if (!empty($item->product_key)){ - if (!empty($item->notes)){ - $this->xrechnung->setDocumentPositionProductDetails($item->product_key, $item->notes); - } - else { + if (!empty($item->product_key)) { + if (!empty($item->notes)) { + $this->xrechnung->setDocumentPositionProductDetails($item->product_key, $item->notes); + } else { $this->xrechnung->setDocumentPositionProductDetails($item->product_key); } - } - else { - if (!empty($item->notes)){ + } else { + if (!empty($item->notes)) { $this->xrechnung->setDocumentPositionProductDetails($item->notes); - } - else { + } else { $this->xrechnung->setDocumentPositionProductDetails("no product name defined"); } } @@ -164,7 +159,7 @@ class ZugferdEInvoice extends AbstractService $this->xrechnung->setDocumentSummation($this->invoice->amount, $this->invoice->balance, $invoicing_data->getSubTotal(), $invoicing_data->getTotalSurcharges(), $invoicing_data->getTotalDiscount(), $invoicing_data->getSubTotal(), $invoicing_data->getItemTotalTaxes(), 0.0, $this->invoice->amount-$this->invoice->balance); - foreach ($this->tax_map as $item){ + foreach ($this->tax_map as $item) { $this->xrechnung->addDocumentTax($item["tax_type"], "VAT", $item["net_amount"], $item["tax_rate"]*$item["net_amount"], $item["tax_rate"]*100); } @@ -225,10 +220,9 @@ class ZugferdEInvoice extends AbstractService private function addtoTaxMap(string $tax_type, float $net_amount, float $tax_rate): void { $hash = hash("md5", $tax_type."-".$tax_rate); - if (array_key_exists($hash, $this->tax_map)){ + if (array_key_exists($hash, $this->tax_map)) { $this->tax_map[$hash]["net_amount"] += $net_amount; - } - else{ + } else { $this->tax_map[$hash] = [ "tax_type" => $tax_type, "net_amount" => $net_amount, diff --git a/app/Services/Invoice/GenerateDeliveryNote.php b/app/Services/Invoice/GenerateDeliveryNote.php index 5b40a550ded8..aec054eb73b7 100644 --- a/app/Services/Invoice/GenerateDeliveryNote.php +++ b/app/Services/Invoice/GenerateDeliveryNote.php @@ -45,8 +45,7 @@ class GenerateDeliveryNote $delivery_note_design_id = $this->invoice->client->getSetting('delivery_note_design_id'); $design = Design::withTrashed()->find($this->decodePrimaryKey($delivery_note_design_id)); - if($design && $design->is_template) - { + if($design && $design->is_template) { $ts = new TemplateService($design); $pdf = $ts->build([ diff --git a/app/Services/Invoice/GetInvoicePdf.php b/app/Services/Invoice/GetInvoicePdf.php index f2eeee32cbef..736df18c9d26 100644 --- a/app/Services/Invoice/GetInvoicePdf.php +++ b/app/Services/Invoice/GetInvoicePdf.php @@ -11,9 +11,9 @@ namespace App\Services\Invoice; -use App\Models\Invoice; -use App\Models\ClientContact; use App\Jobs\Entity\CreateRawPdf; +use App\Models\ClientContact; +use App\Models\Invoice; use App\Services\AbstractService; class GetInvoicePdf extends AbstractService diff --git a/app/Services/Invoice/HandleRestore.php b/app/Services/Invoice/HandleRestore.php index 45a960d4e86a..ee1c94717a34 100644 --- a/app/Services/Invoice/HandleRestore.php +++ b/app/Services/Invoice/HandleRestore.php @@ -17,7 +17,6 @@ use App\Models\Paymentable; use App\Services\AbstractService; use App\Utils\Ninja; use App\Utils\Traits\GeneratesCounter; -use Illuminate\Support\Facades\DB; class HandleRestore extends AbstractService { @@ -115,9 +114,9 @@ class HandleRestore extends AbstractService if ($this->adjustment_amount == $this->total_payments) { $this->invoice->payments()->update(['payments.deleted_at' => null, 'payments.is_deleted' => false]); - } - else + } else { $this->invoice->net_payments()->update(['payments.deleted_at' => null, 'payments.is_deleted' => false]); + } //adjust payments down by the amount applied to the invoice payment. diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index affba6b25536..78fdf1cc272f 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -292,7 +292,7 @@ class InvoiceService /** * Reset the reminders if only the * partial has been paid. - * + * * We can _ONLY_ call this _IF_ a partial * amount has been paid, otherwise we end up wiping * all reminders regardless @@ -302,11 +302,11 @@ class InvoiceService public function checkReminderStatus(): self { - if($this->invoice->partial == 0) + if($this->invoice->partial == 0) { $this->invoice->partial_due_date = null; + } - if($this->invoice->partial == 0 && $this->invoice->balance > 0) - { + if($this->invoice->partial == 0 && $this->invoice->balance > 0) { $this->invoice->reminder1_sent = null; $this->invoice->reminder2_sent = null; $this->invoice->reminder3_sent = null; @@ -386,7 +386,7 @@ class InvoiceService $this->invoice->invitations->each(function ($invitation) { try { // if (Storage::disk(config('filesystems.default'))->exists($this->invoice->client->invoice_filepath($invitation).$this->invoice->numberFormatter().'.pdf')) { - Storage::disk(config('filesystems.default'))->delete($this->invoice->client->invoice_filepath($invitation).$this->invoice->numberFormatter().'.pdf'); + Storage::disk(config('filesystems.default'))->delete($this->invoice->client->invoice_filepath($invitation).$this->invoice->numberFormatter().'.pdf'); // } // if (Ninja::isHosted() && Storage::disk('public')->exists($this->invoice->client->invoice_filepath($invitation).$this->invoice->numberFormatter().'.pdf')) { @@ -408,7 +408,7 @@ class InvoiceService $this->invoice->invitations->each(function ($invitation) { try { // if (Storage::disk(config('filesystems.default'))->exists($this->invoice->client->e_invoice_filepath($invitation).$this->invoice->getFileName("xml"))) { - Storage::disk(config('filesystems.default'))->delete($this->invoice->client->e_invoice_filepath($invitation).$this->invoice->getFileName("xml")); + Storage::disk(config('filesystems.default'))->delete($this->invoice->client->e_invoice_filepath($invitation).$this->invoice->getFileName("xml")); // } // if (Ninja::isHosted() && Storage::disk('public')->exists($this->invoice->client->e_invoice_filepath($invitation).$this->invoice->getFileName("xml"))) { diff --git a/app/Services/Invoice/MarkInvoiceDeleted.php b/app/Services/Invoice/MarkInvoiceDeleted.php index 318737cae128..524e1e933fc3 100644 --- a/app/Services/Invoice/MarkInvoiceDeleted.php +++ b/app/Services/Invoice/MarkInvoiceDeleted.php @@ -11,12 +11,10 @@ namespace App\Services\Invoice; -use App\Models\Credit; +use App\Jobs\Inventory\AdjustProductInventory; use App\Models\Invoice; use App\Services\AbstractService; -use Illuminate\Support\Facades\DB; use App\Utils\Traits\GeneratesCounter; -use App\Jobs\Inventory\AdjustProductInventory; class MarkInvoiceDeleted extends AbstractService { diff --git a/app/Services/Invoice/SendEmail.php b/app/Services/Invoice/SendEmail.php index 7cbc7a0cc0ee..365201a5acb5 100644 --- a/app/Services/Invoice/SendEmail.php +++ b/app/Services/Invoice/SendEmail.php @@ -11,12 +11,12 @@ namespace App\Services\Invoice; -use App\Utils\Ninja; -use App\Models\Invoice; -use App\Models\ClientContact; -use App\Jobs\Entity\EmailEntity; -use App\Services\AbstractService; use App\Events\Invoice\InvoiceWasEmailed; +use App\Jobs\Entity\EmailEntity; +use App\Models\ClientContact; +use App\Models\Invoice; +use App\Services\AbstractService; +use App\Utils\Ninja; class SendEmail extends AbstractService { diff --git a/app/Services/Invoice/UpdateReminder.php b/app/Services/Invoice/UpdateReminder.php index 43768b7cb1f9..0d8c96f3f45b 100644 --- a/app/Services/Invoice/UpdateReminder.php +++ b/app/Services/Invoice/UpdateReminder.php @@ -59,7 +59,7 @@ class UpdateReminder extends AbstractService $this->settings->schedule_reminder1 == 'before_due_date') { $partial_or_due_date = ($this->invoice->partial > 0 && isset($this->invoice->partial_due_date)) ? $this->invoice->partial_due_date : $this->invoice->due_date; $reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->subDays($this->settings->num_days_reminder1); -// nlog("1. {$reminder_date->format('Y-m-d')}"); + // nlog("1. {$reminder_date->format('Y-m-d')}"); if ($reminder_date->gt(now())) { $date_collection->push($reminder_date); @@ -72,7 +72,7 @@ class UpdateReminder extends AbstractService $partial_or_due_date = ($this->invoice->partial > 0 && isset($this->invoice->partial_due_date)) ? $this->invoice->partial_due_date : $this->invoice->due_date; $reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->addDays($this->settings->num_days_reminder1); -// nlog("2. {$reminder_date->format('Y-m-d')}"); + // nlog("2. {$reminder_date->format('Y-m-d')}"); if ($reminder_date->gt(now())) { $date_collection->push($reminder_date); @@ -94,7 +94,7 @@ class UpdateReminder extends AbstractService $partial_or_due_date = ($this->invoice->partial > 0 && isset($this->invoice->partial_due_date)) ? $this->invoice->partial_due_date : $this->invoice->due_date; $reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->subDays($this->settings->num_days_reminder2); -// nlog("3. {$reminder_date->format('Y-m-d')}"); + // nlog("3. {$reminder_date->format('Y-m-d')}"); if ($reminder_date->gt(now())) { $date_collection->push($reminder_date); @@ -107,7 +107,7 @@ class UpdateReminder extends AbstractService $partial_or_due_date = ($this->invoice->partial > 0 && isset($this->invoice->partial_due_date)) ? $this->invoice->partial_due_date : $this->invoice->due_date; $reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->addDays($this->settings->num_days_reminder2); -// nlog("4. {$reminder_date->format('Y-m-d')}"); + // nlog("4. {$reminder_date->format('Y-m-d')}"); if ($reminder_date->gt(now())) { $date_collection->push($reminder_date); @@ -129,7 +129,7 @@ class UpdateReminder extends AbstractService $partial_or_due_date = ($this->invoice->partial > 0 && isset($this->invoice->partial_due_date)) ? $this->invoice->partial_due_date : $this->invoice->due_date; $reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->subDays($this->settings->num_days_reminder3); -// nlog("5. {$reminder_date->format('Y-m-d')}"); + // nlog("5. {$reminder_date->format('Y-m-d')}"); if ($reminder_date->gt(now())) { $date_collection->push($reminder_date); @@ -142,7 +142,7 @@ class UpdateReminder extends AbstractService $partial_or_due_date = ($this->invoice->partial > 0 && isset($this->invoice->partial_due_date)) ? $this->invoice->partial_due_date : $this->invoice->due_date; $reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->addDays($this->settings->num_days_reminder3); -// nlog("6. {$reminder_date->format('Y-m-d')}"); + // nlog("6. {$reminder_date->format('Y-m-d')}"); if ($reminder_date->gt(now())) { $date_collection->push($reminder_date); diff --git a/app/Services/Payment/DeletePayment.php b/app/Services/Payment/DeletePayment.php index 8884dbdef622..caac1125f57f 100644 --- a/app/Services/Payment/DeletePayment.php +++ b/app/Services/Payment/DeletePayment.php @@ -11,10 +11,10 @@ namespace App\Services\Payment; +use App\Models\BankTransaction; use App\Models\Credit; use App\Models\Invoice; use App\Models\Payment; -use App\Models\BankTransaction; use Illuminate\Contracts\Container\BindingResolutionException; class DeletePayment @@ -58,7 +58,7 @@ class DeletePayment $this->payment->is_deleted = true; $this->payment->delete(); - BankTransaction::query()->where('payment_id', $this->payment->id)->cursor()->each(function ($bt){ + BankTransaction::query()->where('payment_id', $this->payment->id)->cursor()->each(function ($bt) { $bt->payment_id = null; $bt->status_id = 1; $bt->save(); @@ -109,11 +109,9 @@ class DeletePayment if ($paymentable_invoice->balance == $paymentable_invoice->amount) { $paymentable_invoice->service()->setStatus(Invoice::STATUS_SENT)->save(); - } - elseif($paymentable_invoice->balance == 0){ + } elseif($paymentable_invoice->balance == 0) { $paymentable_invoice->service()->setStatus(Invoice::STATUS_PAID)->save(); - } - else { + } else { $paymentable_invoice->service()->setStatus(Invoice::STATUS_PARTIAL)->save(); } } else { diff --git a/app/Services/Payment/RefundPayment.php b/app/Services/Payment/RefundPayment.php index 72bdab75f6b0..b06833eeff0d 100644 --- a/app/Services/Payment/RefundPayment.php +++ b/app/Services/Payment/RefundPayment.php @@ -70,8 +70,9 @@ class RefundPayment private function finalize(): self { - if($this->refund_failed) + if($this->refund_failed) { throw new PaymentRefundFailed($this->refund_failed_message); + } return $this; } @@ -89,7 +90,7 @@ class RefundPayment * 'payment_id' => (int), * 'amount' => (float), * ]; - * + * * @return $this * @throws PaymentRefundFailed */ @@ -101,14 +102,14 @@ class RefundPayment if ($this->payment->company_gateway) { $response = $this->payment->company_gateway->driver($this->payment->client)->refund($this->payment, $net_refund); - if($response['amount'] ?? false) + if($response['amount'] ?? false) { $net_refund = $response['amount']; + } - if($response['voided'] ?? false) - { - //When a transaction is voided - all invoices attached to the payment need to be reversed, this + if($response['voided'] ?? false) { + //When a transaction is voided - all invoices attached to the payment need to be reversed, this //block prevents the edge case where a partial refund was attempted. - $this->refund_data['invoices'] = $this->payment->invoices->map(function ($invoice){ + $this->refund_data['invoices'] = $this->payment->invoices->map(function ($invoice) { return [ 'invoice_id' => $invoice->id, 'amount' => $invoice->pivot->amount, @@ -277,8 +278,7 @@ class RefundPayment private function adjustInvoices() { if (isset($this->refund_data['invoices']) && count($this->refund_data['invoices']) > 0) { - foreach ($this->refund_data['invoices'] as $refunded_invoice) - { + foreach ($this->refund_data['invoices'] as $refunded_invoice) { $invoice = Invoice::withTrashed()->find($refunded_invoice['invoice_id']); if ($invoice->trashed()) { @@ -342,4 +342,4 @@ class RefundPayment return $this->payment; } -} \ No newline at end of file +} diff --git a/app/Services/Pdf/PdfBuilder.php b/app/Services/Pdf/PdfBuilder.php index cae7ecaa94de..0c844fcba6f1 100644 --- a/app/Services/Pdf/PdfBuilder.php +++ b/app/Services/Pdf/PdfBuilder.php @@ -11,14 +11,14 @@ namespace App\Services\Pdf; -use DOMDocument; -use App\Models\Quote; use App\Models\Credit; -use App\Utils\Helpers; -use Illuminate\Support\Str; -use Illuminate\Support\Carbon; -use App\Utils\Traits\MakesDates; +use App\Models\Quote; use App\Services\Template\TemplateService; +use App\Utils\Helpers; +use App\Utils\Traits\MakesDates; +use DOMDocument; +use Illuminate\Support\Carbon; +use Illuminate\Support\Str; use League\CommonMark\CommonMarkConverter; class PdfBuilder @@ -74,12 +74,12 @@ class PdfBuilder return $this; } - /** - * Final method to get compiled HTML. - * - * @param bool $final @deprecated // is it? i still see it being called elsewhere - * @return string - */ + /** + * Final method to get compiled HTML. + * + * @param bool $final @deprecated // is it? i still see it being called elsewhere + * @return string + */ public function getCompiledHTML($final = false) { $html = $this->document->saveHTML(); @@ -764,13 +764,13 @@ class PdfBuilder return $data; } - /** - * Generate the structure of table headers. () - * - * @param string $type "product" or "task" - * @return array - * - */ + /** + * Generate the structure of table headers. () + * + * @param string $type "product" or "task" + * @return array + * + */ public function buildTableHeader(string $type): array { $this->processTaxColumns($type); diff --git a/app/Services/Pdf/PdfMock.php b/app/Services/Pdf/PdfMock.php index c7b98de46a71..e08da50cd5c9 100644 --- a/app/Services/Pdf/PdfMock.php +++ b/app/Services/Pdf/PdfMock.php @@ -69,10 +69,11 @@ class PdfMock $pdf_service->config = $pdf_config; - if(isset($this->request['design'])) + if(isset($this->request['design'])) { $pdf_designer = (new PdfDesigner($pdf_service))->buildFromPartials($this->request['design']); - else + } else { $pdf_designer = (new PdfDesigner($pdf_service))->build(); + } $pdf_service->designer = $pdf_designer; diff --git a/app/Services/Pdf/PdfService.php b/app/Services/Pdf/PdfService.php index 31d724fbbc0c..9ef50f988141 100644 --- a/app/Services/Pdf/PdfService.php +++ b/app/Services/Pdf/PdfService.php @@ -67,7 +67,7 @@ class PdfService } public function boot(): self - { + { $this->init(); diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index 9f90a9a2fa25..e9ffb0389864 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -265,9 +265,9 @@ class Design extends BaseDesign $variables = $this->context['pdf_variables']['client_details']; - $elements = collect($variables)->filter(function ($variable) use ($address_variables){ + $elements = collect($variables)->filter(function ($variable) use ($address_variables) { return in_array($variable, $address_variables); - })->map(function ($variable){ + })->map(function ($variable) { $variable = str_replace('$client.', '$client.shipping_', $variable); return ['element' => 'p', 'content' => $variable, 'show_empty' => false, 'properties' => ['data-ref' => "client_details-shipping-" . substr($variable, 1)]]; @@ -935,7 +935,7 @@ class Design extends BaseDesign //07/09/2023 don't show custom values if they are empty // $visible = intval($this->entity->{$_variable}) != 0; - $visible = intval(str_replace(['0','.'],'', $this->entity->{$_variable})) != 0; + $visible = intval(str_replace(['0','.'], '', $this->entity->{$_variable})) != 0; $elements[1]['elements'][] = ['element' => 'div', 'elements' => [ ['element' => 'span', 'content' => $variable . '_label', 'properties' => ['hidden' => !$visible, 'data-ref' => 'totals_table-' . substr($variable, 1) . '-label']], diff --git a/app/Services/PdfMaker/PdfMaker.php b/app/Services/PdfMaker/PdfMaker.php index f54cbbf26677..680bf7ef8146 100644 --- a/app/Services/PdfMaker/PdfMaker.php +++ b/app/Services/PdfMaker/PdfMaker.php @@ -97,7 +97,7 @@ class PdfMaker } - foreach($contents as $key => $content){ + foreach($contents as $key => $content) { $content->parentNode->replaceChild($replacements[$key], $content); } diff --git a/app/Services/PurchaseOrder/GetPurchaseOrderPdf.php b/app/Services/PurchaseOrder/GetPurchaseOrderPdf.php index 32dc93f1083e..40044b90b6e5 100644 --- a/app/Services/PurchaseOrder/GetPurchaseOrderPdf.php +++ b/app/Services/PurchaseOrder/GetPurchaseOrderPdf.php @@ -11,11 +11,11 @@ namespace App\Services\PurchaseOrder; +use App\Jobs\Vendor\CreatePurchaseOrderPdf; use App\Models\PurchaseOrder; use App\Models\VendorContact; use App\Services\AbstractService; use Illuminate\Support\Facades\Storage; -use App\Jobs\Vendor\CreatePurchaseOrderPdf; class GetPurchaseOrderPdf extends AbstractService { diff --git a/app/Services/PurchaseOrder/PurchaseOrderService.php b/app/Services/PurchaseOrder/PurchaseOrderService.php index 6ee50bc5a466..2f40b51f00fa 100644 --- a/app/Services/PurchaseOrder/PurchaseOrderService.php +++ b/app/Services/PurchaseOrder/PurchaseOrderService.php @@ -13,8 +13,6 @@ namespace App\Services\PurchaseOrder; use App\Models\PurchaseOrder; use App\Utils\Traits\MakesHash; -use App\Services\PurchaseOrder\SendEmail; -use App\Jobs\Vendor\CreatePurchaseOrderPdf; class PurchaseOrderService { @@ -132,7 +130,7 @@ class PurchaseOrderService /** * Saves the purchase order. - * @return \App\Models\PurchaseOrder + * @return \App\Models\PurchaseOrder */ public function save(): ?PurchaseOrder { diff --git a/app/Services/PurchaseOrder/SendEmail.php b/app/Services/PurchaseOrder/SendEmail.php index 900d5380bc6a..a6b2fa1c3aaf 100644 --- a/app/Services/PurchaseOrder/SendEmail.php +++ b/app/Services/PurchaseOrder/SendEmail.php @@ -11,16 +11,16 @@ namespace App\Services\PurchaseOrder; -use App\Utils\Ninja; -use App\Models\PurchaseOrder; -use App\Models\VendorContact; +use App\Events\PurchaseOrder\PurchaseOrderWasEmailed; use App\Jobs\Mail\NinjaMailerJob; -use App\Mail\VendorTemplateEmail; -use App\Services\AbstractService; -use Illuminate\Support\Facades\App; use App\Jobs\Mail\NinjaMailerObject; use App\Mail\Engine\PurchaseOrderEmailEngine; -use App\Events\PurchaseOrder\PurchaseOrderWasEmailed; +use App\Mail\VendorTemplateEmail; +use App\Models\PurchaseOrder; +use App\Models\VendorContact; +use App\Services\AbstractService; +use App\Utils\Ninja; +use Illuminate\Support\Facades\App; class SendEmail extends AbstractService { @@ -69,48 +69,3 @@ class SendEmail extends AbstractService } } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/Services/Quote/ConvertQuoteToProject.php b/app/Services/Quote/ConvertQuoteToProject.php index 59227fcfc566..4b37a3c3e8b5 100644 --- a/app/Services/Quote/ConvertQuoteToProject.php +++ b/app/Services/Quote/ConvertQuoteToProject.php @@ -12,11 +12,10 @@ namespace App\Services\Quote; -use App\DataMapper\InvoiceItem; -use App\Models\Quote; use App\Factory\ProjectFactory; use App\Factory\TaskFactory; use App\Models\Project; +use App\Models\Quote; use App\Repositories\TaskRepository; use App\Utils\Traits\GeneratesCounter; @@ -31,9 +30,9 @@ class ConvertQuoteToProject public function run(): Project { - $quote_items = collect($this->quote->line_items)->filter(function ($item){ - return $item->type_id == '2'; - }); + $quote_items = collect($this->quote->line_items)->filter(function ($item) { + return $item->type_id == '2'; + }); $project = ProjectFactory::create($this->quote->company_id, $this->quote->user_id); $project->name = ctrans('texts.quote_number_short'). " " . $this->quote->number . " [{$this->quote->client->present()->name()}]"; @@ -57,20 +56,20 @@ class ConvertQuoteToProject $task_repo = new TaskRepository(); - $quote_items->each(function($item) use($task_repo, $task_status){ + $quote_items->each(function ($item) use ($task_repo, $task_status) { - $task = TaskFactory::create($this->quote->company_id, $this->quote->user_id); - $task->client_id = $this->quote->client_id; - $task->project_id = $this->quote->project_id; - $task->description = $item->notes; - $task->status_id = $task_status->id; - $task->rate = $item->cost; - $task_repo->save([], $task); + $task = TaskFactory::create($this->quote->company_id, $this->quote->user_id); + $task->client_id = $this->quote->client_id; + $task->project_id = $this->quote->project_id; + $task->description = $item->notes; + $task->status_id = $task_status->id; + $task->rate = $item->cost; + $task_repo->save([], $task); - }); + }); event('eloquent.created: App\Models\Project', $project); return $project->fresh(); } -} \ No newline at end of file +} diff --git a/app/Services/Quote/CreateInvitations.php b/app/Services/Quote/CreateInvitations.php index 933bbdbe9de9..47c435a58f1c 100644 --- a/app/Services/Quote/CreateInvitations.php +++ b/app/Services/Quote/CreateInvitations.php @@ -42,7 +42,7 @@ class CreateInvitations $contacts->each(function ($contact) { $invitation = QuoteInvitation::query() - ->where('company_id',$this->quote->company_id) + ->where('company_id', $this->quote->company_id) ->whereClientContactId($contact->id) ->whereQuoteId($this->quote->id) ->withTrashed() diff --git a/app/Services/Quote/GetQuotePdf.php b/app/Services/Quote/GetQuotePdf.php index d58268cbe050..cd1a537aaf98 100644 --- a/app/Services/Quote/GetQuotePdf.php +++ b/app/Services/Quote/GetQuotePdf.php @@ -11,9 +11,9 @@ namespace App\Services\Quote; -use App\Models\Quote; -use App\Models\ClientContact; use App\Jobs\Entity\CreateRawPdf; +use App\Models\ClientContact; +use App\Models\Quote; use App\Services\AbstractService; class GetQuotePdf extends AbstractService diff --git a/app/Services/Quote/MarkSent.php b/app/Services/Quote/MarkSent.php index 263ce043ce20..f7c32b0ef028 100644 --- a/app/Services/Quote/MarkSent.php +++ b/app/Services/Quote/MarkSent.php @@ -11,12 +11,12 @@ namespace App\Services\Quote; -use Carbon\Carbon; -use App\Utils\Ninja; -use App\Models\Quote; -use App\Models\Client; -use App\Models\Webhook; use App\Events\Quote\QuoteWasMarkedSent; +use App\Models\Client; +use App\Models\Quote; +use App\Models\Webhook; +use App\Utils\Ninja; +use Carbon\Carbon; class MarkSent { diff --git a/app/Services/Quote/QuoteService.php b/app/Services/Quote/QuoteService.php index d6a09c08fbf1..fc6b51b45634 100644 --- a/app/Services/Quote/QuoteService.php +++ b/app/Services/Quote/QuoteService.php @@ -11,15 +11,14 @@ namespace App\Services\Quote; -use App\Utils\Ninja; -use App\Models\Quote; -use App\Models\Project; -use App\Utils\Traits\MakesHash; -use App\Exceptions\QuoteConversion; -use App\Repositories\QuoteRepository; use App\Events\Quote\QuoteWasApproved; +use App\Exceptions\QuoteConversion; +use App\Models\Project; +use App\Models\Quote; +use App\Repositories\QuoteRepository; +use App\Utils\Ninja; +use App\Utils\Traits\MakesHash; use Illuminate\Support\Facades\Storage; -use App\Services\Quote\ConvertQuoteToProject; class QuoteService { diff --git a/app/Services/Quote/SendEmail.php b/app/Services/Quote/SendEmail.php index d157792aa0c6..3cd0cf301bac 100644 --- a/app/Services/Quote/SendEmail.php +++ b/app/Services/Quote/SendEmail.php @@ -11,10 +11,8 @@ namespace App\Services\Quote; -use App\Utils\Ninja; -use App\Models\ClientContact; use App\Jobs\Entity\EmailEntity; -use App\Events\Quote\QuoteWasEmailed; +use App\Models\ClientContact; class SendEmail { diff --git a/app/Services/Recurring/GetInvoicePdf.php b/app/Services/Recurring/GetInvoicePdf.php index ea66fff6a8b3..019d094e6fdc 100644 --- a/app/Services/Recurring/GetInvoicePdf.php +++ b/app/Services/Recurring/GetInvoicePdf.php @@ -11,8 +11,8 @@ namespace App\Services\Recurring; -use App\Models\ClientContact; use App\Jobs\Entity\CreateRawPdf; +use App\Models\ClientContact; use App\Services\AbstractService; class GetInvoicePdf extends AbstractService diff --git a/app/Services/Recurring/RecurringService.php b/app/Services/Recurring/RecurringService.php index eca206c746e0..61ae416956b1 100644 --- a/app/Services/Recurring/RecurringService.php +++ b/app/Services/Recurring/RecurringService.php @@ -11,14 +11,13 @@ namespace App\Services\Recurring; -use App\Utils\Ninja; -use App\Jobs\Util\UnlinkFile; -use App\Models\RecurringQuote; -use Illuminate\Support\Carbon; +use App\Jobs\RecurringInvoice\SendRecurring; use App\Models\RecurringExpense; use App\Models\RecurringInvoice; +use App\Models\RecurringQuote; +use App\Utils\Ninja; +use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Storage; -use App\Jobs\RecurringInvoice\SendRecurring; class RecurringService { @@ -94,7 +93,7 @@ class RecurringService //30-06-2023 try { Storage::disk(config('filesystems.default'))->delete($this->recurring_entity->client->recurring_invoice_filepath($invitation) . $this->recurring_entity->numberFormatter().'.pdf'); - Storage::disk('public')->delete($this->recurring_entity->client->recurring_invoice_filepath($invitation) . $this->recurring_entity->numberFormatter().'.pdf'); + Storage::disk('public')->delete($this->recurring_entity->client->recurring_invoice_filepath($invitation) . $this->recurring_entity->numberFormatter().'.pdf'); if (Ninja::isHosted()) { } } catch (\Exception $e) { diff --git a/app/Services/Report/ARDetailReport.php b/app/Services/Report/ARDetailReport.php index 3787acd07cd5..70526195c823 100644 --- a/app/Services/Report/ARDetailReport.php +++ b/app/Services/Report/ARDetailReport.php @@ -11,17 +11,17 @@ namespace App\Services\Report; -use Carbon\Carbon; -use App\Utils\Ninja; -use App\Utils\Number; +use App\Export\CSV\BaseExport; +use App\Libraries\MultiDB; use App\Models\Client; -use League\Csv\Writer; use App\Models\Company; use App\Models\Invoice; -use App\Libraries\MultiDB; -use App\Export\CSV\BaseExport; +use App\Utils\Ninja; +use App\Utils\Number; use App\Utils\Traits\MakesDates; +use Carbon\Carbon; use Illuminate\Support\Facades\App; +use League\Csv\Writer; class ARDetailReport extends BaseExport { @@ -102,7 +102,7 @@ class ARDetailReport extends BaseExport $query->cursor() ->each(function ($invoice) { - $this->csv->insertOne($this->buildRow($invoice)); + $this->csv->insertOne($this->buildRow($invoice)); }); return $this->csv->toString(); @@ -138,4 +138,4 @@ class ARDetailReport extends BaseExport return $header; } -} \ No newline at end of file +} diff --git a/app/Services/Report/ARSummaryReport.php b/app/Services/Report/ARSummaryReport.php index 0fd0d5b83dfb..9193a8d773f7 100644 --- a/app/Services/Report/ARSummaryReport.php +++ b/app/Services/Report/ARSummaryReport.php @@ -106,7 +106,7 @@ class ARSummaryReport extends BaseExport $this->client->present()->name(), $this->client->number, $this->client->id_number, - $this->getCurrent(), + $this->getCurrent(), $this->getAgingAmount('30'), $this->getAgingAmount('60'), $this->getAgingAmount('90'), @@ -128,7 +128,7 @@ class ARSummaryReport extends BaseExport ->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) ->where('balance', '>', 0) ->where('is_deleted', 0) - ->where(function ($query){ + ->where(function ($query) { $query->where('due_date', '>', now()->startOfDay()) ->orWhereNull('due_date'); }) @@ -161,7 +161,7 @@ class ARSummaryReport extends BaseExport ->whereBetween('due_date', [$to, $from]) ->sum('balance'); - $this->total += $amount; + $this->total += $amount; return Number::formatMoney($amount, $this->client); } diff --git a/app/Services/Report/ClientBalanceReport.php b/app/Services/Report/ClientBalanceReport.php index 0c0eb85aca29..405cfdbe2981 100644 --- a/app/Services/Report/ClientBalanceReport.php +++ b/app/Services/Report/ClientBalanceReport.php @@ -11,15 +11,15 @@ namespace App\Services\Report; -use App\Utils\Ninja; +use App\Export\CSV\BaseExport; +use App\Libraries\MultiDB; use App\Models\Client; -use League\Csv\Writer; use App\Models\Company; use App\Models\Invoice; -use App\Libraries\MultiDB; -use App\Export\CSV\BaseExport; +use App\Utils\Ninja; use App\Utils\Traits\MakesDates; use Illuminate\Support\Facades\App; +use League\Csv\Writer; class ClientBalanceReport extends BaseExport { @@ -83,7 +83,7 @@ class ClientBalanceReport extends BaseExport ->where('is_deleted', 0) ->orderBy('balance', 'desc') ->cursor() - ->each(function ($client){ + ->each(function ($client) { $this->csv->insertOne($this->buildRow($client)); @@ -97,8 +97,9 @@ class ClientBalanceReport extends BaseExport { $headers = []; - foreach($this->report_keys as $key) + foreach($this->report_keys as $key) { $headers[] = ctrans("texts.{$key}"); + } return $headers; @@ -119,4 +120,4 @@ class ClientBalanceReport extends BaseExport $client->credit_balance, ]; } -} \ No newline at end of file +} diff --git a/app/Services/Report/ClientSalesReport.php b/app/Services/Report/ClientSalesReport.php index 7bb5b47d8324..66cd6016ca15 100644 --- a/app/Services/Report/ClientSalesReport.php +++ b/app/Services/Report/ClientSalesReport.php @@ -11,16 +11,16 @@ namespace App\Services\Report; -use App\Utils\Ninja; -use App\Utils\Number; +use App\Export\CSV\BaseExport; +use App\Libraries\MultiDB; use App\Models\Client; -use League\Csv\Writer; use App\Models\Company; use App\Models\Invoice; -use App\Libraries\MultiDB; -use App\Export\CSV\BaseExport; +use App\Utils\Ninja; +use App\Utils\Number; use App\Utils\Traits\MakesDates; use Illuminate\Support\Facades\App; +use League\Csv\Writer; class ClientSalesReport extends BaseExport { diff --git a/app/Services/Report/ProfitLoss.php b/app/Services/Report/ProfitLoss.php index b9505848130b..cbdba56c51df 100644 --- a/app/Services/Report/ProfitLoss.php +++ b/app/Services/Report/ProfitLoss.php @@ -11,19 +11,19 @@ namespace App\Services\Report; -use App\Utils\Ninja; -use App\Utils\Number; -use League\Csv\Writer; +use App\Libraries\Currency\Conversion\CurrencyApi; +use App\Libraries\MultiDB; use App\Models\Company; +use App\Models\Currency; use App\Models\Expense; use App\Models\Invoice; use App\Models\Payment; -use App\Models\Currency; -use App\Libraries\MultiDB; -use Illuminate\Support\Str; +use App\Utils\Ninja; +use App\Utils\Number; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\App; -use App\Libraries\Currency\Conversion\CurrencyApi; +use Illuminate\Support\Str; +use League\Csv\Writer; class ProfitLoss { diff --git a/app/Services/Report/TaxSummaryReport.php b/app/Services/Report/TaxSummaryReport.php index 661f741865cf..aaf313eaf23a 100644 --- a/app/Services/Report/TaxSummaryReport.php +++ b/app/Services/Report/TaxSummaryReport.php @@ -88,16 +88,14 @@ class TaxSummaryReport extends BaseExport $accrual_map = []; $cash_map = []; - foreach($query->cursor() as $invoice) - { + foreach($query->cursor() as $invoice) { $calc = $invoice->calc(); //Combine the line taxes with invoice taxes here to get a total tax amount $taxes = array_merge($calc->getTaxMap()->merge($calc->getTotalTaxMap())->toArray()); //filter into two arrays for accrual + cash - foreach($taxes as $tax) - { + foreach($taxes as $tax) { $key = $tax['name']; if(!isset($accrual_map[$key])) { @@ -113,12 +111,13 @@ class TaxSummaryReport extends BaseExport $cash_map[$key]['tax_amount'] = 0; } - if(in_array($invoice->status_id, [Invoice::STATUS_PARTIAL,Invoice::STATUS_PAID])){ + if(in_array($invoice->status_id, [Invoice::STATUS_PARTIAL,Invoice::STATUS_PAID])) { - if($invoice->status_id == Invoice::STATUS_PAID) - $cash_map[$key]['tax_amount'] += $tax['total']; - else - $cash_map[$key]['tax_amount'] += (($invoice->amount - $invoice->balance) / $invoice->balance) * $tax['total'] ?? 0; + if($invoice->status_id == Invoice::STATUS_PAID) { + $cash_map[$key]['tax_amount'] += $tax['total']; + } else { + $cash_map[$key]['tax_amount'] += (($invoice->amount - $invoice->balance) / $invoice->balance) * $tax['total'] ?? 0; + } } } @@ -130,8 +129,7 @@ class TaxSummaryReport extends BaseExport $this->csv->insertOne($this->buildHeader()); - foreach($accrual_map as $key => $value) - { + foreach($accrual_map as $key => $value) { $this->csv->insertOne([$key, Number::formatMoney($value['tax_amount'], $this->company)]); } diff --git a/app/Services/Report/UserSalesReport.php b/app/Services/Report/UserSalesReport.php index 9780e8a9ec82..f533bc7dc1f1 100644 --- a/app/Services/Report/UserSalesReport.php +++ b/app/Services/Report/UserSalesReport.php @@ -11,16 +11,15 @@ namespace App\Services\Report; -use App\Models\User; -use App\Utils\Ninja; -use App\Utils\Number; -use League\Csv\Writer; +use App\Export\CSV\BaseExport; +use App\Libraries\MultiDB; use App\Models\Company; use App\Models\Invoice; -use App\Libraries\MultiDB; -use App\Export\CSV\BaseExport; +use App\Utils\Ninja; +use App\Utils\Number; use App\Utils\Traits\MakesDates; use Illuminate\Support\Facades\App; +use League\Csv\Writer; class UserSalesReport extends BaseExport { @@ -40,7 +39,7 @@ class UserSalesReport extends BaseExport 'total_taxes', ]; /** - @param array $input + @param array $input [ 'date_range', 'start_date', @@ -83,7 +82,7 @@ class UserSalesReport extends BaseExport $users = $this->company->users; - $report = $users->map(function ($user) use($query){ + $report = $users->map(function ($user) use ($query) { $new_query = $query; $new_query->where('user_id', $user->id); diff --git a/app/Services/Scheduler/EmailRecord.php b/app/Services/Scheduler/EmailRecord.php index 1f5886226faf..9c0b498bb3c3 100644 --- a/app/Services/Scheduler/EmailRecord.php +++ b/app/Services/Scheduler/EmailRecord.php @@ -12,8 +12,8 @@ namespace App\Services\Scheduler; use App\Models\Scheduler; -use Illuminate\Support\Str; use App\Utils\Traits\MakesHash; +use Illuminate\Support\Str; class EmailRecord { @@ -29,8 +29,9 @@ class EmailRecord $entity = $class::find($this->decodePrimaryKey($this->scheduler->parameters['entity_id'])); - if($entity) + if($entity) { $entity->service()->sendEmail(); + } $this->scheduler->forceDelete(); } diff --git a/app/Services/Scheduler/EmailReport.php b/app/Services/Scheduler/EmailReport.php index f1def5d9b61c..9b8acf793445 100644 --- a/app/Services/Scheduler/EmailReport.php +++ b/app/Services/Scheduler/EmailReport.php @@ -11,34 +11,34 @@ namespace App\Services\Scheduler; -use App\Models\Client; -use App\Models\Scheduler; -use App\Mail\DownloadReport; -use App\Export\CSV\TaskExport; -use App\Export\CSV\QuoteExport; -use App\Utils\Traits\MakesHash; use App\Export\CSV\ClientExport; -use App\Export\CSV\CreditExport; -use App\Utils\Traits\MakesDates; 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\InvoiceItemExport; use App\Export\CSV\PaymentExport; use App\Export\CSV\ProductExport; -use App\Jobs\Mail\NinjaMailerJob; -use App\Export\CSV\DocumentExport; -use App\Export\CSV\QuoteItemExport; -use App\Services\Report\ProfitLoss; -use App\Jobs\Mail\NinjaMailerObject; -use App\Export\CSV\InvoiceItemExport; use App\Export\CSV\ProductSalesExport; +use App\Export\CSV\QuoteExport; +use App\Export\CSV\QuoteItemExport; +use App\Export\CSV\RecurringInvoiceExport; +use App\Export\CSV\TaskExport; +use App\Jobs\Mail\NinjaMailerJob; +use App\Jobs\Mail\NinjaMailerObject; +use App\Mail\DownloadReport; +use App\Models\Client; +use App\Models\Scheduler; use App\Services\Report\ARDetailReport; use App\Services\Report\ARSummaryReport; -use App\Services\Report\UserSalesReport; -use App\Services\Report\TaxSummaryReport; -use App\Export\CSV\RecurringInvoiceExport; -use App\Services\Report\ClientSalesReport; use App\Services\Report\ClientBalanceReport; +use App\Services\Report\ClientSalesReport; +use App\Services\Report\ProfitLoss; +use App\Services\Report\TaxSummaryReport; +use App\Services\Report\UserSalesReport; +use App\Utils\Traits\MakesDates; +use App\Utils\Traits\MakesHash; class EmailReport { @@ -76,8 +76,7 @@ class EmailReport $export = false; - match($this->scheduler->parameters['report_name']) - { + match($this->scheduler->parameters['report_name']) { 'product_sales' => $export = (new ProductSalesExport($this->scheduler->company, $data)), 'ar_detailed' => $export = (new ARDetailReport($this->scheduler->company, $data)), 'ar_summary' => $export = (new ARSummaryReport($this->scheduler->company, $data)), diff --git a/app/Services/Scheduler/SchedulerService.php b/app/Services/Scheduler/SchedulerService.php index ddf327ab35a1..d870a1cf3fde 100644 --- a/app/Services/Scheduler/SchedulerService.php +++ b/app/Services/Scheduler/SchedulerService.php @@ -12,9 +12,8 @@ namespace App\Services\Scheduler; use App\Models\Scheduler; -use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesDates; -use App\Services\Scheduler\EmailReport; +use App\Utils\Traits\MakesHash; class SchedulerService { diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index a9707222d9ea..e2e331b3f6dd 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -234,8 +234,9 @@ class SubscriptionService // Redirects from here work just fine. Livewire will respect it. $client_contact = ClientContact::find($this->decodePrimaryKey($data['contact_id'])); - if(is_string($data['client_id'])) + if(is_string($data['client_id'])) { $data['client_id'] = $this->decodePrimaryKey($data['client_id']); + } if (!$this->subscription->trial_enabled) { return new \Exception("Trials are disabled for this product"); @@ -788,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}"); @@ -969,7 +970,7 @@ class SubscriptionService ->fillDefaults() ->save(); - if($invoice->fresh()->balance == 0){ + if($invoice->fresh()->balance == 0) { $invoice->service()->markPaid()->save(); } diff --git a/app/Services/Subscription/ZeroCostProduct.php b/app/Services/Subscription/ZeroCostProduct.php index b73cc146cf93..245419edfdca 100644 --- a/app/Services/Subscription/ZeroCostProduct.php +++ b/app/Services/Subscription/ZeroCostProduct.php @@ -79,8 +79,9 @@ class ZeroCostProduct extends AbstractService 'redirect_url' => "/client/recurring_invoices/{$recurring_invoice->hashed_id}", ]; - if(isset($this->data['campaign'])) + if(isset($this->data['campaign'])) { $context['campaign'] = $this->data['campaign']; + } return $context; } diff --git a/app/Services/Tax/Providers/TaxProvider.php b/app/Services/Tax/Providers/TaxProvider.php index 00b540bbc0a4..1136b226e093 100644 --- a/app/Services/Tax/Providers/TaxProvider.php +++ b/app/Services/Tax/Providers/TaxProvider.php @@ -13,7 +13,6 @@ namespace App\Services\Tax\Providers; use App\Models\Client; use App\Models\Company; -use App\Services\Tax\Providers\EuTax; class TaxProvider { @@ -78,7 +77,7 @@ class TaxProvider try { - $this->configureProvider($this->provider, $this->company->country()->iso_3166_2); //hard coded for now to one provider, but we'll be able to swap these out later + $this->configureProvider($this->provider, $this->company->country()->iso_3166_2); //hard coded for now to one provider, but we'll be able to swap these out later $company_details = [ 'address2' => $this->company->settings->address2, @@ -101,8 +100,7 @@ class TaxProvider $this->updated_client = true; } - } - catch(\Exception $e){ + } catch(\Exception $e) { nlog("Could not updated company tax data: " . $e->getMessage()); } @@ -165,8 +163,9 @@ class TaxProvider private function taxShippingAddress(): bool { - if($this->client->shipping_country_id == "840" && strlen($this->client->shipping_postal_code) > 3) + if($this->client->shipping_country_id == "840" && strlen($this->client->shipping_postal_code) > 3) { return true; + } return false; @@ -182,7 +181,7 @@ class TaxProvider private function configureProvider(?string $provider, string $country_code): self { - match($country_code){ + match($country_code) { 'US' => $this->configureZipTax(), "AT" => $this->configureEuTax(), "BE" => $this->configureEuTax(), @@ -251,8 +250,9 @@ class TaxProvider */ private function configureZipTax(): self { - if(!config('services.tax.zip_tax.key')) + if(!config('services.tax.zip_tax.key')) { throw new \Exception("ZipTax API key not set in .env file"); + } $this->api_credentials = config('services.tax.zip_tax.key'); @@ -262,4 +262,4 @@ class TaxProvider } -} \ No newline at end of file +} diff --git a/app/Services/Tax/Providers/ZipTax.php b/app/Services/Tax/Providers/ZipTax.php index dad7ef0768fc..fa8e1bb31f4f 100644 --- a/app/Services/Tax/Providers/ZipTax.php +++ b/app/Services/Tax/Providers/ZipTax.php @@ -31,15 +31,16 @@ class ZipTax implements TaxProviderInterface $response = $this->callApi(['key' => $this->api_key, 'address' => $string_address]); - if($response->successful()){ + if($response->successful()) { return $this->parseResponse($response->json()); } if(isset($this->address['postal_code'])) { - $response = $this->callApi(['key' => $this->api_key, 'address' => $this->address['postal_code']]); + $response = $this->callApi(['key' => $this->api_key, 'address' => $this->address['postal_code']]); - if($response->successful()) + if($response->successful()) { return $this->parseResponse($response->json()); + } } @@ -69,11 +70,13 @@ class ZipTax implements TaxProviderInterface private function parseResponse($response) { - if(isset($response['rCode']) && $response['rCode'] == 100 && isset($response['results']['0'])) + if(isset($response['rCode']) && $response['rCode'] == 100 && isset($response['results']['0'])) { return $response['results']['0']; + } - if(isset($response['rCode']) && class_exists(\Modules\Admin\Events\TaxProviderException::class)) + if(isset($response['rCode']) && class_exists(\Modules\Admin\Events\TaxProviderException::class)) { event(new \Modules\Admin\Events\TaxProviderException($response['rCode'])); + } return null; diff --git a/app/Services/Tax/TaxService.php b/app/Services/Tax/TaxService.php index d724e175ac88..b81bdaa065d0 100644 --- a/app/Services/Tax/TaxService.php +++ b/app/Services/Tax/TaxService.php @@ -37,13 +37,13 @@ class TaxService $this->client->has_valid_vat_number = true; - if(!$this->client->name && strlen($vat_check->getName()) > 2) { - $this->client->name = $vat_check->getName(); - } + if(!$this->client->name && strlen($vat_check->getName()) > 2) { + $this->client->name = $vat_check->getName(); + } - if(empty($this->client->private_notes) && strlen($vat_check->getAddress()) > 2) { - $this->client->private_notes = $vat_check->getAddress(); - } + if(empty($this->client->private_notes) && strlen($vat_check->getAddress()) > 2) { + $this->client->private_notes = $vat_check->getAddress(); + } $this->client->saveQuietly(); } @@ -56,4 +56,4 @@ class TaxService { } -} \ No newline at end of file +} diff --git a/app/Services/Tax/VatNumberCheck.php b/app/Services/Tax/VatNumberCheck.php index 61c5f2bb5073..e7f7cf58737c 100644 --- a/app/Services/Tax/VatNumberCheck.php +++ b/app/Services/Tax/VatNumberCheck.php @@ -48,7 +48,7 @@ class VatNumberCheck } } catch (\SoapFault $e) { - $this->response = ['valid' => false, 'error' => $e->getMessage()]; + $this->response = ['valid' => false, 'error' => $e->getMessage()]; } return $this; diff --git a/app/Services/Template/TemplateAction.php b/app/Services/Template/TemplateAction.php index c1a8ebbd1054..2c753a754d1c 100644 --- a/app/Services/Template/TemplateAction.php +++ b/app/Services/Template/TemplateAction.php @@ -11,34 +11,33 @@ namespace App\Services\Template; -use App\Models\Task; -use App\Models\User; -use App\Models\Quote; +use App\Libraries\MultiDB; 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\Expense; use App\Models\Invoice; use App\Models\Payment; use App\Models\Product; use App\Models\Project; -use App\Libraries\MultiDB; use App\Models\PurchaseOrder; -use Illuminate\Bus\Queueable; -use App\Utils\Traits\MakesHash; +use App\Models\Quote; use App\Models\RecurringInvoice; +use App\Models\Task; +use App\Models\User; +use App\Models\Vendor; use App\Services\Email\AdminEmail; use App\Services\Email\EmailObject; -use Illuminate\Mail\Mailables\Address; -use Illuminate\Queue\SerializesModels; -use Illuminate\Support\Facades\Storage; -use Illuminate\Queue\InteractsWithQueue; +use App\Utils\Traits\MakesHash; +use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; -use Illuminate\Contracts\Database\Eloquent\Builder; +use Illuminate\Mail\Mailables\Address; +use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\Middleware\WithoutOverlapping; +use Illuminate\Queue\SerializesModels; +use Illuminate\Support\Facades\Storage; class TemplateAction implements ShouldQueue { @@ -55,18 +54,19 @@ class TemplateAction implements ShouldQueue * @param int $user_id requesting the template * @param string $db The database name * @param bool $send_email Determines whether to send an email - * + * * @return void */ - public function __construct(public array $ids, - private string $template, - private string $entity, - private int $user_id, - private Company $company, - private string $db, - private string $hash, - private bool $send_email = false) - { + public function __construct( + public array $ids, + private string $template, + private string $entity, + private int $user_id, + private Company $company, + private string $db, + private string $hash, + private bool $send_email = false + ) { } /** @@ -74,7 +74,7 @@ class TemplateAction implements ShouldQueue * */ public function handle() - { + { // nlog("inside template action"); MultiDB::setDb($this->db); @@ -87,7 +87,7 @@ class TemplateAction implements ShouldQueue $template_service = new TemplateService($template); - match($this->entity){ + match($this->entity) { Invoice::class => $resource->with('payments', 'client'), Quote::class => $resource->with('client'), Task::class => $resource->with('client'), @@ -103,10 +103,11 @@ class TemplateAction implements ShouldQueue ->where('company_id', $this->company->id) ->get(); - if($result->count() <= 1) + if($result->count() <= 1) { $data[$key] = collect($result); - else + } else { $data[$key] = $result; + } $ts = $template_service->build($data); @@ -115,8 +116,7 @@ class TemplateAction implements ShouldQueue if($this->send_email) { $pdf = $ts->getPdf(); $this->sendEmail($pdf, $template); - } - else { + } else { $pdf = $ts->getPdf(); $filename = "templates/{$this->hash}.pdf"; Storage::disk(config('filesystems.default'))->put($filename, $pdf); @@ -147,10 +147,10 @@ class TemplateAction implements ShouldQueue /** * Context - * + * * If I have an array of invoices, what could I possib - * - * + * + * */ private function resolveEntityString() { @@ -177,6 +177,3 @@ class TemplateAction implements ShouldQueue } } - - - diff --git a/app/Services/Template/TemplateMock.php b/app/Services/Template/TemplateMock.php index af129c400c6d..400276a217e0 100644 --- a/app/Services/Template/TemplateMock.php +++ b/app/Services/Template/TemplateMock.php @@ -69,9 +69,9 @@ class TemplateMock * @return array */ private function createVariables(string $type): array - { + { $data = [ - 'entity_type' => rtrim($type,"s"), + 'entity_type' => rtrim($type, "s"), 'design' => '', 'settings_type' => 'company', 'settings' => $this->company->settings, @@ -85,4 +85,4 @@ class TemplateMock } -} \ No newline at end of file +} diff --git a/app/Services/Template/TemplateService.php b/app/Services/Template/TemplateService.php index 6ca56d0bdde3..637653300177 100644 --- a/app/Services/Template/TemplateService.php +++ b/app/Services/Template/TemplateService.php @@ -11,38 +11,38 @@ namespace App\Services\Template; -use Twig\TwigFilter; -use App\Utils\Number; -use Twig\Environment; -use Twig\Error\Error; use App\Models\Client; -use App\Models\Design; -use Twig\TwigFunction; use App\Models\Company; +use App\Models\Design; use App\Models\Invoice; use App\Models\Payment; use App\Models\Project; -use App\Utils\HtmlEngine; -use League\Fractal\Manager; -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\Transformers\ProjectTransformer; +use App\Transformers\PurchaseOrderTransformer; +use App\Transformers\QuoteTransformer; +use App\Transformers\TaskTransformer; +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 Twig\Loader\FilesystemLoader; use App\Utils\Traits\Pdf\PdfMaker; -use Twig\Extension\DebugExtension; -use Twig\Extra\Intl\IntlExtension; -use App\Transformers\TaskTransformer; -use App\Transformers\QuoteTransformer; -use App\Transformers\ProjectTransformer; -use Twig\Extension\StringLoaderExtension; -use App\Transformers\PurchaseOrderTransformer; +use App\Utils\VendorHtmlEngine; +use League\Fractal\Manager; use League\Fractal\Serializer\ArraySerializer; +use Twig\Environment; +use Twig\Error\Error; +use Twig\Error\LoaderError; +use Twig\Error\RuntimeError; +use Twig\Error\SyntaxError; +use Twig\Extension\DebugExtension; +use Twig\Extension\StringLoaderExtension; +use Twig\Extra\Intl\IntlExtension; +use Twig\Loader\FilesystemLoader; +use Twig\Sandbox\SecurityError; +use Twig\TwigFilter; +use Twig\TwigFunction; class TemplateService { diff --git a/app/Transformers/ActivityTransformer.php b/app/Transformers/ActivityTransformer.php index 9c910daae682..6d8f465f1e95 100644 --- a/app/Transformers/ActivityTransformer.php +++ b/app/Transformers/ActivityTransformer.php @@ -11,24 +11,22 @@ namespace App\Transformers; -use App\Models\Task; -use App\Models\User; -use App\Models\Quote; +use App\Models\Activity; use App\Models\Backup; use App\Models\Client; +use App\Models\ClientContact; use App\Models\Credit; -use App\Models\Vendor; use App\Models\Expense; use App\Models\Invoice; use App\Models\Payment; -use App\Models\Activity; -use App\Models\ClientContact; use App\Models\PurchaseOrder; +use App\Models\Quote; +use App\Models\RecurringInvoice; +use App\Models\Task; +use App\Models\User; +use App\Models\Vendor; use App\Models\VendorContact; use App\Utils\Traits\MakesHash; -use App\Models\RecurringInvoice; -use App\Transformers\EntityTransformer; -use App\Transformers\InvoiceHistoryTransformer; class ActivityTransformer extends EntityTransformer { diff --git a/app/Transformers/BankIntegrationTransformer.php b/app/Transformers/BankIntegrationTransformer.php index c414e76f466d..7757ee7559e7 100644 --- a/app/Transformers/BankIntegrationTransformer.php +++ b/app/Transformers/BankIntegrationTransformer.php @@ -12,11 +12,10 @@ namespace App\Transformers; use App\Models\Account; -use App\Models\Company; use App\Models\BankIntegration; use App\Models\BankTransaction; +use App\Models\Company; use App\Utils\Traits\MakesHash; -use App\Transformers\EntityTransformer; /** * Class BankIntegrationTransformer. diff --git a/app/Transformers/BankTransactionRuleTransformer.php b/app/Transformers/BankTransactionRuleTransformer.php index 9b9b71ed65a4..ca3bf7262acd 100644 --- a/app/Transformers/BankTransactionRuleTransformer.php +++ b/app/Transformers/BankTransactionRuleTransformer.php @@ -11,7 +11,6 @@ namespace App\Transformers; -use App\Models\BankTransaction; use App\Models\BankTransactionRule; use App\Models\Client; use App\Models\Company; diff --git a/app/Transformers/BankTransactionTransformer.php b/app/Transformers/BankTransactionTransformer.php index dd9484c13542..401d5a0a1eb8 100644 --- a/app/Transformers/BankTransactionTransformer.php +++ b/app/Transformers/BankTransactionTransformer.php @@ -11,11 +11,11 @@ namespace App\Transformers; -use App\Models\Vendor; +use App\Models\BankTransaction; use App\Models\Company; use App\Models\Expense; use App\Models\Payment; -use App\Models\BankTransaction; +use App\Models\Vendor; use App\Utils\Traits\MakesHash; /** diff --git a/app/Transformers/ClientTransformer.php b/app/Transformers/ClientTransformer.php index 4cfb7742b3e4..8bbddfa9f257 100644 --- a/app/Transformers/ClientTransformer.php +++ b/app/Transformers/ClientTransformer.php @@ -20,7 +20,6 @@ use App\Models\Document; use App\Models\GroupSetting; use App\Models\SystemLog; use App\Utils\Traits\MakesHash; -use League\Fractal\Resource\Collection; use stdClass; /** @@ -100,8 +99,9 @@ class ClientTransformer extends EntityTransformer public function includeGroupSettings(Client $client) { - if (!$client->group_settings) + if (!$client->group_settings) { return null; + } $transformer = new GroupSettingTransformer($this->serializer); diff --git a/app/Transformers/CompanyGatewayTransformer.php b/app/Transformers/CompanyGatewayTransformer.php index 9a0fd943d17b..768e8f903b5f 100644 --- a/app/Transformers/CompanyGatewayTransformer.php +++ b/app/Transformers/CompanyGatewayTransformer.php @@ -11,12 +11,12 @@ namespace App\Transformers; -use stdClass; +use App\Models\CompanyGateway; use App\Models\Gateway; use App\Models\SystemLog; -use App\Models\CompanyGateway; use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\SoftDeletes; +use stdClass; /** * Class CompanyGatewayTransformer. diff --git a/app/Transformers/CompanyTransformer.php b/app/Transformers/CompanyTransformer.php index c3e9f2564193..c7d56e27f52b 100644 --- a/app/Transformers/CompanyTransformer.php +++ b/app/Transformers/CompanyTransformer.php @@ -11,43 +11,43 @@ namespace App\Transformers; -use stdClass; -use App\Models\Task; -use App\Models\User; -use App\Models\Quote; -use App\Models\Client; -use App\Models\Credit; -use App\Models\Design; -use App\Models\Vendor; use App\Models\Account; -use App\Models\Company; -use App\Models\Expense; -use App\Models\Invoice; -use App\Models\Payment; -use App\Models\Product; -use App\Models\Project; -use App\Models\TaxRate; -use App\Models\Webhook; use App\Models\Activity; -use App\Models\Document; -use App\Models\Scheduler; -use App\Models\SystemLog; -use App\Models\TaskStatus; -use App\Models\CompanyUser; -use App\Models\PaymentTerm; -use App\Models\CompanyToken; -use App\Models\GroupSetting; -use App\Models\Subscription; -use App\Models\CompanyLedger; -use App\Models\PurchaseOrder; -use App\Models\CompanyGateway; use App\Models\BankIntegration; use App\Models\BankTransaction; +use App\Models\BankTransactionRule; +use App\Models\Client; +use App\Models\Company; +use App\Models\CompanyGateway; +use App\Models\CompanyLedger; +use App\Models\CompanyToken; +use App\Models\CompanyUser; +use App\Models\Credit; +use App\Models\Design; +use App\Models\Document; +use App\Models\Expense; use App\Models\ExpenseCategory; -use App\Utils\Traits\MakesHash; +use App\Models\GroupSetting; +use App\Models\Invoice; +use App\Models\Payment; +use App\Models\PaymentTerm; +use App\Models\Product; +use App\Models\Project; +use App\Models\PurchaseOrder; +use App\Models\Quote; use App\Models\RecurringExpense; use App\Models\RecurringInvoice; -use App\Models\BankTransactionRule; +use App\Models\Scheduler; +use App\Models\Subscription; +use App\Models\SystemLog; +use App\Models\Task; +use App\Models\TaskStatus; +use App\Models\TaxRate; +use App\Models\User; +use App\Models\Vendor; +use App\Models\Webhook; +use App\Utils\Traits\MakesHash; +use stdClass; /** * Class CompanyTransformer. @@ -213,8 +213,7 @@ class CompanyTransformer extends EntityTransformer $user = auth()->user(); //if the user is attached to more than one company AND they are not an admin across all companies - if ($company->is_large || ($user->company_users()->count() > 1 && ($user->company_users()->where('is_admin', 1)->count() != $user->company_users()->count()))) - { + if ($company->is_large || ($user->company_users()->count() > 1 && ($user->company_users()->where('is_admin', 1)->count() != $user->company_users()->count()))) { return true; } diff --git a/app/Transformers/CreditTransformer.php b/app/Transformers/CreditTransformer.php index c6e296316043..9a720f9fb426 100644 --- a/app/Transformers/CreditTransformer.php +++ b/app/Transformers/CreditTransformer.php @@ -11,13 +11,13 @@ namespace App\Transformers; +use App\Models\Activity; use App\Models\Backup; use App\Models\Client; use App\Models\Credit; -use App\Models\Activity; +use App\Models\CreditInvitation; use App\Models\Document; use App\Utils\Traits\MakesHash; -use App\Models\CreditInvitation; use League\Fractal\Resource\Item; class CreditTransformer extends EntityTransformer diff --git a/app/Transformers/ExpenseTransformer.php b/app/Transformers/ExpenseTransformer.php index 760f35909c52..aa13889a9298 100644 --- a/app/Transformers/ExpenseTransformer.php +++ b/app/Transformers/ExpenseTransformer.php @@ -12,15 +12,14 @@ namespace App\Transformers; use App\Models\Client; -use App\Models\Vendor; -use App\Models\Expense; -use App\Models\Invoice; use App\Models\Document; +use App\Models\Expense; use App\Models\ExpenseCategory; +use App\Models\Invoice; +use App\Models\Vendor; use App\Utils\Traits\MakesHash; -use League\Fractal\Resource\Item; use Illuminate\Database\Eloquent\SoftDeletes; -use App\Transformers\ExpenseCategoryTransformer; +use League\Fractal\Resource\Item; /** * class ExpenseTransformer. diff --git a/app/Transformers/PaymentTransformer.php b/app/Transformers/PaymentTransformer.php index 99a50547fc15..0f37438bce7e 100644 --- a/app/Transformers/PaymentTransformer.php +++ b/app/Transformers/PaymentTransformer.php @@ -13,9 +13,9 @@ namespace App\Transformers; use App\Models\Client; use App\Models\Credit; +use App\Models\Document; use App\Models\Invoice; use App\Models\Payment; -use App\Models\Document; use App\Models\Paymentable; use App\Models\PaymentType; use App\Utils\Traits\MakesHash; diff --git a/app/Transformers/ProductTransformer.php b/app/Transformers/ProductTransformer.php index bab47b6f7940..cc28edc2ed1d 100644 --- a/app/Transformers/ProductTransformer.php +++ b/app/Transformers/ProductTransformer.php @@ -16,7 +16,6 @@ use App\Models\Document; use App\Models\Product; use App\Models\User; use App\Utils\Traits\MakesHash; -use League\Fractal\Resource\Collection; class ProductTransformer extends EntityTransformer { @@ -95,7 +94,7 @@ class ProductTransformer extends EntityTransformer 'stock_notification_threshold' => (int) $product->stock_notification_threshold, 'max_quantity' => (int) $product->max_quantity, 'product_image' => (string) $product->product_image ?: '', - 'tax_id' => (string) $product->tax_id ?: '1', + 'tax_id' => (string) $product->tax_id ?: '1', ]; } } diff --git a/app/Transformers/PurchaseOrderTransformer.php b/app/Transformers/PurchaseOrderTransformer.php index b960def78940..8404dd56d7f9 100644 --- a/app/Transformers/PurchaseOrderTransformer.php +++ b/app/Transformers/PurchaseOrderTransformer.php @@ -11,14 +11,14 @@ namespace App\Transformers; -use App\Models\Backup; -use App\Models\Vendor; -use App\Models\Expense; use App\Models\Activity; +use App\Models\Backup; use App\Models\Document; +use App\Models\Expense; use App\Models\PurchaseOrder; -use App\Utils\Traits\MakesHash; use App\Models\PurchaseOrderInvitation; +use App\Models\Vendor; +use App\Utils\Traits\MakesHash; class PurchaseOrderTransformer extends EntityTransformer { diff --git a/app/Transformers/QuoteTransformer.php b/app/Transformers/QuoteTransformer.php index 4d4cf0ced301..649b9995e24c 100644 --- a/app/Transformers/QuoteTransformer.php +++ b/app/Transformers/QuoteTransformer.php @@ -11,11 +11,11 @@ namespace App\Transformers; -use App\Models\Quote; +use App\Models\Activity; use App\Models\Backup; use App\Models\Client; -use App\Models\Activity; use App\Models\Document; +use App\Models\Quote; use App\Models\QuoteInvitation; use App\Utils\Traits\MakesHash; use League\Fractal\Resource\Item; diff --git a/app/Transformers/RecurringExpenseTransformer.php b/app/Transformers/RecurringExpenseTransformer.php index 4b48e8654e55..2988115b3813 100644 --- a/app/Transformers/RecurringExpenseTransformer.php +++ b/app/Transformers/RecurringExpenseTransformer.php @@ -12,12 +12,12 @@ namespace App\Transformers; use App\Models\Client; -use App\Models\Vendor; use App\Models\Document; -use App\Utils\Traits\MakesHash; use App\Models\RecurringExpense; -use League\Fractal\Resource\Item; +use App\Models\Vendor; +use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\SoftDeletes; +use League\Fractal\Resource\Item; /** * class RecurringExpenseTransformer. diff --git a/app/Transformers/TaskTransformer.php b/app/Transformers/TaskTransformer.php index 5791fa3e5807..131789b32ff6 100644 --- a/app/Transformers/TaskTransformer.php +++ b/app/Transformers/TaskTransformer.php @@ -11,13 +11,13 @@ namespace App\Transformers; -use App\Models\Task; -use App\Models\User; use App\Models\Client; +use App\Models\Document; use App\Models\Invoice; use App\Models\Project; -use App\Models\Document; +use App\Models\Task; use App\Models\TaskStatus; +use App\Models\User; use App\Utils\Traits\MakesHash; use League\Fractal\Resource\Item; diff --git a/app/Transformers/UserTransformer.php b/app/Transformers/UserTransformer.php index 0971c7dc2b02..c0274a3e81a7 100644 --- a/app/Transformers/UserTransformer.php +++ b/app/Transformers/UserTransformer.php @@ -97,7 +97,7 @@ class UserTransformer extends EntityTransformer } /** - * + * * @param User $user */ public function includeCompanyUser(User $user) diff --git a/app/Transformers/VendorTransformer.php b/app/Transformers/VendorTransformer.php index 537c98f62f0d..aa3a28669234 100644 --- a/app/Transformers/VendorTransformer.php +++ b/app/Transformers/VendorTransformer.php @@ -16,7 +16,6 @@ use App\Models\Document; use App\Models\Vendor; use App\Models\VendorContact; use App\Utils\Traits\MakesHash; -use League\Fractal\Resource\Collection; /** * class VendorTransformer. diff --git a/app/Utils/Helpers.php b/app/Utils/Helpers.php index 0debc7da4219..0bbbca13d219 100644 --- a/app/Utils/Helpers.php +++ b/app/Utils/Helpers.php @@ -68,7 +68,7 @@ class Helpers $quote_or_credit_field = true; - }elseif($custom_fields && stripos($field, 'credit') !== false && property_exists($custom_fields, $field)) { + } elseif($custom_fields && stripos($field, 'credit') !== false && property_exists($custom_fields, $field)) { $custom_field = $custom_fields->{$field}; $custom_field_parts = explode('|', $custom_field); @@ -78,9 +78,9 @@ class Helpers $quote_or_credit_field = true; - }elseif($custom_fields && stripos($field, 'credit') !== false) { + } elseif($custom_fields && stripos($field, 'credit') !== false) { $field = str_replace("credit", "invoice", $field); - }elseif($custom_fields && stripos($field, 'quote') !== false) { + } elseif($custom_fields && stripos($field, 'quote') !== false) { $field = str_replace("quote", "invoice", $field); } diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index 96425e3ecd0a..e896780c1b11 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -12,22 +12,22 @@ namespace App\Utils; -use Exception; +use App\Helpers\Epc\EpcQrGenerator; +use App\Helpers\SwissQr\SwissQrGenerator; use App\Models\Account; use App\Models\Country; -use App\Models\GatewayType; -use App\Utils\Traits\AppSetup; -use App\Models\QuoteInvitation; -use App\Utils\Traits\MakesHash; use App\Models\CreditInvitation; -use App\Utils\Traits\MakesDates; +use App\Models\GatewayType; use App\Models\InvoiceInvitation; -use App\Helpers\Epc\EpcQrGenerator; +use App\Models\QuoteInvitation; +use App\Models\RecurringInvoiceInvitation; +use App\Utils\Traits\AppSetup; +use App\Utils\Traits\DesignCalculator; +use App\Utils\Traits\MakesDates; +use App\Utils\Traits\MakesHash; +use Exception; use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Cache; -use App\Utils\Traits\DesignCalculator; -use App\Helpers\SwissQr\SwissQrGenerator; -use App\Models\RecurringInvoiceInvitation; class HtmlEngine { @@ -717,7 +717,7 @@ class HtmlEngine $tax_label .= ctrans('texts.reverse_tax_info') . "
"; } - if((int)$this->client->country_id !== (int)$this->company->settings->country_id){ + if((int)$this->client->country_id !== (int)$this->company->settings->country_id) { $tax_label .= ctrans('texts.intracommunity_tax_info') . "
"; } @@ -726,7 +726,7 @@ class HtmlEngine private function getBalance() { - if($this->entity->status_id == 1){ + if($this->entity->status_id == 1) { return $this->entity->amount; } @@ -753,7 +753,7 @@ class HtmlEngine $values = $this->buildEntityDataArray(); foreach ($values as $key => $value) { - $data[str_replace(["$","."],["_","_"],$key)] = $value['value']; + $data[str_replace(["$","."], ["_","_"], $key)] = $value['value']; } return $data; @@ -1038,8 +1038,8 @@ html { $container = $dom->createElement('div'); $container->setAttribute('style', 'display:grid; grid-auto-flow: row; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr);justify-items: center;'); - foreach ($this->entity->documents()->where('is_public',true)->get() as $document) { - if (!$document->isImage()) { + foreach ($this->entity->documents()->where('is_public', true)->get() as $document) { + if (!$document->isImage()) { continue; } diff --git a/app/Utils/Ninja.php b/app/Utils/Ninja.php index ce03dfefc3b9..d25f23ed4aaf 100644 --- a/app/Utils/Ninja.php +++ b/app/Utils/Ninja.php @@ -164,8 +164,7 @@ class Ninja ]); nlog($x->body()); - } - catch (\Exception $e) { + } catch (\Exception $e) { nlog("Attempt forwarding for {$email} - {$company_key} Failed"); } } diff --git a/app/Utils/TemplateEngine.php b/app/Utils/TemplateEngine.php index 4bd3b8310a26..b65392118765 100644 --- a/app/Utils/TemplateEngine.php +++ b/app/Utils/TemplateEngine.php @@ -12,29 +12,27 @@ namespace App\Utils; -use DB; -use App\Models\Quote; -use App\Models\Client; -use App\Models\Credit; -use App\Models\Vendor; -use App\Models\Invoice; -use App\Models\Payment; -use Illuminate\Support\Str; -use App\Models\ClientContact; -use App\Models\PurchaseOrder; -use App\Models\VendorContact; -use App\Models\QuoteInvitation; -use App\Utils\Traits\MakesHash; -use App\Models\RecurringInvoice; -use App\Models\InvoiceInvitation; -use Illuminate\Support\Facades\App; -use App\Utils\Traits\MakesInvoiceHtml; -use App\Mail\Engine\PaymentEmailEngine; -use App\Models\PurchaseOrderInvitation; -use App\Utils\Traits\MakesTemplateData; use App\DataMapper\EmailTemplateDefaults; -use League\CommonMark\CommonMarkConverter; +use App\Mail\Engine\PaymentEmailEngine; +use App\Models\Client; +use App\Models\ClientContact; +use App\Models\Invoice; +use App\Models\InvoiceInvitation; +use App\Models\Payment; +use App\Models\PurchaseOrder; +use App\Models\PurchaseOrderInvitation; +use App\Models\Quote; +use App\Models\QuoteInvitation; +use App\Models\Vendor; +use App\Models\VendorContact; use App\Services\PdfMaker\Designs\Utilities\DesignHelpers; +use App\Utils\Traits\MakesHash; +use App\Utils\Traits\MakesInvoiceHtml; +use App\Utils\Traits\MakesTemplateData; +use DB; +use Illuminate\Support\Facades\App; +use Illuminate\Support\Str; +use League\CommonMark\CommonMarkConverter; class TemplateEngine { @@ -106,11 +104,10 @@ class TemplateEngine } elseif (stripos($this->template, 'purchase') !== false && $purchase_order = PurchaseOrder::query()->whereHas('invitations')->withTrashed()->company()->first()) { $this->entity = 'purchase_order'; $this->entity_obj = $purchase_order; - }elseif (stripos($this->template, 'payment') !== false && $payment = Payment::query()->withTrashed()->company()->first()) { + } elseif (stripos($this->template, 'payment') !== false && $payment = Payment::query()->withTrashed()->company()->first()) { $this->entity = 'payment'; $this->entity_obj = $payment; - } - elseif ($invoice = Invoice::query()->whereHas('invitations')->withTrashed()->company()->first()) { + } elseif ($invoice = Invoice::query()->whereHas('invitations')->withTrashed()->company()->first()) { /** @var \App\Models\Invoice $invoice */ $this->entity_obj = $invoice; } else { diff --git a/app/Utils/Traits/CleanLineItems.php b/app/Utils/Traits/CleanLineItems.php index 8c6a79b85478..8ccb07d02922 100644 --- a/app/Utils/Traits/CleanLineItems.php +++ b/app/Utils/Traits/CleanLineItems.php @@ -64,13 +64,13 @@ trait CleanLineItems if (! array_key_exists('tax_id', $item)) { $item['tax_id'] = '1'; - } - elseif(array_key_exists('tax_id', $item) && $item['tax_id'] == '') { + } elseif(array_key_exists('tax_id', $item) && $item['tax_id'] == '') { - if($item['type_id'] == '2') + if($item['type_id'] == '2') { $item['tax_id'] = '2'; - else + } else { $item['tax_id'] = '1'; + } } diff --git a/app/Utils/Traits/ClientGroupSettingsSaver.php b/app/Utils/Traits/ClientGroupSettingsSaver.php index abfb40989107..2d32b3468417 100644 --- a/app/Utils/Traits/ClientGroupSettingsSaver.php +++ b/app/Utils/Traits/ClientGroupSettingsSaver.php @@ -86,7 +86,7 @@ trait ClientGroupSettingsSaver unset($settings->translations); } - foreach(['translations','pdf_variables'] as $key){ + foreach(['translations','pdf_variables'] as $key) { if (property_exists($settings, $key)) { unset($settings->{$key}); } diff --git a/app/Utils/Traits/CompanyGatewayFeesAndLimitsSaver.php b/app/Utils/Traits/CompanyGatewayFeesAndLimitsSaver.php index 2b4a894094f1..d5b664824890 100644 --- a/app/Utils/Traits/CompanyGatewayFeesAndLimitsSaver.php +++ b/app/Utils/Traits/CompanyGatewayFeesAndLimitsSaver.php @@ -63,7 +63,7 @@ trait CompanyGatewayFeesAndLimitsSaver case 'float': case 'double': return ! is_string($value) && (is_float($value) || is_numeric(strval($value))); - // return is_float($value) || is_numeric(strval($value)); + // return is_float($value) || is_numeric(strval($value)); case 'string': return (is_string($value) && method_exists($value, '__toString')) || is_null($value) || is_string($value); case 'bool': diff --git a/app/Utils/Traits/CompanySettingsSaver.php b/app/Utils/Traits/CompanySettingsSaver.php index 9354c7036435..043d8db5c93f 100644 --- a/app/Utils/Traits/CompanySettingsSaver.php +++ b/app/Utils/Traits/CompanySettingsSaver.php @@ -11,11 +11,10 @@ namespace App\Utils\Traits; -use stdClass; -use App\Utils\Ninja; -use App\Models\Company; use App\DataMapper\CompanySettings; use App\Jobs\Company\CompanyTaxRate; +use App\Models\Company; +use stdClass; /** * Class CompanySettingsSaver. @@ -88,18 +87,16 @@ trait CompanySettingsSaver $entity->settings = $company_settings; - if($entity?->calculate_taxes && $company_settings->country_id == "840" && array_key_exists('settings', $entity->getDirty()) && !$entity?->account->isFreeHostedClient()) - { + if($entity?->calculate_taxes && $company_settings->country_id == "840" && array_key_exists('settings', $entity->getDirty()) && !$entity?->account->isFreeHostedClient()) { $old_settings = $entity->getOriginal()['settings']; /** Monitor changes of the Postal code */ - if($old_settings->postal_code != $company_settings->postal_code) + if($old_settings->postal_code != $company_settings->postal_code) { CompanyTaxRate::dispatch($entity); + } - } - elseif( $entity?->calculate_taxes && $company_settings->country_id == "840" && array_key_exists('calculate_taxes', $entity->getDirty()) && $entity->getOriginal('calculate_taxes') == 0 && !$entity?->account->isFreeHostedClient()) - { + } elseif($entity?->calculate_taxes && $company_settings->country_id == "840" && array_key_exists('calculate_taxes', $entity->getDirty()) && $entity->getOriginal('calculate_taxes') == 0 && !$entity?->account->isFreeHostedClient()) { CompanyTaxRate::dispatch($entity); } @@ -141,7 +138,7 @@ trait CompanySettingsSaver $value = 'integer'; if(in_array($key, $this->string_ids)) { - // if ($key == 'besr_id') { + // if ($key == 'besr_id') { $value = 'string'; } @@ -280,7 +277,7 @@ trait CompanySettingsSaver case 'float': case 'double': return ! is_string($value) && (is_float($value) || is_numeric(strval($value))); -// return is_float($value) || is_numeric(strval($value)); + // return is_float($value) || is_numeric(strval($value)); case 'string': return (is_string($value) && method_exists($value, '__toString')) || is_null($value) || is_string($value); case 'bool': diff --git a/app/Utils/Traits/MakesDates.php b/app/Utils/Traits/MakesDates.php index 69ccb7a8b3c4..a33afbd19fde 100644 --- a/app/Utils/Traits/MakesDates.php +++ b/app/Utils/Traits/MakesDates.php @@ -11,11 +11,11 @@ namespace App\Utils\Traits; +use App\DataMapper\Schedule\EmailStatement; +use App\Models\Company; +use Carbon\Carbon; use DateTime; use DateTimeZone; -use Carbon\Carbon; -use App\Models\Company; -use App\DataMapper\Schedule\EmailStatement; /** * Class MakesDates. @@ -127,8 +127,9 @@ trait MakesDates $first_month_of_year = $company ? $company?->first_month_of_year : 1; $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->subYearNoOverflow(); + } } @@ -161,4 +162,4 @@ trait MakesDates }; } -} \ No newline at end of file +} diff --git a/app/Utils/Traits/MakesInvoiceValues.php b/app/Utils/Traits/MakesInvoiceValues.php index 69c44fff9f82..764be096900b 100644 --- a/app/Utils/Traits/MakesInvoiceValues.php +++ b/app/Utils/Traits/MakesInvoiceValues.php @@ -578,7 +578,7 @@ html { '; $css .= 'font-size:'.$settings->font_size.'px;'; -// $css .= 'font-size:14px;'; + // $css .= 'font-size:14px;'; $css .= '}'; diff --git a/app/Utils/Traits/MakesReminders.php b/app/Utils/Traits/MakesReminders.php index 2f3de1aebb2d..4ef6a7368322 100644 --- a/app/Utils/Traits/MakesReminders.php +++ b/app/Utils/Traits/MakesReminders.php @@ -16,7 +16,7 @@ use Illuminate\Support\Carbon; /** * Class MakesReminders. - * + * */ trait MakesReminders { diff --git a/app/Utils/Traits/SettingsSaver.php b/app/Utils/Traits/SettingsSaver.php index 5c06b4481edc..71877bad3161 100644 --- a/app/Utils/Traits/SettingsSaver.php +++ b/app/Utils/Traits/SettingsSaver.php @@ -64,7 +64,7 @@ trait SettingsSaver $value = 'integer'; if(in_array($key, $this->string_ids)) { - // if ($key == 'gmail_sending_user_id' || $key == 'besr_id') { + // if ($key == 'gmail_sending_user_id' || $key == 'besr_id') { $value = 'string'; } diff --git a/app/Utils/TranslationHelper.php b/app/Utils/TranslationHelper.php index 15850f62e445..20ffbd984ecb 100644 --- a/app/Utils/TranslationHelper.php +++ b/app/Utils/TranslationHelper.php @@ -11,8 +11,8 @@ namespace App\Utils; -use App\Models\PaymentTerm; use \Illuminate\Support\Facades\Cache; +use App\Models\PaymentTerm; use Illuminate\Support\Str; class TranslationHelper diff --git a/app/Utils/VendorHtmlEngine.php b/app/Utils/VendorHtmlEngine.php index 7bd05d75924c..8a7fddfbbe22 100644 --- a/app/Utils/VendorHtmlEngine.php +++ b/app/Utils/VendorHtmlEngine.php @@ -12,19 +12,19 @@ namespace App\Utils; -use Exception; use App\Models\Account; use App\Models\Country; -use App\Utils\Traits\AppSetup; -use App\Models\QuoteInvitation; use App\Models\CreditInvitation; -use App\Utils\Traits\MakesDates; use App\Models\InvoiceInvitation; +use App\Models\PurchaseOrderInvitation; +use App\Models\QuoteInvitation; +use App\Models\RecurringInvoiceInvitation; +use App\Utils\Traits\AppSetup; +use App\Utils\Traits\DesignCalculator; +use App\Utils\Traits\MakesDates; +use Exception; use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Cache; -use App\Utils\Traits\DesignCalculator; -use App\Models\PurchaseOrderInvitation; -use App\Models\RecurringInvoiceInvitation; /** * Note the premise used here is that any currencies will be formatted back to the company currency and not @@ -604,54 +604,54 @@ class VendorHtmlEngine * aggregate data */ - /* + /* private function makeLineTaxes() :string { - $tax_map = $this->entity_calc->getTaxMap(); + $tax_map = $this->entity_calc->getTaxMap(); - $data = ''; + $data = ''; - foreach ($tax_map as $tax) { - $data .= ''; - $data .= ''.$tax['name'].''; - $data .= ''.Number::formatMoney($tax['total'], $this->company).''; - } + foreach ($tax_map as $tax) { + $data .= ''; + $data .= ''.$tax['name'].''; + $data .= ''.Number::formatMoney($tax['total'], $this->company).''; + } - return $data; + return $data; } private function makeTotalTaxes() :string { - $data = ''; + $data = ''; - if (! $this->entity_calc->getTotalTaxMap()) { - return $data; - } + if (! $this->entity_calc->getTotalTaxMap()) { + return $data; + } - foreach ($this->entity_calc->getTotalTaxMap() as $tax) { - $data .= ''; - $data .= ''; - $data .= ''.$tax['name'].''; - $data .= ''.Number::formatMoney($tax['total'], $this->company).''; - } + foreach ($this->entity_calc->getTotalTaxMap() as $tax) { + $data .= ''; + $data .= ''; + $data .= ''.$tax['name'].''; + $data .= ''.Number::formatMoney($tax['total'], $this->company).''; + } - return $data; + return $data; } private function parseLabelsAndValues($labels, $values, $section) :string { - $section = strtr($section, $labels); + $section = strtr($section, $labels); - return strtr($section, $values); + return strtr($section, $values); } - */ + */ /** * Builds CSS to assist with the generation * of Repeating headers and footers on the PDF. * @return string The css string - + private function generateCustomCSS() :string { $header_and_footer = ' @@ -786,7 +786,7 @@ html { $container = $dom->createElement('div'); $container->setAttribute('style', 'display:grid; grid-auto-flow: row; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr);justify-items: center;'); - foreach ($this->entity->documents()->where('is_public',true)->get() as $document) { + foreach ($this->entity->documents()->where('is_public', true)->get() as $document) { if (!$document->isImage()) { continue; } @@ -852,7 +852,7 @@ html { // return ' // // - // //
+ // // '. $text .' //