Skip to content

Commit

Permalink
Merge pull request invoiceninja#10158 from turbo124/v5-develop
Browse files Browse the repository at this point in the history
v5.10.41
  • Loading branch information
turbo124 authored Oct 18, 2024
2 parents d6d9d7d + 61cb67e commit cc66f54
Show file tree
Hide file tree
Showing 46 changed files with 737 additions and 146 deletions.
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.10.40
5.10.41
9 changes: 9 additions & 0 deletions app/Filters/ExpenseFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,15 @@ public function categories(string $categories = ''): Builder
return $this->builder->whereIn('category_id', $categories_keys);
}

public function amount(string $amount = ''): Builder
{
if (strlen($amount) == 0) {
return $this->builder;
}

return $this->builder->where('amount', $amount);
}

public function number(string $number = ''): Builder
{
if (strlen($number) == 0) {
Expand Down
20 changes: 18 additions & 2 deletions app/Http/Controllers/LicenseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ public function index()
{
$this->checkLicense();

nlog("License Check::");
nlog(config('ninja.environment'));
nlog(request()->has('license_key'));
nlog(request()->input('license_key','No License Found'));

/* Catch claim license requests */
if (config('ninja.environment') == 'selfhost' && request()->has('license_key')) {
$license_key = trim(request()->input('license_key'));
Expand Down Expand Up @@ -144,6 +149,8 @@ public function index()
}
}

nlog("No license key or environment not set to selfhost");

$error = [
'message' => ctrans('texts.invoice_license_or_environment', ['environment' => config('ninja.environment')]),
'errors' => new stdClass(),
Expand All @@ -156,15 +163,22 @@ public function v5ClaimLicense(string $license_key)
{
$this->checkLicense();

/* Catch claim license requests */
/* Catch claim license requests */
if (config('ninja.environment') == 'selfhost') {

nlog("Claiming v5 license");

$response = Http::get("https://invoicing.co/claim_license", [
'license_key' => $license_key,
'product_id' => 3,
]);

$payload = $response->json();

nlog("Ninja Server Response");
nlog($payload);

if ($response->successful()) {
$payload = $response->json();

$account = auth()->user()->account;

Expand All @@ -189,6 +203,8 @@ public function v5ClaimLicense(string $license_key)
}
}

nlog("Environment not set to selfhost - failing");

$error = [
'message' => ctrans('texts.invoice_license_or_environment', ['environment' => config('ninja.environment')]),
'errors' => new stdClass(),
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/SmtpController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function check(CheckSmtpRequest $request)
$company = $user->company();

$smtp_host = $request->input('smtp_host', $company->smtp_host);
$smtp_port = $request->input('smtp_port', $company->smtp_port);
$smtp_port = (int)$request->input('smtp_port', $company->smtp_port);
$smtp_username = $request->input('smtp_username', $company->smtp_username);
$smtp_password = $request->input('smtp_password', $company->smtp_password);
$smtp_encryption = $request->input('smtp_encryption', $company->smtp_encryption ?? 'tls');
Expand Down
1 change: 0 additions & 1 deletion app/Http/Middleware/CheckClientExistence.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public function handle(Request $request, Closure $next)
auth()->guard('contact')->user()->loadMissing(['company']); // @phpstan-ignore method.notFound

$multiple_contacts = ClientContact::query()
// ->with('client.gateway_tokens', 'company')
->where('email', auth()->guard('contact')->user()->email)
->whereNotNull('email')
->where('email', '<>', '')
Expand Down
3 changes: 1 addition & 2 deletions app/Jobs/EDocument/ImportEDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function handle(): Expense

public function middleware()
{
return [new WithoutOverlapping($this->company->company_key)];
return [new WithoutOverlapping($this->company->company_key."_expense_import_".$this->file_name)];
}

public function failed($exception = null)
Expand All @@ -63,7 +63,6 @@ public function failed($exception = null)
}

$this->fail($exception); //manually fail - prevents future jobs with the same name from being discarded

config(['queue.failed.driver' => null]);
}
}
2 changes: 1 addition & 1 deletion app/Jobs/Mail/NinjaMailerJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ private function configureSmtpMailer()
$company = $this->company;

$smtp_host = $company->smtp_host ?? '';
$smtp_port = $company->smtp_port;
$smtp_port = (int)$company->smtp_port;
$smtp_username = $company->smtp_username ?? '';
$smtp_password = $company->smtp_password ?? '';
$smtp_encryption = $company->smtp_encryption ?? 'tls';
Expand Down
1 change: 1 addition & 0 deletions app/Jobs/Util/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -1571,6 +1571,7 @@ private function processDocuments(array $data): void


} catch(\Exception $e) {
nlog($e->getMessage());
//do nothing, gracefully :)
}
}
Expand Down
9 changes: 3 additions & 6 deletions app/Models/Expense.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,9 @@ class Expense extends BaseModel
];

