Merge pull request #10601 from turbo124/v5-develop

v5.11.33
This commit is contained in:
David Bomba 2025-01-28 11:33:35 +11:00 committed by GitHub
commit 99d2652f89
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 252 additions and 169 deletions

View File

@ -1 +1 @@
5.11.32
5.11.33

View File

@ -417,6 +417,18 @@ class ClientGatewayTokenController extends BaseController
{
$this->client_gateway_token_repo->delete($client_gateway_token);
if($client_gateway_token->is_default) {
$cgt = ClientGatewayToken::where('client_id', $client_gateway_token->client_id)
->where('company_gateway_id', $client_gateway_token->company_gateway_id)
->first();
if($cgt){
$cgt->is_default = true;
$cgt->save();
}
}
return $this->itemResponse($client_gateway_token->fresh());
}

View File

@ -69,7 +69,6 @@ class AdjustProductInventory implements ShouldQueue
if ($p) {
$p->in_stock_quantity += $i->quantity;
$p->saveQuietly();
}
});

View File

@ -62,7 +62,6 @@ class ClientLedgerBalanceUpdate implements ShouldQueue
->where('client_id', $company_ledger->client_id)
->where('company_id', $company_ledger->company_id)
->whereNotNull('balance')
// ->where('balance', '!=', 0)
->orderBy('id', 'DESC')
->first();

View File

@ -243,7 +243,7 @@ class InvoiceService
public function markDeleted()
{
$this->removeUnpaidGatewayFees();
// $this->removeUnpaidGatewayFees();
$this->invoice = (new MarkInvoiceDeleted($this->invoice))->run();

View File

@ -64,10 +64,16 @@ class MarkInvoiceDeleted extends AbstractService
private function adjustPaidToDateAndBalance()
{
$ba = $this->balance_adjustment * -1;
$aa = $this->adjustment_amount * -1;
$cb = $this->invoice->client->balance;
nlog("APB => {$this->invoice->number} - BA={$ba} - AA={$aa} - CB={$cb}");
$this->invoice
->client
->service()
->updateBalanceAndPaidToDate($this->balance_adjustment * -1, $this->adjustment_amount * -1)
->updateBalanceAndPaidToDate($ba, $aa)
->save();
return $this;
@ -132,6 +138,18 @@ class MarkInvoiceDeleted extends AbstractService
$this->balance_adjustment = $this->invoice->balance;
$pre_count = count((array)$this->invoice->line_items);
$items = collect((array)$this->invoice->line_items)
->filter(function ($item) {
return $item->type_id != '3';
})->toArray();
if(count($items) < $pre_count) {
$this->invoice->line_items = array_values($items);
$this->invoice = $this->invoice->calc()->getInvoice();
}
return $this;
}

View File

@ -57,7 +57,7 @@ class LedgerService
$this->entity->company_ledger()->save($company_ledger);
ClientLedgerBalanceUpdate::dispatch($this->entity->company, $this->entity->client)->delay(rand(3, 7));
ClientLedgerBalanceUpdate::dispatch($this->entity->company, $this->entity->client);
return $this;
}
@ -73,7 +73,7 @@ class LedgerService
$this->entity->company_ledger()->save($company_ledger);
ClientLedgerBalanceUpdate::dispatch($this->entity->company, $this->entity->client)->delay(rand(1, 3));
ClientLedgerBalanceUpdate::dispatch($this->entity->company, $this->entity->client);
return $this;
}
@ -89,7 +89,7 @@ class LedgerService
$this->entity->company_ledger()->save($company_ledger);
ClientLedgerBalanceUpdate::dispatch($this->entity->company, $this->entity->client)->delay(rand(1, 3));
ClientLedgerBalanceUpdate::dispatch($this->entity->company, $this->entity->client);
return $this;
}

View File

