Kaynağa Gözat

Add LKR + 21 currencies, Symbol/Code format, PDF font fixes (#163)

* added lkr currency

* add currency symbol selector

* currency

* Match surrounding semicolon style on hook injection

Github code-quality flagged 6 files where the auto-injected
`const formatCurrency = useFormatCurrency()` line lacked a trailing
semicolon while the enclosing function uses explicit semicolons
on 94-97% of statements.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Bernt Christian Egeland 6 ay önce
ebeveyn
işleme
ff20d8e2c1
22 değiştirilmiş dosya ile 49 ekleme ve 21 silme
  1. 2 1
      src/app/(authenticated)/billing/billing-client.tsx
  2. 2 1
      src/app/(authenticated)/dashboard-client.tsx
  3. 2 1
      src/app/(authenticated)/inventory/inventory-client.tsx
  4. 2 1
      src/app/(authenticated)/quotes/quotes-client.tsx
  5. 2 1
      src/app/(authenticated)/reports/reports-client.tsx
  6. 2 1
      src/app/(authenticated)/vehicles/[id]/service-records-table.tsx
  7. 2 1
      src/app/(authenticated)/vehicles/[id]/vehicle-detail-client.tsx
  8. 2 1
      src/app/(authenticated)/work-orders/work-orders-client.tsx
  9. 2 1
      src/features/billing/Components/RecurringInvoicesClient.tsx
  10. 2 1
      src/features/calendar/Components/CalendarEventList.tsx
  11. 1 0
      src/features/invoices/Pdf/buildInvoicePdfBuffer.ts
  12. 3 1
      src/features/quotes/Components/QuoteLaborEditor.tsx
  13. 3 1
      src/features/quotes/Components/QuotePartsEditor.tsx
  14. 2 1
      src/features/quotes/Components/QuoteRightColumn.tsx
  15. 1 0
      src/features/settings/Components/InvoiceLayoutPreviewRenderer.tsx
  16. 2 1
      src/features/vehicles/Components/invoice-pdf/InvoicePDF.tsx
  17. 2 1
      src/features/vehicles/Components/service-detail/InvoiceSummary.tsx
  18. 2 1
      src/features/vehicles/Components/service-detail/PaymentsSection.tsx
  19. 2 1
      src/features/vehicles/Components/service-edit/InventoryPickerDialog.tsx
  20. 6 2
      src/features/vehicles/Components/service-edit/LaborEditor.tsx
  21. 3 1
      src/features/vehicles/Components/service-edit/PartsEditor.tsx
  22. 2 1
      src/features/vehicles/Components/service-edit/TotalsSection.tsx

+ 2 - 1
src/app/(authenticated)/billing/billing-client.tsx

@@ -26,7 +26,7 @@ import {
   AlertCircle,
 } from "lucide-react";
 import { cn } from "@/lib/utils";
-import { formatCurrency } from "@/lib/format";
+import { useFormatCurrency } from '@/components/currency-settings-context'
 
 interface BillingRecord {
   id: string;
@@ -86,6 +86,7 @@ export default function BillingClient({
   search,
   statusFilter,
 }: BillingClientProps) {
+  const formatCurrency = useFormatCurrency();
   const router = useRouter();
   const t = useTranslations("billing");
   const { formatDate } = useFormatDate();

+ 2 - 1
src/app/(authenticated)/dashboard-client.tsx

@@ -41,7 +41,7 @@ import {
   Users,
   X,
 } from "lucide-react";
-import { formatCurrency } from "@/lib/format";
+import { useFormatCurrency } from '@/components/currency-settings-context'
 import { dismissMaintenance, undismissMaintenance } from "@/features/vehicles/Actions/dismissMaintenance";
 import { updateQuoteRequestStatus } from "@/features/inspections/Actions/quoteRequestActions";
 import { acknowledgeQuoteResponse } from "@/features/quotes/Actions/quoteResponseActions";
@@ -253,6 +253,7 @@ export function DashboardClient({
   }[];
   recentObservations?: DashboardObservation[];
 }) {
+  const formatCurrency = useFormatCurrency();
   const t = useTranslations("dashboard");
   const tAudit = useTranslations("audit");
   const distUnit = unitSystem === "metric" ? "km" : "mi";

+ 2 - 1
src/app/(authenticated)/inventory/inventory-client.tsx

@@ -64,7 +64,7 @@ import {
   Trash2,
   X,
 } from "lucide-react";
-import { formatCurrency } from "@/lib/format";
+import { useFormatCurrency } from '@/components/currency-settings-context'
 import { toast } from "sonner";
 
 interface InventoryPart {
@@ -114,6 +114,7 @@ export function InventoryClient({
   sortBy?: string;
   sortOrder?: "asc" | "desc";
 }) {
+  const formatCurrency = useFormatCurrency();
   const router = useRouter();
   const pathname = usePathname();
   const searchParams = useSearchParams();

+ 2 - 1
src/app/(authenticated)/quotes/quotes-client.tsx

@@ -19,7 +19,7 @@ import {
 import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'
 import { DataTablePagination } from '@/components/data-table-pagination'
 import { Loader2, Plus, Search } from 'lucide-react'
-import { formatCurrency } from '@/lib/format'
+import { useFormatCurrency } from '@/components/currency-settings-context'
 import { toast } from 'sonner'
 import { createQuote } from '@/features/quotes/Actions/quoteActions'
 import { VehicleCombobox } from '@/features/quotes/Components/VehicleCombobox'
@@ -81,6 +81,7 @@ export function QuotesClient({
   search: string
   statusFilter: string
 }) {
+  const formatCurrency = useFormatCurrency()
   const router = useRouter()
   const { formatDate } = useFormatDate()
   const pathname = usePathname()

+ 2 - 1
src/app/(authenticated)/reports/reports-client.tsx

@@ -73,7 +73,7 @@ import {
   getPastDueInvoicesReport,
   getVehicleReport,
 } from "@/features/reports/Actions/reportActions";
-import { formatCurrency } from "@/lib/format";
+import { useFormatCurrency } from '@/components/currency-settings-context'
 import type {
   RevenueReport,
   ServiceReport,
@@ -128,6 +128,7 @@ const VALID_TABS: ReportTab[] = ["financial", "services", "customers", "inventor
 const VALID_SUB_TABS: FinancialSubTab[] = ["revenue", "past-due-invoices", "tax"];
 
 export default function ReportsClient({ currencyCode, primaryColor, organizationName }: ReportsClientProps) {
+  const formatCurrency = useFormatCurrency();
   const t = useTranslations("reports");
   const searchParams = useSearchParams();
   const router = useRouter();

+ 2 - 1
src/app/(authenticated)/vehicles/[id]/service-records-table.tsx

@@ -23,7 +23,7 @@ import {
   TableRow,
 } from "@/components/ui/table";
 import { typeColors, statusColors } from "@/lib/table-utils";
-import { formatCurrency } from "@/lib/format";
+import { useFormatCurrency } from '@/components/currency-settings-context'
 import { getWarrantyStatus, type WarrantyStatus } from "@/lib/warranty";
 import {
   ChevronLeft,
@@ -102,6 +102,7 @@ export function ServiceRecordsTable({
   currencyCode = "USD",
   vehicleMileage,
 }: ServiceRecordsTableProps) {
+  const formatCurrency = useFormatCurrency()
   const router = useRouter();
   const { formatDate } = useFormatDate();
   const pathname = usePathname();

+ 2 - 1
src/app/(authenticated)/vehicles/[id]/vehicle-detail-client.tsx

@@ -40,7 +40,7 @@ import {
 import { ArchiveVehicleDialog } from '@/features/vehicles/Components/ArchiveVehicleDialog'
 import { aiSummarizeVehicleHistory, aiGetCommonIssues, aiClearMessage } from '@/features/ai/Actions/aiActions'
 import { AI_MESSAGE_TYPES } from '@/features/ai/constants'
-import { formatCurrency } from '@/lib/format'
+import { useFormatCurrency } from '@/components/currency-settings-context'
 import {
   AlertTriangle,
   Archive,
@@ -270,6 +270,7 @@ export function VehicleDetailClient({
   quotes?: QuoteRecord[]
   aiEnabled?: boolean
 }) {
+  const formatCurrency = useFormatCurrency()
   const serviceType = useServiceType()
   const isMarine = serviceType === 'marine'
   const distUnit = isMarine ? 'hrs' : unitSystem === 'metric' ? 'km' : 'mi'

+ 2 - 1
src/app/(authenticated)/work-orders/work-orders-client.tsx

@@ -33,7 +33,7 @@ import {
   Plus,
   Search,
 } from "lucide-react";
-import { formatCurrency } from "@/lib/format";
+import { useFormatCurrency } from '@/components/currency-settings-context'
 import { VehiclePickerDialog } from "@/components/vehicle-picker-dialog";
 import { NotifyCustomerDialog } from "@/components/notify-customer-dialog";
 import { useTranslations } from "next-intl";
@@ -143,6 +143,7 @@ export function WorkOrdersClient({
   smsEnabled?: boolean;
   emailEnabled?: boolean;
 }) {
+  const formatCurrency = useFormatCurrency();
   const router = useRouter();
   const { formatDate } = useFormatDate();
   const pathname = usePathname();

+ 2 - 1
src/features/billing/Components/RecurringInvoicesClient.tsx

@@ -41,7 +41,7 @@ import {
   Zap,
   X,
 } from "lucide-react";
-import { formatCurrency } from "@/lib/format";
+import { useFormatCurrency } from '@/components/currency-settings-context'
 import { calculateTotals } from "@/lib/tax";
 import {
   createRecurringInvoice,
@@ -132,6 +132,7 @@ export default function RecurringInvoicesClient({
   vehicles,
   currencyCode,
 }: RecurringInvoicesClientProps) {
+  const formatCurrency = useFormatCurrency();
   const router = useRouter();
   const t = useTranslations("billing");
   const { formatDate } = useFormatDate();

+ 2 - 1
src/features/calendar/Components/CalendarEventList.tsx

@@ -4,7 +4,7 @@ import Link from "next/link";
 import { useTranslations } from "next-intl";
 import { Badge } from "@/components/ui/badge";
 import { formatDateHeader } from "./calendar-utils";
-import { formatCurrency } from "@/lib/format";
+import { useFormatCurrency } from '@/components/currency-settings-context'
 import type { CalendarEvent } from "../Actions/calendarActions";
 
 function getStatusColor(event: CalendarEvent) {
@@ -70,6 +70,7 @@ interface CalendarEventListProps {
 }
 
 export function CalendarEventList({ events, dateStr, selectedDate, currencyCode }: CalendarEventListProps) {
+  const formatCurrency = useFormatCurrency()
   const t = useTranslations('calendar');
   const dayEvents = events.filter((e) => e.date === dateStr);
 

+ 1 - 0
src/features/invoices/Pdf/buildInvoicePdfBuffer.ts

@@ -185,6 +185,7 @@ export async function buildInvoicePdfBuffer(
     showOrgNumber: settingsMap['invoice.showOrgNumber'] === 'true',
     dueDays: Number(settingsMap['invoice.dueDays']) || 0,
     currencyCode: settingsMap['workshop.currencyCode'] || 'USD',
+    currencyFormat: (settingsMap['workshop.currencyFormat'] === 'code' ? 'code' : 'symbol') as 'symbol' | 'code',
     unitSystem: settingsMap['workshop.unitSystem'] || 'imperial',
     dateFormat: settingsMap['workshop.dateFormat'] || undefined,
     timezone: settingsMap['workshop.timezone'] || undefined,

+ 3 - 1
src/features/quotes/Components/QuoteLaborEditor.tsx

@@ -4,7 +4,7 @@ import { memo } from "react";
 import { Button } from "@/components/ui/button";
 import { Input } from "@/components/ui/input";
 import { Layers, Plus, Trash2, Wrench } from "lucide-react";
-import { formatCurrency } from "@/lib/format";
+import { useFormatCurrency } from '@/components/currency-settings-context'
 import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
 import type { QuoteLaborInput } from "./quote-page-types";
 
@@ -40,6 +40,7 @@ const QuoteLaborRow = memo(function QuoteLaborRow({
   tExcludeFromTotal: string;
 }) {
   const isService = labor.pricingType === "service";
+  const formatCurrency = useFormatCurrency();
   return (
     <div className={`grid grid-cols-2 gap-2 sm:grid-cols-[2fr_1fr_1fr_1fr_auto]${labor.excluded ? " line-through opacity-50" : ""}`}>
       <div className="col-span-2 flex gap-2 sm:col-span-1">
@@ -101,6 +102,7 @@ export const QuoteLaborEditor = memo(function QuoteLaborEditor({
   onOpenPresets,
   t,
 }: QuoteLaborEditorProps) {
+  const formatCurrency = useFormatCurrency()
   return (
     <TooltipProvider>
     <div className="rounded-lg border p-3 space-y-2">

+ 3 - 1
src/features/quotes/Components/QuotePartsEditor.tsx

@@ -4,7 +4,7 @@ import { memo } from "react";
 import { Button } from "@/components/ui/button";
 import { Input } from "@/components/ui/input";
 import { Plus, Trash2 } from "lucide-react";
-import { formatCurrency } from "@/lib/format";
+import { useFormatCurrency } from '@/components/currency-settings-context'
 import type { QuotePartInput } from "./quote-page-types";
 
 const QuotePartRow = memo(function QuotePartRow({
@@ -28,6 +28,7 @@ const QuotePartRow = memo(function QuotePartRow({
   tDeleteRow: string;
   tExcludeFromTotal: string;
 }) {
+  const formatCurrency = useFormatCurrency();
   return (
     <div className={`grid grid-cols-2 gap-2 sm:grid-cols-[1fr_2fr_0.7fr_1fr_1fr_auto]${part.excluded ? " line-through opacity-50" : ""}`}>
       <Input placeholder={tPartNumber} value={part.partNumber ?? ""} onChange={(e) => onUpdate(index, "partNumber", e.target.value)} />
@@ -63,6 +64,7 @@ export const QuotePartsEditor = memo(function QuotePartsEditor({
   onAdd,
   t,
 }: QuotePartsEditorProps) {
+  const formatCurrency = useFormatCurrency()
   return (
     <div className="rounded-lg border p-3 space-y-2">
       <div className="flex items-center justify-between">

+ 2 - 1
src/features/quotes/Components/QuoteRightColumn.tsx

@@ -23,7 +23,7 @@ import {
   X,
 } from 'lucide-react'
 import { SharedLinkCard } from '@/components/shared-link-card'
-import { formatCurrency } from '@/lib/format'
+import { useFormatCurrency } from '@/components/currency-settings-context'
 import { netLineTotal } from '@/lib/tax'
 import type { QuoteFormState } from './useQuoteFormState'
 import type { QuoteRecord } from './quote-page-types'
@@ -48,6 +48,7 @@ export const QuoteRightColumn = memo(function QuoteRightColumn({
   t,
   onRevoke,
 }: QuoteRightColumnProps) {
+  const formatCurrency = useFormatCurrency()
   return (
     <div className="space-y-3">
       {/* Convert to Work Order */}

+ 1 - 0
src/features/settings/Components/InvoiceLayoutPreviewRenderer.tsx

@@ -190,6 +190,7 @@ const DUMMY_INVOICE_SETTINGS = {
   showOrgNumber: true,
   dueDays: 14,
   currencyCode: "USD",
+  currencyFormat: "symbol" as const,
   unitSystem: "imperial",
 };
 

+ 2 - 1
src/features/vehicles/Components/invoice-pdf/InvoicePDF.tsx

@@ -215,7 +215,8 @@ export function InvoicePDF({
       <>
         <Totals
           data={data}
-          currencyCode={cc} currencyFormat={cf}
+          currencyCode={cc}
+          currencyFormat={cf}
           primaryColor={primaryColor}
           fontFamily={fontFamily}
           displayTotal={displayTotal}

+ 2 - 1
src/features/vehicles/Components/service-detail/InvoiceSummary.tsx

@@ -2,7 +2,7 @@
 
 import { useTranslations } from "next-intl";
 import { Separator } from "@/components/ui/separator";
-import { formatCurrency } from "@/lib/format";
+import { useFormatCurrency } from "@/components/currency-settings-context";
 import { netLineTotal } from "@/lib/tax";
 
 interface InvoiceSummaryProps {
@@ -42,6 +42,7 @@ export function InvoiceSummary({
   hasPayments,
   currencyCode,
 }: InvoiceSummaryProps) {
+  const formatCurrency = useFormatCurrency()
   const t = useTranslations("service.invoice");
 
   // Universal display: net per category, net subtotal, net discount, tax, gross total.

+ 2 - 1
src/features/vehicles/Components/service-detail/PaymentsSection.tsx

@@ -15,7 +15,7 @@ import {
 } from "@/components/ui/select";
 import { Check, CreditCard, Loader2, Plus, Trash2, X } from "lucide-react";
 import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
-import { formatCurrency } from "@/lib/format";
+import { useFormatCurrency } from "@/components/currency-settings-context";
 import { useFormatDate } from "@/lib/use-format-date";
 import { paymentStatusColors, paymentStatusLabels } from "./types";
 import type { Payment } from "./types";
@@ -49,6 +49,7 @@ export function PaymentsSection({
   paymentLoading,
   deletingPayment,
 }: PaymentsSectionProps) {
+  const formatCurrency = useFormatCurrency()
   const t = useTranslations("service.payments");
   const tc = useTranslations("common.buttons");
   const [showForm, setShowForm] = useState(false);

+ 2 - 1
src/features/vehicles/Components/service-edit/InventoryPickerDialog.tsx

@@ -5,7 +5,7 @@ import { useTranslations } from 'next-intl'
 import { Input } from '@/components/ui/input'
 import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'
 import { Search } from 'lucide-react'
-import { formatCurrency } from '@/lib/format'
+import { useFormatCurrency } from '@/components/currency-settings-context'
 import type { ServicePartInput } from '@/features/vehicles/Schema/serviceSchema'
 import type { InventoryPartOption } from './form-types'
 
@@ -26,6 +26,7 @@ export function InventoryPickerDialog({
   currencyCode,
   onSelectPart,
 }: InventoryPickerDialogProps) {
+  const formatCurrency = useFormatCurrency()
   const t = useTranslations('service.parts')
   const [search, setSearch] = useState('')
   const [visibleCount, setVisibleCount] = useState(PAGE_SIZE)

+ 6 - 2
src/features/vehicles/Components/service-edit/LaborEditor.tsx

@@ -11,7 +11,8 @@ import {
   DropdownMenuItem,
   DropdownMenuTrigger,
 } from '@/components/ui/dropdown-menu'
-import { formatCurrency, getCurrencySymbol } from '@/lib/format'
+import { getCurrencySymbol } from '@/lib/format'
+import { useFormatCurrency, useCurrencySettings } from '@/components/currency-settings-context'
 import { useTranslations } from 'next-intl'
 import type { ServiceLaborInput } from '@/features/vehicles/Schema/serviceSchema'
 import { makeEmptyLabor, makeEmptyService } from './form-types'
@@ -66,6 +67,7 @@ function SortableLaborRow({
   t: (key: string) => string
   dragEnabled: boolean
 }) {
+  const formatCurrency = useFormatCurrency()
   const {
     attributes,
     listeners,
@@ -164,7 +166,9 @@ export function LaborEditor({
   onShowExistingObservations,
 }: LaborEditorProps) {
   const t = useTranslations('service.labor')
-  const cs = getCurrencySymbol(currencyCode)
+  const formatCurrency = useFormatCurrency()
+  const { currencyFormat } = useCurrencySettings()
+  const cs = getCurrencySymbol(currencyCode, currencyFormat)
   const [mounted, setMounted] = useState(false)
   useEffect(() => setMounted(true), [])
   const keyCounterRef = useRef(0)

+ 3 - 1
src/features/vehicles/Components/service-edit/PartsEditor.tsx

@@ -5,7 +5,7 @@ import { Button } from '@/components/ui/button'
 import { Input } from '@/components/ui/input'
 import { Textarea } from '@/components/ui/textarea'
 import { GripVertical, Package, Plus, ScanBarcode, Trash2 } from 'lucide-react'
-import { formatCurrency } from '@/lib/format'
+import { useFormatCurrency } from '@/components/currency-settings-context'
 import { useTranslations } from 'next-intl'
 import type { ServicePartInput } from '@/features/vehicles/Schema/serviceSchema'
 import { emptyPart } from './form-types'
@@ -57,6 +57,7 @@ function SortablePartRow({
   t: (key: string) => string
   dragEnabled: boolean
 }) {
+  const formatCurrency = useFormatCurrency()
   const {
     attributes,
     listeners,
@@ -139,6 +140,7 @@ export function PartsEditor({
   onOpenInventory,
   onScanBarcode,
 }: PartsEditorProps) {
+  const formatCurrency = useFormatCurrency()
   const t = useTranslations('service.parts')
   const [mounted, setMounted] = useState(false)
   useEffect(() => setMounted(true), [])

+ 2 - 1
src/features/vehicles/Components/service-edit/TotalsSection.tsx

@@ -9,7 +9,7 @@ import {
   SelectTrigger,
   SelectValue,
 } from '@/components/ui/select'
-import { formatCurrency } from '@/lib/format'
+import { useFormatCurrency } from '@/components/currency-settings-context'
 import { netLineTotal } from '@/lib/tax'
 
 interface TotalsSectionProps {
@@ -47,6 +47,7 @@ export function TotalsSection({
   totalAmount,
   currencyCode,
 }: TotalsSectionProps) {
+  const formatCurrency = useFormatCurrency()
   const t = useTranslations('service.totals')
 
   // Universal display: net per category, net subtotal, net discount, tax, gross total.