diff --git a/pos/static/js/inventory.js b/pos/static/js/inventory.js index e2c66e3..7bdd44f 100644 --- a/pos/static/js/inventory.js +++ b/pos/static/js/inventory.js @@ -65,6 +65,7 @@ function renderInventoryRow(it) { return '' + + '' + it.id + '' + '' + esc(it.barcode) + '' + '' + esc(it.part_number) + '' + '' + esc(it.name) + '' + @@ -77,6 +78,7 @@ '' + esc(it.location) + '' + '' + ' ' + + ' ' + '' + ''; } @@ -93,7 +95,7 @@ var tbody = document.getElementById('productTableBody'); var items = data.data || []; if (!items.length) { - tbody.innerHTML = 'Sin productos'; + tbody.innerHTML = 'Sin productos'; document.getElementById('productPagination').innerHTML = ''; return; } @@ -104,7 +106,7 @@ rowHeight: 48, buffer: 3, renderRow: renderInventoryRow, - emptyHtml: 'Sin productos' + emptyHtml: 'Sin productos' }); } inventoryVS.setData(items); @@ -236,6 +238,10 @@ function showPurchaseModal() { document.getElementById('purchaseModal').classList.add('is-open'); } + function showPurchaseModalForItem(itemId) { + document.getElementById('purchaseItemId').value = itemId; + showPurchaseModal(); + } function closePurchaseModal() { document.getElementById('purchaseModal').classList.remove('is-open'); document.getElementById('purchaseResult').innerHTML = ''; @@ -254,9 +260,18 @@ return; } apiFetch(API + '/purchase', { method: 'POST', body: JSON.stringify(data) }).then(function (result) { - document.getElementById('purchaseResult').innerHTML = result && result.operation_id - ? 'Compra registrada (op #' + result.operation_id + ')' - : '' + (result ? result.error || 'Error' : 'Error de red') + ''; + if (result && result.operation_id) { + document.getElementById('purchaseResult').innerHTML = 'Compra registrada (op #' + result.operation_id + ')'; + closePurchaseModal(); + ['purchaseItemId','purchaseQty','purchaseCost','purchaseInvoice','purchaseNotes'].forEach(function(id) { + var el = document.getElementById(id); + if (el) el.value = ''; + }); + if (window.loadInventoryStats) window.loadInventoryStats(); + loadItems(currentPage); + } else { + document.getElementById('purchaseResult').innerHTML = '' + (result ? result.error || 'Error' : 'Error de red') + ''; + } }); } @@ -599,6 +614,7 @@ // Product info header html += '
'; + html += '
ID Inventario' + data.id + '
'; html += '
No. Parte' + esc(data.part_number) + '
'; html += '
Nombre' + esc(data.name) + '
'; html += '
Marca' + esc(data.brand) + '
'; @@ -796,6 +812,7 @@ window.closeCreateModal = closeCreateModal; window.createItem = createItem; window.showPurchaseModal = showPurchaseModal; + window.showPurchaseModalForItem = showPurchaseModalForItem; window.closePurchaseModal = closePurchaseModal; window.recordPurchase = recordPurchase; window.showAdjustmentModal = showAdjustmentModal; diff --git a/pos/templates/inventory.html b/pos/templates/inventory.html index b5faef6..59c9b1a 100644 --- a/pos/templates/inventory.html +++ b/pos/templates/inventory.html @@ -317,6 +317,7 @@ +
ID Barcode No. Parte Nombre