1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #8602 from turbo124/v5-develop

updates for user preferences route
This commit is contained in:
David Bomba 2023-07-05 08:01:34 +10:00 committed by GitHub
commit 8c0375a252
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 5909 additions and 5445 deletions

View File

@ -105,7 +105,7 @@ class ImportMigrations extends Command
$import_file = public_path("storage/migrations/$filename/migration.json");
Import::dispatch($import_file, $this->getUser()->companies()->first(), $this->getUser());
// StartMigration::dispatch($file->getRealPath(), $this->getUser(), $this->getUser()->companies()->first());
} catch (NonExistingMigrationFile | ProcessingMigrationArchiveFailed | ResourceNotAvailableForMigration | MigrationValidatorFailed | ResourceDependencyMissing $e) {
\Mail::to($user)->send(new MigrationFailed($e, $company));

View File

@ -235,7 +235,7 @@ class BaseRule implements RuleInterface
$this->client_region = $this->region_codes[$this->client->country->iso_3166_2];
match($this->client_region){
'US' => $this->client_subregion = strlen($this->invoice?->client?->tax_data?->geoState) > 1 ? $this->invoice->client->tax_data->geoState : $this->getUSState(),
'US' => $this->client_subregion = isset($this->invoice?->client?->tax_data?->geoState) ? $this->invoice->client->tax_data->geoState : $this->getUSState(),
'EU' => $this->client_subregion = $this->client->country->iso_3166_2,
'AU' => $this->client_subregion = 'AU',
default => $this->client_subregion = $this->client->country->iso_3166_2,

View File

@ -123,6 +123,21 @@ class TaskFilters extends QueryFilters
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
}
public function task_status(string $value = ''): Builder
{
if (strlen($value) == 0) {
return $this->builder;
}
$status_parameters = explode(',', $value);
if(count($status_parameters) > 0)
return $this->builder->whereIn('status_id', $this->transformKeys($status_parameters));
return $this->builder;
}
/**
* Filters the query by the users company ID.
*

View File

@ -36,6 +36,12 @@ class TokenFilters extends QueryFilters
});
}
public function is_system(bool $value = false): Builder
{
return $this->builder->where('is_system', $value);
}
/**
* Sorts the list based on $sort.
*

View File

@ -14,6 +14,7 @@ namespace App\Http\Controllers;
use App\Models\User;
use App\Models\CompanyUser;
use Illuminate\Http\Response;
use App\Transformers\UserTransformer;
use App\Transformers\CompanyUserTransformer;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use App\Http\Requests\CompanyUser\UpdateCompanyUserRequest;
@ -134,6 +135,7 @@ class CompanyUserController extends BaseController
public function updatePreferences(UpdateCompanyUserPreferencesRequest $request, User $user)
{
/** @var \App\Models\User $logged_in_user */
$company = auth()->user()->company();
$company_user = CompanyUser::whereUserId($user->id)->whereCompanyId($company->id)->first();
@ -143,10 +145,14 @@ class CompanyUserController extends BaseController
return;
}
$this->entity_type = User::class;
$this->entity_transformer = UserTransformer::class;
$company_user->react_settings = $request->react_settings;
$company_user->save();
return $this->itemResponse($company_user->fresh());
return $this->itemResponse($user->fresh());
}

View File

@ -162,16 +162,14 @@ class ImportController extends Controller
$delimiters = [',', '.', ';'];
$bestDelimiter = ' ';
$count = 0;
foreach ($delimiters as $delimiter) {
// if (substr_count($csvfile, $delimiter) > $count) {
// $count = substr_count($csvfile, $delimiter);
// $bestDelimiter = $delimiter;
// }
if (substr_count(strstr($csvfile, "\n", true), $delimiter) > $count) {
if (substr_count(strstr($csvfile, "\n", true), $delimiter) >= $count) {
$count = substr_count($csvfile, $delimiter);
$bestDelimiter = $delimiter;
}
}
return $bestDelimiter;
}

View File

