diff --git a/public/index.html b/public/index.html
index 8385246..2a677f1 100644
--- a/public/index.html
+++ b/public/index.html
@@ -67,9 +67,14 @@
Invoices
-
+
+
+
+
diff --git a/public/js/views/invoice-view.js b/public/js/views/invoice-view.js
index 9ccf0de..78fba23 100644
--- a/public/js/views/invoice-view.js
+++ b/public/js/views/invoice-view.js
@@ -6,7 +6,7 @@ let filterCustomer = localStorage.getItem('inv_filterCustomer') || '';
let filterStatus = localStorage.getItem('inv_filterStatus') || 'unpaid';
let groupBy = localStorage.getItem('inv_groupBy') || 'none';
let filterWorker = localStorage.getItem('inv_filterWorker') || '';
-let filterItemType = localStorage.getItem('inv_filterItemType') === 'true';
+let filterParts = localStorage.getItem('inv_filterParts') === 'true';
let filterEmptyCost = localStorage.getItem('inv_filterEmptyCost') === 'true';
const OVERDUE_DAYS = 30;
@@ -198,7 +198,7 @@ function saveSettings() {
localStorage.setItem('inv_groupBy', groupBy);
localStorage.setItem('inv_filterCustomer', filterCustomer);
localStorage.setItem('inv_filterWorker', filterWorker);
- localStorage.setItem('inv_filterItemType', filterItemType);
+ localStorage.setItem('inv_filterParts', filterParts);
localStorage.setItem('inv_filterEmptyCost', filterEmptyCost);
}
@@ -209,8 +209,8 @@ function saveSettings() {
export async function loadInvoices() {
try {
const params = new URLSearchParams();
- if (filterItemType) {
- params.set('has_parts_or_subscription', 'true');
+ if (filterParts) {
+ params.set('has_parts', 'true');
if (filterEmptyCost) params.set('empty_cost_only', 'true');
}
const qs = params.toString();
@@ -611,17 +611,12 @@ export function injectToolbar() {
-
-
+
-
-
-
...
@@ -649,19 +644,19 @@ export function injectToolbar() {
// ============================================================
export function setStatus(s) { filterStatus = s; saveSettings(); renderInvoiceView(); }
-export function toggleItemType() {
- filterItemType = !filterItemType;
- if (!filterItemType) filterEmptyCost = false;
+export function toggleParts() {
+ filterParts = !filterParts;
+ if (!filterParts) filterEmptyCost = false;
saveSettings();
const itemBtn = document.getElementById('filter-item-type');
const emptyBtn = document.getElementById('filter-empty-cost');
if (itemBtn) {
- itemBtn.className = filterItemType
+ itemBtn.className = filterParts
? 'px-3 py-1.5 text-xs font-medium rounded-md transition-colors bg-blue-500 text-white'
: 'px-3 py-1.5 text-xs font-medium rounded-md transition-colors bg-white text-gray-600';
}
if (emptyBtn) {
- emptyBtn.style.display = filterItemType ? '' : 'none';
+ emptyBtn.style.display = filterParts ? '' : 'none';
emptyBtn.className = filterEmptyCost
? 'px-3 py-1.5 text-xs font-medium rounded-md transition-colors bg-blue-500 text-white'
: 'px-3 py-1.5 text-xs font-medium rounded-md transition-colors bg-white text-gray-600';
@@ -669,7 +664,7 @@ export function toggleItemType() {
loadInvoices();
}
export function toggleEmptyCost() {
- if (!filterItemType) return;
+ if (!filterParts) return;
filterEmptyCost = !filterEmptyCost;
saveSettings();
const btn = document.getElementById('filter-empty-cost');
@@ -920,5 +915,5 @@ async function populateWorkerFilter() {
window.invoiceView = {
viewPDF, viewHTML, syncFromQBO, resetQbo, markPaid, setEmailStatus, edit, remove,
- loadInvoices, renderInvoiceView, setStatus, toggleItemType, toggleEmptyCost, checkStripePayment, editSentDates ,_addSentDateRow, _saveSentDates
+ loadInvoices, renderInvoiceView, setStatus, toggleParts, toggleEmptyCost, checkStripePayment, editSentDates ,_addSentDateRow, _saveSentDates
};
\ No newline at end of file
diff --git a/src/routes/invoices.js b/src/routes/invoices.js
index 540bafe..ef9de61 100644
--- a/src/routes/invoices.js
+++ b/src/routes/invoices.js
@@ -50,17 +50,17 @@ function buildPaymentLinkHtml(invoice) {
// GET all invoices
router.get('/', async (req, res) => {
try {
- const { has_parts_or_subscription, empty_cost_only } = req.query;
+ const { has_parts, empty_cost_only } = req.query;
let whereClauses = [];
- if (has_parts_or_subscription === 'true') {
+ if (has_parts === 'true') {
const costCondition = empty_cost_only === 'true'
? `AND (ii.unit_cost IS NULL OR ii.unit_cost = '')`
: '';
whereClauses.push(`EXISTS (
SELECT 1 FROM invoice_items ii
WHERE ii.invoice_id = i.id
- AND (ii.qbo_item_id = '9' OR ii.qbo_item_id = '115')
+ AND ii.qbo_item_id = '9'
${costCondition}
)`);
}