mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 06:34:34 -04:00
php-cs-fixer
This commit is contained in:
parent
9c288cd452
commit
72aadc0c16
@ -172,18 +172,18 @@ class CheckData extends Command
|
||||
CompanyUser::query()->cursor()->each(function ($cu) {
|
||||
|
||||
if (CompanyToken::where('user_id', $cu->user_id)->where('company_id', $cu->company_id)->where('is_system', 1)->doesntExist()) {
|
||||
|
||||
|
||||
|
||||
if ($cu->company && $cu->user) {
|
||||
$this->logMessage("Creating missing company token for user # {$cu->user_id} for company id # {$cu->company_id}");
|
||||
(new CreateCompanyToken($cu->company, $cu->user, 'System'))->handle();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!$cu->user) {
|
||||
$this->logMessage("No user found for company user - removing company user");
|
||||
$cu->forceDelete();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -477,14 +477,13 @@ class CheckData extends Command
|
||||
}
|
||||
} else {
|
||||
$this->logMessage("No contact present, so cannot add invitation for {$entity_key} - {$entity->id}");
|
||||
|
||||
try{
|
||||
|
||||
try {
|
||||
$entity->service()->createInvitations()->save();
|
||||
}
|
||||
catch(\Exception $e){
|
||||
} catch(\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
@ -949,12 +948,12 @@ class CheckData extends Command
|
||||
|
||||
});
|
||||
|
||||
Company::whereDoesntHave('company_users', function ($query){
|
||||
$query->where('is_owner', 1);
|
||||
Company::whereDoesntHave('company_users', function ($query) {
|
||||
$query->where('is_owner', 1);
|
||||
})
|
||||
->cursor()
|
||||
->when(Ninja::isHosted())
|
||||
->each(function ($c){
|
||||
->each(function ($c) {
|
||||
|
||||
$this->logMessage("Orphan Account # {$c->account_id}");
|
||||
|
||||
@ -963,8 +962,8 @@ class CheckData extends Command
|
||||
CompanyUser::whereDoesntHave('tokens')
|
||||
->cursor()
|
||||
->when(Ninja::isHosted())
|
||||
->each(function ($cu){
|
||||
|
||||
->each(function ($cu) {
|
||||
|
||||
$this->logMessage("Missing tokens for Company User # {$cu->id}");
|
||||
|
||||
});
|
||||
|
@ -1016,7 +1016,7 @@ class CreateSingleAccount extends Command
|
||||
$cg->fees_and_limits = $fees_and_limits;
|
||||
$cg->save();
|
||||
}
|
||||
|
||||
|
||||
if (config('ninja.testvars.eway') && ($this->gateway == 'all' || $this->gateway == 'eway')) {
|
||||
$cg = new CompanyGateway();
|
||||
$cg->company_id = $company->id;
|
||||
@ -1038,12 +1038,12 @@ class CreateSingleAccount extends Command
|
||||
$cg->save();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (config('ninja.testvars.gocardless') && ($this->gateway == 'all' || $this->gateway == 'gocardless')) {
|
||||
|
||||
$c_settings = ClientSettings::defaults();
|
||||
$c_settings->currency_id = '2';
|
||||
|
||||
|
||||
$client = Client::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'company_id' => $company->id,
|
||||
|
@ -48,37 +48,37 @@ class ReactBuilder extends Command
|
||||
{
|
||||
if($this->option('type') == 'local') {
|
||||
|
||||
|
||||
|
||||
$includes = '';
|
||||
|
||||
$directoryIterator = false;
|
||||
$includes = '';
|
||||
|
||||
try {
|
||||
$directoryIterator = new \RecursiveDirectoryIterator(public_path('react/v'.config('ninja.app_version').'/'), \RecursiveDirectoryIterator::SKIP_DOTS);
|
||||
} catch (\Exception $e) {
|
||||
$this->error('React files not found');
|
||||
return;
|
||||
}
|
||||
$directoryIterator = false;
|
||||
|
||||
foreach (new \RecursiveIteratorIterator($directoryIterator) as $file) {
|
||||
if ($file->getExtension() == 'js') {
|
||||
if (str_contains($file->getFileName(), 'index-')) {
|
||||
$includes .= '<script type="module" crossorigin src="/react/v'.config('ninja.app_version').'/'.$file->getFileName().'"></script>'."\n";
|
||||
} else {
|
||||
$includes .= '<link rel="modulepreload" href="/react/v'.config('ninja.app_version').'/'.$file->getFileName().'">'."\n";
|
||||
try {
|
||||
$directoryIterator = new \RecursiveDirectoryIterator(public_path('react/v'.config('ninja.app_version').'/'), \RecursiveDirectoryIterator::SKIP_DOTS);
|
||||
} catch (\Exception $e) {
|
||||
$this->error('React files not found');
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (new \RecursiveIteratorIterator($directoryIterator) as $file) {
|
||||
if ($file->getExtension() == 'js') {
|
||||
if (str_contains($file->getFileName(), 'index-')) {
|
||||
$includes .= '<script type="module" crossorigin src="/react/v'.config('ninja.app_version').'/'.$file->getFileName().'"></script>'."\n";
|
||||
} else {
|
||||
$includes .= '<link rel="modulepreload" href="/react/v'.config('ninja.app_version').'/'.$file->getFileName().'">'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (str_contains($file->getFileName(), '.css')) {
|
||||
$includes .= '<link rel="stylesheet" href="/react/v'.config('ninja.app_version').'/'.$file->getFileName().'">'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (str_contains($file->getFileName(), '.css')) {
|
||||
$includes .= '<link rel="stylesheet" href="/react/v'.config('ninja.app_version').'/'.$file->getFileName().'">'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents(resource_path('views/react/head.blade.php'), $includes);
|
||||
file_put_contents(resource_path('views/react/head.blade.php'), $includes);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class DbQuery extends GenericMixedMetric
|
||||
public $string_metric8 = 'client_version';
|
||||
|
||||
public $string_metric9 = 'platform';
|
||||
|
||||
|
||||
/**
|
||||
* The counter
|
||||
* set to 1.
|
||||
|
@ -64,9 +64,9 @@ class InvoiceItem
|
||||
public $task_id = '';
|
||||
|
||||
public $expense_id = '';
|
||||
|
||||
|
||||
public $unit_code = 'C62';
|
||||
|
||||
|
||||
public static $casts = [
|
||||
'task_id' => 'string',
|
||||
'expense_id' => 'string',
|
||||
|
@ -15,7 +15,6 @@ use App\DataMapper\InvoiceItem;
|
||||
|
||||
class PayPalBalanceAffecting
|
||||
{
|
||||
|
||||
private array $key_map = [
|
||||
'Date' => 'date',
|
||||
'Time' => 'time',
|
||||
@ -105,8 +104,10 @@ class PayPalBalanceAffecting
|
||||
public $discount;
|
||||
public $creditTransactionalFee;
|
||||
public $originalInvoiceId;
|
||||
|
||||
public function __construct(private array $import_row){}
|
||||
|
||||
public function __construct(private array $import_row)
|
||||
{
|
||||
}
|
||||
|
||||
public function run(): self
|
||||
{
|
||||
@ -116,11 +117,11 @@ class PayPalBalanceAffecting
|
||||
|
||||
$prop = $this->key_map[$key] ?? false;
|
||||
|
||||
if($prop){
|
||||
if($prop) {
|
||||
|
||||
echo "Setting {$prop} to {$value}".PHP_EOL;
|
||||
$this->{$prop} = $value;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,7 +131,7 @@ class PayPalBalanceAffecting
|
||||
private function cleanUp(): self
|
||||
{
|
||||
|
||||
foreach($this->key_map as $value){
|
||||
foreach($this->key_map as $value) {
|
||||
echo "Setting {$value} to null".PHP_EOL;
|
||||
$this->{$value} = null;
|
||||
}
|
||||
@ -154,7 +155,7 @@ class PayPalBalanceAffecting
|
||||
|
||||
public function getInvoice(): array
|
||||
{
|
||||
$item = new InvoiceItem;
|
||||
$item = new InvoiceItem();
|
||||
$item->cost = $this->gross ?? 0;
|
||||
$item->product_key = $this->itemId ?? '';
|
||||
$item->notes = $this->subject ?? $this->itemDetails;
|
||||
@ -162,7 +163,7 @@ class PayPalBalanceAffecting
|
||||
|
||||
return [
|
||||
'number' => trim($this->invoiceNumber ?? $this->transactionId),
|
||||
'date' => str_replace('/','-', $this->date ?? ''),
|
||||
'date' => str_replace('/', '-', $this->date ?? ''),
|
||||
'line_items' => [$item],
|
||||
'name' => $this->name ?? '',
|
||||
'email' => $this->fromEmailAddress ?? '',
|
||||
@ -174,12 +175,10 @@ class PayPalBalanceAffecting
|
||||
{
|
||||
$name_parts = explode(" ", $this->name ?? '');
|
||||
|
||||
if(count($name_parts) == 2)
|
||||
{
|
||||
if(count($name_parts) == 2) {
|
||||
$contact['first_name'] = $name_parts[0];
|
||||
$contact['last_name'] = $name_parts[1];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$contact['first_name'] = $this->name ?? '';
|
||||
}
|
||||
|
||||
@ -188,7 +187,7 @@ class PayPalBalanceAffecting
|
||||
|
||||
return $contact;
|
||||
}
|
||||
|
||||
|
||||
private function returnAddress(): array
|
||||
{
|
||||
return [
|
||||
@ -203,13 +202,15 @@ class PayPalBalanceAffecting
|
||||
|
||||
private function returnShippingAddress(): array
|
||||
{
|
||||
if(strlen($this->shippingAddress ?? '') <3)
|
||||
if(strlen($this->shippingAddress ?? '') < 3) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$ship_parts = explode(",", $this->shippingAddress);
|
||||
|
||||
if(count($ship_parts) != 7)
|
||||
if(count($ship_parts) != 7) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
'shipping_address1' => $ship_parts[2],
|
||||
|
@ -838,12 +838,12 @@ class BaseExport
|
||||
return '';
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Apply Product Filters
|
||||
*
|
||||
* @param Builder $query
|
||||
*
|
||||
*
|
||||
* @return Builder
|
||||
*/
|
||||
public function applyProductFilters(Builder $query): Builder
|
||||
@ -863,13 +863,13 @@ class BaseExport
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add Client Filter
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param mixed $clients
|
||||
*
|
||||
*
|
||||
* @return Builder
|
||||
*/
|
||||
protected function addClientFilter(Builder $query, $clients): Builder
|
||||
@ -886,13 +886,13 @@ class BaseExport
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add Vendor Filter
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $vendors
|
||||
*
|
||||
*
|
||||
* @return Builder
|
||||
*/
|
||||
protected function addVendorFilter(Builder$query, string $vendors): Builder
|
||||
@ -910,13 +910,13 @@ class BaseExport
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* AddProjectFilter
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $projects
|
||||
*
|
||||
*
|
||||
* @return Builder
|
||||
*/
|
||||
protected function addProjectFilter(Builder $query, string $projects): Builder
|
||||
@ -934,13 +934,13 @@ class BaseExport
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add Category Filter
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $expense_categories
|
||||
*
|
||||
*
|
||||
* @return Builder
|
||||
*/
|
||||
protected function addCategoryFilter(Builder $query, string $expense_categories): Builder
|
||||
@ -959,13 +959,13 @@ class BaseExport
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add Payment Status Filters
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $status
|
||||
*
|
||||
*
|
||||
* @return Builder
|
||||
*/
|
||||
protected function addPaymentStatusFilters(Builder $query, string $status): Builder
|
||||
@ -976,7 +976,7 @@ class BaseExport
|
||||
if(in_array('all', $status_parameters) || count($status_parameters) == 0) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
$query->where(function ($query) use ($status_parameters) {
|
||||
$payment_filters = [];
|
||||
|
||||
@ -1016,13 +1016,13 @@ class BaseExport
|
||||
return $query;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add RecurringInvoice Status Filter
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $status
|
||||
*
|
||||
*
|
||||
* @return Builder
|
||||
*/
|
||||
protected function addRecurringInvoiceStatusFilter(Builder $query, string $status): Builder
|
||||
@ -1030,7 +1030,7 @@ class BaseExport
|
||||
|
||||
$status_parameters = explode(',', $status);
|
||||
|
||||
if (in_array('all', $status_parameters) || count($status_parameters) == 0){
|
||||
if (in_array('all', $status_parameters) || count($status_parameters) == 0) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
@ -1060,7 +1060,7 @@ class BaseExport
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $status
|
||||
*
|
||||
*
|
||||
* @return Builder
|
||||
*/
|
||||
protected function addQuoteStatusFilter(Builder $query, string $status): Builder
|
||||
@ -1126,12 +1126,12 @@ class BaseExport
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $status
|
||||
*
|
||||
*
|
||||
* @return Builder
|
||||
*/
|
||||
protected function addPurchaseOrderStatusFilter(Builder $query, string $status): Builder
|
||||
{
|
||||
|
||||
|
||||
$status_parameters = explode(',', $status);
|
||||
|
||||
if (in_array('all', $status_parameters) || count($status_parameters) == 0) {
|
||||
@ -1234,7 +1234,7 @@ class BaseExport
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add Date Range
|
||||
*
|
||||
@ -1578,7 +1578,7 @@ class BaseExport
|
||||
|
||||
public function queueDocuments(Builder $query)
|
||||
{
|
||||
|
||||
|
||||
if($query->getModel() instanceof Document) {
|
||||
$documents = $query->pluck('id')->toArray();
|
||||
} else {
|
||||
|
@ -127,8 +127,9 @@ class ClientExport extends BaseExport
|
||||
->withTrashed()
|
||||
->where('company_id', $this->company->id);
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false)
|
||||
if(!$this->input['include_deleted'] ?? false) {
|
||||
$query->where('is_deleted', 0);
|
||||
}
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
|
@ -59,7 +59,7 @@ class ContactExport extends BaseExport
|
||||
|
||||
$query = ClientContact::query()
|
||||
->where('company_id', $this->company->id)
|
||||
->whereHas('client', function ($q){
|
||||
->whereHas('client', function ($q) {
|
||||
$q->where('is_deleted', false);
|
||||
});
|
||||
|
||||
|
@ -102,7 +102,7 @@ class CreditExport extends BaseExport
|
||||
$query = Credit::query()
|
||||
->withTrashed()
|
||||
->with('client')
|
||||
->whereHas('client', function ($q){
|
||||
->whereHas('client', function ($q) {
|
||||
$q->where('is_deleted', false);
|
||||
})
|
||||
->where('company_id', $this->company->id)
|
||||
|
@ -83,9 +83,9 @@ class ExpenseExport extends BaseExport
|
||||
->with('client')
|
||||
->withTrashed()
|
||||
->where('company_id', $this->company->id);
|
||||
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false){
|
||||
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false) {
|
||||
$query->where('is_deleted', 0);
|
||||
}
|
||||
|
||||
|
@ -57,13 +57,13 @@ class InvoiceExport extends BaseExport
|
||||
$query = Invoice::query()
|
||||
->withTrashed()
|
||||
->with('client')
|
||||
->whereHas('client', function ($q){
|
||||
->whereHas('client', function ($q) {
|
||||
$q->where('is_deleted', false);
|
||||
})
|
||||
->where('company_id', $this->company->id);
|
||||
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false){
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false) {
|
||||
$query->where('is_deleted', 0);
|
||||
}
|
||||
|
||||
|
@ -70,12 +70,12 @@ class InvoiceItemExport extends BaseExport
|
||||
$query = Invoice::query()
|
||||
->withTrashed()
|
||||
->with('client')
|
||||
->whereHas('client', function ($q){
|
||||
->whereHas('client', function ($q) {
|
||||
$q->where('is_deleted', false);
|
||||
})
|
||||
->where('company_id', $this->company->id);
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false){
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false) {
|
||||
$query->where('is_deleted', 0);
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ class PaymentExport extends BaseExport
|
||||
|
||||
$query = Payment::query()
|
||||
->withTrashed()
|
||||
->whereHas('client', function ($q){
|
||||
->whereHas('client', function ($q) {
|
||||
$q->where('is_deleted', false);
|
||||
})
|
||||
->where('company_id', $this->company->id)
|
||||
@ -71,7 +71,7 @@ class PaymentExport extends BaseExport
|
||||
}
|
||||
|
||||
$query = $this->addPaymentStatusFilters($query, $this->input['status'] ?? '');
|
||||
|
||||
|
||||
if($this->input['document_email_attachment'] ?? false) {
|
||||
$this->queueDocuments($query);
|
||||
}
|
||||
|
@ -74,9 +74,9 @@ class ProductExport extends BaseExport
|
||||
$query = Product::query()
|
||||
->withTrashed()
|
||||
->where('company_id', $this->company->id);
|
||||
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false){
|
||||
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false) {
|
||||
$query->where('is_deleted', 0);
|
||||
}
|
||||
|
||||
|
@ -80,20 +80,20 @@ class ProductSalesExport extends BaseExport
|
||||
|
||||
public function filterByProducts($query)
|
||||
{
|
||||
|
||||
|
||||
$product_keys = &$this->input['product_key'];
|
||||
|
||||
if ($product_keys && !empty($this->input['product_key'])) {
|
||||
|
||||
$keys = explode(",", $product_keys);
|
||||
$query->where(function ($q) use ($keys){
|
||||
$query->where(function ($q) use ($keys) {
|
||||
|
||||
foreach($keys as $key) {
|
||||
foreach($keys as $key) {
|
||||
$q->orWhereJsonContains('line_items', ['product_key' => $key]);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
return $query;
|
||||
@ -121,7 +121,7 @@ class ProductSalesExport extends BaseExport
|
||||
//insert the header
|
||||
$query = Invoice::query()
|
||||
->withTrashed()
|
||||
->whereHas('client', function ($q){
|
||||
->whereHas('client', function ($q) {
|
||||
$q->where('is_deleted', false);
|
||||
})
|
||||
->where('company_id', $this->company->id)
|
||||
@ -138,30 +138,29 @@ class ProductSalesExport extends BaseExport
|
||||
|
||||
$product_keys = &$this->input['product_key'];
|
||||
|
||||
if($product_keys){
|
||||
if($product_keys) {
|
||||
$product_keys = explode(",", $product_keys);
|
||||
}
|
||||
|
||||
$query->cursor()
|
||||
->each(function ($invoice) use($product_keys) {
|
||||
->each(function ($invoice) use ($product_keys) {
|
||||
foreach ($invoice->line_items as $item) {
|
||||
|
||||
if($product_keys)
|
||||
{
|
||||
if(in_array($item->product_key, $product_keys))
|
||||
$this->csv->insertOne($this->buildRow($invoice, $item));
|
||||
}
|
||||
else {
|
||||
$this->csv->insertOne($this->buildRow($invoice, $item));
|
||||
}
|
||||
|
||||
if($product_keys) {
|
||||
if(in_array($item->product_key, $product_keys)) {
|
||||
$this->csv->insertOne($this->buildRow($invoice, $item));
|
||||
}
|
||||
} else {
|
||||
$this->csv->insertOne($this->buildRow($invoice, $item));
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$grouped = $this->sales->groupBy('product_key')->map(function ($key, $value) use($product_keys){
|
||||
$grouped = $this->sales->groupBy('product_key')->map(function ($key, $value) use ($product_keys) {
|
||||
|
||||
if($product_keys && !in_array($value, $product_keys)){
|
||||
if($product_keys && !in_array($value, $product_keys)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -185,7 +184,8 @@ class ProductSalesExport extends BaseExport
|
||||
|
||||
})->reject(function ($value) {
|
||||
return $value === false;
|
||||
});;
|
||||
});
|
||||
;
|
||||
|
||||
$this->csv->insertOne([]);
|
||||
$this->csv->insertOne([]);
|
||||
|
@ -58,12 +58,12 @@ class PurchaseOrderExport extends BaseExport
|
||||
$query = PurchaseOrder::query()
|
||||
->withTrashed()
|
||||
->with('vendor')
|
||||
->whereHas('vendor', function ($q){
|
||||
->whereHas('vendor', function ($q) {
|
||||
$q->where('is_deleted', false);
|
||||
})
|
||||
->where('company_id', $this->company->id);
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false){
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false) {
|
||||
$query->where('is_deleted', 0);
|
||||
}
|
||||
|
||||
@ -72,8 +72,9 @@ class PurchaseOrderExport extends BaseExport
|
||||
|
||||
$clients = &$this->input['client_id'];
|
||||
|
||||
if($clients)
|
||||
if($clients) {
|
||||
$query = $this->addClientFilter($query, $clients);
|
||||
}
|
||||
|
||||
$query = $this->addPurchaseOrderStatusFilter($query, $this->input['status'] ?? '');
|
||||
|
||||
|
@ -62,12 +62,12 @@ class PurchaseOrderItemExport extends BaseExport
|
||||
|
||||
$query = PurchaseOrder::query()
|
||||
->withTrashed()
|
||||
->whereHas('vendor', function ($q){
|
||||
->whereHas('vendor', function ($q) {
|
||||
$q->where('is_deleted', false);
|
||||
})
|
||||
->with('vendor')->where('company_id', $this->company->id);
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false){
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false) {
|
||||
$query->where('is_deleted', 0);
|
||||
}
|
||||
|
||||
|
@ -64,12 +64,12 @@ class QuoteExport extends BaseExport
|
||||
$query = Quote::query()
|
||||
->withTrashed()
|
||||
->with('client')
|
||||
->whereHas('client', function ($q){
|
||||
->whereHas('client', function ($q) {
|
||||
$q->where('is_deleted', false);
|
||||
})
|
||||
->where('company_id', $this->company->id);
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false){
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false) {
|
||||
$query->where('is_deleted', 0);
|
||||
}
|
||||
|
||||
|
@ -65,12 +65,12 @@ class QuoteItemExport extends BaseExport
|
||||
|
||||
$query = Quote::query()
|
||||
->withTrashed()
|
||||
->whereHas('client', function ($q){
|
||||
->whereHas('client', function ($q) {
|
||||
$q->where('is_deleted', false);
|
||||
})
|
||||
->with('client')->where('company_id', $this->company->id);
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false){
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false) {
|
||||
$query->where('is_deleted', 0);
|
||||
}
|
||||
|
||||
|
@ -56,12 +56,12 @@ class RecurringInvoiceExport extends BaseExport
|
||||
$query = RecurringInvoice::query()
|
||||
->withTrashed()
|
||||
->with('client')
|
||||
->whereHas('client', function ($q){
|
||||
->whereHas('client', function ($q) {
|
||||
$q->where('is_deleted', false);
|
||||
})
|
||||
->where('company_id', $this->company->id);
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false){
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false) {
|
||||
$query->where('is_deleted', 0);
|
||||
}
|
||||
|
||||
|
@ -69,22 +69,24 @@ class TaskExport extends BaseExport
|
||||
$query = Task::query()
|
||||
->withTrashed()
|
||||
->where('company_id', $this->company->id);
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false){
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false) {
|
||||
$query->where('is_deleted', 0);
|
||||
}
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
||||
|
||||
$clients = &$this->input['client_id'];
|
||||
|
||||
if($clients)
|
||||
if($clients) {
|
||||
$query = $this->addClientFilter($query, $clients);
|
||||
}
|
||||
|
||||
$document_attachments = &$this->input['document_email_attachment'];
|
||||
|
||||
if($document_attachments)
|
||||
if($document_attachments) {
|
||||
$this->queueDocuments($query);
|
||||
}
|
||||
|
||||
return $query;
|
||||
|
||||
@ -224,7 +226,7 @@ class TaskExport extends BaseExport
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add Task Status Filter
|
||||
*
|
||||
@ -234,7 +236,7 @@ class TaskExport extends BaseExport
|
||||
*/
|
||||
protected function addTaskStatusFilter(Builder $query, string $status): Builder
|
||||
{
|
||||
|
||||
|
||||
$status_parameters = explode(',', $status);
|
||||
|
||||
if (in_array('all', $status_parameters) || count($status_parameters) == 0) {
|
||||
|
@ -63,8 +63,8 @@ class VendorExport extends BaseExport
|
||||
$query = Vendor::query()->with('contacts')
|
||||
->withTrashed()
|
||||
->where('company_id', $this->company->id);
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false){
|
||||
|
||||
if(!$this->input['include_deleted'] ?? false) {
|
||||
$query->where('is_deleted', 0);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ class ContactDecorator implements DecoratorInterface
|
||||
$contact = $entity->contacts()->first();
|
||||
} elseif($entity->client) {
|
||||
$contact = $entity->client->primary_contact->first() ?? $entity->client->contacts()->whereNotNull('email')->first();
|
||||
} elseif($entity->vendor) {
|
||||
} elseif($entity->vendor) {
|
||||
$contact = $entity->vendor->primary_contact->first() ?? $entity->vendor->contacts()->whereNotNull('email')->first();
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ class CompanyFactory
|
||||
$company->smtp_port = '';
|
||||
$company->smtp_username = '';
|
||||
$company->smtp_verify_peer = true;
|
||||
|
||||
|
||||
return $company;
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class CompanyGatewayFactory
|
||||
$company_gateway->require_shipping_address = false;
|
||||
$company_gateway->config = encrypt(json_encode(new \stdClass()));
|
||||
$company_gateway->always_show_required_fields = true;
|
||||
|
||||
|
||||
return $company_gateway;
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ class PurchaseOrderFactory
|
||||
$purchase_order->exchange_rate = 1;
|
||||
$purchase_order->total_taxes = 0;
|
||||
$purchase_order->uses_inclusive_taxes = false;
|
||||
|
||||
|
||||
return $purchase_order;
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class SubscriptionFactory
|
||||
$billing_subscription->company_id = $company_id;
|
||||
$billing_subscription->user_id = $user_id;
|
||||
$billing_subscription->steps = collect(Purchase::defaultSteps())
|
||||
->map(fn($step) => StepService::mapClassNameToString($step))
|
||||
->map(fn ($step) => StepService::mapClassNameToString($step))
|
||||
->implode(',');
|
||||
|
||||
return $billing_subscription;
|
||||
|
@ -115,7 +115,7 @@ class BankTransactionFilters extends QueryFilters
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Filters the list based on Bank Accounts.
|
||||
*
|
||||
@ -124,11 +124,12 @@ class BankTransactionFilters extends QueryFilters
|
||||
*/
|
||||
public function bank_integration_ids(string $ids = ''): Builder
|
||||
{
|
||||
if(strlen($ids) == 0)
|
||||
if(strlen($ids) == 0) {
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
$ids = $this->transformKeys(explode(",", $ids));
|
||||
|
||||
|
||||
$this->builder->where(function ($query) use ($ids) {
|
||||
$query->whereIn('bank_integration_id', $ids);
|
||||
});
|
||||
|
@ -160,8 +160,9 @@ class ClientFilters extends QueryFilters
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
if($sort_col[0] == 'documents')
|
||||
if($sort_col[0] == 'documents') {
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
if ($sort_col[0] == 'display_name') {
|
||||
$sort_col[0] = 'name';
|
||||
|
@ -58,10 +58,11 @@ class DesignFilters extends QueryFilters
|
||||
|
||||
public function entities(string $entities = ''): Builder
|
||||
{
|
||||
|
||||
if(stripos($entities, 'statement') !== false)
|
||||
|
||||
if(stripos($entities, 'statement') !== false) {
|
||||
$entities = 'client';
|
||||
|
||||
}
|
||||
|
||||
if (strlen($entities) == 0 || str_contains($entities, ',')) {
|
||||
return $this->builder;
|
||||
}
|
||||
|
@ -49,22 +49,22 @@ class DocumentFilters extends QueryFilters
|
||||
*/
|
||||
public function client_id(string $client_id = ''): Builder
|
||||
{
|
||||
|
||||
|
||||
return $this->builder->where(function ($query) use ($client_id) {
|
||||
$query->whereHasMorph('documentable', [
|
||||
\App\Models\Invoice::class,
|
||||
\App\Models\Quote::class,
|
||||
\App\Models\Credit::class,
|
||||
\App\Models\Expense::class,
|
||||
\App\Models\Payment::class,
|
||||
\App\Models\Invoice::class,
|
||||
\App\Models\Quote::class,
|
||||
\App\Models\Credit::class,
|
||||
\App\Models\Expense::class,
|
||||
\App\Models\Payment::class,
|
||||
\App\Models\Task::class,
|
||||
\App\Models\RecurringExpense::class,
|
||||
\App\Models\RecurringInvoice::class,
|
||||
\App\Models\Project::class,
|
||||
], function ($q2) use ($client_id) {
|
||||
$q2->where('client_id', $this->decodePrimaryKey($client_id));
|
||||
})->orWhereHasMorph('documentable', [\App\Models\Client::class], function ($q3) use ($client_id) {
|
||||
$q3->where('id', $this->decodePrimaryKey($client_id));
|
||||
$q2->where('client_id', $this->decodePrimaryKey($client_id));
|
||||
})->orWhereHasMorph('documentable', [\App\Models\Client::class], function ($q3) use ($client_id) {
|
||||
$q3->where('id', $this->decodePrimaryKey($client_id));
|
||||
});
|
||||
});
|
||||
|
||||
@ -74,8 +74,7 @@ class DocumentFilters extends QueryFilters
|
||||
{
|
||||
$types = explode(',', $types);
|
||||
|
||||
foreach ($types as $type)
|
||||
{
|
||||
foreach ($types as $type) {
|
||||
match($type) {
|
||||
'private' => $this->builder->where('is_public', 0),
|
||||
'public' => $this->builder->where('is_public', 1),
|
||||
@ -87,7 +86,7 @@ class DocumentFilters extends QueryFilters
|
||||
}
|
||||
|
||||
return $this->builder;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the list based on $sort.
|
||||
|
@ -111,8 +111,8 @@ class ExpenseFilters extends QueryFilters
|
||||
});
|
||||
}
|
||||
|
||||
if(in_array('uncategorized', $status_parameters)){
|
||||
$query->orWhere(function ($query){
|
||||
if(in_array('uncategorized', $status_parameters)) {
|
||||
$query->orWhere(function ($query) {
|
||||
$query->whereNull('category_id');
|
||||
});
|
||||
}
|
||||
|
@ -228,10 +228,9 @@ class InvoiceFilters extends QueryFilters
|
||||
$date = Carbon::createFromTimestamp((int)$date);
|
||||
} else {
|
||||
|
||||
try{
|
||||
try {
|
||||
$date = Carbon::parse($date);
|
||||
}
|
||||
catch(\Exception $e){
|
||||
} catch(\Exception $e) {
|
||||
return $this->builder;
|
||||
}
|
||||
}
|
||||
@ -339,7 +338,7 @@ class InvoiceFilters extends QueryFilters
|
||||
// return $this->builder->orderByRaw('CAST(number AS UNSIGNED), number ' . $dir);
|
||||
// return $this->builder->orderByRaw("number REGEXP '^[A-Za-z]+$',CAST(number as SIGNED INTEGER),CAST(REPLACE(number,'-','')AS SIGNED INTEGER) ,number");
|
||||
// return $this->builder->orderByRaw('ABS(number) ' . $dir);
|
||||
return $this->builder->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . $dir);
|
||||
return $this->builder->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . $dir);
|
||||
}
|
||||
|
||||
return $this->builder->orderBy($sort_col[0], $dir);
|
||||
|
@ -133,7 +133,7 @@ class RecurringInvoiceFilters extends QueryFilters
|
||||
return $this->builder->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . $dir);
|
||||
}
|
||||
|
||||
if($sort_col[0] == 'next_send_datetime'){
|
||||
if($sort_col[0] == 'next_send_datetime') {
|
||||
$sort_col[0] = 'next_send_date';
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ class Nordigen
|
||||
} catch (\Exception $e) {
|
||||
|
||||
nlog("Nordigen getAccount() failed => {$account_id} => " . $e->getMessage());
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
@ -151,9 +151,10 @@ class Nordigen
|
||||
public function disabledAccountEmail(BankIntegration $bank_integration): void
|
||||
{
|
||||
$cache_key = "email_quota:{$bank_integration->company->company_key}:{$bank_integration->id}";
|
||||
|
||||
if(Cache::has($cache_key))
|
||||
|
||||
if(Cache::has($cache_key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
App::setLocale($bank_integration->company->getLocale());
|
||||
|
||||
@ -168,7 +169,7 @@ class Nordigen
|
||||
$mo->email_template_subject = 'nordigen_requisition_subject';
|
||||
|
||||
Email::dispatch($mo, $bank_integration->company);
|
||||
|
||||
|
||||
Cache::put($cache_key, true, 60 * 60 * 24);
|
||||
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ class TransactionTransformer implements BankRevenueInterface
|
||||
|
||||
private Company $company;
|
||||
|
||||
function __construct(Company $company)
|
||||
public function __construct(Company $company)
|
||||
{
|
||||
$this->company = $company;
|
||||
}
|
||||
@ -192,7 +192,7 @@ class TransactionTransformer implements BankRevenueInterface
|
||||
}
|
||||
|
||||
try {
|
||||
return Carbon::createFromFormat("d-m-Y", $input)->setTimezone($timezone_name)->format($date_format_default) ?? $input;
|
||||
return Carbon::createFromFormat("d-m-Y", $input)->setTimezone($timezone_name)->format($date_format_default) ?? $input;
|
||||
} catch (\Exception $e) {
|
||||
return $input;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ class EpcQrGenerator
|
||||
return implode("\n", $data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// substr("{$this->invoice->number} {$this->invoice->client->number}", 0,139),
|
||||
|
||||
|
@ -27,7 +27,7 @@ trait CustomValuer
|
||||
|
||||
public function valuerTax($custom_value, $has_custom_invoice_taxes)
|
||||
{
|
||||
|
||||
|
||||
if (isset($custom_value) && is_numeric($custom_value) && $has_custom_invoice_taxes !== false) {
|
||||
return round($custom_value * ($this->invoice->tax_rate1 / 100), 2) + round($custom_value * ($this->invoice->tax_rate2 / 100), 2) + round($custom_value * ($this->invoice->tax_rate3 / 100), 2);
|
||||
}
|
||||
@ -35,17 +35,18 @@ trait CustomValuer
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function multiInclusiveTax($custom_value, $has_custom_invoice_taxes) {
|
||||
public function multiInclusiveTax($custom_value, $has_custom_invoice_taxes)
|
||||
{
|
||||
|
||||
if (isset($custom_value) && is_numeric($custom_value) && $has_custom_invoice_taxes !== false) {
|
||||
|
||||
$tax = 0;
|
||||
$tax = 0;
|
||||
|
||||
$tax += $this->formatValue($custom_value - ($custom_value / (1 + ($this->invoice->tax_rate1 / 100))), 2);
|
||||
$tax += $this->formatValue($custom_value - ($custom_value / (1 + ($this->invoice->tax_rate2 / 100))), 2);
|
||||
$tax += $this->formatValue($custom_value - ($custom_value / (1 + ($this->invoice->tax_rate3 / 100))), 2);
|
||||
$tax += $this->formatValue($custom_value - ($custom_value / (1 + ($this->invoice->tax_rate1 / 100))), 2);
|
||||
$tax += $this->formatValue($custom_value - ($custom_value / (1 + ($this->invoice->tax_rate2 / 100))), 2);
|
||||
$tax += $this->formatValue($custom_value - ($custom_value / (1 + ($this->invoice->tax_rate3 / 100))), 2);
|
||||
|
||||
return round($tax,2);
|
||||
return round($tax, 2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -182,7 +182,7 @@ class InvoiceItemSum
|
||||
$class = "App\DataMapper\Tax\\".$this->client->company->country()->iso_3166_2."\\Rule";
|
||||
|
||||
$this->rule = new $class();
|
||||
|
||||
|
||||
if($this->rule->regionWithNoTaxCoverage($this->client->country->iso_3166_2)) {
|
||||
return $this;
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ class InvoiceSum
|
||||
{
|
||||
// $this->invoice->amount = $this->formatValue($this->getTotal(), $this->precision);
|
||||
// $this->invoice->total_taxes = $this->getTotalTaxes();
|
||||
|
||||
|
||||
$this->setCalculatedAttributes();
|
||||
$this->invoice->balance = $this->invoice->amount;
|
||||
$this->invoice->saveQuietly();
|
||||
@ -245,10 +245,9 @@ class InvoiceSum
|
||||
*/
|
||||
private function setCalculatedAttributes(): self
|
||||
{
|
||||
if($this->invoice->status_id == Invoice::STATUS_CANCELLED){
|
||||
if($this->invoice->status_id == Invoice::STATUS_CANCELLED) {
|
||||
$this->invoice->balance = 0;
|
||||
}
|
||||
elseif ($this->invoice->status_id != Invoice::STATUS_DRAFT) {
|
||||
} elseif ($this->invoice->status_id != Invoice::STATUS_DRAFT) {
|
||||
if ($this->invoice->amount != $this->invoice->balance) {
|
||||
$this->invoice->balance = Number::roundValue($this->getTotal(), $this->precision) - $this->invoice->paid_to_date; //21-02-2024 cannot use the calculated $paid_to_date here as it could send the balance backward.
|
||||
} else {
|
||||
@ -258,7 +257,7 @@ class InvoiceSum
|
||||
/* Set new calculated total */
|
||||
$this->invoice->amount = $this->formatValue($this->getTotal(), $this->precision);
|
||||
|
||||
if($this->rappen_rounding){
|
||||
if($this->rappen_rounding) {
|
||||
$this->invoice->amount = $this->roundRappen($this->invoice->amount);
|
||||
$this->invoice->balance = $this->roundRappen($this->invoice->balance);
|
||||
}
|
||||
@ -269,7 +268,7 @@ class InvoiceSum
|
||||
}
|
||||
|
||||
|
||||
function roundRappen($value): float
|
||||
public function roundRappen($value): float
|
||||
{
|
||||
return round($value / .05, 0) * .05;
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ class InvoiceSumInclusive
|
||||
$this->total_taxes += $tax;
|
||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name3.' '.floatval($this->invoice->tax_rate3).'%', 'total' => $tax];
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -279,10 +279,9 @@ class InvoiceSumInclusive
|
||||
private function setCalculatedAttributes()
|
||||
{
|
||||
/* If amount != balance then some money has been paid on the invoice, need to subtract this difference from the total to set the new balance */
|
||||
if($this->invoice->status_id == Invoice::STATUS_CANCELLED){
|
||||
if($this->invoice->status_id == Invoice::STATUS_CANCELLED) {
|
||||
$this->invoice->balance = 0;
|
||||
}
|
||||
elseif ($this->invoice->status_id != Invoice::STATUS_DRAFT) {
|
||||
} elseif ($this->invoice->status_id != Invoice::STATUS_DRAFT) {
|
||||
if ($this->invoice->amount != $this->invoice->balance) {
|
||||
$this->invoice->balance = $this->formatValue($this->getTotal(), $this->precision) - $this->invoice->paid_to_date;
|
||||
} else {
|
||||
@ -302,8 +301,8 @@ class InvoiceSumInclusive
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
function roundRappen($value): float
|
||||
|
||||
public function roundRappen($value): float
|
||||
{
|
||||
return round($value / .05, 0) * .05;
|
||||
}
|
||||
@ -373,7 +372,7 @@ class InvoiceSumInclusive
|
||||
|
||||
$this->total_taxes += $total_line_tax;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -65,18 +65,18 @@ class GmailTransport extends AbstractTransport
|
||||
$body->setRaw($this->base64_encode($bcc_list.$message->toString()));
|
||||
|
||||
// try {
|
||||
$service->users_messages->send('me', $body, []);
|
||||
$service->users_messages->send('me', $body, []);
|
||||
// } catch(\Google\Service\Exception $e) {
|
||||
// /* Need to slow down */
|
||||
// if ($e->getCode() == '429') {
|
||||
// nlog("429 google - retrying ");
|
||||
|
||||
// sleep(rand(3,8));
|
||||
|
||||
|
||||
// try {
|
||||
// $service->users_messages->send('me', $body, []);
|
||||
// } catch(\Google\Service\Exception $e) {
|
||||
|
||||
|
||||
// }
|
||||
|
||||
// }
|
||||
|
@ -54,17 +54,17 @@ class Office365MailTransport extends AbstractTransport
|
||||
->setReturnType(\Microsoft\Graph\Model\Message::class)
|
||||
->execute();
|
||||
} catch (\Exception $e) {
|
||||
|
||||
sleep(rand(5,10));
|
||||
|
||||
sleep(rand(5, 10));
|
||||
|
||||
try {
|
||||
$graphMessage = $graph->createRequest('POST', '/users/'.$symfony_message->getFrom()[0]->getAddress().'/sendmail')
|
||||
->attachBody(base64_encode($bcc_list.$message->toString()))
|
||||
->addHeaders(['Content-Type' => 'text/plain'])
|
||||
->setReturnType(\Microsoft\Graph\Model\Message::class)
|
||||
->execute();
|
||||
$graphMessage = $graph->createRequest('POST', '/users/'.$symfony_message->getFrom()[0]->getAddress().'/sendmail')
|
||||
->attachBody(base64_encode($bcc_list.$message->toString()))
|
||||
->addHeaders(['Content-Type' => 'text/plain'])
|
||||
->setReturnType(\Microsoft\Graph\Model\Message::class)
|
||||
->execute();
|
||||
} catch (\Exception $e) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ class ContactLoginController extends Controller
|
||||
private function setRedirectPath()
|
||||
{
|
||||
if (auth()->guard('contact')->user()->client->getSetting('enable_client_portal_dashboard') === true) {
|
||||
$this->redirectTo = '/client/dashboard';
|
||||
$this->redirectTo = '/client/dashboard';
|
||||
} elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES) {
|
||||
$this->redirectTo = '/client/invoices';
|
||||
} elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES) {
|
||||
|
@ -50,7 +50,7 @@ class ContactRegisterController extends Controller
|
||||
public function register(RegisterRequest $request)
|
||||
{
|
||||
$request->merge(['company' => $request->company()]);
|
||||
|
||||
|
||||
$service = new ClientRegisterService(
|
||||
company: $request->company(),
|
||||
);
|
||||
|
@ -398,8 +398,8 @@ class LoginController extends BaseController
|
||||
$truth->setCompany($set_company);
|
||||
|
||||
//21-03-2024
|
||||
$cu->each(function ($cu){
|
||||
if(CompanyToken::where('company_id', $cu->company_id)->where('user_id', $cu->user_id)->where('is_system', true)->doesntExist()){
|
||||
$cu->each(function ($cu) {
|
||||
if(CompanyToken::where('company_id', $cu->company_id)->where('user_id', $cu->user_id)->where('is_system', true)->doesntExist()) {
|
||||
(new CreateCompanyToken($cu->company, $cu->user, request()->server('HTTP_USER_AGENT')))->handle();
|
||||
}
|
||||
});
|
||||
|
@ -310,7 +310,7 @@ class YodleeController extends BaseController
|
||||
|
||||
private function transformSummary($summary): array
|
||||
{
|
||||
$dto = new \stdClass;
|
||||
$dto = new \stdClass();
|
||||
$dto->id = $summary['id'] ?? 0;
|
||||
$dto->account_type = $summary['CONTAINER'] ?? '';
|
||||
|
||||
|
@ -460,7 +460,7 @@ class BaseController extends Controller
|
||||
}
|
||||
},
|
||||
'company.tasks' => function ($query) use ($updated_at, $user) {
|
||||
$query->where('updated_at', '>=', $updated_at)->with('project','documents');
|
||||
$query->where('updated_at', '>=', $updated_at)->with('project', 'documents');
|
||||
|
||||
if (! $user->hasPermission('view_task')) {
|
||||
$query->whereNested(function ($query) use ($user) {
|
||||
@ -798,7 +798,7 @@ class BaseController extends Controller
|
||||
}
|
||||
},
|
||||
'company.tasks' => function ($query) use ($created_at, $user) {
|
||||
$query->where('created_at', '>=', $created_at)->with('project.documents','documents');
|
||||
$query->where('created_at', '>=', $created_at)->with('project.documents', 'documents');
|
||||
|
||||
if (! $user->hasPermission('view_task')) {
|
||||
$query->whereNested(function ($query) use ($user) {
|
||||
@ -995,7 +995,7 @@ class BaseController extends Controller
|
||||
|
||||
$response_data = Statics::company($user->getCompany()->getLocale());
|
||||
|
||||
if(request()->has('einvoice')){
|
||||
if(request()->has('einvoice')) {
|
||||
|
||||
$ro = new Schema();
|
||||
$response_data['einvoice_schema'] = $ro('Peppol');
|
||||
@ -1003,7 +1003,7 @@ class BaseController extends Controller
|
||||
}
|
||||
|
||||
$response['static'] = $response_data;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -250,22 +250,22 @@ class ClientController extends BaseController
|
||||
return response()->json(['message' => $hash_or_response], 200);
|
||||
}
|
||||
|
||||
if($action == 'assign_group' && $user->can('edit', $clients->first())){
|
||||
if($action == 'assign_group' && $user->can('edit', $clients->first())) {
|
||||
|
||||
$this->client_repo->assignGroup($clients, $request->group_settings_id);
|
||||
|
||||
|
||||
return $this->listResponse(Client::query()->withTrashed()->company()->whereIn('id', $request->ids));
|
||||
|
||||
}
|
||||
|
||||
if($action == 'bulk_update' && $user->can('edit', $clients->first())){
|
||||
if($action == 'bulk_update' && $user->can('edit', $clients->first())) {
|
||||
|
||||
$clients = Client::withTrashed()
|
||||
->company()
|
||||
->whereIn('id', $request->ids);
|
||||
|
||||
$this->client_repo->bulkUpdate($clients, $request->column, $request->new_value);
|
||||
|
||||
|
||||
return $this->listResponse(Client::query()->withTrashed()->company()->whereIn('id', $request->ids));
|
||||
|
||||
}
|
||||
@ -351,9 +351,10 @@ class ClientController extends BaseController
|
||||
return response()->json(['message' => "Client not found"], 400);
|
||||
}
|
||||
|
||||
if($m_client->id == $client->id)
|
||||
if($m_client->id == $client->id) {
|
||||
return response()->json(['message' => "Attempting to merge the same client is not possible."], 400);
|
||||
|
||||
}
|
||||
|
||||
$merged_client = $client->service()->merge($m_client)->save();
|
||||
|
||||
return $this->itemResponse($merged_client);
|
||||
|
@ -21,7 +21,7 @@ class DashboardController extends Controller
|
||||
{
|
||||
if (auth()->guard('contact')->user()->client->getSetting('enable_client_portal_dashboard') === false) {
|
||||
return redirect()->route('client.invoices.index');
|
||||
}
|
||||
}
|
||||
|
||||
$total_invoices = Invoice::withTrashed()
|
||||
->where('client_id', auth()->guard('contact')->user()->client_id)
|
||||
|
@ -108,7 +108,7 @@ class PrePaymentController extends Controller
|
||||
return $invoice;
|
||||
});
|
||||
|
||||
|
||||
|
||||
$variables = false;
|
||||
|
||||
if(($invitation = $invoices->first()->invitations()->first() ?? false) && $invoice->client->getSetting('show_accept_invoice_terms')) {
|
||||
|
@ -178,7 +178,7 @@ class QuoteController extends Controller
|
||||
->where('client_id', auth()->guard('contact')->user()->client->id)
|
||||
->where('company_id', auth()->guard('contact')->user()->client->company_id)
|
||||
->whereIn('status_id', [Quote::STATUS_DRAFT, Quote::STATUS_SENT])
|
||||
->where(function ($q){
|
||||
->where(function ($q) {
|
||||
$q->whereNull('due_date')->orWhere('due_date', '>=', now());
|
||||
})
|
||||
->withTrashed()
|
||||
|
@ -715,18 +715,16 @@ class CompanyController extends BaseController
|
||||
$logo = strlen($company->settings->company_logo) > 5 ? $company->settings->company_logo : 'https://pdf.invoicing.co/favicon-v2.png';
|
||||
$headers = ['Content-Disposition' => 'inline'];
|
||||
|
||||
try{
|
||||
try {
|
||||
$response = \Illuminate\Support\Facades\Http::get($logo);
|
||||
|
||||
if ($response->successful()) {
|
||||
$logo = $response->body();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$logo = base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=');
|
||||
}
|
||||
|
||||
}
|
||||
catch(\Exception $e){
|
||||
} catch(\Exception $e) {
|
||||
|
||||
$logo = base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=');
|
||||
|
||||
|
@ -232,7 +232,7 @@ class CompanyGatewayController extends BaseController
|
||||
} elseif($company_gateway->gateway_key == $this->checkout_key) {
|
||||
CheckoutSetupWebhook::dispatch($company_gateway->company->company_key, $company_gateway->id);
|
||||
} elseif($company_gateway->gateway_key == $this->forte_key) {
|
||||
|
||||
|
||||
dispatch(function () use ($company_gateway) {
|
||||
MultiDB::setDb($company_gateway->company->db);
|
||||
$company_gateway->driver()->updateFees();
|
||||
@ -420,8 +420,8 @@ class CompanyGatewayController extends BaseController
|
||||
|
||||
if($company_gateway->gateway_key == $this->checkout_key) {
|
||||
CheckoutSetupWebhook::dispatch($company_gateway->company->company_key, $company_gateway->fresh()->id);
|
||||
}elseif($company_gateway->gateway_key == $this->forte_key){
|
||||
|
||||
} elseif($company_gateway->gateway_key == $this->forte_key) {
|
||||
|
||||
dispatch(function () use ($company_gateway) {
|
||||
MultiDB::setDb($company_gateway->company->db);
|
||||
$company_gateway->driver()->updateFees();
|
||||
@ -565,12 +565,13 @@ class CompanyGatewayController extends BaseController
|
||||
|
||||
public function importCustomers(TestCompanyGatewayRequest $request, CompanyGateway $company_gateway)
|
||||
{
|
||||
|
||||
//Throttle here
|
||||
if (Cache::has("throttle_polling:import_customers:{$company_gateway->company->company_key}:{$company_gateway->hashed_id}"))
|
||||
return response()->json(['message' => 'Please wait whilst your previous attempts complete.'], 200);
|
||||
|
||||
dispatch(function () use($company_gateway) {
|
||||
//Throttle here
|
||||
if (Cache::has("throttle_polling:import_customers:{$company_gateway->company->company_key}:{$company_gateway->hashed_id}")) {
|
||||
return response()->json(['message' => 'Please wait whilst your previous attempts complete.'], 200);
|
||||
}
|
||||
|
||||
dispatch(function () use ($company_gateway) {
|
||||
MultiDB::setDb($company_gateway->company->db);
|
||||
$company_gateway->driver()->importCustomers();
|
||||
})->afterResponse();
|
||||
|
@ -276,7 +276,7 @@ class ImportController extends Controller
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the best delimiter
|
||||
@ -302,7 +302,7 @@ class ImportController extends Controller
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** @phpstan-ignore-next-line **/
|
||||
return $bestDelimiter ?? ',';
|
||||
|
||||
|
@ -64,11 +64,11 @@ class LogoutController extends BaseController
|
||||
->tokens()
|
||||
->where('is_system', true)
|
||||
->cursor()
|
||||
->each(function ($ct){
|
||||
->each(function ($ct) {
|
||||
$ct->token = \Illuminate\Support\Str::random(64);
|
||||
$ct->save();
|
||||
});
|
||||
|
||||
|
||||
return response()->json(['message' => 'All tokens deleted'], 200);
|
||||
}
|
||||
}
|
||||
|
@ -146,8 +146,7 @@ class PreviewController extends BaseController
|
||||
if (request()->has('entity') &&
|
||||
request()->has('entity_id') &&
|
||||
! empty(request()->input('entity')) &&
|
||||
! empty(request()->input('entity_id')))
|
||||
{
|
||||
! empty(request()->input('entity_id'))) {
|
||||
|
||||
$design_object = json_decode(json_encode(request()->input('design')));
|
||||
|
||||
@ -172,10 +171,9 @@ class PreviewController extends BaseController
|
||||
App::setLocale($entity_obj->client->preferredLocale());
|
||||
$t->replace(Ninja::transformTranslations($entity_obj->client->getMergedSettings()));
|
||||
|
||||
if($entity_obj->client){
|
||||
if($entity_obj->client) {
|
||||
$html = new HtmlEngine($entity_obj->invitations()->first());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$html = new VendorHtmlEngine($entity_obj->invitations()->first());
|
||||
}
|
||||
|
||||
|
@ -66,8 +66,7 @@ class TaskReportController extends BaseController
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
if ($request->has('send_email') && $request->get('send_email') && $request->missing('output'))
|
||||
{
|
||||
if ($request->has('send_email') && $request->get('send_email') && $request->missing('output')) {
|
||||
SendToAdmin::dispatch($user->company(), $request->all(), TaskExport::class, $this->filename);
|
||||
|
||||
return response()->json(['message' => 'working...'], 200);
|
||||
|
@ -62,8 +62,9 @@ class SelfUpdateController extends BaseController
|
||||
|
||||
$file_headers = @get_headers($this->getDownloadUrl());
|
||||
|
||||
if(!is_array($file_headers))
|
||||
if(!is_array($file_headers)) {
|
||||
return response()->json(['message' => 'There was a problem reaching the update server, please try again in a little while.'], 410);
|
||||
}
|
||||
|
||||
if (stripos($file_headers[0], "404 Not Found") > 0 || (stripos($file_headers[0], "302 Found") > 0 && stripos($file_headers[7], "404 Not Found") > 0)) {
|
||||
return response()->json(['message' => 'Download not yet available. Please try again shortly.'], 410);
|
||||
@ -100,8 +101,9 @@ class SelfUpdateController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
if(Storage::disk('base')->directoryExists('resources/lang'))
|
||||
if(Storage::disk('base')->directoryExists('resources/lang')) {
|
||||
Storage::disk('base')->deleteDirectory('resources/lang');
|
||||
}
|
||||
|
||||
nlog('Removing cache files');
|
||||
|
||||
|
@ -18,7 +18,6 @@ use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class SmtpController extends BaseController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@ -51,7 +50,7 @@ class SmtpController extends BaseController
|
||||
'timeout' => 5,
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
(new \Illuminate\Mail\MailServiceProvider(app()))->register();
|
||||
|
||||
try {
|
||||
@ -60,7 +59,7 @@ class SmtpController extends BaseController
|
||||
$sending_user = (isset($company->settings->email_from_name) && strlen($company->settings->email_from_name) > 2) ? $company->settings->email_from_name : $user->name();
|
||||
|
||||
$mailable = new TestMailServer('Email Server Works!', $sending_email);
|
||||
$mailable->from($sending_email,$sending_user);
|
||||
$mailable->from($sending_email, $sending_user);
|
||||
|
||||
Mail::mailer('smtp')
|
||||
->to($user->email, $user->present()->name())
|
||||
@ -68,7 +67,7 @@ class SmtpController extends BaseController
|
||||
|
||||
} catch (\Exception $e) {
|
||||
app('mail.manager')->forgetMailers();
|
||||
return response()->json(['message' => $e->getMessage()], 400);
|
||||
return response()->json(['message' => $e->getMessage()], 400);
|
||||
}
|
||||
|
||||
app('mail.manager')->forgetMailers();
|
||||
@ -77,4 +76,4 @@ class SmtpController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -59,11 +59,11 @@ class StaticController extends BaseController
|
||||
|
||||
$response_data = Statics::company($user->getLocale() ?? $user->company()->getLocale());
|
||||
|
||||
if(request()->has('einvoice')){
|
||||
|
||||
if(request()->has('einvoice')) {
|
||||
|
||||
$schema = new Schema();
|
||||
$response_data['einvoice_schema'] = $schema('Peppol');
|
||||
|
||||
$response_data['einvoice_schema'] = $schema('Peppol');
|
||||
|
||||
}
|
||||
|
||||
return response()->json($response_data, 200, ['Content-type' => 'application/json; charset=utf-8'], JSON_PRETTY_PRINT);
|
||||
|
@ -64,7 +64,7 @@ class StripeConnectController extends BaseController
|
||||
if ($request->has('error') && $request->error == 'access_denied') {
|
||||
return view('auth.connect.access_denied');
|
||||
}
|
||||
|
||||
|
||||
$response = false;
|
||||
|
||||
try {
|
||||
@ -91,7 +91,7 @@ class StripeConnectController extends BaseController
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(!$response) {
|
||||
@ -154,7 +154,7 @@ class StripeConnectController extends BaseController
|
||||
|
||||
//response here
|
||||
return view('auth.connect.completed', ['url' => $redirect_uri]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,10 +21,10 @@ class SubscriptionStepsController extends BaseController
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$dependencies = collect(Purchase::$dependencies)
|
||||
->map(fn($dependency) => [
|
||||
->map(fn ($dependency) => [
|
||||
'id' => $dependency['id'],
|
||||
'dependencies' => collect($dependency['dependencies'])
|
||||
->map(fn($dependency) => Purchase::$dependencies[$dependency]['id'])
|
||||
->map(fn ($dependency) => Purchase::$dependencies[$dependency]['id'])
|
||||
->toArray(),
|
||||
])
|
||||
->toArray();
|
||||
|
@ -72,7 +72,7 @@ class TwoFactorController extends BaseController
|
||||
return response()->json(['message' => ctrans('texts.enabled_two_factor')], 200);
|
||||
} elseif (! $secret || ! $google2fa->verifyKey($secret, $oneTimePassword)) {
|
||||
return response()->json(['message' => ctrans('texts.invalid_one_time_password')], 400);
|
||||
}elseif (! $user->phone) {
|
||||
} elseif (! $user->phone) {
|
||||
return response()->json(['message' => ctrans('texts.set_phone_for_two_factor')], 400);
|
||||
} elseif (! $user->isVerified()) {
|
||||
return response()->json(['message' => 'Please confirm your account first'], 400);
|
||||
|
@ -260,7 +260,7 @@ class UserController extends BaseController
|
||||
/** @var \App\Models\User $logged_in_user */
|
||||
$logged_in_user = auth()->user();
|
||||
|
||||
$company_user = CompanyUser::where('user_id',$user->id)
|
||||
$company_user = CompanyUser::where('user_id', $user->id)
|
||||
->where('company_id', $logged_in_user->companyId())
|
||||
->withTrashed()
|
||||
->first();
|
||||
|
@ -162,7 +162,7 @@ class ContactKeyLogin
|
||||
private function setRedirectPath()
|
||||
{
|
||||
if (auth()->guard('contact')->user()->client->getSetting('enable_client_portal_dashboard') === true) {
|
||||
return '/client/dashboard';
|
||||
return '/client/dashboard';
|
||||
} elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_INVOICES) {
|
||||
return '/client/invoices';
|
||||
} elseif (auth()->guard('contact')->user()->company->enabled_modules & PortalComposer::MODULE_RECURRING_INVOICES) {
|
||||
|
@ -78,13 +78,11 @@ class QueryLogging
|
||||
|
||||
if ($request->hasHeader('X-CLIENT-PLATFORM')) {
|
||||
$platform = $request->header('X-CLIENT-PLATFORM');
|
||||
}
|
||||
elseif($request->hasHeader('X-React')){
|
||||
} elseif($request->hasHeader('X-React')) {
|
||||
$platform = 'react';
|
||||
}
|
||||
|
||||
if ($request->hasHeader('X-CLIENT-VERSION'))
|
||||
{
|
||||
if ($request->hasHeader('X-CLIENT-VERSION')) {
|
||||
$client_version = $request->header('X-CLIENT-VERSION');
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ class StoreBankTransactionRequest extends Request
|
||||
$input['bank_integration_id'] = $this->decodePrimaryKey($input['bank_integration_id']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ use Illuminate\Validation\Rule;
|
||||
class BulkClientRequest extends Request
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
|
@ -48,8 +48,7 @@ class StoreClientRequest extends Request
|
||||
$rules['documents.*'] = $this->fileValidation();
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->fileValidation();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
@ -133,11 +132,9 @@ class StoreClientRequest extends Request
|
||||
} else {
|
||||
$input['settings']['currency_id'] = (string) $user->company()->settings->currency_id;
|
||||
}
|
||||
}
|
||||
elseif (! array_key_exists('currency_id', $input['settings'])) {
|
||||
} elseif (! array_key_exists('currency_id', $input['settings'])) {
|
||||
$input['settings']['currency_id'] = (string) $user->company()->settings->currency_id;
|
||||
}
|
||||
elseif (empty($input['settings']['currency_id']) ?? true) {
|
||||
} elseif (empty($input['settings']['currency_id']) ?? true) {
|
||||
$input['settings']['currency_id'] = (string) $user->company()->settings->currency_id;
|
||||
}
|
||||
|
||||
|
@ -105,8 +105,7 @@ class UpdateClientRequest extends Request
|
||||
/* If the user removes the currency we must always set the default */
|
||||
if (array_key_exists('settings', $input) && ! array_key_exists('currency_id', $input['settings'])) {
|
||||
$input['settings']['currency_id'] = (string) $user->company()->settings->currency_id;
|
||||
}
|
||||
elseif (empty($input['settings']['currency_id']) ?? true) {
|
||||
} elseif (empty($input['settings']['currency_id']) ?? true) {
|
||||
$input['settings']['currency_id'] = (string) $user->company()->settings->currency_id;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ class StoreCompanyRequest extends Request
|
||||
$rules['smtp_host'] = 'sometimes|string|nullable';
|
||||
$rules['smtp_port'] = 'sometimes|integer|nullable';
|
||||
$rules['smtp_encryption'] = 'sometimes|string';
|
||||
$rules['smtp_local_domain'] = 'sometimes|string|nullable';
|
||||
$rules['smtp_local_domain'] = 'sometimes|string|nullable';
|
||||
$rules['smtp_encryption'] = 'sometimes|string|nullable';
|
||||
$rules['smtp_local_domain'] = 'sometimes|string|nullable';
|
||||
|
||||
@ -100,8 +100,9 @@ class StoreCompanyRequest extends Request
|
||||
$input['smtp_port'] = (int) $input['smtp_port'];
|
||||
}
|
||||
|
||||
if(isset($input['smtp_verify_peer']) && is_string($input['smtp_verify_peer']))
|
||||
if(isset($input['smtp_verify_peer']) && is_string($input['smtp_verify_peer'])) {
|
||||
$input['smtp_verify_peer'] == 'true' ? true : false;
|
||||
}
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class UpdateCompanyRequest extends Request
|
||||
$rules['smtp_local_domain'] = 'sometimes|string|nullable';
|
||||
// $rules['smtp_verify_peer'] = 'sometimes|string';
|
||||
|
||||
|
||||
|
||||
if (isset($input['portal_mode']) && ($input['portal_mode'] == 'domain' || $input['portal_mode'] == 'iframe')) {
|
||||
$rules['portal_domain'] = 'bail|nullable|sometimes|url';
|
||||
}
|
||||
@ -97,14 +97,14 @@ class UpdateCompanyRequest extends Request
|
||||
unset($input['e_invoice_certificate_passphrase']);
|
||||
}
|
||||
|
||||
if(isset($input['smtp_username']) && strlen(str_replace("*","", $input['smtp_username'])) < 2) {
|
||||
if(isset($input['smtp_username']) && strlen(str_replace("*", "", $input['smtp_username'])) < 2) {
|
||||
unset($input['smtp_username']);
|
||||
}
|
||||
|
||||
if(isset($input['smtp_password']) && strlen(str_replace("*", "", $input['smtp_password'])) < 2) {
|
||||
unset($input['smtp_password']);
|
||||
}
|
||||
|
||||
|
||||
if(isset($input['smtp_port'])) {
|
||||
$input['smtp_port'] = (int)$input['smtp_port'];
|
||||
}
|
||||
@ -145,8 +145,9 @@ class UpdateCompanyRequest extends Request
|
||||
$settings['email_style_custom'] = str_replace(['{!!','!!}','{{','}}','@checked','@dd', '@dump', '@if', '@if(','@endif','@isset','@unless','@auth','@empty','@guest','@env','@section','@switch', '@foreach', '@while', '@include', '@each', '@once', '@push', '@use', '@forelse', '@verbatim', '<?php', '@php', '@for','@class','</sc','<sc','html;base64', '@elseif', '@else', '@endunless', '@endisset', '@endempty', '@endauth', '@endguest', '@endproduction', '@endenv', '@hasSection', '@endhasSection', '@sectionMissing', '@endsectionMissing', '@endfor', '@endforeach', '@empty', '@endforelse', '@endwhile', '@continue', '@break', '@includeIf', '@includeWhen', '@includeUnless', '@includeFirst', '@component', '@endcomponent', '@endsection', '@yield', '@show', '@append', '@overwrite', '@stop', '@extends', '@endpush', '@stack', '@prepend', '@endprepend', '@slot', '@endslot', '@endphp', '@method', '@csrf', '@error', '@enderror', '@json', '@endverbatim', '@inject'], '', $settings['email_style_custom']);
|
||||
}
|
||||
|
||||
if(isset($settings['company_logo']) && strlen($settings['company_logo']) > 2)
|
||||
if(isset($settings['company_logo']) && strlen($settings['company_logo']) > 2) {
|
||||
$settings['company_logo'] = $this->forceScheme($settings['company_logo']);
|
||||
}
|
||||
|
||||
if (! $account->isFreeHostedClient()) {
|
||||
return $settings;
|
||||
@ -173,7 +174,8 @@ class UpdateCompanyRequest extends Request
|
||||
return rtrim($url, '/');
|
||||
}
|
||||
|
||||
private function forceScheme($url){
|
||||
private function forceScheme($url)
|
||||
{
|
||||
return stripos($url, 'http') !== false ? $url : "https://{$url}";
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,9 @@ class UpdateCompanyUserRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
if(isset($input['company_user']['user']))
|
||||
if(isset($input['company_user']['user'])) {
|
||||
unset($input['company_user']['user']);
|
||||
}
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class StoreCreditRequest extends Request
|
||||
$rules['documents.*'] = $this->fileValidation();
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->fileValidation();
|
||||
}else {
|
||||
} else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ class StoreCreditRequest extends Request
|
||||
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
||||
$rules['amount'] = ['sometimes', 'bail', 'numeric', 'max:99999999999999'];
|
||||
|
||||
$rules['date'] = 'bail|sometimes|date:Y-m-d';
|
||||
$rules['date'] = 'bail|sometimes|date:Y-m-d';
|
||||
|
||||
if ($this->invoice_id) {
|
||||
$rules['invoice_id'] = new ValidInvoiceCreditRule();
|
||||
|
@ -52,7 +52,7 @@ class UpdateCreditRequest extends Request
|
||||
$rules['documents.*'] = $this->fileValidation();
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->fileValidation();
|
||||
}else {
|
||||
} else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ class UpdateExpenseRequest extends Request
|
||||
|
||||
public function prepareForValidation()
|
||||
{
|
||||
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
|
@ -47,7 +47,7 @@ class StoreInvoiceRequest extends Request
|
||||
$rules['documents.*'] = $this->fileValidation();
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->fileValidation();
|
||||
}else {
|
||||
} else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ class StoreInvoiceRequest extends Request
|
||||
$rules['partial'] = 'bail|sometimes|nullable|numeric|gte:0';
|
||||
$rules['partial_due_date'] = ['bail', 'sometimes', 'exclude_if:partial,0', Rule::requiredIf(fn () => $this->partial > 0), 'date'];
|
||||
$rules['amount'] = ['sometimes', 'bail', 'numeric', 'max:99999999999999'];
|
||||
|
||||
|
||||
// $rules['amount'] = ['sometimes', 'bail', 'max:99999999999999'];
|
||||
// $rules['due_date'] = ['bail', 'sometimes', 'nullable', 'after:partial_due_date', Rule::requiredIf(fn () => strlen($this->partial_due_date) > 1), 'date'];
|
||||
|
||||
@ -122,8 +122,9 @@ class StoreInvoiceRequest extends Request
|
||||
if((isset($input['partial_due_date']) && strlen($input['partial_due_date']) > 1) && (!array_key_exists('due_date', $input) || (empty($input['due_date']) && empty($this->invoice->due_date)))) {
|
||||
$client = \App\Models\Client::withTrashed()->find($input['client_id']);
|
||||
|
||||
if($client)
|
||||
if($client) {
|
||||
$input['due_date'] = \Illuminate\Support\Carbon::parse($input['date'])->addDays($client->getSetting('payment_terms'))->format('Y-m-d');
|
||||
}
|
||||
}
|
||||
|
||||
$this->replace($input);
|
||||
|
@ -49,7 +49,7 @@ class UpdateInvoiceRequest extends Request
|
||||
$rules['documents.*'] = $this->fileValidation();
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->fileValidation();
|
||||
}else {
|
||||
} else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
|
@ -45,8 +45,9 @@ class ConnectNordigenBankIntegrationRequest extends Request
|
||||
|
||||
$context = $this->getTokenContent();
|
||||
|
||||
if(isset($context['institution_id']))
|
||||
if(isset($context['institution_id'])) {
|
||||
$input['institution_id'] = $context['institution_id'];
|
||||
}
|
||||
|
||||
$input["redirect"] = isset($context["is_react"]) && $context['is_react'] ? config('ninja.react_url') . "/#/settings/bank_accounts" : config('ninja.app_url');
|
||||
|
||||
|
@ -44,11 +44,11 @@ class StorePaymentRequest extends Request
|
||||
$user = auth()->user();
|
||||
|
||||
$rules = [
|
||||
'client_id' => ['bail','required',Rule::exists('clients','id')->where('company_id',$user->company()->id)->where('is_deleted', 0)],
|
||||
'client_id' => ['bail','required',Rule::exists('clients', 'id')->where('company_id', $user->company()->id)->where('is_deleted', 0)],
|
||||
'invoices' => ['bail','sometimes', 'nullable', 'array', new ValidPayableInvoicesRule()],
|
||||
'invoices.*.amount' => ['bail','required'],
|
||||
'invoices.*.invoice_id' => ['bail','required','distinct', new ValidInvoicesRules($this->all()),Rule::exists('invoices','id')->where('company_id', $user->company()->id)->where('client_id', $this->client_id)],
|
||||
'credits.*.credit_id' => ['bail','required','distinct', new ValidCreditsRules($this->all()),Rule::exists('credits','id')->where('company_id', $user->company()->id)->where('client_id', $this->client_id)],
|
||||
'invoices.*.invoice_id' => ['bail','required','distinct', new ValidInvoicesRules($this->all()),Rule::exists('invoices', 'id')->where('company_id', $user->company()->id)->where('client_id', $this->client_id)],
|
||||
'credits.*.credit_id' => ['bail','required','distinct', new ValidCreditsRules($this->all()),Rule::exists('credits', 'id')->where('company_id', $user->company()->id)->where('client_id', $this->client_id)],
|
||||
'credits.*.amount' => ['bail','required', new CreditsSumRule($this->all())],
|
||||
'amount' => ['bail', 'numeric', new PaymentAmountsBalanceRule(), 'max:99999999999999'],
|
||||
'number' => ['bail', 'nullable', Rule::unique('payments')->where('company_id', $user->company()->id)],
|
||||
@ -59,7 +59,7 @@ class StorePaymentRequest extends Request
|
||||
$rules['documents.*'] = $this->fileValidation();
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->fileValidation();
|
||||
}else {
|
||||
} else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
|
@ -40,14 +40,14 @@ class UpdatePaymentRequest extends Request
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
|
||||
$rules = [
|
||||
'client_id' => ['sometimes', 'bail', Rule::in([$this->payment->client_id])],
|
||||
'number' => ['sometimes', 'bail', Rule::unique('payments')->where('company_id', $user->company()->id)->ignore($this->payment->id)],
|
||||
'invoices' => ['sometimes', 'bail', 'nullable', 'array', new PaymentAppliedValidAmount($this->all())],
|
||||
'invoices.*.invoice_id' => ['sometimes','distinct',Rule::exists('invoices','id')->where('company_id', $user->company()->id)->where('client_id', $this->payment->client_id)],
|
||||
'invoices.*.invoice_id' => ['sometimes','distinct',Rule::exists('invoices', 'id')->where('company_id', $user->company()->id)->where('client_id', $this->payment->client_id)],
|
||||
'invoices.*.amount' => ['sometimes','numeric','min:0'],
|
||||
'credits.*.credit_id' => ['sometimes','bail','distinct',Rule::exists('credits','id')->where('company_id', $user->company()->id)->where('client_id', $this->payment->client_id)],
|
||||
'credits.*.credit_id' => ['sometimes','bail','distinct',Rule::exists('credits', 'id')->where('company_id', $user->company()->id)->where('client_id', $this->payment->client_id)],
|
||||
'credits.*.amount' => ['required', 'bail'],
|
||||
];
|
||||
|
||||
@ -55,7 +55,7 @@ class UpdatePaymentRequest extends Request
|
||||
$rules['documents.*'] = $this->fileValidation();
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->fileValidation();
|
||||
}else {
|
||||
} else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ class StoreProductRequest extends Request
|
||||
$rules['documents.*'] = $this->fileValidation();
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->fileValidation();
|
||||
}else {
|
||||
} else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ class UpdateProductRequest extends Request
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
@ -38,7 +38,7 @@ class UpdateProductRequest extends Request
|
||||
$rules['documents.*'] = $this->fileValidation();
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->fileValidation();
|
||||
}else {
|
||||
} else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ class StoreProjectRequest extends Request
|
||||
$rules['documents.*'] = $this->fileValidation();
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->fileValidation();
|
||||
}else {
|
||||
} else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
@ -75,8 +75,9 @@ class StoreProjectRequest extends Request
|
||||
$input['color'] = '';
|
||||
}
|
||||
|
||||
if(array_key_exists('budgeted_hours', $input) && empty($input['budgeted_hours']))
|
||||
if(array_key_exists('budgeted_hours', $input) && empty($input['budgeted_hours'])) {
|
||||
$input['budgeted_hours'] = 0;
|
||||
}
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class UpdateProjectRequest extends Request
|
||||
$rules['documents.*'] = $this->fileValidation();
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->fileValidation();
|
||||
}else {
|
||||
} else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ class UpdateProjectRequest extends Request
|
||||
if (array_key_exists('color', $input) && is_null($input['color'])) {
|
||||
$input['color'] = '';
|
||||
}
|
||||
|
||||
|
||||
if(array_key_exists('budgeted_hours', $input) && empty($input['budgeted_hours'])) {
|
||||
$input['budgeted_hours'] = 0;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class StorePurchaseOrderRequest extends Request
|
||||
|
||||
$rules['number'] = ['nullable', Rule::unique('purchase_orders')->where('company_id', $user->company()->id)];
|
||||
|
||||
$rules['discount'] = 'sometimes|numeric|max:99999999999999';
|
||||
$rules['discount'] = 'sometimes|numeric|max:99999999999999';
|
||||
$rules['is_amount_discount'] = ['boolean'];
|
||||
$rules['line_items'] = 'array';
|
||||
|
||||
|
@ -53,14 +53,14 @@ class UpdatePurchaseOrderRequest extends Request
|
||||
|
||||
$rules['line_items'] = 'array';
|
||||
|
||||
$rules['discount'] = 'sometimes|numeric|max:99999999999999';
|
||||
$rules['discount'] = 'sometimes|numeric|max:99999999999999';
|
||||
$rules['is_amount_discount'] = ['boolean'];
|
||||
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->fileValidation();
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->fileValidation();
|
||||
}else {
|
||||
} else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
|
@ -43,13 +43,13 @@ class StoreQuoteRequest extends Request
|
||||
|
||||
$rules = [];
|
||||
|
||||
$rules['client_id'] = ['required', 'bail', Rule::exists('clients','id')->where('company_id', $user->company()->id)];
|
||||
$rules['client_id'] = ['required', 'bail', Rule::exists('clients', 'id')->where('company_id', $user->company()->id)];
|
||||
|
||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||
$rules['documents.*'] = $this->fileValidation();
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->fileValidation();
|
||||
}else {
|
||||
} else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ class StoreQuoteRequest extends Request
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
|
||||
$input = $this->all();
|
||||
|
||||
$input = $this->decodePrimaryKeys($input);
|
||||
@ -98,12 +98,13 @@ class StoreQuoteRequest extends Request
|
||||
$input['partial_due_date'] = null;
|
||||
}
|
||||
|
||||
if(!isset($input['date']))
|
||||
if(!isset($input['date'])) {
|
||||
$input['date'] = now()->addSeconds($user->company()->utc_offset())->format('Y-m-d');
|
||||
}
|
||||
|
||||
if(isset($input['partial_due_date']) && (!isset($input['due_date']) || strlen($input['due_date']) <=1 )) {
|
||||
if(isset($input['partial_due_date']) && (!isset($input['due_date']) || strlen($input['due_date']) <= 1)) {
|
||||
$client = \App\Models\Client::withTrashed()->find($input['client_id']);
|
||||
$valid_days = ($client && strlen($client->getSetting('valid_until')) >= 1) ? $client->getSetting('valid_until') : 7;
|
||||
$valid_days = ($client && strlen($client->getSetting('valid_until')) >= 1) ? $client->getSetting('valid_until') : 7;
|
||||
$input['due_date'] = \Carbon\Carbon::parse($input['date'])->addDays($valid_days)->format('Y-m-d');
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ class UpdateQuoteRequest extends Request
|
||||
$rules['documents.*'] = $this->fileValidation();
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->fileValidation();
|
||||
}else {
|
||||
} else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ class StoreRecurringInvoiceRequest extends Request
|
||||
$rules['documents.*'] = $this->fileValidation();
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->fileValidation();
|
||||
}else {
|
||||
} else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ class UpdateRecurringInvoiceRequest extends Request
|
||||
$rules['documents.*'] = $this->fileValidation();
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->fileValidation();
|
||||
}else {
|
||||
} else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
|
@ -68,8 +68,8 @@ class GenericReportRequest extends Request
|
||||
|
||||
$input['user_id'] = auth()->user()->id;
|
||||
|
||||
if(!$this->checkAuthority()){
|
||||
$input['date_range'] = '';
|
||||
if(!$this->checkAuthority()) {
|
||||
$input['date_range'] = '';
|
||||
$input['start_date'] = '';
|
||||
$input['end_date'] = '';
|
||||
$input['send_email'] = true;
|
||||
@ -85,7 +85,7 @@ class GenericReportRequest extends Request
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
|
||||
return $user->isAdmin() || $user->hasPermission('view_reports');
|
||||
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class ProductSalesReportRequest extends Request
|
||||
|
||||
public function rules()
|
||||
{
|
||||
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
@ -82,8 +82,8 @@ class ProductSalesReportRequest extends Request
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
if(Ninja::isHosted() && $user->account->isFreeHostedClient()){
|
||||
|
||||
if(Ninja::isHosted() && $user->account->isFreeHostedClient()) {
|
||||
$this->error_message = ctrans('texts.upgrade_to_view_reports');
|
||||
return false;
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ use Illuminate\Auth\Access\AuthorizationException;
|
||||
|
||||
class ProfitLossRequest extends Request
|
||||
{
|
||||
|
||||
private string $error_message = '';
|
||||
|
||||
/**
|
||||
@ -54,14 +53,14 @@ class ProfitLossRequest extends Request
|
||||
$this->replace($input);
|
||||
}
|
||||
|
||||
private function checkAuthority()
|
||||
private function checkAuthority()
|
||||
{
|
||||
$this->error_message = ctrans('texts.authorization_failure');
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
if(Ninja::isHosted() && $user->account->isFreeHostedClient()){
|
||||
|
||||
if(Ninja::isHosted() && $user->account->isFreeHostedClient()) {
|
||||
$this->error_message = ctrans('texts.upgrade_to_view_reports');
|
||||
return false;
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ class ReportPreviewRequest extends Request
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
if(Ninja::isHosted() && $user->account->isFreeHostedClient()){
|
||||
|
||||
if(Ninja::isHosted() && $user->account->isFreeHostedClient()) {
|
||||
$this->error_message = ctrans('texts.upgrade_to_view_reports');
|
||||
return false;
|
||||
}
|
||||
|
@ -33,11 +33,12 @@ class Request extends FormRequest
|
||||
|
||||
public function fileValidation()
|
||||
{
|
||||
if(config('ninja.upload_extensions'))
|
||||
if(config('ninja.upload_extensions')) {
|
||||
return $this->file_validation. ",".config('ninja.upload_extensions');
|
||||
}
|
||||
|
||||
return $this->file_validation;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function globalRules($rules)
|
||||
@ -46,9 +47,10 @@ class Request extends FormRequest
|
||||
|
||||
foreach ($this->all() as $key => $value) {
|
||||
|
||||
if($key == 'user')
|
||||
if($key == 'user') {
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
if (method_exists($this, $key)) {
|
||||
$merge_rules = $this->{$key}($rules);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class CheckSmtpRequest extends Request
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
|
||||
return $user->isAdmin();
|
||||
}
|
||||
|
||||
@ -44,28 +44,27 @@ class CheckSmtpRequest extends Request
|
||||
}
|
||||
|
||||
public function prepareForValidation()
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
$company = $user->company();
|
||||
|
||||
$input = $this->input();
|
||||
|
||||
if(isset($input['smtp_username']) && $input['smtp_username'] == '********'){
|
||||
if(isset($input['smtp_username']) && $input['smtp_username'] == '********') {
|
||||
// unset($input['smtp_username']);
|
||||
$input['smtp_username'] = $company->smtp_username;
|
||||
}
|
||||
|
||||
if(isset($input['smtp_password'])&& $input['smtp_password'] == '********'){
|
||||
if(isset($input['smtp_password']) && $input['smtp_password'] == '********') {
|
||||
// unset($input['smtp_password']);
|
||||
$input['smtp_password'] = $company->smtp_password;
|
||||
}
|
||||
|
||||
if(isset($input['smtp_host']) && strlen($input['smtp_host']) >=3){
|
||||
if(isset($input['smtp_host']) && strlen($input['smtp_host']) >= 3) {
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$input['smtp_host'] = $company->smtp_host;
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ class StoreTaskRequest extends Request
|
||||
$rules['documents.*'] = $this->fileValidation();
|
||||
} elseif ($this->file('documents')) {
|
||||
$rules['documents'] = $this->fileValidation();
|
||||
}else {
|
||||
} else {
|
||||
$rules['documents'] = 'bail|sometimes|array';
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user