More product cleanup

This commit is contained in:
2023-05-05 22:05:42 +10:00
parent dc74a064ba
commit 691180b3f0
7 changed files with 109 additions and 87 deletions

View File

@@ -53,6 +53,7 @@ use App\Traits\SiteID;
*
* @package App\Models
* @todo "Billing Start Date" = "connection date" for sub types??
* @todo Add min_charge
*/
class Service extends Model implements IDs
{
@@ -577,13 +578,13 @@ class Service extends Model implements IDs
/**
* This function will determine the minimum contract term for a service, which is the maximum of
* supplier->type->contract_term, or the product->type->contract_term;
* supplied->contract_term, or the product->type->contract_term;
*
* @return int
*/
public function getContractTermAttribute(): int
{
return $this->getSuppliedAttribute()->contract_term;
return max($this->supplied->contract_term,$this->product->type->contract_term);
}
/**
@@ -1077,7 +1078,7 @@ class Service extends Model implements IDs
*/
public function charge_normalized(): float
{
return number_format($this->getBillingChargeAttribute()*Invoice::billing_change($this->recur_schedule,$this->offering->normalizeBillingInterval()),2);
return number_format($this->getBillingChargeAttribute()*Invoice::billing_change($this->recur_schedule,$this->offering->billing_interval),2);
}
private function getOrderInfoValue(string $key): ?string