Minor bug fixes rendering services and invoicing

This commit is contained in:
Deon George 2020-02-13 22:18:20 +11:00
parent c5f171da95
commit f8d998d935
4 changed files with 11 additions and 11 deletions

View File

@ -37,16 +37,16 @@ class Service extends Model
'status', 'status',
]; ];
protected $casts = [
'order_info'=>'array',
];
protected $dates = [ protected $dates = [
'date_last_invoice', 'date_last_invoice',
'date_next_invoice', 'date_next_invoice',
'date_start', 'date_start',
'date_end', 'date_end',
]; ];
protected $casts = [
'order_info'=>'array',
];
public $dateFormat = 'U'; public $dateFormat = 'U';
protected $table = 'ab_service'; protected $table = 'ab_service';
@ -334,7 +334,7 @@ class Service extends Model
? $last->addDay() ? $last->addDay()
: ($this->date_next_invoice ? $this->date_next_invoice->clone() : Carbon::now()); : ($this->date_next_invoice ? $this->date_next_invoice->clone() : Carbon::now());
return $date; return request()->wantsJson() ? $date->format('Y-m-d') : $date;
} }
/** /**
@ -803,7 +803,9 @@ class Service extends Model
} }
// If the service is active, there will be service charges // If the service is active, there will be service charges
if ($this->active OR $this->isPending()) { if ((! $this->invoice_items->filter(function($item) { return $item->item_type==0 AND ! $item->exists; })->sum('total'))
AND ($this->active OR $this->isPending()))
{
do { do {
$o = new InvoiceItem; $o = new InvoiceItem;
$o->active = TRUE; $o->active = TRUE;

View File

@ -1,9 +1,9 @@
<table class="table"> <table class="table">
<tr> <tr>
<th colspan="3">{{ $o->name }}</th><th class="text-right">${{ number_format($o->next_invoice_items()->sum('total'),2) }}</th> <th colspan="3">{{ $o->name }}</th><th class="text-right">${{ number_format(($x=$o->next_invoice_items(TRUE))->sum('total'),2) }}</th>
</tr> </tr>
@foreach ($o->next_invoice_items() as $io) @foreach ($x as $io)
<tr> <tr>
<td class="pt-0 pb-1">&nbsp;</td> <td class="pt-0 pb-1">&nbsp;</td>
<td class="pt-0 pb-1">{{ $io->item_type_name }}</td> <td class="pt-0 pb-1">{{ $io->item_type_name }}</td>

View File

@ -34,7 +34,7 @@
</tr> </tr>
<tr> <tr>
<th>Next Estimated Invoice</th> <th>Next Estimated Invoice</th>
<td>${{ number_format($o->next_invoice_items()->sum('total'),2) }} <sup>*</sup></td> <td>${{ number_format($o->next_invoice_items(TRUE)->sum('total'),2) }} <sup>*</sup></td>
</tr> </tr>
<tr> <tr>
<th>Payment Method</th> <th>Payment Method</th>

View File

@ -5,12 +5,10 @@
@endsection @endsection
@section('main-content') @section('main-content')
<div class="error-page"> <div class="error-page">
<h2 class="headline text-red">500</h2> <h2 class="headline text-red">500</h2>
<div class="error-content"> <div class="error-content">
<h3><i class="fa fa-warning text-red"></i> Oops! {{ trans('adminlte_lang::message.somethingwrong') }}</h3> <h3><i class="fa fa-warning text-red"></i> Oops! {{ trans('adminlte_lang::message.somethingwrong') }}</h3>
<h4><i class="text-red"></i> {{ trans($exception->getMessage()) }}</h4>
<p> <p>
{{ trans('adminlte_lang::message.wewillwork') }} {{ trans('adminlte_lang::message.wewillwork') }}
{{ trans('adminlte_lang::message.mainwhile') }} <a href='{{ url('/home') }}'>{{ trans('adminlte_lang::message.returndashboard') }}</a>. {{ trans('adminlte_lang::message.mainwhile') }} <a href='{{ url('/home') }}'>{{ trans('adminlte_lang::message.returndashboard') }}</a>.