12 lines
3.8 KiB
PHP
12 lines
3.8 KiB
PHP
<?php
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Str;
|
|
$out=$s['root'].'/industrial-correction-coexistence.json';if(file_exists($out))throw new LogicException('Preserved coexistence proof');$before=$fingerprint();$count=DB::table('gl_journals')->count();if($count!==4)throw new LogicException('After single industrial pair, before other source workflows');$checks=0;$ok=function($v,$m)use(&$checks){$checks++;if(!$v)throw new LogicException($m);};
|
|
DB::beginTransaction();try{
|
|
$cf=json_decode(file_get_contents($s['root'].'/ledger-composition-fixture.json'),true);$cg=json_decode(file_get_contents($s['root'].'/cost-correction-fixture.json'),true);$accounts=DB::table('gl_accounts')->where($scope)->pluck('id','code');foreach(['REVERSE'=>['journal.reversal','QA-FORNECEDOR','QA-CONTRAPARTIDA'],'REPLACE'=>['journal.replacement','QA-CONTRAPARTIDA','QA-FORNECEDOR']] as $name=>[$kind,$d,$c])DB::table('gl_rules')->insert($scope+['rule_key'=>'QA-CORRECTION-'.$name,'version'=>1,'policy'=>Tempo\Finance\GeneralLedger\PayableJournal::POLICY,'effect_type'=>$kind,'currency'=>'MZN','valid_from'=>'2026-10-01','valid_to'=>'2026-10-31','debit_account_id'=>$accounts[$d],'credit_account_id'=>$accounts[$c],'created_by'=>$g['actors']['prepare'],'reason'=>'Existing authorised supplier correction compatibility only, rollback.','created_at'=>now()]);
|
|
$p=$command('prepare','prepare',['obligation_id'=>$cf['supplier_obligation_id'],'journal_on'=>'2026-10-29','period_key'=>'QA-2026-10','rule_key'=>'QA-PAYABLE-JOURNAL','reason'=>'Rollback-only existing supplier60 recognition compatibility.']);$command('validate','validate',['proposal_id'=>$p['proposal_id'],'revision'=>$p['revision'],'decision'=>'approved','reason'=>'Distinct supplier60 original review.']);$j=$command('prepare','post',['proposal_id'=>$p['proposal_id'],'revision'=>$p['revision'],'reason'=>'Existing supplier original once in rollback.']);
|
|
foreach([$j['journal_id'],$cg['original_journal_id']] as $original){$p=$command('prepare','correct-prepare',['journal_id'=>$original,'journal_on'=>'2026-10-29','period_key'=>'QA-2026-10','reason'=>'Existing approved source correction alongside industrial pair; rollback-only.']);$command('validate','correct-validate',['correction_id'=>$p['correction_id'],'revision'=>$p['revision'],'decision'=>'approved','reason'=>'Distinct exact domain-specific pair review.']);$command('prepare','correct-post',['correction_id'=>$p['correction_id'],'revision'=>$p['revision'],'reason'=>'Apply approved domain pair in rollback-only coexistence probe.']);}
|
|
DB::statement('SET CONSTRAINTS ALL IMMEDIATE');$ok(DB::table('gl_correction_results')->count()===3&&DB::table('gl_journals')->count()===9&&DB::table('gl_lines')->count()===18,'Three pair domains pass their deferred SQL constraints');foreach(['industrial_lot_id'=>[$i['lot_id'],542000],'cost_order_id'=>[$g['order_id'],84500],'obligation_id'=>[$cf['supplier_obligation_id'],18000]] as $key=>[$id,$gross]){$book=$ledger->listing($enter('read'),[$key=>$id]);$ok(count($book['journals'])===3&&count($book['events'])===9&&$book['totals']['debit_minor']===$gross,'Typed same-numeric-ID filters: '.$key);}$ok(count($ledger->industrial($enter('read'),$i['lot_id'])['corrections'])===1&&count($ledger->costs($enter('read'),$g['order_id'])['corrections'])===1,'Owner group windows exclude other pair domains');
|
|
}finally{while(DB::transactionLevel())DB::rollBack();}
|
|
$ok($before===$fingerprint()&&DB::table('gl_journals')->count()===$count,'Original source/outbox/rights and pre-probe book restored');file_put_contents($out,json_encode(['passed'=>true,'checks'=>$checks,'three_pair_domains_sql_validated'=>true,'same_numeric_source_ids_separate'=>true,'rollback_only'=>true,'source_outbox_rights_unchanged'=>true],JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo "Three correction domains coexist: $checks checks, scoped typed filters and SQL; all probe changes rolled back.\n";
|