1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #7940 from turbo124/v5-develop

Update invoice notifications
This commit is contained in:
David Bomba 2022-11-14 07:53:50 +11:00 committed by GitHub
commit f92dbe34bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 34 deletions

View File

@ -823,7 +823,7 @@ class BaseController extends Controller
//06-10-2022 - some entities do not have assigned_user_id - this becomes an issue when we have a large company and low permission users //06-10-2022 - some entities do not have assigned_user_id - this becomes an issue when we have a large company and low permission users
if(lcfirst(class_basename(Str::snake($this->entity_type))) == 'user') if(lcfirst(class_basename(Str::snake($this->entity_type))) == 'user')
$query->where('id', auth()->user()->id); $query->where('id', auth()->user()->id);
elseif(in_array(lcfirst(class_basename(Str::snake($this->entity_type))),['design','group_setting','payment_term'])){ elseif(in_array(lcfirst(class_basename(Str::snake($this->entity_type))),['design','group_setting','payment_term','bank_transaction'])){
//need to pass these back regardless //need to pass these back regardless
} }
else else

View File

@ -214,9 +214,8 @@ class MatchBankTransactions implements ShouldQueue
$this->invoice = Invoice::withTrashed()->where('id', $invoice->id)->lockForUpdate()->first(); $this->invoice = Invoice::withTrashed()->where('id', $invoice->id)->lockForUpdate()->first();
// if($invoices->count() == 1){ $_amount = false;
// $_amount = $this->available_balance;
// }
if(floatval($this->invoice->balance) < floatval($this->available_balance) && $this->available_balance > 0) if(floatval($this->invoice->balance) < floatval($this->available_balance) && $this->available_balance > 0)
{ {
$_amount = $this->invoice->balance; $_amount = $this->invoice->balance;
@ -230,6 +229,9 @@ class MatchBankTransactions implements ShouldQueue
$this->available_balance = 0; $this->available_balance = 0;
} }
if($_amount)
{
$this->attachable_invoices[] = ['id' => $this->invoice->id, 'amount' => $_amount]; $this->attachable_invoices[] = ['id' => $this->invoice->id, 'amount' => $_amount];
$this->invoice $this->invoice
@ -239,6 +241,7 @@ class MatchBankTransactions implements ShouldQueue
->updatePaidToDate($_amount) ->updatePaidToDate($_amount)
->setCalculatedStatus() ->setCalculatedStatus()
->save(); ->save();
}
}); });

View File