public static array $bulk_update_columns = [
'tax_rate1',
'tax_name1',
'tax_rate2',
'tax_name2',
'tax_rate3',
'tax_name3',
'tax1',
'tax2',
'tax3',
'custom_value1',
'custom_value2',
'custom_value3',
Expand Down
4 changes: 2 additions & 2 deletions app/Models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function markdownNotes()
return $converter->convert($this->notes ?? '');
}

public static function markdownHelp(string $notes = '')
public static function markdownHelp(?string $notes = '')
{

$converter = new CommonMarkConverter([
Expand All @@ -226,7 +226,7 @@ public static function markdownHelp(string $notes = '')
],
]);

return $converter->convert($notes);
return $converter->convert($notes ?? '');

}

Expand Down
9 changes: 3 additions & 6 deletions app/Models/RecurringInvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,9 @@ class RecurringInvoice extends BaseModel
protected $touches = [];

public static array $bulk_update_columns = [
'tax_rate1',
'tax_name1',
'tax_rate2',
'tax_name2',
'tax_rate3',
'tax_name3',
'tax1',
'tax2',
'tax3',
'custom_value1',
'custom_value2',
'custom_value3',
Expand Down
11 changes: 6 additions & 5 deletions app/Repositories/BaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,23 +396,24 @@ protected function alternativeSave($data, $model)
public function bulkUpdate(\Illuminate\Database\Eloquent\Builder $model, string $column, mixed $new_value): void
{
/** Handle taxes being updated */
if(in_array($column, ['tax_name1','tax_name2','tax_name3'])) {
if(in_array($column, ['tax1','tax2','tax3'])) {

$parts = explode("||", $new_value);

if (count($parts) !== 2)
return;

$tax_name = trim($parts[0]);
$tax_name_column = str_replace("tax", "tax_name", $column);
$rate = filter_var($parts[1], FILTER_VALIDATE_FLOAT);

$tax_name = $parts[0];

if ($rate === false)
return;

$taxrate_column = str_replace("name", "rate", $column);
$taxrate_column = str_replace("tax", "tax_rate", $column);

$model->update([
$column => $tax_name,
$tax_name_column => $tax_name,
$taxrate_column => $rate,
]);
return;
Expand Down
2 changes: 1 addition & 1 deletion app/Repositories/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function save(array $data, User $user, $unset_company_user = false, $is_m
$user->confirmation_code = $this->createDbHash($company->db);
}

$user->account_id = $account->id;
$user->account_id = $account->id;//@todo we should never change the account_id if it is set at this point.

if (strlen($user->password) >= 1) {
$user->has_password = true;
Expand Down
3 changes: 3 additions & 0 deletions app/Services/Client/Merge.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public function run()

$this->mergable_client->forceDelete();

$this->client->credit_balance = $this->client->service()->getCreditBalance();
$this->client->saveQuietly();

return $this->client;
}

Expand Down
Loading

0 comments on commit cc66f54

Please sign in to comment.