Fixed order processing, broken after upgrade to Laravel 5.8
This commit is contained in:
parent
9fa773d283
commit
4c5c43c390
app
Classes/External/Accounting
Console/Commands
Models
Traits
21
app/Classes/External/Accounting/Quickbooks.php
vendored
21
app/Classes/External/Accounting/Quickbooks.php
vendored
@ -7,7 +7,6 @@ use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
use QuickBooksOnline\API\Data\IPPCustomer;
|
||||
use QuickBooksOnline\API\Facades\Customer;
|
||||
|
||||
use App\User;
|
||||
use App\Classes\External\Accounting as Base;
|
||||
@ -36,6 +35,26 @@ class Quickbooks extends Base
|
||||
});
|
||||
}
|
||||
|
||||
public function getInvoice(int $id,$refresh=FALSE)
|
||||
{
|
||||
if ($refresh)
|
||||
Cache::forget(__METHOD__.$id);
|
||||
|
||||
return Cache::remember(__METHOD__.$id,86400,function() use ($id) {
|
||||
return $this->api->getDataService()->Query(sprintf("SELECT * FROM Invoice where id = '%s'",$id));
|
||||
});
|
||||
}
|
||||
|
||||
public function getInvoices($refresh=FALSE): Collection
|
||||
{
|
||||
if ($refresh)
|
||||
Cache::forget(__METHOD__);
|
||||
|
||||
return Cache::remember(__METHOD__,86400,function() {
|
||||
return collect($this->api->getDataService()->Query('SELECT * FROM Invoice'));
|
||||
});
|
||||
}
|
||||
|
||||
public function updateCustomer(IPPCustomer $r,array $args)
|
||||
{
|
||||
$r->sparse = TRUE;
|
||||
|
@ -4,8 +4,6 @@ namespace App\Console\Commands;
|
||||
|
||||
use App\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\External\Accounting\Quickbooks;
|
||||
use App\Models\Account;
|
||||
@ -47,10 +45,6 @@ class QuickAccounts extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
DB::listen(function($query) {
|
||||
Log::debug('- SQL',['sql'=>$query->sql,'binding'=>$query->bindings]);
|
||||
});
|
||||
|
||||
foreach (Integrations::active()->type('ACCOUNTING')->get() as $into)
|
||||
{
|
||||
switch ($into->name)
|
||||
|
@ -9,6 +9,9 @@ use App\Traits\NextKey;
|
||||
class Account extends Model
|
||||
{
|
||||
use NextKey;
|
||||
|
||||
const RECORD_ID = 'account';
|
||||
|
||||
public $incrementing = FALSE;
|
||||
|
||||
protected $table = 'ab_account';
|
||||
|
@ -21,7 +21,7 @@ class AdslPlan extends Model
|
||||
],
|
||||
];
|
||||
|
||||
protected $order_model = ServiceAdsl::class;
|
||||
protected $order_model = Service\Adsl::class;
|
||||
|
||||
public function product()
|
||||
{
|
||||
|
@ -4,12 +4,8 @@ namespace App\Models\Base;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use App\Traits\NextKey;
|
||||
|
||||
abstract class ServiceType extends Model
|
||||
{
|
||||
use NextKey;
|
||||
|
||||
public $timestamps = FALSE;
|
||||
public $dateFormat = 'U';
|
||||
|
||||
|
@ -31,5 +31,5 @@ class PlanVoip extends Model
|
||||
],
|
||||
];
|
||||
|
||||
protected $order_model = ServiceVoip::class;
|
||||
protected $order_model = Service\Voip::class;
|
||||
}
|
@ -10,9 +10,11 @@ class Service extends Model
|
||||
{
|
||||
use NextKey;
|
||||
|
||||
public $incrementing = FALSE;
|
||||
const RECORD_ID = 'service';
|
||||
|
||||
const CREATED_AT = 'date_orig';
|
||||
const UPDATED_AT = 'date_last';
|
||||
public $incrementing = FALSE;
|
||||
|
||||
protected $table = 'ab_service';
|
||||
protected $with = ['product.descriptions','account.language'];
|
||||
@ -86,7 +88,7 @@ class Service extends Model
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function orderedby()
|
||||
public function orderby()
|
||||
{
|
||||
return $this->belongsTo(Account::class);
|
||||
}
|
||||
|
@ -2,8 +2,14 @@
|
||||
|
||||
namespace App\Models\Service;
|
||||
|
||||
use App\Traits\NextKey;
|
||||
|
||||
class Adsl extends \App\Models\Base\ServiceType
|
||||
{
|
||||
use NextKey;
|
||||
|
||||
const RECORD_ID = 'service__adsl';
|
||||
|
||||
// @todo column service_id can be removed.
|
||||
protected $table = 'ab_service__adsl';
|
||||
|
||||
|
@ -2,8 +2,14 @@
|
||||
|
||||
namespace App\Models\Service;
|
||||
|
||||
use App\Traits\NextKey;
|
||||
|
||||
class Domain extends \App\Models\Base\ServiceType
|
||||
{
|
||||
use NextKey;
|
||||
|
||||
const RECORD_ID = 'service__domain';
|
||||
|
||||
protected $table = 'ab_service__domain';
|
||||
|
||||
public function tld()
|
||||
|
@ -2,8 +2,14 @@
|
||||
|
||||
namespace App\Models\Service;
|
||||
|
||||
use App\Traits\NextKey;
|
||||
|
||||
class Host extends \App\Models\Base\ServiceType
|
||||
{
|
||||
use NextKey;
|
||||
|
||||
const RECORD_ID = 'service__hosting';
|
||||
|
||||
protected $table = 'ab_service__hosting';
|
||||
|
||||
public function getNameAttribute()
|
||||
|
@ -2,9 +2,16 @@
|
||||
|
||||
namespace App\Models\Service;
|
||||
|
||||
use App\Traits\NextKey;
|
||||
|
||||
class SSL extends \App\Models\Base\ServiceType
|
||||
{
|
||||
use NextKey;
|
||||
|
||||
const RECORD_ID = 'service__ssl';
|
||||
|
||||
protected $table = 'ab_service__ssl';
|
||||
|
||||
protected $_o = NULL;
|
||||
|
||||
public function tld()
|
||||
|
@ -2,8 +2,14 @@
|
||||
|
||||
namespace App\Models\Service;
|
||||
|
||||
use App\Traits\NextKey;
|
||||
|
||||
class Voip extends \App\Models\Base\ServiceType
|
||||
{
|
||||
use NextKey;
|
||||
|
||||
const RECORD_ID = 'service__adsl';
|
||||
|
||||
protected $table = 'ab_service__voip';
|
||||
|
||||
public function getFullNameAttribute()
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
namespace App\Traits;
|
||||
|
||||
use App\Models\Module;
|
||||
use App\Models\{Module,Record};
|
||||
|
||||
trait NextKey
|
||||
{
|
||||
@ -27,6 +27,13 @@ trait NextKey
|
||||
throw new \Exception('Missing record_id const for '.get_class($model));
|
||||
|
||||
$mo = Module::where('name',$model::RECORD_ID)->firstOrFail();
|
||||
|
||||
if (! $mo->record) {
|
||||
$mo->record = new Record;
|
||||
$mo->record->module_id = $mo->id;
|
||||
$mo->record->site_id = 1; // @todo
|
||||
}
|
||||
|
||||
$mo->record->id = $model->id;
|
||||
$mo->record->save();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user