-
{{ ctrans('texts.email_link_not_working') }}:
-
{{ $url }}
-
-@endisset
\ No newline at end of file
+
\ No newline at end of file
diff --git a/resources/views/email/template/dark.blade.php b/resources/views/email/template/dark.blade.php
index d536ded96b28..4f409cf4fa88 100644
--- a/resources/views/email/template/dark.blade.php
+++ b/resources/views/email/template/dark.blade.php
@@ -1,7 +1,7 @@
@component('email.template.master', ['design' => 'dark'])
@slot('header')
- @component('email.components.header', ['p' => '', 'logo' => 'https://www.invoiceninja.com/wp-content/uploads/2019/01/InvoiceNinja-Logo-Round-300x300.png'])
+ @component('email.components.header', ['p' => $body, 'logo' => 'https://www.invoiceninja.com/wp-content/uploads/2019/01/InvoiceNinja-Logo-Round-300x300.png'])
@if(isset($title))
{{$title}}
@@ -9,17 +9,14 @@
@endcomponent
-{!! $body !!}
-@slot('footer')
+ @if($footer)
+ @component('email.components.button', ['url' => $view_link])
+ {{$view_text}}
+ @endcomponent
+ @endif
- @if(isset($footer))
- {!! $footer !!}
- @endif
- @component('email.components.footer', ['url' => 'https://invoiceninja.com', 'url_text' => '© InvoiceNinja'])
- For any info, please visit InvoiceNinja.
- @endcomponent
@endslot
diff --git a/resources/views/email/template/light.blade.php b/resources/views/email/template/light.blade.php
index 13622d0784da..b78d7b10121f 100644
--- a/resources/views/email/template/light.blade.php
+++ b/resources/views/email/template/light.blade.php
@@ -1,7 +1,7 @@
@component('email.template.master', ['design' => 'light'])
@slot('header')
- @component('email.components.header', ['p' => '', 'logo' => 'https://www.invoiceninja.com/wp-content/uploads/2019/01/InvoiceNinja-Logo-Round-300x300.png'])
+ @component('email.components.header', ['p' => $body, 'logo' => 'https://www.invoiceninja.com/wp-content/uploads/2019/01/InvoiceNinja-Logo-Round-300x300.png'])
@if(isset($title))
{{$title}}
@@ -9,17 +9,14 @@
@endcomponent
-{!! $body !!}
-@slot('footer')
+ @if($footer)
+ @component('email.components.button', ['url' => $view_link])
+ {{$view_text}}
+ @endcomponent
+ @endif
- @if(isset($footer))
- {!! $footer !!}
- @endif
- @component('email.components.footer', ['url' => 'https://invoiceninja.com', 'url_text' => '© InvoiceNinja'])
- For any info, please visit InvoiceNinja.
- @endcomponent
@endslot
diff --git a/routes/breadcrumbs.php b/routes/breadcrumbs.php
index 10435ff2799d..59e75d2ee9b3 100644
--- a/routes/breadcrumbs.php
+++ b/routes/breadcrumbs.php
@@ -113,4 +113,4 @@ Breadcrumbs::for('clients.edit', function ($trail, $client) {
Breadcrumbs::for('clients.create', function ($trail) {
$trail->parent('clients');
-});
\ No newline at end of file
+});
diff --git a/routes/client.php b/routes/client.php
index 68e6e7bd132e..ee24a9055d42 100644
--- a/routes/client.php
+++ b/routes/client.php
@@ -50,14 +50,16 @@ Route::group(['middleware' => ['auth:contact','locale'], 'prefix' => 'client', '
});
Route::group(['middleware' => ['invite_db'], 'prefix' => 'client', 'as' => 'client.'], function () {
- Route::get('invoice/{invitation_key}/download_pdf', 'InvoiceController@downloadPdf');
- Route::get('quote/{invitation_key}/download_pdf', 'QuoteController@downloadPdf');
- Route::get('credit/{invitation_key}/download_pdf', 'CreditController@downloadPdf');
- Route::get('{entity}/{invitation_key}/download', 'ClientPortal\InvitationController@routerForDownload');
-
/*Invitation catches*/
- Route::get('{entity}/{invitation_key}', 'ClientPortal\InvitationController@router');
- Route::get('{entity}/{client_hash}/{invitation_key}', 'ClientPortal\InvitationController@routerForIframe'); //should never need this
+ Route::get('invoice/{invitation_key}', 'ClientPortal\InvitationController@router')->name('invoice.invitation_key');
+ Route::get('quote/{invitation_key}', 'ClientPortal\InvitationController@router')->name('quote.invitation_key');
+ Route::get('credit/{invitation_key}', 'ClientPortal\InvitationController@router')->name('credit.invitation_key');
+ Route::get('invoice/{invitation_key}/download_pdf', 'InvoiceController@downloadPdf')->name('invoice.download_invitation_key');
+ Route::get('quote/{invitation_key}/download_pdf', 'QuoteController@downloadPdf')->name('quote.download_invitation_key');
+ Route::get('credit/{invitation_key}/download_pdf', 'CreditController@downloadPdf')->name('credit.download_invitation_key');
+ Route::get('{entity}/{invitation_key}/download', 'ClientPortal\InvitationController@routerForDownload');
+ Route::get('{entity}/{client_hash}/{invitation_key}', 'ClientPortal\InvitationController@routerForIframe')->name('invoice.client_hash_and_invitation_key'); //should never need this
+
Route::get('payment_hook/{company_gateway_id}/{gateway_type_id}', 'ClientPortal\PaymentHookController@process');
});
diff --git a/tests/Feature/CancelInvoiceTest.php b/tests/Feature/CancelInvoiceTest.php
index da9202ccd243..5e38385358d7 100644
--- a/tests/Feature/CancelInvoiceTest.php
+++ b/tests/Feature/CancelInvoiceTest.php
@@ -52,7 +52,7 @@ class CancelInvoiceTest extends TestCase
public function testCancelInvoice()
{
- $this->assertTrue($this->invoice->invoiceCancellable($this->invoice));
+ $this->assertTrue($this->invoice->invoiceCancellable($this->invoice));
$client_balance = $this->client->balance;
$invoice_balance = $this->invoice->balance;
@@ -65,8 +65,5 @@ class CancelInvoiceTest extends TestCase
$this->assertEquals($this->client->balance, ($client_balance - $invoice_balance));
$this->assertNotEquals($client_balance, $this->client->balance);
$this->assertEquals(Invoice::STATUS_CANCELLED, $this->invoice->status_id);
-
}
}
-
-
diff --git a/tests/Feature/CompanyTokenApiTest.php b/tests/Feature/CompanyTokenApiTest.php
index 8c2af519ce49..e63fdc4c9a2c 100644
--- a/tests/Feature/CompanyTokenApiTest.php
+++ b/tests/Feature/CompanyTokenApiTest.php
@@ -45,12 +45,10 @@ class CompanyTokenApiTest extends TestCase
$this->withoutMiddleware(
ThrottleRequests::class
);
-
}
public function testCompanyTokenList()
{
-
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token
@@ -94,12 +92,10 @@ class CompanyTokenApiTest extends TestCase
$arr = $response->json();
$this->assertEquals('newname', $arr['data']['name']);
-
}
public function testCompanyTokenGet()
{
-
$company_token = CompanyToken::whereCompanyId($this->company->id)->first();
@@ -125,5 +121,4 @@ class CompanyTokenApiTest extends TestCase
$this->assertEquals(0, $arr['data']['archived_at']);
}
-
}
diff --git a/tests/Feature/InvoiceEmailTest.php b/tests/Feature/InvoiceEmailTest.php
index be5fd4850d03..421dffd45492 100644
--- a/tests/Feature/InvoiceEmailTest.php
+++ b/tests/Feature/InvoiceEmailTest.php
@@ -21,6 +21,7 @@ use Tests\TestCase;
/**
* @test
+* @covers App\Jobs\Invoice\EmailInvoice
*/
class InvoiceEmailTest extends TestCase
{
@@ -48,6 +49,12 @@ class InvoiceEmailTest extends TestCase
$this->invoice->number = $this->getNextInvoiceNumber($this->client);
$this->invoice->client_id = $this->client->id;
+
+ $client_settings = $this->client->settings;
+ $client_settings->email_style = 'dark';
+ $this->client->settings = $client_settings;
+ $this->client->save();
+
$this->invoice->setRelation('client', $this->client);
$this->invoice->save();
@@ -56,10 +63,98 @@ class InvoiceEmailTest extends TestCase
if ($invitation->contact->send_email && $invitation->contact->email) {
$email_builder = (new InvoiceEmail())->build($invitation, null);
- EmailInvoice::dispatch($email_builder, $invitation, $invitation->company);
+ EmailInvoice::dispatchNow($email_builder, $invitation, $invitation->company);
$this->expectsJobs(EmailInvoice::class);
}
});
+
+ $this->assertTrue(true);
+ }
+
+ public function testTemplateThemes()
+ {
+ $settings = $this->company->settings;
+ $settings->email_style = 'light';
+
+ $this->company->settings = $settings;
+ $this->company->save();
+
+ $this->invoice->date = now();
+ $this->invoice->due_date = now()->addDays(7);
+ $this->invoice->number = $this->getNextInvoiceNumber($this->client);
+
+ $this->invoice->client_id = $this->client->id;
+ $this->invoice->setRelation('client', $this->client);
+
+ $this->invoice->save();
+
+ $this->invoice->invitations->each(function ($invitation) {
+ if ($invitation->contact->send_email && $invitation->contact->email) {
+ $email_builder = (new InvoiceEmail())->build($invitation, null);
+
+ EmailInvoice::dispatchNow($email_builder, $invitation, $invitation->company);
+
+ $this->expectsJobs(EmailInvoice::class);
+ }
+ });
+
+ $settings = $this->company->settings;
+ $settings->email_style = 'dark';
+
+ $this->company->settings = $settings;
+ $this->company->save();
+
+ $this->invoice->date = now();
+ $this->invoice->due_date = now()->addDays(7);
+ $this->invoice->number = $this->getNextInvoiceNumber($this->client);
+
+ $this->invoice->client_id = $this->client->id;
+
+ $client_settings = $this->client->settings;
+ $client_settings->email_style = 'dark';
+ $this->client->settings = $client_settings;
+ $this->client->save();
+
+ $this->invoice->setRelation('client', $this->client);
+ $this->invoice->save();
+
+ $this->invoice->invitations->each(function ($invitation) {
+ if ($invitation->contact->send_email && $invitation->contact->email) {
+ $email_builder = (new InvoiceEmail())->build($invitation, null);
+
+ EmailInvoice::dispatchNow($email_builder, $invitation, $invitation->company);
+
+ $this->expectsJobs(EmailInvoice::class);
+ }
+ });
+
+ $settings = $this->company->settings;
+ $settings->email_style = 'plain';
+
+ $this->company->settings = $settings;
+ $this->company->save();
+
+ $this->invoice->date = now();
+ $this->invoice->due_date = now()->addDays(7);
+ $this->invoice->number = $this->getNextInvoiceNumber($this->client);
+
+ $this->invoice->client_id = $this->client->id;
+ $this->invoice->setRelation('client', $this->client);
+
+ $this->invoice->save();
+
+ $this->invoice->invitations->each(function ($invitation) {
+ if ($invitation->contact->send_email && $invitation->contact->email) {
+ $email_builder = (new InvoiceEmail())->build($invitation, null);
+
+ EmailInvoice::dispatchNow($email_builder, $invitation, $invitation->company);
+
+ $this->expectsJobs(EmailInvoice::class);
+ }
+ });
+
+
+ $this->assertTrue(true);
}
}
diff --git a/tests/Feature/PaymentTest.php b/tests/Feature/PaymentTest.php
index c44e7832b5ad..0ca71dea854e 100644
--- a/tests/Feature/PaymentTest.php
+++ b/tests/Feature/PaymentTest.php
@@ -1250,5 +1250,4 @@ class PaymentTest extends TestCase
$this->assertEquals(1, $payment->invoices()->count());
}
}
-
}
diff --git a/tests/Feature/ReminderTest.php b/tests/Feature/ReminderTest.php
new file mode 100644
index 000000000000..645b49958597
--- /dev/null
+++ b/tests/Feature/ReminderTest.php
@@ -0,0 +1,89 @@
+withoutMiddleware(
+ ThrottleRequests::class
+ );
+
+ $this->faker = \Faker\Factory::create();
+
+ Model::reguard();
+
+ $this->makeTestData();
+
+ $this->withoutExceptionHandling();
+ }
+
+ public function testReminderQueryCatchesDate()
+ {
+ $this->invoice->next_send_date = now()->format('Y-m-d');
+ $this->invoice->save();
+
+ $invoices = Invoice::where('next_send_date', Carbon::today())->get();
+
+ $this->assertEquals(1, $invoices->count());
+ }
+
+ public function testReminderHits()
+ {
+ $this->invoice->date = now()->format('Y-m-d');
+ $this->invoice->due_date = Carbon::now()->addDays(30)->format('Y-m-d');
+
+ $settings = $this->company->settings;
+ $settings->enable_reminder1 = true;
+ $settings->schedule_reminder1 = 'after_invoice_date';
+ $settings->num_days_reminder1 = 7;
+ $settings->enable_reminder2 = true;
+ $settings->schedule_reminder2 = 'before_due_date';
+ $settings->num_days_reminder2 = 1;
+ $settings->enable_reminder3 = true;
+ $settings->schedule_reminder3 = 'after_due_date';
+ $settings->num_days_reminder3 = 1;
+
+ $this->company->settings = $settings;
+ $this->invoice->service()->markSent();
+ $this->invoice->setReminder($settings);
+
+ $this->assertEquals($this->invoice->next_send_date, Carbon::now()->addDays(7)->format('Y-m-d'));
+
+ ReminderJob::dispatchNow();
+ }
+
+
+}
diff --git a/tests/Feature/ReverseInvoiceTest.php b/tests/Feature/ReverseInvoiceTest.php
index a5f4cc6b37e2..c2b0cde3d2b1 100644
--- a/tests/Feature/ReverseInvoiceTest.php
+++ b/tests/Feature/ReverseInvoiceTest.php
@@ -52,18 +52,17 @@ class ReverseInvoiceTest extends TestCase
public function testReverseInvoice()
{
-
- $amount = $this->invoice->amount;
- $balance = $this->invoice->balance;
+ $amount = $this->invoice->amount;
+ $balance = $this->invoice->balance;
- $this->invoice->service()->markPaid()->save();
+ $this->invoice->service()->markPaid()->save();
- $first_payment = $this->invoice->payments->first();
+ $first_payment = $this->invoice->payments->first();
- $this->assertEquals((float)$first_payment->amount, (float)$this->invoice->amount);
- $this->assertEquals((float)$first_payment->applied, (float)$this->invoice->amount);
+ $this->assertEquals((float)$first_payment->amount, (float)$this->invoice->amount);
+ $this->assertEquals((float)$first_payment->applied, (float)$this->invoice->amount);
- $this->assertTrue($this->invoice->invoiceReversable($this->invoice));
+ $this->assertTrue($this->invoice->invoiceReversable($this->invoice));
$balance_remaining = $this->invoice->balance;
$total_paid = $this->invoice->amount - $this->invoice->balance;
@@ -71,30 +70,28 @@ class ReverseInvoiceTest extends TestCase
/*Adjust payment applied and the paymentables to the correct amount */
$paymentables = Paymentable::wherePaymentableType(Invoice::class)
- ->wherePaymentableId($this->invoice->id)
- ->get();
+ ->wherePaymentableId($this->invoice->id)
+ ->get();
- $paymentables->each(function ($paymentable) use($total_paid){
+ $paymentables->each(function ($paymentable) use ($total_paid) {
+ $reversable_amount = $paymentable->amount - $paymentable->refunded;
- $reversable_amount = $paymentable->amount - $paymentable->refunded;
+ $total_paid -= $reversable_amount;
- $total_paid -= $reversable_amount;
+ $paymentable->amount = $paymentable->refunded;
+ $paymentable->save();
+ });
- $paymentable->amount = $paymentable->refunded;
- $paymentable->save();
-
- });
+ /* Generate a credit for the $total_paid amount */
+ $credit = CreditFactory::create($this->invoice->company_id, $this->invoice->user_id);
+ $credit->client_id = $this->invoice->client_id;
- /* Generate a credit for the $total_paid amount */
- $credit = CreditFactory::create($this->invoice->company_id, $this->invoice->user_id);
- $credit->client_id = $this->invoice->client_id;
+ $item = InvoiceItemFactory::create();
+ $item->quantity = 1;
+ $item->cost = (float)$total_paid;
+ $item->notes = "Credit for reversal of ".$this->invoice->number;
- $item = InvoiceItemFactory::create();
- $item->quantity = 1;
- $item->cost = (float)$total_paid;
- $item->notes = "Credit for reversal of ".$this->invoice->number;
-
- $line_items[] = $item;
+ $line_items[] = $item;
$credit->line_items = $line_items;
@@ -106,8 +103,8 @@ class ReverseInvoiceTest extends TestCase
$credit = $credit_calc->getCredit();
$credit->service()
- ->setStatus(Credit::STATUS_SENT)
- ->markSent()->save();
+ ->setStatus(Credit::STATUS_SENT)
+ ->markSent()->save();
/* Set invoice balance to 0 */
$this->invoice->ledger()->updateInvoiceBalance($balance_remaining*-1, $item->notes)->save();
@@ -115,15 +112,15 @@ class ReverseInvoiceTest extends TestCase
/* Set invoice status to reversed... somehow*/
$this->invoice->service()->setStatus(Invoice::STATUS_REVERSED)->save();
- /* Reduce client.paid_to_date by $total_paid amount */
- $this->client->paid_to_date -= $total_paid;
+ /* Reduce client.paid_to_date by $total_paid amount */
+ $this->client->paid_to_date -= $total_paid;
- /* Reduce the client balance by $balance_remaining */
- $this->client->balance -= $balance_remaining;
+ /* Reduce the client balance by $balance_remaining */
+ $this->client->balance -= $balance_remaining;
- $this->client->save();
+ $this->client->save();
- //create a ledger row for this with the resulting Credit ( also include an explanation in the notes section )
+ //create a ledger row for this with the resulting Credit ( also include an explanation in the notes section )
}
@@ -149,8 +146,6 @@ class ReverseInvoiceTest extends TestCase
$this->assertEquals(Invoice::STATUS_REVERSED, $this->invoice->status_id);
$this->assertEquals(0, $this->invoice->balance);
$this->assertEquals($this->client->paid_to_date, ($client_paid_to_date));
-
-
}
public function testReversalNoPayment()
@@ -171,5 +166,3 @@ class ReverseInvoiceTest extends TestCase
$this->assertEquals($this->client->balance, ($client_balance-$invoice_balance));
}
}
-
-
diff --git a/tests/Feature/SubscriptionAPITest.php b/tests/Feature/SubscriptionAPITest.php
index 87f422b67d5e..c52b9b228ea1 100644
--- a/tests/Feature/SubscriptionAPITest.php
+++ b/tests/Feature/SubscriptionAPITest.php
@@ -43,7 +43,6 @@ class SubscriptionAPITest extends TestCase
public function testSubscriptionGetRoute()
{
-
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
@@ -108,7 +107,7 @@ class SubscriptionAPITest extends TestCase
$arr = $response->json();
- $this->assertEquals(0,$arr['data'][0]['archived_at']);
+ $this->assertEquals(0, $arr['data'][0]['archived_at']);
$response = $this->withHeaders([
@@ -121,5 +120,4 @@ class SubscriptionAPITest extends TestCase
$this->assertNotNull($arr['data'][0]['archived_at']);
$this->assertTrue($arr['data'][0]['is_deleted']);
}
-
-}
\ No newline at end of file
+}
diff --git a/tests/Unit/GoogleAnalyticsTest.php b/tests/Unit/GoogleAnalyticsTest.php
index 6bd349ad066c..115d57dfbada 100644
--- a/tests/Unit/GoogleAnalyticsTest.php
+++ b/tests/Unit/GoogleAnalyticsTest.php
@@ -25,13 +25,10 @@ class GoogleAnalyticsTest extends TestCase
parent::setUp();
$this->makeTestData();
-
}
public function testGoogleAnalyticsLogic()
{
-
-
$analytics_id = "analytics_id";
$invoice = $this->invoice;
$client = $this->client;
@@ -42,12 +39,11 @@ class GoogleAnalyticsTest extends TestCase
$amount = $payment->amount;
- if($invoice){
+ if ($invoice) {
$items = $invoice->line_items;
$item = end($items)->product_key;
$entity_number = $invoice->number;
- }
- else{
+ } else {
$item = $payment->number;
$entity_number = $item;
}
@@ -67,6 +63,3 @@ class GoogleAnalyticsTest extends TestCase
$this->assertNotNull($url);
}
}
-
-
-
diff --git a/tests/Unit/InvoiceActionsTest.php b/tests/Unit/InvoiceActionsTest.php
index e503bab5a210..3057666ea345 100644
--- a/tests/Unit/InvoiceActionsTest.php
+++ b/tests/Unit/InvoiceActionsTest.php
@@ -67,5 +67,4 @@ class InvoiceActionsTest extends TestCase
$this->assertFalse($this->invoiceReversable($this->invoice));
$this->assertFalse($this->invoiceCancellable($this->invoice));
}
-
}
diff --git a/tests/Unit/UBLInvoiceTest.php b/tests/Unit/UBLInvoiceTest.php
index ab7b507a4830..b9814153cde8 100644
--- a/tests/Unit/UBLInvoiceTest.php
+++ b/tests/Unit/UBLInvoiceTest.php
@@ -29,7 +29,6 @@ class UBLInvoiceTest extends TestCase
ThrottleRequests::class
);
$this->makeTestData();
-
}
public function testUblGenerates()
@@ -38,5 +37,4 @@ class UBLInvoiceTest extends TestCase
$this->assertNotNull($ubl);
}
-
-}
\ No newline at end of file
+}