commit12
This commit is contained in:
@@ -90,7 +90,7 @@ final class ServiceReceivables
|
||||
$right=$kind==='correction'?'correction_request':'prepare';
|
||||
if(isset($d['amount'])) $d['amount']=self::money($d['amount'],$kind!=='observation');
|
||||
return $this->command($actor,$right,$key,$d,function($s)use($actor,$d,$kind) {
|
||||
$inv=DB::table('si_invoices')->where($s)->where('id',$d['invoice_id'])->first();
|
||||
$inv=\App\Shared\Context\ModuleRecords::query('si_invoices')->where($s)->where('id',$d['invoice_id'])->first();
|
||||
abort_unless($inv,403,'Documento de origem não autorizado.');
|
||||
$snapshot=json_decode($inv->snapshot,true,32,JSON_THROW_ON_ERROR);
|
||||
abort_unless(($snapshot['simulation_only']??false)===true && ($snapshot['notice']??'')===self::NOTICE && ($snapshot['document']['data']['currency']??'')==='MZN',422,'Origem sintética compatível necessária.');
|
||||
@@ -222,7 +222,7 @@ final class ServiceReceivables
|
||||
return DB::transaction(function()use($s) {
|
||||
DB::table('companies')->where('id',$s['company_id'])->lockForUpdate()->firstOrFail();
|
||||
$records=DB::table('sr_records')->where($s)->orderBy('id')->get();
|
||||
return ['blocked'=>false,'notice'=>self::NOTICE,'simulation'=>self::SIMULATION,'records'=>$records->map(function($r){$r->data=$this->data($r);return $r;})->all(),'obligations'=>$records->where('kind','obligation')->map(fn($r)=>$this->state($r->id))->values()->all(),'documents'=>DB::table('si_invoices')->where($s)->get(['id','series_code','number'])->all()];
|
||||
return ['blocked'=>false,'notice'=>self::NOTICE,'simulation'=>self::SIMULATION,'records'=>$records->map(function($r){$r->data=$this->data($r);return $r;})->all(),'obligations'=>$records->where('kind','obligation')->map(fn($r)=>$this->state($r->id))->values()->all(),'documents'=>\App\Shared\Context\ModuleRecords::query('si_invoices')->where($s)->get(['id','series_code','number'])->all()];
|
||||
});
|
||||
}
|
||||
/** Idempotent internal delivery only: validates ledger, never posts accounts or calls banks. */
|
||||
|
||||
Reference in New Issue
Block a user