From ddd44b643f3e382a20387aea24ad0080d9ba8675 Mon Sep 17 00:00:00 2001 From: Deon George Date: Wed, 24 Jul 2024 20:17:23 +1000 Subject: [PATCH] Service display pricing, as a result of moving to psql. Service information updates --- app/Models/Product.php | 7 +++--- app/Models/Service.php | 4 +++- .../service/widget/information.blade.php | 23 +++++++------------ 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/app/Models/Product.php b/app/Models/Product.php index 9309074..dd950fb 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -13,9 +13,10 @@ use Illuminate\Support\Facades\File; use Illuminate\Support\Str; use Leenooks\Traits\ScopeActive; +use App\Casts\CollectionOrNull; use App\Http\Controllers\AccountingController; use App\Interfaces\{IDs,ProductItem}; -use App\Traits\{ProductDetails,ProviderRef,SiteID}; +use App\Traits\{ProductDetails,ProviderRef}; /** * Class Product @@ -65,10 +66,10 @@ use App\Traits\{ProductDetails,ProviderRef,SiteID}; */ class Product extends Model implements IDs { - use HasFactory,SiteID,ProductDetails,ScopeActive,ProviderRef; + use HasFactory,ProductDetails,ScopeActive,ProviderRef; protected $casts = [ - 'pricing'=>'collection', + 'pricing' => CollectionOrNull::class, ]; /* STATIC */ diff --git a/app/Models/Service.php b/app/Models/Service.php index eaddfa8..3125087 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -901,7 +901,9 @@ class Service extends Model implements IDs */ public function getStatusAttribute(): string { - return $this->active ? $this->order_status : 'INACTIVE'; + return $this->active + ? strtolower($this->order_status) + : ((strtolower($this->order_status) === 'cancelled') ? 'cancelled' : 'inactive'); } /** diff --git a/resources/views/theme/backend/adminlte/service/widget/information.blade.php b/resources/views/theme/backend/adminlte/service/widget/information.blade.php index 44a151f..2bfe85c 100644 --- a/resources/views/theme/backend/adminlte/service/widget/information.blade.php +++ b/resources/views/theme/backend/adminlte/service/widget/information.blade.php @@ -1,4 +1,4 @@ - +
@if($o->external_billing)
@@ -20,7 +20,7 @@ Status - @include('theme.backend.adminlte.service.widget.status') + @if ($o->order_status == 'ORDER-SENT') @@ -34,13 +34,7 @@ {{ $o->start_at->format('Y-m-d') }} @endif - @if ($o->stop_at) - - Cancellation Date - {{ $o->stop_at->format('Y-m-d') }} - - @endif - @if (($o->active OR $o->isPending()) AND ! $o->external_billing) + @if (($o->active || $o->isPending()) && (! $o->external_billing)) Billed {{ $o->billing_interval_string }} @@ -53,7 +47,7 @@ ${{ number_format($o->billing_charge,2) }} @endif - @if($o->active AND $o->invoice_to) + @if($o->active && $o->invoice_to) Invoiced To {{ $o->invoice_to->format('Y-m-d') }} @@ -67,7 +61,7 @@ @endif Next Invoice - @if ($o->suspend_billing)@endif{{ $o->invoice_next->format('Y-m-d') }}@if ($o->suspend_billing) SUSPENDED@endif + @if ($o->suspend_billing)@endif{{ $o->invoice_next->format('Y-m-d') }}@if ($o->suspend_billing) SUSPENDED@endif Next Estimated Invoice @@ -81,16 +75,15 @@ @elseif($o->wasCancelled()) Cancelled - - {!! $o->stop_at ? $o->stop_at->format('Y-m-d') : ($o->paid_to ? $o->paid_to->format('Y-m-d') : '').'*' !!} + {{ ($o->stop_at ?: $o->paid_to)?->format('Y-m-d') }} @endif
- @if($o->active OR $o->isPending()) + @if($o->active || $o->isPending()) @endif -
+ \ No newline at end of file