- Removed the delete action from various components including InvoiceInfo, PaymentInfo, and others to streamline functionality. - Introduced a new DeleteObject component to handle deletion logic in a centralized manner, enhancing code maintainability. - Updated models to utilize the new DeleteObject component for consistent deletion handling across the application. - Simplified ObjectForm by eliminating the previous delete modal, improving component structure and clarity.
229 lines
5.0 KiB
JavaScript
229 lines
5.0 KiB
JavaScript
import { createElement, lazy } from 'react'
|
|
|
|
const TaxRecordInfo = lazy(
|
|
() => import('../../components/Dashboard/Finance/TaxRecords/TaxRecordInfo')
|
|
)
|
|
const NewTaxRecord = lazy(
|
|
() => import('../../components/Dashboard/Finance/TaxRecords/NewTaxRecord')
|
|
)
|
|
const DeleteObject = lazy(
|
|
() => import('../../components/Dashboard/common/DeleteObject')
|
|
)
|
|
import TaxRecordIcon from '../../components/Icons/TaxRecordIcon'
|
|
import PlusIcon from '../../components/Icons/PlusIcon'
|
|
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
|
|
import EditIcon from '../../components/Icons/EditIcon'
|
|
import CheckIcon from '../../components/Icons/CheckIcon'
|
|
import XMarkIcon from '../../components/Icons/XMarkIcon'
|
|
import BinIcon from '../../components/Icons/BinIcon'
|
|
import ListIcon from '../../components/Icons/ListIcon'
|
|
|
|
export const TaxRecord = {
|
|
name: 'taxRecord',
|
|
label: 'Tax Record',
|
|
labelPlural: 'Tax Records',
|
|
url: '/dashboard/finance/taxrecords',
|
|
prefix: 'TXR',
|
|
icon: TaxRecordIcon,
|
|
actions: [
|
|
{
|
|
name: 'new',
|
|
type: 'modal',
|
|
pageName: 'list',
|
|
modalWidth: 700,
|
|
label: 'New Tax Record',
|
|
icon: PlusIcon,
|
|
content: (objectData, { onOk } = {}) => {
|
|
return createElement(NewTaxRecord, { defaultValues: objectData, onOk, reset: true })
|
|
}
|
|
},
|
|
{
|
|
name: 'list',
|
|
type: 'page',
|
|
pageName: 'list',
|
|
label: 'List',
|
|
icon: ListIcon
|
|
},
|
|
{
|
|
name: 'info',
|
|
type: 'page',
|
|
pageName: 'info',
|
|
label: 'Info',
|
|
default: true,
|
|
row: true,
|
|
icon: InfoCircleIcon
|
|
},
|
|
{
|
|
name: 'edit',
|
|
type: 'page',
|
|
pageName: 'info',
|
|
label: 'Edit',
|
|
row: true,
|
|
icon: EditIcon,
|
|
visible: (objectData) => {
|
|
return !(objectData?._isEditing && objectData?._isEditing == true)
|
|
}
|
|
},
|
|
{
|
|
name: 'cancelEdit',
|
|
label: 'Cancel Edits',
|
|
type: 'page',
|
|
pageName: 'info',
|
|
icon: XMarkIcon,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{
|
|
name: 'finishEdit',
|
|
label: 'Save Edits',
|
|
type: 'page',
|
|
pageName: 'info',
|
|
icon: CheckIcon,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{ type: 'divider' },
|
|
{
|
|
name: 'delete',
|
|
type: 'modal',
|
|
modalWidth: 520,
|
|
modalCentered: true,
|
|
label: 'Delete',
|
|
icon: BinIcon,
|
|
danger: true,
|
|
content: (objectData, { onOk } = {}) => {
|
|
return createElement(DeleteObject, { objectData, onOk })
|
|
}
|
|
}
|
|
],
|
|
pages: [
|
|
{
|
|
name: 'info',
|
|
content: () => createElement(TaxRecordInfo)
|
|
}
|
|
],
|
|
columns: [
|
|
'_reference',
|
|
'taxRate',
|
|
'transactionType',
|
|
'transaction',
|
|
'amount',
|
|
'taxAmount',
|
|
'transactionDate',
|
|
'createdAt',
|
|
'updatedAt'
|
|
],
|
|
filters: [
|
|
'taxRate',
|
|
'transactionType',
|
|
'transaction',
|
|
'transactionDate',
|
|
'createdAt',
|
|
'updatedAt',
|
|
'_reference'
|
|
],
|
|
sorters: [
|
|
'transactionDate',
|
|
'amount',
|
|
'taxAmount',
|
|
'createdAt',
|
|
'_id',
|
|
'updatedAt'
|
|
],
|
|
group: ['transactionType'],
|
|
properties: [
|
|
{
|
|
name: '_id',
|
|
label: 'ID',
|
|
columnFixed: 'left',
|
|
type: 'id',
|
|
objectType: 'taxRecord',
|
|
showCopy: true,
|
|
columnWidth: 140
|
|
},
|
|
{
|
|
name: 'createdAt',
|
|
label: 'Created At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: '_reference',
|
|
label: 'Reference',
|
|
type: 'reference',
|
|
columnFixed: 'left',
|
|
objectType: 'taxRecord',
|
|
showCopy: true,
|
|
readOnly: true,
|
|
columnWidth: 180
|
|
},
|
|
{
|
|
name: 'taxRate',
|
|
label: 'Tax Rate',
|
|
required: true,
|
|
type: 'object',
|
|
objectType: 'taxRate',
|
|
showHyperlink: true,
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'transactionType',
|
|
label: 'Transaction Type',
|
|
required: true,
|
|
type: 'select',
|
|
columnWidth: 175,
|
|
options: [
|
|
{ label: 'Purchase Order', value: 'purchaseOrder' },
|
|
{ label: 'Sales Order', value: 'salesOrder' },
|
|
{ label: 'Other', value: 'other' }
|
|
]
|
|
},
|
|
{
|
|
name: 'transaction',
|
|
label: 'Transaction',
|
|
required: true,
|
|
type: 'object',
|
|
objectType: (objectData) => {
|
|
return objectData?.transactionType || 'purchaseOrder'
|
|
},
|
|
showHyperlink: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'amount',
|
|
label: 'Amount',
|
|
required: true,
|
|
type: 'currency',
|
|
min: 0,
|
|
step: 0.01,
|
|
columnWidth: 125
|
|
},
|
|
{
|
|
name: 'taxAmount',
|
|
label: 'Tax Amount',
|
|
required: true,
|
|
type: 'currency',
|
|
min: 0,
|
|
step: 0.01,
|
|
columnWidth: 125
|
|
},
|
|
{
|
|
name: 'transactionDate',
|
|
label: 'Transaction Date',
|
|
required: true,
|
|
type: 'date',
|
|
columnWidth: 175,
|
|
default: () => new Date()
|
|
},
|
|
{
|
|
name: 'updatedAt',
|
|
label: 'Updated At',
|
|
type: 'dateTime',
|
|
readOnly: true
|
|
}
|
|
]
|
|
}
|