@ -175,6 +175,7 @@ class UserController extends BaseController
$user->oauth_user_refresh_token = null;
$user->oauth_user_token = null;
$user->save();
UserEmailChanged::dispatch($new_user, json_decode($old_user), $logged_in_user->company());
}

View File

@ -91,6 +91,10 @@ class BaseImport
public function getCsvData($entity_type)
{
if (! ini_get('auto_detect_line_endings')) {
ini_set('auto_detect_line_endings', '1');
}
$base64_encoded_csv = Cache::pull($this->hash.'-'.$entity_type);
if (empty($base64_encoded_csv)) {
@ -132,14 +136,12 @@ class BaseImport
$bestDelimiter = ',';
$count = 0;
foreach ($delimiters as $delimiter) {
// if (substr_count($csvfile, $delimiter) > $count) {
// $count = substr_count($csvfile, $delimiter);
// $bestDelimiter = $delimiter;
// }
if (substr_count(strstr($csvfile, "\n", true), $delimiter) > $count) {
if (substr_count(strstr($csvfile, "\n", true), $delimiter) >= $count) {
$count = substr_count($csvfile, $delimiter);
$bestDelimiter = $delimiter;
}
}
return $bestDelimiter;
}

View File

@ -60,10 +60,6 @@ class StartMigration implements ShouldQueue
public $timeout = 0;
// public $maxExceptions = 2;
//public $backoff = 86430;
public function __construct($filepath, User $user, Company $company)
{
$this->filepath = $filepath;
@ -159,8 +155,6 @@ class StartMigration implements ShouldQueue
}
//always make sure we unset the migration as running
return true;
}

View File

@ -309,7 +309,6 @@ class Company extends BaseModel
'google_analytics_key',
'matomo_url',
'matomo_id',
'enable_e_invoice',
'client_can_register',
'enable_shop_api',
'invoice_task_timelog',

View File

@ -522,17 +522,18 @@ class Payment extends BaseModel
event(new PaymentWasVoided($this, $this->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
}
// public function getLink()
// {
// return route('client.payments.show', $this->hashed_id);
// }
public function getLink() :string
{
// if (Ninja::isHosted()) {
// $domain = isset($this->company->portal_domain) ? $this->company->portal_domain : $this->company->domain();
// } else {
// $domain = config('ninja.app_url');
// }
if (Ninja::isHosted()) {
$domain = isset($this->company->portal_domain) ? $this->company->portal_domain : $this->company->domain();
$domain = $this->company->domain();
} else {
$domain = config('ninja.app_url');
$domain = strlen($this->company->portal_domain) > 5 ? $this->company->portal_domain : config('ninja.app_url');
}
return $domain.'/client/payment/'.$this->client->contacts()->first()->contact_key.'/'.$this->hashed_id.'?next=/client/payments/'.$this->hashed_id;

View File

@ -732,6 +732,9 @@ class BaseDriver extends AbstractPaymentDriver
$invoices_string = \implode(', ', collect($this->payment_hash->invoices())->pluck('invoice_number')->toArray()) ?: null;
if (!$invoices_string)
return str_replace(["*","<",">","'",'"'], "", $this->client->company->present()->name());
$invoices_string = str_replace(["*","<",">","'",'"'], "-", $invoices_string);
$invoices_string = "I-".$invoices_string;

View File

@ -150,7 +150,7 @@ class ClientTransformer extends EntityTransformer
'has_valid_vat_number' => (bool) $client->has_valid_vat_number,
'is_tax_exempt' => (bool) $client->is_tax_exempt,
'routing_id' => (string) $client->routing_id,
// 'tax_data' => $client->tax_data ?: '',
'tax_data' => $client->tax_data ?: '',
];
}
}

View File

@ -149,7 +149,7 @@ class InvoiceTransformer extends EntityTransformer
'paid_to_date' => (float) $invoice->paid_to_date,
'subscription_id' => $this->encodePrimaryKey($invoice->subscription_id),
'auto_bill_enabled' => (bool) $invoice->auto_bill_enabled,
// 'tax_data' => $invoice->tax_data ?: '',
'tax_data' => $invoice->tax_data ?: '',
];
}
}

