Changeset 87c9f1e for src/sections/invoice/invoice-new-edit-form.tsx
- Timestamp:
- 02/27/25 00:42:38 (5 weeks ago)
- Branches:
- main
- Children:
- 32e9876
- Parents:
- 3c5302a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sections/invoice/invoice-new-edit-form.tsx
r3c5302a r87c9f1e 81 81 const NewInvoiceSchema = Yup.object().shape({ 82 82 invoiceNumber: Yup.string().nullable().required('Invoice number is required'), 83 createDate: Yup.mixed<any>().nullable().required('Create date is required'),83 issueDate: Yup.mixed<any>().nullable().required('Create date is required'), 84 84 dueDate: Yup.mixed<any>() 85 85 .required('Due date is required') … … 87 87 'date-min', 88 88 'Due date must be later than create date', 89 (value, { parent }) => value.getTime() > parent. createDate.getTime()89 (value, { parent }) => value.getTime() > parent.issueDate.getTime() 90 90 ), 91 91 invoiceFrom: Yup.mixed<any>().nullable().required('Invoice from is required'), … … 117 117 ? currentInvoice?.invoiceNumber 118 118 : incrementInvoiceNumber(tenant?.lastInvoiceNumber), 119 createDate: currentInvoice?.createDate ? new Date(currentInvoice.createDate) : new Date(),119 issueDate: currentInvoice?.issueDate ? new Date(currentInvoice.issueDate) : new Date(), 120 120 dueDate: currentInvoice?.dueDate 121 121 ? new Date(currentInvoice.dueDate) … … 175 175 176 176 // Ensure dates are valid Date objects 177 const createDate = 178 data.createDate instanceof Date ? data.createDate : new Date(data.createDate); 177 const issueDate = data.issueDate instanceof Date ? data.issueDate : new Date(data.issueDate); 179 178 const dueDate = data.dueDate instanceof Date ? data.dueDate : new Date(data.dueDate); 180 179 181 180 const currentTime = new Date(); 182 createDate.setHours(181 issueDate.setHours( 183 182 currentTime.getHours(), 184 183 currentTime.getMinutes(), … … 197 196 invoiceNumber: incrementInvoiceNumber(tenant?.lastInvoiceNumber), 198 197 status: 'draft', 199 createDate,198 issueDate, 200 199 dueDate, 201 200 items: items.filter((item) => item.service !== null) as CreateInvoice['items'], … … 246 245 if (currentInvoice) { 247 246 // Ensure dates are valid Date objects 248 const createDate =249 data. createDate instanceof Date ? data.createDate : new Date(data.createDate);247 const issueDate = 248 data.issueDate instanceof Date ? data.issueDate : new Date(data.issueDate); 250 249 const dueDate = data.dueDate instanceof Date ? data.dueDate : new Date(data.dueDate); 251 250 … … 259 258 const writeData = { 260 259 ...data, 261 createDate,260 issueDate, 262 261 dueDate, 263 262 items, … … 312 311 313 312 // Ensure dates are valid Date objects 314 const createDate =315 data. createDate instanceof Date ? data.createDate : new Date(data.createDate);313 const issueDate = 314 data.issueDate instanceof Date ? data.issueDate : new Date(data.issueDate); 316 315 const dueDate = data.dueDate instanceof Date ? data.dueDate : new Date(data.dueDate); 317 316 … … 325 324 const writeData = { 326 325 ...data, 327 createDate,326 issueDate, 328 327 dueDate, 329 328 items,
Note:
See TracChangeset
for help on using the changeset viewer.