- Updated filters in multiple models such as AppPassword, AuditLog, Client, Courier, and others to include '_reference' and other relevant fields like 'createdAt' and 'updatedAt'. - This change improves data handling and consistency across the application, ensuring that all necessary fields are available for filtering.
389 lines
9.0 KiB
JavaScript
389 lines
9.0 KiB
JavaScript
import PurchaseOrderIcon from '../../components/Icons/PurchaseOrderIcon'
|
|
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 PurchaseOrder = {
|
|
name: 'purchaseOrder',
|
|
label: 'Purchase Order',
|
|
labelPlural: 'Purchase Orders',
|
|
url: '/dashboard/inventory/purchaseorders',
|
|
prefix: 'POR',
|
|
icon: PurchaseOrderIcon,
|
|
actions: [
|
|
{
|
|
name: 'info',
|
|
label: 'Info',
|
|
default: true,
|
|
row: true,
|
|
icon: InfoCircleIcon,
|
|
url: (_id) =>
|
|
`/dashboard/inventory/purchaseorders/info?purchaseOrderId=${_id}`
|
|
},
|
|
{
|
|
name: 'edit',
|
|
label: 'Edit',
|
|
type: 'button',
|
|
icon: EditIcon,
|
|
url: (_id) =>
|
|
`/dashboard/inventory/purchaseorders/info?purchaseOrderId=${_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/inventory/purchaseorders/info?purchaseOrderId=${_id}&action=cancelEdit`,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{
|
|
name: 'finishEdit',
|
|
label: 'Finish Edit',
|
|
type: 'button',
|
|
icon: CheckIcon,
|
|
url: (_id) =>
|
|
`/dashboard/inventory/purchaseorders/info?purchaseOrderId=${_id}&action=finishEdit`,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{
|
|
name: 'delete',
|
|
label: 'Delete',
|
|
type: 'button',
|
|
icon: BinIcon,
|
|
danger: true,
|
|
url: (_id) =>
|
|
`/dashboard/inventory/purchaseorders/info?purchaseOrderId=${_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/inventory/purchaseorders/info?purchaseOrderId=${_id}&action=newOrderItem`,
|
|
disabled: (objectData) => {
|
|
return objectData?.state?.type != 'draft'
|
|
}
|
|
},
|
|
{
|
|
name: 'New Shipment',
|
|
label: 'New Shipment',
|
|
type: 'button',
|
|
icon: PlusIcon,
|
|
url: (_id) =>
|
|
`/dashboard/inventory/purchaseorders/info?purchaseOrderId=${_id}&action=newShipment`,
|
|
disabled: (objectData) => {
|
|
return objectData?.state?.type != 'draft'
|
|
}
|
|
},
|
|
{
|
|
name: 'New Invoice',
|
|
label: 'New Invoice',
|
|
type: 'button',
|
|
icon: PlusIcon,
|
|
url: (_id) =>
|
|
`/dashboard/inventory/purchaseorders/info?purchaseOrderId=${_id}&action=newInvoice`,
|
|
disabled: (objectData) => {
|
|
const allowedStates = [
|
|
'received',
|
|
'shipped',
|
|
'partiallyReceived',
|
|
'partiallyShipped'
|
|
]
|
|
return !allowedStates.includes(objectData?.state?.type)
|
|
}
|
|
},
|
|
{
|
|
type: 'divider'
|
|
},
|
|
{
|
|
name: 'post',
|
|
label: 'Post',
|
|
type: 'button',
|
|
icon: CheckIcon,
|
|
url: (_id) =>
|
|
`/dashboard/inventory/purchaseorders/info?purchaseOrderId=${_id}&action=post`,
|
|
visible: (objectData) => {
|
|
return objectData?.state?.type == 'draft'
|
|
}
|
|
},
|
|
{
|
|
name: 'acknowledge',
|
|
label: 'Acknowledge',
|
|
type: 'button',
|
|
icon: CheckIcon,
|
|
url: (_id) =>
|
|
`/dashboard/inventory/purchaseorders/info?purchaseOrderId=${_id}&action=acknowledge`,
|
|
visible: (objectData) => {
|
|
return objectData?.state?.type == 'sent'
|
|
}
|
|
},
|
|
{
|
|
name: 'complete',
|
|
label: 'Complete',
|
|
type: 'button',
|
|
icon: CheckIcon,
|
|
url: (_id) =>
|
|
`/dashboard/inventory/shipments/info?shipmentId=${_id}&action=complete`,
|
|
disabled: (objectData) => {
|
|
return objectData?.state?.type != 'received'
|
|
},
|
|
visible: (objectData) => {
|
|
return objectData?.state?.type == 'received'
|
|
}
|
|
},
|
|
{
|
|
name: 'cancel',
|
|
label: 'Cancel',
|
|
type: 'button',
|
|
icon: XMarkIcon,
|
|
danger: true,
|
|
url: (_id) =>
|
|
`/dashboard/inventory/purchaseorders/info?purchaseOrderId=${_id}&action=cancel`,
|
|
disabled: (objectData) => {
|
|
return objectData?.state?.type == 'cancelled'
|
|
},
|
|
visible: (objectData) => {
|
|
return (
|
|
objectData?.state?.type != 'draft' &&
|
|
objectData?.state?.type != 'completed' &&
|
|
objectData?.state?.type != 'received'
|
|
)
|
|
}
|
|
}
|
|
],
|
|
group: ['vendor'],
|
|
filters: [
|
|
'vendor',
|
|
'state',
|
|
'value',
|
|
'vendor._id',
|
|
'totalAmount',
|
|
'totalAmountWithTax',
|
|
'totalTaxAmount',
|
|
'shippingAmount',
|
|
'shippingAmountWithTax',
|
|
'grandTotalAmount',
|
|
'createdAt',
|
|
'updatedAt',
|
|
'_reference'
|
|
],
|
|
sorters: [
|
|
'createdAt',
|
|
'state',
|
|
'updatedAt',
|
|
'totalAmount',
|
|
'totalAmountWithTax',
|
|
'totalTaxAmount',
|
|
'shippingAmount',
|
|
'shippingAmountWithTax',
|
|
'grandTotalAmount'
|
|
],
|
|
columns: [
|
|
'_reference',
|
|
'state',
|
|
'vendor',
|
|
'totalAmount',
|
|
'totalAmountWithTax',
|
|
'totalTaxAmount',
|
|
'shippingAmount',
|
|
'shippingAmountWithTax',
|
|
'grandTotalAmount',
|
|
'createdAt',
|
|
'updatedAt',
|
|
'vendor'
|
|
],
|
|
properties: [
|
|
{
|
|
name: '_id',
|
|
label: 'ID',
|
|
type: 'id',
|
|
columnFixed: 'left',
|
|
objectType: 'purchaseOrder',
|
|
columnWidth: 140,
|
|
showCopy: true
|
|
},
|
|
{
|
|
name: 'createdAt',
|
|
label: 'Created At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: '_reference',
|
|
label: 'Reference',
|
|
type: 'reference',
|
|
columnFixed: 'left',
|
|
required: true,
|
|
objectType: 'purchaseOrder',
|
|
showCopy: true,
|
|
readOnly: true,
|
|
columnWidth: 180
|
|
},
|
|
{
|
|
name: 'updatedAt',
|
|
label: 'Updated At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'state',
|
|
label: 'State',
|
|
type: 'state',
|
|
readOnly: true,
|
|
columnWidth: 260
|
|
},
|
|
{
|
|
name: 'postedAt',
|
|
label: 'Posted At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'vendor',
|
|
label: 'Vendor',
|
|
required: true,
|
|
type: 'object',
|
|
objectType: 'vendor',
|
|
showHyperlink: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'acknowledgedAt',
|
|
label: 'Acknowledged At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'totalTaxAmount',
|
|
label: 'Total Tax Amount',
|
|
type: 'number',
|
|
prefix: '£',
|
|
roundNumber: 2,
|
|
readOnly: true,
|
|
columnWidth: 185
|
|
},
|
|
{
|
|
name: 'completedAt',
|
|
label: 'Completed At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'totalAmountWithTax',
|
|
label: 'Total Amount w/ Tax',
|
|
type: 'number',
|
|
prefix: '£',
|
|
readOnly: true,
|
|
columnWidth: 215,
|
|
roundNumber: 2
|
|
},
|
|
{
|
|
name: 'shippingAmount',
|
|
label: 'Shipping Amount',
|
|
type: 'number',
|
|
prefix: '£',
|
|
roundNumber: 2,
|
|
readOnly: true,
|
|
columnWidth: 190
|
|
},
|
|
{
|
|
name: 'shippingAmountWithTax',
|
|
label: 'Shipping Amount w/ Tax',
|
|
type: 'number',
|
|
prefix: '£',
|
|
readOnly: true,
|
|
roundNumber: 2,
|
|
columnWidth: 240
|
|
},
|
|
{
|
|
name: 'totalAmount',
|
|
label: 'Total Amount',
|
|
type: 'number',
|
|
prefix: '£',
|
|
roundNumber: 2,
|
|
readOnly: true,
|
|
columnWidth: 170
|
|
},
|
|
{
|
|
name: 'grandTotalAmount',
|
|
label: 'Grand Total Amount',
|
|
type: 'number',
|
|
prefix: '£',
|
|
roundNumber: 2,
|
|
columnWidth: 215,
|
|
readOnly: true
|
|
}
|
|
],
|
|
stats: [
|
|
{
|
|
name: 'draft.count',
|
|
label: 'Draft',
|
|
type: 'number',
|
|
color: 'default'
|
|
},
|
|
{
|
|
name: 'sent.count',
|
|
label: 'Sent',
|
|
type: 'number',
|
|
color: 'cyan'
|
|
},
|
|
{
|
|
name: 'acknowledged.count',
|
|
label: 'Acknowledged',
|
|
type: 'number',
|
|
color: 'purple'
|
|
},
|
|
{
|
|
name: 'partiallyShipped.count',
|
|
label: 'Partially Shipped',
|
|
type: 'number',
|
|
color: 'processing'
|
|
},
|
|
{
|
|
name: 'shipped.count',
|
|
label: 'Shipped',
|
|
type: 'number',
|
|
color: 'processing'
|
|
},
|
|
{
|
|
name: 'partiallyReceived.count',
|
|
label: 'Partially Received',
|
|
type: 'number',
|
|
color: 'success'
|
|
},
|
|
{
|
|
name: 'received.count',
|
|
label: 'Received',
|
|
type: 'number',
|
|
color: 'success'
|
|
}
|
|
]
|
|
}
|