Skip to content

πŸ›‘οΈ Warracker is an open source, self-hostable warranty tracker to monitor expirations, store receipts, files. You own the data, your rules!

Add void warranty status (issue #250)

Omega (QA)4555ce0e1e19
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 73eeaf6..3ed430b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,8 @@
- **Claim documents (issue #148):** claims can now carry documents β€” claim approval or rejection letters, photos of the defect, repair invoices, and similar evidence. Each claim shows a Documents section in the claims view: attach a file directly, or upload it to Paperless-ngx and link it, then view or remove it from the same place. Access follows the warranty's other documents: the owner and admins only, never shared through global view. Deleting a claim or its warranty removes the attached local files from disk; Paperless documents are unlinked, never deleted from Paperless.
- _Files: `backend/migrations/052_create_claim_documents_table.sql`, `backend/warranties_routes.py`, `backend/file_routes.py`, `frontend/js/components/claims.js`, `frontend/style.css`, `locales/en/translation.json`_
+- **Void warranty status (issue #250):** a warranty can now be manually terminated ("voided") when its conditions are broken before the expiration date β€” physical damage, unauthorized repairs, broken seals β€” without deleting the item or changing its expiration date. Voided warranties stay in the list with a Void status (with a matching filter on the main page and the status dashboard, plus a Void count card), and are excluded from the Total Value card, active/expired/expiring counts, expiration timelines, and expiry notification emails. Voiding is reversible from the same card actions.
+ - _Files: `backend/migrations/053_add_voided_at_to_warranties.sql`, `backend/warranties_routes.py`, `backend/statistics_routes.py`, `backend/notifications.py`, `frontend/js/components/warrantyActions.js`, `frontend/js/components/warrantyRenderer.js`, `frontend/js/controllers/warrantyListController.js`, `frontend/js/lib/warrantyProcessing.js`, `frontend/script.js`, `frontend/index.html`, `frontend/status.js`, `frontend/status.html`, `frontend/style.css`, `locales/en/translation.json`_
## 1.0.3 - 2026-10-02
diff --git a/backend/migrations/053_add_voided_at_to_warranties.sql b/backend/migrations/053_add_voided_at_to_warranties.sql
new file mode 100644
index 0000000..51dbbbf
--- /dev/null
+++ b/backend/migrations/053_add_voided_at_to_warranties.sql
@@ -0,0 +1,6 @@
+-- Migration 053: voided_at on warranties (issue #250)
+-- Manual warranty termination: a warranty can be marked void (conditions
+-- broken, unauthorized repair, etc.) without deleting it or changing its
+-- expiration date. Mirrors archived_at (migration 045): NULL = not void.
+ALTER TABLE warranties ADD COLUMN IF NOT EXISTS voided_at TIMESTAMP WITH TIME ZONE DEFAULT NULL;
+CREATE INDEX IF NOT EXISTS idx_warranties_voided_at ON warranties(voided_at);
diff --git a/backend/notifications.py b/backend/notifications.py
index 46b8b8e..ec15768 100644
--- a/backend/notifications.py
+++ b/backend/notifications.py
@@ -124,6 +124,7 @@ def get_expiring_warranties(get_db_connection, release_db_connection):
AND w.expiration_date >= %s
AND w.expiration_date <= (%s::date + (COALESCE(up.expiring_soon_days, 30) || ' days')::interval)::date
AND w.archived_at IS NULL
+ AND w.voided_at IS NULL
AND u.is_active = TRUE;
""", (today, today))
diff --git a/backend/statistics_routes.py b/backend/statistics_routes.py
index fd6b90c..af1397f 100644
--- a/backend/statistics_routes.py
+++ b/backend/statistics_routes.py
@@ -111,26 +111,32 @@ def get_statistics():
archived_count = cur.fetchone()[0]
logger.info(f"Archived warranties: {archived_count}")
+ # Get voided count (issue #250; warranties that are also
+ # archived count as archived, matching the list views)
+ cur.execute(f"SELECT COUNT(*) {from_clause} {where_clause} AND w.archived_at IS NULL AND w.voided_at IS NOT NULL", params)
+ voided_count = cur.fetchone()[0]
+ logger.info(f"Voided warranties: {voided_count}")
+
# Get total purchase value (excluding archived; issue #192:
# only the user's default currency, not a cross-currency sum)
user_currency = get_user_currency_code(cur, user_id)
- cur.execute(f"SELECT COALESCE(SUM(w.purchase_price), 0) {from_clause} {where_clause} AND w.archived_at IS NULL AND w.currency = %s", params + [user_currency])
+ cur.execute(f"SELECT COALESCE(SUM(w.purchase_price), 0) {from_clause} {where_clause} AND w.archived_at IS NULL AND w.voided_at IS NULL AND w.currency = %s", params + [user_currency])
total_value = cur.fetchone()[0]
logger.info(f"Total purchase value ({user_currency}): {total_value}")
# 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 AND w.voided_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 AND w.voided_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 preference
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.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 AND w.voided_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}")
@@ -143,7 +149,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 NULL AND w.voided_at IS NULL
GROUP BY EXTRACT(YEAR FROM expiration_date), EXTRACT(MONTH FROM expiration_date)
ORDER BY year, month
""", params + [today, ninety_days_later])
@@ -171,7 +177,7 @@ def get_statistics():
expiration_date, invoice_path, manual_path, other_document_path, product_url, purchase_price, is_lifetime
{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 AND w.voided_at IS NULL
ORDER BY expiration_date
LIMIT 10
""", params + [days_ago_for_recent, days_later_for_recent])
@@ -202,7 +208,8 @@ def get_statistics():
warranty_duration_years, warranty_duration_months, warranty_duration_days,
expiration_date, invoice_path, manual_path, other_document_path, product_url, purchase_price, is_lifetime,
model_number, notes, currency, vendor, warranty_type,
- (archived_at IS NOT NULL) AS is_archived
+ (archived_at IS NOT NULL) AS is_archived,
+ (voided_at IS NOT NULL) AS is_voided
{from_clause}
{where_clause}
ORDER BY expiration_date DESC
@@ -247,6 +254,7 @@ def get_statistics():
'expired': expired_count,
'expiring_soon': expiring_soon_count,
'archived': archived_count,
+ 'voided': voided_count,
'total_value': total_value,
'timeline': timeline,
'recent_warranties': recent_warranties,
@@ -321,24 +329,28 @@ def get_global_statistics():
cur.execute("SELECT COUNT(*) FROM warranties w WHERE w.archived_at IS NOT NULL")
archived_count = cur.fetchone()[0]
+ # Get voided count (issue #250)
+ cur.execute("SELECT COUNT(*) FROM warranties w WHERE w.archived_at IS NULL AND w.voided_at IS NOT NULL")
+ voided_count = cur.fetchone()[0]
+
# Get total purchase value (excluding archived; issue #192:
# only the requesting user's default currency, not a cross-currency sum)
user_currency = get_user_currency_code(cur, request.user['id'])
- cur.execute("SELECT COALESCE(SUM(w.purchase_price), 0) FROM warranties w WHERE w.archived_at IS NULL AND w.currency = %s", (user_currency,))
+ cur.execute("SELECT COALESCE(SUM(w.purchase_price), 0) FROM warranties w WHERE w.archived_at IS NULL AND w.voided_at IS NULL AND w.currency = %s", (user_currency,))
total_value = cur.fetchone()[0]
logger.info(f"Global total purchase value ({user_currency}): {total_value}")
# 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 AND w.voided_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 AND w.voided_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 AND w.voided_at IS NULL""",
(today, expiring_soon_date))
expiring_soon_count = cur.fetchone()[0]
@@ -349,7 +361,7 @@ def get_global_statistics():
EXTRACT(MONTH FROM expiration_date) as month,
COUNT(*) as 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
+ WHERE w.is_lifetime = FALSE AND w.expiration_date >= %s AND w.expiration_date <= %s AND w.archived_at IS NULL AND w.voided_at IS NULL
GROUP BY EXTRACT(YEAR FROM expiration_date), EXTRACT(MONTH FROM expiration_date)
ORDER BY year, month
""", (today, ninety_days_later))
@@ -377,7 +389,7 @@ def get_global_statistics():
u.username, u.email, u.first_name, u.last_name
FROM warranties w
JOIN users u ON w.user_id = u.id
- 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 NULL AND w.voided_at IS NULL
ORDER BY w.expiration_date
LIMIT 10
""", (days_ago_for_recent, days_later_for_recent))
@@ -425,7 +437,8 @@ def get_global_statistics():
w.product_url, w.purchase_price, w.is_lifetime,
u.username, u.email, u.first_name, u.last_name,
w.model_number, w.notes, w.currency, w.vendor, w.warranty_type,
- (w.archived_at IS NOT NULL) AS is_archived
+ (w.archived_at IS NOT NULL) AS is_archived,
+ (w.voided_at IS NOT NULL) AS is_voided
FROM warranties w
JOIN users u ON w.user_id = u.id
ORDER BY w.expiration_date DESC
@@ -484,6 +497,7 @@ def get_global_statistics():
'expired': expired_count,
'expiring_soon': expiring_soon_count,
'archived': archived_count,
+ 'voided': voided_count,
'total_value': total_value,
'timeline': timeline,
'recent_warranties': recent_warranties,
diff --git a/backend/warranties_routes.py b/backend/warranties_routes.py
index 929515e..0b5a2eb 100644
--- a/backend/warranties_routes.py
+++ b/backend/warranties_routes.py
@@ -103,7 +103,7 @@ def get_warranties():
w.purchase_price, w.user_id, w.created_at, w.updated_at, w.is_lifetime, w.vendor, w.warranty_type,
w.warranty_duration_years, w.warranty_duration_months, w.warranty_duration_days, w.product_photo_path, w.currency,
w.paperless_invoice_id, w.paperless_manual_id, w.paperless_photo_id, w.paperless_other_id,
- w.invoice_url, w.manual_url, w.other_document_url, w.model_number,
+ w.invoice_url, w.manual_url, w.other_document_url, w.model_number, w.voided_at,
CASE
WHEN COUNT(c.id) = 0 THEN 'NO_CLAIMS'
WHEN BOOL_OR(c.status IN ('Submitted', 'In Progress')) THEN 'OPEN'
@@ -172,7 +172,7 @@ def get_archived_warranties():
w.purchase_price, w.user_id, w.created_at, w.updated_at, w.is_lifetime, w.vendor, w.warranty_type,
w.warranty_duration_years, w.warranty_duration_months, w.warranty_duration_days, w.product_photo_path, w.currency,
w.paperless_invoice_id, w.paperless_manual_id, w.paperless_photo_id, w.paperless_other_id,
- w.invoice_url, w.manual_url, w.other_document_url, w.model_number,
+ w.invoice_url, w.manual_url, w.other_document_url, w.model_number, w.voided_at,
CASE
WHEN COUNT(c.id) = 0 THEN 'NO_CLAIMS'
WHEN BOOL_OR(c.status IN ('Submitted', 'In Progress')) THEN 'OPEN'
@@ -588,6 +588,57 @@ def toggle_archive_warranty(warranty_id):
if conn:
release_db_connection(conn)
+@warranties_bp.route('/warranties/<int:warranty_id>/void', methods=['PATCH'])
+@token_required
+def toggle_void_warranty(warranty_id):
+ """Manually terminate (void) or restore a warranty (issue #250).
+
+ Voiding marks the warranty inactive without deleting it or changing its
+ expiration date. Voided warranties stay in the list with a Void status,
+ and are excluded from totals, active counts, and expiry notifications.
+ """
+ conn = None
+ try:
+ user_id = request.user['id']
+ is_admin = request.user.get('is_admin', False)
+
+ if not request.is_json:
+ return jsonify({"error": "Request must be JSON"}), 400
+ data = request.get_json(silent=True)
+ if not data:
+ return jsonify({"error": "Request body must be valid JSON"}), 400
+ voided_flag = data.get('voided')
+ if voided_flag is None:
+ return jsonify({"error": "Missing 'voided' boolean in request body"}), 400
+
+ conn = get_db_connection()
+ with conn.cursor() as cur:
+ # Ensure warranty exists and belongs to user unless admin
+ if is_admin:
+ cur.execute('SELECT id FROM warranties WHERE id = %s', (warranty_id,))
+ else:
+ cur.execute('SELECT id FROM warranties WHERE id = %s AND user_id = %s', (warranty_id, user_id))
+ row = cur.fetchone()
+ if not row:
+ return jsonify({"error": "Warranty not found or permission denied"}), 404
+
+ if voided_flag is True:
+ cur.execute('UPDATE warranties SET voided_at = NOW(), updated_at = NOW() WHERE id = %s', (warranty_id,))
+ else:
+ cur.execute('UPDATE warranties SET voided_at = NULL, updated_at = NOW() WHERE id = %s', (warranty_id,))
+
+ conn.commit()
+
+ return jsonify({"message": "Void status updated", "voided": bool(voided_flag)})
+ except Exception as e:
+ current_app.logger.error(f"Error toggling void status: {e}")
+ if conn:
+ conn.rollback()
+ return jsonify({"error": "Failed to update void status"}), 500
+ finally:
+ if conn:
+ release_db_connection(conn)
+
@warranties_bp.route('/warranties/<int:warranty_id>', methods=['DELETE'])
@token_required
def delete_warranty(warranty_id):
@@ -1738,7 +1789,7 @@ def get_global_warranties():
w.product_url, w.notes, w.purchase_price, w.user_id, w.created_at, w.updated_at, w.is_lifetime,
w.vendor, w.warranty_type, w.warranty_duration_years, w.warranty_duration_months, w.warranty_duration_days, w.product_photo_path, w.currency,
w.paperless_invoice_id, w.paperless_manual_id, w.paperless_photo_id, w.paperless_other_id,
- w.invoice_url, w.manual_url, w.other_document_url, w.model_number,
+ w.invoice_url, w.manual_url, w.other_document_url, w.model_number, w.voided_at,
u.username, u.email, u.first_name, u.last_name,
CASE
WHEN EXISTS (
@@ -1851,7 +1902,7 @@ def get_global_warranties_archived():
w.product_url, w.notes, w.purchase_price, w.user_id, w.created_at, w.updated_at, w.is_lifetime,
w.vendor, w.warranty_type, w.warranty_duration_years, w.warranty_duration_months, w.warranty_duration_days, w.product_photo_path, w.currency,
w.paperless_invoice_id, w.paperless_manual_id, w.paperless_photo_id, w.paperless_other_id,
- w.invoice_url, w.manual_url, w.other_document_url, w.model_number,
+ w.invoice_url, w.manual_url, w.other_document_url, w.model_number, w.voided_at,
u.username, u.email, u.first_name, u.last_name,
CASE
WHEN EXISTS (
diff --git a/frontend/index.html b/frontend/index.html
index 8f9f181..bf88c49 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -205,6 +205,7 @@
<option value="active" data-i18n="warranties.active">Active</option>
<option value="expiring" data-i18n="warranties.expiring_soon">Expiring Soon</option>
<option value="expired" data-i18n="warranties.expired">Expired</option>
+ <option value="void" data-i18n="warranties.void">Void</option>
<option value="archived" data-i18n="warranties.archived">Archived</option>
</select>
</div>
diff --git a/frontend/js/components/warrantyActions.js b/frontend/js/components/warrantyActions.js
index a235458..7902521 100644
--- a/frontend/js/components/warrantyActions.js
+++ b/frontend/js/components/warrantyActions.js
@@ -34,6 +34,37 @@ async function toggleArchiveStatus(warrantyId, shouldArchive) {
}
}
+async function toggleVoidStatus(warrantyId, shouldVoid) {
+ if (!warrantyId) {
+ showToast(window.i18next ? window.i18next.t('messages.no_warranty_selected') : 'No warranty selected', 'error');
+ return;
+ }
+ try {
+ showLoadingSpinner();
+ await request(`/api/warranties/${warrantyId}/void`, {
+ method: 'PATCH',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ voided: !!shouldVoid }),
+ });
+ hideLoadingSpinner();
+ showToast(
+ shouldVoid
+ ? window.i18next ? window.i18next.t('messages.voided_success') : 'Warranty voided'
+ : window.i18next ? window.i18next.t('messages.unvoided_success') : 'Warranty restored from void',
+ 'success',
+ );
+ await loadWarranties(true);
+ applyFilters();
+ } catch (error) {
+ hideLoadingSpinner();
+ console.error('[warrantyActions] Failed to toggle void', error);
+ showToast(
+ window.i18next ? window.i18next.t('messages.error_updating_void_status') : 'Failed to update void status',
+ 'error',
+ );
+ }
+}
+
async function deleteWarranty() {
let warrantyId = getCurrentWarrantyId();
// Fallback to global variable (script.js compatibility)
@@ -87,10 +118,11 @@ function closeModals() {
document.querySelectorAll('.modal-backdrop').forEach((modal) => modal.classList.remove('active'));
}
-export { toggleArchiveStatus, deleteWarranty, confirmArchive, closeModals };
+export { toggleArchiveStatus, toggleVoidStatus, deleteWarranty, confirmArchive, closeModals };
if (typeof window !== 'undefined') {
window.toggleArchiveStatus = toggleArchiveStatus;
+ window.toggleVoidStatus = toggleVoidStatus;
window.deleteWarranty = deleteWarranty;
window.confirmArchive = confirmArchive;
window.closeModals = closeModals;
diff --git a/frontend/js/components/warrantyRenderer.js b/frontend/js/components/warrantyRenderer.js
index 6ac4638..e84d9dd 100644
--- a/frontend/js/components/warrantyRenderer.js
+++ b/frontend/js/components/warrantyRenderer.js
@@ -373,6 +373,17 @@ function buildActionButtons(warranty, { canEdit, isArchivedView, claimsMeta }) {
<button class="action-btn archive-btn" title="Archive" data-id="${warranty.id}">
<i class="fas fa-archive"></i>
</button>
+ ${warranty.is_voided
+ ? `
+ <button class="action-btn unvoid-btn" title="${t('warranties.unvoid_warranty', 'Unvoid warranty')}" data-id="${warranty.id}">
+ <i class="fas fa-undo"></i>
+ </button>
+ `
+ : `
+ <button class="action-btn void-btn" title="${t('warranties.void_warranty', 'Void warranty')}" data-id="${warranty.id}">
+ <i class="fas fa-ban"></i>
+ </button>
+ `}
`}
<button class="action-btn delete-btn" title="Delete" data-id="${warranty.id}">
<i class="fas fa-trash"></i>
@@ -383,6 +394,7 @@ function buildActionButtons(warranty, { canEdit, isArchivedView, claimsMeta }) {
function cardClassName(warranty, view, statusClass) {
const isArchived = warranty.is_archived || warranty.viewFlags?.isArchivedView;
if (isArchived) return 'warranty-card archived';
+ if (warranty.is_voided) return 'warranty-card voided';
if (view === 'table') return `warranty-card status-${statusClass}`;
if (statusClass === 'expired') return 'warranty-card expired';
if (statusClass === 'expiring') return 'warranty-card expiring-soon';
@@ -525,8 +537,14 @@ export function renderWarrantiesList(warranties, options = {}) {
sorted.forEach((warranty) => {
const statusText = (isArchivedView || warranty.is_archived)
? t('warranties.archived', 'Archived')
- : warranty.statusText || t('warranties.unknown_status', 'Unknown Status');
- const statusClass = (isArchivedView || warranty.is_archived) ? 'archived' : (warranty.status || 'unknown');
+ : warranty.is_voided
+ ? t('warranties.void', 'Void')
+ : warranty.statusText || t('warranties.unknown_status', 'Unknown Status');
+ const statusClass = (isArchivedView || warranty.is_archived)
+ ? 'archived'
+ : warranty.is_voided
+ ? 'void'
+ : (warranty.status || 'unknown');
const notesLink = buildNotesLink(warranty);
const documentLinks = buildDocumentLinks(warranty, notesLink.html);
const tagsHtml = buildTagsHtml(warranty.tags);
diff --git a/frontend/js/controllers/warrantyListController.js b/frontend/js/controllers/warrantyListController.js
index b3e1522..206476a 100644
--- a/frontend/js/controllers/warrantyListController.js
+++ b/frontend/js/controllers/warrantyListController.js
@@ -28,7 +28,7 @@ import { loadTags as loadTagsModule, openTagManagementModal } from '../component
import { renderWarrantiesList } from '../components/warrantyRenderer.js';
import { processWarrantyData } from '../lib/warrantyProcessing.js';
import { exportWarranties, handleImport as importCsv } from '../components/importExport.js';
-import { deleteWarranty as deleteWarrantyAction, toggleArchiveStatus as toggleArchive, confirmArchive as confirmArchiveAction } from '../components/warrantyActions.js';
+import { deleteWarranty as deleteWarrantyAction, toggleArchiveStatus as toggleArchive, toggleVoidStatus as toggleVoid, confirmArchive as confirmArchiveAction } from '../components/warrantyActions.js';
import { openEditModal, saveWarranty as saveEditedWarranty } from '../components/editModal.js';
import { preloadWarrantyImages } from '../components/paperless.js';
@@ -831,6 +831,21 @@ export function initEventListeners() {
if (Number.isFinite(id)) toggleArchive(id, false);
return;
}
+ if (e.target.closest('.void-btn')) {
+ e.preventDefault();
+ const id = parseInt(e.target.closest('.void-btn')?.dataset?.id);
+ const confirmMessage = window.i18next
+ ? window.i18next.t('messages.confirm_void_warranty')
+ : 'Void this warranty? It will be marked inactive and excluded from totals and notifications. You can restore it later.';
+ if (Number.isFinite(id) && window.confirm(confirmMessage)) toggleVoid(id, true);
+ return;
+ }
+ if (e.target.closest('.unvoid-btn')) {
+ e.preventDefault();
+ const id = parseInt(e.target.closest('.unvoid-btn')?.dataset?.id);
+ if (Number.isFinite(id)) toggleVoid(id, false);
+ return;
+ }
});
list._wlcDelegated = true;
}
diff --git a/frontend/js/lib/warrantyProcessing.js b/frontend/js/lib/warrantyProcessing.js
index abc28e4..9b391a0 100644
--- a/frontend/js/lib/warrantyProcessing.js
+++ b/frontend/js/lib/warrantyProcessing.js
@@ -12,6 +12,7 @@ export function processWarrantyData(warranty) {
if (!warranty || typeof warranty !== 'object') return warranty;
const processed = { ...warranty };
processed.is_archived = Boolean(warranty.__isArchived || warranty.is_archived);
+ processed.is_voided = Boolean(warranty.is_voided || warranty.voided_at);
processed.product_name = processed.product_name || 'Unnamed Product';
const today = new Date();
@@ -31,6 +32,10 @@ export function processWarrantyData(warranty) {
processed.display_duration_months = 0;
processed.display_duration_days = 0;
processed.original_input_method = 'duration';
+ if (processed.is_voided) {
+ processed.status = 'void';
+ processed.statusText = translate('warranties.void', 'Void');
+ }
return processed;
}
@@ -90,6 +95,12 @@ export function processWarrantyData(warranty) {
processed.daysRemaining = null;
}
+ // Void (issue #250) takes precedence over the date-derived status
+ if (processed.is_voided) {
+ processed.status = 'void';
+ processed.statusText = translate('warranties.void', 'Void');
+ }
+
return processed;
}
diff --git a/frontend/script.js b/frontend/script.js
index ed4f6a4..2fb4ecb 100644
--- a/frontend/script.js
+++ b/frontend/script.js
@@ -1088,6 +1088,7 @@ function processWarrantyData(warranty) {
const processedWarranty = { ...warranty };
// Flag archived items when merged into All view
processedWarranty.is_archived = !!(warranty.__isArchived || warranty.is_archived);
+ processedWarranty.is_voided = !!(warranty.is_voided || warranty.voided_at);
// Ensure product_name exists
if (!processedWarranty.product_name) {
@@ -1221,6 +1222,12 @@ function processWarrantyData(warranty) {
processedWarranty.daysRemaining = null;
}
+ // Void (issue #250) takes precedence over the date-derived status
+ if (processedWarranty.is_voided) {
+ processedWarranty.status = 'void';
+ processedWarranty.statusText = window.i18next ? window.i18next.t('warranties.void') : 'Void';
+ }
+
console.log('Processed warranty data result:', processedWarranty);
return processedWarranty;
}
diff --git a/frontend/status.html b/frontend/status.html
index 0793006..a9dc5b6 100644
--- a/frontend/status.html
+++ b/frontend/status.html
@@ -452,6 +452,16 @@
</div>
</div>
+ <div class="status-card" data-status="void">
+ <div class="card-icon">
+ <i class="fas fa-ban"></i>
+ </div>
+ <div class="card-content">
+ <h3 data-i18n="status.void_warranties">Void</h3>
+ <p class="count" id="voidedCount">0</p>
+ </div>
+ </div>
+
<div class="status-card" data-status="total_value" id="totalValueCard" role="button" tabindex="0" aria-label="Total Value details">
<div class="card-icon">
<i class="fas fa-coins"></i>
@@ -497,6 +507,7 @@
<option value="active" data-i18n="warranties.active">Active</option>
<option value="expiring" data-i18n="warranties.expiring_soon">Expiring Soon</option>
<option value="expired" data-i18n="warranties.expired">Expired</option>
+ <option value="void" data-i18n="warranties.void">Void</option>
<option value="archived" data-i18n="warranties.archived">Archived</option>
</select>
</div>
diff --git a/frontend/status.js b/frontend/status.js
index bd643b4..109f71d 100644
--- a/frontend/status.js
+++ b/frontend/status.js
@@ -419,12 +419,14 @@
const expiringEl = document.getElementById('expiringCount');
const expiredEl = document.getElementById('expiredCount');
const archivedEl = document.getElementById('archivedCount');
+ const voidedEl = document.getElementById('voidedCount');
const totalValueEl = document.getElementById('totalValueCount');
if (totalEl) totalEl.textContent = statusData.total || 0;
if (activeEl) activeEl.textContent = statusData.active || 0;
if (expiringEl) expiringEl.textContent = statusData.expiring_soon || 0;
if (expiredEl) expiredEl.textContent = statusData.expired || 0;
if (archivedEl) archivedEl.textContent = statusData.archived || 0;
+ if (voidedEl) voidedEl.textContent = statusData.voided || 0;
if (totalValueEl) {
const val = parseFloat(statusData.total_value || 0);
totalValueEl.textContent = userCurrencySymbol + val.toFixed(2);
@@ -581,6 +583,7 @@
manual_path: warranty.manual_path || null,
other_document_path: warranty.other_document_path || null,
is_archived: !!warranty.is_archived,
+ is_voided: !!warranty.is_voided,
// Add user fields for global view
user_display_name: warranty.user_display_name,
username: warranty.username,
@@ -597,6 +600,10 @@
if (warranty.is_archived) {
return { text: i18next.t('warranties.archived', 'Archived'), className: 'status-archived' };
}
+ // Void (issue #250) takes precedence over the date-derived status
+ if (warranty.is_voided) {
+ return { text: i18next.t('warranties.void', 'Void'), className: 'status-void' };
+ }
if (warranty.is_lifetime) {
return { text: i18next.t('warranties.lifetime'), className: 'status-lifetime' };
}
@@ -638,6 +645,16 @@
return currentStatusValue === 'all';
}
+ // Explicit void filter (issue #250)
+ if (currentStatusValue === 'void') {
+ return !!w.is_voided;
+ }
+
+ // Exclude voided from the other specific filters
+ if (w.is_voided) {
+ return currentStatusValue === 'all';
+ }
+
if (w.is_lifetime) {
if (currentStatusValue === 'expired' || currentStatusValue === 'expiring') return false;
return true; // Included in 'all' and 'active'
@@ -1028,7 +1045,7 @@
if (Object.keys(statusDistributionData).length > 0 && statusDistributionData.total > 0) {
currentStatusData = statusDistributionData;
- updateSummaryCounts(statusDistributionData);
+ updateSummaryCounts({ ...statusDistributionData, voided: data.voided || 0 });
createStatusChart(statusDistributionData);
} else {
console.warn("Status distribution data from API is incomplete or zero. Displaying empty/default chart/summary.");
diff --git a/frontend/style.css b/frontend/style.css
index 6681132..ae2dac1 100644
--- a/frontend/style.css
+++ b/frontend/style.css
@@ -917,10 +917,28 @@ input.invalid {
color: #f39c12;
}
+.status-void {
+ background-color: rgba(142, 68, 173, 0.15);
+ color: #7d3c98;
+}
+
+/* Voided warranty cards (issue #250): purple accent, distinct from
+ active (green), expiring (amber), expired (red), and archived (grey) */
+.warranty-card.voided {
+ border-left: 4px solid #8e44ad;
+ opacity: 0.9;
+}
+
+.table-view .warranty-card.voided {
+ border-left: none;
+ background-color: rgba(142, 68, 173, 0.05);
+}
+
/* Ensure all status badges share the same shape/spacing */
.status-active,
.status-expired,
.status-expiring,
+.status-void,
.status-archived {
display: inline-block;
padding: 4px 10px;
@@ -3547,6 +3565,11 @@ input.invalid {
background-color: var(--danger-color);
}
+/* Color for voided warranties (issue #250) */
+.warranty-card.voided .product-name-header {
+ background-color: #8e44ad;
+}
+
/* Neutralize top header bar in archived view (all layouts) */
.archived-view .warranty-card .product-name-header,
.warranty-card.archived .product-name-header {
diff --git a/locales/en/translation.json b/locales/en/translation.json
index d216ce9..c5369bf 100644
--- a/locales/en/translation.json
+++ b/locales/en/translation.json
@@ -223,7 +223,10 @@
"none": "None",
"not_specified": "Not specified",
"notes_title": "Warranty Notes",
- "unnamed_product": "Unnamed Product"
+ "unnamed_product": "Unnamed Product",
+ "void": "Void",
+ "void_warranty": "Void warranty",
+ "unvoid_warranty": "Unvoid warranty"
},
"settings": {
"title": "Warracker - Settings",
@@ -637,7 +640,11 @@
"unarchived_success": "Warranty unarchived",
"warranty_duration_required": "Warranty duration is required",
"warranty_not_found_refresh": "Warranty not found. Please refresh and try again.",
- "import_success": "{{success}} warranties imported. {{failure}} failed."
+ "import_success": "{{success}} warranties imported. {{failure}} failed.",
+ "voided_success": "Warranty voided",
+ "unvoided_success": "Warranty restored from void",
+ "error_updating_void_status": "Failed to update void status",
+ "confirm_void_warranty": "Void this warranty? It will be marked inactive and excluded from totals and notifications. You can restore it later."
},
"languages": {
"en": "English",
@@ -683,7 +690,8 @@
"version": "Version",
"uptime": "Uptime",
"total_value": "Total Value",
- "total_value_tooltip": "Sum of the purchase prices of all non-archived warranties. Warranties without a purchase price count as 0."
+ "total_value_tooltip": "Sum of the purchase prices of all non-archived warranties. Warranties without a purchase price count as 0.",
+ "void_warranties": "Void Warranties"
},
"about": {
"title": "About - Warracker",