diff --git a/app/PaymentDrivers/BasePaymentDriver.php b/app/PaymentDrivers/BasePaymentDriver.php
index 6f8ced3a6eed..0585aaf2ee5b 100644
--- a/app/PaymentDrivers/BasePaymentDriver.php
+++ b/app/PaymentDrivers/BasePaymentDriver.php
@@ -268,7 +268,7 @@ class BasePaymentDriver
$payment->currency_id = $this->client->getSetting('currency_id');
$payment->date = Carbon::now();
- return $payment;
+ return $payment->service()->applyNumber()->save();
}
diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php
index 523d9a894df3..f441b6a0075e 100644
--- a/app/PaymentDrivers/StripePaymentDriver.php
+++ b/app/PaymentDrivers/StripePaymentDriver.php
@@ -393,9 +393,8 @@ class StripePaymentDriver extends BasePaymentDriver
$payment->date = Carbon::now();
$payment->transaction_reference = $data['transaction_reference'];
$payment->amount = $amount;
- $payment->client->getNextPaymentNumber($this->client);
$payment->save();
- return $payment;
+ return $payment->service()->applyNumber()->save();
}
}
diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php
index 4984ce42b5e0..5ed126eee41d 100644
--- a/app/Utils/HtmlEngine.php
+++ b/app/Utils/HtmlEngine.php
@@ -123,7 +123,7 @@ class HtmlEngine
$data['$entity.terms'] = ['value' => $this->entity->terms ?: ' ', 'label' => ctrans('texts.invoice_terms')];
$data['$terms'] = &$data['$entity.terms'];
// $data['$view_link'] = ['value' => ''. ctrans('texts.view_invoice').'', 'label' => ctrans('texts.view_invoice')];
- $data['$view_link'] = ['value' => $invitation->getLink(), 'label' => ctrans('texts.view_invoice')];
+ $data['$view_link'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_invoice')];
}
@@ -133,7 +133,7 @@ class HtmlEngine
$data['$entity.terms'] = ['value' => $this->entity->terms ?: ' ', 'label' => ctrans('texts.quote_terms')];
$data['$terms'] = &$data['$entity.terms'];
// $data['$view_link'] = ['value' => ''. ctrans('texts.view_quote').'', 'label' => ctrans('texts.view_quote')];
- $data['$view_link'] = ['value' => $invitation->getLink(), 'label' => ctrans('texts.view_quote')];
+ $data['$view_link'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_quote')];
}
if ($this->entity_string == 'credit') {
@@ -142,7 +142,7 @@ class HtmlEngine
$data['$entity.terms'] = ['value' => $this->entity->terms ?: ' ', 'label' => ctrans('texts.credit_terms')];
$data['$terms'] = &$data['$entity.terms'];
// $data['$view_link'] = ['value' => ''. ctrans('texts.view_credit').'', 'label' => ctrans('texts.view_credit')];
- $data['$view_link'] = ['value' => $invitation->getLink(), 'label' => ctrans('texts.view_credit')];
+ $data['$view_link'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_credit')];
}
$data['$entity_number'] = &$data['$number'];
diff --git a/database/factories/QuoteInvitationFactory.php b/database/factories/QuoteInvitationFactory.php
new file mode 100644
index 000000000000..2cf3b27210e6
--- /dev/null
+++ b/database/factories/QuoteInvitationFactory.php
@@ -0,0 +1,10 @@
+define(App\Models\QuoteInvitation::class, function (Faker $faker) {
+ return [
+ 'key' => Str::random(40),
+ ];
+});
diff --git a/tests/MockAccountData.php b/tests/MockAccountData.php
index dc9b397d25fe..d2a9df121935 100644
--- a/tests/MockAccountData.php
+++ b/tests/MockAccountData.php
@@ -154,7 +154,7 @@ trait MockAccountData
]);
- $contact = factory(\App\Models\ClientContact::class, 1)->create([
+ $contact = factory(\App\Models\ClientContact::class)->create([
'user_id' => $this->user->id,
'client_id' => $this->client->id,
'company_id' => $this->company->id,
@@ -162,12 +162,13 @@ trait MockAccountData
'send_email' => true,
]);
- $contact2 = factory(\App\Models\ClientContact::class, 1)->create([
+ $contact2 = factory(\App\Models\ClientContact::class)->create([
'user_id' => $this->user->id,
'client_id' => $this->client->id,
'company_id' => $this->company->id,
'send_email' => true
]);
+
// $rels = collect($contact, $contact2);
// $this->client->setRelation('contacts', $rels);
@@ -211,7 +212,24 @@ trait MockAccountData
$this->invoice->save();
- $this->invoice->service()->createInvitations()->markSent();
+ //$this->invoice->service()->createInvitations()->markSent();
+ //$this->invoice->service()->createInvitations();
+
+ factory(\App\Models\InvoiceInvitation::class)->create([
+ 'user_id' => $this->user->id,
+ 'company_id' => $this->company->id,
+ 'client_contact_id' => $contact->id,
+ 'invoice_id' => $this->invoice->id,
+ ]);
+
+ factory(\App\Models\InvoiceInvitation::class)->create([
+ 'user_id' => $this->user->id,
+ 'company_id' => $this->company->id,
+ 'client_contact_id' => $contact2->id,
+ 'invoice_id' => $this->invoice->id,
+ ]);
+
+ $this->invoice->service()->markSent();
$this->quote = factory(\App\Models\Quote::class)->create([
'user_id' => $this->user->id,
@@ -229,8 +247,24 @@ trait MockAccountData
$this->quote = $this->quote_calc->getQuote();
+ $this->quote->status_id = Quote::STATUS_SENT;
$this->quote->number = $this->getNextQuoteNumber($this->client);
- $this->quote->service()->createInvitations()->markSent();
+
+ //$this->quote->service()->createInvitations()->markSent();
+
+ factory(\App\Models\QuoteInvitation::class)->create([
+ 'user_id' => $this->user->id,
+ 'company_id' => $this->company->id,
+ 'client_contact_id' => $contact->id,
+ 'quote_id' => $this->quote->id,
+ ]);
+
+ factory(\App\Models\QuoteInvitation::class)->create([
+ 'user_id' => $this->user->id,
+ 'company_id' => $this->company->id,
+ 'client_contact_id' => $contact2->id,
+ 'quote_id' => $this->quote->id,
+ ]);
$this->quote->setRelation('client', $this->client);
$this->quote->setRelation('company', $this->company);