Updates for merge/purge activity events

This commit is contained in:
David Bomba 2025-08-28 16:14:13 +10:00
parent a936c09358
commit c2a2e0d8e9
4 changed files with 20 additions and 10 deletions

View File

@ -148,10 +148,15 @@ class ClientRepository extends BaseRepository
{ {
$purged_client = $client->present()->name(); $purged_client = $client->present()->name();
$purged_client_hash = $client->client_hash;
$user = auth()->user() ?? $client->user; $user = auth()->user() ?? $client->user;
$company = $client->company; $company = $client->company;
event(new \App\Events\Client\ClientWasPurged($purged_client, $user, $company, \App\Utils\Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); $event_vars = \App\Utils\Ninja::eventVars(auth()->user() ? auth()->user()->id : null);
$event_vars['client_hash'] = $purged_client_hash;
event(new \App\Events\Client\ClientWasPurged($purged_client, $user, $company, $event_vars));
nlog("Purging client id => {$client->id} => {$client->number}"); nlog("Purging client id => {$client->id} => {$client->number}");

View File

@ -45,6 +45,9 @@ class Merge extends AbstractService
nlog("balance post {$this->client->balance}"); nlog("balance post {$this->client->balance}");
nlog("paid_to_date post {$this->client->paid_to_date}"); nlog("paid_to_date post {$this->client->paid_to_date}");
$event_vars = \App\Utils\Ninja::eventVars(auth()->user() ? auth()->user()->id : null);
$event_vars['client_hash'] = $this->mergable_client->client_hash;
$this->updateLedger($this->mergable_client->balance); $this->updateLedger($this->mergable_client->balance);
$this->mergable_client->activities()->update(['client_id' => $this->client->id]); $this->mergable_client->activities()->update(['client_id' => $this->client->id]);
@ -79,7 +82,7 @@ class Merge extends AbstractService
$this->client->credit_balance = $this->client->service()->getCreditBalance(); $this->client->credit_balance = $this->client->service()->getCreditBalance();
$this->client->saveQuietly(); $this->client->saveQuietly();
event(new \App\Events\Client\ClientWasMerged($mergeable_client, $this->client, $this->client->company, \App\Utils\Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); event(new \App\Events\Client\ClientWasMerged($mergeable_client, $this->client, $this->client->company, $event_vars));
return $this->client; return $this->client;
} }

View File

@ -34,6 +34,8 @@ class Merge extends AbstractService
{ {
$_mergeable_vendor = $this->mergable_vendor->present()->name(); $_mergeable_vendor = $this->mergable_vendor->present()->name();
$event_vars = \App\Utils\Ninja::eventVars(auth()->user() ? auth()->user()->id : null);
$event_vars['vendor_hash'] = $this->mergable_vendor->vendor_hash;
$this->mergable_vendor->activities()->update(['vendor_id' => $this->vendor->id]); $this->mergable_vendor->activities()->update(['vendor_id' => $this->vendor->id]);
$this->mergable_vendor->contacts()->update(['vendor_id' => $this->vendor->id]); $this->mergable_vendor->contacts()->update(['vendor_id' => $this->vendor->id]);
@ -58,7 +60,7 @@ class Merge extends AbstractService
$this->mergable_vendor->forceDelete(); $this->mergable_vendor->forceDelete();
event(new \App\Events\Vendor\VendorWasMerged($_mergeable_vendor, $this->vendor, $this->vendor->company, \App\Utils\Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); event(new \App\Events\Vendor\VendorWasMerged($_mergeable_vendor, $this->vendor, $this->vendor->company, $event_vars));
return $this->vendor; return $this->vendor;
} }

14
composer.lock generated
View File

@ -19338,16 +19338,16 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "11.5.34", "version": "11.5.35",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "3e4c6ef395f7cb61a6206c23e0e04b31724174f2" "reference": "d341ee94ee5007b286fc7907b383aae6b5b3cc91"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3e4c6ef395f7cb61a6206c23e0e04b31724174f2", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d341ee94ee5007b286fc7907b383aae6b5b3cc91",
"reference": "3e4c6ef395f7cb61a6206c23e0e04b31724174f2", "reference": "d341ee94ee5007b286fc7907b383aae6b5b3cc91",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -19361,7 +19361,7 @@
"phar-io/manifest": "^2.0.4", "phar-io/manifest": "^2.0.4",
"phar-io/version": "^3.2.1", "phar-io/version": "^3.2.1",
"php": ">=8.2", "php": ">=8.2",
"phpunit/php-code-coverage": "^11.0.10", "phpunit/php-code-coverage": "^11.0.11",
"phpunit/php-file-iterator": "^5.1.0", "phpunit/php-file-iterator": "^5.1.0",
"phpunit/php-invoker": "^5.0.1", "phpunit/php-invoker": "^5.0.1",
"phpunit/php-text-template": "^4.0.1", "phpunit/php-text-template": "^4.0.1",
@ -19419,7 +19419,7 @@
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues", "issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy", "security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.34" "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.35"
}, },
"funding": [ "funding": [
{ {
@ -19443,7 +19443,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2025-08-20T14:41:45+00:00" "time": "2025-08-28T05:13:54+00:00"
}, },
{ {
"name": "react/cache", "name": "react/cache",