All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
- Integrated BulkObjectActions component across various management and dashboard components for improved batch processing capabilities. - Updated components including Invoices, PaymentPolicies, Payments, TaxRecords, and multiple Inventory and Management sections to include bulk action functionality. - Enhanced user experience by allowing users to perform actions on multiple items simultaneously, streamlining workflows and improving efficiency.
342 lines
8.0 KiB
JavaScript
342 lines
8.0 KiB
JavaScript
import { createElement, lazy } from 'react'
|
|
|
|
const StockAuditInfo = lazy(
|
|
() =>
|
|
import('../../components/Dashboard/Inventory/StockAudits/StockAuditInfo')
|
|
)
|
|
const NewStockAudit = lazy(
|
|
() => import('../../components/Dashboard/Inventory/StockAudits/NewStockAudit')
|
|
)
|
|
const DeleteObject = lazy(
|
|
() => import('../../components/Dashboard/common/DeleteObject')
|
|
)
|
|
const PostStockAudit = lazy(
|
|
() =>
|
|
import('../../components/Dashboard/Inventory/StockAudits/PostStockAudit')
|
|
)
|
|
import StockAuditIcon from '../../components/Icons/StockAuditIcon'
|
|
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'
|
|
import DuplicateIcon from '../../components/Icons/DuplicateIcon'
|
|
|
|
export const StockAudit = {
|
|
name: 'stockAudit',
|
|
label: 'Stock Audit',
|
|
labelPlural: 'Stock Audits',
|
|
url: '/dashboard/inventory/stockaudits',
|
|
prefix: 'SAU',
|
|
icon: StockAuditIcon,
|
|
actions: [
|
|
{
|
|
name: 'new',
|
|
type: 'modal',
|
|
pageName: 'list',
|
|
modalWidth: 700,
|
|
label: 'New Stock Audit',
|
|
icon: PlusIcon,
|
|
content: (objectData, { onOk } = {}) => {
|
|
return createElement(NewStockAudit, {
|
|
defaultValues: objectData,
|
|
onOk,
|
|
reset: true
|
|
})
|
|
}
|
|
},
|
|
{
|
|
name: 'duplicate',
|
|
type: 'alias',
|
|
objectType: 'stockAudit',
|
|
aliasAction: 'new',
|
|
pageName: 'info',
|
|
label: 'Duplicate',
|
|
icon: DuplicateIcon,
|
|
objectData: (objectData) => objectData
|
|
},
|
|
{
|
|
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)
|
|
},
|
|
disabled: (objectData) => {
|
|
return objectData?.state?.type != 'draft'
|
|
}
|
|
},
|
|
{
|
|
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',
|
|
bulk: true,
|
|
type: 'modal',
|
|
modalWidth: 520,
|
|
modalCentered: true,
|
|
label: 'Delete',
|
|
icon: BinIcon,
|
|
danger: true,
|
|
visible: (objectData) => {
|
|
return !(objectData?._isEditing && objectData?._isEditing == true)
|
|
},
|
|
disabled: (objectData) => {
|
|
return objectData?.state?.type != 'draft'
|
|
},
|
|
content: (objectData, { onOk } = {}) => {
|
|
return createElement(DeleteObject, { objectData, onOk })
|
|
}
|
|
},
|
|
{ type: 'divider' },
|
|
{
|
|
name: 'post',
|
|
type: 'modal',
|
|
modalWidth: 520,
|
|
modalCentered: true,
|
|
label: 'Post',
|
|
icon: CheckIcon,
|
|
visible: (objectData) => {
|
|
return objectData?.state?.type == 'draft'
|
|
},
|
|
content: (objectData, { onOk } = {}) => {
|
|
return createElement(PostStockAudit, { objectData, onOk })
|
|
}
|
|
}
|
|
],
|
|
pages: [
|
|
{
|
|
name: 'info',
|
|
content: () => createElement(StockAuditInfo)
|
|
}
|
|
],
|
|
columns: [
|
|
'_reference',
|
|
'state',
|
|
'auditLevel',
|
|
'stockLocation',
|
|
'postedAt',
|
|
'createdAt',
|
|
'updatedAt'
|
|
],
|
|
filters: [
|
|
'state',
|
|
'state.type',
|
|
'auditLevel',
|
|
'stockLocation',
|
|
'postedAt',
|
|
'createdAt',
|
|
'updatedAt',
|
|
'_reference'
|
|
],
|
|
sorters: ['createdAt', 'updatedAt', 'postedAt', 'state'],
|
|
group: ['state'],
|
|
properties: [
|
|
{
|
|
name: '_id',
|
|
label: 'ID',
|
|
type: 'id',
|
|
objectType: 'stockAudit',
|
|
showCopy: true,
|
|
readOnly: true,
|
|
columnWidth: 140
|
|
},
|
|
{
|
|
name: 'createdAt',
|
|
label: 'Created At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: '_reference',
|
|
label: 'Reference',
|
|
type: 'reference',
|
|
columnFixed: 'left',
|
|
objectType: 'stockAudit',
|
|
showCopy: true,
|
|
readOnly: true,
|
|
columnWidth: 180
|
|
},
|
|
{
|
|
name: 'updatedAt',
|
|
label: 'Updated At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'state',
|
|
label: 'State',
|
|
type: 'state',
|
|
readOnly: true,
|
|
columnWidth: 260
|
|
},
|
|
{
|
|
name: 'postedAt',
|
|
label: 'Posted At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'auditLevel',
|
|
label: 'Audit Level',
|
|
type: 'object',
|
|
objectType: 'stockAuditLevel',
|
|
showHyperlink: true,
|
|
required: true,
|
|
columnWidth: 220
|
|
},
|
|
{
|
|
name: 'stockLocation',
|
|
label: 'Stock Location',
|
|
type: 'object',
|
|
objectType: 'stockLocation',
|
|
showHyperlink: true,
|
|
required: true,
|
|
columnWidth: 220
|
|
},
|
|
|
|
{
|
|
name: 'auditLines',
|
|
label: 'Audit Lines',
|
|
type: 'objectChildren',
|
|
required: false,
|
|
size: 'medium',
|
|
canAddRemove: false,
|
|
columns: [
|
|
'itemType',
|
|
'item',
|
|
'itemSku',
|
|
'current',
|
|
'actual',
|
|
'new',
|
|
'variance'
|
|
],
|
|
properties: [
|
|
{
|
|
name: 'itemType',
|
|
label: 'Item Type',
|
|
type: 'objectType',
|
|
readOnly: true,
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'item',
|
|
label: 'Item',
|
|
type: 'object',
|
|
objectType: (row) => row?.itemType,
|
|
readOnly: true,
|
|
showHyperlink: true,
|
|
columnWidth: 220
|
|
},
|
|
{
|
|
name: 'itemSku',
|
|
label: 'Item SKU',
|
|
type: 'object',
|
|
objectType: (row) => {
|
|
if (row?.itemType === 'filament') return 'filamentSku'
|
|
if (row?.itemType === 'part') return 'partSku'
|
|
if (row?.itemType === 'product') return 'productSku'
|
|
return undefined
|
|
},
|
|
readOnly: true,
|
|
showHyperlink: true,
|
|
columnWidth: 220
|
|
},
|
|
{
|
|
name: 'current',
|
|
label: 'Current',
|
|
type: 'number',
|
|
readOnly: true,
|
|
columnWidth: 150,
|
|
suffix: (row) => (row?.itemType === 'filament' ? 'g net' : null)
|
|
},
|
|
{
|
|
name: 'actual',
|
|
label: 'Actual',
|
|
type: 'number',
|
|
columnWidth: 150,
|
|
suffix: (row) => (row?.itemType === 'filament' ? 'g net' : null)
|
|
},
|
|
{
|
|
name: 'new',
|
|
label: 'New',
|
|
type: 'number',
|
|
readOnly: true,
|
|
columnWidth: 150,
|
|
suffix: (row) => (row?.itemType === 'filament' ? 'g net' : null),
|
|
value: (row) => Number(row?.actual) || 0
|
|
},
|
|
{
|
|
name: 'variance',
|
|
label: 'Variance',
|
|
type: 'variance',
|
|
readOnly: true,
|
|
columnWidth: 150,
|
|
suffix: (row) => (row?.itemType === 'filament' ? 'g net' : null),
|
|
value: (row) => {
|
|
const current = Number(row?.current) || 0
|
|
const actual = Number(row?.actual) || 0
|
|
return actual - current
|
|
}
|
|
}
|
|
]
|
|
}
|
|
],
|
|
stats: [
|
|
{
|
|
name: 'draft.count',
|
|
label: 'Draft',
|
|
type: 'number',
|
|
color: 'default'
|
|
},
|
|
{
|
|
name: 'complete.count',
|
|
label: 'Complete',
|
|
type: 'number',
|
|
color: 'success'
|
|
}
|
|
]
|
|
}
|