Skip to content

Commit

Permalink
improvement(Asset Inventory)
Browse files Browse the repository at this point in the history
- Use reference_number instead external_reference_number
- Change site for column text in table inventory type`
  • Loading branch information
lomamech committed Feb 14, 2022
1 parent 39ec7a8 commit ef37488
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion client/src/modules/inventory/inventory.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function InventoryService(
key : 'is_asset',
label : 'FORM.LABELS.ASSET',
}, {
key : 'external_reference_number',
key : 'reference_number',
label : 'FORM.LABELS.REFERENCE_NUMBER',
}, {
key : 'manufacturer_brand',
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/inventory/list/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function InventoryListController(
visible : false,
cellTemplate : '/modules/inventory/list/templates/asset.cell.tmpl.html',
}, {
field : 'external_reference_number',
field : 'reference_number',
displayName : 'FORM.LABELS.REFERENCE_NUMBER',
headerCellFilter : 'translate',
visible : false,
Expand Down
8 changes: 4 additions & 4 deletions client/src/modules/inventory/list/modals/actions.tmpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@
</div>

<div ng-if="$ctrl.item.is_asset" class="form-group"
ng-class="{ 'has-error' : ActionForm.$submitted && ActionForm.external_reference_number.$invalid }">
ng-class="{ 'has-error' : ActionForm.$submitted && ActionForm.reference_number.$invalid }">
<label class="control-label" translate>FORM.LABELS.REFERENCE_NUMBER</label>
<input
ng-model="$ctrl.item.external_reference_number"
ng-model="$ctrl.item.reference_number"
class="form-control"
type="text"
name="external_reference_number"
name="reference_number"
autocomplete="off"
translate-attr="{ placeholder : 'FORM.PLACEHOLDERS.REFERENCE_NUMBER' }">
<div class="help-block" ng-messages="ActionForm.external_reference_number.$error" ng-show="ActionForm.$submitted">
<div class="help-block" ng-messages="ActionForm.reference_number.$error" ng-show="ActionForm.$submitted">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions client/src/modules/inventory/list/modals/search.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
</div>
</div>

<div class="form-group" ng-class="{ 'has-error' : ModalForm.$submitted && ModalForm.external_reference_number.$invalid }">
<div class="form-group" ng-class="{ 'has-error' : ModalForm.$submitted && ModalForm.reference_number.$invalid }">
<label class="control-label" translate>
FORM.LABELS.REFERENCE_NUMBER
</label>
<bh-clear on-clear="ModalCtrl.clear('external_reference_number')"></bh-clear>
<bh-clear on-clear="ModalCtrl.clear('reference_number')"></bh-clear>

<input type="text" class="form-control" name="external_reference_number" ng-model="ModalCtrl.searchQueries.external_reference_number">
<div class="help-block" ng-messages="ModalForm.external_reference_number.$error" ng-show="ModalForm.$submitted">
<input type="text" class="form-control" name="reference_number" ng-model="ModalCtrl.searchQueries.reference_number">
<div class="help-block" ng-messages="ModalForm.reference_number.$error" ng-show="ModalForm.$submitted">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="ui-grid-cell-contents">
<em>
<span>{{ row.entity.external_reference_number }}</span>
<span>{{ row.entity.reference_number }}</span>
</em>
</div>
6 changes: 3 additions & 3 deletions server/controllers/inventory/inventory/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ async function getItemsMetadata(params) {
inventory.consumable,inventory.locked, inventory.stock_min,
inventory.stock_max, inventory.created_at AS timestamp, inventory.type_id, inventory.unit_id,
inventory.note, inventory.unit_weight, inventory.unit_volume, inventory.is_asset,
inventory.external_reference_number, inventory.manufacturer_brand, inventory.manufacturer_model,
inventory.reference_number, inventory.manufacturer_brand, inventory.manufacturer_model,
ig.sales_account, ig.stock_account, ig.donation_account, inventory.sellable,
inventory.note, inventory.unit_weight, inventory.unit_volume, ig.sales_account, ig.stock_account,
ig.donation_account, ig.cogs_account, inventory.default_quantity, ig.tracking_consumption, ig.tracking_expiration,
Expand Down Expand Up @@ -285,7 +285,7 @@ async function getItemsMetadata(params) {
filters.equals('is_asset');
filters.equals('manufacturer_brand');
filters.equals('manufacturer_model');
filters.equals('external_reference_number');
filters.equals('reference_number');
filters.custom('tags', 't.uuid IN (?)', [params.tags]);
filters.custom('find_null_importance', 'inventory.importance IS NULL');
filters.custom('inventory_uuids', 'inventory.uuid IN (?)', params.inventory_uuids);
Expand Down Expand Up @@ -337,7 +337,7 @@ function remove(_uuid) {
*/
async function getItemsMetadataById(uid, query = {}) {
const sql = `
SELECT BUID(i.uuid) as uuid, i.code, i.text AS label, i.price, i.is_asset, i.external_reference_number,
SELECT BUID(i.uuid) as uuid, i.code, i.text AS label, i.price, i.is_asset, i.reference_number,
iu.abbr AS unit, it.text AS type, ig.name AS groupName, BUID(ig.uuid) AS group_uuid,
ig.unique_item, i.consumable, i.locked, i.stock_min, i.sellable,
i.stock_max, i.created_at AS timestamp, i.type_id, i.unit_id, i.unit_weight, i.unit_volume,
Expand Down
4 changes: 4 additions & 0 deletions server/models/migrations/next/migrate.sql
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ CALL add_column_if_missing('inventory', 'manufacturer_model', 'TEXT NULL');

CALL add_column_if_missing('inventory_type', 'description', 'TEXT NULL');
CALL add_column_if_missing('inventory_type', 'is_predefined', 'TINYINT(1) NOT NULL DEFAULT 0');

ALTER TABLE `inventory_type`
CHANGE COLUMN `text` `text` VARCHAR(200) NOT NULL COLLATE AFTER `id`;

2 changes: 1 addition & 1 deletion server/models/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ CREATE TABLE `inventory` (
`num_delivery` INT(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Number of stock delivery' ,
`importance` SMALLINT(5) NULL COMMENT 'Inventory level of importance : 1 -> LOW, 2 -> MID, 3 -> HIGH' ,
`is_asset` TINYINT(1) NOT NULL DEFAULT 0,
`external_reference_number` TEXT NULL,
`reference_number` TEXT NULL,
`manufacturer_brand` TEXT NULL,
`manufacturer_model` TEXT NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
Expand Down
2 changes: 1 addition & 1 deletion test/integration/inventory/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('(/inventory/metadata) The inventory metadata http API', () => {
sellable : 1,
importance : 2,
is_asset : 1,
external_reference_number : 'BHIMA_O1',
reference_number : 'BHIMA_O1',
manufacturer_brand : 'BHIMA',
manufacturer_model : '2.X',
};
Expand Down

0 comments on commit ef37488

Please sign in to comment.