Initial reseller domain report, enable editing domain service details

This commit is contained in:
Deon George
2021-07-13 12:31:56 +10:00
parent bc26f7b881
commit b515a1edeb
26 changed files with 652 additions and 56 deletions

View File

@@ -24,8 +24,9 @@ use App\Traits\NextKey;
* Services that belong to an account
*
* Attributes for services:
* + name_short : Service Product short name, eg: phone number, domain name, certificate CN
* + sid : System ID for service
* + billing_period : The period that this service is billed for by default
* + name_short : Service Product short name, eg: phone number, domain name, certificate CN
* + sid : System ID for service
*
* @package App\Models
*/
@@ -89,12 +90,19 @@ class Service extends Model implements IDs
'type',
];
// @todo Change to self::INACTIVE_STATUS
private $inactive_status = [
'CANCELLED',
'ORDER-REJECTED',
'ORDER-CANCELLED',
];
public const INACTIVE_STATUS = [
'CANCELLED',
'ORDER-REJECTED',
'ORDER-CANCELLED',
];
/**
* Valid status shows the applicable next status for an action on a service
* Each status can be
@@ -362,6 +370,15 @@ class Service extends Model implements IDs
});
}
/**
* Only query records that the user is authorised to see
*/
public function scopeAuthorised($query,User $uo)
{
return $query
->whereIN($this->getTable().'.account_id',$uo->all_accounts()->pluck('id')->unique()->toArray());
}
/**
* Find inactive services.
*
@@ -1192,10 +1209,21 @@ class Service extends Model implements IDs
return $this->active OR ($this->order_status AND ! in_array($this->order_status,$this->inactive_status));
}
/**
* Do we bill for this service
*
* @return bool
*/
public function isBilled(): bool
{
return ! ($this->external_billing && $this->suspend_billing);
}
/**
* Should this service be invoiced soon
*
* @todo get the number of days from account setup
* @todo Use self::isBilled();
* @return bool
*/
public function isInvoiceDueSoon($days=30): bool
@@ -1221,6 +1249,7 @@ class Service extends Model implements IDs
* @param bool $future Next item to be billed (not in the next x days)
* @return Collection
* @throws Exception
* @todo Use self::isBilled();
*/
public function next_invoice_items(bool $future,Carbon $billdate=NULL): Collection
{