More product cleanup
This commit is contained in:
@@ -173,7 +173,7 @@ class Product extends Model implements IDs
|
||||
*/
|
||||
public function getBaseCostAttribute(): float
|
||||
{
|
||||
return $this->supplied->base_cost*Invoice::billing_change($this->type->normalizeBillingInterval(),$this->billing_interval) ?: 0;
|
||||
return round($this->supplied->base_cost,2)*Invoice::billing_change($this->type->billing_interval,$this->billing_interval) ?: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,7 +184,7 @@ class Product extends Model implements IDs
|
||||
*/
|
||||
public function getBillingIntervalAttribute(): int
|
||||
{
|
||||
return max($this->price_recur_default,$this->type->normalizeBillingInterval());
|
||||
return max($this->price_recur_default,$this->type->billing_interval);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,7 +239,18 @@ class Product extends Model implements IDs
|
||||
*/
|
||||
public function getMinChargeAttribute(int $timeperiod=NULL,Group $go=NULL): float
|
||||
{
|
||||
return $this->getSetupChargeAttribute($timeperiod,$go)+$this->getBaseChargeAttribute($timeperiod,$go)*Invoice::billing_term($this->type->contract_term,$this->getBillingIntervalAttribute());
|
||||
return $this->getSetupChargeAttribute($timeperiod,$go)
|
||||
+ $this->getBaseChargeAttribute($timeperiod,$go)*Invoice::billing_change($this->billing_interval,$this->type->billing_interval)*$this->type->contract_term;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the minimum cost for this product
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getMinCostAttribute(): float
|
||||
{
|
||||
return $this->supplied->min_cost;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -340,7 +351,7 @@ class Product extends Model implements IDs
|
||||
$go = $default;
|
||||
|
||||
if (is_null($timeperiod))
|
||||
$timeperiod = $this->getBillingIntervalAttribute();
|
||||
$timeperiod = $this->billing_interval;
|
||||
|
||||
// If the price doesnt exist for $go->id, use $go->id = 0 which is all users.
|
||||
if (! $price=$this->charge($timeperiod,$go,$type)) {
|
||||
|
Reference in New Issue
Block a user