commit12
This commit is contained in:
@@ -36,7 +36,7 @@ final class CatalogueAccounting
|
||||
public function listing(int $actor): array
|
||||
{
|
||||
$scope=$this->scope($actor); $rows=$this->query($scope)->orderBy('id')->get()->map(fn($r)=>$this->decode($r))->all();
|
||||
$services=$this->permissions->has($actor,$scope['tenant_id'],$scope['company_id'],'services.view') ? DB::table('a_services')->where($scope)->orderBy('name')->get(['id','version','name'])->all() : [];
|
||||
$services=$this->permissions->has($actor,$scope['tenant_id'],$scope['company_id'],'services.view') ? \App\Shared\Context\ModuleRecords::query('a_services')->where($scope)->orderBy('name')->get(['id','version','name'])->all() : [];
|
||||
return ['notice'=>self::NOTICE,'reference'=>self::REFERENCE,'proposals'=>$rows,'services'=>$services];
|
||||
}
|
||||
private function command(int $actor,string $action,array $request,string $key,callable $write): array
|
||||
@@ -73,7 +73,7 @@ final class CatalogueAccounting
|
||||
if(isset($data['service_id'])) {
|
||||
$data['service_id']=(int)$data['service_id'];
|
||||
$this->permissions->require($this->context->userId(),$scope['tenant_id'],$scope['company_id'],'services.view');
|
||||
abort_unless(DB::table('a_services')->where($scope)->where('id',$data['service_id'])->exists(),403,'Serviço fora da empresa.');
|
||||
abort_unless(\App\Shared\Context\ModuleRecords::query('a_services')->where($scope)->where('id',$data['service_id'])->exists(),403,'Serviço fora da empresa.');
|
||||
}
|
||||
if($kind==='account') {
|
||||
$data['movable']=(bool)$data['movable'];
|
||||
@@ -166,7 +166,7 @@ final class CatalogueAccounting
|
||||
}
|
||||
private function resolveInternal(int $service,string $date,array $scope): array
|
||||
{
|
||||
$s=DB::table('a_services')->where($scope)->where('id',$service)->first(); abort_unless($s,403,'Serviço fora da empresa.');
|
||||
$s=\App\Shared\Context\ModuleRecords::query('a_services')->where($scope)->where('id',$service)->first(); abort_unless($s,403,'Serviço fora da empresa.');
|
||||
$base=['service'=>['id'=>$service,'version'=>(int)$s->version,'name'=>$s->name],'reference_date'=>$date,'notice'=>self::NOTICE];
|
||||
$override=$this->select($scope,'service_override','service:'.$service,$date);
|
||||
$link=$this->select($scope,'service_link','service:'.$service,$date);
|
||||
@@ -181,7 +181,7 @@ final class CatalogueAccounting
|
||||
public function resolve(int $service,?string $date,int $actor): array
|
||||
{
|
||||
$scope=$this->scope($actor); $this->permissions->require($actor,$scope['tenant_id'],$scope['company_id'],'services.view');
|
||||
abort_unless(DB::table('a_services')->where($scope)->where('id',$service)->exists(),403);
|
||||
abort_unless(\App\Shared\Context\ModuleRecords::query('a_services')->where($scope)->where('id',$service)->exists(),403);
|
||||
if(!$date)return ['state'=>'pending','pending'=>['Data de referência explícita em falta; nenhuma data foi presumida.']]; $this->date($date);
|
||||
$read=function()use($service,$date,$scope){$result=$this->resolveInternal($service,$date,$scope);return $result+['revision'=>hash_hmac('sha256',json_encode($result,JSON_THROW_ON_ERROR),(string)config('app.key'))];};
|
||||
if(DB::transactionLevel())return $read();
|
||||
|
||||
Reference in New Issue
Block a user