diff --git a/app/Http/Controllers/ServiceController.php b/app/Http/Controllers/ServiceController.php index 647a73e..8bf2028 100644 --- a/app/Http/Controllers/ServiceController.php +++ b/app/Http/Controllers/ServiceController.php @@ -96,6 +96,7 @@ class ServiceController extends Controller $co->save(); $o->product_id = Arr::get($request->broadband,'product_id'); + $o->price = Arr::get($request->broadband,'price'); $o->order_status = 'ACTIVE'; $o->save(); @@ -345,7 +346,7 @@ class ServiceController extends Controller $co->type = $iio->item_type; $co->start_at = $start_at; $co->stop_at = $iio->stop_at; - $co->amount = $po->base_charge; + $co->amount = Arr::get($request->broadband,'price') ?: $po->base_charge; $co->taxable = TRUE; // @todo this should be determined $co->quantity = $start_at->diff($iio->stop_at)->days/$iio->start_at->diff($iio->stop_at)->days; $charges->push($co); diff --git a/app/Http/Requests/ServiceChangeRequest.php b/app/Http/Requests/ServiceChangeRequest.php index a313fb7..91a074b 100644 --- a/app/Http/Requests/ServiceChangeRequest.php +++ b/app/Http/Requests/ServiceChangeRequest.php @@ -32,6 +32,7 @@ class ServiceChangeRequest extends FormRequest return [ 'broadband.product_id' => 'required|exists:products,id', 'broadband.change_fee' => 'nullable|numeric', + 'broadband.price' => 'nullable|numeric', 'broadband.start_at' => 'required|date', // @todo Check that it is not more than 1 billing cycle ago, and not future. ]; } diff --git a/app/Models/Product.php b/app/Models/Product.php index c9aa3f4..83de383 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -184,11 +184,11 @@ class Product extends Model implements IDs /** * Return the type of service is provided. eg: Broadband, Phone. * - * @return string + * @return string|null */ - public function getCategoryAttribute(): string + public function getCategoryAttribute(): ?string { - return $this->supplied->getCategoryAttribute(); + return $this->supplied ? $this->supplied->getCategoryAttribute() : NULL; } /** diff --git a/app/Models/Service.php b/app/Models/Service.php index 8eb9f84..b0c79d6 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -35,6 +35,7 @@ use App\Traits\SiteID; * + billed_to : When this service has been billed to // @todo rename all references to invoice_to * + category : The type of service this is, eg: broadband, phone * + category_name : The type of service this is, eg: Broadband, Telephone (in human friendly) + * + isChargedOverride : Has the price been overridden? * + contract_term : The term that this service must be active * + contract_end : The date that the contract ends for this service * + name : Service short name with service address @@ -1216,6 +1217,11 @@ class Service extends Model implements IDs AND ! in_array($this->order_status,array_merge(self::INACTIVE_STATUS,['INACTIVE'])); } + public function isChargeOverriden(): bool + { + return (! is_null($this->price)) || (! is_null($this->price_override)); + } + /** * Generate a collection of invoice_item objects that will be billed for the next invoice * diff --git a/resources/views/theme/backend/adminlte/service/change_pending.blade.php b/resources/views/theme/backend/adminlte/service/change_pending.blade.php index 9a5fab0..c406a44 100644 --- a/resources/views/theme/backend/adminlte/service/change_pending.blade.php +++ b/resources/views/theme/backend/adminlte/service/change_pending.blade.php @@ -17,7 +17,7 @@ @section('main-content')
#{{ $s->id }}: {{ $s->name }} | @endif -#{{ $o->product->id }}: {{ $o->product->name }} | +#{{ $p->id }}: {{ $p->name }} | @if ($s->exists) -{{ $o->product->category_name }} | +{{ $p->category_name }} | @endif|||||||||||||
Setup | @if ($s->exists)${{ number_format($a=\App\Models\Tax::tax_calc($s->setup_cost,$o->account->taxes),2) }} | -${{ number_format($b=\App\Models\Tax::tax_calc($o->product->setup_charge,$o->account->taxes),2) }} | +${{ number_format($b=\App\Models\Tax::tax_calc($p->setup_charge,$o->account->taxes),2) }} | {!! markup($a,$b) !!} | @else- | @@ -47,7 +47,7 @@||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Billing Price | @if ($s->exists) -${{ number_format($a=\App\Models\Tax::tax_calc($s->base_cost*\App\Models\Invoice::billing_change($s->billing_interval,$o->product->billing_interval),$o->account->taxes),2) }} | +${{ number_format($a=\App\Models\Tax::tax_calc($s->base_cost*\App\Models\Invoice::billing_change($s->billing_interval,$p->billing_interval),$o->account->taxes),2) }} | @endif${{ number_format($b=$o->billing_charge,2) }} | @if ($s->exists) @@ -59,7 +59,7 @@ @if ($s->exists)${{ number_format($a=\App\Models\Tax::tax_calc($s->base_cost*\App\Models\Invoice::billing_change($s->billing_interval,1),$o->account->taxes),2) }} | @endif -${{ number_format($b=$o->billing_monthly_price,2) }} | +isChargeOverriden()) class="text-danger" @endif>${{ number_format($b=($x ? $p->base_charge_taxable : $o->billing_monthly_price),2) }} | @if ($s->exists){!! markup($a,$b) !!} | @endif @@ -69,7 +69,7 @@ @if ($s->exists){{ $s->contract_term }} months | @endif -{{ $o->contract_term }} months | +{{ $p->contract_term }} months | @if ($s->exists)@endif @@ -78,19 +78,11 @@ | Min Price | @if ($s->exists)${{ number_format($a=\App\Models\Tax::tax_calc($s->min_cost,$o->account->taxes),2) }} | -${{ number_format($b=\App\Models\Tax::tax_calc($o->product->getMinChargeAttribute($o->billing_interval),$o->account->taxes),2) }} | +${{ number_format($b=\App\Models\Tax::tax_calc($p->getMinChargeAttribute($o->billing_interval),$o->account->taxes),2) }} | {!! markup($a,$b) !!} | @else- | @endif