From 769f6befcafa51d328268139f9c19561c771e878 Mon Sep 17 00:00:00 2001 From: lomamech Date: Wed, 9 Feb 2022 16:06:24 +0100 Subject: [PATCH] Resolve conflict --- client/src/i18n/en/form.json | 6 +++ client/src/i18n/en/inventory.json | 1 + client/src/i18n/fr/form.json | 12 +++-- client/src/i18n/fr/inventory.json | 1 + .../types/modals/actions.modal.js | 32 +++++++----- .../types/modals/actions.tmpl.html | 6 +++ .../inventory/configuration/types/types.html | 9 ++-- .../inventory/configuration/types/types.js | 10 +++- .../modules/inventory/inventory.service.js | 36 +++++++------ client/src/modules/inventory/list/list.html | 2 + client/src/modules/inventory/list/list.js | 25 +++++++++ .../inventory/list/modals/actions.modal.js | 4 +- .../inventory/list/modals/actions.tmpl.html | 52 +++++++++++++++++++ .../list/modals/asset.cell.tmpl.html | 4 ++ .../inventory/list/modals/search.modal.html | 52 +++++++++++++++++++ .../list/templates/reference_number.cell.html | 5 ++ .../transaction-type/transaction-type.ctrl.js | 1 - server/controllers/inventory/index.js | 3 ++ .../controllers/inventory/inventory/core.js | 20 ++++--- .../controllers/inventory/inventory/types.js | 8 +-- server/models/bhima.sql | 2 +- server/models/migrations/next/migrate.sql | 13 +++++ server/models/schema.sql | 7 ++- 23 files changed, 257 insertions(+), 54 deletions(-) create mode 100644 client/src/modules/inventory/list/modals/asset.cell.tmpl.html create mode 100644 client/src/modules/inventory/list/templates/reference_number.cell.html diff --git a/client/src/i18n/en/form.json b/client/src/i18n/en/form.json index e56162e89a..42f24611a2 100644 --- a/client/src/i18n/en/form.json +++ b/client/src/i18n/en/form.json @@ -570,6 +570,8 @@ "LOSS_ACCOUNT": "Loss Account", "LOT": "Lot", "MALE": "Male", + "MANUFACTURER_BRAND": "Manufacturer brand", + "MANUFACTURER_MODEL": "Manufacturer model", "MARGIN" : "Margin", "MARITAL_STATUS": "Marital Status", "MAX_CREDIT_INFO": "The maximum credit value this debtor group can collect before being warned. A value of 0 means no maximum limit.", @@ -698,6 +700,7 @@ "RECORD": "Record", "RECORDS": "Records (Rows)", "REFERENCE_GROUP": "Reference Group", + "REFERENCE_NUMBER": "Reference number", "REFERENCE_PATIENT": "Patient Reference", "REFERENCE_VOUCHER" : "Voucher Reference", "REFERENCE": "Reference", @@ -932,6 +935,8 @@ "LOT":"Enter Batch Number", "LONGITUDE": "Enter the longitude", "LATITUDE": "Enter the latitude", + "MANUFACTURER_BRAND": "Enter Manufacturer brand", + "MANUFACTURER_MODEL": "Enter Manufacturer model", "MAX_CREDIT": "Enter max credit", "NAME": "Enter a name", "NOTES": "Enter any additional information", @@ -941,6 +946,7 @@ "PICK_ONE": "Pick one", "PRICE": "Enter a price", "PROVINCE": "Enter province", + "REFERENCE_NUMBER": "Enter reference number", "SECTOR": "Enter sector", "UNIT_WEIGHT": "Enter weight", "UNIT_VOLUME": "Enter volume", diff --git a/client/src/i18n/en/inventory.json b/client/src/i18n/en/inventory.json index 409e4f58e1..0f9e59d50b 100644 --- a/client/src/i18n/en/inventory.json +++ b/client/src/i18n/en/inventory.json @@ -14,6 +14,7 @@ "EDIT_TYPE": "Edit inventory type", "EDIT_UNIT": "Edit inventory unit form", "ELEMENT": "Element", + "IS_IT_ASSET": "Is it an asset", "PRICE_LIST_REPORT": "Inventory Prices Report", "PRICES": "Inventory Prices", "LIST": "Inventory Data List", diff --git a/client/src/i18n/fr/form.json b/client/src/i18n/fr/form.json index bd0b535bfa..683aeb277f 100644 --- a/client/src/i18n/fr/form.json +++ b/client/src/i18n/fr/form.json @@ -417,9 +417,9 @@ "DEBTOR_ACCOUNT": "Comptes de tiers", "DEBTOR_BALANCE_REMAINING": "Solde Restant du Débiteur", "DEBTOR_CREDITOR": "Débiteur/Créditeur", - "DEBTOR_GROUP_FORM": "Formulaire d'enregistrement de Groupe Débiteur", "DEBTOR_GROUP": "Groupe débiteur", - "DEBTOR_GROUP_OPTIONAL": "Groupe débiteur (optionnel)", + "DEBTOR_GROUP_OPTIONAL": "Groupe débiteur (optionel)", + "DEBTOR_GROUP_FORM": "Formulaire d'enregistrement de Groupe Débiteur", "DECREASE" : "Dimunition", "DEDUCTION" : "Contribution ou retenue", "DEFAULT_QUANTITY": "Quantité par Défaut", @@ -573,6 +573,8 @@ "LOSS_ACCOUNT": "Compte perte", "LOT": "Lot", "MALE": "Homme", + "MANUFACTURER_BRAND": "Marque", + "MANUFACTURER_MODEL": "Modèle", "MARGIN" : "Marge", "MARITAL_STATUS": "État Civil", "MAX_CREDIT": "Crédit Max", @@ -698,6 +700,7 @@ "RECORD": "Enregistrement", "RECORDS": "Enregistrements (Lignes)", "REFERENCE_GROUP": "Groupe de référence", + "REFERENCE_NUMBER": "Numéro de référence", "REFERENCE_PATIENT": "Référence Patient", "REFERENCE_VOUCHER": "Référence Bordereau", "REFERENCE": "Référence", @@ -931,6 +934,8 @@ "LOT":"Entrer le lot", "LONGITUDE": "Entrer la longitude", "LATITUDE": "Entrer la latitude", + "MANUFACTURER_BRAND": "Entrer la marque", + "MANUFACTURER_MODEL": "Entrer le modèle", "MAX_CREDIT": "Entrer le crédit maximale", "NAME": "Entrer le nom", "NOTES": "Commentaire", @@ -941,7 +946,8 @@ "PHONE": "Entrer le téléphone", "PICK_ONE": "Choisissez-en un", "PRICE": "Entrer le prix", - "PROVINCE": "Enter la province", + "PROVINCE": "Entrer la province", + "REFERENCE_NUMBER": "Entrer le numéro de référence", "SECTOR": "Entrer le secteur", "SUPPLIER": "Entrer le fournisseur", "TYPE": "Entrer le type", diff --git a/client/src/i18n/fr/inventory.json b/client/src/i18n/fr/inventory.json index 2b38646adc..ba9442e6df 100644 --- a/client/src/i18n/fr/inventory.json +++ b/client/src/i18n/fr/inventory.json @@ -15,6 +15,7 @@ "EDIT_TYPE": "Modifier Types d'inventaires", "EDIT_UNIT": "Modifier Forme d'inventaires", "ELEMENT": "Élément", + "IS_IT_ASSET": "Est ce un actif", "PRICE_LIST_REPORT": "Rapport des prix des articles et services", "PRICES": "Tarification", "LIST": "Liste des données d'inventaire", diff --git a/client/src/modules/inventory/configuration/types/modals/actions.modal.js b/client/src/modules/inventory/configuration/types/modals/actions.modal.js index e583c04b3f..0d0f91c81a 100644 --- a/client/src/modules/inventory/configuration/types/modals/actions.modal.js +++ b/client/src/modules/inventory/configuration/types/modals/actions.modal.js @@ -1,15 +1,19 @@ angular.module('bhima.controllers') -.controller('InventoryTypeActionsModalController', InventoryTypeActionsModalController); + .controller('InventoryTypeActionsModalController', InventoryTypeActionsModalController); InventoryTypeActionsModalController.$inject = [ - 'InventoryTypeService', 'NotifyService', '$uibModalInstance', 'data' + 'InventoryTypeService', 'NotifyService', '$uibModalInstance', 'data', ]; function InventoryTypeActionsModalController(InventoryType, Notify, Instance, Data) { - var vm = this, session = vm.session = {}; + const vm = this; + vm.session = {}; // map for actions - var map = { 'add' : addType, 'edit' : editType }; + const map = { + add : addType, + edit : editType, + }; // expose to the view vm.submit = submit; @@ -22,9 +26,10 @@ function InventoryTypeActionsModalController(InventoryType, Notify, Instance, Da function submit(form) { if (form.$invalid) { return; } - var record = cleanForSubmit(vm.session); + const record = cleanForSubmit(vm.session); + map[vm.action](record, vm.identifier) - .then(function (res) { + .then((res) => { Instance.close(res); }); } @@ -47,9 +52,10 @@ function InventoryTypeActionsModalController(InventoryType, Notify, Instance, Da } /** format data to data structure in the db */ - function cleanForSubmit(session) { + function cleanForSubmit(data) { return { - text : session.text + text : data.text, + description : data.description, }; } @@ -60,12 +66,10 @@ function InventoryTypeActionsModalController(InventoryType, Notify, Instance, Da if (vm.identifier) { InventoryType.read(vm.identifier) - .then(function (type) { - vm.session = type[0]; - }) - .catch(Notify.handleError); + .then((type) => { + [vm.session] = type; + }) + .catch(Notify.handleError); } - } - } diff --git a/client/src/modules/inventory/configuration/types/modals/actions.tmpl.html b/client/src/modules/inventory/configuration/types/modals/actions.tmpl.html index 0d1af8c527..abacfcf0b3 100644 --- a/client/src/modules/inventory/configuration/types/modals/actions.tmpl.html +++ b/client/src/modules/inventory/configuration/types/modals/actions.tmpl.html @@ -20,6 +20,12 @@
+ +
+ + +
+
+ +
+ +
+ + +
+
+
+
+ +
+ + +
+
+
+
+ +
+ + +
+
+
+
+
+
+ + + + +
+
+
+
+ +
+ + + + +
+
+
+
+ +
+ + + + +
+
+
+
+
+ +
+ + +
+ + +
diff --git a/client/src/modules/inventory/list/templates/reference_number.cell.html b/client/src/modules/inventory/list/templates/reference_number.cell.html new file mode 100644 index 0000000000..85e4ae65d9 --- /dev/null +++ b/client/src/modules/inventory/list/templates/reference_number.cell.html @@ -0,0 +1,5 @@ +
+ + {{ row.entity.external_reference_number }} + +
\ No newline at end of file diff --git a/client/src/modules/transaction-type/transaction-type.ctrl.js b/client/src/modules/transaction-type/transaction-type.ctrl.js index e4db564234..7a9179bf0f 100644 --- a/client/src/modules/transaction-type/transaction-type.ctrl.js +++ b/client/src/modules/transaction-type/transaction-type.ctrl.js @@ -108,7 +108,6 @@ function TransactionTypeController($translate, TransactionType, Notify, Modal, u return transactionType; } - function assignDescriptionTranslation(type) { type.descriptionLabel = $translate.instant(type.text); return type; diff --git a/server/controllers/inventory/index.js b/server/controllers/inventory/index.js index 777d62503d..cd942ce298 100644 --- a/server/controllers/inventory/index.js +++ b/server/controllers/inventory/index.js @@ -425,6 +425,9 @@ function countInventoryGroups(req, res, next) { * Create a new inventory types */ function createInventoryTypes(req, res, next) { + console.log('REQ.BODYYYYYYYYyyyyyyyyyyyyY'); + console.log(req.body); + types.create(req.body) .then((id) => { res.status(201).json({ id }); diff --git a/server/controllers/inventory/inventory/core.js b/server/controllers/inventory/inventory/core.js index 0a2c75a16b..5a1201dc39 100644 --- a/server/controllers/inventory/inventory/core.js +++ b/server/controllers/inventory/inventory/core.js @@ -251,10 +251,11 @@ async function getItemsMetadata(params) { it.text AS type, ig.name AS groupName, BUID(ig.uuid) AS group_uuid, ig.unique_item, 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, - 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, + inventory.note, inventory.unit_weight, inventory.unit_volume, inventory.is_asset, + inventory.external_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, inventory.importance, GROUP_CONCAT(BUID(t.uuid), ';', t.name, ';', t.color ORDER BY t.name) AS tag_details, ${usePreviousPrice ? previousPriceQuery : 'inventory.price'} @@ -281,6 +282,10 @@ async function getItemsMetadata(params) { filters.equals('sellable'); filters.equals('note'); filters.equals('importance'); + filters.equals('is_asset'); + filters.equals('manufacturer_brand'); + filters.equals('manufacturer_model'); + filters.equals('external_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); @@ -332,12 +337,13 @@ function remove(_uuid) { */ async function getItemsMetadataById(uid, query = {}) { const sql = ` - 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, + SELECT BUID(i.uuid) as uuid, i.code, i.text AS label, i.price, i.is_asset, i.external_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, ig.sales_account, i.default_quantity, i.delay, i.purchase_interval, i.importance, - i.last_purchase, i.num_purchase, ig.tracking_consumption, ig.tracking_expiration + i.last_purchase, i.num_purchase, i.manufacturer_brand, i.manufacturer_model, + ig.tracking_consumption, ig.tracking_expiration FROM inventory AS i JOIN inventory_type AS it JOIN inventory_unit AS iu JOIN inventory_group AS ig ON i.type_id = it.id diff --git a/server/controllers/inventory/inventory/types.js b/server/controllers/inventory/inventory/types.js index 5e720db25a..62425ae837 100644 --- a/server/controllers/inventory/inventory/types.js +++ b/server/controllers/inventory/inventory/types.js @@ -23,15 +23,15 @@ function details(identifier) { return getTypes(identifier); } - /** create new inventory type */ function create(record) { - const sql = 'INSERT INTO inventory_type (text) VALUES (?);'; + + const sql = 'INSERT INTO inventory_type (text, description) VALUES (?, ?);'; /* * return a promise which can contains result or error which is caught * in the main controller (inventory.js) */ - return db.exec(sql, [record.text]) + return db.exec(sql, [record.text, record.description]) .then(row => row.insertId); } @@ -51,7 +51,7 @@ function update(record, id) { * @param {string} uid the type id is optional */ function getTypes(id) { - const sql = `SELECT id, text FROM inventory_type ${id ? ' WHERE id = ?' : ''};`; + const sql = `SELECT id, text, description, is_predefined FROM inventory_type ${id ? ' WHERE id = ?' : ''};`; return db.exec(sql, [id]); } diff --git a/server/models/bhima.sql b/server/models/bhima.sql index 8d1af3f590..13ae32bfda 100644 --- a/server/models/bhima.sql +++ b/server/models/bhima.sql @@ -271,7 +271,7 @@ INSERT INTO `currency` (`id`, `name`, `format_key`, `symbol`, `note`, `min_monen (2,'United States Dollars','usd','$',NULL,0.01), (3,'Euro','EUR','€',NULL,0.01); -INSERT INTO `inventory_type` VALUES (1,'Article'),(2,'Assembly'),(3,'Service'); +INSERT INTO `inventory_type` VALUES (1,'Article',NULL,0),(2,'Assembly',NULL,0),(3,'Service',NULL,0); INSERT INTO `inventory_unit` VALUES (1,'Act', 'Act'), (2,'Pal', 'Pallet'), diff --git a/server/models/migrations/next/migrate.sql b/server/models/migrations/next/migrate.sql index 2546f95d47..2c6e00eca3 100644 --- a/server/models/migrations/next/migrate.sql +++ b/server/models/migrations/next/migrate.sql @@ -47,3 +47,16 @@ UPDATE unit SET `name` = 'Analysis of Cashbox', `key` = 'REPORT.ANALYSIS_AUX_CAS */ INSERT IGNORE INTO unit VALUES (307, 'Asset Management', 'TREE.ASSET_MANAGEMENT.TITLE', 'Asset Management', 0, '/ASSET_MANAGEMENT_FOLDER'); + + /* + * Issue: Asset Management - Inventory Changes #6348 + * @author: lomamech + * @date: 2022-02-07 + */ +CALL add_column_if_missing('inventory', 'is_asset', 'TINYINT(1) NOT NULL DEFAULT 0 AFTER `importance`'); +CALL add_column_if_missing('inventory', 'external_reference_number', 'TEXT NULL'); +CALL add_column_if_missing('inventory', 'manufacturer_brand', 'TEXT NULL'); +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'); diff --git a/server/models/schema.sql b/server/models/schema.sql index 5559d1fc3a..35d858dc8a 100644 --- a/server/models/schema.sql +++ b/server/models/schema.sql @@ -793,6 +793,10 @@ CREATE TABLE `inventory` ( `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' , `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, + `manufacturer_brand` TEXT NULL, + `manufacturer_model` TEXT NULL, `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`uuid`), @@ -830,11 +834,12 @@ CREATE TABLE `inventory_group` ( KEY `donation_account` (`donation_account`) ) ENGINE=InnoDB DEFAULT CHARACTER SET = utf8mb4 DEFAULT COLLATE = utf8mb4_unicode_ci; - DROP TABLE IF EXISTS `inventory_type`; CREATE TABLE `inventory_type` ( `id` TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, `text` VARCHAR(30) NOT NULL, + `description` TEXT NULL, + `is_predefined` TINYINT(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `inventory_type_1` (`text`) ) ENGINE=InnoDB DEFAULT CHARACTER SET = utf8mb4 DEFAULT COLLATE = utf8mb4_unicode_ci;