diff --git a/app/Http/Controllers/BankIntegrationController.php b/app/Http/Controllers/BankIntegrationController.php index 774aa97057e8..aaa2ed88b5fe 100644 --- a/app/Http/Controllers/BankIntegrationController.php +++ b/app/Http/Controllers/BankIntegrationController.php @@ -687,7 +687,7 @@ class BankIntegrationController extends BaseController auth()->user()->account->bank_integrations->each(function ($bank_integration) { - ProcessBankTransactions::dispatchSync(auth()->user()->account->bank_integration_account_id, $bank_integration); + (new ProcessBankTransactions(auth()->user()->account->bank_integration_account_id, $bank_integration))->handle(); }); diff --git a/app/Http/Livewire/BillingPortalPurchasev2.php b/app/Http/Livewire/BillingPortalPurchasev2.php index bab495c2bfd6..dd1c29d6c287 100644 --- a/app/Http/Livewire/BillingPortalPurchasev2.php +++ b/app/Http/Livewire/BillingPortalPurchasev2.php @@ -332,6 +332,8 @@ class BillingPortalPurchasev2 extends Component $total = $p->price * $qty; $this->bundle->push([ + 'product_key' => $p->product_key, + 'unit_cost' => $p->price, 'product' => nl2br(substr($p->notes, 0, 50)), 'price' => Number::formatMoney($total, $this->subscription->company).' / '. RecurringInvoice::frequencyForKey($this->subscription->frequency_id), 'total' => $total, @@ -348,6 +350,8 @@ class BillingPortalPurchasev2 extends Component $total = $p->price * $qty; $this->bundle->push([ + 'product_key' => $p->product_key, + 'unit_cost' => $p->price, 'product' => nl2br(substr($p->notes, 0, 50)), 'price' => Number::formatMoney($total, $this->subscription->company), 'total' => $total, @@ -375,6 +379,8 @@ class BillingPortalPurchasev2 extends Component $this->bundle->push([ + 'product_key' => $p->product_key, + 'unit_cost' => $p->price, 'product' => nl2br(substr($p->notes, 0, 50)), 'price' => Number::formatMoney($total, $this->subscription->company).' / '. RecurringInvoice::frequencyForKey($this->subscription->frequency_id), 'total' => $total, @@ -398,6 +404,8 @@ class BillingPortalPurchasev2 extends Component return; $this->bundle->push([ + 'product_key' => $p->product_key, + 'unit_cost' => $p->price, 'product' => nl2br(substr($p->notes, 0, 50)), 'price' => Number::formatMoney($total, $this->subscription->company), 'total' => $total, @@ -503,19 +511,19 @@ class BillingPortalPurchasev2 extends Component { $this->payment_started = true; - // $data = [ - // 'client_id' => $this->contact->client->id, - // 'date' => now()->format('Y-m-d'), - // 'invitations' => [[ - // 'key' => '', - // 'client_contact_id' => $this->contact->hashed_id, - // ]], - // 'user_input_promo_code' => $this->coupon, - // 'coupon' => empty($this->subscription->promo_code) ? '' : $this->coupon, - // // 'quantity' => $this->quantity, - // ]; + $data = [ + 'client_id' => $this->contact->client->id, + 'date' => now()->format('Y-m-d'), + 'invitations' => [[ + 'key' => '', + 'client_contact_id' => $this->contact->hashed_id, + ]], + 'user_input_promo_code' => $this->coupon, + 'coupon' => empty($this->subscription->promo_code) ? '' : $this->coupon, + // 'quantity' => $this->quantity, + ]; - // $is_eligible = $this->subscription->service()->isEligible($this->contact); + $is_eligible = $this->subscription->service()->isEligible($this->contact); // if (is_array($is_eligible) && $is_eligible['message'] != 'Success') { // $this->steps['not_eligible'] = true; @@ -525,14 +533,14 @@ class BillingPortalPurchasev2 extends Component // return; // } - // $this->invoice = $this->subscription - // ->service() - // ->createInvoice($data, $this->quantity) - // ->service() - // ->markSent() - // ->fillDefaults() - // ->adjustInventory() - // ->save(); + $this->invoice = $this->subscription + ->service() + ->createInvoiceV2($this->bundle) + ->service() + // ->markSent() + ->fillDefaults() + ->adjustInventory() + ->save(); // Cache::put($this->hash, [ // 'subscription_id' => $this->subscription->id, diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index 7e060e532c85..ca2ef2178f14 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -426,14 +426,14 @@ class NinjaMailerJob implements ShouldQueue private function logMailError($errors, $recipient_object) { - SystemLogger::dispatchSync( + (new SystemLogger( $errors, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_SEND, SystemLog::TYPE_FAILURE, $recipient_object, $this->nmo->company - ); + ))->handle(); $job_failure = new EmailFailure($this->nmo->company->company_key); $job_failure->string_metric5 = 'failed_email'; diff --git a/app/Jobs/Ninja/BankTransactionSync.php b/app/Jobs/Ninja/BankTransactionSync.php index 8afeb82aabd1..7699d951bb36 100644 --- a/app/Jobs/Ninja/BankTransactionSync.php +++ b/app/Jobs/Ninja/BankTransactionSync.php @@ -60,7 +60,7 @@ class BankTransactionSync implements ShouldQueue $account->bank_integrations()->where('auto_sync', true)->cursor()->each(function ($bank_integration) use ($account){ - ProcessBankTransactions::dispatchSync($account->bank_integration_account_id, $bank_integration); + (new ProcessBankTransactions($account->bank_integration_account_id, $bank_integration))->handle(); }); diff --git a/app/Jobs/PostMark/ProcessPostmarkWebhook.php b/app/Jobs/PostMark/ProcessPostmarkWebhook.php index 5567d9536103..cca82d47aa2b 100644 --- a/app/Jobs/PostMark/ProcessPostmarkWebhook.php +++ b/app/Jobs/PostMark/ProcessPostmarkWebhook.php @@ -142,13 +142,13 @@ class ProcessPostmarkWebhook implements ShouldQueue $this->invitation->opened_date = now(); $this->invitation->save(); - SystemLogger::dispatchSync($this->request, + (new SystemLogger($this->request, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_OPENED, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company - ); + ))->handle(); } @@ -171,13 +171,13 @@ class ProcessPostmarkWebhook implements ShouldQueue $this->invitation->email_status = 'delivered'; $this->invitation->save(); - SystemLogger::dispatchSync($this->request, + (new SystemLogger($this->request, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_DELIVERY, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company - ); + ))->handle(); } // { @@ -219,7 +219,7 @@ class ProcessPostmarkWebhook implements ShouldQueue LightLogs::create($bounce)->send(); - SystemLogger::dispatchSync($this->request, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_BOUNCED, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company); + (new SystemLogger($this->request, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_BOUNCED, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company))->handle(); // if(config('ninja.notification.slack')) // $this->invitation->company->notification(new EmailBounceNotification($this->invitation->company->account))->ninja(); @@ -265,7 +265,7 @@ class ProcessPostmarkWebhook implements ShouldQueue LightLogs::create($spam)->send(); - SystemLogger::dispatchSync($this->request, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_SPAM_COMPLAINT, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company); + (new SystemLogger($this->request, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_SPAM_COMPLAINT, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company))->handle(); if(config('ninja.notification.slack')) $this->invitation->company->notification(new EmailSpamNotification($this->invitation->company->account))->ninja(); diff --git a/app/Services/Recurring/RecurringService.php b/app/Services/Recurring/RecurringService.php index 045eab8afd72..d04cc2a1d050 100644 --- a/app/Services/Recurring/RecurringService.php +++ b/app/Services/Recurring/RecurringService.php @@ -127,7 +127,7 @@ class RecurringService if($this->recurring_entity instanceof RecurringInvoice && $this->recurring_entity->status_id == RecurringInvoice::STATUS_DRAFT){ $this->start()->save(); - SendRecurring::dispatchSync($this->recurring_entity, $this->recurring_entity->company->db); + (new SendRecurring($this->recurring_entity, $this->recurring_entity->company->db))->handle(); } $this->recurring_entity = $this->recurring_entity->fresh(); diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index f4256b6399aa..bf1e61742093 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -702,6 +702,28 @@ class SubscriptionService ->fillDefaults() ->save(); + } + + public function createInvoiceV2($bundle) + { + + $invoice_repo = new InvoiceRepository(); + $subscription_repo = new SubscriptionRepository(); + + $invoice = InvoiceFactory::create($this->subscription->company_id, $this->subscription->user_id); + $invoice->subscription_id = $this->subscription->id; + + $line_items = $bundle->map(function ($item){ + + $line_item = new InvoiceItem; + + + })->toArray(); + + $invoice->line_items = $line_items; + + + } /** diff --git a/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php b/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php index 6c03ece2f88f..2c0aae8c4c20 100644 --- a/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php @@ -7,8 +7,31 @@ {{ $subscription->name }} -