Skip to content

Commit

Permalink
use of integer for importance levels
Browse files Browse the repository at this point in the history
  • Loading branch information
mbayopanda authored and jniles committed Sep 10, 2020
1 parent 868f18b commit f3f3382
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
5 changes: 5 additions & 0 deletions client/src/js/constants/bhConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,10 @@ function constantConfig() {
CANCELLED : 5,
EXCESSIVE_RECEIVED_QUANTITY : 6,
},
inventoryImportanceLevel : {
LOW : 1,
MID : 2,
HIGH : 3,
},
};
}
6 changes: 3 additions & 3 deletions client/src/modules/inventory/list/modals/actions.tmpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@
name="importance"
ng-model="$ctrl.item.importance">
<option value="" disabled translate>INVENTORY.IMPORTANCE_LEVEL_SELECT</option>
<option value="LOW" translate>INVENTORY.LOW</option>
<option value="MID" translate>INVENTORY.MID</option>
<option value="HIGH" translate>INVENTORY.HIGH</option>
<option ng-value="1" translate>INVENTORY.LOW</option>
<option ng-value="2" translate>INVENTORY.MID</option>
<option ng-value="3" translate>INVENTORY.HIGH</option>
</select>
</div>

Expand Down
2 changes: 1 addition & 1 deletion server/models/migrations/next/migrate.sql
Original file line number Diff line number Diff line change
Expand Up @@ -744,5 +744,5 @@ CREATE TABLE `stock_movement_status` (
* @date: 2020-09-07
* @description: Add the importance level column in the inventory table
*/
ALTER TABLE inventory ADD COLUMN `importance` VARCHAR(20) NULL COMMENT 'Inventory level of importance : LOW, MID, HIGH';
ALTER TABLE inventory ADD COLUMN `importance` SMALLINT(5) NULL COMMENT 'Inventory level of importance : 1 -> LOW, 2 -> MID, 3 -> HIGH';
ALTER TABLE inventory ADD COLUMN `tracker` TINYINT(1) NOT NULL DEFAULT 0;
4 changes: 2 additions & 2 deletions server/models/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -774,12 +774,12 @@ CREATE TABLE `inventory` (
`locked` TINYINT(1) NOT NULL DEFAULT 0,
`delay` DECIMAL(10,4) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Delivery time',
`avg_consumption` DECIMAL(10,4) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Average consumption' ,
`purchase_INTerval` DECIMAL(10,4) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Purchase Order INTerval' ,
`purchase_interval` DECIMAL(10,4) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Purchase Order Interval' ,
`last_purchase` DATE NULL COMMENT 'This element allows to store the date of the last purchase order of the product in order to allow the calculation without making much of the average ordering INTerval',
`num_purchase` INT(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Number of purchase orders' ,
`num_delivery` INT(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Number of stock delivery' ,
`tracker` TINYINT(1) NOT NULL DEFAULT 0 ,
`importance` VARCHAR(20) NULL COMMENT 'Inventory level of importance : LOW, MID, HIGH' ,
`importance` SMALLINT(5) NULL COMMENT 'Inventory level of importance : 1 -> LOW, 2 -> MID, 3 -> HIGH' ,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`uuid`),
Expand Down
9 changes: 3 additions & 6 deletions test/integration/inventory/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('(/inventory/metadata) The inventory metadata http API', () => {
consumable : 0,
sellable : 1,
tracker : 1,
importance : 'MID',
importance : 2,
};

const inventoryUuid = 'f6556e72-9d05-4799-8cbd-0a03b1810185';
Expand All @@ -45,7 +45,6 @@ describe('(/inventory/metadata) The inventory metadata http API', () => {
.catch(helpers.handler);
});


it('POST /inventory/metadata create a new inventory metadata', () => {
return agent.post('/inventory/metadata')
.send(metadata)
Expand All @@ -56,7 +55,6 @@ describe('(/inventory/metadata) The inventory metadata http API', () => {
.catch(helpers.handler);
});


it('PUT /inventory/metadata/:uuid update an existing inventory metadata', () => {
return agent.put(`/inventory/metadata/${metadata.uuid}`)
.send(metadataUpdate)
Expand Down Expand Up @@ -122,11 +120,11 @@ describe('(/inventory/metadata) The inventory metadata http API', () => {

it('GET /inventory/metadata filters on the importance column', () => {
return agent.get('/inventory/metadata')
.query({ importance : 'MID' })
.query({ importance : 2 })
.then(res => {
helpers.api.listed(res, 1);
const [item] = res.body;
expect(item.importance).to.equal('MID');
expect(item.importance).to.equal(2);
})
.catch(helpers.handler);
});
Expand Down Expand Up @@ -212,7 +210,6 @@ describe('(/inventory/metadata) The inventory metadata http API', () => {
.catch(helpers.handler);
});


// count inventory in the group
it('GET /inventory/groups/:uuid/count', () => {
return agent.get(`/inventory/groups/${shared.inventoryGroup.uuid}/count`)
Expand Down

0 comments on commit f3f3382

Please sign in to comment.