diff --git a/VERSION.txt b/VERSION.txt index 848752579580..554960d31785 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.9.5 \ No newline at end of file +5.9.6 \ No newline at end of file diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index 3e4773e580c3..5ffb915c978a 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -172,18 +172,18 @@ class CheckData extends Command CompanyUser::query()->cursor()->each(function ($cu) { if (CompanyToken::where('user_id', $cu->user_id)->where('company_id', $cu->company_id)->where('is_system', 1)->doesntExist()) { - + if ($cu->company && $cu->user) { $this->logMessage("Creating missing company token for user # {$cu->user_id} for company id # {$cu->company_id}"); (new CreateCompanyToken($cu->company, $cu->user, 'System'))->handle(); - } - + } + if (!$cu->user) { $this->logMessage("No user found for company user - removing company user"); $cu->forceDelete(); } - + } }); } @@ -477,14 +477,13 @@ class CheckData extends Command } } else { $this->logMessage("No contact present, so cannot add invitation for {$entity_key} - {$entity->id}"); - - try{ + + try { $entity->service()->createInvitations()->save(); - } - catch(\Exception $e){ + } catch(\Exception $e) { } - + } try { @@ -949,12 +948,12 @@ class CheckData extends Command }); - Company::whereDoesntHave('company_users', function ($query){ - $query->where('is_owner', 1); + Company::whereDoesntHave('company_users', function ($query) { + $query->where('is_owner', 1); }) ->cursor() ->when(Ninja::isHosted()) - ->each(function ($c){ + ->each(function ($c) { $this->logMessage("Orphan Account # {$c->account_id}"); @@ -963,8 +962,8 @@ class CheckData extends Command CompanyUser::whereDoesntHave('tokens') ->cursor() ->when(Ninja::isHosted()) - ->each(function ($cu){ - + ->each(function ($cu) { + $this->logMessage("Missing tokens for Company User # {$cu->id}"); }); diff --git a/app/Console/Commands/CreateSingleAccount.php b/app/Console/Commands/CreateSingleAccount.php index d812ea5db63e..f2769de649a1 100644 --- a/app/Console/Commands/CreateSingleAccount.php +++ b/app/Console/Commands/CreateSingleAccount.php @@ -1016,7 +1016,7 @@ class CreateSingleAccount extends Command $cg->fees_and_limits = $fees_and_limits; $cg->save(); } - + if (config('ninja.testvars.eway') && ($this->gateway == 'all' || $this->gateway == 'eway')) { $cg = new CompanyGateway(); $cg->company_id = $company->id; @@ -1038,12 +1038,12 @@ class CreateSingleAccount extends Command $cg->save(); } - + if (config('ninja.testvars.gocardless') && ($this->gateway == 'all' || $this->gateway == 'gocardless')) { $c_settings = ClientSettings::defaults(); $c_settings->currency_id = '2'; - + $client = Client::factory()->create([ 'user_id' => $user->id, 'company_id' => $company->id, diff --git a/app/Console/Commands/ReactBuilder.php b/app/Console/Commands/ReactBuilder.php index 1a0a3b6a2458..d4c5b7533c7f 100644 --- a/app/Console/Commands/ReactBuilder.php +++ b/app/Console/Commands/ReactBuilder.php @@ -48,37 +48,37 @@ class ReactBuilder extends Command { if($this->option('type') == 'local') { - - $includes = ''; - $directoryIterator = false; + $includes = ''; - try { - $directoryIterator = new \RecursiveDirectoryIterator(public_path('react/v'.config('ninja.app_version').'/'), \RecursiveDirectoryIterator::SKIP_DOTS); - } catch (\Exception $e) { - $this->error('React files not found'); - return; - } + $directoryIterator = false; - foreach (new \RecursiveIteratorIterator($directoryIterator) as $file) { - if ($file->getExtension() == 'js') { - if (str_contains($file->getFileName(), 'index-')) { - $includes .= ''."\n"; - } else { - $includes .= ''."\n"; + try { + $directoryIterator = new \RecursiveDirectoryIterator(public_path('react/v'.config('ninja.app_version').'/'), \RecursiveDirectoryIterator::SKIP_DOTS); + } catch (\Exception $e) { + $this->error('React files not found'); + return; + } + + foreach (new \RecursiveIteratorIterator($directoryIterator) as $file) { + if ($file->getExtension() == 'js') { + if (str_contains($file->getFileName(), 'index-')) { + $includes .= ''."\n"; + } else { + $includes .= ''."\n"; + } + } + + if (str_contains($file->getFileName(), '.css')) { + $includes .= ''."\n"; } } - if (str_contains($file->getFileName(), '.css')) { - $includes .= ''."\n"; - } - } - - file_put_contents(resource_path('views/react/head.blade.php'), $includes); + file_put_contents(resource_path('views/react/head.blade.php'), $includes); } - + } } diff --git a/app/DataMapper/Analytics/DbQuery.php b/app/DataMapper/Analytics/DbQuery.php index 833aa9707e85..5b8dfeea9f7e 100644 --- a/app/DataMapper/Analytics/DbQuery.php +++ b/app/DataMapper/Analytics/DbQuery.php @@ -55,7 +55,7 @@ class DbQuery extends GenericMixedMetric public $string_metric8 = 'client_version'; public $string_metric9 = 'platform'; - + /** * The counter * set to 1. diff --git a/app/DataMapper/Analytics/LoginMeta.php b/app/DataMapper/Analytics/LoginMeta.php new file mode 100644 index 000000000000..1234feaa89ee --- /dev/null +++ b/app/DataMapper/Analytics/LoginMeta.php @@ -0,0 +1,61 @@ +string_metric7 = $string_metric7; + $this->string_metric6 = $string_metric6; + $this->string_metric5 = $string_metric5; + } +} diff --git a/app/DataMapper/InvoiceItem.php b/app/DataMapper/InvoiceItem.php index de1b3338c752..9d217efb64c2 100644 --- a/app/DataMapper/InvoiceItem.php +++ b/app/DataMapper/InvoiceItem.php @@ -64,9 +64,9 @@ class InvoiceItem public $task_id = ''; public $expense_id = ''; - + public $unit_code = 'C62'; - + public static $casts = [ 'task_id' => 'string', 'expense_id' => 'string', diff --git a/app/DataMapper/Sources/PayPalBalanceAffecting.php b/app/DataMapper/Sources/PayPalBalanceAffecting.php index 2e547b706fd5..549423051026 100644 --- a/app/DataMapper/Sources/PayPalBalanceAffecting.php +++ b/app/DataMapper/Sources/PayPalBalanceAffecting.php @@ -15,7 +15,6 @@ use App\DataMapper\InvoiceItem; class PayPalBalanceAffecting { - private array $key_map = [ 'Date' => 'date', 'Time' => 'time', @@ -105,8 +104,10 @@ class PayPalBalanceAffecting public $discount; public $creditTransactionalFee; public $originalInvoiceId; - - public function __construct(private array $import_row){} + + public function __construct(private array $import_row) + { + } public function run(): self { @@ -116,11 +117,11 @@ class PayPalBalanceAffecting $prop = $this->key_map[$key] ?? false; - if($prop){ + if($prop) { echo "Setting {$prop} to {$value}".PHP_EOL; $this->{$prop} = $value; - + } } @@ -130,7 +131,7 @@ class PayPalBalanceAffecting private function cleanUp(): self { - foreach($this->key_map as $value){ + foreach($this->key_map as $value) { echo "Setting {$value} to null".PHP_EOL; $this->{$value} = null; } @@ -154,7 +155,7 @@ class PayPalBalanceAffecting public function getInvoice(): array { - $item = new InvoiceItem; + $item = new InvoiceItem(); $item->cost = $this->gross ?? 0; $item->product_key = $this->itemId ?? ''; $item->notes = $this->subject ?? $this->itemDetails; @@ -162,7 +163,7 @@ class PayPalBalanceAffecting return [ 'number' => trim($this->invoiceNumber ?? $this->transactionId), - 'date' => str_replace('/','-', $this->date ?? ''), + 'date' => str_replace('/', '-', $this->date ?? ''), 'line_items' => [$item], 'name' => $this->name ?? '', 'email' => $this->fromEmailAddress ?? '', @@ -174,12 +175,10 @@ class PayPalBalanceAffecting { $name_parts = explode(" ", $this->name ?? ''); - if(count($name_parts) == 2) - { + if(count($name_parts) == 2) { $contact['first_name'] = $name_parts[0]; $contact['last_name'] = $name_parts[1]; - } - else { + } else { $contact['first_name'] = $this->name ?? ''; } @@ -188,7 +187,7 @@ class PayPalBalanceAffecting return $contact; } - + private function returnAddress(): array { return [ @@ -203,13 +202,15 @@ class PayPalBalanceAffecting private function returnShippingAddress(): array { - if(strlen($this->shippingAddress ?? '') <3) + if(strlen($this->shippingAddress ?? '') < 3) { return []; + } $ship_parts = explode(",", $this->shippingAddress); - if(count($ship_parts) != 7) + if(count($ship_parts) != 7) { return []; + } return [ 'shipping_address1' => $ship_parts[2], diff --git a/app/Export/CSV/BaseExport.php b/app/Export/CSV/BaseExport.php index 31cfb9b05c04..11d92f15df94 100644 --- a/app/Export/CSV/BaseExport.php +++ b/app/Export/CSV/BaseExport.php @@ -838,12 +838,12 @@ class BaseExport return ''; } - + /** * Apply Product Filters * * @param Builder $query - * + * * @return Builder */ public function applyProductFilters(Builder $query): Builder @@ -863,13 +863,13 @@ class BaseExport return $query; } - + /** * Add Client Filter * * @param Builder $query * @param mixed $clients - * + * * @return Builder */ protected function addClientFilter(Builder $query, $clients): Builder @@ -886,13 +886,13 @@ class BaseExport return $query; } - + /** * Add Vendor Filter * * @param Builder $query * @param string $vendors - * + * * @return Builder */ protected function addVendorFilter(Builder$query, string $vendors): Builder @@ -910,13 +910,13 @@ class BaseExport return $query; } - + /** * AddProjectFilter * * @param Builder $query * @param string $projects - * + * * @return Builder */ protected function addProjectFilter(Builder $query, string $projects): Builder @@ -934,13 +934,13 @@ class BaseExport return $query; } - + /** * Add Category Filter * * @param Builder $query * @param string $expense_categories - * + * * @return Builder */ protected function addCategoryFilter(Builder $query, string $expense_categories): Builder @@ -959,13 +959,13 @@ class BaseExport return $query; } - + /** * Add Payment Status Filters * * @param Builder $query * @param string $status - * + * * @return Builder */ protected function addPaymentStatusFilters(Builder $query, string $status): Builder @@ -976,7 +976,7 @@ class BaseExport if(in_array('all', $status_parameters) || count($status_parameters) == 0) { return $query; } - + $query->where(function ($query) use ($status_parameters) { $payment_filters = []; @@ -1016,13 +1016,13 @@ class BaseExport return $query; } - + /** * Add RecurringInvoice Status Filter * * @param Builder $query * @param string $status - * + * * @return Builder */ protected function addRecurringInvoiceStatusFilter(Builder $query, string $status): Builder @@ -1030,7 +1030,7 @@ class BaseExport $status_parameters = explode(',', $status); - if (in_array('all', $status_parameters) || count($status_parameters) == 0){ + if (in_array('all', $status_parameters) || count($status_parameters) == 0) { return $query; } @@ -1060,7 +1060,7 @@ class BaseExport * * @param Builder $query * @param string $status - * + * * @return Builder */ protected function addQuoteStatusFilter(Builder $query, string $status): Builder @@ -1126,12 +1126,12 @@ class BaseExport * * @param Builder $query * @param string $status - * + * * @return Builder */ protected function addPurchaseOrderStatusFilter(Builder $query, string $status): Builder { - + $status_parameters = explode(',', $status); if (in_array('all', $status_parameters) || count($status_parameters) == 0) { @@ -1234,7 +1234,7 @@ class BaseExport return $query; } - + /** * Add Date Range * @@ -1578,7 +1578,7 @@ class BaseExport public function queueDocuments(Builder $query) { - + if($query->getModel() instanceof Document) { $documents = $query->pluck('id')->toArray(); } else { diff --git a/app/Export/CSV/ClientExport.php b/app/Export/CSV/ClientExport.php index de3ee42c0650..4b27fb45df62 100644 --- a/app/Export/CSV/ClientExport.php +++ b/app/Export/CSV/ClientExport.php @@ -127,8 +127,9 @@ class ClientExport extends BaseExport ->withTrashed() ->where('company_id', $this->company->id); - if(!$this->input['include_deleted'] ?? false) + if(!$this->input['include_deleted'] ?? false) { $query->where('is_deleted', 0); + } $query = $this->addDateRange($query); diff --git a/app/Export/CSV/ContactExport.php b/app/Export/CSV/ContactExport.php index b7e2c0e52dda..12ea78384c6e 100644 --- a/app/Export/CSV/ContactExport.php +++ b/app/Export/CSV/ContactExport.php @@ -59,7 +59,7 @@ class ContactExport extends BaseExport $query = ClientContact::query() ->where('company_id', $this->company->id) - ->whereHas('client', function ($q){ + ->whereHas('client', function ($q) { $q->where('is_deleted', false); }); diff --git a/app/Export/CSV/CreditExport.php b/app/Export/CSV/CreditExport.php index a549f274efb8..16ea287a0101 100644 --- a/app/Export/CSV/CreditExport.php +++ b/app/Export/CSV/CreditExport.php @@ -102,7 +102,7 @@ class CreditExport extends BaseExport $query = Credit::query() ->withTrashed() ->with('client') - ->whereHas('client', function ($q){ + ->whereHas('client', function ($q) { $q->where('is_deleted', false); }) ->where('company_id', $this->company->id) diff --git a/app/Export/CSV/ExpenseExport.php b/app/Export/CSV/ExpenseExport.php index abd6dc5d43b9..8610193e824a 100644 --- a/app/Export/CSV/ExpenseExport.php +++ b/app/Export/CSV/ExpenseExport.php @@ -83,9 +83,9 @@ class ExpenseExport extends BaseExport ->with('client') ->withTrashed() ->where('company_id', $this->company->id); - - - if(!$this->input['include_deleted'] ?? false){ + + + if(!$this->input['include_deleted'] ?? false) { $query->where('is_deleted', 0); } diff --git a/app/Export/CSV/InvoiceExport.php b/app/Export/CSV/InvoiceExport.php index b0435e3859fd..e8c096778313 100644 --- a/app/Export/CSV/InvoiceExport.php +++ b/app/Export/CSV/InvoiceExport.php @@ -57,13 +57,13 @@ class InvoiceExport extends BaseExport $query = Invoice::query() ->withTrashed() ->with('client') - ->whereHas('client', function ($q){ + ->whereHas('client', function ($q) { $q->where('is_deleted', false); }) ->where('company_id', $this->company->id); - - if(!$this->input['include_deleted'] ?? false){ + + if(!$this->input['include_deleted'] ?? false) { $query->where('is_deleted', 0); } diff --git a/app/Export/CSV/InvoiceItemExport.php b/app/Export/CSV/InvoiceItemExport.php index 20308854f2ac..7068a33170e1 100644 --- a/app/Export/CSV/InvoiceItemExport.php +++ b/app/Export/CSV/InvoiceItemExport.php @@ -70,12 +70,12 @@ class InvoiceItemExport extends BaseExport $query = Invoice::query() ->withTrashed() ->with('client') - ->whereHas('client', function ($q){ + ->whereHas('client', function ($q) { $q->where('is_deleted', false); }) ->where('company_id', $this->company->id); - - if(!$this->input['include_deleted'] ?? false){ + + if(!$this->input['include_deleted'] ?? false) { $query->where('is_deleted', 0); } diff --git a/app/Export/CSV/PaymentExport.php b/app/Export/CSV/PaymentExport.php index 18c25feb0298..02b519346964 100644 --- a/app/Export/CSV/PaymentExport.php +++ b/app/Export/CSV/PaymentExport.php @@ -56,7 +56,7 @@ class PaymentExport extends BaseExport $query = Payment::query() ->withTrashed() - ->whereHas('client', function ($q){ + ->whereHas('client', function ($q) { $q->where('is_deleted', false); }) ->where('company_id', $this->company->id) @@ -71,7 +71,7 @@ class PaymentExport extends BaseExport } $query = $this->addPaymentStatusFilters($query, $this->input['status'] ?? ''); - + if($this->input['document_email_attachment'] ?? false) { $this->queueDocuments($query); } diff --git a/app/Export/CSV/ProductExport.php b/app/Export/CSV/ProductExport.php index cd874d16eb92..a572825a3e72 100644 --- a/app/Export/CSV/ProductExport.php +++ b/app/Export/CSV/ProductExport.php @@ -74,9 +74,9 @@ class ProductExport extends BaseExport $query = Product::query() ->withTrashed() ->where('company_id', $this->company->id); - - - if(!$this->input['include_deleted'] ?? false){ + + + if(!$this->input['include_deleted'] ?? false) { $query->where('is_deleted', 0); } diff --git a/app/Export/CSV/ProductSalesExport.php b/app/Export/CSV/ProductSalesExport.php index db33e311352d..74c7b71ffec1 100644 --- a/app/Export/CSV/ProductSalesExport.php +++ b/app/Export/CSV/ProductSalesExport.php @@ -25,6 +25,7 @@ class ProductSalesExport extends BaseExport { public string $date_key = 'created_at'; + /** @var Collection<\App\Models\Product> $products*/ protected Collection $products; public Writer $csv; @@ -80,20 +81,20 @@ class ProductSalesExport extends BaseExport public function filterByProducts($query) { - + $product_keys = &$this->input['product_key']; if ($product_keys && !empty($this->input['product_key'])) { $keys = explode(",", $product_keys); - $query->where(function ($q) use ($keys){ + $query->where(function ($q) use ($keys) { - foreach($keys as $key) { + foreach($keys as $key) { $q->orWhereJsonContains('line_items', ['product_key' => $key]); } }); - + } return $query; @@ -121,7 +122,7 @@ class ProductSalesExport extends BaseExport //insert the header $query = Invoice::query() ->withTrashed() - ->whereHas('client', function ($q){ + ->whereHas('client', function ($q) { $q->where('is_deleted', false); }) ->where('company_id', $this->company->id) @@ -138,30 +139,29 @@ class ProductSalesExport extends BaseExport $product_keys = &$this->input['product_key']; - if($product_keys){ + if($product_keys) { $product_keys = explode(",", $product_keys); } $query->cursor() - ->each(function ($invoice) use($product_keys) { + ->each(function ($invoice) use ($product_keys) { foreach ($invoice->line_items as $item) { - if($product_keys) - { - if(in_array($item->product_key, $product_keys)) - $this->csv->insertOne($this->buildRow($invoice, $item)); - } - else { - $this->csv->insertOne($this->buildRow($invoice, $item)); - } - + if($product_keys) { + if(in_array($item->product_key, $product_keys)) { + $this->csv->insertOne($this->buildRow($invoice, $item)); + } + } else { + $this->csv->insertOne($this->buildRow($invoice, $item)); + } + } }); - $grouped = $this->sales->groupBy('product_key')->map(function ($key, $value) use($product_keys){ + $grouped = $this->sales->groupBy('product_key')->map(function ($key, $value) use ($product_keys) { - if($product_keys && !in_array($value, $product_keys)){ + if($product_keys && !in_array($value, $product_keys)) { return false; } @@ -185,7 +185,8 @@ class ProductSalesExport extends BaseExport })->reject(function ($value) { return $value === false; - });; + }); + ; $this->csv->insertOne([]); $this->csv->insertOne([]); @@ -327,9 +328,9 @@ class ProductSalesExport extends BaseExport * getProduct * * @param string $product_key - * @return Product + * @return ?\Illuminate\Database\Eloquent\Model */ - private function getProduct(string $product_key): ?Product + private function getProduct(string $product_key) { return $this->products->firstWhere('product_key', $product_key); } diff --git a/app/Export/CSV/PurchaseOrderExport.php b/app/Export/CSV/PurchaseOrderExport.php index cbe54e51b2c9..c09353387d15 100644 --- a/app/Export/CSV/PurchaseOrderExport.php +++ b/app/Export/CSV/PurchaseOrderExport.php @@ -58,12 +58,12 @@ class PurchaseOrderExport extends BaseExport $query = PurchaseOrder::query() ->withTrashed() ->with('vendor') - ->whereHas('vendor', function ($q){ + ->whereHas('vendor', function ($q) { $q->where('is_deleted', false); }) ->where('company_id', $this->company->id); - - if(!$this->input['include_deleted'] ?? false){ + + if(!$this->input['include_deleted'] ?? false) { $query->where('is_deleted', 0); } @@ -72,8 +72,9 @@ class PurchaseOrderExport extends BaseExport $clients = &$this->input['client_id']; - if($clients) + if($clients) { $query = $this->addClientFilter($query, $clients); + } $query = $this->addPurchaseOrderStatusFilter($query, $this->input['status'] ?? ''); diff --git a/app/Export/CSV/PurchaseOrderItemExport.php b/app/Export/CSV/PurchaseOrderItemExport.php index 96c4c03aff28..fcebc7810f5c 100644 --- a/app/Export/CSV/PurchaseOrderItemExport.php +++ b/app/Export/CSV/PurchaseOrderItemExport.php @@ -62,12 +62,12 @@ class PurchaseOrderItemExport extends BaseExport $query = PurchaseOrder::query() ->withTrashed() - ->whereHas('vendor', function ($q){ + ->whereHas('vendor', function ($q) { $q->where('is_deleted', false); }) ->with('vendor')->where('company_id', $this->company->id); - - if(!$this->input['include_deleted'] ?? false){ + + if(!$this->input['include_deleted'] ?? false) { $query->where('is_deleted', 0); } diff --git a/app/Export/CSV/QuoteExport.php b/app/Export/CSV/QuoteExport.php index 13c53cb0dc3a..6decca083870 100644 --- a/app/Export/CSV/QuoteExport.php +++ b/app/Export/CSV/QuoteExport.php @@ -64,12 +64,12 @@ class QuoteExport extends BaseExport $query = Quote::query() ->withTrashed() ->with('client') - ->whereHas('client', function ($q){ + ->whereHas('client', function ($q) { $q->where('is_deleted', false); }) ->where('company_id', $this->company->id); - - if(!$this->input['include_deleted'] ?? false){ + + if(!$this->input['include_deleted'] ?? false) { $query->where('is_deleted', 0); } diff --git a/app/Export/CSV/QuoteItemExport.php b/app/Export/CSV/QuoteItemExport.php index d3f8be4b91f8..04caacf613ad 100644 --- a/app/Export/CSV/QuoteItemExport.php +++ b/app/Export/CSV/QuoteItemExport.php @@ -65,12 +65,12 @@ class QuoteItemExport extends BaseExport $query = Quote::query() ->withTrashed() - ->whereHas('client', function ($q){ + ->whereHas('client', function ($q) { $q->where('is_deleted', false); }) ->with('client')->where('company_id', $this->company->id); - - if(!$this->input['include_deleted'] ?? false){ + + if(!$this->input['include_deleted'] ?? false) { $query->where('is_deleted', 0); } diff --git a/app/Export/CSV/RecurringInvoiceExport.php b/app/Export/CSV/RecurringInvoiceExport.php index 9c88f33f7ab9..500137b88683 100644 --- a/app/Export/CSV/RecurringInvoiceExport.php +++ b/app/Export/CSV/RecurringInvoiceExport.php @@ -56,12 +56,12 @@ class RecurringInvoiceExport extends BaseExport $query = RecurringInvoice::query() ->withTrashed() ->with('client') - ->whereHas('client', function ($q){ + ->whereHas('client', function ($q) { $q->where('is_deleted', false); }) ->where('company_id', $this->company->id); - - if(!$this->input['include_deleted'] ?? false){ + + if(!$this->input['include_deleted'] ?? false) { $query->where('is_deleted', 0); } diff --git a/app/Export/CSV/TaskExport.php b/app/Export/CSV/TaskExport.php index 5b1985ce4782..47423c23e2b3 100644 --- a/app/Export/CSV/TaskExport.php +++ b/app/Export/CSV/TaskExport.php @@ -69,22 +69,24 @@ class TaskExport extends BaseExport $query = Task::query() ->withTrashed() ->where('company_id', $this->company->id); - - if(!$this->input['include_deleted'] ?? false){ + + if(!$this->input['include_deleted'] ?? false) { $query->where('is_deleted', 0); } $query = $this->addDateRange($query); - + $clients = &$this->input['client_id']; - if($clients) + if($clients) { $query = $this->addClientFilter($query, $clients); + } $document_attachments = &$this->input['document_email_attachment']; - if($document_attachments) + if($document_attachments) { $this->queueDocuments($query); + } return $query; @@ -224,7 +226,7 @@ class TaskExport extends BaseExport } } - + /** * Add Task Status Filter * @@ -234,7 +236,7 @@ class TaskExport extends BaseExport */ protected function addTaskStatusFilter(Builder $query, string $status): Builder { - + $status_parameters = explode(',', $status); if (in_array('all', $status_parameters) || count($status_parameters) == 0) { diff --git a/app/Export/CSV/VendorExport.php b/app/Export/CSV/VendorExport.php index 187487a14765..c04f83e8c4c4 100644 --- a/app/Export/CSV/VendorExport.php +++ b/app/Export/CSV/VendorExport.php @@ -63,8 +63,8 @@ class VendorExport extends BaseExport $query = Vendor::query()->with('contacts') ->withTrashed() ->where('company_id', $this->company->id); - - if(!$this->input['include_deleted'] ?? false){ + + if(!$this->input['include_deleted'] ?? false) { $query->where('is_deleted', 0); } diff --git a/app/Export/Decorators/ContactDecorator.php b/app/Export/Decorators/ContactDecorator.php index 71707e9b0883..b6fa3edc72b3 100644 --- a/app/Export/Decorators/ContactDecorator.php +++ b/app/Export/Decorators/ContactDecorator.php @@ -25,7 +25,7 @@ class ContactDecorator implements DecoratorInterface $contact = $entity->contacts()->first(); } elseif($entity->client) { $contact = $entity->client->primary_contact->first() ?? $entity->client->contacts()->whereNotNull('email')->first(); - } elseif($entity->vendor) { + } elseif($entity->vendor) { $contact = $entity->vendor->primary_contact->first() ?? $entity->vendor->contacts()->whereNotNull('email')->first(); } diff --git a/app/Factory/BankIntegrationFactory.php b/app/Factory/BankIntegrationFactory.php index a69dc3813947..376321ff00d8 100644 --- a/app/Factory/BankIntegrationFactory.php +++ b/app/Factory/BankIntegrationFactory.php @@ -23,14 +23,13 @@ class BankIntegrationFactory $bank_integration->company_id = $company_id; $bank_integration->provider_name = ''; - $bank_integration->bank_account_id = ''; $bank_integration->bank_account_name = ''; $bank_integration->bank_account_number = ''; $bank_integration->bank_account_status = ''; $bank_integration->bank_account_type = ''; $bank_integration->balance = 0; $bank_integration->currency = ''; - $bank_integration->auto_sync = 1; + $bank_integration->auto_sync = true; return $bank_integration; } diff --git a/app/Factory/ClientFactory.php b/app/Factory/ClientFactory.php index e653c7f63355..7bb5bd13dbbb 100644 --- a/app/Factory/ClientFactory.php +++ b/app/Factory/ClientFactory.php @@ -29,7 +29,7 @@ class ClientFactory $client->balance = 0; $client->paid_to_date = 0; $client->country_id = null; - $client->is_deleted = 0; + $client->is_deleted = false; $client->client_hash = Str::random(40); $client->settings = ClientSettings::defaults(); $client->classification = ''; diff --git a/app/Factory/CloneQuoteToProjectFactory.php b/app/Factory/CloneQuoteToProjectFactory.php index e136b8d15104..f0fe7f0e4324 100644 --- a/app/Factory/CloneQuoteToProjectFactory.php +++ b/app/Factory/CloneQuoteToProjectFactory.php @@ -33,7 +33,7 @@ class CloneQuoteToProjectFactory $project->custom_value2 = ''; $project->custom_value3 = ''; $project->custom_value4 = ''; - $project->is_deleted = 0; + $project->is_deleted = false; return $project; } diff --git a/app/Factory/CompanyFactory.php b/app/Factory/CompanyFactory.php index ef32ea77e069..d9d11edad297 100644 --- a/app/Factory/CompanyFactory.php +++ b/app/Factory/CompanyFactory.php @@ -48,7 +48,7 @@ class CompanyFactory $company->markdown_email_enabled = true; $company->markdown_enabled = false; $company->tax_data = new TaxModel(); - $company->first_month_of_year = 1; + $company->first_month_of_year = '1'; $company->smtp_encryption = 'tls'; $company->smtp_host = ''; $company->smtp_local_domain = ''; @@ -56,7 +56,7 @@ class CompanyFactory $company->smtp_port = ''; $company->smtp_username = ''; $company->smtp_verify_peer = true; - + return $company; } } diff --git a/app/Factory/CompanyGatewayFactory.php b/app/Factory/CompanyGatewayFactory.php index ecb7b3934005..1e44477d6477 100644 --- a/app/Factory/CompanyGatewayFactory.php +++ b/app/Factory/CompanyGatewayFactory.php @@ -24,7 +24,7 @@ class CompanyGatewayFactory $company_gateway->require_shipping_address = false; $company_gateway->config = encrypt(json_encode(new \stdClass())); $company_gateway->always_show_required_fields = true; - + return $company_gateway; } } diff --git a/app/Factory/PurchaseOrderFactory.php b/app/Factory/PurchaseOrderFactory.php index 5803c25790a1..b2a3f837b294 100644 --- a/app/Factory/PurchaseOrderFactory.php +++ b/app/Factory/PurchaseOrderFactory.php @@ -52,7 +52,7 @@ class PurchaseOrderFactory $purchase_order->exchange_rate = 1; $purchase_order->total_taxes = 0; $purchase_order->uses_inclusive_taxes = false; - + return $purchase_order; } } diff --git a/app/Factory/SubscriptionFactory.php b/app/Factory/SubscriptionFactory.php index 8b904a28a743..0b8464c05f9e 100644 --- a/app/Factory/SubscriptionFactory.php +++ b/app/Factory/SubscriptionFactory.php @@ -23,7 +23,7 @@ class SubscriptionFactory $billing_subscription->company_id = $company_id; $billing_subscription->user_id = $user_id; $billing_subscription->steps = collect(Purchase::defaultSteps()) - ->map(fn($step) => StepService::mapClassNameToString($step)) + ->map(fn ($step) => StepService::mapClassNameToString($step)) ->implode(','); return $billing_subscription; diff --git a/app/Factory/TaxRateFactory.php b/app/Factory/TaxRateFactory.php index 63252cad3f84..e4cb3ab5be92 100644 --- a/app/Factory/TaxRateFactory.php +++ b/app/Factory/TaxRateFactory.php @@ -20,7 +20,7 @@ class TaxRateFactory $tax_rate = new TaxRate(); $tax_rate->name = ''; - $tax_rate->rate = ''; + $tax_rate->rate = 0; $tax_rate->company_id = $company_id; $tax_rate->user_id = $user_id; diff --git a/app/Factory/VendorFactory.php b/app/Factory/VendorFactory.php index d569c0cfe4e9..560a75c1a89a 100644 --- a/app/Factory/VendorFactory.php +++ b/app/Factory/VendorFactory.php @@ -26,7 +26,7 @@ class VendorFactory $vendor->private_notes = ''; $vendor->public_notes = ''; $vendor->country_id = 4; - $vendor->is_deleted = 0; + $vendor->is_deleted = false; $vendor->vendor_hash = Str::random(40); // $vendor->classification = ''; diff --git a/app/Filters/BankTransactionFilters.php b/app/Filters/BankTransactionFilters.php index 4a7db04e8b70..faaeaa7ade4a 100644 --- a/app/Filters/BankTransactionFilters.php +++ b/app/Filters/BankTransactionFilters.php @@ -115,6 +115,29 @@ class BankTransactionFilters extends QueryFilters return $this->builder; } + + /** + * Filters the list based on Bank Accounts. + * + * @param string $ids Comma Separated List of bank account ids + * @return Builder + */ + public function bank_integration_ids(string $ids = ''): Builder + { + if(strlen($ids) == 0) { + return $this->builder; + } + + $ids = $this->transformKeys(explode(",", $ids)); + + $this->builder->where(function ($query) use ($ids) { + $query->whereIn('bank_integration_id', $ids); + }); + + return $this->builder; + + } + /** * Sorts the list based on $sort. * diff --git a/app/Filters/ClientFilters.php b/app/Filters/ClientFilters.php index ab56672f28eb..ffc3e4fd7717 100644 --- a/app/Filters/ClientFilters.php +++ b/app/Filters/ClientFilters.php @@ -160,8 +160,9 @@ class ClientFilters extends QueryFilters return $this->builder; } - if($sort_col[0] == 'documents') + if($sort_col[0] == 'documents') { return $this->builder; + } if ($sort_col[0] == 'display_name') { $sort_col[0] = 'name'; diff --git a/app/Filters/DesignFilters.php b/app/Filters/DesignFilters.php index 8d7ba26ea05e..f914bcc4ba46 100644 --- a/app/Filters/DesignFilters.php +++ b/app/Filters/DesignFilters.php @@ -58,10 +58,11 @@ class DesignFilters extends QueryFilters public function entities(string $entities = ''): Builder { - - if(stripos($entities, 'statement') !== false) + + if(stripos($entities, 'statement') !== false) { $entities = 'client'; - + } + if (strlen($entities) == 0 || str_contains($entities, ',')) { return $this->builder; } diff --git a/app/Filters/DocumentFilters.php b/app/Filters/DocumentFilters.php index 9973cbf51345..4623e25326e2 100644 --- a/app/Filters/DocumentFilters.php +++ b/app/Filters/DocumentFilters.php @@ -49,22 +49,22 @@ class DocumentFilters extends QueryFilters */ public function client_id(string $client_id = ''): Builder { - + return $this->builder->where(function ($query) use ($client_id) { $query->whereHasMorph('documentable', [ - \App\Models\Invoice::class, - \App\Models\Quote::class, - \App\Models\Credit::class, - \App\Models\Expense::class, - \App\Models\Payment::class, + \App\Models\Invoice::class, + \App\Models\Quote::class, + \App\Models\Credit::class, + \App\Models\Expense::class, + \App\Models\Payment::class, \App\Models\Task::class, \App\Models\RecurringExpense::class, \App\Models\RecurringInvoice::class, \App\Models\Project::class, ], function ($q2) use ($client_id) { - $q2->where('client_id', $this->decodePrimaryKey($client_id)); - })->orWhereHasMorph('documentable', [\App\Models\Client::class], function ($q3) use ($client_id) { - $q3->where('id', $this->decodePrimaryKey($client_id)); + $q2->where('client_id', $this->decodePrimaryKey($client_id)); + })->orWhereHasMorph('documentable', [\App\Models\Client::class], function ($q3) use ($client_id) { + $q3->where('id', $this->decodePrimaryKey($client_id)); }); }); @@ -74,8 +74,7 @@ class DocumentFilters extends QueryFilters { $types = explode(',', $types); - foreach ($types as $type) - { + foreach ($types as $type) { match($type) { 'private' => $this->builder->where('is_public', 0), 'public' => $this->builder->where('is_public', 1), @@ -87,7 +86,7 @@ class DocumentFilters extends QueryFilters } return $this->builder; - } + } /** * Sorts the list based on $sort. diff --git a/app/Filters/ExpenseFilters.php b/app/Filters/ExpenseFilters.php index 0d133e96ce12..108dc359d811 100644 --- a/app/Filters/ExpenseFilters.php +++ b/app/Filters/ExpenseFilters.php @@ -111,8 +111,8 @@ class ExpenseFilters extends QueryFilters }); } - if(in_array('uncategorized', $status_parameters)){ - $query->orWhere(function ($query){ + if(in_array('uncategorized', $status_parameters)) { + $query->orWhere(function ($query) { $query->whereNull('category_id'); }); } diff --git a/app/Filters/InvoiceFilters.php b/app/Filters/InvoiceFilters.php index 5f307de3079b..3ef024429485 100644 --- a/app/Filters/InvoiceFilters.php +++ b/app/Filters/InvoiceFilters.php @@ -228,10 +228,9 @@ class InvoiceFilters extends QueryFilters $date = Carbon::createFromTimestamp((int)$date); } else { - try{ + try { $date = Carbon::parse($date); - } - catch(\Exception $e){ + } catch(\Exception $e) { return $this->builder; } } @@ -339,7 +338,7 @@ class InvoiceFilters extends QueryFilters // return $this->builder->orderByRaw('CAST(number AS UNSIGNED), number ' . $dir); // return $this->builder->orderByRaw("number REGEXP '^[A-Za-z]+$',CAST(number as SIGNED INTEGER),CAST(REPLACE(number,'-','')AS SIGNED INTEGER) ,number"); // return $this->builder->orderByRaw('ABS(number) ' . $dir); - return $this->builder->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . $dir); + return $this->builder->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . $dir); } return $this->builder->orderBy($sort_col[0], $dir); diff --git a/app/Filters/RecurringInvoiceFilters.php b/app/Filters/RecurringInvoiceFilters.php index b9124c9168cb..56ac04619c99 100644 --- a/app/Filters/RecurringInvoiceFilters.php +++ b/app/Filters/RecurringInvoiceFilters.php @@ -133,7 +133,7 @@ class RecurringInvoiceFilters extends QueryFilters return $this->builder->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . $dir); } - if($sort_col[0] == 'next_send_datetime'){ + if($sort_col[0] == 'next_send_datetime') { $sort_col[0] = 'next_send_date'; } diff --git a/app/Helpers/Bank/Nordigen/Nordigen.php b/app/Helpers/Bank/Nordigen/Nordigen.php index 6f71155140a4..f12e0fbe5318 100644 --- a/app/Helpers/Bank/Nordigen/Nordigen.php +++ b/app/Helpers/Bank/Nordigen/Nordigen.php @@ -100,7 +100,7 @@ class Nordigen } catch (\Exception $e) { nlog("Nordigen getAccount() failed => {$account_id} => " . $e->getMessage()); - + return false; } @@ -151,9 +151,10 @@ class Nordigen public function disabledAccountEmail(BankIntegration $bank_integration): void { $cache_key = "email_quota:{$bank_integration->company->company_key}:{$bank_integration->id}"; - - if(Cache::has($cache_key)) + + if(Cache::has($cache_key)) { return; + } App::setLocale($bank_integration->company->getLocale()); @@ -168,7 +169,7 @@ class Nordigen $mo->email_template_subject = 'nordigen_requisition_subject'; Email::dispatch($mo, $bank_integration->company); - + Cache::put($cache_key, true, 60 * 60 * 24); } diff --git a/app/Helpers/Bank/Nordigen/Transformer/TransactionTransformer.php b/app/Helpers/Bank/Nordigen/Transformer/TransactionTransformer.php index b9fc87de4ba2..d2259150e181 100644 --- a/app/Helpers/Bank/Nordigen/Transformer/TransactionTransformer.php +++ b/app/Helpers/Bank/Nordigen/Transformer/TransactionTransformer.php @@ -71,7 +71,7 @@ class TransactionTransformer implements BankRevenueInterface private Company $company; - function __construct(Company $company) + public function __construct(Company $company) { $this->company = $company; } @@ -192,7 +192,7 @@ class TransactionTransformer implements BankRevenueInterface } try { - return Carbon::createFromFormat("d-m-Y", $input)->setTimezone($timezone_name)->format($date_format_default) ?? $input; + return Carbon::createFromFormat("d-m-Y", $input)->setTimezone($timezone_name)->format($date_format_default) ?? $input; } catch (\Exception $e) { return $input; } diff --git a/app/Helpers/Epc/EpcQrGenerator.php b/app/Helpers/Epc/EpcQrGenerator.php index b38dc7efcf5c..87bb585ba6e4 100644 --- a/app/Helpers/Epc/EpcQrGenerator.php +++ b/app/Helpers/Epc/EpcQrGenerator.php @@ -105,7 +105,7 @@ class EpcQrGenerator return implode("\n", $data); } - + // substr("{$this->invoice->number} {$this->invoice->client->number}", 0,139), diff --git a/app/Helpers/Invoice/CustomValuer.php b/app/Helpers/Invoice/CustomValuer.php index 7ef81f074f9d..cc79dd22e136 100644 --- a/app/Helpers/Invoice/CustomValuer.php +++ b/app/Helpers/Invoice/CustomValuer.php @@ -27,7 +27,7 @@ trait CustomValuer public function valuerTax($custom_value, $has_custom_invoice_taxes) { - + if (isset($custom_value) && is_numeric($custom_value) && $has_custom_invoice_taxes !== false) { return round($custom_value * ($this->invoice->tax_rate1 / 100), 2) + round($custom_value * ($this->invoice->tax_rate2 / 100), 2) + round($custom_value * ($this->invoice->tax_rate3 / 100), 2); } @@ -35,17 +35,18 @@ trait CustomValuer return 0; } - public function multiInclusiveTax($custom_value, $has_custom_invoice_taxes) { + public function multiInclusiveTax($custom_value, $has_custom_invoice_taxes) + { if (isset($custom_value) && is_numeric($custom_value) && $has_custom_invoice_taxes !== false) { - $tax = 0; + $tax = 0; - $tax += $this->formatValue($custom_value - ($custom_value / (1 + ($this->invoice->tax_rate1 / 100))), 2); - $tax += $this->formatValue($custom_value - ($custom_value / (1 + ($this->invoice->tax_rate2 / 100))), 2); - $tax += $this->formatValue($custom_value - ($custom_value / (1 + ($this->invoice->tax_rate3 / 100))), 2); + $tax += $this->formatValue($custom_value - ($custom_value / (1 + ($this->invoice->tax_rate1 / 100))), 2); + $tax += $this->formatValue($custom_value - ($custom_value / (1 + ($this->invoice->tax_rate2 / 100))), 2); + $tax += $this->formatValue($custom_value - ($custom_value / (1 + ($this->invoice->tax_rate3 / 100))), 2); - return round($tax,2); + return round($tax, 2); } return 0; diff --git a/app/Helpers/Invoice/InvoiceItemSum.php b/app/Helpers/Invoice/InvoiceItemSum.php index 6e449252927d..dc946874f043 100644 --- a/app/Helpers/Invoice/InvoiceItemSum.php +++ b/app/Helpers/Invoice/InvoiceItemSum.php @@ -182,7 +182,7 @@ class InvoiceItemSum $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; } diff --git a/app/Helpers/Invoice/InvoiceSum.php b/app/Helpers/Invoice/InvoiceSum.php index 75a6139d92a0..32a821445d17 100644 --- a/app/Helpers/Invoice/InvoiceSum.php +++ b/app/Helpers/Invoice/InvoiceSum.php @@ -229,7 +229,7 @@ class InvoiceSum { // $this->invoice->amount = $this->formatValue($this->getTotal(), $this->precision); // $this->invoice->total_taxes = $this->getTotalTaxes(); - + $this->setCalculatedAttributes(); $this->invoice->balance = $this->invoice->amount; $this->invoice->saveQuietly(); @@ -245,10 +245,9 @@ class InvoiceSum */ private function setCalculatedAttributes(): self { - if($this->invoice->status_id == Invoice::STATUS_CANCELLED){ + if($this->invoice->status_id == Invoice::STATUS_CANCELLED) { $this->invoice->balance = 0; - } - elseif ($this->invoice->status_id != Invoice::STATUS_DRAFT) { + } elseif ($this->invoice->status_id != Invoice::STATUS_DRAFT) { if ($this->invoice->amount != $this->invoice->balance) { $this->invoice->balance = Number::roundValue($this->getTotal(), $this->precision) - $this->invoice->paid_to_date; //21-02-2024 cannot use the calculated $paid_to_date here as it could send the balance backward. } else { @@ -258,7 +257,7 @@ class InvoiceSum /* Set new calculated total */ $this->invoice->amount = $this->formatValue($this->getTotal(), $this->precision); - if($this->rappen_rounding){ + if($this->rappen_rounding) { $this->invoice->amount = $this->roundRappen($this->invoice->amount); $this->invoice->balance = $this->roundRappen($this->invoice->balance); } @@ -269,7 +268,7 @@ class InvoiceSum } - function roundRappen($value): float + public function roundRappen($value): float { return round($value / .05, 0) * .05; } diff --git a/app/Helpers/Invoice/InvoiceSumInclusive.php b/app/Helpers/Invoice/InvoiceSumInclusive.php index bdc3eaacac4d..fe50d9cb1fb0 100644 --- a/app/Helpers/Invoice/InvoiceSumInclusive.php +++ b/app/Helpers/Invoice/InvoiceSumInclusive.php @@ -171,7 +171,7 @@ class InvoiceSumInclusive $this->total_taxes += $tax; $this->total_tax_map[] = ['name' => $this->invoice->tax_name3.' '.floatval($this->invoice->tax_rate3).'%', 'total' => $tax]; } - + return $this; } @@ -279,10 +279,9 @@ class InvoiceSumInclusive private function setCalculatedAttributes() { /* If amount != balance then some money has been paid on the invoice, need to subtract this difference from the total to set the new balance */ - if($this->invoice->status_id == Invoice::STATUS_CANCELLED){ + if($this->invoice->status_id == Invoice::STATUS_CANCELLED) { $this->invoice->balance = 0; - } - elseif ($this->invoice->status_id != Invoice::STATUS_DRAFT) { + } elseif ($this->invoice->status_id != Invoice::STATUS_DRAFT) { if ($this->invoice->amount != $this->invoice->balance) { $this->invoice->balance = $this->formatValue($this->getTotal(), $this->precision) - $this->invoice->paid_to_date; } else { @@ -302,8 +301,8 @@ class InvoiceSumInclusive return $this; } - - function roundRappen($value): float + + public function roundRappen($value): float { return round($value / .05, 0) * .05; } @@ -373,7 +372,7 @@ class InvoiceSumInclusive $this->total_taxes += $total_line_tax; } - + return $this; } diff --git a/app/Helpers/Mail/GmailTransport.php b/app/Helpers/Mail/GmailTransport.php index 0655c710cad8..1be44af73641 100644 --- a/app/Helpers/Mail/GmailTransport.php +++ b/app/Helpers/Mail/GmailTransport.php @@ -34,7 +34,7 @@ class GmailTransport extends AbstractTransport $message = MessageConverter::toEmail($message->getOriginalMessage()); /** @phpstan-ignore-next-line **/ - $token = $message->getHeaders()->get('gmailtoken')->getValue(); + $token = $message->getHeaders()->get('gmailtoken')->getValue(); // @phpstan-ignore-line $message->getHeaders()->remove('gmailtoken'); $client = new Client(); @@ -53,9 +53,8 @@ class GmailTransport extends AbstractTransport if ($bccs) { $bcc_list = 'Bcc: '; + foreach ($bccs->getAddresses() as $address) { - /** @phpstan-ignore-next-line **/ - foreach ($bccs->getAddresses() as $address) { $bcc_list .= $address->getAddress() .','; } @@ -65,18 +64,18 @@ class GmailTransport extends AbstractTransport $body->setRaw($this->base64_encode($bcc_list.$message->toString())); // try { - $service->users_messages->send('me', $body, []); + $service->users_messages->send('me', $body, []); // } catch(\Google\Service\Exception $e) { // /* Need to slow down */ // if ($e->getCode() == '429') { // nlog("429 google - retrying "); // sleep(rand(3,8)); - + // try { // $service->users_messages->send('me', $body, []); // } catch(\Google\Service\Exception $e) { - + // } // } diff --git a/app/Helpers/Mail/Office365MailTransport.php b/app/Helpers/Mail/Office365MailTransport.php index 258ed9d0ff53..c5cf6fa91235 100644 --- a/app/Helpers/Mail/Office365MailTransport.php +++ b/app/Helpers/Mail/Office365MailTransport.php @@ -54,17 +54,17 @@ class Office365MailTransport extends AbstractTransport ->setReturnType(\Microsoft\Graph\Model\Message::class) ->execute(); } catch (\Exception $e) { - - sleep(rand(5,10)); + + sleep(rand(5, 10)); try { - $graphMessage = $graph->createRequest('POST', '/users/'.$symfony_message->getFrom()[0]->getAddress().'/sendmail') - ->attachBody(base64_encode($bcc_list.$message->toString())) - ->addHeaders(['Content-Type' => 'text/plain']) - ->setReturnType(\Microsoft\Graph\Model\Message::class) - ->execute(); + $graphMessage = $graph->createRequest('POST', '/users/'.$symfony_message->getFrom()[0]->getAddress().'/sendmail') + ->attachBody(base64_encode($bcc_list.$message->toString())) + ->addHeaders(['Content-Type' => 'text/plain']) + ->setReturnType(\Microsoft\Graph\Model\Message::class) + ->execute(); } catch (\Exception $e) { - + } } diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 12f53d7b7d38..fca1806e1632 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -61,7 +61,7 @@ class AccountController extends BaseController * Store a newly created resource in storage. * * @param CreateAccountRequest $request - * @return Response + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response * */ public function store(CreateAccountRequest $request) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index a58973cdf367..93445d7caf09 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -105,6 +105,14 @@ class ActivityController extends BaseController } + + /** + * downloadHistoricalEntity + * + * @param DownloadHistoricalEntityRequest $request + * @param Activity $activity + * @return \Symfony\Component\HttpFoundation\StreamedResponse | \Illuminate\Http\JsonResponse + */ public function downloadHistoricalEntity(DownloadHistoricalEntityRequest $request, Activity $activity) { $backup = $activity->backup; diff --git a/app/Http/Controllers/Auth/ContactLoginController.php b/app/Http/Controllers/Auth/ContactLoginController.php index 0c387a666405..e0f18daad76d 100644 --- a/app/Http/Controllers/Auth/ContactLoginController.php +++ b/app/Http/Controllers/Auth/ContactLoginController.php @@ -166,7 +166,7 @@ class ContactLoginController extends Controller private function setRedirectPath() { if (auth()->guard('contact')->user()->client->getSetting('enable_client_portal_dashboard') === true) { - $this->redirectTo = '/client/dashboard'; + $this->redirectTo = '/client/dashboard'; } elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES) { $this->redirectTo = '/client/invoices'; } elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES) { diff --git a/app/Http/Controllers/Auth/ContactRegisterController.php b/app/Http/Controllers/Auth/ContactRegisterController.php index bc3b20071433..3181021f9cf4 100644 --- a/app/Http/Controllers/Auth/ContactRegisterController.php +++ b/app/Http/Controllers/Auth/ContactRegisterController.php @@ -50,7 +50,7 @@ class ContactRegisterController extends Controller public function register(RegisterRequest $request) { $request->merge(['company' => $request->company()]); - + $service = new ClientRegisterService( company: $request->company(), ); diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 74effaffe029..47f8efd624a1 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -46,7 +46,7 @@ class ForgotPasswordController extends Controller /** * @param Request $request - * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse * @throws \Illuminate\Validation\ValidationException */ public function sendResetLinkEmail(Request $request) diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 203e3b2d4aa0..fdad07677017 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -13,6 +13,7 @@ namespace App\Http\Controllers\Auth; use App\DataMapper\Analytics\LoginFailure; +use App\DataMapper\Analytics\LoginMeta; use App\DataMapper\Analytics\LoginSuccess; use App\Events\User\UserLoggedIn; use App\Http\Controllers\BaseController; @@ -111,6 +112,9 @@ class LoginController extends BaseController ->increment() ->batch(); + LightLogs::create(new LoginMeta($request->email, $request->ip, 'success')) + ->batch(); + /** @var \App\Models\User $user */ $user = $this->guard()->user(); @@ -159,6 +163,9 @@ class LoginController extends BaseController ->increment() ->batch(); + LightLogs::create(new LoginMeta($request->email, $request->ip, 'failure')) + ->batch(); + $this->incrementLoginAttempts($request); return response() @@ -172,7 +179,7 @@ class LoginController extends BaseController * Refreshes the data feed with the current Company User. * * @param Request $request - * @return Response|JsonResponse + * @return \Illuminate\Http\Response|JsonResponse */ public function refresh(Request $request) { @@ -391,8 +398,8 @@ class LoginController extends BaseController $truth->setCompany($set_company); //21-03-2024 - $cu->each(function ($cu){ - if(CompanyToken::where('company_id', $cu->company_id)->where('user_id', $cu->user_id)->where('is_system', true)->doesntExist()){ + $cu->each(function ($cu) { + if(CompanyToken::where('company_id', $cu->company_id)->where('user_id', $cu->user_id)->where('is_system', true)->doesntExist()) { (new CreateCompanyToken($cu->company, $cu->user, request()->server('HTTP_USER_AGENT')))->handle(); } }); @@ -481,7 +488,7 @@ class LoginController extends BaseController * send login response to oauthed users * * @param \App\Models\User $existing_user - * @return Response | JsonResponse + * @return Response| \Illuminate\Http\JsonResponse | JsonResponse */ private function existingOauthUser($existing_user) { @@ -651,7 +658,9 @@ class LoginController extends BaseController } if(request()->hasHeader('X-REACT') || request()->query('react')) { - Cache::put("react_redir:".auth()->user()?->account->key, 'true', 300); + /**@var \App\Models\User $user */ + $user = auth()->user(); + Cache::put("react_redir:".$user?->account->key, 'true', 300); } if (request()->has('code')) { diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index fff62640a2d5..08c02b6892f6 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -78,7 +78,7 @@ class ResetPasswordController extends Controller * Reset the given user's password. * * @param Request $request - * @return RedirectResponse|JsonResponse + * @return \Illuminate\Http\RedirectResponse | \Illuminate\Http\RedirectResponse|JsonResponse * @throws \Illuminate\Validation\ValidationException */ public function reset(Request $request) diff --git a/app/Http/Controllers/Bank/YodleeController.php b/app/Http/Controllers/Bank/YodleeController.php index 7fd789bdea7f..26977d49383e 100644 --- a/app/Http/Controllers/Bank/YodleeController.php +++ b/app/Http/Controllers/Bank/YodleeController.php @@ -310,7 +310,7 @@ class YodleeController extends BaseController private function transformSummary($summary): array { - $dto = new \stdClass; + $dto = new \stdClass(); $dto->id = $summary['id'] ?? 0; $dto->account_type = $summary['CONTAINER'] ?? ''; diff --git a/app/Http/Controllers/BankIntegrationController.php b/app/Http/Controllers/BankIntegrationController.php index 732463a2a3ca..c8a1cfdaf853 100644 --- a/app/Http/Controllers/BankIntegrationController.php +++ b/app/Http/Controllers/BankIntegrationController.php @@ -55,7 +55,7 @@ class BankIntegrationController extends BaseController /** * @param BankIntegrationFilters $filters - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ public function index(BankIntegrationFilters $filters) { @@ -69,7 +69,7 @@ class BankIntegrationController extends BaseController * * @param ShowBankIntegrationRequest $request * @param BankIntegration $bank_integration - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function show(ShowBankIntegrationRequest $request, BankIntegration $bank_integration) @@ -83,7 +83,7 @@ class BankIntegrationController extends BaseController * * @param EditBankIntegrationRequest $request * @param BankIntegration $bank_integration - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function edit(EditBankIntegrationRequest $request, BankIntegration $bank_integration) @@ -96,7 +96,7 @@ class BankIntegrationController extends BaseController * * @param UpdateBankIntegrationRequest $request * @param BankIntegration $bank_integration - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function update(UpdateBankIntegrationRequest $request, BankIntegration $bank_integration) @@ -111,7 +111,7 @@ class BankIntegrationController extends BaseController * Show the form for creating a new resource. * * @param CreateBankIntegrationRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * */ @@ -130,7 +130,7 @@ class BankIntegrationController extends BaseController * Store a newly created resource in storage. * * @param StoreBankIntegrationRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function store(StoreBankIntegrationRequest $request) @@ -150,7 +150,7 @@ class BankIntegrationController extends BaseController * * @param DestroyBankIntegrationRequest $request * @param BankIntegration $bank_integration - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * @throws \Exception */ @@ -165,7 +165,7 @@ class BankIntegrationController extends BaseController /** * Perform bulk actions on the list view. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function bulk(BulkBankIntegrationRequest $request) @@ -295,7 +295,7 @@ class BankIntegrationController extends BaseController * Return the remote list of accounts stored on the third party provider * and update our local cache. * - * @return Response | JsonResponse + * @return Response| \Illuminate\Http\JsonResponse | JsonResponse * */ diff --git a/app/Http/Controllers/BankTransactionRuleController.php b/app/Http/Controllers/BankTransactionRuleController.php index 0b812943db55..28eebd1d05ce 100644 --- a/app/Http/Controllers/BankTransactionRuleController.php +++ b/app/Http/Controllers/BankTransactionRuleController.php @@ -85,7 +85,7 @@ class BankTransactionRuleController extends BaseController * ), * ) * @param BankTransactionRuleFilters $filters - * @return Response|mixed + * @return Response| \Illuminate\Http\JsonResponse|mixed */ public function index(BankTransactionRuleFilters $filters) { @@ -99,7 +99,7 @@ class BankTransactionRuleController extends BaseController * * @param ShowBankTransactionRuleRequest $request * @param BankTransactionRule $bank_transaction_rule - * @return \Illuminate\Http\JsonResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response|\Illuminate\Http\Response * * * @OA\Get( @@ -154,7 +154,7 @@ class BankTransactionRuleController extends BaseController * * @param EditBankTransactionRuleRequest $request * @param BankTransactionRule $bank_transaction_rule - * @return \Illuminate\Http\JsonResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response * * * @OA\Get( @@ -208,7 +208,7 @@ class BankTransactionRuleController extends BaseController * * @param UpdateBankTransactionRuleRequest $request * @param BankTransactionRule $bank_transaction_rule - * @return \Illuminate\Http\JsonResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response * * * @@ -269,7 +269,7 @@ class BankTransactionRuleController extends BaseController * Show the form for creating a new resource. * * @param CreateBankTransactionRuleRequest $request - * @return \Illuminate\Http\JsonResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response * * * @@ -317,7 +317,7 @@ class BankTransactionRuleController extends BaseController * Store a newly created resource in storage. * * @param StoreBankTransactionRuleRequest $request - * @return \Illuminate\Http\JsonResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response * * * @@ -369,7 +369,7 @@ class BankTransactionRuleController extends BaseController * * @param DestroyBankTransactionRuleRequest $request * @param BankTransactionRule $bank_transaction_rule - * @return \Illuminate\Http\JsonResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response * * * @throws \Exception @@ -424,7 +424,7 @@ class BankTransactionRuleController extends BaseController /** * Perform bulk actions on the list view. * - * @return \Illuminate\Support\Collection + * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse * * @OA\Post( * path="/api/v1/bank_transation_rules/bulk", diff --git a/app/Http/Controllers/BaseController.php b/app/Http/Controllers/BaseController.php index 92f1d4a6c272..b951e61c6fb0 100644 --- a/app/Http/Controllers/BaseController.php +++ b/app/Http/Controllers/BaseController.php @@ -262,7 +262,7 @@ class BaseController extends Controller /** * 404 for the client portal. - * @return Response 404 response + * @return Response| \Illuminate\Http\JsonResponse 404 response */ public function notFoundClient() { @@ -279,7 +279,7 @@ class BaseController extends Controller * * @param string|array $message The return error message * @param int $httpErrorCode 404/401/403 etc - * @return Response The JSON response + * @return Response| \Illuminate\Http\JsonResponse The JSON response * @throws BindingResolutionException */ protected function errorResponse($message, $httpErrorCode = 400) @@ -297,7 +297,7 @@ class BaseController extends Controller * Refresh API response with latest cahnges * * @param Builder $query - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ protected function refreshResponse($query) { @@ -460,7 +460,7 @@ class BaseController extends Controller } }, 'company.tasks' => function ($query) use ($updated_at, $user) { - $query->where('updated_at', '>=', $updated_at)->with('project','documents'); + $query->where('updated_at', '>=', $updated_at)->with('project', 'documents'); if (! $user->hasPermission('view_task')) { $query->whereNested(function ($query) use ($user) { @@ -798,7 +798,7 @@ class BaseController extends Controller } }, 'company.tasks' => function ($query) use ($created_at, $user) { - $query->where('created_at', '>=', $created_at)->with('project.documents','documents'); + $query->where('created_at', '>=', $created_at)->with('project.documents', 'documents'); if (! $user->hasPermission('view_task')) { $query->whereNested(function ($query) use ($user) { @@ -969,7 +969,7 @@ class BaseController extends Controller * Sorts the response by keys * * @param mixed $response - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ protected function response($response) { @@ -995,7 +995,7 @@ class BaseController extends Controller $response_data = Statics::company($user->getCompany()->getLocale()); - if(request()->has('einvoice')){ + if(request()->has('einvoice')) { $ro = new Schema(); $response_data['einvoice_schema'] = $ro('Peppol'); @@ -1003,7 +1003,7 @@ class BaseController extends Controller } $response['static'] = $response_data; - + } } @@ -1020,7 +1020,7 @@ class BaseController extends Controller * Item Response * * @param mixed $item - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ protected function itemResponse($item) { diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index ffe011a6e3fc..38f1f3a0397e 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -89,7 +89,7 @@ class ClientController extends BaseController /** * * @param ClientFilters $filters - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function index(ClientFilters $filters) @@ -106,7 +106,7 @@ class ClientController extends BaseController * * @param ShowClientRequest $request * @param Client $client - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function show(ShowClientRequest $request, Client $client) @@ -119,7 +119,7 @@ class ClientController extends BaseController * * @param EditClientRequest $request * @param Client $client - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function edit(EditClientRequest $request, Client $client) @@ -132,7 +132,7 @@ class ClientController extends BaseController * * @param UpdateClientRequest $request * @param Client $client - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function update(UpdateClientRequest $request, Client $client) @@ -157,7 +157,7 @@ class ClientController extends BaseController * Show the form for creating a new resource. * * @param CreateClientRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function create(CreateClientRequest $request) @@ -174,7 +174,7 @@ class ClientController extends BaseController * Store a newly created resource in storage. * * @param StoreClientRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function store(StoreClientRequest $request) @@ -203,7 +203,7 @@ class ClientController extends BaseController * * @param DestroyClientRequest $request * @param Client $client - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * @throws \Exception */ @@ -217,7 +217,7 @@ class ClientController extends BaseController /** * Perform bulk actions on the list view. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function bulk(BulkClientRequest $request) @@ -250,22 +250,22 @@ class ClientController extends BaseController return response()->json(['message' => $hash_or_response], 200); } - if($action == 'assign_group' && $user->can('edit', $clients->first())){ + if($action == 'assign_group' && $user->can('edit', $clients->first())) { $this->client_repo->assignGroup($clients, $request->group_settings_id); - + return $this->listResponse(Client::query()->withTrashed()->company()->whereIn('id', $request->ids)); } - if($action == 'bulk_update' && $user->can('edit', $clients->first())){ + if($action == 'bulk_update' && $user->can('edit', $clients->first())) { $clients = Client::withTrashed() ->company() ->whereIn('id', $request->ids); $this->client_repo->bulkUpdate($clients, $request->column, $request->new_value); - + return $this->listResponse(Client::query()->withTrashed()->company()->whereIn('id', $request->ids)); } @@ -284,7 +284,7 @@ class ClientController extends BaseController * * @param UploadClientRequest $request * @param Client $client - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function upload(UploadClientRequest $request, Client $client) @@ -305,7 +305,7 @@ class ClientController extends BaseController * * @param PurgeClientRequest $request * @param Client $client - * @return \Illuminate\Http\JsonResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response * */ public function purge(PurgeClientRequest $request, Client $client) @@ -333,7 +333,7 @@ class ClientController extends BaseController * @param PurgeClientRequest $request * @param Client $client * @param string $mergeable_client - * @return \Illuminate\Http\JsonResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response * */ @@ -351,9 +351,10 @@ class ClientController extends BaseController return response()->json(['message' => "Client not found"], 400); } - if($m_client->id == $client->id) + if($m_client->id == $client->id) { return response()->json(['message' => "Attempting to merge the same client is not possible."], 400); - + } + $merged_client = $client->service()->merge($m_client)->save(); return $this->itemResponse($merged_client); @@ -364,7 +365,7 @@ class ClientController extends BaseController * * @param PurgeClientRequest $request * @param Client $client - * @return \Illuminate\Http\JsonResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response */ public function updateTaxData(PurgeClientRequest $request, Client $client) { @@ -380,7 +381,7 @@ class ClientController extends BaseController * * @param ReactivateClientEmailRequest $request * @param string $bounce_id //could also be the invitationId - * @return \Illuminate\Http\JsonResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response */ public function reactivateEmail(ReactivateClientEmailRequest $request, string $bounce_id) { diff --git a/app/Http/Controllers/ClientGatewayTokenController.php b/app/Http/Controllers/ClientGatewayTokenController.php index 5caa5c69914f..c7f270d28a04 100644 --- a/app/Http/Controllers/ClientGatewayTokenController.php +++ b/app/Http/Controllers/ClientGatewayTokenController.php @@ -89,7 +89,7 @@ class ClientGatewayTokenController extends BaseController * ), * ) * @param ListClientGatewayTokenRequest $request - * @return Response|mixed + * @return Response| \Illuminate\Http\JsonResponse|mixed */ public function index(ListClientGatewayTokenRequest $request) { @@ -103,7 +103,7 @@ class ClientGatewayTokenController extends BaseController * * @param ShowClientGatewayTokenRequest $request * @param ClientGatewayToken $client_gateway_token - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -157,7 +157,7 @@ class ClientGatewayTokenController extends BaseController * * @param EditClientGatewayTokenRequest $request * @param ClientGatewayToken $client_gateway_token - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -211,7 +211,7 @@ class ClientGatewayTokenController extends BaseController * * @param UpdateClientGatewayTokenRequest $request * @param ClientGatewayToken $client_gateway_token - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -267,7 +267,7 @@ class ClientGatewayTokenController extends BaseController * Show the form for creating a new resource. * * @param CreateClientGatewayTokenRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -317,7 +317,7 @@ class ClientGatewayTokenController extends BaseController * Store a newly created resource in storage. * * @param StoreClientGatewayTokenRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -369,7 +369,7 @@ class ClientGatewayTokenController extends BaseController * * @param DestroyClientGatewayTokenRequest $request * @param ClientGatewayToken $client_gateway_token - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @throws \Exception diff --git a/app/Http/Controllers/ClientPortal/ContactHashLoginController.php b/app/Http/Controllers/ClientPortal/ContactHashLoginController.php index 11bbbb47a426..944385c28ec2 100644 --- a/app/Http/Controllers/ClientPortal/ContactHashLoginController.php +++ b/app/Http/Controllers/ClientPortal/ContactHashLoginController.php @@ -21,7 +21,7 @@ class ContactHashLoginController extends Controller /** * Logs a user into the client portal using their contact_key * @param string $contact_key The contact key - * @return Redirect + * @return \Illuminate\Http\RedirectResponse */ public function login(string $contact_key) { @@ -50,7 +50,7 @@ class ContactHashLoginController extends Controller /** * Generic error page for client portal. * - * @return void + * @return \Illuminate\View\View */ public function errorPage() { diff --git a/app/Http/Controllers/ClientPortal/DashboardController.php b/app/Http/Controllers/ClientPortal/DashboardController.php index c8c53d3b8445..33b3e392b601 100644 --- a/app/Http/Controllers/ClientPortal/DashboardController.php +++ b/app/Http/Controllers/ClientPortal/DashboardController.php @@ -21,7 +21,7 @@ class DashboardController extends Controller { if (auth()->guard('contact')->user()->client->getSetting('enable_client_portal_dashboard') === false) { return redirect()->route('client.invoices.index'); - } + } $total_invoices = Invoice::withTrashed() ->where('client_id', auth()->guard('contact')->user()->client_id) diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php index 615b2409702f..bce4399d3be8 100644 --- a/app/Http/Controllers/ClientPortal/PaymentController.php +++ b/app/Http/Controllers/ClientPortal/PaymentController.php @@ -103,7 +103,7 @@ class PaymentController extends Controller * and invoice ids for reference. * * @param Request $request - * @return RedirectResponse|mixed + * @return \Illuminate\Http\RedirectResponse|mixed */ public function process(Request $request) { @@ -157,7 +157,7 @@ class PaymentController extends Controller * Pay for invoice/s using credits only. * * @param Request $request The request object - * @return \Response The response view + * @return \Illuminate\Http\RedirectResponse The response view */ public function credit_response(Request $request) { diff --git a/app/Http/Controllers/ClientPortal/PaymentMethodController.php b/app/Http/Controllers/ClientPortal/PaymentMethodController.php index 51b07eb7adf8..f85d9dbc9483 100644 --- a/app/Http/Controllers/ClientPortal/PaymentMethodController.php +++ b/app/Http/Controllers/ClientPortal/PaymentMethodController.php @@ -127,7 +127,7 @@ class PaymentMethodController extends Controller * Remove the specified resource from storage. * * @param ClientGatewayToken $payment_method - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function destroy(ClientGatewayToken $payment_method) { diff --git a/app/Http/Controllers/ClientPortal/PrePaymentController.php b/app/Http/Controllers/ClientPortal/PrePaymentController.php index 7acd355a9bf0..6a666e9c7d9d 100644 --- a/app/Http/Controllers/ClientPortal/PrePaymentController.php +++ b/app/Http/Controllers/ClientPortal/PrePaymentController.php @@ -108,7 +108,7 @@ class PrePaymentController extends Controller return $invoice; }); - + $variables = false; if(($invitation = $invoices->first()->invitations()->first() ?? false) && $invoice->client->getSetting('show_accept_invoice_terms')) { diff --git a/app/Http/Controllers/ClientPortal/ProfileController.php b/app/Http/Controllers/ClientPortal/ProfileController.php index f0296241b914..c183252b6afa 100644 --- a/app/Http/Controllers/ClientPortal/ProfileController.php +++ b/app/Http/Controllers/ClientPortal/ProfileController.php @@ -38,7 +38,7 @@ class ProfileController extends Controller * * @param UpdateContactRequest $request * @param ClientContact $client_contact - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function update(UpdateContactRequest $request, ClientContact $client_contact) { diff --git a/app/Http/Controllers/ClientPortal/QuoteController.php b/app/Http/Controllers/ClientPortal/QuoteController.php index 52c5ccf58416..9dce7c6e3eab 100644 --- a/app/Http/Controllers/ClientPortal/QuoteController.php +++ b/app/Http/Controllers/ClientPortal/QuoteController.php @@ -178,7 +178,7 @@ class QuoteController extends Controller ->where('client_id', auth()->guard('contact')->user()->client->id) ->where('company_id', auth()->guard('contact')->user()->client->company_id) ->whereIn('status_id', [Quote::STATUS_DRAFT, Quote::STATUS_SENT]) - ->where(function ($q){ + ->where(function ($q) { $q->whereNull('due_date')->orWhere('due_date', '>=', now()); }) ->withTrashed() diff --git a/app/Http/Controllers/ClientPortal/RecurringInvoiceController.php b/app/Http/Controllers/ClientPortal/RecurringInvoiceController.php index 30356b24c03a..f0a2bc57b3dc 100644 --- a/app/Http/Controllers/ClientPortal/RecurringInvoiceController.php +++ b/app/Http/Controllers/ClientPortal/RecurringInvoiceController.php @@ -66,7 +66,7 @@ class RecurringInvoiceController extends Controller * @param RequestCancellationRequest $request [description] * @param RecurringInvoice $recurring_invoice [description] * - * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse + * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View */ public function requestCancellation(RequestCancellationRequest $request, RecurringInvoice $recurring_invoice) { diff --git a/app/Http/Controllers/ClientPortal/TempRouteController.php b/app/Http/Controllers/ClientPortal/TempRouteController.php index f85edb8ca8b5..7bb4b24704f1 100644 --- a/app/Http/Controllers/ClientPortal/TempRouteController.php +++ b/app/Http/Controllers/ClientPortal/TempRouteController.php @@ -13,14 +13,13 @@ namespace App\Http\Controllers\ClientPortal; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Cache; -use Illuminate\Support\Facades\Redirect; class TempRouteController extends Controller { /** * Logs a user into the client portal using their contact_key * @param string $hash The hash - * @return Redirect + * @return \Illuminate\View\View */ public function index(string $hash) { diff --git a/app/Http/Controllers/ClientPortal/UploadController.php b/app/Http/Controllers/ClientPortal/UploadController.php index bb379634958a..31105e6b0a6e 100644 --- a/app/Http/Controllers/ClientPortal/UploadController.php +++ b/app/Http/Controllers/ClientPortal/UploadController.php @@ -26,7 +26,7 @@ class UploadController extends Controller * Main logic behind uploading the files. * * @param StoreUploadRequest $request - * @return Response|ResponseFactory + * @return Response| \Illuminate\Http\JsonResponse|ResponseFactory */ public function __invoke(StoreUploadRequest $request) { diff --git a/app/Http/Controllers/ClientStatementController.php b/app/Http/Controllers/ClientStatementController.php index 434b6685c67e..341f9c8dbf02 100644 --- a/app/Http/Controllers/ClientStatementController.php +++ b/app/Http/Controllers/ClientStatementController.php @@ -33,7 +33,7 @@ class ClientStatementController extends BaseController * Update the specified resource in storage. * * @param CreateStatementRequest $request - * @return Response + * @return \Symfony\Component\HttpFoundation\StreamedResponse | \Illuminate\Http\JsonResponse */ public function statement(CreateStatementRequest $request) { diff --git a/app/Http/Controllers/CompanyController.php b/app/Http/Controllers/CompanyController.php index 83ffb0a96f77..520bd201905b 100644 --- a/app/Http/Controllers/CompanyController.php +++ b/app/Http/Controllers/CompanyController.php @@ -78,7 +78,7 @@ class CompanyController extends BaseController /** * Display a listing of the resource. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * @OA\Get( * path="/api/v1/companies", @@ -136,7 +136,7 @@ class CompanyController extends BaseController * Show the form for creating a new resource. * * @param CreateCompanyRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -186,7 +186,7 @@ class CompanyController extends BaseController * Store a newly created resource in storage. * * @param StoreCompanyRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Post( @@ -272,7 +272,7 @@ class CompanyController extends BaseController * * @param ShowCompanyRequest $request * @param Company $company - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -326,7 +326,7 @@ class CompanyController extends BaseController * * @param EditCompanyRequest $request * @param Company $company - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -380,7 +380,7 @@ class CompanyController extends BaseController * * @param UpdateCompanyRequest $request * @param Company $company - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Put( @@ -457,7 +457,7 @@ class CompanyController extends BaseController * * @param DestroyCompanyRequest $request * @param Company $company - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @throws \Exception @@ -573,7 +573,7 @@ class CompanyController extends BaseController * * @param UploadCompanyRequest $request * @param Company $company - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -636,7 +636,7 @@ class CompanyController extends BaseController * * @param DefaultCompanyRequest $request * @param Company $company - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -706,6 +706,11 @@ class CompanyController extends BaseController return $this->itemResponse($company->fresh()); } + /** + * + * + * @return \Symfony\Component\HttpFoundation\StreamedResponse | \Illuminate\Http\JsonResponse + */ public function logo() { @@ -715,18 +720,16 @@ 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']; - try{ + try { $response = \Illuminate\Support\Facades\Http::get($logo); if ($response->successful()) { $logo = $response->body(); - } - else { + } else { $logo = base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='); } - } - catch(\Exception $e){ + } catch(\Exception $e) { $logo = base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='); diff --git a/app/Http/Controllers/CompanyGatewayController.php b/app/Http/Controllers/CompanyGatewayController.php index fb3726be9d78..56fc9ce0c1ff 100644 --- a/app/Http/Controllers/CompanyGatewayController.php +++ b/app/Http/Controllers/CompanyGatewayController.php @@ -72,7 +72,7 @@ class CompanyGatewayController extends BaseController /** * Display a listing of the resource. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -119,7 +119,7 @@ class CompanyGatewayController extends BaseController * Show the form for creating a new resource. * * @param CreateCompanyGatewayRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -168,7 +168,7 @@ class CompanyGatewayController extends BaseController * Store a newly created resource in storage. * * @param StoreCompanyGatewayRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -232,7 +232,7 @@ class CompanyGatewayController extends BaseController } elseif($company_gateway->gateway_key == $this->checkout_key) { CheckoutSetupWebhook::dispatch($company_gateway->company->company_key, $company_gateway->id); } elseif($company_gateway->gateway_key == $this->forte_key) { - + dispatch(function () use ($company_gateway) { MultiDB::setDb($company_gateway->company->db); $company_gateway->driver()->updateFees(); @@ -248,7 +248,7 @@ class CompanyGatewayController extends BaseController * * @param ShowCompanyGatewayRequest $request * @param CompanyGateway $company_gateway - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -302,7 +302,7 @@ class CompanyGatewayController extends BaseController * * @param EditCompanyGatewayRequest $request * @param CompanyGateway $company_gateway - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -356,7 +356,7 @@ class CompanyGatewayController extends BaseController * * @param UpdateCompanyGatewayRequest $request * @param CompanyGateway $company_gateway - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Put( @@ -420,8 +420,8 @@ class CompanyGatewayController extends BaseController if($company_gateway->gateway_key == $this->checkout_key) { CheckoutSetupWebhook::dispatch($company_gateway->company->company_key, $company_gateway->fresh()->id); - }elseif($company_gateway->gateway_key == $this->forte_key){ - + } elseif($company_gateway->gateway_key == $this->forte_key) { + dispatch(function () use ($company_gateway) { MultiDB::setDb($company_gateway->company->db); $company_gateway->driver()->updateFees(); @@ -437,7 +437,7 @@ class CompanyGatewayController extends BaseController * * @param DestroyCompanyGatewayRequest $request * @param CompanyGateway $company_gateway - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @throws \Exception @@ -494,7 +494,7 @@ class CompanyGatewayController extends BaseController /** * Perform bulk actions on the list view. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Post( @@ -565,12 +565,13 @@ class CompanyGatewayController extends BaseController public function importCustomers(TestCompanyGatewayRequest $request, CompanyGateway $company_gateway) { - - //Throttle here - if (Cache::has("throttle_polling:import_customers:{$company_gateway->company->company_key}:{$company_gateway->hashed_id}")) - return response()->json(['message' => 'Please wait whilst your previous attempts complete.'], 200); - dispatch(function () use($company_gateway) { + //Throttle here + if (Cache::has("throttle_polling:import_customers:{$company_gateway->company->company_key}:{$company_gateway->hashed_id}")) { + return response()->json(['message' => 'Please wait whilst your previous attempts complete.'], 200); + } + + dispatch(function () use ($company_gateway) { MultiDB::setDb($company_gateway->company->db); $company_gateway->driver()->importCustomers(); })->afterResponse(); diff --git a/app/Http/Controllers/CompanyLedgerController.php b/app/Http/Controllers/CompanyLedgerController.php index e616daf08d80..5cc7d91ab36e 100644 --- a/app/Http/Controllers/CompanyLedgerController.php +++ b/app/Http/Controllers/CompanyLedgerController.php @@ -31,7 +31,7 @@ class CompanyLedgerController extends BaseController * Store a newly created resource in storage. * * @param ShowCompanyLedgerRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * @OA\Get( * path="/api/v1/company_ledger", diff --git a/app/Http/Controllers/CompanyUserController.php b/app/Http/Controllers/CompanyUserController.php index 5dbeb183c943..c9526fec3604 100644 --- a/app/Http/Controllers/CompanyUserController.php +++ b/app/Http/Controllers/CompanyUserController.php @@ -107,7 +107,7 @@ class CompanyUserController extends BaseController * ) * @param UpdateCompanyUserRequest $request * @param User $user - * @return Response|mixed|void + * @return Response| \Illuminate\Http\JsonResponse|mixed|void */ public function update(UpdateCompanyUserRequest $request, User $user) { diff --git a/app/Http/Controllers/ConnectedAccountController.php b/app/Http/Controllers/ConnectedAccountController.php index 91f7c2d3fa92..532a5bd7a914 100644 --- a/app/Http/Controllers/ConnectedAccountController.php +++ b/app/Http/Controllers/ConnectedAccountController.php @@ -38,7 +38,7 @@ class ConnectedAccountController extends BaseController * Connect an OAuth account to a regular email/password combination account * * @param Request $request - * @return \Illuminate\Http\JsonResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response * * * @OA\Post( diff --git a/app/Http/Controllers/Contact/InvoiceController.php b/app/Http/Controllers/Contact/InvoiceController.php index d151660b0cc5..c3164ce34144 100644 --- a/app/Http/Controllers/Contact/InvoiceController.php +++ b/app/Http/Controllers/Contact/InvoiceController.php @@ -36,7 +36,7 @@ class InvoiceController extends BaseController * * @param InvoiceFilters $filters The filters * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ public function index(InvoiceFilters $filters) { diff --git a/app/Http/Controllers/Contact/LoginController.php b/app/Http/Controllers/Contact/LoginController.php index eb084aa250c7..54b54a79ac7b 100644 --- a/app/Http/Controllers/Contact/LoginController.php +++ b/app/Http/Controllers/Contact/LoginController.php @@ -58,7 +58,7 @@ class LoginController extends BaseController * * @param Request $request The request * - * @return \Illuminate\Http\JsonResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response * @throws \Illuminate\Validation\ValidationException */ public function apiLogin(Request $request) @@ -86,7 +86,7 @@ class LoginController extends BaseController * Redirect the user to the provider authentication page. * * @param string $provider - * @return void + * @return mixed */ public function redirectToProvider(string $provider) { diff --git a/app/Http/Controllers/CreditController.php b/app/Http/Controllers/CreditController.php index abb6c7e2f1fe..5d02ed881ede 100644 --- a/app/Http/Controllers/CreditController.php +++ b/app/Http/Controllers/CreditController.php @@ -69,7 +69,7 @@ class CreditController extends BaseController * * @param CreditFilters $filters The filters * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * @OA\Get( * path="/api/v1/credits", @@ -115,7 +115,7 @@ class CreditController extends BaseController * * @param CreateCreditRequest $request The request * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -164,7 +164,7 @@ class CreditController extends BaseController * * @param StoreCreditRequest $request The request * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Post( @@ -226,7 +226,7 @@ class CreditController extends BaseController * @param ShowCreditRequest $request The request * @param Credit $credit The credit * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -281,7 +281,7 @@ class CreditController extends BaseController * @param EditCreditRequest $request The request * @param Credit $credit The credit * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * @OA\Get( * path="/api/v1/credits/{id}/edit", @@ -334,7 +334,7 @@ class CreditController extends BaseController * * @param UpdateCreditRequest $request The request * @param Credit $credit - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @throws \ReflectionException @@ -458,7 +458,7 @@ class CreditController extends BaseController /** * Perform bulk actions on the list view. * - * @return \Illuminate\Support\Collection + * @return \Symfony\Component\HttpFoundation\StreamedResponse | \Illuminate\Http\JsonResponse * * @OA\Post( * path="/api/v1/credits/bulk", @@ -700,7 +700,7 @@ class CreditController extends BaseController * ), * ) * @param $invitation_key - * @return \Symfony\Component\HttpFoundation\BinaryFileResponse + * @return \Symfony\Component\HttpFoundation\StreamedResponse */ public function downloadPdf($invitation_key) { @@ -801,7 +801,7 @@ class CreditController extends BaseController * * @param UploadCreditRequest $request * @param Credit $credit - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * diff --git a/app/Http/Controllers/DesignController.php b/app/Http/Controllers/DesignController.php index 1fbcc0331467..4e2530bb1452 100644 --- a/app/Http/Controllers/DesignController.php +++ b/app/Http/Controllers/DesignController.php @@ -82,7 +82,7 @@ class DesignController extends BaseController * ), * ) * @param DesignFilters $filters - * @return Response|mixed + * @return Response| \Illuminate\Http\JsonResponse|mixed */ public function index(DesignFilters $filters) { @@ -96,7 +96,7 @@ class DesignController extends BaseController * * @param ShowDesignRequest $request * @param Design $design - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -150,7 +150,7 @@ class DesignController extends BaseController * * @param EditDesignRequest $request * @param Design $design - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -204,7 +204,7 @@ class DesignController extends BaseController * * @param UpdateDesignRequest $request * @param Design $design - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -265,7 +265,7 @@ class DesignController extends BaseController * Show the form for creating a new resource. * * @param CreateDesignRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -313,7 +313,7 @@ class DesignController extends BaseController * Store a newly created resource in storage. * * @param StoreDesignRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -415,7 +415,7 @@ class DesignController extends BaseController * * @param DestroyDesignRequest $request * @param Design $design - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @throws \Exception @@ -473,7 +473,7 @@ class DesignController extends BaseController /** * Perform bulk actions on the list view. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Post( diff --git a/app/Http/Controllers/DocumentController.php b/app/Http/Controllers/DocumentController.php index 6b76ce25c3e7..2a66c150f3d7 100644 --- a/app/Http/Controllers/DocumentController.php +++ b/app/Http/Controllers/DocumentController.php @@ -70,7 +70,7 @@ class DocumentController extends BaseController * ), * ) * @param DocumentFilters $filters - * @return Response|mixed + * @return Response| \Illuminate\Http\JsonResponse|mixed */ public function index(DocumentFilters $filters) { @@ -105,7 +105,7 @@ class DocumentController extends BaseController * * @param ShowDocumentRequest $request * @param Document $document - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ public function show(ShowDocumentRequest $request, Document $document) { @@ -131,7 +131,7 @@ class DocumentController extends BaseController * * @param EditDocumentRequest $request * @param Document $document - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ public function edit(EditDocumentRequest $request, Document $document) { @@ -143,7 +143,7 @@ class DocumentController extends BaseController * * @param UpdateDocumentRequest $request * @param Document $document - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ public function update(UpdateDocumentRequest $request, Document $document) { @@ -158,7 +158,7 @@ class DocumentController extends BaseController * * @param DestroyDocumentRequest $request * @param Document $document - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ public function destroy(DestroyDocumentRequest $request, Document $document) { diff --git a/app/Http/Controllers/ExpenseCategoryController.php b/app/Http/Controllers/ExpenseCategoryController.php index be4b14399e73..c5c9b606ec40 100644 --- a/app/Http/Controllers/ExpenseCategoryController.php +++ b/app/Http/Controllers/ExpenseCategoryController.php @@ -78,7 +78,7 @@ class ExpenseCategoryController extends BaseController * * Display a listing of the resource. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ public function index(ExpenseCategoryFilters $filters) { @@ -93,7 +93,7 @@ class ExpenseCategoryController extends BaseController * Show the form for creating a new resource. * * @param CreateExpenseCategoryRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -142,7 +142,7 @@ class ExpenseCategoryController extends BaseController * Store a newly created resource in storage. * * @param StoreExpenseCategoryRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Post( @@ -192,7 +192,7 @@ class ExpenseCategoryController extends BaseController * * @param ShowExpenseCategoryRequest $request * @param ExpenseCategory $expense_category - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -245,7 +245,7 @@ class ExpenseCategoryController extends BaseController * * @param EditExpenseCategoryRequest $request * @param ExpenseCategory $expense_category - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -298,7 +298,7 @@ class ExpenseCategoryController extends BaseController * * @param UpdateExpenseCategoryRequest $request * @param ExpenseCategory $expense_category - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -355,7 +355,7 @@ class ExpenseCategoryController extends BaseController * * @param DestroyExpenseCategoryRequest $request * @param ExpenseCategory $expense_category - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @throws \Exception @@ -410,7 +410,7 @@ class ExpenseCategoryController extends BaseController /** * Perform bulk actions on the list view. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Post( diff --git a/app/Http/Controllers/ExpenseController.php b/app/Http/Controllers/ExpenseController.php index daa49e20875e..3ab2cc90da02 100644 --- a/app/Http/Controllers/ExpenseController.php +++ b/app/Http/Controllers/ExpenseController.php @@ -98,7 +98,7 @@ class ExpenseController extends BaseController * ), * ) * @param ExpenseFilters $filters - * @return Response|mixed + * @return Response| \Illuminate\Http\JsonResponse|mixed */ public function index(ExpenseFilters $filters) { @@ -112,7 +112,7 @@ class ExpenseController extends BaseController * * @param ShowExpenseRequest $request * @param Expense $expense - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -166,7 +166,7 @@ class ExpenseController extends BaseController * * @param EditExpenseRequest $request * @param Expense $expense - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -220,7 +220,7 @@ class ExpenseController extends BaseController * * @param UpdateExpenseRequest $request * @param Expense $expense - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -286,7 +286,7 @@ class ExpenseController extends BaseController * Show the form for creating a new resource. * * @param CreateExpenseRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -334,7 +334,7 @@ class ExpenseController extends BaseController * Store a newly created resource in storage. * * @param StoreExpenseRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -387,7 +387,7 @@ class ExpenseController extends BaseController * * @param DestroyExpenseRequest $request * @param Expense $expense - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @throws \Exception @@ -441,7 +441,7 @@ class ExpenseController extends BaseController /** * Perform bulk actions on the list view. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Post( @@ -524,7 +524,7 @@ class ExpenseController extends BaseController * * @param UploadExpenseRequest $request * @param Expense $expense - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * diff --git a/app/Http/Controllers/GroupSettingController.php b/app/Http/Controllers/GroupSettingController.php index cbaf6d16886f..ad1b33d3a679 100644 --- a/app/Http/Controllers/GroupSettingController.php +++ b/app/Http/Controllers/GroupSettingController.php @@ -55,7 +55,7 @@ class GroupSettingController extends BaseController * Show the form for creating a new resource. * * @param GroupSettingFilters $filters - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function index(GroupSettingFilters $filters) @@ -69,7 +69,7 @@ class GroupSettingController extends BaseController * Show the form for creating a new resource. * * @param CreateGroupSettingRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function create(CreateGroupSettingRequest $request) @@ -86,7 +86,7 @@ class GroupSettingController extends BaseController * Store a newly created resource in storage. * * @param StoreGroupSettingRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function store(StoreGroupSettingRequest $request) @@ -108,7 +108,7 @@ class GroupSettingController extends BaseController * * @param ShowGroupSettingRequest $request * @param GroupSetting $group_setting - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function show(ShowGroupSettingRequest $request, GroupSetting $group_setting) @@ -121,7 +121,7 @@ class GroupSettingController extends BaseController * * @param EditGroupSettingRequest $request * @param GroupSetting $group_setting - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function edit(EditGroupSettingRequest $request, GroupSetting $group_setting) @@ -134,7 +134,7 @@ class GroupSettingController extends BaseController * * @param UpdateGroupSettingRequest $request * @param GroupSetting $group_setting - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function update(UpdateGroupSettingRequest $request, GroupSetting $group_setting) @@ -158,7 +158,7 @@ class GroupSettingController extends BaseController * * @param DestroyGroupSettingRequest $request * @param GroupSetting $group_setting - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @throws \Exception @@ -173,7 +173,7 @@ class GroupSettingController extends BaseController /** * Perform bulk actions on the list view. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function bulk() @@ -210,7 +210,7 @@ class GroupSettingController extends BaseController * * @param UploadGroupSettingRequest $request * @param GroupSetting $group_setting - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function upload(UploadGroupSettingRequest $request, GroupSetting $group_setting) diff --git a/app/Http/Controllers/ImportController.php b/app/Http/Controllers/ImportController.php index 187e4a3ff476..807340fa1e57 100644 --- a/app/Http/Controllers/ImportController.php +++ b/app/Http/Controllers/ImportController.php @@ -27,7 +27,7 @@ class ImportController extends Controller * * @param PreImportRequest $request * - * @return \Illuminate\Http\JsonResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response * * @OA\Post( * path="/api/v1/preimport", @@ -276,7 +276,7 @@ class ImportController extends Controller return $data; } - + /** * Returns the best delimiter @@ -302,7 +302,7 @@ class ImportController extends Controller } } - + /** @phpstan-ignore-next-line **/ return $bestDelimiter ?? ','; diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index c307e6302d01..ec74c7597086 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -81,7 +81,7 @@ class InvoiceController extends BaseController * * @param InvoiceFilters $filters The filters * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * @OA\Get( * path="/api/v1/invoices", @@ -128,7 +128,7 @@ class InvoiceController extends BaseController * * @param CreateInvoiceRequest $request The request * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -176,7 +176,7 @@ class InvoiceController extends BaseController * * @param StoreInvoiceRequest $request The request * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Post( @@ -248,7 +248,7 @@ class InvoiceController extends BaseController * @param ShowInvoiceRequest $request The request * @param Invoice $invoice The invoice * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -303,7 +303,7 @@ class InvoiceController extends BaseController * @param EditInvoiceRequest $request The request * @param Invoice $invoice The invoice * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * @OA\Get( * path="/api/v1/invoices/{id}/edit", @@ -357,7 +357,7 @@ class InvoiceController extends BaseController * @param UpdateInvoiceRequest $request The request * @param Invoice $invoice The invoice * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Put( @@ -954,7 +954,7 @@ class InvoiceController extends BaseController * * @param UploadInvoiceRequest $request * @param Invoice $invoice - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * diff --git a/app/Http/Controllers/LicenseController.php b/app/Http/Controllers/LicenseController.php index 7e5335b5fc97..f2454aca5e21 100644 --- a/app/Http/Controllers/LicenseController.php +++ b/app/Http/Controllers/LicenseController.php @@ -28,7 +28,7 @@ class LicenseController extends BaseController /** * Claim a white label license. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * @OA\Get( * path="/api/v1/claim_license", diff --git a/app/Http/Controllers/LogoutController.php b/app/Http/Controllers/LogoutController.php index 33b0091aae2a..65bab6ec08b8 100644 --- a/app/Http/Controllers/LogoutController.php +++ b/app/Http/Controllers/LogoutController.php @@ -52,7 +52,7 @@ class LogoutController extends BaseController * ), * ) * @param Request $request - * @return Response|mixed + * @return Response| \Illuminate\Http\JsonResponse|mixed */ public function index(Request $request) { @@ -64,11 +64,11 @@ class LogoutController extends BaseController ->tokens() ->where('is_system', true) ->cursor() - ->each(function ($ct){ + ->each(function ($ct) { $ct->token = \Illuminate\Support\Str::random(64); $ct->save(); }); - + return response()->json(['message' => 'All tokens deleted'], 200); } } diff --git a/app/Http/Controllers/MigrationController.php b/app/Http/Controllers/MigrationController.php index bb5cc463ba52..85fec16ab097 100644 --- a/app/Http/Controllers/MigrationController.php +++ b/app/Http/Controllers/MigrationController.php @@ -80,7 +80,7 @@ class MigrationController extends BaseController * ), * ) * @param Company $company - * @return \Illuminate\Http\JsonResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response * @throws \Exception */ public function purgeCompany(Company $company) @@ -171,7 +171,7 @@ class MigrationController extends BaseController * ) * @param Request $request * @param Company $company - * @return \Illuminate\Http\JsonResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response */ public function purgeCompanySaveSettings(Request $request, Company $company) { @@ -255,7 +255,7 @@ class MigrationController extends BaseController * ), * ) * @param Request $request - * @return \Illuminate\Http\JsonResponse|void + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response|void */ public function startMigration(Request $request) { diff --git a/app/Http/Controllers/OneTimeTokenController.php b/app/Http/Controllers/OneTimeTokenController.php index 73d355f97bec..6e3f54f2e914 100644 --- a/app/Http/Controllers/OneTimeTokenController.php +++ b/app/Http/Controllers/OneTimeTokenController.php @@ -34,7 +34,7 @@ class OneTimeTokenController extends BaseController * Store a newly created resource in storage. * * @param OneTimeTokenRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * @OA\Post( * path="/api/v1/one_time_token", diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php index 548288c7cfdb..db03e8b6aa7b 100644 --- a/app/Http/Controllers/PaymentController.php +++ b/app/Http/Controllers/PaymentController.php @@ -67,7 +67,7 @@ class PaymentController extends BaseController * * @param PaymentFilters $filters The filters * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -115,7 +115,7 @@ class PaymentController extends BaseController * * @param CreatePaymentRequest $request The request * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -165,7 +165,7 @@ class PaymentController extends BaseController * * @param StorePaymentRequest $request The request * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -222,7 +222,7 @@ class PaymentController extends BaseController * @param ShowPaymentRequest $request The request * @param Payment $payment The invoice * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -277,7 +277,7 @@ class PaymentController extends BaseController * @param EditPaymentRequest $request The request * @param Payment $payment The invoice * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -332,7 +332,7 @@ class PaymentController extends BaseController * @param UpdatePaymentRequest $request The request * @param Payment $payment The invoice * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Put( @@ -454,7 +454,7 @@ class PaymentController extends BaseController /** * Perform bulk actions on the list view. * - * @return \Illuminate\Support\Collection + * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse * * * @OA\Post( @@ -667,7 +667,7 @@ class PaymentController extends BaseController * * @param RefundPaymentRequest $request The request * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -720,7 +720,7 @@ class PaymentController extends BaseController * * @param UploadPaymentRequest $request * @param Payment $payment - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * diff --git a/app/Http/Controllers/PaymentTermController.php b/app/Http/Controllers/PaymentTermController.php index 730ed2b2ce00..ac8c5f1afba1 100644 --- a/app/Http/Controllers/PaymentTermController.php +++ b/app/Http/Controllers/PaymentTermController.php @@ -94,7 +94,7 @@ class PaymentTermController extends BaseController * * @param CreatePaymentTermRequest $request The request * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -142,7 +142,7 @@ class PaymentTermController extends BaseController * * @param StorePaymentTermRequest $request The request * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -236,7 +236,7 @@ class PaymentTermController extends BaseController * ) * @param ShowPaymentTermRequest $request * @param PaymentTerm $payment_term - * @return Response|mixed + * @return Response| \Illuminate\Http\JsonResponse|mixed */ public function show(ShowPaymentTermRequest $request, PaymentTerm $payment_term) { @@ -286,7 +286,7 @@ class PaymentTermController extends BaseController * ) * @param EditPaymentTermRequest $request * @param PaymentTerm $payment_term - * @return Response|mixed + * @return Response| \Illuminate\Http\JsonResponse|mixed */ public function edit(EditPaymentTermRequest $request, PaymentTerm $payment_term) { @@ -299,7 +299,7 @@ class PaymentTermController extends BaseController * @param UpdatePaymentTermRequest $request The request * @param PaymentTerm $payment_term The payment term * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Put( @@ -411,7 +411,7 @@ class PaymentTermController extends BaseController /** * Perform bulk actions on the list view. * - * @return \Illuminate\Support\Collection + * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse * * * @OA\Post( diff --git a/app/Http/Controllers/PingController.php b/app/Http/Controllers/PingController.php index deb848b546df..dd4b675d596d 100644 --- a/app/Http/Controllers/PingController.php +++ b/app/Http/Controllers/PingController.php @@ -20,7 +20,7 @@ class PingController extends BaseController /** * Get a ping response from the system. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * @OA\Get( * path="/api/v1/ping", @@ -55,7 +55,7 @@ class PingController extends BaseController /** * Get a health check of the system. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * @OA\Get( * path="/api/v1/health_check", diff --git a/app/Http/Controllers/PreviewController.php b/app/Http/Controllers/PreviewController.php index 8d47a49637b6..bbfa9b150368 100644 --- a/app/Http/Controllers/PreviewController.php +++ b/app/Http/Controllers/PreviewController.php @@ -146,8 +146,7 @@ class PreviewController extends BaseController if (request()->has('entity') && request()->has('entity_id') && ! empty(request()->input('entity')) && - ! empty(request()->input('entity_id'))) - { + ! empty(request()->input('entity_id'))) { $design_object = json_decode(json_encode(request()->input('design'))); @@ -172,10 +171,9 @@ class PreviewController extends BaseController App::setLocale($entity_obj->client->preferredLocale()); $t->replace(Ninja::transformTranslations($entity_obj->client->getMergedSettings())); - if($entity_obj->client){ + if($entity_obj->client) { $html = new HtmlEngine($entity_obj->invitations()->first()); - } - else { + } else { $html = new VendorHtmlEngine($entity_obj->invitations()->first()); } diff --git a/app/Http/Controllers/ProductController.php b/app/Http/Controllers/ProductController.php index 7c50074616f9..e60351e67bb3 100644 --- a/app/Http/Controllers/ProductController.php +++ b/app/Http/Controllers/ProductController.php @@ -83,7 +83,7 @@ class ProductController extends BaseController * ), * ) * @param ProductFilters $filters - * @return Response|mixed + * @return Response| \Illuminate\Http\JsonResponse|mixed */ public function index(ProductFilters $filters) { @@ -96,7 +96,7 @@ class ProductController extends BaseController * Show the form for creating a new resource. * * @param CreateProductRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -145,7 +145,7 @@ class ProductController extends BaseController * Store a newly created resource in storage. * * @param StoreProductRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -195,7 +195,7 @@ class ProductController extends BaseController * * @param ShowProductRequest $request * @param Product $product - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -249,7 +249,7 @@ class ProductController extends BaseController * * @param EditProductRequest $request * @param Product $product - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * @OA\Get( * path="/api/v1/products/{id}/edit", @@ -302,7 +302,7 @@ class ProductController extends BaseController * * @param UpdateProductRequest $request * @param Product $product - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Put( @@ -362,7 +362,7 @@ class ProductController extends BaseController * * @param DestroyProductRequest $request * @param Product $product - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @throws \Exception @@ -416,7 +416,7 @@ class ProductController extends BaseController /** * Perform bulk actions on the list view. * - * @return \Illuminate\Support\Collection + * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse * * * @OA\Post( @@ -498,7 +498,7 @@ class ProductController extends BaseController * * @param UploadProductRequest $request * @param Product $product - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 4a55e5fb00e3..2559d01adfd1 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -88,7 +88,7 @@ class ProjectController extends BaseController * ), * ) * @param ProjectFilters $filters - * @return Response|mixed + * @return Response| \Illuminate\Http\JsonResponse|mixed */ public function index(ProjectFilters $filters) { @@ -102,7 +102,7 @@ class ProjectController extends BaseController * * @param ShowProjectRequest $request * @param Project $project - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -156,7 +156,7 @@ class ProjectController extends BaseController * * @param EditProjectRequest $request * @param Project $project - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -210,7 +210,7 @@ class ProjectController extends BaseController * * @param UpdateProjectRequest $request * @param Project $project - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -278,7 +278,7 @@ class ProjectController extends BaseController * Show the form for creating a new resource. * * @param CreateProjectRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -326,7 +326,7 @@ class ProjectController extends BaseController * Store a newly created resource in storage. * * @param StoreProjectRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -388,7 +388,7 @@ class ProjectController extends BaseController * * @param DestroyProjectRequest $request * @param Project $project - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @throws \Exception @@ -445,7 +445,7 @@ class ProjectController extends BaseController /** * Perform bulk actions on the list view. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Post( @@ -535,7 +535,7 @@ class ProjectController extends BaseController * * @param UploadProjectRequest $request * @param Project $project - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * @OA\Put( * path="/api/v1/projects/{id}/upload", diff --git a/app/Http/Controllers/PurchaseOrderController.php b/app/Http/Controllers/PurchaseOrderController.php index 44e747d78fcf..2a55a084fd2e 100644 --- a/app/Http/Controllers/PurchaseOrderController.php +++ b/app/Http/Controllers/PurchaseOrderController.php @@ -60,7 +60,7 @@ class PurchaseOrderController extends BaseController * * @param \App\Filters\PurchaseOrderFilters $filters The filters * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * @OA\Get( * path="/api/v1/purchase_orders", @@ -105,7 +105,7 @@ class PurchaseOrderController extends BaseController * * @param CreatePurchaseOrderRequest $request The request * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -153,7 +153,7 @@ class PurchaseOrderController extends BaseController * * @param StorePurchaseOrderRequest $request The request * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Post( @@ -208,7 +208,7 @@ class PurchaseOrderController extends BaseController * @param ShowPurchaseOrderRequest $request The request * @param PurchaseOrder $purchase_order The purchase order * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -262,7 +262,7 @@ class PurchaseOrderController extends BaseController * @param EditPurchaseOrderRequest $request The request * @param PurchaseOrder $purchase_order The purchase order * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * @OA\Get( * path="/api/v1/purchase_orders/{id}/edit", @@ -314,7 +314,7 @@ class PurchaseOrderController extends BaseController * * @param UpdatePurchaseOrderRequest $request The request * @param PurchaseOrder $purchase_order - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @throws \ReflectionException @@ -434,7 +434,7 @@ class PurchaseOrderController extends BaseController /** * Perform bulk actions on the list view. * - * @return \Illuminate\Support\Collection + * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse * * @OA\Post( * path="/api/v1/purchase_orders/bulk", @@ -726,7 +726,7 @@ class PurchaseOrderController extends BaseController * * @param UploadPurchaseOrderRequest $request * @param PurchaseOrder $purchase_order - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * diff --git a/app/Http/Controllers/QuoteController.php b/app/Http/Controllers/QuoteController.php index 1081676e387b..3a03350406ac 100644 --- a/app/Http/Controllers/QuoteController.php +++ b/app/Http/Controllers/QuoteController.php @@ -83,7 +83,7 @@ class QuoteController extends BaseController * Display a listing of the resource. * * @param QuoteFilters $filters - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -128,7 +128,7 @@ class QuoteController extends BaseController * Show the form for creating a new resource. * * @param CreateQuoteRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -178,7 +178,7 @@ class QuoteController extends BaseController * * @param StoreQuoteRequest $request The request * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -235,7 +235,7 @@ class QuoteController extends BaseController * @param ShowQuoteRequest $request The request * @param Quote $quote The quote * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -290,7 +290,7 @@ class QuoteController extends BaseController * @param EditQuoteRequest $request The request * @param Quote $quote The quote * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -345,7 +345,7 @@ class QuoteController extends BaseController * @param UpdateQuoteRequest $request The request * @param Quote $quote The quote * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Put( @@ -465,7 +465,7 @@ class QuoteController extends BaseController /** * Perform bulk actions on the list view. * - * @return \Illuminate\Support\Collection + * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse * * * @OA\Post( @@ -692,7 +692,7 @@ class QuoteController extends BaseController * @param ActionQuoteRequest $request * @param Quote $quote * @param $action - * @return \Illuminate\Http\JsonResponse|Response|mixed|\Symfony\Component\HttpFoundation\StreamedResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response|Response|mixed|\Symfony\Component\HttpFoundation\StreamedResponse */ public function action(ActionQuoteRequest $request, Quote $quote, $action) { @@ -901,7 +901,7 @@ class QuoteController extends BaseController * ), * ) * @param $invitation_key - * @return \Symfony\Component\HttpFoundation\BinaryFileResponse + * @return \Symfony\Component\HttpFoundation\StreamedResponse|\Illuminate\Http\JsonResponse */ public function downloadEQuote($invitation_key) { @@ -934,7 +934,7 @@ class QuoteController extends BaseController * * @param UploadQuoteRequest $request * @param Quote $quote - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * diff --git a/app/Http/Controllers/RecurringExpenseController.php b/app/Http/Controllers/RecurringExpenseController.php index 390caf63cc2d..8d1e93d1606b 100644 --- a/app/Http/Controllers/RecurringExpenseController.php +++ b/app/Http/Controllers/RecurringExpenseController.php @@ -97,7 +97,7 @@ class RecurringExpenseController extends BaseController * ), * ) * @param RecurringExpenseFilters $filters - * @return Response|mixed + * @return Response| \Illuminate\Http\JsonResponse|mixed */ public function index(RecurringExpenseFilters $filters) { @@ -111,7 +111,7 @@ class RecurringExpenseController extends BaseController * * @param ShowRecurringExpenseRequest $request * @param RecurringExpense $recurring_expense - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -165,7 +165,7 @@ class RecurringExpenseController extends BaseController * * @param EditRecurringExpenseRequest $request * @param RecurringExpense $recurring_expense - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -219,7 +219,7 @@ class RecurringExpenseController extends BaseController * * @param UpdateRecurringExpenseRequest $request * @param RecurringExpense $recurring_expense - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -284,7 +284,7 @@ class RecurringExpenseController extends BaseController * Show the form for creating a new resource. * * @param CreateRecurringExpenseRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -332,7 +332,7 @@ class RecurringExpenseController extends BaseController * Store a newly created resource in storage. * * @param StoreRecurringExpenseRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -384,7 +384,7 @@ class RecurringExpenseController extends BaseController * * @param DestroyRecurringExpenseRequest $request * @param RecurringExpense $recurring_expense - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @throws \Exception @@ -438,7 +438,7 @@ class RecurringExpenseController extends BaseController /** * Perform bulk actions on the list view. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Post( @@ -557,7 +557,7 @@ class RecurringExpenseController extends BaseController * * @param UploadRecurringExpenseRequest $request * @param RecurringExpense $recurring_expense - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * diff --git a/app/Http/Controllers/RecurringInvoiceController.php b/app/Http/Controllers/RecurringInvoiceController.php index 3f5e0266e624..9a064edd12bf 100644 --- a/app/Http/Controllers/RecurringInvoiceController.php +++ b/app/Http/Controllers/RecurringInvoiceController.php @@ -70,7 +70,7 @@ class RecurringInvoiceController extends BaseController * * @param RecurringInvoiceFilters $filters The filters * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -117,7 +117,7 @@ class RecurringInvoiceController extends BaseController * * @param CreateRecurringInvoiceRequest $request The request * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -167,7 +167,7 @@ class RecurringInvoiceController extends BaseController * * @param StoreRecurringInvoiceRequest $request The request * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -223,7 +223,7 @@ class RecurringInvoiceController extends BaseController * @param ShowRecurringInvoiceRequest $request The request * @param RecurringInvoice $recurring_invoice The RecurringInvoice * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -278,7 +278,7 @@ class RecurringInvoiceController extends BaseController * @param EditRecurringInvoiceRequest $request The request * @param RecurringInvoice $recurring_invoice The RecurringInvoice * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -333,7 +333,7 @@ class RecurringInvoiceController extends BaseController * @param UpdateRecurringInvoiceRequest $request The request * @param RecurringInvoice $recurring_invoice The RecurringInvoice * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Put( @@ -451,7 +451,7 @@ class RecurringInvoiceController extends BaseController * @param ActionRecurringInvoiceRequest $request * @param RecurringInvoice $recurring_invoice * @param $action - * @return Response|mixed + * @return Response| \Illuminate\Http\JsonResponse|mixed */ public function action(ActionRecurringInvoiceRequest $request, RecurringInvoice $recurring_invoice, $action) { @@ -520,7 +520,7 @@ class RecurringInvoiceController extends BaseController * * @param UploadRecurringInvoiceRequest $request * @param RecurringInvoice $recurring_invoice - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * diff --git a/app/Http/Controllers/RecurringQuoteController.php b/app/Http/Controllers/RecurringQuoteController.php index 52324adf3f5d..b891f3427e40 100644 --- a/app/Http/Controllers/RecurringQuoteController.php +++ b/app/Http/Controllers/RecurringQuoteController.php @@ -66,7 +66,7 @@ class RecurringQuoteController extends BaseController * * @param RecurringQuoteFilters $filters The filters * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -113,7 +113,7 @@ class RecurringQuoteController extends BaseController * * @param CreateRecurringQuoteRequest $request The request * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -161,7 +161,7 @@ class RecurringQuoteController extends BaseController * * @param StoreRecurringQuoteRequest $request The request * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Post( @@ -210,7 +210,7 @@ class RecurringQuoteController extends BaseController * @param ShowRecurringQuoteRequest $request The request * @param RecurringQuote $recurring_quote The RecurringQuote * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -265,7 +265,7 @@ class RecurringQuoteController extends BaseController * @param EditRecurringQuoteRequest $request The request * @param RecurringQuote $recurring_quote The RecurringQuote * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -320,7 +320,7 @@ class RecurringQuoteController extends BaseController * @param UpdateRecurringQuoteRequest $request The request * @param RecurringQuote $recurring_quote The RecurringQuote * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Put( @@ -435,7 +435,7 @@ class RecurringQuoteController extends BaseController /** * Perform bulk actions on the list view. * - * @return \Illuminate\Support\Collection + * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse * * * @OA\Post( diff --git a/app/Http/Controllers/Reports/TaskReportController.php b/app/Http/Controllers/Reports/TaskReportController.php index b381a417e433..5a7c18572608 100644 --- a/app/Http/Controllers/Reports/TaskReportController.php +++ b/app/Http/Controllers/Reports/TaskReportController.php @@ -66,8 +66,7 @@ class TaskReportController extends BaseController /** @var \App\Models\User $user */ $user = auth()->user(); - if ($request->has('send_email') && $request->get('send_email') && $request->missing('output')) - { + if ($request->has('send_email') && $request->get('send_email') && $request->missing('output')) { SendToAdmin::dispatch($user->company(), $request->all(), TaskExport::class, $this->filename); return response()->json(['message' => 'working...'], 200); diff --git a/app/Http/Controllers/SelfUpdateController.php b/app/Http/Controllers/SelfUpdateController.php index de5808b0f120..c5c2f07f2398 100644 --- a/app/Http/Controllers/SelfUpdateController.php +++ b/app/Http/Controllers/SelfUpdateController.php @@ -62,8 +62,9 @@ class SelfUpdateController extends BaseController $file_headers = @get_headers($this->getDownloadUrl()); - if(!is_array($file_headers)) + if(!is_array($file_headers)) { return response()->json(['message' => 'There was a problem reaching the update server, please try again in a little while.'], 410); + } if (stripos($file_headers[0], "404 Not Found") > 0 || (stripos($file_headers[0], "302 Found") > 0 && stripos($file_headers[7], "404 Not Found") > 0)) { return response()->json(['message' => 'Download not yet available. Please try again shortly.'], 410); @@ -100,8 +101,9 @@ class SelfUpdateController extends BaseController } } - if(Storage::disk('base')->directoryExists('resources/lang')) + if(Storage::disk('base')->directoryExists('resources/lang')) { Storage::disk('base')->deleteDirectory('resources/lang'); + } nlog('Removing cache files'); diff --git a/app/Http/Controllers/Shop/ProductController.php b/app/Http/Controllers/Shop/ProductController.php index d4f207241ba7..f5893d9764d4 100644 --- a/app/Http/Controllers/Shop/ProductController.php +++ b/app/Http/Controllers/Shop/ProductController.php @@ -32,7 +32,7 @@ class ProductController extends BaseController * Display a listing of the resource. * * @param Request $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ public function index(Request $request) { diff --git a/app/Http/Controllers/SmtpController.php b/app/Http/Controllers/SmtpController.php index ce84282d8f28..3e1f7f6e378f 100644 --- a/app/Http/Controllers/SmtpController.php +++ b/app/Http/Controllers/SmtpController.php @@ -18,7 +18,6 @@ use Illuminate\Support\Facades\Mail; class SmtpController extends BaseController { - public function __construct() { parent::__construct(); @@ -51,7 +50,7 @@ class SmtpController extends BaseController 'timeout' => 5, ], ]); - + (new \Illuminate\Mail\MailServiceProvider(app()))->register(); try { @@ -60,7 +59,7 @@ class SmtpController extends BaseController $sending_user = (isset($company->settings->email_from_name) && strlen($company->settings->email_from_name) > 2) ? $company->settings->email_from_name : $user->name(); $mailable = new TestMailServer('Email Server Works!', $sending_email); - $mailable->from($sending_email,$sending_user); + $mailable->from($sending_email, $sending_user); Mail::mailer('smtp') ->to($user->email, $user->present()->name()) @@ -68,7 +67,7 @@ class SmtpController extends BaseController } catch (\Exception $e) { app('mail.manager')->forgetMailers(); - return response()->json(['message' => $e->getMessage()], 400); + return response()->json(['message' => $e->getMessage()], 400); } app('mail.manager')->forgetMailers(); @@ -77,4 +76,4 @@ class SmtpController extends BaseController } -} \ No newline at end of file +} diff --git a/app/Http/Controllers/StaticController.php b/app/Http/Controllers/StaticController.php index 0a8f584d1bf2..b01cc0858c40 100644 --- a/app/Http/Controllers/StaticController.php +++ b/app/Http/Controllers/StaticController.php @@ -20,7 +20,7 @@ class StaticController extends BaseController /** * Show the list of Invoices. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * @OA\Get( * path="/api/v1/statics", @@ -59,11 +59,11 @@ class StaticController extends BaseController $response_data = Statics::company($user->getLocale() ?? $user->company()->getLocale()); - if(request()->has('einvoice')){ - + if(request()->has('einvoice')) { + $schema = new Schema(); - $response_data['einvoice_schema'] = $schema('Peppol'); - + $response_data['einvoice_schema'] = $schema('Peppol'); + } return response()->json($response_data, 200, ['Content-type' => 'application/json; charset=utf-8'], JSON_PRETTY_PRINT); diff --git a/app/Http/Controllers/StripeConnectController.php b/app/Http/Controllers/StripeConnectController.php index 0ddc95b57e4c..3ef2c87c9af0 100644 --- a/app/Http/Controllers/StripeConnectController.php +++ b/app/Http/Controllers/StripeConnectController.php @@ -64,7 +64,7 @@ class StripeConnectController extends BaseController if ($request->has('error') && $request->error == 'access_denied') { return view('auth.connect.access_denied'); } - + $response = false; try { @@ -91,7 +91,7 @@ class StripeConnectController extends BaseController } catch (\Exception $e) { - + } if(!$response) { @@ -154,7 +154,7 @@ class StripeConnectController extends BaseController //response here return view('auth.connect.completed', ['url' => $redirect_uri]); - + } } diff --git a/app/Http/Controllers/SubscriptionController.php b/app/Http/Controllers/SubscriptionController.php index ddab4b2cddbe..23d162bce786 100644 --- a/app/Http/Controllers/SubscriptionController.php +++ b/app/Http/Controllers/SubscriptionController.php @@ -420,7 +420,7 @@ class SubscriptionController extends BaseController /** * Perform bulk actions on the list view. * - * @return \Illuminate\Support\Collection + * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse * * * @OA\Post( diff --git a/app/Http/Controllers/SubscriptionStepsController.php b/app/Http/Controllers/SubscriptionStepsController.php index 81243ffbbba4..070960a04392 100644 --- a/app/Http/Controllers/SubscriptionStepsController.php +++ b/app/Http/Controllers/SubscriptionStepsController.php @@ -21,10 +21,10 @@ class SubscriptionStepsController extends BaseController public function index(): JsonResponse { $dependencies = collect(Purchase::$dependencies) - ->map(fn($dependency) => [ + ->map(fn ($dependency) => [ 'id' => $dependency['id'], 'dependencies' => collect($dependency['dependencies']) - ->map(fn($dependency) => Purchase::$dependencies[$dependency]['id']) + ->map(fn ($dependency) => Purchase::$dependencies[$dependency]['id']) ->toArray(), ]) ->toArray(); diff --git a/app/Http/Controllers/Support/Messages/SendingController.php b/app/Http/Controllers/Support/Messages/SendingController.php index 139e73a971d1..ad8646527de4 100644 --- a/app/Http/Controllers/Support/Messages/SendingController.php +++ b/app/Http/Controllers/Support/Messages/SendingController.php @@ -60,7 +60,7 @@ class SendingController extends Controller * ), * ) * @param Request $request - * @return \Illuminate\Http\JsonResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response */ public function __invoke(Request $request) { diff --git a/app/Http/Controllers/SystemLogController.php b/app/Http/Controllers/SystemLogController.php index 4c8f122ffc18..7d8878a65c35 100644 --- a/app/Http/Controllers/SystemLogController.php +++ b/app/Http/Controllers/SystemLogController.php @@ -23,7 +23,7 @@ class SystemLogController extends BaseController * * @param SystemLogFilters $filters The filters * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * @OA\Get( * path="/api/v1/system_logs", @@ -73,7 +73,7 @@ class SystemLogController extends BaseController /** * Show the form for creating a new resource. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ public function create() { @@ -89,7 +89,7 @@ class SystemLogController extends BaseController * Store a newly created resource in storage. * * @param Request $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ public function store(Request $request) { @@ -106,7 +106,7 @@ class SystemLogController extends BaseController * * @param Request $request The request * @param SystemLog $system_log - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -159,7 +159,7 @@ class SystemLogController extends BaseController * Show the form for editing the specified resource. * * @param int $id - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ public function edit($id) { @@ -176,7 +176,7 @@ class SystemLogController extends BaseController * * @param Request $request * @param int $id - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ public function update(Request $request, $id) { @@ -192,7 +192,7 @@ class SystemLogController extends BaseController * Remove the specified resource from storage. * * @param int $id - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ public function destroy($id) { diff --git a/app/Http/Controllers/TaskController.php b/app/Http/Controllers/TaskController.php index f36c78de7bba..642302760850 100644 --- a/app/Http/Controllers/TaskController.php +++ b/app/Http/Controllers/TaskController.php @@ -100,7 +100,7 @@ class TaskController extends BaseController * ), * ) * @param TaskFilters $filters - * @return Response|mixed + * @return Response| \Illuminate\Http\JsonResponse|mixed */ public function index(TaskFilters $filters) { @@ -114,7 +114,7 @@ class TaskController extends BaseController * * @param ShowTaskRequest $request * @param Task $task - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -168,7 +168,7 @@ class TaskController extends BaseController * * @param EditTaskRequest $request * @param Task $task - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -222,7 +222,7 @@ class TaskController extends BaseController * * @param UpdateTaskRequest $request * @param Task $task - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -294,7 +294,7 @@ class TaskController extends BaseController * Show the form for creating a new resource. * * @param CreateTaskRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -342,7 +342,7 @@ class TaskController extends BaseController * Store a newly created resource in storage. * * @param StoreTaskRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -397,7 +397,7 @@ class TaskController extends BaseController * * @param DestroyTaskRequest $request * @param Task $task - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @throws \Exception @@ -452,7 +452,7 @@ class TaskController extends BaseController /** * Perform bulk actions on the list view. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Post( @@ -542,7 +542,7 @@ class TaskController extends BaseController * * @param UploadTaskRequest $request * @param Task $task - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -604,7 +604,7 @@ class TaskController extends BaseController * Store a newly created resource in storage. * * @param SortTaskRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * diff --git a/app/Http/Controllers/TaskStatusController.php b/app/Http/Controllers/TaskStatusController.php index c6680bc64d8b..a6925564d04a 100644 --- a/app/Http/Controllers/TaskStatusController.php +++ b/app/Http/Controllers/TaskStatusController.php @@ -55,7 +55,7 @@ class TaskStatusController extends BaseController * index * * @param TaskStatusFilters $filters - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ public function index(TaskStatusFilters $filters) { @@ -69,7 +69,7 @@ class TaskStatusController extends BaseController * create * * @param CreateTaskStatusRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ public function create(CreateTaskStatusRequest $request) { @@ -85,7 +85,7 @@ class TaskStatusController extends BaseController * Store a newly created resource in storage. * * @param StoreTaskStatusRequest $request The request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function store(StoreTaskStatusRequest $request) @@ -104,7 +104,7 @@ class TaskStatusController extends BaseController /** * @param ShowTaskStatusRequest $request * @param TaskStatus $task_status - * @return Response|mixed + * @return Response| \Illuminate\Http\JsonResponse|mixed */ public function show(ShowTaskStatusRequest $request, TaskStatus $task_status) { @@ -114,7 +114,7 @@ class TaskStatusController extends BaseController /** * @param EditTaskStatusRequest $request * @param TaskStatus $payment - * @return Response|mixed + * @return Response| \Illuminate\Http\JsonResponse|mixed */ public function edit(EditTaskStatusRequest $request, TaskStatus $payment) { @@ -126,7 +126,7 @@ class TaskStatusController extends BaseController * * @param UpdateTaskStatusRequest $request The request * @param TaskStatus $task_status The payment term - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ public function update(UpdateTaskStatusRequest $request, TaskStatus $task_status) { @@ -148,7 +148,7 @@ class TaskStatusController extends BaseController * * @param DestroyTaskStatusRequest $request * @param TaskStatus $task_status - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * @throws \Exception */ @@ -162,7 +162,7 @@ class TaskStatusController extends BaseController /** * Perform bulk actions on the list view. * @param ActionTaskStatusRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ public function bulk(ActionTaskStatusRequest $request) { diff --git a/app/Http/Controllers/TaxRateController.php b/app/Http/Controllers/TaxRateController.php index acad06c679ec..640bf1c79e83 100644 --- a/app/Http/Controllers/TaxRateController.php +++ b/app/Http/Controllers/TaxRateController.php @@ -77,7 +77,7 @@ class TaxRateController extends BaseController * * Display a listing of the resource. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ public function index(TaxRateFilters $filters) { @@ -90,7 +90,7 @@ class TaxRateController extends BaseController * Show the form for creating a new resource. * * @param CreateTaxRateRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -137,7 +137,7 @@ class TaxRateController extends BaseController * Store a newly created resource in storage. * * @param StoreTaxRateRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ public function store(StoreTaxRateRequest $request) { @@ -156,7 +156,7 @@ class TaxRateController extends BaseController * * @param ShowTaxRateRequest $request * @param TaxRate $tax_rate - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -209,7 +209,7 @@ class TaxRateController extends BaseController * * @param EditTaxRateRequest $request * @param TaxRate $tax_rate - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -262,7 +262,7 @@ class TaxRateController extends BaseController * * @param UpdateTaxRateRequest $request * @param TaxRate $tax_rate - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -319,7 +319,7 @@ class TaxRateController extends BaseController * * @param DestroyTaxRateRequest $request * @param TaxRate $tax_rate - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @throws \Exception @@ -374,7 +374,7 @@ class TaxRateController extends BaseController /** * Perform bulk actions on the list view. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Post( diff --git a/app/Http/Controllers/TemplateController.php b/app/Http/Controllers/TemplateController.php index a672c837184d..fa28e9b701d5 100644 --- a/app/Http/Controllers/TemplateController.php +++ b/app/Http/Controllers/TemplateController.php @@ -31,7 +31,7 @@ class TemplateController extends BaseController /** * Returns a template filled with entity variables. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * @OA\Post( * path="/api/v1/templates", diff --git a/app/Http/Controllers/TokenController.php b/app/Http/Controllers/TokenController.php index 7acf8c8f47b9..b5bd8ce3566c 100644 --- a/app/Http/Controllers/TokenController.php +++ b/app/Http/Controllers/TokenController.php @@ -87,7 +87,7 @@ class TokenController extends BaseController * ), * ) * @param TokenFilters $filters - * @return Response|mixed + * @return Response| \Illuminate\Http\JsonResponse|mixed */ public function index(TokenFilters $filters) { @@ -103,7 +103,7 @@ class TokenController extends BaseController * * @param ShowTokenRequest $request * @param CompanyToken $token - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -157,7 +157,7 @@ class TokenController extends BaseController * * @param EditTokenRequest $request * @param CompanyToken $token - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -213,7 +213,7 @@ class TokenController extends BaseController * * @param UpdateTokenRequest $request * @param CompanyToken $token - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -275,7 +275,7 @@ class TokenController extends BaseController * Show the form for creating a new resource. * * @param CreateTokenRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -324,7 +324,7 @@ class TokenController extends BaseController * Store a newly created resource in storage. * * @param StoreTokenRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -376,7 +376,7 @@ class TokenController extends BaseController * * @param DestroyTokenRequest $request * @param CompanyToken $token - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @throws \Exception @@ -433,7 +433,7 @@ class TokenController extends BaseController /** * Perform bulk actions on the list view. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Post( diff --git a/app/Http/Controllers/Traits/VerifiesUserEmail.php b/app/Http/Controllers/Traits/VerifiesUserEmail.php index 33355c9daadb..42e134c89b8e 100644 --- a/app/Http/Controllers/Traits/VerifiesUserEmail.php +++ b/app/Http/Controllers/Traits/VerifiesUserEmail.php @@ -28,7 +28,7 @@ trait VerifiesUserEmail use MakesHash; /** - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function confirm() { diff --git a/app/Http/Controllers/TwilioController.php b/app/Http/Controllers/TwilioController.php index 8efb09a7135d..126ce23ea0fe 100644 --- a/app/Http/Controllers/TwilioController.php +++ b/app/Http/Controllers/TwilioController.php @@ -34,7 +34,7 @@ class TwilioController extends BaseController /** * Display a listing of the resource. * - * @return \Illuminate\Http\JsonResponse; + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response; */ public function generate(GenerateSmsRequest $request) { @@ -94,7 +94,7 @@ class TwilioController extends BaseController /** * Show the form for creating a new resource. * - * @return \Illuminate\Http\JsonResponse; + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response; */ public function confirm(ConfirmSmsRequest $request) { @@ -143,7 +143,7 @@ class TwilioController extends BaseController /** * generate2faResetCode * - * @return \Illuminate\Http\JsonResponse; + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response; */ public function generate2faResetCode(Generate2faRequest $request) { @@ -193,7 +193,7 @@ class TwilioController extends BaseController * confirm2faResetCode * * @param Confirm2faRequest $request - * @return \Illuminate\Http\JsonResponse; + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response; */ public function confirm2faResetCode(Confirm2faRequest $request) { diff --git a/app/Http/Controllers/TwoFactorController.php b/app/Http/Controllers/TwoFactorController.php index 3d387bdf3f6a..1707ff2d9e30 100644 --- a/app/Http/Controllers/TwoFactorController.php +++ b/app/Http/Controllers/TwoFactorController.php @@ -72,7 +72,7 @@ class TwoFactorController extends BaseController return response()->json(['message' => ctrans('texts.enabled_two_factor')], 200); } elseif (! $secret || ! $google2fa->verifyKey($secret, $oneTimePassword)) { return response()->json(['message' => ctrans('texts.invalid_one_time_password')], 400); - }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 a1bf7bf17bf5..41b6a2f91296 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -67,7 +67,7 @@ class UserController extends BaseController * Display a listing of the resource. * * @param UserFilters $filters - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function index(UserFilters $filters) @@ -81,7 +81,7 @@ class UserController extends BaseController * Show the form for creating a new resource. * * @param CreateUserRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function create(CreateUserRequest $request) @@ -95,7 +95,7 @@ class UserController extends BaseController * Store a newly created resource in storage. * * @param StoreUserRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function store(StoreUserRequest $request) @@ -126,7 +126,7 @@ class UserController extends BaseController * * @param ShowUserRequest $request * @param User $user - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function show(ShowUserRequest $request, User $user) @@ -139,7 +139,7 @@ class UserController extends BaseController * * @param EditUserRequest $request * @param User $user - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function edit(EditUserRequest $request, User $user) @@ -152,7 +152,7 @@ class UserController extends BaseController * * @param UpdateUserRequest $request * @param User $user - * @return Response|mixed + * @return Response| \Illuminate\Http\JsonResponse|mixed */ public function update(UpdateUserRequest $request, User $user) { @@ -191,7 +191,7 @@ class UserController extends BaseController * * @param DestroyUserRequest $request * @param User $user - * @return \Illuminate\Http\JsonResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response * */ public function destroy(DestroyUserRequest $request, User $user) @@ -214,7 +214,7 @@ class UserController extends BaseController /** * Perform bulk actions on the list view. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * */ public function bulk(BulkUserRequest $request) @@ -253,14 +253,14 @@ class UserController extends BaseController * * @param DetachCompanyUserRequest $request * @param User $user - * @return \Illuminate\Http\JsonResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response */ public function detach(DetachCompanyUserRequest $request, User $user) { /** @var \App\Models\User $logged_in_user */ $logged_in_user = auth()->user(); - $company_user = CompanyUser::where('user_id',$user->id) + $company_user = CompanyUser::where('user_id', $user->id) ->where('company_id', $logged_in_user->companyId()) ->withTrashed() ->first(); @@ -283,7 +283,7 @@ class UserController extends BaseController * * @param ReconfirmUserRequest $request * @param User $user - * @return \Illuminate\Http\JsonResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response */ public function invite(ReconfirmUserRequest $request, User $user) { @@ -301,7 +301,7 @@ class UserController extends BaseController * * @param ReconfirmUserRequest $request * @param User $user - * @return \Illuminate\Http\JsonResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response */ public function reconfirm(ReconfirmUserRequest $request, User $user) { diff --git a/app/Http/Controllers/VendorController.php b/app/Http/Controllers/VendorController.php index 353f80209722..a24602069871 100644 --- a/app/Http/Controllers/VendorController.php +++ b/app/Http/Controllers/VendorController.php @@ -96,7 +96,7 @@ class VendorController extends BaseController * ), * ) * @param VendorFilters $filters - * @return Response|mixed + * @return Response| \Illuminate\Http\JsonResponse|mixed */ public function index(VendorFilters $filters) { @@ -110,7 +110,7 @@ class VendorController extends BaseController * * @param ShowVendorRequest $request * @param Vendor $vendor - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -164,7 +164,7 @@ class VendorController extends BaseController * * @param EditVendorRequest $request * @param Vendor $vendor - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -218,7 +218,7 @@ class VendorController extends BaseController * * @param UpdateVendorRequest $request * @param Vendor $vendor - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -284,7 +284,7 @@ class VendorController extends BaseController * Show the form for creating a new resource. * * @param CreateVendorRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -333,7 +333,7 @@ class VendorController extends BaseController * Store a newly created resource in storage. * * @param StoreVendorRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -391,7 +391,7 @@ class VendorController extends BaseController * * @param DestroyVendorRequest $request * @param Vendor $vendor - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @throws \Exception @@ -446,7 +446,7 @@ class VendorController extends BaseController /** * Perform bulk actions on the list view. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Post( @@ -527,7 +527,7 @@ class VendorController extends BaseController * * @param UploadVendorRequest $request * @param Vendor $vendor - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * diff --git a/app/Http/Controllers/VendorPortal/UploadController.php b/app/Http/Controllers/VendorPortal/UploadController.php index bc2c6fe2726f..2d6a3fdebd2b 100644 --- a/app/Http/Controllers/VendorPortal/UploadController.php +++ b/app/Http/Controllers/VendorPortal/UploadController.php @@ -29,7 +29,7 @@ class UploadController extends Controller * Main logic behind uploading the files. * * @param StoreUploadRequest $request - * @return Response|ResponseFactory + * @return Response| \Illuminate\Http\JsonResponse|ResponseFactory */ public function upload(StoreUploadRequest $request, PurchaseOrder $purchase_order) { diff --git a/app/Http/Controllers/WebCronController.php b/app/Http/Controllers/WebCronController.php index aeb92cc7fb69..4a7fe11d837a 100644 --- a/app/Http/Controllers/WebCronController.php +++ b/app/Http/Controllers/WebCronController.php @@ -23,7 +23,7 @@ class WebCronController extends Controller /** * Store a newly created resource in storage. * - * @return \Illuminate\Http\JsonResponse + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response * * @OA\Get( * path="/webcron", diff --git a/app/Http/Controllers/WebhookController.php b/app/Http/Controllers/WebhookController.php index 8c12effcc204..972e6f76fd6d 100644 --- a/app/Http/Controllers/WebhookController.php +++ b/app/Http/Controllers/WebhookController.php @@ -79,7 +79,7 @@ class WebhookController extends BaseController * ), * ) * @param WebhookFilters $filters - * @return Response|mixed + * @return Response| \Illuminate\Http\JsonResponse|mixed */ public function index(WebhookFilters $filters) { @@ -93,7 +93,7 @@ class WebhookController extends BaseController * * @param ShowWebhookRequest $request * @param Webhook $webhook - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -147,7 +147,7 @@ class WebhookController extends BaseController * * @param EditWebhookRequest $request * @param Webhook $webhook - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Get( @@ -201,7 +201,7 @@ class WebhookController extends BaseController * * @param UpdateWebhookRequest $request * @param Webhook $webhook - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -262,7 +262,7 @@ class WebhookController extends BaseController * Show the form for creating a new resource. * * @param CreateWebhookRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -312,7 +312,7 @@ class WebhookController extends BaseController * Store a newly created resource in storage. * * @param StoreWebhookRequest $request - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @@ -378,7 +378,7 @@ class WebhookController extends BaseController * * @param DestroyWebhookRequest $request * @param Webhook $webhook - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @throws \Exception @@ -433,7 +433,7 @@ class WebhookController extends BaseController /** * Perform bulk actions on the list view. * - * @return Response + * @return Response| \Illuminate\Http\JsonResponse * * * @OA\Post( diff --git a/app/Http/Middleware/CheckClientExistence.php b/app/Http/Middleware/CheckClientExistence.php index 8b8977a0048e..34a3666e4fdb 100644 --- a/app/Http/Middleware/CheckClientExistence.php +++ b/app/Http/Middleware/CheckClientExistence.php @@ -32,8 +32,10 @@ class CheckClientExistence return $next($request); } + auth()->guard('contact')->user()->loadMissing(['company']); // @phpstan-ignore method.notFound + $multiple_contacts = ClientContact::query() - ->with('client.gateway_tokens', 'company') + // ->with('client.gateway_tokens', 'company') ->where('email', auth()->guard('contact')->user()->email) ->whereNotNull('email') ->where('email', '<>', '') @@ -56,6 +58,11 @@ class CheckClientExistence if (count($multiple_contacts) == 1 && ! Auth::guard('contact')->check()) { Auth::guard('contact')->loginUsingId($multiple_contacts[0]->id, true); + + auth()->guard('contact')->user()->loadMissing(['client' => function ($query) { + $query->without('gateway_tokens', 'documents', 'contacts.company', 'contacts'); // Exclude 'grandchildren' relation of 'client' + }]); + } session()->put('multiple_contacts', $multiple_contacts); diff --git a/app/Http/Middleware/ClientPortalEnabled.php b/app/Http/Middleware/ClientPortalEnabled.php index f4562eca670b..93027d6b9691 100644 --- a/app/Http/Middleware/ClientPortalEnabled.php +++ b/app/Http/Middleware/ClientPortalEnabled.php @@ -25,10 +25,12 @@ class ClientPortalEnabled */ public function handle($request, Closure $next) { - /** @var \App\Models\ClientContact $client_contact */ - $client_contact = auth()->user(); - if ($client_contact->client->getSetting('enable_client_portal') === false) { + auth()->guard('contact')->user()->loadMissing(['client' => function ($query) { + $query->without('gateway_tokens', 'documents', 'contacts.company', 'contacts'); // Exclude 'grandchildren' relation of 'client' + }]); + + if (auth()->guard('contact')->user()->client->getSetting('enable_client_portal') === false) { return redirect()->route('client.error')->with(['title' => ctrans('texts.client_portal'), 'notification' => 'This section of the app has been disabled by the administrator.']); } diff --git a/app/Http/Middleware/ContactKeyLogin.php b/app/Http/Middleware/ContactKeyLogin.php index ce3711dbccc0..a35c4f351642 100644 --- a/app/Http/Middleware/ContactKeyLogin.php +++ b/app/Http/Middleware/ContactKeyLogin.php @@ -162,7 +162,7 @@ class ContactKeyLogin private function setRedirectPath() { if (auth()->guard('contact')->user()->client->getSetting('enable_client_portal_dashboard') === true) { - return '/client/dashboard'; + return '/client/dashboard'; } elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES) { return '/client/invoices'; } elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES) { diff --git a/app/Http/Middleware/Locale.php b/app/Http/Middleware/Locale.php index 0fbd44ab7f6f..f95be219c7fc 100644 --- a/app/Http/Middleware/Locale.php +++ b/app/Http/Middleware/Locale.php @@ -69,15 +69,23 @@ class Locale */ public function handle($request, Closure $next) { + + /*LOCALE SET */ if ($request->has('lang') && in_array($request->input('lang', 'en'), $this->locales)) { $locale = $request->input('lang'); App::setLocale($locale); } elseif (auth()->guard('contact')->user()) { - App::setLocale(auth()->guard('contact')->user()->client()->setEagerLoads([])->first()->locale()); + + auth()->guard('contact')->user()->loadMissing(['client' => function ($query) { // @phpstan-ignore method.undefined + $query->without('gateway_tokens', 'documents', 'contacts.company', 'contacts'); // Exclude 'grandchildren' relation of 'client' + }]); + + App::setLocale(auth()->guard('contact')->user()->client->locale()); } elseif (auth()->user()) { try { - App::setLocale(auth()->user()->company()->getLocale()); + App::setLocale(auth()->user()->company()->getLocale()); // @phpstan-ignore method.undefined + } catch (\Exception $e) { } } else { diff --git a/app/Http/Middleware/QueryLogging.php b/app/Http/Middleware/QueryLogging.php index efe0ef707702..2bafda5c41ec 100644 --- a/app/Http/Middleware/QueryLogging.php +++ b/app/Http/Middleware/QueryLogging.php @@ -78,13 +78,11 @@ class QueryLogging if ($request->hasHeader('X-CLIENT-PLATFORM')) { $platform = $request->header('X-CLIENT-PLATFORM'); - } - elseif($request->hasHeader('X-React')){ + } elseif($request->hasHeader('X-React')) { $platform = 'react'; } - if ($request->hasHeader('X-CLIENT-VERSION')) - { + if ($request->hasHeader('X-CLIENT-VERSION')) { $client_version = $request->header('X-CLIENT-VERSION'); } diff --git a/app/Http/Requests/BankTransaction/StoreBankTransactionRequest.php b/app/Http/Requests/BankTransaction/StoreBankTransactionRequest.php index 55deb420ab4a..80ecf6c6b36a 100644 --- a/app/Http/Requests/BankTransaction/StoreBankTransactionRequest.php +++ b/app/Http/Requests/BankTransaction/StoreBankTransactionRequest.php @@ -55,7 +55,7 @@ class StoreBankTransactionRequest extends Request $input['bank_integration_id'] = $this->decodePrimaryKey($input['bank_integration_id']); } - + $this->replace($input); } } diff --git a/app/Http/Requests/Client/BulkClientRequest.php b/app/Http/Requests/Client/BulkClientRequest.php index 31870f0e2752..7cab86724ca5 100644 --- a/app/Http/Requests/Client/BulkClientRequest.php +++ b/app/Http/Requests/Client/BulkClientRequest.php @@ -18,7 +18,7 @@ use Illuminate\Validation\Rule; class BulkClientRequest extends Request { use MakesHash; - + /** * Determine if the user is authorized to make this request. * diff --git a/app/Http/Requests/Client/StoreClientRequest.php b/app/Http/Requests/Client/StoreClientRequest.php index 72afa16e4bc5..f1d4c84518f4 100644 --- a/app/Http/Requests/Client/StoreClientRequest.php +++ b/app/Http/Requests/Client/StoreClientRequest.php @@ -48,8 +48,7 @@ class StoreClientRequest extends Request $rules['documents.*'] = $this->fileValidation(); } elseif ($this->file('documents')) { $rules['documents'] = $this->fileValidation(); - } - else { + } else { $rules['documents'] = 'bail|sometimes|array'; } @@ -133,11 +132,9 @@ class StoreClientRequest extends Request } else { $input['settings']['currency_id'] = (string) $user->company()->settings->currency_id; } - } - elseif (! array_key_exists('currency_id', $input['settings'])) { + } elseif (! array_key_exists('currency_id', $input['settings'])) { $input['settings']['currency_id'] = (string) $user->company()->settings->currency_id; - } - elseif (empty($input['settings']['currency_id']) ?? true) { + } elseif (empty($input['settings']['currency_id']) ?? true) { $input['settings']['currency_id'] = (string) $user->company()->settings->currency_id; } diff --git a/app/Http/Requests/Client/UpdateClientRequest.php b/app/Http/Requests/Client/UpdateClientRequest.php index bf057bf113ea..1378b239ed41 100644 --- a/app/Http/Requests/Client/UpdateClientRequest.php +++ b/app/Http/Requests/Client/UpdateClientRequest.php @@ -105,8 +105,7 @@ class UpdateClientRequest extends Request /* If the user removes the currency we must always set the default */ if (array_key_exists('settings', $input) && ! array_key_exists('currency_id', $input['settings'])) { $input['settings']['currency_id'] = (string) $user->company()->settings->currency_id; - } - elseif (empty($input['settings']['currency_id']) ?? true) { + } elseif (empty($input['settings']['currency_id']) ?? true) { $input['settings']['currency_id'] = (string) $user->company()->settings->currency_id; } diff --git a/app/Http/Requests/ClientPortal/Credits/ShowCreditRequest.php b/app/Http/Requests/ClientPortal/Credits/ShowCreditRequest.php index dee356bad22c..19abb31bd009 100644 --- a/app/Http/Requests/ClientPortal/Credits/ShowCreditRequest.php +++ b/app/Http/Requests/ClientPortal/Credits/ShowCreditRequest.php @@ -14,6 +14,8 @@ class ShowCreditRequest extends FormRequest */ public function authorize() { + auth()->guard('contact')->user()->loadMissing(['company']); + return ! $this->credit->is_deleted && auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_CREDITS && auth()->guard('contact')->user()->client_id === $this->credit->client_id; diff --git a/app/Http/Requests/ClientPortal/Invoices/ProcessInvoicesInBulkRequest.php b/app/Http/Requests/ClientPortal/Invoices/ProcessInvoicesInBulkRequest.php index 0171c66d19d9..59469b2f891f 100644 --- a/app/Http/Requests/ClientPortal/Invoices/ProcessInvoicesInBulkRequest.php +++ b/app/Http/Requests/ClientPortal/Invoices/ProcessInvoicesInBulkRequest.php @@ -19,6 +19,9 @@ class ProcessInvoicesInBulkRequest extends FormRequest { public function authorize() { + + auth()->guard('contact')->user()->loadMissing(['company']); + return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES; } diff --git a/app/Http/Requests/ClientPortal/Invoices/ShowInvoiceRequest.php b/app/Http/Requests/ClientPortal/Invoices/ShowInvoiceRequest.php index dc31612cb86a..27c55d602a4a 100644 --- a/app/Http/Requests/ClientPortal/Invoices/ShowInvoiceRequest.php +++ b/app/Http/Requests/ClientPortal/Invoices/ShowInvoiceRequest.php @@ -23,6 +23,9 @@ class ShowInvoiceRequest extends Request */ public function authorize(): bool { + + auth()->guard('contact')->user()->loadMissing(['company']); + return (int) auth()->guard('contact')->user()->client_id === (int) $this->invoice->client_id && auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES; } diff --git a/app/Http/Requests/ClientPortal/Invoices/ShowInvoicesRequest.php b/app/Http/Requests/ClientPortal/Invoices/ShowInvoicesRequest.php index b74e4c7dda1f..872da16d6699 100644 --- a/app/Http/Requests/ClientPortal/Invoices/ShowInvoicesRequest.php +++ b/app/Http/Requests/ClientPortal/Invoices/ShowInvoicesRequest.php @@ -19,6 +19,9 @@ class ShowInvoicesRequest extends FormRequest { public function authorize() { + + auth()->guard('contact')->user()->loadMissing(['company']); + return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES; } diff --git a/app/Http/Requests/ClientPortal/PaymentMethod/CreatePaymentMethodRequest.php b/app/Http/Requests/ClientPortal/PaymentMethod/CreatePaymentMethodRequest.php index 76ffa929dfd7..272e8e1bf2e2 100644 --- a/app/Http/Requests/ClientPortal/PaymentMethod/CreatePaymentMethodRequest.php +++ b/app/Http/Requests/ClientPortal/PaymentMethod/CreatePaymentMethodRequest.php @@ -18,6 +18,11 @@ class CreatePaymentMethodRequest extends FormRequest */ public function authorize(): bool { + + auth()->guard('contact')->user()->loadMissing(['client' => function ($query) { + $query->without('gateway_tokens', 'documents', 'contacts.company', 'contacts'); // Exclude 'grandchildren' relation of 'client' + }]); + /** @var Client $client */ $client = auth()->guard('contact')->user()->client; diff --git a/app/Http/Requests/ClientPortal/PrePayments/StorePrePaymentRequest.php b/app/Http/Requests/ClientPortal/PrePayments/StorePrePaymentRequest.php index 4f304bb1b811..5a5c8d7be439 100644 --- a/app/Http/Requests/ClientPortal/PrePayments/StorePrePaymentRequest.php +++ b/app/Http/Requests/ClientPortal/PrePayments/StorePrePaymentRequest.php @@ -15,6 +15,13 @@ class StorePrePaymentRequest extends FormRequest */ public function authorize() { + + auth()->guard('contact')->user()->loadMissing(['company']); + + auth()->guard('contact')->user()->loadMissing(['client' => function ($query) { + $query->without('gateway_tokens', 'documents', 'contacts.company', 'contacts'); // Exclude 'grandchildren' relation of 'client' + }]); + return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES; } diff --git a/app/Http/Requests/ClientPortal/Quotes/ProcessQuotesInBulkRequest.php b/app/Http/Requests/ClientPortal/Quotes/ProcessQuotesInBulkRequest.php index b168babfccf9..502eb5d3c3a8 100644 --- a/app/Http/Requests/ClientPortal/Quotes/ProcessQuotesInBulkRequest.php +++ b/app/Http/Requests/ClientPortal/Quotes/ProcessQuotesInBulkRequest.php @@ -21,6 +21,9 @@ class ProcessQuotesInBulkRequest extends FormRequest { public function authorize() { + + auth()->guard('contact')->user()->loadMissing(['company']); + return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES; } diff --git a/app/Http/Requests/ClientPortal/Quotes/ShowQuoteRequest.php b/app/Http/Requests/ClientPortal/Quotes/ShowQuoteRequest.php index 70a01b8e0b92..7643ec213e68 100644 --- a/app/Http/Requests/ClientPortal/Quotes/ShowQuoteRequest.php +++ b/app/Http/Requests/ClientPortal/Quotes/ShowQuoteRequest.php @@ -19,6 +19,9 @@ class ShowQuoteRequest extends FormRequest { public function authorize() { + + auth()->guard('contact')->user()->loadMissing(['company']); + return auth()->guard('contact')->user()->client->id === (int) $this->quote->client_id && auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES; } diff --git a/app/Http/Requests/ClientPortal/Quotes/ShowQuotesRequest.php b/app/Http/Requests/ClientPortal/Quotes/ShowQuotesRequest.php index 4a244cd05596..87f4ccd70d9b 100644 --- a/app/Http/Requests/ClientPortal/Quotes/ShowQuotesRequest.php +++ b/app/Http/Requests/ClientPortal/Quotes/ShowQuotesRequest.php @@ -19,6 +19,9 @@ class ShowQuotesRequest extends FormRequest { public function authorize() { + + auth()->guard('contact')->user()->loadMissing(['company']); + return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_QUOTES; } diff --git a/app/Http/Requests/ClientPortal/RecurringInvoices/RequestCancellationRequest.php b/app/Http/Requests/ClientPortal/RecurringInvoices/RequestCancellationRequest.php index 25acacd46d1d..418c91493950 100644 --- a/app/Http/Requests/ClientPortal/RecurringInvoices/RequestCancellationRequest.php +++ b/app/Http/Requests/ClientPortal/RecurringInvoices/RequestCancellationRequest.php @@ -9,6 +9,9 @@ class RequestCancellationRequest extends FormRequest { public function authorize() { + + auth()->guard('contact')->user()->loadMissing(['company']); + return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES; } diff --git a/app/Http/Requests/ClientPortal/RecurringInvoices/ShowRecurringInvoiceRequest.php b/app/Http/Requests/ClientPortal/RecurringInvoices/ShowRecurringInvoiceRequest.php index 6a2649661660..a060215d8baa 100644 --- a/app/Http/Requests/ClientPortal/RecurringInvoices/ShowRecurringInvoiceRequest.php +++ b/app/Http/Requests/ClientPortal/RecurringInvoices/ShowRecurringInvoiceRequest.php @@ -18,6 +18,8 @@ class ShowRecurringInvoiceRequest extends Request { public function authorize(): bool { + auth()->guard('contact')->user()->loadMissing(['company']); + return auth()->guard('contact')->user()->client->id == $this->recurring_invoice->client_id && auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES; } diff --git a/app/Http/Requests/ClientPortal/RecurringInvoices/ShowRecurringInvoicesRequest.php b/app/Http/Requests/ClientPortal/RecurringInvoices/ShowRecurringInvoicesRequest.php index ab2378ecc5d3..5cde35b30c2c 100644 --- a/app/Http/Requests/ClientPortal/RecurringInvoices/ShowRecurringInvoicesRequest.php +++ b/app/Http/Requests/ClientPortal/RecurringInvoices/ShowRecurringInvoicesRequest.php @@ -19,6 +19,8 @@ class ShowRecurringInvoicesRequest extends FormRequest { public function authorize() { + auth()->guard('contact')->user()->loadMissing(['company']); + return auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES; } diff --git a/app/Http/Requests/ClientPortal/Tasks/ShowTasksRequest.php b/app/Http/Requests/ClientPortal/Tasks/ShowTasksRequest.php index edd6097caa11..143ef60e21aa 100644 --- a/app/Http/Requests/ClientPortal/Tasks/ShowTasksRequest.php +++ b/app/Http/Requests/ClientPortal/Tasks/ShowTasksRequest.php @@ -23,6 +23,11 @@ class ShowTasksRequest extends FormRequest */ public function authorize() { + + auth()->guard('contact')->user()->loadMissing(['client' => function ($query) { + $query->without('gateway_tokens', 'documents', 'contacts.company', 'contacts'); // Exclude 'grandchildren' relation of 'client' + }]); + return (bool) auth()->guard('contact')->user()->client->getSetting('enable_client_portal_tasks'); } diff --git a/app/Http/Requests/ClientPortal/Uploads/StoreUploadRequest.php b/app/Http/Requests/ClientPortal/Uploads/StoreUploadRequest.php index 10680342201b..50369aa5c99f 100644 --- a/app/Http/Requests/ClientPortal/Uploads/StoreUploadRequest.php +++ b/app/Http/Requests/ClientPortal/Uploads/StoreUploadRequest.php @@ -22,6 +22,12 @@ class StoreUploadRequest extends FormRequest */ public function authorize() { + + /** @phpstan-ignore-next-line **/ + auth()->guard('contact')->user()->loadMissing(['client' => function ($query) { + $query->without('gateway_tokens', 'documents', 'contacts.company', 'contacts'); // Exclude 'grandchildren' relation of 'client' + }]); + return (bool) auth()->guard('contact')->user()->client->getSetting('client_portal_enable_uploads'); } diff --git a/app/Http/Requests/Company/StoreCompanyRequest.php b/app/Http/Requests/Company/StoreCompanyRequest.php index 7b87278183e6..6db6cce58c75 100644 --- a/app/Http/Requests/Company/StoreCompanyRequest.php +++ b/app/Http/Requests/Company/StoreCompanyRequest.php @@ -59,7 +59,7 @@ class StoreCompanyRequest extends Request $rules['smtp_host'] = 'sometimes|string|nullable'; $rules['smtp_port'] = 'sometimes|integer|nullable'; $rules['smtp_encryption'] = 'sometimes|string'; - $rules['smtp_local_domain'] = 'sometimes|string|nullable'; + $rules['smtp_local_domain'] = 'sometimes|string|nullable'; $rules['smtp_encryption'] = 'sometimes|string|nullable'; $rules['smtp_local_domain'] = 'sometimes|string|nullable'; @@ -100,8 +100,9 @@ class StoreCompanyRequest extends Request $input['smtp_port'] = (int) $input['smtp_port']; } - if(isset($input['smtp_verify_peer']) && is_string($input['smtp_verify_peer'])) + if(isset($input['smtp_verify_peer']) && is_string($input['smtp_verify_peer'])) { $input['smtp_verify_peer'] == 'true' ? true : false; + } $this->replace($input); } diff --git a/app/Http/Requests/Company/UpdateCompanyRequest.php b/app/Http/Requests/Company/UpdateCompanyRequest.php index dd4adc5ca8a7..be71818dd8d7 100644 --- a/app/Http/Requests/Company/UpdateCompanyRequest.php +++ b/app/Http/Requests/Company/UpdateCompanyRequest.php @@ -64,7 +64,7 @@ class UpdateCompanyRequest extends Request $rules['smtp_local_domain'] = 'sometimes|string|nullable'; // $rules['smtp_verify_peer'] = 'sometimes|string'; - + if (isset($input['portal_mode']) && ($input['portal_mode'] == 'domain' || $input['portal_mode'] == 'iframe')) { $rules['portal_domain'] = 'bail|nullable|sometimes|url'; } @@ -97,14 +97,14 @@ class UpdateCompanyRequest extends Request unset($input['e_invoice_certificate_passphrase']); } - if(isset($input['smtp_username']) && strlen(str_replace("*","", $input['smtp_username'])) < 2) { + if(isset($input['smtp_username']) && strlen(str_replace("*", "", $input['smtp_username'])) < 2) { unset($input['smtp_username']); } if(isset($input['smtp_password']) && strlen(str_replace("*", "", $input['smtp_password'])) < 2) { unset($input['smtp_password']); } - + if(isset($input['smtp_port'])) { $input['smtp_port'] = (int)$input['smtp_port']; } @@ -145,8 +145,9 @@ class UpdateCompanyRequest extends Request $settings['email_style_custom'] = str_replace(['{!!','!!}','{{','}}','@checked','@dd', '@dump', '@if', '@if(','@endif','@isset','@unless','@auth','@empty','@guest','@env','@section','@switch', '@foreach', '@while', '@include', '@each', '@once', '@push', '@use', '@forelse', '@verbatim', ' 2) + if(isset($settings['company_logo']) && strlen($settings['company_logo']) > 2) { $settings['company_logo'] = $this->forceScheme($settings['company_logo']); + } if (! $account->isFreeHostedClient()) { return $settings; @@ -173,7 +174,8 @@ class UpdateCompanyRequest extends Request return rtrim($url, '/'); } - private function forceScheme($url){ + private function forceScheme($url) + { return stripos($url, 'http') !== false ? $url : "https://{$url}"; } diff --git a/app/Http/Requests/CompanyUser/UpdateCompanyUserRequest.php b/app/Http/Requests/CompanyUser/UpdateCompanyUserRequest.php index 5c17f5ccd52a..b32cf382ed87 100644 --- a/app/Http/Requests/CompanyUser/UpdateCompanyUserRequest.php +++ b/app/Http/Requests/CompanyUser/UpdateCompanyUserRequest.php @@ -40,8 +40,9 @@ class UpdateCompanyUserRequest extends Request { $input = $this->all(); - if(isset($input['company_user']['user'])) + if(isset($input['company_user']['user'])) { unset($input['company_user']['user']); + } $this->replace($input); } diff --git a/app/Http/Requests/Credit/StoreCreditRequest.php b/app/Http/Requests/Credit/StoreCreditRequest.php index 8d6240c4c3bc..69f24d28ab19 100644 --- a/app/Http/Requests/Credit/StoreCreditRequest.php +++ b/app/Http/Requests/Credit/StoreCreditRequest.php @@ -50,7 +50,7 @@ class StoreCreditRequest extends Request $rules['documents.*'] = $this->fileValidation(); } elseif ($this->file('documents')) { $rules['documents'] = $this->fileValidation(); - }else { + } else { $rules['documents'] = 'bail|sometimes|array'; } @@ -78,7 +78,7 @@ class StoreCreditRequest extends Request $rules['exchange_rate'] = 'bail|sometimes|numeric'; $rules['amount'] = ['sometimes', 'bail', 'numeric', 'max:99999999999999']; -$rules['date'] = 'bail|sometimes|date:Y-m-d'; + $rules['date'] = 'bail|sometimes|date:Y-m-d'; if ($this->invoice_id) { $rules['invoice_id'] = new ValidInvoiceCreditRule(); diff --git a/app/Http/Requests/Credit/UpdateCreditRequest.php b/app/Http/Requests/Credit/UpdateCreditRequest.php index 91a1608fe04c..d7ece562fb6d 100644 --- a/app/Http/Requests/Credit/UpdateCreditRequest.php +++ b/app/Http/Requests/Credit/UpdateCreditRequest.php @@ -52,7 +52,7 @@ class UpdateCreditRequest extends Request $rules['documents.*'] = $this->fileValidation(); } elseif ($this->file('documents')) { $rules['documents'] = $this->fileValidation(); - }else { + } else { $rules['documents'] = 'bail|sometimes|array'; } diff --git a/app/Http/Requests/Expense/UpdateExpenseRequest.php b/app/Http/Requests/Expense/UpdateExpenseRequest.php index ced5c9bd1a70..812449e30b38 100644 --- a/app/Http/Requests/Expense/UpdateExpenseRequest.php +++ b/app/Http/Requests/Expense/UpdateExpenseRequest.php @@ -62,7 +62,7 @@ class UpdateExpenseRequest extends Request public function prepareForValidation() { - + /** @var \App\Models\User $user */ $user = auth()->user(); diff --git a/app/Http/Requests/Invoice/StoreInvoiceRequest.php b/app/Http/Requests/Invoice/StoreInvoiceRequest.php index 54dae6e20ba2..eb0395450ac9 100644 --- a/app/Http/Requests/Invoice/StoreInvoiceRequest.php +++ b/app/Http/Requests/Invoice/StoreInvoiceRequest.php @@ -47,7 +47,7 @@ class StoreInvoiceRequest extends Request $rules['documents.*'] = $this->fileValidation(); } elseif ($this->file('documents')) { $rules['documents'] = $this->fileValidation(); - }else { + } else { $rules['documents'] = 'bail|sometimes|array'; } @@ -80,7 +80,7 @@ class StoreInvoiceRequest extends Request $rules['partial'] = 'bail|sometimes|nullable|numeric|gte:0'; $rules['partial_due_date'] = ['bail', 'sometimes', 'exclude_if:partial,0', Rule::requiredIf(fn () => $this->partial > 0), 'date']; $rules['amount'] = ['sometimes', 'bail', 'numeric', 'max:99999999999999']; - + // $rules['amount'] = ['sometimes', 'bail', 'max:99999999999999']; // $rules['due_date'] = ['bail', 'sometimes', 'nullable', 'after:partial_due_date', Rule::requiredIf(fn () => strlen($this->partial_due_date) > 1), 'date']; @@ -122,8 +122,9 @@ class StoreInvoiceRequest extends Request if((isset($input['partial_due_date']) && strlen($input['partial_due_date']) > 1) && (!array_key_exists('due_date', $input) || (empty($input['due_date']) && empty($this->invoice->due_date)))) { $client = \App\Models\Client::withTrashed()->find($input['client_id']); - if($client) + if($client) { $input['due_date'] = \Illuminate\Support\Carbon::parse($input['date'])->addDays($client->getSetting('payment_terms'))->format('Y-m-d'); + } } $this->replace($input); diff --git a/app/Http/Requests/Invoice/UpdateInvoiceRequest.php b/app/Http/Requests/Invoice/UpdateInvoiceRequest.php index 961fcb52ca68..f4ccb51684c9 100644 --- a/app/Http/Requests/Invoice/UpdateInvoiceRequest.php +++ b/app/Http/Requests/Invoice/UpdateInvoiceRequest.php @@ -49,7 +49,7 @@ class UpdateInvoiceRequest extends Request $rules['documents.*'] = $this->fileValidation(); } elseif ($this->file('documents')) { $rules['documents'] = $this->fileValidation(); - }else { + } else { $rules['documents'] = 'bail|sometimes|array'; } diff --git a/app/Http/Requests/Nordigen/ConnectNordigenBankIntegrationRequest.php b/app/Http/Requests/Nordigen/ConnectNordigenBankIntegrationRequest.php index 9852d8e60316..783480a5d188 100644 --- a/app/Http/Requests/Nordigen/ConnectNordigenBankIntegrationRequest.php +++ b/app/Http/Requests/Nordigen/ConnectNordigenBankIntegrationRequest.php @@ -45,8 +45,9 @@ class ConnectNordigenBankIntegrationRequest extends Request $context = $this->getTokenContent(); - if(isset($context['institution_id'])) + if(isset($context['institution_id'])) { $input['institution_id'] = $context['institution_id']; + } $input["redirect"] = isset($context["is_react"]) && $context['is_react'] ? config('ninja.react_url') . "/#/settings/bank_accounts" : config('ninja.app_url'); diff --git a/app/Http/Requests/Payment/StorePaymentRequest.php b/app/Http/Requests/Payment/StorePaymentRequest.php index 10fe585229b5..f3e8e33adfe8 100644 --- a/app/Http/Requests/Payment/StorePaymentRequest.php +++ b/app/Http/Requests/Payment/StorePaymentRequest.php @@ -44,11 +44,11 @@ class StorePaymentRequest extends Request $user = auth()->user(); $rules = [ - 'client_id' => ['bail','required',Rule::exists('clients','id')->where('company_id',$user->company()->id)->where('is_deleted', 0)], + 'client_id' => ['bail','required',Rule::exists('clients', 'id')->where('company_id', $user->company()->id)->where('is_deleted', 0)], 'invoices' => ['bail','sometimes', 'nullable', 'array', new ValidPayableInvoicesRule()], 'invoices.*.amount' => ['bail','required'], - 'invoices.*.invoice_id' => ['bail','required','distinct', new ValidInvoicesRules($this->all()),Rule::exists('invoices','id')->where('company_id', $user->company()->id)->where('client_id', $this->client_id)], - 'credits.*.credit_id' => ['bail','required','distinct', new ValidCreditsRules($this->all()),Rule::exists('credits','id')->where('company_id', $user->company()->id)->where('client_id', $this->client_id)], + 'invoices.*.invoice_id' => ['bail','required','distinct', new ValidInvoicesRules($this->all()),Rule::exists('invoices', 'id')->where('company_id', $user->company()->id)->where('client_id', $this->client_id)], + 'credits.*.credit_id' => ['bail','required','distinct', new ValidCreditsRules($this->all()),Rule::exists('credits', 'id')->where('company_id', $user->company()->id)->where('client_id', $this->client_id)], 'credits.*.amount' => ['bail','required', new CreditsSumRule($this->all())], 'amount' => ['bail', 'numeric', new PaymentAmountsBalanceRule(), 'max:99999999999999'], 'number' => ['bail', 'nullable', Rule::unique('payments')->where('company_id', $user->company()->id)], @@ -59,7 +59,7 @@ class StorePaymentRequest extends Request $rules['documents.*'] = $this->fileValidation(); } elseif ($this->file('documents')) { $rules['documents'] = $this->fileValidation(); - }else { + } else { $rules['documents'] = 'bail|sometimes|array'; } diff --git a/app/Http/Requests/Payment/UpdatePaymentRequest.php b/app/Http/Requests/Payment/UpdatePaymentRequest.php index 3c309af4c6f4..eba4d15c6cf9 100644 --- a/app/Http/Requests/Payment/UpdatePaymentRequest.php +++ b/app/Http/Requests/Payment/UpdatePaymentRequest.php @@ -40,14 +40,14 @@ class UpdatePaymentRequest extends Request /** @var \App\Models\User $user */ $user = auth()->user(); - + $rules = [ 'client_id' => ['sometimes', 'bail', Rule::in([$this->payment->client_id])], 'number' => ['sometimes', 'bail', Rule::unique('payments')->where('company_id', $user->company()->id)->ignore($this->payment->id)], 'invoices' => ['sometimes', 'bail', 'nullable', 'array', new PaymentAppliedValidAmount($this->all())], - 'invoices.*.invoice_id' => ['sometimes','distinct',Rule::exists('invoices','id')->where('company_id', $user->company()->id)->where('client_id', $this->payment->client_id)], + 'invoices.*.invoice_id' => ['sometimes','distinct',Rule::exists('invoices', 'id')->where('company_id', $user->company()->id)->where('client_id', $this->payment->client_id)], 'invoices.*.amount' => ['sometimes','numeric','min:0'], - 'credits.*.credit_id' => ['sometimes','bail','distinct',Rule::exists('credits','id')->where('company_id', $user->company()->id)->where('client_id', $this->payment->client_id)], + 'credits.*.credit_id' => ['sometimes','bail','distinct',Rule::exists('credits', 'id')->where('company_id', $user->company()->id)->where('client_id', $this->payment->client_id)], 'credits.*.amount' => ['required', 'bail'], ]; @@ -55,7 +55,7 @@ class UpdatePaymentRequest extends Request $rules['documents.*'] = $this->fileValidation(); } elseif ($this->file('documents')) { $rules['documents'] = $this->fileValidation(); - }else { + } else { $rules['documents'] = 'bail|sometimes|array'; } diff --git a/app/Http/Requests/Product/StoreProductRequest.php b/app/Http/Requests/Product/StoreProductRequest.php index 23f5339f2575..6984288cf859 100644 --- a/app/Http/Requests/Product/StoreProductRequest.php +++ b/app/Http/Requests/Product/StoreProductRequest.php @@ -35,7 +35,7 @@ class StoreProductRequest extends Request $rules['documents.*'] = $this->fileValidation(); } elseif ($this->file('documents')) { $rules['documents'] = $this->fileValidation(); - }else { + } else { $rules['documents'] = 'bail|sometimes|array'; } diff --git a/app/Http/Requests/Product/UpdateProductRequest.php b/app/Http/Requests/Product/UpdateProductRequest.php index cf82ee6a6aca..39b0b2a16767 100644 --- a/app/Http/Requests/Product/UpdateProductRequest.php +++ b/app/Http/Requests/Product/UpdateProductRequest.php @@ -25,7 +25,7 @@ class UpdateProductRequest extends Request */ public function authorize(): bool { - + /** @var \App\Models\User $user */ $user = auth()->user(); @@ -38,7 +38,7 @@ class UpdateProductRequest extends Request $rules['documents.*'] = $this->fileValidation(); } elseif ($this->file('documents')) { $rules['documents'] = $this->fileValidation(); - }else { + } else { $rules['documents'] = 'bail|sometimes|array'; } diff --git a/app/Http/Requests/Project/StoreProjectRequest.php b/app/Http/Requests/Project/StoreProjectRequest.php index d65baf75bbda..fdaca3b2db6a 100644 --- a/app/Http/Requests/Project/StoreProjectRequest.php +++ b/app/Http/Requests/Project/StoreProjectRequest.php @@ -54,7 +54,7 @@ class StoreProjectRequest extends Request $rules['documents.*'] = $this->fileValidation(); } elseif ($this->file('documents')) { $rules['documents'] = $this->fileValidation(); - }else { + } else { $rules['documents'] = 'bail|sometimes|array'; } @@ -75,8 +75,9 @@ class StoreProjectRequest extends Request $input['color'] = ''; } - if(array_key_exists('budgeted_hours', $input) && empty($input['budgeted_hours'])) + if(array_key_exists('budgeted_hours', $input) && empty($input['budgeted_hours'])) { $input['budgeted_hours'] = 0; + } $this->replace($input); } diff --git a/app/Http/Requests/Project/UpdateProjectRequest.php b/app/Http/Requests/Project/UpdateProjectRequest.php index 77666948ca37..cab826e32ac6 100644 --- a/app/Http/Requests/Project/UpdateProjectRequest.php +++ b/app/Http/Requests/Project/UpdateProjectRequest.php @@ -51,7 +51,7 @@ class UpdateProjectRequest extends Request $rules['documents.*'] = $this->fileValidation(); } elseif ($this->file('documents')) { $rules['documents'] = $this->fileValidation(); - }else { + } else { $rules['documents'] = 'bail|sometimes|array'; } @@ -75,7 +75,7 @@ class UpdateProjectRequest extends Request if (array_key_exists('color', $input) && is_null($input['color'])) { $input['color'] = ''; } - + if(array_key_exists('budgeted_hours', $input) && empty($input['budgeted_hours'])) { $input['budgeted_hours'] = 0; } diff --git a/app/Http/Requests/PurchaseOrder/StorePurchaseOrderRequest.php b/app/Http/Requests/PurchaseOrder/StorePurchaseOrderRequest.php index 50ff98993f7a..3805ed73a9e3 100644 --- a/app/Http/Requests/PurchaseOrder/StorePurchaseOrderRequest.php +++ b/app/Http/Requests/PurchaseOrder/StorePurchaseOrderRequest.php @@ -50,7 +50,7 @@ class StorePurchaseOrderRequest extends Request $rules['number'] = ['nullable', Rule::unique('purchase_orders')->where('company_id', $user->company()->id)]; -$rules['discount'] = 'sometimes|numeric|max:99999999999999'; + $rules['discount'] = 'sometimes|numeric|max:99999999999999'; $rules['is_amount_discount'] = ['boolean']; $rules['line_items'] = 'array'; diff --git a/app/Http/Requests/PurchaseOrder/UpdatePurchaseOrderRequest.php b/app/Http/Requests/PurchaseOrder/UpdatePurchaseOrderRequest.php index c0ab87926983..5ae69e8d1598 100644 --- a/app/Http/Requests/PurchaseOrder/UpdatePurchaseOrderRequest.php +++ b/app/Http/Requests/PurchaseOrder/UpdatePurchaseOrderRequest.php @@ -53,14 +53,14 @@ class UpdatePurchaseOrderRequest extends Request $rules['line_items'] = 'array'; -$rules['discount'] = 'sometimes|numeric|max:99999999999999'; + $rules['discount'] = 'sometimes|numeric|max:99999999999999'; $rules['is_amount_discount'] = ['boolean']; if ($this->file('documents') && is_array($this->file('documents'))) { $rules['documents.*'] = $this->fileValidation(); } elseif ($this->file('documents')) { $rules['documents'] = $this->fileValidation(); - }else { + } else { $rules['documents'] = 'bail|sometimes|array'; } diff --git a/app/Http/Requests/Quote/StoreQuoteRequest.php b/app/Http/Requests/Quote/StoreQuoteRequest.php index c8d0a02035ae..f1e7ba47b74a 100644 --- a/app/Http/Requests/Quote/StoreQuoteRequest.php +++ b/app/Http/Requests/Quote/StoreQuoteRequest.php @@ -43,13 +43,13 @@ class StoreQuoteRequest extends Request $rules = []; - $rules['client_id'] = ['required', 'bail', Rule::exists('clients','id')->where('company_id', $user->company()->id)]; + $rules['client_id'] = ['required', 'bail', Rule::exists('clients', 'id')->where('company_id', $user->company()->id)]; if ($this->file('documents') && is_array($this->file('documents'))) { $rules['documents.*'] = $this->fileValidation(); } elseif ($this->file('documents')) { $rules['documents'] = $this->fileValidation(); - }else { + } else { $rules['documents'] = 'bail|sometimes|array'; } @@ -77,7 +77,7 @@ class StoreQuoteRequest extends Request { /** @var \App\Models\User $user */ $user = auth()->user(); - + $input = $this->all(); $input = $this->decodePrimaryKeys($input); @@ -98,12 +98,13 @@ class StoreQuoteRequest extends Request $input['partial_due_date'] = null; } - if(!isset($input['date'])) + if(!isset($input['date'])) { $input['date'] = now()->addSeconds($user->company()->utc_offset())->format('Y-m-d'); + } - if(isset($input['partial_due_date']) && (!isset($input['due_date']) || strlen($input['due_date']) <=1 )) { + if(isset($input['partial_due_date']) && (!isset($input['due_date']) || strlen($input['due_date']) <= 1)) { $client = \App\Models\Client::withTrashed()->find($input['client_id']); - $valid_days = ($client && strlen($client->getSetting('valid_until')) >= 1) ? $client->getSetting('valid_until') : 7; + $valid_days = ($client && strlen($client->getSetting('valid_until')) >= 1) ? $client->getSetting('valid_until') : 7; $input['due_date'] = \Carbon\Carbon::parse($input['date'])->addDays($valid_days)->format('Y-m-d'); } diff --git a/app/Http/Requests/Quote/UpdateQuoteRequest.php b/app/Http/Requests/Quote/UpdateQuoteRequest.php index 4f9986df2e30..ce8c6eeeb273 100644 --- a/app/Http/Requests/Quote/UpdateQuoteRequest.php +++ b/app/Http/Requests/Quote/UpdateQuoteRequest.php @@ -46,7 +46,7 @@ class UpdateQuoteRequest extends Request $rules['documents.*'] = $this->fileValidation(); } elseif ($this->file('documents')) { $rules['documents'] = $this->fileValidation(); - }else { + } else { $rules['documents'] = 'bail|sometimes|array'; } diff --git a/app/Http/Requests/RecurringInvoice/StoreRecurringInvoiceRequest.php b/app/Http/Requests/RecurringInvoice/StoreRecurringInvoiceRequest.php index 5b56080959e0..7dc6ef5fdc7e 100644 --- a/app/Http/Requests/RecurringInvoice/StoreRecurringInvoiceRequest.php +++ b/app/Http/Requests/RecurringInvoice/StoreRecurringInvoiceRequest.php @@ -49,7 +49,7 @@ class StoreRecurringInvoiceRequest extends Request $rules['documents.*'] = $this->fileValidation(); } elseif ($this->file('documents')) { $rules['documents'] = $this->fileValidation(); - }else { + } else { $rules['documents'] = 'bail|sometimes|array'; } diff --git a/app/Http/Requests/RecurringInvoice/UpdateRecurringInvoiceRequest.php b/app/Http/Requests/RecurringInvoice/UpdateRecurringInvoiceRequest.php index 9e6238570955..db70ca922927 100644 --- a/app/Http/Requests/RecurringInvoice/UpdateRecurringInvoiceRequest.php +++ b/app/Http/Requests/RecurringInvoice/UpdateRecurringInvoiceRequest.php @@ -48,7 +48,7 @@ class UpdateRecurringInvoiceRequest extends Request $rules['documents.*'] = $this->fileValidation(); } elseif ($this->file('documents')) { $rules['documents'] = $this->fileValidation(); - }else { + } else { $rules['documents'] = 'bail|sometimes|array'; } diff --git a/app/Http/Requests/Report/GenericReportRequest.php b/app/Http/Requests/Report/GenericReportRequest.php index 1ebd60dc4321..c9d467423fca 100644 --- a/app/Http/Requests/Report/GenericReportRequest.php +++ b/app/Http/Requests/Report/GenericReportRequest.php @@ -68,8 +68,8 @@ class GenericReportRequest extends Request $input['user_id'] = auth()->user()->id; - if(!$this->checkAuthority()){ - $input['date_range'] = ''; + if(!$this->checkAuthority()) { + $input['date_range'] = ''; $input['start_date'] = ''; $input['end_date'] = ''; $input['send_email'] = true; @@ -85,7 +85,7 @@ class GenericReportRequest extends Request /** @var \App\Models\User $user */ $user = auth()->user(); - + return $user->isAdmin() || $user->hasPermission('view_reports'); } diff --git a/app/Http/Requests/Report/ProductSalesReportRequest.php b/app/Http/Requests/Report/ProductSalesReportRequest.php index d386f89b6b0f..aed50d82fb4d 100644 --- a/app/Http/Requests/Report/ProductSalesReportRequest.php +++ b/app/Http/Requests/Report/ProductSalesReportRequest.php @@ -34,7 +34,7 @@ class ProductSalesReportRequest extends Request public function rules() { - + /** @var \App\Models\User $user */ $user = auth()->user(); @@ -82,8 +82,8 @@ class ProductSalesReportRequest extends Request /** @var \App\Models\User $user */ $user = auth()->user(); - - if(Ninja::isHosted() && $user->account->isFreeHostedClient()){ + + if(Ninja::isHosted() && $user->account->isFreeHostedClient()) { $this->error_message = ctrans('texts.upgrade_to_view_reports'); return false; } diff --git a/app/Http/Requests/Report/ProfitLossRequest.php b/app/Http/Requests/Report/ProfitLossRequest.php index a62417d8c369..908abc092ecb 100644 --- a/app/Http/Requests/Report/ProfitLossRequest.php +++ b/app/Http/Requests/Report/ProfitLossRequest.php @@ -17,7 +17,6 @@ use Illuminate\Auth\Access\AuthorizationException; class ProfitLossRequest extends Request { - private string $error_message = ''; /** @@ -54,14 +53,14 @@ class ProfitLossRequest extends Request $this->replace($input); } - private function checkAuthority() + private function checkAuthority() { $this->error_message = ctrans('texts.authorization_failure'); /** @var \App\Models\User $user */ $user = auth()->user(); - - if(Ninja::isHosted() && $user->account->isFreeHostedClient()){ + + if(Ninja::isHosted() && $user->account->isFreeHostedClient()) { $this->error_message = ctrans('texts.upgrade_to_view_reports'); return false; } diff --git a/app/Http/Requests/Report/ReportPreviewRequest.php b/app/Http/Requests/Report/ReportPreviewRequest.php index 7757e57746a7..869f34cd7d17 100644 --- a/app/Http/Requests/Report/ReportPreviewRequest.php +++ b/app/Http/Requests/Report/ReportPreviewRequest.php @@ -45,8 +45,8 @@ class ReportPreviewRequest extends Request /** @var \App\Models\User $user */ $user = auth()->user(); - - if(Ninja::isHosted() && $user->account->isFreeHostedClient()){ + + if(Ninja::isHosted() && $user->account->isFreeHostedClient()) { $this->error_message = ctrans('texts.upgrade_to_view_reports'); return false; } diff --git a/app/Http/Requests/Request.php b/app/Http/Requests/Request.php index 3c42d83dc980..9617f48ab364 100644 --- a/app/Http/Requests/Request.php +++ b/app/Http/Requests/Request.php @@ -33,11 +33,12 @@ class Request extends FormRequest public function fileValidation() { - if(config('ninja.upload_extensions')) + if(config('ninja.upload_extensions')) { return $this->file_validation. ",".config('ninja.upload_extensions'); + } return $this->file_validation; - + } public function globalRules($rules) @@ -46,9 +47,10 @@ class Request extends FormRequest foreach ($this->all() as $key => $value) { - if($key == 'user') + if($key == 'user') { continue; - + } + if (method_exists($this, $key)) { $merge_rules = $this->{$key}($rules); } diff --git a/app/Http/Requests/Smtp/CheckSmtpRequest.php b/app/Http/Requests/Smtp/CheckSmtpRequest.php index df9cc98a360a..3a4ab408a579 100644 --- a/app/Http/Requests/Smtp/CheckSmtpRequest.php +++ b/app/Http/Requests/Smtp/CheckSmtpRequest.php @@ -24,7 +24,7 @@ class CheckSmtpRequest extends Request { /** @var \App\Models\User $user */ $user = auth()->user(); - + return $user->isAdmin(); } @@ -44,28 +44,27 @@ class CheckSmtpRequest extends Request } public function prepareForValidation() - { - + { + /** @var \App\Models\User $user */ $user = auth()->user(); $company = $user->company(); $input = $this->input(); - if(isset($input['smtp_username']) && $input['smtp_username'] == '********'){ + if(isset($input['smtp_username']) && $input['smtp_username'] == '********') { // unset($input['smtp_username']); $input['smtp_username'] = $company->smtp_username; } - if(isset($input['smtp_password'])&& $input['smtp_password'] == '********'){ + if(isset($input['smtp_password']) && $input['smtp_password'] == '********') { // unset($input['smtp_password']); $input['smtp_password'] = $company->smtp_password; } - if(isset($input['smtp_host']) && strlen($input['smtp_host']) >=3){ + if(isset($input['smtp_host']) && strlen($input['smtp_host']) >= 3) { - } - else { + } else { $input['smtp_host'] = $company->smtp_host; } diff --git a/app/Http/Requests/Task/StoreTaskRequest.php b/app/Http/Requests/Task/StoreTaskRequest.php index b9726331d3f7..f61bc4267a23 100644 --- a/app/Http/Requests/Task/StoreTaskRequest.php +++ b/app/Http/Requests/Task/StoreTaskRequest.php @@ -82,7 +82,7 @@ class StoreTaskRequest extends Request $rules['documents.*'] = $this->fileValidation(); } elseif ($this->file('documents')) { $rules['documents'] = $this->fileValidation(); - }else { + } else { $rules['documents'] = 'bail|sometimes|array'; } diff --git a/app/Http/Requests/Task/UpdateTaskRequest.php b/app/Http/Requests/Task/UpdateTaskRequest.php index 11bd12ee1d92..85b2c4de955b 100644 --- a/app/Http/Requests/Task/UpdateTaskRequest.php +++ b/app/Http/Requests/Task/UpdateTaskRequest.php @@ -88,7 +88,7 @@ class UpdateTaskRequest extends Request $rules['documents.*'] = $this->fileValidation(); } elseif ($this->file('documents')) { $rules['documents'] = $this->fileValidation(); - }else { + } else { $rules['documents'] = 'bail|sometimes|array'; } diff --git a/app/Http/Requests/TaskScheduler/StoreSchedulerRequest.php b/app/Http/Requests/TaskScheduler/StoreSchedulerRequest.php index 1825c9b2e34a..313b1926837f 100644 --- a/app/Http/Requests/TaskScheduler/StoreSchedulerRequest.php +++ b/app/Http/Requests/TaskScheduler/StoreSchedulerRequest.php @@ -27,7 +27,7 @@ class StoreSchedulerRequest extends Request 'logged', 'partial', 'applied', - 'active', + 'active', 'paused', 'completed', 'approved', diff --git a/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php b/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php index b3691fc717c0..f55cbe64e567 100644 --- a/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php +++ b/app/Http/Requests/TaskScheduler/UpdateSchedulerRequest.php @@ -27,7 +27,7 @@ class UpdateSchedulerRequest extends Request 'logged', 'partial', 'applied', - 'active', + 'active', 'paused', 'completed', 'approved', @@ -92,8 +92,8 @@ class UpdateSchedulerRequest extends Request if(isset($input['parameters']['status'])) { - -$task_statuses = []; + + $task_statuses = []; if(isset($input['parameters']['report_name']) && $input['parameters']['report_name'] == 'task') { $task_statuses = array_diff(explode(",", $input['parameters']['status']), $this->client_statuses); diff --git a/app/Http/Requests/User/StoreUserRequest.php b/app/Http/Requests/User/StoreUserRequest.php index c3e87fe890a2..f47b1bd1a217 100644 --- a/app/Http/Requests/User/StoreUserRequest.php +++ b/app/Http/Requests/User/StoreUserRequest.php @@ -96,7 +96,7 @@ class StoreUserRequest extends Request } $input['id'] = null; - + $this->replace($input); } diff --git a/app/Http/Requests/Vendor/StoreVendorRequest.php b/app/Http/Requests/Vendor/StoreVendorRequest.php index d3af8fb39668..96006df89bd2 100644 --- a/app/Http/Requests/Vendor/StoreVendorRequest.php +++ b/app/Http/Requests/Vendor/StoreVendorRequest.php @@ -64,7 +64,7 @@ class StoreVendorRequest extends Request $rules['documents.*'] = $this->fileValidation(); } elseif ($this->file('documents')) { $rules['documents'] = $this->fileValidation(); - }else { + } else { $rules['documents'] = 'bail|sometimes|array'; } diff --git a/app/Http/Requests/Vendor/UpdateVendorRequest.php b/app/Http/Requests/Vendor/UpdateVendorRequest.php index 53e5ee2765b6..398492d84aa8 100644 --- a/app/Http/Requests/Vendor/UpdateVendorRequest.php +++ b/app/Http/Requests/Vendor/UpdateVendorRequest.php @@ -65,7 +65,7 @@ class UpdateVendorRequest extends Request $rules['documents.*'] = $this->fileValidation(); } elseif ($this->file('documents')) { $rules['documents'] = $this->fileValidation(); - }else { + } else { $rules['documents'] = 'bail|sometimes|array'; } diff --git a/app/Http/Requests/Webhook/StoreWebhookRequest.php b/app/Http/Requests/Webhook/StoreWebhookRequest.php index a116aae65fd7..c0a3c6632b72 100644 --- a/app/Http/Requests/Webhook/StoreWebhookRequest.php +++ b/app/Http/Requests/Webhook/StoreWebhookRequest.php @@ -45,7 +45,7 @@ class StoreWebhookRequest extends Request if (!isset($input['rest_method'])) { $input['rest_method'] = 'post'; } - + $this->replace($input); } } diff --git a/app/Http/ValidationRules/Design/TwigLint.php b/app/Http/ValidationRules/Design/TwigLint.php index f65fc328fc3c..187fd706b51e 100644 --- a/app/Http/ValidationRules/Design/TwigLint.php +++ b/app/Http/ValidationRules/Design/TwigLint.php @@ -37,8 +37,6 @@ class TwigLint implements ValidationRule } - + } } - - diff --git a/app/Http/ValidationRules/Invoice/LockedInvoiceRule.php b/app/Http/ValidationRules/Invoice/LockedInvoiceRule.php index 169df7757f15..cb0dcde42137 100644 --- a/app/Http/ValidationRules/Invoice/LockedInvoiceRule.php +++ b/app/Http/ValidationRules/Invoice/LockedInvoiceRule.php @@ -69,10 +69,11 @@ class LockedInvoiceRule implements Rule return true; - //if now is greater than the end of month the invoice was dated - do not modify + //if now is greater than the end of month the invoice was dated - do not modify case 'end_of_month': - if(\Carbon\Carbon::parse($this->invoice->date)->setTimezone($this->invoice->company->timezone()->name)->endOfMonth()->lte(now())) + if(\Carbon\Carbon::parse($this->invoice->date)->setTimezone($this->invoice->company->timezone()->name)->endOfMonth()->lte(now())) { return false; + } return true; default: diff --git a/app/Http/ViewComposers/PortalComposer.php b/app/Http/ViewComposers/PortalComposer.php index b7c5fba8602b..15c8016a5f89 100644 --- a/app/Http/ViewComposers/PortalComposer.php +++ b/app/Http/ViewComposers/PortalComposer.php @@ -79,6 +79,10 @@ class PortalComposer return []; } + auth()->guard('contact')->user()->loadMissing(['client' => function ($query) { + $query->without('gateway_tokens', 'documents'); // Exclude 'grandchildren' relation of 'client' + }]); + $this->settings = auth()->guard('contact')->user()->client->getMergedSettings(); $data['sidebar'] = $this->sidebarMenu(); diff --git a/app/Import/Providers/BaseImport.php b/app/Import/Providers/BaseImport.php index 38294e82a6f4..94670d2e9c08 100644 --- a/app/Import/Providers/BaseImport.php +++ b/app/Import/Providers/BaseImport.php @@ -255,8 +255,9 @@ class BaseImport unset($record['']); - if(!is_array($record)) + if(!is_array($record)) { continue; + } try { $entity = $this->transformer->transform($record); @@ -313,7 +314,7 @@ class BaseImport $count = 0; foreach ($data as $key => $record) { - + if(!is_array($record)) { continue; } @@ -380,7 +381,7 @@ class BaseImport $invoices = $this->groupInvoices($invoices, $invoice_number_key); foreach ($invoices as $raw_invoice) { - + if(!is_array($raw_invoice)) { continue; } @@ -472,7 +473,7 @@ class BaseImport foreach ($tasks as $raw_task) { $task_data = []; - + if(!is_array($raw_task)) { continue; } @@ -545,7 +546,7 @@ class BaseImport $invoices = $this->groupInvoices($invoices, $invoice_number_key); foreach ($invoices as $raw_invoice) { - + if(!is_array($raw_invoice)) { continue; } @@ -765,7 +766,7 @@ class BaseImport $quotes = $this->groupInvoices($quotes, $quote_number_key); foreach ($quotes as $raw_quote) { - + if(!is_array($raw_quote)) { continue; } @@ -976,5 +977,5 @@ class BaseImport return $data; } - + } diff --git a/app/Import/Providers/Wave.php b/app/Import/Providers/Wave.php index 8fdc56f984d9..89c3ef9931a2 100644 --- a/app/Import/Providers/Wave.php +++ b/app/Import/Providers/Wave.php @@ -232,7 +232,7 @@ class Wave extends BaseImport implements ImportInterface $expenses = $this->groupExpenses($data); foreach ($expenses as $raw_expense) { - + if(!is_array($raw_expense)) { continue; } diff --git a/app/Import/Transformer/BaseTransformer.php b/app/Import/Transformer/BaseTransformer.php index 4c6af4aee64d..32a333f66e98 100644 --- a/app/Import/Transformer/BaseTransformer.php +++ b/app/Import/Transformer/BaseTransformer.php @@ -65,7 +65,7 @@ class BaseTransformer return $parsed_date; } } - + public function parseDateOrNull($data, $field) { $date = &$data[$field]; @@ -345,10 +345,10 @@ class BaseTransformer { if (array_key_exists($field, $data)) { return Number::parseFloat($data[$field]); - } - + } + return 0; - + } /** diff --git a/app/Import/Transformer/Invoice2Go/InvoiceTransformer.php b/app/Import/Transformer/Invoice2Go/InvoiceTransformer.php index b3e7fc46155d..cf7771d63740 100644 --- a/app/Import/Transformer/Invoice2Go/InvoiceTransformer.php +++ b/app/Import/Transformer/Invoice2Go/InvoiceTransformer.php @@ -91,7 +91,7 @@ class InvoiceTransformer extends BaseTransformer ]; $addresses = $this->harvestAddresses($invoice_data); - + $transformed['client'] = array_merge($transformed['client'], $addresses); } @@ -102,17 +102,15 @@ class InvoiceTransformer extends BaseTransformer 'amount' => $this->getFloat($invoice_data, 'Payments'), ], ]; - } - elseif(isset($invoice_data['AmountPaidAmount']) && isset($invoice_data['DatePaid'])){ + } elseif(isset($invoice_data['AmountPaidAmount']) && isset($invoice_data['DatePaid'])) { $transformed['payments'] = [ [ 'date' => $this->parseDate($invoice_data['DatePaid']), 'amount' => $this->getFloat($invoice_data, 'AmountPaidAmount'), ] ]; - } - elseif(isset($invoice_data['DocumentStatus']) && $invoice_data['DocumentStatus'] == 'fully_paid'){ - + } elseif(isset($invoice_data['DocumentStatus']) && $invoice_data['DocumentStatus'] == 'fully_paid') { + $transformed['payments'] = [ [ 'date' => isset($invoice_data['DatePaid']) ? $this->parseDate($invoice_data['DatePaid']) : ($this->parseDate($invoice_data['DocumentDate']) ?? now()->format('Y-m-d')), @@ -125,33 +123,34 @@ class InvoiceTransformer extends BaseTransformer } - private function harvestAddresses($invoice_data) { + private function harvestAddresses($invoice_data) + { $address = $invoice_data['DocumentRecipientAddress']; $lines = explode("\n", $address); $billing_address = []; - if(count($lines) == 2){ + if(count($lines) == 2) { $billing_address['address1'] = $lines[0]; - + $parts = explode(",", $lines[1]); - if(count($parts) == 3){ + if(count($parts) == 3) { $billing_address['city'] = $parts[0]; $billing_address['state'] = $parts[1]; $billing_address['postal_code'] = $parts[2]; } - + } - $shipaddress = $invoice_data['ShipAddress'] ?? ''; + $shipaddress = $invoice_data['ShipAddress'] ?? ''; $shipping_address = []; $lines = explode("\n", $shipaddress); if(count($lines) == 2) { $shipping_address['address1'] = $lines[0]; - + $parts = explode(",", $lines[1]); if(count($parts) == 3) { @@ -188,7 +187,7 @@ class InvoiceTransformer extends BaseTransformer private function harvestLineItems(array $invoice_data): array { - + $default_data = [ [ @@ -198,8 +197,8 @@ class InvoiceTransformer extends BaseTransformer 'is_amount_discount' => false, ], ]; - - if(!isset($invoice_data['Items'])){ + + if(!isset($invoice_data['Items'])) { return $default_data; } @@ -208,15 +207,14 @@ class InvoiceTransformer extends BaseTransformer $line_items = []; - foreach($processed as $item) - { + foreach($processed as $item) { $_item['cost'] = $item['unit_price']; $_item['quantity'] = $item['qty'] ?? 1; - $_item['discount'] = $item['discount_percentage'] > $item['discount_amount'] ? $item['discount_percentage'] : $item['discount_amount']; + $_item['discount'] = $item['discount_percentage'] > $item['discount_amount'] ? $item['discount_percentage'] : $item['discount_amount']; $_item['is_amount_discount'] = $item['discount_type'] == 'percentage' ? false : true; $_item['product_key'] = $item['code'] ?? ''; $_item['notes'] = $item['description'] ?? ''; - + $_item = $this->parseTaxes($_item, $item); $this->is_amount_discount = $_item['is_amount_discount']; @@ -230,18 +228,19 @@ class InvoiceTransformer extends BaseTransformer private function parseTaxes($ninja_item, $i2g_item): array { - if(is_string($i2g_item['applied_taxes'])) + if(is_string($i2g_item['applied_taxes'])) { return $ninja_item; - + } + $ninja_item['tax_name1'] = 'Tax'; $ninja_item['tax_rate1'] = $i2g_item['applied_taxes']['rate']; return $ninja_item; } - - function parseCsvWithNestedCsv($csvString, $delimiter = ',', $enclosure = '"', $lineEnding = ';') + + public function parseCsvWithNestedCsv($csvString, $delimiter = ',', $enclosure = '"', $lineEnding = ';') { // Regular expression to find nested CSVs $nestedCsvPattern = '/"([^"]*(?:""[^"]*)*)"/'; diff --git a/app/Jobs/Bank/MatchBankTransactions.php b/app/Jobs/Bank/MatchBankTransactions.php index 2dabff1e05c7..321f0aafc428 100644 --- a/app/Jobs/Bank/MatchBankTransactions.php +++ b/app/Jobs/Bank/MatchBankTransactions.php @@ -289,7 +289,7 @@ class MatchBankTransactions implements ShouldQueue private function createPayment($invoices, float $amount): void { - + $this->attachable_invoices = []; $this->available_balance = $amount; diff --git a/app/Jobs/Bank/ProcessBankTransactionsNordigen.php b/app/Jobs/Bank/ProcessBankTransactionsNordigen.php index 8ff86efd14a5..cc0d807e370c 100644 --- a/app/Jobs/Bank/ProcessBankTransactionsNordigen.php +++ b/app/Jobs/Bank/ProcessBankTransactionsNordigen.php @@ -86,7 +86,7 @@ class ProcessBankTransactionsNordigen implements ShouldQueue $this->bank_integration->company->notification(new GenericNinjaAdminNotification($content))->ninja(); sleep(5); - + throw $e; } if (!$this->nordigen_account) { diff --git a/app/Jobs/Brevo/ProcessBrevoWebhook.php b/app/Jobs/Brevo/ProcessBrevoWebhook.php index a4626b1bf89a..c8704cf163dd 100644 --- a/app/Jobs/Brevo/ProcessBrevoWebhook.php +++ b/app/Jobs/Brevo/ProcessBrevoWebhook.php @@ -36,7 +36,10 @@ use Turbo124\Beacon\Facades\LightLogs; class ProcessBrevoWebhook implements ShouldQueue { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + use Dispatchable; + use InteractsWithQueue; + use Queueable; + use SerializesModels; public $tries = 1; diff --git a/app/Jobs/Company/CompanyImport.php b/app/Jobs/Company/CompanyImport.php index c6a1054f2eaa..3a60741a82d9 100644 --- a/app/Jobs/Company/CompanyImport.php +++ b/app/Jobs/Company/CompanyImport.php @@ -350,11 +350,13 @@ class CompanyImport implements ShouldQueue } } - if(file_exists($tmp_file)) + if(file_exists($tmp_file)) { unlink($tmp_file); + } - if(Storage::exists($this->file_location)) + if(Storage::exists($this->file_location)) { unlink(Storage::path($this->file_location)); + } } // @@ -513,8 +515,7 @@ class CompanyImport implements ShouldQueue $settings->email_style_custom = str_replace(['{!!','!!}','{{','}}','@dd', '@dump', '@if', '@if(','@endif','@isset','@unless','@auth','@empty','@guest','@env','@section','@switch', '@foreach', '@while', '@include', '@each', '@once', '@push', '@use', '@forelse', '@verbatim', 'email_style_custom); $settings->company_logo = (strlen($settings->company_logo) > 2 && stripos($settings->company_logo, 'http') !== false) ? $settings->company_logo : "https://{$settings->company_logo}"; - foreach($this->protected_input as $protected_var) - { + foreach($this->protected_input as $protected_var) { $settings->{$protected_var} = str_replace("script", "", $settings->{$protected_var}); } diff --git a/app/Jobs/Credit/ApplyCreditPayment.php b/app/Jobs/Credit/ApplyCreditPayment.php index d2ebc361ef35..e9aab7c4a63e 100644 --- a/app/Jobs/Credit/ApplyCreditPayment.php +++ b/app/Jobs/Credit/ApplyCreditPayment.php @@ -78,7 +78,7 @@ class ApplyCreditPayment implements ShouldQueue $item->cost = $this->amount * -1; $item->notes = "{$item_date} - " . ctrans('texts.credit_payment', ['invoice_number' => $invoice_numbers]) . " ". Number::formatMoney($this->amount, $this->payment->client); $item->type_id = "1"; - + $line_items = $this->credit->line_items; $line_items[] = $item; $this->credit->line_items = $line_items; @@ -106,7 +106,7 @@ class ApplyCreditPayment implements ShouldQueue ->client ->service() ->adjustCreditBalance($this->amount * -1) - ->save(); + ->save(); /* Update Payment Applied Amount*/ $this->payment->save(); diff --git a/app/Jobs/Cron/SubscriptionCron.php b/app/Jobs/Cron/SubscriptionCron.php index e9d0d32b4838..1c4b7dbc16ad 100644 --- a/app/Jobs/Cron/SubscriptionCron.php +++ b/app/Jobs/Cron/SubscriptionCron.php @@ -44,11 +44,11 @@ class SubscriptionCron if (! config('ninja.db.multi_db_enabled')) { - nlog('Subscription Cron '. now()->toDateTimeString()); + nlog('Subscription Cron '. now()->toDateTimeString()); + + $this->timezoneAware(); - $this->timezoneAware(); - } else { //multiDB environment, need to foreach (MultiDB::$dbs as $db) { @@ -65,7 +65,7 @@ class SubscriptionCron //Requires the crons to be updated and set to hourly @ 00:01 private function timezoneAware() { - $grouped_company_ids = + $grouped_company_ids = Invoice::select('company_id') ->where('is_deleted', 0) @@ -77,7 +77,7 @@ class SubscriptionCron ->whereNotNull('subscription_id') ->groupBy('company_id') ->cursor() - ->each(function ($company_id){ + ->each(function ($company_id) { /** @var \App\Models\Company $company */ $company = Company::find($company_id); @@ -111,7 +111,7 @@ class SubscriptionCron $this->sendLoad($subscription, $body); //This will send the notification daily. //We'll need to handle this by performing some action on the invoice to either archive it or delete it? - }); + }); } diff --git a/app/Jobs/Cron/UpdateCalculatedFields.php b/app/Jobs/Cron/UpdateCalculatedFields.php index 6dde0e91b186..b25d88fa56f3 100644 --- a/app/Jobs/Cron/UpdateCalculatedFields.php +++ b/app/Jobs/Cron/UpdateCalculatedFields.php @@ -68,7 +68,7 @@ class UpdateCalculatedFields $project->current_hours = $this->calculateDuration($project); $project->save(); }); - + //Clean password resets table \DB::connection($db)->table('password_resets')->where('created_at', '<', now()->subHour())->delete(); diff --git a/app/Jobs/Document/CopyDocs.php b/app/Jobs/Document/CopyDocs.php index 98e5003a8d21..e0f091b3012c 100644 --- a/app/Jobs/Document/CopyDocs.php +++ b/app/Jobs/Document/CopyDocs.php @@ -32,7 +32,7 @@ class CopyDocs implements ShouldQueue public $tries = 1; /** - * + * */ public function __construct(private \Illuminate\Support\Collection $document_ids, private $entity, private string $db) { @@ -49,14 +49,14 @@ class CopyDocs implements ShouldQueue Document::whereIn('id', $this->document_ids) ->where('company_id', $this->entity->company_id) - ->each(function ($document){ + ->each(function ($document) { $file = $document->getFile(); - - $extension = pathinfo($document->name, PATHINFO_EXTENSION); + + $extension = pathinfo($document->name, PATHINFO_EXTENSION); $new_hash = \Illuminate\Support\Str::random(32) . "." . $extension; - + Storage::disk($document->disk)->put( "{$this->entity->company->company_key}/documents/{$new_hash}", $file, @@ -76,7 +76,7 @@ class CopyDocs implements ShouldQueue $new_doc->width = $document->width; $new_doc->height = $document->height; $new_doc->is_public = $document->is_public; - + $this->entity->documents()->save($new_doc); }); diff --git a/app/Jobs/EDocument/CreateEDocument.php b/app/Jobs/EDocument/CreateEDocument.php index c2e0b5a16f25..103ab05d9d2d 100644 --- a/app/Jobs/EDocument/CreateEDocument.php +++ b/app/Jobs/EDocument/CreateEDocument.php @@ -59,13 +59,14 @@ class CreateEDocument implements ShouldQueue App::setLocale($settings_entity->locale()); /* Set customized translations _NOW_ */ - if($this->document->client ?? false) + if($this->document->client ?? false) { $t->replace(Ninja::transformTranslations($this->document->client->getMergedSettings())); + } $e_document_type = strlen($settings_entity->getSetting('e_invoice_type')) > 2 ? $settings_entity->getSetting('e_invoice_type') : "XInvoice_3_0"; $e_quote_type = strlen($settings_entity->getSetting('e_quote_type')) > 2 ? $settings_entity->getSetting('e_quote_type') : "OrderX_Extended"; - if ($this->document instanceof Invoice){ + if ($this->document instanceof Invoice) { switch ($e_document_type) { case "FACT1": return (new RoEInvoice($this->document))->generateXml(); @@ -95,9 +96,8 @@ class CreateEDocument implements ShouldQueue return $this->returnObject ? $zugferd : $zugferd->getXml(); } - } - elseif ($this->document instanceof Quote){ - switch ($e_quote_type){ + } elseif ($this->document instanceof Quote) { + switch ($e_quote_type) { case "OrderX_Basic": case "OrderX_Comfort": case "OrderX_Extended": @@ -107,9 +107,8 @@ class CreateEDocument implements ShouldQueue $orderx = (new OrderXDocument($this->document))->run(); return $this->returnObject ? $orderx->orderxdocument : $orderx->getXml(); } - } - elseif ($this->document instanceof PurchaseOrder){ - switch ($e_quote_type){ + } elseif ($this->document instanceof PurchaseOrder) { + switch ($e_quote_type) { case "OrderX_Basic": case "OrderX_Comfort": case "OrderX_Extended": @@ -119,8 +118,7 @@ class CreateEDocument implements ShouldQueue $orderx = (new OrderXDocument($this->document))->run(); return $this->returnObject ? $orderx->orderxdocument : $orderx->getXml(); } - } - elseif ($this->document instanceof Credit) { + } elseif ($this->document instanceof Credit) { switch ($e_document_type) { case "EN16931": case "XInvoice_3_0": @@ -138,8 +136,7 @@ class CreateEDocument implements ShouldQueue $zugferd = (new ZugferdEDokument($this->document))->run(); return $this->returnObject ? $zugferd : $zugferd->getXml(); } - } - else{ + } else { return ""; } } diff --git a/app/Jobs/EDocument/MergeEDocument.php b/app/Jobs/EDocument/MergeEDocument.php index 08eaf171124a..bf92e5fdcc97 100644 --- a/app/Jobs/EDocument/MergeEDocument.php +++ b/app/Jobs/EDocument/MergeEDocument.php @@ -35,7 +35,7 @@ class MergeEDocument implements ShouldQueue $e_document_type = strlen($settings_entity->getSetting('e_invoice_type')) > 2 ? $settings_entity->getSetting('e_invoice_type') : "XInvoice_3_0"; - if ($this->document instanceof Invoice){ + if ($this->document instanceof Invoice) { switch ($e_document_type) { case "EN16931": case "XInvoice_3_0": @@ -53,10 +53,8 @@ class MergeEDocument implements ShouldQueue return $this->pdf_file; } - } - else{ + } else { return $this->pdf_file; } } } - diff --git a/app/Jobs/Entity/CreateRawPdf.php b/app/Jobs/Entity/CreateRawPdf.php index 13e082215503..aa10bdf019d9 100644 --- a/app/Jobs/Entity/CreateRawPdf.php +++ b/app/Jobs/Entity/CreateRawPdf.php @@ -113,7 +113,7 @@ class CreateRawPdf } catch (\Exception) { throw new FilePermissionsFailure('Unable to generate the raw PDF'); } - if ($this->entity_string == "invoice" && $this->entity->client->getSetting("merge_e_invoice_to_pdf")){ + if ($this->entity_string == "invoice" && $this->entity->client->getSetting("merge_e_invoice_to_pdf")) { $pdf = (new MergeEDocument($this->entity, $pdf))->handle(); } return $pdf; diff --git a/app/Jobs/Ledger/ClientLedgerBalanceUpdate.php b/app/Jobs/Ledger/ClientLedgerBalanceUpdate.php index 7a8724ce15c8..a8171e517e5f 100644 --- a/app/Jobs/Ledger/ClientLedgerBalanceUpdate.php +++ b/app/Jobs/Ledger/ClientLedgerBalanceUpdate.php @@ -47,7 +47,7 @@ class ClientLedgerBalanceUpdate implements ShouldQueue */ public function handle(): void { - + MultiDB::setDb($this->company->db); CompanyLedger::query() diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index 841f6207fc80..dbcf47bf2068 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -96,7 +96,7 @@ class NinjaMailerJob implements ShouldQueue } $this->nmo->mailable->replyTo($this->nmo->settings->reply_to_email, $reply_to_name); - } elseif (isset ($this->nmo->invitation->user)) { + } elseif (isset($this->nmo->invitation->user)) { $this->nmo->mailable->replyTo($this->nmo->invitation->user->email, $this->nmo->invitation->user->present()->name()); } else { $this->nmo->mailable->replyTo($this->company->owner()->email, $this->company->owner()->present()->name()); @@ -153,34 +153,30 @@ class NinjaMailerJob implements ShouldQueue LightLogs::create(new EmailSuccess($this->nmo->company->company_key, $this->nmo->mailable->subject)) ->send(); - } - catch (\Symfony\Component\Mime\Exception\RfcComplianceException $e) { + } catch (\Symfony\Component\Mime\Exception\RfcComplianceException $e) { nlog("Mailer failed with a Logic Exception {$e->getMessage()}"); $this->fail(); $this->cleanUpMailers(); $this->logMailError($e->getMessage(), $this->company->clients()->first()); return; - } - catch (\Symfony\Component\Mime\Exception\LogicException $e) { + } catch (\Symfony\Component\Mime\Exception\LogicException $e) { nlog("Mailer failed with a Logic Exception {$e->getMessage()}"); $this->fail(); $this->cleanUpMailers(); $this->logMailError($e->getMessage(), $this->company->clients()->first()); return; - } - catch(\Google\Service\Exception $e){ + } catch(\Google\Service\Exception $e) { if ($e->getCode() == '429') { - + $message = "Google rate limiting triggered, we are queueing based on Gmail requirements."; $this->logMailError($message, $this->company->clients()->first()); sleep(rand(1, 2)); $this->release(900); } - - } - catch (\Exception $e) { + + } catch (\Exception $e) { nlog("Mailer failed with {$e->getMessage()}"); $message = $e->getMessage(); @@ -194,7 +190,7 @@ class NinjaMailerJob implements ShouldQueue $this->fail(); $this->logMailError($e->getMessage(), $this->company->clients()->first()); - + if ($this->nmo->entity) { $this->entityEmailFailed($message); } @@ -204,8 +200,8 @@ class NinjaMailerJob implements ShouldQueue return; } - if(stripos($e->getMessage(), 'Dsn') !== false){ - + if(stripos($e->getMessage(), 'Dsn') !== false) { + nlog("Incorrectly configured mail server - setting to default mail driver."); $this->nmo->settings->email_sending_method = 'default'; return $this->setMailDriver(); @@ -220,7 +216,7 @@ class NinjaMailerJob implements ShouldQueue $this->fail(); $this->logMailError($message, $this->company->clients()->first()); - + if ($this->nmo->entity) { $this->entityEmailFailed($message); } @@ -258,8 +254,9 @@ class NinjaMailerJob implements ShouldQueue private function incrementEmailCounter(): void { - if(in_array($this->mailer, ['default','mailgun','postmark'])) + if(in_array($this->mailer, ['default','mailgun','postmark'])) { Cache::increment("email_quota".$this->company->account->key); + } } /** @@ -400,8 +397,7 @@ class NinjaMailerJob implements ShouldQueue if(strlen($smtp_host) <= 1 || strlen($smtp_username) <= 1 || strlen($smtp_password) <= 1 - ) - { + ) { $this->nmo->settings->email_sending_method = 'default'; return $this->setMailDriver(); } @@ -428,7 +424,7 @@ class NinjaMailerJob implements ShouldQueue } $user = $this->resolveSendingUser(); - $sending_email = (isset ($this->nmo->settings->custom_sending_email) && stripos($this->nmo->settings->custom_sending_email, "@")) ? $this->nmo->settings->custom_sending_email : $user->email; + $sending_email = (isset($this->nmo->settings->custom_sending_email) && stripos($this->nmo->settings->custom_sending_email, "@")) ? $this->nmo->settings->custom_sending_email : $user->email; $this->nmo ->mailable @@ -546,8 +542,8 @@ class NinjaMailerJob implements ShouldQueue $user = $this->resolveSendingUser(); - $sending_email = (isset ($this->nmo->settings->custom_sending_email) && stripos($this->nmo->settings->custom_sending_email, "@")) ? $this->nmo->settings->custom_sending_email : $user->email; - $sending_user = (isset ($this->nmo->settings->email_from_name) && strlen($this->nmo->settings->email_from_name) > 2) ? $this->nmo->settings->email_from_name : $user->name(); + $sending_email = (isset($this->nmo->settings->custom_sending_email) && stripos($this->nmo->settings->custom_sending_email, "@")) ? $this->nmo->settings->custom_sending_email : $user->email; + $sending_user = (isset($this->nmo->settings->email_from_name) && strlen($this->nmo->settings->email_from_name) > 2) ? $this->nmo->settings->email_from_name : $user->name(); $this->nmo ->mailable @@ -569,8 +565,8 @@ class NinjaMailerJob implements ShouldQueue $user = $this->resolveSendingUser(); - $sending_email = (isset ($this->nmo->settings->custom_sending_email) && stripos($this->nmo->settings->custom_sending_email, "@")) ? $this->nmo->settings->custom_sending_email : $user->email; - $sending_user = (isset ($this->nmo->settings->email_from_name) && strlen($this->nmo->settings->email_from_name) > 2) ? $this->nmo->settings->email_from_name : $user->name(); + $sending_email = (isset($this->nmo->settings->custom_sending_email) && stripos($this->nmo->settings->custom_sending_email, "@")) ? $this->nmo->settings->custom_sending_email : $user->email; + $sending_user = (isset($this->nmo->settings->email_from_name) && strlen($this->nmo->settings->email_from_name) > 2) ? $this->nmo->settings->email_from_name : $user->name(); $this->nmo ->mailable @@ -592,8 +588,8 @@ class NinjaMailerJob implements ShouldQueue $user = $this->resolveSendingUser(); - $sending_email = (isset ($this->nmo->settings->custom_sending_email) && stripos($this->nmo->settings->custom_sending_email, "@")) ? $this->nmo->settings->custom_sending_email : $user->email; - $sending_user = (isset ($this->nmo->settings->email_from_name) && strlen($this->nmo->settings->email_from_name) > 2) ? $this->nmo->settings->email_from_name : $user->name(); + $sending_email = (isset($this->nmo->settings->custom_sending_email) && stripos($this->nmo->settings->custom_sending_email, "@")) ? $this->nmo->settings->custom_sending_email : $user->email; + $sending_user = (isset($this->nmo->settings->email_from_name) && strlen($this->nmo->settings->email_from_name) > 2) ? $this->nmo->settings->email_from_name : $user->name(); $this->nmo ->mailable @@ -802,7 +798,7 @@ class NinjaMailerJob implements ShouldQueue if (!$user->oauth_user_refresh_token || $user->oauth_user_refresh_token == '') { return false; } - + try { $token = json_decode($guzzle->post($url, [ 'form_params' => [ @@ -813,8 +809,7 @@ class NinjaMailerJob implements ShouldQueue 'refresh_token' => $user->oauth_user_refresh_token ], ])->getBody()->getContents()); - } - catch(\Exception $e){ + } catch(\Exception $e) { nlog("Problem getting new Microsoft token for User: {$user->email}"); } diff --git a/app/Jobs/Ninja/BankTransactionSync.php b/app/Jobs/Ninja/BankTransactionSync.php index bb8e33c21cc5..572860f9e88c 100644 --- a/app/Jobs/Ninja/BankTransactionSync.php +++ b/app/Jobs/Ninja/BankTransactionSync.php @@ -92,8 +92,7 @@ class BankTransactionSync implements ShouldQueue $account->bank_integrations()->where('integration_type', BankIntegration::INTEGRATION_TYPE_NORDIGEN)->where('auto_sync', true)->where('disabled_upstream', 0)->cursor()->each(function ($bank_integration) { try { (new ProcessBankTransactionsNordigen($bank_integration))->handle(); - } - catch(\Exception $e) { + } catch(\Exception $e) { sleep(20); } diff --git a/app/Jobs/Payment/EmailPayment.php b/app/Jobs/Payment/EmailPayment.php index 1d1c88313e02..1e93c099181d 100644 --- a/app/Jobs/Payment/EmailPayment.php +++ b/app/Jobs/Payment/EmailPayment.php @@ -116,7 +116,7 @@ class EmailPayment implements ShouldQueue $invoice->invitations->each(function ($invite) use ($email_builder) { - + $cloned_mailable = unserialize(serialize($email_builder)); $nmo = new NinjaMailerObject(); diff --git a/app/Jobs/PostMark/ProcessPostmarkWebhook.php b/app/Jobs/PostMark/ProcessPostmarkWebhook.php index 6e4ddd38191a..07ebd194bf85 100644 --- a/app/Jobs/PostMark/ProcessPostmarkWebhook.php +++ b/app/Jobs/PostMark/ProcessPostmarkWebhook.php @@ -405,8 +405,7 @@ class ProcessPostmarkWebhook implements ShouldQueue try { $messageDetail = $postmark->getOutboundMessageDetails($this->request['MessageID']); - } - catch(\Exception $e){ + } catch(\Exception $e) { $postmark_secret = config('services.postmark-outlook.token'); $postmark = new PostmarkClient($postmark_secret); diff --git a/app/Jobs/Report/SendToAdmin.php b/app/Jobs/Report/SendToAdmin.php index 8e24c5a3ff0f..60e7ebac0079 100644 --- a/app/Jobs/Report/SendToAdmin.php +++ b/app/Jobs/Report/SendToAdmin.php @@ -57,8 +57,7 @@ class SendToAdmin implements ShouldQueue $csv = $export->run(); $user = $this->company->owner(); - if(isset($this->request['user_id'])) - { + if(isset($this->request['user_id'])) { $user = User::find($this->request['user_id']) ?? $this->company->owner(); } diff --git a/app/Jobs/Subscription/CleanStaleInvoiceOrder.php b/app/Jobs/Subscription/CleanStaleInvoiceOrder.php index 25528d29523f..c585aa33647a 100644 --- a/app/Jobs/Subscription/CleanStaleInvoiceOrder.php +++ b/app/Jobs/Subscription/CleanStaleInvoiceOrder.php @@ -65,7 +65,7 @@ class CleanStaleInvoiceOrder implements ShouldQueue ->whereJsonContains('line_items', ['type_id' => '3']) ->cursor() ->each(function ($invoice) { - $invoice->service()->removeUnpaidGatewayFees(); + $invoice->service()->removeUnpaidGatewayFees(); }); return; @@ -84,7 +84,7 @@ class CleanStaleInvoiceOrder implements ShouldQueue $invoice->is_proforma = false; $repo->delete($invoice); }); - + Invoice::query() ->withTrashed() ->where('status_id', Invoice::STATUS_SENT) diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index 396f4f0d8165..91d06f2b49be 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -1529,7 +1529,7 @@ class Import implements ShouldQueue } $entity = false; - + if (array_key_exists('expense_id', $resource) && $resource['expense_id'] && array_key_exists('expenses', $this->ids)) { $expense_id = $this->transformId('expenses', $resource['expense_id']); $entity = Expense::query()->where('id', $expense_id)->withTrashed()->first(); @@ -1740,7 +1740,7 @@ class Import implements ShouldQueue $modified['company_id'] = $this->company->id; $modified['user_id'] = $this->processUserId($resource); $modified['is_deleted'] = isset($modified['is_deleted']) ? (bool)$modified['is_deleted'] : false; - + /** @var \App\Models\ExpenseCategory $expense_category **/ $expense_category = ExpenseCategory::create($modified); diff --git a/app/Jobs/Util/ReminderJob.php b/app/Jobs/Util/ReminderJob.php index 86be2d258cb7..38b2009c4b2f 100644 --- a/app/Jobs/Util/ReminderJob.php +++ b/app/Jobs/Util/ReminderJob.php @@ -173,43 +173,43 @@ class ReminderJob implements ShouldQueue //2024-06-07 this early return prevented any reminders from sending for users who enabled lock_invoices. if ($amount > 0 || $percent > 0) { // return; - - $fee = $amount; - if ($over_due_invoice->partial > 0) { - $fee += round($over_due_invoice->partial * $percent / 100, 2); - } else { - $fee += round($over_due_invoice->balance * $percent / 100, 2); - } + $fee = $amount; - /** @var \App\Models\Invoice $invoice */ - $invoice = InvoiceFactory::create($over_due_invoice->company_id, $over_due_invoice->user_id); - $invoice->client_id = $over_due_invoice->client_id; - $invoice->date = now()->format('Y-m-d'); - $invoice->due_date = now()->format('Y-m-d'); + if ($over_due_invoice->partial > 0) { + $fee += round($over_due_invoice->partial * $percent / 100, 2); + } else { + $fee += round($over_due_invoice->balance * $percent / 100, 2); + } - $invoice_item = new InvoiceItem(); - $invoice_item->type_id = '5'; - $invoice_item->product_key = trans('texts.fee'); - $invoice_item->notes = ctrans('texts.late_fee_added_locked_invoice', ['invoice' => $over_due_invoice->number, 'date' => $this->translateDate(now()->startOfDay(), $over_due_invoice->client->date_format(), $over_due_invoice->client->locale())]); - $invoice_item->quantity = 1; - $invoice_item->cost = $fee; + /** @var \App\Models\Invoice $invoice */ + $invoice = InvoiceFactory::create($over_due_invoice->company_id, $over_due_invoice->user_id); + $invoice->client_id = $over_due_invoice->client_id; + $invoice->date = now()->format('Y-m-d'); + $invoice->due_date = now()->format('Y-m-d'); - $invoice_items = []; - $invoice_items[] = $invoice_item; + $invoice_item = new InvoiceItem(); + $invoice_item->type_id = '5'; + $invoice_item->product_key = trans('texts.fee'); + $invoice_item->notes = ctrans('texts.late_fee_added_locked_invoice', ['invoice' => $over_due_invoice->number, 'date' => $this->translateDate(now()->startOfDay(), $over_due_invoice->client->date_format(), $over_due_invoice->client->locale())]); + $invoice_item->quantity = 1; + $invoice_item->cost = $fee; - $invoice->line_items = $invoice_items; + $invoice_items = []; + $invoice_items[] = $invoice_item; - /**Refresh Invoice values*/ - $invoice = $invoice->calc()->getInvoice(); - $invoice->service() - ->createInvitations() - ->applyNumber() - ->markSent() - ->save(); + $invoice->line_items = $invoice_items; + + /**Refresh Invoice values*/ + $invoice = $invoice->calc()->getInvoice(); + $invoice->service() + ->createInvitations() + ->applyNumber() + ->markSent() + ->save(); } - if(!$invoice){ + if(!$invoice) { $invoice = $over_due_invoice; } diff --git a/app/Libraries/MultiDB.php b/app/Libraries/MultiDB.php index 8461db1445d1..712ed37184e4 100644 --- a/app/Libraries/MultiDB.php +++ b/app/Libraries/MultiDB.php @@ -538,7 +538,7 @@ class MultiDB $current_db = config('database.default'); - if(SMSNumbers::hasNumber($phone)){ + if(SMSNumbers::hasNumber($phone)) { return true; } diff --git a/app/Livewire/BillingPortal/Authentication/Login.php b/app/Livewire/BillingPortal/Authentication/Login.php index 3c24baae9562..ea471b117050 100644 --- a/app/Livewire/BillingPortal/Authentication/Login.php +++ b/app/Livewire/BillingPortal/Authentication/Login.php @@ -151,7 +151,7 @@ class Login extends Component ]); if ($attempt) { - + $this->dispatch('purchase.context', property: 'contact', value: auth()->guard('contact')->user()); $this->dispatch('purchase.next'); } @@ -171,4 +171,4 @@ class Login extends Component { return view('billing-portal.v3.authentication.login'); } -} \ No newline at end of file +} diff --git a/app/Livewire/BillingPortal/Authentication/Register.php b/app/Livewire/BillingPortal/Authentication/Register.php index 6e85cbc62201..33c8e3d1860a 100644 --- a/app/Livewire/BillingPortal/Authentication/Register.php +++ b/app/Livewire/BillingPortal/Authentication/Register.php @@ -81,7 +81,7 @@ class Register extends Component public function registerForm() { $count = collect($this->subscription->company->client_registration_fields ?? []) - ->filter(fn($field) => $field['required'] === true || $field['visible'] === true) + ->filter(fn ($field) => $field['required'] === true || $field['visible'] === true) ->count(); if ($count === 0) { diff --git a/app/Livewire/BillingPortal/Authentication/RegisterOrLogin.php b/app/Livewire/BillingPortal/Authentication/RegisterOrLogin.php index 4cbecca75207..100d1e6e174a 100644 --- a/app/Livewire/BillingPortal/Authentication/RegisterOrLogin.php +++ b/app/Livewire/BillingPortal/Authentication/RegisterOrLogin.php @@ -181,7 +181,7 @@ class RegisterOrLogin extends Component public function registerForm() { $count = collect($this->subscription->company->client_registration_fields ?? []) - ->filter(fn($field) => $field['required'] === true || $field['visible'] === true) + ->filter(fn ($field) => $field['required'] === true || $field['visible'] === true) ->count(); if ($count === 0) { diff --git a/app/Livewire/BillingPortal/Cart/Cart.php b/app/Livewire/BillingPortal/Cart/Cart.php index f8fae332df76..a63c10ebaf80 100644 --- a/app/Livewire/BillingPortal/Cart/Cart.php +++ b/app/Livewire/BillingPortal/Cart/Cart.php @@ -30,7 +30,7 @@ class Cart extends Component public function showOptionalProductsLabel() { $optional = [ - ...$this->context['bundle']['optional_recurring_products'] ?? [], + ...$this->context['bundle']['optional_recurring_products'] ?? [], ...$this->context['bundle']['optional_one_time_products'] ?? [], ]; diff --git a/app/Livewire/BillingPortal/Cart/OptionalRecurringProducts.php b/app/Livewire/BillingPortal/Cart/OptionalRecurringProducts.php index 9193ba59ae7c..846457d60b6f 100644 --- a/app/Livewire/BillingPortal/Cart/OptionalRecurringProducts.php +++ b/app/Livewire/BillingPortal/Cart/OptionalRecurringProducts.php @@ -25,7 +25,7 @@ class OptionalRecurringProducts extends Component { $this->dispatch('purchase.context', property: "bundle.optional_recurring_products.{$id}.quantity", value: $value); - + } public function render(): \Illuminate\View\View diff --git a/app/Livewire/BillingPortal/Example.php b/app/Livewire/BillingPortal/Example.php index 00cdba32fe2e..992f93bf20fb 100644 --- a/app/Livewire/BillingPortal/Example.php +++ b/app/Livewire/BillingPortal/Example.php @@ -21,7 +21,7 @@ class Example extends Component public function mount() { $this->dispatch('purchase.context', property: 'quantity', value: 1); - $this->dispatch('purchase.next'); + $this->dispatch('purchase.next'); } public function render() diff --git a/app/Livewire/BillingPortal/Purchase.php b/app/Livewire/BillingPortal/Purchase.php index bcad791b4ff2..5fb9c7c9c991 100644 --- a/app/Livewire/BillingPortal/Purchase.php +++ b/app/Livewire/BillingPortal/Purchase.php @@ -36,7 +36,7 @@ class Purchase extends Component public ?string $campaign; - // + // public int $step = 0; @@ -127,11 +127,11 @@ class Purchase extends Component public function mount() { - $classes = collect(self::$dependencies)->mapWithKeys(fn($dependency, $class) => [$dependency['id'] => $class])->toArray(); + $classes = collect(self::$dependencies)->mapWithKeys(fn ($dependency, $class) => [$dependency['id'] => $class])->toArray(); if ($this->subscription->steps) { $steps = collect(explode(',', $this->subscription->steps)) - ->map(fn($step) => $classes[$step]) + ->map(fn ($step) => $classes[$step]) ->toArray(); $this->steps = [ diff --git a/app/Livewire/BillingPortal/Setup.php b/app/Livewire/BillingPortal/Setup.php index bee2f4c21419..d8454257729a 100644 --- a/app/Livewire/BillingPortal/Setup.php +++ b/app/Livewire/BillingPortal/Setup.php @@ -21,7 +21,7 @@ class Setup extends Component public function mount() { $this->dispatch('purchase.context', property: 'quantity', value: 1); - $this->dispatch('purchase.next'); + $this->dispatch('purchase.next'); } public function render() diff --git a/app/Livewire/BillingPortal/Summary.php b/app/Livewire/BillingPortal/Summary.php index 25e7c86a7684..3e824f95efe4 100644 --- a/app/Livewire/BillingPortal/Summary.php +++ b/app/Livewire/BillingPortal/Summary.php @@ -139,7 +139,7 @@ class Summary extends Component } $products = []; - + foreach ($this->context['bundle']['recurring_products'] as $key => $item) { $products[] = [ 'product_key' => $item['product']['product_key'], diff --git a/app/Livewire/RecurringInvoicesTable.php b/app/Livewire/RecurringInvoicesTable.php index 935cd582be91..06ba0f841d9b 100644 --- a/app/Livewire/RecurringInvoicesTable.php +++ b/app/Livewire/RecurringInvoicesTable.php @@ -41,6 +41,7 @@ class RecurringInvoicesTable extends Component $query = RecurringInvoice::query(); $query = $query + // ->with('client') ->where('client_id', auth()->guard('contact')->user()->client_id) ->where('company_id', $this->company->id) ->whereIn('status_id', [RecurringInvoice::STATUS_ACTIVE]) diff --git a/app/Livewire/RequiredClientInfo.php b/app/Livewire/RequiredClientInfo.php index 3ff7d5374bba..7192f45432b5 100644 --- a/app/Livewire/RequiredClientInfo.php +++ b/app/Livewire/RequiredClientInfo.php @@ -194,10 +194,14 @@ class RequiredClientInfo extends Component public function mount() { + MultiDB::setDb($this->db); - $contact = ClientContact::withTrashed()->find($this->contact_id); - $company = $contact->company; - $this->company_gateway = CompanyGateway::withTrashed()->find($this->company_gateway_id); + $contact = ClientContact::withTrashed()->with(['client' => function ($query) { + $query->without('gateway_tokens', 'documents', 'contacts.company', 'contacts'); // Exclude 'grandchildren' relation of 'client' + }])->find($this->contact_id); + + $this->company_gateway = CompanyGateway::withTrashed()->with('company')->find($this->company_gateway_id); + $company = $this->company_gateway->company; $this->client_name = $contact->client->name; $this->contact_first_name = $contact->first_name; @@ -232,11 +236,13 @@ class RequiredClientInfo extends Component $this->invoice_terms = $invoice->terms; } - if(!$this->company_gateway->always_show_required_fields || $this->is_subscription) + if(!$this->company_gateway->always_show_required_fields || $this->is_subscription) { $this->checkFields(); + } - if($this->unfilled_fields > 0 || ($this->company_gateway->always_show_required_fields || $this->is_subscription)) + if($this->unfilled_fields > 0 || ($this->company_gateway->always_show_required_fields || $this->is_subscription)) { $this->show_form = true; + } } #[Computed] @@ -266,7 +272,10 @@ class RequiredClientInfo extends Component { MultiDB::setDb($this->db); - $contact = ClientContact::withTrashed()->find($this->contact_id); + + $contact = ClientContact::withTrashed()->with(['client' => function ($query) { + $query->without('gateway_tokens', 'documents', 'contacts.company', 'contacts'); // Exclude 'grandchildren' relation of 'client' + }])->find($this->contact_id); $rules = []; @@ -308,7 +317,11 @@ class RequiredClientInfo extends Component MultiDB::setDb($this->db); - $_contact = ClientContact::withTrashed()->find($this->contact_id); + // $_contact = ClientContact::withTrashed()->with('client')->find($this->contact_id); + + $_contact = ClientContact::withTrashed()->with(['client' => function ($query) { + $query->without('gateway_tokens', 'documents', 'contacts.company', 'contacts'); // Exclude 'grandchildren' relation of 'client' + }])->find($this->contact_id); foreach ($data as $field => $value) { diff --git a/app/Mail/Admin/EntitySentObject.php b/app/Mail/Admin/EntitySentObject.php index 512a2878b3ad..9ee99cb99f5a 100644 --- a/app/Mail/Admin/EntitySentObject.php +++ b/app/Mail/Admin/EntitySentObject.php @@ -200,7 +200,7 @@ class EntitySentObject 'whitelabel' => $this->company->account->isPaid() ? true : false, 'text_body' => $content, 'template' => $this->company->account->isPremium() ? 'email.template.admin_premium' : 'email.template.admin', - + ]; } } diff --git a/app/Mail/Engine/BaseEmailEngine.php b/app/Mail/Engine/BaseEmailEngine.php index 56155107e7eb..af43f66d4e95 100644 --- a/app/Mail/Engine/BaseEmailEngine.php +++ b/app/Mail/Engine/BaseEmailEngine.php @@ -126,7 +126,7 @@ class BaseEmailEngine implements EngineInterface if (! empty($this->variables)) { - $text = str_replace(['$paymentLink', '$viewButton', '$view_button', '$viewLink', '$view_link'], '$view_url', $text); + $text = str_replace(['$paymentLink', '$viewButton', '$view_button', '$viewLink', '$view_link'], "\r\n\r\n".'$view_url'."\r\n", $text); $text = str_replace(array_keys($this->variables), array_values($this->variables), $text); $text = str_replace(array_keys($this->variables), array_values($this->variables), $text); diff --git a/app/Mail/Engine/CreditEmailEngine.php b/app/Mail/Engine/CreditEmailEngine.php index 2aafed3d1c1e..e774c6d658ce 100644 --- a/app/Mail/Engine/CreditEmailEngine.php +++ b/app/Mail/Engine/CreditEmailEngine.php @@ -119,9 +119,9 @@ class CreditEmailEngine extends BaseEmailEngine $pdf = ((new CreateRawPdf($this->invitation))->handle()); - if($this->client->getSetting('embed_documents') && ($this->credit->documents()->where('is_public', true)->count() > 0 || $this->credit->company->documents()->where('is_public', true)->count() > 0)) { - $pdf = $this->credit->documentMerge($pdf); - } + if($this->client->getSetting('embed_documents') && ($this->credit->documents()->where('is_public', true)->count() > 0 || $this->credit->company->documents()->where('is_public', true)->count() > 0)) { + $pdf = $this->credit->documentMerge($pdf); + } $this->setAttachments([['file' => base64_encode($pdf), 'name' => $this->credit->numberFormatter().'.pdf']]); } diff --git a/app/Mail/Engine/PaymentEmailEngine.php b/app/Mail/Engine/PaymentEmailEngine.php index c2d68aef570f..7fee5173eba3 100644 --- a/app/Mail/Engine/PaymentEmailEngine.php +++ b/app/Mail/Engine/PaymentEmailEngine.php @@ -30,7 +30,7 @@ class PaymentEmailEngine extends BaseEmailEngine { use MakesDates; use MakesHash; - + public $client; /** @var \App\Models\Payment $payment */ @@ -102,7 +102,7 @@ class PaymentEmailEngine extends BaseEmailEngine if ($this->client->getSetting('pdf_email_attachment') !== false && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) { $template_in_use = false; - + if($this->is_refund && \App\Models\Design::where('id', $this->decodePrimaryKey($this->payment->client->getSetting('payment_refund_design_id')))->where('is_template', true)->exists()) { $pdf = (new TemplateAction( [$this->payment->hashed_id], diff --git a/app/Mail/Engine/QuoteEmailEngine.php b/app/Mail/Engine/QuoteEmailEngine.php index d43592595080..9034af367d2a 100644 --- a/app/Mail/Engine/QuoteEmailEngine.php +++ b/app/Mail/Engine/QuoteEmailEngine.php @@ -118,9 +118,9 @@ class QuoteEmailEngine extends BaseEmailEngine if ($this->client->getSetting('pdf_email_attachment') !== false && $this->quote->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) { $pdf = ((new CreateRawPdf($this->invitation))->handle()); - if($this->client->getSetting('embed_documents') && ($this->quote->documents()->where('is_public', true)->count() > 0 || $this->quote->company->documents()->where('is_public', true)->count() > 0)){ - $pdf = $this->quote->documentMerge($pdf); - } + if($this->client->getSetting('embed_documents') && ($this->quote->documents()->where('is_public', true)->count() > 0 || $this->quote->company->documents()->where('is_public', true)->count() > 0)) { + $pdf = $this->quote->documentMerge($pdf); + } $this->setAttachments([['file' => base64_encode($pdf), 'name' => $this->quote->numberFormatter().'.pdf']]); } diff --git a/app/Mail/TemplateEmail.php b/app/Mail/TemplateEmail.php index 3bce1cd84a1b..2eaa14389dae 100644 --- a/app/Mail/TemplateEmail.php +++ b/app/Mail/TemplateEmail.php @@ -154,8 +154,9 @@ class TemplateEmail extends Mailable } } - if(!$this->invitation) + if(!$this->invitation) { return $this; + } if ($this->invitation->invoice && $settings->ubl_email_attachment && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) { $ubl_string = (new CreateUbl($this->invitation->invoice))->handle(); @@ -175,8 +176,7 @@ class TemplateEmail extends Mailable } } - } - elseif ($this->invitation->credit){ + } elseif ($this->invitation->credit) { if ($this->invitation->credit->client->getSetting('enable_e_invoice') && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) { $xml_string = $this->invitation->credit->service()->getECredit($this->invitation->contact); @@ -185,8 +185,7 @@ class TemplateEmail extends Mailable } } - } - elseif ($this->invitation->quote){ + } elseif ($this->invitation->quote) { if ($this->invitation->quote->client->getSetting('enable_e_invoice') && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) { $xml_string = $this->invitation->quote->service()->getEQuote($this->invitation->contact); @@ -195,8 +194,7 @@ class TemplateEmail extends Mailable } } - } - elseif ($this->invitation->purchase_order){ + } elseif ($this->invitation->purchase_order) { if ($this->invitation->purchase_order->vendor->getSetting('enable_e_invoice') && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) { $xml_string = $this->invitation->purchase_order->service()->getEPurchaseOrder($this->invitation->contact); diff --git a/app/Mail/VendorTemplateEmail.php b/app/Mail/VendorTemplateEmail.php index ff54cf4e1048..7adbcbcc743c 100644 --- a/app/Mail/VendorTemplateEmail.php +++ b/app/Mail/VendorTemplateEmail.php @@ -74,7 +74,7 @@ class VendorTemplateEmail extends Mailable if (in_array($this->build_email->getTemplate(), ['light', 'dark'])) { $template_name = 'email.template.client'; } - + if($this->build_email->getTemplate() == 'premium') { $template_name = 'email.template.client_premium'; } diff --git a/app/Models/Account.php b/app/Models/Account.php index 81d262454b79..c78d23549b2a 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -71,7 +71,7 @@ use Laracasts\Presenter\PresentableTrait; * @property string|null $account_sms_verification_number * @property bool $account_sms_verified * @property string|null $bank_integration_account_id - * @property int $is_trial + * @property bool $is_trial * @property-read int|null $bank_integrations_count * @property-read int|null $companies_count * @property-read int|null $company_users_count @@ -495,6 +495,10 @@ class Account extends BaseModel return 0; } + if($this->email_quota) { + return (int)$this->email_quota; + } + if (Carbon::createFromTimestamp($this->created_at)->diffInWeeks() <= 1) { return 20; } diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 56eb2d490f76..97e561b41c97 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -258,7 +258,7 @@ class Activity extends StaticModel public const PAYMENT_EMAILED = 138; public const VENDOR_NOTIFICATION_EMAIL = 139; - + public const EMAIL_STATEMENT = 140; @@ -473,7 +473,7 @@ class Activity extends StaticModel ':ip' => $translation = [ 'ip' => $this->ip ?? ''], ':contact' => $translation = $this->resolveContact(), ':notes' => $translation = [ 'notes' => $this->notes ?? ''], - + default => $translation = [], }; diff --git a/app/Models/BankIntegration.php b/app/Models/BankIntegration.php index 5e50fdccb9b5..f651c4228027 100644 --- a/app/Models/BankIntegration.php +++ b/app/Models/BankIntegration.php @@ -29,7 +29,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property string|null $bank_account_status * @property string|null $bank_account_type * @property float $balance - * @property int|null $currency + * @property string|null $currency * @property string $nickname * @property string $nordigen_account_id * @property string $nordigen_institution_id diff --git a/app/Models/BankTransaction.php b/app/Models/BankTransaction.php index 28ecc36298a6..77f2219f9067 100644 --- a/app/Models/BankTransaction.php +++ b/app/Models/BankTransaction.php @@ -24,7 +24,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property int $bank_integration_id * @property int $transaction_id * @property string $nordigen_transaction_id - * @property string $amount + * @property float $amount * @property string|null $currency_code * @property int|null $currency_id * @property string|null $account_type @@ -41,7 +41,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property int|null $expense_id * @property int|null $vendor_id * @property int $status_id - * @property int $is_deleted + * @property bool $is_deleted * @property int|null $created_at * @property int|null $updated_at * @property int|null $deleted_at diff --git a/app/Models/BankTransactionRule.php b/app/Models/BankTransactionRule.php index 40a444cc49eb..229d6fc08fba 100644 --- a/app/Models/BankTransactionRule.php +++ b/app/Models/BankTransactionRule.php @@ -27,7 +27,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property int|null $client_id * @property int|null $vendor_id * @property int|null $category_id - * @property int $is_deleted + * @property bool $is_deleted * @property int|null $created_at * @property int|null $updated_at * @property int|null $deleted_at diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index 19b443c476db..727b2adfe19d 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -78,7 +78,7 @@ class BaseModel extends Model use UserSessionAttributes; use HasFactory; use Excludable; - + public int $max_attachment_size = 3000000; protected $appends = [ @@ -340,7 +340,7 @@ class BaseModel extends Model return strtr($section, $variables['values']); } - + /** * Merged PDFs associated with the entity / company * into a single document diff --git a/app/Models/Client.php b/app/Models/Client.php index 66d04a14ade7..d67c3593f81a 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -421,7 +421,7 @@ class Client extends BaseModel implements HasLocalePreference // } return $date_formats->first(function ($item) { - + /** @var \stdClass $item */ return $item->id == $this->getSetting('date_format_id'); })->format; @@ -429,7 +429,7 @@ class Client extends BaseModel implements HasLocalePreference public function currency() { - + /** @var \Illuminate\Support\Collection $currencies */ $currencies = app('currencies'); // $currencies = Cache::get('currencies'); @@ -439,8 +439,8 @@ class Client extends BaseModel implements HasLocalePreference // } return $currencies->first(function ($item) { - - /** @var \stdClass $item */ + + /** @var \stdClass $item */ return $item->id == $this->getSetting('currency_id'); }); } diff --git a/app/Models/ClientGatewayToken.php b/app/Models/ClientGatewayToken.php index 5e74ef1b902c..f8e45a688b3f 100644 --- a/app/Models/ClientGatewayToken.php +++ b/app/Models/ClientGatewayToken.php @@ -25,12 +25,12 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property int $company_gateway_id * @property string|null $gateway_customer_reference * @property int $gateway_type_id - * @property int $is_default + * @property bool $is_default * @property object|null $meta * @property int|null $deleted_at * @property int|null $created_at * @property int|null $updated_at - * @property int $is_deleted + * @property bool $is_deleted * @property-read \App\Models\Client|null $client * @property-read \App\Models\Company $company * @property-read \App\Models\CompanyGateway|null $gateway diff --git a/app/Models/Company.php b/app/Models/Company.php index 815b21aa8ffc..c20d096c2453 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -59,7 +59,7 @@ use Laracasts\Presenter\PresentableTrait; * @property string|null $portal_domain * @property int $enable_modules * @property object $custom_fields - * @property \App\DataMapper\CompanySettings $settings + * @property \App\DataMapper\CompanySettings|\stdClass $settings * @property string $slack_webhook_url * @property string $google_analytics_key * @property int|null $created_at @@ -647,7 +647,7 @@ class Company extends BaseModel // } return $countries->first(function ($item) { - + /** @var \stdClass $item */ return $item->id == $this->getSetting('country_id'); }); diff --git a/app/Models/CompanyGateway.php b/app/Models/CompanyGateway.php index 44f3c606ea6e..9311699f31e3 100644 --- a/app/Models/CompanyGateway.php +++ b/app/Models/CompanyGateway.php @@ -53,7 +53,6 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property-read \App\Models\Gateway $gateway * @property-read mixed $hashed_id * @method getConfigField(string $field) - * @method static \Illuminate\Database\Eloquent\Builder|BaseModel company() * @method static \Illuminate\Database\Eloquent\Builder|CompanyGateway filter(\App\Filters\QueryFilters $filters) * @method static \Illuminate\Database\Eloquent\Builder|CompanyGateway newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|CompanyGateway newQuery() diff --git a/app/Models/Credit.php b/app/Models/Credit.php index b20000e8ff44..4c53fd62cbb8 100644 --- a/app/Models/Credit.php +++ b/app/Models/Credit.php @@ -46,7 +46,7 @@ use Laracasts\Presenter\PresentableTrait; * @property string|null $date * @property string|null $last_sent_date * @property string|null $due_date - * @property int $is_deleted + * @property bool $is_deleted * @property array|null $line_items * @property object|null $backup * @property string|null $footer @@ -60,7 +60,7 @@ use Laracasts\Presenter\PresentableTrait; * @property string|null $tax_name3 * @property float $tax_rate3 * @property string $total_taxes - * @property int $uses_inclusive_taxes + * @property bool $uses_inclusive_taxes * @property string|null $custom_value1 * @property string|null $custom_value2 * @property string|null $custom_value3 diff --git a/app/Models/Document.php b/app/Models/Document.php index e948e9c3e8cc..30e8f8f684d1 100644 --- a/app/Models/Document.php +++ b/app/Models/Document.php @@ -176,9 +176,9 @@ class Document extends BaseModel public function generateRoute($absolute = false) { - try{ - return route('api.documents.show', ['document' => $this->hashed_id]).'/download'; - }catch(\Exception $e){ + try { + return route('api.documents.show', ['document' => $this->hashed_id]).'/download'; + } catch(\Exception $e) { return ''; } } diff --git a/app/Models/Expense.php b/app/Models/Expense.php index eb9ee205ca6f..4b944aecb1c8 100644 --- a/app/Models/Expense.php +++ b/app/Models/Expense.php @@ -36,7 +36,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property bool $is_deleted * @property float $amount * @property float $foreign_amount - * @property string $exchange_rate + * @property float $exchange_rate * @property string|null $tax_name1 * @property float $tax_rate1 * @property string|null $tax_name2 @@ -60,8 +60,8 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property float $tax_amount1 * @property float $tax_amount2 * @property float $tax_amount3 - * @property int $uses_inclusive_taxes - * @property int $calculate_tax_by_amount + * @property bool $uses_inclusive_taxes + * @property bool $calculate_tax_by_amount * @property-read \App\Models\User|null $assigned_user * @property-read \App\Models\ExpenseCategory|null $category * @property-read \App\Models\Client|null $client diff --git a/app/Models/GatewayType.php b/app/Models/GatewayType.php index f30d5c97cb14..1513550cf63d 100644 --- a/app/Models/GatewayType.php +++ b/app/Models/GatewayType.php @@ -92,7 +92,7 @@ class GatewayType extends StaticModel public const PAYLATER = 28; public const PAYPAL_ADVANCED_CARDS = 29; - + public function gateway() { return $this->belongsTo(Gateway::class); @@ -162,7 +162,7 @@ class GatewayType extends StaticModel return ctrans('texts.paypal_paylater'); case self::PAYPAL_ADVANCED_CARDS: return ctrans('texts.credit_card'); - + default: return ' '; } diff --git a/app/Models/GroupSetting.php b/app/Models/GroupSetting.php index 18556b10e343..88d12d0f2745 100644 --- a/app/Models/GroupSetting.php +++ b/app/Models/GroupSetting.php @@ -28,7 +28,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property int|null $deleted_at * @property int|null $created_at * @property int|null $updated_at - * @property int $is_deleted + * @property bool $is_deleted * @property-read \Illuminate\Database\Eloquent\Collection $clients * @property-read int|null $clients_count * @property-read \App\Models\Company $company diff --git a/app/Models/License.php b/app/Models/License.php index 89127ed22bef..2de8088f298b 100644 --- a/app/Models/License.php +++ b/app/Models/License.php @@ -74,4 +74,4 @@ class License extends StaticModel $contact = $this->recurring_invoice->client->contacts()->where('email', $this->email)->first(); } -} \ No newline at end of file +} diff --git a/app/Models/PaymentTerm.php b/app/Models/PaymentTerm.php index 10a2102e2f50..c1bbcde291c5 100644 --- a/app/Models/PaymentTerm.php +++ b/app/Models/PaymentTerm.php @@ -21,7 +21,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property string|null $name * @property int|null $company_id * @property int|null $user_id - * @property int $is_deleted + * @property bool $is_deleted * @property int|null $created_at * @property int|null $updated_at * @property int|null $deleted_at diff --git a/app/Models/Product.php b/app/Models/Product.php index 556488c8f58d..169a7abd8865 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -208,7 +208,7 @@ class Product extends BaseModel public static function markdownHelp(string $notes = '') { - + $converter = new CommonMarkConverter([ 'allow_unsafe_links' => false, 'renderer' => [ diff --git a/app/Models/Project.php b/app/Models/Project.php index 3e5b3dc81748..d341a3fb8569 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -136,7 +136,7 @@ class Project extends BaseModel { return $this->hasMany(Quote::class); } - + public function translate_entity() { diff --git a/app/Models/PurchaseOrder.php b/app/Models/PurchaseOrder.php index 63912a90ca91..d536310fd881 100644 --- a/app/Models/PurchaseOrder.php +++ b/app/Models/PurchaseOrder.php @@ -54,7 +54,7 @@ use Illuminate\Support\Carbon; * @property string|null $tax_name3 * @property float $tax_rate3 * @property float $total_taxes - * @property int $uses_inclusive_taxes + * @property bool $uses_inclusive_taxes * @property string|null $reminder1_sent * @property string|null $reminder2_sent * @property string|null $reminder3_sent diff --git a/app/Models/Quote.php b/app/Models/Quote.php index 71770a531f8a..283d55b3aeb2 100644 --- a/app/Models/Quote.php +++ b/app/Models/Quote.php @@ -48,20 +48,20 @@ use Laracasts\Presenter\PresentableTrait; * @property string|null|Carbon $due_date * @property string|null $next_send_date * @property bool $is_deleted - * @property object|null $line_items + * @property array|null $line_items * @property object|null $backup * @property string|null $footer * @property string|null $public_notes * @property string|null $private_notes * @property string|null $terms * @property string|null $tax_name1 - * @property string $tax_rate1 + * @property float $tax_rate1 * @property string|null $tax_name2 - * @property string $tax_rate2 + * @property float $tax_rate2 * @property string|null $tax_name3 - * @property string $tax_rate3 + * @property float $tax_rate3 * @property string $total_taxes - * @property int $uses_inclusive_taxes + * @property bool $uses_inclusive_taxes * @property string|null $custom_value1 * @property string|null $custom_value2 * @property string|null $custom_value3 @@ -87,7 +87,7 @@ use Laracasts\Presenter\PresentableTrait; * @property string|null $reminder2_sent * @property string|null $reminder3_sent * @property string|null $reminder_last_sent - * @property string $paid_to_date + * @property float $paid_to_date * @property int|null $subscription_id * @property \App\Models\User|null $assigned_user * @property \App\Models\Client $client @@ -198,10 +198,10 @@ class Quote extends BaseModel return $this->dateMutator($value); } -// public function getDueDateAttribute($value) -// { -// return $value ? $this->dateMutator($value) : null; -// } + // public function getDueDateAttribute($value) + // { + // return $value ? $this->dateMutator($value) : null; + // } // public function getPartialDueDateAttribute($value) // { diff --git a/app/Models/RecurringExpense.php b/app/Models/RecurringExpense.php index 1be7816e2104..2775ab500bfc 100644 --- a/app/Models/RecurringExpense.php +++ b/app/Models/RecurringExpense.php @@ -33,30 +33,30 @@ use Illuminate\Support\Carbon; * @property int|null $payment_type_id * @property int|null $recurring_expense_id * @property bool $is_deleted - * @property int $uses_inclusive_taxes + * @property bool $uses_inclusive_taxes * @property string|null $tax_name1 * @property string|null $tax_name2 * @property string|null $tax_name3 * @property string|null $date * @property string|null $payment_date - * @property int $should_be_invoiced - * @property int $invoice_documents + * @property bool $should_be_invoiced + * @property bool $invoice_documents * @property string|null $transaction_id * @property string|null $custom_value1 * @property string|null $custom_value2 * @property string|null $custom_value3 * @property string|null $custom_value4 * @property int|null $category_id - * @property int $calculate_tax_by_amount - * @property string|null $tax_amount1 - * @property string|null $tax_amount2 - * @property string|null $tax_amount3 - * @property string|null $tax_rate1 - * @property string|null $tax_rate2 - * @property string|null $tax_rate3 - * @property string|null $amount - * @property string|null $foreign_amount - * @property string $exchange_rate + * @property bool $calculate_tax_by_amount + * @property float|null $tax_amount1 + * @property float|null $tax_amount2 + * @property float|null $tax_amount3 + * @property float|null $tax_rate1 + * @property float|null $tax_rate2 + * @property float|null $tax_rate3 + * @property float|null $amount + * @property float|null $foreign_amount + * @property float|null $exchange_rate * @property int|null $assigned_user_id * @property string|null $number * @property int|null $invoice_currency_id @@ -221,7 +221,7 @@ class RecurringExpense extends BaseModel return $this->belongsTo(User::class, 'assigned_user_id', 'id'); } - public function company():\Illuminate\Database\Eloquent\Relations\BelongsTo + public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(Company::class); } diff --git a/app/Models/RecurringInvoice.php b/app/Models/RecurringInvoice.php index a9953f3d85aa..097d53b302b4 100644 --- a/app/Models/RecurringInvoice.php +++ b/app/Models/RecurringInvoice.php @@ -40,7 +40,7 @@ use Laracasts\Presenter\PresentableTrait; * @property string|null $date * @property string|null $due_date * @property bool $is_deleted - * @property mixed $line_items + * @property array $line_items * @property object|null $backup * @property string|null $footer * @property string|null $public_notes @@ -72,17 +72,17 @@ use Laracasts\Presenter\PresentableTrait; * @property bool $auto_bill_enabled * @property int|null $design_id * @property bool $uses_inclusive_taxes - * @property string|null $custom_surcharge1 - * @property string|null $custom_surcharge2 - * @property string|null $custom_surcharge3 - * @property string|null $custom_surcharge4 + * @property float|null $custom_surcharge1 + * @property float|null $custom_surcharge2 + * @property float|null $custom_surcharge3 + * @property float|null $custom_surcharge4 * @property bool $custom_surcharge_tax1 * @property bool $custom_surcharge_tax2 * @property bool $custom_surcharge_tax3 * @property bool $custom_surcharge_tax4 * @property string|null $due_date_days * @property string|null $partial_due_date - * @property string $exchange_rate + * @property float $exchange_rate * @property float $paid_to_date * @property int|null $subscription_id * @property string|null $next_send_date_client @@ -341,12 +341,12 @@ class RecurringInvoice extends BaseModel return $this->status_id; } } - + /** * CalculateStatus * * Calculates the status of the Recurring Invoice. - * + * * We only apply the pending status on new models, we never revert an invoice back to * pending. * @param bool $new_model @@ -355,15 +355,16 @@ class RecurringInvoice extends BaseModel public function calculateStatus(bool $new_model = false) //15-02-2024 - $new_model needed { - if($this->remaining_cycles == 0) + if($this->remaining_cycles == 0) { return self::STATUS_COMPLETED; - elseif ($new_model && $this->status_id == self::STATUS_ACTIVE && Carbon::parse($this->next_send_date)->isFuture()) + } elseif ($new_model && $this->status_id == self::STATUS_ACTIVE && Carbon::parse($this->next_send_date)->isFuture()) { return self::STATUS_PENDING; - elseif($this->remaining_cycles != 0 && ($this->status_id == self::STATUS_COMPLETED)) + } elseif($this->remaining_cycles != 0 && ($this->status_id == self::STATUS_COMPLETED)) { return self::STATUS_ACTIVE; + } return $this->status_id; - + } public function nextSendDate(): ?Carbon diff --git a/app/Models/RecurringQuote.php b/app/Models/RecurringQuote.php index 1a554e6008e0..ef4c973d2644 100644 --- a/app/Models/RecurringQuote.php +++ b/app/Models/RecurringQuote.php @@ -34,31 +34,31 @@ use Laracasts\Presenter\PresentableTrait; * @property int|null $vendor_id * @property int $status_id * @property float $discount - * @property int $is_amount_discount + * @property bool $is_amount_discount * @property string|null $number * @property string|null $po_number * @property string|null $date * @property string|null $due_date - * @property int $is_deleted - * @property object|null $line_items + * @property bool $is_deleted + * @property array $line_items * @property object|null $backup * @property string|null $footer * @property string|null $public_notes * @property string|null $private_notes * @property string|null $terms * @property string|null $tax_name1 - * @property string $tax_rate1 + * @property float $tax_rate1 * @property string|null $tax_name2 - * @property string $tax_rate2 + * @property float $tax_rate2 * @property string|null $tax_name3 - * @property string $tax_rate3 - * @property string $total_taxes + * @property float $tax_rate3 + * @property float $total_taxes * @property string|null $custom_value1 * @property string|null $custom_value2 * @property string|null $custom_value3 * @property string|null $custom_value4 - * @property string $amount - * @property string $balance + * @property float $amount + * @property float $balance * @property string|null $last_viewed * @property int $frequency_id * @property int $design_id @@ -69,22 +69,22 @@ use Laracasts\Presenter\PresentableTrait; * @property int|null $updated_at * @property int|null $deleted_at * @property string $auto_bill - * @property int $auto_bill_enabled - * @property string $paid_to_date - * @property string|null $custom_surcharge1 - * @property string|null $custom_surcharge2 - * @property string|null $custom_surcharge3 - * @property string|null $custom_surcharge4 + * @property bool $auto_bill_enabled + * @property float $paid_to_date + * @property float|null $custom_surcharge1 + * @property float|null $custom_surcharge2 + * @property float|null $custom_surcharge3 + * @property float|null $custom_surcharge4 * @property int $custom_surcharge_tax1 * @property int $custom_surcharge_tax2 * @property int $custom_surcharge_tax3 * @property int $custom_surcharge_tax4 * @property string|null $due_date_days - * @property string $exchange_rate + * @property float $exchange_rate * @property float|null $partial * @property string|null $partial_due_date * @property int|null $subscription_id - * @property int $uses_inclusive_taxes + * @property bool $uses_inclusive_taxes * @property-read \Illuminate\Database\Eloquent\Collection $activities * @property-read int|null $activities_count * @property-read \App\Models\User|null $assigned_user diff --git a/app/Models/Subscription.php b/app/Models/Subscription.php index 5c963121afcd..bc0f759222c8 100644 --- a/app/Models/Subscription.php +++ b/app/Models/Subscription.php @@ -30,7 +30,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property string|null $auto_bill * @property string|null $promo_code * @property float $promo_discount - * @property int $is_amount_discount + * @property bool $is_amount_discount * @property int $allow_cancellation * @property int $per_seat_enabled * @property int $min_seats_limit diff --git a/app/Models/SystemLog.php b/app/Models/SystemLog.php index 5ef3305d525b..f61b6c4fbf45 100644 --- a/app/Models/SystemLog.php +++ b/app/Models/SystemLog.php @@ -151,7 +151,7 @@ class SystemLog extends Model public const TYPE_PAYPAL_PPCP = 323; public const TYPE_BTC_PAY = 324; - + public const TYPE_QUOTA_EXCEEDED = 400; public const TYPE_UPSTREAM_FAILURE = 401; diff --git a/app/Models/Task.php b/app/Models/Task.php index 6958f3964659..5875680fbec8 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -44,7 +44,7 @@ use Illuminate\Support\Carbon; * @property string|null $time_log * @property string|null $number * @property string $rate - * @property int $invoice_documents + * @property bool $invoice_documents * @property int $is_date_based * @property int|null $status_order * @property-read \App\Models\User|null $assigned_user diff --git a/app/Models/TaskStatus.php b/app/Models/TaskStatus.php index 170c5211ee34..23ca8e53d688 100644 --- a/app/Models/TaskStatus.php +++ b/app/Models/TaskStatus.php @@ -20,7 +20,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property string|null $name * @property int|null $company_id * @property int|null $user_id - * @property int $is_deleted + * @property bool $is_deleted * @property int|null $created_at * @property int|null $updated_at * @property int|null $deleted_at diff --git a/app/Models/Vendor.php b/app/Models/Vendor.php index 834f15a1ecb6..687eb966477f 100644 --- a/app/Models/Vendor.php +++ b/app/Models/Vendor.php @@ -37,7 +37,7 @@ use Laracasts\Presenter\PresentableTrait; * @property string|null $city * @property string|null $state * @property string|null $postal_code - * @property string|null $country_id + * @property int|null $country_id * @property string|null $phone * @property string|null $private_notes * @property string|null $website @@ -53,7 +53,7 @@ use Laracasts\Presenter\PresentableTrait; * @property string|null $vendor_hash * @property string|null $public_notes * @property string|null $id_number - * @property string|null $language_id + * @property int|null $language_id * @property int|null $last_login * @property-read \Illuminate\Database\Eloquent\Collection $activities * @property-read int|null $activities_count diff --git a/app/Models/Webhook.php b/app/Models/Webhook.php index 511abfbaca39..02eb4911f006 100644 --- a/app/Models/Webhook.php +++ b/app/Models/Webhook.php @@ -20,7 +20,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property int|null $company_id * @property int|null $user_id * @property int|null $event_id - * @property int $is_deleted + * @property bool $is_deleted * @property string $target_url * @property string $format * @property int|null $created_at diff --git a/app/PaymentDrivers/Authorize/AuthorizePaymentMethod.php b/app/PaymentDrivers/Authorize/AuthorizePaymentMethod.php index 529c4f64b4e0..61a10d27860f 100644 --- a/app/PaymentDrivers/Authorize/AuthorizePaymentMethod.php +++ b/app/PaymentDrivers/Authorize/AuthorizePaymentMethod.php @@ -169,9 +169,10 @@ class AuthorizePaymentMethod $billto->setCity(substr($this->authorize->client->city, 0, 40)); $billto->setState(substr($this->authorize->client->state, 0, 40)); $billto->setZip(substr($this->authorize->client->postal_code, 0, 20)); - - if(isset($contact->email) && str_contains($contact->email, '@')) + + if(isset($contact->email) && str_contains($contact->email, '@')) { $billto->setEmail($contact->email); + } if ($this->authorize->client->country_id) { $billto->setCountry($this->authorize->client->country->name); @@ -183,7 +184,7 @@ class AuthorizePaymentMethod // Create a new Customer Payment Profile object $paymentprofile = new CustomerPaymentProfileType(); $paymentprofile->setCustomerType('individual'); - + if ($billto) { $paymentprofile->setBillTo($billto); } diff --git a/app/PaymentDrivers/Authorize/AuthorizeTransaction.php b/app/PaymentDrivers/Authorize/AuthorizeTransaction.php index 88b6c47d4739..fe187cab29aa 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeTransaction.php +++ b/app/PaymentDrivers/Authorize/AuthorizeTransaction.php @@ -145,7 +145,7 @@ class AuthorizeTransaction nlog(' Description : '.$tresponse->getMessages()[0]->getDescription()); nlog(print_r($tresponse->getMessages()[0], 1)); - if($tresponse->getResponseCode() == "4"){ + if($tresponse->getResponseCode() == "4") { //notify user that this transaction is being held under FDS review: FDSReview::dispatch((string)$tresponse->getTransId(), $this->authorize->payment_hash, $this->authorize->company_gateway->company->db); } diff --git a/app/PaymentDrivers/Authorize/FDSReview.php b/app/PaymentDrivers/Authorize/FDSReview.php index 91f7401449a9..aede54529ea1 100644 --- a/app/PaymentDrivers/Authorize/FDSReview.php +++ b/app/PaymentDrivers/Authorize/FDSReview.php @@ -31,7 +31,7 @@ class FDSReview implements ShouldQueue use InteractsWithQueue; use Queueable; use SerializesModels; - + public $tries = 1; //number of retries public $deleteWhenMissingModels = true; @@ -43,11 +43,11 @@ class FDSReview implements ShouldQueue { MultiDB::setDB($this->db); - + $company = $this->payment_hash->fee_invoice->company; App::setLocale($company->getLocale()); - + $invoices_string = \implode(', ', collect($this->payment_hash->invoices())->pluck('invoice_number')->toArray()) ?: ''; $body = "Transaction {$this->transaction_reference} has been held for your review in Auth.net based on your Fraud Detection Settings.\n\n\nWe have marked invoices {$invoices_string} as paid in Invoice Ninja.\n\n\nPlease review this transaction in your auth.net account, and authorize if correct to ensure the transaction is finalized as expected.\n\n\nIf these charges need to be cancelled, you will need to delete the payments that have been created in Invoice Ninja."; diff --git a/app/PaymentDrivers/AuthorizePaymentDriver.php b/app/PaymentDrivers/AuthorizePaymentDriver.php index 465474a5d595..a34d29a63115 100644 --- a/app/PaymentDrivers/AuthorizePaymentDriver.php +++ b/app/PaymentDrivers/AuthorizePaymentDriver.php @@ -194,7 +194,7 @@ class AuthorizePaymentDriver extends BaseDriver public function import() { $this->init(); - + nlog("starting import auth.net"); return (new AuthorizeCustomer($this))->importCustomers(); diff --git a/app/PaymentDrivers/BTCPayPaymentDriver.php b/app/PaymentDrivers/BTCPayPaymentDriver.php index 7d5926ec408c..6d4d7ec3dd51 100644 --- a/app/PaymentDrivers/BTCPayPaymentDriver.php +++ b/app/PaymentDrivers/BTCPayPaymentDriver.php @@ -43,7 +43,7 @@ class BTCPayPaymentDriver extends BaseDriver GatewayType::CRYPTO => BTCPay::class, //maps GatewayType => Implementation class ]; - const SYSTEM_LOG_TYPE = SystemLog::TYPE_CHECKOUT; //define a constant for your gateway ie TYPE_YOUR_CUSTOM_GATEWAY - set the const in the SystemLog model + public const SYSTEM_LOG_TYPE = SystemLog::TYPE_CHECKOUT; //define a constant for your gateway ie TYPE_YOUR_CUSTOM_GATEWAY - set the const in the SystemLog model public $btcpay_url = ""; public $api_key = ""; diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 82f52215264f..78fbc57d79f2 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -572,8 +572,7 @@ class BaseDriver extends AbstractPaymentDriver $nmo->company = $this->client->company; $nmo->settings = $this->client->company->settings; - if($this->payment_hash) - { + if($this->payment_hash) { $invoices = Invoice::query()->whereIn('id', $this->transformKeys(array_column($this->payment_hash->invoices(), 'invoice_id')))->withTrashed()->get(); $invoices->first()->invitations->each(function ($invitation) use ($nmo) { @@ -583,7 +582,7 @@ class BaseDriver extends AbstractPaymentDriver } }); } - + $message = [ 'server_response' => $response, 'data' => $this->payment_hash->data, @@ -815,6 +814,6 @@ class BaseDriver extends AbstractPaymentDriver public function importCustomers() { - + } } diff --git a/app/PaymentDrivers/BraintreePaymentDriver.php b/app/PaymentDrivers/BraintreePaymentDriver.php index 5ffdc7d5c3be..9fe58cf6b9e1 100644 --- a/app/PaymentDrivers/BraintreePaymentDriver.php +++ b/app/PaymentDrivers/BraintreePaymentDriver.php @@ -37,7 +37,7 @@ use App\PaymentDrivers\Braintree\CreditCard; class BraintreePaymentDriver extends BaseDriver { use GeneratesCounter; - + public $refundable = true; public $token_billing = true; @@ -296,14 +296,14 @@ class BraintreePaymentDriver extends BaseDriver public function getClientRequiredFields(): array { $fields = []; - - $fields[] = ['name' => 'contact_first_name', 'label' => ctrans('texts.first_name'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'contact_last_name', 'label' => ctrans('texts.last_name'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'contact_email', 'label' => ctrans('texts.email'), 'type' => 'text', 'validation' => 'required,email:rfc']; - $fields[] = ['name' => 'client_address_line_1', 'label' => ctrans('texts.address1'), 'type' => 'text', 'validation' => 'required']; - $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']; + + $fields[] = ['name' => 'contact_first_name', 'label' => ctrans('texts.first_name'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'contact_last_name', 'label' => ctrans('texts.last_name'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'contact_email', 'label' => ctrans('texts.email'), 'type' => 'text', 'validation' => 'required,email:rfc']; + $fields[] = ['name' => 'client_address_line_1', 'label' => ctrans('texts.address1'), 'type' => 'text', 'validation' => 'required']; + $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']; return $fields; } @@ -333,25 +333,24 @@ class BraintreePaymentDriver extends BaseDriver public function auth(): bool { - + try { - $ct =$this->init()->gateway->clientToken()->generate(); - + $ct = $this->init()->gateway->clientToken()->generate(); + return true; - } - catch(\Exception $e) { + } catch(\Exception $e) { } - + return false; } - private function find(string $customer_id = '') { - + private function find(string $customer_id = '') + { + try { return $this->init()->gateway->customer()->find($customer_id); - } - catch(\Exception $e){ + } catch(\Exception $e) { return false; } @@ -375,7 +374,8 @@ class BraintreePaymentDriver extends BaseDriver } - private function findClient(string $email) { + private function findClient(string $email) + { return ClientContact::where('company_id', $this->company_gateway->company_id) ->where('email', $email) ->first()->client ?? false; @@ -383,13 +383,14 @@ class BraintreePaymentDriver extends BaseDriver private function addClientCards(Client $client, array $cards) { - + $this->client = $client; foreach($cards as $card) { - if($this->getToken($card->token, $card->customerId) || Carbon::createFromDate($card->expirationYear, $card->expirationMonth, '1')->lt(now())) + if($this->getToken($card->token, $card->customerId) || Carbon::createFromDate($card->expirationYear, $card->expirationMonth, '1')->lt(now())) { continue; + } $payment_meta = new \stdClass(); $payment_meta->exp_month = (string) $card->expirationMonth; @@ -405,7 +406,7 @@ class BraintreePaymentDriver extends BaseDriver ]; $this->storeGatewayToken($data, ['gateway_customer_reference' => $card->customerId]); - + nlog("adding card to customer payment profile"); } @@ -423,7 +424,7 @@ class BraintreePaymentDriver extends BaseDriver if($b_business_address) { - $braintree_address = + $braintree_address = [ 'address1' => $b_business_address->extendedAddress ?? '', 'address2' => $b_business_address->streetAddress ?? '', @@ -438,7 +439,7 @@ class BraintreePaymentDriver extends BaseDriver if($b_shipping_address) { - $braintree_shipping_address = + $braintree_shipping_address = [ 'shipping_address1' => $b_shipping_address->extendedAddress ?? '', 'shipping_address2' => $b_shipping_address->streetAddress ?? '', @@ -498,15 +499,16 @@ class BraintreePaymentDriver extends BaseDriver public function importCustomers() { $customers = $this->init()->gateway->customer()->all(); - - foreach($customers as $c){ + + foreach($customers as $c) { $customer = $this->find($c->id); // nlog(count($customer->creditCards). " Exists for {$c->id}"); - if(!$customer) + if(!$customer) { continue; + } $client = $this->findClient($customer->email); @@ -515,7 +517,7 @@ class BraintreePaymentDriver extends BaseDriver $client = $this->createNinjaClient($customer); // nlog("Creating new Client"); } - + $this->addClientCards($client, $customer->creditCards); // nlog("Adding Braintree Client: {$c->id} => {$client->id}"); diff --git a/app/PaymentDrivers/CheckoutComPaymentDriver.php b/app/PaymentDrivers/CheckoutComPaymentDriver.php index 8b615b2283d0..03b161d076af 100644 --- a/app/PaymentDrivers/CheckoutComPaymentDriver.php +++ b/app/PaymentDrivers/CheckoutComPaymentDriver.php @@ -538,11 +538,10 @@ class CheckoutComPaymentDriver extends BaseDriver public function auth(): bool { - try{ + try { $this->init()->gateway->getCustomersClient('x'); return true; - } - catch(\Exception $e){ + } catch(\Exception $e) { } return false; @@ -556,65 +555,65 @@ class CheckoutComPaymentDriver extends BaseDriver ->where('token', $token) ->first(); } - + /** * ImportCustomers * - * Only their methods because checkout.com + * Only their methods because checkout.com * does not have a list route for customers - * + * * @return void */ public function importCustomers() { $this->init(); - + $this->company_gateway ->company ->clients() ->cursor() - ->each(function ($client){ + ->each(function ($client) { - if(!str_contains($client->present()->email(), "@")) - return; + if(!str_contains($client->present()->email(), "@")) { + return; + } - try{ - $customer = $this->gateway->getCustomersClient()->get($client->present()->email()); - } - catch(\Exception $e) { - nlog("Checkout: Customer not found"); - return; - } + try { + $customer = $this->gateway->getCustomersClient()->get($client->present()->email()); + } catch(\Exception $e) { + nlog("Checkout: Customer not found"); + return; + } - $this->client = $client; + $this->client = $client; - nlog($customer['instruments']); + nlog($customer['instruments']); - foreach($customer['instruments'] as $card) - { - if( - $card['type'] != 'card' || - Carbon::createFromDate($card['expiry_year'], $card['expiry_month'], '1')->lt(now()) || - $this->getToken($card['id'], $customer['id']) - ) - continue; - - $payment_meta = new \stdClass(); - $payment_meta->exp_month = (string) $card['expiry_month']; - $payment_meta->exp_year = (string) $card['expiry_year']; - $payment_meta->brand = (string) $card['scheme']; - $payment_meta->last4 = (string) $card['last4']; - $payment_meta->type = (int) GatewayType::CREDIT_CARD; + foreach($customer['instruments'] as $card) { + if( + $card['type'] != 'card' || + Carbon::createFromDate($card['expiry_year'], $card['expiry_month'], '1')->lt(now()) || + $this->getToken($card['id'], $customer['id']) + ) { + continue; + } - $data = [ - 'payment_meta' => $payment_meta, - 'token' => $card['id'], - 'payment_method_id' => GatewayType::CREDIT_CARD, - ]; + $payment_meta = new \stdClass(); + $payment_meta->exp_month = (string) $card['expiry_month']; + $payment_meta->exp_year = (string) $card['expiry_year']; + $payment_meta->brand = (string) $card['scheme']; + $payment_meta->last4 = (string) $card['last4']; + $payment_meta->type = (int) GatewayType::CREDIT_CARD; - $this->storeGatewayToken($data, ['gateway_customer_reference' => $customer['id']]); + $data = [ + 'payment_meta' => $payment_meta, + 'token' => $card['id'], + 'payment_method_id' => GatewayType::CREDIT_CARD, + ]; - } + $this->storeGatewayToken($data, ['gateway_customer_reference' => $customer['id']]); + + } }); } diff --git a/app/PaymentDrivers/EwayPaymentDriver.php b/app/PaymentDrivers/EwayPaymentDriver.php index a416cea387c2..2222b071a78d 100644 --- a/app/PaymentDrivers/EwayPaymentDriver.php +++ b/app/PaymentDrivers/EwayPaymentDriver.php @@ -215,12 +215,12 @@ class EwayPaymentDriver extends BaseDriver public function auth(): bool { - $response =$this->init()->eway->queryTransaction('xx'); + $response = $this->init()->eway->queryTransaction('xx'); return (bool) count($response->getErrors()) == 0; } - + /** * importCustomers * diff --git a/app/PaymentDrivers/Factory/ForteCustomerFactory.php b/app/PaymentDrivers/Factory/ForteCustomerFactory.php index eb6336d778fb..613870fe42e2 100644 --- a/app/PaymentDrivers/Factory/ForteCustomerFactory.php +++ b/app/PaymentDrivers/Factory/ForteCustomerFactory.php @@ -17,23 +17,22 @@ use App\Models\Company; class ForteCustomerFactory { - public function convertToNinja(array $customer, Company $company): array { - return + return collect([ - 'name' => $customer['company_name'] ?? $customer['first_name'], - 'contacts' => [ - [ - 'first_name' => $customer['first_name'], - 'last_name' => $customer['last_name'], - 'email' => $this->getBillingAddress($customer)['email'], - 'phone' => $this->getBillingAddress($customer)['phone'], - ] - ], - 'settings' => [ - 'currency_id' => $company->settings->currency_id, - ], + 'name' => $customer['company_name'] ?? $customer['first_name'], + 'contacts' => [ + [ + 'first_name' => $customer['first_name'], + 'last_name' => $customer['last_name'], + 'email' => $this->getBillingAddress($customer)['email'], + 'phone' => $this->getBillingAddress($customer)['phone'], + ] + ], + 'settings' => [ + 'currency_id' => $company->settings->currency_id, + ], ])->merge($this->getShippingAddress($customer)) ->merge($this->getBillingAddress($customer)) ->toArray(); @@ -42,7 +41,7 @@ class ForteCustomerFactory // public function convertToGateway(Client $client): array // { - + // } private function getBillingAddress(array $customer): array @@ -51,8 +50,9 @@ class ForteCustomerFactory foreach($customer['addresses'] as $address) { - if($address['address_token'] != $customer['default_billing_address_token']) + if($address['address_token'] != $customer['default_billing_address_token']) { continue; + } return [ 'address1' => $address['physical_address']['street_line1'], @@ -114,8 +114,8 @@ class ForteCustomerFactory } - if(isset($customer['addresses'][1])){ - + if(isset($customer['addresses'][1])) { + $address = $customer['addresses'][1]; return [ diff --git a/app/PaymentDrivers/Factory/PaytraceCustomerFactory.php b/app/PaymentDrivers/Factory/PaytraceCustomerFactory.php index 731a6c7085f6..3f05dbf84d06 100644 --- a/app/PaymentDrivers/Factory/PaytraceCustomerFactory.php +++ b/app/PaymentDrivers/Factory/PaytraceCustomerFactory.php @@ -21,7 +21,7 @@ class PaytraceCustomerFactory return collect([ 'name' => $customer->billing_address->name ?? $customer->shipping_address->name, - 'contacts' => [ + 'contacts' => [ [ 'first_name' => $customer->billing_address->name ?? $customer->shipping_address->name, 'last_name' => '', @@ -55,5 +55,5 @@ class PaytraceCustomerFactory ->toArray(); } - + } diff --git a/app/PaymentDrivers/Factory/SquareCustomerFactory.php b/app/PaymentDrivers/Factory/SquareCustomerFactory.php index fa3d9ad71bfd..c62eac3d8055 100644 --- a/app/PaymentDrivers/Factory/SquareCustomerFactory.php +++ b/app/PaymentDrivers/Factory/SquareCustomerFactory.php @@ -17,7 +17,6 @@ use App\Models\GatewayType; class SquareCustomerFactory { - /* { "id": "A537H7KAQWSAF8M8EM1Y23E16M", @@ -83,9 +82,9 @@ class SquareCustomerFactory $cards = []; - foreach($customer->getCards() ?? [] as $card){ - - $meta = new \stdClass; + foreach($customer->getCards() ?? [] as $card) { + + $meta = new \stdClass(); $meta->exp_month = $card->getExpMonth(); $meta->exp_year = $card->getExpYear(); $meta->last4 = $card->getLast4(); @@ -101,7 +100,7 @@ class SquareCustomerFactory } $address = $customer->getAddress(); - + return collect([ 'name' => $customer->getCompanyName() ?? ($customer->getGivenName() ?? '' ." " . $customer->getFamilyName() ?? ''), diff --git a/app/PaymentDrivers/FortePaymentDriver.php b/app/PaymentDrivers/FortePaymentDriver.php index 0cbf1e3883df..902b4a62e46f 100644 --- a/app/PaymentDrivers/FortePaymentDriver.php +++ b/app/PaymentDrivers/FortePaymentDriver.php @@ -194,7 +194,7 @@ class FortePaymentDriver extends BaseDriver /////////////////////////////////////////// public function auth(): bool { - + $forte_base_uri = "https://sandbox.forte.net/api/v3/"; if ($this->company_gateway->getConfigField('testMode') == false) { $forte_base_uri = "https://api.forte.net/v3/"; @@ -204,13 +204,13 @@ class FortePaymentDriver extends BaseDriver $forte_auth_organization_id = $this->company_gateway->getConfigField('authOrganizationId'); $forte_organization_id = $this->company_gateway->getConfigField('organizationId'); $forte_location_id = $this->company_gateway->getConfigField('locationId'); - + $response = Http::withBasicAuth($forte_api_access_id, $forte_secure_key) ->withHeaders(['X-Forte-Auth-Organization-Id' => $forte_organization_id]) ->get("{$forte_base_uri}/organizations/{$forte_organization_id}/locations/{$forte_location_id}/customers/"); return $response->successful(); - + } public function baseUri(): string @@ -236,7 +236,7 @@ class FortePaymentDriver extends BaseDriver public function stubRequest() { - + $forte_api_access_id = $this->company_gateway->getConfigField('apiAccessId'); $forte_secure_key = $this->company_gateway->getConfigField('secureKey'); $forte_auth_organization_id = $this->company_gateway->getConfigField('authOrganizationId'); @@ -255,13 +255,14 @@ class FortePaymentDriver extends BaseDriver public function getLocation() { - + $response = $this->stubRequest() ->withQueryParameters(['page_size' => 10000]) ->get("{$this->baseUri()}/organizations/{$this->getOrganisationId()}/locations/{$this->getLocationId()}"); - if($response->successful()) + if($response->successful()) { return $response->json(); + } return false; } @@ -270,18 +271,17 @@ class FortePaymentDriver extends BaseDriver { $response = $this->getLocation(); - if($response) - { + if($response) { $body = $response['services']; - + $fees_and_limits = $this->company_gateway->fees_and_limits; - if($body['card']['service_fee_percentage'] > 0 || $body['card']['service_fee_additional_amount'] > 0){ + if($body['card']['service_fee_percentage'] > 0 || $body['card']['service_fee_additional_amount'] > 0) { $fees_and_limits->{1}->fee_amount = $body['card']['service_fee_additional_amount']; $fees_and_limits->{1}->fee_percent = $body['card']['service_fee_percentage']; } - + if($body['debit']['service_fee_percentage'] > 0 || $body['debit']['service_fee_additional_amount'] > 0) { $fees_and_limits->{2}->fee_amount = $body['debit']['service_fee_additional_amount']; @@ -290,7 +290,7 @@ class FortePaymentDriver extends BaseDriver $this->company_gateway->fees_and_limits = $fees_and_limits; $this->company_gateway->save(); - + } return false; @@ -303,26 +303,26 @@ class FortePaymentDriver extends BaseDriver $response = $this->stubRequest() ->withQueryParameters(['page_size' => 10000]) ->get("{$this->baseUri()}/organizations/{$this->getOrganisationId()}/locations/{$this->getLocationId()}/customers"); - - if($response->successful()){ - - foreach($response->json()['results'] as $customer) - { + + if($response->successful()) { + + foreach($response->json()['results'] as $customer) { $client_repo = new ClientRepository(new ClientContactRepository()); $factory = new ForteCustomerFactory(); $data = $factory->convertToNinja($customer, $this->company_gateway->company); - if(strlen($data['email']) == 0 || $this->getClient($data['email'])) + if(strlen($data['email']) == 0 || $this->getClient($data['email'])) { continue; + } $client_repo->save($data, ClientFactory::create($this->company_gateway->company_id, $this->company_gateway->user_id)); //persist any payment methods here! } } - + } - + } diff --git a/app/PaymentDrivers/GoCardless/ACH.php b/app/PaymentDrivers/GoCardless/ACH.php index 579839f36a50..694cac15b9af 100644 --- a/app/PaymentDrivers/GoCardless/ACH.php +++ b/app/PaymentDrivers/GoCardless/ACH.php @@ -48,7 +48,7 @@ class ACH implements MethodInterface * Authorization page for ACH. * * @param array $data - * @return Redirector|RedirectResponse + * @return \Illuminate\Http\RedirectResponseor|RedirectResponse */ public function authorizeView(array $data) { @@ -107,7 +107,7 @@ class ACH implements MethodInterface * Handle ACH post-redirect authorization. * * @param Request $request - * @return RedirectResponse|void + * @return \Illuminate\Http\RedirectResponse|void */ public function authorizeResponse(Request $request) { @@ -157,7 +157,7 @@ class ACH implements MethodInterface * Process payments for ACH. * * @param PaymentResponseRequest $request - * @return RedirectResponse|void + * @return \Illuminate\Http\RedirectResponse|void */ public function paymentResponse(PaymentResponseRequest $request) { @@ -206,7 +206,7 @@ class ACH implements MethodInterface * * @param ResourcesPayment $payment * @param array $data - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function processPendingPayment(ResourcesPayment $payment, array $data = []) { diff --git a/app/PaymentDrivers/GoCardless/DirectDebit.php b/app/PaymentDrivers/GoCardless/DirectDebit.php index 689d649ca45e..ab67f2862263 100644 --- a/app/PaymentDrivers/GoCardless/DirectDebit.php +++ b/app/PaymentDrivers/GoCardless/DirectDebit.php @@ -46,7 +46,7 @@ class DirectDebit implements MethodInterface * Handle authorization for Direct Debit. * * @param array $data - * @return Redirector|RedirectResponse|void + * @return \Illuminate\Http\RedirectResponseor|RedirectResponse|void */ public function authorizeView(array $data) { @@ -138,7 +138,7 @@ class DirectDebit implements MethodInterface * Handle authorization response for Direct Debit. * * @param Request $request - * @return RedirectResponse|void + * @return \Illuminate\Http\RedirectResponse|void */ public function authorizeResponse(Request $request) { @@ -272,7 +272,7 @@ class DirectDebit implements MethodInterface * * @param ResourcesPayment $payment * @param array $data - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function processPendingPayment(\GoCardlessPro\Resources\Payment $payment, array $data = []) { diff --git a/app/PaymentDrivers/GoCardless/InstantBankPay.php b/app/PaymentDrivers/GoCardless/InstantBankPay.php index 17f0028ffdfb..9133a47a68a3 100644 --- a/app/PaymentDrivers/GoCardless/InstantBankPay.php +++ b/app/PaymentDrivers/GoCardless/InstantBankPay.php @@ -30,7 +30,7 @@ class InstantBankPay implements MethodInterface * Authorization page for Instant Bank Pay. * * @param array $data - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse * @throws BindingResolutionException */ public function authorizeView(array $data): RedirectResponse @@ -42,7 +42,7 @@ class InstantBankPay implements MethodInterface * Handle authorization for Instant Bank Pay. * * @param array $data - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse * @throws BindingResolutionException */ public function authorizeResponse(Request $request): RedirectResponse @@ -131,7 +131,7 @@ class InstantBankPay implements MethodInterface * * @param \GoCardlessPro\Resources\Payment $payment * @param array $data - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function processPendingPayment(\GoCardlessPro\Resources\Payment $payment, array $data = []) { @@ -164,7 +164,7 @@ class InstantBankPay implements MethodInterface * * @param \GoCardlessPro\Resources\Payment $payment * @param array $data - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function processSuccessfulPayment(\GoCardlessPro\Resources\Payment $payment, array $data = []) { diff --git a/app/PaymentDrivers/GoCardless/SEPA.php b/app/PaymentDrivers/GoCardless/SEPA.php index e7cebf830c20..d0f81228ceff 100644 --- a/app/PaymentDrivers/GoCardless/SEPA.php +++ b/app/PaymentDrivers/GoCardless/SEPA.php @@ -46,7 +46,7 @@ class SEPA implements MethodInterface * Handle authorization for SEPA. * * @param array $data - * @return Redirector|RedirectResponse|void + * @return \Illuminate\Http\RedirectResponseor|RedirectResponse|void */ public function authorizeView(array $data) { @@ -106,7 +106,7 @@ class SEPA implements MethodInterface * Handle authorization response for SEPA. * * @param Request $request - * @return RedirectResponse|void + * @return \Illuminate\Http\RedirectResponse|void */ public function authorizeResponse(Request $request) { @@ -156,7 +156,7 @@ class SEPA implements MethodInterface * Handle the payment page for SEPA. * * @param PaymentResponseRequest $request - * @return RedirectResponse|App\PaymentDrivers\GoCardless\never|void + * @return \Illuminate\Http\RedirectResponse|App\PaymentDrivers\GoCardless\never|void */ public function paymentResponse(PaymentResponseRequest $request) { @@ -204,7 +204,7 @@ class SEPA implements MethodInterface * * @param ResourcesPayment $payment * @param array $data - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function processPendingPayment(\GoCardlessPro\Resources\Payment $payment, array $data = []) { diff --git a/app/PaymentDrivers/GoCardlessPaymentDriver.php b/app/PaymentDrivers/GoCardlessPaymentDriver.php index 2906a589fa3b..6985ac144f9d 100644 --- a/app/PaymentDrivers/GoCardlessPaymentDriver.php +++ b/app/PaymentDrivers/GoCardlessPaymentDriver.php @@ -564,8 +564,7 @@ class GoCardlessPaymentDriver extends BaseDriver try { $customers = $this->init()->gateway->customers()->list(); return true; - } - catch(\Exception $e){ + } catch(\Exception $e) { } diff --git a/app/PaymentDrivers/Mollie/Bancontact.php b/app/PaymentDrivers/Mollie/Bancontact.php index 59bf0053e787..3df988bbb2ef 100644 --- a/app/PaymentDrivers/Mollie/Bancontact.php +++ b/app/PaymentDrivers/Mollie/Bancontact.php @@ -51,7 +51,7 @@ class Bancontact implements MethodInterface * Handle the authorization for Bancontact. * * @param Request $request - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function authorizeResponse(Request $request): RedirectResponse { @@ -62,7 +62,7 @@ class Bancontact implements MethodInterface * Show the payment page for Bancontact. * * @param array $data - * @return Redirector|RedirectResponse + * @return \Illuminate\Http\RedirectResponseor|RedirectResponse */ public function paymentView(array $data) { @@ -171,7 +171,7 @@ class Bancontact implements MethodInterface * * @param string $status * @param ResourcesPayment $payment - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function processSuccessfulPayment(\Mollie\Api\Resources\Payment $payment, string $status = 'paid'): RedirectResponse { @@ -203,7 +203,7 @@ class Bancontact implements MethodInterface * Handle 'open' payment status for Bancontact. * * @param ResourcesPayment $payment - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function processOpenPayment(\Mollie\Api\Resources\Payment $payment): RedirectResponse { diff --git a/app/PaymentDrivers/Mollie/BankTransfer.php b/app/PaymentDrivers/Mollie/BankTransfer.php index a6f2b4d706de..7c5872714c06 100644 --- a/app/PaymentDrivers/Mollie/BankTransfer.php +++ b/app/PaymentDrivers/Mollie/BankTransfer.php @@ -54,7 +54,7 @@ class BankTransfer implements MethodInterface * Handle the authorization for bank transfer. * * @param Request $request - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function authorizeResponse(Request $request): RedirectResponse { @@ -65,7 +65,7 @@ class BankTransfer implements MethodInterface * Show the payment page for bank transfer. * * @param array $data - * @return Redirector|RedirectResponse + * @return \Illuminate\Http\RedirectResponseor|RedirectResponse */ public function paymentView(array $data) { @@ -168,7 +168,7 @@ class BankTransfer implements MethodInterface * * @param ResourcesPayment $payment * @param string $status - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function processSuccessfulPayment(ResourcesPayment $payment, $status = 'paid'): RedirectResponse { @@ -200,7 +200,7 @@ class BankTransfer implements MethodInterface * Handle 'open' payment status for bank transfer. * * @param ResourcesPayment $payment - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function processOpenPayment(ResourcesPayment $payment): RedirectResponse { diff --git a/app/PaymentDrivers/Mollie/CreditCard.php b/app/PaymentDrivers/Mollie/CreditCard.php index 39805f2e69af..627605974532 100644 --- a/app/PaymentDrivers/Mollie/CreditCard.php +++ b/app/PaymentDrivers/Mollie/CreditCard.php @@ -251,7 +251,7 @@ class CreditCard * Handle authorization response. * * @param mixed $request - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function authorizeResponse($request): RedirectResponse { diff --git a/app/PaymentDrivers/Mollie/IDEAL.php b/app/PaymentDrivers/Mollie/IDEAL.php index 977a16f33c5a..3b19cad34f11 100644 --- a/app/PaymentDrivers/Mollie/IDEAL.php +++ b/app/PaymentDrivers/Mollie/IDEAL.php @@ -51,7 +51,7 @@ class IDEAL implements MethodInterface * Handle the authorization for iDEAL. * * @param Request $request - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function authorizeResponse(Request $request): RedirectResponse { @@ -62,7 +62,7 @@ class IDEAL implements MethodInterface * Show the payment page for iDEAL. * * @param array $data - * @return Redirector|RedirectResponse + * @return \Illuminate\Http\RedirectResponseor|RedirectResponse */ public function paymentView(array $data) { @@ -171,7 +171,7 @@ class IDEAL implements MethodInterface * * @param string $status * @param ResourcesPayment $payment - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function processSuccessfulPayment(\Mollie\Api\Resources\Payment $payment, string $status = 'paid'): RedirectResponse { @@ -203,7 +203,7 @@ class IDEAL implements MethodInterface * Handle 'open' payment status for IDEAL. * * @param ResourcesPayment $payment - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function processOpenPayment(\Mollie\Api\Resources\Payment $payment): RedirectResponse { diff --git a/app/PaymentDrivers/Mollie/KBC.php b/app/PaymentDrivers/Mollie/KBC.php index cb856d6c8f36..00b87934a92d 100644 --- a/app/PaymentDrivers/Mollie/KBC.php +++ b/app/PaymentDrivers/Mollie/KBC.php @@ -51,7 +51,7 @@ class KBC implements MethodInterface * Handle the authorization for KBC. * * @param Request $request - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function authorizeResponse(Request $request): RedirectResponse { @@ -62,7 +62,7 @@ class KBC implements MethodInterface * Show the payment page for KBC. * * @param array $data - * @return Redirector|RedirectResponse + * @return \Illuminate\Http\RedirectResponseor|RedirectResponse */ public function paymentView(array $data) { @@ -166,7 +166,7 @@ class KBC implements MethodInterface * Handle the successful payment for KBC. * * @param ResourcesPayment $payment - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function processSuccessfulPayment(\Mollie\Api\Resources\Payment $payment): RedirectResponse { diff --git a/app/PaymentDrivers/MolliePaymentDriver.php b/app/PaymentDrivers/MolliePaymentDriver.php index 172c7906517d..0f02d33e12f3 100644 --- a/app/PaymentDrivers/MolliePaymentDriver.php +++ b/app/PaymentDrivers/MolliePaymentDriver.php @@ -428,8 +428,7 @@ class MolliePaymentDriver extends BaseDriver try { $p = $this->gateway->payments->page(); return true; - } - catch(\Exception $e){ + } catch(\Exception $e) { } diff --git a/app/PaymentDrivers/PayPal/PayPalBasePaymentDriver.php b/app/PaymentDrivers/PayPal/PayPalBasePaymentDriver.php index dc5f845a0c76..26ad7f06568f 100644 --- a/app/PaymentDrivers/PayPal/PayPalBasePaymentDriver.php +++ b/app/PaymentDrivers/PayPal/PayPalBasePaymentDriver.php @@ -16,6 +16,7 @@ use Carbon\Carbon; use App\Models\Invoice; use App\Models\SystemLog; use App\Models\GatewayType; +use App\Models\PaymentHash; use App\Models\PaymentType; use Illuminate\Http\Request; use App\Jobs\Util\SystemLogger; @@ -30,6 +31,8 @@ class PayPalBasePaymentDriver extends BaseDriver { use MakesHash; + public string $risk_guid; + public $token_billing = true; public $can_authorise_credit_card = false; @@ -68,8 +71,8 @@ class PayPalBasePaymentDriver extends BaseDriver public function gatewayTypes() { - $funding_options = - + $funding_options = + collect($this->company_gateway->fees_and_limits) ->filter(function ($fee) { return $fee->is_enabled; @@ -78,10 +81,11 @@ class PayPalBasePaymentDriver extends BaseDriver })->toArray(); /** Parse funding options and remove card option if advanced cards is enabled. */ - if(in_array(1, $funding_options) && in_array(29, $funding_options)){ + if(in_array(1, $funding_options) && in_array(29, $funding_options)) { - if (($key = array_search(1, $funding_options)) !== false) + if (($key = array_search(1, $funding_options)) !== false) { unset($funding_options[$key]); + } } @@ -106,6 +110,7 @@ class PayPalBasePaymentDriver extends BaseDriver public function init() { + $this->risk_guid = Str::random(32); $this->api_endpoint_url = $this->company_gateway->getConfigField('testMode') ? 'https://api-m.sandbox.paypal.com' : 'https://api-m.paypal.com'; @@ -137,7 +142,7 @@ class PayPalBasePaymentDriver extends BaseDriver * getFundingOptions * * Hosted fields requires this. - * + * * @return string */ public function getFundingOptions(): string @@ -176,6 +181,40 @@ class PayPalBasePaymentDriver extends BaseDriver } + //@todo turn this back on when PayPal..... + public function getClientHash() + { + return ''; + + /** @var \App\Models\ClientGatewayToken $cgt */ + $cgt = ClientGatewayToken::where('company_gateway_id', $this->company_gateway->id) + ->where('client_id', $this->client->id) + ->first(); + if(!$cgt) { + return ''; + } + + $client_reference = $cgt->gateway_customer_reference; + + $secret = $this->company_gateway->getConfigField('secret'); + $client_id = $this->company_gateway->getConfigField('clientId'); + + $response = Http::withBasicAuth($client_id, $secret) + ->withHeaders(['Content-Type' => 'application/x-www-form-urlencoded']) + ->withQueryParameters(['grant_type' => 'client_credentials','response_type' => 'id_token', 'target_customer_id' => $client_reference]) + ->post("{$this->api_endpoint_url}/v1/oauth2/token"); + + if($response->successful()) { + + $data = $response->json(); + + return $data['id_token'] ?? ''; + + } + + return ''; + } + public function handleDuplicateInvoiceId(string $orderID) { @@ -196,7 +235,7 @@ class PayPalBasePaymentDriver extends BaseDriver return $r; } - + public function getShippingAddress(): ?array { return $this->company_gateway->require_shipping_address ? @@ -232,7 +271,7 @@ class PayPalBasePaymentDriver extends BaseDriver "country_code" => $this->client->country->iso_3166_2, ]; } - + public function getPaymentSource(): array { //@todo - roll back here for advanced payments vs hosted card fields. @@ -256,7 +295,7 @@ class PayPalBasePaymentDriver extends BaseDriver // "payment_initiator" => "MERCHANT", //"CUSTOMER" who initiated the transaction? "payment_initiator" => "CUSTOMER", //"" who initiated the transaction? "payment_type" => "UNSCHEDULED", //UNSCHEDULED - "usage"=> "DERIVED", + "usage" => "DERIVED", ], ], ]; @@ -292,15 +331,13 @@ class PayPalBasePaymentDriver extends BaseDriver "postal_code" => $this->client->shipping_postal_code, "country_code" => $this->client->present()->shipping_country_code(), ]; - } - elseif( + } elseif( strlen($this->client->address1 ?? '') > 2 && strlen($this->client->city ?? '') > 2 && strlen($this->client->state ?? '') >= 2 && strlen($this->client->postal_code ?? '') > 2 && strlen($this->client->country->iso_3166_2 ?? '') >= 2 - ) - { + ) { $order['paypal']['address'] = [ "address_line_1" => $this->client->address1, "address_line_2" => $this->client->address2, @@ -314,7 +351,7 @@ class PayPalBasePaymentDriver extends BaseDriver return $order; } - + /** * Payment method setter * @@ -365,8 +402,8 @@ class PayPalBasePaymentDriver extends BaseDriver ->withHeaders($this->getHeaders($headers)) ->{$verb}("{$this->api_endpoint_url}{$uri}", $data); - if($r->status() <= 422){ - // if($r->successful()) { + if($r->status() <= 422) { + // if($r->successful()) { return $r; } @@ -383,13 +420,13 @@ class PayPalBasePaymentDriver extends BaseDriver $this->client->company ?? $this->company_gateway->company, ); - + return response()->json(['message' => "Gateway failure - {$r->body()}"], 401); // throw new PaymentFailed("Gateway failure - {$r->body()}", 401); } - + public function handleProcessingFailure(array $response) { @@ -406,14 +443,15 @@ class PayPalBasePaymentDriver extends BaseDriver case 'NOT_AUTHORIZED': throw new PaymentFailed("There was a permissions issue processing this payment, please contact the merchant. ", 401); break; - + default: throw new PaymentFailed("Unknown error occurred processing payment. Please contact merchant.", 500); break; } } - public function handleRetry($response, $request) { + public function handleRetry($response, $request) + { return response()->json($response->json()); } @@ -432,6 +470,7 @@ class PayPalBasePaymentDriver extends BaseDriver 'Accept-Language' => 'en_US', 'PayPal-Partner-Attribution-Id' => 'invoiceninja_SP_PPCP', 'PayPal-Request-Id' => Str::uuid()->toString(), + 'PAYPAL-CLIENT-METADATA-ID' => $this->risk_guid, ], $headers); } @@ -459,8 +498,7 @@ class PayPalBasePaymentDriver extends BaseDriver try { $this->init()->getClientToken(); return true; - } - catch(\Exception $e) { + } catch(\Exception $e) { } @@ -470,7 +508,7 @@ class PayPalBasePaymentDriver extends BaseDriver public function importCustomers() { return true; - } + } public function processWebhookRequest(Request $request) { @@ -479,5 +517,61 @@ class PayPalBasePaymentDriver extends BaseDriver PayPalWebhook::dispatch($request->all(), $request->headers->all(), $this->access_token); } - -} \ No newline at end of file + + public function createNinjaPayment($request, $response) + { + + $data = [ + 'payment_type' => $this->getPaymentMethod($request->gateway_type_id), + 'amount' => $response['purchase_units'][0]['payments']['captures'][0]['amount']['value'], + 'transaction_reference' => $response['purchase_units'][0]['payments']['captures'][0]['id'], + 'gateway_type_id' => GatewayType::PAYPAL, + ]; + + $payment = $this->createPayment($data, \App\Models\Payment::STATUS_COMPLETED); + + if ($request->has('store_card') && $request->input('store_card') === true) { + $payment_source = $response->json()['payment_source'] ?? false; + + if(isset($payment_source['card']) && ($payment_source['card']['attributes']['vault']['status'] ?? false) && $payment_source['card']['attributes']['vault']['status'] == 'VAULTED') { + + $last4 = $payment_source['card']['last_digits']; + $expiry = $payment_source['card']['expiry']; //'2025-01' + $expiry_meta = explode('-', $expiry); + $brand = $payment_source['card']['brand']; + + $payment_meta = new \stdClass(); + $payment_meta->exp_month = $expiry_meta[1] ?? ''; + $payment_meta->exp_year = $expiry_meta[0] ?? $expiry; + $payment_meta->brand = $brand; + $payment_meta->last4 = $last4; + $payment_meta->type = GatewayType::CREDIT_CARD; + + $token = $payment_source['card']['attributes']['vault']['id']; // 09f28652d01257021 + $gateway_customer_reference = $payment_source['card']['attributes']['vault']['customer']['id']; //rbTHnLsZqE; + + $data['token'] = $token; + $data['payment_method_id'] = GatewayType::PAYPAL_ADVANCED_CARDS; + $data['payment_meta'] = $payment_meta; + + $additional['gateway_customer_reference'] = $gateway_customer_reference; + + $this->storeGatewayToken($data, $additional); + + } + } + + SystemLogger::dispatch( + ['response' => $response->json(), 'data' => $data], + SystemLog::CATEGORY_GATEWAY_RESPONSE, + SystemLog::EVENT_GATEWAY_SUCCESS, + SystemLog::TYPE_PAYPAL, + $this->client, + $this->client->company, + ); + + return response()->json(['redirect' => route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)], false)]); + + } + +} diff --git a/app/PaymentDrivers/PayPal/PayPalWebhook.php b/app/PaymentDrivers/PayPal/PayPalWebhook.php index fa08542af0e1..e4ba19d442fd 100644 --- a/app/PaymentDrivers/PayPal/PayPalWebhook.php +++ b/app/PaymentDrivers/PayPal/PayPalWebhook.php @@ -459,4 +459,4 @@ class PayPalWebhook implements ShouldQueue } ] } - */ \ No newline at end of file + */ diff --git a/app/PaymentDrivers/PayPalPPCPPaymentDriver.php b/app/PaymentDrivers/PayPalPPCPPaymentDriver.php index 3f29b8146516..1803265d4b7e 100644 --- a/app/PaymentDrivers/PayPalPPCPPaymentDriver.php +++ b/app/PaymentDrivers/PayPalPPCPPaymentDriver.php @@ -16,6 +16,7 @@ use Carbon\Carbon; use App\Models\Invoice; use App\Models\SystemLog; use App\Models\GatewayType; +use App\Models\PaymentHash; use App\Models\PaymentType; use Illuminate\Http\Request; use App\Jobs\Util\SystemLogger; @@ -29,26 +30,26 @@ use App\PaymentDrivers\PayPal\PayPalBasePaymentDriver; class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver { use MakesHash; - -///v1/customer/partners/merchant-accounts/{merchant_id}/capabilities - test if advanced cards is available. -// { -// "capabilities": [ -// { -// "name": "ADVANCED_CARD_PAYMENTS", -// "status": "ENABLED" -// }, -// { -// "name": "VAULTING", -// "status": "ENABLED" -// } -// ] -// } + + ///v1/customer/partners/merchant-accounts/{merchant_id}/capabilities - test if advanced cards is available. + // { + // "capabilities": [ + // { + // "name": "ADVANCED_CARD_PAYMENTS", + // "status": "ENABLED" + // }, + // { + // "name": "VAULTING", + // "status": "ENABLED" + // } + // ] + // } public const SYSTEM_LOG_TYPE = SystemLog::TYPE_PAYPAL_PPCP; - + /** * Checks whether payments are enabled on the merchant account - * + * * @return self */ private function checkPaymentsReceivable(): self @@ -80,10 +81,11 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver * Presents the Payment View to the client * * @param array $data - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function processPaymentView($data) { + $this->init()->checkPaymentsReceivable(); $data['gateway'] = $this; @@ -97,11 +99,15 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver $data['gateway_type_id'] = $this->gateway_type_id; $data['merchantId'] = $this->company_gateway->getConfigField('merchantId'); $data['currency'] = $this->client->currency()->code; + $data['guid'] = $this->risk_guid; + $data['identifier'] = "s:INN_".$this->company_gateway->getConfigField('merchantId')."_CHCK"; + $data['pp_client_reference'] = $this->getClientHash(); - if($this->gateway_type_id == 29) + if($this->gateway_type_id == 29) { return render('gateways.paypal.ppcp.card', $data); - else + } else { return render('gateways.paypal.ppcp.pay', $data); + } } @@ -109,14 +115,14 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver * Processes the payment response * * @param mixed $request - * @return void */ public function processPaymentResponse($request) { nlog("response"); + $this->init(); $r = false; - + $request['gateway_response'] = str_replace("Error: ", "", $request['gateway_response']); $response = json_decode($request['gateway_response'], true); @@ -155,7 +161,7 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver if($r->status() == 422) { //handle conditions where the client may need to try again. // return $this->handleRetry($r, $request); - + $r = $this->handleDuplicateInvoiceId($orderID); } @@ -176,27 +182,9 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver if(isset($response['status']) && $response['status'] == 'COMPLETED' && isset($response['purchase_units'])) { - $data = [ - 'payment_type' => $this->getPaymentMethod($request->gateway_type_id), - 'amount' => $response['purchase_units'][0]['payments']['captures'][0]['amount']['value'], - 'transaction_reference' => $response['purchase_units'][0]['payments']['captures'][0]['id'], - 'gateway_type_id' => GatewayType::PAYPAL, - ]; - $payment = $this->createPayment($data, \App\Models\Payment::STATUS_COMPLETED); + return $this->createNinjaPayment($request, $response); - SystemLogger::dispatch( - ['response' => $response, 'data' => $data], - SystemLog::CATEGORY_GATEWAY_RESPONSE, - SystemLog::EVENT_GATEWAY_SUCCESS, - SystemLog::TYPE_PAYPAL_PPCP, - $this->client, - $this->client->company, - ); - - return response()->json(['redirect' => route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)], false)]); - - // return redirect()->route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)]); } else { @@ -247,7 +235,6 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver })->implode("\n"); $order = [ - "intent" => "CAPTURE", "payment_source" => $this->getPaymentSource(), "purchase_units" => [ @@ -298,7 +285,7 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver $r = $this->gatewayRequest('/v2/checkout/orders', 'post', $order); $this->payment_hash->withData("orderID", $r->json()['id']); - + return $r->json()['id']; } @@ -306,18 +293,19 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver /** * processTokenPayment * - * With PayPal and token payments, the order needs to be + * With PayPal and token payments, the order needs to be * deleted and then created with the payment source that * has been selected by the client. - * - * This method handle the deletion of the current paypal order, + * + * This method handle the deletion of the current paypal order, * and the automatic payment of the order with the selected payment source. - * + * * @param mixed $request * @param array $response * @return void */ - public function processTokenPayment($request, array $response) { + public function processTokenPayment($request, array $response) + { /** @var \App\Models\ClientGatewayToken $cgt */ $cgt = ClientGatewayToken::where('client_id', $this->client->id) @@ -333,18 +321,44 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver "vault_id" => $cgt->token, "stored_credential" => [ "payment_initiator" => "MERCHANT", - "payment_type" => "UNSCHEDULED", + "payment_type" => "UNSCHEDULED", "usage" => "SUBSEQUENT", ], ], ]; - + $orderId = $this->createOrder($data); + + // $r = $this->gatewayRequest("/v2/checkout/orders/{$orderId}", 'get', ['body' => '']); - $r = $this->gatewayRequest("/v2/checkout/orders/{$orderId}", 'get', ['body' => '']); - + try { + + $r = $this->gatewayRequest("/v2/checkout/orders/{$orderId}", 'get', ['body' => '']); + + if($r->status() == 422) { + //handle conditions where the client may need to try again. + nlog("hit 422"); + $r = $this->handleDuplicateInvoiceId($orderId); + + + } + + } catch(\Exception $e) { + + //Rescue for duplicate invoice_id + if(stripos($e->getMessage(), 'DUPLICATE_INVOICE_ID') !== false) { + + + nlog("hit 422 in exception"); + + $r = $this->handleDuplicateInvoiceId($orderId); + + } + + } + $response = $r->json(); - + $data = [ 'payment_type' => $this->getPaymentMethod($request->gateway_type_id), 'amount' => $response['purchase_units'][0]['payments']['captures'][0]['amount']['value'], @@ -366,4 +380,73 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver return redirect()->route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)]); } -} \ No newline at end of file + + public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) + { + $data = []; + $this->payment_hash = $payment_hash; + + $data['amount_with_fee'] = $this->payment_hash->data->amount_with_fee; + $data["payment_source"] = [ + "card" => [ + "vault_id" => $cgt->token, + "stored_credential" => [ + "payment_initiator" => "MERCHANT", + "payment_type" => "UNSCHEDULED", + "usage" => "SUBSEQUENT", + ], + ], + ]; + + $orderId = $this->createOrder($data); + + $r = false; + + try { + + $r = $this->gatewayRequest("/v2/checkout/orders/{$orderId}", 'get', ['body' => '']); + + if($r->status() == 422) { + //handle conditions where the client may need to try again. + + $r = $this->handleDuplicateInvoiceId($orderId); + + + } + + } catch(\Exception $e) { + + //Rescue for duplicate invoice_id + if(stripos($e->getMessage(), 'DUPLICATE_INVOICE_ID') !== false) { + + + $r = $this->handleDuplicateInvoiceId($orderId); + + } + + } + + $response = $r->json(); + + $data = [ + 'payment_type' => $this->getPaymentMethod((string)$cgt->gateway_type_id), + 'amount' => $response['purchase_units'][0]['payments']['captures'][0]['amount']['value'], + 'transaction_reference' => $response['purchase_units'][0]['payments']['captures'][0]['id'], + 'gateway_type_id' => $this->gateway_type_id, + ]; + + $payment = $this->createPayment($data, \App\Models\Payment::STATUS_COMPLETED); + + SystemLogger::dispatch( + ['response' => $response, 'data' => $data], + SystemLog::CATEGORY_GATEWAY_RESPONSE, + SystemLog::EVENT_GATEWAY_SUCCESS, + SystemLog::TYPE_PAYPAL_PPCP, + $this->client, + $this->client->company, + ); + + + } + +} diff --git a/app/PaymentDrivers/PayPalRestPaymentDriver.php b/app/PaymentDrivers/PayPalRestPaymentDriver.php index 5e06c72d2422..d6e8dbadcf5c 100644 --- a/app/PaymentDrivers/PayPalRestPaymentDriver.php +++ b/app/PaymentDrivers/PayPalRestPaymentDriver.php @@ -20,6 +20,7 @@ use App\Jobs\Util\SystemLogger; use App\Utils\Traits\MakesHash; use App\Exceptions\PaymentFailed; use App\Models\ClientGatewayToken; +use App\Models\PaymentHash; use App\PaymentDrivers\PayPal\PayPalBasePaymentDriver; class PayPalRestPaymentDriver extends PayPalBasePaymentDriver @@ -30,6 +31,7 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver public function processPaymentView($data) { + $this->init(); $data['gateway'] = $this; @@ -43,34 +45,37 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver $data['funding_source'] = $this->paypal_payment_method; $data['gateway_type_id'] = $this->gateway_type_id; $data['currency'] = $this->client->currency()->code; + $data['guid'] = $this->risk_guid; + $data['identifier'] = "s:INN_ACDC_CHCK"; + $data['pp_client_reference'] = $this->getClientHash(); - if($this->gateway_type_id == 29) + if($this->gateway_type_id == 29) { return render('gateways.paypal.ppcp.card', $data); - else + } else { return render('gateways.paypal.pay', $data); + } } - - + /** * processPaymentResponse * * @param mixed $request - * @return void */ public function processPaymentResponse($request) { nlog("response"); $this->init(); $r = false; - + $request['gateway_response'] = str_replace("Error: ", "", $request['gateway_response']); $response = json_decode($request['gateway_response'], true); - + nlog($response); - if($request->has('token') && strlen($request->input('token')) > 2) + if($request->has('token') && strlen($request->input('token')) > 2) { return $this->processTokenPayment($request, $response); + } //capture @@ -96,11 +101,11 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver } - try{ - + try { + $r = $this->gatewayRequest("/v2/checkout/orders/{$orderID}/capture", 'post', ['body' => '']); - if($r->status() == 422){ + if($r->status() == 422) { //handle conditions where the client may need to try again. $r = $this->handleDuplicateInvoiceId($orderID); @@ -108,13 +113,12 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver } - } - catch(\Exception $e) { + } catch(\Exception $e) { //Rescue for duplicate invoice_id - if(stripos($e->getMessage(), 'DUPLICATE_INVOICE_ID') !== false){ + if(stripos($e->getMessage(), 'DUPLICATE_INVOICE_ID') !== false) { + - $r = $this->handleDuplicateInvoiceId($orderID); } @@ -128,7 +132,7 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver if(isset($response['status']) && $response['status'] == 'COMPLETED' && isset($response['purchase_units'])) { - return $this->createNinjaPayment($request, $response); + return $this->createNinjaPayment($request, $response); } else { @@ -153,65 +157,10 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver } + + - private function createNinjaPayment($request, $response) { - - $data = [ - 'payment_type' => $this->getPaymentMethod($request->gateway_type_id), - 'amount' => $response['purchase_units'][0]['payments']['captures'][0]['amount']['value'], - 'transaction_reference' => $response['purchase_units'][0]['payments']['captures'][0]['id'], - 'gateway_type_id' => GatewayType::PAYPAL, - ]; - - $payment = $this->createPayment($data, \App\Models\Payment::STATUS_COMPLETED); - - if ($request->has('store_card') && $request->input('store_card') === true) { - $payment_source = $response->json()['payment_source']; - - if(isset($payment_source['card']) && ($payment_source['card']['attributes']['vault']['status'] ?? false) && $payment_source['card']['attributes']['vault']['status'] == 'VAULTED') { - - $last4 = $payment_source['card']['last_digits']; - $expiry = $payment_source['card']['expiry']; //'2025-01' - $expiry_meta = explode('-', $expiry); - $brand = $payment_source['card']['brand']; - - $payment_meta = new \stdClass(); - $payment_meta->exp_month = $expiry_meta[1] ?? ''; - $payment_meta->exp_year = $expiry_meta[0] ?? $expiry; - $payment_meta->brand = $brand; - $payment_meta->last4 = $last4; - $payment_meta->type = GatewayType::CREDIT_CARD; - - $token = $payment_source['card']['attributes']['vault']['id']; // 09f28652d01257021 - $gateway_customer_reference = $payment_source['card']['attributes']['vault']['customer']['id']; //rbTHnLsZqE; - - $data['token'] = $token; - $data['payment_method_id'] = GatewayType::PAYPAL_ADVANCED_CARDS; - $data['payment_meta'] = $payment_meta; - - $additional['gateway_customer_reference'] = $gateway_customer_reference; - - $this->storeGatewayToken($data, $additional); - - } - } - - SystemLogger::dispatch( - ['response' => $response->json(), 'data' => $data], - SystemLog::CATEGORY_GATEWAY_RESPONSE, - SystemLog::EVENT_GATEWAY_SUCCESS, - SystemLog::TYPE_PAYPAL, - $this->client, - $this->client->company, - ); - - return response()->json(['redirect' => route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)], false)]); - - // return redirect()->route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)]); - - } - public function createOrder(array $data): string { @@ -260,16 +209,35 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver $order['purchase_units'][0]["shipping"] = $shipping; } - if(isset($data['payment_source'])) + if(isset($data['payment_source'])) { $order['payment_source'] = $data['payment_source']; + } $r = $this->gatewayRequest('/v2/checkout/orders', 'post', $order); nlog($r->json()); $response = $r->json(); - if(!isset($response['id'])) + + if($r->status() == 422) { + //handle conditions where the client may need to try again. + + $_invoice = collect($this->payment_hash->data->invoices)->first(); + $invoice = Invoice::withTrashed()->find($this->decodePrimaryKey($_invoice->invoice_id)); + $new_invoice_number = $invoice->number."_".Str::random(5); + + $order['purchase_units'][0]['invoice_id'] = $new_invoice_number; + + $r = $this->gatewayRequest('/v2/checkout/orders', 'post', $order); + + nlog($r->json()); + $response = $r->json(); + + } + + if(!isset($response['id'])) { $this->handleProcessingFailure($response); + } $this->payment_hash->withData("orderID", $response['id']); @@ -282,18 +250,19 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver /** * processTokenPayment * - * With PayPal and token payments, the order needs to be + * With PayPal and token payments, the order needs to be * deleted and then created with the payment source that * has been selected by the client. - * - * This method handle the deletion of the current paypal order, + * + * This method handle the deletion of the current paypal order, * and the automatic payment of the order with the selected payment source. - * + * + * ** Do not move to BasePPDriver ** * @param mixed $request * @param array $response - * @return void */ - public function processTokenPayment($request, array $response) { + public function processTokenPayment($request, array $response) + { /** @var \App\Models\ClientGatewayToken $cgt */ $cgt = ClientGatewayToken::where('client_id', $this->client->id) @@ -303,24 +272,52 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver $orderId = $response['orderID']; $r = $this->gatewayRequest("/v1/checkout/orders/{$orderId}/", 'delete', ['body' => '']); + nlog($r->body()); + $data['amount_with_fee'] = $this->payment_hash->data->amount_with_fee; $data["payment_source"] = [ "card" => [ "vault_id" => $cgt->token, "stored_credential" => [ "payment_initiator" => "MERCHANT", - "payment_type" => "UNSCHEDULED", + "payment_type" => "UNSCHEDULED", "usage" => "SUBSEQUENT", ], ], ]; - + $orderId = $this->createOrder($data); - - $r = $this->gatewayRequest("/v2/checkout/orders/{$orderId}", 'get', ['body' => '']); - + + // $r = $this->gatewayRequest("/v2/checkout/orders/{$orderId}", 'get', ['body' => '']); + + try { + + $r = $this->gatewayRequest("/v2/checkout/orders/{$orderId}", 'get', ['body' => '']); + + if($r->status() == 422) { + //handle conditions where the client may need to try again. + nlog("hit 422"); + $r = $this->handleDuplicateInvoiceId($orderId); + + + } + + } catch(\Exception $e) { + + //Rescue for duplicate invoice_id + if(stripos($e->getMessage(), 'DUPLICATE_INVOICE_ID') !== false) { + + + nlog("hit 422 in exception"); + + $r = $this->handleDuplicateInvoiceId($orderId); + + } + + } + $response = $r->json(); - + $data = [ 'payment_type' => $this->getPaymentMethod($request->gateway_type_id), 'amount' => $response['purchase_units'][0]['payments']['captures'][0]['amount']['value'], @@ -342,4 +339,72 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver return redirect()->route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)]); } + + public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) + { + $data = []; + $this->payment_hash = $payment_hash; + + $data['amount_with_fee'] = $this->payment_hash->data->amount_with_fee; + $data["payment_source"] = [ + "card" => [ + "vault_id" => $cgt->token, + "stored_credential" => [ + "payment_initiator" => "MERCHANT", + "payment_type" => "UNSCHEDULED", + "usage" => "SUBSEQUENT", + ], + ], + ]; + + $orderId = $this->createOrder($data); + + $r = false; + + try { + + $r = $this->gatewayRequest("/v2/checkout/orders/{$orderId}", 'get', ['body' => '']); + + if($r->status() == 422) { + //handle conditions where the client may need to try again. + + $r = $this->handleDuplicateInvoiceId($orderId); + + + } + + } catch(\Exception $e) { + + //Rescue for duplicate invoice_id + if(stripos($e->getMessage(), 'DUPLICATE_INVOICE_ID') !== false) { + + + $r = $this->handleDuplicateInvoiceId($orderId); + + } + + } + + $response = $r->json(); + + $data = [ + 'payment_type' => $this->getPaymentMethod((string)$cgt->gateway_type_id), + 'amount' => $response['purchase_units'][0]['payments']['captures'][0]['amount']['value'], + 'transaction_reference' => $response['purchase_units'][0]['payments']['captures'][0]['id'], + 'gateway_type_id' => $this->gateway_type_id, + ]; + + $payment = $this->createPayment($data, \App\Models\Payment::STATUS_COMPLETED); + + SystemLogger::dispatch( + ['response' => $response, 'data' => $data], + SystemLog::CATEGORY_GATEWAY_RESPONSE, + SystemLog::EVENT_GATEWAY_SUCCESS, + SystemLog::TYPE_PAYPAL_PPCP, + $this->client, + $this->client->company, + ); + + + } } diff --git a/app/PaymentDrivers/PaytracePaymentDriver.php b/app/PaymentDrivers/PaytracePaymentDriver.php index 2b7ac2677bfe..bb0348d0a5dd 100644 --- a/app/PaymentDrivers/PaytracePaymentDriver.php +++ b/app/PaymentDrivers/PaytracePaymentDriver.php @@ -270,8 +270,7 @@ class PaytracePaymentDriver extends BaseDriver try { $this->init()->generateAuthHeaders() && strlen($this->company_gateway->getConfigField('integratorId')) > 2; return true; - } - catch(\Exception $e){ + } catch(\Exception $e) { } @@ -291,31 +290,31 @@ class PaytracePaymentDriver extends BaseDriver nlog($response); if ($response && $response->success) { - + $client_repo = new ClientRepository(new ClientContactRepository()); $factory = new PaytraceCustomerFactory(); - foreach($response->customers as $customer) - { + foreach($response->customers as $customer) { $data = $factory->convertToNinja($customer, $this->company_gateway->company); - + $client = false; - if(str_contains($data['contacts'][0]['email'], "@")) - { + if(str_contains($data['contacts'][0]['email'], "@")) { $client = ClientContact::query() ->where('company_id', $this->company_gateway->company_id) ->where('email', $data['contacts'][0]['email']) ->first()->client ?? false; } - if(!$client) + if(!$client) { $client = $client_repo->save($data, ClientFactory::create($this->company_gateway->company_id, $this->company_gateway->user_id)); - + } + $this->client = $client; - if(ClientGatewayToken::query()->where('client_id', $client->id)->where('token',$data['card']['token'])->exists()) + if(ClientGatewayToken::query()->where('client_id', $client->id)->where('token', $data['card']['token'])->exists()) { continue; + } $cgt = []; $cgt['token'] = $data['card']['token']; @@ -331,7 +330,7 @@ class PaytracePaymentDriver extends BaseDriver $cgt['payment_meta'] = $payment_meta; $token = $this->storeGatewayToken($cgt, []); - + } } diff --git a/app/PaymentDrivers/Razorpay/Hosted.php b/app/PaymentDrivers/Razorpay/Hosted.php index 3528535a47ce..2a8c35bafc1f 100644 --- a/app/PaymentDrivers/Razorpay/Hosted.php +++ b/app/PaymentDrivers/Razorpay/Hosted.php @@ -52,7 +52,7 @@ class Hosted implements MethodInterface * Handle the authorization page for Razorpay. * * @param Request $request - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function authorizeResponse(Request $request): RedirectResponse { @@ -127,7 +127,7 @@ class Hosted implements MethodInterface * Handle the successful payment for Razorpay. * * @param string $payment_id - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function processSuccessfulPayment(string $payment_id): RedirectResponse { diff --git a/app/PaymentDrivers/Square/CreditCard.php b/app/PaymentDrivers/Square/CreditCard.php index d44f69b77d6c..1075b0a292ad 100644 --- a/app/PaymentDrivers/Square/CreditCard.php +++ b/app/PaymentDrivers/Square/CreditCard.php @@ -55,7 +55,7 @@ class CreditCard implements MethodInterface * Handle authorization for credit card. * * @param Request $request - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function authorizeResponse($request): RedirectResponse { @@ -238,5 +238,5 @@ class CreditCard implements MethodInterface return false; } - + } diff --git a/app/PaymentDrivers/SquarePaymentDriver.php b/app/PaymentDrivers/SquarePaymentDriver.php index d8ef5633f450..8e590059e515 100644 --- a/app/PaymentDrivers/SquarePaymentDriver.php +++ b/app/PaymentDrivers/SquarePaymentDriver.php @@ -450,66 +450,68 @@ class SquarePaymentDriver extends BaseDriver public function importCustomers() { - + $limit = 100; $api_response = $this->init() ->square ->getCustomersApi() - ->listCustomers(null, + ->listCustomers( + null, $limit, 'DEFAULT', 'DESC' ); if ($api_response->isSuccess()) { - - while ($api_response->getResult()->getCustomers()) { - $customers = $api_response->getResult()->getCustomers(); + while ($api_response->getResult()->getCustomers()) { - $client_repo = new ClientRepository(new ClientContactRepository()); + $customers = $api_response->getResult()->getCustomers(); - foreach($customers as $customer) - { + $client_repo = new ClientRepository(new ClientContactRepository()); - $data = (new SquareCustomerFactory())->convertToNinja($customer, $this->company_gateway->company); - $client = ClientContact::where('company_id', $this->company_gateway->company_id)->where('email', $customer->getEmailAddress())->first()->client ?? false; + foreach($customers as $customer) { - if(!$client) - $client = $client_repo->save($data, ClientFactory::create($this->company_gateway->company_id, $this->company_gateway->user_id)); + $data = (new SquareCustomerFactory())->convertToNinja($customer, $this->company_gateway->company); + $client = ClientContact::where('company_id', $this->company_gateway->company_id)->where('email', $customer->getEmailAddress())->first()->client ?? false; - $this->client = $client; + if(!$client) { + $client = $client_repo->save($data, ClientFactory::create($this->company_gateway->company_id, $this->company_gateway->user_id)); + } - foreach($data['cards'] as $card) { - - if(ClientGatewayToken::where('company_id', $this->company_gateway->company_id)->where('token', $card['token'])->exists()) - continue; + $this->client = $client; - $this->storeGatewayToken($card); + foreach($data['cards'] as $card) { + if(ClientGatewayToken::where('company_id', $this->company_gateway->company_id)->where('token', $card['token'])->exists()) { + continue; + } + + $this->storeGatewayToken($card); + + } } - } - - $c = $api_response->getCursor(); - if ($c) { - $api_response = $this->init() - ->square - ->getCustomersApi() - ->listCustomers( + $c = $api_response->getCursor(); + if ($c) { + + $api_response = $this->init() + ->square + ->getCustomersApi() + ->listCustomers( $c, $limit, 'DEFAULT', 'DESC' ); - } else { - break; + } else { + break; + } + + } - - } - } } @@ -558,8 +560,9 @@ class SquarePaymentDriver extends BaseDriver public function findOrCreateClient() { - if($customer_id = $this->findClient()) + if($customer_id = $this->findClient()) { return $customer_id; + } return $this->createClient(); } diff --git a/app/PaymentDrivers/Stripe/ACH.php b/app/PaymentDrivers/Stripe/ACH.php index 6e43f04784cf..b21641609476 100644 --- a/app/PaymentDrivers/Stripe/ACH.php +++ b/app/PaymentDrivers/Stripe/ACH.php @@ -113,10 +113,10 @@ class ACH //double check here if we need to show the verification view. $this->stripe->init(); - if(substr($token->token,0,2) == 'pm'){ + if(substr($token->token, 0, 2) == 'pm') { $pm = $this->stripe->getStripePaymentMethod($token->token); - - if(!$pm->customer){ + + if(!$pm->customer) { $meta = $token->meta; $meta->state = 'unauthorized'; @@ -134,8 +134,9 @@ class ACH ->with('message', __('texts.payment_method_verified')); } - if($token->meta->next_action) + if($token->meta->next_action) { return redirect($token->meta->next_action); + } } @@ -340,7 +341,7 @@ class ACH $data['message'] = 'Too many requests made to the API too quickly'; break; case $e instanceof InvalidRequestException: - + return redirect()->route('client.payment_methods.verification', ['payment_method' => $cgt->hashed_id, 'method' => GatewayType::BANK_TRANSFER]); $data['message'] = 'Invalid parameters were supplied to Stripe\'s API'; diff --git a/app/PaymentDrivers/Stripe/BrowserPay.php b/app/PaymentDrivers/Stripe/BrowserPay.php index 7ec846168cf4..d468d0a2b7c2 100644 --- a/app/PaymentDrivers/Stripe/BrowserPay.php +++ b/app/PaymentDrivers/Stripe/BrowserPay.php @@ -46,7 +46,7 @@ class BrowserPay implements MethodInterface * Authorization page for browser pay. * * @param array $data - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function authorizeView(array $data): RedirectResponse { @@ -57,7 +57,7 @@ class BrowserPay implements MethodInterface * Handle the authorization for browser pay. * * @param Request $request - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ public function authorizeResponse(Request $request): RedirectResponse { @@ -100,7 +100,7 @@ class BrowserPay implements MethodInterface * Handle payment response for browser pay. * * @param PaymentResponseRequest $request - * @return RedirectResponse|App\PaymentDrivers\Stripe\never + * @return \Illuminate\Http\RedirectResponse|App\PaymentDrivers\Stripe\never */ public function paymentResponse(PaymentResponseRequest $request) { @@ -120,7 +120,7 @@ class BrowserPay implements MethodInterface /** * Handle successful payment for browser pay. * - * @return RedirectResponse + * @return \Illuminate\Http\RedirectResponse */ protected function processSuccessfulPayment() { diff --git a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentFailureWebhook.php b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentFailureWebhook.php index 1c5a9b24b5b8..28b4db9d7bec 100644 --- a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentFailureWebhook.php +++ b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentFailureWebhook.php @@ -66,12 +66,14 @@ class PaymentIntentFailureWebhook implements ShouldQueue $payment = Payment::query() ->where('company_id', $company->id) ->where(function ($query) use ($transaction) { - - if(isset($transaction['payment_intent'])) + + if(isset($transaction['payment_intent'])) { $query->where('transaction_reference', $transaction['payment_intent']); - - if(isset($transaction['payment_intent']) && isset($transaction['id'])) + } + + if(isset($transaction['payment_intent']) && isset($transaction['id'])) { $query->orWhere('transaction_reference', $transaction['id']); + } if(!isset($transaction['payment_intent']) && isset($transaction['id'])) { $query->where('transaction_reference', $transaction['id']); diff --git a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentProcessingWebhook.php b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentProcessingWebhook.php index c277bb221fd4..3b0c3b30982a 100644 --- a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentProcessingWebhook.php +++ b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentProcessingWebhook.php @@ -64,7 +64,7 @@ class PaymentIntentProcessingWebhook implements ShouldQueue $company = Company::query()->where('company_key', $this->company_key)->first(); foreach ($this->stripe_request as $transaction) { - + $payment = Payment::query() ->where('company_id', $company->id) diff --git a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php index 3cb0d6d403ec..367a99c24206 100644 --- a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php +++ b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php @@ -63,7 +63,7 @@ class PaymentIntentWebhook implements ShouldQueue $company = Company::query()->where('company_key', $this->company_key)->first(); foreach ($this->stripe_request as $transaction) { - + $payment = Payment::query() ->where('company_id', $company->id) ->where(function ($query) use ($transaction) { @@ -100,8 +100,9 @@ class PaymentIntentWebhook implements ShouldQueue $company_gateway = CompanyGateway::query()->find($this->company_gateway_id); - if(!$company_gateway) + if(!$company_gateway) { return; + } $stripe_driver = $company_gateway->driver()->init(); diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index d5f8e689dad7..3b3a2047d4ef 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -263,7 +263,7 @@ class StripePaymentDriver extends BaseDriver && in_array($this->client->country->iso_3166_3, ['AUT','BEL','DNK','FIN','FRA','DEU','IRL','ITA','NLD','NOR','ESP','SWE','GBR','USA'])) { $types[] = GatewayType::KLARNA; } - + if ( $this->client && isset($this->client->country) @@ -330,12 +330,12 @@ class StripePaymentDriver extends BaseDriver } // if ($this->company_gateway->require_contact_name) { - $fields[] = ['name' => 'contact_first_name', 'label' => ctrans('texts.first_name'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'contact_last_name', 'label' => ctrans('texts.last_name'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'contact_first_name', 'label' => ctrans('texts.first_name'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'contact_last_name', 'label' => ctrans('texts.last_name'), 'type' => 'text', 'validation' => 'required']; // } // if ($this->company_gateway->require_contact_email) { - $fields[] = ['name' => 'contact_email', 'label' => ctrans('texts.email'), 'type' => 'text', 'validation' => 'required,email:rfc']; + $fields[] = ['name' => 'contact_email', 'label' => ctrans('texts.email'), 'type' => 'text', 'validation' => 'required,email:rfc']; // } if ($this->company_gateway->require_client_phone) { @@ -389,7 +389,7 @@ class StripePaymentDriver extends BaseDriver * Proxy method to pass the data into payment method authorizeView(). * * @param array $data - * @return RedirectResponse|mixed + * @return \Illuminate\Http\RedirectResponse|mixed */ public function authorizeView(array $data) { @@ -400,7 +400,7 @@ class StripePaymentDriver extends BaseDriver * Processes the gateway response for credit card authorization. * * @param \Illuminate\Http\Request $request - * @return RedirectResponse|mixed + * @return \Illuminate\Http\RedirectResponse|mixed */ public function authorizeResponse($request) { @@ -411,7 +411,7 @@ class StripePaymentDriver extends BaseDriver * Process the payment with gateway. * * @param array $data - * @return RedirectResponse|mixed + * @return \Illuminate\Http\RedirectResponse|mixed */ public function processPaymentView(array $data) { @@ -680,7 +680,7 @@ class StripePaymentDriver extends BaseDriver } if ($request->type === 'payment_intent.processing') { - PaymentIntentProcessingWebhook::dispatch($request->data, $request->company_key, $this->company_gateway->id)->delay(now()->addSeconds(rand(10,12))); + PaymentIntentProcessingWebhook::dispatch($request->data, $request->company_key, $this->company_gateway->id)->delay(now()->addSeconds(rand(10, 12))); return response()->json([], 200); } @@ -705,26 +705,26 @@ class StripePaymentDriver extends BaseDriver if ($request->type === 'charge.succeeded') { foreach ($request->data as $transaction) { - - $payment = Payment::query() - ->where('company_id', $this->company_gateway->company_id) - ->where(function ($query) use ($transaction) { - if(isset($transaction['payment_intent'])) { - $query->where('transaction_reference', $transaction['payment_intent']); - } + $payment = Payment::query() + ->where('company_id', $this->company_gateway->company_id) + ->where(function ($query) use ($transaction) { - if(isset($transaction['payment_intent']) && isset($transaction['id'])) { - $query->orWhere('transaction_reference', $transaction['id']); - } + if(isset($transaction['payment_intent'])) { + $query->where('transaction_reference', $transaction['payment_intent']); + } - if(!isset($transaction['payment_intent']) && isset($transaction['id'])) { - $query->where('transaction_reference', $transaction['id']); - } + if(isset($transaction['payment_intent']) && isset($transaction['id'])) { + $query->orWhere('transaction_reference', $transaction['id']); + } - }) - ->first(); + if(!isset($transaction['payment_intent']) && isset($transaction['id'])) { + $query->where('transaction_reference', $transaction['id']); + } + + }) + ->first(); if ($payment) { @@ -752,26 +752,26 @@ class StripePaymentDriver extends BaseDriver ], $this->stripe_connect_auth); if ($charge->captured) { - - $payment = Payment::query() - ->where('company_id', $this->company_gateway->company_id) - ->where(function ($query) use ($transaction) { - if(isset($transaction['payment_intent'])) { - $query->where('transaction_reference', $transaction['payment_intent']); - } + $payment = Payment::query() + ->where('company_id', $this->company_gateway->company_id) + ->where(function ($query) use ($transaction) { - if(isset($transaction['payment_intent']) && isset($transaction['id'])) { - $query->orWhere('transaction_reference', $transaction['id']); - } + if(isset($transaction['payment_intent'])) { + $query->where('transaction_reference', $transaction['payment_intent']); + } - if(!isset($transaction['payment_intent']) && isset($transaction['id'])) { - $query->where('transaction_reference', $transaction['id']); - } + if(isset($transaction['payment_intent']) && isset($transaction['id'])) { + $query->orWhere('transaction_reference', $transaction['id']); + } - }) - ->first(); + if(!isset($transaction['payment_intent']) && isset($transaction['id'])) { + $query->where('transaction_reference', $transaction['id']); + } + + }) + ->first(); @@ -1010,9 +1010,8 @@ class StripePaymentDriver extends BaseDriver try { $this->verifyConnect(); return true; - } - catch(\Exception $e) { - + } catch(\Exception $e) { + } return false; diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index f90a4a9e4a48..ec849224b615 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -122,7 +122,7 @@ class AppServiceProvider extends ServiceProvider }); Mail::extend('brevo', function () { - return (new BrevoTransportFactory)->create( + return (new BrevoTransportFactory())->create( new Dsn( 'brevo+api', 'default', @@ -133,7 +133,7 @@ class AppServiceProvider extends ServiceProvider Mailer::macro('brevo_config', function (string $brevo_key) { // @phpstan-ignore /** @phpstan-ignore-next-line **/ Mailer::setSymfonyTransport( - (new BrevoTransportFactory)->create( + (new BrevoTransportFactory())->create( new Dsn( 'brevo+api', 'default', diff --git a/app/Providers/StaticServiceProvider.php b/app/Providers/StaticServiceProvider.php index 4327edb1682d..523a92e08c0b 100644 --- a/app/Providers/StaticServiceProvider.php +++ b/app/Providers/StaticServiceProvider.php @@ -34,7 +34,7 @@ class StaticServiceProvider extends ServiceProvider public function register() { - + app()->singleton('currencies', function ($app) { return Currency::query()->orderBy('name')->get(); }); @@ -128,4 +128,4 @@ class StaticServiceProvider extends ServiceProvider { } -} \ No newline at end of file +} diff --git a/app/Repositories/BankTransactionRepository.php b/app/Repositories/BankTransactionRepository.php index f7d275ae9057..8488f12938f8 100644 --- a/app/Repositories/BankTransactionRepository.php +++ b/app/Repositories/BankTransactionRepository.php @@ -42,7 +42,7 @@ class BankTransactionRepository extends BaseRepository $data['transactions'] = $bank_transactions->map(function ($bt) { return ['id' => $bt->id, 'invoice_ids' => $bt->invoice_ids, 'ninja_category_id' => $bt->ninja_category_id]; })->toArray(); - + $bts = (new MatchBankTransactions($user->company()->id, $user->company()->db, $data))->handle(); } diff --git a/app/Repositories/BaseRepository.php b/app/Repositories/BaseRepository.php index ff2c6e1f8816..24248c58b08f 100644 --- a/app/Repositories/BaseRepository.php +++ b/app/Repositories/BaseRepository.php @@ -380,7 +380,7 @@ class BaseRepository return $model->fresh(); } - public function bulkUpdate(\Illuminate\Database\Eloquent\Builder $model, string $column, mixed $new_value) :void + public function bulkUpdate(\Illuminate\Database\Eloquent\Builder $model, string $column, mixed $new_value): void { $model->update([$column => $new_value]); } diff --git a/app/Repositories/ClientRepository.php b/app/Repositories/ClientRepository.php index f9c25a2e3ab0..8c52b83f9572 100644 --- a/app/Repositories/ClientRepository.php +++ b/app/Repositories/ClientRepository.php @@ -126,7 +126,7 @@ class ClientRepository extends BaseRepository ClientFactory::create($user->company()->id, $user->id) ); } - + /** * Bulk assign clients to a group. * @@ -144,7 +144,7 @@ class ClientRepository extends BaseRepository public function purge($client) { - + nlog("Purging client id => {$client->id}"); $client->contacts()->forceDelete(); diff --git a/app/Repositories/SubscriptionRepository.php b/app/Repositories/SubscriptionRepository.php index fc668600cd91..e340b0e78d51 100644 --- a/app/Repositories/SubscriptionRepository.php +++ b/app/Repositories/SubscriptionRepository.php @@ -118,25 +118,26 @@ class SubscriptionRepository extends BaseRepository return $line_items; } - + /** * ConvertV3Bundle * * Removing the nested keys of the items array - * + * * @param array $bundle * @return array */ private function convertV3Bundle($bundle): array { - if(is_object($bundle)) - $bundle = json_decode(json_encode($bundle),1); + if(is_object($bundle)) { + $bundle = json_decode(json_encode($bundle), 1); + } $items = []; foreach($bundle['recurring_products'] as $key => $value) { - $line_item = new \stdClass; + $line_item = new \stdClass(); $line_item->product_key = $value['product']['product_key']; $line_item->qty = (float) $value['quantity']; $line_item->unit_cost = (float) $value['product']['price']; @@ -147,7 +148,7 @@ class SubscriptionRepository extends BaseRepository foreach($bundle['recurring_products'] as $key => $value) { - $line_item = new \stdClass; + $line_item = new \stdClass(); $line_item->product_key = $value['product']['product_key']; $line_item->qty = (float) $value['quantity']; $line_item->unit_cost = (float) $value['product']['price']; @@ -163,8 +164,9 @@ class SubscriptionRepository extends BaseRepository public function generateBundleLineItems($bundle, $is_recurring = false, $is_credit = false) { - if(isset($bundle->recurring_products)) + if(isset($bundle->recurring_products)) { $bundle = $this->convertV3Bundle($bundle); + } $multiplier = $is_credit ? -1 : 1; diff --git a/app/Repositories/TaskRepository.php b/app/Repositories/TaskRepository.php index 36097917be28..0da689a3bfd5 100644 --- a/app/Repositories/TaskRepository.php +++ b/app/Repositories/TaskRepository.php @@ -111,8 +111,7 @@ class TaskRepository extends BaseRepository $key_values = array_column($time_log, 0); array_multisort($key_values, SORT_ASC, $time_log); - foreach($time_log as $key => $value) - { + foreach($time_log as $key => $value) { $time_log[$key][1] = $this->roundTimeLog($time_log[$key][0], $time_log[$key][1]); } @@ -254,25 +253,28 @@ class TaskRepository extends BaseRepository public function roundTimeLog(int $start_time, int $end_time): int { - if($this->task_round_to_nearest == 1 || $end_time == 0) + if($this->task_round_to_nearest == 1 || $end_time == 0) { return $end_time; + } $interval = $end_time - $start_time; - - if($this->task_round_up) - return $start_time + (int)ceil($interval/$this->task_round_to_nearest)*$this->task_round_to_nearest; - if($interval <= $this->task_round_to_nearest) + if($this->task_round_up) { + return $start_time + (int)ceil($interval / $this->task_round_to_nearest) * $this->task_round_to_nearest; + } + + if($interval <= $this->task_round_to_nearest) { return $start_time; - - return $start_time + (int)floor($interval/$this->task_round_to_nearest) * $this->task_round_to_nearest; + } + + return $start_time + (int)floor($interval / $this->task_round_to_nearest) * $this->task_round_to_nearest; } public function stop(Task $task) { $this->init($task); - + $log = json_decode($task->time_log, true); $last = end($log); @@ -305,7 +307,7 @@ class TaskRepository extends BaseRepository private function init(Task $task): self { - + $this->task_round_up = $task->client ? $task->client->getSetting('task_round_up') : $task->company->getSetting('task_round_up'); $this->task_round_to_nearest = $task->client ? $task->client->getSetting('task_round_to_nearest') : $task->company->getSetting('task_round_to_nearest'); diff --git a/app/Repositories/UserRepository.php b/app/Repositories/UserRepository.php index 4334b87cea70..d155c133bd3b 100644 --- a/app/Repositories/UserRepository.php +++ b/app/Repositories/UserRepository.php @@ -207,7 +207,7 @@ class UserRepository extends BaseRepository $cu->restore(); $cu->tokens()->restore(); - + event(new UserWasRestored($user, auth()->user(), auth()->user()->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); } diff --git a/app/Services/Client/PaymentMethod.php b/app/Services/Client/PaymentMethod.php index 25f8091a4131..5d91bae79664 100644 --- a/app/Services/Client/PaymentMethod.php +++ b/app/Services/Client/PaymentMethod.php @@ -41,8 +41,8 @@ class PaymentMethod public function run() { $this->getGateways() - ->getMethods() - ->buildUrls(); + ->getMethods(); + // ->buildUrls(); return $this->getPaymentUrls(); } @@ -61,10 +61,11 @@ class PaymentMethod { $company_gateways = $this->client->getSetting('company_gateway_ids'); - //we need to check for "0" here as we disable a payment gateway for a client with the number "0" + // We need to check for "0" here as we disable a payment gateway for a client with the number "0" if ($company_gateways || $company_gateways == '0') { $transformed_ids = $this->transformKeys(explode(',', $company_gateways)); + //gateways disabled if($company_gateways == '0') { $transformed_ids = []; } @@ -80,26 +81,6 @@ class PaymentMethod return array_search($model->id, $transformed_ids); // this closure sorts for us }); - //2023-10-11 - Roll back, do not show any gateways, if they have been archived upstream. - //removing this logic now to prevent any - // if($this->gateways->count() == 0 && count($transformed_ids) >=1) { - - // /** - // * This is a fallback in case a user archives some gateways that have been ordered preferentially. - // * - // * If the user archives a parent gateway upstream, it may leave a client setting in a state where no payment gateways are available. - // * - // * In this case we fall back to all gateways. - // */ - // $this->gateways = CompanyGateway::query() - // ->with('gateway') - // ->where('company_id', $this->client->company_id) - // ->where('gateway_key', '!=', '54faab2ab6e3223dbe848b1686490baa') - // ->whereNull('deleted_at') - // ->where('is_deleted', false)->get(); - - // } - } else { $this->gateways = CompanyGateway::query() ->with('gateway') @@ -173,6 +154,19 @@ class PaymentMethod //** Plucks the remaining keys into its own collection $this->payment_methods = $payment_methods_collections->intersectByKeys($payment_methods_collections->flatten(1)->unique()); + //@15-06-2024 + foreach($this->payment_methods as $key => $type) + { + foreach ($type as $gateway_id => $gateway_type_id) + { + $gate = $this->gateways->where('id',$gateway_id)->first(); + $this->buildUrl($gate, $gateway_type_id); + } + } + + //@15-06-2024 + $this->payment_methods =[]; + /* Loop through custom gateways if any exist and append them to the methods collection*/ $this->getCustomGateways(); @@ -181,10 +175,14 @@ class PaymentMethod foreach ($gateway->driver($this->client)->gatewayTypes() as $type) { if (isset($gateway->fees_and_limits) && is_object($gateway->fees_and_limits) && property_exists($gateway->fees_and_limits, GatewayType::CREDIT_CARD)) { if ($this->validGatewayForAmount($gateway->fees_and_limits->{GatewayType::CREDIT_CARD}, $this->amount)) { - $this->payment_methods[] = [$gateway->id => $type]; + // $this->payment_methods[] = [$gateway->id => $type]; + //@15-06-2024 + $this->buildUrl($gateway, $type); } } else { - $this->payment_methods[] = [$gateway->id => null]; + // $this->payment_methods[] = [$gateway->id => null]; + //@15-06-2024 + $this->buildUrl($gateway, null); } } } @@ -192,6 +190,30 @@ class PaymentMethod return $this; } + + //@15-06-2024 + private function buildUrl(CompanyGateway $gateway, ?int $type = null) + { + + $fee_label = $gateway->calcGatewayFeeLabel($this->amount, $this->client, $type); + + if (! $type || (GatewayType::CUSTOM == $type)) { + $this->payment_urls[] = [ + 'label' => $gateway->getConfigField('name').$fee_label, + 'company_gateway_id' => $gateway->id, + 'gateway_type_id' => GatewayType::CREDIT_CARD, + ]; + } else { + $this->payment_urls[] = [ + 'label' => $gateway->getTypeAlias($type).$fee_label, + 'company_gateway_id' => $gateway->id, + 'gateway_type_id' => $type, + ]; + } + + } + + //@deprecated as buildUrl() supercedes private function buildUrls() { foreach ($this->payment_methods as $key => $child_array) { diff --git a/app/Services/Client/Statement.php b/app/Services/Client/Statement.php index a1a93fc900f4..9b574e0674dd 100644 --- a/app/Services/Client/Statement.php +++ b/app/Services/Client/Statement.php @@ -63,10 +63,10 @@ class Statement $variables = []; $variables = $html->generateLabelsAndValues(); - + $option_template = &$this->options['template']; - $custom_statement_template = \App\Models\Design::where('id', $this->decodePrimaryKey($this->client->getSetting('statement_design_id')))->where('is_template',true)->first(); + $custom_statement_template = \App\Models\Design::where('id', $this->decodePrimaryKey($this->client->getSetting('statement_design_id')))->where('is_template', true)->first(); if($custom_statement_template || $option_template && $option_template != '') { diff --git a/app/Services/ClientPortal/InstantPayment.php b/app/Services/ClientPortal/InstantPayment.php index 3bbb8489e42b..aea285866945 100644 --- a/app/Services/ClientPortal/InstantPayment.php +++ b/app/Services/ClientPortal/InstantPayment.php @@ -45,7 +45,7 @@ class InstantPayment public function run() { nlog($this->request->all()); - + /** @var \App\Models\ClientContact $cc */ $cc = auth()->guard('contact')->user(); diff --git a/app/Services/Credit/ApplyPayment.php b/app/Services/Credit/ApplyPayment.php index 284450b1c0f1..559c47edac88 100644 --- a/app/Services/Credit/ApplyPayment.php +++ b/app/Services/Credit/ApplyPayment.php @@ -120,9 +120,9 @@ class ApplyPayment ->credits() ->attach($this->credit->id, ['amount' => $this->amount_applied]); - $this->payment - ->ledger() - ->updatePaymentBalance($this->amount_applied * -1, "ApplyPaymentCredit"); + // $this->payment + // ->ledger() + // ->updatePaymentBalance($this->amount_applied * -1, "ApplyPaymentCredit"); // this duplicated the company ledger paid to date amount. $this->payment ->client diff --git a/app/Services/Credit/CreditService.php b/app/Services/Credit/CreditService.php index 8c6f1929345d..9474058f85f9 100644 --- a/app/Services/Credit/CreditService.php +++ b/app/Services/Credit/CreditService.php @@ -47,7 +47,7 @@ class CreditService { return $this->getECredit($contact); } - + /** * Applies the invoice number. * @return $this InvoiceService object diff --git a/app/Services/EDocument/Standards/FatturaPA.php b/app/Services/EDocument/Standards/FatturaPA.php index 24da1fc4794e..626c67d26dc1 100644 --- a/app/Services/EDocument/Standards/FatturaPA.php +++ b/app/Services/EDocument/Standards/FatturaPA.php @@ -51,12 +51,12 @@ class FatturaPA extends AbstractService /** * File Types - * + * * EI01 => FILE VUOTO * EI02 => SERVIZIO NON DISPONIBILE * EI03 => UTENTE NON ABILITATO */ - + /** Formato Trasmissione * FPA12: This is the format used for FatturaPA version 1.2. * FPR12: This format is used for FatturaPA version 1.2 in cases where the invoice is destined for the Public Administration. @@ -70,7 +70,7 @@ class FatturaPA extends AbstractService * "D" (Differita): VAT is due at a later date, typically when payment for the goods or services is received. * "S" (Soggetta): VAT is due under the reverse charge mechanism, where the recipient of the goods or services is responsible for accounting for the VAT. */ - + /** * MP01 contanti //cash * MP02 assegno //check @@ -97,11 +97,11 @@ class FatturaPA extends AbstractService * MP23 PagoPA //PagoPA */ - /** - * TP01 pagamento a rate //payment in installments - * TP02 pagamento completo //full payment - * TP03 anticipo //advance - */ + /** + * TP01 pagamento a rate //payment in installments + * TP02 pagamento completo //full payment + * TP03 anticipo //advance + */ /** * @param Invoice $invoice @@ -113,181 +113,184 @@ class FatturaPA extends AbstractService public function run() { - $fatturaHeader = new FatturaElettronicaHeader(); + $fatturaHeader = new FatturaElettronicaHeader(); - $datiTrasmissione = new DatiTrasmissione(); - $datiTrasmissione->setFormatoTrasmissione("FPR12"); - $datiTrasmissione->setCodiceDestinatario($this->invoice->client->routing_id); - $datiTrasmissione->setProgressivoInvio($this->invoice->number); + $datiTrasmissione = new DatiTrasmissione(); + $datiTrasmissione->setFormatoTrasmissione("FPR12"); + $datiTrasmissione->setCodiceDestinatario($this->invoice->client->routing_id); + $datiTrasmissione->setProgressivoInvio($this->invoice->number); - $idPaese = new IdTrasmittente(); - $idPaese->setIdPaese($this->invoice->company->country()->iso_3166_2); - $idPaese->setIdCodice($this->invoice->company->settings->vat_number); + $idPaese = new IdTrasmittente(); + $idPaese->setIdPaese($this->invoice->company->country()->iso_3166_2); + $idPaese->setIdCodice($this->invoice->company->settings->vat_number); - $datiTrasmissione->setIdTrasmittente($idPaese); - $fatturaHeader->setDatiTrasmissione($datiTrasmissione); + $datiTrasmissione->setIdTrasmittente($idPaese); + $fatturaHeader->setDatiTrasmissione($datiTrasmissione); - $cedentePrestatore = new CedentePrestatore(); - $datiAnagrafici = new DatiAnagrafici(); - $idFiscaleIVA = new IdFiscaleIVA(IdPaese: $this->invoice->company->country()->iso_3166_2, IdCodice: $this->invoice->company->settings->vat_number); - $datiAnagrafici->setIdFiscaleIVA($idFiscaleIVA); + $cedentePrestatore = new CedentePrestatore(); + $datiAnagrafici = new DatiAnagrafici(); + $idFiscaleIVA = new IdFiscaleIVA(IdPaese: $this->invoice->company->country()->iso_3166_2, IdCodice: $this->invoice->company->settings->vat_number); + $datiAnagrafici->setIdFiscaleIVA($idFiscaleIVA); - $anagrafica = new Anagrafica(Denominazione: $this->invoice->company->present()->name()); - $datiAnagrafici->setAnagrafica($anagrafica); - $datiAnagrafici->setRegimeFiscale("RF01"); //swap this out with the custom settings. - $cedentePrestatore->setDatiAnagrafici($datiAnagrafici); + $anagrafica = new Anagrafica(Denominazione: $this->invoice->company->present()->name()); + $datiAnagrafici->setAnagrafica($anagrafica); + $datiAnagrafici->setRegimeFiscale("RF01"); //swap this out with the custom settings. + $cedentePrestatore->setDatiAnagrafici($datiAnagrafici); - $sede = new Sede(Indirizzo: $this->invoice->company->settings->address1, - CAP: (int)$this->invoice->company->settings->postal_code, - Comune: $this->invoice->company->settings->city, - Provincia: $this->invoice->company->settings->state); + $sede = new Sede( + Indirizzo: $this->invoice->company->settings->address1, + CAP: (int)$this->invoice->company->settings->postal_code, + Comune: $this->invoice->company->settings->city, + Provincia: $this->invoice->company->settings->state + ); - $cedentePrestatore->setSede($sede); - $fatturaHeader->setCedentePrestatore($cedentePrestatore); + $cedentePrestatore->setSede($sede); + $fatturaHeader->setCedentePrestatore($cedentePrestatore); - //client details - $datiAnagrafici = new DatiAnagrafici(); + //client details + $datiAnagrafici = new DatiAnagrafici(); -//for some reason the validation does not like codice fiscale for the client? -//perhaps it may need IdFiscaleIVA? -// $datiAnagrafici->setCodiceFiscale("09876543210"); + //for some reason the validation does not like codice fiscale for the client? + //perhaps it may need IdFiscaleIVA? + // $datiAnagrafici->setCodiceFiscale("09876543210"); - $anagrafica = new Anagrafica(Denominazione: $this->invoice->client->present()->name()); - $datiAnagrafici->setAnagrafica($anagrafica); + $anagrafica = new Anagrafica(Denominazione: $this->invoice->client->present()->name()); + $datiAnagrafici->setAnagrafica($anagrafica); - $sede = new Sede(Indirizzo: $this->invoice->client->address1, - CAP: (int)$this->invoice->client->postal_code, - Comune: $this->invoice->client->city, - Provincia: $this->invoice->client->state); + $sede = new Sede( + Indirizzo: $this->invoice->client->address1, + CAP: (int)$this->invoice->client->postal_code, + Comune: $this->invoice->client->city, + Provincia: $this->invoice->client->state + ); - $cessionarioCommittente = new CessionarioCommittente($datiAnagrafici, $sede); + $cessionarioCommittente = new CessionarioCommittente($datiAnagrafici, $sede); - $fatturaHeader->setCessionarioCommittente($cessionarioCommittente); + $fatturaHeader->setCessionarioCommittente($cessionarioCommittente); -////////////////// Fattura Body ////////////////// -$fatturaBody = new FatturaElettronicaBody(); + ////////////////// Fattura Body ////////////////// + $fatturaBody = new FatturaElettronicaBody(); -$datiGeneraliDocument = new DatiGeneraliDocumento(); -$datiGeneraliDocument->setTipoDocumento("TD01") - ->setDivisa($this->invoice->client->currency()->code) - ->setData($this->invoice->date) - ->setNumero($this->invoice->number) - ->setCausale($this->invoice->public_notes ?? ''); //unsure... + $datiGeneraliDocument = new DatiGeneraliDocumento(); + $datiGeneraliDocument->setTipoDocumento("TD01") + ->setDivisa($this->invoice->client->currency()->code) + ->setData($this->invoice->date) + ->setNumero($this->invoice->number) + ->setCausale($this->invoice->public_notes ?? ''); //unsure... -/**PO information -$datiOrdineAcquisto = new DatiOrdineAcquisto(); -$datiOrdineAcquisto->setRiferimentoNumeroLinea(1) - ->setIdDocumento($this->invoice->po_number) - ->setNumItem(1) - ->setCodiceCIG("123abc") // special invoice props - ->setCodiceCUP("456def"); // special invoice props -*/ + /**PO information + $datiOrdineAcquisto = new DatiOrdineAcquisto(); + $datiOrdineAcquisto->setRiferimentoNumeroLinea(1) + ->setIdDocumento($this->invoice->po_number) + ->setNumItem(1) + ->setCodiceCIG("123abc") // special invoice props + ->setCodiceCUP("456def"); // special invoice props + */ -/**Contract data -$datiContratto = new DatiContratto( - RiferimentoNumeroLinea: 1, - IdDocumento: 6685, - Data: "2024-01-01", - NumItem: 5, - CodiceCUP: "123abc", - CodiceCIG: "456def", -); -*/ + /**Contract data + $datiContratto = new DatiContratto( + RiferimentoNumeroLinea: 1, + IdDocumento: 6685, + Data: "2024-01-01", + NumItem: 5, + CodiceCUP: "123abc", + CodiceCIG: "456def", + ); + */ -/**Shipping/Delivery Data -$datiRicezione = new DatiRicezione( - RiferimentoNumeroLinea: 1, - IdDocumento: 6685, - Data: "2024-01-01", - NumItem: 5, - CodiceCUP: "123abc", - CodiceCIG: "456def", -); - */ + /**Shipping/Delivery Data + $datiRicezione = new DatiRicezione( + RiferimentoNumeroLinea: 1, + IdDocumento: 6685, + Data: "2024-01-01", + NumItem: 5, + CodiceCUP: "123abc", + CodiceCIG: "456def", + ); + */ - /**Shippers details + /**Shippers details $datiAnagraficiVettore = new DatiAnagraficiVettore(); $idFiscaleIVA = new IdFiscaleIVA("IT", "24681012141"); $anagrafica = new Anagrafica("Trasport SPA"); $datiAnagraficiVettore->setIdFiscaleIVA($idFiscaleIVA) - ->setAnagrafica($anagrafica); + ->setAnagrafica($anagrafica); $datiTrasporto = new DatiTrasporto(); $datiTrasporto->setDatiAnagraficiVettore($datiAnagraficiVettore) - ->setDataOraConsegna("2017-01-10T16:46:12.000+02:00"); + ->setDataOraConsegna("2017-01-10T16:46:12.000+02:00"); */ -$datiGenerali = new DatiGenerali(); -$datiGenerali->setDatiGeneraliDocumento($datiGeneraliDocument); - // ->setDatiOrdineAcquisto($datiOrdineAcquisto) - // ->setDatiContratto($datiContratto) - // ->setDatiRicezione($datiRicezione); + $datiGenerali = new DatiGenerali(); + $datiGenerali->setDatiGeneraliDocumento($datiGeneraliDocument); + // ->setDatiOrdineAcquisto($datiOrdineAcquisto) + // ->setDatiContratto($datiContratto) + // ->setDatiRicezione($datiRicezione); - $datiBeniServizi = new DatiBeniServizi(); - $tax_rate_level = 0; - //line items - foreach ($this->invoice->line_items as $key => $item) - { + $datiBeniServizi = new DatiBeniServizi(); + $tax_rate_level = 0; + //line items + foreach ($this->invoice->line_items as $key => $item) { - $numero = $key+1; - $dettaglioLinee = new DettaglioLinee( - NumeroLinea: "{$numero}", - Descrizione: $item->notes ?? 'Descrizione', - Quantita: sprintf('%0.2f', $item->quantity), - PrezzoUnitario: sprintf('%0.2f', $item->cost), - PrezzoTotale: sprintf('%0.2f', $item->line_total), - AliquotaIVA: sprintf('%0.2f', $item->tax_rate1), - ); + $numero = $key + 1; + $dettaglioLinee = new DettaglioLinee( + NumeroLinea: "{$numero}", + Descrizione: $item->notes ?? 'Descrizione', + Quantita: sprintf('%0.2f', $item->quantity), + PrezzoUnitario: sprintf('%0.2f', $item->cost), + PrezzoTotale: sprintf('%0.2f', $item->line_total), + AliquotaIVA: sprintf('%0.2f', $item->tax_rate1), + ); - $datiBeniServizi->setDettaglioLinee($dettaglioLinee); + $datiBeniServizi->setDettaglioLinee($dettaglioLinee); + + if ($item->tax_rate1 > $tax_rate_level) { + $tax_rate_level = sprintf('%0.2f', $item->tax_rate1); + } - if ($item->tax_rate1 > $tax_rate_level) { - $tax_rate_level = sprintf('%0.2f', $item->tax_rate1); } - } - - //totals - if($this->invoice->tax_rate1 > $tax_rate_level) { - $tax_rate_level = sprintf('%0.2f', $this->invoice->tax_rate1); - } + //totals + if($this->invoice->tax_rate1 > $tax_rate_level) { + $tax_rate_level = sprintf('%0.2f', $this->invoice->tax_rate1); + } - $calc = $this->invoice->calc(); - $subtotal = sprintf('%0.2f', $calc->getSubTotal()); - $taxes = sprintf('%0.2f', $calc->getTotalTaxes()); + $calc = $this->invoice->calc(); + $subtotal = sprintf('%0.2f', $calc->getSubTotal()); + $taxes = sprintf('%0.2f', $calc->getTotalTaxes()); - $datiRiepilogo = new DatiRiepilogo( - AliquotaIVA: "{$tax_rate_level}", - ImponibileImporto: "{$subtotal}", - Imposta: "{$taxes}", - EsigibilitaIVA: "I", - ); + $datiRiepilogo = new DatiRiepilogo( + AliquotaIVA: "{$tax_rate_level}", + ImponibileImporto: "{$subtotal}", + Imposta: "{$taxes}", + EsigibilitaIVA: "I", + ); - $datiBeniServizi->setDatiRiepilogo($datiRiepilogo); + $datiBeniServizi->setDatiRiepilogo($datiRiepilogo); - $dettalioPagament = new DettaglioPagamento( - ModalitaPagamento: "MP01", //String - DataScadenzaPagamento: (string) $this->invoice->due_date ?? $this->invoice->date, - ImportoPagamento: (string) sprintf('%0.2f', $this->invoice->balance), - ); + $dettalioPagament = new DettaglioPagamento( + ModalitaPagamento: "MP01", //String + DataScadenzaPagamento: (string) $this->invoice->due_date ?? $this->invoice->date, + ImportoPagamento: (string) sprintf('%0.2f', $this->invoice->balance), + ); - $datiPagamento = new DatiPagamento(); - $datiPagamento->setCondizioniPagamento("TP02") - ->setDettaglioPagamento($dettalioPagament); + $datiPagamento = new DatiPagamento(); + $datiPagamento->setCondizioniPagamento("TP02") + ->setDettaglioPagamento($dettalioPagament); - $fatturaBody->setDatiGenerali($datiGenerali) - ->setDatiBeniServizi($datiBeniServizi) - ->setDatiPagamento($datiPagamento); + $fatturaBody->setDatiGenerali($datiGenerali) + ->setDatiBeniServizi($datiBeniServizi) + ->setDatiPagamento($datiPagamento); - //////////////////////////////////// - $xmlService = new Service(); + //////////////////////////////////// + $xmlService = new Service(); - $xml = $xmlService->write('p:FatturaElettronica', new FatturaElettronica($fatturaHeader, $fatturaBody)); + $xml = $xmlService->write('p:FatturaElettronica', new FatturaElettronica($fatturaHeader, $fatturaBody)); - return $xml; + return $xml; } -} \ No newline at end of file +} diff --git a/app/Services/EDocument/Standards/FatturaPANew.php b/app/Services/EDocument/Standards/FatturaPANew.php index 6cdb87549b52..5988e27b9d59 100644 --- a/app/Services/EDocument/Standards/FatturaPANew.php +++ b/app/Services/EDocument/Standards/FatturaPANew.php @@ -90,7 +90,7 @@ class FatturaPANew extends AbstractService } - private function setIdTrasmittente():self + private function setIdTrasmittente(): self { $this->IdTrasmittente->IdPaese = $this->invoice->company->country()->iso_3166_2; $this->IdTrasmittente->IdCodice = $this->invoice->company->settings->vat_number; @@ -98,11 +98,11 @@ class FatturaPANew extends AbstractService return $this; } - private function setCedentePrestatore():self + private function setCedentePrestatore(): self { $this->CedentePrestatore->DatiAnagrafici = $this->DatiAnagrafici; - $sede = new Sede; + $sede = new Sede(); $sede->Indirizzo = $this->invoice->company->settings->address1; $sede->CAP = (int)$this->invoice->company->settings->postal_code; $sede->Comune = $this->invoice->company->settings->city; @@ -115,7 +115,7 @@ class FatturaPANew extends AbstractService return $this; } - private function setDatiAnagrafici():self + private function setDatiAnagrafici(): self { $this->DatiAnagrafici->RegimeFiscale = "RF01"; $this->DatiAnagrafici->Anagrafica = $this->Anagrafica; @@ -124,7 +124,7 @@ class FatturaPANew extends AbstractService return $this; } - private function setClientDetails():self + private function setClientDetails(): self { $datiAnagrafici = new DatiAnagrafici(); @@ -132,20 +132,20 @@ class FatturaPANew extends AbstractService $anagrafica->Denominazione = $this->invoice->client->present()->name(); $datiAnagrafici->Anagrafica = $anagrafica; - $idFiscale = new IdFiscaleIVA; - $idFiscale->IdCodice= $this->invoice->client->vat_number; + $idFiscale = new IdFiscaleIVA(); + $idFiscale->IdCodice = $this->invoice->client->vat_number; $idFiscale->IdPaese = $this->invoice->client->country->iso_3166_2; $datiAnagrafici->IdFiscaleIVA = $idFiscale; - - $sede = new Sede; + + $sede = new Sede(); $sede->Indirizzo = $this->invoice->client->address1; $sede->CAP = (int)$this->invoice->client->postal_code; $sede->Comune = $this->invoice->client->city; $sede->Provincia = $this->invoice->client->state; $sede->Nazione = $this->invoice->client->country->iso_3166_2; - $cessionarioCommittente = new CessionarioCommittente; + $cessionarioCommittente = new CessionarioCommittente(); $cessionarioCommittente->DatiAnagrafici = $datiAnagrafici; $cessionarioCommittente->Sede = $sede; @@ -154,7 +154,7 @@ class FatturaPANew extends AbstractService return $this; } - private function setIdFiscaleIVA():self + private function setIdFiscaleIVA(): self { $this->IdFiscaleIVA->IdPaese = $this->invoice->company->country()->iso_3166_2; @@ -164,14 +164,14 @@ class FatturaPANew extends AbstractService } //this is a choice, need to switch based on values here. - private function setAnagrafica():self + private function setAnagrafica(): self { $this->Anagrafica->Denominazione = $this->invoice->company->present()->name(); return $this; } - private function setDatiGeneraliDocumento():self + private function setDatiGeneraliDocumento(): self { $this->DatiGeneraliDocumento->TipoDocumento = "TD01"; @@ -183,23 +183,23 @@ class FatturaPANew extends AbstractService return $this; } - private function setDatiGenerali():self + private function setDatiGenerali(): self { $this->DatiGenerali->DatiGeneraliDocumento = $this->DatiGeneraliDocumento; $this->FatturaElettronicaBody->DatiGenerali = $this->DatiGenerali; - + return $this; } - private function setDettaglioPagamento():self + private function setDettaglioPagamento(): self { $this->DettaglioPagamento->ModalitaPagamento = "MP01"; //String $this->DettaglioPagamento->DataScadenzaPagamento = new \DateTime($this->invoice->due_date ?? $this->invoice->date); $this->DettaglioPagamento->ImportoPagamento = (string) sprintf('%0.2f', $this->invoice->balance); - $DatiPagamento = new DatiPagamento; + $DatiPagamento = new DatiPagamento(); $DatiPagamento->CondizioniPagamento = "TP02"; $DatiPagamento->DettaglioPagamento[] = $this->DettaglioPagamento; @@ -219,14 +219,14 @@ class FatturaPANew extends AbstractService foreach ($this->invoice->line_items as $key => $item) { $numero = $key + 1; - $dettaglioLinee = new DettaglioLinee; + $dettaglioLinee = new DettaglioLinee(); $dettaglioLinee->NumeroLinea = "{$numero}"; $dettaglioLinee->Descrizione = $item->notes ?? 'Descrizione'; $dettaglioLinee->Quantita = sprintf('%0.2f', $item->quantity); $dettaglioLinee->PrezzoUnitario = sprintf('%0.2f', $item->cost); $dettaglioLinee->PrezzoTotale = sprintf('%0.2f', $item->line_total); $dettaglioLinee->AliquotaIVA = sprintf('%0.2f', $item->tax_rate1); - + $datiBeniServizi->DettaglioLinee[] = $dettaglioLinee; @@ -244,7 +244,7 @@ class FatturaPANew extends AbstractService $subtotal = sprintf('%0.2f', $calc->getSubTotal()); $taxes = sprintf('%0.2f', $calc->getTotalTaxes()); - $datiRiepilogo = new DatiRiepilogo; + $datiRiepilogo = new DatiRiepilogo(); $datiRiepilogo->AliquotaIVA = "{$tax_rate_level}"; $datiRiepilogo->ImponibileImporto = "{$subtotal}"; $datiRiepilogo->Imposta = "{$taxes}"; @@ -269,20 +269,20 @@ class FatturaPANew extends AbstractService private function init(): self { - $this->FatturaElettronica = new FatturaElettronica; - $this->FatturaElettronicaBody = new FatturaElettronicaBody; - $this->FatturaElettronicaHeader = new FatturaElettronicaHeader; - $this->DatiTrasmissione = new DatiTrasmissione; - $this->IdTrasmittente = new IdTrasmittente; - $this->CedentePrestatore = new CedentePrestatore; - $this->DatiAnagrafici = new DatiAnagrafici; - $this->IdFiscaleIVA = new IdFiscaleIVA; - $this->Anagrafica = new Anagrafica; - $this->DatiGeneraliDocumento = new DatiGeneraliDocumento; - $this->DatiGenerali = new DatiGenerali; - $this->DettaglioPagamento = new DettaglioPagamento; - + $this->FatturaElettronica = new FatturaElettronica(); + $this->FatturaElettronicaBody = new FatturaElettronicaBody(); + $this->FatturaElettronicaHeader = new FatturaElettronicaHeader(); + $this->DatiTrasmissione = new DatiTrasmissione(); + $this->IdTrasmittente = new IdTrasmittente(); + $this->CedentePrestatore = new CedentePrestatore(); + $this->DatiAnagrafici = new DatiAnagrafici(); + $this->IdFiscaleIVA = new IdFiscaleIVA(); + $this->Anagrafica = new Anagrafica(); + $this->DatiGeneraliDocumento = new DatiGeneraliDocumento(); + $this->DatiGenerali = new DatiGenerali(); + $this->DettaglioPagamento = new DettaglioPagamento(); + return $this; } -} \ No newline at end of file +} diff --git a/app/Services/EDocument/Standards/OrderXDocument.php b/app/Services/EDocument/Standards/OrderXDocument.php index f6dbaf3e3dd7..de3af56868d5 100644 --- a/app/Services/EDocument/Standards/OrderXDocument.php +++ b/app/Services/EDocument/Standards/OrderXDocument.php @@ -25,7 +25,7 @@ use horstoeko\orderx\OrderProfiles; class OrderXDocument extends AbstractService { public OrderDocumentBuilder $orderxdocument; - + /** * __construct * @@ -40,7 +40,7 @@ class OrderXDocument extends AbstractService public function run(): self { - + $company = $this->document->company; $settings_entity = ($this->document instanceof PurchaseOrder) ? $this->document->vendor : $this->document->client; $profile = $settings_entity->getSetting('e_quote_type') ? $settings_entity->getSetting('e_quote_type') : "OrderX_Extended"; @@ -68,7 +68,7 @@ class OrderXDocument extends AbstractService } // Document type $document_class = get_class($this->document); - switch ($document_class){ + switch ($document_class) { case Quote::class: // Probably wrong file code https://github.com/horstoeko/zugferd/blob/master/src/codelists/ZugferdInvoiceType.php if (empty($this->document->number)) { @@ -129,12 +129,12 @@ class OrderXDocument extends AbstractService $this->orderxdocument->setDocumentPositionProductDetails("no product name defined"); } } -// TODO: add item classification (kg, m^3, ...) -// if (isset($item->task_id)) { -// $this->orderxdocument->setDocumentPositionQuantity($item->quantity, "HUR"); -// } else { -// $this->orderxdocument->setDocumentPositionQuantity($item->quantity, "H87"); -// } + // TODO: add item classification (kg, m^3, ...) + // if (isset($item->task_id)) { + // $this->orderxdocument->setDocumentPositionQuantity($item->quantity, "HUR"); + // } else { + // $this->orderxdocument->setDocumentPositionQuantity($item->quantity, "H87"); + // } $linenetamount = $item->line_total; if ($item->discount > 0) { if ($this->document->is_amount_discount) { @@ -182,15 +182,15 @@ class OrderXDocument extends AbstractService } $this->orderxdocument->setDocumentSummation( - $this->document->amount, - $this->document->balance, - $invoicing_data->getSubTotal(), - $invoicing_data->getTotalSurcharges(), - // $invoicing_data->getTotalDiscount(), - $invoicing_data->getSubTotal(), - $invoicing_data->getItemTotalTaxes(), - // 0.0, - // ($this->document->amount - $this->document->balance) + $this->document->amount, + $this->document->balance, + $invoicing_data->getSubTotal(), + $invoicing_data->getTotalSurcharges(), + // $invoicing_data->getTotalDiscount(), + $invoicing_data->getSubTotal(), + $invoicing_data->getItemTotalTaxes(), + // 0.0, + // ($this->document->amount - $this->document->balance) ); foreach ($this->tax_map as $item) { diff --git a/app/Services/EDocument/Standards/Peppol.php b/app/Services/EDocument/Standards/Peppol.php index 7d2065df1e05..fca7ac0ecedb 100644 --- a/app/Services/EDocument/Standards/Peppol.php +++ b/app/Services/EDocument/Standards/Peppol.php @@ -43,7 +43,6 @@ use InvoiceNinja\EInvoice\Models\Peppol\TaxTotal as PeppolTaxTotal; class Peppol extends AbstractService { - private array $InvoiceTypeCodes = [ "380" => "Commercial invoice", "381" => "Credit note", @@ -68,7 +67,7 @@ class Peppol extends AbstractService */ public function __construct(public Invoice $invoice) { - $this->p_invoice = new \InvoiceNinja\EInvoice\Models\Peppol\Invoice; + $this->p_invoice = new \InvoiceNinja\EInvoice\Models\Peppol\Invoice(); $this->calc = $this->invoice->calc(); } @@ -90,45 +89,45 @@ class Peppol extends AbstractService $this->p_invoice->TaxTotal = $this->getTotalTaxes(); $this->p_invoice->LegalMonetaryTotal = $this->getLegalMonetaryTotal(); -// $payeeFinancialAccount = (new PayeeFinancialAccount()) -// ->setBankId($company->settings->custom_value1) -// ->setBankName($company->settings->custom_value2); + // $payeeFinancialAccount = (new PayeeFinancialAccount()) + // ->setBankId($company->settings->custom_value1) + // ->setBankName($company->settings->custom_value2); -// $paymentMeans = (new PaymentMeans()) -// ->setPaymentMeansCode($invoice->custom_value1) -// ->setPayeeFinancialAccount($payeeFinancialAccount); -// $ubl_invoice->setPaymentMeans($paymentMeans); + // $paymentMeans = (new PaymentMeans()) + // ->setPaymentMeansCode($invoice->custom_value1) + // ->setPayeeFinancialAccount($payeeFinancialAccount); + // $ubl_invoice->setPaymentMeans($paymentMeans); } private function getLegalMonetaryTotal(): LegalMonetaryTotal - { + { $taxable = $this->getTaxable(); - $lmt = new LegalMonetaryTotal; - - $lea = new LineExtensionAmount; + $lmt = new LegalMonetaryTotal(); + + $lea = new LineExtensionAmount(); $lea->currencyID = $this->invoice->client->currency()->code; $lea->amount = $taxable; $lmt->LineExtensionAmount = $lea; - $tea = new TaxExclusiveAmount; + $tea = new TaxExclusiveAmount(); $tea->currencyID = $this->invoice->client->currency()->code; $tea->amount = $taxable; $lmt->TaxExclusiveAmount = $tea; - $tia = new TaxInclusiveAmount; + $tia = new TaxInclusiveAmount(); $tia->currencyID = $this->invoice->client->currency()->code; $tia->amount = $this->invoice->amount; $lmt->TaxInclusiveAmount = $tia; - $pa = new PayableAmount; + $pa = new PayableAmount(); $pa->currencyID = $this->invoice->client->currency()->code; $pa->amount = $this->invoice->amount; $lmt->PayableAmount = $pa; return $lmt; - } + } private function getTotalTaxes(): array { @@ -136,24 +135,23 @@ class Peppol extends AbstractService $type_id = $this->invoice->line_items[0]->type_id; - if( strlen($this->invoice->tax_name1 ?? '') > 1) - { - + if(strlen($this->invoice->tax_name1 ?? '') > 1) { + $tax_amount = new TaxAmount(); $tax_amount->currencyID = $this->invoice->client->currency()->code; - $tax_amount->amount = round($this->invoice->amount * (1 / $this->invoice->tax_rate1),2); + $tax_amount->amount = round($this->invoice->amount * (1 / $this->invoice->tax_rate1), 2); -$tax_subtotal = new TaxSubtotal(); -$tax_subtotal->TaxAmount = $tax_amount; + $tax_subtotal = new TaxSubtotal(); + $tax_subtotal->TaxAmount = $tax_amount; -$taxable_amount = new TaxableAmount(); -$taxable_amount->currencyID = $this->invoice->client->currency()->code; -$taxable_amount->amount = $this->invoice->amount; -$tax_subtotal->TaxableAmount = $taxable_amount; + $taxable_amount = new TaxableAmount(); + $taxable_amount->currencyID = $this->invoice->client->currency()->code; + $taxable_amount->amount = $this->invoice->amount; + $tax_subtotal->TaxableAmount = $taxable_amount; + - $tc = new TaxCategory(); $tc->ID = $type_id == '2' ? 'HUR' : 'C62'; $tc->Percent = $this->invoice->tax_rate1; @@ -162,13 +160,13 @@ $tax_subtotal->TaxableAmount = $taxable_amount; $tc->TaxScheme = $ts; $tax_subtotal->TaxCategory = $tc; - $tax_total = new TaxTotal; + $tax_total = new TaxTotal(); $tax_total->TaxAmount = $tax_amount; $tax_total->TaxSubtotal = $tax_subtotal; $taxes[] = $tax_total; } - + if(strlen($this->invoice->tax_name2 ?? '') > 1) { @@ -176,17 +174,17 @@ $tax_subtotal->TaxableAmount = $taxable_amount; $tax_amount->currencyID = $this->invoice->client->currency()->code; $tax_amount->amount = round($this->invoice->amount * (1 / $this->invoice->tax_rate2), 2); -$tax_subtotal = new TaxSubtotal(); -$tax_subtotal->TaxAmount = $tax_amount; + $tax_subtotal = new TaxSubtotal(); + $tax_subtotal->TaxAmount = $tax_amount; -$taxable_amount = new TaxableAmount(); -$taxable_amount->currencyID = $this->invoice->client->currency()->code; -$taxable_amount->amount = $this->invoice->amount; -$tax_subtotal->TaxableAmount = $taxable_amount; + $taxable_amount = new TaxableAmount(); + $taxable_amount->currencyID = $this->invoice->client->currency()->code; + $taxable_amount->amount = $this->invoice->amount; + $tax_subtotal->TaxableAmount = $taxable_amount; $tc = new TaxCategory(); - $tc->ID = $type_id == '2' ? 'HUR' : 'C62'; + $tc->ID = $type_id == '2' ? 'HUR' : 'C62'; $tc->Percent = $this->invoice->tax_rate2; $ts = new PeppolTaxScheme(); $ts->ID = $this->invoice->tax_name2; @@ -208,13 +206,13 @@ $tax_subtotal->TaxableAmount = $taxable_amount; $tax_amount->currencyID = $this->invoice->client->currency()->code; $tax_amount->amount = round($this->invoice->amount * (1 / $this->invoice->tax_rate1), 2); -$tax_subtotal = new TaxSubtotal(); -$tax_subtotal->TaxAmount = $tax_amount; + $tax_subtotal = new TaxSubtotal(); + $tax_subtotal->TaxAmount = $tax_amount; -$taxable_amount = new TaxableAmount(); -$taxable_amount->currencyID = $this->invoice->client->currency()->code; -$taxable_amount->amount = $this->invoice->amount; -$tax_subtotal->TaxableAmount = $taxable_amount; + $taxable_amount = new TaxableAmount(); + $taxable_amount->currencyID = $this->invoice->client->currency()->code; + $taxable_amount->amount = $this->invoice->amount; + $tax_subtotal->TaxableAmount = $taxable_amount; $tc = new TaxCategory(); @@ -242,18 +240,17 @@ $tax_subtotal->TaxableAmount = $taxable_amount; { $lines = []; - foreach($this->invoice->line_items as $key => $item) - { + foreach($this->invoice->line_items as $key => $item) { - $_item = new Item; + $_item = new Item(); $_item->Name = $item->product_key; $_item->Description = $item->notes; - $line = new InvoiceLine; - $line->ID = $key+1; + $line = new InvoiceLine(); + $line->ID = $key + 1; $line->InvoicedQuantity = $item->quantity; - $lea = new LineExtensionAmount; + $lea = new LineExtensionAmount(); $lea->currencyID = $this->invoice->client->currency()->code; $lea->amount = $item->line_total; $line->LineExtensionAmount = $lea; @@ -265,16 +262,17 @@ $tax_subtotal->TaxableAmount = $taxable_amount; // $tt->TaxAmount = $ta; $item_taxes = $this->getItemTaxes($item); - if(count($item_taxes) > 0) + if(count($item_taxes) > 0) { $line->TaxTotal = $item_taxes; + } - $price = new Price; - $pa = new PriceAmount; + $price = new Price(); + $pa = new PriceAmount(); $pa->currencyID = $this->invoice->client->currency()->code; $pa->amount = $this->costWithDiscount($item); $price->PriceAmount = $pa; - - $line->Price = $price; + + $line->Price = $price; $lines[] = $line; } @@ -301,32 +299,31 @@ $tax_subtotal->TaxableAmount = $taxable_amount; { $item_taxes = []; - if(strlen($item->tax_name1 ?? '') > 1) - { + if(strlen($item->tax_name1 ?? '') > 1) { - $tax_amount = new TaxAmount; + $tax_amount = new TaxAmount(); $tax_amount->currencyID = $this->invoice->client->currency()->code; - $tax_amount->amount = round(($item->line_total * (1/$item->tax_rate1)),2); - $tax_subtotal = new TaxSubtotal; + $tax_amount->amount = round(($item->line_total * (1 / $item->tax_rate1)), 2); + $tax_subtotal = new TaxSubtotal(); $tax_subtotal->TaxAmount = $tax_amount; - $taxable_amount = new TaxableAmount; + $taxable_amount = new TaxableAmount(); $taxable_amount->currencyID = $this->invoice->client->currency()->code; $taxable_amount->amount = $item->line_total; $tax_subtotal->TaxableAmount = $taxable_amount; - $tc = new TaxCategory; + $tc = new TaxCategory(); $tc->ID = $item->type_id == '2' ? 'HUR' : 'C62'; $tc->Percent = $item->tax_rate1; - $ts = new PeppolTaxScheme; - $ts->ID = $item->tax_name1; + $ts = new PeppolTaxScheme(); + $ts->ID = $item->tax_name1; $tc->TaxScheme = $ts; $tax_subtotal->TaxCategory = $tc; - -$tax_total = new TaxTotal(); -$tax_total->TaxAmount = $tax_amount; -$tax_total->TaxSubtotal[] = $tax_subtotal; -$item_taxes[] = $tax_total; + + $tax_total = new TaxTotal(); + $tax_total->TaxAmount = $tax_amount; + $tax_total->TaxSubtotal[] = $tax_subtotal; + $item_taxes[] = $tax_total; } @@ -335,15 +332,15 @@ $item_taxes[] = $tax_total; $tax_amount = new TaxAmount(); $tax_amount->currencyID = $this->invoice->client->currency()->code; - $tax_amount->amount = round(($item->line_total * (1 / $item->tax_rate2)),2); + $tax_amount->amount = round(($item->line_total * (1 / $item->tax_rate2)), 2); -$tax_subtotal = new TaxSubtotal(); -$tax_subtotal->TaxAmount = $tax_amount; + $tax_subtotal = new TaxSubtotal(); + $tax_subtotal->TaxAmount = $tax_amount; -$taxable_amount = new TaxableAmount(); -$taxable_amount->currencyID = $this->invoice->client->currency()->code; -$taxable_amount->amount = $item->line_total; -$tax_subtotal->TaxableAmount = $taxable_amount; + $taxable_amount = new TaxableAmount(); + $taxable_amount->currencyID = $this->invoice->client->currency()->code; + $taxable_amount->amount = $item->line_total; + $tax_subtotal->TaxableAmount = $taxable_amount; $tc = new TaxCategory(); @@ -355,10 +352,10 @@ $tax_subtotal->TaxableAmount = $taxable_amount; $tax_subtotal->TaxCategory = $tc; -$tax_total = new TaxTotal(); -$tax_total->TaxAmount = $tax_amount; -$tax_total->TaxSubtotal[] = $tax_subtotal; -$item_taxes[] = $tax_total; + $tax_total = new TaxTotal(); + $tax_total->TaxAmount = $tax_amount; + $tax_total->TaxSubtotal[] = $tax_subtotal; + $item_taxes[] = $tax_total; } @@ -368,15 +365,15 @@ $item_taxes[] = $tax_total; $tax_amount = new TaxAmount(); $tax_amount->currencyID = $this->invoice->client->currency()->code; - $tax_amount->amount = round(($item->line_total * (1 / $item->tax_rate3)),2); + $tax_amount->amount = round(($item->line_total * (1 / $item->tax_rate3)), 2); -$tax_subtotal = new TaxSubtotal(); -$tax_subtotal->TaxAmount = $tax_amount; + $tax_subtotal = new TaxSubtotal(); + $tax_subtotal->TaxAmount = $tax_amount; -$taxable_amount = new TaxableAmount(); -$taxable_amount->currencyID = $this->invoice->client->currency()->code; -$taxable_amount->amount = $item->line_total; -$tax_subtotal->TaxableAmount = $taxable_amount; + $taxable_amount = new TaxableAmount(); + $taxable_amount->currencyID = $this->invoice->client->currency()->code; + $taxable_amount->amount = $item->line_total; + $tax_subtotal->TaxableAmount = $taxable_amount; $tc = new TaxCategory(); @@ -387,10 +384,10 @@ $tax_subtotal->TaxableAmount = $taxable_amount; $tc->TaxScheme = $ts; $tax_subtotal->TaxCategory = $tc; -$tax_total = new TaxTotal(); -$tax_total->TaxAmount = $tax_amount; -$tax_total->TaxSubtotal[] = $tax_subtotal; -$item_taxes[] = $tax_total; + $tax_total = new TaxTotal(); + $tax_total->TaxAmount = $tax_amount; + $tax_total->TaxSubtotal[] = $tax_subtotal; + $item_taxes[] = $tax_total; } @@ -404,7 +401,7 @@ $item_taxes[] = $tax_total; $asp = new AccountingSupplierParty(); $party = new Party(); - $party_name = new PartyName; + $party_name = new PartyName(); $party_name->Name = $this->invoice->company->present()->name(); $party->PartyName[] = $party_name; @@ -417,7 +414,7 @@ $item_taxes[] = $tax_total; // $address->CountrySubentityCode = $this->invoice->company->settings->state; $country = new Country(); - $country->IdentificationCode = $this->invoice->company->country()->iso_3166_2; + $country->IdentificationCode = $this->invoice->company->country()->iso_3166_2; $address->Country = $country; $party->PostalAddress = $address; @@ -439,7 +436,7 @@ $item_taxes[] = $tax_total; $acp = new AccountingCustomerParty(); $party = new Party(); - + $party_name = new PartyName(); $party_name->Name = $this->invoice->client->present()->name(); $party->PartyName[] = $party_name; @@ -459,7 +456,7 @@ $item_taxes[] = $tax_total; $party->PostalAddress = $address; $party->PhysicalLocation = $address; - + $contact = new Contact(); $contact->ElectronicMail = $this->invoice->client->present()->email(); @@ -516,4 +513,4 @@ $item_taxes[] = $tax_total; return $total; } -} \ No newline at end of file +} diff --git a/app/Services/EDocument/Standards/RoEInvoice.php b/app/Services/EDocument/Standards/RoEInvoice.php index 608173c55282..ebee4d1fcd38 100644 --- a/app/Services/EDocument/Standards/RoEInvoice.php +++ b/app/Services/EDocument/Standards/RoEInvoice.php @@ -35,7 +35,7 @@ use App\Models\Product; /** * Requirements: - * FACT1: + * FACT1: * Bank ID => company->settings->custom_value1 * Bank Name => company->settings->custom_value2 * Sector Code => company->settings->state @@ -44,7 +44,6 @@ use App\Models\Product; */ class RoEInvoice extends AbstractService { - private array $countrySubEntity = [ 'RO-AB' => 'Alba', 'RO-AG' => 'Argeș', @@ -149,14 +148,14 @@ class RoEInvoice extends AbstractService { } - private function resolveSubEntityCode(string $city) + private function resolveSubEntityCode(string $city) { $city_references = &$this->countrySubEntity[$city]; return $city_references ?? 'RO-B'; } - private function resolveSectorCode(string $state) + private function resolveSectorCode(string $state) { return in_array($state, $this->sectorList) ? $state : 'SECTOR1'; } @@ -198,7 +197,7 @@ class RoEInvoice extends AbstractService $taxName = ''; - foreach ($invoice->line_items as $index => $item) { + foreach ($invoice->line_items as $index => $item) { if (!empty($item->tax_name1)) { $taxName = $item->tax_name1; @@ -219,11 +218,11 @@ class RoEInvoice extends AbstractService $payeeFinancialAccount = (new PayeeFinancialAccount()) ->setBankId($company->settings->custom_value1) ->setBankName($company->settings->custom_value2); - - $paymentMeans = (new PaymentMeans()) - ->setPaymentMeansCode($invoice->custom_value1) - ->setPayeeFinancialAccount($payeeFinancialAccount); - $ubl_invoice->setPaymentMeans($paymentMeans); + + $paymentMeans = (new PaymentMeans()) + ->setPaymentMeansCode($invoice->custom_value1) + ->setPayeeFinancialAccount($payeeFinancialAccount); + $ubl_invoice->setPaymentMeans($paymentMeans); // line items $invoice_lines = []; @@ -241,7 +240,7 @@ class RoEInvoice extends AbstractService $taxRatePercent = $item->tax_rate2; } elseif (!empty($item->tax_rate3)) { $taxRatePercent = $item->tax_rate3; - }else { + } else { $taxRatePercent = 0; } @@ -336,7 +335,7 @@ class RoEInvoice extends AbstractService ->setName($fullName) ->setElectronicMail($eMail) ->setTelephone($phone); - + $party->setContact($contact); return $party; @@ -359,13 +358,13 @@ class RoEInvoice extends AbstractService ->setId($this->resolveTaxCode($item->tax_id ?? 1)) ->setPercent($item->tax_rate3) ->setTaxScheme(((new TaxScheme())->setId(($item->tax_name3 === 'TVA') ? 'VAT' : $item->tax_name3))); - }else { - + } else { + $classifiedTaxCategory = (new ClassifiedTaxCategory()) ->setId($this->resolveTaxCode($item->tax_id ?? 8)) ->setPercent(0) ->setTaxScheme(((new TaxScheme())->setId(($item->tax_name3 === 'TVA') ? 'VAT' : $item->tax_name3))); - + } $invoiceLine = (new InvoiceLine()) @@ -511,7 +510,7 @@ class RoEInvoice extends AbstractService { $code = $tax_id; - match($tax_id){ + match($tax_id) { Product::PRODUCT_TYPE_REVERSE_TAX => $code = 'AE', // VAT_REVERSE_CHARGE = Product::PRODUCT_TYPE_EXEMPT => $code = 'E', // EXEMPT_FROM_TAX = Product::PRODUCT_TYPE_PHYSICAL => $code = 'S', // STANDARD_RATE = @@ -523,7 +522,7 @@ class RoEInvoice extends AbstractService Product::PRODUCT_TYPE_OVERRIDE_TAX => $code = 'S', // STANDARD_RATE = default => $code = 'S', }; - + return $code; } diff --git a/app/Services/EDocument/Standards/ZugferdEDokument.php b/app/Services/EDocument/Standards/ZugferdEDokument.php index f54d971ed1b3..e650372b98ba 100644 --- a/app/Services/EDocument/Standards/ZugferdEDokument.php +++ b/app/Services/EDocument/Standards/ZugferdEDokument.php @@ -25,7 +25,7 @@ class ZugferdEDokument extends AbstractService { public ZugferdDocumentBuilder $xdocument; - + /** * __construct * @@ -43,11 +43,11 @@ class ZugferdEDokument extends AbstractService /** @var \App\Models\Company $company */ $company = $this->document->company; - - + + /** @var \App\Models\Client $client */ $client = $this->document->client; - + $profile = $client->getSetting('e_invoice_type'); $profile = match ($profile) { @@ -81,7 +81,7 @@ class ZugferdEDokument extends AbstractService } // Document type $document_class = get_class($this->document); - switch ($document_class){ + switch ($document_class) { case Quote::class: // Probably wrong file code https://github.com/horstoeko/zugferd/blob/master/src/codelists/ZugferdInvoiceType.php if (empty($this->document->number)) { @@ -123,11 +123,11 @@ class ZugferdEDokument extends AbstractService } //Payment Means - Switcher - if($company->settings->custom_value1 == '42'){ + if($company->settings->custom_value1 == '42') { $this->xdocument->addDocumentPaymentMean(typecode: 42, payeeIban: $company->settings->custom_value2, payeeAccountName: $company->settings->custom_value4, payeeBic: $company->settings->custom_value3); - } - else + } else { $this->xdocument->addDocumentPaymentMean(68, ctrans("texts.xinvoice_online_payment")); + } if (str_contains($company->getSetting('vat_number'), "/")) { $this->xdocument->addDocumentSellerTaxRegistration("FC", $company->getSetting('vat_number')); @@ -135,7 +135,7 @@ class ZugferdEDokument extends AbstractService $this->xdocument->addDocumentSellerTaxRegistration("VA", $company->getSetting('vat_number')); } - if (!empty($client->vat_number)){ + if (!empty($client->vat_number)) { $this->xdocument->addDocumentBuyerTaxRegistration("VA", $client->vat_number); } @@ -144,7 +144,7 @@ class ZugferdEDokument extends AbstractService foreach ($this->document->line_items as $index => $item) { /** @var InvoiceItem $item **/ $this->xdocument->addNewPosition($index) - ->setDocumentPositionGrossPrice($item->gross_line_total+$item->discount) + ->setDocumentPositionGrossPrice($item->gross_line_total + $item->discount) ->setDocumentPositionNetPrice($item->line_total); if (!empty($item->product_key)) { if (!empty($item->notes)) { @@ -171,7 +171,7 @@ class ZugferdEDokument extends AbstractService } else { $line_discount -= $item->line_total * ($item->discount / 100); } - $this->xdocument->addDocumentPositionGrossPriceAllowanceCharge( abs($line_discount), false); + $this->xdocument->addDocumentPositionGrossPriceAllowanceCharge(abs($line_discount), false); } $this->xdocument->setDocumentPositionLineSummation($item->line_total); @@ -179,21 +179,21 @@ class ZugferdEDokument extends AbstractService if (!(empty($item->tax_name1) && empty($item->tax_name2) && empty($item->tax_name3))) { $taxtype = $this->getTaxType($item->tax_id); if (!empty($item->tax_name1)) { - if ($taxtype == ZugferdDutyTaxFeeCategories::VAT_EXEMPT_FOR_EEA_INTRACOMMUNITY_SUPPLY_OF_GOODS_AND_SERVICES){ + if ($taxtype == ZugferdDutyTaxFeeCategories::VAT_EXEMPT_FOR_EEA_INTRACOMMUNITY_SUPPLY_OF_GOODS_AND_SERVICES) { $this->xdocument->addDocumentPositionTax($taxtype, 'VAT', $item->tax_rate1, exemptionReason: ctrans('texts.intracommunity_tax_info')); } else { $this->xdocument->addDocumentPositionTax($taxtype, 'VAT', $item->tax_rate1); } $this->addtoTaxMap($taxtype, $item->line_total, $item->tax_rate1); } elseif (!empty($item->tax_name2)) { - if ($taxtype == ZugferdDutyTaxFeeCategories::VAT_EXEMPT_FOR_EEA_INTRACOMMUNITY_SUPPLY_OF_GOODS_AND_SERVICES){ + if ($taxtype == ZugferdDutyTaxFeeCategories::VAT_EXEMPT_FOR_EEA_INTRACOMMUNITY_SUPPLY_OF_GOODS_AND_SERVICES) { $this->xdocument->addDocumentPositionTax($taxtype, 'VAT', $item->tax_rate2, exemptionReason: ctrans('texts.intracommunity_tax_info')); } else { $this->xdocument->addDocumentPositionTax($taxtype, 'VAT', $item->tax_rate2); } $this->addtoTaxMap($taxtype, $item->line_total, $item->tax_rate2); } elseif (!empty($item->tax_name3)) { - if ($taxtype == ZugferdDutyTaxFeeCategories::VAT_EXEMPT_FOR_EEA_INTRACOMMUNITY_SUPPLY_OF_GOODS_AND_SERVICES){ + if ($taxtype == ZugferdDutyTaxFeeCategories::VAT_EXEMPT_FOR_EEA_INTRACOMMUNITY_SUPPLY_OF_GOODS_AND_SERVICES) { $this->xdocument->addDocumentPositionTax($taxtype, 'VAT', $item->tax_rate3, exemptionReason: ctrans('texts.intracommunity_tax_info')); } else { $this->xdocument->addDocumentPositionTax($taxtype, 'VAT', $item->tax_rate3); @@ -227,11 +227,11 @@ class ZugferdEDokument extends AbstractService $document_discount = abs($this->document->discount); } else { $document_discount = $this->document->amount * $this->document->discount / 100; - } + } - $this->xdocument->setDocumentSummation($this->document->amount, $this->document->balance, $invoicing_data->getSubTotal(), $invoicing_data->getTotalSurcharges(), $document_discount, $invoicing_data->getSubTotal()-$document_discount, $invoicing_data->getItemTotalTaxes(), 0.0, $this->document->amount - $this->document->balance); + $this->xdocument->setDocumentSummation($this->document->amount, $this->document->balance, $invoicing_data->getSubTotal(), $invoicing_data->getTotalSurcharges(), $document_discount, $invoicing_data->getSubTotal() - $document_discount, $invoicing_data->getItemTotalTaxes(), 0.0, $this->document->amount - $this->document->balance); foreach ($this->tax_map as $item) { - if ($document_discount > 0){ + if ($document_discount > 0) { if ($item["net_amount"] >= $document_discount) { $item["net_amount"] -= $document_discount; $this->xdocument->addDocumentAllowanceCharge($document_discount, false, $item["tax_type"], "VAT", $item["tax_rate"] * 100); @@ -242,10 +242,10 @@ class ZugferdEDokument extends AbstractService } } - if ($item["tax_type"] == ZugferdDutyTaxFeeCategories::VAT_EXEMPT_FOR_EEA_INTRACOMMUNITY_SUPPLY_OF_GOODS_AND_SERVICES){ + if ($item["tax_type"] == ZugferdDutyTaxFeeCategories::VAT_EXEMPT_FOR_EEA_INTRACOMMUNITY_SUPPLY_OF_GOODS_AND_SERVICES) { $this->xdocument->addDocumentTax($item["tax_type"], "VAT", $item["net_amount"], $item["tax_rate"] * $item["net_amount"], $item["tax_rate"] * 100, ctrans('texts.intracommunity_tax_info')); } else { - $this->xdocument->addDocumentTax($item["tax_type"], "VAT", $item["net_amount"], $item["tax_rate"] * $item["net_amount"], $item["tax_rate"] * 100); + $this->xdocument->addDocumentTax($item["tax_type"], "VAT", $item["net_amount"], $item["tax_rate"] * $item["net_amount"], $item["tax_rate"] * 100); } } diff --git a/app/Services/Email/Email.php b/app/Services/Email/Email.php index 447f65129aaa..04492da8fa77 100644 --- a/app/Services/Email/Email.php +++ b/app/Services/Email/Email.php @@ -250,8 +250,9 @@ class Email implements ShouldQueue private function incrementEmailCounter(): void { - if(in_array($this->mailer, ['default','mailgun','postmark'])) + if(in_array($this->mailer, ['default','mailgun','postmark'])) { Cache::increment("email_quota".$this->company->account->key); + } } /** @@ -302,21 +303,18 @@ class Email implements ShouldQueue $this->cleanUpMailers(); $this->logMailError($e->getMessage(), $this->company->clients()->first()); return; - } - catch(\Google\Service\Exception $e){ + } catch(\Google\Service\Exception $e) { if ($e->getCode() == '429') { - + $message = "Google rate limiting triggered, we are queueing based on Gmail requirements."; $this->logMailError($message, $this->company->clients()->first()); sleep(rand(1, 2)); $this->release(900); $message = null; } - - } - - catch (\Exception | \RuntimeException $e) { + + } catch (\Exception | \RuntimeException $e) { nlog("Mailer failed with {$e->getMessage()}"); $message = $e->getMessage(); @@ -332,7 +330,7 @@ class Email implements ShouldQueue return; } - + if(stripos($e->getMessage(), 'Dsn') !== false) { nlog("Incorrectly configured mail server - setting to default mail driver."); @@ -374,7 +372,7 @@ class Email implements ShouldQueue $this->fail(); $this->entityEmailFailed($message); $this->cleanUpMailers(); - + return; } @@ -648,8 +646,8 @@ class Email implements ShouldQueue $user = $this->resolveSendingUser(); - $sending_email = (isset ($this->email_object->settings->custom_sending_email) && stripos($this->email_object->settings->custom_sending_email, "@")) ? $this->email_object->settings->custom_sending_email : $user->email; - $sending_user = (isset ($this->email_object->settings->email_from_name) && strlen($this->email_object->settings->email_from_name) > 2) ? $this->email_object->settings->email_from_name : $user->name(); + $sending_email = (isset($this->email_object->settings->custom_sending_email) && stripos($this->email_object->settings->custom_sending_email, "@")) ? $this->email_object->settings->custom_sending_email : $user->email; + $sending_user = (isset($this->email_object->settings->email_from_name) && strlen($this->email_object->settings->email_from_name) > 2) ? $this->email_object->settings->email_from_name : $user->name(); $this->mailable ->from($sending_email, $sending_user); @@ -756,8 +754,8 @@ class Email implements ShouldQueue $user = $this->resolveSendingUser(); - $sending_email = (isset ($this->email_object->settings->custom_sending_email) && stripos($this->email_object->settings->custom_sending_email, "@")) ? $this->email_object->settings->custom_sending_email : $user->email; - $sending_user = (isset ($this->email_object->settings->email_from_name) && strlen($this->email_object->settings->email_from_name) > 2) ? $this->email_object->settings->email_from_name : $user->name(); + $sending_email = (isset($this->email_object->settings->custom_sending_email) && stripos($this->email_object->settings->custom_sending_email, "@")) ? $this->email_object->settings->custom_sending_email : $user->email; + $sending_user = (isset($this->email_object->settings->email_from_name) && strlen($this->email_object->settings->email_from_name) > 2) ? $this->email_object->settings->email_from_name : $user->name(); $this->mailable ->from($sending_email, $sending_user); @@ -778,8 +776,8 @@ class Email implements ShouldQueue $user = $this->resolveSendingUser(); - $sending_email = (isset ($this->email_object->settings->custom_sending_email) && stripos($this->email_object->settings->custom_sending_email, "@")) ? $this->email_object->settings->custom_sending_email : $user->email; - $sending_user = (isset ($this->email_object->settings->email_from_name) && strlen($this->email_object->settings->email_from_name) > 2) ? $this->email_object->settings->email_from_name : $user->name(); + $sending_email = (isset($this->email_object->settings->custom_sending_email) && stripos($this->email_object->settings->custom_sending_email, "@")) ? $this->email_object->settings->custom_sending_email : $user->email; + $sending_user = (isset($this->email_object->settings->email_from_name) && strlen($this->email_object->settings->email_from_name) > 2) ? $this->email_object->settings->email_from_name : $user->name(); $this->mailable ->from($sending_email, $sending_user); @@ -800,8 +798,8 @@ class Email implements ShouldQueue $user = $this->resolveSendingUser(); - $sending_email = (isset ($this->email_object->settings->custom_sending_email) && stripos($this->email_object->settings->custom_sending_email, "@")) ? $this->email_object->settings->custom_sending_email : $user->email; - $sending_user = (isset ($this->email_object->settings->email_from_name) && strlen($this->email_object->settings->email_from_name) > 2) ? $this->email_object->settings->email_from_name : $user->name(); + $sending_email = (isset($this->email_object->settings->custom_sending_email) && stripos($this->email_object->settings->custom_sending_email, "@")) ? $this->email_object->settings->custom_sending_email : $user->email; + $sending_user = (isset($this->email_object->settings->email_from_name) && strlen($this->email_object->settings->email_from_name) > 2) ? $this->email_object->settings->email_from_name : $user->name(); $this->mailable ->from($sending_email, $sending_user); @@ -934,7 +932,7 @@ class Email implements ShouldQueue { $expiry = $user->oauth_user_token_expiry ?: now()->subDay(); $token = false; - + if ($expiry->lt(now())) { $guzzle = new \GuzzleHttp\Client(); $url = 'https://login.microsoftonline.com/common/oauth2/v2.0/token'; @@ -949,8 +947,7 @@ class Email implements ShouldQueue 'refresh_token' => $user->oauth_user_refresh_token ], ])->getBody()->getContents()); - } - catch(\Exception $e){ + } catch(\Exception $e) { nlog("Problem getting new Microsoft token for User: {$user->email}"); } diff --git a/app/Services/Email/EmailDefaults.php b/app/Services/Email/EmailDefaults.php index 79c7dcf812a3..068ad85c77ad 100644 --- a/app/Services/Email/EmailDefaults.php +++ b/app/Services/Email/EmailDefaults.php @@ -126,7 +126,7 @@ class EmailDefaults */ private function setFrom(): self { - if (Ninja::isHosted() && in_array($this->email->email_object->settings->email_sending_method,['default', 'mailgun'])) { + if (Ninja::isHosted() && in_array($this->email->email_object->settings->email_sending_method, ['default', 'mailgun'])) { if ($this->email->company->account->isPaid() && property_exists($this->email->email_object->settings, 'email_from_name') && strlen($this->email->email_object->settings->email_from_name) > 1) { $email_from_name = $this->email->email_object->settings->email_from_name; } else { @@ -180,7 +180,7 @@ class EmailDefaults $breaks = ["
","
","
"]; $this->email->email_object->text_body = str_ireplace($breaks, "\r\n", $this->email->email_object->body); $this->email->email_object->text_body = strip_tags($this->email->email_object->text_body); - $this->email->email_object->text_body = str_replace(['$view_button','$viewButton'], '$view_url', $this->email->email_object->text_body); + $this->email->email_object->text_body = str_replace(['$view_button','$viewButton'], "\r\n\r\n".'$view_url'."\r\n", $this->email->email_object->text_body); if ($this->template == 'email.template.custom') { $this->email->email_object->body = (str_replace('$body', $this->email->email_object->body, str_replace(["\r","\n"], "", $this->email->email_object->settings->email_style_custom))); diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php index d6ecd64117b0..782b0fac9a76 100644 --- a/app/Services/Invoice/AutoBillInvoice.php +++ b/app/Services/Invoice/AutoBillInvoice.php @@ -36,7 +36,7 @@ class AutoBillInvoice extends AbstractService private Client $client; private array $used_credit = []; - + /*Specific variable for partial payments */ private bool $is_partial_amount = false; @@ -262,10 +262,10 @@ class AutoBillInvoice extends AbstractService ->workFlow() //07-06-2024 - run the workflow if paid! ->save(); } - + /** * If the client has unapplied payments on file - * we will use these prior to charging a + * we will use these prior to charging a * payment method on file. * * This needs to be wrapped in a transaction. @@ -282,11 +282,11 @@ class AutoBillInvoice extends AbstractService ->where('amount', '>', 0) ->orderBy('created_at') ->get(); - + $available_unapplied_balance = $unapplied_payments->sum('amount') - $unapplied_payments->sum('applied'); - + nlog("available unapplied balance = {$available_unapplied_balance}"); - + if ((int) $available_unapplied_balance == 0) { return $this; } @@ -296,7 +296,7 @@ class AutoBillInvoice extends AbstractService } $payment_repo = new PaymentRepository(new CreditRepository()); - + foreach ($unapplied_payments as $key => $payment) { $payment_balance = $payment->amount - $payment->applied; @@ -305,7 +305,7 @@ class AutoBillInvoice extends AbstractService if ($payment_balance > $this->invoice->partial) { $payload = ['client_id' => $this->invoice->client_id, 'invoices' => [['invoice_id' => $this->invoice->id,'amount' => $this->invoice->partial]]]; $payment_repo->save($payload, $payment); - + $this->invoice = $this->invoice->fresh(); return $this; @@ -316,16 +316,16 @@ class AutoBillInvoice extends AbstractService } else { //more than needed if ($payment_balance > $this->invoice->balance) { - + $payload = ['client_id' => $this->invoice->client_id, 'invoices' => [['invoice_id' => $this->invoice->id,'amount' => $this->invoice->balance]]]; $payment_repo->save($payload, $payment); $this->invoice = $this->invoice->fresh(); return $this; - + } else { - + $payload = ['client_id' => $this->invoice->client_id, 'invoices' => [['invoice_id' => $this->invoice->id,'amount' => $payment_balance]]]; $payment_repo->save($payload, $payment); diff --git a/app/Services/Invoice/GenerateDeliveryNote.php b/app/Services/Invoice/GenerateDeliveryNote.php index 8bce3df7610a..80a5fd236799 100644 --- a/app/Services/Invoice/GenerateDeliveryNote.php +++ b/app/Services/Invoice/GenerateDeliveryNote.php @@ -49,7 +49,7 @@ class GenerateDeliveryNote if($design && $design->is_template) { $ts = new TemplateService($design); - + $pdf = $ts->setCompany($this->invoice->company) ->build([ 'invoices' => collect([$this->invoice]), @@ -82,8 +82,8 @@ class GenerateDeliveryNote } $variables = $html->generateLabelsAndValues(); - $variables['labels']['$entity_label']= ctrans('texts.delivery_note'); - + $variables['labels']['$entity_label'] = ctrans('texts.delivery_note'); + $state = [ 'template' => $template->elements([ 'client' => $this->invoice->client, diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index 88666d79cfac..13f94fe63656 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -90,7 +90,7 @@ class InvoiceService if ($company_currency != $client_currency) { $exchange_rate = new CurrencyApi(); - $this->invoice->exchange_rate = 1/$exchange_rate->exchangeRate($client_currency, $company_currency, now()); + $this->invoice->exchange_rate = 1 / $exchange_rate->exchangeRate($client_currency, $company_currency, now()); } return $this; @@ -175,6 +175,11 @@ class InvoiceService public function markSent($fire_event = false) { + + $this->invoice->loadMissing(['client' => function ($q) { + $q->without('documents', 'contacts.company', 'contacts'); // Exclude 'grandchildren' relation of 'client' + }]); + $this->invoice = (new MarkSent($this->invoice->client, $this->invoice))->run($fire_event); $this->setExchangeRate(); @@ -208,7 +213,7 @@ class InvoiceService { return $this->getEInvoice($contact); } - + public function sendEmail($contact = null) { $send_email = new SendEmail($this->invoice, null, $contact); @@ -488,7 +493,8 @@ class InvoiceService /*When a reminder is sent we want to touch the dates they were sent*/ public function touchReminder(string $reminder_template) - { nrlog(now()->format('Y-m-d h:i:s') . " INV #{$this->invoice->number} : Touching Reminder => {$reminder_template}"); + { + nrlog(now()->format('Y-m-d h:i:s') . " INV #{$this->invoice->number} : Touching Reminder => {$reminder_template}"); switch ($reminder_template) { case 'reminder1': $this->invoice->reminder1_sent = now(); diff --git a/app/Services/Pdf/PdfMock.php b/app/Services/Pdf/PdfMock.php index 9801d89cc6c3..9b7dc767807a 100644 --- a/app/Services/Pdf/PdfMock.php +++ b/app/Services/Pdf/PdfMock.php @@ -184,7 +184,7 @@ class PdfMock /** * getTaxMap * - * @return \Illuminate\Support\Collection + * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse */ private function getTaxMap(): \Illuminate\Support\Collection { diff --git a/app/Services/PdfMaker/PdfMaker.php b/app/Services/PdfMaker/PdfMaker.php index d0990d349706..876500e13309 100644 --- a/app/Services/PdfMaker/PdfMaker.php +++ b/app/Services/PdfMaker/PdfMaker.php @@ -80,7 +80,7 @@ class PdfMaker $replacements = []; $contents = $this->document->getElementsByTagName('ninja'); - $ts = new TemplateService(); + $ts = new TemplateService(); if(isset($this->options['client'])) { $client = $this->options['client']; @@ -88,10 +88,10 @@ class PdfMaker $ts->setCompany($client->company); $ts->addGlobal(['currency_code' => $client->company->currency()->code]); } catch(\Exception $e) { - nlog($e->getMessage()); + nlog($e->getMessage()); } } - + if(isset($this->options['vendor'])) { $vendor = $this->options['vendor']; try { diff --git a/app/Services/PurchaseOrder/PurchaseOrderExpense.php b/app/Services/PurchaseOrder/PurchaseOrderExpense.php index 9abb4b6b4869..80a43bc07f7f 100644 --- a/app/Services/PurchaseOrder/PurchaseOrderExpense.php +++ b/app/Services/PurchaseOrder/PurchaseOrderExpense.php @@ -57,12 +57,12 @@ class PurchaseOrderExpense $expense->number = empty($expense->number) ? $this->getNextExpenseNumber($expense) : $expense->number; - if($this->purchase_order->project_id){ + if($this->purchase_order->project_id) { $expense->project_id = $this->purchase_order->project_id; $expense->client_id = $this->purchase_order->project->client_id; - } - elseif($this->purchase_order->client_id) + } elseif($this->purchase_order->client_id) { $expense->client_id = $this->purchase_order->client_id; + } $expense->saveQuietly(); event('eloquent.created: App\Models\Expense', $expense); diff --git a/app/Services/PurchaseOrder/PurchaseOrderService.php b/app/Services/PurchaseOrder/PurchaseOrderService.php index ad9c4b02858d..005f99509f82 100644 --- a/app/Services/PurchaseOrder/PurchaseOrderService.php +++ b/app/Services/PurchaseOrder/PurchaseOrderService.php @@ -86,7 +86,7 @@ class PurchaseOrderService { return $this->getEPurchaseOrder($contact); } - + public function deleteEPurchaseOrder() { $this->purchase_order->load('invitations'); diff --git a/app/Services/Quote/ConvertQuote.php b/app/Services/Quote/ConvertQuote.php index 97c1e18e8641..ec822245d8f9 100644 --- a/app/Services/Quote/ConvertQuote.php +++ b/app/Services/Quote/ConvertQuote.php @@ -75,8 +75,9 @@ class ConvertQuote $quote->status_id = Quote::STATUS_CONVERTED; $quote->save(); - if($quote->documents()->count() > 0) + if($quote->documents()->count() > 0) { CopyDocs::dispatch($quote->documents()->pluck('id'), $invoice, $invoice->company->db); + } return $invoice; } diff --git a/app/Services/Report/ARDetailReport.php b/app/Services/Report/ARDetailReport.php index 8b937b495de2..588c48249cbc 100644 --- a/app/Services/Report/ARDetailReport.php +++ b/app/Services/Report/ARDetailReport.php @@ -91,7 +91,7 @@ class ARDetailReport extends BaseExport $query = Invoice::query() ->withTrashed() - ->whereHas('client', function ($query){ + ->whereHas('client', function ($query) { $query->where('is_deleted', 0); }) ->where('company_id', $this->company->id) diff --git a/app/Services/Report/ProfitLoss.php b/app/Services/Report/ProfitLoss.php index 812978d665eb..e3b9fc4e1db6 100644 --- a/app/Services/Report/ProfitLoss.php +++ b/app/Services/Report/ProfitLoss.php @@ -288,8 +288,9 @@ class ProfitLoss if ($pivot->paymentable_type == 'invoices') { $invoice = Invoice::query()->withTrashed()->find($pivot->paymentable_id); - if(!$invoice) + if(!$invoice) { continue; + } $pivot_diff = $pivot->amount - $pivot->refunded; $amount_payment_paid += $pivot_diff; @@ -301,10 +302,10 @@ class ProfitLoss } } - - if(!$invoice) { - continue; - } + + if(!$invoice) { + continue; + } if ($pivot->paymentable_type == 'credits') { $amount_credit_paid += $pivot->amount - $pivot->refunded; @@ -399,7 +400,7 @@ class ProfitLoss $csv->insertOne(['']); $csv->insertOne(['']); - + $csv->insertOne(['--------------------']); $csv->insertOne([ctrans('texts.revenue')]); $csv->insertOne(['--------------------']); @@ -414,7 +415,7 @@ class ProfitLoss $csv->insertOne(['--------------------']); $csv->insertOne([ctrans('texts.expenses')]); $csv->insertOne(['--------------------']); - foreach($this->expenses as $expense){ + foreach($this->expenses as $expense) { $csv->insertOne([$expense->currency, ($expense->total - $expense->foreign_tax_amount), $expense->foreign_tax_amount]); } @@ -450,10 +451,10 @@ class ProfitLoss private function expenseData() { $expenses = Expense::query()->where('company_id', $this->company->id) - ->where(function ($query){ - $query->whereNull('client_id')->orWhereHas('client', function ($q){ - $q->where('is_deleted', 0); - }); + ->where(function ($query) { + $query->whereNull('client_id')->orWhereHas('client', function ($q) { + $q->where('is_deleted', 0); + }); }) ->where('is_deleted', 0) ->withTrashed() diff --git a/app/Services/Subscription/StepService.php b/app/Services/Subscription/StepService.php index 84ed67ecf965..99baebca06a2 100644 --- a/app/Services/Subscription/StepService.php +++ b/app/Services/Subscription/StepService.php @@ -18,9 +18,9 @@ class StepService { public static function mapToClassNames(string $steps): array { - $classes = collect(Purchase::$dependencies)->mapWithKeys(fn($dependency, $class) => [$dependency['id'] => $class])->toArray(); + $classes = collect(Purchase::$dependencies)->mapWithKeys(fn ($dependency, $class) => [$dependency['id'] => $class])->toArray(); - return array_map(fn($step) => $classes[$step], explode(',', $steps)); + return array_map(fn ($step) => $classes[$step], explode(',', $steps)); } public static function check(array $steps): array @@ -35,7 +35,7 @@ class StepService if (!empty($dependent) && !array_intersect($dependent, $steps)) { $errors[] = ctrans('texts.step_dependency_fail', [ 'step' => ctrans('texts.' . self::mapClassNameToString($step)), - 'dependencies' => implode(', ', array_map(fn($dependency) => ctrans('texts.' . self::mapClassNameToString($dependency)), $dependent)), + 'dependencies' => implode(', ', array_map(fn ($dependency) => ctrans('texts.' . self::mapClassNameToString($dependency)), $dependent)), ]); } @@ -43,7 +43,7 @@ class StepService if (in_array($dependency, $steps) && $step_order[$dependency] > $step_order[$step]) { $errors[] = ctrans('texts.step_dependency_order_fail', [ 'step' => ctrans('texts.' . self::mapClassNameToString($step)), - 'dependency' => implode(', ', array_map(fn($dependency) => ctrans('texts.' . self::mapClassNameToString($dependency)), $dependent)), + 'dependency' => implode(', ', array_map(fn ($dependency) => ctrans('texts.' . self::mapClassNameToString($dependency)), $dependent)), ]); } } @@ -63,8 +63,8 @@ class StepService public static function mapClassNameToString(string $class): string { - $classes = collect(Purchase::$dependencies)->mapWithKeys(fn($dependency, $class) => [$class => $dependency['id']])->toArray(); + $classes = collect(Purchase::$dependencies)->mapWithKeys(fn ($dependency, $class) => [$class => $dependency['id']])->toArray(); return $classes[$class]; } -} \ No newline at end of file +} diff --git a/app/Services/Subscription/SubscriptionCalculator.php b/app/Services/Subscription/SubscriptionCalculator.php index c91747f981dc..0179f35b6147 100644 --- a/app/Services/Subscription/SubscriptionCalculator.php +++ b/app/Services/Subscription/SubscriptionCalculator.php @@ -27,8 +27,10 @@ class SubscriptionCalculator { use MakesHash; - public function __construct(public Subscription $subscription){} - + public function __construct(public Subscription $subscription) + { + } + /** * BuildPurchaseInvoice * @@ -55,12 +57,12 @@ class SubscriptionCalculator return $invoice_repo->save([], $invoice); } - + /** * Build Line Items - * + * * @param array $context - * + * * @return array */ private function buildItems(array $context): array @@ -74,9 +76,10 @@ class SubscriptionCalculator $items = []; foreach($recurring as $item) { - - if($item['quantity'] < 1) + + if($item['quantity'] < 1) { continue; + } $line_item = new InvoiceItem(); $line_item->product_key = $item['product']['product_key']; @@ -191,7 +194,9 @@ class SubscriptionCalculator return $this->subscription->price; } - public function executeUpgradePlan() {} + public function executeUpgradePlan() + { + } private function getRefundInvoice(Invoice $invoice) { diff --git a/app/Services/Tax/Providers/ZipTax.php b/app/Services/Tax/Providers/ZipTax.php index d25732d903b2..751204f79d38 100644 --- a/app/Services/Tax/Providers/ZipTax.php +++ b/app/Services/Tax/Providers/ZipTax.php @@ -57,7 +57,7 @@ class ZipTax implements TaxProviderInterface * callApi * * @param array $parameters - * @return Response + * @return Response| \Illuminate\Http\JsonResponse */ private function callApi(array $parameters): Response { diff --git a/app/Services/Template/TemplateAction.php b/app/Services/Template/TemplateAction.php index 9e4d775d87e2..170b0cef7701 100644 --- a/app/Services/Template/TemplateAction.php +++ b/app/Services/Template/TemplateAction.php @@ -114,43 +114,44 @@ class TemplateAction implements ShouldQueue /** Lets be clever and sniff out Statements */ if($first_entity instanceof Client && stripos(json_encode($template->design), '##statement##') !== false) { - - $options = [ - 'show_payments_table' => true, - 'show_aging_table' => true, - 'status' => 'all', - 'show_credits_table' => false, - 'template' => $this->template, - ]; - $pdfs = []; + $options = [ + 'show_payments_table' => true, + 'show_aging_table' => true, + 'status' => 'all', + 'show_credits_table' => false, + 'template' => $this->template, + ]; - foreach($result as $client) { - $pdfs[] = $client->service()->statement($options); - } + $pdfs = []; - if(count($pdfs) == 1) { - $pdf = $pdfs[0]; - } else { - $pdf = (new PdfMerge($pdfs))->run(); - } - - if($this->send_email) { - $this->sendEmail($pdf, $template); - } else { - $filename = "templates/{$this->hash}.pdf"; - Storage::disk(config('filesystems.default'))->put($filename, $pdf); - return $pdf; - } + foreach($result as $client) { + $pdfs[] = $client->service()->statement($options); + } + + if(count($pdfs) == 1) { + $pdf = $pdfs[0]; + } else { + $pdf = (new PdfMerge($pdfs))->run(); + } + + if($this->send_email) { + $this->sendEmail($pdf, $template); + } else { + $filename = "templates/{$this->hash}.pdf"; + Storage::disk(config('filesystems.default'))->put($filename, $pdf); + return $pdf; + } } - if($first_entity instanceof Client) + if($first_entity instanceof Client) { $currency_code = $first_entity->currency()->code; - elseif($first_entity->client) + } elseif($first_entity->client) { $currency_code = $first_entity->client->currency()->code; - else + } else { $currency_code = $this->company->currency()->code; + } if($result->count() <= 1) { $data[$key] = collect($result); diff --git a/app/Services/Template/TemplateService.php b/app/Services/Template/TemplateService.php index 7819b0bdd8f9..14babd5de3aa 100644 --- a/app/Services/Template/TemplateService.php +++ b/app/Services/Template/TemplateService.php @@ -94,7 +94,7 @@ class TemplateService $this->twig = new \Twig\Environment($loader, [ 'debug' => true, ]); - + $string_extension = new \Twig\Extension\StringLoaderExtension(); $this->twig->addExtension($string_extension); $this->twig->addExtension(new IntlExtension()); @@ -170,7 +170,7 @@ class TemplateService public function setGlobals(): self { - + foreach($this->global_vars as $key => $value) { $this->twig->addGlobal($key, $value); } @@ -251,7 +251,7 @@ class TemplateService */ public function getPdf(): string { - + if (config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja') { $pdf = (new NinjaPdf())->build($this->compiled_html); } else { @@ -564,7 +564,7 @@ class TemplateService 'credit_balance' => $invoice->client->credit_balance, 'vat_number' => $invoice->client->vat_number ?? '', 'currency' => $invoice->client->currency()->code ?? 'USD', - 'locale' => substr($invoice->client->locale(),0,2), + 'locale' => substr($invoice->client->locale(), 0, 2), ], 'payments' => $payments, 'total_tax_map' => $invoice->calc()->getTotalTaxMap(), @@ -721,9 +721,10 @@ class TemplateService private function getPaymentRefundActivity(Payment $payment): array { - if(!is_array($payment->refund_meta)) + if(!is_array($payment->refund_meta)) { return []; - + } + return collect($payment->refund_meta) ->map(function ($refund) use ($payment) { diff --git a/app/Transformers/BankTransactionTransformer.php b/app/Transformers/BankTransactionTransformer.php index dfbe4ec57d99..37fb2cfb62ce 100644 --- a/app/Transformers/BankTransactionTransformer.php +++ b/app/Transformers/BankTransactionTransformer.php @@ -72,6 +72,7 @@ class BankTransactionTransformer extends EntityTransformer 'vendor_id' => (string) $this->encodePrimaryKey($bank_transaction->vendor_id) ?: '', 'bank_transaction_rule_id' => (string) $this->encodePrimaryKey($bank_transaction->bank_transaction_rule_id) ?: '', 'is_deleted' => (bool) $bank_transaction->is_deleted, + 'nordigen_transaction_id' => (string) $bank_transaction->nordigen_transaction_id, 'created_at' => (int) $bank_transaction->created_at, 'updated_at' => (int) $bank_transaction->updated_at, 'archived_at' => (int) $bank_transaction->deleted_at, diff --git a/app/Transformers/ClientTransformer.php b/app/Transformers/ClientTransformer.php index 4211fc450f21..a6ba3c3ac069 100644 --- a/app/Transformers/ClientTransformer.php +++ b/app/Transformers/ClientTransformer.php @@ -48,7 +48,7 @@ class ClientTransformer extends EntityTransformer /** * @param Client $client * - * @return \Illuminate\Support\Collection + * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse */ public function includeActivities(Client $client) { @@ -67,7 +67,7 @@ class ClientTransformer extends EntityTransformer /** * @param Client $client * - * @return \Illuminate\Support\Collection + * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse */ public function includeContacts(Client $client) { diff --git a/app/Transformers/ProductTransformer.php b/app/Transformers/ProductTransformer.php index 56467fded417..181db94c0777 100644 --- a/app/Transformers/ProductTransformer.php +++ b/app/Transformers/ProductTransformer.php @@ -36,7 +36,7 @@ class ProductTransformer extends EntityTransformer /** * @param Product $product * - * @return \Illuminate\Support\Collection + * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse */ public function includeUser(Product $product) { @@ -48,7 +48,7 @@ class ProductTransformer extends EntityTransformer /** * @param Product $product * - * @return \Illuminate\Support\Collection + * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse */ public function includeCompany(Product $product) { diff --git a/app/Transformers/ProjectTransformer.php b/app/Transformers/ProjectTransformer.php index e03318b9a2a6..3d8ddcc6402c 100644 --- a/app/Transformers/ProjectTransformer.php +++ b/app/Transformers/ProjectTransformer.php @@ -47,9 +47,10 @@ class ProjectTransformer extends EntityTransformer { $transformer = new DocumentTransformer($this->serializer); - if($project->documents) + if($project->documents) { return $this->includeCollection($project->documents, $transformer, Document::class); - + } + return null; } @@ -83,14 +84,14 @@ class ProjectTransformer extends EntityTransformer public function includeExpenses(Project $project): \League\Fractal\Resource\Collection { $transformer = new ExpenseTransformer($this->serializer); - + return $this->includeCollection($project->expenses, $transformer, Expense::class); } public function includeQuotes(Project $project): \League\Fractal\Resource\Collection { $transformer = new QuoteTransformer($this->serializer); - + return $this->includeCollection($project->quotes, $transformer, Quote::class); } diff --git a/app/Transformers/TaskTransformer.php b/app/Transformers/TaskTransformer.php index 826f89ef1386..668cc4f7f3aa 100644 --- a/app/Transformers/TaskTransformer.php +++ b/app/Transformers/TaskTransformer.php @@ -111,8 +111,9 @@ class TaskTransformer extends EntityTransformer { $transformer = new ProjectTransformer($this->serializer); - if ($task->project) + if ($task->project) { return $this->includeItem($task->project, $transformer, Project::class); + } return null; } diff --git a/app/Transformers/UserTransformer.php b/app/Transformers/UserTransformer.php index 8f82a952ce89..3f4ec9801ac8 100644 --- a/app/Transformers/UserTransformer.php +++ b/app/Transformers/UserTransformer.php @@ -109,10 +109,11 @@ class UserTransformer extends EntityTransformer $transformer = new CompanyUserTransformer($this->serializer); - $cu = $user->company_users()->where('company_id',$user->company_id)->first(); + $cu = $user->company_users()->where('company_id', $user->company_id)->first(); - if(!$cu) + if(!$cu) { return null; + } return $this->includeItem($cu, $transformer, CompanyUser::class); } diff --git a/app/Transformers/VendorTransformer.php b/app/Transformers/VendorTransformer.php index 5f3f1e587e52..3a29f29584f2 100644 --- a/app/Transformers/VendorTransformer.php +++ b/app/Transformers/VendorTransformer.php @@ -39,7 +39,7 @@ class VendorTransformer extends EntityTransformer /** * @param Vendor $vendor * - * @return \Illuminate\Support\Collection + * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse */ public function includeActivities(Vendor $vendor) { @@ -51,7 +51,7 @@ class VendorTransformer extends EntityTransformer /** * @param Vendor $vendor * - * @return \Illuminate\Support\Collection + * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse */ public function includeContacts(Vendor $vendor) { diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index 94625a6af972..d63abf547a1c 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -397,7 +397,7 @@ class HtmlEngine $data['$balance'] = ['value' => Number::formatMoney($this->getBalance(), $this->client) ?: ' ', 'label' => ctrans('texts.balance')]; $data['$credit.balance'] = ['value' => Number::formatMoney($this->entity_calc->getBalance(), $this->client) ?: ' ', 'label' => ctrans('texts.credit_balance')]; $data['$client.credit_balance'] = &$data['$credit.balance']; - + $data['$invoice.balance'] = &$data['$balance']; $data['$taxes'] = ['value' => Number::formatMoney($this->entity_calc->getItemTotalTaxes(), $this->client) ?: ' ', 'label' => ctrans('texts.taxes')]; $data['$invoice.taxes'] = &$data['$taxes']; @@ -561,17 +561,18 @@ class HtmlEngine $data['$spc_qr_code'] = ['value' => $this->company->present()->getSpcQrCode($this->client->currency()->code, $this->entity->number, $this->entity->balance, $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company1', $this->settings->custom_value1, $this->client)), 'label' => '']; - if(Ninja::isHosted()) + if(Ninja::isHosted()) { $logo = $this->company->present()->logo($this->settings); - else + } else { $logo = $this->company->present()->logo_base64($this->settings); + } $logo_url = $this->company->present()->logo($this->settings); $data['$company.logo'] = ['value' => $logo ?: ' ', 'label' => ctrans('texts.logo')]; $data['$company_logo'] = &$data['$company.logo']; - + $data['$company.logo_url'] = ['value' => $logo_url ?: ' ', 'label' => ctrans('texts.logo')]; $data['$company1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'company1', $this->settings->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'company1')]; @@ -767,33 +768,35 @@ class HtmlEngine return $data; } - private function getPaymentMeta(\App\Models\Payment $payment) { + private function getPaymentMeta(\App\Models\Payment $payment) + { - if(!is_array($payment->refund_meta)) + if(!is_array($payment->refund_meta)) { return ''; + } - return + return collect($payment->refund_meta) ->map(function ($refund) use ($payment) { - $date = \Carbon\Carbon::parse($refund['date'] ?? $payment->date)->addSeconds($payment->client->timezone_offset()); - $date = $this->translateDate($date, $payment->client->date_format(), $payment->client->locale()); - $entity = ctrans('texts.invoice'); + $date = \Carbon\Carbon::parse($refund['date'] ?? $payment->date)->addSeconds($payment->client->timezone_offset()); + $date = $this->translateDate($date, $payment->client->date_format(), $payment->client->locale()); + $entity = ctrans('texts.invoice'); - $map = []; + $map = []; - foreach($refund['invoices'] as $refunded_invoice) { - $invoice = \App\Models\Invoice::withTrashed()->find($refunded_invoice['invoice_id']); - $amount = Number::formatMoney($refunded_invoice['amount'], $payment->client); - $notes = ctrans('texts.status_partially_refunded_amount', ['amount' => $amount]); + foreach($refund['invoices'] as $refunded_invoice) { + $invoice = \App\Models\Invoice::withTrashed()->find($refunded_invoice['invoice_id']); + $amount = Number::formatMoney($refunded_invoice['amount'], $payment->client); + $notes = ctrans('texts.status_partially_refunded_amount', ['amount' => $amount]); - array_push($map, "{$date} {$entity} #{$invoice->number} {$notes}\n"); + array_push($map, "{$date} {$entity} #{$invoice->number} {$notes}\n"); - } + } - return $map; + return $map; - })->flatten()->implode("\n"); + })->flatten()->implode("\n"); } /** diff --git a/app/Utils/Number.php b/app/Utils/Number.php index 9501df90f81f..2a8b592a6a99 100644 --- a/app/Utils/Number.php +++ b/app/Utils/Number.php @@ -89,8 +89,9 @@ class Number public static function parseFloat($value) { - if(!$value) + if(!$value) { return 0; + } //remove everything except for numbers, decimals, commas and hyphens $value = preg_replace('/[^0-9.,-]+/', '', $value); @@ -98,16 +99,17 @@ class Number $decimal = strpos($value, '.'); $comma = strpos($value, ','); - if($comma === false) //no comma must be a decimal number already + if($comma === false) { //no comma must be a decimal number already return (float) $value; + } - if(!$decimal && substr($value, -3, 1) != ","){ + if(!$decimal && substr($value, -3, 1) != ",") { $value = $value.".00"; } - + $decimal = strpos($value, '.'); - if($decimal < $comma){ //decimal before a comma = euro + if($decimal < $comma) { //decimal before a comma = euro $value = str_replace(['.',','], ['','.'], $value); return (float) $value; } @@ -119,7 +121,7 @@ class Number } - + /** * Formats a given value based on the clients currency * BACK to a float. @@ -130,13 +132,15 @@ class Number public static function parseFloatXX($value) { - if(!$value) + if(!$value) { return 0; + } $multiplier = false; - if(substr($value, 0,1) == '-') + if(substr($value, 0, 1) == '-') { $multiplier = -1; + } $s = str_replace(',', '.', $value); @@ -148,13 +152,14 @@ class Number $s = str_replace('.', '', substr($s, 0, -3)).substr($s, -3); - if($multiplier) - $s = floatval($s)*-1; + if($multiplier) { + $s = floatval($s) * -1; + } return (float) $s; } - + //next iteration of float parsing public static function parseFloat2($value) { @@ -198,8 +203,8 @@ class Number return (float)$value; } - - + + public static function parseStringFloat($value) { $value = preg_replace('/[^0-9-.]+/', '', $value); diff --git a/app/Utils/Statics.php b/app/Utils/Statics.php index ee36bbd80b2b..e4b2201db658 100644 --- a/app/Utils/Statics.php +++ b/app/Utils/Statics.php @@ -130,7 +130,7 @@ class Statics $data['bulk_updates'] = [ 'client' => \App\Models\Client::$bulk_update_columns, ]; - + return $data; } } diff --git a/app/Utils/Traits/CleanLineItems.php b/app/Utils/Traits/CleanLineItems.php index 59688878b5c4..9cd45a73f576 100644 --- a/app/Utils/Traits/CleanLineItems.php +++ b/app/Utils/Traits/CleanLineItems.php @@ -80,9 +80,9 @@ trait CleanLineItems if(isset($item['product_key'])) { $item['product_key'] = str_replace([" ['body' => $body], RequestOptions::ALLOW_REDIRECTS => false, ]); - if($response_body = json_decode($response->getBody(), true)) + if($response_body = json_decode($response->getBody(), true)) { return array_merge($body, $response_body); + } return array_merge($body, ['message' => 'Success', 'status_code' => 200]); diff --git a/app/Utils/TruthSource.php b/app/Utils/TruthSource.php index 11fa4c84a9b7..e5aa81108223 100644 --- a/app/Utils/TruthSource.php +++ b/app/Utils/TruthSource.php @@ -62,7 +62,7 @@ class TruthSource { return $this->premium_hosted; } - + public function getCompany() { return $this->company; diff --git a/composer.json b/composer.json index e9ba02ae5bc1..c5aa5340a417 100644 --- a/composer.json +++ b/composer.json @@ -117,7 +117,7 @@ "larastan/larastan": "^2", "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^7.0", - "phpstan/phpstan": "^1.9", + "phpstan/phpstan": "^1.11", "phpunit/phpunit": "^10", "spatie/laravel-ignition": "^2.0", "spaze/phpstan-stripe": "^3.0" diff --git a/composer.lock b/composer.lock index d2f9fc2456a9..0d5f7c627536 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a52dad71889f0bfe78dca5f02e7373c5", + "content-hash": "3a4f9e64fb5fae2cd0f6735badfd3224", "packages": [ { "name": "adrienrn/php-mimetyper", @@ -1056,16 +1056,16 @@ }, { "name": "apimatic/jsonmapper", - "version": "3.1.3", + "version": "3.1.4", "source": { "type": "git", "url": "https://github.com/apimatic/jsonmapper.git", - "reference": "5fe6ee7ed1857d6fed669dde935c6c6c70b637d2" + "reference": "407b455d2adda2efa51a44b99400389fbee0394e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/apimatic/jsonmapper/zipball/5fe6ee7ed1857d6fed669dde935c6c6c70b637d2", - "reference": "5fe6ee7ed1857d6fed669dde935c6c6c70b637d2", + "url": "https://api.github.com/repos/apimatic/jsonmapper/zipball/407b455d2adda2efa51a44b99400389fbee0394e", + "reference": "407b455d2adda2efa51a44b99400389fbee0394e", "shasum": "" }, "require": { @@ -1104,9 +1104,9 @@ "support": { "email": "mehdi.jaffery@apimatic.io", "issues": "https://github.com/apimatic/jsonmapper/issues", - "source": "https://github.com/apimatic/jsonmapper/tree/3.1.3" + "source": "https://github.com/apimatic/jsonmapper/tree/3.1.4" }, - "time": "2024-03-15T06:02:44+00:00" + "time": "2024-06-11T11:48:30+00:00" }, { "name": "apimatic/unirest-php", @@ -1385,16 +1385,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.311.2", + "version": "3.314.1", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "731cd73062909594c5f7443413c4c4c40ed1c25c" + "reference": "85207a1f342443f40711ac8fe246120821370f11" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/731cd73062909594c5f7443413c4c4c40ed1c25c", - "reference": "731cd73062909594c5f7443413c4c4c40ed1c25c", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/85207a1f342443f40711ac8fe246120821370f11", + "reference": "85207a1f342443f40711ac8fe246120821370f11", "shasum": "" }, "require": { @@ -1474,9 +1474,9 @@ "support": { "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.311.2" + "source": "https://github.com/aws/aws-sdk-php/tree/3.314.1" }, - "time": "2024-06-07T18:05:33+00:00" + "time": "2024-06-13T18:07:00+00:00" }, { "name": "bacon/bacon-qr-code", @@ -2349,16 +2349,16 @@ }, { "name": "doctrine/dbal", - "version": "3.8.4", + "version": "3.8.5", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "b05e48a745f722801f55408d0dbd8003b403dbbd" + "reference": "0e3536ba088a749985c8801105b6b3ac6c1280b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/b05e48a745f722801f55408d0dbd8003b403dbbd", - "reference": "b05e48a745f722801f55408d0dbd8003b403dbbd", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/0e3536ba088a749985c8801105b6b3ac6c1280b6", + "reference": "0e3536ba088a749985c8801105b6b3ac6c1280b6", "shasum": "" }, "require": { @@ -2374,12 +2374,12 @@ "doctrine/coding-standard": "12.0.0", "fig/log-test": "^1", "jetbrains/phpstorm-stubs": "2023.1", - "phpstan/phpstan": "1.10.58", - "phpstan/phpstan-strict-rules": "^1.5", - "phpunit/phpunit": "9.6.16", + "phpstan/phpstan": "1.11.1", + "phpstan/phpstan-strict-rules": "^1.6", + "phpunit/phpunit": "9.6.19", "psalm/plugin-phpunit": "0.18.4", "slevomat/coding-standard": "8.13.1", - "squizlabs/php_codesniffer": "3.9.0", + "squizlabs/php_codesniffer": "3.9.2", "symfony/cache": "^5.4|^6.0|^7.0", "symfony/console": "^4.4|^5.4|^6.0|^7.0", "vimeo/psalm": "4.30.0" @@ -2442,7 +2442,7 @@ ], "support": { "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/3.8.4" + "source": "https://github.com/doctrine/dbal/tree/3.8.5" }, "funding": [ { @@ -2458,7 +2458,7 @@ "type": "tidelift" } ], - "time": "2024-04-25T07:04:44+00:00" + "time": "2024-06-08T17:49:56+00:00" }, { "name": "doctrine/deprecations", @@ -3602,16 +3602,16 @@ }, { "name": "google/apiclient-services", - "version": "v0.358.0", + "version": "v0.359.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-api-php-client-services.git", - "reference": "a6daf60ee25cb45b6e3dbd04b62d1df39a609fbd" + "reference": "e975e6d0efa47f7e49280c4ea7fd6a93b6d7e338" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/a6daf60ee25cb45b6e3dbd04b62d1df39a609fbd", - "reference": "a6daf60ee25cb45b6e3dbd04b62d1df39a609fbd", + "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/e975e6d0efa47f7e49280c4ea7fd6a93b6d7e338", + "reference": "e975e6d0efa47f7e49280c4ea7fd6a93b6d7e338", "shasum": "" }, "require": { @@ -3640,9 +3640,9 @@ ], "support": { "issues": "https://github.com/googleapis/google-api-php-client-services/issues", - "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.358.0" + "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.359.0" }, - "time": "2024-06-03T01:02:16+00:00" + "time": "2024-06-10T01:02:17+00:00" }, { "name": "google/auth", @@ -4911,16 +4911,16 @@ }, { "name": "imdhemy/laravel-purchases", - "version": "1.12.0", + "version": "1.12.1", "source": { "type": "git", "url": "https://github.com/imdhemy/laravel-in-app-purchases.git", - "reference": "bd7303d23a950aa8f4573d98498ce1e4c8b6664a" + "reference": "487cc34363a598f18a6db89b3b3eebb97974e337" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/imdhemy/laravel-in-app-purchases/zipball/bd7303d23a950aa8f4573d98498ce1e4c8b6664a", - "reference": "bd7303d23a950aa8f4573d98498ce1e4c8b6664a", + "url": "https://api.github.com/repos/imdhemy/laravel-in-app-purchases/zipball/487cc34363a598f18a6db89b3b3eebb97974e337", + "reference": "487cc34363a598f18a6db89b3b3eebb97974e337", "shasum": "" }, "require": { @@ -4976,7 +4976,7 @@ ], "support": { "issues": "https://github.com/imdhemy/laravel-in-app-purchases/issues", - "source": "https://github.com/imdhemy/laravel-in-app-purchases/tree/1.12.0" + "source": "https://github.com/imdhemy/laravel-in-app-purchases/tree/1.12.1" }, "funding": [ { @@ -4984,7 +4984,7 @@ "type": "github" } ], - "time": "2024-05-25T12:18:29+00:00" + "time": "2024-06-11T12:40:12+00:00" }, { "name": "intervention/image", @@ -5076,12 +5076,12 @@ "source": { "type": "git", "url": "https://github.com/invoiceninja/einvoice.git", - "reference": "d77f090f8a5e954ee27e3dd02a1e071a40639978" + "reference": "c26ae46a132b00d9cba5b047218f530ae660ccc7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/invoiceninja/einvoice/zipball/d77f090f8a5e954ee27e3dd02a1e071a40639978", - "reference": "d77f090f8a5e954ee27e3dd02a1e071a40639978", + "url": "https://api.github.com/repos/invoiceninja/einvoice/zipball/c26ae46a132b00d9cba5b047218f530ae660ccc7", + "reference": "c26ae46a132b00d9cba5b047218f530ae660ccc7", "shasum": "" }, "require": { @@ -5123,7 +5123,7 @@ "source": "https://github.com/invoiceninja/einvoice/tree/main", "issues": "https://github.com/invoiceninja/einvoice/issues" }, - "time": "2024-06-07T10:37:13+00:00" + "time": "2024-06-12T06:01:18+00:00" }, { "name": "invoiceninja/inspector", @@ -7629,16 +7629,16 @@ }, { "name": "mollie/mollie-api-php", - "version": "v2.67.1", + "version": "v2.68.0", "source": { "type": "git", "url": "https://github.com/mollie/mollie-api-php.git", - "reference": "ed5b2ba1dc8f30a4674f10ca78ad547c2df91008" + "reference": "a3c383a76b20e3efaa39377c22e570396714830d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mollie/mollie-api-php/zipball/ed5b2ba1dc8f30a4674f10ca78ad547c2df91008", - "reference": "ed5b2ba1dc8f30a4674f10ca78ad547c2df91008", + "url": "https://api.github.com/repos/mollie/mollie-api-php/zipball/a3c383a76b20e3efaa39377c22e570396714830d", + "reference": "a3c383a76b20e3efaa39377c22e570396714830d", "shasum": "" }, "require": { @@ -7715,9 +7715,9 @@ ], "support": { "issues": "https://github.com/mollie/mollie-api-php/issues", - "source": "https://github.com/mollie/mollie-api-php/tree/v2.67.1" + "source": "https://github.com/mollie/mollie-api-php/tree/v2.68.0" }, - "time": "2024-05-07T07:59:20+00:00" + "time": "2024-06-10T09:50:59+00:00" }, { "name": "moneyphp/money", @@ -10612,16 +10612,16 @@ }, { "name": "psy/psysh", - "version": "v0.12.3", + "version": "v0.12.4", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "b6b6cce7d3ee8fbf31843edce5e8f5a72eff4a73" + "reference": "2fd717afa05341b4f8152547f142cd2f130f6818" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/b6b6cce7d3ee8fbf31843edce5e8f5a72eff4a73", - "reference": "b6b6cce7d3ee8fbf31843edce5e8f5a72eff4a73", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/2fd717afa05341b4f8152547f142cd2f130f6818", + "reference": "2fd717afa05341b4f8152547f142cd2f130f6818", "shasum": "" }, "require": { @@ -10685,9 +10685,9 @@ ], "support": { "issues": "https://github.com/bobthecow/psysh/issues", - "source": "https://github.com/bobthecow/psysh/tree/v0.12.3" + "source": "https://github.com/bobthecow/psysh/tree/v0.12.4" }, - "time": "2024-04-02T15:57:53+00:00" + "time": "2024-06-10T01:18:23+00:00" }, { "name": "pusher/pusher-php-server", @@ -16884,16 +16884,16 @@ }, { "name": "composer/class-map-generator", - "version": "1.3.2", + "version": "1.3.4", "source": { "type": "git", "url": "https://github.com/composer/class-map-generator.git", - "reference": "acd227952154850d0bb7d65caa4f9edf9cd806a7" + "reference": "b1b3fd0b4eaf3ddf3ee230bc340bf3fff454a1a3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/class-map-generator/zipball/acd227952154850d0bb7d65caa4f9edf9cd806a7", - "reference": "acd227952154850d0bb7d65caa4f9edf9cd806a7", + "url": "https://api.github.com/repos/composer/class-map-generator/zipball/b1b3fd0b4eaf3ddf3ee230bc340bf3fff454a1a3", + "reference": "b1b3fd0b4eaf3ddf3ee230bc340bf3fff454a1a3", "shasum": "" }, "require": { @@ -16937,7 +16937,7 @@ ], "support": { "issues": "https://github.com/composer/class-map-generator/issues", - "source": "https://github.com/composer/class-map-generator/tree/1.3.2" + "source": "https://github.com/composer/class-map-generator/tree/1.3.4" }, "funding": [ { @@ -16953,7 +16953,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T19:45:56+00:00" + "time": "2024-06-12T14:13:04+00:00" }, { "name": "composer/pcre", @@ -17817,16 +17817,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.11.1", + "version": "1.12.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", "shasum": "" }, "require": { @@ -17834,11 +17834,12 @@ }, "conflict": { "doctrine/collections": "<1.6.8", - "doctrine/common": "<2.13.3 || >=3,<3.2.2" + "doctrine/common": "<2.13.3 || >=3 <3.2.2" }, "require-dev": { "doctrine/collections": "^1.6.8", "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, "type": "library", @@ -17864,7 +17865,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.0" }, "funding": [ { @@ -17872,7 +17873,7 @@ "type": "tidelift" } ], - "time": "2023-03-08T13:26:56+00:00" + "time": "2024-06-12T14:39:25+00:00" }, { "name": "nunomaduro/collision", @@ -18809,28 +18810,28 @@ }, { "name": "react/dns", - "version": "v1.12.0", + "version": "v1.13.0", "source": { "type": "git", "url": "https://github.com/reactphp/dns.git", - "reference": "c134600642fa615b46b41237ef243daa65bb64ec" + "reference": "eb8ae001b5a455665c89c1df97f6fb682f8fb0f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/dns/zipball/c134600642fa615b46b41237ef243daa65bb64ec", - "reference": "c134600642fa615b46b41237ef243daa65bb64ec", + "url": "https://api.github.com/repos/reactphp/dns/zipball/eb8ae001b5a455665c89c1df97f6fb682f8fb0f5", + "reference": "eb8ae001b5a455665c89c1df97f6fb682f8fb0f5", "shasum": "" }, "require": { "php": ">=5.3.0", "react/cache": "^1.0 || ^0.6 || ^0.5", "react/event-loop": "^1.2", - "react/promise": "^3.0 || ^2.7 || ^1.2.1" + "react/promise": "^3.2 || ^2.7 || ^1.2.1" }, "require-dev": { "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", - "react/async": "^4 || ^3 || ^2", - "react/promise-timer": "^1.9" + "react/async": "^4.3 || ^3 || ^2", + "react/promise-timer": "^1.11" }, "type": "library", "autoload": { @@ -18873,7 +18874,7 @@ ], "support": { "issues": "https://github.com/reactphp/dns/issues", - "source": "https://github.com/reactphp/dns/tree/v1.12.0" + "source": "https://github.com/reactphp/dns/tree/v1.13.0" }, "funding": [ { @@ -18881,7 +18882,7 @@ "type": "open_collective" } ], - "time": "2023-11-29T12:41:06+00:00" + "time": "2024-06-13T14:18:03+00:00" }, { "name": "react/event-loop", @@ -19110,16 +19111,16 @@ }, { "name": "react/stream", - "version": "v1.3.0", + "version": "v1.4.0", "source": { "type": "git", "url": "https://github.com/reactphp/stream.git", - "reference": "6fbc9672905c7d5a885f2da2fc696f65840f4a66" + "reference": "1e5b0acb8fe55143b5b426817155190eb6f5b18d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/stream/zipball/6fbc9672905c7d5a885f2da2fc696f65840f4a66", - "reference": "6fbc9672905c7d5a885f2da2fc696f65840f4a66", + "url": "https://api.github.com/repos/reactphp/stream/zipball/1e5b0acb8fe55143b5b426817155190eb6f5b18d", + "reference": "1e5b0acb8fe55143b5b426817155190eb6f5b18d", "shasum": "" }, "require": { @@ -19129,7 +19130,7 @@ }, "require-dev": { "clue/stream-filter": "~1.2", - "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35" + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36" }, "type": "library", "autoload": { @@ -19176,7 +19177,7 @@ ], "support": { "issues": "https://github.com/reactphp/stream/issues", - "source": "https://github.com/reactphp/stream/tree/v1.3.0" + "source": "https://github.com/reactphp/stream/tree/v1.4.0" }, "funding": [ { @@ -19184,7 +19185,7 @@ "type": "open_collective" } ], - "time": "2023-06-16T10:52:11+00:00" + "time": "2024-06-11T12:45:25+00:00" }, { "name": "sebastian/cli-parser", @@ -20166,23 +20167,97 @@ "time": "2024-04-24T13:22:11+00:00" }, { - "name": "spatie/flare-client-php", - "version": "1.6.0", + "name": "spatie/error-solutions", + "version": "1.0.0", "source": { "type": "git", - "url": "https://github.com/spatie/flare-client-php.git", - "reference": "220a7c8745e9fa427d54099f47147c4b97fe6462" + "url": "https://github.com/spatie/error-solutions.git", + "reference": "202108314a6988ede156fba1b3ea80a784c1734a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/flare-client-php/zipball/220a7c8745e9fa427d54099f47147c4b97fe6462", - "reference": "220a7c8745e9fa427d54099f47147c4b97fe6462", + "url": "https://api.github.com/repos/spatie/error-solutions/zipball/202108314a6988ede156fba1b3ea80a784c1734a", + "reference": "202108314a6988ede156fba1b3ea80a784c1734a", + "shasum": "" + }, + "require": { + "php": "^8.0" + }, + "require-dev": { + "illuminate/broadcasting": "^10.0|^11.0", + "illuminate/cache": "^10.0|^11.0", + "illuminate/support": "^10.0|^11.0", + "livewire/livewire": "^2.11|^3.3.5", + "openai-php/client": "^0.10.1", + "orchestra/testbench": "^7.0|8.22.3|^9.0", + "pestphp/pest": "^2.20", + "phpstan/phpstan": "^1.11", + "psr/simple-cache": "^3.0", + "psr/simple-cache-implementation": "^3.0", + "spatie/ray": "^1.28", + "symfony/cache": "^5.4|^6.0|^7.0", + "symfony/process": "^5.4|^6.0|^7.0", + "vlucas/phpdotenv": "^5.5" + }, + "suggest": { + "openai-php/client": "Require get solutions from OpenAI", + "simple-cache-implementation": "To cache solutions from OpenAI" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\Ignition\\": "legacy/ignition", + "Spatie\\ErrorSolutions\\": "src", + "Spatie\\LaravelIgnition\\": "legacy/laravel-ignition" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ruben Van Assche", + "email": "ruben@spatie.be", + "role": "Developer" + } + ], + "description": "This is my package error-solutions", + "homepage": "https://github.com/spatie/error-solutions", + "keywords": [ + "error-solutions", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/error-solutions/issues", + "source": "https://github.com/spatie/error-solutions/tree/1.0.0" + }, + "funding": [ + { + "url": "https://github.com/Spatie", + "type": "github" + } + ], + "time": "2024-06-12T14:49:54+00:00" + }, + { + "name": "spatie/flare-client-php", + "version": "1.7.0", + "source": { + "type": "git", + "url": "https://github.com/spatie/flare-client-php.git", + "reference": "097040ff51e660e0f6fc863684ac4b02c93fa234" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/flare-client-php/zipball/097040ff51e660e0f6fc863684ac4b02c93fa234", + "reference": "097040ff51e660e0f6fc863684ac4b02c93fa234", "shasum": "" }, "require": { "illuminate/pipeline": "^8.0|^9.0|^10.0|^11.0", "php": "^8.0", - "spatie/backtrace": "^1.5.2", + "spatie/backtrace": "^1.6.1", "symfony/http-foundation": "^5.2|^6.0|^7.0", "symfony/mime": "^5.2|^6.0|^7.0", "symfony/process": "^5.2|^6.0|^7.0", @@ -20224,7 +20299,7 @@ ], "support": { "issues": "https://github.com/spatie/flare-client-php/issues", - "source": "https://github.com/spatie/flare-client-php/tree/1.6.0" + "source": "https://github.com/spatie/flare-client-php/tree/1.7.0" }, "funding": [ { @@ -20232,28 +20307,28 @@ "type": "github" } ], - "time": "2024-05-22T09:45:39+00:00" + "time": "2024-06-12T14:39:14+00:00" }, { "name": "spatie/ignition", - "version": "1.14.2", + "version": "1.15.0", "source": { "type": "git", "url": "https://github.com/spatie/ignition.git", - "reference": "5e11c11f675bb5251f061491a493e04a1a571532" + "reference": "e3a68e137371e1eb9edc7f78ffa733f3b98991d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/ignition/zipball/5e11c11f675bb5251f061491a493e04a1a571532", - "reference": "5e11c11f675bb5251f061491a493e04a1a571532", + "url": "https://api.github.com/repos/spatie/ignition/zipball/e3a68e137371e1eb9edc7f78ffa733f3b98991d2", + "reference": "e3a68e137371e1eb9edc7f78ffa733f3b98991d2", "shasum": "" }, "require": { "ext-json": "*", "ext-mbstring": "*", "php": "^8.0", - "spatie/backtrace": "^1.5.3", - "spatie/flare-client-php": "^1.4.0", + "spatie/error-solutions": "^1.0", + "spatie/flare-client-php": "^1.7", "symfony/console": "^5.4|^6.0|^7.0", "symfony/var-dumper": "^5.4|^6.0|^7.0" }, @@ -20315,20 +20390,20 @@ "type": "github" } ], - "time": "2024-05-29T08:10:20+00:00" + "time": "2024-06-12T14:55:22+00:00" }, { "name": "spatie/laravel-ignition", - "version": "2.7.0", + "version": "2.8.0", "source": { "type": "git", "url": "https://github.com/spatie/laravel-ignition.git", - "reference": "f52124d50122611e8a40f628cef5c19ff6cc5b57" + "reference": "3c067b75bfb50574db8f7e2c3978c65eed71126c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/f52124d50122611e8a40f628cef5c19ff6cc5b57", - "reference": "f52124d50122611e8a40f628cef5c19ff6cc5b57", + "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/3c067b75bfb50574db8f7e2c3978c65eed71126c", + "reference": "3c067b75bfb50574db8f7e2c3978c65eed71126c", "shasum": "" }, "require": { @@ -20337,8 +20412,7 @@ "ext-mbstring": "*", "illuminate/support": "^10.0|^11.0", "php": "^8.1", - "spatie/flare-client-php": "^1.5", - "spatie/ignition": "^1.14", + "spatie/ignition": "^1.15", "symfony/console": "^6.2.3|^7.0", "symfony/var-dumper": "^6.2.3|^7.0" }, @@ -20407,7 +20481,7 @@ "type": "github" } ], - "time": "2024-05-02T13:42:49+00:00" + "time": "2024-06-12T15:01:18+00:00" }, { "name": "spaze/phpstan-stripe", diff --git a/config/ninja.php b/config/ninja.php index a373dc939329..91fad18aea71 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -17,8 +17,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => env('APP_VERSION', '5.9.5'), - 'app_tag' => env('APP_TAG', '5.9.5'), + 'app_version' => env('APP_VERSION', '5.9.6'), + 'app_tag' => env('APP_TAG', '5.9.6'), 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', false), diff --git a/database/migrations/2024_05_19_215103_2024_05_20_einvoice_columns.php b/database/migrations/2024_05_19_215103_2024_05_20_einvoice_columns.php index b9183d0c753a..1ecc2cbc915d 100644 --- a/database/migrations/2024_05_19_215103_2024_05_20_einvoice_columns.php +++ b/database/migrations/2024_05_19_215103_2024_05_20_einvoice_columns.php @@ -37,7 +37,7 @@ return new class extends Migration }); Schema::table('accounts', function (Blueprint $table) { - $table->integer('email_quota')->default(20)->nullable(); + $table->integer('email_quota')->nullable(); }); } diff --git a/lang/ar/texts.php b/lang/ar/texts.php index 96182c97c3c7..7de2e7d1e491 100644 --- a/lang/ar/texts.php +++ b/lang/ar/texts.php @@ -2676,7 +2676,7 @@ $lang = array( 'no_assets' => 'لا توجد صور ، اسحب للتحميل', 'add_image' => 'إضافة صورة', 'select_image' => 'اختر صورة', - 'upgrade_to_upload_images' => 'قم بالترقية إلى خطة المؤسسة لتحميل الصور', + 'upgrade_to_upload_images' => 'Upgrade to the Enterprise Plan to upload files & images', 'delete_image' => 'حذف صورة', 'delete_image_help' => 'تحذير: سيؤدي حذف الصورة إلى إزالتها من جميع المقترحات.', 'amount_variable_help' => 'ملاحظة: سيستخدم حقل مبلغ الفاتورة $ الحقل الجزئي / الإيداع إذا تم تعيينه وإلا فسيستخدم رصيد الفاتورة.', @@ -4418,7 +4418,7 @@ $lang = array( 'client_shipping_country' => 'بلد شحن العميل', 'load_pdf' => 'قم بتحميل ملف PDF', 'start_free_trial' => 'ابدأ الإصدار التجريبي المجاني', - 'start_free_trial_message' => 'ابدأ تجربتك المجانية لمدة 14 يومًا من الخطة الاحترافية', + 'start_free_trial_message' => 'Start your FREE 14 day trial of the Pro Plan', 'due_on_receipt' => 'المستحقة على إيصال', 'is_paid' => 'مدفوع', 'age_group_paid' => 'مدفوع', diff --git a/lang/ca/texts.php b/lang/ca/texts.php index 1ea46d3f2524..07ff822ace02 100644 --- a/lang/ca/texts.php +++ b/lang/ca/texts.php @@ -2695,7 +2695,7 @@ $lang = array( 'no_assets' => 'No images, drag to upload', 'add_image' => 'Add Image', 'select_image' => 'Tria imatge', - 'upgrade_to_upload_images' => 'Actualitzeu al pla empresarial per penjar imatges', + 'upgrade_to_upload_images' => 'Upgrade to the Enterprise Plan to upload files & images', 'delete_image' => 'Esborra imatge', 'delete_image_help' => 'Warning: deleting the image will remove it from all proposals.', 'amount_variable_help' => 'Note: the invoice $amount field will use the partial/deposit field if set otherwise it will use the invoice balance.', @@ -4437,7 +4437,7 @@ $lang = array( 'client_shipping_country' => 'Client Shipping Country', 'load_pdf' => 'Load PDF', 'start_free_trial' => 'Start Free Trial', - 'start_free_trial_message' => 'Start your FREE 14 day trial of the pro plan', + 'start_free_trial_message' => 'Start your FREE 14 day trial of the Pro Plan', 'due_on_receipt' => 'Due on Receipt', 'is_paid' => 'Is Paid', 'age_group_paid' => 'Paid', diff --git a/lang/da/texts.php b/lang/da/texts.php index 9b6d9e84defc..df4dc4f1fe5d 100644 --- a/lang/da/texts.php +++ b/lang/da/texts.php @@ -2694,7 +2694,7 @@ $lang = array( 'no_assets' => 'Ingen billeder, træk for at uploade', 'add_image' => 'Tilføj billede', 'select_image' => 'Vælg Billede', - 'upgrade_to_upload_images' => 'Opgrader til Enterprise Plan for at uploade billeder', + 'upgrade_to_upload_images' => 'Upgrade to the Enterprise Plan to upload files & images', 'delete_image' => 'Slet billede', 'delete_image_help' => 'Advarsel: Hvis du sletter billedet, fjernes det fra alle forslag.', 'amount_variable_help' => 'Bemærk : Faktura $ Beløb feltet vil bruge del-/indbetalingsfeltet, hvis det er angivet, ellers vil det bruge Faktura saldoen.', @@ -4436,7 +4436,7 @@ $lang = array( 'client_shipping_country' => 'Klient forsendelsesland', 'load_pdf' => 'Indlæs PDF', 'start_free_trial' => 'Start gratis prøveperiode', - 'start_free_trial_message' => 'Start din GRATIS 14 dages prøveversion af pro-planen', + 'start_free_trial_message' => 'Start your FREE 14 day trial of the Pro Plan', 'due_on_receipt' => 'Forfalder ved modtagelse', 'is_paid' => 'Er betalt', 'age_group_paid' => 'Betalt', diff --git a/lang/de/texts.php b/lang/de/texts.php index 2e74c0e0aed6..83575735e1ed 100644 --- a/lang/de/texts.php +++ b/lang/de/texts.php @@ -2696,7 +2696,7 @@ Sobald Sie die Beträge erhalten haben, kommen Sie bitte wieder zurück zu diese 'no_assets' => 'Keine Bilder, hierhin ziehen zum hochladen', 'add_image' => 'Bild hinzufügen', 'select_image' => 'Bild auswählen', - 'upgrade_to_upload_images' => 'Aktualisieren Sie zum Hochladen von Bildern auf den Enterprise-Plan', + 'upgrade_to_upload_images' => 'Upgrade to the Enterprise Plan to upload files & images', 'delete_image' => 'Bild löschen', 'delete_image_help' => 'Warnung: Wenn Sie das Bild löschen, wird es aus allen Vorschlägen entfernt.', 'amount_variable_help' => 'Hinweis: Das Rechnungsfeld $amount verwendet das Feld Teil-/Anzahlung. Wenn nicht anders eingestellt, wird der Rechnungsbetrag verwendet.', @@ -4439,7 +4439,7 @@ https://invoiceninja.github.io/docs/migration/#troubleshooting', 'client_shipping_country' => 'Kunde Lieferung LAND', 'load_pdf' => 'PDF laden', 'start_free_trial' => 'Kostenlose Testversion starten', - 'start_free_trial_message' => 'Teste den Pro-Tarif GRATIS für 14 Tage', + 'start_free_trial_message' => 'Start your FREE 14 day trial of the Pro Plan', 'due_on_receipt' => 'Fällig bei Erhalt', 'is_paid' => 'Ist bezahlt', 'age_group_paid' => 'Bezahlt', diff --git a/lang/es/texts.php b/lang/es/texts.php index a3a2df83401f..0cc1d8c1a34c 100644 --- a/lang/es/texts.php +++ b/lang/es/texts.php @@ -2694,7 +2694,7 @@ $lang = array( 'no_assets' => 'No hay imágenes, arrastre para cargar', 'add_image' => 'Añadir imagen', 'select_image' => 'Seleccionar imagen', - 'upgrade_to_upload_images' => 'Actualiza al Plan Enterprise para subir imágenes', + 'upgrade_to_upload_images' => 'Upgrade to the Enterprise Plan to upload files & images', 'delete_image' => 'Eliminar Imagen', 'delete_image_help' => 'Advertencia: al eliminar la imagen, se eliminará de todas las propuestas.', 'amount_variable_help' => 'Nota: el campo de monto de $ de la factura usará el campo de depósito/parcial si se configura; de lo contrario, usará el saldo de la factura.', @@ -4436,7 +4436,7 @@ $lang = array( 'client_shipping_country' => 'País de envío del cliente', 'load_pdf' => 'Cargar PDF', 'start_free_trial' => 'Empiza la prueba gratuita', - 'start_free_trial_message' => 'Comience su prueba GRATUITA de 14 días del plan profesional', + 'start_free_trial_message' => 'Start your FREE 14 day trial of the Pro Plan', 'due_on_receipt' => 'Debido a la recepción', 'is_paid' => 'Está pagado', 'age_group_paid' => 'Pagado', diff --git a/lang/es_ES/texts.php b/lang/es_ES/texts.php index 499b1b1a8a00..c8a26a3abe21 100644 --- a/lang/es_ES/texts.php +++ b/lang/es_ES/texts.php @@ -2691,7 +2691,7 @@ Una vez que tenga los montos, vuelva a esta página de métodos de pago y haga c 'no_assets' => 'Sin imágenes, arrastra aquí para subir', 'add_image' => 'Añadir Imagen', 'select_image' => 'Seleccionar Imagen', - 'upgrade_to_upload_images' => 'Actualiza al Plan Enterprise para subir imágenes', + 'upgrade_to_upload_images' => 'Upgrade to the Enterprise Plan to upload files & images', 'delete_image' => 'Borrar Imagen', 'delete_image_help' => 'Atención: borrar la imagen la eliminará de todas las propuestas.', 'amount_variable_help' => 'Nota: el campo de la factura $amount usará el campo parcial/depósito si se indica, de otra forma se usará el balance de la factura.', @@ -4433,7 +4433,7 @@ Una vez que tenga los montos, vuelva a esta página de métodos de pago y haga c 'client_shipping_country' => 'País de envío del cliente', 'load_pdf' => 'Cargar PDF', 'start_free_trial' => 'Iniciar prueba gratuita', - 'start_free_trial_message' => 'Comience su prueba GRATUITA de 14 días del plan profesional', + 'start_free_trial_message' => 'Start your FREE 14 day trial of the Pro Plan', 'due_on_receipt' => 'Adeudado a la recepción', 'is_paid' => 'Está pagado', 'age_group_paid' => 'Pagado', diff --git a/lang/fr/texts.php b/lang/fr/texts.php index 39dbd514add6..46957138dc48 100644 --- a/lang/fr/texts.php +++ b/lang/fr/texts.php @@ -2695,7 +2695,7 @@ Lorsque les montant apparaîtront sur votre relevé, veuillez revenir sur cette 'no_assets' => 'Aucune image, faites glisser pour envoyer', 'add_image' => 'Ajouter une image', 'select_image' => 'Sélectionner une image', - 'upgrade_to_upload_images' => 'Passez au plan Entreprise pour télécharger des images', + 'upgrade_to_upload_images' => 'Upgrade to the Enterprise Plan to upload files & images', 'delete_image' => 'Supprimer l\'image', 'delete_image_help' => 'Attention : supprimer l\'image la retirera de toutes les propositions.', 'amount_variable_help' => 'Note: le champ $amount de la facture utilisera le champ d\'acompte. Il utilisera le solde de la facture, si spécifié autrement.', @@ -4437,7 +4437,7 @@ Lorsque les montant apparaîtront sur votre relevé, veuillez revenir sur cette 'client_shipping_country' => 'Pays d\'expédition du client', 'load_pdf' => 'Charger le PDF', 'start_free_trial' => 'Commencer l\'essai gratuit', - 'start_free_trial_message' => 'Commencez votre essai GRATUIT de 14 jours du plan pro', + 'start_free_trial_message' => 'Start your FREE 14 day trial of the Pro Plan', 'due_on_receipt' => 'Payable à réception', 'is_paid' => 'Est payé', 'age_group_paid' => 'Payé', diff --git a/lang/fr_CA/texts.php b/lang/fr_CA/texts.php index 30daffbd8bbc..4f89ea736773 100644 --- a/lang/fr_CA/texts.php +++ b/lang/fr_CA/texts.php @@ -2692,7 +2692,7 @@ Lorsque les montant apparaîtront sur votre relevé, veuillez revenir sur cette 'no_assets' => 'Aucune image, glisser-déposer pour la téléverser', 'add_image' => 'Ajouter une image', 'select_image' => 'Sélectionner une image', - 'upgrade_to_upload_images' => 'Passer au plan Entreprise pour téléverser des images', + 'upgrade_to_upload_images' => 'Passer au plan Entreprise pour téléverser des images et des fichiers', 'delete_image' => 'Supprimer une image', 'delete_image_help' => 'Avertissement: la suppression de cette image va la supprimer de toutes les propositions.', 'amount_variable_help' => 'Note: le champ $amount de la facture utilisera le champ partiel/dépôt. Il utilisera le solde de la facture, si spécifié autrement.', diff --git a/lang/fr_CH/texts.php b/lang/fr_CH/texts.php index 8fbd588b87df..c0c848899595 100644 --- a/lang/fr_CH/texts.php +++ b/lang/fr_CH/texts.php @@ -2692,7 +2692,7 @@ Lorsque les montant apparaîtront sur votre relevé, veuillez revenir sur cette 'no_assets' => 'Aucune image, glisser-déposer pour la téléverser', 'add_image' => 'Ajouter une image', 'select_image' => 'Sélectionner une image', - 'upgrade_to_upload_images' => 'Passez au plan Entreprise pour télécharger des images', + 'upgrade_to_upload_images' => 'Upgrade to the Enterprise Plan to upload files & images', 'delete_image' => 'Supprimer une image', 'delete_image_help' => 'Avertissement: la suppression de cette image va la supprimer de toutes les propositions.', 'amount_variable_help' => 'Note: le champ $amount de la facture utilisera le champ partiel/dépôt. Il utilisera le solde de la facture, si spécifié autrement.', @@ -4434,7 +4434,7 @@ Lorsque les montant apparaîtront sur votre relevé, veuillez revenir sur cette 'client_shipping_country' => 'Client Shipping Country', 'load_pdf' => 'Load PDF', 'start_free_trial' => 'Start Free Trial', - 'start_free_trial_message' => 'Start your FREE 14 day trial of the pro plan', + 'start_free_trial_message' => 'Start your FREE 14 day trial of the Pro Plan', 'due_on_receipt' => 'Due on Receipt', 'is_paid' => 'Is Paid', 'age_group_paid' => 'Paid', diff --git a/lang/he/texts.php b/lang/he/texts.php index fe65b742ae5f..85ea250aca9b 100644 --- a/lang/he/texts.php +++ b/lang/he/texts.php @@ -2693,7 +2693,7 @@ $lang = array( 'no_assets' => 'אין תמונה, גרור תמונות להעלאה ', 'add_image' => 'הוספת תמונה', 'select_image' => 'בחירת תמונה', - 'upgrade_to_upload_images' => 'שדרג לתוכנית Enterprise כדי להעלות תמונות', + 'upgrade_to_upload_images' => 'Upgrade to the Enterprise Plan to upload files & images', 'delete_image' => 'מחיקת תמונה', 'delete_image_help' => 'אזהרה: מחיקת התמונה תסיר אותה מכל ההצעות.', 'amount_variable_help' => 'Note: the invoice $amount field will use the partial/deposit field if set otherwise it will use the invoice balance.', @@ -4435,7 +4435,7 @@ $lang = array( 'client_shipping_country' => 'ארץ משלוח ללקוח', 'load_pdf' => 'טען PDF', 'start_free_trial' => 'להתחיל ניסיון ללא תשלום', - 'start_free_trial_message' => 'התחל את 14 ימי הניסיון שלך בחינם של תוכנית המקצוענים', + 'start_free_trial_message' => 'Start your FREE 14 day trial of the Pro Plan', 'due_on_receipt' => 'לפירעון בקבלה', 'is_paid' => 'שולם', 'age_group_paid' => 'שולם', diff --git a/lang/hu/texts.php b/lang/hu/texts.php index c286d8f7402a..a932fd05b79a 100644 --- a/lang/hu/texts.php +++ b/lang/hu/texts.php @@ -2679,7 +2679,7 @@ adva :date', 'no_assets' => 'Nincsenek eszközök', 'add_image' => 'Kép hozzáadása', 'select_image' => 'Kép kiválasztása', - 'upgrade_to_upload_images' => 'A képek feltöltéséhez frissítsen az Vállalati tervre', + 'upgrade_to_upload_images' => 'Upgrade to the Enterprise Plan to upload files & images', 'delete_image' => 'Kép törlése', 'delete_image_help' => 'Törlés esetén a kép mindenhol eltávolításra kerül.', 'amount_variable_help' => 'Megjegyzés: az összeg változó automatikusan beállítódik a maradék összegre, ha az előzetes befizetés mező nem üres.', @@ -4421,7 +4421,7 @@ adva :date', 'client_shipping_country' => 'Ügyfél szállítási országa', 'load_pdf' => 'PDF betöltése', 'start_free_trial' => 'Ingyenes próbaverzió indítása', - 'start_free_trial_message' => 'Ingyenes próbaverzió indításának üzenete', + 'start_free_trial_message' => 'Start your FREE 14 day trial of the Pro Plan', 'due_on_receipt' => 'Esedékes a fogadáskor', 'is_paid' => 'Fizetett', 'age_group_paid' => 'Fizetett korcsoport', diff --git a/lang/it/texts.php b/lang/it/texts.php index f63d8e3114d8..f3b397946071 100644 --- a/lang/it/texts.php +++ b/lang/it/texts.php @@ -2686,7 +2686,7 @@ $lang = array( 'no_assets' => 'Nessuna immagine, trascinare per caricare', 'add_image' => 'Aggiungi Immagine', 'select_image' => 'Seleziona Immagine', - 'upgrade_to_upload_images' => 'Passa al piano Enterprise per caricare le immagini', + 'upgrade_to_upload_images' => 'Upgrade to the Enterprise Plan to upload files & images', 'delete_image' => 'Cancella Immagine', 'delete_image_help' => 'Attenzione: l'eliminazione dell'immagine la rimuoverà da tutte le proposte.', 'amount_variable_help' => 'Nota: il campo $amount della fattura userà il campo parziale/deposito se impostato, altrimenti verrà usato il saldo della fattura.', @@ -4428,7 +4428,7 @@ $lang = array( 'client_shipping_country' => 'Paese di spedizione del cliente', 'load_pdf' => 'Carica PDF', 'start_free_trial' => 'Inizia la prova gratuita', - 'start_free_trial_message' => 'Inizia la tua prova GRATUITA di 14 giorni del piano pro', + 'start_free_trial_message' => 'Start your FREE 14 day trial of the Pro Plan', 'due_on_receipt' => 'Dovuto al ricevimento', 'is_paid' => 'È pagato', 'age_group_paid' => 'Pagato', diff --git a/lang/km_KH/texts.php b/lang/km_KH/texts.php index 81ca4d67ea80..a0f8f9b411dd 100644 --- a/lang/km_KH/texts.php +++ b/lang/km_KH/texts.php @@ -2675,7 +2675,7 @@ $lang = array( 'no_assets' => 'គ្មានរូបភាព អូសដើម្បីបង្ហោះ', 'add_image' => 'បន្ថែមរូបភាព', 'select_image' => 'ជ្រើសរើសរូបភាព', - 'upgrade_to_upload_images' => 'ដំឡើងកំណែទៅផែនការសហគ្រាស ដើម្បីបង្ហោះរូបភាព', + 'upgrade_to_upload_images' => 'Upgrade to the Enterprise Plan to upload files & images', 'delete_image' => 'លុបរូបភាព', 'delete_image_help' => 'ការព្រមាន៖ ការលុបរូបភាពនឹងលុបវាចេញពីសំណើទាំងអស់។', 'amount_variable_help' => 'ចំណាំ៖ វាលវិក្កយបត្រ $amount នឹងប្រើផ្នែកខ្លះ/កន្លែងដាក់ប្រាក់ ប្រសិនបើកំណត់បើមិនដូច្នេះទេ វានឹងប្រើសមតុល្យវិក្កយបត្រ។', @@ -4417,7 +4417,7 @@ $lang = array( 'client_shipping_country' => 'ប្រទេសដឹកជញ្ជូនអតិថិជន', 'load_pdf' => 'ផ្ទុកឯកសារ PDF', 'start_free_trial' => 'ចាប់ផ្តើមការសាកល្បងឥតគិតថ្លៃ', - 'start_free_trial_message' => 'ចាប់ផ្តើមការសាកល្បងឥតគិតថ្លៃរយៈពេល 14 ថ្ងៃនៃគម្រោងគាំទ្ររបស់អ្នក។', + 'start_free_trial_message' => 'Start your FREE 14 day trial of the Pro Plan', 'due_on_receipt' => 'ដល់ពេលទទួល', 'is_paid' => 'ត្រូវបានបង់', 'age_group_paid' => 'បង់', diff --git a/lang/lo_LA/texts.php b/lang/lo_LA/texts.php index 00adc2be6f19..3fab708c8e0f 100644 --- a/lang/lo_LA/texts.php +++ b/lang/lo_LA/texts.php @@ -2197,7 +2197,7 @@ $lang = array( 'mailgun_private_key' => 'ກະແຈສ່ວນຕົວຂອງ Mailgun', 'brevo_domain' => 'ໂດເມນ Brevo', 'brevo_private_key' => 'ກະແຈສ່ວນຕົວ Brevo', - 'send_test_email' => 'Send Test Email', + 'send_test_email' => 'ສົ່ງອີເມວທົດສອບ', 'select_label' => 'ເລືອກປ້າຍກຳກັບ', 'label' => 'ປ້າຍກຳກັບ', 'service' => 'ບໍລິການ', @@ -2695,7 +2695,7 @@ $lang = array( 'no_assets' => 'ບໍ່ມີຮູບພາບ, ລາກເພື່ອອັບໂຫລດ', 'add_image' => 'ເພີ່ມຮູບ', 'select_image' => 'ເລືອກຮູບ', - 'upgrade_to_upload_images' => 'ອັບເກຣດເປັນແຜນວິສາຫະກິດເພື່ອອັບໂຫລດຮູບພາບ', + 'upgrade_to_upload_images' => 'ອັບເກຣດເປັນແຜນວິສາຫະກິດເພື່ອອັບໂຫລດໄຟລ໌ ແລະຮູບພາບ', 'delete_image' => 'ລຶບຮູບພາບ', 'delete_image_help' => 'ຄຳເຕືອນ: ການລຶບຮູບພາບຈະລຶບມັນອອກຈາກທຸກຂໍ້ສະເໜີ.', 'amount_variable_help' => 'ໝາຍເຫດ: ຊ່ອງໃບແຈ້ງໜີ້ $amount ຈະໃຊ້ຊ່ອງໃສ່ບາງສ່ວນ/ການຝາກເງິນ ຖ້າຕັ້ງໄວ້ຖ້າບໍ່ດັ່ງນັ້ນມັນຈະໃຊ້ຍອດເງິນໃນໃບແຈ້ງໜີ້.', @@ -4029,7 +4029,7 @@ $lang = array( 'user_detached' => 'ຜູ້ໃຊ້ຖືກແຍກອອກຈາກບໍລິສັດ', 'create_webhook_failure' => 'ລົ້ມເຫລວໃນການສ້າງ Webhook', 'payment_message_extended' => 'ຂໍຂອບໃຈສຳລັບການຈ່າຍເງິນ:ຈຳນວນເງິນ:ໃບແຈ້ງໜີ້', - 'online_payments_minimum_note' => 'Note: Online payments are supported only if amount is larger than $1 or currency equivalent.', + 'online_payments_minimum_note' => 'ໝາຍເຫດ: ການຈ່າຍເງິນອອນລາຍແມ່ນຮອງຮັບໄດ້ພຽງແຕ່ຖ້າຈຳນວນເງິນໃຫຍ່ກວ່າ $1 ຫຼື ທຽບເທົ່າສະກຸນເງິນເທົ່ານັ້ນ.', 'payment_token_not_found' => 'ບໍ່ພົບໂທເຄັນການຈ່າຍເງິນ, ກະລຸນາລອງໃໝ່ອີກຄັ້ງ. ຖ້າບັນຫາຍັງຄົງຢູ່, ໃຫ້ລອງໃຊ້ວິທີຈ່າຍເງິນອື່ນ', 'vendor_address1' => 'ຖະໜົນຜູ້ຂາຍ', 'vendor_address2' => 'ຜູ້ຂາຍ Apt/Suite', @@ -4170,7 +4170,7 @@ $lang = array( 'one_time_purchases' => 'ຊື້ຄັ້ງດຽວ', 'recurring_purchases' => 'ການຊື້ຊໍ້າ', 'you_might_be_interested_in_following' => 'ເຈົ້າອາດຈະສົນໃຈສິ່ງຕໍ່ໄປນີ້', - 'quotes_with_status_sent_can_be_approved' => 'Only quotes with "Sent" status can be approved. Expired quotes cannot be approved.', + 'quotes_with_status_sent_can_be_approved' => 'ມີພຽງແຕ່ວົງຢືມທີ່ມີສະຖານະ "ສົ່ງ" ເທົ່ານັ້ນທີ່ສາມາດອະນຸມັດໄດ້. ວົງຢືມໝົດອາຍຸບໍ່ສາມາດອະນຸມັດໄດ້.', 'no_quotes_available_for_download' => 'ບໍ່ມີວົງຢືມທີ່ສາມາດດາວໂຫລດໄດ້.', 'copyright' => 'ລິຂະສິດ', 'user_created_user' => ':ຜູ້ໃຊ້ສ້າງ :created_user at :time', @@ -4437,7 +4437,7 @@ $lang = array( 'client_shipping_country' => 'ລູກຄ້າຈັດສົ່ງປະເທດ', 'load_pdf' => 'ໂຫລດ PDF', 'start_free_trial' => 'ເລີ່ມທົດລອງໃຊ້ຟຣີ', - 'start_free_trial_message' => 'ເລີ່ມການທົດລອງໃຊ້ຟຣີ 14 ມື້ຂອງແຜນການສົ່ງເສີມຂອງທ່ານ', + 'start_free_trial_message' => 'ເລີ່ມການທົດລອງໃຊ້ Pro Plan ຟຣີ 14 ມື້ຂອງທ່ານ', 'due_on_receipt' => 'ຄົບກຳນົດໃນໃບຮັບເງິນ', 'is_paid' => 'ໄດ້ຈ່າຍແລ້ວ', 'age_group_paid' => 'ຈ່າຍແລ້ວ', @@ -5147,7 +5147,7 @@ $lang = array( 'payment_refund_receipt' => 'ໃບຮັບເງິນຄືນການຈ່າຍເງິນ # : ໝາຍເລກ', 'payment_receipt' => 'ໃບຮັບເງິນ # : ໝາຍເລກ', 'load_template_description' => 'ແມ່ແບບຈະຖືກນໍາໃຊ້ກັບດັ່ງຕໍ່ໄປນີ້:', - 'run_template' => 'Run Template', + 'run_template' => 'ແລ່ນແມ່ແບບ', 'statement_design' => 'ການອອກແບບຖະແຫຼງການ', 'delivery_note_design' => 'ການອອກແບບບັນທຶກການຈັດສົ່ງ', 'payment_receipt_design' => 'ການອອກແບບໃບຮັບເງິນ', @@ -5296,23 +5296,23 @@ $lang = array( 'rappen_rounding' => 'Rappen Rounding', 'rappen_rounding_help' => 'ຈໍານວນຮອບເປັນ 5 ເຊັນ', 'assign_group' => 'ກຳນົດກຸ່ມ', - 'paypal_advanced_cards' => 'Advanced Card Payments', + 'paypal_advanced_cards' => 'ການຈ່າຍເງິນບັດຂັ້ນສູງ', 'local_domain_help' => 'EHLO domain (optional)', 'port_help' => 'ie. 25,587,465', 'host_help' => 'ie. smtp.gmail.com', - 'always_show_required_fields' => 'Allows show required fields form', - 'always_show_required_fields_help' => 'Displays the required fields form always at checkout', - 'advanced_cards' => 'Advanced Cards', + 'always_show_required_fields' => 'ອະນຸຍາດໃຫ້ສະແດງແບບຟອມທີ່ຕ້ອງການ', + 'always_show_required_fields_help' => 'ສະແດງແບບຟອມຊ່ອງຂໍ້ມູນທີ່ຕ້ອງການຢູ່ສະເໝີໃນເວລາຈ່າຍເງິນ', + 'advanced_cards' => 'ບັດຂັ້ນສູງ', 'activity_140' => 'Statement sent to :client', - 'invoice_net_amount' => 'Invoice Net Amount', - 'round_to_minutes' => 'Round To Minutes', - '1_second' => '1 Second', - '1_minute' => '1 Minute', - '5_minutes' => '5 Minutes', - '15_minutes' => '15 Minutes', - '30_minutes' => '30 Minutes', - '1_hour' => '1 Hour', - '1_day' => '1 Day', + 'invoice_net_amount' => 'ໃບເກັບເງິນສຸດທິ', + 'round_to_minutes' => 'ຮອບເຖິງນາທີ', + '1_second' => '1 ວິນາທີ', + '1_minute' => '1 ນາທີ', + '5_minutes' => '5 ນາທີ', + '15_minutes' => '15 ນາທີ', + '30_minutes' => '30 ນາທີ', + '1_hour' => '1 ຊົ່ວ​ໂມງ', + '1_day' => '1 ມື້', 'round_tasks' => 'Task Rounding Direction', 'round_tasks_help' => 'Round task times up or down.', 'direction' => 'Direction', @@ -5320,21 +5320,21 @@ $lang = array( 'round_down' => 'Round Down', 'task_round_to_nearest' => 'Round To Nearest', 'task_round_to_nearest_help' => 'The interval to round the task to.', - 'bulk_updated' => 'Successfully updated data', + 'bulk_updated' => 'ອັບເດດຂໍ້ມູນສຳເລັດແລ້ວ', 'bulk_update' => 'Bulk Update', - 'calculate' => 'Calculate', - 'sum' => 'Sum', - 'money' => 'Money', - 'web_app' => 'Web App', - 'desktop_app' => 'Desktop App', - 'disconnected' => 'Disconnected', - 'reconnect' => 'Reconnect', - 'e_invoice_settings' => 'E-Invoice Settings', + 'calculate' => 'ໄລ່ເລກ', + 'sum' => 'ຈໍານວນ', + 'money' => 'ເງິນ', + 'web_app' => 'ແອັບເວັບ', + 'desktop_app' => 'ແອັບເດັສທັອບ', + 'disconnected' => 'ຕັດການເຊື່ອມຕໍ່', + 'reconnect' => 'ເຊື່ອມຕໍ່ຄືນໃໝ່', + 'e_invoice_settings' => 'ການຕັ້ງຄ່າ E-Invoice', 'btcpay_refund_subject' => 'Refund of your invoice via BTCPay', 'btcpay_refund_body' => 'A refund intended for you has been issued. To claim it via BTCPay, please click on this link:', 'currency_mauritanian_ouguiya' => 'Mauritanian Ouguiya', 'currency_bhutan_ngultrum' => 'Bhutan Ngultrum', - 'end_of_month' => 'End Of Month' + 'end_of_month' => 'ທ້າຍເດືອນ' ); return $lang; \ No newline at end of file diff --git a/lang/nl/texts.php b/lang/nl/texts.php index c12d9a9ac843..d2b930c8d050 100644 --- a/lang/nl/texts.php +++ b/lang/nl/texts.php @@ -2692,7 +2692,7 @@ Kom terug naar deze betalingsmethode pagina zodra u de bedragen heeft ontvangen 'no_assets' => 'Geen afbeeldingen, slepen om te uploaden', 'add_image' => 'Afbeelding toevoegen', 'select_image' => 'Afbeelding selecteren', - 'upgrade_to_upload_images' => 'Upgrade naar het Enterprise Plan om afbeeldingen te uploaden', + 'upgrade_to_upload_images' => 'Upgrade to the Enterprise Plan to upload files & images', 'delete_image' => 'Afbeelding verwijderen', 'delete_image_help' => 'Waarschuwing: als je de afbeelding verwijdert, wordt deze uit alle voorstellen verwijderd.', 'amount_variable_help' => 'Opmerking: Het veld $amount op de factuur wordt gebruikt als gedeeltelijke betaling als dit is ingesteld, anders wordt het factuur saldo gebruikt.', @@ -4437,7 +4437,7 @@ Email: :email
', 'client_shipping_country' => 'Land van verzending van de klant', 'load_pdf' => 'Laad PDF', 'start_free_trial' => 'Start gratis proefperiode', - 'start_free_trial_message' => 'Start uw GRATIS proefperiode van 14 dagen voor het pro-abonnement', + 'start_free_trial_message' => 'Start your FREE 14 day trial of the Pro Plan', 'due_on_receipt' => 'Verschuldigd bij ontvangst', 'is_paid' => 'Is betaald', 'age_group_paid' => 'Betaald', diff --git a/lang/pt_BR/texts.php b/lang/pt_BR/texts.php index d559f6c80602..ecb0ffea95e5 100644 --- a/lang/pt_BR/texts.php +++ b/lang/pt_BR/texts.php @@ -2692,7 +2692,7 @@ Quando tiver as quantias, volte a esta página de formas de pagamento e clique " 'no_assets' => 'Sem imagens, arraste para fazer upload', 'add_image' => 'Adicionar Imagem', 'select_image' => 'Selecionar Imagem', - 'upgrade_to_upload_images' => 'Atualize para o plano Enterprise para fazer upload de imagens', + 'upgrade_to_upload_images' => 'Upgrade to the Enterprise Plan to upload files & images', 'delete_image' => 'Excluir Imagem', 'delete_image_help' => 'Aviso: excluir a imagem irá removê-la de todas as propostas.', 'amount_variable_help' => 'Nota: o campo $amount da fatura usará o campo parcial/depósito se habilitado ou usará o saldo da fatura.', @@ -4434,7 +4434,7 @@ Quando tiver as quantias, volte a esta página de formas de pagamento e clique " 'client_shipping_country' => 'País de envio do cliente', 'load_pdf' => 'Carregar PDF', 'start_free_trial' => 'Comece o teste gratuito', - 'start_free_trial_message' => 'Comece seu teste GRATUITO de 14 dias do plano pro', + 'start_free_trial_message' => 'Start your FREE 14 day trial of the Pro Plan', 'due_on_receipt' => 'Vencimento no recebimento', 'is_paid' => 'É pago', 'age_group_paid' => 'Pago', diff --git a/lang/pt_PT/texts.php b/lang/pt_PT/texts.php index 159b7e207fb6..656264d2df44 100644 --- a/lang/pt_PT/texts.php +++ b/lang/pt_PT/texts.php @@ -2694,7 +2694,7 @@ debitar da sua conta de acordo com essas instruções. Está elegível a um reem 'no_assets' => 'Sem imagens, arraste para carregar', 'add_image' => 'Adicionar Imagem', 'select_image' => 'Selecionar Imagem', - 'upgrade_to_upload_images' => 'Atualize para o plano Enterprise para fazer upload de imagens', + 'upgrade_to_upload_images' => 'Upgrade to the Enterprise Plan to upload files & images', 'delete_image' => 'Apagar Imagem', 'delete_image_help' => 'Aviso: Ao apagar a imagem irá removê-la de todas as propostas.', 'amount_variable_help' => 'Nota: o campo $amount da nota de pagamento usará o campo parcial/depósito se habilitado ou usará o saldo da nota de pagamento.', @@ -4437,7 +4437,7 @@ O envio de E-mails foi suspenso. Será retomado às 23:00 UTC.', 'client_shipping_country' => 'País de envio do cliente', 'load_pdf' => 'Carregar PDF', 'start_free_trial' => 'Iniciar teste gratuito', - 'start_free_trial_message' => 'Comece seu teste GRATUITO de 14 dias do plano pro', + 'start_free_trial_message' => 'Start your FREE 14 day trial of the Pro Plan', 'due_on_receipt' => 'Vence Quando Recebido', 'is_paid' => 'É pago', 'age_group_paid' => 'Pago', diff --git a/lang/ro/texts.php b/lang/ro/texts.php index 36fce500a36d..6e78c5006972 100644 --- a/lang/ro/texts.php +++ b/lang/ro/texts.php @@ -2695,7 +2695,7 @@ Odată ce sumele au ajuns la dumneavoastră, reveniți la pagina cu metode de pl 'no_assets' => 'Nicio imagine, atașați pentru a încărca', 'add_image' => 'Adăugați o imagine', 'select_image' => 'Selectați imaginea', - 'upgrade_to_upload_images' => 'Faceți upgrade la Planul Enterprise pentru a încărca imagini', + 'upgrade_to_upload_images' => 'Upgrade to the Enterprise Plan to upload files & images', 'delete_image' => 'Eliminați imaginea', 'delete_image_help' => 'Atenție: eliminând imaginea, o veți îndepărta din toate propunerile.', 'amount_variable_help' => 'Notă: câmul facturii $amount va utiliza câmul parțial/depozit. Va utiliza soldul facturii, în cazul în care este setat diferit. ', @@ -4438,7 +4438,7 @@ Odată ce sumele au ajuns la dumneavoastră, reveniți la pagina cu metode de pl 'client_shipping_country' => 'Țară livrare client', 'load_pdf' => 'Încărcați PDF', 'start_free_trial' => 'Începeți perioada gratuită de test ', - 'start_free_trial_message' => 'Începeți perioada gratuită de test de 14 zile pentru planul PRO', + 'start_free_trial_message' => 'Start your FREE 14 day trial of the Pro Plan', 'due_on_receipt' => 'Scadență pe nota de plată', 'is_paid' => 'Este plătită', 'age_group_paid' => 'Plătit(ă)', diff --git a/lang/sk/texts.php b/lang/sk/texts.php index dabfb77a003b..bdc5336eb90d 100644 --- a/lang/sk/texts.php +++ b/lang/sk/texts.php @@ -2682,7 +2682,7 @@ $lang = array( 'no_assets' => 'Žiadne obrázky, nahrajte ich presunutím', 'add_image' => 'Pridať obrázok', 'select_image' => 'Vybrať obrázok', - 'upgrade_to_upload_images' => 'Ak chcete odovzdať obrázky, inovujte na podnikový plán', + 'upgrade_to_upload_images' => 'Upgrade to the Enterprise Plan to upload files & images', 'delete_image' => 'Zmazať obrázok', 'delete_image_help' => 'Upozornenie: Odstránením obrázka ho odstránite zo všetkých návrhov.', 'amount_variable_help' => 'Poznámka: Pole Faktúra $amount použije pole čiastková/záloha, ak je nastavené inak, použije sa zostatok faktúry.', @@ -4424,7 +4424,7 @@ $lang = array( 'client_shipping_country' => 'Krajina doručenia klienta', 'load_pdf' => 'Načítať PDF', 'start_free_trial' => 'Spustiť bezplatnú skúšobnú verziu', - 'start_free_trial_message' => 'Začnite BEZPLATNÚ 14-dňovú skúšobnú verziu profesionálneho plánu', + 'start_free_trial_message' => 'Start your FREE 14 day trial of the Pro Plan', 'due_on_receipt' => 'Splatné pri prijatí', 'is_paid' => 'Je zaplatená', 'age_group_paid' => 'Zaplatené', diff --git a/lang/sv/texts.php b/lang/sv/texts.php index a7b75c5b5ac6..93a53489e012 100644 --- a/lang/sv/texts.php +++ b/lang/sv/texts.php @@ -2703,7 +2703,7 @@ Den här funktionen kräver att en produkt skapas och en betalningsgateway är k 'no_assets' => 'Inga bilder, dra för att ladda upp', 'add_image' => 'Lägg till bild', 'select_image' => 'Välj bild', - 'upgrade_to_upload_images' => 'Upgrade to the Enterprise Plan to upload images', + 'upgrade_to_upload_images' => 'Upgrade to the Enterprise Plan to upload files & images', 'delete_image' => 'Ta bort bild', 'delete_image_help' => 'Varning: Bortagning av denna bild kommer ta bort den från alla förslag', 'amount_variable_help' => 'Notera: fakturans $amount fält kommer att använda del-/insättningsfältet om det ställs in annars kommer det att använda fakturasaldot.', @@ -4445,7 +4445,7 @@ Den här funktionen kräver att en produkt skapas och en betalningsgateway är k 'client_shipping_country' => 'Kundens leveransland', 'load_pdf' => 'Ladda PDF', 'start_free_trial' => 'Påbörja gratis försöksperiod', - 'start_free_trial_message' => 'Starta din GRATIS 14 dagars provversion av proplanen', + 'start_free_trial_message' => 'Start your FREE 14 day trial of the Pro Plan', 'due_on_receipt' => 'Förfaller vid mottagandet', 'is_paid' => 'Är betalad', 'age_group_paid' => 'Betalt', diff --git a/lang/zh_TW/texts.php b/lang/zh_TW/texts.php index 8fce614652c0..cc7cc58c5fe5 100644 --- a/lang/zh_TW/texts.php +++ b/lang/zh_TW/texts.php @@ -2695,7 +2695,7 @@ $lang = array( 'no_assets' => '無圖片,拖曳檔案至此上傳', 'add_image' => '新增圖片', 'select_image' => '選擇圖片', - 'upgrade_to_upload_images' => '升級至企業套餐上傳圖片', + 'upgrade_to_upload_images' => 'Upgrade to the Enterprise Plan to upload files & images', 'delete_image' => '刪除圖片', 'delete_image_help' => '警告: 刪除這個圖片,將會在所有的提案中移除它。', 'amount_variable_help' => '注意: 若經設定,發票的 $amount 欄位將使用 部分/存款 欄位;否則,它將使用發票餘額。', @@ -4437,7 +4437,7 @@ $lang = array( 'client_shipping_country' => '客戶出貨國家/地區', 'load_pdf' => '載入 PDF', 'start_free_trial' => '開啟免費體驗', - 'start_free_trial_message' => '開始 14 天免費試用專業計劃', + 'start_free_trial_message' => 'Start your FREE 14 day trial of the Pro Plan', 'due_on_receipt' => '收據到期', 'is_paid' => '已經付款了', 'age_group_paid' => '有薪資的', diff --git a/phpstan.neon b/phpstan.neon index b2c5b484fb23..5c586c4bb520 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,19 +3,20 @@ includes: - ./vendor/spaze/phpstan-stripe/extension.neon - phpstan-baseline.neon parameters: - level: 2 + level: 3 paths: - app excludePaths: - - 'vendor/*' - - 'resources/*/*.php' - - 'app/Jobs/Ninja/*' - - 'app/Models/Presenters/*' - - 'app/Console/Commands/*' - - 'app/DataMapper/Analytics/*' - - 'app/PaymentDrivers/Authorize/*' - - 'app/PaymentDrivers/AuthorizePaymentDriver.php' - - 'app/Utils/Traits/*' + analyseAndScan: + - 'vendor' + - 'resources' + - 'app/Jobs/Ninja/*' + - 'app/Models/Presenters/*' + - 'app/Console/Commands/*' + - 'app/DataMapper/Analytics/*' + - 'app/PaymentDrivers/Authorize/*' + - 'app/PaymentDrivers/AuthorizePaymentDriver.php' + - 'app/Utils/Traits/*' universalObjectCratesClasses: - App\DataMapper\Tax\RuleInterface - App\DataMapper\FeesAndLimits @@ -28,3 +29,5 @@ parameters: - '#makeHidden#' - '#Socialite#' - '#Access to protected property#' + - '#Call to undefined method .*#' + - '#Argument of an invalid type stdClass supplied for foreach, only iterables are supported.#' \ No newline at end of file diff --git a/resources/views/portal/ninja2020/gateways/paypal/pay.blade.php b/resources/views/portal/ninja2020/gateways/paypal/pay.blade.php index 588ed1123de7..86eba7ccf830 100644 --- a/resources/views/portal/ninja2020/gateways/paypal/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/paypal/pay.blade.php @@ -29,6 +29,17 @@ @endsection @push('footer') + + + + + +