From 3ae588041fff474c1842f0125df14322231f7a13 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 18 May 2025 23:38:48 +1000 Subject: [PATCH] Fix rendering internal cost/revenue when in contract but not yet invoiced --- app/Models/Service.php | 6 ++++++ .../backend/adminlte/service/widget/internal.blade.php | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Models/Service.php b/app/Models/Service.php index 3075f7d..6c6c7b3 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -944,6 +944,9 @@ class Service extends Model implements IDs { $max = max($date,$this->getCancelDateAttribute())->clone(); + if (! $this->getPaidToAttribute()) + return $this->account->taxed($this->getContractTermAttribute()*$this->getBillingChargeNormalisedAttribute()); + if ($this->getPaidToAttribute()->lessThan($max)) { $d = $this->getPaidToAttribute()->diffInDays($max); @@ -981,6 +984,9 @@ class Service extends Model implements IDs { $max = max($date,$this->getCancelDateAttribute())->clone(); + if (! $this->getInvoicedToAttribute()) + return $this->account->taxed($this->getContractTermAttribute()*$this->getBillingChargeNormalisedAttribute()); + if ($this->getInvoicedToAttribute()->lessThan($max)) { $d = $this->getInvoicedToAttribute()->diffInDays($max); diff --git a/resources/views/theme/backend/adminlte/service/widget/internal.blade.php b/resources/views/theme/backend/adminlte/service/widget/internal.blade.php index a5f2c5f..fe6668c 100644 --- a/resources/views/theme/backend/adminlte/service/widget/internal.blade.php +++ b/resources/views/theme/backend/adminlte/service/widget/internal.blade.php @@ -130,8 +130,8 @@ Contract Left @if($o->isContract()) - ${{ number_format($o->billing_charge_to($o->contract_end),2) }} ({{ $o->paid_to->format('Y-m-d') }}) - ${{ number_format($o->billing_cost_to($o->contract_end),2) }} ({{ $o->invoiced_to->format('Y-m-d') }}) + ${{ number_format($o->billing_charge_to($o->contract_end),2) }} ({{ $o->paid_to?->format('Y-m-d') }}) + ${{ number_format($o->billing_cost_to($o->contract_end),2) }} ({{ $o->invoiced_to?->format('Y-m-d') }}) {{ $o->contract_end->format('Y-m-d') }}
({{ $o->contract_end->diffForHumans(now(),CarbonInterface::DIFF_RELATIVE_TO_OTHER,FALSE,2) }} today) @else