Rework service, removed redundant code, service invoicing improvements

This commit is contained in:
2024-07-29 23:12:53 +10:00
parent 5f10175b35
commit 0b5bc9e012
29 changed files with 474 additions and 523 deletions

View File

@@ -48,11 +48,13 @@ class Broadband extends Type implements ServiceUsage
* The usage information for broadband
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
* @todo rename to usage()
*/
public function traffic()
{
return $this->hasMany(UsageBroadband::class,'service_item_id')
->where('site_id',$this->site_id);
->where('date','>=',Carbon::now()->startOfMonth());
//->where('site_id',$this->site_id);
}
/* ATTRIBUTES */
@@ -154,8 +156,6 @@ class Broadband extends Type implements ServiceUsage
if (! $maxdate)
return collect();
Log::debug(sprintf('%s:Getting Usage data for [%d] months from [%s]',self::LOGKEY,$months,$maxdate),['m'=>__METHOD__]);
// Go back an extra month;
$start = $maxdate->date->subMonths($months);
@@ -166,8 +166,6 @@ class Broadband extends Type implements ServiceUsage
$start = $start->subDays($start->day-15);
}
Log::debug(sprintf('%s:Getting Usage data from [%s]',self::LOGKEY,$start->format('Y-m-d')),['m'=>__METHOD__]);
$result = collect();
foreach ($this->traffic()