Improvements for service_change and service_cancel
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 37s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s

This commit is contained in:
Deon George 2024-08-16 08:20:58 +10:00
parent 5f66987a3e
commit 3b40e92c48
12 changed files with 186 additions and 327 deletions

View File

@ -330,9 +330,8 @@ class ServiceController extends Controller
$start_at = Carbon::create(Arr::get($request->broadband,'start_at'));
// Get the invoiced items covering the start_at date
foreach ($o->invoiced_items->filter(function($item) use ($start_at) {
return ($item->start_at < $start_at) && ($item->stop_at > $start_at) && ($item->item_type === 0);
}) as $iio)
foreach ($o->invoiced_items
->filter(fn($item)=>($item->start_at < $start_at) && ($item->stop_at > $start_at) && ($item->item_type === 0)) as $iio)
{
// Reverse the original charge
$co = new Charge;
@ -400,7 +399,7 @@ class ServiceController extends Controller
*/
public function service_change_charges_display(Request $request,Service $o)
{
return view('theme.backend.adminlte.a.charge.service_change')
return view('theme.backend.adminlte.service.change_charge')
->with('charges',$this->service_change_charges($request,$o));
}

View File

@ -15,15 +15,15 @@ class CancelRequest extends Mailable
use Queueable, SerializesModels;
public Service $service;
public string $notes;
public ?string $notes;
/**
* Create a new message instance.
*
* @param Service $o
* @param string $notes
* @param string|NULL $notes
*/
public function __construct(Service $o,string $notes='')
public function __construct(Service $o,string $notes=NULL)
{
$this->service = $o;
$this->notes = $notes;
@ -40,7 +40,9 @@ class CancelRequest extends Mailable
switch (get_class($this->service->type)) {
case Service\Broadband::class:
$subject = sprintf('Cancel BROADBAND: %s',$this->service->type->service_address);
$subject = sprintf('Cancel BROADBAND: %s (%s)',
$this->service->type->service_number,
$this->service->type->service_address);
break;
case Service\Phone::class:

View File

@ -15,18 +15,18 @@ class ChangeRequest extends Mailable
use Queueable, SerializesModels;
public Service $service;
public string $notes;
public ?string $notes;
/**
* Create a new message instance.
*
* @param Service $o
* @param string $notes
* @param string|NULL $notes
*/
public function __construct(Service $o,string $notes='')
public function __construct(Service $o,string $notes=NULL)
{
$this->service = $o;
$this->notes = $notes ?? '';
$this->notes = $notes;
}
/**
@ -40,7 +40,9 @@ class ChangeRequest extends Mailable
switch (get_class($this->service->type)) {
case Service\Broadband::class:
$subject = sprintf('Change BROADBAND: %s',$this->service->type->service_address);
$subject = sprintf('Change BROADBAND: %s (%s)',
$this->service->type->service_number,
$this->service->type->service_address);
break;
case Service\Phone::class:

View File

@ -8,6 +8,7 @@ use Illuminate\Support\Facades\Log;
use Leenooks\Traits\ScopeActive;
use App\Casts\CollectionOrNull;
use App\Traits\SiteID;
/**
* CLEANUP NOTES:
@ -15,7 +16,7 @@ use App\Casts\CollectionOrNull;
*/
class Charge extends Model
{
use ScopeActive;
use ScopeActive,SiteID;
protected $casts = [
'attributes' => CollectionOrNull::class,

View File

@ -1,33 +0,0 @@
<div class="row">
<div class="col-12">
<div class="card card-info">
<div class="card-header">
<h3 class="card-title">Pending Transactions</h3>
</div>
<div class="card-body">
<table class="table table-sm">
<thead>
<tr>
<th>Service Charge</th>
<th class="text-right">Quantity</th>
<th class="text-right">Rate</th>
<th class="text-right">Amount</th>
</tr>
</thead>
<tbody>
@foreach ($charges as $co)
<tr>
<td>{{ $co->type_name }}</td>
<td class="text-right">{{ number_format($co->quantity,2) }}</td>
<td class="text-right">${{ number_format($co->amount,2) }}</td>
<td class="text-right">${{ number_format($co->amount*$co->quantity,2) }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>

View File

@ -16,72 +16,35 @@
@section('main-content')
<div class="row">
<div class="col-12">
@include('adminlte::widget.status')
<div class="col-12 col-md-6">
<form method="POST">
@csrf
<div class="card card-dark">
<div class="card-header p-2">
<div class="card-title">Cancelling Service</div>
</div>
<div class="card-body">
<div class="row">
<div class="col-8 col-sm-5 col-md-12 col-lg-6">
<x-leenooks::form.date name="stop_at" icon="fa-calendar" label="Cancel Date" :value="($x=$o->stop_at) ? $x->format('Y-m-d') : '' "/>
</div>
</div>
<div class="row">
<div class="col-6">
<div class="card">
<div class="card-header">
<div class="card-title">Cancelling Service</div>
</div>
<form class="form-horizontal" method="POST">
{{ csrf_field() }}
<div class="card-body">
<div class="form-group row">
<label for="reference" class="col-sm-2 col-form-label text-right">Cancel Date</label>
<div class="col-sm-6">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<input type="text" class="form-control" id="datestop" name="stop_at" value="{{ ($x=$o->stop_at) ? $x->format('Y-m-d') : '' }}">
</div>
</div>
</div>
{{--
@includeIf('theme.backend.adminlte.service.widget.'.$o->product->category.'.order',['o'=>$o->type])
--}}
<div class="form-group row">
<label for="notes" class="col-2 col-form-label text-right">Notes</label>
<div class="col-10">
<textarea class="form-control" rows="4" name="notes">{{ $o->order_info_notes ?? '' }}</textarea>
<div class="col">
<x-leenooks::form.textarea name="notes" label="Notes" placeholder="Please let us know why you are cancelling" :value="$o->order_info_notes ?? ''"/>
</div>
</div>
</div>
<div class="card-footer">
<button type="reset" class="btn btn-secondary mr-2" onclick="window.history.go(-1); return false;">Cancel</button>
<button type="submit" class="btn btn-success">Submit</button>
<x-leenooks::button.cancel/>
<x-leenooks::button.submit class="float-right">Save</x-leenooks::button.submit>
</div>
</div>
</form>
</div>
</div>
</div>
@endsection
@section('page-scripts')
@themejs('//cdn.jsdelivr.net/momentjs/latest/moment.min.js','moment-js')
@themejs('//cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js','daterange-js')
@themecss('//cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css','daterange-css')
<script>
$(document).ready(function() {
$('#datestop').daterangepicker({
singleDatePicker: true,
showDropdowns: true,
minDate: moment().add(30,'days'),
locale: {
format: 'YYYY-MM-DD'
}
});
});
</script>
@append

View File

@ -0,0 +1,29 @@
<div class="card card-info">
<div class="card-header">
<h3 class="card-title">Pending Transactions</h3>
</div>
<div class="card-body">
<table class="table table-sm">
<thead>
<tr>
<th>Service Charge</th>
<th class="text-right">Quantity</th>
<th class="text-right">Rate</th>
<th class="text-right">Amount</th>
</tr>
</thead>
<tbody>
@foreach ($charges as $co)
<tr>
<td>{{ $co->type_name }}</td>
<td class="text-right">{{ number_format($co->quantity,2) }}</td>
<td class="text-right">${{ number_format($co->amount,2) }}</td>
<td class="text-right">${{ number_format($co->amount*$co->quantity,2) }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>

View File

@ -1,3 +1,5 @@
@use(App\Models\Product)
@extends('adminlte::layouts.app')
@section('htmlheader_title')
@ -8,7 +10,7 @@
@endsection
@section('contentheader_title')
Change Service #{{ $o->id }} - WARNING - this is only for Broadband for now
Change Service #{{ $o->id }} - <small><strong>WARNING - this is only for Broadband for now</strong></small>
@endsection
@section('contentheader_description')
{{ $o->sid }}
@ -18,10 +20,10 @@
@section('main-content')
<div class="row">
<div class="col-12 col-lg-4">
<form role="form" method="POST" enctype="multipart/form-data">
<div class="card card-dark">
{{ csrf_field() }}
<form method="POST">
@csrf
<div class="card card-dark">
<div class="card-header">
<h3 class="card-title">Service Information</h3>
</div>
@ -30,114 +32,42 @@
<div class="row">
<div class="col-12">
<!-- SERVICE NUMBER -->
<div class="form-group">
<label for="service_number" class="col-form-label text-right">Service Number</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-phone"></i></span>
</div>
<input type="text" class="form-control" name="broadband[service_number]" value="{{ $o->name_short ?? '' }}" disabled>
</div>
</div>
<x-leenooks::form.text id="service_number" name="broadband[service_number]" icon="fa-phone" label="Service Number" old="broadband.service_number" :value="$o->name_short" disabled/>
</div>
</div>
<div class="row">
<div class="col-12">
<!-- PRODUCT -->
<div class="form-group has-validation">
<label for="product_id">Type</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fas fa-fw fa-hashtag"></i></span>
</div>
<select class="form-control @error('broadband.product_id') is-invalid @enderror" id="product_id" name="broadband[product_id]" required>
<!-- @todo TO DO LIMIT THIS TO OF THE SAME OFFERING TYPE AND SORT BY NAME -->
@foreach (\App\Models\Product::get() as $po)
@if (! $po->category || ($po->category !== $o->product->category)) @continue @endif
<option value="{{ $po->id }}" {{ $po->id == old('broadband.product_id',$np->id) ? 'selected' : '' }}>{{ $po->name }}</option>
@endforeach
</select>
<span class="invalid-feedback" role="alert">
@error('broadband.product_id')
{{ $message }}
@else
Type is required.
@enderror
</span>
</div>
<span class="input-helper">Product - {{ $o->product->category_name }}.</span>
</div>
<x-leenooks::form.select id="product_id" name="broadband[product_id]" icon="fa-list" label="Product" :helper="$o->product->category_name" groupby="active"
:value="$np->id"
:options="Product::get()->filter(fn($item)=>$item->category === $np->category)->sortBy('name')->sortByDesc('active')->transform(fn($item)=>['id'=>$item->id,'active'=>$item->active,'value'=>$item->name])" required/>
</div>
</div>
<div class="row">
<div class="col-12">
<!-- CHANGE DATE -->
<div class="form-group has-validation">
<label for="start_at" class="col-form-label text-right">Change Date</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<input type="date" class="form-control @error('broadband.start_at') is-invalid @enderror" id="start_at" name="broadband[start_at]" value="{{ $np->pivot->effective_at ?? $np->pivot->ordered_at }}" required>
<span class="invalid-feedback" role="alert">
@error('broadband.start_at')
{{ $message }}
@else
Type is required.
@enderror
</span>
</div>
</div>
<x-leenooks::form.date id="start_at" name="broadband[start_at]" icon="fa-calendar" label="Change Date" old="broadband.start_at" :value="$np->pivot->effective_at ?? $np->pivot->ordered_at" required/>
</div>
</div>
<div class="row">
<div class="col-6">
<!-- CHANGE FEE -->
<div class="form-group has-validation">
<label for="change_fee" class="col-form-label text-right">Change Fee</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-dollar-sign"></i></span>
</div>
<input type="text" class="form-control @error('broadband.change_fee') is-invalid @enderror" id="change_fee" name="broadband[change_fee]" value="0">
<span class="invalid-feedback" role="alert">
@error('broadband.change_fee')
{{ $message }}
@enderror
</span>
</div>
</div>
<x-leenooks::form.text id="change_fee" name="broadband[change_fee]" icon="fa-dollar-sign" label="Change Fee" old="broadband.change_fee" value="0"/>
</div>
<div class="col-6">
<!-- NEW PRICE -->
<div class="form-group has-validation">
<label for="price" class="col-form-label text-right">New Price <small>(Override)</small></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-dollar-sign"></i></span>
</div>
<input type="text" class="form-control @error('broadband.price') is-invalid @enderror" id="price" name="broadband[price]" value="{{ $o->price }}">
<span class="invalid-feedback" role="alert">
@error('broadband.price')
{{ $message }}
@enderror
</span>
</div>
</div>
<x-leenooks::form.text id="price" name="broadband[price]" icon="fa-dollar-sign" label="New Price" helper="Price Override" old="broadband.price" value=""/>
</div>
</div>
<div class="row">
<div class="col-12">
<a href="{{ url('u/service',[$o->id]) }}" class="btn btn-danger">Cancel</a>
@can('wholesaler')
<button type="submit" name="submit" class="btn btn-success mr-0 float-right">@if ($site->exists)Save @else Add @endif</button>
@endcan
<x-leenooks::button.reset/>
<x-leenooks::button.submit class="float-right">Save</x-leenooks::button.submit>
</div>
</div>
</div>
@ -146,7 +76,10 @@
</div>
<!-- Current Plan -->
<!-- @todo Refresh the Plan Information with the new plan -->
<div class="col-12 col-lg-8">
<div class="row">
<div class="col">
<div class="card card-dark">
<div class="card-header">
<h3 class="card-title">Plan Information</h3>
@ -158,13 +91,19 @@
</div>
</div>
</div>
<div class="row">
<div class="col">
<div id="transactions"></div>
</div>
</div>
</div>
</div>
@endsection
@section('page-scripts')
@css(select2)
@js(select2,autofocus)
@pa(select2,autofocus)
@section('page-scripts')
<script type="text/javascript">
function pendingtrans() {
var pid = $('#product_id').val();
@ -182,7 +121,7 @@
url: '{{ url('r/service_change_charges',[$o->id]) }}',
timeout: 2000,
error: function(x) {
spinner.toggleClass('d-none').toggleClass('fa-spin');
//spinner.toggleClass('d-none').toggleClass('fa-spin');
alert('Failed to submit');
},
success: function(data) {

View File

@ -1,3 +1,5 @@
@use(Carbon\Carbon)
@extends('adminlte::layouts.app')
@section('htmlheader_title')
@ -16,76 +18,45 @@
@section('main-content')
<div class="row">
<div class="col-12">
@include('adminlte::widget.status')
<div class="col-12 col-md-6">
<form method="POST">
@csrf
<div class="card card-dark">
<div class="card-header p-2">
<div class="card-title">Change Service</div>
</div>
<div class="card-body">
<div class="row">
<div class="col-8 col-sm-5 col-md-12 col-lg-6">
<x-leenooks::form.date name="change_date" icon="fa-calendar" label="Request Change Date" :value="Carbon::now()->addDays(7)->format('Y-m-d')"/>
</div>
</div>
<div class="row">
<div class="col-6">
<div class="card">
<div class="card-header">
<div class="card-title">Change Service</div>
</div>
<form class="form-horizontal" method="POST">
{{ csrf_field() }}
<div class="card-body">
<div class="form-group row">
<label for="reference" class="col-sm-2 col-form-label text-right">Request Change Date</label>
<div class="col-sm-6">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<input type="text" class="form-control" id="datestop" name="change_date" value="{{ ($x=\Carbon\Carbon::now()->addDays(7)) ? $x->format('Y-m-d') : '' }}">
</div>
</div>
</div>
<div class="col">
@includeIf('theme.backend.adminlte.service.widget.'.$o->product->category.'.change',['o'=>$o->type])
</div>
</div>
<div class="form-group row">
<label for="notes" class="col-2 col-form-label text-right">Notes</label>
<div class="col-10">
<textarea class="form-control" rows="4" name="notes" placeholder="Please let us know what you would like to change your service to">{{ $o->order_info_notes ?? '' }}</textarea>
<div class="row">
<div class="col">
<x-leenooks::form.textarea name="notes" label="Notes" placeholder="Please let us know what you would like to change your service to" :value="$o->order_info_notes ?? ''"/>
</div>
</div>
</div>
<div class="card-footer">
<button type="reset" class="btn btn-secondary mr-2" onclick="window.history.go(-1); return false;">Cancel</button>
<button type="submit" class="btn btn-success">Submit</button>
<x-leenooks::button.cancel/>
<x-leenooks::button.submit class="float-right">Save</x-leenooks::button.submit>
</div>
</div>
</form>
</div>
</div>
<div class="col-6">
<div class="card">
<div id="product_info"></div>
</div>
</div>
</div>
@endsection
@section('page-scripts')
@themejs('//cdn.jsdelivr.net/momentjs/latest/moment.min.js','moment-js')
@themejsc('//cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js','daterange-js')
@themecss('//cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css','daterange-css')
<script>
$(document).ready(function() {
$('#datestop').daterangepicker({
singleDatePicker: true,
showDropdowns: true,
minDate: moment().add(7,'days'),
locale: {
format: 'YYYY-MM-DD'
}
});
});
</script>
@append

View File

@ -1,31 +1,11 @@
<div class="form-group row">
<label for="reference" class="col-sm-2 col-form-label text-right">Product</label>
<div class="col-sm-6">
<div class="input-group">
<select class="form-control" id="product_id" name="product_id">
<option value="">&nbsp;</option>
@php
$po = $selected = NULL;
@endphp
@foreach (\App\Models\Product::active()->get()->filter(function($item) { return get_class($item->type) === \App\Models\Product\Broadband::class; })->sortBy('name') as $o)
@php
if ($o->id == old('product_id')) {
$selected = 'selected';
$po = $o;
} else {
$selected = NULL;
}
@endphp
<option value="{{ $o->id }}" {{ $selected }}>{{ $o->name }}</option>
@endforeach
</select>
</div>
</div>
@use(App\Models\Product)
@use(App\Models\Product\Broadband)
<x-leenooks::form.select id="product_id" name="product_id" icon="fa-list" label="Product" :helper="$o->category_name"
:value="$o->id"
:options="Product::active()->get()->filter(fn($item)=>get_class($item->type) === Broadband::class)->sortBy('name')->sortByDesc('active')->transform(fn($item)=>['id'=>$item->id,'active'=>$item->active,'value'=>$item->name])" required/>
<div class="offset-2 col-10">
<strong>NOTE</strong>: A plan setup fee is normally not applicable to Broadband changes, but a plan change fee normally is.
</div>
</div>
@section('page-scripts')
<script>

View File

@ -62,13 +62,15 @@
@if($o->status !== 'cancel-pending')
<tr>
<th>Next Invoice</th>
<td>@if($o->suspend_billing)<del>@endif{{ $o->invoice_next->format('Y-m-d') }}@if($o->suspend_billing)</del> <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>
@if($o->invoice_next)
<tr>
<th>Next Estimated Invoice</th>
<td>${{ number_format($o->next_invoice_items()->sum('total'),2) }} <sup>*</sup></td>
</tr>
@endif
@endif
<tr>
<th>Payment Method</th>
<td>@if($o->billing)Direct Debit @else Invoice @endif</td>

View File

@ -1,9 +1,11 @@
<!-- $pdo=Product::class -->
<div class="col-md-12">
<p>{!! $pdo->name !!}</p>
<div class="card card-primary">
<div class="card-header p-2">
<div class="card-title">{!! $pdo->name !!}</div>
</div>
<table class="table table-condensed">
<div class="card-body">
<table class="table table-sm">
<tr>
<th>Type</th>
<td class="text-right">{{ $pdo->category_name }}</td>
@ -42,3 +44,5 @@
</tr>
</tfoot>
</table>
</div>
</div>