varias alteracoes
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-06 14:50:12 +02:00
parent 4f35313d06
commit e65cb26901
333 changed files with 54656 additions and 2058 deletions
+9 -2
View File
@@ -17,6 +17,13 @@ class ConvertInterestToLead
{
return DB::transaction(function () use ($interest, $data, $actor) {
$interest = InterestRequest::lockForUpdate()->findOrFail($interest->id);
$contactConsentIsCurrent = DB::table('consents')->where('interest_request_id', $interest->id)
->where('subject_ref', $interest->reference)->where('purpose', 'respond_to_interest')
->where('status', 'granted')->whereNotNull('granted_at')->where('granted_at', '<=', now())
->whereNull('withdrawn_at')->whereNull('deleted_at')->lockForUpdate()->exists();
if (! $interest->privacy_consent || ! $contactConsentIsCurrent) {
throw ValidationException::withMessages(['investor_id' => 'O pedido não tem consentimento de contacto activo.']);
}
$existing = Lead::withTrashed()->where('interest_request_id', $interest->id)->first();
if ($existing) {
if ($existing->trashed()) {
@@ -25,8 +32,8 @@ class ConvertInterestToLead
return $existing;
}
if (! $interest->privacy_consent) {
throw ValidationException::withMessages(['investor_id' => 'O pedido não tem consentimento de contacto registado.']);
if (! is_string($interest->email) || trim($interest->email) === '') {
throw ValidationException::withMessages(['investor_id' => 'Confirme um email antes de converter este pedido telefonico num contacto/lead CRM.']);
}
$email = strtolower(trim($interest->email));
$journeyInvestor = DB::table('investor_journeys')->where('interest_request_id', $interest->id)->whereNull('deleted_at')->value('investor_id');