@ -1993,34 +1993,44 @@ class PdfBuilder
return $element;
}
private function isMarkdown(string $content): bool
{
$content = str_ireplace('<br>', "\n", $content);
$markdownPatterns = [
'/^\s*#{1,6}\s/m', // Headers
'/^\s*[-+*]\s/m', // Lists
'/\[.*?\]\(.*?\)/', // Links
'/!\[.*?\]\(.*?\)/', // Images
'/\*\*.*?\*\*/', // Bold
'/\*.*?\*/', // Italic
'/__.*?__/', // Bold
'/_.*?_/', // Italic
'/`.*?`/', // Inline code
'/^\s*>/m', // Blockquotes
'/^\s*```/m', // Code blocks
];
// Check if any pattern matches the text
foreach ($markdownPatterns as $pattern) {
if (preg_match($pattern, $content)) {
return true;
}
}
return false;
}
public function createElementContent($element, $children): self
{
foreach ($children as $child) {
$contains_html = false;
$contains_markdown = false;
$child['content'] = $child['content'] ?? '';
$lines = explode("\n", $child['content']);
$contains_markdown = false;
foreach ($lines as $line) {
$trimmed = ltrim($line);
if (empty($trimmed)) {
continue;
}
$first_char = substr($trimmed, 0, 1);
if (in_array($first_char, ['#', '>', '-', '+', '*', '_', '`', '[']) || // Markdown characters
str_contains($trimmed, '**') // Bold (special case)
) {
$contains_markdown = true;
break;
}
}
if ($this->service->company->markdown_enabled && $contains_markdown && $child['element'] !== 'script') {
if ($this->service->company->markdown_enabled && $this->isMarkdown($child['content']) && $child['element'] !== 'script') {
$child['content'] = str_ireplace('<br>', "\r", $child['content']);
$child['content'] = $this->commonmark->convert($child['content']); //@phpstan-ignore-line
}

View File

@ -87,34 +87,43 @@ trait PdfMakerUtilities
return $element;
}
private function isMarkdown(string $content): bool
{
$content = str_ireplace('<br>', "\n", $content);
$markdownPatterns = [
'/^\s*#{1,6}\s/m', // Headers
'/^\s*[-+*]\s/m', // Lists
'/\[.*?\]\(.*?\)/', // Links
'/!\[.*?\]\(.*?\)/', // Images
'/\*\*.*?\*\*/', // Bold
'/\*.*?\*/', // Italic
'/__.*?__/', // Bold
'/_.*?_/', // Italic
'/`.*?`/', // Inline code
'/^\s*>/m', // Blockquotes
'/^\s*```/m', // Code blocks
];
// Check if any pattern matches the text
foreach ($markdownPatterns as $pattern) {
if (preg_match($pattern, $content)) {
return true;
}
}
return false;
}
public function createElementContent($element, $children)
{
foreach ($children as $child) {
$contains_html = false;
$contains_markdown = false;
$child['content'] = $child['content'] ?? '';
$lines = explode("\n", $child['content']);
$contains_markdown = false;
foreach ($lines as $line) {
$trimmed = ltrim($line);
if (empty($trimmed)) {
continue;
}
$first_char = substr($trimmed, 0, 1);
if (
in_array($first_char, ['#', '>', '-', '+', '*', '_', '`', '[']) || // Markdown characters
str_contains($trimmed, '**') // Bold (special case)
) {
$contains_markdown = true;
break;
}
}
if (isset($this->data['process_markdown']) && $this->data['process_markdown'] && $contains_markdown &&$child['element'] !== 'script') {
if (isset($this->data['process_markdown']) && $this->data['process_markdown'] && $this->isMarkdown($child['content']) && $child['element'] !== 'script') {
$child['content'] = str_replace('<br>', "\r", $child['content']);
$child['content'] = $this->commonmark->convert($child['content']); //@phpstan-ignore-line
}

View File

@ -37,7 +37,7 @@
"ext-json": "*",
"ext-libxml": "*",
"ext-simplexml": "*",
"afosto/yaac": "^1.4",
"afosto/yaac": "^1.5",
"asm/php-ansible": "dev-main",
"authorizenet/authorizenet": "^2.0",
"awobaz/compoships": "^2.1",

216
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "0fd554859df6ddb888c01b8ea86ac68b",
"content-hash": "a8c8a77c6cc5e0b0c046923603c2110a",
"packages": [
{
"name": "adrienrn/php-mimetyper",
@ -1400,6 +1400,85 @@
],
"time": "2025-01-08T16:17:16+00:00"
},
{
"name": "composer/pcre",
"version": "3.3.2",
"source": {
"type": "git",
"url": "https://github.com/composer/pcre.git",
"reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e",
"reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0"
},
"conflict": {
"phpstan/phpstan": "<1.11.10"
},
"require-dev": {
"phpstan/phpstan": "^1.12 || ^2",
"phpstan/phpstan-strict-rules": "^1 || ^2",
"phpunit/phpunit": "^8 || ^9"
},
"type": "library",
"extra": {
"phpstan": {
"includes": [
"extension.neon"
]
},
"branch-alias": {
"dev-main": "3.x-dev"
}
},
"autoload": {
"psr-4": {
"Composer\\Pcre\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "PCRE wrapping library that offers type-safe preg_* replacements.",
"keywords": [
"PCRE",
"preg",
"regex",
"regular expression"
],
"support": {
"issues": "https://github.com/composer/pcre/issues",
"source": "https://github.com/composer/pcre/tree/3.3.2"
},
"funding": [
{
"url": "https://packagist.com",
"type": "custom"
},
{
"url": "https://github.com/composer",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/composer/composer",
"type": "tidelift"
}
],
"time": "2024-11-12T16:29:46+00:00"
},
{
"name": "dasprid/enum",
"version": "1.0.6",
@ -2953,16 +3032,16 @@
},
{
"name": "google/apiclient-services",
"version": "v0.391.0",
"version": "v0.392.0",
"source": {
"type": "git",
"url": "https://github.com/googleapis/google-api-php-client-services.git",
"reference": "911ebf7a6b570780fb994c007344cf3da4187de6"
"reference": "a74c2790865bd1f06c0a49460ef1c0edb0be0e7e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/911ebf7a6b570780fb994c007344cf3da4187de6",
"reference": "911ebf7a6b570780fb994c007344cf3da4187de6",
"url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/a74c2790865bd1f06c0a49460ef1c0edb0be0e7e",
"reference": "a74c2790865bd1f06c0a49460ef1c0edb0be0e7e",
"shasum": ""
},
"require": {
@ -2991,9 +3070,9 @@
],
"support": {
"issues": "https://github.com/googleapis/google-api-php-client-services/issues",
"source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.391.0"
"source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.392.0"
},
"time": "2025-01-20T01:04:13+00:00"
"time": "2025-01-27T01:10:20+00:00"
},
{
"name": "google/auth",
@ -6903,31 +6982,32 @@
},
{
"name": "maennchen/zipstream-php",
"version": "3.1.1",
"version": "3.1.2",
"source": {
"type": "git",
"url": "https://github.com/maennchen/ZipStream-PHP.git",
"reference": "6187e9cc4493da94b9b63eb2315821552015fca9"
"reference": "aeadcf5c412332eb426c0f9b4485f6accba2a99f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/6187e9cc4493da94b9b63eb2315821552015fca9",
"reference": "6187e9cc4493da94b9b63eb2315821552015fca9",
"url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/aeadcf5c412332eb426c0f9b4485f6accba2a99f",
"reference": "aeadcf5c412332eb426c0f9b4485f6accba2a99f",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"ext-zlib": "*",
"php-64bit": "^8.1"
"php-64bit": "^8.2"
},
"require-dev": {
"brianium/paratest": "^7.7",
"ext-zip": "*",
"friendsofphp/php-cs-fixer": "^3.16",
"guzzlehttp/guzzle": "^7.5",
"mikey179/vfsstream": "^1.6",
"php-coveralls/php-coveralls": "^2.5",
"phpunit/phpunit": "^10.0",
"vimeo/psalm": "^5.0"
"phpunit/phpunit": "^11.0",
"vimeo/psalm": "^6.0"
},
"suggest": {
"guzzlehttp/psr7": "^2.4",
@ -6968,7 +7048,7 @@
],
"support": {
"issues": "https://github.com/maennchen/ZipStream-PHP/issues",
"source": "https://github.com/maennchen/ZipStream-PHP/tree/3.1.1"
"source": "https://github.com/maennchen/ZipStream-PHP/tree/3.1.2"
},
"funding": [
{
@ -6976,7 +7056,7 @@
"type": "github"
}
],
"time": "2024-10-10T12:33:01+00:00"
"time": "2025-01-27T12:07:53+00:00"
},
{
"name": "mailgun/mailgun-php",
@ -9459,19 +9539,20 @@
},
{
"name": "phpoffice/phpspreadsheet",
"version": "2.3.6",
"version": "2.3.7",
"source": {
"type": "git",
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
"reference": "098b848ee6688cb9a252d9ce97889defc517ee88"
"reference": "cf357183b1d17a3862e8e4b9b056a556654dcae6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/098b848ee6688cb9a252d9ce97889defc517ee88",
"reference": "098b848ee6688cb9a252d9ce97889defc517ee88",
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/cf357183b1d17a3862e8e4b9b056a556654dcae6",
"reference": "cf357183b1d17a3862e8e4b9b056a556654dcae6",
"shasum": ""
},
"require": {
"composer/pcre": "^3.2",
"ext-ctype": "*",
"ext-dom": "*",
"ext-fileinfo": "*",
@ -9557,9 +9638,9 @@
],
"support": {
"issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues",
"source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/2.3.6"
"source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/2.3.7"
},
"time": "2025-01-12T03:22:26+00:00"
"time": "2025-01-26T04:53:06+00:00"
},
{
"name": "phpoption/phpoption",
@ -17498,85 +17579,6 @@
],
"time": "2024-11-25T16:11:06+00:00"
},
{
"name": "composer/pcre",
"version": "3.3.2",
"source": {
"type": "git",
"url": "https://github.com/composer/pcre.git",
"reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e",
"reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0"
},
"conflict": {
"phpstan/phpstan": "<1.11.10"
},
"require-dev": {
"phpstan/phpstan": "^1.12 || ^2",
"phpstan/phpstan-strict-rules": "^1 || ^2",
"phpunit/phpunit": "^8 || ^9"
},
"type": "library",
"extra": {
"phpstan": {
"includes": [
"extension.neon"
]
},
"branch-alias": {
"dev-main": "3.x-dev"
}
},
"autoload": {
"psr-4": {
"Composer\\Pcre\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "PCRE wrapping library that offers type-safe preg_* replacements.",
"keywords": [
"PCRE",
"preg",
"regex",
"regular expression"
],
"support": {
"issues": "https://github.com/composer/pcre/issues",
"source": "https://github.com/composer/pcre/tree/3.3.2"
},
"funding": [
{
"url": "https://packagist.com",
"type": "custom"
},
{
"url": "https://github.com/composer",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/composer/composer",
"type": "tidelift"
}
],
"time": "2024-11-12T16:29:46+00:00"
},
{
"name": "composer/semver",
"version": "3.4.3",
@ -17905,16 +17907,16 @@
},
{
"name": "friendsofphp/php-cs-fixer",
"version": "v3.68.1",
"version": "v3.68.3",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "b9db2b2ea3cdba7201067acee46f984ef2397cff"
"reference": "85fd31cced824749a732e697acdd1a3d657312f0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/b9db2b2ea3cdba7201067acee46f984ef2397cff",
"reference": "b9db2b2ea3cdba7201067acee46f984ef2397cff",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/85fd31cced824749a732e697acdd1a3d657312f0",
"reference": "85fd31cced824749a732e697acdd1a3d657312f0",
"shasum": ""
},
"require": {
@ -17996,7 +17998,7 @@
],
"support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.68.1"
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.68.3"
},
"funding": [
{
@ -18004,7 +18006,7 @@
"type": "github"
}
],
"time": "2025-01-17T09:20:36+00:00"
"time": "2025-01-27T16:37:32+00:00"
},
{
"name": "hamcrest/hamcrest-php",

View File

@ -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.11.32'),
'app_tag' => env('APP_TAG', '5.11.32'),
'app_version' => env('APP_VERSION', '5.11.33'),
'app_tag' => env('APP_TAG', '5.11.33'),
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', false),

View File

@ -10,16 +10,49 @@ return new class extends Migration {
*/
public function up(): void
{
// Schema::table('companies', function (Blueprint $table) {
// $table->boolean("expense_mailbox_active")->default(false);
// $table->string("expense_mailbox")->nullable();
// $table->boolean("inbound_mailbox_allow_company_users")->default(false);
// $table->boolean("inbound_mailbox_allow_vendors")->default(false);
// $table->boolean("inbound_mailbox_allow_clients")->default(false);
// $table->boolean("inbound_mailbox_allow_unknown")->default(false);
// $table->text("inbound_mailbox_whitelist")->nullable();
// $table->text("inbound_mailbox_blacklist")->nullable();
// });
Schema::table('companies', function (Blueprint $table) {
$table->boolean("expense_mailbox_active")->default(false);
$table->string("expense_mailbox")->nullable();
$table->boolean("inbound_mailbox_allow_company_users")->default(false);
$table->boolean("inbound_mailbox_allow_vendors")->default(false);
$table->boolean("inbound_mailbox_allow_clients")->default(false);
$table->boolean("inbound_mailbox_allow_unknown")->default(false);
$table->text("inbound_mailbox_whitelist")->nullable();
$table->text("inbound_mailbox_blacklist")->nullable();
if (!Schema::hasColumn('companies', 'expense_mailbox_active')) {
$table->boolean("expense_mailbox_active")->default(false);
}
if (!Schema::hasColumn('companies', 'expense_mailbox')) {
$table->string("expense_mailbox")->nullable();
}
if (!Schema::hasColumn('companies', 'inbound_mailbox_allow_company_users')) {
$table->boolean("inbound_mailbox_allow_company_users")->default(false);
}
if (!Schema::hasColumn('companies', 'inbound_mailbox_allow_vendors')) {
$table->boolean("inbound_mailbox_allow_vendors")->default(false);
}
if (!Schema::hasColumn('companies', 'inbound_mailbox_allow_clients')) {
$table->boolean("inbound_mailbox_allow_clients")->default(false);
}
if (!Schema::hasColumn('companies', 'inbound_mailbox_allow_unknown')) {
$table->boolean("inbound_mailbox_allow_unknown")->default(false);
}
if (!Schema::hasColumn('companies', 'inbound_mailbox_whitelist')) {
$table->text("inbound_mailbox_whitelist")->nullable();
}
if (!Schema::hasColumn('companies', 'inbound_mailbox_blacklist')) {
$table->text("inbound_mailbox_blacklist")->nullable();
}
});
}
/**

View File

@ -6,6 +6,7 @@ parameters:
level: 5
paths:
- app
- vendor/invoiceninja/admin-api
- Modules
excludePaths:
analyseAndScan: