File size: 1,795 Bytes
901c055 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | // Simple demo functionality (not meant for production)
document.addEventListener('DOMContentLoaded', function() {
// This would be replaced with real functionality in a production environment
console.log('Invoice editor loaded');
// Example: Calculate line totals when quantity or price changes
const quantityInputs = document.querySelectorAll('input[type="number"][min="0"]');
quantityInputs.forEach(input => {
input.addEventListener('change', function() {
const row = this.closest('tr');
if (row) {
const quantity = parseFloat(this.value) || 0;
const priceInput = row.querySelector('input[type="number"][step="0.01"]:not([min="0"])');
const price = parseFloat(priceInput?.value) || 0;
const totalCell = row.querySelector('td:nth-child(6)');
if (totalCell) {
totalCell.textContent = (quantity * price).toFixed(2) + ' €';
}
}
});
});
// Similar for price inputs
const priceInputs = document.querySelectorAll('input[type="number"][step="0.01"]:not([min="0"])');
priceInputs.forEach(input => {
input.addEventListener('change', function() {
const row = this.closest('tr');
if (row) {
const price = parseFloat(this.value) || 0;
const quantityInput = row.querySelector('input[type="number"][min="0"]');
const quantity = parseFloat(quantityInput?.value) || 0;
const totalCell = row.querySelector('td:nth-child(6)');
if (totalCell) {
totalCell.textContent = (quantity * price).toFixed(2) + ' €';
}
}
});
});
}); |