diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index 5c7ca4f4ff..d86d3ae563 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -499,6 +499,9 @@ class Import implements ShouldQueue $invoice_repository = new InvoiceMigrationRepository(); foreach ($data as $key => $resource) { + + info("importing recurring with key {$key}"); + $modified = $resource; if (array_key_exists('client_id', $resource) && ! array_key_exists('clients', $this->ids)) { diff --git a/app/Models/RecurringInvoiceInvitation.php b/app/Models/RecurringInvoiceInvitation.php index 6d3f7cca19..eec7d83fd6 100644 --- a/app/Models/RecurringInvoiceInvitation.php +++ b/app/Models/RecurringInvoiceInvitation.php @@ -11,11 +11,17 @@ namespace App\Models; +use App\Utils\Traits\Inviteable; +use App\Utils\Traits\MakesDates; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\SoftDeletes; class RecurringInvoiceInvitation extends BaseModel { - + use MakesDates; + use SoftDeletes; + use Inviteable; + protected $fillable = ['client_contact_id']; protected $touches = ['recurring_invoice']; diff --git a/app/Services/Recurring/CreateRecurringInvitations.php b/app/Services/Recurring/CreateRecurringInvitations.php index e511114aba..7c870a2172 100644 --- a/app/Services/Recurring/CreateRecurringInvitations.php +++ b/app/Services/Recurring/CreateRecurringInvitations.php @@ -12,8 +12,11 @@ namespace App\Services\Recurring; use App\Factory\InvoiceInvitationFactory; +use App\Factory\RecurringInvoiceFactory; use App\Models\Invoice; +use App\Models\RecurringInvoice; use App\Models\InvoiceInvitation; +use App\Models\RecurringInvoiceInvitation; use App\Services\AbstractService; use Illuminate\Support\Str; @@ -34,13 +37,14 @@ class CreateRecurringInvitations extends AbstractService $this->entity = $entity; $this->entity_name = lcfirst(Str::snake(class_basename($entity))); $this->entity_id_name = $this->entity_name . "_id"; - $this->invitation_class = Str::camel($this->entity_name); - $this->invitation_factory = $this->invitaiton_class . "Factory"; + $this->invitation_class = 'App\Models\\' . ucfirst(Str::camel($this->entity_name)) . "Invitation"; + $this->invitation_factory = 'App\Factory\\' . ucfirst(Str::camel($this->entity_name)) . "Factory"; } public function run() { $this->entity->client->contacts->each(function ($contact) { + $invitation = $this->invitation_class::whereCompanyId($this->entity->company_id) ->whereClientContactId($contact->id) ->where($this->entity_id_name, $this->entity->id) @@ -49,14 +53,15 @@ class CreateRecurringInvitations extends AbstractService if (! $invitation && $contact->send_email) { $ii = $this->invitation_factory::create($this->entity->company_id, $this->entity->user_id); - $ii->{$this->entity_id} = $this->entity->id; + $ii->{$this->entity_id_name} = $this->entity->id; $ii->client_contact_id = $contact->id; $ii->save(); } elseif ($invitation && ! $contact->send_email) { $invitation->delete(); } + }); return $this->entity; } -} +} \ No newline at end of file