Files
Investidor-V2/outputs/investmoz-audit-current-20261012/patch-franchise-materiality-QA.py
T
nala 287e991486
tests / ci (push) Waiting to run
oportunidades 7
2026-10-13 11:40:29 +02:00

22 lines
3.3 KiB
Python

from pathlib import Path
from datetime import datetime,timezone
import json,hashlib,shutil
OUT=Path(__file__).resolve().parent;ROOT=OUT.parents[1];f=json.loads((OUT/'business-country-fixture.json').read_text(encoding='utf-8'));QA=Path(f['QA_source']);assert QA.resolve().is_relative_to((ROOT/'storage/app/private/investmoz-v2/portal-audit').resolve()) and f['target']['port']==55441
relative='app/Services/OpportunityReviewMateriality.php';p=QA/relative;original=ROOT/relative;activeHash=hashlib.sha256(original.read_bytes()).hexdigest();backup=QA/'storage/app/private/franchise-materiality-20261012-before.php';assert not backup.exists();shutil.copyfile(p,backup)
s=p.read_text(encoding='utf-8');needle=" public const VERSION = 'review-scopes-20261011-v3';";assert s.count(needle)==1;s=s.replace(needle," public const VERSION = 'review-scopes-20261012-v4';\n\n // Preserve the projections used by earlier signed reviews.\n public const BEFORE_FRANCHISE_FINANCE_VERSION = 'review-scopes-20261011-v3';")
needle='private function scope(array $snapshot, string $gate, bool $extended = true): array';assert s.count(needle)==1;s=s.replace(needle,'private function scope(array $snapshot, string $gate, bool $extended = true, bool $franchiseFinance = true): array')
needle=' $data = [];\n foreach ([...$common, ...$fields] as $field) {';assert s.count(needle)==1;s=s.replace(needle,""" if ($franchiseFinance && $gate === 'financial_review' && ($p['opportunity_category'] ?? '') === 'franchise') {
// Existing canonical monetary obligations affect the existing financial review.
// No rates, calculations, reviewers or external decisions are introduced here.
$fields = [...$fields, 'business_transaction.franchise_terms.initial_fee', 'business_transaction.franchise_terms.royalties'];
}
$data = [];
foreach ([...$common, ...$fields] as $field) {""")
needle=" $extended = ! $legacy && ($rule ?? self::VERSION) !== self::PREVIOUS_VERSION;\n $data = $this->scope($snapshot, $gate, $extended);";assert s.count(needle)==1;s=s.replace(needle,""" $effectiveRule = $rule ?? self::VERSION;
$extended = ! $legacy && $effectiveRule !== self::PREVIOUS_VERSION;
$franchiseFinance = ! $legacy && ! in_array($effectiveRule, [self::PREVIOUS_VERSION, self::BEFORE_FRANCHISE_FINANCE_VERSION], true);
$data = $this->scope($snapshot, $gate, $extended, $franchiseFinance);""")
p.write_text(s,encoding='utf-8');assert hashlib.sha256(original.read_bytes()).hexdigest()==activeHash
proof={'at':datetime.now(timezone.utc).isoformat(),'case':'C136','QA_target':f['target'],'file':relative,'before_sha256':hashlib.sha256(backup.read_bytes()).hexdigest(),'after_sha256':hashlib.sha256(p.read_bytes()).hexdigest(),'active_sha256_preserved':activeHash,'compilation_required':False,'new_schema_or_reviews_or_reviewers':False,'source':'Existing franchise_terms initial_fee/royalties contract; existing financial_review and approved materiality principle D-S2','old_signed_projection_versions_preserved':['review-scopes-20261011-v2','review-scopes-20261011-v3'],'visual_and_HTTP_transition_proof_pending':True}
(OUT/'franchise-materiality-QA-delta.json').write_text(json.dumps(proof,indent=2),encoding='utf-8');print(json.dumps(proof))