Skip to content

Commit

Permalink
Merge pull request #152 from bcgov/uspa-changes-2024/SOW25N003-7-
Browse files Browse the repository at this point in the history
SOW25N003-7  Exceeding Caps - Draft vs Error
  • Loading branch information
m7amad-github authored Dec 16, 2024
2 parents f62918d + 23e277d commit 3049dd7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,16 @@ private function getFedGuid(Cap $cap)
$next_numeric_part = 100000000;
}

// Construct the next value
return 'BC'.$year_prefix.'-'.sprintf('%03d', $next_numeric_part);
// Loop to ensure uniqueness
do {
$fed_guid = 'BC' . $year_prefix . '-' . sprintf('%09d', $next_numeric_part);
$exists = Attestation::where('fed_guid', $fed_guid)->exists();

if ($exists) {
$next_numeric_part++;
}
} while ($exists);

return $fed_guid;
}
}
13 changes: 11 additions & 2 deletions Modules/Institution/App/Http/Requests/AttestationStoreRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,16 @@ private function getFedGuid(Cap $cap)
$next_numeric_part = 100000000;
}

// Construct the next value
return 'BC'.$year_prefix.'-'.sprintf('%03d', $next_numeric_part);
// Loop to ensure uniqueness
do {
$fed_guid = 'BC' . $year_prefix . '-' . sprintf('%09d', $next_numeric_part);
$exists = Attestation::where('fed_guid', $fed_guid)->exists();

if ($exists) {
$next_numeric_part++;
}
} while ($exists);

return $fed_guid;
}
}
13 changes: 11 additions & 2 deletions app/Http/Requests/AttestationStoreRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,16 @@ private function getFedGuid(Cap $cap)
$next_numeric_part = 100000000;
}

// Construct the next value
return 'BC'.$year_prefix.'-'.sprintf('%03d', $next_numeric_part);
// Loop to ensure uniqueness
do {
$fed_guid = 'BC' . $year_prefix . '-' . sprintf('%09d', $next_numeric_part);
$exists = Attestation::where('fed_guid', $fed_guid)->exists();

if ($exists) {
$next_numeric_part++;
}
} while ($exists);

return $fed_guid;
}
}

0 comments on commit 3049dd7

Please sign in to comment.