diff --git a/app/Models/EInvoicingToken.php b/app/Models/EInvoicingToken.php index 53f07949b6..f6d86b0514 100644 --- a/app/Models/EInvoicingToken.php +++ b/app/Models/EInvoicingToken.php @@ -24,4 +24,9 @@ class EInvoicingToken extends Model 'token', 'account_key', ]; + + public function license() + { + $this->belongsTo(License::class, 'license_key', 'license_key'); + } } diff --git a/app/Models/License.php b/app/Models/License.php index 70f6c3c361..6c4820662c 100644 --- a/app/Models/License.php +++ b/app/Models/License.php @@ -29,6 +29,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property int|null $product_id * @property int|null $recurring_invoice_id * @property int|null $e_invoice_quota + * @property bool $is_flagged * @property-read \App\Models\RecurringInvoice $recurring_invoice * @method static \Illuminate\Database\Eloquent\Builder|StaticModel company() * @method static \Illuminate\Database\Eloquent\Builder|StaticModel exclude($columns) @@ -73,6 +74,10 @@ class License extends StaticModel public function url() { $contact = $this->recurring_invoice->client->contacts()->where('email', $this->email)->first(); + } + public function e_invoicing_tokens() + { + return $this->hasMany(EInvoicingToken::class, 'license_key', 'license_key'); } } diff --git a/app/Services/EDocument/Jobs/SendEDocument.php b/app/Services/EDocument/Jobs/SendEDocument.php index 051940b37f..0f969cb042 100644 --- a/app/Services/EDocument/Jobs/SendEDocument.php +++ b/app/Services/EDocument/Jobs/SendEDocument.php @@ -53,6 +53,11 @@ class SendEDocument implements ShouldQueue $model = $this->entity::find($this->id); + if($model->company->account->is_flagged){ + nlog("Bad Actor"); + return; //Bad Actor present. + } + /** Concrete implementation current linked to Storecove only */ $p = new Peppol($model); $p->run(); diff --git a/database/migrations/2024_11_11_043923_kill_switch_licenses_table.php b/database/migrations/2024_11_11_043923_kill_switch_licenses_table.php new file mode 100644 index 0000000000..e0dd625a97 --- /dev/null +++ b/database/migrations/2024_11_11_043923_kill_switch_licenses_table.php @@ -0,0 +1,26 @@ +boolean('is_flagged')->default(0); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + // + } +};