- 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.
329 lines
7.4 KiB
JavaScript
329 lines
7.4 KiB
JavaScript
import PaymentIcon from '../../components/Icons/PaymentIcon'
|
|
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
|
|
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 Payment = {
|
|
name: 'payment',
|
|
label: 'Payment',
|
|
labelPlural: 'Payments',
|
|
url: '/dashboard/finance/payments',
|
|
prefix: 'PAY',
|
|
icon: PaymentIcon,
|
|
actions: [
|
|
{
|
|
name: 'info',
|
|
label: 'Info',
|
|
default: true,
|
|
row: true,
|
|
icon: InfoCircleIcon,
|
|
url: (_id) => `/dashboard/finance/payments/info?paymentId=${_id}`
|
|
},
|
|
{
|
|
name: 'edit',
|
|
label: 'Edit',
|
|
type: 'button',
|
|
icon: EditIcon,
|
|
url: (_id) =>
|
|
`/dashboard/finance/payments/info?paymentId=${_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/finance/payments/info?paymentId=${_id}&action=cancelEdit`,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{
|
|
name: 'finishEdit',
|
|
label: 'Finish Edit',
|
|
type: 'button',
|
|
icon: CheckIcon,
|
|
url: (_id) =>
|
|
`/dashboard/finance/payments/info?paymentId=${_id}&action=finishEdit`,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{
|
|
name: 'delete',
|
|
label: 'Delete',
|
|
type: 'button',
|
|
icon: BinIcon,
|
|
danger: true,
|
|
url: (_id) =>
|
|
`/dashboard/finance/payments/info?paymentId=${_id}&action=delete`,
|
|
visible: (objectData) => {
|
|
return !(objectData?._isEditing && objectData?._isEditing == true)
|
|
},
|
|
disabled: (objectData) => {
|
|
return objectData?.state?.type != 'draft'
|
|
}
|
|
},
|
|
{ type: 'divider' },
|
|
{
|
|
name: 'post',
|
|
label: 'Post',
|
|
type: 'button',
|
|
icon: CheckIcon,
|
|
url: (_id) =>
|
|
`/dashboard/finance/payments/info?paymentId=${_id}&action=post`,
|
|
visible: (objectData) => {
|
|
return objectData?.state?.type == 'draft'
|
|
}
|
|
},
|
|
{
|
|
name: 'authorise',
|
|
label: 'Authorise',
|
|
type: 'button',
|
|
icon: CheckIcon,
|
|
url: (_id) =>
|
|
`/dashboard/finance/payments/info?paymentId=${_id}&action=authorise`,
|
|
disabled: (objectData) => {
|
|
return objectData?.state?.type != 'posted'
|
|
},
|
|
visible: (objectData) => {
|
|
return objectData?.state?.type == 'posted'
|
|
}
|
|
},
|
|
{
|
|
name: 'decline',
|
|
label: 'Decline',
|
|
type: 'button',
|
|
icon: XMarkIcon,
|
|
danger: true,
|
|
url: (_id) =>
|
|
`/dashboard/finance/payments/info?paymentId=${_id}&action=decline`,
|
|
disabled: (objectData) => {
|
|
return objectData?.state?.type != 'posted'
|
|
},
|
|
visible: (objectData) => {
|
|
return objectData?.state?.type == 'posted'
|
|
}
|
|
},
|
|
{
|
|
name: 'cancel',
|
|
label: 'Cancel',
|
|
type: 'button',
|
|
icon: XMarkIcon,
|
|
danger: true,
|
|
url: (_id) =>
|
|
`/dashboard/finance/payments/info?paymentId=${_id}&action=cancel`,
|
|
disabled: (objectData) => {
|
|
return objectData?.state?.type != 'posted'
|
|
},
|
|
visible: (objectData) => {
|
|
return objectData?.state?.type == 'posted'
|
|
}
|
|
}
|
|
],
|
|
group: ['vendor', 'client', 'invoice'],
|
|
filters: [
|
|
'vendor',
|
|
'client',
|
|
'state',
|
|
'vendor._id',
|
|
'client._id',
|
|
'invoice',
|
|
'invoice._id',
|
|
'createdAt',
|
|
'updatedAt',
|
|
'_reference'
|
|
],
|
|
sorters: ['createdAt', 'state', 'updatedAt', 'paymentDate'],
|
|
columns: [
|
|
'_reference',
|
|
'state',
|
|
'invoice',
|
|
'vendor',
|
|
'client',
|
|
'paymentDate',
|
|
'amount',
|
|
'paymentMethod',
|
|
'createdAt',
|
|
'updatedAt'
|
|
],
|
|
properties: [
|
|
{
|
|
name: '_id',
|
|
label: 'ID',
|
|
type: 'id',
|
|
columnFixed: 'left',
|
|
objectType: 'payment',
|
|
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: 'payment',
|
|
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: 'invoice',
|
|
label: 'Invoice',
|
|
type: 'object',
|
|
objectType: 'invoice',
|
|
required: true,
|
|
showHyperlink: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'authorisedAt',
|
|
label: 'Authorised At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'payTo',
|
|
label: 'Pay To',
|
|
type: 'object',
|
|
objectType: 'vendor',
|
|
showHyperlink: true,
|
|
required: true,
|
|
readOnly: true,
|
|
columnWidth: 200,
|
|
disabled: (objectData) => {
|
|
return objectData?.invoice?.orderType == 'purchaseOrder'
|
|
},
|
|
value: (objectData) => {
|
|
return objectData?.invoice?.from
|
|
}
|
|
},
|
|
{
|
|
name: 'declinedAt',
|
|
label: 'Declined At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'amount',
|
|
label: 'Amount',
|
|
type: 'number',
|
|
prefix: '£',
|
|
roundNumber: 2,
|
|
required: true,
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'cancelledAt',
|
|
label: 'Cancelled At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'paymentMethod',
|
|
label: 'Payment Method',
|
|
type: 'string',
|
|
required: false,
|
|
columnWidth: 150
|
|
}
|
|
],
|
|
stats: [
|
|
{
|
|
name: 'draft.draftCount.count',
|
|
label: 'Draft',
|
|
type: 'number',
|
|
color: 'default'
|
|
},
|
|
{
|
|
name: 'draft.draftAmount.sum',
|
|
label: 'Draft Amount',
|
|
type: 'number',
|
|
prefix: '£',
|
|
roundNumber: 2,
|
|
color: 'default'
|
|
},
|
|
{
|
|
name: 'posted.postedCount.count',
|
|
label: 'Posted',
|
|
type: 'number',
|
|
color: 'cyan'
|
|
},
|
|
{
|
|
name: 'posted.postedAmount.sum',
|
|
label: 'Posted Amount',
|
|
type: 'number',
|
|
prefix: '£',
|
|
roundNumber: 2,
|
|
color: 'cyan'
|
|
},
|
|
{
|
|
name: 'authorised.authorisedCount.count',
|
|
label: 'Authorised',
|
|
type: 'number',
|
|
color: 'green'
|
|
},
|
|
{
|
|
name: 'authorised.authorisedAmount.sum',
|
|
label: 'Authorised Amount',
|
|
type: 'number',
|
|
prefix: '£',
|
|
roundNumber: 2,
|
|
color: 'green'
|
|
},
|
|
{
|
|
name: 'declined.declinedCount.count',
|
|
label: 'Declined',
|
|
type: 'number',
|
|
color: 'red'
|
|
},
|
|
{
|
|
name: 'declined.declinedAmount.sum',
|
|
label: 'Declined Amount',
|
|
type: 'number',
|
|
prefix: '£',
|
|
roundNumber: 2,
|
|
color: 'red'
|
|
}
|
|
]
|
|
}
|