diff --git a/app/Console/Commands/AccountingAccountAdd.php b/app/Console/Commands/AccountingAccountAdd.php new file mode 100644 index 0000000..c5bf30d --- /dev/null +++ b/app/Console/Commands/AccountingAccountAdd.php @@ -0,0 +1,62 @@ +argument('siteid')); + Config::set('site',$site); + + $so = ProviderOauth::where('name',$this->argument('provider'))->singleOrFail(); + $uo = User::where('email',$this->argument('user'))->singleOrFail(); + + if (($x=$so->tokens->where('user_id',$uo->id))->count() !== 1) + abort(500,sprintf('Unknown Tokens for [%s]',$uo->email)); + + $ao = Account::findOrFail($this->argument('id')); + + $customer = new Customer; + $customer->PrimaryEmailAddr = (object)['Address'=>$ao->user->email]; + $customer->ResaleNum = $ao->sid; + $customer->GivenName = $ao->user->firstname; + $customer->FamilyName = $ao->user->lastname; + $customer->CompanyName = $ao->name; + $customer->DisplayName = $ao->name; + $customer->FullyQualifiedName = $ao->name; + $customer->Active = (bool)$ao->active; + + return AccountingCustomerUpdate::dispatchSync($x->pop(),$customer); + } +}