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/ledger_entries/ledger_entriesSlice'
import { useAppDispatch } from '../../stores/hooks'
import { useRouter } from 'next/router'
import moment from 'moment';

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    company: '',
    
    
    
    
    entry_no: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    transaction_date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    source_module: 'invoice',
    
    
    
    
    
    
    
    source_ref: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    account: '',
    
    
    
    
    debit: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    credit: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    driver: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    vehicle: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    invoice: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    payment: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    vehicle_expense: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    bill: '',
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    created_on: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reversal_entry: '',
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/ledger_entries/ledger_entries-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="Company" labelFor="company">
      <Field name="company" id="company" component={SelectField} options={[]} itemRef={'companies'}></Field>
  </FormField>









  <FormField
      label="EntryNo"
  >
      <Field
          name="entry_no"
          placeholder="EntryNo"
      />
  </FormField>





































  <FormField
      label="TransactionDate"
  >
      <Field
          type="datetime-local"
          name="transaction_date"
          placeholder="TransactionDate"
      />
  </FormField>































  <FormField label="SourceModule" labelFor="source_module">
      <Field name="source_module" id="source_module" component="select">
      
        <option value="invoice">invoice</option>
      
        <option value="payment">payment</option>
      
        <option value="vehicle_expense">vehicle_expense</option>
      
        <option value="driver_expense">driver_expense</option>
      
        <option value="bill">bill</option>
      
        <option value="bill_payment">bill_payment</option>
      
        <option value="adjustment">adjustment</option>
      
        <option value="reversal">reversal</option>
      
        <option value="opening_balance">opening_balance</option>
      
      </Field>
  </FormField>













  <FormField
      label="SourceRef"
  >
      <Field
          name="source_ref"
          placeholder="SourceRef"
      />
  </FormField>













































  <FormField label="Account" labelFor="account">
      <Field name="account" id="account" component={SelectField} options={[]} itemRef={'chart_of_accounts'}></Field>
  </FormField>















    <FormField
        label="Debit"
    >
        <Field
            type="number"
            name="debit"
            placeholder="Debit"
        />
    </FormField>



























    <FormField
        label="Credit"
    >
        <Field
            type="number"
            name="credit"
            placeholder="Credit"
        />
    </FormField>







































  <FormField label="Driver" labelFor="driver">
      <Field name="driver" id="driver" component={SelectField} options={[]} itemRef={'drivers'}></Field>
  </FormField>



























  <FormField label="Vehicle" labelFor="vehicle">
      <Field name="vehicle" id="vehicle" component={SelectField} options={[]} itemRef={'vehicles'}></Field>
  </FormField>



























  <FormField label="Invoice" labelFor="invoice">
      <Field name="invoice" id="invoice" component={SelectField} options={[]} itemRef={'invoices'}></Field>
  </FormField>



























  <FormField label="Payment" labelFor="payment">
      <Field name="payment" id="payment" component={SelectField} options={[]} itemRef={'payments'}></Field>
  </FormField>



























  <FormField label="VehicleExpense" labelFor="vehicle_expense">
      <Field name="vehicle_expense" id="vehicle_expense" component={SelectField} options={[]} itemRef={'vehicle_expenses'}></Field>
  </FormField>



























  <FormField label="Bill" labelFor="bill">
      <Field name="bill" id="bill" component={SelectField} options={[]} itemRef={'bills'}></Field>
  </FormField>











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



































  <FormField
      label="CreatedOn"
  >
      <Field
          type="datetime-local"
          name="created_on"
          placeholder="CreatedOn"
      />
  </FormField>



































  <FormField label="ReversalEntry" labelFor="reversal_entry">
      <Field name="reversal_entry" id="reversal_entry" component={SelectField} options={[]} itemRef={'ledger_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('/ledger_entries/ledger_entries-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Ledger_entriesNew
