- Updated multiple models to change the column identifier from '_id' to '_reference' for consistency across the database schema. - Adjusted relevant filters and properties to align with the new column naming convention.
338 lines
8.0 KiB
JavaScript
338 lines
8.0 KiB
JavaScript
import SalesOrderIcon from '../../components/Icons/SalesOrderIcon'
|
|
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
|
|
import PlusIcon from '../../components/Icons/PlusIcon'
|
|
import CheckIcon from '../../components/Icons/CheckIcon'
|
|
import EditIcon from '../../components/Icons/EditIcon'
|
|
import XMarkIcon from '../../components/Icons/XMarkIcon'
|
|
import BinIcon from '../../components/Icons/BinIcon'
|
|
|
|
export const SalesOrder = {
|
|
name: 'salesOrder',
|
|
label: 'Sales Order',
|
|
prefix: 'SOR',
|
|
icon: SalesOrderIcon,
|
|
actions: [
|
|
{
|
|
name: 'info',
|
|
label: 'Info',
|
|
default: true,
|
|
row: true,
|
|
icon: InfoCircleIcon,
|
|
url: (_id) => `/dashboard/sales/salesorders/info?salesOrderId=${_id}`
|
|
},
|
|
{
|
|
name: 'edit',
|
|
label: 'Edit',
|
|
type: 'button',
|
|
icon: EditIcon,
|
|
url: (_id) =>
|
|
`/dashboard/sales/salesorders/info?salesOrderId=${_id}&action=edit`,
|
|
visible: (objectData) => {
|
|
return !(objectData?._isEditing && objectData?._isEditing == true)
|
|
},
|
|
disabled: (objectData) => {
|
|
return objectData?.state?.type != 'draft'
|
|
}
|
|
},
|
|
{
|
|
name: 'cancelEdit',
|
|
label: 'Cancel Edit',
|
|
type: 'button',
|
|
icon: XMarkIcon,
|
|
url: (_id) =>
|
|
`/dashboard/sales/salesorders/info?salesOrderId=${_id}&action=cancelEdit`,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{
|
|
name: 'finishEdit',
|
|
label: 'Finish Edit',
|
|
type: 'button',
|
|
icon: CheckIcon,
|
|
url: (_id) =>
|
|
`/dashboard/sales/salesorders/info?salesOrderId=${_id}&action=finishEdit`,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{
|
|
name: 'delete',
|
|
label: 'Delete',
|
|
type: 'button',
|
|
icon: BinIcon,
|
|
danger: true,
|
|
url: (_id) =>
|
|
`/dashboard/sales/salesorders/info?salesOrderId=${_id}&action=delete`,
|
|
visible: (objectData) => {
|
|
return !(objectData?._isEditing && objectData?._isEditing == true)
|
|
},
|
|
disabled: (objectData) => {
|
|
return objectData?.state?.type != 'draft'
|
|
}
|
|
},
|
|
{ type: 'divider' },
|
|
{
|
|
name: 'New Order Item',
|
|
label: 'New Order Item',
|
|
type: 'button',
|
|
icon: PlusIcon,
|
|
url: (_id) =>
|
|
`/dashboard/sales/salesorders/info?salesOrderId=${_id}&action=newOrderItem`,
|
|
disabled: (objectData) => {
|
|
return objectData?.state?.type != 'draft'
|
|
}
|
|
},
|
|
{
|
|
name: 'New Shipment',
|
|
label: 'New Shipment',
|
|
type: 'button',
|
|
icon: PlusIcon,
|
|
url: (_id) =>
|
|
`/dashboard/sales/salesorders/info?salesOrderId=${_id}&action=newShipment`,
|
|
disabled: (objectData) => {
|
|
return objectData?.state?.type != 'draft'
|
|
}
|
|
},
|
|
{
|
|
name: 'New Invoice',
|
|
label: 'New Invoice',
|
|
type: 'button',
|
|
icon: PlusIcon,
|
|
url: (_id) =>
|
|
`/dashboard/sales/salesorders/info?salesOrderId=${_id}&action=newInvoice`,
|
|
disabled: (objectData) => {
|
|
return objectData?.state?.type != 'delivered'
|
|
}
|
|
},
|
|
{
|
|
type: 'divider'
|
|
},
|
|
{
|
|
name: 'post',
|
|
label: 'Post',
|
|
type: 'button',
|
|
icon: CheckIcon,
|
|
url: (_id) =>
|
|
`/dashboard/sales/salesorders/info?salesOrderId=${_id}&action=post`,
|
|
visible: (objectData) => {
|
|
return objectData?.state?.type == 'draft'
|
|
}
|
|
},
|
|
{
|
|
name: 'confirm',
|
|
label: 'Confirm',
|
|
type: 'button',
|
|
icon: CheckIcon,
|
|
url: (_id) =>
|
|
`/dashboard/sales/salesorders/info?salesOrderId=${_id}&action=confirm`,
|
|
visible: (objectData) => {
|
|
return objectData?.state?.type == 'sent'
|
|
}
|
|
},
|
|
{
|
|
name: 'complete',
|
|
label: 'Complete',
|
|
type: 'button',
|
|
icon: CheckIcon,
|
|
url: (_id) =>
|
|
`/dashboard/sales/salesorders/info?salesOrderId=${_id}&action=complete`,
|
|
disabled: (objectData) => {
|
|
return objectData?.state?.type != 'delivered'
|
|
},
|
|
visible: (objectData) => {
|
|
return objectData?.state?.type == 'delivered'
|
|
}
|
|
},
|
|
{
|
|
name: 'cancel',
|
|
label: 'Cancel',
|
|
type: 'button',
|
|
icon: XMarkIcon,
|
|
danger: true,
|
|
url: (_id) =>
|
|
`/dashboard/sales/salesorders/info?salesOrderId=${_id}&action=cancel`,
|
|
disabled: (objectData) => {
|
|
return objectData?.state?.type == 'cancelled'
|
|
},
|
|
visible: (objectData) => {
|
|
return (
|
|
objectData?.state?.type != 'draft' &&
|
|
objectData?.state?.type != 'completed' &&
|
|
objectData?.state?.type != 'delivered'
|
|
)
|
|
}
|
|
}
|
|
],
|
|
group: ['client'],
|
|
filters: ['client'],
|
|
sorters: ['createdAt', 'state', 'updatedAt'],
|
|
columns: [
|
|
'_reference',
|
|
'state',
|
|
'client',
|
|
'totalAmount',
|
|
'totalAmountWithTax',
|
|
'totalTaxAmount',
|
|
'shippingAmount',
|
|
'shippingAmountWithTax',
|
|
'grandTotalAmount',
|
|
'createdAt',
|
|
'updatedAt',
|
|
'client'
|
|
],
|
|
properties: [
|
|
{
|
|
name: '_id',
|
|
label: 'ID',
|
|
type: 'id',
|
|
columnFixed: 'left',
|
|
objectType: 'salesOrder',
|
|
columnWidth: 140,
|
|
showCopy: true
|
|
},
|
|
{
|
|
name: 'createdAt',
|
|
label: 'Created At',
|
|
type: 'dateTime',
|
|
readOnly: true
|
|
},
|
|
{
|
|
name: '_reference',
|
|
label: 'Reference',
|
|
type: 'reference',
|
|
columnFixed: 'left',
|
|
required: true,
|
|
objectType: 'salesOrder',
|
|
showCopy: true,
|
|
readOnly: true
|
|
},
|
|
{
|
|
name: 'updatedAt',
|
|
label: 'Updated At',
|
|
type: 'dateTime',
|
|
readOnly: true
|
|
},
|
|
{ name: 'state', label: 'State', type: 'state', readOnly: true },
|
|
{ name: 'postedAt', label: 'Posted At', type: 'dateTime', readOnly: true },
|
|
{
|
|
name: 'client',
|
|
label: 'Client',
|
|
required: true,
|
|
type: 'object',
|
|
objectType: 'client',
|
|
showHyperlink: true
|
|
},
|
|
{
|
|
name: 'confirmedAt',
|
|
label: 'Confirmed At',
|
|
type: 'dateTime',
|
|
readOnly: true
|
|
},
|
|
{
|
|
name: 'totalTaxAmount',
|
|
label: 'Total Tax Amount',
|
|
type: 'number',
|
|
prefix: '£',
|
|
roundNumber: 2,
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'completedAt',
|
|
label: 'Completed At',
|
|
type: 'dateTime',
|
|
readOnly: true
|
|
},
|
|
{
|
|
name: 'totalAmountWithTax',
|
|
label: 'Total Amount w/ Tax',
|
|
type: 'number',
|
|
prefix: '£',
|
|
readOnly: true,
|
|
columnWidth: 175,
|
|
roundNumber: 2
|
|
},
|
|
{
|
|
name: 'shippingAmount',
|
|
label: 'Shipping Amount',
|
|
type: 'number',
|
|
prefix: '£',
|
|
roundNumber: 2,
|
|
readOnly: true,
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'shippingAmountWithTax',
|
|
label: 'Shipping Amount w/ Tax',
|
|
type: 'number',
|
|
prefix: '£',
|
|
readOnly: true,
|
|
roundNumber: 2,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'totalAmount',
|
|
label: 'Total Amount',
|
|
type: 'number',
|
|
prefix: '£',
|
|
roundNumber: 2,
|
|
readOnly: true,
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'grandTotalAmount',
|
|
label: 'Grand Total Amount',
|
|
type: 'number',
|
|
prefix: '£',
|
|
roundNumber: 2,
|
|
columnWidth: 175,
|
|
readOnly: true
|
|
}
|
|
],
|
|
stats: [
|
|
{
|
|
name: 'draft.count',
|
|
label: 'Draft',
|
|
type: 'number',
|
|
color: 'default'
|
|
},
|
|
{
|
|
name: 'sent.count',
|
|
label: 'Sent',
|
|
type: 'number',
|
|
color: 'cyan'
|
|
},
|
|
{
|
|
name: 'confirmed.count',
|
|
label: 'Confirmed',
|
|
type: 'number',
|
|
color: 'purple'
|
|
},
|
|
{
|
|
name: 'partiallyShipped.count',
|
|
label: 'Partially Shipped',
|
|
type: 'number',
|
|
color: 'processing'
|
|
},
|
|
{
|
|
name: 'shipped.count',
|
|
label: 'Shipped',
|
|
type: 'number',
|
|
color: 'processing'
|
|
},
|
|
{
|
|
name: 'partiallyDelivered.count',
|
|
label: 'Partially Delivered',
|
|
type: 'number',
|
|
color: 'success'
|
|
},
|
|
{
|
|
name: 'delivered.count',
|
|
label: 'Delivered',
|
|
type: 'number',
|
|
color: 'success'
|
|
}
|
|
]
|
|
}
|