All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
- Updated InventoryOverview to include additional statistics for part stock, filament stock, product stock, and stock events, improving data visibility. - Refactored InfoCollapse components to support new statistics and ensure proper state management for collapsible sections. - Enhanced ModelHistoryDisplay to support both line and bar chart types, providing more flexibility in data visualization. - Added new stats definitions for FilamentStock, PartStock, ProductStock, and StockEvent models to support the expanded inventory features.
232 lines
4.7 KiB
JavaScript
232 lines
4.7 KiB
JavaScript
import { createElement, lazy } from 'react'
|
|
|
|
const PartStockInfo = lazy(
|
|
() => import('../../components/Dashboard/Inventory/PartStocks/PartStockInfo')
|
|
)
|
|
const NewPartStock = lazy(
|
|
() => import('../../components/Dashboard/Inventory/PartStocks/NewPartStock')
|
|
)
|
|
import PartStockIcon from '../../components/Icons/PartStockIcon'
|
|
import PlusIcon from '../../components/Icons/PlusIcon'
|
|
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
|
|
import ListIcon from '../../components/Icons/ListIcon'
|
|
|
|
export const PartStock = {
|
|
name: 'partStock',
|
|
label: 'Part Stock',
|
|
labelPlural: 'Part Stocks',
|
|
url: '/dashboard/inventory/partstocks',
|
|
prefix: 'PTS',
|
|
readOnly: true,
|
|
icon: PartStockIcon,
|
|
actions: [
|
|
{
|
|
name: 'new',
|
|
type: 'modal',
|
|
pageName: 'list',
|
|
modalWidth: 800,
|
|
label: 'New Part Stock',
|
|
icon: PlusIcon,
|
|
content: (objectData, { onOk } = {}) => {
|
|
return createElement(NewPartStock, {
|
|
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
|
|
}
|
|
],
|
|
pages: [
|
|
{
|
|
name: 'info',
|
|
content: () => createElement(PartStockInfo)
|
|
}
|
|
],
|
|
filters: [
|
|
'part',
|
|
'partSku',
|
|
'state',
|
|
'startingQuantity',
|
|
'currentQuantity',
|
|
'stockLocation',
|
|
'createdAt',
|
|
'updatedAt',
|
|
'_reference'
|
|
],
|
|
sorters: [
|
|
'part',
|
|
'partSku',
|
|
'startingQuantity',
|
|
'currentQuantity',
|
|
'state',
|
|
'createdAt',
|
|
'updatedAt'
|
|
],
|
|
columns: [
|
|
'_reference',
|
|
'state',
|
|
'startingQuantity',
|
|
'currentQuantity',
|
|
'part',
|
|
'partSku',
|
|
'stockLocation',
|
|
'createdAt',
|
|
'updatedAt'
|
|
],
|
|
properties: [
|
|
{
|
|
name: '_id',
|
|
label: 'ID',
|
|
type: 'id',
|
|
objectType: 'partStock',
|
|
showCopy: true,
|
|
readOnly: true,
|
|
columnWidth: 140
|
|
},
|
|
{
|
|
name: 'createdAt',
|
|
label: 'Created At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: '_reference',
|
|
label: 'Reference',
|
|
type: 'reference',
|
|
columnFixed: 'left',
|
|
objectType: 'partStock',
|
|
showCopy: true,
|
|
readOnly: true,
|
|
columnWidth: 180
|
|
},
|
|
{
|
|
name: 'state',
|
|
label: 'State',
|
|
type: 'state',
|
|
readOnly: true,
|
|
columnWidth: 260
|
|
},
|
|
{
|
|
name: 'updatedAt',
|
|
label: 'Updated At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'sourceType',
|
|
label: 'Source Type',
|
|
type: 'objectType',
|
|
readOnly: false,
|
|
columnWidth: 200,
|
|
required: true,
|
|
masterFilter: ['subJob', 'stockTransfer']
|
|
},
|
|
{
|
|
name: 'part',
|
|
label: 'Part',
|
|
type: 'object',
|
|
objectType: 'part',
|
|
required: true,
|
|
showHyperlink: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'partSku',
|
|
label: 'Part SKU',
|
|
type: 'object',
|
|
objectType: 'partSku',
|
|
required: true,
|
|
showHyperlink: true,
|
|
columnWidth: 200,
|
|
masterFilter: (objectData) => {
|
|
return { part: objectData?.part?._id }
|
|
}
|
|
},
|
|
{
|
|
name: 'stockLocation',
|
|
label: 'Stock location',
|
|
type: 'object',
|
|
objectType: 'stockLocation',
|
|
required: false,
|
|
showHyperlink: true,
|
|
columnWidth: 200
|
|
},
|
|
|
|
{
|
|
name: 'source',
|
|
label: 'Source',
|
|
type: 'object',
|
|
readOnly: false,
|
|
required: true,
|
|
columnWidth: 200,
|
|
objectType: (objectData) => {
|
|
return objectData?.sourceType
|
|
},
|
|
showHyperlink: true
|
|
},
|
|
{
|
|
name: 'currentQuantity',
|
|
label: 'Current Quantity',
|
|
type: 'number',
|
|
readOnly: true,
|
|
columnWidth: 200,
|
|
required: true,
|
|
value: (objectData) => {
|
|
if (objectData?.state?.type === 'new') {
|
|
return objectData?.startingQuantity
|
|
} else {
|
|
return objectData.currentQuantity
|
|
}
|
|
}
|
|
}
|
|
],
|
|
stats: [
|
|
{
|
|
name: 'new.count',
|
|
label: 'New',
|
|
type: 'number',
|
|
color: 'success',
|
|
history: false
|
|
},
|
|
{
|
|
name: 'used.count',
|
|
label: 'Used',
|
|
type: 'number',
|
|
color: 'warning',
|
|
history: false
|
|
},
|
|
{
|
|
name: 'consumed.count',
|
|
label: 'Consumed',
|
|
type: 'number',
|
|
color: 'default',
|
|
history: false
|
|
},
|
|
{
|
|
name: 'totalCurrentQuantity.sum',
|
|
label: 'Total Current Quantity',
|
|
type: 'number',
|
|
roundNumber: 2,
|
|
cardWidth: 200
|
|
}
|
|
]
|
|
}
|