Fixed an error where toFixed() wouldn't round correctly. Added a util function that does a better job (at least for 2 digits precision)

This commit is contained in:
2025-10-29 10:24:39 +01:00
parent da73a18bf9
commit 039ffa6f2e
3 changed files with 10 additions and 6 deletions
@@ -12,7 +12,7 @@
import { ref, computed, watch, onMounted, onUpdated, useTemplateRef } from "vue"
import { Customer, Invoice, Contact, PaymentTerms, Address } from "@/types"
import { newCustomer, newContact, newBillingData } from '@/types/index.d'
import { toCurrency, toLocalDate, toShortISOString, cn, calcDueDate } from '@/lib/utils';
import { toCurrency, toLocalDate, toShortISOString, cn, calcDueDate, toFixedRounded } from '@/lib/utils';
import axios from 'axios'
import { type DateValue, DateFormatter, getLocalTimeZone, parseDate, fromDate } from "@internationalized/date"
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"
@@ -383,8 +383,7 @@ const updateTotalAmount = () => {
<div class="flex flex-col m-0 items-end gap-0">
<span class="text-md text-muted-foreground">{{ toCurrency(invoice.totalAmount) }}</span>
<span class="text-2xl font-bold">{{ toCurrency(Number((invoice.totalAmount *
1.19).toFixed(2))) }}</span>
<span class="text-2xl font-bold">{{ toCurrency(toFixedRounded(Number(invoice.totalAmount * 1.19), 2)) }}</span>
</div>
</div>