import { mdiAccount, mdiChartTimelineVariant, mdiMail, mdiUpload } from '@mdi/js'
import Head from 'next/head'
import React, { ReactElement } from 'react'
import CardBox from '../../components/CardBox'
import LayoutAuthenticated from '../../layouts/Authenticated'
import SectionMain from '../../components/SectionMain'
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
import { getPageTitle } from '../../config'

import { Field, Form, Formik } from 'formik'
import FormField from '../../components/FormField'
import BaseDivider from '../../components/BaseDivider'
import BaseButtons from '../../components/BaseButtons'
import BaseButton from '../../components/BaseButton'
import FormCheckRadio from '../../components/FormCheckRadio'
import FormCheckRadioGroup from '../../components/FormCheckRadioGroup'
import FormFilePicker from '../../components/FormFilePicker'
import FormImagePicker from '../../components/FormImagePicker'
import { SwitchField } from '../../components/SwitchField'

import { SelectField } from '../../components/SelectField'
import { SelectFieldMany } from "../../components/SelectFieldMany";
import {RichTextField} from "../../components/RichTextField";

import { create } from '../../stores/ap_invoices/ap_invoicesSlice'
import { useAppDispatch } from '../../stores/hooks'
import { useRouter } from 'next/router'
import moment from 'moment';

const initialValues = {
    
    
    invoiceNumber: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    vendor: '',
    
    
    
    
    vendorInvoiceNumber: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    invoiceDate: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    receiptDate: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    dueDate: '',
    
    
    
    
    
    
    
    
    
    
    grossAmount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    vatAmount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ewtAmount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    netPayable: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    glAccount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    costCenter: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'UNPOSTED',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    journalEntry: '',
    
    
    
}


const Ap_invoicesNew = () => {
  const router = useRouter()
  const dispatch = useAppDispatch()

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/ap_invoices/ap_invoices-list')
  }
  return (
    <>
      <Head>
        <title>{getPageTitle('New Item')}</title>
      </Head>
      <SectionMain>
        <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="New Item" main>
        {''}
        </SectionTitleLineWithButton>
        <CardBox>
          <Formik
            initialValues={
                
                initialValues
                
            }
            onSubmit={(values) => handleSubmit(values)}
          >
            <Form>



  <FormField
      label="APInvoiceNumber"
  >
      <Field
          name="invoiceNumber"
          placeholder="APInvoiceNumber"
      />
  </FormField>













































  <FormField label="Vendor" labelFor="vendor">
      <Field name="vendor" id="vendor" component={SelectField} options={[]} itemRef={'vendors'}></Field>
  </FormField>









  <FormField
      label="VendorInvoiceNumber"
  >
      <Field
          name="vendorInvoiceNumber"
          placeholder="VendorInvoiceNumber"
      />
  </FormField>





































  <FormField
      label="InvoiceDate"
  >
      <Field
          type="datetime-local"
          name="invoiceDate"
          placeholder="InvoiceDate"
      />
  </FormField>



























  <FormField
      label="ReceiptDate"
  >
      <Field
          type="datetime-local"
          name="receiptDate"
          placeholder="ReceiptDate"
      />
  </FormField>



























  <FormField
      label="DueDate"
  >
      <Field
          type="datetime-local"
          name="dueDate"
          placeholder="DueDate"
      />
  </FormField>























    <FormField
        label="GrossAmount"
    >
        <Field
            type="number"
            name="grossAmount"
            placeholder="GrossAmount"
        />
    </FormField>



























    <FormField
        label="VATAmount"
    >
        <Field
            type="number"
            name="vatAmount"
            placeholder="VATAmount"
        />
    </FormField>



























    <FormField
        label="EWTAmount"
    >
        <Field
            type="number"
            name="ewtAmount"
            placeholder="EWTAmount"
        />
    </FormField>



























    <FormField
        label="NetPayable"
    >
        <Field
            type="number"
            name="netPayable"
            placeholder="NetPayable"
        />
    </FormField>























    <FormField label="Description" hasTextareaHeight>
        <Field name="description" as="textarea" placeholder="Description" />
    </FormField>











































  <FormField label="GLAccount" labelFor="glAccount">
      <Field name="glAccount" id="glAccount" component={SelectField} options={[]} itemRef={'accounts'}></Field>
  </FormField>



























  <FormField label="CostCenter" labelFor="costCenter">
      <Field name="costCenter" id="costCenter" component={SelectField} options={[]} itemRef={'cost_centers'}></Field>
  </FormField>























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="UNPOSTED">UNPOSTED</option>
      
        <option value="POSTED">POSTED</option>
      
        <option value="PARTIALLY_PAID">PARTIALLY_PAID</option>
      
        <option value="FULLY_PAID">FULLY_PAID</option>
      
        <option value="OVERDUE">OVERDUE</option>
      
        <option value="CANCELLED">CANCELLED</option>
      
      </Field>
  </FormField>































  <FormField label="JournalEntry" labelFor="journalEntry">
      <Field name="journalEntry" id="journalEntry" component={SelectField} options={[]} itemRef={'journal_entries'}></Field>
  </FormField>







              <BaseDivider />
              <BaseButtons>
                <BaseButton type="submit" color="info" label="Submit" />
                <BaseButton type="reset" color="info" outline label="Reset" />
                <BaseButton type='reset' color='danger' outline label='Cancel' onClick={() => router.push('/ap_invoices/ap_invoices-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

Ap_invoicesNew.getLayout = function getLayout(page: ReactElement) {
  return (
      <LayoutAuthenticated
        
          permission={'CREATE_AP_INVOICES'}
        
      >
          {page}
      </LayoutAuthenticated>
  )
}

export default Ap_invoicesNew
