Style fixes

This commit is contained in:
David Bomba 2024-11-20 11:15:49 +11:00
parent 57f5ec7d1f
commit 552d596eae
613 changed files with 6887 additions and 6906 deletions

View File

@ -9,7 +9,6 @@
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Casts;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
@ -19,7 +18,7 @@ class AsTaxEntityCollection implements CastsAttributes
{
public function get($model, string $key, $value, array $attributes)
{
if (!$value || (is_string($value) && $value =="null")) {
if (!$value || (is_string($value) && $value == "null")) {
return [];
}
@ -33,7 +32,7 @@ class AsTaxEntityCollection implements CastsAttributes
if (!$value) {
return '[]';
}
if ($value instanceof TaxEntity) {
$value = [$value];
}

View File

@ -18,7 +18,7 @@ class ClientSyncCast implements CastsAttributes
{
public function get($model, string $key, $value, array $attributes)
{
if (is_null($value)) {
return null; // Return null if the value is null
}

View File

@ -18,7 +18,7 @@ class InvoiceSyncCast implements CastsAttributes
{
public function get($model, string $key, $value, array $attributes)
{
if (is_null($value)) {
return null; // Return null if the value is null
}
@ -38,8 +38,9 @@ class InvoiceSyncCast implements CastsAttributes
{
$data = [];
if(isset($value->qb_id) && strlen($value->qb_id) >= 1)
if (isset($value->qb_id) && strlen($value->qb_id) >= 1) {
$data['qb_id'] = $value->qb_id;
}
return [
$key => json_encode($data)

View File

@ -18,7 +18,7 @@ class ProductSyncCast implements CastsAttributes
{
public function get($model, string $key, $value, array $attributes)
{
if (is_null($value)) {
return null; // Return null if the value is null
}

View File

@ -18,8 +18,9 @@ class QuickbooksSettingsCast implements CastsAttributes
{
public function get($model, string $key, $value, array $attributes)
{
if (is_null($value))
if (is_null($value)) {
return new QuickbooksSettings();
}
$data = json_decode($value, true);
return QuickbooksSettings::fromArray($data);

View File

@ -56,7 +56,7 @@ class BackupUpdate extends Command
{
//always return state to first DB
if(Ninja::isSelfHost()) {
if (Ninja::isSelfHost()) {
return;
}
@ -175,7 +175,7 @@ class BackupUpdate extends Command
try {
$doc_bin = $document->getFile();
} catch(\Exception $e) {
} catch (\Exception $e) {
nlog("Exception:: BackupUpdate::" . $e->getMessage());
}

View File

@ -145,15 +145,15 @@ class CheckData extends Command
$this->checkOAuth();
}
if($this->option('bank_transaction')) {
if ($this->option('bank_transaction')) {
$this->fixBankTransactions();
}
if($this->option('line_items')) {
if ($this->option('line_items')) {
$this->cleanInvoiceLineItems();
}
if($this->option('payment_balance')){
if ($this->option('payment_balance')) {
$this->updateClientPaymentBalances();
}
$this->logMessage('Done: '.strtoupper($this->isValid ? Account::RESULT_SUCCESS : Account::RESULT_FAILURE));
@ -492,7 +492,7 @@ class CheckData extends Command
try {
$entity->service()->createInvitations()->save();
} catch(\Exception $e) {
} catch (\Exception $e) {
}
@ -502,7 +502,7 @@ class CheckData extends Command
if ($invitation) {
$invitation->save();
}
} catch(\Exception $e) {
} catch (\Exception $e) {
$this->logMessage($e->getMessage());
$invitation = null;
}
@ -527,7 +527,7 @@ class CheckData extends Command
try {
$invitation->save();
} catch(\Exception $e) {
} catch (\Exception $e) {
$invitation = null;
}
}
@ -562,7 +562,7 @@ class CheckData extends Command
->where('is_deleted', 0)
->cursor()
->each(function ($client) {
$client->service()->updatePaymentBalance();
$this->logMessage("{$client->present()->name()} payment balance = {$client->payment_balance}");
});
@ -1109,7 +1109,7 @@ class CheckData extends Command
BankTransaction::with('payment')->withTrashed()->where('invoice_ids', ',,,,,,,,')->cursor()->each(function ($bt) {
if($bt->payment->exists()) {
if ($bt->payment->exists()) {
$this->isValid = false;
$bt->invoice_ids = collect($bt->payment->invoices)->pluck('hashed_id')->implode(',');
@ -1144,7 +1144,7 @@ class CheckData extends Command
public function checkSubdomainsSet()
{
if(Ninja::isSelfHost()) {
if (Ninja::isSelfHost()) {
return;
}
@ -1169,7 +1169,7 @@ class CheckData extends Command
$this->logMessage($p->count() . " Payments with No currency set");
if($p->count() != 0) {
if ($p->count() != 0) {
$this->isValid = false;
}
@ -1213,8 +1213,8 @@ class CheckData extends Command
$invoice->saveQuietly();
});
}
}

View File

@ -103,7 +103,7 @@ class CreateSingleAccount extends Command
try {
$pdo = \DB::connection('ronin')->getPdo();
if(class_exists(\Modules\Ronin\app\Models\Admin::class)) {
if (class_exists(\Modules\Ronin\app\Models\Admin::class)) {
$this->info('Creating Ronin Account');
$this->createRoninAccount();
}
@ -378,7 +378,7 @@ class CreateSingleAccount extends Command
Project::query()->with('client')->whereNotNull('client_id')->cursor()->each(function ($p) {
if($p && $p->client && !isset($p->number)) {
if ($p && $p->client && !isset($p->number)) {
$p->number = $this->getNextProjectNumber($p);
$p->save();
}
@ -584,7 +584,7 @@ class CreateSingleAccount extends Command
'task_rate' => rand(1, 200),
]);
for($x = 0; $x < rand(2, 5); $x++) {
for ($x = 0; $x < rand(2, 5); $x++) {
$task = $this->createTask($client);
$task->project_id = $project->id;
$task->save();
@ -883,7 +883,7 @@ class CreateSingleAccount extends Command
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
}
if (config('ninja.testvars.braintree') && ($this->gateway == 'all' || $this->gateway == 'braintree')) {
$cg = new CompanyGateway();
$cg->company_id = $company->id;

View File

@ -52,11 +52,11 @@ class EncryptNinja extends Command
*/
public function handle()
{
if($this->option('encrypt')) {
if ($this->option('encrypt')) {
return $this->encryptFiles();
}
if($this->option('decrypt')) {
if ($this->option('decrypt')) {
return $this->decryptFiles();
}

View File

@ -63,7 +63,7 @@ class MobileLocalization extends Command
{
$resources = (array)$this->getResources();
if(is_iterable($resources)) {
if (is_iterable($resources)) {
foreach ($resources as $key => $val) {
$transKey = "texts.{$key}";
if (trans($transKey) == $transKey) {

View File

@ -46,7 +46,7 @@ class ReactBuilder extends Command
*/
public function handle()
{
if($this->option('type') == 'local') {
if ($this->option('type') == 'local') {

View File

@ -68,7 +68,7 @@ class SendTestEmails extends Command
});
} catch(\Exception $e) {
} catch (\Exception $e) {
$this->info("Error sending email: " . $e->getMessage());
}
}

View File

@ -139,7 +139,7 @@ class TranslationsExport extends Command
Storage::disk('local')->makeDirectory("lang/{$lang}");
$translations = Lang::getLoader()->load($lang, 'texts');
foreach($translations as $key => $value) {
foreach ($translations as $key => $value) {
$translations[$key] = html_entity_decode($value);
}

View File

@ -130,7 +130,7 @@ class TypeCheck extends Command
$company->saveSettings($company->settings, $company);
});
Invoice::query()->cursor()->each(function ($invoice){
Invoice::query()->cursor()->each(function ($invoice) {
$this->logMessage("Checking invoice {$invoice->id}");
$invoice->line_items = $this->cleanItems($invoice->line_items);
$invoice->saveQuietly();

View File

@ -16,7 +16,6 @@ namespace App\DataMapper;
*/
class BaseSettings
{
public static function setCasts($obj, $casts)
{
foreach ($casts as $key => $value) {

View File

@ -11,24 +11,23 @@
namespace App\DataMapper\EInvoice;
class TaxEntity
{
/** @var string $version */
public string $version = 'alpha';
/** @var ?int $legal_entity_id */
public ?int $legal_entity_id = null;
/** @var string $company_key */
public string $company_key = '';
/** @var array<string> */
public array $received_documents = [];
/** @var bool $acts_as_sender */
public bool $acts_as_sender = true;
/** @var bool $acts_as_receiver */
public bool $acts_as_receiver = true;
/**

View File

@ -20,12 +20,12 @@ use Illuminate\Contracts\Database\Eloquent\Castable;
class InvoiceSync implements Castable
{
public string $qb_id;
public function __construct(array $attributes = [])
{
$this->qb_id = $attributes['qb_id'] ?? '';
}
/**

View File

@ -28,9 +28,9 @@ class QuickbooksSettings implements Castable
public int $accessTokenExpiresAt;
public int $refreshTokenExpiresAt;
public string $baseURL;
public QuickbooksSync $settings;
public function __construct(array $attributes = [])

View File

@ -19,19 +19,19 @@ class QuickbooksSync
public QuickbooksSyncMap $client;
public QuickbooksSyncMap $vendor;
public QuickbooksSyncMap $invoice;
public QuickbooksSyncMap $sales;
public QuickbooksSyncMap $quote;
public QuickbooksSyncMap $purchase_order;
public QuickbooksSyncMap $product;
public QuickbooksSyncMap $payment;
public QuickbooksSyncMap $expense;
public string $default_income_account = '';
@ -52,4 +52,4 @@ class QuickbooksSync
$this->default_income_account = $attributes['default_income_account'] ?? '';
$this->default_expense_account = $attributes['default_expense_account'] ?? '';
}
}
}

View File

@ -113,11 +113,11 @@ class PayPalBalanceAffecting
{
$this->cleanUp();
foreach($this->import_row as $key => $value) {
foreach ($this->import_row as $key => $value) {
$prop = $this->key_map[$key] ?? false;
if($prop) {
if ($prop) {
echo "Setting {$prop} to {$value}".PHP_EOL;
$this->{$prop} = $value;
@ -131,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;
}
@ -175,7 +175,7 @@ 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 {
@ -202,13 +202,13 @@ 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 [];
}

View File

@ -157,8 +157,8 @@ class BaseRule implements RuleInterface
$this->resolveRegions();
if(!$this->isTaxableRegion()) {
if (!$this->isTaxableRegion()) {
$this->tax_data = null;
$this->tax_rate1 = 0;
$this->tax_name1 = '';
@ -173,8 +173,9 @@ class BaseRule implements RuleInterface
$this->tax_data = new Response($this->invoice->tax_data);
if($this->invoice instanceof \App\Models\RecurringInvoice)
if ($this->invoice instanceof \App\Models\RecurringInvoice) {
$this->tax_data = new Response($this->client->tax_data);
}
return $this;
}
@ -187,14 +188,14 @@ class BaseRule implements RuleInterface
private function configTaxData(): self
{
/* We should only apply taxes for configured states */
if(!array_key_exists($this->client->country->iso_3166_2, $this->region_codes)) {
if (!array_key_exists($this->client->country->iso_3166_2, $this->region_codes)) {
nlog('Automatic tax calculations not supported for this country - defaulting to company country');
}
/** Harvest the client_region */
/** If the tax data is already set and the invoice is marked as sent, do not adjust the rates */
if($this->invoice->tax_data && $this->invoice->status_id > 1) {
if ($this->invoice->tax_data && $this->invoice->status_id > 1) {
return $this;
}
@ -206,23 +207,23 @@ class BaseRule implements RuleInterface
$tax_data = false;
if($this->seller_region == 'US' && $this->client_region == 'US') {
if ($this->seller_region == 'US' && $this->client_region == 'US') {
$company = $this->invoice->company;
/** If no company tax data has been configured, lets do that now. */
/** We should never encounter this scenario */
if(!$company->origin_tax_data) {
if (!$company->origin_tax_data) {
$this->should_calc_tax = false;
return $this;
}
/** If we are in a Origin based state, force the company tax here */
if($company->origin_tax_data->originDestination == 'O' && ($company->tax_data?->seller_subregion == $this->client_subregion)) {
if ($company->origin_tax_data->originDestination == 'O' && ($company->tax_data?->seller_subregion == $this->client_subregion)) {
$tax_data = $company->origin_tax_data;
} elseif($this->client->tax_data) {
} elseif ($this->client->tax_data) {
$tax_data = $this->client->tax_data;
@ -231,15 +232,15 @@ class BaseRule implements RuleInterface
}
/** Applies the tax data to the invoice */
if(($this->invoice instanceof Invoice || $this->invoice instanceof Quote) && $tax_data) {
if (($this->invoice instanceof Invoice || $this->invoice instanceof Quote) && $tax_data) {
$this->invoice->tax_data = $tax_data;
if(\DB::transactionLevel() == 0 && isset($this->invoice->id)) {
if (\DB::transactionLevel() == 0 && isset($this->invoice->id)) {
try {
$this->invoice->saveQuietly();
} catch(\Exception $e) {
} catch (\Exception $e) {
nlog("Exception:: BaseRule::" . $e->getMessage());
}
@ -279,7 +280,7 @@ class BaseRule implements RuleInterface
$states = USStates::$states;
if(isset($states[$this->client->state])) {
if (isset($states[$this->client->state])) {
return $this->client->state;
}
@ -292,18 +293,18 @@ class BaseRule implements RuleInterface
public function isTaxableRegion(): bool
{
return
return
isset($this->client->company->tax_data->regions->{$this->client_region}->tax_all_subregions) && $this->client->company->tax_data->regions->{$this->client_region}->tax_all_subregions ||
(isset($this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}) && ($this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->apply_tax ?? false));
}
public function defaultForeign(): self
{
if($this->invoice->client->is_tax_exempt){
if ($this->invoice->client->is_tax_exempt) {
$this->tax_rate1 = 0;
$this->tax_name1 = '';
$this->tax_rate2 = 0;
$this->tax_name2 = '';
@ -312,16 +313,14 @@ class BaseRule implements RuleInterface
return $this;
}
elseif($this->client_region == 'US' && isset($this->tax_data?->taxSales)) {
} elseif ($this->client_region == 'US' && isset($this->tax_data?->taxSales)) {
$this->tax_rate1 = $this->tax_data->taxSales * 100;
$this->tax_name1 = "{$this->tax_data->geoState} Sales Tax";
return $this;
}
elseif($this->client_region == 'AU') { //these are defaults and are only stubbed out for now, for AU we can actually remove these
} elseif ($this->client_region == 'AU') { //these are defaults and are only stubbed out for now, for AU we can actually remove these
$this->tax_rate1 = $this->client->company->tax_data->regions->AU->subregions->AU->tax_rate;
$this->tax_name1 = $this->client->company->tax_data->regions->AU->subregions->AU->tax_name;
@ -329,7 +328,7 @@ class BaseRule implements RuleInterface
return $this;
}
if(isset($this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion})) {
if (isset($this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion})) {
if ($this->client_region === 'EU') {
$company_country_code = $this->client->company->country()->iso_3166_2;
$client_country_code = $this->client->country->iso_3166_2;
@ -350,13 +349,11 @@ class BaseRule implements RuleInterface
elseif (in_array($company_country_code, $this->eu_country_codes)) {
$this->tax_rate1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$company_country_code}->tax_rate;
$this->tax_name1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$company_country_code}->tax_name;
}
elseif($is_over_threshold){
} elseif ($is_over_threshold) {
$this->tax_rate1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_rate;
$this->tax_name1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_name;
}
}
else {
} else {
$this->tax_rate1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_rate;
$this->tax_name1 = $this->client->company->tax_data->regions->{$this->client_region}->subregions->{$this->client_subregion}->tax_name;
}
@ -368,17 +365,17 @@ class BaseRule implements RuleInterface
public function tax($item = null): self
{
if ($this->client->is_tax_exempt || !property_exists($item, 'tax_id') ) {
if ($this->client->is_tax_exempt || !property_exists($item, 'tax_id')) {
return $this->taxExempt($item);
} elseif($this->client_region == $this->seller_region && $this->isTaxableRegion()) {
} elseif ($this->client_region == $this->seller_region && $this->isTaxableRegion()) {
$this->taxByType($item);
return $this;
} elseif($this->isTaxableRegion()) { //other regions outside of US
} elseif ($this->isTaxableRegion()) { //other regions outside of US
match(intval($item->tax_id)) {
Product::PRODUCT_TYPE_EXEMPT => $this->taxExempt($item),
@ -420,7 +417,7 @@ class BaseRule implements RuleInterface
public function taxExempt($item): self
{
$this->tax_rate1 = 0;
$this->tax_name1 = '';
@ -485,7 +482,7 @@ class BaseRule implements RuleInterface
{
$lock_invoices = $this->client->getSetting('lock_invoices');
if($this->invoice instanceof RecurringInvoice) {
if ($this->invoice instanceof RecurringInvoice) {
return true;
}
@ -508,7 +505,7 @@ class BaseRule implements RuleInterface
//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;

View File

@ -237,7 +237,7 @@ class Rule extends BaseRule implements RuleInterface
*/
public function calculateRates(): self
{
// Tax exempt clients always get zero tax
if ($this->client->is_tax_exempt) {
$this->tax_rate = 0;

View File

@ -50,7 +50,7 @@ class Rule extends BaseRule implements RuleInterface
*/
public function init(): self
{
$this->calculateRates();
return $this;
@ -65,11 +65,11 @@ class Rule extends BaseRule implements RuleInterface
public function taxByType($item): self
{
if ($this->client->is_tax_exempt || !property_exists($item, 'tax_id') || (isset($item->type_id) && $item->type_id == '5')) {
return $this->taxExempt($item);
}
match(intval($item->tax_id)) {
Product::PRODUCT_TYPE_EXEMPT => $this->taxExempt($item),
Product::PRODUCT_TYPE_DIGITAL => $this->taxDigital($item),
@ -216,7 +216,7 @@ class Rule extends BaseRule implements RuleInterface
*/
public function override($item): self
{
$this->tax_rate1 = $item->tax_rate1;
$this->tax_name1 = $item->tax_name1;
$this->tax_rate2 = $item->tax_rate2;
@ -270,14 +270,14 @@ class Rule extends BaseRule implements RuleInterface
}
// GB => GB sales
if($this->client_subregion == 'GB') {
if ($this->client_subregion == 'GB') {
$this->tax_name = $this->client->company->tax_data->regions->UK->subregions->GB->tax_name;
$this->tax_rate = $this->client->company->tax_data->regions->UK->subregions->GB->tax_rate ?? 0;
return $this;
}
$is_over_threshold = $this->client->company->tax_data->regions->EU->has_sales_above_threshold ?? false;
//GB => EU sales - Reverse Charge
@ -287,20 +287,19 @@ class Rule extends BaseRule implements RuleInterface
$this->tax_rate = 0;
return $this;
}
elseif(in_array($this->client_subregion, $this->eu_country_codes) && $is_over_threshold) {
} elseif (in_array($this->client_subregion, $this->eu_country_codes) && $is_over_threshold) {
$this->tax_name = $this->client->company->tax_data->regions->EU->subregions->{$this->client->country->iso_3166_2}->tax_name;
$this->tax_rate = $this->client->company->tax_data->regions->EU->subregions->{$this->client->country->iso_3166_2}->tax_rate ?? 0;
return $this;
}
// must be tax exempt at this point
$this->tax_name = 'VAT';
$this->tax_rate = 0;
$this->tax_name = 'VAT';
$this->tax_rate = 0;
return $this;
}

View File

@ -25,7 +25,7 @@ class TaxData
public function __construct(public Response $origin)
{
// @phpstan-ignore-next-line
foreach($origin as $key => $value) {
foreach ($origin as $key => $value) {
$this->{$key} = $value;
}
}

View File

@ -21,13 +21,13 @@ class TaxModel
/** @var object $regions */
public object $regions;
/** @var bool $acts_as_sender */
public bool $acts_as_sender = false;
/** @var bool $acts_as_receiver */
public bool $acts_as_receiver = false;
/**
* __construct
*
@ -37,14 +37,14 @@ class TaxModel
public function __construct(public mixed $model = null)
{
if(!$model) {
if (!$model) {
$this->regions = $this->init();
} else {
$this->seller_subregion = $model->seller_subregion ?? '';
$this->acts_as_sender = $model->acts_as_sender ?? false;
$this->acts_as_receiver = $model->acts_as_receiver ?? false;
$modelArray = get_object_vars($model);
foreach ($modelArray as $key => $value) {
$this->{$key} = $value;
@ -58,7 +58,7 @@ class TaxModel
public function migrate(): self
{
if($this->version == 'alpha') {
if ($this->version == 'alpha') {
$this->regions->EU->subregions->PL = new \stdClass();
$this->regions->EU->subregions->PL->tax_rate = 23;
$this->regions->EU->subregions->PL->tax_name = 'VAT';
@ -68,7 +68,7 @@ class TaxModel
$this->version = 'beta';
}
if($this->version == 'beta') {
if ($this->version == 'beta') {
//CEUTA
$this->regions->EU->subregions->{'ES-CE'} = new \stdClass();
@ -138,7 +138,7 @@ class TaxModel
$this->usRegion()
->euRegion()
->auRegion();
// ->ukRegion();
// ->ukRegion();
return $this->regions;
@ -149,9 +149,9 @@ class TaxModel
// Add new UK region
$this->regions->UK = new \stdClass();
$this->regions->UK->has_sales_above_threshold = false;
$this->regions->UK->tax_threshold = 85000;
$this->regions->UK->tax_all_subregions = false;
$this->regions->UK->has_sales_above_threshold = false;
$this->regions->UK->tax_threshold = 85000;
$this->regions->UK->tax_all_subregions = false;
$this->regions->UK->subregions = new \stdClass();
// Great Britain (England, Scotland, Wales)
@ -178,7 +178,7 @@ class TaxModel
return $this;
}
/**
* Builds the model for Australian Taxes
*
@ -577,7 +577,7 @@ class TaxModel
$this->regions->EU->subregions->IE->tax_name = 'VAT';
$this->regions->EU->subregions->IE->reduced_tax_rate = 0;
$this->regions->EU->subregions->IE->apply_tax = false;
$this->regions->EU->subregions->IS = new \stdClass();
$this->regions->EU->subregions->IS->tax_rate = 24;
$this->regions->EU->subregions->IS->tax_name = 'VSK';
@ -589,7 +589,7 @@ class TaxModel
$this->regions->EU->subregions->IT->tax_name = 'IVA';
$this->regions->EU->subregions->IT->reduced_tax_rate = 10;
$this->regions->EU->subregions->IT->apply_tax = false;
$this->regions->EU->subregions->LI = new \stdClass();
$this->regions->EU->subregions->LI->tax_rate = 7.7;
$this->regions->EU->subregions->LI->tax_name = 'MWST';
@ -619,7 +619,7 @@ class TaxModel
$this->regions->EU->subregions->MT->tax_name = 'VAT';
$this->regions->EU->subregions->MT->reduced_tax_rate = 5;
$this->regions->EU->subregions->MT->apply_tax = false;
$this->regions->EU->subregions->NO = new \stdClass();
$this->regions->EU->subregions->NO->tax_rate = 25;
$this->regions->EU->subregions->NO->tax_name = 'MVA';
@ -682,7 +682,7 @@ class TaxModel
}
$subregions[$region_code] = [];
foreach ($region->subregions as $subregion_code => $subregion) {
$subregions[$region_code][] = $subregion_code;
}
@ -697,7 +697,7 @@ class TaxModel
if (!isset($region->subregions)) {
continue;
}
if (isset($region->subregions->{$subregion_code})) {
return $region_code;
}

View File

@ -116,7 +116,7 @@ class Rule extends BaseRule implements RuleInterface
*/
public function taxService($item): self
{
if(in_array($this->tax_data?->txbService, ['Y','L'])) {
if (in_array($this->tax_data?->txbService, ['Y','L'])) {
$this->default($item);
} else {
$this->taxExempt($item);
@ -133,7 +133,7 @@ class Rule extends BaseRule implements RuleInterface
*/
public function taxShipping($item): self
{
if($this->tax_data?->txbFreight == 'Y') {
if ($this->tax_data?->txbFreight == 'Y') {
return $this->default($item);
}
@ -164,7 +164,7 @@ class Rule extends BaseRule implements RuleInterface
public function default($item): self
{
if($this->tax_data?->stateSalesTax == 0) {
if ($this->tax_data?->stateSalesTax == 0) {
$this->tax_rate1 = 0;
$this->tax_name1 = '';

View File

@ -103,9 +103,9 @@ class Response
public function __construct($data = null)
{
if($data) {
if ($data) {
foreach($data as $key => $value) {
foreach ($data as $key => $value) {
$this->{$key} = $value;
}

View File

@ -93934,34 +93934,34 @@ class SMSNumbers
{
// Remove duplicates and reindex array
$unique_numbers = array_values(array_unique(self::$temp_numbers));
// Sort the array
sort($unique_numbers);
return $unique_numbers;
}
/**
* deDupe
*
* Cleans up the phone numbers are removed duplicates
*
*
* @return void
*/
public static function deDupe()
{
$unique_numbers = self::uniqueNumbers();
$output = "private static array \$temp_numbers = [\n";
foreach ($unique_numbers as $number) {
$output .= " '" . $number . "',\n";
}
$output .= "];";
echo $output;
}

View File

@ -33868,19 +33868,19 @@ class USStates
public static function getState(?string $zip = '90210'): string
{
if(isset(self::$zip_code_map[$zip])) {
if (isset(self::$zip_code_map[$zip])) {
return self::$zip_code_map[$zip];
}
$prefix_state = self::getStateFromThreeDigitPrefix($zip);
if($prefix_state) {
if ($prefix_state) {
return $prefix_state;
}
$zippo_response = self::getStateFromZippo($zip);
if($zippo_response) {
if ($zippo_response) {
return $zippo_response;
}
@ -33908,13 +33908,13 @@ class USStates
$response = Http::get("https://api.zippopotam.us/us/{$zip}");
if($response->failed()) {
if ($response->failed()) {
return false;
}
$data = $response->object();
if(isset($data->places[0])) {
if (isset($data->places[0])) {
return $data->places[0]->{'state abbreviation'};
}

View File

@ -48,7 +48,7 @@ class CreditWasUpdated implements ShouldBroadcast
$this->dontBroadcastToCurrentUser();
}
public function broadcastModel(): BaseModel
{
return $this->credit;

View File

@ -26,7 +26,9 @@ use Illuminate\Queue\SerializesModels;
*/
class InvoiceWasPaid implements ShouldBroadcast
{
use SerializesModels, DefaultResourceBroadcast, InteractsWithSockets;
use SerializesModels;
use DefaultResourceBroadcast;
use InteractsWithSockets;
/**
* Create a new event instance.

View File

@ -24,7 +24,9 @@ use Illuminate\Queue\SerializesModels;
*/
class PaymentWasUpdated implements ShouldBroadcast
{
use SerializesModels, InteractsWithSockets, DefaultResourceBroadcast;
use SerializesModels;
use InteractsWithSockets;
use DefaultResourceBroadcast;
/**
* @var Payment

View File

@ -15,7 +15,6 @@ use Exception;
class PeppolValidationException extends Exception
{
protected string $field = '';
public function __construct($message, $field, $code = 0, Exception $previous = null)

View File

@ -104,8 +104,8 @@ class ActivityExport extends BaseExport
/** @var \App\Models\DateFormat $df */
$df = DateFormat::query()->find($this->company->settings->date_format_id);
$this->date_format = $df->format;
$this->date_format = $df->format;
if (count($this->input['report_keys']) == 0) {
$this->input['report_keys'] = array_values($this->entity_keys);
}

View File

@ -473,20 +473,20 @@ class BaseExport
{
if (isset($this->input['client_id']) && $this->input['client_id'] != 'all') {
if(!is_int($this->input['client_id'])) {
if (!is_int($this->input['client_id'])) {
$this->input['client_id'] = $this->decodePrimaryKey($this->input['client_id']);
}
$client = Client::withTrashed()->find($this->input['client_id']);
if(!$client) {
if (!$client) {
return $query;
}
$this->client_description = $client->present()->name;
return $query->where('client_id', $this->input['client_id']);
} elseif(isset($this->input['clients']) && count($this->input['clients']) > 0) {
} elseif (isset($this->input['clients']) && count($this->input['clients']) > 0) {
$this->client_description = 'Multiple Clients';
return $query->whereIn('client_id', $this->input['clients']);
@ -498,7 +498,7 @@ class BaseExport
{
$parts = explode(".", $key);
if(!is_array($parts) || count($parts) < 2) {
if (!is_array($parts) || count($parts) < 2) {
return '';
}
@ -525,7 +525,7 @@ class BaseExport
private function resolveClientContactKey($column, $entity, $transformer)
{
if(!$entity->client) {
if (!$entity->client) {
return "";
}
@ -537,7 +537,7 @@ class BaseExport
private function resolveVendorContactKey($column, $entity, $transformer)
{
if(!$entity->vendor) {
if (!$entity->vendor) {
return "";
}
@ -551,19 +551,19 @@ class BaseExport
private function resolveExpenseKey($column, $entity, $transformer)
{
if($column == 'user' && $entity?->expense?->user) {
if ($column == 'user' && $entity?->expense?->user) {
return $entity->expense->user->present()->name() ?? ' ';
}
if($column == 'assigned_user' && $entity?->expense?->assigned_user) {
if ($column == 'assigned_user' && $entity?->expense?->assigned_user) {
return $entity->expense->assigned_user->present()->name() ?? ' ';
}
if($column == 'category' && $entity->expense) {
if ($column == 'category' && $entity->expense) {
return $entity->expense->category?->name ?? ' ';
}
if($entity instanceof Expense) {
if ($entity instanceof Expense) {
return '';
}
@ -573,11 +573,11 @@ class BaseExport
$manager->setSerializer(new ArraySerializer());
$transformed_entity = $manager->createData($transformed_entity)->toArray();
if(array_key_exists($column, $transformed_entity)) {
if (array_key_exists($column, $transformed_entity)) {
return $transformed_entity[$column];
}
if(property_exists($entity, $column)) {
if (property_exists($entity, $column)) {
return $entity?->{$column} ?? '';
}
@ -593,7 +593,7 @@ class BaseExport
$transformed_entity = $transformer->transform($entity);
if(array_key_exists($column, $transformed_entity)) {
if (array_key_exists($column, $transformed_entity)) {
return $transformed_entity[$column];
}
@ -606,7 +606,7 @@ class BaseExport
private function resolveVendorKey($column, $entity, $transformer)
{
if(!$entity->vendor) {
if (!$entity->vendor) {
return '';
}
@ -616,15 +616,15 @@ class BaseExport
$manager->setSerializer(new ArraySerializer());
$transformed_entity = $manager->createData($transformed_entity)->toArray();
if($column == 'name') {
if ($column == 'name') {
return $entity->vendor->present()->name() ?: '';
}
if($column == 'user_id') {
if ($column == 'user_id') {
return $entity->vendor->user->present()->name() ?: '';
}
if($column == 'country_id') {
if ($column == 'country_id') {
return $entity->vendor->country ? ctrans("texts.country_{$entity->vendor->country->name}") : '';
}
@ -632,11 +632,11 @@ class BaseExport
return $entity->vendor->currency() ? $entity->vendor->currency()->code : $entity->company->currency()->code;
}
if($column == 'status') {
if ($column == 'status') {
return $entity->stringStatus($entity->status_id) ?: '';
}
if(array_key_exists($column, $transformed_entity)) {
if (array_key_exists($column, $transformed_entity)) {
return $transformed_entity[$column];
}
@ -650,7 +650,7 @@ class BaseExport
private function resolveClientKey($column, $entity, $transformer)
{
if(!$entity->client) {
if (!$entity->client) {
return '';
}
@ -660,31 +660,31 @@ class BaseExport
$manager->setSerializer(new ArraySerializer());
$transformed_client = $manager->createData($transformed_client)->toArray();
if(in_array($column, ['client.name', 'name'])) {
if (in_array($column, ['client.name', 'name'])) {
return $transformed_client['display_name'];
}
if(in_array($column, ['client.user_id', 'user_id'])) {
if (in_array($column, ['client.user_id', 'user_id'])) {
return $entity->client->user ? $entity->client->user->present()->name() : '';
}
if(in_array($column, ['client.assigned_user_id', 'assigned_user_id'])) {
if (in_array($column, ['client.assigned_user_id', 'assigned_user_id'])) {
return $entity->client->assigned_user ? $entity->client->assigned_user->present()->name() : '';
}
if(in_array($column, ['client.country_id', 'country_id'])) {
if (in_array($column, ['client.country_id', 'country_id'])) {
return $entity->client->country ? ctrans("texts.country_{$entity->client->country->name}") : '';
}
if(in_array($column, ['client.shipping_country_id', 'shipping_country_id'])) {
if (in_array($column, ['client.shipping_country_id', 'shipping_country_id'])) {
return $entity->client->shipping_country ? ctrans("texts.country_{$entity->client->shipping_country->name}") : '';
}
if(in_array($column, ['client.size_id', 'size_id'])) {
if (in_array($column, ['client.size_id', 'size_id'])) {
return $entity->client->size?->name ?? '';
}
if(in_array($column, ['client.industry_id', 'industry_id'])) {
if (in_array($column, ['client.industry_id', 'industry_id'])) {
return $entity->client->industry?->name ?? '';
}
@ -692,12 +692,12 @@ class BaseExport
return $entity->client->currency() ? $entity->client->currency()->code : $entity->company->currency()->code;
}
if(in_array($column, ['payment_terms', 'client.payment_terms'])) {
if (in_array($column, ['payment_terms', 'client.payment_terms'])) {
return $entity->client->getSetting('payment_terms');
}
if(array_key_exists($column, $transformed_client)) {
if (array_key_exists($column, $transformed_client)) {
return $transformed_client[$column];
}
@ -713,7 +713,7 @@ class BaseExport
$transformed_entity = $transformer->transform($entity);
if($column == 'status') {
if ($column == 'status') {
return $entity->stringStatus($entity->status_id);
}
@ -726,7 +726,7 @@ class BaseExport
$transformed_entity = $transformer->transform($entity);
if(array_key_exists($column, $transformed_entity)) {
if (array_key_exists($column, $transformed_entity)) {
return $transformed_entity[$column];
}
@ -739,24 +739,24 @@ class BaseExport
// nlog("searching for {$column}");
$transformed_invoice = false;
if($transformer instanceof PaymentTransformer && ($entity->invoices ?? false)) {
if ($transformer instanceof PaymentTransformer && ($entity->invoices ?? false)) {
$transformed_invoices = $transformer->includeInvoices($entity);
$manager = new Manager();
$manager->setSerializer(new ArraySerializer());
$transformed_invoices = $manager->createData($transformed_invoices)->toArray();
if(!isset($transformed_invoices['App\\Models\\Invoice'])) {
if (!isset($transformed_invoices['App\\Models\\Invoice'])) {
return '';
}
$transformed_invoices = $transformed_invoices['App\\Models\\Invoice'];
if(count($transformed_invoices) == 1 && array_key_exists($column, $transformed_invoices[0])) {
if (count($transformed_invoices) == 1 && array_key_exists($column, $transformed_invoices[0])) {
return $transformed_invoices[0][$column];
}
if(count($transformed_invoices) > 1 && array_key_exists($column, $transformed_invoices[0])) {
if (count($transformed_invoices) > 1 && array_key_exists($column, $transformed_invoices[0])) {
return implode(', ', array_column($transformed_invoices, $column));
}
@ -764,10 +764,10 @@ class BaseExport
}
if($transformer instanceof TaskTransformer && ($entity->invoice ?? false)) {
if ($transformer instanceof TaskTransformer && ($entity->invoice ?? false)) {
$transformed_invoice = $transformer->includeInvoice($entity);
if(!$transformed_invoice) {
if (!$transformed_invoice) {
return '';
}
@ -777,7 +777,7 @@ class BaseExport
}
if($transformed_invoice && array_key_exists($column, $transformed_invoice)) {
if ($transformed_invoice && array_key_exists($column, $transformed_invoice)) {
return $transformed_invoice[$column];
} elseif ($transformed_invoice && array_key_exists(str_replace("invoice.", "", $column), $transformed_invoice)) {
return $transformed_invoice[$column];
@ -789,11 +789,11 @@ class BaseExport
private function resolvePaymentKey($column, $entity, $transformer)
{
if($entity instanceof Payment) {
if ($entity instanceof Payment) {
$transformed_payment = $transformer->transform($entity);
if(array_key_exists($column, $transformed_payment)) {
if (array_key_exists($column, $transformed_payment)) {
return $transformed_payment[$column];
} elseif (array_key_exists(str_replace("payment.", "", $column), $transformed_payment)) {
return $transformed_payment[$column];
@ -805,15 +805,15 @@ class BaseExport
}
if($column == 'amount') {
if ($column == 'amount') {
return $entity->payments()->exists() ? $entity->payments()->withoutTrashed()->sum('paymentables.amount') : ctrans('texts.unpaid');
}
if($column == 'refunded') {
if ($column == 'refunded') {
return $entity->payments()->exists() ? $entity->payments()->withoutTrashed()->sum('paymentables.refunded') : '';
}
if($column == 'applied') {
if ($column == 'applied') {
$refunded = $entity->payments()->withoutTrashed()->sum('paymentables.refunded');
$amount = $entity->payments()->withoutTrashed()->sum('paymentables.amount');
@ -822,26 +822,26 @@ class BaseExport
$payment = $entity->payments()->withoutTrashed()->first();
if(!$payment) {
if (!$payment) {
return '';
}
if($column == 'method') {
if ($column == 'method') {
return $payment->translatedType();
}
if($column == 'currency') {
if ($column == 'currency') {
return $payment?->currency?->code ?? '';
}
$payment_transformer = new PaymentTransformer();
$transformed_payment = $payment_transformer->transform($payment);
if($column == 'status') {
if ($column == 'status') {
return $payment->stringStatus($transformed_payment['status_id']);
}
if(array_key_exists($column, $transformed_payment)) {
if (array_key_exists($column, $transformed_payment)) {
return $transformed_payment[$column];
}
@ -859,12 +859,12 @@ class BaseExport
public function applyProductFilters(Builder $query): Builder
{
if(isset($this->input['product_key'])) {
if (isset($this->input['product_key'])) {
$products = explode(",", $this->input['product_key']);
$query->where(function ($q) use ($products) {
foreach($products as $product) {
foreach ($products as $product) {
$q->orWhereJsonContains('line_items', ['product_key' => $product]);
}
});
@ -884,13 +884,13 @@ class BaseExport
*/
protected function addClientFilter(Builder $query, $clients): Builder
{
if(is_string($clients)) {
if (is_string($clients)) {
$clients = explode(',', $clients);
}
$transformed_clients = $this->transformKeys($clients);
if(count($transformed_clients) > 0) {
if (count($transformed_clients) > 0) {
$query->whereIn('client_id', $transformed_clients);
}
@ -908,13 +908,13 @@ class BaseExport
protected function addVendorFilter(Builder$query, string $vendors): Builder
{
if(is_string($vendors)) {
if (is_string($vendors)) {
$vendors = explode(',', $vendors);
}
$transformed_vendors = $this->transformKeys($vendors);
if(count($transformed_vendors) > 0) {
if (count($transformed_vendors) > 0) {
$query->whereIn('vendor_id', $transformed_vendors);
}
@ -932,13 +932,13 @@ class BaseExport
protected function addProjectFilter(Builder $query, string $projects): Builder
{
if(is_string($projects)) {
if (is_string($projects)) {
$projects = explode(',', $projects);
}
$transformed_projects = $this->transformKeys($projects);
if(count($transformed_projects) > 0) {
if (count($transformed_projects) > 0) {
$query->whereIn('project_id', $transformed_projects);
}
@ -956,14 +956,14 @@ class BaseExport
protected function addCategoryFilter(Builder $query, string $expense_categories): Builder
{
if(is_string($expense_categories)) {
if (is_string($expense_categories)) {
$expense_categories = explode(',', $expense_categories);
}
$transformed_expense_categories = $this->transformKeys($expense_categories);
if(count($transformed_expense_categories) > 0) {
if (count($transformed_expense_categories) > 0) {
$query->whereIn('category_id', $transformed_expense_categories);
}
@ -984,7 +984,7 @@ class BaseExport
/** @var array $status_parameters */
$status_parameters = explode(',', $status);
if((count($status_parameters) == 0) || in_array('all', $status_parameters)) {
if ((count($status_parameters) == 0) || in_array('all', $status_parameters)) {
return $query;
}
@ -1019,7 +1019,7 @@ class BaseExport
$query->whereIn('status_id', $payment_filters);
}
if(in_array('partially_unapplied', $status_parameters)) {
if (in_array('partially_unapplied', $status_parameters)) {
$query->whereColumn('amount', '>', 'applied')->where('refunded', 0);
}
});
@ -1048,7 +1048,7 @@ class BaseExport
$recurring_filters = [];
if($this->company->getSetting('report_include_drafts')) {
if ($this->company->getSetting('report_include_drafts')) {
$recurring_filters[] = RecurringInvoice::STATUS_DRAFT;
}
@ -1127,7 +1127,7 @@ class BaseExport
});
}
if(in_array('converted', $status_parameters)) {
if (in_array('converted', $status_parameters)) {
$query->orWhere(function ($q) {
$q->whereNotNull('invoice_id');
});
@ -1200,7 +1200,7 @@ class BaseExport
/** @var array $status_parameters */
$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;
}
@ -1239,7 +1239,7 @@ class BaseExport
->orWhere('partial_due_date', '<', Carbon::now());
}
if(in_array('viewed', $status_parameters)) {
if (in_array('viewed', $status_parameters)) {
$nested->whereHas('invitations', function ($q) {
$q->whereNotNull('viewed_date')->whereNotNull('deleted_at');
@ -1316,7 +1316,7 @@ class BaseExport
$first_month_of_year = $this->company->getSetting('first_month_of_year') ?? 1;
$fin_year_start = now()->createFromDate(now()->year, $first_month_of_year, 1);
if(now()->lt($fin_year_start)) {
if (now()->lt($fin_year_start)) {
$fin_year_start->subYearNoOverflow();
}
@ -1329,7 +1329,7 @@ class BaseExport
$fin_year_start = now()->createFromDate(now()->year, $first_month_of_year, 1);
$fin_year_start->subYearNoOverflow();
if(now()->subYear()->lt($fin_year_start)) {
if (now()->subYear()->lt($fin_year_start)) {
$fin_year_start->subYearNoOverflow();
}
@ -1374,71 +1374,71 @@ class BaseExport
// nlog("{$key} => {$value}");
$prefix = '';
if(!$key) {
if (!$key) {
$prefix = stripos($value, 'client.') !== false ? ctrans('texts.client')." " : ctrans('texts.contact')." ";
$key = array_search($value, $this->client_report_keys);
}
if(!$key) {
if (!$key) {
$prefix = ctrans('texts.invoice')." ";
$key = array_search($value, $this->invoice_report_keys);
}
if(!$key) {
if (!$key) {
$prefix = ctrans('texts.recurring_invoice')." ";
$key = array_search($value, $this->recurring_invoice_report_keys);
}
if(!$key) {
if (!$key) {
$prefix = ctrans('texts.payment')." ";
$key = array_search($value, $this->payment_report_keys);
}
if(!$key) {
if (!$key) {
$prefix = ctrans('texts.quote')." ";
$key = array_search($value, $this->quote_report_keys);
}
if(!$key) {
if (!$key) {
$prefix = ctrans('texts.credit')." ";
$key = array_search($value, $this->credit_report_keys);
}
if(!$key) {
if (!$key) {
$prefix = ctrans('texts.item')." ";
$key = array_search($value, $this->item_report_keys);
}
if(!$key) {
if (!$key) {
$prefix = ctrans('texts.expense')." ";
$key = array_search($value, $this->expense_report_keys);
if(!$key && $value == 'expense.category') {
if (!$key && $value == 'expense.category') {
$key = 'category';
}
}
if(!$key) {
if (!$key) {
$prefix = ctrans('texts.task')." ";
$key = array_search($value, $this->task_report_keys);
}
if(!$key) {
if (!$key) {
$prefix = ctrans('texts.vendor')." ";
$key = array_search($value, $this->vendor_report_keys);
}
if(!$key) {
if (!$key) {
$prefix = ctrans('texts.purchase_order')." ";
$key = array_search($value, $this->purchase_order_report_keys);
}
if(!$key) {
if (!$key) {
$prefix = '';
$key = array_search($value, $this->product_report_keys);
}
if(!$key) {
if (!$key) {
$prefix = '';
}
@ -1459,29 +1459,29 @@ class BaseExport
$key = str_replace('product.', '', $key);
$key = str_replace('task.', '', $key);
if(stripos($value, 'custom_value') !== false) {
if (stripos($value, 'custom_value') !== false) {
$parts = explode(".", $value);
if(count($parts) == 2 && in_array($parts[0], ['credit','quote','invoice','purchase_order','recurring_invoice'])) {
if (count($parts) == 2 && in_array($parts[0], ['credit','quote','invoice','purchase_order','recurring_invoice'])) {
$entity = "invoice".substr($parts[1], -1);
$prefix = ctrans("texts.".$parts[0]);
$fallback = "custom_value".substr($parts[1], -1);
$custom_field_label = $helper->makeCustomField($this->company->custom_fields, $entity);
if(strlen($custom_field_label) > 1) {
if (strlen($custom_field_label) > 1) {
$header[] = $custom_field_label;
} else {
$header[] = $prefix . " ". ctrans("texts.{$fallback}");
}
} elseif(count($parts) == 2 && (stripos($parts[0], 'vendor_contact') !== false || stripos($parts[0], 'contact') !== false)) {
} elseif (count($parts) == 2 && (stripos($parts[0], 'vendor_contact') !== false || stripos($parts[0], 'contact') !== false)) {
$parts[0] = str_replace('vendor_contact', 'contact', $parts[0]);
$entity = "contact".substr($parts[1], -1);
$custom_field_string = strlen($helper->makeCustomField($this->company->custom_fields, $entity)) > 1 ? $helper->makeCustomField($this->company->custom_fields, $entity) : ctrans("texts.{$parts[1]}");
$header[] = ctrans("texts.{$parts[0]}") . " " . $custom_field_string;
} elseif(count($parts) == 2 && in_array(substr($original_key, 0, -1), ['credit','quote','invoice','purchase_order','recurring_invoice','task'])) {
} elseif (count($parts) == 2 && in_array(substr($original_key, 0, -1), ['credit','quote','invoice','purchase_order','recurring_invoice','task'])) {
$custom_field_string = strlen($helper->makeCustomField($this->company->custom_fields, "product".substr($original_key, -1))) > 1 ? $helper->makeCustomField($this->company->custom_fields, "product".substr($original_key, -1)) : ctrans("texts.{$parts[1]}");
$header[] = ctrans("texts.{$parts[0]}") . " " . $custom_field_string;
} else {
@ -1528,12 +1528,12 @@ class BaseExport
$column_key = $value;
if($value == 'product_image') {
if ($value == 'product_image') {
$column_key = 'image';
$value = 'image';
}
if($value == 'tax_id') {
if ($value == 'tax_id') {
$column_key = 'tax_category';
$value = 'tax_category';
}
@ -1575,11 +1575,11 @@ class BaseExport
$column_key = $value;
if($value == 'type_id' || $value == 'item.type_id') {
if ($value == 'type_id' || $value == 'item.type_id') {
$column_key = 'type';
}
if($value == 'tax_id' || $value == 'item.tax_id') {
if ($value == 'tax_id' || $value == 'item.tax_id') {
$column_key = 'tax_category';
}
@ -1595,9 +1595,10 @@ class BaseExport
return $clean_row;
}
public function queuePdfs(Builder $query) {
public function queuePdfs(Builder $query)
{
if(in_array(get_class($query->getModel()), [Invoice::class, Quote::class, Credit::class, PurchaseOrder::class]) && $query->count() > 0) {
if (in_array(get_class($query->getModel()), [Invoice::class, Quote::class, Credit::class, PurchaseOrder::class]) && $query->count() > 0) {
$user = $this->company->owner();
@ -1617,7 +1618,7 @@ class BaseExport
ZipCredits::dispatch($query->pluck('id'), $this->company, $user);
break;
case PurchaseOrder::class:
ZipPurchaseOrders::dispatch($query->pluck('id'),$this->company, $user);
ZipPurchaseOrders::dispatch($query->pluck('id'), $this->company, $user);
break;
default:
# code...
@ -1629,7 +1630,7 @@ class BaseExport
public function queueDocuments(Builder $query)
{
if($query->getModel() instanceof Document) {
if ($query->getModel() instanceof Document) {
$documents = $query->pluck('id')->toArray();
} else {
$documents = $query->cursor()
@ -1639,15 +1640,15 @@ class BaseExport
->toArray();
}
if(count($documents) > 0) {
if (count($documents) > 0) {
$user = $this->company->owner();
if(auth()->user() && auth()->user()->account_id == $this->company->account_id) {
if (auth()->user() && auth()->user()->account_id == $this->company->account_id) {
$user = auth()->user();
}
if($this->input['user_id'] ?? false) {
if ($this->input['user_id'] ?? false) {
$user = User::where('id', $this->input['user_id'])->where('account_id', $this->company->account_id)->first();
}
@ -1672,7 +1673,7 @@ class BaseExport
public function convertFloats(iterable $entity): iterable
{
$currency = $this->company->currency();
foreach ($entity as $key => $value) {
if (is_float($value)) {
$entity[$key] = \App\Utils\Number::formatValue($value, $currency);

View File

@ -129,13 +129,13 @@ 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, ' clients');
if($this->input['document_email_attachment'] ?? false) {
if ($this->input['document_email_attachment'] ?? false) {
$this->queueDocuments($query);
}
@ -208,7 +208,7 @@ class ClientExport extends BaseExport
$clean_row[$key]['value'] = $row[$column_key];
$clean_row[$key]['identifier'] = $value;
if(in_array($clean_row[$key]['id'], ['paid_to_date', 'balance', 'credit_balance','payment_balance'])) {
if (in_array($clean_row[$key]['id'], ['paid_to_date', 'balance', 'credit_balance','payment_balance'])) {
$clean_row[$key]['display_value'] = Number::formatMoney($row[$column_key], $resource);
} else {
$clean_row[$key]['display_value'] = $row[$column_key];

View File

@ -75,7 +75,7 @@ class CreditExport extends BaseExport
$clean_row[$key]['value'] = $row[$column_key];
$clean_row[$key]['identifier'] = $value;
if(in_array($clean_row[$key]['id'], ['paid_to_date','total_taxes','amount', 'balance', 'partial', 'refunded', 'applied','unit_cost','cost','price'])) {
if (in_array($clean_row[$key]['id'], ['paid_to_date','total_taxes','amount', 'balance', 'partial', 'refunded', 'applied','unit_cost','cost','price'])) {
$clean_row[$key]['display_value'] = Number::formatMoney($row[$column_key], $resource->client);
} else {
$clean_row[$key]['display_value'] = $row[$column_key];
@ -114,15 +114,15 @@ class CreditExport extends BaseExport
$clients = &$this->input['client_id'];
if($clients) {
if ($clients) {
$query = $this->addClientFilter($query, $clients);
}
if($this->input['status'] ?? false) {
if ($this->input['status'] ?? false) {
$query = $this->addCreditStatusFilter($query, $this->input['status']);
}
if($this->input['document_email_attachment'] ?? false) {
if ($this->input['document_email_attachment'] ?? false) {
$this->queueDocuments($query);
}
@ -168,7 +168,7 @@ class CreditExport extends BaseExport
$entity[$keyval] = $transformed_credit[$credit_key];
} elseif (isset($transformed_credit[$keyval])) {
$entity[$keyval] = $transformed_credit[$keyval];
} elseif(isset($transformed_credit[$searched_credit_key])) {
} elseif (isset($transformed_credit[$searched_credit_key])) {
$entity[$keyval] = $transformed_credit[$searched_credit_key];
} else {
$entity[$key] = $this->decorator->transform($key, $credit);

View File

@ -80,7 +80,7 @@ class DocumentExport extends BaseExport
$query = $this->addDateRange($query, 'documents');
if($this->input['document_email_attachment'] ?? false) {
if ($this->input['document_email_attachment'] ?? false) {
$this->queueDocuments($query);
}

View File

@ -87,33 +87,33 @@ class ExpenseExport extends BaseExport
->where('company_id', $this->company->id);
if(!$this->input['include_deleted'] ?? false) { // @phpstan-ignore-line
if (!$this->input['include_deleted'] ?? false) { // @phpstan-ignore-line
$query->where('is_deleted', 0);
}
$query = $this->addDateRange($query, 'expenses');
if($this->input['status'] ?? false) {
if ($this->input['status'] ?? false) {
$query = $this->addExpenseStatusFilter($query, $this->input['status']);
}
if(isset($this->input['clients'])) {
if (isset($this->input['clients'])) {
$query = $this->addClientFilter($query, $this->input['clients']);
}
if(isset($this->input['vendors'])) {
if (isset($this->input['vendors'])) {
$query = $this->addVendorFilter($query, $this->input['vendors']);
}
if(isset($this->input['projects'])) {
if (isset($this->input['projects'])) {
$query = $this->addProjectFilter($query, $this->input['projects']);
}
if(isset($this->input['categories'])) {
if (isset($this->input['categories'])) {
$query = $this->addCategoryFilter($query, $this->input['categories']);
}
if($this->input['document_email_attachment'] ?? false) {
if ($this->input['document_email_attachment'] ?? false) {
$this->queueDocuments($query);
}
@ -264,11 +264,11 @@ class ExpenseExport extends BaseExport
{
$precision = $expense->currency->precision ?? 2;
if($expense->calculate_tax_by_amount) {
if ($expense->calculate_tax_by_amount) {
$total_tax_amount = round($expense->tax_amount1 + $expense->tax_amount2 + $expense->tax_amount3, $precision);
if($expense->uses_inclusive_taxes) {
if ($expense->uses_inclusive_taxes) {
$entity['expense.net_amount'] = round($expense->amount, $precision) - $total_tax_amount;
} else {
$entity['expense.net_amount'] = round($expense->amount, $precision);
@ -276,7 +276,7 @@ class ExpenseExport extends BaseExport
} else {
if($expense->uses_inclusive_taxes) {
if ($expense->uses_inclusive_taxes) {
$total_tax_amount = ($this->calcInclusiveLineTax($expense->tax_rate1 ?? 0, $expense->amount, $precision)) + ($this->calcInclusiveLineTax($expense->tax_rate2 ?? 0, $expense->amount, $precision)) + ($this->calcInclusiveLineTax($expense->tax_rate3 ?? 0, $expense->amount, $precision));
$entity['expense.net_amount'] = round(($expense->amount - round($total_tax_amount, $precision)), $precision);
} else {

View File

@ -63,7 +63,7 @@ class InvoiceExport extends BaseExport
->where('company_id', $this->company->id);
if(!$this->input['include_deleted'] ?? false) {// @phpstan-ignore-line
if (!$this->input['include_deleted'] ?? false) {// @phpstan-ignore-line
$query->where('is_deleted', 0);
}
@ -71,19 +71,19 @@ class InvoiceExport extends BaseExport
$clients = &$this->input['client_id'];
if($clients) {
if ($clients) {
$query = $this->addClientFilter($query, $clients);
}
if($this->input['status'] ?? false) {
if ($this->input['status'] ?? false) {
$query = $this->addInvoiceStatusFilter($query, $this->input['status']);
}
if($this->input['document_email_attachment'] ?? false) {
if ($this->input['document_email_attachment'] ?? false) {
$this->queueDocuments($query);
}
if($this->input['pdf_email_attachment'] ?? false) {
if ($this->input['pdf_email_attachment'] ?? false) {
$this->queuePdfs($query);
}

View File

@ -78,7 +78,7 @@ class InvoiceItemExport extends BaseExport
})
->where('company_id', $this->company->id);
if(!$this->input['include_deleted'] ?? false) {// @phpstan-ignore-line
if (!$this->input['include_deleted'] ?? false) {// @phpstan-ignore-line
$query->where('is_deleted', 0);
}
@ -86,17 +86,17 @@ class InvoiceItemExport extends BaseExport
$clients = &$this->input['client_id'];
if($clients) {
if ($clients) {
$query = $this->addClientFilter($query, $clients);
}
if($this->input['status'] ?? false) {
if ($this->input['status'] ?? false) {
$query = $this->addInvoiceStatusFilter($query, $this->input['status']);
}
$query = $this->applyProductFilters($query);
if($this->input['document_email_attachment'] ?? false) {
if ($this->input['document_email_attachment'] ?? false) {
$this->queueDocuments($query);
}
@ -120,7 +120,7 @@ class InvoiceItemExport extends BaseExport
/** @var \App\Models\Invoice $resource */
$this->iterateItems($resource);
foreach($this->storage_array as $row) {
foreach ($this->storage_array as $row) {
$this->storage_item_array[] = $this->processItemMetaData($row, $resource);
}
@ -171,11 +171,11 @@ class InvoiceItemExport extends BaseExport
$tmp_key = str_replace("item.", "", $key);
if($tmp_key == 'type_id') {
if ($tmp_key == 'type_id') {
$tmp_key = 'type';
}
if($tmp_key == 'tax_id') {
if ($tmp_key == 'tax_id') {
$tmp_key = 'tax_category';
}
@ -203,12 +203,12 @@ class InvoiceItemExport extends BaseExport
$entity = [];
foreach (array_values($this->input['report_keys']) as $key) {
$parts = explode('.', $key);
if(is_array($parts) && $parts[0] == 'item') {
if (is_array($parts) && $parts[0] == 'item') {
continue;
}
@ -220,7 +220,7 @@ class InvoiceItemExport extends BaseExport
$entity[$key] = $this->decorator->transform($key, $invoice);
}
}
$entity = $this->decorateAdvancedFields($invoice, $entity);
return $entity;
}

View File

@ -66,13 +66,13 @@ class PaymentExport extends BaseExport
$clients = &$this->input['client_id'];
if($clients) {
if ($clients) {
$query = $this->addClientFilter($query, $clients);
}
$query = $this->addPaymentStatusFilters($query, $this->input['status'] ?? '');
if($this->input['document_email_attachment'] ?? false) {
if ($this->input['document_email_attachment'] ?? false) {
$this->queueDocuments($query);
}

View File

@ -77,13 +77,13 @@ class ProductExport extends BaseExport
->withTrashed()
->where('company_id', $this->company->id);
if(!$this->input['include_deleted'] ?? false) { //@phpstan-ignore-line
if (!$this->input['include_deleted'] ?? false) { //@phpstan-ignore-line
$query->where('is_deleted', 0);
}
$query = $this->addDateRange($query, 'products');
if($this->input['document_email_attachment'] ?? false) {
if ($this->input['document_email_attachment'] ?? false) {
$this->queueDocuments($query);
}

View File

@ -83,7 +83,7 @@ class ProductSalesExport extends BaseExport
$keys = explode(",", $product_keys);
$query->where(function ($q) use ($keys) {
foreach($keys as $key) {
foreach ($keys as $key) {
$q->orWhereJsonContains('line_items', ['product_key' => $key]);
}
@ -133,7 +133,7 @@ class ProductSalesExport extends BaseExport
$product_keys = &$this->input['product_key'];
if($product_keys) {
if ($product_keys) {
$product_keys = explode(",", $product_keys);
}
@ -141,8 +141,8 @@ class ProductSalesExport extends BaseExport
->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->convertFloats($this->buildRow($invoice, $item)));
}
} else {
@ -155,7 +155,7 @@ class ProductSalesExport extends BaseExport
$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;
}
@ -219,15 +219,15 @@ class ProductSalesExport extends BaseExport
if (array_key_exists($key, $transformed_entity)) {
$entity[$keyval] = $transformed_entity[$key];
} elseif($key == 'currency') {
} elseif ($key == 'currency') {
$entity['currency'] = $invoice->client->currency()->code;
} else {
$entity[$keyval] = '';
}
}
$entity = $this->decorateAdvancedFields($invoice, $entity);
$this->sales->push($entity);
return $entity;

View File

@ -63,7 +63,7 @@ class PurchaseOrderExport extends BaseExport
})
->where('company_id', $this->company->id);
if(!$this->input['include_deleted'] ?? false) { // @phpstan-ignore-line
if (!$this->input['include_deleted'] ?? false) { // @phpstan-ignore-line
$query->where('is_deleted', 0);
}
@ -72,13 +72,13 @@ 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'] ?? '');
if($this->input['document_email_attachment'] ?? false) {
if ($this->input['document_email_attachment'] ?? false) {
$this->queueDocuments($query);
}
@ -151,9 +151,9 @@ class PurchaseOrderExport extends BaseExport
}
$entity = $this->decorateAdvancedFields($purchase_order, $entity);
return $this->convertFloats($entity);
}

View File

@ -67,7 +67,7 @@ class PurchaseOrderItemExport extends BaseExport
})
->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);
}
@ -75,13 +75,13 @@ class PurchaseOrderItemExport extends BaseExport
$clients = &$this->input['client_id'];
if($clients) {
if ($clients) {
$query = $this->addClientFilter($query, $clients);
}
$query = $this->addPurchaseOrderStatusFilter($query, $this->input['status'] ?? '');
if($this->input['document_email_attachment'] ?? false) {
if ($this->input['document_email_attachment'] ?? false) {
$this->queueDocuments($query);
}
@ -105,7 +105,7 @@ class PurchaseOrderItemExport extends BaseExport
/** @var \App\Models\PurchaseOrder $resource */
$this->iterateItems($resource);
foreach($this->storage_array as $row) {
foreach ($this->storage_array as $row) {
$this->storage_item_array[] = $this->processItemMetaData($row, $resource);
}
@ -155,11 +155,11 @@ class PurchaseOrderItemExport extends BaseExport
$tmp_key = str_replace("item.", "", $key);
if($tmp_key == 'type_id') {
if ($tmp_key == 'type_id') {
$tmp_key = 'type';
}
if($tmp_key == 'tax_id') {
if ($tmp_key == 'tax_id') {
$tmp_key = 'tax_category';
}
@ -174,10 +174,10 @@ class PurchaseOrderItemExport extends BaseExport
$transformed_items = array_merge($transformed_purchase_order, $item_array);
$entity = $this->decorateAdvancedFields($purchase_order, $transformed_items);
$entity = array_merge(array_flip(array_values($this->input['report_keys'])), $entity);
$this->storage_array[] = $this->convertFloats($entity);
}
}
private function buildRow(PurchaseOrder $purchase_order): array
@ -189,7 +189,7 @@ class PurchaseOrderItemExport extends BaseExport
foreach (array_values($this->input['report_keys']) as $key) {
$parts = explode('.', $key);
if(is_array($parts) && $parts[0] == 'item') {
if (is_array($parts) && $parts[0] == 'item') {
continue;
}
@ -210,7 +210,7 @@ class PurchaseOrderItemExport extends BaseExport
private function decorateAdvancedFields(PurchaseOrder $purchase_order, array $entity): array
{
if (in_array('purchase_order.currency_id', $this->input['report_keys'])) {
$entity['purchase_order.currency_id'] = $purchase_order->vendor->currency() ? $purchase_order->vendor->currency()->code : $purchase_order->company->currency()->code;
}

View File

@ -63,7 +63,7 @@ class QuoteExport 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);
}
@ -71,13 +71,13 @@ class QuoteExport extends BaseExport
$clients = &$this->input['client_id'];
if($clients) {
if ($clients) {
$query = $this->addClientFilter($query, $clients);
}
$query = $this->addQuoteStatusFilter($query, $this->input['status'] ?? '');
if($this->input['document_email_attachment'] ?? false) {
if ($this->input['document_email_attachment'] ?? false) {
$this->queueDocuments($query);
}
@ -150,10 +150,10 @@ class QuoteExport extends BaseExport
}
}
$entity = $this->decorateAdvancedFields($quote, $entity);
return $this->convertFloats($entity);
}

View File

@ -70,7 +70,7 @@ class QuoteItemExport extends BaseExport
})
->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);
}
@ -78,13 +78,13 @@ class QuoteItemExport extends BaseExport
$clients = &$this->input['client_id'];
if($clients) {
if ($clients) {
$query = $this->addClientFilter($query, $clients);
}
$query = $this->addQuoteStatusFilter($query, $this->input['status'] ?? '');
if($this->input['document_email_attachment'] ?? false) {
if ($this->input['document_email_attachment'] ?? false) {
$this->queueDocuments($query);
}
@ -108,7 +108,7 @@ class QuoteItemExport extends BaseExport
/** @var \App\Models\Quote $resource */
$this->iterateItems($resource);
foreach($this->storage_array as $row) {
foreach ($this->storage_array as $row) {
$this->storage_item_array[] = $this->processItemMetaData($row, $resource);
}
@ -163,11 +163,11 @@ class QuoteItemExport extends BaseExport
$tmp_key = str_replace("item.", "", $key);
if($tmp_key == 'type_id') {
if ($tmp_key == 'type_id') {
$tmp_key = 'type';
}
if($tmp_key == 'tax_id') {
if ($tmp_key == 'tax_id') {
$tmp_key = 'tax_category';
}
@ -181,7 +181,7 @@ class QuoteItemExport extends BaseExport
$transformed_items = array_merge($transformed_quote, $item_array);
$entity = $this->decorateAdvancedFields($quote, $transformed_items);
$entity = array_merge(array_flip(array_values($this->input['report_keys'])), $entity);
$entity = array_merge(array_flip(array_values($this->input['report_keys'])), $entity);
$entity = $this->convertFloats($entity);
$this->storage_array[] = $entity;
@ -198,7 +198,7 @@ class QuoteItemExport extends BaseExport
$parts = explode('.', $key);
if(is_array($parts) && $parts[0] == 'item') {
if (is_array($parts) && $parts[0] == 'item') {
continue;
}
@ -213,7 +213,7 @@ class QuoteItemExport extends BaseExport
$entity = $this->decorateAdvancedFields($quote, $entity);
return $entity;
}
private function decorateAdvancedFields(Quote $quote, array $entity): array
{

View File

@ -61,7 +61,7 @@ class RecurringInvoiceExport 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);
}
@ -69,7 +69,7 @@ class RecurringInvoiceExport extends BaseExport
$clients = &$this->input['client_id'];
if($clients) {
if ($clients) {
$query = $this->addClientFilter($query, $clients);
}
@ -137,14 +137,15 @@ class RecurringInvoiceExport extends BaseExport
if (is_array($parts) && $parts[0] == 'recurring_invoice' && array_key_exists($parts[1], $transformed_invoice)) {
$entity[$key] = $transformed_invoice[$parts[1]];
} elseif($parts[0] == 'item') {
} elseif ($parts[0] == 'item') {
$entity[$key] = '';
} else {
$entity[$key] = $this->decorator->transform($key, $invoice);
}
if (is_float($entity[$key]))
if (is_float($entity[$key])) {
$entity[$key] = \App\Utils\Number::formatValue($entity[$key], $currency);
}
}

View File

@ -69,7 +69,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);
}
@ -77,13 +77,13 @@ 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);
}
@ -132,7 +132,7 @@ class TaskExport extends BaseExport
/** @var \App\Models\Task $resource*/
$this->buildRow($resource);
foreach($this->storage_array as $row) {
foreach ($this->storage_array as $row) {
$this->storage_item_array[] = $this->processMetaData($row, $resource);
}
@ -233,7 +233,7 @@ class TaskExport extends BaseExport
$entity['task.item_notes'] = isset($item[2]) ? (string)$item[2] : '';
}
$this->storage_array[] = $entity;
$entity['task.start_date'] = '';

View File

@ -64,13 +64,13 @@ 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);
}
$query = $this->addDateRange($query, 'vendors');
if($this->input['document_email_attachment'] ?? false) {
if ($this->input['document_email_attachment'] ?? false) {
$this->queueDocuments($query);
}

View File

@ -21,15 +21,15 @@ class ClientDecorator extends Decorator implements DecoratorInterface
{
$client = false;
if($entity instanceof Client) {
if ($entity instanceof Client) {
$client = $entity;
} elseif($entity->client) {
} elseif ($entity->client) {
$client = $entity->client;
}
if($client && method_exists($this, $key)) {
if ($client && method_exists($this, $key)) {
return $this->{$key}($client);
} elseif($client && ($client->{$key} ?? false)) {
} elseif ($client && ($client->{$key} ?? false)) {
return $client->{$key};
}

View File

@ -19,20 +19,20 @@ class ContactDecorator implements DecoratorInterface
{
$contact = false;
if($entity instanceof ClientContact) {
if ($entity instanceof ClientContact) {
$contact = $entity;
} elseif($entity->contacts) {
} elseif ($entity->contacts) {
$contact = $entity->contacts()->first();
} elseif($entity->client) {
} 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();
}
if($contact && method_exists($this, $key)) {
if ($contact && method_exists($this, $key)) {
return $this->{$key}($contact);
} elseif($contact && ($contact->{$key} ?? false)) {
} elseif ($contact && ($contact->{$key} ?? false)) {
return $contact->{$key};
}

View File

@ -19,15 +19,15 @@ class CreditDecorator implements DecoratorInterface
{
$credit = false;
if($entity instanceof Credit) {
if ($entity instanceof Credit) {
$credit = $entity;
} elseif($entity->credit) {
} elseif ($entity->credit) {
$credit = $entity->credit;
}
if($credit && method_exists($this, $key)) {
if ($credit && method_exists($this, $key)) {
return $this->{$key}($credit);
} elseif($credit && ($credit->{$key} ?? false)) {
} elseif ($credit && ($credit->{$key} ?? false)) {
return $credit->{$key};
}

View File

@ -19,15 +19,15 @@ class ExpenseDecorator implements DecoratorInterface
{
$expense = false;
if($entity instanceof Expense) {
if ($entity instanceof Expense) {
$expense = $entity;
} elseif($entity->expense) {
} elseif ($entity->expense) {
$expense = $entity->expense;
}
if($expense && method_exists($this, $key)) {
if ($expense && method_exists($this, $key)) {
return $this->{$key}($expense);
} elseif($expense && ($expense->{$key} ?? false)) {
} elseif ($expense && ($expense->{$key} ?? false)) {
return $expense->{$key};
}

View File

@ -19,17 +19,17 @@ class InvoiceDecorator extends Decorator implements DecoratorInterface
{
$invoice = false;
if($entity instanceof Invoice) {
if ($entity instanceof Invoice) {
$invoice = $entity;
} elseif($entity->invoice) {
} elseif ($entity->invoice) {
$invoice = $entity->invoice;
} elseif(method_exists($entity, 'invoices') && $entity->invoices()->exists()) {
} elseif (method_exists($entity, 'invoices') && $entity->invoices()->exists()) {
$invoice = $entity->invoices()->first();
}
if($invoice && method_exists($this, $key)) {
if ($invoice && method_exists($this, $key)) {
return $this->{$key}($invoice);
} elseif($invoice && ($invoice->{$key} ?? false)) {
} elseif ($invoice && ($invoice->{$key} ?? false)) {
return $invoice->{$key};
}

View File

@ -21,27 +21,27 @@ class PaymentDecorator extends Decorator implements DecoratorInterface
{
$payment = false;
if($entity instanceof Payment) {
if ($entity instanceof Payment) {
$payment = $entity;
} elseif($entity->payment) {
} elseif ($entity->payment) {
$payment = $entity->payment;
} elseif($entity->payments()->exists()) {
} elseif ($entity->payments()->exists()) {
$payment = $entity->payments()->first();
}
if($key == 'amount' && (!$entity instanceof Payment)) {
if ($key == 'amount' && (!$entity instanceof Payment)) {
return $entity->payments()->exists() ? $entity->payments()->withoutTrashed()->sum('paymentables.amount') : ctrans('texts.unpaid');
} elseif($key == 'refunded' && (!$entity instanceof Payment)) {
} elseif ($key == 'refunded' && (!$entity instanceof Payment)) {
return $entity->payments()->exists() ? $entity->payments()->withoutTrashed()->sum('paymentables.refunded') : '';
} elseif($key == 'applied' && (!$entity instanceof Payment)) {
} elseif ($key == 'applied' && (!$entity instanceof Payment)) {
$refunded = $entity->payments()->withoutTrashed()->sum('paymentables.refunded');
$amount = $entity->payments()->withoutTrashed()->sum('paymentables.amount');
return $entity->payments()->withoutTrashed()->exists() ? ($amount - $refunded) : '';
}
if($payment && method_exists($this, $key)) {
if ($payment && method_exists($this, $key)) {
return $this->{$key}($payment);
} elseif($payment && ($payment->{$key} ?? false)) {
} elseif ($payment && ($payment->{$key} ?? false)) {
return $payment->{$key};
}

View File

@ -19,15 +19,15 @@ class ProductDecorator implements DecoratorInterface
{
$product = false;
if($entity instanceof Product) {
if ($entity instanceof Product) {
$product = $entity;
} elseif($entity->product) {
} elseif ($entity->product) {
$product = $entity->product;
}
if($product && method_exists($this, $key)) {
if ($product && method_exists($this, $key)) {
return $this->{$key}($product);
} elseif($product->{$key} ?? false) {
} elseif ($product->{$key} ?? false) {
return $product->{$key} ?? '';
}

View File

@ -19,15 +19,15 @@ class PurchaseOrderDecorator extends Decorator implements DecoratorInterface
{
$purchase_order = false;
if($entity instanceof PurchaseOrder) {
if ($entity instanceof PurchaseOrder) {
$purchase_order = $entity;
} elseif($entity->purchase_order) {
} elseif ($entity->purchase_order) {
$purchase_order = $entity->purchase_order;
}
if($purchase_order && method_exists($this, $key)) {
if ($purchase_order && method_exists($this, $key)) {
return $this->{$key}($purchase_order);
} elseif($purchase_order->{$key} ?? false) {
} elseif ($purchase_order->{$key} ?? false) {
return $purchase_order->{$key} ?? '';
}

View File

@ -19,15 +19,15 @@ class QuoteDecorator extends Decorator implements DecoratorInterface
{
$quote = false;
if($entity instanceof Quote) {
if ($entity instanceof Quote) {
$quote = $entity;
} elseif($entity->quote) {
} elseif ($entity->quote) {
$quote = $entity->quote;
}
if($quote && method_exists($this, $key)) {
if ($quote && method_exists($this, $key)) {
return $this->{$key}($quote);
} elseif($quote->{$key} ?? false) {
} elseif ($quote->{$key} ?? false) {
return $quote->{$key} ?? '';
}

View File

@ -19,15 +19,15 @@ class RecurringInvoiceDecorator extends Decorator implements DecoratorInterface
{
$recurring_invoice = false;
if($entity instanceof RecurringInvoice) {
if ($entity instanceof RecurringInvoice) {
$recurring_invoice = $entity;
} elseif($entity->recurring_invoice) {
} elseif ($entity->recurring_invoice) {
$recurring_invoice = $entity->recurring_invoice;
}
if($recurring_invoice && method_exists($this, $key)) {
if ($recurring_invoice && method_exists($this, $key)) {
return $this->{$key}($recurring_invoice);
} elseif($recurring_invoice->{$key} ?? false) {
} elseif ($recurring_invoice->{$key} ?? false) {
return $recurring_invoice->{$key} ?? '';
}

View File

@ -22,15 +22,15 @@ class TaskDecorator extends Decorator implements DecoratorInterface
public function transform(string $key, mixed $entity): mixed
{
$task = false;
if($entity instanceof Task) {
if ($entity instanceof Task) {
$task = $entity;
} elseif($entity->task) {
} elseif ($entity->task) {
$task = $entity->task;
}
if($task && method_exists($this, $key)) {
if ($task && method_exists($this, $key)) {
return $this->{$key}($task);
} elseif($task && $task->{$key} ?? false) {
} elseif ($task && $task->{$key} ?? false) {
return $task->{$key};
}
@ -58,7 +58,7 @@ class TaskDecorator extends Decorator implements DecoratorInterface
$date_format_default = $date_format->format;
}
if(is_array($logs)) {
if (is_array($logs)) {
$item = $logs[0];
return Carbon::createFromTimeStamp((int)$item[0])->setTimezone($timezone_name)->format($date_format_default);
}
@ -87,7 +87,7 @@ class TaskDecorator extends Decorator implements DecoratorInterface
$date_format_default = $date_format->format;
}
if(is_array($logs)) {
if (is_array($logs)) {
$item = $logs[1];
return Carbon::createFromTimeStamp((int)$item[1])->setTimezone($timezone_name)->format($date_format_default);
}

View File

@ -19,15 +19,15 @@ class VendorContactDecorator implements DecoratorInterface
{
$contact = false;
if($entity instanceof VendorContact) {
if ($entity instanceof VendorContact) {
$contact = $entity;
} elseif($entity->contacts) {
} elseif ($entity->contacts) {
$contact = $entity->contacts()->first();
}
if($contact && method_exists($this, $key)) {
if ($contact && method_exists($this, $key)) {
return $this->{$key}($contact);
} elseif($contact && ($contact->{$key} ?? false)) {
} elseif ($contact && ($contact->{$key} ?? false)) {
return $contact->{$key} ?? '';
}

View File

@ -19,15 +19,15 @@ class VendorDecorator extends Decorator implements DecoratorInterface
{
$vendor = false;
if($entity instanceof Vendor) {
if ($entity instanceof Vendor) {
$vendor = $entity;
} elseif($entity->vendor) {
} elseif ($entity->vendor) {
$vendor = $entity->vendor;
}
if($vendor && method_exists($this, $key)) {
if ($vendor && method_exists($this, $key)) {
return $this->{$key}($vendor);
} elseif($vendor->{$key} ?? false) {
} elseif ($vendor->{$key} ?? false) {
return $vendor->{$key} ?? '';
}

View File

@ -78,23 +78,23 @@ class InvoiceItemFactory
}
$item = self::create();
$item->quantity = rand(1, 10);
$item->cost = $faker->randomFloat(2, 1, 1000);
$item->line_total = $item->quantity * $item->cost;
$item->is_amount_discount = true;
$item->discount = rand(1, 10);
$item->notes = str_replace(['"',"'"], ['',""], $faker->realText(20));
$item->product_key = $faker->word();
// $item->custom_value1 = $faker->realText(10);
// $item->custom_value2 = $faker->realText(10);
// $item->custom_value3 = $faker->realText(10);
// $item->custom_value4 = $faker->realText(10);
$item->tax_name1 = 'GST';
$item->tax_rate1 = 10.00;
$item->type_id = '2';
$item = self::create();
$item->quantity = rand(1, 10);
$item->cost = $faker->randomFloat(2, 1, 1000);
$item->line_total = $item->quantity * $item->cost;
$item->is_amount_discount = true;
$item->discount = rand(1, 10);
$item->notes = str_replace(['"',"'"], ['',""], $faker->realText(20));
$item->product_key = $faker->word();
// $item->custom_value1 = $faker->realText(10);
// $item->custom_value2 = $faker->realText(10);
// $item->custom_value3 = $faker->realText(10);
// $item->custom_value4 = $faker->realText(10);
$item->tax_name1 = 'GST';
$item->tax_rate1 = 10.00;
$item->type_id = '2';
$data[] = $item;
$data[] = $item;
return $data;

View File

@ -122,7 +122,7 @@ class BankTransactionFilters extends QueryFilters
return $this->builder;
}
return $this->builder->whereHas('bank_integration', function ($query){
return $this->builder->whereHas('bank_integration', function ($query) {
$query->where('is_deleted', 0)->whereNull('deleted_at');
});
}
@ -135,7 +135,7 @@ class BankTransactionFilters extends QueryFilters
*/
public function bank_integration_ids(string $ids = ''): Builder
{
if(strlen($ids) == 0) {
if (strlen($ids) == 0) {
return $this->builder;
}

View File

@ -124,7 +124,7 @@ class ClientFilters extends QueryFilters
*/
public function filter(string $filter = ''): Builder
{
if (strlen($filter) == 0) {
return $this->builder;
}
@ -168,7 +168,7 @@ class ClientFilters extends QueryFilters
return $this->builder;
}
if($sort_col[0] == 'documents') {
if ($sort_col[0] == 'documents') {
return $this->builder;
}
@ -178,7 +178,7 @@ class ClientFilters extends QueryFilters
$dir = ($sort_col[1] == 'asc') ? 'asc' : 'desc';
if($sort_col[0] == 'number') {
if ($sort_col[0] == 'number') {
return $this->builder->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . $dir);
}

View File

@ -155,7 +155,7 @@ class CreditFilters extends QueryFilters
}
if($sort_col[0] == 'number') {
if ($sort_col[0] == 'number') {
return $this->builder->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . $dir);
}

View File

@ -59,7 +59,7 @@ class DesignFilters extends QueryFilters
public function entities(string $entities = ''): Builder
{
if(stripos($entities, 'statement') !== false) {
if (stripos($entities, 'statement') !== false) {
$entities = 'client';
}

View File

@ -117,7 +117,7 @@ class ExpenseFilters extends QueryFilters
});
}
if(in_array('uncategorized', $status_parameters)) {
if (in_array('uncategorized', $status_parameters)) {
$query->orWhere(function ($query) {
$query->whereNull('category_id');
});
@ -168,7 +168,7 @@ class ExpenseFilters extends QueryFilters
{
$categories_exploded = explode(",", $categories);
if(empty($categories) || count(array_filter($categories_exploded)) == 0) {
if (empty($categories) || count(array_filter($categories_exploded)) == 0) {
return $this->builder;
}
@ -238,7 +238,7 @@ class ExpenseFilters extends QueryFilters
->orderByRaw('ISNULL(payment_date), payment_date '. $sort_col[1]);
}
if($sort_col[0] == 'number') {
if ($sort_col[0] == 'number') {
return $this->builder->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . $dir);
}

View File

@ -238,7 +238,7 @@ class InvoiceFilters extends QueryFilters
try {
$date = Carbon::parse($date);
} catch(\Exception $e) {
} catch (\Exception $e) {
return $this->builder;
}
}
@ -289,7 +289,7 @@ class InvoiceFilters extends QueryFilters
}
if($sort_col[0] == 'number') {
if ($sort_col[0] == 'number') {
return $this->builder->orderByRaw("REGEXP_REPLACE(invoices.number,'[^0-9]+','')+0 " . $dir);
}

View File

@ -113,7 +113,7 @@ class PaymentFilters extends QueryFilters
$query->whereIn('status_id', $payment_filters);
}
if(in_array('partially_unapplied', $status_parameters)) {
if (in_array('partially_unapplied', $status_parameters)) {
$query->whereColumn('amount', '>', 'applied')->where('refunded', 0);
}
});
@ -175,7 +175,7 @@ class PaymentFilters extends QueryFilters
->whereColumn('clients.id', 'payments.client_id'), $dir);
}
if($sort_col[0] == 'number') {
if ($sort_col[0] == 'number') {
return $this->builder->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . $dir);
}
@ -190,7 +190,7 @@ class PaymentFilters extends QueryFilters
return $this->builder;
}
if(!in_array($parts[0], ['date'])) {
if (!in_array($parts[0], ['date'])) {
return $this->builder;
}
@ -200,7 +200,7 @@ class PaymentFilters extends QueryFilters
$end_date = Carbon::parse($parts[2]);
return $this->builder->whereBetween($parts[0], [$start_date, $end_date]);
} catch(\Exception $e) {
} catch (\Exception $e) {
return $this->builder;
}

View File

@ -71,7 +71,7 @@ class ProjectFilters extends QueryFilters
->whereColumn('clients.id', 'projects.client_id'), $dir);
}
if($sort_col[0] == 'number') {
if ($sort_col[0] == 'number') {
return $this->builder->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . $dir);
}

View File

@ -137,7 +137,7 @@ class PurchaseOrderFilters extends QueryFilters
->whereColumn('vendors.id', 'purchase_orders.vendor_id'), $dir);
}
if($sort_col[0] == 'number') {
if ($sort_col[0] == 'number') {
return $this->builder->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . $dir);
}

View File

@ -215,7 +215,7 @@ abstract class QueryFilters
}
return $this->builder->where('created_at', '>=', $created_at);
} catch(\Exception $e) {
} catch (\Exception $e) {
return $this->builder;
}
}
@ -322,7 +322,7 @@ abstract class QueryFilters
return $this->builder;
}
if($this->with_property == 'id') {
if ($this->with_property == 'id') {
$value = $this->decodePrimaryKey($value);
}
@ -353,7 +353,7 @@ abstract class QueryFilters
$end_date = Carbon::parse($parts[1]);
return $this->builder->whereBetween('date', [$start_date, $end_date]);
} catch(\Exception $e) {
} catch (\Exception $e) {
return $this->builder;
}
@ -380,7 +380,7 @@ abstract class QueryFilters
$end_date = Carbon::parse($parts[1]);
return $this->builder->whereBetween('due_date', [$start_date, $end_date]);
} catch(\Exception $e) {
} catch (\Exception $e) {
return $this->builder;
}

View File

@ -121,7 +121,7 @@ class QuoteFilters extends QueryFilters
});
}
if(in_array('converted', $status_parameters)) {
if (in_array('converted', $status_parameters)) {
$query->orWhere(function ($q) {
$q->whereNotNull('invoice_id');
});
@ -156,14 +156,14 @@ class QuoteFilters extends QueryFilters
$dir = ($sort_col[1] == 'asc') ? 'asc' : 'desc';
if($sort_col[0] == 'client_id') {
if ($sort_col[0] == 'client_id') {
return $this->builder->orderBy(\App\Models\Client::select('name')
->whereColumn('clients.id', 'quotes.client_id'), $dir);
}
if($sort_col[0] == 'number') {
if ($sort_col[0] == 'number') {
return $this->builder->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . $dir);
}

View File

@ -164,7 +164,7 @@ class RecurringExpenseFilters extends QueryFilters
->whereColumn('expense_categories.id', 'recurring_expenses.category_id'), $sort_col[1]);
}
if($sort_col[0] == 'number') {
if ($sort_col[0] == 'number') {
return $this->builder->orderByRaw('ABS(number) ' . $dir);
}

View File

@ -137,15 +137,15 @@ class RecurringInvoiceFilters extends QueryFilters
->whereColumn('clients.id', 'recurring_invoices.client_id'), $dir);
}
if($sort_col[0] == 'number') {
if ($sort_col[0] == 'number') {
return $this->builder->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . $dir);
}
if($sort_col[0] == 'status_id') {
if ($sort_col[0] == 'status_id') {
return $this->builder->orderBy('status_id', $dir)->orderBy('last_sent_date', $dir);
}
if($sort_col[0] == 'next_send_datetime') {
if ($sort_col[0] == 'next_send_datetime') {
$sort_col[0] = 'next_send_date';
}

View File

@ -146,7 +146,7 @@ class TaskFilters extends QueryFilters
->whereColumn('users.id', 'tasks.user_id'), $dir);
}
if($sort_col[0] == 'number') {
if ($sort_col[0] == 'number') {
return $this->builder->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . $dir);
}
@ -182,7 +182,7 @@ class TaskFilters extends QueryFilters
/** @var array $status_parameters */
$status_parameters = explode(',', $value);
if(count($status_parameters) >= 1) {
if (count($status_parameters) >= 1) {
$this->builder->where(function ($query) use ($status_parameters) {
$query->whereIn('status_id', $this->transformKeys($status_parameters))->whereNull('invoice_id');

View File

@ -71,7 +71,7 @@ class VendorFilters extends QueryFilters
$dir = ($sort_col[1] == 'asc') ? 'asc' : 'desc';
if($sort_col[0] == 'number') {
if ($sort_col[0] == 'number') {
return $this->builder->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . $dir);
}

View File

@ -97,17 +97,15 @@ class Nordigen
$it = new AccountTransformer();
return $it->transform($out);
}
catch (\GuzzleHttp\Exception\ClientException $e) {
} catch (\GuzzleHttp\Exception\ClientException $e) {
$response = $e->getResponse();
$statusCode = $response->getStatusCode();
if ($statusCode === 429) {
nlog("Nordigen Rate Limit hit for account {$account_id}");
return ['error' => 'Nordigen Institution Rate Limit Reached'];
}
}
catch (\Exception $e) {
} catch (\Exception $e) {
nlog("Nordigen getAccount() failed => {$account_id} => " . $e->getMessage());
return ['error' => $e->getMessage()];
@ -133,7 +131,7 @@ class Nordigen
return true;
} catch (\Exception $e) {
nlog("Nordigen:: AccountActiveStatus:: {$e->getMessage()} {$e->getCode()}");
if (strpos($e->getMessage(), "Invalid Account ID") !== false) {
@ -164,7 +162,7 @@ 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;
}

View File

@ -84,17 +84,17 @@ class AccountTransformer implements AccountTransformerInterface
$current_balance = 0;
$account_currency = '';
if(property_exists($account, 'currentBalance')) {
if (property_exists($account, 'currentBalance')) {
$current_balance = $account->currentBalance->amount ?? 0;
$account_currency = $account->currentBalance->currency ?? '';
} elseif(property_exists($account, 'balance')) {
} elseif (property_exists($account, 'balance')) {
$current_balance = $account->balance->amount ?? 0;
$account_currency = $account->balance->currency ?? '';
}
$account_status = $account->accountStatus;
if(property_exists($account, 'dataset')) {
if (property_exists($account, 'dataset')) {
$dataset = $account->dataset[0];
$status = false;
$update = false;
@ -114,7 +114,7 @@ class AccountTransformer implements AccountTransformerInterface
default => $status = false
};
if($status) {
if ($status) {
$account_status = $status;
}
@ -125,9 +125,9 @@ class AccountTransformer implements AccountTransformerInterface
default => $update = false,
};
if($status && $update) {
if ($status && $update) {
$account_status = $status . ' - ' . $update;
} elseif($update) {
} elseif ($update) {
$account_status = $update;
}

View File

@ -132,7 +132,7 @@ class IncomeTransformer implements BankRevenueInterface
}
//some object do no store amounts ignore these
if(!property_exists($transaction, 'amount')) {
if (!property_exists($transaction, 'amount')) {
continue;
}

View File

@ -60,7 +60,7 @@ class Piste
{
$response = Http::asForm()->post($this->oauthUrl(), $this->oauthHeaders());
if($response->successful()) {
if ($response->successful()) {
return $response->json()['access_token'];
}

View File

@ -58,7 +58,7 @@ class EpcQrGenerator
return "<svg viewBox='0 0 200 200' width='200' height='200' x='0' y='0' xmlns='http://www.w3.org/2000/svg'>
<rect x='0' y='0' width='100%'' height='100%' />{$qr}</svg>";
} catch(\Throwable $e) {
} catch (\Throwable $e) {
nlog("EPC QR failure => ".$e->getMessage());
return '';
}

View File

@ -67,7 +67,7 @@ class InvoiceItemSum
'NO', //NORWAY - EEA
'IS', //ICELAND - EEA
'LI', //Liechtenstein - EEA
];
private array $tax_jurisdictions = [
@ -198,11 +198,11 @@ class InvoiceItemSum
if (in_array($this->client->company->country()->iso_3166_2, $this->tax_jurisdictions)) { //only calculate for supported tax jurisdictions
/** @var \App\DataMapper\Tax\BaseRule $class */
$class = "App\DataMapper\Tax\\".str_replace("-","_",$this->client->company->country()->iso_3166_2)."\\Rule";
$class = "App\DataMapper\Tax\\".str_replace("-", "_", $this->client->company->country()->iso_3166_2)."\\Rule";
$this->rule = new $class();
if($this->rule->regionWithNoTaxCoverage($this->client->country->iso_3166_2)) {
if ($this->rule->regionWithNoTaxCoverage($this->client->country->iso_3166_2)) {
return $this;
}
@ -292,7 +292,7 @@ class InvoiceItemSum
$this->calcTaxesAutomatically();
}
if($this->client->is_tax_exempt){
if ($this->client->is_tax_exempt) {
$this->item->tax_rate1 = 0;
$this->item->tax_rate2 = 0;
$this->item->tax_rate3 = 0;
@ -340,8 +340,9 @@ class InvoiceItemSum
private function getPeppolSurchargeTaxes(): self
{
if(!$this->client->getSetting('e_invoice_type') == 'PEPPOL')
if (!$this->client->getSetting('e_invoice_type') == 'PEPPOL') {
return $this;
}
collect($this->invoice->line_items)
->flatMap(function ($item) {
@ -355,32 +356,33 @@ class InvoiceItemSum
})
->unique(fn ($tax) => $tax['percentage'] . '_' . $tax['name'])
->values()
->each(function ($tax){
$tax_component = 0;
->each(function ($tax) {
if ($this->invoice->custom_surcharge1) {
$tax_component += round($this->invoice->custom_surcharge1 * ($tax['percentage'] / 100), 2);
}
$tax_component = 0;
if ($this->invoice->custom_surcharge2) {
$tax_component += round($this->invoice->custom_surcharge2 * ($tax['percentage'] / 100), 2);
}
if ($this->invoice->custom_surcharge1) {
$tax_component += round($this->invoice->custom_surcharge1 * ($tax['percentage'] / 100), 2);
}
if ($this->invoice->custom_surcharge3) {
$tax_component += round($this->invoice->custom_surcharge3 * ($tax['percentage'] / 100), 2);
}
if ($this->invoice->custom_surcharge2) {
$tax_component += round($this->invoice->custom_surcharge2 * ($tax['percentage'] / 100), 2);
}
if ($this->invoice->custom_surcharge4) {
$tax_component += round($this->invoice->custom_surcharge4 * ($tax['percentage'] / 100), 2);
}
if ($this->invoice->custom_surcharge3) {
$tax_component += round($this->invoice->custom_surcharge3 * ($tax['percentage'] / 100), 2);
}
$amount = $this->invoice->custom_surcharge4 + $this->invoice->custom_surcharge3 + $this->invoice->custom_surcharge2 + $this->invoice->custom_surcharge1;
if ($this->invoice->custom_surcharge4) {
$tax_component += round($this->invoice->custom_surcharge4 * ($tax['percentage'] / 100), 2);
}
if($tax_component > 0)
$this->groupTax($tax['name'], $tax['percentage'], $tax_component, $amount, $tax['tax_id']);
$amount = $this->invoice->custom_surcharge4 + $this->invoice->custom_surcharge3 + $this->invoice->custom_surcharge2 + $this->invoice->custom_surcharge1;
});
if ($tax_component > 0) {
$this->groupTax($tax['name'], $tax['percentage'], $tax_component, $amount, $tax['tax_id']);
}
});
return $this;
}
@ -482,7 +484,7 @@ class InvoiceItemSum
try {
$amount = $this->item->line_total - ($this->item->line_total * ($this->invoice->discount / $this->sub_total));
} catch(\DivisionByZeroError $e) {
} catch (\DivisionByZeroError $e) {
$amount = $this->item->line_total;
}

View File

@ -425,7 +425,7 @@ class InvoiceItemSumInclusive
$this->rule = new $class();
if($this->rule->regionWithNoTaxCoverage($this->client->country->iso_3166_2 ?? false)) {
if ($this->rule->regionWithNoTaxCoverage($this->client->country->iso_3166_2 ?? false)) {
return $this;
}

View File

@ -127,7 +127,7 @@ class InvoiceSum
private function calculateInvoiceTaxes(): self
{
if($this->client->is_tax_exempt) {
if ($this->client->is_tax_exempt) {
$this->invoice->tax_name1 = '';
$this->invoice->tax_name2 = '';
$this->invoice->tax_name3 = '';
@ -254,7 +254,7 @@ 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) {
if ($this->invoice->amount != $this->invoice->balance) {
@ -268,14 +268,14 @@ class InvoiceSum
$this->invoice->total_taxes = $this->getTotalTaxes();
if($this->rappen_rounding) {
if ($this->rappen_rounding) {
$this->invoice->amount = $this->roundRappen($this->invoice->amount);
$this->invoice->balance = $this->roundRappen($this->invoice->balance);
$this->total = $this->roundRappen($this->total);
$this->invoice->total_taxes = $this->roundRappen($this->invoice->total_taxes);
}
return $this;
}
@ -351,11 +351,11 @@ class InvoiceSum
$tax_name = $values->filter(function ($value, $k) use ($key) {
return $value['key'] == $key;
})->pluck('tax_name')->first();
$tax_rate = $values->filter(function ($value, $k) use ($key) {
return $value['key'] == $key;
})->pluck('tax_rate')->first();
$tax_id = $values->filter(function ($value, $k) use ($key) {
return $value['key'] == $key;
})->pluck('tax_id')->first();
@ -363,14 +363,14 @@ class InvoiceSum
$total_line_tax = $values->filter(function ($value, $k) use ($key) {
return $value['key'] == $key;
})->sum('total');
$base_amount = $values->filter(function ($value, $k) use ($key) {
return $value['key'] == $key;
})->sum('base_amount');
$tax_id = $values->first()['tax_id'] ?? '';
$this->tax_map[] = ['name' => $tax_name, 'total' => $total_line_tax, 'tax_id' => $tax_id, 'tax_rate' => $tax_rate, 'base_amount' => round($base_amount,2)];
$this->tax_map[] = ['name' => $tax_name, 'total' => $total_line_tax, 'tax_id' => $tax_id, 'tax_rate' => $tax_rate, 'base_amount' => round($base_amount, 2)];
$this->total_taxes += $total_line_tax;
}

View File

@ -147,19 +147,19 @@ class InvoiceSumInclusive
}
//Handles cases where the surcharge is not taxed
if(is_numeric($this->invoice->custom_surcharge1) && $this->invoice->custom_surcharge1 > 0 && $this->invoice->custom_surcharge_tax1) {
if (is_numeric($this->invoice->custom_surcharge1) && $this->invoice->custom_surcharge1 > 0 && $this->invoice->custom_surcharge_tax1) {
$amount += $this->invoice->custom_surcharge1;
}
if(is_numeric($this->invoice->custom_surcharge2) && $this->invoice->custom_surcharge2 > 0 && $this->invoice->custom_surcharge_tax2) {
if (is_numeric($this->invoice->custom_surcharge2) && $this->invoice->custom_surcharge2 > 0 && $this->invoice->custom_surcharge_tax2) {
$amount += $this->invoice->custom_surcharge2;
}
if(is_numeric($this->invoice->custom_surcharge3) && $this->invoice->custom_surcharge3 > 0 && $this->invoice->custom_surcharge_tax3) {
if (is_numeric($this->invoice->custom_surcharge3) && $this->invoice->custom_surcharge3 > 0 && $this->invoice->custom_surcharge_tax3) {
$amount += $this->invoice->custom_surcharge3;
}
if(is_numeric($this->invoice->custom_surcharge4) && $this->invoice->custom_surcharge4 > 0 && $this->invoice->custom_surcharge_tax4) {
if (is_numeric($this->invoice->custom_surcharge4) && $this->invoice->custom_surcharge4 > 0 && $this->invoice->custom_surcharge_tax4) {
$amount += $this->invoice->custom_surcharge4;
}
@ -289,7 +289,7 @@ 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) {
if ($this->invoice->amount != $this->invoice->balance) {
@ -304,9 +304,9 @@ class InvoiceSumInclusive
$this->invoice->total_taxes = $this->getTotalTaxes();
if($this->rappen_rounding) {
if ($this->rappen_rounding) {
$this->invoice->amount = $this->roundRappen($this->invoice->amount);
$this->invoice->balance = $this->roundRappen($this->invoice->balance);
$this->invoice->balance = $this->roundRappen($this->invoice->balance);
$this->total = $this->roundRappen($this->total);
$this->invoice->total_taxes = $this->roundRappen($this->invoice->total_taxes);
}
@ -387,17 +387,17 @@ class InvoiceSumInclusive
$total_line_tax = $values->filter(function ($value, $k) use ($key) {
return $value['key'] == $key;
})->sum('total');
$base_amount = $values->filter(function ($value, $k) use ($key) {
return $value['key'] == $key;
})->sum('base_amount');
$tax_id = $values->first()['tax_id'] ?? '';
$this->tax_map[] = ['name' => $tax_name, 'total' => $total_line_tax, 'tax_id' => $tax_id, 'tax_rate' => $tax_rate, 'base_amount' => round($base_amount,2)];
$this->tax_map[] = ['name' => $tax_name, 'total' => $total_line_tax, 'tax_id' => $tax_id, 'tax_rate' => $tax_rate, 'base_amount' => round($base_amount, 2)];
$this->total_taxes += $total_line_tax;
}
return $this;

View File

@ -13,7 +13,6 @@ namespace App\Helpers;
class Sanitizer
{
public static function removeBlanks($input): array
{
foreach ($input as &$value) {
@ -25,4 +24,4 @@ class Sanitizer
// Use array_filter to remove empty or null values
return array_filter($input);
}
}
}

View File

@ -175,7 +175,7 @@ class SwissQrGenerator
return $html;
} catch (\Exception $e) {
if(is_iterable($qrBill->getViolations())) {
if (is_iterable($qrBill->getViolations())) {
foreach ($qrBill->getViolations() as $key => $violation) {
// nlog("qr");

View File

@ -67,16 +67,16 @@ class AccountController extends BaseController
public function store(CreateAccountRequest $request)
{
if($request->has('cf-turnstile-response') && config('ninja.cloudflare.turnstile.secret')) {
if ($request->has('cf-turnstile-response') && config('ninja.cloudflare.turnstile.secret')) {
$r = \Illuminate\Support\Facades\Http::post('https://challenges.cloudflare.com/turnstile/v0/siteverify', [
'secret' => config('ninja.cloudflare.turnstile.secret'),
'response' => $request->input('cf-turnstile-response'),
'remoteip' => $request->getClientIp(),
]);
if($r->successful()) {
if ($r->successful()) {
if($r->json()['success'] === true) {
if ($r->json()['success'] === true) {
// Captcha passed
} else {
return response()->json(['message' => 'Captcha Failed'], 400);
@ -85,9 +85,9 @@ class AccountController extends BaseController
}
if($request->has('hash') && config('ninja.cloudflare.turnstile.secret')) { //@todo once all platforms are implemented, we disable access to the rest of this route without a success response.
if ($request->has('hash') && config('ninja.cloudflare.turnstile.secret')) { //@todo once all platforms are implemented, we disable access to the rest of this route without a success response.
if(Secure::decrypt($request->input('hash')) !== $request->input('email')) {
if (Secure::decrypt($request->input('hash')) !== $request->input('email')) {
return response()->json(['message' => 'Invalid Signup Payload'], 400);
}

View File

@ -62,7 +62,7 @@ class ActivityController extends BaseController
->company()
->take($default_activities);
if($request->has('reactv2')) {
if ($request->has('reactv2')) {
/** @var \App\Models\User auth()->user() */
$user = auth()->user();

View File

@ -41,7 +41,7 @@ class ContactLoginController extends Controller
$company = false;
$account = false;
if($request->query('intended')) {
if ($request->query('intended')) {
$request->session()->put('url.intended', $request->query('intended'));
}
@ -143,7 +143,7 @@ class ContactLoginController extends Controller
$this->setRedirectPath();
if($intended) {
if ($intended) {
$this->redirectTo = $intended;
}

View File

@ -403,7 +403,7 @@ class LoginController extends BaseController
$cu->each(function ($cu) {
/** @var \App\Models\CompanyUser $cu */
if(CompanyToken::query()->where('company_id', $cu->company_id)->where('user_id', $cu->user_id)->where('is_system', true)->doesntExist()) {
if (CompanyToken::query()->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();
}
});
@ -539,7 +539,7 @@ class LoginController extends BaseController
if (request()->has('id_token')) {
$user = $google->getTokenResponse(request()->input('id_token'));
} elseif(request()->has('access_token')) {
} elseif (request()->has('access_token')) {
$user = $google->harvestUser(request()->input('access_token'));
} else {
return response()->json(['message' => 'Illegal request'], 403);
@ -655,7 +655,7 @@ class LoginController extends BaseController
$parameters = ['response_type' => 'code', 'redirect_uri' => config('ninja.app_url') . "/auth/microsoft"];
}
if(request()->hasHeader('X-REACT') || request()->query('react')) {
if (request()->hasHeader('X-REACT') || request()->query('react')) {
/**@var \App\Models\User $user */
$user = auth()->user();
Cache::put("react_redir:".$user?->account->key, 'true', 300);

View File

@ -111,7 +111,7 @@ class ResetPasswordController extends Controller
{
auth()->logout();
if(request()->has('react') || request()->hasHeader('X-React')) {
if (request()->has('react') || request()->hasHeader('X-React')) {
return redirect(config('ninja.react_url').'/#/login');
}
@ -131,7 +131,7 @@ class ResetPasswordController extends Controller
return new JsonResponse(['message' => trans($response)], 200);
}
if($request->hasHeader('X-REACT') || $request->has('react')) {
if ($request->hasHeader('X-REACT') || $request->has('react')) {
return redirect(config('ninja.react_url').'/#/login');
} else {
return redirect('/#/login');

View File

@ -218,8 +218,9 @@ class NordigenController extends BaseController
$nordigen_account = $nordigen->getAccount($nordigenAccountId);
if(!$nordigen_account)
if (!$nordigen_account) {
continue;
}
$existing_bank_integration = BankIntegration::withTrashed()->where('nordigen_account_id', $nordigen_account['id'])->where('company_id', $company->id)->where('is_deleted', 0)->first();

View File

@ -112,7 +112,7 @@ class BankTransactionController extends BaseController
$this->bank_transaction_repo->convert_matched($bank_transactions);
} else {
$bank_transactions->each(function ($bank_transaction, $key) use ($action, $user) {
if($user->can('edit', $bank_transaction)) {
if ($user->can('edit', $bank_transaction)) {
$this->bank_transaction_repo->{$action}($bank_transaction);
}
});

View File

@ -924,9 +924,9 @@ class BaseController extends Controller
if ($this->entity_type == BankIntegration::class && !$user->isSuperUser() && $user->hasIntersectPermissions(['create_bank_transaction','edit_bank_transaction','view_bank_transaction'])) {
$query->exclude(["balance"]);
} //allows us to selective display bank integrations back to the user if they can view / create bank transactions but without the bank balance being present in the response
elseif($this->entity_type == TaxRate::class && $user->hasIntersectPermissions(['create_invoice','edit_invoice','create_quote','edit_quote','create_purchase_order','edit_purchase_order'])) {
elseif ($this->entity_type == TaxRate::class && $user->hasIntersectPermissions(['create_invoice','edit_invoice','create_quote','edit_quote','create_purchase_order','edit_purchase_order'])) {
// need to show tax rates if the user has the ability to create documents.
} elseif($this->entity_type == ExpenseCategory::class && $user->hasPermission('create_expense')) {
} elseif ($this->entity_type == ExpenseCategory::class && $user->hasPermission('create_expense')) {
// need to show expense categories if the user has the ability to create expenses.
} else {
$query->where('user_id', '=', $user->id);
@ -994,9 +994,9 @@ class BaseController extends Controller
$response_data = Statics::company($user->getCompany()->getLocale());
if(request()->has('einvoice')) {
if (request()->has('einvoice')) {
if(class_exists(Schema::class)) {
if (class_exists(Schema::class)) {
$ro = new Schema();
$response_data['einvoice_schema'] = $ro('Peppol');
}
@ -1223,7 +1223,7 @@ class BaseController extends Controller
return response()->json(['message' => 'Upgrade to a paid plan for this feature.'], 403);
}
/**
* GetEncodedFilename
*

View File

@ -185,8 +185,9 @@ class BrevoController extends BaseController
{
$input = $request->all();
if (!($request->has('token') && $request->get('token') == config('ninja.inbound_mailbox.inbound_webhook_token')))
if (!($request->has('token') && $request->get('token') == config('ninja.inbound_mailbox.inbound_webhook_token'))) {
return response()->json(['message' => 'Unauthorized'], 403);
}
if (!array_key_exists('items', $input)) {
nlog('Failed: Message could not be parsed, because required parameters are missing.');

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