@@ -7,13 +7,16 @@ use Illuminate\Support\Arr;
|
||||
/** §28.1: preserve signed decisions; only changed review scopes need new decisions. */
|
||||
class OpportunityReviewMateriality
|
||||
{
|
||||
public const VERSION = 'review-scopes-20261011-v3';
|
||||
public const VERSION = 'review-scopes-20261012-v4';
|
||||
|
||||
// Preserve the projections used by earlier signed reviews.
|
||||
public const BEFORE_FRANCHISE_FINANCE_VERSION = 'review-scopes-20261011-v3';
|
||||
|
||||
public const PREVIOUS_VERSION = 'review-scopes-20261011-v2';
|
||||
|
||||
/** @param array<string,mixed> $snapshot
|
||||
* @return array<string,mixed> */
|
||||
private function scope(array $snapshot, string $gate, bool $extended = true): array
|
||||
private function scope(array $snapshot, string $gate, bool $extended = true, bool $franchiseFinance = true): array
|
||||
{
|
||||
$p = $snapshot['payload'] ?? [];
|
||||
$common = ['opportunity_category', 'promoter_id', 'promoter_type', 'sector_id', 'subsector_id', 'economic_activity_id', 'demand_statement', 'executive_summary'];
|
||||
@@ -49,6 +52,11 @@ class OpportunityReviewMateriality
|
||||
default => [],
|
||||
}];
|
||||
}
|
||||
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) {
|
||||
if (! is_string($field)) {
|
||||
@@ -88,8 +96,10 @@ class OpportunityReviewMateriality
|
||||
* @param array<string,mixed> $review */
|
||||
public function hash(array $snapshot, string $gate, array $review = [], bool $legacy = false, ?string $rule = null): string
|
||||
{
|
||||
$extended = ! $legacy && ($rule ?? self::VERSION) !== self::PREVIOUS_VERSION;
|
||||
$data = $this->scope($snapshot, $gate, $extended);
|
||||
$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);
|
||||
$locationGates = ['registry_urban_review', 'cadastral_screening', 'legal_territorial_review', 'property_review'];
|
||||
if (! $legacy) {
|
||||
$locationGates = [...$locationGates, 'land_legal_review', 'community_environment_review', 'competent_authority_clearance'];
|
||||
@@ -130,7 +140,7 @@ class OpportunityReviewMateriality
|
||||
return true; // Caller must independently verify the original signed submission hash.
|
||||
}
|
||||
$rule = $review['scope_rule'] ?? '';
|
||||
$legacy = ! in_array($rule, [self::VERSION, self::PREVIOUS_VERSION], true);
|
||||
$legacy = ! in_array($rule, [self::VERSION, self::PREVIOUS_VERSION, self::BEFORE_FRANCHISE_FINANCE_VERSION], true);
|
||||
$expected = $this->hash($snapshot, $gate, $review, $legacy, $rule);
|
||||
|
||||
return hash_equals($review['scope_hash'], $expected);
|
||||
|
||||
Reference in New Issue
Block a user