diff --git a/app/Jobs/Entity/EmailEntity.php b/app/Jobs/Entity/EmailEntity.php index 1696b0b53eaa..fcb449c201b2 100644 --- a/app/Jobs/Entity/EmailEntity.php +++ b/app/Jobs/Entity/EmailEntity.php @@ -181,11 +181,6 @@ class EmailEntity extends BaseMailerJob implements ShouldQueue } } - private function findReminderTemplate() - { - - } - private function resolveEmailBuilder() { $class = 'App\Mail\Engine\\' . ucfirst(Str::camel($this->entity_string)) . "EmailEngine"; diff --git a/app/Jobs/Ninja/SendReminders.php b/app/Jobs/Ninja/SendReminders.php index 829afe0dd999..89d5dbe28599 100644 --- a/app/Jobs/Ninja/SendReminders.php +++ b/app/Jobs/Ninja/SendReminders.php @@ -214,14 +214,18 @@ class SendReminders implements ShouldQueue $invoice->invitations->each(function ($invitation) use($template, $invoice){ //only send if enable_reminder setting is toggled to yes - if($this->checkSendSetting($invoice, $template)) - EmailEntity::dispatch($invitation, $invitation->company, $template); + if($this->checkSendSetting($invoice, $template)) { + + EmailEntity::dispatchNow($invitation, $invitation->company, $template); + + event(new InvoiceWasEmailed($invitation, $invoice->company, Ninja::eventVars())); + + } + }); - if ($invoice->invitations->count() > 0) - event(new InvoiceWasEmailed($invoice->invitations->first(), $invoice->company, Ninja::eventVars())); - + $invoice->last_sent_date = now(); $invoice->next_send_date = $this->calculateNextSendDate($invoice); diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index 25dc8c956c13..436a8ae373ac 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -261,7 +261,7 @@ class Import implements ShouldQueue $company_repository = new CompanyRepository(); $company_repository->save($data, $this->company); - if(isset($data['settings']->company_logo)) { + if(isset($data['settings']->company_logo) && strlen($data['settings']->company_logo) > 0) { $tempImage = tempnam(sys_get_temp_dir(), basename($data['settings']->company_logo)); copy($data['settings']->company_logo, $tempImage); diff --git a/app/Mail/Engine/InvoiceEmailEngine.php b/app/Mail/Engine/InvoiceEmailEngine.php index e91e13a1b33c..0eb4ce4cf9f5 100644 --- a/app/Mail/Engine/InvoiceEmailEngine.php +++ b/app/Mail/Engine/InvoiceEmailEngine.php @@ -11,6 +11,7 @@ namespace App\Mail\Engine; +use App\DataMapper\EmailTemplateDefaults; use App\Utils\HtmlEngine; use App\Utils\Number; @@ -43,8 +44,10 @@ class InvoiceEmailEngine extends BaseEmailEngine if(is_array($this->template_data) && array_key_exists('body', $this->template_data) && strlen($this->template_data['body']) > 0) $body_template = $this->template_data['body']; - else - $body_template = $this->client->getSetting('email_template_'.$this->reminder_template); + else{ + //$body_template = $this->client->getSetting('email_template_'.$this->reminder_template); + $body_template = EmailTemplateDefaults::getDefaultTemplate($this->client->getSetting('email_template_'.$this->reminder_template), $this->client->locale()); + } /* Use default translations if a custom message has not been set*/ if (iconv_strlen($body_template) == 0) { @@ -62,8 +65,10 @@ class InvoiceEmailEngine extends BaseEmailEngine if(is_array($this->template_data) && array_key_exists('subject', $this->template_data) && strlen($this->template_data['subject']) > 0) $subject_template = $this->template_data['subject']; - else - $subject_template = $this->client->getSetting('email_subject_'.$this->reminder_template); + else{ + $subject_template = EmailTemplateDefaults::getDefaultTemplate($this->client->getSetting('email_subject_'.$this->reminder_template), $this->client->locale()); + // $subject_template = $this->client->getSetting('email_subject_'.$this->reminder_template); + } if (iconv_strlen($subject_template) == 0) { diff --git a/tests/Feature/MigrationTest.php b/tests/Feature/MigrationTest.php index e396f57de6a3..9ace31182d42 100644 --- a/tests/Feature/MigrationTest.php +++ b/tests/Feature/MigrationTest.php @@ -84,38 +84,6 @@ class MigrationTest extends TestCase $this->assertEquals($co->count(), 1); $this->assertEquals($inv->count(), 1); - // DB::statement( 'DELETE FROM `clients` WHERE `company_id`=:company_id', array('company_id' => $this->company->id) ); - - // $co = Client::whereCompanyId($this->company->id)->get(); - // $inv = Invoice::whereCompanyId($this->company->id)->get(); - - // $this->assertEquals($co->count(),0); - // $this->assertEquals($inv->count(),0); - - // $this->assertNotNull($this->company); - // $this->assertNotNull($this->company->settings); - // $this->assertNotNull($this->company->settings->timezone_id); } - // public function testMigrationFileUpload() - // { - // $file = new UploadedFile(base_path('tests/Unit/Migration/migration.zip'), 'migration.zip'); - - // $data = [ - // 'migration' => $file, - // 'force' => true, - // ]; - - // $token = $this->company->tokens->first()->token; - - // $response = $this->withHeaders([ - // 'X-API-TOKEN' => $token, - // 'X-API-SECRET' => config('ninja.api_secret'), - // 'X-Requested-With' => 'XMLHttpRequest', - // 'X-API-PASSWORD' => 'ALongAndBriliantPassword', - // ])->post('/api/v1/migration/start', $data); - - // $response->assertStatus(200); - // $this->assertTrue(file_exists(base_path('storage/migrations/migration/migration.json'))); - // } } diff --git a/tests/Unit/Migration/migration.json b/tests/Unit/Migration/migration.json index d73df558201f..5494db3c9151 100644 --- a/tests/Unit/Migration/migration.json +++ b/tests/Unit/Migration/migration.json @@ -65638,7 +65638,7 @@ "accepted_credit_cards": 0, "require_cvv": 1, "require_billing_address": null, - "show_shipping_address": 0, + "require_shipping_address": 0, "update_details": null, "config": "{\"apiKey\":\"345345345\",\"publishableKey\":\"5435345\",\"plaidClientId\":\"\",\"plaidSecret\":\"\",\"plaidPublicKey\":\"\",\"enableAlipay\":false,\"enableSofort\":false,\"enableSepa\":false,\"enableBitcoin\":false,\"enableApplePay\":false,\"enableAch\":false}", "fees_and_limits": { @@ -65667,7 +65667,7 @@ "accepted_credit_cards": 0, "require_cvv": 1, "require_billing_address": null, - "show_shipping_address": 0, + "require_shipping_address": 0, "update_details": null, "config": "{\"apiKey\":\"345345345\",\"publishableKey\":\"5435345\",\"plaidClientId\":\"\",\"plaidSecret\":\"\",\"plaidPublicKey\":\"\",\"enableAlipay\":false,\"enableSofort\":false,\"enableSepa\":false,\"enableBitcoin\":false,\"enableApplePay\":false,\"enableAch\":false}", "fees_and_limits": {},