Skip to content

Commit

Permalink
feat(inventory): Adding locking functionnality
Browse files Browse the repository at this point in the history
  • Loading branch information
DedrickEnc committed Oct 2, 2017
1 parent dfd07ad commit d9cb36a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
7 changes: 7 additions & 0 deletions client/src/modules/inventory/list/modals/actions.tmpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@
</label>
</div>

<div class="checkbox" ng-if="$ctrl.isUpdateState">
<label>
<input type="checkbox" name="locked" ng-true-value="1" ng-false-value="0" ng-model="$ctrl.item.locked">
<span translate>FORM.LABELS.LOCKED</span>
</label>
</div>

<div class="form-group"
ng-class="{ 'has-error' : ActionForm.$submitted && ActionForm.price.$invalid }">
<label class="control-label" translate>FORM.LABELS.PRICE</label>
Expand Down
1 change: 0 additions & 1 deletion client/src/modules/stock/inventories/registry.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@

<div class="flex-content">
<div class="container-fluid">

<div
id="stock-inventory-grid"
class="grid-full-height-with-filters"
Expand Down
5 changes: 3 additions & 2 deletions server/controllers/inventory/inventory/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function getItemsMetadata(params) {

const sql =
`SELECT BUID(inventory.uuid) as uuid, inventory.code, inventory.text AS label, inventory.price, iu.text AS unit,
it.text AS type, ig.name AS groupName, BUID(ig.uuid) AS group_uuid, inventory.consumable, inventory.stock_min,
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,
ig.cogs_account, inventory.default_quantity
Expand All @@ -133,6 +133,7 @@ function getItemsMetadata(params) {
filters.equals('code');
filters.equals('price');
filters.equals('consumable');
filters.equals('locked');
filters.equals('label');

filters.custom('inventory_uuids', 'inventory.uuid IN (?)', params.inventory_uuids);
Expand All @@ -155,7 +156,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,
it.text AS type, ig.name AS groupName, BUID(ig.uuid) AS group_uuid, i.consumable, i.stock_min,
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
FROM inventory AS i JOIN inventory_type AS it
Expand Down
1 change: 1 addition & 0 deletions server/models/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,7 @@ CREATE TABLE `inventory` (
`stock_min` INT(10) UNSIGNED NOT NULL DEFAULT 0,
`type_id` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
`consumable` TINYINT(1) NOT NULL DEFAULT 0,
`locked` TINYINT(1) NOT NULL DEFAULT 0,
`delay` INT(10) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Delai de livraison',
`avg_consumption` DECIMAL(10,4) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Consommation moyenne' ,
`purchase_interval` DECIMAL(10,4) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Intervalle de commande' ,
Expand Down
6 changes: 3 additions & 3 deletions test/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ INSERT INTO `inventory_group` VALUES
(HUID('1410dfe0-b478-11e5-b297-023919d3d5b0'),'Test inventory group','INVGRP',3636,3636,3636,3636);

INSERT INTO `inventory` VALUES
(1, HUID('cf05da13-b477-11e5-b297-023919d3d5b0'), 'INV0', 'First Test Inventory Item', 25.0, 1, HUID('1410dfe0-b478-11e5-b297-023919d3d5b0'), 2, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, CURRENT_TIMESTAMP, NULL),
(1, HUID('289cc0a1-b90f-11e5-8c73-159fdc73ab02'), 'INV1', 'Second Test Inventory Item', 10.0, 20, HUID('1410dfe0-b478-11e5-b297-023919d3d5b0'), 2, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, CURRENT_TIMESTAMP, NULL),
(1, HUID('c48a3c4b-c07d-4899-95af-411f7708e296'), 'INV2', 'Third Test Inventory Item', 105.0, 1, HUID('1410dfe0-b478-11e5-b297-023919d3d5b0'), 2, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, CURRENT_TIMESTAMP, NULL);
(1, HUID('cf05da13-b477-11e5-b297-023919d3d5b0'), 'INV0', 'First Test Inventory Item', 25.0, 1, HUID('1410dfe0-b478-11e5-b297-023919d3d5b0'), 2, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, CURRENT_TIMESTAMP, NULL),
(1, HUID('289cc0a1-b90f-11e5-8c73-159fdc73ab02'), 'INV1', 'Second Test Inventory Item', 10.0, 20, HUID('1410dfe0-b478-11e5-b297-023919d3d5b0'), 2, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, CURRENT_TIMESTAMP, NULL),
(1, HUID('c48a3c4b-c07d-4899-95af-411f7708e296'), 'INV2', 'Third Test Inventory Item', 105.0, 1, HUID('1410dfe0-b478-11e5-b297-023919d3d5b0'), 2, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, CURRENT_TIMESTAMP, NULL);

INSERT INTO `debtor_group` VALUES
(1,HUID('4de0fe47-177f-4d30-b95f-cff8166400b4'),'First Test Debtor Group',3631,HUID('1f162a10-9f67-4788-9eff-c1fea42fcc9b'),NULL,NULL,NULL,0,10,0,NULL,1,1,1, '#ff0000', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
Expand Down

0 comments on commit d9cb36a

Please sign in to comment.