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
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
This commit is contained in:
parent
333ce96fd8
commit
0a347c1396
@ -10,6 +10,9 @@ const NewCourierService = ({ onOk, defaultValues }) => {
|
||||
defaultValues={{
|
||||
active: true,
|
||||
tracked: false,
|
||||
cost: 0,
|
||||
shippingCurrency: 'GBP',
|
||||
international: false,
|
||||
...defaultValues
|
||||
}}
|
||||
>
|
||||
|
||||
@ -22,6 +22,7 @@ const NewListingVarient = ({ onOk, defaultValues }) => {
|
||||
isEditing={true}
|
||||
required={true}
|
||||
objectData={objectData}
|
||||
labelWidth={105}
|
||||
/>
|
||||
)
|
||||
},
|
||||
|
||||
@ -175,6 +175,7 @@ const ListingInfo = () => {
|
||||
loading={loading}
|
||||
isEditing={isEditing}
|
||||
type='listing'
|
||||
labelWidth={165}
|
||||
objectData={objectData}
|
||||
/>
|
||||
</InfoCollapse>
|
||||
@ -249,7 +250,7 @@ const ListingInfo = () => {
|
||||
}}
|
||||
reset={newListingVarientOpen}
|
||||
defaultValues={{
|
||||
listing: { _id: listingId }
|
||||
listing: objectFormState.objectData
|
||||
}}
|
||||
/>
|
||||
</Modal>
|
||||
|
||||
@ -22,6 +22,7 @@ const NewListing = ({ onOk, defaultValues }) => {
|
||||
isEditing={true}
|
||||
required={true}
|
||||
objectData={objectData}
|
||||
labelWidth={133}
|
||||
/>
|
||||
)
|
||||
},
|
||||
|
||||
@ -90,7 +90,8 @@ export const Courier = {
|
||||
columnFixed: 'left',
|
||||
objectType: 'courier',
|
||||
showCopy: true,
|
||||
readOnly: true,
|
||||
readOnly: false,
|
||||
required: true,
|
||||
columnWidth: 180
|
||||
},
|
||||
{
|
||||
|
||||
@ -69,14 +69,27 @@ export const CourierService = {
|
||||
'courier',
|
||||
'tracked',
|
||||
'deliveryTime',
|
||||
'cost',
|
||||
'costWithTax',
|
||||
'active'
|
||||
],
|
||||
filters: ['name', '_id', 'courier', 'active', 'deliveryTime', 'tracked'],
|
||||
filters: [
|
||||
'name',
|
||||
'_id',
|
||||
'courier',
|
||||
'active',
|
||||
'deliveryTime',
|
||||
'tracked',
|
||||
'cost',
|
||||
'costWithTax'
|
||||
],
|
||||
sorters: [
|
||||
'name',
|
||||
'courier',
|
||||
'active',
|
||||
'tracked',
|
||||
'cost',
|
||||
'costWithTax',
|
||||
'estimatedDeliveryTime',
|
||||
'createdAt',
|
||||
'_id'
|
||||
@ -138,7 +151,7 @@ export const CourierService = {
|
||||
label: 'Delivery Time',
|
||||
type: 'number',
|
||||
readOnly: false,
|
||||
required: false,
|
||||
required: true,
|
||||
suffix: 'days',
|
||||
columnWidth: 175
|
||||
},
|
||||
@ -150,6 +163,99 @@ export const CourierService = {
|
||||
required: true,
|
||||
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',
|
||||
label: 'Tracked',
|
||||
|
||||
@ -103,6 +103,7 @@ export const Listing = {
|
||||
'vendor',
|
||||
'stockLocation',
|
||||
'marketplace',
|
||||
'courierServices',
|
||||
'state',
|
||||
'price',
|
||||
'currency',
|
||||
@ -117,6 +118,7 @@ export const Listing = {
|
||||
'vendor',
|
||||
'stockLocation',
|
||||
'marketplace',
|
||||
'courierServices',
|
||||
'state',
|
||||
'createdAt',
|
||||
'updatedAt'
|
||||
@ -131,7 +133,13 @@ export const Listing = {
|
||||
'updatedAt',
|
||||
'_id'
|
||||
],
|
||||
group: ['marketplace', 'product', 'vendor', 'stockLocation'],
|
||||
group: [
|
||||
'marketplace',
|
||||
'product',
|
||||
'vendor',
|
||||
'stockLocation',
|
||||
'courierServices'
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
name: '_id',
|
||||
@ -172,8 +180,14 @@ export const Listing = {
|
||||
columnFixed: 'left',
|
||||
type: 'text',
|
||||
readOnly: false,
|
||||
required: false,
|
||||
columnWidth: 250
|
||||
required: true,
|
||||
columnWidth: 250,
|
||||
value: (objectData) => {
|
||||
if (objectData?.title == undefined) {
|
||||
return objectData?.product?.name
|
||||
}
|
||||
return objectData?.title
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'lastSyncedAt',
|
||||
@ -189,7 +203,7 @@ export const Listing = {
|
||||
objectType: 'product',
|
||||
showHyperlink: true,
|
||||
readOnly: false,
|
||||
required: false,
|
||||
required: true,
|
||||
columnWidth: 200
|
||||
},
|
||||
{
|
||||
@ -200,6 +214,12 @@ export const Listing = {
|
||||
showHyperlink: true,
|
||||
readOnly: false,
|
||||
required: true,
|
||||
value: (objectData) => {
|
||||
if (objectData?.vendor == undefined) {
|
||||
return objectData?.product?.vendor
|
||||
}
|
||||
return objectData?.vendor
|
||||
},
|
||||
columnWidth: 200
|
||||
},
|
||||
{
|
||||
@ -256,6 +276,16 @@ export const Listing = {
|
||||
readOnly: true,
|
||||
required: false,
|
||||
columnWidth: 250
|
||||
},
|
||||
{
|
||||
name: 'courierServices',
|
||||
label: 'Courier Services',
|
||||
type: 'objectList',
|
||||
multiple: true,
|
||||
objectType: 'courierService',
|
||||
readOnly: false,
|
||||
required: true,
|
||||
columnWidth: 250
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -18,7 +18,8 @@ export const ListingVarient = {
|
||||
default: true,
|
||||
row: true,
|
||||
icon: InfoCircleIcon,
|
||||
url: (_id) => `/dashboard/sales/listingvarients/info?listingVarientId=${_id}`
|
||||
url: (_id) =>
|
||||
`/dashboard/sales/listingvarients/info?listingVarientId=${_id}`
|
||||
},
|
||||
{
|
||||
name: 'edit',
|
||||
@ -106,14 +107,7 @@ export const ListingVarient = {
|
||||
'createdAt',
|
||||
'updatedAt'
|
||||
],
|
||||
sorters: [
|
||||
'state',
|
||||
'price',
|
||||
'lastSyncedAt',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_id'
|
||||
],
|
||||
sorters: ['state', 'price', 'lastSyncedAt', 'createdAt', 'updatedAt', '_id'],
|
||||
group: ['listing', 'state'],
|
||||
properties: [
|
||||
{
|
||||
@ -165,8 +159,12 @@ export const ListingVarient = {
|
||||
type: 'object',
|
||||
objectType: 'product',
|
||||
showHyperlink: true,
|
||||
readOnly: false,
|
||||
required: false,
|
||||
readOnly: true,
|
||||
value: (objectData) => {
|
||||
console.log('listing product id', objectData?.listing?.product?._id)
|
||||
return objectData?.listing?.product
|
||||
},
|
||||
required: true,
|
||||
columnWidth: 200
|
||||
},
|
||||
{
|
||||
@ -176,8 +174,11 @@ export const ListingVarient = {
|
||||
objectType: 'productSku',
|
||||
showHyperlink: true,
|
||||
readOnly: false,
|
||||
required: false,
|
||||
columnWidth: 200
|
||||
required: true,
|
||||
columnWidth: 200,
|
||||
masterFilter: (objectData) => {
|
||||
return { product: objectData?.listing?.product?._id }
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'state',
|
||||
|
||||
@ -124,6 +124,13 @@ export const Part = {
|
||||
readOnly: true,
|
||||
columnWidth: 180
|
||||
},
|
||||
{
|
||||
name: 'updatedAt',
|
||||
label: 'Updated At',
|
||||
type: 'dateTime',
|
||||
readOnly: true,
|
||||
columnWidth: 175
|
||||
},
|
||||
{
|
||||
name: 'name',
|
||||
label: 'Name',
|
||||
@ -132,13 +139,6 @@ export const Part = {
|
||||
type: 'text',
|
||||
columnWidth: 200
|
||||
},
|
||||
{
|
||||
name: 'updatedAt',
|
||||
label: 'Updated At',
|
||||
type: 'dateTime',
|
||||
readOnly: true,
|
||||
columnWidth: 175
|
||||
},
|
||||
{
|
||||
name: 'file',
|
||||
label: 'File',
|
||||
|
||||
@ -125,6 +125,13 @@ export const PartSku = {
|
||||
readOnly: true,
|
||||
columnWidth: 180
|
||||
},
|
||||
{
|
||||
name: 'updatedAt',
|
||||
label: 'Updated At',
|
||||
type: 'dateTime',
|
||||
readOnly: true,
|
||||
columnWidth: 175
|
||||
},
|
||||
{
|
||||
name: 'name',
|
||||
label: 'Name',
|
||||
@ -133,13 +140,6 @@ export const PartSku = {
|
||||
columnWidth: 200,
|
||||
columnFixed: 'left'
|
||||
},
|
||||
{
|
||||
name: 'updatedAt',
|
||||
label: 'Updated At',
|
||||
type: 'dateTime',
|
||||
readOnly: true,
|
||||
columnWidth: 175
|
||||
},
|
||||
{
|
||||
name: 'part',
|
||||
label: 'Part',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user