Reimplmement service changes going to the service__change table

This commit is contained in:
2023-05-06 13:53:14 +10:00
parent 691180b3f0
commit 013bb632d3
9 changed files with 181 additions and 26 deletions

View File

@@ -28,6 +28,11 @@ use App\Traits\SiteID;
* Class Service
* Services that belong to an account
*
* So each service attribute has:
* - Offering, what product we supply (we make offerings from supplier's supplied products) - in the DB these are products/*
* - Supplied, our supplier's product that is providing the service - in the DB these are supplier/*
* - Type, what service we are providing, made up of a product we supply - in the DB these are service/*
*
* Attributes for services:
* + additional_cost : Pending additional charges for this service (excluding setup) //@todo check all these are still valid
* + billing_charge : Charge for this service each invoice period // @todo change to "charge"
@@ -46,14 +51,10 @@ use App\Traits\SiteID;
* + sid : System ID for service
* + supplied : The model of the supplier's product used for this service.
*
* = Terminology:
* - Offering, what product we supply (we make offerings from supplier's supplied products) - in the DB these are products/*
* - Supplied, our supplier's product that is providing the service - in the DB these are supplier/*
* - Type, what service we are providing, made up of a product we supply - in the DB these are 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
*/
class Service extends Model implements IDs
{
@@ -356,6 +357,14 @@ class Service extends Model implements IDs
->orderBy('created_at');
}
public function changes()
{
return $this->belongsToMany(Product::class,'service__change','service_id','product_id','id','id')
->where('service__change.site_id',$this->site_id)
->withPivot(['ordered_at','effective_at','ordered_by','active','complete','notes'])
->withTimestamps();
}
// @todo changed to invoiced_items
public function invoice_items($active=TRUE)
{

View File

@@ -12,5 +12,4 @@ use Illuminate\Database\Eloquent\Model;
class ServiceChange extends Model
{
protected $table = 'service__change';
public $timestamps = FALSE;
}