feat: replace all hardcoded en-US and $ formatting with locale-aware helpers
This commit is contained in:
@@ -54,7 +54,7 @@
|
||||
{{ formatDate(invoice.date) }}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-right text-[0.75rem] font-mono text-accent-text">
|
||||
${{ invoice.total.toFixed(2) }}
|
||||
{{ formatCurrency(invoice.total) }}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-center">
|
||||
<span
|
||||
@@ -194,19 +194,19 @@
|
||||
<div class="bg-bg-inset rounded-lg p-4">
|
||||
<div class="flex justify-between text-[0.75rem] text-text-secondary mb-2">
|
||||
<span>Subtotal:</span>
|
||||
<span class="font-mono">${{ calculateSubtotal().toFixed(2) }}</span>
|
||||
<span class="font-mono">{{ formatCurrency(calculateSubtotal()) }}</span>
|
||||
</div>
|
||||
<div class="flex justify-between text-[0.75rem] text-text-secondary mb-2">
|
||||
<span>Tax ({{ createForm.tax_rate }}%):</span>
|
||||
<span class="font-mono">${{ calculateTax().toFixed(2) }}</span>
|
||||
<span class="font-mono">{{ formatCurrency(calculateTax()) }}</span>
|
||||
</div>
|
||||
<div class="flex justify-between text-[0.75rem] text-text-secondary mb-2">
|
||||
<span>Discount:</span>
|
||||
<span class="font-mono">-${{ createForm.discount.toFixed(2) }}</span>
|
||||
<span class="font-mono">-{{ formatCurrency(createForm.discount) }}</span>
|
||||
</div>
|
||||
<div class="flex justify-between text-text-primary font-medium text-[0.8125rem] pt-2 border-t border-border-subtle">
|
||||
<span>Total:</span>
|
||||
<span class="font-mono text-accent-text">${{ calculateTotal().toFixed(2) }}</span>
|
||||
<span class="font-mono text-accent-text">{{ formatCurrency(calculateTotal()) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -266,19 +266,19 @@
|
||||
<div class="border-t border-border-subtle pt-4">
|
||||
<div class="flex justify-between text-[0.75rem] text-text-secondary mb-2">
|
||||
<span>Subtotal:</span>
|
||||
<span class="font-mono">${{ (selectedInvoice?.subtotal || 0).toFixed(2) }}</span>
|
||||
<span class="font-mono">{{ formatCurrency(selectedInvoice?.subtotal || 0) }}</span>
|
||||
</div>
|
||||
<div class="flex justify-between text-[0.75rem] text-text-secondary mb-2">
|
||||
<span>Tax ({{ selectedInvoice?.tax_rate || 0 }}%):</span>
|
||||
<span class="font-mono">${{ (selectedInvoice?.tax_amount || 0).toFixed(2) }}</span>
|
||||
<span class="font-mono">{{ formatCurrency(selectedInvoice?.tax_amount || 0) }}</span>
|
||||
</div>
|
||||
<div class="flex justify-between text-[0.75rem] text-text-secondary mb-2">
|
||||
<span>Discount:</span>
|
||||
<span class="font-mono">-${{ (selectedInvoice?.discount || 0).toFixed(2) }}</span>
|
||||
<span class="font-mono">-{{ formatCurrency(selectedInvoice?.discount || 0) }}</span>
|
||||
</div>
|
||||
<div class="flex justify-between text-text-primary font-medium text-[0.8125rem] pt-2 border-t border-border-subtle">
|
||||
<span>Total:</span>
|
||||
<span class="font-mono text-accent-text">${{ (selectedInvoice?.total || 0).toFixed(2) }}</span>
|
||||
<span class="font-mono text-accent-text">{{ formatCurrency(selectedInvoice?.total || 0) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -339,6 +339,7 @@ import { useInvoicesStore, type Invoice } from '../stores/invoices'
|
||||
import { useClientsStore } from '../stores/clients'
|
||||
import { useToastStore } from '../stores/toast'
|
||||
import { generateInvoicePdf } from '../utils/invoicePdf'
|
||||
import { formatDate, formatCurrency } from '../utils/locale'
|
||||
|
||||
const invoicesStore = useInvoicesStore()
|
||||
const clientsStore = useClientsStore()
|
||||
@@ -369,17 +370,6 @@ function getClientName(clientId: number): string {
|
||||
return client?.name || 'Unknown Client'
|
||||
}
|
||||
|
||||
// Format date
|
||||
function formatDate(dateString: string): string {
|
||||
if (!dateString) return '-'
|
||||
const date = new Date(dateString)
|
||||
return date.toLocaleDateString('en-US', {
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
year: 'numeric'
|
||||
})
|
||||
}
|
||||
|
||||
// Calculate subtotal (simplified - would need line items in a real app)
|
||||
function calculateSubtotal(): number {
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user