Moved some basic intuit commands to leenooks/intuit
This commit is contained in:
parent
5abc07b712
commit
bab1f45234
@ -1,56 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands\Intuit;
|
|
||||||
|
|
||||||
use GuzzleHttp\Exception\ConnectException;
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Intuit\Exceptions\ConnectionIssueException;
|
|
||||||
|
|
||||||
use App\Models\{ProviderOauth,User};
|
|
||||||
|
|
||||||
class AccountGet extends Command
|
|
||||||
{
|
|
||||||
private const provider = 'intuit';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'intuit:account:get'
|
|
||||||
.' {id : Account ID}'
|
|
||||||
.' {user? : User Email}';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Get an account from 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));
|
|
||||||
|
|
||||||
try {
|
|
||||||
$api = $to->API();
|
|
||||||
dump($api->getAccountQuery($this->argument('id')));
|
|
||||||
|
|
||||||
} catch (ConnectException|ConnectionIssueException $e) {
|
|
||||||
$this->error($e->getMessage());
|
|
||||||
|
|
||||||
return self::FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands\Intuit;
|
|
||||||
|
|
||||||
use GuzzleHttp\Exception\ConnectException;
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Intuit\Exceptions\ConnectionIssueException;
|
|
||||||
|
|
||||||
use App\Models\{ProviderOauth,User};
|
|
||||||
|
|
||||||
class InvoiceGet extends Command
|
|
||||||
{
|
|
||||||
private const provider = 'intuit';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'intuit:invoice:get'
|
|
||||||
.' {id : Invoice ID}'
|
|
||||||
.' {user? : User Email}';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Get an invoice from the 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));
|
|
||||||
|
|
||||||
try {
|
|
||||||
$api = $to->API();
|
|
||||||
dump($api->getInvoiceQuery($this->argument('id')));
|
|
||||||
|
|
||||||
} catch (ConnectException|ConnectionIssueException $e) {
|
|
||||||
$this->error($e->getMessage());
|
|
||||||
|
|
||||||
return self::FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,13 +3,17 @@
|
|||||||
namespace App\Console\Commands\Intuit;
|
namespace App\Console\Commands\Intuit;
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
use Intuit\Exceptions\NotTokenException;
|
||||||
|
use Intuit\Traits\ProviderTokenTrait;
|
||||||
|
|
||||||
use App\Models\{Product,ProviderOauth,User};
|
use App\Models\Product;
|
||||||
use App\Jobs\AccountingItemSync as Job;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a list of products and their accounting id
|
||||||
|
*/
|
||||||
class ItemList extends Command
|
class ItemList extends Command
|
||||||
{
|
{
|
||||||
private const provider = 'intuit';
|
use ProviderTokenTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name and signature of the console command.
|
* The name and signature of the console command.
|
||||||
@ -30,16 +34,11 @@ class ItemList extends Command
|
|||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
|
* @throws NotTokenException
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$uo = User::where('email',$this->argument('user') ?: config('osb.admin'))->singleOrFail();
|
$to = $this->providerToken($this->argument('user'));
|
||||||
|
|
||||||
$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));
|
|
||||||
|
|
||||||
$to = $x->pop();
|
|
||||||
|
|
||||||
// Current Products used by services
|
// Current Products used by services
|
||||||
$products = Product::select(['products.*'])
|
$products = Product::select(['products.*'])
|
||||||
@ -48,19 +47,12 @@ class ItemList extends Command
|
|||||||
->where('services.active',TRUE)
|
->where('services.active',TRUE)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$api = $so->API($to,TRUE); // @todo Remove TRUE
|
|
||||||
|
|
||||||
$acc = $api->getItems()->pluck('pid','FullyQualifiedName');
|
|
||||||
|
|
||||||
foreach ($products as $po) {
|
foreach ($products as $po) {
|
||||||
if (! $po->accounting)
|
if (! $x=$po->provider_ref($to->provider))
|
||||||
$this->error(sprintf('Product [%d](%s) doesnt have accounting set',$po->id,$po->name));
|
$this->error(sprintf('Product [%03d](%s) doesnt have accounting set',$po->id,$po->name));
|
||||||
|
|
||||||
elseif ($acc->has($po->accounting) === FALSE)
|
|
||||||
$this->error(sprintf('Product [%d](%s) accounting [%s] doesnt exist?',$po->id,$po->name,$po->accounting));
|
|
||||||
|
|
||||||
else
|
else
|
||||||
$this->info(sprintf('Product [%d](%s) set to accounting [%s]',$po->id,$po->name,$po->accounting));
|
$this->info(sprintf('Product [%03d](%s) set to accounting [%s]',$po->id,$po->name,$x));
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::SUCCESS;
|
return self::SUCCESS;
|
||||||
|
@ -1,61 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands\Intuit;
|
|
||||||
|
|
||||||
use GuzzleHttp\Exception\ConnectException;
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Intuit\Exceptions\ConnectionIssueException;
|
|
||||||
|
|
||||||
use App\Jobs\AccountingPaymentSync as Job;
|
|
||||||
use App\Models\{ProviderOauth,User};
|
|
||||||
|
|
||||||
class PaymentGet extends Command
|
|
||||||
{
|
|
||||||
private const provider = 'intuit';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'accounting:payment:get'
|
|
||||||
.' {id : Payment ID}'
|
|
||||||
.' {user? : User Email}';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Get a payment from the accounting provider';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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));
|
|
||||||
|
|
||||||
try {
|
|
||||||
$api = $to->API();
|
|
||||||
$acc = $api->getPayment($this->argument('id'));
|
|
||||||
dump($acc);
|
|
||||||
|
|
||||||
} catch (ConnectException|ConnectionIssueException $e) {
|
|
||||||
$this->error($e->getMessage());
|
|
||||||
|
|
||||||
return Command::FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($acc)
|
|
||||||
Job::dispatchSync($to,$acc);
|
|
||||||
|
|
||||||
return self::SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,6 +11,8 @@ trait ProviderRef
|
|||||||
{
|
{
|
||||||
public function provider_ref(ProviderOauth $poo): ?string
|
public function provider_ref(ProviderOauth $poo): ?string
|
||||||
{
|
{
|
||||||
return (($x=$this->providers->where('pivot.provider_oauth_id',$poo->id))->count() === 1) ? $x->pop()->pivot->ref : NULL;
|
return (($x=$this->providers->where('pivot.provider_oauth_id',$poo->id))->count() === 1)
|
||||||
|
? $x->pop()->pivot->ref
|
||||||
|
: NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,7 +16,7 @@
|
|||||||
"laravel/socialite": "^5.15",
|
"laravel/socialite": "^5.15",
|
||||||
"laravel/ui": "^4.5",
|
"laravel/ui": "^4.5",
|
||||||
"leenooks/dreamscape": "^0.1.4",
|
"leenooks/dreamscape": "^0.1.4",
|
||||||
"leenooks/intuit": "^0.1.11",
|
"leenooks/intuit": "^0.2",
|
||||||
"leenooks/laravel": "^11.1",
|
"leenooks/laravel": "^11.1",
|
||||||
"leenooks/passkey": "^0.2",
|
"leenooks/passkey": "^0.2",
|
||||||
"paypal/paypal-checkout-sdk": "^1.0",
|
"paypal/paypal-checkout-sdk": "^1.0",
|
||||||
|
32
composer.lock
generated
32
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "72b6dd9641c690d74fbc9885084918d3",
|
"content-hash": "ae477f3c8e083f7f127d92de0a070e8d",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "barryvdh/laravel-snappy",
|
"name": "barryvdh/laravel-snappy",
|
||||||
@ -3021,11 +3021,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "leenooks/intuit",
|
"name": "leenooks/intuit",
|
||||||
"version": "0.1.11",
|
"version": "0.2.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://gitea.dege.au/laravel/intuit.git",
|
"url": "https://gitea.dege.au/laravel/intuit.git",
|
||||||
"reference": "c9523f595b0e860ccf8d8be327ad1903fe63c686"
|
"reference": "0cc4a217bdeabf0ad7973d9d159c823125492174"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"jenssegers/model": "^1.5"
|
"jenssegers/model": "^1.5"
|
||||||
@ -3055,7 +3055,7 @@
|
|||||||
"laravel",
|
"laravel",
|
||||||
"leenooks"
|
"leenooks"
|
||||||
],
|
],
|
||||||
"time": "2024-08-11T11:05:29+00:00"
|
"time": "2024-08-12T10:55:41+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "leenooks/laravel",
|
"name": "leenooks/laravel",
|
||||||
@ -4017,16 +4017,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpseclib/phpseclib",
|
"name": "phpseclib/phpseclib",
|
||||||
"version": "3.0.39",
|
"version": "3.0.41",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/phpseclib/phpseclib.git",
|
"url": "https://github.com/phpseclib/phpseclib.git",
|
||||||
"reference": "211ebc399c6e73c225a018435fe5ae209d1d1485"
|
"reference": "621c73f7dcb310b61de34d1da4c4204e8ace6ceb"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/211ebc399c6e73c225a018435fe5ae209d1d1485",
|
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/621c73f7dcb310b61de34d1da4c4204e8ace6ceb",
|
||||||
"reference": "211ebc399c6e73c225a018435fe5ae209d1d1485",
|
"reference": "621c73f7dcb310b61de34d1da4c4204e8ace6ceb",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -4107,7 +4107,7 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/phpseclib/phpseclib/issues",
|
"issues": "https://github.com/phpseclib/phpseclib/issues",
|
||||||
"source": "https://github.com/phpseclib/phpseclib/tree/3.0.39"
|
"source": "https://github.com/phpseclib/phpseclib/tree/3.0.41"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -4123,7 +4123,7 @@
|
|||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2024-06-24T06:27:33+00:00"
|
"time": "2024-08-12T00:13:54+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "psr/clock",
|
"name": "psr/clock",
|
||||||
@ -9182,16 +9182,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/comparator",
|
"name": "sebastian/comparator",
|
||||||
"version": "6.0.1",
|
"version": "6.0.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/comparator.git",
|
"url": "https://github.com/sebastianbergmann/comparator.git",
|
||||||
"reference": "131942b86d3587291067a94f295498ab6ac79c20"
|
"reference": "450d8f237bd611c45b5acf0733ce43e6bb280f81"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/131942b86d3587291067a94f295498ab6ac79c20",
|
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/450d8f237bd611c45b5acf0733ce43e6bb280f81",
|
||||||
"reference": "131942b86d3587291067a94f295498ab6ac79c20",
|
"reference": "450d8f237bd611c45b5acf0733ce43e6bb280f81",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -9247,7 +9247,7 @@
|
|||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/comparator/issues",
|
"issues": "https://github.com/sebastianbergmann/comparator/issues",
|
||||||
"security": "https://github.com/sebastianbergmann/comparator/security/policy",
|
"security": "https://github.com/sebastianbergmann/comparator/security/policy",
|
||||||
"source": "https://github.com/sebastianbergmann/comparator/tree/6.0.1"
|
"source": "https://github.com/sebastianbergmann/comparator/tree/6.0.2"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -9255,7 +9255,7 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2024-07-03T04:48:07+00:00"
|
"time": "2024-08-12T06:07:25+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/complexity",
|
"name": "sebastian/complexity",
|
||||||
|
Loading…
Reference in New Issue
Block a user