From 4a4f5288146c51daa708ee1f3b828f0911e223df Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 4 Jul 2022 10:53:33 +1000 Subject: [PATCH 01/11] New Account Notification --- app/Notifications/Ninja/NewAccountNotification.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Notifications/Ninja/NewAccountNotification.php b/app/Notifications/Ninja/NewAccountNotification.php index 52648d36066f..1cd13b8d55e2 100644 --- a/app/Notifications/Ninja/NewAccountNotification.php +++ b/app/Notifications/Ninja/NewAccountNotification.php @@ -78,10 +78,10 @@ class NewAccountNotification extends Notification public function toSlack($notifiable) { $content = "New Trial Started\n"; - $content = "{$this->client->name}\n"; - $content = "Account key: {$this->account->key}\n"; - $content = "Users: {$this->account->users()->pluck('email')}\n"; - $content = "Contacts: {$this->client->contacts()->pluck('email')}\n"; + $content .= "{$this->client->name}\n"; + $content .= "Account key: {$this->account->key}\n"; + $content .= "Users: {$this->account->users()->pluck('email')}\n"; + $content .= "Contacts: {$this->client->contacts()->pluck('email')}\n"; return (new SlackMessage) From 40bf4c9a1ac22672dcc48c0aa05d338b7e4d3a20 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 4 Jul 2022 14:41:16 +1000 Subject: [PATCH 02/11] Fixes for template engine --- app/Utils/TemplateEngine.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Utils/TemplateEngine.php b/app/Utils/TemplateEngine.php index 4e0b6580de6d..d481a33d24bf 100644 --- a/app/Utils/TemplateEngine.php +++ b/app/Utils/TemplateEngine.php @@ -185,7 +185,8 @@ class TemplateEngine 'allow_unsafe_links' => false, ]); - $this->body = $converter->convert($this->body); + $this->body = $converter->convert($this->body)->getContent(); + } private function entityValues($contact) From 80ea41568c257154197ecb5dd7fa2986b56a6ca9 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 4 Jul 2022 15:27:09 +1000 Subject: [PATCH 03/11] Purchase Order Emails --- app/Http/Controllers/EmailController.php | 6 ++++++ app/Http/Requests/Email/SendEmailRequest.php | 3 ++- app/Services/PurchaseOrder/PurchaseOrderService.php | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/EmailController.php b/app/Http/Controllers/EmailController.php index 07acd26b721b..175011ac61f0 100644 --- a/app/Http/Controllers/EmailController.php +++ b/app/Http/Controllers/EmailController.php @@ -17,6 +17,7 @@ use App\Http\Middleware\UserVerified; use App\Http\Requests\Email\SendEmailRequest; use App\Jobs\Entity\EmailEntity; use App\Jobs\Mail\EntitySentMailer; +use App\Jobs\PurchaseOrder\PurchaseOrderEmail; use App\Models\Credit; use App\Models\Invoice; use App\Models\Quote; @@ -125,6 +126,11 @@ class EmailController extends BaseController 'body' => $body ]; + if($entity == 'purchaseOrder' || $template == 'purchase_order'){ + PurchaseOrderEmail::dispatch($entity, $entity->company, $data); + return; + } + $entity_obj->invitations->each(function ($invitation) use ($data, $entity_string, $entity_obj, $template) { if (!$invitation->contact->trashed() && $invitation->contact->email) { diff --git a/app/Http/Requests/Email/SendEmailRequest.php b/app/Http/Requests/Email/SendEmailRequest.php index d75f91dfda16..3cfcc61a9365 100644 --- a/app/Http/Requests/Email/SendEmailRequest.php +++ b/app/Http/Requests/Email/SendEmailRequest.php @@ -13,6 +13,7 @@ namespace App\Http\Requests\Email; use App\Http\Requests\Request; use App\Utils\Traits\MakesHash; +use Illuminate\Support\Str; class SendEmailRequest extends Request { @@ -60,7 +61,7 @@ class SendEmailRequest extends Request $input['entity_id'] = $this->decodePrimaryKey($input['entity_id']); if(array_key_exists('entity', $input)) - $input['entity'] = "App\Models\\".ucfirst($input['entity']); + $input['entity'] = "App\Models\\".ucfirst(Str::camel($input['entity'])); $this->replace($input); } diff --git a/app/Services/PurchaseOrder/PurchaseOrderService.php b/app/Services/PurchaseOrder/PurchaseOrderService.php index e2990b372b42..e68e5c508761 100644 --- a/app/Services/PurchaseOrder/PurchaseOrderService.php +++ b/app/Services/PurchaseOrder/PurchaseOrderService.php @@ -40,7 +40,7 @@ class PurchaseOrderService public function applyNumber() { - $this->invoice = (new ApplyNumber($this->purchase_order->vendor, $this->purchase_order))->run(); + $this->purchase_order = (new ApplyNumber($this->purchase_order->vendor, $this->purchase_order))->run(); return $this; } From dee96182d56c2c7e47cdd682f469748bdd7110c5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 4 Jul 2022 15:33:31 +1000 Subject: [PATCH 04/11] Purchase Order Emails --- app/Http/Controllers/EmailController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/EmailController.php b/app/Http/Controllers/EmailController.php index 175011ac61f0..2d1c25cf0fd1 100644 --- a/app/Http/Controllers/EmailController.php +++ b/app/Http/Controllers/EmailController.php @@ -127,7 +127,7 @@ class EmailController extends BaseController ]; if($entity == 'purchaseOrder' || $template == 'purchase_order'){ - PurchaseOrderEmail::dispatch($entity, $entity->company, $data); + PurchaseOrderEmail::dispatch($entity_obj, $entity_obj->company, $data); return; } From 24b4c3fbabe3982c2586281554f81cbfb4542c15 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 4 Jul 2022 15:34:54 +1000 Subject: [PATCH 05/11] Purchase Order Emails --- app/Http/Controllers/EmailController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/EmailController.php b/app/Http/Controllers/EmailController.php index 2d1c25cf0fd1..817cf485eddb 100644 --- a/app/Http/Controllers/EmailController.php +++ b/app/Http/Controllers/EmailController.php @@ -128,7 +128,7 @@ class EmailController extends BaseController if($entity == 'purchaseOrder' || $template == 'purchase_order'){ PurchaseOrderEmail::dispatch($entity_obj, $entity_obj->company, $data); - return; + return $this->itemResponse($entity_obj); } $entity_obj->invitations->each(function ($invitation) use ($data, $entity_string, $entity_obj, $template) { From 8f5896db2260d5d52b74e0590e4852711cb49798 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 4 Jul 2022 15:37:00 +1000 Subject: [PATCH 06/11] Purchase Order Emails --- app/Http/Controllers/EmailController.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/EmailController.php b/app/Http/Controllers/EmailController.php index 817cf485eddb..e425206d5975 100644 --- a/app/Http/Controllers/EmailController.php +++ b/app/Http/Controllers/EmailController.php @@ -20,6 +20,7 @@ use App\Jobs\Mail\EntitySentMailer; use App\Jobs\PurchaseOrder\PurchaseOrderEmail; use App\Models\Credit; use App\Models\Invoice; +use App\Models\PurchaseOrder; use App\Models\Quote; use App\Models\RecurringInvoice; use App\Transformers\CreditTransformer; @@ -127,8 +128,7 @@ class EmailController extends BaseController ]; if($entity == 'purchaseOrder' || $template == 'purchase_order'){ - PurchaseOrderEmail::dispatch($entity_obj, $entity_obj->company, $data); - return $this->itemResponse($entity_obj); + return $this->sendPurchaseOrder($entity_obj, $data); } $entity_obj->invitations->each(function ($invitation) use ($data, $entity_string, $entity_obj, $template) { @@ -182,4 +182,17 @@ class EmailController extends BaseController return $this->itemResponse($entity_obj->fresh()); } + + private function sendPurchaseOrder($entity_obj, $data) + { + + $this->entity_type = PurchaseOrder::class; + + $this->entity_transformer = PurchaseOrderTransformer::class; + + PurchaseOrderEmail::dispatch($entity_obj, $entity_obj->company, $data); + + return $this->itemResponse($entity_obj); + + } } From 32387e052c9d4a8cfb02eafa6be775fddf7c8d5e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 4 Jul 2022 15:37:37 +1000 Subject: [PATCH 07/11] Purchase Order Emails --- app/Http/Controllers/EmailController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Controllers/EmailController.php b/app/Http/Controllers/EmailController.php index e425206d5975..9325a1d9cc7e 100644 --- a/app/Http/Controllers/EmailController.php +++ b/app/Http/Controllers/EmailController.php @@ -25,6 +25,7 @@ use App\Models\Quote; use App\Models\RecurringInvoice; use App\Transformers\CreditTransformer; use App\Transformers\InvoiceTransformer; +use App\Transformers\PurchaseOrderTransformer; use App\Transformers\QuoteTransformer; use App\Transformers\RecurringInvoiceTransformer; use App\Utils\Ninja; From 0a2a4e91e282d7384061ac7bf8d7c55d519a477f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 4 Jul 2022 16:34:35 +1000 Subject: [PATCH 08/11] Minor fixes for vendor contacts --- app/Repositories/VendorContactRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Repositories/VendorContactRepository.php b/app/Repositories/VendorContactRepository.php index 049b4acdfac7..1df37b6846da 100644 --- a/app/Repositories/VendorContactRepository.php +++ b/app/Repositories/VendorContactRepository.php @@ -32,7 +32,7 @@ class VendorContactRepository extends BaseRepository } /* Get array of IDs which have been removed from the contacts array and soft delete each contact */ - $vendor->contacts->pluck('id')->diff($contacts->pluck('id'))->each(function ($contact) { + $vendor->contacts->pluck('hashed_id')->diff($contacts->pluck('id'))->each(function ($contact) { VendorContact::destroy($contact); }); From 6d54db85074b094646db31f8f803dc923f324002 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 5 Jul 2022 08:26:41 +1000 Subject: [PATCH 09/11] Minor fixes for import --- app/Jobs/Util/Import.php | 7 ++++++- app/Utils/TemplateEngine.php | 3 --- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index 99549bd53224..b3d6cd822672 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -275,7 +275,12 @@ class Import implements ShouldQueue info('CompletedπŸš€πŸš€πŸš€πŸš€πŸš€ at '.now()); - unlink($this->file_path); + try{ + unlink($this->file_path); + } + catch(\Exception $e){ + nlog("problem unsetting file"); + } } private function fixData() diff --git a/app/Utils/TemplateEngine.php b/app/Utils/TemplateEngine.php index d481a33d24bf..a360a078cca1 100644 --- a/app/Utils/TemplateEngine.php +++ b/app/Utils/TemplateEngine.php @@ -84,9 +84,6 @@ class TemplateEngine public function build() { - - if ($this->template == 'email_template_null') - $this->template = 'email_template_purchase_order'; return $this->setEntity() ->setSettingsObject() From a55dd2ec40369e93b4eb462c437d7bc43bf778d8 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 5 Jul 2022 09:55:05 +1000 Subject: [PATCH 10/11] Purchase Orders --- app/Jobs/RecurringInvoice/SendRecurring.php | 1 - app/Models/ClientContact.php | 1 - app/Services/Invoice/ApplyNumber.php | 2 -- 3 files changed, 4 deletions(-) diff --git a/app/Jobs/RecurringInvoice/SendRecurring.php b/app/Jobs/RecurringInvoice/SendRecurring.php index b3bf0a53ddb3..d019e23790f4 100644 --- a/app/Jobs/RecurringInvoice/SendRecurring.php +++ b/app/Jobs/RecurringInvoice/SendRecurring.php @@ -85,7 +85,6 @@ class SendRecurring implements ShouldQueue $invoice = $invoice->service() ->markSent() ->applyNumber() - //->createInvitations() //need to only link invitations to those in the recurring invoice ->fillDefaults() ->adjustInventory() ->save(); diff --git a/app/Models/ClientContact.php b/app/Models/ClientContact.php index e71bf14812be..f6f256798488 100644 --- a/app/Models/ClientContact.php +++ b/app/Models/ClientContact.php @@ -210,7 +210,6 @@ class ClientContact extends Authenticatable implements HasLocalePreference NinjaMailerJob::dispatch($nmo); - //$this->notify(new ClientContactResetPassword($token)); } public function preferredLocale() diff --git a/app/Services/Invoice/ApplyNumber.php b/app/Services/Invoice/ApplyNumber.php index d43f3b71bb83..325991ab67ec 100644 --- a/app/Services/Invoice/ApplyNumber.php +++ b/app/Services/Invoice/ApplyNumber.php @@ -43,12 +43,10 @@ class ApplyNumber extends AbstractService switch ($this->client->getSetting('counter_number_applied')) { case 'when_saved': $this->trySaving(); - // $this->invoice->number = $this->getNextInvoiceNumber($this->client, $this->invoice, $this->invoice->recurring_id); break; case 'when_sent': if ($this->invoice->status_id == Invoice::STATUS_SENT) { $this->trySaving(); - // $this->invoice->number = $this->getNextInvoiceNumber($this->client, $this->invoice, $this->invoice->recurring_id); } break; From 939f3fae2eef55ce5dae423b178cf17c7623aab5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 5 Jul 2022 09:55:31 +1000 Subject: [PATCH 11/11] v5.4.8 --- VERSION.txt | 2 +- config/ninja.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index 48360de846a2..017d74f4a2e9 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.4.7 \ No newline at end of file +5.4.8 \ No newline at end of file diff --git a/config/ninja.php b/config/ninja.php index 10db9fa47b2f..5eb5af73c1a8 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -14,8 +14,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => '5.4.7', - 'app_tag' => '5.4.7', + 'app_version' => '5.4.8', + 'app_tag' => '5.4.8', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''),