Enhance NewCourierService and CourierService models by adding cost-related fields and default values. Update NewListing and NewListingVarient components to set label widths for better layout. Modify Listing and ListingVarient models to include courierServices and update required fields for improved data integrity.
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good

This commit is contained in:
Tom Butcher 2026-07-18 13:35:52 +01:00
parent 333ce96fd8
commit 0a347c1396
10 changed files with 179 additions and 35 deletions

View File

@ -10,6 +10,9 @@ const NewCourierService = ({ onOk, defaultValues }) => {
defaultValues={{ defaultValues={{
active: true, active: true,
tracked: false, tracked: false,
cost: 0,
shippingCurrency: 'GBP',
international: false,
...defaultValues ...defaultValues
}} }}
> >

View File

@ -22,6 +22,7 @@ const NewListingVarient = ({ onOk, defaultValues }) => {
isEditing={true} isEditing={true}
required={true} required={true}
objectData={objectData} objectData={objectData}
labelWidth={105}
/> />
) )
}, },

View File

@ -175,6 +175,7 @@ const ListingInfo = () => {
loading={loading} loading={loading}
isEditing={isEditing} isEditing={isEditing}
type='listing' type='listing'
labelWidth={165}
objectData={objectData} objectData={objectData}
/> />
</InfoCollapse> </InfoCollapse>
@ -249,7 +250,7 @@ const ListingInfo = () => {
}} }}
reset={newListingVarientOpen} reset={newListingVarientOpen}
defaultValues={{ defaultValues={{
listing: { _id: listingId } listing: objectFormState.objectData
}} }}
/> />
</Modal> </Modal>

View File

@ -22,6 +22,7 @@ const NewListing = ({ onOk, defaultValues }) => {
isEditing={true} isEditing={true}
required={true} required={true}
objectData={objectData} objectData={objectData}
labelWidth={133}
/> />
) )
}, },

View File