@ -27,6 +27,8 @@ class TriggeredActions extends AbstractService
private $invoice; private $invoice;
private bool $updated = false;
public function __construct(Invoice $invoice, Request $request) public function __construct(Invoice $invoice, Request $request)
{ {
$this->request = $request; $this->request = $request;
@ -37,30 +39,38 @@ class TriggeredActions extends AbstractService
public function run() public function run()
{ {
if ($this->request->has('auto_bill') && $this->request->input('auto_bill') == 'true') { if ($this->request->has('auto_bill') && $this->request->input('auto_bill') == 'true') {
$this->invoice->service()->autoBill(); $this->invoice->service()->autoBill(); //update notification sends automatically for this.
} }
if ($this->request->has('paid') && $this->request->input('paid') == 'true') { if ($this->request->has('paid') && $this->request->input('paid') == 'true') {
$this->invoice = $this->invoice->service()->markPaid()->save(); $this->invoice = $this->invoice->service()->markPaid()->save(); //update notification sends automatically for this.
} }
if ($this->request->has('mark_sent') && $this->request->input('mark_sent') == 'true') { if ($this->request->has('mark_sent') && $this->request->input('mark_sent') == 'true' && $this->invoice->status_id == Invoice::STATUS_DRAFT) {
$this->invoice = $this->invoice->service()->markSent()->save(); $this->invoice = $this->invoice->service()->markSent()->save(); //update notification NOT sent
$this->updated = true;
} }
if ($this->request->has('amount_paid') && is_numeric($this->request->input('amount_paid'))) { if ($this->request->has('amount_paid') && is_numeric($this->request->input('amount_paid'))) {
$this->invoice = $this->invoice->service()->applyPaymentAmount($this->request->input('amount_paid'))->save(); $this->invoice = $this->invoice->service()->applyPaymentAmount($this->request->input('amount_paid'))->save();
$this->updated = false;
} }
if ($this->request->has('send_email') && $this->request->input('send_email') == 'true') { if ($this->request->has('send_email') && $this->request->input('send_email') == 'true') {
$this->invoice->service()->markSent()->touchPdf()->save(); $this->invoice->service()->markSent()->touchPdf()->save();
$this->sendEmail(); $this->sendEmail();
$this->updated = false;
} }
if ($this->request->has('cancel') && $this->request->input('cancel') == 'true') { if ($this->request->has('cancel') && $this->request->input('cancel') == 'true') {
$this->invoice = $this->invoice->service()->handleCancellation()->save(); $this->invoice = $this->invoice->service()->handleCancellation()->save();
$this->updated = false;
} }
if($this->updated)
event('eloquent.updated: App\Models\Invoice', $this->invoice);
return $this->invoice; return $this->invoice;
} }

View File

@ -7,10 +7,10 @@
@foreach ($entity->documents as $document) @foreach ($entity->documents as $document)
<div class="inline-flex items-center space-x-1"> <div class="inline-flex items-center space-x-1">
@if($entity instanceof App\Models\PurchaseOrder) @if($entity instanceof App\Models\PurchaseOrder)
<a href="{{ route('vendor.documents.show', $document->hashed_id) }}" target="_blank" <a href="{{ route('vendor.documents.download', $document->hashed_id) }}" target="_blank"
class="block text-sm button-link text-primary">{{ Illuminate\Support\Str::limit($document->name, 40) }}</a> class="block text-sm button-link text-primary">{{ Illuminate\Support\Str::limit($document->name, 40) }}</a>
@else @else
<a href="{{ route('client.documents.show', $document->hashed_id) }}" target="_blank" <a href="{{ route('client.documents.download', $document->hashed_id) }}" target="_blank"
class="block text-sm button-link text-primary">{{ Illuminate\Support\Str::limit($document->name, 40) }}</a> class="block text-sm button-link text-primary">{{ Illuminate\Support\Str::limit($document->name, 40) }}</a>
@endif @endif
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
@ -30,10 +30,10 @@
@foreach ($entity->company->documents as $document) @foreach ($entity->company->documents as $document)
<div class="inline-flex items-center space-x-1"> <div class="inline-flex items-center space-x-1">
@if($entity instanceof App\Models\PurchaseOrder) @if($entity instanceof App\Models\PurchaseOrder)
<a href="{{ route('vendor.documents.show', $document->hashed_id) }}" target="_blank" <a href="{{ route('vendor.documents.download', $document->hashed_id) }}" target="_blank"
class="block text-sm button-link text-primary">{{ Illuminate\Support\Str::limit($document->name, 40) }}</a> class="block text-sm button-link text-primary">{{ Illuminate\Support\Str::limit($document->name, 40) }}</a>
@else @else
<a href="{{ route('client.documents.show', $document->hashed_id) }}" target="_blank" <a href="{{ route('client.documents.download', $document->hashed_id) }}" target="_blank"
class="block text-sm button-link text-primary">{{ Illuminate\Support\Str::limit($document->name, 40) }}</a> class="block text-sm button-link text-primary">{{ Illuminate\Support\Str::limit($document->name, 40) }}</a>
@endif @endif
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
@ -54,7 +54,7 @@
@foreach ($entity->expense_documents() as $expense) @foreach ($entity->expense_documents() as $expense)
@foreach($expense->documents as $document) @foreach($expense->documents as $document)
<div class="inline-flex items-center space-x-1"> <div class="inline-flex items-center space-x-1">
<a href="{{ route('client.documents.show', $document->hashed_id) }}" target="_blank" <a href="{{ route('client.documents.download', $document->hashed_id) }}" target="_blank"
class="block text-sm button-link text-primary">{{ Illuminate\Support\Str::limit($document->name, 40) }}</a> class="block text-sm button-link text-primary">{{ Illuminate\Support\Str::limit($document->name, 40) }}</a>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
@ -77,7 +77,7 @@
@foreach ($entity->task_documents() as $task) @foreach ($entity->task_documents() as $task)
@foreach($task->documents as $document) @foreach($task->documents as $document)
<div class="inline-flex items-center space-x-1"> <div class="inline-flex items-center space-x-1">
<a href="{{ route('client.documents.show', $document->hashed_id) }}" target="_blank" <a href="{{ route('client.documents.download', $document->hashed_id) }}" target="_blank"
class="block text-sm button-link text-primary">{{ Illuminate\Support\Str::limit($document->name, 40) }}</a> class="block text-sm button-link text-primary">{{ Illuminate\Support\Str::limit($document->name, 40) }}</a>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"