Show accounting link on accounts that are linked

This commit is contained in:
Deon George
2022-08-19 20:12:08 +10:00
parent 1deda523b4
commit 71b252843c
4 changed files with 32 additions and 18 deletions

View File

@@ -40,7 +40,7 @@ class AccountingAccountSync implements ShouldQueue
public function handle()
{
$api = $this->to->provider->API($this->to);
$accounts = Account::get();
$accounts = Account::with(['user'])->get();
foreach ($api->getCustomers() as $customer) {
$ao = NULL;
@@ -54,7 +54,7 @@ class AccountingAccountSync implements ShouldQueue
$ao = $x->pop();
// Look based on Name
} elseif (($x=$accounts->filter(function($item) use ($customer) { return $item->company == $customer->companyname || $item->name == $customer->fullname; }))->count() === 1) {
} elseif (($x=$accounts->filter(function($item) use ($customer) { return $item->company == $customer->companyname || $item->name == $customer->fullname || $item->user->email == $customer->email; }))->count() === 1) {
$ao = $x->pop();
} else {

View File

@@ -45,13 +45,6 @@ class Account extends Model implements IDs
return $this->hasMany(Charge::class);
}
public function providers()
{
return $this->belongsToMany(ProviderOauth::class,'account_provider')
->where('account_provider.site_id',$this->site_id)
->withPivot('ref','synctoken','created_at','updated_at');
}
/**
* Return the country the user belongs to
*/
@@ -85,6 +78,13 @@ class Account extends Model implements IDs
return $this->hasMany(Payment::class);
}
public function providers()
{
return $this->belongsToMany(ProviderOauth::class,'account_provider')
->where('account_provider.site_id',$this->site_id)
->withPivot('ref','synctoken','created_at','updated_at');
}
public function services($active=FALSE)
{
$query = $this->hasMany(Service::class);