Moving accounting commands into an Intuit/ namespace, updates to intuit module
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
use App\Models\{ProviderOauth,Site,User};
|
||||
use App\Jobs\AccountingAccountSync as Job;
|
||||
|
||||
/**
|
||||
* Synchronise Customers with Accounts
|
||||
*/
|
||||
class AccountingAccountSync extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'accounting:account:sync'
|
||||
.' {siteid : Site ID}'
|
||||
.' {provider : Provider Name}'
|
||||
.' {user : User Email}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Synchronise accounts with accounting system';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$site = Site::findOrFail($this->argument('siteid'));
|
||||
Config::set('site',$site);
|
||||
|
||||
$uo = User::where('email',$this->argument('user'))->singleOrFail();
|
||||
|
||||
$so = ProviderOauth::where('name',$this->argument('provider'))->singleOrFail();
|
||||
if (! ($to=$so->token($uo)))
|
||||
abort(500,sprintf('Unknown Tokens for [%s]',$uo->email));
|
||||
|
||||
Job::dispatchSync($to);
|
||||
}
|
||||
}
|
@@ -1,33 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
namespace App\Console\Commands\Intuit;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Intuit\Jobs\AccountingCustomerUpdate;
|
||||
use Intuit\Models\Customer as AccAccount;
|
||||
|
||||
use App\Models\{Account,ProviderOauth,Site,User};
|
||||
use App\Models\{Account,ProviderOauth,User};
|
||||
|
||||
class AccountingAccountAdd extends Command
|
||||
class AccountAdd extends Command
|
||||
{
|
||||
private const provider = 'intuit';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'accounting:account:add'
|
||||
.' {siteid : Site ID}'
|
||||
.' {provider : Provider Name}'
|
||||
.' {user : User Email}'
|
||||
.' {id : Account ID}';
|
||||
protected $signature = 'intuit:account:add'
|
||||
.' {id : Account ID}'
|
||||
.' {user? : User Email}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Add an account to the accounting provider';
|
||||
protected $description = 'Add an account to quickbooks';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -36,12 +35,9 @@ class AccountingAccountAdd extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$site = Site::findOrFail($this->argument('siteid'));
|
||||
Config::set('site',$site);
|
||||
$uo = User::where('email',$this->argument('user') ?: config('osb.admin'))->singleOrFail();
|
||||
|
||||
$uo = User::where('email',$this->argument('user'))->singleOrFail();
|
||||
|
||||
$so = ProviderOauth::where('name',$this->argument('provider'))->singleOrFail();
|
||||
$so = ProviderOauth::where('name',self::provider)->singleOrFail();
|
||||
if (! ($to=$so->token($uo)))
|
||||
abort(500,sprintf('Unknown Tokens for [%s]',$uo->email));
|
||||
|
@@ -1,33 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
namespace App\Console\Commands\Intuit;
|
||||
|
||||
use GuzzleHttp\Exception\ConnectException;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Intuit\Exceptions\ConnectionIssueException;
|
||||
|
||||
use App\Models\{ProviderOauth,Site,User};
|
||||
use App\Models\{ProviderOauth,User};
|
||||
|
||||
class AccountingAccountGet extends Command
|
||||
class AccountGet extends Command
|
||||
{
|
||||
private const provider = 'intuit';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'accounting:account:get'
|
||||
.' {siteid : Site ID}'
|
||||
.' {provider : Provider Name}'
|
||||
.' {user : User Email}'
|
||||
.' {id : Account ID}';
|
||||
protected $signature = 'intuit:account:get'
|
||||
.' {id : Account ID}'
|
||||
.' {user? : User Email}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get an account from the accounting provider';
|
||||
protected $description = 'Get an account from quickbooks';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -36,12 +35,9 @@ class AccountingAccountGet extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$site = Site::findOrFail($this->argument('siteid'));
|
||||
Config::set('site',$site);
|
||||
$uo = User::where('email',$this->argument('user') ?: config('osb.admin'))->singleOrFail();
|
||||
|
||||
$uo = User::where('email',$this->argument('user'))->singleOrFail();
|
||||
|
||||
$so = ProviderOauth::where('name',$this->argument('provider'))->singleOrFail();
|
||||
$so = ProviderOauth::where('name',self::provider)->singleOrFail();
|
||||
if (! ($to=$so->token($uo)))
|
||||
abort(500,sprintf('Unknown Tokens for [%s]',$uo->email));
|
||||
|
||||
@@ -52,7 +48,9 @@ class AccountingAccountGet extends Command
|
||||
} catch (ConnectException|ConnectionIssueException $e) {
|
||||
$this->error($e->getMessage());
|
||||
|
||||
return Command::FAILURE;
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
49
app/Console/Commands/Intuit/AccountSync.php
Normal file
49
app/Console/Commands/Intuit/AccountSync.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Intuit;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use App\Models\{ProviderOauth,User};
|
||||
use App\Jobs\AccountingAccountSync as Job;
|
||||
|
||||
/**
|
||||
* Synchronise Customers with Accounts
|
||||
*/
|
||||
class AccountSync extends Command
|
||||
{
|
||||
private const provider = 'intuit';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'intuit:account:sync'
|
||||
.' {user? : User Email}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Synchronise accounts with quickbooks';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$uo = User::where('email',$this->argument('user') ?: config('osb.admin'))->singleOrFail();
|
||||
|
||||
$so = ProviderOauth::where('name',self::provider)->singleOrFail();
|
||||
if (! ($to=$so->token($uo)))
|
||||
abort(500,sprintf('Unknown Tokens for [%s]',$uo->email));
|
||||
|
||||
Job::dispatchSync($to);
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
@@ -1,26 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
namespace App\Console\Commands\Intuit;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Intuit\Jobs\AccountingInvoiceUpdate;
|
||||
use Intuit\Models\Invoice as AccInvoice;
|
||||
|
||||
use App\Models\{Invoice,ProviderOauth,Site,User};
|
||||
use App\Models\{Invoice,ProviderOauth,User};
|
||||
|
||||
class AccountingInvoiceAdd extends Command
|
||||
class InvoiceAdd extends Command
|
||||
{
|
||||
private const provider = 'intuit';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'accounting:invoice:add'
|
||||
.' {siteid : Site ID}'
|
||||
.' {provider : Provider Name}'
|
||||
.' {user : User Email}'
|
||||
.' {id : Invoice ID}';
|
||||
.' {id : Invoice ID}'
|
||||
.' {user? : User Email}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -33,15 +32,13 @@ class AccountingInvoiceAdd extends Command
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$site = Site::findOrFail($this->argument('siteid'));
|
||||
Config::set('site',$site);
|
||||
$uo = User::where('email',$this->argument('user') ?: config('osb.admin'))->singleOrFail();
|
||||
|
||||
$uo = User::where('email',$this->argument('user'))->singleOrFail();
|
||||
|
||||
$so = ProviderOauth::where('name',$this->argument('provider'))->singleOrFail();
|
||||
$so = ProviderOauth::where('name',self::provider)->singleOrFail();
|
||||
if (! ($to=$so->token($uo)))
|
||||
abort(500,sprintf('Unknown Tokens for [%s]',$uo->email));
|
||||
|
||||
@@ -78,12 +75,14 @@ class AccountingInvoiceAdd extends Command
|
||||
// Some validation
|
||||
if (! ($ref=$key->product->provider_ref($so))) {
|
||||
$this->error(sprintf('Accounting not defined in product [%d]',$key->product_id));
|
||||
exit(1);
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
if ($key->taxes->count() !== 1) {
|
||||
$this->error(sprintf('Cannot handle when there is not just 1 tax line [%d]',$key->id));
|
||||
exit(1);
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$c++;
|
@@ -1,33 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
namespace App\Console\Commands\Intuit;
|
||||
|
||||
use GuzzleHttp\Exception\ConnectException;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Intuit\Exceptions\ConnectionIssueException;
|
||||
|
||||
use App\Models\{ProviderOauth,Site,User};
|
||||
use App\Models\{ProviderOauth,User};
|
||||
|
||||
class AccountingInvoiceGet extends Command
|
||||
class InvoiceGet extends Command
|
||||
{
|
||||
private const provider = 'intuit';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'accounting:invoice:get'
|
||||
.' {siteid : Site ID}'
|
||||
.' {provider : Provider Name}'
|
||||
.' {user : User Email}'
|
||||
.' {id : Invoice ID}';
|
||||
protected $signature = 'intuit:invoice:get'
|
||||
.' {id : Invoice ID}'
|
||||
.' {user? : User Email}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get an invoice from the accounting provider';
|
||||
protected $description = 'Get an invoice from the quickbooks';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@@ -36,12 +35,9 @@ class AccountingInvoiceGet extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$site = Site::findOrFail($this->argument('siteid'));
|
||||
Config::set('site',$site);
|
||||
$uo = User::where('email',$this->argument('user') ?: config('osb.admin'))->singleOrFail();
|
||||
|
||||
$uo = User::where('email',$this->argument('user'))->singleOrFail();
|
||||
|
||||
$so = ProviderOauth::where('name',$this->argument('provider'))->singleOrFail();
|
||||
$so = ProviderOauth::where('name',self::provider)->singleOrFail();
|
||||
if (! ($to=$so->token($uo)))
|
||||
abort(500,sprintf('Unknown Tokens for [%s]',$uo->email));
|
||||
|
||||
@@ -52,7 +48,9 @@ class AccountingInvoiceGet extends Command
|
||||
} catch (ConnectException|ConnectionIssueException $e) {
|
||||
$this->error($e->getMessage());
|
||||
|
||||
return Command::FAILURE;
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
@@ -1,25 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
namespace App\Console\Commands\Intuit;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Models\{Product, ProviderOauth, Site, User};
|
||||
use App\Models\{Product,ProviderOauth,User};
|
||||
use App\Jobs\AccountingItemSync as Job;
|
||||
|
||||
class AccountingItemList extends Command
|
||||
class ItemList extends Command
|
||||
{
|
||||
private const provider = 'intuit';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'accounting:item:list'
|
||||
.' {siteid : Site ID}'
|
||||
.' {provider : Provider Name}'
|
||||
.' {user : User Email}';
|
||||
.' {user? : User Email}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -35,12 +33,9 @@ class AccountingItemList extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$site = Site::findOrFail($this->argument('siteid'));
|
||||
Config::set('site',$site);
|
||||
|
||||
$so = ProviderOauth::where('name',$this->argument('provider'))->singleOrFail();
|
||||
$uo = User::where('email',$this->argument('user'))->singleOrFail();
|
||||
$uo = User::where('email',$this->argument('user') ?: config('osb.admin'))->singleOrFail();
|
||||
|
||||
$so = ProviderOauth::where('name',self::provider)->singleOrFail();
|
||||
if (($x=$so->tokens->where('user_id',$uo->id))->count() !== 1)
|
||||
abort(500,sprintf('Unknown Tokens for [%s]',$uo->email));
|
||||
|
||||
@@ -67,5 +62,7 @@ class AccountingItemList extends Command
|
||||
else
|
||||
$this->info(sprintf('Product [%d](%s) set to accounting [%s]',$po->id,$po->name,$po->accounting));
|
||||
}
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
@@ -1,27 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
namespace App\Console\Commands\Intuit;
|
||||
|
||||
use GuzzleHttp\Exception\ConnectException;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Intuit\Exceptions\ConnectionIssueException;
|
||||
|
||||
use App\Jobs\AccountingPaymentSync as Job;
|
||||
use App\Models\{ProviderOauth,Site,User};
|
||||
use App\Models\{ProviderOauth,User};
|
||||
|
||||
class AccountingPaymentGet extends Command
|
||||
class PaymentGet extends Command
|
||||
{
|
||||
private const provider = 'intuit';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'accounting:payment:get'
|
||||
.' {siteid : Site ID}'
|
||||
.' {provider : Provider Name}'
|
||||
.' {user : User Email}'
|
||||
.' {id : Payment ID}';
|
||||
.' {id : Payment ID}'
|
||||
.' {user? : User Email}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -37,12 +36,9 @@ class AccountingPaymentGet extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$site = Site::findOrFail($this->argument('siteid'));
|
||||
Config::set('site',$site);
|
||||
$uo = User::where('email',$this->argument('user') ?: config('osb.admin'))->singleOrFail();
|
||||
|
||||
$uo = User::where('email',$this->argument('user'))->singleOrFail();
|
||||
|
||||
$so = ProviderOauth::where('name',$this->argument('provider'))->singleOrFail();
|
||||
$so = ProviderOauth::where('name',self::provider)->singleOrFail();
|
||||
if (! ($to=$so->token($uo)))
|
||||
abort(500,sprintf('Unknown Tokens for [%s]',$uo->email));
|
||||
|
||||
@@ -59,5 +55,7 @@ class AccountingPaymentGet extends Command
|
||||
|
||||
if ($acc)
|
||||
Job::dispatchSync($to,$acc);
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
@@ -1,24 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
namespace App\Console\Commands\Intuit;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
use App\Models\{ProviderOauth,Site,User};
|
||||
use App\Models\{ProviderOauth,User};
|
||||
use App\Jobs\AccountingPaymentSync as Job;
|
||||
|
||||
class AccountingPaymentSync extends Command
|
||||
class PaymentSync extends Command
|
||||
{
|
||||
private const provider = 'intuit';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'accounting:payment:sync'
|
||||
.' {siteid : Site ID}'
|
||||
.' {provider : Provider Name}'
|
||||
.' {user : User Email}';
|
||||
.' {user? : User Email}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -34,17 +33,16 @@ class AccountingPaymentSync extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$site = Site::findOrFail($this->argument('siteid'));
|
||||
Config::set('site',$site);
|
||||
$uo = User::where('email',$this->argument('user') ?: config('osb.admin'))->singleOrFail();
|
||||
|
||||
$uo = User::where('email',$this->argument('user'))->singleOrFail();
|
||||
|
||||
$so = ProviderOauth::where('name',$this->argument('provider'))->singleOrFail();
|
||||
$so = ProviderOauth::where('name',self::provider)->singleOrFail();
|
||||
if (! ($to=$so->token($uo)))
|
||||
abort(500,sprintf('Unknown Tokens for [%s]',$uo->email));
|
||||
|
||||
$api = $to->API();
|
||||
foreach ($api->getPayments() as $acc)
|
||||
Job::dispatchSync($to,$acc);
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
@@ -1,27 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
namespace App\Console\Commands\Intuit;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
use App\Models\{ProviderOauth,Site,User};
|
||||
use App\Models\{ProviderOauth,User};
|
||||
use App\Jobs\AccountingTaxSync as Job;
|
||||
|
||||
/**
|
||||
* Synchronise TAX ids with our taxes.
|
||||
*/
|
||||
class AccountingTaxSync extends Command
|
||||
class TaxSync extends Command
|
||||
{
|
||||
private const provider = 'intuit';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'accounting:tax:sync'
|
||||
.' {siteid : Site ID}'
|
||||
.' {provider : Provider Name}'
|
||||
.' {user : User Email}';
|
||||
.' {user? : User Email}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -37,15 +36,14 @@ class AccountingTaxSync extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$site = Site::findOrFail($this->argument('siteid'));
|
||||
Config::set('site',$site);
|
||||
$uo = User::where('email',$this->argument('user') ?: config('osb.admin'))->singleOrFail();
|
||||
|
||||
$uo = User::where('email',$this->argument('user'))->singleOrFail();
|
||||
|
||||
$so = ProviderOauth::where('name',$this->argument('provider'))->singleOrFail();
|
||||
$so = ProviderOauth::where('name',self::provider)->singleOrFail();
|
||||
if (! ($to=$so->token($uo)))
|
||||
abort(500,sprintf('Unknown Tokens for [%s]',$uo->email));
|
||||
|
||||
Job::dispatchSync($to);
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
@@ -16,9 +16,8 @@ class ProviderTokenRefresh extends Command
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'provider:token:refresh'
|
||||
.' {siteid : Site ID}'
|
||||
.' {provider : Supplier Name}'
|
||||
.' {user : User Email}';
|
||||
.' {user? : User Email}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -34,15 +33,14 @@ class ProviderTokenRefresh extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$site = Site::findOrFail($this->argument('siteid'));
|
||||
Config::set('site',$site);
|
||||
$uo = User::where('email',$this->argument('user') ?: config('osb.admin'))->singleOrFail();
|
||||
|
||||
$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));
|
||||
|
||||
Job::dispatchSync($x->pop());
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user