v2.1
This commit is contained in:
parent
b645325c25
commit
ed52d17b4b
File diff suppressed because one or more lines are too long
@ -350,7 +350,7 @@ module.exports = class OrdersDBApi {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
tracking_number: {
|
destination: {
|
||||||
[Op.or]: searchTerms.map((term) => ({
|
[Op.or]: searchTerms.map((term) => ({
|
||||||
[Op.iLike]: `%${term}%`,
|
[Op.iLike]: `%${term}%`,
|
||||||
})),
|
})),
|
||||||
|
|||||||
@ -17,6 +17,8 @@ module.exports = class ShipmentsDBApi {
|
|||||||
|
|
||||||
tracking_number: data.tracking_number || null,
|
tracking_number: data.tracking_number || null,
|
||||||
shipment_date: data.shipment_date || null,
|
shipment_date: data.shipment_date || null,
|
||||||
|
carrier: data.carrier || null,
|
||||||
|
destination: data.destination || null,
|
||||||
importHash: data.importHash || null,
|
importHash: data.importHash || null,
|
||||||
createdById: currentUser.id,
|
createdById: currentUser.id,
|
||||||
updatedById: currentUser.id,
|
updatedById: currentUser.id,
|
||||||
@ -49,6 +51,8 @@ module.exports = class ShipmentsDBApi {
|
|||||||
|
|
||||||
tracking_number: item.tracking_number || null,
|
tracking_number: item.tracking_number || null,
|
||||||
shipment_date: item.shipment_date || null,
|
shipment_date: item.shipment_date || null,
|
||||||
|
carrier: item.carrier || null,
|
||||||
|
destination: item.destination || null,
|
||||||
importHash: item.importHash || null,
|
importHash: item.importHash || null,
|
||||||
createdById: currentUser.id,
|
createdById: currentUser.id,
|
||||||
updatedById: currentUser.id,
|
updatedById: currentUser.id,
|
||||||
@ -80,6 +84,11 @@ module.exports = class ShipmentsDBApi {
|
|||||||
if (data.shipment_date !== undefined)
|
if (data.shipment_date !== undefined)
|
||||||
updatePayload.shipment_date = data.shipment_date;
|
updatePayload.shipment_date = data.shipment_date;
|
||||||
|
|
||||||
|
if (data.carrier !== undefined) updatePayload.carrier = data.carrier;
|
||||||
|
|
||||||
|
if (data.destination !== undefined)
|
||||||
|
updatePayload.destination = data.destination;
|
||||||
|
|
||||||
updatePayload.updatedById = currentUser.id;
|
updatePayload.updatedById = currentUser.id;
|
||||||
|
|
||||||
await shipments.update(updatePayload, { transaction });
|
await shipments.update(updatePayload, { transaction });
|
||||||
@ -261,6 +270,20 @@ module.exports = class ShipmentsDBApi {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filter.carrier) {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
[Op.and]: Utils.ilike('shipments', 'carrier', filter.carrier),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.destination) {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
[Op.and]: Utils.ilike('shipments', 'destination', filter.destination),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (filter.calendarStart && filter.calendarEnd) {
|
if (filter.calendarStart && filter.calendarEnd) {
|
||||||
where = {
|
where = {
|
||||||
...where,
|
...where,
|
||||||
@ -408,22 +431,22 @@ module.exports = class ShipmentsDBApi {
|
|||||||
where = {
|
where = {
|
||||||
[Op.or]: [
|
[Op.or]: [
|
||||||
{ ['id']: Utils.uuid(query) },
|
{ ['id']: Utils.uuid(query) },
|
||||||
Utils.ilike('shipments', 'tracking_number', query),
|
Utils.ilike('shipments', 'destination', query),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const records = await db.shipments.findAll({
|
const records = await db.shipments.findAll({
|
||||||
attributes: ['id', 'tracking_number'],
|
attributes: ['id', 'destination'],
|
||||||
where,
|
where,
|
||||||
limit: limit ? Number(limit) : undefined,
|
limit: limit ? Number(limit) : undefined,
|
||||||
offset: offset ? Number(offset) : undefined,
|
offset: offset ? Number(offset) : undefined,
|
||||||
orderBy: [['tracking_number', 'ASC']],
|
orderBy: [['destination', 'ASC']],
|
||||||
});
|
});
|
||||||
|
|
||||||
return records.map((record) => ({
|
return records.map((record) => ({
|
||||||
id: record.id,
|
id: record.id,
|
||||||
label: record.tracking_number,
|
label: record.destination,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
49
backend/src/db/migrations/1749942138871.js
Normal file
49
backend/src/db/migrations/1749942138871.js
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
module.exports = {
|
||||||
|
/**
|
||||||
|
* @param {QueryInterface} queryInterface
|
||||||
|
* @param {Sequelize} Sequelize
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async up(queryInterface, Sequelize) {
|
||||||
|
/**
|
||||||
|
* @type {Transaction}
|
||||||
|
*/
|
||||||
|
const transaction = await queryInterface.sequelize.transaction();
|
||||||
|
try {
|
||||||
|
await queryInterface.addColumn(
|
||||||
|
'shipments',
|
||||||
|
'carrier',
|
||||||
|
{
|
||||||
|
type: Sequelize.DataTypes.TEXT,
|
||||||
|
},
|
||||||
|
{ transaction },
|
||||||
|
);
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* @param {QueryInterface} queryInterface
|
||||||
|
* @param {Sequelize} Sequelize
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async down(queryInterface, Sequelize) {
|
||||||
|
/**
|
||||||
|
* @type {Transaction}
|
||||||
|
*/
|
||||||
|
const transaction = await queryInterface.sequelize.transaction();
|
||||||
|
try {
|
||||||
|
await queryInterface.removeColumn('shipments', 'carrier', {
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
49
backend/src/db/migrations/1749942366797.js
Normal file
49
backend/src/db/migrations/1749942366797.js
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
module.exports = {
|
||||||
|
/**
|
||||||
|
* @param {QueryInterface} queryInterface
|
||||||
|
* @param {Sequelize} Sequelize
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async up(queryInterface, Sequelize) {
|
||||||
|
/**
|
||||||
|
* @type {Transaction}
|
||||||
|
*/
|
||||||
|
const transaction = await queryInterface.sequelize.transaction();
|
||||||
|
try {
|
||||||
|
await queryInterface.addColumn(
|
||||||
|
'shipments',
|
||||||
|
'destination',
|
||||||
|
{
|
||||||
|
type: Sequelize.DataTypes.TEXT,
|
||||||
|
},
|
||||||
|
{ transaction },
|
||||||
|
);
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* @param {QueryInterface} queryInterface
|
||||||
|
* @param {Sequelize} Sequelize
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async down(queryInterface, Sequelize) {
|
||||||
|
/**
|
||||||
|
* @type {Transaction}
|
||||||
|
*/
|
||||||
|
const transaction = await queryInterface.sequelize.transaction();
|
||||||
|
try {
|
||||||
|
await queryInterface.removeColumn('shipments', 'destination', {
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
@ -22,6 +22,14 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
type: DataTypes.DATE,
|
type: DataTypes.DATE,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
carrier: {
|
||||||
|
type: DataTypes.TEXT,
|
||||||
|
},
|
||||||
|
|
||||||
|
destination: {
|
||||||
|
type: DataTypes.TEXT,
|
||||||
|
},
|
||||||
|
|
||||||
importHash: {
|
importHash: {
|
||||||
type: DataTypes.STRING(255),
|
type: DataTypes.STRING(255),
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
|
|||||||
@ -17,7 +17,7 @@ const OrdersData = [
|
|||||||
|
|
||||||
total_amount: 150.75,
|
total_amount: 150.75,
|
||||||
|
|
||||||
status: 'delivered',
|
status: 'pending',
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ const OrdersData = [
|
|||||||
|
|
||||||
total_amount: 200,
|
total_amount: 200,
|
||||||
|
|
||||||
status: 'packed',
|
status: 'returned',
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
@ -49,7 +49,23 @@ const OrdersData = [
|
|||||||
|
|
||||||
total_amount: 99.99,
|
total_amount: 99.99,
|
||||||
|
|
||||||
status: 'returned',
|
status: 'delivered',
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
// type code here for "relation_many" field
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
order_number: 'ORD004',
|
||||||
|
|
||||||
|
order_date: new Date('2023-10-04T14:45:00Z'),
|
||||||
|
|
||||||
|
total_amount: 250.5,
|
||||||
|
|
||||||
|
status: 'pending',
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
@ -85,7 +101,19 @@ const ReturnsData = [
|
|||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
return_id: 'Joseph J. Thomson',
|
return_id: 'Pierre Simon de Laplace',
|
||||||
|
|
||||||
|
return_date: new Date(Date.now()),
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
return_id: 'Johannes Kepler',
|
||||||
|
|
||||||
return_date: new Date(Date.now()),
|
return_date: new Date(Date.now()),
|
||||||
|
|
||||||
@ -108,6 +136,10 @@ const ShipmentsData = [
|
|||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
carrier: 'Jean Baptiste Lamarck',
|
||||||
|
|
||||||
|
destination: 'Alfred Binet',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -120,6 +152,10 @@ const ShipmentsData = [
|
|||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
carrier: 'George Gaylord Simpson',
|
||||||
|
|
||||||
|
destination: 'Albrecht von Haller',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -132,6 +168,26 @@ const ShipmentsData = [
|
|||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
carrier: 'Louis Pasteur',
|
||||||
|
|
||||||
|
destination: 'Marcello Malpighi',
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
tracking_number: 'Noam Chomsky',
|
||||||
|
|
||||||
|
shipment_date: new Date(Date.now()),
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
carrier: 'George Gaylord Simpson',
|
||||||
|
|
||||||
|
destination: 'Gustav Kirchhoff',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -147,6 +203,10 @@ const OrganizationsData = [
|
|||||||
{
|
{
|
||||||
name: 'Magento2 Store',
|
name: 'Magento2 Store',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'Lucretius',
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
// Similar logic for "relation_many"
|
// Similar logic for "relation_many"
|
||||||
@ -184,6 +244,17 @@ async function associateUserWithOrganization() {
|
|||||||
if (User2?.setOrganization) {
|
if (User2?.setOrganization) {
|
||||||
await User2.setOrganization(relatedOrganization2);
|
await User2.setOrganization(relatedOrganization2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedOrganization3 = await Organizations.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
||||||
|
});
|
||||||
|
const User3 = await Users.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (User3?.setOrganization) {
|
||||||
|
await User3.setOrganization(relatedOrganization3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateOrderWithOrganization() {
|
async function associateOrderWithOrganization() {
|
||||||
@ -219,6 +290,17 @@ async function associateOrderWithOrganization() {
|
|||||||
if (Order2?.setOrganization) {
|
if (Order2?.setOrganization) {
|
||||||
await Order2.setOrganization(relatedOrganization2);
|
await Order2.setOrganization(relatedOrganization2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedOrganization3 = await Organizations.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
||||||
|
});
|
||||||
|
const Order3 = await Orders.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Order3?.setOrganization) {
|
||||||
|
await Order3.setOrganization(relatedOrganization3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Similar logic for "relation_many"
|
// Similar logic for "relation_many"
|
||||||
@ -256,6 +338,17 @@ async function associateOrderWithOrganization() {
|
|||||||
if (Order2?.setOrganization) {
|
if (Order2?.setOrganization) {
|
||||||
await Order2.setOrganization(relatedOrganization2);
|
await Order2.setOrganization(relatedOrganization2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedOrganization3 = await Organizations.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
||||||
|
});
|
||||||
|
const Order3 = await Orders.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Order3?.setOrganization) {
|
||||||
|
await Order3.setOrganization(relatedOrganization3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateReturnWithOrder() {
|
async function associateReturnWithOrder() {
|
||||||
@ -291,6 +384,17 @@ async function associateReturnWithOrder() {
|
|||||||
if (Return2?.setOrder) {
|
if (Return2?.setOrder) {
|
||||||
await Return2.setOrder(relatedOrder2);
|
await Return2.setOrder(relatedOrder2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedOrder3 = await Orders.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Orders.count())),
|
||||||
|
});
|
||||||
|
const Return3 = await Returns.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Return3?.setOrder) {
|
||||||
|
await Return3.setOrder(relatedOrder3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateReturnWithOrganization() {
|
async function associateReturnWithOrganization() {
|
||||||
@ -326,6 +430,17 @@ async function associateReturnWithOrganization() {
|
|||||||
if (Return2?.setOrganization) {
|
if (Return2?.setOrganization) {
|
||||||
await Return2.setOrganization(relatedOrganization2);
|
await Return2.setOrganization(relatedOrganization2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedOrganization3 = await Organizations.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
||||||
|
});
|
||||||
|
const Return3 = await Returns.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Return3?.setOrganization) {
|
||||||
|
await Return3.setOrganization(relatedOrganization3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateReturnWithOrganization() {
|
async function associateReturnWithOrganization() {
|
||||||
@ -361,6 +476,17 @@ async function associateReturnWithOrganization() {
|
|||||||
if (Return2?.setOrganization) {
|
if (Return2?.setOrganization) {
|
||||||
await Return2.setOrganization(relatedOrganization2);
|
await Return2.setOrganization(relatedOrganization2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedOrganization3 = await Organizations.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
||||||
|
});
|
||||||
|
const Return3 = await Returns.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Return3?.setOrganization) {
|
||||||
|
await Return3.setOrganization(relatedOrganization3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateShipmentWithOrder() {
|
async function associateShipmentWithOrder() {
|
||||||
@ -396,6 +522,17 @@ async function associateShipmentWithOrder() {
|
|||||||
if (Shipment2?.setOrder) {
|
if (Shipment2?.setOrder) {
|
||||||
await Shipment2.setOrder(relatedOrder2);
|
await Shipment2.setOrder(relatedOrder2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedOrder3 = await Orders.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Orders.count())),
|
||||||
|
});
|
||||||
|
const Shipment3 = await Shipments.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Shipment3?.setOrder) {
|
||||||
|
await Shipment3.setOrder(relatedOrder3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateShipmentWithOrganization() {
|
async function associateShipmentWithOrganization() {
|
||||||
@ -431,6 +568,17 @@ async function associateShipmentWithOrganization() {
|
|||||||
if (Shipment2?.setOrganization) {
|
if (Shipment2?.setOrganization) {
|
||||||
await Shipment2.setOrganization(relatedOrganization2);
|
await Shipment2.setOrganization(relatedOrganization2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedOrganization3 = await Organizations.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
||||||
|
});
|
||||||
|
const Shipment3 = await Shipments.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Shipment3?.setOrganization) {
|
||||||
|
await Shipment3.setOrganization(relatedOrganization3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function associateShipmentWithOrganization() {
|
async function associateShipmentWithOrganization() {
|
||||||
@ -466,6 +614,17 @@ async function associateShipmentWithOrganization() {
|
|||||||
if (Shipment2?.setOrganization) {
|
if (Shipment2?.setOrganization) {
|
||||||
await Shipment2.setOrganization(relatedOrganization2);
|
await Shipment2.setOrganization(relatedOrganization2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedOrganization3 = await Organizations.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
||||||
|
});
|
||||||
|
const Shipment3 = await Shipments.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Shipment3?.setOrganization) {
|
||||||
|
await Shipment3.setOrganization(relatedOrganization3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@ -25,6 +25,12 @@ router.use(checkCrudPermissions('shipments'));
|
|||||||
* tracking_number:
|
* tracking_number:
|
||||||
* type: string
|
* type: string
|
||||||
* default: tracking_number
|
* default: tracking_number
|
||||||
|
* carrier:
|
||||||
|
* type: string
|
||||||
|
* default: carrier
|
||||||
|
* destination:
|
||||||
|
* type: string
|
||||||
|
* default: destination
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -310,7 +316,14 @@ router.get(
|
|||||||
currentUser,
|
currentUser,
|
||||||
});
|
});
|
||||||
if (filetype && filetype === 'csv') {
|
if (filetype && filetype === 'csv') {
|
||||||
const fields = ['id', 'tracking_number', 'shipment_date'];
|
const fields = [
|
||||||
|
'id',
|
||||||
|
'tracking_number',
|
||||||
|
'carrier',
|
||||||
|
'destination',
|
||||||
|
|
||||||
|
'shipment_date',
|
||||||
|
];
|
||||||
const opts = { fields };
|
const opts = { fields };
|
||||||
try {
|
try {
|
||||||
const csv = parse(payload.rows, opts);
|
const csv = parse(payload.rows, opts);
|
||||||
|
|||||||
@ -47,7 +47,7 @@ module.exports = class SearchService {
|
|||||||
|
|
||||||
returns: ['return_id'],
|
returns: ['return_id'],
|
||||||
|
|
||||||
shipments: ['tracking_number'],
|
shipments: ['tracking_number', 'carrier', 'destination'],
|
||||||
|
|
||||||
organizations: ['name'],
|
organizations: ['name'],
|
||||||
};
|
};
|
||||||
|
|||||||
1
frontend/json/runtimeError.json
Normal file
1
frontend/json/runtimeError.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
@ -62,7 +62,7 @@ const CardShipments = ({
|
|||||||
href={`/shipments/shipments-view/?id=${item.id}`}
|
href={`/shipments/shipments-view/?id=${item.id}`}
|
||||||
className='text-lg font-bold leading-6 line-clamp-1'
|
className='text-lg font-bold leading-6 line-clamp-1'
|
||||||
>
|
>
|
||||||
{item.tracking_number}
|
{item.destination}
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<div className='ml-auto '>
|
<div className='ml-auto '>
|
||||||
@ -119,6 +119,28 @@ 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'>
|
||||||
|
Carrier
|
||||||
|
</dt>
|
||||||
|
<dd className='flex items-start gap-x-2'>
|
||||||
|
<div className='font-medium line-clamp-4'>
|
||||||
|
{item.carrier}
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='flex justify-between gap-x-4 py-3'>
|
||||||
|
<dt className=' text-gray-500 dark:text-dark-600'>
|
||||||
|
Destination
|
||||||
|
</dt>
|
||||||
|
<dd className='flex items-start gap-x-2'>
|
||||||
|
<div className='font-medium line-clamp-4'>
|
||||||
|
{item.destination}
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
</dl>
|
</dl>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@ -80,6 +80,16 @@ const ListShipments = ({
|
|||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className={'flex-1 px-3'}>
|
||||||
|
<p className={'text-xs text-gray-500 '}>Carrier</p>
|
||||||
|
<p className={'line-clamp-2'}>{item.carrier}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'flex-1 px-3'}>
|
||||||
|
<p className={'text-xs text-gray-500 '}>Destination</p>
|
||||||
|
<p className={'line-clamp-2'}>{item.destination}</p>
|
||||||
|
</div>
|
||||||
</Link>
|
</Link>
|
||||||
<ListActionsPopover
|
<ListActionsPopover
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
|
|||||||
@ -106,6 +106,30 @@ export const loadColumns = async (
|
|||||||
params?.value?.id ?? params?.value,
|
params?.value?.id ?? params?.value,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'carrier',
|
||||||
|
headerName: 'Carrier',
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 120,
|
||||||
|
filterable: false,
|
||||||
|
headerClassName: 'datagrid--header',
|
||||||
|
cellClassName: 'datagrid--cell',
|
||||||
|
|
||||||
|
editable: hasUpdatePermission,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'destination',
|
||||||
|
headerName: 'Destination',
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 120,
|
||||||
|
filterable: false,
|
||||||
|
headerClassName: 'datagrid--header',
|
||||||
|
cellClassName: 'datagrid--cell',
|
||||||
|
|
||||||
|
editable: hasUpdatePermission,
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'actions',
|
field: 'actions',
|
||||||
type: 'actions',
|
type: 'actions',
|
||||||
|
|||||||
@ -60,21 +60,21 @@ export default {
|
|||||||
|
|
||||||
shipmentsManyListFormatter(val) {
|
shipmentsManyListFormatter(val) {
|
||||||
if (!val || !val.length) return [];
|
if (!val || !val.length) return [];
|
||||||
return val.map((item) => item.tracking_number);
|
return val.map((item) => item.destination);
|
||||||
},
|
},
|
||||||
shipmentsOneListFormatter(val) {
|
shipmentsOneListFormatter(val) {
|
||||||
if (!val) return '';
|
if (!val) return '';
|
||||||
return val.tracking_number;
|
return val.destination;
|
||||||
},
|
},
|
||||||
shipmentsManyListFormatterEdit(val) {
|
shipmentsManyListFormatterEdit(val) {
|
||||||
if (!val || !val.length) return [];
|
if (!val || !val.length) return [];
|
||||||
return val.map((item) => {
|
return val.map((item) => {
|
||||||
return { id: item.id, label: item.tracking_number };
|
return { id: item.id, label: item.destination };
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
shipmentsOneListFormatterEdit(val) {
|
shipmentsOneListFormatterEdit(val) {
|
||||||
if (!val) return '';
|
if (!val) return '';
|
||||||
return { label: val.tracking_number, id: val.id };
|
return { label: val.destination, id: val.id };
|
||||||
},
|
},
|
||||||
|
|
||||||
rolesManyListFormatter(val) {
|
rolesManyListFormatter(val) {
|
||||||
|
|||||||
@ -170,7 +170,7 @@ const EditOrders = () => {
|
|||||||
component={SelectFieldMany}
|
component={SelectFieldMany}
|
||||||
options={initialValues.shipments}
|
options={initialValues.shipments}
|
||||||
itemRef={'shipments'}
|
itemRef={'shipments'}
|
||||||
showField={'tracking_number'}
|
showField={'destination'}
|
||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
|||||||
@ -168,7 +168,7 @@ const EditOrdersPage = () => {
|
|||||||
component={SelectFieldMany}
|
component={SelectFieldMany}
|
||||||
options={initialValues.shipments}
|
options={initialValues.shipments}
|
||||||
itemRef={'shipments'}
|
itemRef={'shipments'}
|
||||||
showField={'tracking_number'}
|
showField={'destination'}
|
||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
|||||||
@ -113,6 +113,10 @@ const OrdersView = () => {
|
|||||||
<th>TrackingNumber</th>
|
<th>TrackingNumber</th>
|
||||||
|
|
||||||
<th>ShipmentDate</th>
|
<th>ShipmentDate</th>
|
||||||
|
|
||||||
|
<th>Carrier</th>
|
||||||
|
|
||||||
|
<th>Destination</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -136,6 +140,10 @@ const OrdersView = () => {
|
|||||||
item.shipment_date,
|
item.shipment_date,
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
<td data-label='carrier'>{item.carrier}</td>
|
||||||
|
|
||||||
|
<td data-label='destination'>{item.destination}</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -207,6 +215,10 @@ const OrdersView = () => {
|
|||||||
<th>TrackingNumber</th>
|
<th>TrackingNumber</th>
|
||||||
|
|
||||||
<th>ShipmentDate</th>
|
<th>ShipmentDate</th>
|
||||||
|
|
||||||
|
<th>Carrier</th>
|
||||||
|
|
||||||
|
<th>Destination</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -230,6 +242,10 @@ const OrdersView = () => {
|
|||||||
item.shipment_date,
|
item.shipment_date,
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
<td data-label='carrier'>{item.carrier}</td>
|
||||||
|
|
||||||
|
<td data-label='destination'>{item.destination}</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@ -309,6 +309,10 @@ const OrganizationsView = () => {
|
|||||||
<th>TrackingNumber</th>
|
<th>TrackingNumber</th>
|
||||||
|
|
||||||
<th>ShipmentDate</th>
|
<th>ShipmentDate</th>
|
||||||
|
|
||||||
|
<th>Carrier</th>
|
||||||
|
|
||||||
|
<th>Destination</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -332,6 +336,10 @@ const OrganizationsView = () => {
|
|||||||
item.shipment_date,
|
item.shipment_date,
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
<td data-label='carrier'>{item.carrier}</td>
|
||||||
|
|
||||||
|
<td data-label='destination'>{item.destination}</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -356,6 +364,10 @@ const OrganizationsView = () => {
|
|||||||
<th>TrackingNumber</th>
|
<th>TrackingNumber</th>
|
||||||
|
|
||||||
<th>ShipmentDate</th>
|
<th>ShipmentDate</th>
|
||||||
|
|
||||||
|
<th>Carrier</th>
|
||||||
|
|
||||||
|
<th>Destination</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -379,6 +391,10 @@ const OrganizationsView = () => {
|
|||||||
item.shipment_date,
|
item.shipment_date,
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
<td data-label='carrier'>{item.carrier}</td>
|
||||||
|
|
||||||
|
<td data-label='destination'>{item.destination}</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@ -47,6 +47,10 @@ const EditShipments = () => {
|
|||||||
organization: null,
|
organization: null,
|
||||||
|
|
||||||
organizations: null,
|
organizations: null,
|
||||||
|
|
||||||
|
carrier: '',
|
||||||
|
|
||||||
|
destination: '',
|
||||||
};
|
};
|
||||||
const [initialValues, setInitialValues] = useState(initVals);
|
const [initialValues, setInitialValues] = useState(initVals);
|
||||||
|
|
||||||
@ -161,6 +165,14 @@ const EditShipments = () => {
|
|||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Carrier'>
|
||||||
|
<Field name='carrier' placeholder='Carrier' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Destination'>
|
||||||
|
<Field name='destination' placeholder='Destination' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
<BaseButtons>
|
<BaseButtons>
|
||||||
<BaseButton type='submit' color='info' label='Submit' />
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
|||||||
@ -47,6 +47,10 @@ const EditShipmentsPage = () => {
|
|||||||
organization: null,
|
organization: null,
|
||||||
|
|
||||||
organizations: null,
|
organizations: null,
|
||||||
|
|
||||||
|
carrier: '',
|
||||||
|
|
||||||
|
destination: '',
|
||||||
};
|
};
|
||||||
const [initialValues, setInitialValues] = useState(initVals);
|
const [initialValues, setInitialValues] = useState(initVals);
|
||||||
|
|
||||||
@ -159,6 +163,14 @@ const EditShipmentsPage = () => {
|
|||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Carrier'>
|
||||||
|
<Field name='carrier' placeholder='Carrier' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Destination'>
|
||||||
|
<Field name='destination' placeholder='Destination' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
<BaseButtons>
|
<BaseButtons>
|
||||||
<BaseButton type='submit' color='info' label='Submit' />
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
|||||||
@ -30,6 +30,8 @@ const ShipmentsTablesPage = () => {
|
|||||||
|
|
||||||
const [filters] = useState([
|
const [filters] = useState([
|
||||||
{ label: 'TrackingNumber', title: 'tracking_number' },
|
{ label: 'TrackingNumber', title: 'tracking_number' },
|
||||||
|
{ label: 'Carrier', title: 'carrier' },
|
||||||
|
{ label: 'Destination', title: 'destination' },
|
||||||
|
|
||||||
{ label: 'ShipmentDate', title: 'shipment_date', date: 'true' },
|
{ label: 'ShipmentDate', title: 'shipment_date', date: 'true' },
|
||||||
|
|
||||||
|
|||||||
@ -42,6 +42,10 @@ const initialValues = {
|
|||||||
organization: '',
|
organization: '',
|
||||||
|
|
||||||
organizations: '',
|
organizations: '',
|
||||||
|
|
||||||
|
carrier: '',
|
||||||
|
|
||||||
|
destination: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
const ShipmentsNew = () => {
|
const ShipmentsNew = () => {
|
||||||
@ -113,6 +117,14 @@ const ShipmentsNew = () => {
|
|||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Carrier'>
|
||||||
|
<Field name='carrier' placeholder='Carrier' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Destination'>
|
||||||
|
<Field name='destination' placeholder='Destination' />
|
||||||
|
</FormField>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
<BaseButtons>
|
<BaseButtons>
|
||||||
<BaseButton type='submit' color='info' label='Submit' />
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
|||||||
@ -30,6 +30,8 @@ const ShipmentsTablesPage = () => {
|
|||||||
|
|
||||||
const [filters] = useState([
|
const [filters] = useState([
|
||||||
{ label: 'TrackingNumber', title: 'tracking_number' },
|
{ label: 'TrackingNumber', title: 'tracking_number' },
|
||||||
|
{ label: 'Carrier', title: 'carrier' },
|
||||||
|
{ label: 'Destination', title: 'destination' },
|
||||||
|
|
||||||
{ label: 'ShipmentDate', title: 'shipment_date', date: 'true' },
|
{ label: 'ShipmentDate', title: 'shipment_date', date: 'true' },
|
||||||
|
|
||||||
|
|||||||
@ -104,6 +104,16 @@ const ShipmentsView = () => {
|
|||||||
<p>{shipments?.organizations?.name ?? 'No data'}</p>
|
<p>{shipments?.organizations?.name ?? 'No data'}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Carrier</p>
|
||||||
|
<p>{shipments?.carrier}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={'mb-4'}>
|
||||||
|
<p className={'block font-bold mb-2'}>Destination</p>
|
||||||
|
<p>{shipments?.destination}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
|
|
||||||
<BaseButton
|
<BaseButton
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user