Fixes for payment number creation for online payments

This commit is contained in:
David Bomba 2020-08-19 11:06:19 +10:00
parent 3850c6b516
commit 05ce11138e
5 changed files with 53 additions and 10 deletions

View File

@ -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();
}

View File

@ -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();
}
}

View File

@ -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' => '<a href="' .$this->invitation->getLink() .'">'. ctrans('texts.view_invoice').'</a>', '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 ?: '&nbsp;', 'label' => ctrans('texts.quote_terms')];
$data['$terms'] = &$data['$entity.terms'];
// $data['$view_link'] = ['value' => '<a href="' .$this->invitation->getLink() .'">'. ctrans('texts.view_quote').'</a>', '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 ?: '&nbsp;', 'label' => ctrans('texts.credit_terms')];
$data['$terms'] = &$data['$entity.terms'];
// $data['$view_link'] = ['value' => '<a href="' .$this->invitation->getLink() .'">'. ctrans('texts.view_credit').'</a>', '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'];

View File

@ -0,0 +1,10 @@
<?php
use Faker\Generator as Faker;
use Illuminate\Support\Str;
$factory->define(App\Models\QuoteInvitation::class, function (Faker $faker) {
return [
'key' => Str::random(40),
];
});

View File

@ -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);