diff --git a/src/components/Dashboard/Management/CourierServices/NewCourierService.jsx b/src/components/Dashboard/Management/CourierServices/NewCourierService.jsx index fc754d0..0560fca 100644 --- a/src/components/Dashboard/Management/CourierServices/NewCourierService.jsx +++ b/src/components/Dashboard/Management/CourierServices/NewCourierService.jsx @@ -10,6 +10,9 @@ const NewCourierService = ({ onOk, defaultValues }) => { defaultValues={{ active: true, tracked: false, + cost: 0, + shippingCurrency: 'GBP', + international: false, ...defaultValues }} > diff --git a/src/components/Dashboard/Sales/ListingVarients/NewListingVarient.jsx b/src/components/Dashboard/Sales/ListingVarients/NewListingVarient.jsx index 73101f1..63c649c 100644 --- a/src/components/Dashboard/Sales/ListingVarients/NewListingVarient.jsx +++ b/src/components/Dashboard/Sales/ListingVarients/NewListingVarient.jsx @@ -22,6 +22,7 @@ const NewListingVarient = ({ onOk, defaultValues }) => { isEditing={true} required={true} objectData={objectData} + labelWidth={105} /> ) }, diff --git a/src/components/Dashboard/Sales/Listings/ListingInfo.jsx b/src/components/Dashboard/Sales/Listings/ListingInfo.jsx index b7fb9eb..bd56e03 100644 --- a/src/components/Dashboard/Sales/Listings/ListingInfo.jsx +++ b/src/components/Dashboard/Sales/Listings/ListingInfo.jsx @@ -175,6 +175,7 @@ const ListingInfo = () => { loading={loading} isEditing={isEditing} type='listing' + labelWidth={165} objectData={objectData} /> @@ -249,7 +250,7 @@ const ListingInfo = () => { }} reset={newListingVarientOpen} defaultValues={{ - listing: { _id: listingId } + listing: objectFormState.objectData }} /> diff --git a/src/components/Dashboard/Sales/Listings/NewListing.jsx b/src/components/Dashboard/Sales/Listings/NewListing.jsx index 84513c2..cc31176 100644 --- a/src/components/Dashboard/Sales/Listings/NewListing.jsx +++ b/src/components/Dashboard/Sales/Listings/NewListing.jsx @@ -22,6 +22,7 @@ const NewListing = ({ onOk, defaultValues }) => { isEditing={true} required={true} objectData={objectData} + labelWidth={133} /> ) }, diff --git a/src/database/models/Courier.js b/src/database/models/Courier.js index aeae729..0785c22 100644 --- a/src/database/models/Courier.js +++ b/src/database/models/Courier.js @@ -90,7 +90,8 @@ export const Courier = { columnFixed: 'left', objectType: 'courier', showCopy: true, - readOnly: true, + readOnly: false, + required: true, columnWidth: 180 }, { diff --git a/src/database/models/CourierService.js b/src/database/models/CourierService.js index cd2a424..9ba61bd 100644 --- a/src/database/models/CourierService.js +++ b/src/database/models/CourierService.js @@ -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', diff --git a/src/database/models/Listing.js b/src/database/models/Listing.js index d87cb4c..c7d4e4b 100644 --- a/src/database/models/Listing.js +++ b/src/database/models/Listing.js @@ -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 } ] } diff --git a/src/database/models/ListingVarient.js b/src/database/models/ListingVarient.js index 64d6943..f35f4c3 100644 --- a/src/database/models/ListingVarient.js +++ b/src/database/models/ListingVarient.js @@ -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', diff --git a/src/database/models/Part.js b/src/database/models/Part.js index a8624c3..57e0e90 100644 --- a/src/database/models/Part.js +++ b/src/database/models/Part.js @@ -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', diff --git a/src/database/models/PartSku.js b/src/database/models/PartSku.js index 8cfcee5..2a317d2 100644 --- a/src/database/models/PartSku.js +++ b/src/database/models/PartSku.js @@ -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',