diff --git a/app/Http/Controllers/ServiceController.php b/app/Http/Controllers/ServiceController.php index ed569fd..d992350 100644 --- a/app/Http/Controllers/ServiceController.php +++ b/app/Http/Controllers/ServiceController.php @@ -442,9 +442,7 @@ class ServiceController extends Controller $o->suspend_billing = ($request->suspend_billing == 'on'); $o->external_billing = ($request->external_billing == 'on'); - // @todo Cant have both price and price_override - show an exception. (price_override shows a discount, whereas price shows the price) $o->price = $request->price ?: NULL; - $o->price_override = $request->price_override ?: NULL; // Also update our service start_at date. // @todo We may want to make start_at/stop_at dynamic values calculated by the type records diff --git a/app/Models/Service.php b/app/Models/Service.php index fe841a6..cc5cde2 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -41,7 +41,6 @@ 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 @@ -51,10 +50,13 @@ use App\Traits\SiteID; * + sid : System ID for service * + supplied : The model of the supplier's product used for this service. * + * Methods: + * + isChargeOverriden : Has the price been overridden? + * + isPending : Is this a pending active service + * * @package App\Models - * @todo "Billing Start Date" = "connection date" for sub types?? * @todo Add min_charge - * @todo deprecate price_override, and if price < what would be billed, show it striked through, otherwise show it as if it was the price + * @todo Add charge_orig : The original chargeable price */ class Service extends Model implements IDs { @@ -1216,6 +1218,15 @@ class Service extends Model implements IDs return ! ($this->external_billing || $this->suspend_billing || ($this->price === 0)); } + /** + * Has the price for this service been override + * @return bool + */ + public function isChargeOverriden(): bool + { + return ! is_null($this->price); + } + /** * Should this service be invoiced soon * @@ -1239,11 +1250,6 @@ 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 * @@ -1299,7 +1305,7 @@ class Service extends Model implements IDs $o->product_id = $this->product_id; $o->item_type = 0; $o->price_base = is_null($this->price) - ? (is_null($this->price_override) ? $this->product->getBaseChargeAttribute($this->recur_schedule,$this->account->group) : $this->price_override) + ? (is_null($this->price) ? $this->product->getBaseChargeAttribute($this->recur_schedule,$this->account->group) : $this->price) : $this->price; // @todo change to a method in this class $o->recur_schedule = $this->recur_schedule; $o->start_at = $this->invoice_next; diff --git a/database/factories/ServiceFactory.php b/database/factories/ServiceFactory.php index a133bec..75399bd 100644 --- a/database/factories/ServiceFactory.php +++ b/database/factories/ServiceFactory.php @@ -52,7 +52,6 @@ class ServiceFactory extends Factory 'suspend_billing' => FALSE, 'external_billing' => FALSE, 'price' => 100, - // 'price_override', // 'taxable', // 'queue', 'invoice_last_at' => Carbon::createFromFormat('Y-m-d','2021-01-01'), 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 5b88081..bd5a0d6 100644 --- a/resources/views/theme/backend/adminlte/service/change_pending.blade.php +++ b/resources/views/theme/backend/adminlte/service/change_pending.blade.php @@ -121,7 +121,7 @@
- + @error('broadband.price') {{ $message }} diff --git a/resources/views/theme/backend/adminlte/service/widget/information.blade.php b/resources/views/theme/backend/adminlte/service/widget/information.blade.php index 79d913d..853d04a 100644 --- a/resources/views/theme/backend/adminlte/service/widget/information.blade.php +++ b/resources/views/theme/backend/adminlte/service/widget/information.blade.php @@ -45,6 +45,14 @@ Billed {{ $o->billing_interval_string }} + + Amount + @if($o->isChargeOverriden()) + @if ($o->billing_charge < $o->charge_orig)${{ number_format($o->charge_orig,2) }} @endif${{ number_format($o->billing_charge,2) }} + @else + ${{ number_format($o->billing_charge,2) }} + @endif + @if($o->active AND $o->invoice_to) Invoiced To diff --git a/resources/views/theme/backend/adminlte/service/widget/update.blade.php b/resources/views/theme/backend/adminlte/service/widget/update.blade.php index 9243704..dbfe00a 100644 --- a/resources/views/theme/backend/adminlte/service/widget/update.blade.php +++ b/resources/views/theme/backend/adminlte/service/widget/update.blade.php @@ -68,18 +68,6 @@ 'value'=>$o->recur_schedule ?? '', ]) - - -
- @include('adminlte::widget.form_text',[ - 'label'=>'Override Price', - 'icon'=>'fas fa-dollar-sign', - 'id'=>'price_override', - 'old'=>'price_override', - 'name'=>'price_override', - 'value'=>$o->price_override ?? '', - ]) -