Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ MBeneficiaryregidmapping findFirstByProviderServiceMapIDAndVehicalNoOrderByBenRe

Long countByProvisioned(Boolean isProvisioned);

/**
* Count of BenRegIds that are genuinely claimable right now — i.e. not
* provisioned AND not reserved. countByProvisioned(false) alone overstates
* availability because it also counts rows claimed (Reserved=true) by an
* in-flight registration that was later abandoned/crashed before completing.
*/
Long countByProvisionedAndReserved(Boolean isProvisioned, Boolean isReserved);

@Transactional
@Modifying
@Query("update MBeneficiaryregidmapping set providerServiceMapID = null , vehicalNo = null "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2201,7 +2201,10 @@ public int importBenIdToLocalServer(List<BenIdImportDTO> benIdImportDTOList) {
}

public Long checkBenIDAvailabilityLocal() {
return regIdRepo.countByProvisioned(false);
// Provisioned=false alone also counts rows claimed (Reserved=true) by an
// abandoned/crashed registration attempt that never completed. Those are
// not actually available to a new registration, so exclude them here.
return regIdRepo.countByProvisionedAndReserved(false, false);

}

Expand Down
Loading