Skip to content

Commit

Permalink
feat(data): adding abbreviation and text for inventory unit for more …
Browse files Browse the repository at this point in the history
…clarity
  • Loading branch information
DedrickEnc committed Oct 10, 2017
1 parent f3936cc commit 1b22336
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
6 changes: 4 additions & 2 deletions client/src/modules/inventory/configuration/units/units.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<thead>
<tr>
<th>#</th>
<th translate>FORM.LABELS.ABBREVIATION</th>
<th translate>FORM.LABELS.LABEL</th>
<th>&nbsp;</th>
</tr>
Expand All @@ -26,14 +27,15 @@
<tbody>
<tr ng-repeat="unit in UnitsCtrl.unitList | orderBy: 'text' track by unit.id">
<td>{{ $index + 1 }}</td>
<td>{{ unit.abbr }}</td>
<td>{{ unit.text }}</td>
<td>
<a href ng-click="UnitsCtrl.editInventoryUnit(unit.id)" data-edit-unit="{{ unit.text }}">
<a href ng-click="UnitsCtrl.editInventoryUnit(unit.id)" data-edit-unit="{{ unit.abbr }}">
<i class="fa fa-edit"></i> <span translate>FORM.BUTTONS.EDIT</span>
</a>
</td>
<td>
<a href ng-click="UnitsCtrl.deleteInventoryUnit(unit.id)" data-delete-unit="{{ unit.text }}" class="text-danger">
<a href ng-click="UnitsCtrl.deleteInventoryUnit(unit.id)" data-delete-unit="{{ unit.abbr }}" class="text-danger">
<i class="fa fa-remove"></i> <span translate>FORM.BUTTONS.DELETE</span>
</a>
</td>
Expand Down
4 changes: 2 additions & 2 deletions server/controllers/inventory/inventory/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function getItemsMetadata(params) {
const filters = new FilterParser(params, { tableAlias : 'inventory', autoParseStatements : false });

const sql =
`SELECT BUID(inventory.uuid) as uuid, inventory.code, inventory.text AS label, inventory.price, iu.text AS unit,
`SELECT BUID(inventory.uuid) as uuid, inventory.code, inventory.text AS label, inventory.price, iu.abbr AS unit,
it.text AS type, ig.name AS groupName, BUID(ig.uuid) AS group_uuid, inventory.consumable,inventory.locked, inventory.stock_min,
inventory.stock_max, inventory.created_at AS timestamp, inventory.type_id, inventory.unit_id,
inventory.unit_weight, inventory.unit_volume, ig.sales_account, ig.stock_account, ig.donation_account,
Expand Down Expand Up @@ -155,7 +155,7 @@ function getItemsMetadata(params) {
*/
function getItemsMetadataById(uid) {
const sql =
`SELECT BUID(i.uuid) as uuid, i.code, i.text AS label, i.price, iu.text AS unit,
`SELECT BUID(i.uuid) as uuid, i.code, i.text AS label, i.price, iu.abbr AS unit,
it.text AS type, ig.name AS groupName, BUID(ig.uuid) AS group_uuid, i.consumable, i.locked, i.stock_min,
i.stock_max, i.created_at AS timestamp, i.type_id, i.unit_id, i.unit_weight, i.unit_volume,
ig.sales_account, i.default_quantity, i.avg_consumption, i.delay, i.purchase_interval
Expand Down
4 changes: 2 additions & 2 deletions server/controllers/inventory/inventory/units.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function details(identifier) {

/** create new inventory unit */
function create(record) {
const sql = 'INSERT INTO inventory_unit (text) VALUES (?);';
const sql = 'INSERT INTO inventory_unit (abbr, text) VALUES (?, ?);';
/*
* return a promise which can contains result or error which is caught
* in the main controller (inventory.js)
Expand Down Expand Up @@ -56,6 +56,6 @@ function remove(id) {
* @param {number} id - the unit id is optional
*/
function getUnits(id) {
const sql = `SELECT id, text FROM inventory_unit ${id ? ' WHERE id = ?;' : ';'}`;
const sql = `SELECT id, abbr, text FROM inventory_unit ${id ? ' WHERE id = ?;' : ';'}`;
return db.exec(sql, [id]);
}
2 changes: 1 addition & 1 deletion server/models/bhima.sql
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ INSERT INTO `currency` (`id`, `name`, `format_key`, `symbol`, `note`, `min_monen
(2,'United States Dollars','usd','$',NULL,0.01);

INSERT INTO `inventory_type` VALUES (1,'Article'),(2,'Assembly'),(3,'Service');
INSERT INTO `inventory_unit` VALUES (1,'Act'),(2,'Pallet'),(3,'Pill'),(4,'Box'),(5,'Lot'),(6,'amp'),(7,'bags'),(8,'btl'),(9,'cap'),(10,'flc'),(11,'jar'),(12,'ltr'),(13,'pce'),(14,'sch'),(15,'tab'),(16,'tub'),(17,'vial');
INSERT INTO `inventory_unit` VALUES (1,'Act', 'Act'),(2,'Pal', 'Pallet'),(3,'Pill', 'Pillule'),(4,'Box', 'Box'),(5,'Lot', 'Lot'),(6,'amp', 'ampoule'),(7,'bags', 'bags'),(8,'btl', 'bouteille'),(9,'cap', 'capsule'),(10,'flc', 'flacon'),(11,'jar', 'jar'),(12,'ltr', 'littre'),(13,'pce', 'piece'),(14,'sch', 'sachet'),(15,'tab', 'tablette'),(16,'tub', 'tube'),(17,'vial', 'vial');

-- fonctions
INSERT INTO `fonction` VALUES
Expand Down
6 changes: 4 additions & 2 deletions server/models/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -924,9 +924,11 @@ DROP TABLE IF EXISTS `inventory_unit`;

CREATE TABLE `inventory_unit` (
`id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`text` varchar(100) NOT NULL,
`abbr` varchar(10) NOT NULL,
`text` varchar(30) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `inventory_unit_1` (`text`)
UNIQUE KEY `inventory_unit_1` (`text`),
UNIQUE KEY `inventory_unit_2` (`abbr`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


Expand Down

0 comments on commit 1b22336

Please sign in to comment.