Fix site_id table references

This commit is contained in:
Deon George
2022-08-19 13:52:16 +10:00
parent 4b85e01e93
commit 798608cebd
2 changed files with 57 additions and 5 deletions

View File

@@ -35,19 +35,19 @@ class ImportCosts implements ShouldQueue
$this->file = $file;
Config::set('site',$site);
$this->co = Cost::where('site_id',$site->id)
$this->co = Cost::where('site_id',$site->site_id)
->where('supplier_id',$so->id)
->where('billed_at',$invoice_date)
->firstOrNew();
$this->co->active = TRUE;
$this->co->site_id = $site->id;
$this->co->site_id = $site->site_id;
$this->co->billed_at = $invoice_date;
$this->co->supplier_id = $so->id;
$this->co->save();
Cost\Broadband::where('cost_id',$this->co->id)->where('site_id',$site->id)->delete();
Cost\Phone::where('cost_id',$this->co->id)->where('site_id',$site->id)->delete();
Cost\Generic::where('cost_id',$this->co->id)->where('site_id',$site->id)->delete();
Cost\Broadband::where('cost_id',$this->co->id)->where('site_id',$site->site_id)->delete();
Cost\Phone::where('cost_id',$this->co->id)->where('site_id',$site->site_id)->delete();
Cost\Generic::where('cost_id',$this->co->id)->where('site_id',$site->site_id)->delete();
// @todo to be stored in supplier config
$headers = [