Fix some missing date_* attributes for Service that have been missed
This commit is contained in:
@@ -36,6 +36,28 @@ class Payment extends Model implements IDs
|
||||
// Any balance below this we'll assume its all used.
|
||||
private const threshold = 0.05;
|
||||
|
||||
/* INTERFACES */
|
||||
|
||||
/**
|
||||
* Payment Local ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLIDattribute(): string
|
||||
{
|
||||
return sprintf('%06s',$this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Payment System ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSIDAttribute(): string
|
||||
{
|
||||
return sprintf('%02s-%04s#%s',$this->site_id,$this->account_id,$this->getLIDattribute());
|
||||
}
|
||||
|
||||
/* RELATIONS */
|
||||
|
||||
public function account()
|
||||
@@ -81,6 +103,11 @@ class Payment extends Model implements IDs
|
||||
|
||||
/* ATTRIBUTES */
|
||||
|
||||
/**
|
||||
* Work out the remaining amount from this payment that has not been allocated.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getBalanceAttribute(): float
|
||||
{
|
||||
$balance = $this->getTotalAttribute()-$this->items->sum('amount');
|
||||
@@ -89,25 +116,11 @@ class Payment extends Model implements IDs
|
||||
}
|
||||
|
||||
/**
|
||||
* Payment Local ID
|
||||
* The total of the payment.
|
||||
*
|
||||
* @return string
|
||||
* @return float
|
||||
* @todo Change the DB column to total
|
||||
*/
|
||||
public function getLIDattribute(): string
|
||||
{
|
||||
return sprintf('%06s',$this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Payment System ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSIDAttribute(): string
|
||||
{
|
||||
return sprintf('%02s-%04s#%s',$this->site_id,$this->account_id,$this->getLIDattribute());
|
||||
}
|
||||
|
||||
public function getTotalAttribute(): float
|
||||
{
|
||||
return sprintf('%3.2f',$this->total_amt);
|
||||
|
@@ -636,8 +636,8 @@ class Service extends Model implements IDs
|
||||
}
|
||||
|
||||
// If the invoice has an end date, our invoice period shouldnt be greater than that.
|
||||
if ($this->date_end AND $this->date_end < $date)
|
||||
$date = $this->date_end;
|
||||
if ($this->stop_at AND $this->stop_at < $date)
|
||||
$date = $this->stop_at;
|
||||
|
||||
return $date;
|
||||
}
|
||||
@@ -1211,7 +1211,7 @@ class Service extends Model implements IDs
|
||||
AND ($this->active OR $this->isPending())
|
||||
AND (
|
||||
(($future == TRUE) AND $this->invoice_next < $this->invoice_next_end) OR
|
||||
(($future == FALSE) AND ($this->invoice_to < ($this->date_end ?: $billdate)))
|
||||
(($future == FALSE) AND ($this->invoice_to < ($this->stop_at ?: $billdate)))
|
||||
))
|
||||
{
|
||||
do {
|
||||
@@ -1231,7 +1231,7 @@ class Service extends Model implements IDs
|
||||
|
||||
$o->addTaxes($this->account->country->taxes);
|
||||
$this->invoice_items->push($o);
|
||||
} while ($future == FALSE AND ($this->invoice_to < ($this->date_end ?: $billdate)));
|
||||
} while ($future == FALSE AND ($this->invoice_to < ($this->stop_at ?: $billdate)));
|
||||
}
|
||||
|
||||
// Add additional charges
|
||||
|
Reference in New Issue
Block a user