@ -90,7 +90,8 @@ export const Courier = {
columnFixed: 'left', columnFixed: 'left',
objectType: 'courier', objectType: 'courier',
showCopy: true, showCopy: true,
readOnly: true, readOnly: false,
required: true,
columnWidth: 180 columnWidth: 180
}, },
{ {

View File

@ -69,14 +69,27 @@ export const CourierService = {
'courier', 'courier',
'tracked', 'tracked',
'deliveryTime', 'deliveryTime',
'cost',
'costWithTax',
'active' 'active'
], ],
filters: ['name', '_id', 'courier', 'active', 'deliveryTime', 'tracked'], filters: [
'name',
'_id',
'courier',
'active',
'deliveryTime',
'tracked',
'cost',
'costWithTax'
],
sorters: [ sorters: [
'name', 'name',
'courier', 'courier',
'active', 'active',
'tracked', 'tracked',
'cost',
'costWithTax',
'estimatedDeliveryTime', 'estimatedDeliveryTime',
'createdAt', 'createdAt',
'_id' '_id'
@ -138,7 +151,7 @@ export const CourierService = {
label: 'Delivery Time', label: 'Delivery Time',
type: 'number', type: 'number',
readOnly: false, readOnly: false,
required: false, required: true,
suffix: 'days', suffix: 'days',
columnWidth: 175 columnWidth: 175
}, },
@ -150,6 +163,99 @@ export const CourierService = {
required: true, required: true,
columnWidth: 125 columnWidth: 125
}, },
{
name: 'cost',
label: 'Cost',
type: 'number',
prefix: '£',
min: 0,
step: 0.01,
readOnly: false,
required: true,
columnWidth: 150
},
{
name: 'costWithTax',
label: 'Cost w/ Tax',
type: 'number',
prefix: '£',
min: 0,
step: 0.01,
readOnly: true,
required: true,
columnWidth: 150,
value: (objectData) => {
const cost = objectData?.cost
if (cost == null) return 0
if (objectData?.costTaxRate?.rateType == 'percentage') {
return (
(cost * (1 + objectData.costTaxRate.rate / 100)).toFixed(2) || 0
)
} else if (objectData?.costTaxRate?.rateType == 'amount') {
return (cost + objectData.costTaxRate.rate).toFixed(2) || 0
}
return cost
}
},
{
name: 'costTaxRate',
label: 'Cost Tax Rate',
required: true,
type: 'object',
objectType: 'taxRate',
showHyperlink: true,
columnWidth: 150
},
{
name: 'additionalCost',
label: 'Additional Item Cost',
type: 'number',
prefix: '£',
min: 0,
step: 0.01,
readOnly: false,
required: false,
columnWidth: 220
},
{
name: 'additionalCostWithTax',
label: 'Additional Item Cost w/ Tax',
type: 'number',
prefix: '£',
min: 0,
step: 0.01,
readOnly: true,
required: false,
columnWidth: 220,
value: (objectData) => {
const cost = objectData?.additionalCost
if (cost == null) return undefined
if (objectData?.costTaxRate?.rateType == 'percentage') {
return (
(cost * (1 + objectData.costTaxRate.rate / 100)).toFixed(2) || 0
)
} else if (objectData?.costTaxRate?.rateType == 'amount') {
return (cost + objectData.costTaxRate.rate).toFixed(2) || 0
}
return cost
}
},
{
name: 'shippingCurrency',
label: 'Shipping Currency',
type: 'text',
readOnly: false,
required: true,
columnWidth: 160
},
{
name: 'international',
label: 'International Service',
type: 'bool',
readOnly: false,
required: true,
columnWidth: 170
},
{ {
name: 'tracked', name: 'tracked',
label: 'Tracked', label: 'Tracked',

View File

@ -103,6 +103,7 @@ export const Listing = {
'vendor', 'vendor',
'stockLocation', 'stockLocation',
'marketplace', 'marketplace',
'courierServices',
'state', 'state',
'price', 'price',
'currency', 'currency',
@ -117,6 +118,7 @@ export const Listing = {
'vendor', 'vendor',
'stockLocation', 'stockLocation',
'marketplace', 'marketplace',
'courierServices',
'state', 'state',
'createdAt', 'createdAt',
'updatedAt' 'updatedAt'
@ -131,7 +133,13 @@ export const Listing = {
'updatedAt', 'updatedAt',
'_id' '_id'
], ],
group: ['marketplace', 'product', 'vendor', 'stockLocation'], group: [
'marketplace',
'product',
'vendor',
'stockLocation',
'courierServices'
],
properties: [ properties: [
{ {
name: '_id', name: '_id',
@ -172,8 +180,14 @@ export const Listing = {
columnFixed: 'left', columnFixed: 'left',
type: 'text', type: 'text',
readOnly: false, readOnly: false,
required: false, required: true,
columnWidth: 250 columnWidth: 250,
value: (objectData) => {
if (objectData?.title == undefined) {
return objectData?.product?.name
}
return objectData?.title
}
}, },
{ {
name: 'lastSyncedAt', name: 'lastSyncedAt',
@ -189,7 +203,7 @@ export const Listing = {
objectType: 'product', objectType: 'product',
showHyperlink: true, showHyperlink: true,
readOnly: false, readOnly: false,
required: false, required: true,
columnWidth: 200 columnWidth: 200
}, },
{ {
@ -200,6 +214,12 @@ export const Listing = {
showHyperlink: true, showHyperlink: true,
readOnly: false, readOnly: false,
required: true, required: true,
value: (objectData) => {
if (objectData?.vendor == undefined) {
return objectData?.product?.vendor
}
return objectData?.vendor
},
columnWidth: 200 columnWidth: 200
}, },
{ {
@ -256,6 +276,16 @@ export const Listing = {
readOnly: true, readOnly: true,
required: false, required: false,
columnWidth: 250 columnWidth: 250
},
{
name: 'courierServices',
label: 'Courier Services',
type: 'objectList',
multiple: true,
objectType: 'courierService',
readOnly: false,
required: true,
columnWidth: 250
} }
] ]
} }

View File

@ -18,7 +18,8 @@ export const ListingVarient = {
default: true, default: true,
row: true, row: true,
icon: InfoCircleIcon, icon: InfoCircleIcon,
url: (_id) => `/dashboard/sales/listingvarients/info?listingVarientId=${_id}` url: (_id) =>
`/dashboard/sales/listingvarients/info?listingVarientId=${_id}`
}, },
{ {
name: 'edit', name: 'edit',
@ -106,14 +107,7 @@ export const ListingVarient = {
'createdAt', 'createdAt',
'updatedAt' 'updatedAt'
], ],
sorters: [ sorters: ['state', 'price', 'lastSyncedAt', 'createdAt', 'updatedAt', '_id'],
'state',
'price',
'lastSyncedAt',
'createdAt',
'updatedAt',
'_id'
],
group: ['listing', 'state'], group: ['listing', 'state'],
properties: [ properties: [
{ {
@ -165,8 +159,12 @@ export const ListingVarient = {
type: 'object', type: 'object',
objectType: 'product', objectType: 'product',
showHyperlink: true, showHyperlink: true,
readOnly: false, readOnly: true,
required: false, value: (objectData) => {
console.log('listing product id', objectData?.listing?.product?._id)
return objectData?.listing?.product
},
required: true,
columnWidth: 200 columnWidth: 200
}, },
{ {
@ -176,8 +174,11 @@ export const ListingVarient = {
objectType: 'productSku', objectType: 'productSku',
showHyperlink: true, showHyperlink: true,
readOnly: false, readOnly: false,
required: false, required: true,
columnWidth: 200 columnWidth: 200,
masterFilter: (objectData) => {
return { product: objectData?.listing?.product?._id }
}
}, },
{ {
name: 'state', name: 'state',

View File

@ -124,6 +124,13 @@ export const Part = {
readOnly: true, readOnly: true,
columnWidth: 180 columnWidth: 180
}, },
{
name: 'updatedAt',
label: 'Updated At',
type: 'dateTime',
readOnly: true,
columnWidth: 175
},
{ {
name: 'name', name: 'name',
label: 'Name', label: 'Name',
@ -132,13 +139,6 @@ export const Part = {
type: 'text', type: 'text',
columnWidth: 200 columnWidth: 200
}, },
{
name: 'updatedAt',
label: 'Updated At',
type: 'dateTime',
readOnly: true,
columnWidth: 175
},
{ {
name: 'file', name: 'file',
label: 'File', label: 'File',

View File

@ -125,6 +125,13 @@ export const PartSku = {
readOnly: true, readOnly: true,
columnWidth: 180 columnWidth: 180
}, },
{
name: 'updatedAt',
label: 'Updated At',
type: 'dateTime',
readOnly: true,
columnWidth: 175
},
{ {
name: 'name', name: 'name',
label: 'Name', label: 'Name',
@ -133,13 +140,6 @@ export const PartSku = {
columnWidth: 200, columnWidth: 200,
columnFixed: 'left' columnFixed: 'left'
}, },
{
name: 'updatedAt',
label: 'Updated At',
type: 'dateTime',
readOnly: true,
columnWidth: 175
},
{ {
name: 'part', name: 'part',
label: 'Part', label: 'Part',