Minor Updates

This commit is contained in:
David Bomba 2025-05-09 17:14:30 +10:00
parent 9954ce482e
commit 1e481e051b
7 changed files with 532 additions and 245 deletions

View File

@ -39,6 +39,7 @@ use App\Jobs\Invoice\InvoiceCheckLateWebhook;
use App\Jobs\Subscription\CleanStaleInvoiceOrder;
use App\PaymentDrivers\Rotessa\Jobs\TransactionReport;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use App\Console\Commands\CreateElasticIndex;
class Kernel extends ConsoleKernel
{
@ -155,4 +156,5 @@ class Kernel extends ConsoleKernel
require base_path('routes/console.php');
}
}

View File

@ -0,0 +1,63 @@
<?php
namespace App\Elastic\Index;
class EntityIndex
{
public array $mapping = [
'properties' => [
'id' => [ 'type' => 'text' ],
'name' => [ 'type' => 'text' ],
'hashed_id' => [ 'type' => 'text' ],
'number' => [ 'type' => 'text' ],
'is_deleted' => [ 'type' => 'boolean' ],
'amount' => [ 'type' => 'long' ],
'balance' => [ 'type' => 'long' ],
'due_date' => [ 'type' => 'date' ],
'date' => [ 'type' => 'date' ],
'custom_value1' => [ 'type' => 'text' ],
'custom_value2' => [ 'type' => 'text' ],
'custom_value3' => [ 'type' => 'text' ],
'custom_value4' => [ 'type' => 'text' ],
'company_key' => [ 'type' => 'text' ],
'po_number' => [ 'type' => 'text' ],
'line_items' => [
'type' => 'nested',
'properties' => [
'product_key' => [ 'type' => 'text' ],
'notes' => [ 'type' => 'text' ],
'cost' => [ 'type' => 'long' ],
'product_cost' => [ 'type' => 'long' ],
'is_amount_discount' => [ 'type' => 'boolean' ],
'line_total' => [ 'type' => 'long' ],
'gross_line_total' => [ 'type' => 'long' ],
'tax_amount' => [ 'type' => 'long' ],
'quantity' => [ 'type' => 'float' ],
'discount' => [ 'type' => 'float' ],
'tax_name1' => [ 'type' => 'text' ],
'tax_rate1' => [ 'type' => 'float' ],
'tax_name2' => [ 'type' => 'text' ],
'tax_rate2' => [ 'type' => 'float' ],
'tax_name3' => [ 'type' => 'text' ],
'tax_rate3' => [ 'type' => 'float' ],
'custom_value1' => [ 'type' => 'text' ],
'custom_value2' => [ 'type' => 'text' ],
'custom_value3' => [ 'type' => 'text' ],
'custom_value4' => [ 'type' => 'text' ],
'type_id' => [ 'type' => 'text' ],
'tax_id' => [ 'type' => 'text' ],
'task_id' => [ 'type' => 'text' ],
'expense_id' => [ 'type' => 'text' ],
'unit_code' => [ 'type' => 'text' ],
]
]
]
];
public function create(string $index_name): void
{
\Elastic\Migrations\Facades\Index::createRaw($index_name, $this->mapping);
}
}

View File

@ -22,6 +22,7 @@ class BlackListRule implements ValidationRule
{
/** Bad domains +/- disposable email domains */
private array $blacklist = [
"tabletship.com",
"tiktook.lol",
"0-mail.com",
"027168.com",

View File

@ -43,6 +43,6 @@ class PaymentBalanceActivity implements ShouldQueue
public function middleware($event): array
{
return [(new WithoutOverlapping($event->payment->client->client_hash))->releaseAfter(60)];
return [(new WithoutOverlapping($event->payment->client->client_hash))->releaseAfter(60)->expireAfter(60)];
}
}

View File

@ -13,7 +13,7 @@
namespace App\Models;
use App\Utils\Ninja;
use Laravel\Scout\Searchable;
use Elastic\ScoutDriverPlus\Searchable;
use Illuminate\Support\Carbon;
use App\DataMapper\InvoiceSync;
use App\Helpers\Invoice\InvoiceSum;
@ -149,6 +149,7 @@ class Invoice extends BaseModel
use ActionsInvoice;
use Searchable;
protected $presenter = EntityPresenter::class;
protected $touches = [];
@ -244,6 +245,11 @@ class Invoice extends BaseModel
public const STATUS_UNPAID = -2; //status < 4 || < 3 && !is_deleted && !trashed()
// public function searchableAs()
// {
// return 'invoices_index'; // for when we need to rename
// }
public function toSearchableArray()
{
$locale = $this->company->locale();
@ -265,6 +271,7 @@ class Invoice extends BaseModel
'custom_value4' => (string)$this->custom_value4,
'company_key' => $this->company->company_key,
'po_number' => (string)$this->po_number,
'line_items' => $this->line_items,
];
}
@ -456,6 +463,7 @@ class Invoice extends BaseModel
public function getStatusAttribute()
{
$due_date = $this->due_date ? Carbon::parse($this->due_date) : false;
$partial_due_date = $this->partial_due_date ? Carbon::parse($this->partial_due_date) : false;

View File

@ -42,7 +42,9 @@
"authorizenet/authorizenet": "^2.0",
"awobaz/compoships": "^2.1",
"aws/aws-sdk-php": "^3.319",
"babenkoivan/elastic-migrations": "^4.0",
"babenkoivan/elastic-scout-driver": "^4.0",
"babenkoivan/elastic-scout-driver-plus": "^5.1",
"bacon/bacon-qr-code": "^2.0",
"beganovich/snappdf": "dev-master",
"braintree/braintree_php": "^6.23",
@ -114,7 +116,8 @@
"twig/twig": "^3.14",
"twilio/sdk": "^6.40",
"wikimedia/composer-merge-plugin": "^2.1",
"wildbit/postmark-php": "^4.0"
"wildbit/postmark-php": "^4.0",
"invoiceninja/admin-api": "dev-main"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.6",
@ -224,9 +227,8 @@
"url": "https://github.com/turbo124/snappdf"
},
{
"type": "vcs",
"url": "https://github.com/invoiceninja/admin-api"
"type": "path",
"url": "../admin-api"
}
],
"minimum-stability": "dev",

689
composer.lock generated

File diff suppressed because it is too large Load Diff