Index: src/sections/invoice/invoice-details.tsx
===================================================================
--- src/sections/invoice/invoice-details.tsx	(revision 5d6f37a75130aab7d9a67b5b430603eff2c0ca6e)
+++ src/sections/invoice/invoice-details.tsx	(revision 057453cdc828f504e8bcd813422d99221b3b5732)
@@ -18,5 +18,5 @@
 import { fCurrency } from 'src/utils/format-number';
 // types
-import { Invoice } from 'mvpmasters-shared';
+import { Invoice } from 'src/schemas';
 // components
 import Label from 'src/components/label';
@@ -28,4 +28,5 @@
 import { getQuantityType } from 'src/utils/get-invoice-quantity-type';
 import InvoiceToolbar from './invoice-toolbar';
+import { updateInvoice } from 'src/api/invoice';
 
 // ----------------------------------------------------------------------
@@ -59,5 +60,8 @@
   const handleChangeStatus = useCallback(
     async (event: React.ChangeEvent<HTMLInputElement>) => {
-      await updateDocument(collections.invoice, invoice.id, { status: event.target.value });
+      // await updateDocument(collections.invoice, invoice.id, { status: event.target.value });
+      await updateInvoice(invoice.id, {
+        status: event.target.value as 'draft' | 'processing' | 'pending' | 'overdue' | 'paid',
+      });
       mutate([collections.invoice, invoice.id]);
     },
@@ -240,7 +244,7 @@
             {invoice.invoiceTo.name}
             <br />
-            {!!invoice.invoiceTo.companyId && (
+            {!!invoice.invoiceTo.companyNumber && (
               <>
-                Company ID: {invoice.invoiceTo.companyId}
+                Company ID: {invoice.invoiceTo.companyNumber}
                 <br />
               </>
@@ -257,5 +261,5 @@
               Date Issued
             </Typography>
-            {fDate(invoice.createDate.toDate())}
+            {fDate(invoice.createDate)}
           </Stack>
 
@@ -264,5 +268,5 @@
               Due Date
             </Typography>
-            {fDate(invoice.dueDate.toDate())}
+            {fDate(invoice.dueDate)}
           </Stack>
         </Box>
Index: src/sections/invoice/invoice-ee-pdf.tsx
===================================================================
--- src/sections/invoice/invoice-ee-pdf.tsx	(revision 5d6f37a75130aab7d9a67b5b430603eff2c0ca6e)
+++ src/sections/invoice/invoice-ee-pdf.tsx	(revision 057453cdc828f504e8bcd813422d99221b3b5732)
@@ -5,5 +5,5 @@
 import { fCurrency } from 'src/utils/format-number';
 // types
-import { Invoice } from 'mvpmasters-shared';
+import { Invoice } from 'src/schemas';
 import { createFullAddress } from 'src/utils/create-full-address';
 import { getQuantityType } from 'src/utils/get-invoice-quantity-type';
@@ -229,9 +229,9 @@
           <View style={styles.col6}>
             <Text style={[styles.subtitle1, styles.mb4]}>Date Issued</Text>
-            <Text style={styles.body2}>{fDate(createDate.toDate())}</Text>
+            <Text style={styles.body2}>{fDate(createDate)}</Text>
           </View>
           <View style={styles.col6}>
             <Text style={[styles.subtitle1, styles.mb4]}>Due date</Text>
-            <Text style={styles.body2}>{fDate(dueDate.toDate())}</Text>
+            <Text style={styles.body2}>{fDate(dueDate)}</Text>
           </View>
         </View>
Index: src/sections/invoice/invoice-mk-pdf.tsx
===================================================================
--- src/sections/invoice/invoice-mk-pdf.tsx	(revision 5d6f37a75130aab7d9a67b5b430603eff2c0ca6e)
+++ src/sections/invoice/invoice-mk-pdf.tsx	(revision 057453cdc828f504e8bcd813422d99221b3b5732)
@@ -5,5 +5,5 @@
 import { fCurrency } from 'src/utils/format-number';
 // types
-import { Invoice } from 'mvpmasters-shared';
+import { Invoice } from 'src/schemas';
 import { createFullAddress } from 'src/utils/create-full-address';
 import { getQuantityType } from 'src/utils/get-invoice-quantity-type';
@@ -179,9 +179,9 @@
           <View style={styles.col6}>
             <Text style={[styles.subtitle1, styles.mb4]}>Date Issued</Text>
-            <Text style={styles.body2}>{fDate(createDate.toDate())}</Text>
+            <Text style={styles.body2}>{fDate(createDate)}</Text>
           </View>
           <View style={styles.col6}>
             <Text style={[styles.subtitle1, styles.mb4]}>Due date</Text>
-            <Text style={styles.body2}>{fDate(dueDate.toDate())}</Text>
+            <Text style={styles.body2}>{fDate(dueDate)}</Text>
           </View>
         </View>
Index: src/sections/invoice/invoice-new-edit-address.tsx
===================================================================
--- src/sections/invoice/invoice-new-edit-address.tsx	(revision 5d6f37a75130aab7d9a67b5b430603eff2c0ca6e)
+++ src/sections/invoice/invoice-new-edit-address.tsx	(revision 057453cdc828f504e8bcd813422d99221b3b5732)
@@ -7,5 +7,5 @@
 import Typography from '@mui/material/Typography';
 // hooks
-import { useGetSettings } from 'src/api/settings';
+import { useGetTenant } from 'src/api/tenant';
 import { useBoolean } from 'src/hooks/use-boolean';
 import { useResponsive } from 'src/hooks/use-responsive';
@@ -32,5 +32,5 @@
   const { invoiceFrom, invoiceTo } = values;
 
-  const { settings } = useGetSettings();
+  const { settings: tenant } = useGetTenant();
   const { customers } = useGetCustomers();
 
@@ -100,5 +100,5 @@
       </Stack>
 
-      {settings && (
+      {tenant && (
         <CompanyListDialog
           title="Companies"
@@ -106,6 +106,6 @@
           onClose={from.onFalse}
           selected={(selectedId: string) => invoiceFrom?.id === selectedId}
-          onSelect={(company) => setValue('invoiceFrom', company)}
-          list={[settings?.company, settings?.['company-ee']]}
+          onSelect={(tenant) => setValue('invoiceFrom', tenant)}
+          tenant={tenant}
           action={
             <Button
Index: src/sections/invoice/invoice-new-edit-details.tsx
===================================================================
--- src/sections/invoice/invoice-new-edit-details.tsx	(revision 5d6f37a75130aab7d9a67b5b430603eff2c0ca6e)
+++ src/sections/invoice/invoice-new-edit-details.tsx	(revision 057453cdc828f504e8bcd813422d99221b3b5732)
@@ -14,5 +14,5 @@
 import { fCurrency } from 'src/utils/format-number';
 // types
-import { InvoiceItem } from 'mvpmasters-shared';
+import { InvoiceItem } from 'src/schemas';
 // components
 import Iconify from 'src/components/iconify';
@@ -75,14 +75,26 @@
   const handleSelectService = useCallback(
     (index: number, option: string) => {
-      setValue(
-        `items[${index}].price`,
-        invoiceServices.find((service) => service.id === option)?.price?.[
-          values.quantityType?.toLowerCase() as 'sprint' | 'hour' | 'month'
-        ]
-      );
-      setValue(
-        `items[${index}].total`,
-        values.items.map((item: InvoiceItem) => item.quantity * item.price)[index]
-      );
+      const service = invoiceServices.find((service) => service.id === option);
+      if (!service) return;
+
+      const quantityType = values.quantityType?.toLowerCase();
+      let price = 0;
+
+      switch (quantityType) {
+        case 'sprint':
+          price = service.sprint;
+          break;
+        case 'hour':
+          price = service.hour;
+          break;
+        case 'month':
+          price = service.month;
+          break;
+        default:
+          price = 0;
+      }
+
+      setValue(`items[${index}].price`, price);
+      setValue(`items[${index}].total`, values.items[index].quantity * price);
     },
     [setValue, values.items, values.quantityType, invoiceServices]
Index: src/sections/invoice/invoice-new-edit-form.tsx
===================================================================
--- src/sections/invoice/invoice-new-edit-form.tsx	(revision 5d6f37a75130aab7d9a67b5b430603eff2c0ca6e)
+++ src/sections/invoice/invoice-new-edit-form.tsx	(revision 057453cdc828f504e8bcd813422d99221b3b5732)
@@ -11,5 +11,5 @@
 import { useRouter } from 'src/routes/hooks';
 // types
-import { Invoice } from 'mvpmasters-shared';
+import { CreateInvoice, Invoice } from 'src/schemas';
 // hooks
 import { useBoolean } from 'src/hooks/use-boolean';
@@ -20,19 +20,13 @@
 import uploadToFirebaseStorage from 'src/utils/upload-to-firebase-storage';
 import { pdf } from '@react-pdf/renderer';
-import { useGetSettings } from 'src/api/settings';
-import {
-  collections,
-  documents,
-  firestoreBatch,
-  generateId,
-  updateDocument,
-} from 'src/lib/firestore';
+import { useGetTenant } from 'src/api/tenant';
+import { collections, generateId, updateDocument } from 'src/lib/firestore';
 import { useGetServices } from 'src/api/service';
 import { mutate } from 'swr';
-import { Timestamp } from 'firebase/firestore';
 import InvoiceNewEditStatusDate from './invoice-new-edit-status-date';
 import InvoiceNewEditAddress from './invoice-new-edit-address';
 import InvoiceNewEditDetails from './invoice-new-edit-details';
 import InvoicePDF from './invoice-pdf';
+import { createInvoice, updateInvoice } from 'src/api/invoice';
 
 // ----------------------------------------------------------------------
@@ -58,4 +52,13 @@
 ];
 
+interface InvoiceItem {
+  service: string | null;
+  title: string;
+  price: number;
+  total: number;
+  quantity: number;
+  description: string;
+}
+
 export default function InvoiceNewEditForm({ isCopy, currentInvoice }: Props) {
   const router = useRouter();
@@ -69,5 +72,7 @@
     description: Yup.string().required('Description is required'),
     service: Yup.string().nullable(),
-    quantity: Yup.number().required('Quantity is required').min(0.5, 'Quantity must be at least 1'),
+    quantity: Yup.number()
+      .required('Quantity is required')
+      .min(0.5, 'Quantity must be at least 0.5'),
     price: Yup.number().required('Price is required').min(0, 'Price must be at least 0'),
     total: Yup.number().required('Total is required').min(0, 'Total must be at least 0'),
@@ -91,5 +96,5 @@
       .required('Quantity type is required'),
     month: Yup.string().oneOf(monthNames).required('Month is required'),
-    status: Yup.string().required(),
+    status: Yup.string().oneOf(['draft', 'processing', 'pending', 'overdue', 'paid']).required(),
     totalAmount: Yup.number().required(),
     // not required
@@ -103,5 +108,6 @@
 
   const { services: invoiceServices } = useGetServices();
-  const { settings, settingsEmpty, settingsLoading } = useGetSettings();
+  console.log('invoiceServices', invoiceServices);
+  const { settings: tenant, settingsEmpty, settingsLoading } = useGetTenant();
 
   const defaultValues = useMemo(
@@ -110,7 +116,9 @@
         !isCopy && currentInvoice?.invoiceNumber
           ? currentInvoice?.invoiceNumber
-          : incrementInvoiceNumber(settings?.invoice?.lastInvoiceNumber),
-      createDate: currentInvoice?.createDate?.toDate() || new Date(),
-      dueDate: currentInvoice?.dueDate?.toDate() || null,
+          : incrementInvoiceNumber(tenant?.lastInvoiceNumber),
+      createDate: currentInvoice?.createDate ? new Date(currentInvoice.createDate) : new Date(),
+      dueDate: currentInvoice?.dueDate
+        ? new Date(currentInvoice.dueDate)
+        : new Date(Date.now() + 30 * 24 * 60 * 60 * 1000),
       invoiceFrom: currentInvoice?.invoiceFrom || null,
       invoiceTo: currentInvoice?.invoiceTo || null,
@@ -138,5 +146,5 @@
       totalAmount: currentInvoice?.totalAmount || 0,
     }),
-    [currentInvoice, isCopy, settings]
+    [currentInvoice, isCopy, tenant]
   );
 
@@ -164,6 +172,17 @@
 
     try {
-      // generate collection id
       const id = generateId(collections.invoice);
+
+      // Ensure dates are valid Date objects
+      const createDate =
+        data.createDate instanceof Date ? data.createDate : new Date(data.createDate);
+      const dueDate = data.dueDate instanceof Date ? data.dueDate : new Date(data.dueDate);
+
+      const currentTime = new Date();
+      createDate.setHours(
+        currentTime.getHours(),
+        currentTime.getMinutes(),
+        currentTime.getSeconds()
+      );
 
       // attach serivce details
@@ -173,21 +192,16 @@
       }));
 
-      const currentTime = new Date();
-      const createDateWithCurrentTime = new Date(data.createDate); // This creates a date object using the date from data.createDate
-      // Set the time of createDateWithCurrentTime to the current hour, minutes, and seconds
-      createDateWithCurrentTime.setHours(
-        currentTime.getHours(),
-        currentTime.getMinutes(),
-        currentTime.getSeconds()
-      );
-
       // transform data
-      const writeData = {
+      const writeData: CreateInvoice = {
         ...data,
-        invoiceNumber: incrementInvoiceNumber(settings?.invoice.lastInvoiceNumber),
+        invoiceNumber: incrementInvoiceNumber(tenant?.lastInvoiceNumber),
         status: 'draft',
-        createDate: Timestamp.fromDate(createDateWithCurrentTime),
-        dueDate: Timestamp.fromDate(new Date(data.dueDate)),
-        items,
+        createDate,
+        dueDate,
+        items: items.filter((item) => item.service !== null) as CreateInvoice['items'],
+        subTotal: data.totalAmount - (data.taxes || 0) - (data.discount || 0),
+        month: data.month as Invoice['month'],
+        invoiceFrom: data.invoiceFrom!,
+        invoiceTo: data.invoiceTo!,
       };
 
@@ -199,19 +213,21 @@
 
       // write to DB
-      await firestoreBatch([
-        {
-          docPath: `${collections.invoice}/${id}`,
-          type: 'set',
-          data: {
-            ...writeData,
-            pdfRef: storagePath,
-          },
-        },
-        {
-          docPath: `${collections.settings}/${documents.settingsInvoice}`,
-          type: 'set',
-          data: { lastInvoiceNumber: writeData.invoiceNumber },
-        },
-      ]);
+      // await firestoreBatch([
+      //   {
+      //     docPath: `${collections.invoice}/${id}`,
+      //     type: 'set',
+      //     data: {
+      //       ...writeData,
+      //       pdfRef: storagePath,
+      //     },
+      //   },
+      //   {
+      //     docPath: `${collections.settings}/${documents.settingsInvoice}`,
+      //     type: 'set',
+      //     data: { lastInvoiceNumber: writeData.invoiceNumber },
+      //   },
+      // ]);
+
+      await createInvoice({ ...writeData, pdfRef: storagePath });
 
       loadingSave.onFalse();
@@ -229,4 +245,9 @@
     try {
       if (currentInvoice) {
+        // Ensure dates are valid Date objects
+        const createDate =
+          data.createDate instanceof Date ? data.createDate : new Date(data.createDate);
+        const dueDate = data.dueDate instanceof Date ? data.dueDate : new Date(data.dueDate);
+
         // attach serivce details
         const items = data.items.map((item) => ({
@@ -238,7 +259,9 @@
         const writeData = {
           ...data,
-          createDate: Timestamp.fromDate(new Date(data.createDate)),
-          dueDate: Timestamp.fromDate(new Date(data.dueDate)),
+          createDate,
+          dueDate,
           items,
+          invoiceFrom: data.invoiceFrom!,
+          invoiceTo: data.invoiceTo!,
         };
 
@@ -250,14 +273,46 @@
 
         // update DB
-        await updateDocument(collections.invoice, currentInvoice.id, {
+        // await updateDocument(collections.invoice, currentInvoice.id, {
+        //   ...writeData,
+        //   pdfRef: storagePath,
+        // });
+
+        await updateInvoice(currentInvoice.id, {
           ...writeData,
           pdfRef: storagePath,
+          status: data.status as 'draft' | 'processing' | 'pending' | 'overdue' | 'paid',
+          month: data.month as
+            | 'January'
+            | 'February'
+            | 'March'
+            | 'April'
+            | 'May'
+            | 'June'
+            | 'July'
+            | 'August'
+            | 'September'
+            | 'October'
+            | 'November'
+            | 'December',
+          items: items.filter((item) => item.service !== null) as {
+            service: { id: string; month: number; name: string; sprint: number; hour: number };
+            title: string;
+            price: number;
+            total: number;
+            quantity: number;
+            description: string;
+          }[],
         });
 
         // mutate current data
-        mutate([collections.invoice, currentInvoice.id]);
+        // mutate([collections.invoice, currentInvoice.id]);
       } else {
         // generate collection id
         const id = generateId(collections.invoice);
+
+        // Ensure dates are valid Date objects
+        const createDate =
+          data.createDate instanceof Date ? data.createDate : new Date(data.createDate);
+        const dueDate = data.dueDate instanceof Date ? data.dueDate : new Date(data.dueDate);
 
         // attach serivce details
@@ -270,7 +325,9 @@
         const writeData = {
           ...data,
-          createDate: Timestamp.fromDate(new Date(data.createDate)),
-          dueDate: Timestamp.fromDate(new Date(data.dueDate)),
+          createDate,
+          dueDate,
           items,
+          invoiceFrom: data.invoiceFrom!,
+          invoiceTo: data.invoiceTo!,
         };
 
@@ -282,19 +339,20 @@
 
         // write to DB
-        await firestoreBatch([
-          {
-            docPath: `${collections.invoice}/${id}`,
-            type: 'set',
-            data: {
-              ...writeData,
-              pdfRef: storagePath,
-            },
-          },
-          {
-            docPath: `${collections.settings}/${documents.settingsInvoice}`,
-            type: 'set',
-            data: { lastInvoiceNumber: writeData.invoiceNumber },
-          },
-        ]);
+        // await firestoreBatch([
+        //   {
+        //     docPath: `${collections.invoice}/${id}`,
+        //     type: 'set',
+        //     data: {
+        //       ...writeData,
+        //       pdfRef: storagePath,
+        //     },
+        //   },
+        //   {
+        //     docPath: `${collections.settings}/${documents.settingsInvoice}`,
+        //     type: 'set',
+        //     data: { lastInvoiceNumber: writeData.invoiceNumber },
+        //   },
+        // ]);
+        await createInvoice({ ...writeData, pdfRef: storagePath });
 
         reset();
@@ -314,5 +372,5 @@
     <FormProvider methods={methods}>
       <Card>
-        {settings?.company && <InvoiceNewEditAddress />}
+        {!!tenant && <InvoiceNewEditAddress />}
 
         <InvoiceNewEditStatusDate isCopy={isCopy} />
Index: src/sections/invoice/invoice-new-edit-status-date.tsx
===================================================================
--- src/sections/invoice/invoice-new-edit-status-date.tsx	(revision 5d6f37a75130aab7d9a67b5b430603eff2c0ca6e)
+++ src/sections/invoice/invoice-new-edit-status-date.tsx	(revision 057453cdc828f504e8bcd813422d99221b3b5732)
@@ -7,5 +7,5 @@
 import { RHFSelect, RHFTextField } from 'src/components/hook-form';
 // api
-import { useGetSettings } from 'src/api/settings';
+// import { useGetTenant } from 'src/api/settings';
 // utils
 import { incrementInvoiceNumber } from 'src/utils/increment-invoice-number';
@@ -33,5 +33,5 @@
   const values = watch();
 
-  const { settings } = useGetSettings();
+  // const { settings } = useGetTenant();
 
   return (
Index: src/sections/invoice/invoice-pdf.tsx
===================================================================
--- src/sections/invoice/invoice-pdf.tsx	(revision 5d6f37a75130aab7d9a67b5b430603eff2c0ca6e)
+++ src/sections/invoice/invoice-pdf.tsx	(revision 057453cdc828f504e8bcd813422d99221b3b5732)
@@ -1,3 +1,3 @@
-import { Invoice } from 'mvpmasters-shared';
+import { Invoice } from 'src/schemas';
 import InvoiceEEPDF from './invoice-ee-pdf';
 import InvoiceMKPDF from './invoice-mk-pdf';
Index: src/sections/invoice/invoice-table-filters-result.tsx
===================================================================
--- src/sections/invoice/invoice-table-filters-result.tsx	(revision 5d6f37a75130aab7d9a67b5b430603eff2c0ca6e)
+++ src/sections/invoice/invoice-table-filters-result.tsx	(revision 057453cdc828f504e8bcd813422d99221b3b5732)
@@ -6,5 +6,5 @@
 import Stack, { StackProps } from '@mui/material/Stack';
 // types
-import { InvoiceTableFilters, InvoiceTableFilterValue } from 'mvpmasters-shared';
+import { InvoiceTableFilters, InvoiceTableFilterValue } from 'src/schemas';
 // components
 import Iconify from 'src/components/iconify';
Index: src/sections/invoice/invoice-table-row.tsx
===================================================================
--- src/sections/invoice/invoice-table-row.tsx	(revision 5d6f37a75130aab7d9a67b5b430603eff2c0ca6e)
+++ src/sections/invoice/invoice-table-row.tsx	(revision 057453cdc828f504e8bcd813422d99221b3b5732)
@@ -16,5 +16,5 @@
 import { fNumber } from 'src/utils/format-number';
 // types
-import { Invoice } from 'mvpmasters-shared';
+import { Invoice } from 'src/schemas';
 // components
 import Label from 'src/components/label';
@@ -60,4 +60,6 @@
   } = row;
 
+  console.log(createDate);
+
   const confirmSend = useBoolean();
   const confirmDelete = useBoolean();
@@ -105,6 +107,6 @@
         <TableCell>
           <ListItemText
-            primary={format(createDate.toDate(), 'dd MMM yyyy')}
-            secondary={format(createDate.toDate(), 'p')}
+            primary={format(new Date(createDate), 'dd MMM yyyy')}
+            secondary={format(new Date(createDate), 'p')}
             primaryTypographyProps={{ typography: 'body2', noWrap: true }}
             secondaryTypographyProps={{
@@ -118,6 +120,6 @@
         <TableCell>
           <ListItemText
-            primary={format(dueDate.toDate(), 'dd MMM yyyy')}
-            secondary={format(dueDate.toDate(), 'p')}
+            primary={format(new Date(dueDate), 'dd MMM yyyy')}
+            secondary={format(new Date(dueDate), 'p')}
             primaryTypographyProps={{ typography: 'body2', noWrap: true }}
             secondaryTypographyProps={{
Index: src/sections/invoice/invoice-table-toolbar.tsx
===================================================================
--- src/sections/invoice/invoice-table-toolbar.tsx	(revision 5d6f37a75130aab7d9a67b5b430603eff2c0ca6e)
+++ src/sections/invoice/invoice-table-toolbar.tsx	(revision 057453cdc828f504e8bcd813422d99221b3b5732)
@@ -7,5 +7,5 @@
 import InputAdornment from '@mui/material/InputAdornment';
 // types
-import { InvoiceTableFilters, InvoiceTableFilterValue } from 'mvpmasters-shared';
+import { InvoiceTableFilters, InvoiceTableFilterValue } from 'src/schemas';
 // components
 import Iconify from 'src/components/iconify';
Index: src/sections/invoice/invoice-toolbar.tsx
===================================================================
--- src/sections/invoice/invoice-toolbar.tsx	(revision 5d6f37a75130aab7d9a67b5b430603eff2c0ca6e)
+++ src/sections/invoice/invoice-toolbar.tsx	(revision 057453cdc828f504e8bcd813422d99221b3b5732)
@@ -18,5 +18,5 @@
 import { useBoolean } from 'src/hooks/use-boolean';
 // types
-import { Invoice } from 'mvpmasters-shared';
+import { Invoice } from 'src/schemas';
 // components
 import Iconify from 'src/components/iconify';
Index: src/sections/invoice/mail-compose.tsx
===================================================================
--- src/sections/invoice/mail-compose.tsx	(revision 5d6f37a75130aab7d9a67b5b430603eff2c0ca6e)
+++ src/sections/invoice/mail-compose.tsx	(revision 057453cdc828f504e8bcd813422d99221b3b5732)
@@ -13,5 +13,5 @@
 import Iconify from 'src/components/iconify';
 import Editor from 'src/components/editor';
-import { Invoice } from 'mvpmasters-shared';
+import { Invoice } from 'src/schemas';
 import FormProvider from 'src/components/hook-form/form-provider';
 import { RHFTextField } from 'src/components/hook-form';
Index: src/sections/invoice/view/invoice-edit-view.tsx
===================================================================
--- src/sections/invoice/view/invoice-edit-view.tsx	(revision 5d6f37a75130aab7d9a67b5b430603eff2c0ca6e)
+++ src/sections/invoice/view/invoice-edit-view.tsx	(revision 057453cdc828f504e8bcd813422d99221b3b5732)
@@ -23,4 +23,5 @@
 
   const { currentInvoice } = useGetInvoice({ id });
+  console.log('currentInvoice', currentInvoice);
 
   return (
Index: src/sections/invoice/view/invoice-list-view.tsx
===================================================================
--- src/sections/invoice/view/invoice-list-view.tsx	(revision 5d6f37a75130aab7d9a67b5b430603eff2c0ca6e)
+++ src/sections/invoice/view/invoice-list-view.tsx	(revision 057453cdc828f504e8bcd813422d99221b3b5732)
@@ -36,14 +36,9 @@
 } from 'src/components/table';
 // types
-import {
-  Invoice,
-  InvoiceStatus,
-  InvoiceTableFilters,
-  InvoiceTableFilterValue,
-} from 'mvpmasters-shared';
+import { Invoice, InvoiceStatus, InvoiceTableFilters, InvoiceTableFilterValue } from 'src/schemas';
 //
 import deleteFromFirebaseStorage from 'src/utils/delete-from-firebase-storage';
 // fetch
-import { useGetInvoices } from 'src/api/invoice';
+import { useDeleteInvoice, useGetInvoices } from 'src/api/invoice';
 import { collections, removeDocument } from 'src/lib/firestore';
 import { mutate } from 'swr';
@@ -163,9 +158,5 @@
   const [filters, setFilters] = useState(defaultFilters);
 
-  const { invoices: tableData } = useGetInvoices({
-    where: [['createDate', '>=', filters.startDate]],
-    orderBy: 'createDate',
-    direction: 'desc',
-  });
+  const { invoices: tableData } = useGetInvoices({ startDate: filters.startDate?.toISOString() });
 
   const invoiceMutationKey = useMemo(
@@ -269,4 +260,6 @@
   );
 
+  const { deleteInvoiceMutation } = useDeleteInvoice();
+
   const handleDeleteRow = useCallback(
     async (invoice: Invoice) => {
@@ -275,19 +268,11 @@
         orderBy: 'createDate',
         direction: 'desc',
-      }); // Get the same params as used in useGetInvoices
-
-      // Optimistically update the cache before the deletion
-      // mutate(
-      //   [collections.invoice, serializedParams],
-      //   (invoices: Invoice[] = []) => invoices.filter((row) => row.id !== invoice.id),
-      //   false
-      // );
-
-      await removeDocument(collections.invoice, invoice.id);
+      });
+
+      await deleteInvoiceMutation(invoice.id);
       await deleteFromFirebaseStorage(
         `invoices/${invoice.invoiceTo.name}/${invoice.id}-${invoice.invoiceNumber}.pdf`
       );
 
-      // Optionally, rollback optimistic update or refetch data
       mutate(invoiceMutationKey);
     },
@@ -672,6 +657,6 @@
       inputData = inputData.filter(
         (invoice) =>
-          fTimestamp(invoice.createDate.toMillis()) >= fTimestamp(startDate) &&
-          fTimestamp(invoice.createDate.toMillis()) <= fTimestamp(endDate)
+          fTimestamp(invoice.createDate.getTime()) >= fTimestamp(startDate.getTime()) &&
+          fTimestamp(invoice.createDate.getTime()) <= fTimestamp(endDate.getTime())
       );
     }
