commit de compras
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace App\Modules\Purchasing;
|
||||
|
||||
use Tempo\Purchasing\Embedded\Models\Supplier;
|
||||
|
||||
/** Explicit fixture bindings and suppliers actually prepared in this company/unit. */
|
||||
final class SupplierAccess
|
||||
{
|
||||
public static function scope(string $context):string{return hash('sha256',substr($context,0,strrpos($context,':')));}
|
||||
public static function query(array $binding,string $context){
|
||||
return Supplier::query()->where(function($q)use($binding,$context){
|
||||
$q->whereIn('suppliers.id',$binding['supplier_ids']??[]);
|
||||
if(config('receipt_qa.suppliers_enabled')===true)$q->orWhereExists(fn($a)=>$a->selectRaw('1')->from('audit_logs as sa')->whereColumn('sa.tenant_id','suppliers.tenant_id')->where('sa.action','sgf.supplier.command')->where('sa.after->supplier_scope',self::scope($context))->whereRaw("sa.after->'result'->>'supplier_id'=suppliers.id::text"));
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user