Compare commits

...

2 Commits

Author SHA1 Message Date
Flatlogic Bot
3c4a72358d Clean up the shipment table 2025-05-05 06:05:51 +00:00
Flatlogic Bot
b48264df80 Revert to version 761fe36 2025-05-05 05:11:38 +00:00
20 changed files with 278 additions and 126 deletions

View File

@ -25,6 +25,7 @@ module.exports = class ShipmentsDBApi {
customerCharge: data.customerCharge || null, customerCharge: data.customerCharge || null,
actualCharge: data.actualCharge || null, actualCharge: data.actualCharge || null,
businessname: data.businessname || null, businessname: data.businessname || null,
business: data.business || null,
importHash: data.importHash || null, importHash: data.importHash || null,
createdById: currentUser.id, createdById: currentUser.id,
updatedById: currentUser.id, updatedById: currentUser.id,
@ -61,6 +62,7 @@ module.exports = class ShipmentsDBApi {
customerCharge: item.customerCharge || null, customerCharge: item.customerCharge || null,
actualCharge: item.actualCharge || null, actualCharge: item.actualCharge || null,
businessname: item.businessname || null, businessname: item.businessname || null,
business: item.business || null,
importHash: item.importHash || null, importHash: item.importHash || null,
createdById: currentUser.id, createdById: currentUser.id,
updatedById: currentUser.id, updatedById: currentUser.id,
@ -109,6 +111,8 @@ module.exports = class ShipmentsDBApi {
if (data.businessname !== undefined) if (data.businessname !== undefined)
updatePayload.businessname = data.businessname; updatePayload.businessname = data.businessname;
if (data.business !== undefined) updatePayload.business = data.business;
updatePayload.updatedById = currentUser.id; updatePayload.updatedById = currentUser.id;
await shipments.update(updatePayload, { transaction }); await shipments.update(updatePayload, { transaction });
@ -315,6 +319,13 @@ module.exports = class ShipmentsDBApi {
}; };
} }
if (filter.business) {
where = {
...where,
[Op.and]: Utils.ilike('shipments', 'business', filter.business),
};
}
if (filter.customerChargeRange) { if (filter.customerChargeRange) {
const [start, end] = filter.customerChargeRange; const [start, end] = filter.customerChargeRange;

View File

@ -12,7 +12,7 @@ module.exports = {
try { try {
await queryInterface.addColumn( await queryInterface.addColumn(
'shipments', 'shipments',
'businessname', 'business',
{ {
type: Sequelize.DataTypes.TEXT, type: Sequelize.DataTypes.TEXT,
}, },
@ -36,7 +36,7 @@ module.exports = {
*/ */
const transaction = await queryInterface.sequelize.transaction(); const transaction = await queryInterface.sequelize.transaction();
try { try {
await queryInterface.removeColumn('shipments', 'businessname', { await queryInterface.removeColumn('shipments', 'business', {
transaction, transaction,
}); });

View File

@ -54,6 +54,10 @@ module.exports = function (sequelize, DataTypes) {
type: DataTypes.TEXT, type: DataTypes.TEXT,
}, },
business: {
type: DataTypes.TEXT,
},
importHash: { importHash: {
type: DataTypes.STRING(255), type: DataTypes.STRING(255),
allowNull: true, allowNull: true,

View File

@ -9,7 +9,7 @@ const Shipments = db.shipments;
const ProductsData = [ const ProductsData = [
{ {
productName: 'John Dalton', productName: 'Emil Fischer',
// type code here for "images" field // type code here for "images" field
@ -23,7 +23,7 @@ const ProductsData = [
}, },
{ {
productName: 'Edward Teller', productName: 'Claude Levi-Strauss',
// type code here for "images" field // type code here for "images" field
@ -37,7 +37,7 @@ const ProductsData = [
}, },
{ {
productName: 'Richard Feynman', productName: 'Karl Landsteiner',
// type code here for "images" field // type code here for "images" field
@ -49,29 +49,51 @@ const ProductsData = [
height: 5, height: 5,
}, },
{
productName: 'Karl Landsteiner',
// type code here for "images" field
weight: 4,
length: 25,
width: 12,
height: 6,
},
]; ];
const QuotesData = [ const QuotesData = [
{ {
carrierName: 'Paul Dirac', carrierName: 'Justus Liebig',
quotePrice: 78.38, quotePrice: 20.13,
// type code here for "relation_one" field // type code here for "relation_one" field
}, },
{ {
carrierName: 'Paul Ehrlich', carrierName: 'Sigmund Freud',
quotePrice: 99.12, quotePrice: 56.18,
// type code here for "relation_one" field // type code here for "relation_one" field
}, },
{ {
carrierName: 'Michael Faraday', carrierName: 'Galileo Galilei',
quotePrice: 93.69, quotePrice: 25.93,
// type code here for "relation_one" field
},
{
carrierName: 'Edwin Hubble',
quotePrice: 48.31,
// type code here for "relation_one" field // type code here for "relation_one" field
}, },
@ -79,81 +101,115 @@ const QuotesData = [
const ShipmentsData = [ const ShipmentsData = [
{ {
customer: 'Edward Teller', customer: 'Claude Levi-Strauss',
phoneNumber: 'Emil Kraepelin', phoneNumber: 'Alfred Wegener',
address: 'Frederick Sanger', address: 'Rudolf Virchow',
address2: 'Anton van Leeuwenhoek', address2: 'Carl Gauss (Karl Friedrich Gauss)',
zipCode: 'Ernst Mayr', zipCode: 'Franz Boas',
city: 'Stephen Hawking', city: 'Michael Faraday',
state: 'Max Born', state: 'Christiaan Huygens',
// type code here for "relation_many" field // type code here for "relation_many" field
// type code here for "relation_one" field // type code here for "relation_one" field
customerCharge: 71.54, customerCharge: 13.96,
actualCharge: 83.68, actualCharge: 44.54,
businessname: 'Willard Libby', businessname: 'Marcello Malpighi',
business: 'Max von Laue',
}, },
{ {
customer: 'Rudolf Virchow', customer: 'Albert Einstein',
phoneNumber: 'Comte de Buffon', phoneNumber: 'Enrico Fermi',
address: 'Hans Bethe', address: 'Robert Koch',
address2: 'Edward Teller', address2: 'James Watson',
zipCode: 'Willard Libby', zipCode: 'Pierre Simon de Laplace',
city: 'Ernst Mayr', city: 'Sheldon Glashow',
state: 'Joseph J. Thomson', state: 'William Bayliss',
// type code here for "relation_many" field // type code here for "relation_many" field
// type code here for "relation_one" field // type code here for "relation_one" field
customerCharge: 38.34, customerCharge: 14.11,
actualCharge: 45.04, actualCharge: 66.43,
businessname: 'Frederick Sanger', businessname: 'Karl Landsteiner',
business: 'Max Delbruck',
}, },
{ {
customer: 'James Clerk Maxwell', customer: 'Hans Bethe',
phoneNumber: 'Charles Sherrington', phoneNumber: 'Sheldon Glashow',
address: 'Trofim Lysenko', address: 'Leonard Euler',
address2: 'Werner Heisenberg', address2: 'Neils Bohr',
zipCode: 'Charles Darwin', zipCode: 'Johannes Kepler',
city: 'Joseph J. Thomson', city: 'Max Born',
state: 'Carl Gauss (Karl Friedrich Gauss)', state: 'J. Robert Oppenheimer',
// type code here for "relation_many" field // type code here for "relation_many" field
// type code here for "relation_one" field // type code here for "relation_one" field
customerCharge: 43.34, customerCharge: 87.48,
actualCharge: 10.66, actualCharge: 66.23,
businessname: 'James Clerk Maxwell', businessname: 'George Gaylord Simpson',
business: 'Arthur Eddington',
},
{
customer: 'Max Planck',
phoneNumber: 'Edward Teller',
address: 'Max Born',
address2: 'James Watson',
zipCode: 'Louis Victor de Broglie',
city: 'Konrad Lorenz',
state: 'Richard Feynman',
// type code here for "relation_many" field
// type code here for "relation_one" field
customerCharge: 49.33,
actualCharge: 50.57,
businessname: 'John von Neumann',
business: 'Max Delbruck',
}, },
]; ];
@ -192,6 +248,17 @@ async function associateQuoteWithShipment() {
if (Quote2?.setShipment) { if (Quote2?.setShipment) {
await Quote2.setShipment(relatedShipment2); await Quote2.setShipment(relatedShipment2);
} }
const relatedShipment3 = await Shipments.findOne({
offset: Math.floor(Math.random() * (await Shipments.count())),
});
const Quote3 = await Quotes.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Quote3?.setShipment) {
await Quote3.setShipment(relatedShipment3);
}
} }
// Similar logic for "relation_many" // Similar logic for "relation_many"
@ -229,6 +296,17 @@ async function associateShipmentWithQuote() {
if (Shipment2?.setQuote) { if (Shipment2?.setQuote) {
await Shipment2.setQuote(relatedQuote2); await Shipment2.setQuote(relatedQuote2);
} }
const relatedQuote3 = await Quotes.findOne({
offset: Math.floor(Math.random() * (await Quotes.count())),
});
const Shipment3 = await Shipments.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Shipment3?.setQuote) {
await Shipment3.setQuote(relatedQuote3);
}
} }
module.exports = { module.exports = {

View File

@ -44,6 +44,9 @@ router.use(checkCrudPermissions('shipments'));
* businessname: * businessname:
* type: string * type: string
* default: businessname * default: businessname
* business:
* type: string
* default: business
* customerCharge: * customerCharge:
* type: integer * type: integer
@ -342,6 +345,7 @@ router.get(
'city', 'city',
'state', 'state',
'businessname', 'businessname',
'business',
'customerCharge', 'customerCharge',
'actualCharge', 'actualCharge',

View File

@ -63,6 +63,8 @@ module.exports = class SearchService {
'state', 'state',
'businessname', 'businessname',
'business',
], ],
}; };
const columnsInt = { const columnsInt = {

View File

@ -59,7 +59,7 @@ const CardProducts = ({
className={`flex items-center ${bgColor} p-6 md:p-0 md:block gap-x-4 border-b border-gray-900/5 bg-gray-50 dark:bg-dark-800 relative`} className={`flex items-center ${bgColor} p-6 md:p-0 md:block gap-x-4 border-b border-gray-900/5 bg-gray-50 dark:bg-dark-800 relative`}
> >
<Link <Link
href={`/products/products-edit/?id=${item.id}`} href={`/products/products-view/?id=${item.id}`}
className={'cursor-pointer'} className={'cursor-pointer'}
> >
<ImageField <ImageField

View File

@ -199,6 +199,17 @@ const CardShipments = ({
</div> </div>
</dd> </dd>
</div> </div>
<div className='flex justify-between gap-x-4 py-3'>
<dt className=' text-gray-500 dark:text-dark-600'>
Business
</dt>
<dd className='flex items-start gap-x-2'>
<div className='font-medium line-clamp-4'>
{item.business}
</div>
</dd>
</div>
</dl> </dl>
</li> </li>
))} ))}

View File

@ -124,6 +124,11 @@ const ListShipments = ({
<p className={'text-xs text-gray-500 '}>Businessname</p> <p className={'text-xs text-gray-500 '}>Businessname</p>
<p className={'line-clamp-2'}>{item.businessname}</p> <p className={'line-clamp-2'}>{item.businessname}</p>
</div> </div>
<div className={'flex-1 px-3'}>
<p className={'text-xs text-gray-500 '}>Business</p>
<p className={'line-clamp-2'}>{item.business}</p>
</div>
</Link> </Link>
<ListActionsPopover <ListActionsPopover
onDelete={onDelete} onDelete={onDelete}

View File

@ -39,31 +39,28 @@ export const loadColumns = async (
return [ return [
{ {
field: 'businessname', field: 'createdAt',
headerName: 'Business Name', headerName: 'Ship Date',
type: 'date',
flex: 1, flex: 1,
minWidth: 120, minWidth: 160,
filterable: false, valueFormatter: (params: GridValueGetterParams) => params.value ? new Date(params.value).toLocaleDateString() : '',
headerClassName: 'datagrid--header',
cellClassName: 'datagrid--cell',
},
{
field: 'business',
headerName: 'Business',
flex: 1,
minWidth: 120,
headerClassName: 'datagrid--header', headerClassName: 'datagrid--header',
cellClassName: 'datagrid--cell', cellClassName: 'datagrid--cell',
editable: hasUpdatePermission,
}, },
{ {
field: 'customer', field: 'customer',
headerName: 'Customer', headerName: 'Customer',
flex: 1, flex: 1,
minWidth: 120, minWidth: 120,
filterable: false,
headerClassName: 'datagrid--header',
cellClassName: 'datagrid--cell',
editable: hasUpdatePermission,
},
{
field: 'address',
headerName: 'Address',
flex: 1,
minWidth: 120,
filterable: false,
headerClassName: 'datagrid--header', headerClassName: 'datagrid--header',
cellClassName: 'datagrid--cell', cellClassName: 'datagrid--cell',
editable: hasUpdatePermission, editable: hasUpdatePermission,
@ -73,7 +70,6 @@ export const loadColumns = async (
headerName: 'State', headerName: 'State',
flex: 1, flex: 1,
minWidth: 120, minWidth: 120,
filterable: false,
headerClassName: 'datagrid--header', headerClassName: 'datagrid--header',
cellClassName: 'datagrid--cell', cellClassName: 'datagrid--cell',
editable: hasUpdatePermission, editable: hasUpdatePermission,
@ -83,32 +79,36 @@ export const loadColumns = async (
headerName: 'Zip Code', headerName: 'Zip Code',
flex: 1, flex: 1,
minWidth: 120, minWidth: 120,
filterable: false,
headerClassName: 'datagrid--header', headerClassName: 'datagrid--header',
cellClassName: 'datagrid--cell', cellClassName: 'datagrid--cell',
editable: hasUpdatePermission, editable: hasUpdatePermission,
}, },
{ {
field: 'customerCharge', field: 'quote',
headerName: 'Customer Charge', headerName: 'Quote',
flex: 1, flex: 1,
minWidth: 120, minWidth: 120,
filterable: false,
headerClassName: 'datagrid--header', headerClassName: 'datagrid--header',
cellClassName: 'datagrid--cell', cellClassName: 'datagrid--cell',
editable: hasUpdatePermission, valueGetter: (params: GridValueGetterParams) => params.row.quote?.quotePrice ?? '',
type: 'number',
}, },
{ {
field: 'actualCharge', type: 'actions',
headerName: 'Actual Charge', field: 'actions',
flex: 1, headerName: 'Actions',
minWidth: 120, minWidth: 80,
filterable: false,
headerClassName: 'datagrid--header', headerClassName: 'datagrid--header',
cellClassName: 'datagrid--cell', cellClassName: 'datagrid--cell',
editable: hasUpdatePermission, getActions: (params: GridRowParams) => [
type: 'number', <ListActionsPopover
onDelete={onDelete}
itemId={params.row.id}
pathEdit={`/shipments/shipments-edit/?id=${params.row.id}`}
pathView={`/shipments/shipments-view/?id=${params.row.id}`}
key={1}
hasUpdatePermission={hasUpdatePermission}
/>
],
}, },
]; ];
}; };

View File

@ -9,40 +9,48 @@ const menuAside: MenuAsideItem[] = [
}, },
{ {
href: '/shipments/shipments-list', href: '/shipments/shipments-list',
icon: icon.mdiTruck ? icon.mdiTruck : icon.mdiTable,
label: 'Shipments', label: 'Shipments',
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
icon: icon.mdiTruck || icon.mdiTable,
permissions: 'READ_SHIPMENTS', permissions: 'READ_SHIPMENTS',
}, },
{ {
href: '/products/products-list', href: '/products/products-list',
icon: icon.mdiPackageVariant ? icon.mdiPackageVariant : icon.mdiTable,
label: 'Products', label: 'Products',
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
icon: icon.mdiPackageVariant || icon.mdiTable,
permissions: 'READ_PRODUCTS', permissions: 'READ_PRODUCTS',
}, },
{ divider: true },
{ {
href: '/users/users-list', href: '/users/users-list',
icon: icon.mdiAccountGroup ? icon.mdiAccountGroup : icon.mdiTable,
label: 'Users', label: 'Users',
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
icon: icon.mdiAccountGroup || icon.mdiTable,
permissions: 'READ_USERS', permissions: 'READ_USERS',
}, },
{ {
href: '/roles/roles-list', href: '/roles/roles-list',
icon: icon.mdiShieldAccountVariantOutline ? icon.mdiShieldAccountVariantOutline : icon.mdiTable,
label: 'Roles', label: 'Roles',
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
icon: icon.mdiShieldAccountVariantOutline || icon.mdiTable,
permissions: 'READ_ROLES', permissions: 'READ_ROLES',
}, },
{ {
href: '/permissions/permissions-list', href: '/permissions/permissions-list',
icon: icon.mdiShieldAccountOutline ? icon.mdiShieldAccountOutline : icon.mdiTable,
label: 'Permissions', label: 'Permissions',
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
icon: icon.mdiShieldAccountOutline || icon.mdiTable,
permissions: 'READ_PERMISSIONS', permissions: 'READ_PERMISSIONS',
}, },
{ divider: true },
{ {
href: '/profile', href: '/profile',
icon: icon.mdiAccountCircle,
label: 'Profile', label: 'Profile',
icon: icon.mdiAccountCircle,
}, },
]; ];

View File

@ -142,7 +142,7 @@ const Dashboard = () => {
)} )}
{rolesWidgets && {rolesWidgets &&
rolesWidgets.map((widget) => ( rolesWidgets.filter((widget) => widget.label !== 'Product Shipment Counts').map((widget) => (
<SmartWidget <SmartWidget
key={widget.id} key={widget.id}
userId={currentUser?.id} userId={currentUser?.id}

View File

@ -99,6 +99,8 @@ const QuotesView = () => {
<th>Actual Charge</th> <th>Actual Charge</th>
<th>Businessname</th> <th>Businessname</th>
<th>Business</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -134,6 +136,8 @@ const QuotesView = () => {
<td data-label='actualCharge'>{item.actualCharge}</td> <td data-label='actualCharge'>{item.actualCharge}</td>
<td data-label='businessname'>{item.businessname}</td> <td data-label='businessname'>{item.businessname}</td>
<td data-label='business'>{item.business}</td>
</tr> </tr>
))} ))}
</tbody> </tbody>

View File

@ -59,6 +59,8 @@ const EditShipments = () => {
actualCharge: '', actualCharge: '',
businessname: '', businessname: '',
business: '',
}; };
const [initialValues, setInitialValues] = useState(initVals); const [initialValues, setInitialValues] = useState(initVals);
@ -183,6 +185,10 @@ const EditShipments = () => {
<Field name='businessname' placeholder='Businessname' /> <Field name='businessname' placeholder='Businessname' />
</FormField> </FormField>
<FormField label='Business'>
<Field name='business' placeholder='Business' />
</FormField>
<BaseDivider /> <BaseDivider />
<BaseButtons> <BaseButtons>
<BaseButton type='submit' color='info' label='Submit' /> <BaseButton type='submit' color='info' label='Submit' />

View File

@ -59,6 +59,8 @@ const EditShipmentsPage = () => {
actualCharge: '', actualCharge: '',
businessname: '', businessname: '',
business: '',
}; };
const [initialValues, setInitialValues] = useState(initVals); const [initialValues, setInitialValues] = useState(initVals);
@ -181,6 +183,10 @@ const EditShipmentsPage = () => {
<Field name='businessname' placeholder='Businessname' /> <Field name='businessname' placeholder='Businessname' />
</FormField> </FormField>
<FormField label='Business'>
<Field name='business' placeholder='Business' />
</FormField>
<BaseDivider /> <BaseDivider />
<BaseButtons> <BaseButtons>
<BaseButton type='submit' color='info' label='Submit' /> <BaseButton type='submit' color='info' label='Submit' />

View File

@ -37,6 +37,7 @@ const ShipmentsTablesPage = () => {
{ label: 'City', title: 'city' }, { label: 'City', title: 'city' },
{ label: 'State', title: 'state' }, { label: 'State', title: 'state' },
{ label: 'Businessname', title: 'businessname' }, { label: 'Businessname', title: 'businessname' },
{ label: 'Business', title: 'business' },
{ label: 'Customer Charge', title: 'customerCharge', number: 'true' }, { label: 'Customer Charge', title: 'customerCharge', number: 'true' },
{ label: 'Actual Charge', title: 'actualCharge', number: 'true' }, { label: 'Actual Charge', title: 'actualCharge', number: 'true' },

View File

@ -56,6 +56,8 @@ const initialValues = {
actualCharge: '', actualCharge: '',
businessname: '', businessname: '',
business: '',
}; };
const ShipmentsNew = () => { const ShipmentsNew = () => {
@ -153,6 +155,10 @@ const ShipmentsNew = () => {
<Field name='businessname' placeholder='Businessname' /> <Field name='businessname' placeholder='Businessname' />
</FormField> </FormField>
<FormField label='Business'>
<Field name='business' placeholder='Business' />
</FormField>
<BaseDivider /> <BaseDivider />
<BaseButtons> <BaseButtons>
<BaseButton type='submit' color='info' label='Submit' /> <BaseButton type='submit' color='info' label='Submit' />

View File

@ -37,6 +37,7 @@ const ShipmentsTablesPage = () => {
{ label: 'City', title: 'city' }, { label: 'City', title: 'city' },
{ label: 'State', title: 'state' }, { label: 'State', title: 'state' },
{ label: 'Businessname', title: 'businessname' }, { label: 'Businessname', title: 'businessname' },
{ label: 'Business', title: 'business' },
{ label: 'Customer Charge', title: 'customerCharge', number: 'true' }, { label: 'Customer Charge', title: 'customerCharge', number: 'true' },
{ label: 'Actual Charge', title: 'actualCharge', number: 'true' }, { label: 'Actual Charge', title: 'actualCharge', number: 'true' },

View File

@ -166,6 +166,11 @@ const ShipmentsView = () => {
<p>{shipments?.businessname}</p> <p>{shipments?.businessname}</p>
</div> </div>
<div className={'mb-4'}>
<p className={'block font-bold mb-2'}>Business</p>
<p>{shipments?.business}</p>
</div>
<> <>
<p className={'block font-bold mb-2'}>Quotes Shipment</p> <p className={'block font-bold mb-2'}>Quotes Shipment</p>
<CardBox <CardBox

View File

@ -78,7 +78,7 @@ module.exports = {
diversityMain: '#5A7BEB', diversityMain: '#5A7BEB',
diversityHeader: '#5A7BEB', diversityHeader: '#5A7BEB',
websiteBG: '#FFFFFF', websiteBG: '#EDF2FA',
900: '#14142A', 900: '#14142A',
800: '#DFE7F4', 800: '#DFE7F4',
}, },