diff --git a/VERSION.txt b/VERSION.txt index e84a0af153..cc6288ce32 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.10.38 \ No newline at end of file +5.10.39 \ No newline at end of file diff --git a/app/Console/Commands/CreateSingleAccount.php b/app/Console/Commands/CreateSingleAccount.php index 444fe2dd77..ec85679482 100644 --- a/app/Console/Commands/CreateSingleAccount.php +++ b/app/Console/Commands/CreateSingleAccount.php @@ -385,9 +385,12 @@ class CreateSingleAccount extends Command }); - $this->countryClients($company, $user); + $cc = ClientContact::where('company_id', $company->id)->latest()->first(); + $cc->email = 'user@example.com'; + $cc->save(); + $this->info("finished"); } @@ -472,13 +475,13 @@ class CreateSingleAccount extends Command 'company_id' => $company->id, ]); - ClientContact::factory()->create([ - 'user_id' => $user->id, - 'client_id' => $client->id, - 'company_id' => $company->id, - 'is_primary' => 1, - 'email' => 'user@example.com', - ]); + // ClientContact::factory()->create([ + // 'user_id' => $user->id, + // 'client_id' => $client->id, + // 'company_id' => $company->id, + // 'is_primary' => 1, + // 'email' => 'user@example.com', + // ]); ClientContact::factory()->count(rand(1, 2))->create([ 'user_id' => $user->id, @@ -490,7 +493,6 @@ class CreateSingleAccount extends Command $settings = $client->settings; $settings->currency_id = "1"; - // $settings->use_credits_payment = "always"; $client->settings = $settings; diff --git a/app/Http/Controllers/BaseController.php b/app/Http/Controllers/BaseController.php index 873bab7114..1fea58e073 100644 --- a/app/Http/Controllers/BaseController.php +++ b/app/Http/Controllers/BaseController.php @@ -610,6 +610,7 @@ class BaseController extends Controller if (! $user->isAdmin()) { $query->where('activities.user_id', $user->id); } + $query->whereColumn('companies.account_id', 'activities.account_id'); }, 'company.bank_integrations' => function ($query) use ($user) { if (! $user->hasPermission('view_bank_transaction')) { diff --git a/app/Http/Controllers/ClientPortal/InvoiceController.php b/app/Http/Controllers/ClientPortal/InvoiceController.php index 1f9555523b..006ae9e268 100644 --- a/app/Http/Controllers/ClientPortal/InvoiceController.php +++ b/app/Http/Controllers/ClientPortal/InvoiceController.php @@ -91,7 +91,6 @@ class InvoiceController extends Controller return auth()->guard('contact')->user()->client->getSetting('payment_flow') == 'default' ? $this->render('invoices.show', $data) : $this->render('invoices.show_smooth', $data); - // return $this->render('invoices.show_smooth', $data); } public function showBlob($hash) diff --git a/app/Http/Controllers/SubdomainController.php b/app/Http/Controllers/SubdomainController.php index 345e6ddb9e..d92130a9ad 100644 --- a/app/Http/Controllers/SubdomainController.php +++ b/app/Http/Controllers/SubdomainController.php @@ -25,13 +25,20 @@ class SubdomainController extends BaseController */ public function index() { + + $user = auth()->user(); + $company = $user->company(); + + if($company->subdomain == trim(request()->input('subdomain'))){ + return response()->json(['message' => 'Current subdomain name.'], 200); + } + if (!MultiDB::checkDomainAvailable(request()->input('subdomain'))) { return response()->json(['message' => ctrans('texts.subdomain_is_not_available')], 401); } - if (!preg_match('/^[A-Za-z0-9](?:[A-Za-z0-9\-]{0,61}[A-Za-z0-9])?$/', request()->input('subdomain'))) { - return response()->json(['message' => ctrans('texts.subdomain_is_not_available')], 401); + return response()->json(['message' => "Invalid subdomain format."], 401); } diff --git a/app/Http/Middleware/CheckClientExistence.php b/app/Http/Middleware/CheckClientExistence.php index 34a3666e4f..33ed398664 100644 --- a/app/Http/Middleware/CheckClientExistence.php +++ b/app/Http/Middleware/CheckClientExistence.php @@ -66,7 +66,6 @@ class CheckClientExistence } session()->put('multiple_contacts', $multiple_contacts); - session()->put('is_silent', request()->has('silent')); return $next($request); diff --git a/app/Http/Requests/Company/UpdateCompanyRequest.php b/app/Http/Requests/Company/UpdateCompanyRequest.php index 3f7300fb9b..60320cd16a 100644 --- a/app/Http/Requests/Company/UpdateCompanyRequest.php +++ b/app/Http/Requests/Company/UpdateCompanyRequest.php @@ -74,7 +74,7 @@ class UpdateCompanyRequest extends Request } if (Ninja::isHosted()) { - $rules['subdomain'] = ['nullable', 'regex:/^[a-zA-Z0-9.-]+[a-zA-Z0-9]$/', new ValidSubdomain()]; + $rules['subdomain'] = ['nullable', 'regex:/^[a-zA-Z0-9-]+[a-zA-Z0-9]$/', new ValidSubdomain()]; } $rules['expense_mailbox'] = ['sometimes','email', 'nullable', new ValidExpenseMailbox(), Rule::unique('companies')->ignore($this->company->id)]; diff --git a/app/Livewire/Flow2/InvoicePay.php b/app/Livewire/Flow2/InvoicePay.php index 811b168385..10f7af50b2 100644 --- a/app/Livewire/Flow2/InvoicePay.php +++ b/app/Livewire/Flow2/InvoicePay.php @@ -105,15 +105,12 @@ class InvoicePay extends Component #[On('terms-accepted')] public function termsAccepted() { - nlog("Terms accepted"); - // $this->invite = \App\Models\InvoiceInvitation::withTrashed()->find($this->invitation_id)->withoutRelations(); $this->terms_accepted = true; } #[On('signature-captured')] public function signatureCaptured($base64) { - nlog("signature captured"); $this->signature_accepted = true; $invite = \App\Models\InvoiceInvitation::withTrashed()->find($this->invitation_id); @@ -141,7 +138,6 @@ class InvoicePay extends Component $this->setContext('amount', $amount); $this->setContext('pre_payment', false); $this->setContext('is_recurring', false); - $this->setContext('invitation_id', $this->invitation_id); $this->payment_method_accepted = true; @@ -178,9 +174,7 @@ class InvoicePay extends Component empty($contact->client->{$_field}) || is_null($contact->client->{$_field}) //@phpstan-ignore-line ) { - return $this->required_fields = true; - } } @@ -190,7 +184,7 @@ class InvoicePay extends Component } } } - + return $this->required_fields = false; } @@ -231,17 +225,20 @@ class InvoicePay extends Component public function mount() { + $this->resetContext(); MultiDB::setDb($this->db); // @phpstan-ignore-next-line $invite = \App\Models\InvoiceInvitation::with('contact.client', 'company')->withTrashed()->find($this->invitation_id); + $client = $invite->contact->client; $settings = $client->getMergedSettings(); $this->setContext('contact', $invite->contact); // $this->context['contact'] = $invite->contact; $this->setContext('settings', $settings); // $this->context['settings'] = $settings; $this->setContext('db', $this->db); // $this->context['db'] = $this->db; + $this->setContext('invitation_id', $this->invitation_id); if(is_array($this->invoices)) $this->invoices = Invoice::find($this->transformKeys($this->invoices)); @@ -292,9 +289,9 @@ class InvoicePay extends Component public function exception($e, $stopPropagation) { - + + app('sentry')->captureException($e); nlog($e->getMessage()); - $stopPropagation(); } diff --git a/app/Livewire/Flow2/PaymentMethod.php b/app/Livewire/Flow2/PaymentMethod.php index 780c51023c..8995c2676d 100644 --- a/app/Livewire/Flow2/PaymentMethod.php +++ b/app/Livewire/Flow2/PaymentMethod.php @@ -78,9 +78,7 @@ class PaymentMethod extends Component public function exception($e, $stopPropagation) { - - nlog($e->getMessage()); + app('sentry')->captureException($e); $stopPropagation(); - } } diff --git a/app/Livewire/Flow2/ProcessPayment.php b/app/Livewire/Flow2/ProcessPayment.php index 46efada6c0..33737ca4c5 100644 --- a/app/Livewire/Flow2/ProcessPayment.php +++ b/app/Livewire/Flow2/ProcessPayment.php @@ -87,6 +87,8 @@ class ProcessPayment extends Component public function exception($e, $stopPropagation) { + app('sentry')->captureException($e); + $errors = session()->get('errors', new \Illuminate\Support\ViewErrorBag()); $bag = new \Illuminate\Support\MessageBag(); diff --git a/app/Livewire/Flow2/RequiredFields.php b/app/Livewire/Flow2/RequiredFields.php index 4f8fa23ba7..ce21e40c65 100644 --- a/app/Livewire/Flow2/RequiredFields.php +++ b/app/Livewire/Flow2/RequiredFields.php @@ -61,12 +61,12 @@ class RequiredFields extends Component $this->fields = $this->getContext()['fields']; + $contact = auth()->guard('contact')->user(); + $this->company_gateway = CompanyGateway::withTrashed() ->with('company') ->find($this->getContext()['company_gateway_id']); - - $contact = auth()->guard('contact')->user(); - + $this->client_name = $contact->client->name; $this->contact_first_name = $contact->first_name; $this->contact_last_name = $contact->last_name; @@ -138,9 +138,8 @@ class RequiredFields extends Component public function exception($e, $stopPropagation) { - + app('sentry')->captureException($e); nlog($e->getMessage()); - $stopPropagation(); } diff --git a/app/Models/Company.php b/app/Models/Company.php index 3e36b1b65e..495c9ef869 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -577,8 +577,8 @@ class Company extends BaseModel } public function activities(): HasMany - { - return $this->hasMany(Activity::class)->where('account_id', $this->account_id)->orderBy('id', 'DESC')->take(50); + { + return $this->hasMany(Activity::class)->orderBy('id', 'DESC')->take(50); } /** diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 38a7e9123d..704fa8158e 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -467,7 +467,7 @@ class Invoice extends BaseModel public function isPayable(): bool { - if($this->is_deleted || $this->status_id == self::STATUS_PAID) { + if($this->is_deleted || $this->status_id == self::STATUS_PAID || $this->balance < 0) { return false; } elseif ($this->status_id == self::STATUS_DRAFT && $this->is_deleted == false) { return true; diff --git a/app/Services/EDocument/Imports/Ubl2Pdf.php b/app/Services/EDocument/Imports/Ubl2Pdf.php index 160b4c82b0..e1c46c3936 100644 --- a/app/Services/EDocument/Imports/Ubl2Pdf.php +++ b/app/Services/EDocument/Imports/Ubl2Pdf.php @@ -281,4 +281,4 @@ class Ubl2Pdf extends AbstractService // return $c->code === $currency_code; // })?->id ?? (int) $this->company->settings->currency_id; // } -// } \ No newline at end of file +} diff --git a/config/ninja.php b/config/ninja.php index 2b74c28d07..1c7962a609 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -17,8 +17,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => env('APP_VERSION', '5.10.38'), - 'app_tag' => env('APP_TAG', '5.10.38'), + 'app_version' => env('APP_VERSION', '5.10.39'), + 'app_tag' => env('APP_TAG', '5.10.39'), 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', false), diff --git a/resources/views/portal/ninja2020/invoices/show.blade.php b/resources/views/portal/ninja2020/invoices/show.blade.php index f2a4e99b5a..94b50ab5c3 100644 --- a/resources/views/portal/ninja2020/invoices/show.blade.php +++ b/resources/views/portal/ninja2020/invoices/show.blade.php @@ -78,11 +78,14 @@