bug fix
This commit is contained in:
@@ -882,16 +882,17 @@ async function openTaxPeriodDetail(startDate, endDate, existingPeriod) {
|
||||
${reportHtml}
|
||||
|
||||
<div class="mt-4 border-t pt-4">
|
||||
<div class="flex items-center gap-4 text-sm mb-3">
|
||||
<div class="flex items-center gap-4 text-sm mb-3" id="st-summary-bar">
|
||||
<span><strong>Tax Collected:</strong> ${fmtMoney(taxCollected)}</span>
|
||||
<span class="${adjustments !== 0 ? 'text-red-600' : ''}"><strong>Adjustment:</strong> ${adjustments > 0 ? `−${fmtMoney(adjustments)}` : adjustments < 0 ? `+$${Math.abs(adjustments).toFixed(2)}` : '—'}</span>
|
||||
<span class="text-lg font-bold text-gray-900"><strong>Net Due:</strong> ${fmtMoney(netPaid)}</span>
|
||||
<span id="st-adj-display" class="${adjustments !== 0 ? 'text-red-600' : ''}"><strong>Adjustment:</strong> ${adjustments > 0 ? `−${fmtMoney(adjustments)}` : adjustments < 0 ? `+$${Math.abs(adjustments).toFixed(2)}` : '—'}</span>
|
||||
<span id="st-net-due" class="text-lg font-bold text-gray-900"><strong>Net Due:</strong> ${fmtMoney(netPaid)}</span>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-3 mb-3">
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-700 mb-1">Adjustment Amount</label>
|
||||
<input type="number" step="0.01" id="st-adjustment" value="${adjustments !== 0 ? adjustments : ''}" placeholder="e.g. 6.15 (discount)" ${isPaid ? 'disabled' : ''}
|
||||
oninput="window.accountingView.updateTaxPreview()"
|
||||
class="w-full px-3 py-1.5 border border-gray-300 rounded-md text-sm">
|
||||
<p class="text-xs text-gray-400 mt-0.5">Positive = discount (reduces net due)</p>
|
||||
</div>
|
||||
@@ -933,12 +934,13 @@ async function openTaxPeriodDetail(startDate, endDate, existingPeriod) {
|
||||
|
||||
${!isPaid ? `
|
||||
<div class="flex items-center justify-between border-t pt-3 mt-1">
|
||||
<div>
|
||||
<div id="st-je-lines">
|
||||
<p class="text-sm"><strong>Journal Entry lines:</strong></p>
|
||||
<p class="text-xs text-gray-500 font-mono">Debit Sales Tax Payable: ${fmtMoney(taxCollected)}</p>
|
||||
${adjustments > 0 ? `<p class="text-xs text-gray-500 font-mono">Credit Discount: ${fmtMoney(adjustments)}</p>` : ''}
|
||||
${adjustments < 0 ? `<p class="text-xs text-gray-500 font-mono">Debit Penalty: ${fmtMoney(Math.abs(adjustments))}</p>` : ''}
|
||||
<p class="text-xs text-gray-500 font-mono">Credit Bank: ${fmtMoney(netPaid)}</p>
|
||||
${adjustments === 0 ? `` : ''}
|
||||
<p class="text-xs text-gray-500 font-mono" id="st-je-bank">Credit Bank: ${fmtMoney(netPaid)}</p>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<button onclick="window.accountingView.saveTaxPeriodDraft()"
|
||||
@@ -969,6 +971,39 @@ export function closeTaxPeriodDetail() {
|
||||
stEditingPeriodId = null;
|
||||
}
|
||||
|
||||
export function updateTaxPreview() {
|
||||
if (!stCurrentTaxData) return;
|
||||
const adjInput = document.getElementById('st-adjustment');
|
||||
const adj = parseFloat(adjInput?.value) || 0;
|
||||
const taxCollected = stCurrentTaxData.taxCollected;
|
||||
const netPaid = taxCollected - adj;
|
||||
|
||||
const adjDisplay = document.getElementById('st-adj-display');
|
||||
if (adjDisplay) {
|
||||
adjDisplay.className = adj !== 0 ? 'text-red-600' : '';
|
||||
adjDisplay.innerHTML = adj > 0
|
||||
? `<strong>Adjustment:</strong> −${fmtMoney(adj)}`
|
||||
: adj < 0
|
||||
? `<strong>Adjustment:</strong> +$${Math.abs(adj).toFixed(2)}`
|
||||
: `<strong>Adjustment:</strong> —`;
|
||||
}
|
||||
|
||||
const netDue = document.getElementById('st-net-due');
|
||||
if (netDue) {
|
||||
netDue.innerHTML = `<strong>Net Due:</strong> ${fmtMoney(netPaid)}`;
|
||||
}
|
||||
|
||||
const jeLines = document.getElementById('st-je-lines');
|
||||
if (jeLines) {
|
||||
jeLines.innerHTML = `
|
||||
<p class="text-sm"><strong>Journal Entry lines:</strong></p>
|
||||
<p class="text-xs text-gray-500 font-mono">Debit Sales Tax Payable: ${fmtMoney(taxCollected)}</p>
|
||||
${adj > 0 ? `<p class="text-xs text-gray-500 font-mono">Credit Discount: ${fmtMoney(adj)}</p>` : ''}
|
||||
${adj < 0 ? `<p class="text-xs text-gray-500 font-mono">Debit Penalty: ${fmtMoney(Math.abs(adj))}</p>` : ''}
|
||||
<p class="text-xs text-gray-500 font-mono">Credit Bank: ${fmtMoney(netPaid)}</p>`;
|
||||
}
|
||||
}
|
||||
|
||||
export async function saveTaxPeriodDraft() {
|
||||
const adjAmount = parseFloat(document.getElementById('st-adjustment').value) || 0;
|
||||
const adjReason = document.getElementById('st-adjustment-reason').value.trim();
|
||||
@@ -1191,6 +1226,7 @@ window.accountingView = {
|
||||
openNewTaxPeriod,
|
||||
openTaxPeriod,
|
||||
closeTaxPeriodDetail,
|
||||
updateTaxPreview,
|
||||
saveTaxPeriodDraft,
|
||||
recordTaxPayment
|
||||
};
|
||||
Reference in New Issue
Block a user