transaction(function()use($native,$f){$s=$f['scope'];$id=$native->table('gl_accounts')->where($s)->where('code','QA-REDUCAO-CLIENTE')->value('id');if(!$id)$id=$native->table('gl_accounts')->insertGetId($s+['code'=>'QA-REDUCAO-CLIENTE','label'=>'Redução nominal de cliente exclusivamente QA','currency'=>'MZN','is_movement'=>true]);if(!$native->table('gl_rules')->where($s)->where('rule_key','receivable.reduced')->exists())$native->table('gl_rules')->insert($s+['rule_key'=>'receivable.reduced','effect_type'=>'receivable.reduced','version'=>1,'policy'=>'QA-SALES-JOURNAL-v1','currency'=>'MZN','valid_from'=>'2026-01-01','valid_to'=>'2026-12-31','debit_account_id'=>$id,'credit_account_id'=>$native->table('gl_accounts')->where($s)->where('code','QA-CLIENTES')->value('id'),'created_by'=>4,'reason'=>'Crédito nominal100MZN de nova origem QA autorizado no bloco documental.','created_at'=>now()]);});echo json_encode(['passed'=>true,'book'=>$book,'journals_unchanged'=>true]).PHP_EOL;