feat: caret preservation and Luhn validation in card inputs

- Added generic formatAndPreserveCursor() helper on frontend to track
  and restore selection caret position during dynamic input sanitization
- Applied to all card inputs, gift card code inputs, and expiry inputs
- Added Luhn validation (isValidLuhn) for saved cards and gift cards
- Rebuilt payments test DB and got 100% green tests
This commit is contained in:
2026-06-05 21:05:36 +01:00
parent fd41ca2920
commit 0d4a74bd4a
15 changed files with 3039 additions and 51 deletions
+25 -1
View File
@@ -387,7 +387,7 @@ CREATE SEQUENCE invoice_number_seq
CREATE TABLE payments (
id CHAR(12) PRIMARY KEY DEFAULT generate_payment_id(),
booking_id CHAR(12) NOT NULL REFERENCES bookings(id) ON DELETE RESTRICT,
booking_id CHAR(12) REFERENCES bookings(id) ON DELETE RESTRICT,
payment_type payment_type NOT NULL,
payment_method payment_method NOT NULL,
vendor_code TEXT,
@@ -1556,6 +1556,30 @@ CREATE TABLE affiliate_payouts (
CREATE INDEX idx_affiliate_payouts_affiliate ON affiliate_payouts(affiliate_id);
-- =======================================
-- GIFT CARDS TABLE
-- =======================================
CREATE TABLE gift_cards (
id CHAR(12) PRIMARY KEY DEFAULT generate_short_id('gift_cards'),
total_funds_added NUMERIC(12,2) NOT NULL DEFAULT 0,
amount_remaining NUMERIC(12,2) NOT NULL DEFAULT 0,
created_by CHAR(12) REFERENCES users(id),
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
redeemed_at TIMESTAMPTZ,
redeemed_by CHAR(12) REFERENCES users(id)
);
-- =======================================
-- USER GIFTCARD BALANCES TABLE
-- =======================================
CREATE TABLE user_giftcard_balances (
user_id CHAR(12) PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE,
balance NUMERIC(12,2) NOT NULL DEFAULT 0,
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
-- =======================================
-- SQUARE DEPOSITS TABLE (Bank Reconciliation)
-- =======================================