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 Illuminate\Support\Str;
use Leenooks\Traits\ScopeActive; use Leenooks\Traits\ScopeActive;
use App\Casts\CollectionOrNull;
use App\Http\Controllers\AccountingController; use App\Http\Controllers\AccountingController;
use App\Interfaces\{IDs,ProductItem}; use App\Interfaces\{IDs,ProductItem};
use App\Traits\{ProductDetails,ProviderRef,SiteID}; use App\Traits\{ProductDetails,ProviderRef};
/** /**
* Class Product * Class Product
@ -65,10 +66,10 @@ use App\Traits\{ProductDetails,ProviderRef,SiteID};
*/ */
class Product extends Model implements IDs class Product extends Model implements IDs
{ {
use HasFactory,SiteID,ProductDetails,ScopeActive,ProviderRef; use HasFactory,ProductDetails,ScopeActive,ProviderRef;
protected $casts = [ protected $casts = [
'pricing'=>'collection', 'pricing' => CollectionOrNull::class,
]; ];
/* STATIC */ /* STATIC */

View File

@ -901,7 +901,9 @@ class Service extends Model implements IDs
*/ */
public function getStatusAttribute(): string 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"> <div class="card">
@if($o->external_billing) @if($o->external_billing)
<div class="ribbon-wrapper ribbon-lg"> <div class="ribbon-wrapper ribbon-lg">
@ -20,7 +20,7 @@
</tr> </tr>
<tr> <tr>
<th>Status</th> <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> </tr>
@if ($o->order_status == 'ORDER-SENT') @if ($o->order_status == 'ORDER-SENT')
<tr> <tr>
@ -34,13 +34,7 @@
<td>{{ $o->start_at->format('Y-m-d') }}</td> <td>{{ $o->start_at->format('Y-m-d') }}</td>
</tr> </tr>
@endif @endif
@if ($o->stop_at) @if (($o->active || $o->isPending()) && (! $o->external_billing))
<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)
<tr> <tr>
<th>Billed</th> <th>Billed</th>
<td>{{ $o->billing_interval_string }}</td> <td>{{ $o->billing_interval_string }}</td>
@ -53,7 +47,7 @@
<td>${{ number_format($o->billing_charge,2) }}</td> <td>${{ number_format($o->billing_charge,2) }}</td>
@endif @endif
</tr> </tr>
@if($o->active AND $o->invoice_to) @if($o->active && $o->invoice_to)
<tr> <tr>
<th>Invoiced To</th> <th>Invoiced To</th>
<td>{{ $o->invoice_to->format('Y-m-d') }}</td> <td>{{ $o->invoice_to->format('Y-m-d') }}</td>
@ -67,7 +61,7 @@
@endif @endif
<tr> <tr>
<th>Next Invoice</th> <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>
<tr> <tr>
<th>Next Estimated Invoice</th> <th>Next Estimated Invoice</th>
@ -81,16 +75,15 @@
@elseif($o->wasCancelled()) @elseif($o->wasCancelled())
<tr> <tr>
<th>Cancelled</th> <th>Cancelled</th>
<!-- @todo This should show the cancelled date --> <td>{{ ($o->stop_at ?: $o->paid_to)?->format('Y-m-d') }}</td>
<td>{!! $o->stop_at ? $o->stop_at->format('Y-m-d') : ($o->paid_to ? $o->paid_to->format('Y-m-d') : '').'<sup>*</sup>' !!}</td>
</tr> </tr>
@endif @endif
</table> </table>
</div> </div>
@if($o->active OR $o->isPending()) @if($o->active || $o->isPending())
<div class="card-footer sm"> <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. <strong><sup>*</sup>NOTE:</strong> Estimated Invoice does not include any setup, connection nor all current billing cycle usage charges.
</div> </div>
@endif @endif
</div> </div>