View File

@ -101,7 +101,6 @@ trait Inviteable
break;
case 'iframe':
return $domain.'/client/'.$entity_type.'/'.$this->key;
//return $domain . $entity_type .'/'. $this->contact->client->client_hash .'/'. $this->key;
break;
case 'domain':
return $domain.'/client/'.$entity_type.'/'.$this->key;
@ -127,7 +126,6 @@ trait Inviteable
break;
case 'iframe':
return $domain.'/client/';
//return $domain . $entity_type .'/'. $this->contact->client->client_hash .'/'. $this->key;
break;
case 'domain':
return $domain.'/client/';

View File

@ -2260,7 +2260,7 @@ $LANG = array(
'restore_recurring_expense' => 'Restore Recurring Expense',
'restored_recurring_expense' => 'Successfully restored recurring expense',
'delete_recurring_expense' => 'Delete Recurring Expense',
'deleted_recurring_expense' => 'Successfully deleted project',
'deleted_recurring_expense' => 'Successfully deleted recurring expense',
'view_recurring_expense' => 'View Recurring Expense',
'taxes_and_fees' => 'Taxes and fees',
'import_failed' => 'Import Failed',

File diff suppressed because it is too large Load Diff

View File

@ -101,26 +101,229 @@
example: true
enabled_modules:
type: integer
example: 2048
description: |
Bitmask representation of the modules that are enabled in the application
Bitmask representation of the modules that are enabled in the application
```
self::ENTITY_RECURRING_INVOICE => 1,
self::ENTITY_CREDIT => 2,
self::ENTITY_QUOTE => 4,
self::ENTITY_TASK => 8,
self::ENTITY_EXPENSE => 16,
self::ENTITY_PROJECT => 32,
self::ENTITY_VENDOR => 64,
self::ENTITY_TICKET => 128,
self::ENTITY_PROPOSAL => 256,
self::ENTITY_RECURRING_EXPENSE => 512,
self::ENTITY_RECURRING_TASK => 1024,
self::ENTITY_RECURRING_QUOTE => 2048,
```
```
self::ENTITY_RECURRING_INVOICE => 1,
self::ENTITY_CREDIT => 2,
self::ENTITY_QUOTE => 4,
self::ENTITY_TASK => 8,
self::ENTITY_EXPENSE => 16,
self::ENTITY_PROJECT => 32,
self::ENTITY_VENDOR => 64,
self::ENTITY_TICKET => 128,
self::ENTITY_PROPOSAL => 256,
self::ENTITY_RECURRING_EXPENSE => 512,
self::ENTITY_RECURRING_TASK => 1024,
self::ENTITY_RECURRING_QUOTE => 2048,
```
The default per_page value is 20.
example: 2048
db:
readOnly: true
type: string
example: 'db-ninja-01'
first_day_of_week:
description: "The first day of the week for the company"
type: string
example: '1'
first_month_of_year:
description: "The first month for the company financial year"
type: string
example: '1'
enabled_item_tax_rates:
description: "The number of tax rates used per item"
type: integer
example: 2
is_large:
description: "A flag determining whether the company is considered large"
type: boolean
example: true
default_auto_bill:
type: enum
example: 'always'
description: |
A flag determining whether to auto-bill clients by default
values:
- always - Always auto bill
- disabled - Never auto bill
- optin - Allow the client to select their auto bill status with the default being disabled
- optout -Allow the client to select their auto bill status with the default being enabled
mark_expenses_invoiceable:
description: "A flag determining whether to mark expenses as invoiceable by default"
type: boolean
example: true
mark_expenses_paid:
description: "A flag determining whether to mark expenses as paid by default"
type: boolean
example: true
invoice_expense_documents:
description: "A flag determining whether to include expense documents on invoices by default"
type: boolean
example: true
auto_start_tasks:
description: "A flag determining whether to auto-start tasks by default"
type: boolean
example: true
invoice_task_timelog:
description: "A flag determining whether to include task time logs on invoices by default"
type: boolean
example: true
invoice_task_documents:
description: "A flag determining whether to include task documents on invoices by default"
type: boolean
example: true
show_tasks_table:
description: "A flag determining whether to show the tasks table on invoices by default"
type: boolean
example: true
is_disabled:
description: "A flag determining whether the company is disabled"
type: boolean
example: true
default_task_is_date_based:
description: "A flag determining whether to default tasks to be date-based"
type: boolean
example: true
enable_product_discount:
description: "A flag determining whether to show or hide the product discount field in the user interface"
type: boolean
example: true
calculate_expense_tax_by_amount:
description: "A flag determining whether to calculate expense taxes by amount"
type: boolean
example: true
expense_inclusive_taxes:
description: "A flag determining whether to include taxes in the expense amount"
type: boolean
example: true
session_timeout:
description: "The session timeout for the company"
type: integer
example: 60
oauth_password_required:
description: "A flag determining whether to require a password for `dangerous` actions when using OAuth"
type: boolean
example: true
invoice_task_datelog:
description: "A flag determining whether to include task date logs on invoices by default"
type: boolean
example: true
default_password_timeout:
description: "The default password timeout for the company"
type: integer
example: 60
show_task_end_date:
description: "A flag determining whether to show the task end date on invoices by default"
type: boolean
example: true
markdown_enabled:
description: "A flag determining whether markdown is enabled for the company"
type: boolean
example: true
report_include_drafts:
description: "A flag determining whether to include draft invoices in reports"
type: boolean
example: true
client_registration_fields:
description: "The client registration fields for the company"
type: object
stop_on_unpaid_recurring:
description: "A flag determining whether to stop recurring invoices when they are unpaid"
type: boolean
example: true
use_quote_terms_on_conversion:
description: "A flag determining whether to use quote terms on conversion to an invoice"
type: boolean
example: true
enable_applying_payments:
description: "A flag determining whether to enable applying payments to invoices"
type: boolean
example: true
track_inventory:
description: "A flag determining whether to track inventory for the company"
type: boolean
example: true
inventory_notification_threshold:
description: "The inventory notification threshold for the company"
type: integer
example: 60
stock_notification:
description: "A flag determining whether to send stock notifications for the company"
type: boolean
example: true
matomo_url:
description: "The Matomo URL for the company"
type: string
example: 'https://matomo.example.com'
matomo_id:
description: "The Matomo ID for the company"
type: string
example: '1'
enabled_expense_tax_rates:
description: "The number of tax rates used per expense"
type: integer
example: 2
invoice_task_project:
description: "A flag determining whether to include the project on invoices by default"
type: boolean
example: true
report_include_deleted:
description: "A flag determining whether to include deleted invoices in reports"
type: boolean
example: true
invoice_task_lock:
description: "A flag determining whether to lock tasks when invoiced"
type: boolean
example: true
convert_payment_currency:
description: "A flag determining whether to convert the payment currency"
type: boolean
example: true
convert_expense_currency:
description: "A flag determining whether to convert the expense currency"
type: boolean
example: true
notify_vendor_when_paid:
description: "A flag determining whether to notify the vendor when an expense is paid"
type: boolean
example: true
invoice_task_hours:
description: "A flag determining whether to include the task hours on invoices by default"
type: boolean
example: true
calculate_taxes:
description: "A flag determining whether to calculate taxes for the company"
type: boolean
example: true
tax_data:
description: "The tax data for the company"
type: object
e_invoice_certificate:
description: "The e-invoice certificate for the company"
type: string
example: '-----BEGIN CERTIFICATE-----'
e_invoice_certificate_passphrase:
description: "The e-invoice certificate passphrase for the company"
type: string
example: 'secret'
origin_tax_data:
description: "The origin tax data for the company"
type: object
invoice_task_project_header:
description: "A flag determining whether to include the project header on invoices by default"
type: boolean
example: true
invoice_task_item_description:
description: "A flag determining whether to include the item description on invoices by default"
type: boolean
example: true
settings:
$ref: '#/components/schemas/CompanySettings'
type: object