From 84a985ec0e1ec238d38de3a662fc624b1522357e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Nov 2022 18:34:23 +1100 Subject: [PATCH 1/3] Add checks for bank_transaction in basecontroller --- app/Http/Controllers/BaseController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/BaseController.php b/app/Http/Controllers/BaseController.php index 991489968d..eda1ef6af9 100644 --- a/app/Http/Controllers/BaseController.php +++ b/app/Http/Controllers/BaseController.php @@ -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 if(lcfirst(class_basename(Str::snake($this->entity_type))) == 'user') $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 } else From 4830154ac60c38fc92e23ce58d69a65b260e8d97 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 14 Nov 2022 07:30:16 +1100 Subject: [PATCH 2/3] Change UX for downloading documents from the client portal --- app/Jobs/Bank/MatchBankTransactions.php | 49 ++++++++++--------- .../components/entity-documents.blade.php | 12 ++--- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/app/Jobs/Bank/MatchBankTransactions.php b/app/Jobs/Bank/MatchBankTransactions.php index bb366453c1..17e3a61a96 100644 --- a/app/Jobs/Bank/MatchBankTransactions.php +++ b/app/Jobs/Bank/MatchBankTransactions.php @@ -214,31 +214,34 @@ class MatchBankTransactions implements ShouldQueue $this->invoice = Invoice::withTrashed()->where('id', $invoice->id)->lockForUpdate()->first(); - // if($invoices->count() == 1){ - // $_amount = $this->available_balance; - // } - if(floatval($this->invoice->balance) < floatval($this->available_balance) && $this->available_balance > 0) - { - $_amount = $this->invoice->balance; - $this->applied_amount += $this->invoice->balance; - $this->available_balance = $this->available_balance - $this->invoice->balance; - } - elseif(floatval($this->invoice->balance) >= floatval($this->available_balance) && $this->available_balance > 0) - { - $_amount = $this->available_balance; - $this->applied_amount += $this->available_balance; - $this->available_balance = 0; - } + $_amount = false; - $this->attachable_invoices[] = ['id' => $this->invoice->id, 'amount' => $_amount]; + if(floatval($this->invoice->balance) < floatval($this->available_balance) && $this->available_balance > 0) + { + $_amount = $this->invoice->balance; + $this->applied_amount += $this->invoice->balance; + $this->available_balance = $this->available_balance - $this->invoice->balance; + } + elseif(floatval($this->invoice->balance) >= floatval($this->available_balance) && $this->available_balance > 0) + { + $_amount = $this->available_balance; + $this->applied_amount += $this->available_balance; + $this->available_balance = 0; + } - $this->invoice - ->service() - ->setExchangeRate() - ->updateBalance($_amount * -1) - ->updatePaidToDate($_amount) - ->setCalculatedStatus() - ->save(); + if($_amount) + { + + $this->attachable_invoices[] = ['id' => $this->invoice->id, 'amount' => $_amount]; + + $this->invoice + ->service() + ->setExchangeRate() + ->updateBalance($_amount * -1) + ->updatePaidToDate($_amount) + ->setCalculatedStatus() + ->save(); + } }); diff --git a/resources/views/portal/ninja2020/components/entity-documents.blade.php b/resources/views/portal/ninja2020/components/entity-documents.blade.php index b288e9c920..989203b5ad 100644 --- a/resources/views/portal/ninja2020/components/entity-documents.blade.php +++ b/resources/views/portal/ninja2020/components/entity-documents.blade.php @@ -7,10 +7,10 @@ @foreach ($entity->documents as $document)
@if($entity instanceof App\Models\PurchaseOrder) - {{ Illuminate\Support\Str::limit($document->name, 40) }} @else - {{ Illuminate\Support\Str::limit($document->name, 40) }} @endif company->documents as $document)
@if($entity instanceof App\Models\PurchaseOrder) - {{ Illuminate\Support\Str::limit($document->name, 40) }} @else - {{ Illuminate\Support\Str::limit($document->name, 40) }} @endif expense_documents() as $expense) @foreach($expense->documents as $document)
- {{ Illuminate\Support\Str::limit($document->name, 40) }} task_documents() as $task) @foreach($task->documents as $document)
- {{ Illuminate\Support\Str::limit($document->name, 40) }} Date: Mon, 14 Nov 2022 07:53:23 +1100 Subject: [PATCH 3/3] ensure we post event notifications when the invoice is marked as sent --- app/Services/Invoice/TriggeredActions.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/Services/Invoice/TriggeredActions.php b/app/Services/Invoice/TriggeredActions.php index 99368b156e..76d9a0623a 100644 --- a/app/Services/Invoice/TriggeredActions.php +++ b/app/Services/Invoice/TriggeredActions.php @@ -27,6 +27,8 @@ class TriggeredActions extends AbstractService private $invoice; + private bool $updated = false; + public function __construct(Invoice $invoice, Request $request) { $this->request = $request; @@ -37,30 +39,38 @@ class TriggeredActions extends AbstractService public function run() { 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') { - $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') { - $this->invoice = $this->invoice->service()->markSent()->save(); + 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(); //update notification NOT sent + $this->updated = true; } 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->updated = false; } if ($this->request->has('send_email') && $this->request->input('send_email') == 'true') { $this->invoice->service()->markSent()->touchPdf()->save(); $this->sendEmail(); + $this->updated = false; } if ($this->request->has('cancel') && $this->request->input('cancel') == 'true') { $this->invoice = $this->invoice->service()->handleCancellation()->save(); + $this->updated = false; } + if($this->updated) + event('eloquent.updated: App\Models\Invoice', $this->invoice); + + return $this->invoice; }