php-cs-fixer

This commit is contained in:
David Bomba 2024-06-14 17:09:44 +10:00
parent 9c288cd452
commit 72aadc0c16
232 changed files with 1436 additions and 1417 deletions

View File

@ -478,10 +478,9 @@ 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) {
}
@ -949,12 +948,12 @@ class CheckData extends Command
});
Company::whereDoesntHave('company_users', function ($query){
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,7 +962,7 @@ 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}");

View File

@ -15,7 +15,6 @@ use App\DataMapper\InvoiceItem;
class PayPalBalanceAffecting
{
private array $key_map = [
'Date' => 'date',
'Time' => 'time',
@ -106,7 +105,9 @@ class PayPalBalanceAffecting
public $creditTransactionalFee;
public $originalInvoiceId;
public function __construct(private array $import_row){}
public function __construct(private array $import_row)
{
}
public function run(): self
{
@ -116,7 +117,7 @@ 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 ?? '';
}
@ -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],

View File

@ -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;
}

View File

@ -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);

View File

@ -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);
});

View File

@ -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)

View File

@ -85,7 +85,7 @@ class ExpenseExport extends BaseExport
->where('company_id', $this->company->id);
if(!$this->input['include_deleted'] ?? false){
if(!$this->input['include_deleted'] ?? false) {
$query->where('is_deleted', 0);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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)

View File

@ -76,7 +76,7 @@ class ProductExport extends BaseExport
->where('company_id', $this->company->id);
if(!$this->input['include_deleted'] ?? false){
if(!$this->input['include_deleted'] ?? false) {
$query->where('is_deleted', 0);
}

View File

@ -86,7 +86,7 @@ class ProductSalesExport extends BaseExport
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) {
$q->orWhereJsonContains('line_items', ['product_key' => $key]);
@ -121,7 +121,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,20 +138,19 @@ 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))
if($product_keys) {
if(in_array($item->product_key, $product_keys)) {
$this->csv->insertOne($this->buildRow($invoice, $item));
}
else {
} else {
$this->csv->insertOne($this->buildRow($invoice, $item));
}
@ -159,9 +158,9 @@ class ProductSalesExport extends BaseExport
});
$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 +184,8 @@ class ProductSalesExport extends BaseExport
})->reject(function ($value) {
return $value === false;
});;
});
;
$this->csv->insertOne([]);
$this->csv->insertOne([]);

View File

@ -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'] ?? '');

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -70,7 +70,7 @@ class TaskExport 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);
}
@ -78,13 +78,15 @@ class TaskExport extends BaseExport
$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;

View File

@ -64,7 +64,7 @@ class VendorExport 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);
}

View File

@ -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;

View File

@ -124,8 +124,9 @@ class BankTransactionFilters extends QueryFilters
*/
public function bank_integration_ids(string $ids = ''): Builder
{
if(strlen($ids) == 0)
if(strlen($ids) == 0) {
return $this->builder;
}
$ids = $this->transformKeys(explode(",", $ids));

View File

@ -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';

View File

@ -59,8 +59,9 @@ 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;

View File

@ -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),

View File

@ -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');
});
}

View File

@ -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;
}
}

View File

@ -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';
}

View File

@ -152,8 +152,9 @@ class Nordigen
{
$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());

View File

@ -71,7 +71,7 @@ class TransactionTransformer implements BankRevenueInterface
private Company $company;
function __construct(Company $company)
public function __construct(Company $company)
{
$this->company = $company;
}

View File

@ -35,7 +35,8 @@ 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) {
@ -45,7 +46,7 @@ trait CustomValuer
$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;

View File

@ -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;
}

View File

@ -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 {
@ -303,7 +302,7 @@ class InvoiceSumInclusive
return $this;
}
function roundRappen($value): float
public function roundRappen($value): float
{
return round($value / .05, 0) * .05;
}

View File

@ -55,7 +55,7 @@ class Office365MailTransport extends AbstractTransport
->execute();
} catch (\Exception $e) {
sleep(rand(5,10));
sleep(rand(5, 10));
try {
$graphMessage = $graph->createRequest('POST', '/users/'.$symfony_message->getFrom()[0]->getAddress().'/sendmail')

View File

@ -398,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();
}
});

View File

@ -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'] ?? '';

View File

@ -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) {
@ -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');

View File

@ -250,7 +250,7 @@ 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);
@ -258,7 +258,7 @@ class ClientController extends BaseController
}
if($action == 'bulk_update' && $user->can('edit', $clients->first())){
if($action == 'bulk_update' && $user->can('edit', $clients->first())) {
$clients = Client::withTrashed()
->company()
@ -351,8 +351,9 @@ 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();

View File

@ -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()

View File

@ -715,18 +715,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=');

View File

@ -420,7 +420,7 @@ 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);
@ -567,10 +567,11 @@ class CompanyGatewayController extends BaseController
{
//Throttle here
if (Cache::has("throttle_polling:import_customers:{$company_gateway->company->company_key}:{$company_gateway->hashed_id}"))
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) {
dispatch(function () use ($company_gateway) {
MultiDB::setDb($company_gateway->company->db);
$company_gateway->driver()->importCustomers();
})->afterResponse();

View File

@ -64,7 +64,7 @@ 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();
});

View File

@ -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());
}

View File

@ -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);

View File

@ -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');

View File

@ -18,7 +18,6 @@ use Illuminate\Support\Facades\Mail;
class SmtpController extends BaseController
{
public function __construct()
{
parent::__construct();
@ -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())

View File

@ -59,7 +59,7 @@ 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');

View File

@ -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();

View File

@ -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);

