recurring, tax exempt, badge
This commit is contained in:
@@ -7,6 +7,21 @@ import { setDefaultDate, showSpinner, hideSpinner } from '../utils/helpers.js';
|
||||
|
||||
let currentQuoteId = null;
|
||||
|
||||
/**
|
||||
* Auto-set tax exempt based on customer's taxable flag
|
||||
*/
|
||||
function applyCustomerTaxStatus(customerId) {
|
||||
const allCust = window.getCustomers ? window.getCustomers() : (window.customers || []);
|
||||
const customer = allCust.find(c => c.id === parseInt(customerId));
|
||||
if (customer) {
|
||||
const cb = document.getElementById('quote-tax-exempt');
|
||||
if (cb) {
|
||||
cb.checked = (customer.taxable === false);
|
||||
updateQuoteTotals();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function openQuoteModal(quoteId = null) {
|
||||
currentQuoteId = quoteId;
|
||||
|
||||
@@ -146,6 +161,17 @@ export function initQuoteModal() {
|
||||
|
||||
const taxExempt = document.getElementById('quote-tax-exempt');
|
||||
if (taxExempt) taxExempt.addEventListener('change', updateQuoteTotals);
|
||||
|
||||
// Watch for customer selection → auto-set tax exempt (only for new quotes)
|
||||
const customerHidden = document.getElementById('quote-customer');
|
||||
if (customerHidden) {
|
||||
const observer = new MutationObserver(() => {
|
||||
if (!currentQuoteId && customerHidden.value) {
|
||||
applyCustomerTaxStatus(customerHidden.value);
|
||||
}
|
||||
});
|
||||
observer.observe(customerHidden, { attributes: true, attributeFilter: ['value'] });
|
||||
}
|
||||
}
|
||||
|
||||
// Expose for onclick handlers
|
||||
|
||||
Reference in New Issue
Block a user