fixed generated code

This commit is contained in:
2025-09-08 19:21:31 +02:00
parent 8341404f45
commit e198fce791

View File

@@ -229,7 +229,7 @@ export const createLoanInDatabase = async (
// Generate unique loan_code (retry a few times) // Generate unique loan_code (retry a few times)
let loanCode = null; let loanCode = null;
for (let i = 0; i < 6; i++) { for (let i = 0; i < 6; i++) {
const candidate = Math.floor(1000 + Math.random() * 900000); // 4-6 digits const candidate = Math.floor(100000 + Math.random() * 899999); // 6 digits
const [exists] = await conn.query( const [exists] = await conn.query(
"SELECT 1 FROM loans WHERE loan_code = ? LIMIT 1", "SELECT 1 FROM loans WHERE loan_code = ? LIMIT 1",
[candidate] [candidate]