View File

@ -260,7 +260,7 @@ class UserController extends BaseController
/** @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();

View File

@ -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');
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -97,7 +97,7 @@ 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']);
}
@ -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', '<?php', '@php', '@for','@class','</sc','<sc','html;base64', '@elseif', '@else', '@endunless', '@endisset', '@endempty', '@endauth', '@endguest', '@endproduction', '@endenv', '@hasSection', '@endhasSection', '@sectionMissing', '@endsectionMissing', '@endfor', '@endforeach', '@empty', '@endforelse', '@endwhile', '@continue', '@break', '@includeIf', '@includeWhen', '@includeUnless', '@includeFirst', '@component', '@endcomponent', '@endsection', '@yield', '@show', '@append', '@overwrite', '@stop', '@extends', '@endpush', '@stack', '@prepend', '@endprepend', '@slot', '@endslot', '@endphp', '@method', '@csrf', '@error', '@enderror', '@json', '@endverbatim', '@inject'], '', $settings['email_style_custom']);
}
if(isset($settings['company_logo']) && strlen($settings['company_logo']) > 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}";
}

View File

@ -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);
}

View File

@ -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();

View File

@ -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';
}

View File

@ -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';
}
@ -122,9 +122,10 @@ 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);
}

View File

@ -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';
}

View File

@ -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');

View File

@ -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';
}

View File

@ -45,9 +45,9 @@ class UpdatePaymentRequest extends Request
'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';
}

View File

@ -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';
}

View File

@ -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';
}

View File

@ -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);
}

View File

@ -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';
}

View File

@ -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';

View File

@ -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';
}

View File

@ -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';
}
@ -98,10 +98,11 @@ 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;
$input['due_date'] = \Carbon\Carbon::parse($input['date'])->addDays($valid_days)->format('Y-m-d');

View File

@ -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';
}

View File

@ -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';
}

View File

@ -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';
}

View File

@ -68,7 +68,7 @@ class GenericReportRequest extends Request
$input['user_id'] = auth()->user()->id;
if(!$this->checkAuthority()){
if(!$this->checkAuthority()) {
$input['date_range'] = '';
$input['start_date'] = '';
$input['end_date'] = '';

View File

@ -83,7 +83,7 @@ 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;
}

View File

@ -17,7 +17,6 @@ use Illuminate\Auth\Access\AuthorizationException;
class ProfitLossRequest extends Request
{
private string $error_message = '';
/**
@ -61,7 +60,7 @@ class ProfitLossRequest 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;
}

View File

@ -46,7 +46,7 @@ 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;
}

View File

@ -33,8 +33,9 @@ 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;
@ -46,8 +47,9 @@ 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);

View File

@ -52,20 +52,19 @@ class CheckSmtpRequest extends Request
$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;
}

View File

@ -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';
}

View File

@ -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';
}

View File

@ -93,7 +93,7 @@ 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);

View File

@ -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';
}

View File

@ -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';
}

View File

@ -40,5 +40,3 @@ class TwigLint implements ValidationRule
}
}

View File

@ -71,8 +71,9 @@ class LockedInvoiceRule implements Rule
//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:

View File

@ -255,8 +255,9 @@ class BaseImport
unset($record['']);
if(!is_array($record))
if(!is_array($record)) {
continue;
}
try {
$entity = $this->transformer->transform($record);

View File

@ -102,16 +102,14 @@ 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'] = [
[
@ -125,18 +123,19 @@ 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];
@ -199,7 +198,7 @@ class InvoiceTransformer extends BaseTransformer
],
];
if(!isset($invoice_data['Items'])){
if(!isset($invoice_data['Items'])) {
return $default_data;
}
@ -208,8 +207,7 @@ 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'];
@ -230,8 +228,9 @@ 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'];
@ -241,7 +240,7 @@ class InvoiceTransformer extends BaseTransformer
}
function parseCsvWithNestedCsv($csvString, $delimiter = ',', $enclosure = '"', $lineEnding = ';')
public function parseCsvWithNestedCsv($csvString, $delimiter = ',', $enclosure = '"', $lineEnding = ';')
{
// Regular expression to find nested CSVs
$nestedCsvPattern = '/"([^"]*(?:""[^"]*)*)"/';

View File

@ -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;

View File

@ -350,12 +350,14 @@ 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));
}
}
//
private function postImportCleanup()
@ -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', '<?php', '@php', '@for','@class','</s','<s','html;base64'], '', $settings->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});
}

View File

@ -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);

View File

@ -49,7 +49,7 @@ 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();

View File

@ -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 "";
}
}

View File

@ -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;
}
}
}

View File

@ -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;

View File

@ -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,22 +153,19 @@ 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') {
@ -179,8 +176,7 @@ class NinjaMailerJob implements ShouldQueue
}
}
catch (\Exception $e) {
} catch (\Exception $e) {
nlog("Mailer failed with {$e->getMessage()}");
$message = $e->getMessage();
@ -204,7 +200,7 @@ 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';
@ -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
@ -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}");
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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();
}

View File

@ -209,7 +209,7 @@ class ReminderJob implements ShouldQueue
->save();
}
if(!$invoice){
if(!$invoice) {
$invoice = $over_due_invoice;
}

View File

@ -538,7 +538,7 @@ class MultiDB
$current_db = config('database.default');
if(SMSNumbers::hasNumber($phone)){
if(SMSNumbers::hasNumber($phone)) {
return true;
}

Some files were not shown because too many files have changed in this diff Show More