Enhance PurchaseOrder components with new invoice modal and state management
- Added a new modal for creating invoices within the PurchaseOrderInfo component. - Introduced state management for the new invoice modal, allowing users to open and close it. - Updated PurchaseOrder model to include additional allowed states for invoice creation. - Added a new field for 'completedAt' in the NewPurchaseOrder component for better order tracking.
This commit is contained in:
parent
de74fb0668
commit
4da63e6a32
@ -53,7 +53,8 @@ const NewPurchaseOrder = ({ onOk, reset, defaultValues }) => {
|
||||
acknowledgedAt: false,
|
||||
shippingAmount: false,
|
||||
shippingAmountWithTax: false,
|
||||
grandTotalAmount: false
|
||||
grandTotalAmount: false,
|
||||
completedAt: false
|
||||
}}
|
||||
isEditing={false}
|
||||
objectData={objectData}
|
||||
|
||||
@ -31,6 +31,7 @@ import ShipmentIcon from '../../../Icons/ShipmentIcon.jsx'
|
||||
import InvoiceIcon from '../../../Icons/InvoiceIcon.jsx'
|
||||
import StockEventIcon from '../../../Icons/StockEventIcon.jsx'
|
||||
import { getModelByName } from '../../../../database/ObjectModels.js'
|
||||
import NewInvoice from '../../Finance/Invoices/NewInvoice.jsx'
|
||||
|
||||
const log = loglevel.getLogger('PurchaseOrderInfo')
|
||||
log.setLevel(config.logLevel)
|
||||
@ -47,6 +48,7 @@ const PurchaseOrderInfo = () => {
|
||||
const [acknowledgePurchaseOrderOpen, setAcknowledgePurchaseOrderOpen] =
|
||||
useState(false)
|
||||
const [cancelPurchaseOrderOpen, setCancelPurchaseOrderOpen] = useState(false)
|
||||
const [newInvoiceOpen, setNewInvoiceOpen] = useState(false)
|
||||
const purchaseOrderId = new URLSearchParams(location.search).get(
|
||||
'purchaseOrderId'
|
||||
)
|
||||
@ -102,6 +104,10 @@ const PurchaseOrderInfo = () => {
|
||||
setNewShipmentOpen(true)
|
||||
return true
|
||||
},
|
||||
newInvoice: () => {
|
||||
setNewInvoiceOpen(true)
|
||||
return true
|
||||
},
|
||||
post: () => {
|
||||
setPostPurchaseOrderOpen(true)
|
||||
return true
|
||||
@ -382,6 +388,26 @@ const PurchaseOrderInfo = () => {
|
||||
}}
|
||||
/>
|
||||
</Modal>
|
||||
<Modal
|
||||
open={newInvoiceOpen}
|
||||
onCancel={() => {
|
||||
setNewInvoiceOpen(false)
|
||||
}}
|
||||
width={800}
|
||||
footer={null}
|
||||
destroyOnHidden={true}
|
||||
>
|
||||
<NewInvoice
|
||||
onOk={() => {
|
||||
setNewInvoiceOpen(false)
|
||||
}}
|
||||
reset={newInvoiceOpen}
|
||||
defaultValues={{
|
||||
orderType: 'purchaseOrder',
|
||||
order: { ...objectFormState.objectData }
|
||||
}}
|
||||
/>
|
||||
</Modal>
|
||||
<Modal
|
||||
open={postPurchaseOrderOpen}
|
||||
onCancel={() => {
|
||||
|
||||
@ -103,7 +103,13 @@ export const PurchaseOrder = {
|
||||
url: (_id) =>
|
||||
`/dashboard/inventory/purchaseorders/info?purchaseOrderId=${_id}&action=newInvoice`,
|
||||
disabled: (objectData) => {
|
||||
return objectData?.state?.type != 'received'
|
||||
const allowedStates = [
|
||||
'received',
|
||||
'shipped',
|
||||
'partiallyReceived',
|
||||
'partiallyShipped'
|
||||
]
|
||||
return !allowedStates.includes(objectData?.state?.type)
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -240,7 +246,7 @@ export const PurchaseOrder = {
|
||||
columnWidth: 175
|
||||
},
|
||||
{
|
||||
name: 'CompletedAt',
|
||||
name: 'completedAt',
|
||||
label: 'Completed At',
|
||||
type: 'dateTime',
|
||||
readOnly: true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user