import { Typography } from "@material-ui/core";
import { GridColumns } from "@material-ui/data-grid";
import capitalize from "capitalize";
import { TFunction } from "i18next";
import { IJobInfo, IJobReports } from "../../../../../../Application/DTOs/JobsDto/JobsDto.types";
import {
    calculateGST,
    computationWaitingTimeCharge,
} from '../../../../Utilities/Computation';
import { formatDate, formatDates } from '../../../../Utilities/DateTime'
import moment from "moment";



export const getInvoiceReportsColumns = (t: TFunction, access_type: string): GridColumns => {
   
    return [
        {
            field: 'reference',
            headerName: t('Columns:reference'),
            width: 300,
            sortable: true,
        },

        {
            field: 'company',
            headerName: "Company",
            width: 200,
            sortable: true,
            renderCell: (params) => {
              const job: any = params.row as any
      
       
              return (
                <Typography>
                  {job.company?.name}
                 
                </Typography>
              )
            }
          },
          {
            field: 'customer',
            headerName: "Customer",
            width: 200,
            sortable: true,
            renderCell: (params) => {
              const job: any = params.row as any
              
              return (
                <Typography>
                  {(job?.customer?.first_name && job?.customer?.last_name) ? job?.customer?.first_name + job?.customer?.last_name : "N/A"}
                </Typography>
              )
            }
          },
          {
            field: 'transport',
            headerName: "Transporter",
            width: 300,
            sortable: true,
      
            renderCell: (params) => {
              const job: any = params.row as any
              
              return (
                <Typography>
                  {String(job?.transporter?.accountcontactname ?? "N/A")}
                </Typography>
              )
            }
          },
      
        {
            field: 'Delivery_date',
            headerName: "Delivery date",
            width: 200,
            sortable: true,
            renderCell: (params) => {
                const job: any = params.row as any
               
                return (
                  <Typography>
                   {job?.job_addresses[0]?.delivery_date_time ? moment(job?.job_addresses?.delivery_date_time).format('DD-MM-YYYY') : 'N/A'}
                  </Typography>
                )
              }
        },

        {
            field: 'Invoice No.',
            headerName: "Invoice No.",
            width: 200,
            sortable: true,
            renderCell: (params) => {
                const job: any = params.row as any
                
                return (
                  <Typography>
                   { access_type == "supplier" ?   job?.supplier_invoice_no ?? 'N/A' : job?.moveit4u_invoice_no ?? 'N/A'}
                  </Typography>
                )
              }
        },



        {
            field: 'Invoice Date',
            headerName: "Invoice Date",
            width: 200,
            sortable: true,
            renderCell: (params) => {
                const job: any = params.row as any
                
                return (
                  <Typography>
                   { access_type == "supplier" ? job?.supplier_invoice_date ?  moment(job?.supplier_invoice_date).format('DD-MM-YYYY') : 'N/A' : job?.moveit4u_invoice_date ? moment(job?.moveit4u_invoice_date).format('DD-MM-YYYY') : 'N/A'}
                  </Typography>
                )
              }
        },
     
        {
            field: 'movementType',
            headerName: 'Movement Type',
            width: 300,
            sortable: true,
            renderCell: (params) => {
                const job: IJobReports = params.row as IJobReports
         
                
                return (
                    <Typography>
                       {job?.movementType}
                    </Typography>
                )
            }
        },
       
      

      
       

       
    ]
}