From 86ea2f070932568cdb47b462772b476d2207c525 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 17 Mar 2021 12:04:54 +1100 Subject: [PATCH 1/2] Fixes for free plan invoice designs - default to clean --- app/Jobs/Entity/CreateEntityPdf.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Jobs/Entity/CreateEntityPdf.php b/app/Jobs/Entity/CreateEntityPdf.php index 5f368e5d64fa..acf4331dbba2 100644 --- a/app/Jobs/Entity/CreateEntityPdf.php +++ b/app/Jobs/Entity/CreateEntityPdf.php @@ -12,6 +12,7 @@ namespace App\Jobs\Entity; +use App\Models\Account; use App\Models\Credit; use App\Models\CreditInvitation; use App\Models\Design; @@ -118,6 +119,9 @@ class CreateEntityPdf implements ShouldQueue $entity_design_id = $this->entity->design_id ? $this->entity->design_id : $this->decodePrimaryKey($this->entity->client->getSetting($entity_design_id)); + if(!$this->company->account->hasFeature(Account::FEATURE_DIFFERENT_DESIGNS)) + $entity_design_id = 2; + $design = Design::find($entity_design_id); $html = new HtmlEngine($this->invitation); From 1012c8df4b5dc1011c77795c9cbb58f75bd16595 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 17 Mar 2021 13:21:06 +1100 Subject: [PATCH 2/2] Working on billing subscriptions --- .../BillingSubscriptionService.php | 45 +++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/app/Services/BillingSubscription/BillingSubscriptionService.php b/app/Services/BillingSubscription/BillingSubscriptionService.php index c3abf2f2ea20..e464f4d9ea6f 100644 --- a/app/Services/BillingSubscription/BillingSubscriptionService.php +++ b/app/Services/BillingSubscription/BillingSubscriptionService.php @@ -11,7 +11,11 @@ namespace App\Services\BillingSubscription; +use App\DataMapper\InvoiceItem; +use App\Factory\InvoiceFactory; use App\Models\ClientSubscription; +use App\Models\Product; +use App\Repositories\InvoiceRepository; class BillingSubscriptionService { @@ -23,10 +27,21 @@ class BillingSubscriptionService $this->billing_subscription = $billing_subscription; } - public function createInvoice($payment_hash) + public function createInvoice($data) { - //create the invoice if necessary ie. only is a payment was actually processed - + + $invoice_repo = new InvoiceRepository(); + + // $data = [ + // 'client_id' =>, + // 'date' => Y-m-d, + // 'invitations' => [ + // 'client_contact_id' => hashed_id + // ], + // 'line_items' => [], + // ]; + + $invoice = $invoice_repo->save($data, InvoiceFactory::create($billing_subscription->company_id, $billing_subscription->user_id)); /* If trial_enabled -> return early @@ -39,6 +54,30 @@ class BillingSubscriptionService 1. Is this a recurring product? 2. What is the quantity? ie is this a multi seat product ( does this mean we need this value stored in the client sub?) */ + + return $invoice; + + } + + private function createLineItems($quantity) + { + $line_items = []; + + $product = $this->billing_subscription->product; + + $item = new InvoiceItem; + $item->quantity = $quantity; + $item->product_key = $product->product_key; + $item->notes = $product->notes; + $item->cost = $product->price; + //$item->type_id need to switch whether the subscription is a service or product + + $line_items[] = $item; + + + //do we have a promocode? enter this as a line item. + + return $line_items; } private function convertInvoiceToRecurring()