Skip to content

Commit

Permalink
Removed condition from shipment items
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcameron committed Apr 13, 2022
1 parent de0ffa5 commit 1406ff5
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 68 deletions.
22 changes: 11 additions & 11 deletions client/src/i18n/en/shipment.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@
"UPDATE_PACKING_LIST": "Update Packing List",
"UPDATE_STATUS": "Update Status",
"UPDATE_TRACKING_LOG_MESSAGE": "Please provide current shipping location and other important new information",
"UPDATE_TRACKING_LOG_WARNING": "You cannot update the tracking log, as only shipments with IN-TRANSIT status can be updated"
},
"STATUS" : {
"EMPTY" : "Empty",
"PARTIAL" : "Partial",
"COMPLETE" : "Complete",
"IN_TRANSIT" : "In Transit",
"DELIVERED" : "Delivered",
"AT_DEPOT" : "At Depot",
"READY_FOR_SHIPMENT" : "Ready for shipment",
"LOST" : "LOST"
"UPDATE_TRACKING_LOG_WARNING": "You cannot update the tracking log, as only shipments with IN-TRANSIT status can be updated",
"STATUS" : {
"EMPTY" : "Empty",
"PARTIAL" : "Partial",
"COMPLETE" : "Complete",
"IN_TRANSIT" : "In Transit",
"DELIVERED" : "Delivered",
"AT_DEPOT" : "At Depot",
"READY_FOR_SHIPMENT" : "Ready for shipment",
"LOST" : "Lost"
}
}
}
22 changes: 11 additions & 11 deletions client/src/i18n/fr/shipment.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@
"UPDATE_PACKING_LIST": "Mise à jour colisage",
"UPDATE_STATUS": "Mise à jour statut",
"UPDATE_TRACKING_LOG_MESSAGE": "Veuillez préciser la localisation actuelle de l'expédition et d'autres nouvelles informations importantes",
"UPDATE_TRACKING_LOG_WARNING": "Vous ne pouvez pas mettre à jour le journal de suivi, car seule les expéditions ayant un statut EN-TRANSIT peuvent être mise à jour"
},
"STATUS" : {
"EMPTY" : "Vide",
"PARTIAL" : "En partie",
"COMPLETE" : "Complète",
"IN_TRANSIT" : "En transit",
"DELIVERED" : "Livré",
"AT_DEPOT" : "Au dépôt",
"READY_FOR_SHIPMENT" : "Prêt pour l'expédition",
"LOST" : "Perdu"
"UPDATE_TRACKING_LOG_WARNING": "Vous ne pouvez pas mettre à jour le journal de suivi, car seule les expéditions ayant un statut EN-TRANSIT peuvent être mise à jour",
"STATUS" : {
"EMPTY" : "Vide",
"PARTIAL" : "En partie",
"COMPLETE" : "Complète",
"IN_TRANSIT" : "En transit",
"DELIVERED" : "Livré",
"AT_DEPOT" : "Au dépôt",
"READY_FOR_SHIPMENT" : "Prêt pour l'expédition",
"LOST" : "Perdu"
}
}
}
8 changes: 0 additions & 8 deletions client/src/modules/shipment/create-shipment.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@ function CreateShipmentController(
headerCellFilter : 'translate',
cellTemplate : 'modules/stock/exit/templates/available.tmpl.html',
}, {
field : 'condition',
width : 150,
displayName : 'SHIPMENT.LOT_CONDITION',
headerCellFilter : 'translate',
cellTemplate : 'modules/shipment/templates/condition.tmpl.html',
},
{
displayName : '',
field : 'actions',
width : 25,
Expand Down Expand Up @@ -348,7 +341,6 @@ function CreateShipmentController(
return {
lot_uuid : row.lot_uuid,
quantity : row.quantity,
condition_id : row.condition_id,
};
}

Expand Down
1 change: 0 additions & 1 deletion client/src/modules/shipment/modals/overview.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ <h3 class="text-center">{{ $ctrl.shipment.name }}</h3>
<td>{{ item.inventory_label }}</td>
<td>{{ item.lot_label }}</td>
<td>{{ item.quantity_sent }}</td>
<td translate>{{ item.condition }}</td>
</tr>
</table>
</div>
Expand Down
19 changes: 19 additions & 0 deletions client/src/modules/shipment/shipment.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,61 +38,80 @@ function ShipmentRegistryController(
{
field : 'status',
displayName : 'TABLE.COLUMNS.STATUS',
headerTooltip : 'TABLE.COLUMNS.STATUS',
headerCellFilter : 'translate',
cellFilter : 'translate',
},
{
field : 'reference',
displayName : 'SHIPMENT.REFERENCE',
headerTooltip : 'SHIPMENT.REFERENCE',
headerCellFilter : 'translate',
headerCellClass : 'wrappingColHeader',
},
{
field : 'stock_reference',
displayName : 'SHIPMENT.STOCK_REFERENCE',
headerTooltip : 'SHIPMENT.STOCK_REFERENCE',
headerCellFilter : 'translate',
headerCellClass : 'wrappingColHeader',
},
{
field : 'name',
displayName : 'TABLE.COLUMNS.NAME',
headerTooltip : 'TABLE.COLUMNS.NAME',
headerCellFilter : 'translate',
},
{
field : 'description',
displayName : 'TABLE.COLUMNS.DESCRIPTION',
headerTooltip : 'TABLE.COLUMNS.DESCRIPTION',
headerCellFilter : 'translate',
headerCellClass : 'wrappingColHeader',
},
{
field : 'origin_depot',
displayName : 'SHIPMENT.ORIGIN_DEPOT',
headerTooltip : 'SHIPMENT.ORIGIN_DEPOT',
headerCellFilter : 'translate',
headerCellClass : 'wrappingColHeader',
},
{
field : 'destination_depot',
displayName : 'SHIPMENT.DESTINATION_DEPOT',
headerTooltip : 'SHIPMENT.DESTINATION_DEPOT',
headerCellFilter : 'translate',
headerCellClass : 'wrappingColHeader',
},
{
field : 'date_sent',
displayName : 'SHIPMENT.DATE_SENT',
headerTooltip : 'SHIPMENT.DATE_SENT',
headerCellFilter : 'translate',
headerCellClass : 'wrappingColHeader',
cellFilter : 'date',
},
{
field : 'date_delivered',
displayName : 'SHIPMENT.DATE_DELIVERED',
headerTooltip : 'SHIPMENT.DATE_DELIVERED',
headerCellFilter : 'translate',
headerCellClass : 'wrappingColHeader',
cellFilter : 'date',
},
{
field : 'anticipated_delivery_date',
displayName : 'SHIPMENT.ANTICIPATED_DELIVERY_DATE',
headerTooltip : 'SHIPMENT.ANTICIPATED_DELIVERY_DATE',
headerCellFilter : 'translate',
cellFilter : 'date',
},
{
field : 'created_by',
displayName : 'SHIPMENT.CREATED_BY',
headerTooltip : 'SHIPMENT.CREATED_BY',
headerCellFilter : 'translate',
headerCellClass : 'wrappingColHeader',
},
{
field : 'action',
Expand Down
14 changes: 0 additions & 14 deletions client/src/modules/shipment/templates/condition.tmpl.html

This file was deleted.

10 changes: 2 additions & 8 deletions server/controllers/asset_management/shipment/shipment.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ exports.create = async (req, res, next) => {
lot_uuid : db.bid(lot.lot_uuid),
date_packed : new Date(),
quantity_sent : lot.quantity,
condition_id : lot.condition_id,
};
transaction.addQuery('INSERT INTO shipment_item SET ?', shipmentItem);
});
Expand Down Expand Up @@ -155,7 +154,6 @@ exports.update = async (req, res, next) => {
lot_uuid : db.bid(lot.lot_uuid),
date_packed : new Date(),
quantity_sent : lot.quantity,
condition_id : lot.condition_id,
};
transaction.addQuery('INSERT INTO shipment_item SET ?', [shipmentItem]);
});
Expand Down Expand Up @@ -558,7 +556,7 @@ async function lookup(identifier) {
sh.created_at AS date, sh.date_sent, sh.date_delivered,
sh.anticipated_delivery_date, sh.date_ready_for_shipment,
sh.receiver, u.display_name AS created_by,
BUID(shi.lot_uuid) AS lot_uuid, shi.quantity_sent AS quantity, shi.condition_id
BUID(shi.lot_uuid) AS lot_uuid, shi.quantity_sent AS quantity
FROM shipment sh
JOIN shipment_item shi ON shi.shipment_uuid = sh.uuid
JOIN shipment_status ss ON ss.id = sh.status_id
Expand All @@ -576,7 +574,6 @@ async function lookup(identifier) {
return {
lot_uuid : item.lot_uuid,
quantity : item.quantity,
condition_id : item.condition_id,
};
});
return shipment;
Expand Down Expand Up @@ -631,15 +628,12 @@ async function getPackingList(identifier) {
sh.created_at AS date, sh.date_sent, sh.date_delivered,
sh.anticipated_delivery_date,
sh.receiver, u.display_name AS created_by,
shi.quantity_sent, shi.quantity_delivered,
shi.date_packed, shi.condition_id,
c.condition, c.predefined AS condition_predefined,
shi.quantity_sent, shi.quantity_delivered, shi.date_packed,
l.label AS lot_label, i.code AS inventory_code, i.text AS inventory_label,
dm.text AS reference
FROM shipment sh
JOIN shipment_status ss ON ss.id = sh.status_id
JOIN shipment_item shi ON shi.shipment_uuid = sh.uuid
LEFT JOIN asset_condition c ON c.id = shi.condition_id
JOIN lot l ON l.uuid = shi.lot_uuid
JOIN inventory i ON i.uuid = l.inventory_uuid
JOIN user u ON u.id = sh.created_by
Expand Down
2 changes: 2 additions & 0 deletions server/models/admin.sql
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ END $$
Recomputes the lot barcodes from the base data.
*/
DROP PROCEDURE IF EXISTS zRecomputeLotBarcodes$$
CREATE PROCEDURE zRecomputeLotBarcodes()
BEGIN
UPDATE lot SET barcode = CONCAT('LT', LEFT(HEX(lot.uuid), 8));
Expand All @@ -301,6 +302,7 @@ END $$
Gets the balance on an invoice due to a debtor.
*/
DROP PROCEDURE IF EXISTS zGetInvoiceBalance$$
CREATE FUNCTION zGetInvoiceBalance(invoiceUuid BINARY(16))
RETURNS DOUBLE DETERMINISTIC
BEGIN
Expand Down
53 changes: 48 additions & 5 deletions server/models/migrations/next/migrate.sql
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ CREATE TABLE IF NOT EXISTS `shipment` (
`document_uuid` BINARY(16) NULL, /* stock exit document_uuid */
PRIMARY KEY (`uuid`),
CONSTRAINT `shipment__project` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`),
CONSTRAINT `shipment__requisition` FOREIGN KEY (`requisition_uuid`) REFERENCES `requisition` (`uuid`),
CONSTRAINT `shipment__requisition` FOREIGN KEY (`requisition_uuid`) REFERENCES `stock_requisition` (`uuid`),
CONSTRAINT `shipment__origin_depot` FOREIGN KEY (`origin_depot_uuid`) REFERENCES `depot` (`uuid`),
CONSTRAINT `shipment__destination_depot` FOREIGN KEY (`destination_depot_uuid`) REFERENCES `depot` (`uuid`),
CONSTRAINT `shipment__status` FOREIGN KEY (`status_id`) REFERENCES `shipment_status` (`id`),
Expand All @@ -149,13 +149,34 @@ CREATE TABLE IF NOT EXISTS `shipment_item` (
`date_packed` DATETIME,
`quantity_sent` INT(11) UNSIGNED DEFAULT 0,
`quantity_delivered` INT(11) UNSIGNED DEFAULT 0,
`condition_id` SMALLINT(5) UNSIGNED NULL,
`condition_id` SMALLINT(5) UNSIGNED NOT NULL,
PRIMARY KEY (`uuid`),
CONSTRAINT `shipment_item__shipment` FOREIGN KEY (`shipment_uuid`) REFERENCES `shipment` (`uuid`),
CONSTRAINT `shipment_item__lot` FOREIGN KEY (`lot_uuid`) REFERENCES `lot` (`uuid`),
CONSTRAINT `shipment_item__condition` FOREIGN KEY (`condition_id`) REFERENCES `asset_condition` (`id`)
) ENGINE=InnoDB DEFAULT CHARACTER SET = utf8mb4 DEFAULT COLLATE = utf8mb4_unicode_ci;

DELIMITER $$

-- Shipment Triggers
-- the shipment reference is incremented based on the shipment uuid.
DROP TRIGGER IF EXISTS shipment_reference $$
CREATE TRIGGER shipment_reference BEFORE INSERT ON shipment
FOR EACH ROW
SET NEW.reference = (SELECT IF(NEW.reference, NEW.reference, IFNULL(MAX(sh.reference) + 1, 1)) FROM shipment sh WHERE sh.uuid <> NEW.uuid);
$$

-- compute the document map
DROP TRIGGER IF EXISTS shipment_document_map $$
CREATE TRIGGER shipment_document_map AFTER INSERT ON shipment
FOR EACH ROW BEGIN
INSERT INTO `document_map`
SELECT NEW.uuid, CONCAT_WS('.', 'SHIP', project.abbr, new.reference) FROM project WHERE project.id = NEW.project_id
ON DUPLICATE KEY UPDATE text = text;
END$$

DELIMITER ;

/** ADD DEFAULT SHIPMENT STATUS */
INSERT IGNORE INTO `shipment_status` (`id`, `name`, `translation_key`) VALUES
(1, 'empty', 'SHIPMENT.STATUS.EMPTY'),
Expand Down Expand Up @@ -215,7 +236,7 @@ CREATE TABLE IF NOT EXISTS `asset_scan` (
`location_uuid` BINARY(16),
`depot_uuid` BINARY(16), -- NULL if not assigned to a depot
`scanned_by` SMALLINT(5) UNSIGNED NOT NULL,
`condition_id` SMALLINT(5) NOT NULL,
`condition_id` SMALLINT(5) UNSIGNED NOT NULL,
`notes` TEXT DEFAULT NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- This is the official "scan date"
`updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
Expand Down Expand Up @@ -259,10 +280,10 @@ Issue: 6501
@author: jniles
@date: 2022-04-06
*/
DELETE FROM role WHERE unit_id = 167;
DELETE FROM `role_unit` WHERE unit_id = 167;
DELETE FROM `unit` WHERE id = 167;

/*
/**
* adding reports for inventory scanning
* @author: jmcameron
* @date: 2022-04-06
Expand All @@ -273,3 +294,25 @@ INSERT IGNORE INTO unit VALUES

INSERT IGNORE INTO `report` (`report_key`, `title_key`) VALUES
('needed_inventory_scans', 'TREE.INVENTORY_SCANS_NEEDED');

/**
* Remove condition from shipment items
* @author: jmcameron
* @date: 2022-04-07
*/
CALL drop_foreign_key('shipment_item', 'shipment_item__condition');
CALL drop_column_if_exists('shipment_item', 'condition_id');

--
-- WARNING!
--
-- When migrating a production site after a release that uses this migration file,
-- it will be necessary to comment out the triggers
--
-- shipment_reference
--
-- shipment_document_map
--
-- from the triggers.sql file before performing the migration. This is necessary
-- because these triggers refer to the 'shipment' table which does not exist when
-- this file is processed (during migrations).
7 changes: 3 additions & 4 deletions server/models/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1965,7 +1965,7 @@ CREATE TABLE `asset_scan` (
`location_uuid` BINARY(16),
`depot_uuid` BINARY(16), -- NULL if not assigned to a depot
`scanned_by` SMALLINT(5) UNSIGNED NOT NULL,
`condition_id` SMALLINT(5) NOT NULL,
`condition_id` SMALLINT(5) UNSIGNED NOT NULL,
`notes` TEXT DEFAULT NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- This is the official "scan date"
`updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
Expand Down Expand Up @@ -1996,7 +1996,7 @@ CREATE TABLE `required_inventory_scan` (

DROP TABLE IF EXISTS `asset_condition`;
CREATE TABLE `asset_condition` (
`id` SMALLINT(5) NOT NULL AUTO_INCREMENT,
`id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
`condition` VARCHAR(100) NOT NULL, -- Will be treated as a translation token (if predefined)
`predefined` BOOLEAN NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
Expand Down Expand Up @@ -2733,7 +2733,7 @@ CREATE TABLE `shipment` (
`document_uuid` BINARY(16) NULL, /* stock exit document_uuid */
PRIMARY KEY (`uuid`),
CONSTRAINT `shipment__project` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`),
CONSTRAINT `shipment__requisition` FOREIGN KEY (`requisition_uuid`) REFERENCES `requisition` (`uuid`),
CONSTRAINT `shipment__requisition` FOREIGN KEY (`requisition_uuid`) REFERENCES `stock_requisition` (`uuid`),
CONSTRAINT `shipment__origin_depot` FOREIGN KEY (`origin_depot_uuid`) REFERENCES `depot` (`uuid`),
CONSTRAINT `shipment__destination_depot` FOREIGN KEY (`destination_depot_uuid`) REFERENCES `depot` (`uuid`),
CONSTRAINT `shipment__status` FOREIGN KEY (`status_id`) REFERENCES `shipment_status` (`id`),
Expand All @@ -2749,7 +2749,6 @@ CREATE TABLE `shipment_item` (
`date_packed` DATETIME,
`quantity_sent` INT(11) UNSIGNED DEFAULT 0,
`quantity_delivered` INT(11) UNSIGNED DEFAULT 0,
`condition_id` SMALLINT(5) UNSIGNED NULL,
PRIMARY KEY (`uuid`),
CONSTRAINT `shipment_item__shipment` FOREIGN KEY (`shipment_uuid`) REFERENCES `shipment` (`uuid`),
CONSTRAINT `shipment_item__lot` FOREIGN KEY (`lot_uuid`) REFERENCES `lot` (`uuid`)
Expand Down
Loading

0 comments on commit 1406ff5

Please sign in to comment.