Enhance Invoice Model with New Payment and Acknowledgment Features
- Added a "New Payment" button to the Invoice model, allowing users to initiate payments based on invoice state. - Introduced an "Acknowledge" button for invoices in the "sent" state, enabling acknowledgment actions. - Updated the invoice grouping and filtering criteria to include "orderType" and "to/from" fields. - Adjusted column definitions to improve layout and visibility of new fields, including "acknowledgedAt" and "paidAt". - Enhanced the invoice summary calculations to include acknowledged counts and totals.
This commit is contained in:
parent
d52b89de43
commit
b2b1cd4fe0
@ -4,6 +4,7 @@ import CheckIcon from '../../components/Icons/CheckIcon'
|
|||||||
import EditIcon from '../../components/Icons/EditIcon'
|
import EditIcon from '../../components/Icons/EditIcon'
|
||||||
import XMarkIcon from '../../components/Icons/XMarkIcon'
|
import XMarkIcon from '../../components/Icons/XMarkIcon'
|
||||||
import BinIcon from '../../components/Icons/BinIcon'
|
import BinIcon from '../../components/Icons/BinIcon'
|
||||||
|
import PlusIcon from '../../components/Icons/PlusIcon'
|
||||||
|
|
||||||
export const Invoice = {
|
export const Invoice = {
|
||||||
name: 'invoice',
|
name: 'invoice',
|
||||||
@ -71,6 +72,19 @@ export const Invoice = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ type: 'divider' },
|
{ type: 'divider' },
|
||||||
|
{
|
||||||
|
name: 'newPayment',
|
||||||
|
label: 'New Payment',
|
||||||
|
type: 'button',
|
||||||
|
icon: PlusIcon,
|
||||||
|
url: (_id) =>
|
||||||
|
`/dashboard/finance/invoices/info?invoiceId=${_id}&action=newPayment`,
|
||||||
|
disabled: (objectData) => {
|
||||||
|
const allowedStates = ['acknowledged', 'partiallyPaid', 'overdue']
|
||||||
|
return !allowedStates.includes(objectData?.state?.type)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ type: 'divider' },
|
||||||
{
|
{
|
||||||
name: 'post',
|
name: 'post',
|
||||||
label: 'Post',
|
label: 'Post',
|
||||||
@ -82,6 +96,17 @@ export const Invoice = {
|
|||||||
return objectData?.state?.type == 'draft'
|
return objectData?.state?.type == 'draft'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'acknowledge',
|
||||||
|
label: 'Acknowledge',
|
||||||
|
type: 'button',
|
||||||
|
icon: CheckIcon,
|
||||||
|
url: (_id) =>
|
||||||
|
`/dashboard/finance/invoices/info?invoiceId=${_id}&action=acknowledge`,
|
||||||
|
visible: (objectData) => {
|
||||||
|
return objectData?.state?.type == 'sent'
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'cancel',
|
name: 'cancel',
|
||||||
label: 'Cancel',
|
label: 'Cancel',
|
||||||
@ -91,25 +116,28 @@ export const Invoice = {
|
|||||||
url: (_id) =>
|
url: (_id) =>
|
||||||
`/dashboard/finance/invoices/info?invoiceId=${_id}&action=cancel`,
|
`/dashboard/finance/invoices/info?invoiceId=${_id}&action=cancel`,
|
||||||
disabled: (objectData) => {
|
disabled: (objectData) => {
|
||||||
return (
|
const allowedStates = [
|
||||||
objectData?.state?.type == 'cancelled' ||
|
'acknowledged',
|
||||||
objectData?.state?.type == 'paid'
|
'partiallyPaid',
|
||||||
)
|
'overdue',
|
||||||
|
'sent'
|
||||||
|
]
|
||||||
|
return !allowedStates.includes(objectData?.state?.type)
|
||||||
},
|
},
|
||||||
visible: (objectData) => {
|
visible: (objectData) => {
|
||||||
return objectData?.state?.type == 'sent'
|
return objectData?.state?.type != 'draft'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
group: ['vendor', 'client', 'invoiceType'],
|
group: ['orderType'],
|
||||||
filters: ['vendor', 'client', 'invoiceType'],
|
filters: ['to', 'from', 'orderType'],
|
||||||
sorters: ['createdAt', 'state', 'updatedAt', 'invoiceDate', 'dueDate'],
|
sorters: ['createdAt', 'state', 'updatedAt', 'invoiceDate', 'dueDate'],
|
||||||
columns: [
|
columns: [
|
||||||
'_reference',
|
'_reference',
|
||||||
'state',
|
'state',
|
||||||
'invoiceType',
|
'orderType',
|
||||||
'vendor',
|
'to',
|
||||||
'client',
|
'from',
|
||||||
'invoiceDate',
|
'invoiceDate',
|
||||||
'dueDate',
|
'dueDate',
|
||||||
'totalAmount',
|
'totalAmount',
|
||||||
@ -206,12 +234,14 @@ export const Invoice = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'paidAt',
|
name: 'acknowledgedAt',
|
||||||
label: 'Paid At',
|
label: 'Acknowledged At',
|
||||||
type: 'dateTime',
|
type: 'dateTime',
|
||||||
readOnly: true
|
readOnly: true
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'to',
|
name: 'to',
|
||||||
label: 'To',
|
label: 'To',
|
||||||
@ -244,6 +274,12 @@ export const Invoice = {
|
|||||||
readOnly: true,
|
readOnly: true,
|
||||||
columnWidth: 175
|
columnWidth: 175
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'paidAt',
|
||||||
|
label: 'Paid At',
|
||||||
|
type: 'dateTime',
|
||||||
|
readOnly: true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'totalAmountWithTax',
|
name: 'totalAmountWithTax',
|
||||||
label: 'Total Amount w/ Tax',
|
label: 'Total Amount w/ Tax',
|
||||||
@ -301,13 +337,15 @@ export const Invoice = {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
objectType: 'orderItem',
|
objectType: 'orderItem',
|
||||||
required: true,
|
required: true,
|
||||||
|
columnWidth: 300,
|
||||||
showHyperlink: true
|
showHyperlink: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'invoiceQuantity',
|
name: 'invoiceQuantity',
|
||||||
label: 'Quantity',
|
label: 'Quantity',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
required: true
|
required: true,
|
||||||
|
columnWidth: 175
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'invoiceAmount',
|
name: 'invoiceAmount',
|
||||||
@ -315,7 +353,8 @@ export const Invoice = {
|
|||||||
type: 'number',
|
type: 'number',
|
||||||
prefix: '£',
|
prefix: '£',
|
||||||
roundNumber: 2,
|
roundNumber: 2,
|
||||||
required: true
|
required: true,
|
||||||
|
columnWidth: 150
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'taxRate',
|
name: 'taxRate',
|
||||||
@ -323,7 +362,8 @@ export const Invoice = {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
objectType: 'taxRate',
|
objectType: 'taxRate',
|
||||||
required: false,
|
required: false,
|
||||||
showHyperlink: true
|
showHyperlink: true,
|
||||||
|
columnWidth: 200
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'invoiceAmountWithTax',
|
name: 'invoiceAmountWithTax',
|
||||||
@ -333,6 +373,7 @@ export const Invoice = {
|
|||||||
roundNumber: 2,
|
roundNumber: 2,
|
||||||
required: true,
|
required: true,
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
|
columnWidth: 200,
|
||||||
value: (objectData) => {
|
value: (objectData) => {
|
||||||
const invoiceAmount = objectData?.invoiceAmount || 0
|
const invoiceAmount = objectData?.invoiceAmount || 0
|
||||||
if (objectData?.taxRate?.rateType == 'percentage') {
|
if (objectData?.taxRate?.rateType == 'percentage') {
|
||||||
@ -413,6 +454,7 @@ export const Invoice = {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
objectType: 'shipment',
|
objectType: 'shipment',
|
||||||
required: true,
|
required: true,
|
||||||
|
columnWidth: 300,
|
||||||
showHyperlink: true
|
showHyperlink: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -421,6 +463,7 @@ export const Invoice = {
|
|||||||
type: 'number',
|
type: 'number',
|
||||||
prefix: '£',
|
prefix: '£',
|
||||||
roundNumber: 2,
|
roundNumber: 2,
|
||||||
|
columnWidth: 175,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -429,7 +472,8 @@ export const Invoice = {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
objectType: 'taxRate',
|
objectType: 'taxRate',
|
||||||
required: false,
|
required: false,
|
||||||
showHyperlink: true
|
showHyperlink: true,
|
||||||
|
columnWidth: 200
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'invoiceAmountWithTax',
|
name: 'invoiceAmountWithTax',
|
||||||
@ -439,6 +483,7 @@ export const Invoice = {
|
|||||||
roundNumber: 2,
|
roundNumber: 2,
|
||||||
required: true,
|
required: true,
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
|
columnWidth: 200,
|
||||||
value: (objectData) => {
|
value: (objectData) => {
|
||||||
const invoiceAmount = objectData?.invoiceAmount || 0
|
const invoiceAmount = objectData?.invoiceAmount || 0
|
||||||
if (objectData?.taxRate?.rateType == 'percentage') {
|
if (objectData?.taxRate?.rateType == 'percentage') {
|
||||||
@ -516,6 +561,12 @@ export const Invoice = {
|
|||||||
type: 'number',
|
type: 'number',
|
||||||
color: 'cyan'
|
color: 'cyan'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'acknowledged.acknowledgedCount.count',
|
||||||
|
label: 'Acknowledged',
|
||||||
|
type: 'number',
|
||||||
|
color: 'purple'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'due.dueCount.count',
|
name: 'due.dueCount.count',
|
||||||
label: 'Due',
|
label: 'Due',
|
||||||
@ -524,7 +575,8 @@ export const Invoice = {
|
|||||||
sum: [
|
sum: [
|
||||||
'sent.sentCount.count',
|
'sent.sentCount.count',
|
||||||
'partiallyPaid.partiallyPaidCount.count',
|
'partiallyPaid.partiallyPaidCount.count',
|
||||||
'overdue.overdueCount.count'
|
'overdue.overdueCount.count',
|
||||||
|
'acknowledged.acknowledgedCount.count'
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -537,7 +589,8 @@ export const Invoice = {
|
|||||||
sum: [
|
sum: [
|
||||||
'sent.sentGrandTotalAmount.sum',
|
'sent.sentGrandTotalAmount.sum',
|
||||||
'partiallyPaid.partiallyPaidGrandTotalAmount.sum',
|
'partiallyPaid.partiallyPaidGrandTotalAmount.sum',
|
||||||
'overdue.overdueGrandTotalAmount.sum'
|
'overdue.overdueGrandTotalAmount.sum',
|
||||||
|
'acknowledged.acknowledgedGrandTotalAmount.sum'
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user