π‘οΈ Warracker is an open source, self-hostable warranty tracker to monitor expirations, store receipts, files. You own the data, your rules!
Fix 5 minor QA findings (expiry-day, validation, CSV, claim status)
Omega (QA)5979f9d75ced
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 57fc87c..77dbba0 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -2,6 +2,16 @@## 1.0.3 - 2026-05-18### Fixed+- **Expiry-day inconsistency fixed:** a warranty expiring *today* got three different answers β statistics counted it as `expired` (`expiration_date <= today`), the UI showed "expiring" (0 days left), and the notification query excluded it (`expiration_date > today`). All three now agree it is still valid: statistics uses `expiration_date < today` for expired and `>= today` for the active / expiring-soon / timeline buckets, and the expiry notification query includes it (`>= today`).+ - _Files: `backend/statistics_routes.py`, `backend/notifications.py`_+- **Product name length validated:** a 500-character product name (column is `VARCHAR(255)`) caused an unhandled DB error β HTTP 500. Both the create and update endpoints now return HTTP 400 when the name exceeds 255 characters.+ - _Files: `backend/warranties_routes.py`_+- **Expiration-before-purchase rejected:** an exact expiration date earlier than the purchase date was accepted (201). Both the create and update endpoints now return HTTP 400 in that case.+ - _Files: `backend/warranties_routes.py`_+- **CSV tag/serial round-trip fixed:** the frontend export joined tags and serial numbers with spaces while the import splits on commas, so re-importing an export merged multi-tag warranties into a single tag. Export now joins with `", "` to match the import.+ - _Files: `frontend/js/components/importExport.js`_+- **Invalid claim status now rejected:** creating or updating a claim with an invalid status returned 200 and silently coerced it (to `'Submitted'` on create, to the previous value on update). Both endpoints now return HTTP 400 listing the valid statuses.+ - _Files: `backend/warranties_routes.py`_- **All 19 non-English locales now fully translated (machine translation):** Every key in `locales/en/translation.json` (767 keys) was missing from at least one other locale β 2,015 missing keys in total (ru 173, it 150, most others ~95β98) β and a further 1,194 strings existed in 14 locales only as untranslated English. All have now been machine-translated from English (Google Translate), with `{{placeholder}}` integrity verified on every string (22 cases where the engine translated placeholder names like `{{name}}` β `{{nombre}}` were repaired; one Hindi string that dropped `{{count}}` was fixed by hand). Also fixed a pre-existing Hebrew translation that dropped the `{{username}}` placeholder. Short brand/technical terms (Warracker, Paperless-ngx, CSV, OIDC, URLs) were deliberately left as-is. These are machine translations β native-speaker review is recommended before relying on them for customer-facing polish.- _Files: `locales/*/translation.json`_- **66 i18n keys referenced by the frontend had no English definition:** Static analysis of every `t('β¦')` call and `data-i18n` attribute found 66 keys (toast messages, validation errors, claims labels, tag-manager strings, the registration-disabled notice) missing from `locales/en/translation.json`. i18next renders undefined keys as raw key text, so users saw strings like `messages.deleted_successfully` in toasts. All values were taken from the inline English fallbacks already present at the call sites, so default-language UX is unchanged; other languages now fall back to English instead of showing raw keys.diff --git a/backend/notifications.py b/backend/notifications.pyindex b08873e..4e11470 100644--- a/backend/notifications.py+++ b/backend/notifications.py@@ -120,7 +120,7 @@ def get_expiring_warranties(get_db_connection, release_db_connection):user_preferences up ON u.id = up.user_idWHEREw.is_lifetime = FALSE- AND w.expiration_date > %s+ AND w.expiration_date >= %sAND w.expiration_date <= (%s::date + (COALESCE(up.expiring_soon_days, 30) || ' days')::interval)::dateAND w.archived_at IS NULLAND u.is_active = TRUE;diff --git a/backend/statistics_routes.py b/backend/statistics_routes.pyindex 0c27962..7eac26b 100644--- a/backend/statistics_routes.py+++ b/backend/statistics_routes.py@@ -91,18 +91,18 @@ def get_statistics():logger.info(f"Archived warranties: {archived_count}")# Get active count (includes lifetime, excludes archived)- cur.execute(f"SELECT COUNT(*) {from_clause} {where_clause} {active_where if where_clause else 'WHERE'} (w.is_lifetime = TRUE OR w.expiration_date > %s) AND w.archived_at IS NULL", params + [today])+ cur.execute(f"SELECT COUNT(*) {from_clause} {where_clause} {active_where if where_clause else 'WHERE'} (w.is_lifetime = TRUE OR w.expiration_date >= %s) AND w.archived_at IS NULL", params + [today])active_count = cur.fetchone()[0]logger.info(f"Active warranties: {active_count}")# Get expired count (excludes lifetime and archived)- cur.execute(f"SELECT COUNT(*) {from_clause} {where_clause} {active_where if where_clause else 'WHERE'} w.is_lifetime = FALSE AND w.expiration_date <= %s AND w.archived_at IS NULL", params + [today])+ cur.execute(f"SELECT COUNT(*) {from_clause} {where_clause} {active_where if where_clause else 'WHERE'} w.is_lifetime = FALSE AND w.expiration_date < %s AND w.archived_at IS NULL", params + [today])expired_count = cur.fetchone()[0]logger.info(f"Expired warranties: {expired_count}")# Get expiring soon count (excludes lifetime and archived) using user preferencecur.execute(f"""SELECT COUNT(*) {from_clause} {where_clause} {active_where if where_clause else 'WHERE'}- w.is_lifetime = FALSE AND w.expiration_date > %s AND w.expiration_date <= %s AND w.archived_at IS NULL""",+ w.is_lifetime = FALSE AND w.expiration_date >= %s AND w.expiration_date <= %s AND w.archived_at IS NULL""",params + [today, expiring_soon_date])expiring_soon_count = cur.fetchone()[0]logger.info(f"Expiring soon ({expiring_soon_days} days) warranties: {expiring_soon_count}")@@ -115,7 +115,7 @@ def get_statistics():COUNT(*) as count{from_clause}{where_clause} {active_where if where_clause else 'WHERE'}- w.is_lifetime = FALSE AND w.expiration_date > %s AND w.expiration_date <= %s AND w.archived_at IS NULL+ w.is_lifetime = FALSE AND w.expiration_date >= %s AND w.expiration_date <= %s AND w.archived_at IS NULLGROUP BY EXTRACT(YEAR FROM expiration_date), EXTRACT(MONTH FROM expiration_date)ORDER BY year, month""", params + [today, ninety_days_later])@@ -280,16 +280,16 @@ def get_global_statistics():archived_count = cur.fetchone()[0]# Get active count (includes lifetime, excludes archived)- cur.execute("SELECT COUNT(*) FROM warranties w WHERE (w.is_lifetime = TRUE OR w.expiration_date > %s) AND w.archived_at IS NULL", (today,))+ cur.execute("SELECT COUNT(*) FROM warranties w WHERE (w.is_lifetime = TRUE OR w.expiration_date >= %s) AND w.archived_at IS NULL", (today,))active_count = cur.fetchone()[0]# Get expired count (excludes lifetime and archived)- cur.execute("SELECT COUNT(*) FROM warranties w WHERE w.is_lifetime = FALSE AND w.expiration_date <= %s AND w.archived_at IS NULL", (today,))+ cur.execute("SELECT COUNT(*) FROM warranties w WHERE w.is_lifetime = FALSE AND w.expiration_date < %s AND w.archived_at IS NULL", (today,))expired_count = cur.fetchone()[0]# Get expiring soon count (excludes lifetime and archived)cur.execute("""SELECT COUNT(*) FROM warranties w WHERE- w.is_lifetime = FALSE AND w.expiration_date > %s AND w.expiration_date <= %s AND w.archived_at IS NULL""",+ w.is_lifetime = FALSE AND w.expiration_date >= %s AND w.expiration_date <= %s AND w.archived_at IS NULL""",(today, expiring_soon_date))expiring_soon_count = cur.fetchone()[0]@@ -300,7 +300,7 @@ def get_global_statistics():EXTRACT(MONTH FROM expiration_date) as month,COUNT(*) as countFROM warranties w- WHERE w.is_lifetime = FALSE AND w.expiration_date > %s AND w.expiration_date <= %s AND w.archived_at IS NULL+ WHERE w.is_lifetime = FALSE AND w.expiration_date >= %s AND w.expiration_date <= %s AND w.archived_at IS NULLGROUP BY EXTRACT(YEAR FROM expiration_date), EXTRACT(MONTH FROM expiration_date)ORDER BY year, month""", (today, ninety_days_later))diff --git a/backend/warranties_routes.py b/backend/warranties_routes.pyindex 1f98d02..2d0fbec 100644--- a/backend/warranties_routes.py+++ b/backend/warranties_routes.py@@ -192,6 +192,9 @@ def add_warranty():# Validate input dataif not request.form.get('product_name'):return jsonify({"error": "Product name is required"}), 400++ if len(request.form.get('product_name')) > 255:+ return jsonify({"error": "Product name must be 255 characters or less"}), 400if not request.form.get('purchase_date'):return jsonify({"error": "Purchase date is required"}), 400@@ -325,7 +328,11 @@ def add_warranty():else:# Neither exact date nor duration providedreturn jsonify({"error": "Either exact expiration date or warranty duration must be specified for non-lifetime warranties."}), 400-++ # Expiration date cannot precede the purchase date+ if expiration_date is not None and expiration_date < purchase_date:+ return jsonify({"error": "Expiration date cannot be before purchase date"}), 400+# Handle Paperless-ngx document IDs if provided (check before file uploads)paperless_invoice_id = request.form.get('paperless_invoice_id')paperless_manual_id = request.form.get('paperless_manual_id')@@ -635,6 +642,8 @@ def update_warranty(warranty_id):# Validate input data similar to the add_warranty routeif not request.form.get('product_name'):return jsonify({"error": "Product name is required"}), 400+ if len(request.form.get('product_name')) > 255:+ return jsonify({"error": "Product name must be 255 characters or less"}), 400if not request.form.get('purchase_date'):return jsonify({"error": "Purchase date is required"}), 400logger.info(f"Received update request for warranty {warranty_id}")@@ -704,7 +713,11 @@ def update_warranty(warranty_id):return jsonify({"error": "Failed to calculate expiration date from duration components"}), 500else:return jsonify({"error": "Either exact expiration date or warranty duration must be specified for non-lifetime warranties."}), 400-++ # Expiration date cannot precede the purchase date+ if expiration_date is not None and expiration_date < purchase_date:+ return jsonify({"error": "Expiration date cannot be before purchase date"}), 400+logger.info(f"Calculated values: Y={warranty_duration_years}, M={warranty_duration_months}, D={warranty_duration_days}, expiration_date={expiration_date}")product_name = request.form['product_name']serial_numbers = request.form.getlist('serial_numbers[]') # Ensure correct parsing for lists@@ -2166,7 +2179,7 @@ def create_claim(warranty_id):# Validate statusvalid_statuses = ['Submitted', 'In Progress', 'Approved', 'Denied', 'Resolved', 'Cancelled']if status not in valid_statuses:- status = 'Submitted'+ return jsonify({'error': f"Invalid claim status. Must be one of: {', '.join(valid_statuses)}"}), 400# Insert new claimcur.execute("""@@ -2362,8 +2375,8 @@ def update_claim(warranty_id, claim_id):# Validate statusvalid_statuses = ['Submitted', 'In Progress', 'Approved', 'Denied', 'Resolved', 'Cancelled']if status not in valid_statuses:- status = current_claim[1]-+ return jsonify({'error': f"Invalid claim status. Must be one of: {', '.join(valid_statuses)}"}), 400+# Handle empty strings as Noneclaim_number = claim_number.strip() if claim_number else Nonedescription = description.strip() if description else Nonediff --git a/frontend/js/components/importExport.js b/frontend/js/components/importExport.jsindex d2bf021..1a1ad0d 100644--- a/frontend/js/components/importExport.js+++ b/frontend/js/components/importExport.js@@ -60,10 +60,10 @@ export async function exportWarranties() {let csv = `${headers.join(',')}\n`;filtered.forEach((warranty) => {const serials = Array.isArray(warranty.serial_numbers)- ? warranty.serial_numbers.filter(Boolean).join(' ')+ ? warranty.serial_numbers.filter(Boolean).join(', '): '';const tags = Array.isArray(warranty.tags)- ? warranty.tags.map((tag) => tag.name).join(' ')+ ? warranty.tags.map((tag) => tag.name).join(', '): '';const row = [warranty.product_name || '',