Service display pricing, as a result of moving to psql. Service information updates

This commit is contained in:
Deon George 2024-07-24 20:17:23 +10:00
parent 79237868cb
commit ddd44b643f
3 changed files with 15 additions and 19 deletions

View File

@ -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 */

View File

@ -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');
}
/**

View File

@ -1,4 +1,4 @@
<!-- $o = App\Models\Service -->
<!-- $o=Service::class -->
<div class="card">
@if($o->external_billing)
<div class="ribbon-wrapper ribbon-lg">
@ -20,7 +20,7 @@
</tr>
<tr>
<th>Status</th>
<td>@include('theme.backend.adminlte.service.widget.status')</td>
<td><x-button.status :status="$o->status" :substatus="$o->order_status"/></td>
</tr>
@if ($o->order_status == 'ORDER-SENT')
<tr>
@ -34,13 +34,7 @@
<td>{{ $o->start_at->format('Y-m-d') }}</td>
</tr>
@endif
@if ($o->stop_at)
<tr>
<th>Cancellation Date</th>
<td>{{ $o->stop_at->format('Y-m-d') }}</td>
</tr>
@endif
@if (($o->active OR $o->isPending()) AND ! $o->external_billing)
@if (($o->active || $o->isPending()) && (! $o->external_billing))
<tr>
<th>Billed</th>
<td>{{ $o->billing_interval_string }}</td>
@ -53,7 +47,7 @@
<td>${{ number_format($o->billing_charge,2) }}</td>
@endif
</tr>
@if($o->active AND $o->invoice_to)
@if($o->active && $o->invoice_to)
<tr>
<th>Invoiced To</th>
<td>{{ $o->invoice_to->format('Y-m-d') }}</td>
@ -67,7 +61,7 @@
@endif
<tr>
<th>Next Invoice</th>
<td>@if ($o->suspend_billing)<strike>@endif{{ $o->invoice_next->format('Y-m-d') }}@if ($o->suspend_billing)</strike> <strong>SUSPENDED</strong>@endif</td>
<td>@if ($o->suspend_billing)<del>@endif{{ $o->invoice_next->format('Y-m-d') }}@if ($o->suspend_billing)</del> <strong>SUSPENDED</strong>@endif</td>
</tr>
<tr>
<th>Next Estimated Invoice</th>
@ -81,16 +75,15 @@
@elseif($o->wasCancelled())
<tr>
<th>Cancelled</th>
<!-- @todo This should show the cancelled date -->
<td>{!! $o->stop_at ? $o->stop_at->format('Y-m-d') : ($o->paid_to ? $o->paid_to->format('Y-m-d') : '').'<sup>*</sup>' !!}</td>
<td>{{ ($o->stop_at ?: $o->paid_to)?->format('Y-m-d') }}</td>
</tr>
@endif
</table>
</div>
@if($o->active OR $o->isPending())
@if($o->active || $o->isPending())
<div class="card-footer sm">
<strong><sup>*</sup>NOTE:</strong> Estimated Invoice does not include any setup, connection nor all current billing cycle usage charges.
</div>
@endif
</div>
</div>