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