From 99fd704f90ac158a463b9c9c2d0059e33fdb570c Mon Sep 17 00:00:00 2001 From: DedrickEnc Date: Tue, 25 Jul 2017 14:06:10 +0100 Subject: [PATCH 01/13] creating a cmponent to replace all stock destination box --- client/src/i18n/en/patient_reg.json | 15 +- client/src/i18n/en/service.json | 19 +- client/src/i18n/en/stock.json | 1 + client/src/i18n/fr/depot.json | 23 +- client/src/i18n/fr/patient_reg.json | 15 +- client/src/i18n/fr/service.json | 19 +- client/src/i18n/fr/stock.json | 1 + .../bhStockDistributionDestination.js | 33 ++ client/src/modules/stock/exit/exit.html | 345 ++++++++-------- client/src/modules/stock/exit/exit.js | 390 ++++++++++-------- .../bhStockDistributionDestination.tmpl.html | 27 ++ 11 files changed, 517 insertions(+), 371 deletions(-) create mode 100644 client/src/js/components/bhStockDistributionDestination.js create mode 100644 client/src/modules/templates/bhStockDistributionDestination.tmpl.html diff --git a/client/src/i18n/en/patient_reg.json b/client/src/i18n/en/patient_reg.json index 4041433f10..b28586acda 100644 --- a/client/src/i18n/en/patient_reg.json +++ b/client/src/i18n/en/patient_reg.json @@ -1,5 +1,10 @@ -{"PATIENT_REG":{"PAGE_TITLE":"Patient Registration", -"PATIENT_DETAILS":"Patient Details", -"SUCCESS":"Patient Registered Successfully", -"CARD":"Patient Card", -"IDENTITY":"Patient Identity"}} \ No newline at end of file +{ + "PATIENT_REG": { + "ENTITY" : "Patient", + "PAGE_TITLE": "Patient Registration", + "PATIENT_DETAILS": "Patient Details", + "SUCCESS": "Patient Registered Successfully", + "CARD": "Patient Card", + "IDENTITY": "Patient Identity" + } +} \ No newline at end of file diff --git a/client/src/i18n/en/service.json b/client/src/i18n/en/service.json index 03968aecfe..28df9ae44a 100644 --- a/client/src/i18n/en/service.json +++ b/client/src/i18n/en/service.json @@ -1,7 +1,12 @@ -{"SERVICE":{"ADDING_SERVICE":"Adding service", -"ADD_SERVICE":"Add service", -"ALL_SERVICES":"All services", -"DESCRIPTION":"This module allows to create, list, edit, delete and view the cost and product service", -"EDITING_SERVICE":"Editing service", -"OVERVIEWING_SERVICE":"Overviewing Service", -"TITLE":"Service Management"}} \ No newline at end of file +{ + "SERVICE": { + "ADDING_SERVICE": "Adding service", + "ADD_SERVICE": "Add service", + "ALL_SERVICES": "All services", + "DESCRIPTION": "This module allows to create, list, edit, delete and view the cost and product service", + "EDITING_SERVICE": "Editing service", + "ENTITY" : "Service", + "OVERVIEWING_SERVICE": "Overviewing Service", + "TITLE": "Service Management" + } +} \ No newline at end of file diff --git a/client/src/i18n/en/stock.json b/client/src/i18n/en/stock.json index 4212ca76ac..494e668ba8 100644 --- a/client/src/i18n/en/stock.json +++ b/client/src/i18n/en/stock.json @@ -6,6 +6,7 @@ "AMOUNT" : "Montant", "APPROVISIONING" : "Quantity to order", "CACHED_DATA" : "Data saved", + "CHOOSE_AGAIN" : "(Click On This Box to Choose Again)", "CODE" : "Code", "COST" : "Cost", "DECREASE" : "Decrease", diff --git a/client/src/i18n/fr/depot.json b/client/src/i18n/fr/depot.json index b5b237a0ae..463ea11704 100644 --- a/client/src/i18n/fr/depot.json +++ b/client/src/i18n/fr/depot.json @@ -1,8 +1,15 @@ -{"DEPOT":{"ADD_DEPOT":"Ajouter un dépôt", -"ALL_DEPOTS":"Tous les dépôts", -"DEPOTS_LIST":"Liste des dépôts", -"DESCRIPTION":"Ce module vous permet de Lister, Creer, Modifier et Supprimer un dépôt", -"EDIT_DEPOT":"Editer les informations d'un dépôt", -"MAIN":{"TITLE":"Gestion des dépôts"}, -"NO_DEPOT":"Aucun dépôt", -"TITLE":"Gestion des dépôts"}} \ No newline at end of file +{ + "DEPOT": { + "ADD_DEPOT": "Ajouter un dépôt", + "ALL_DEPOTS": "Tous les dépôts", + "DEPOTS_LIST": "Liste des dépôts", + "DESCRIPTION": "Ce module vous permet de Lister, Creer, Modifier et Supprimer un dépôt", + "EDIT_DEPOT": "Editer les informations d'un dépôt", + "ENTITY" : "Depot", + "MAIN": { + "TITLE": "Gestion des dépôts" + }, + "NO_DEPOT": "Aucun dépôt", + "TITLE": "Gestion des dépôts" + } +} \ No newline at end of file diff --git a/client/src/i18n/fr/patient_reg.json b/client/src/i18n/fr/patient_reg.json index 5953af2938..0774b37c9a 100644 --- a/client/src/i18n/fr/patient_reg.json +++ b/client/src/i18n/fr/patient_reg.json @@ -1,5 +1,10 @@ -{"PATIENT_REG":{"CARD":"Fiche du patient", -"PAGE_TITLE":"Enregistrement des Patients", -"PATIENT_DETAILS":"Détails Patient", -"SUCCESS":"Patient enregistré avec succès", -"IDENTITY":"Identité du patient"}} \ No newline at end of file +{ + "PATIENT_REG": { + "ENTITY" : "Patient", + "CARD": "Fiche du patient", + "PAGE_TITLE": "Enregistrement des Patients", + "PATIENT_DETAILS": "Détails Patient", + "SUCCESS": "Patient enregistré avec succès", + "IDENTITY": "Identité du patient" + } +} \ No newline at end of file diff --git a/client/src/i18n/fr/service.json b/client/src/i18n/fr/service.json index fbef6bb649..14982278f2 100644 --- a/client/src/i18n/fr/service.json +++ b/client/src/i18n/fr/service.json @@ -1,7 +1,12 @@ -{"SERVICE":{"ADDING_SERVICE":"Ajout service", -"ADD_SERVICE":"Ajouter service", -"ALL_SERVICES":"Tous les services", -"DESCRIPTION":"Ce module permet de creer, lister, modifier, supprimer et voir le cout et produit du service", -"EDITING_SERVICE":"Modification service", -"OVERVIEWING_SERVICE":"Visualisation sommaire du service", -"TITLE":"Gestion des services"}} \ No newline at end of file +{ + "SERVICE": { + "ADDING_SERVICE": "Ajout service", + "ADD_SERVICE": "Ajouter service", + "ALL_SERVICES": "Tous les services", + "DESCRIPTION": "Ce module permet de creer, lister, modifier, supprimer et voir le cout et produit du service", + "EDITING_SERVICE": "Modification service", + "ENTITY" : "Service", + "OVERVIEWING_SERVICE": "Visualisation sommaire du service", + "TITLE": "Gestion des services" + } +} \ No newline at end of file diff --git a/client/src/i18n/fr/stock.json b/client/src/i18n/fr/stock.json index 4d2f8fdc97..9410100759 100644 --- a/client/src/i18n/fr/stock.json +++ b/client/src/i18n/fr/stock.json @@ -6,6 +6,7 @@ "AMOUNT" : "Montant", "APPROVISIONING" : "Quantité à commander", "CACHED_DATA" : "Donnees mises en cache", + "CHOOSE_AGAIN" : "(Cliquer Sur Cette Boite Pour Choisir Encore)", "CODE" : "Code", "COST" : "Cout", "DECREASE" : "Diminution", diff --git a/client/src/js/components/bhStockDistributionDestination.js b/client/src/js/components/bhStockDistributionDestination.js new file mode 100644 index 0000000000..6a6192d431 --- /dev/null +++ b/client/src/js/components/bhStockDistributionDestination.js @@ -0,0 +1,33 @@ +angular.module('bhima.components') + .component('bhDistributionDestination', { + templateUrl: 'modules/templates/bhStockDistributionDestination.tmpl.html', + controller: DistributionDestinationController, + bindings: { + onExitTypeSelectCallback: '&?', + reference : '
  1. TREE.STOCK
  2. -
  3. STOCK.EXIT {{StockCtrl.movement.exit_type}}
  4. +
  5. + STOCK.EXIT + {{StockCtrl.movement.exit_type}} +
@@ -18,196 +21,206 @@
- - -
- -
- +
--> + + + -
- +
--> + + + -
- +
--> + + + + +
- -
- - -
-
- - - - - -
- - -
-
+ +
+
+ + + + + +
+ + +
+
+
-
- - -
-
- - -

- - FORM.INFO.NO_DESTINATION -

- -
- -
- - -
- + +
+
+ + +

+ + FORM.INFO.NO_DESTINATION +

+ + +
- -
+ + +
+ + + + +
+
-
- -
-
+ +
+
- -
-
-
- + +
+
+
+ - - FORM.BUTTONS.SUBMIT - + + FORM.BUTTONS.SUBMIT + +
-
- -
diff --git a/client/src/modules/stock/exit/exit.js b/client/src/modules/stock/exit/exit.js index de041e6093..37bec0d89d 100644 --- a/client/src/modules/stock/exit/exit.js +++ b/client/src/modules/stock/exit/exit.js @@ -1,5 +1,5 @@ angular.module('bhima.controllers') -.controller('StockExitController', StockExitController); + .controller('StockExitController', StockExitController); // dependencies injections StockExitController.$inject = [ @@ -20,10 +20,10 @@ function StockExitController(Depots, Inventory, Notify, uiGridGroupingConstants, $translate) { var vm = this; var mapExit = { - patient : { description : 'STOCK.EXIT_PATIENT', find : findPatient, submit : submitPatient }, - service : { description : 'STOCK.EXIT_SERVICE', find : findService, submit : submitService }, - depot : { description : 'STOCK.EXIT_DEPOT', find : findDepot, submit : submitDepot }, - loss : { description : 'STOCK.EXIT_LOSS', find : configureLoss, submit : submitLoss }, + patient: { description: 'STOCK.EXIT_PATIENT', find: findPatient, submit: submitPatient }, + service: { description: 'STOCK.EXIT_SERVICE', find: findService, submit: submitService }, + depot: { description: 'STOCK.EXIT_DEPOT', find: findDepot, submit: submitDepot }, + loss: { description: 'STOCK.EXIT_LOSS', find: configureLoss, submit: submitLoss }, }; vm.Stock = new StockForm('StockExit'); @@ -44,75 +44,95 @@ function StockExitController(Depots, Inventory, Notify, // grid options var gridOptions = { - appScopeProvider : vm, - enableSorting : false, - enableColumnMenus : false, - columnDefs : [ - { field : 'status', - width : 25, - displayName : '', - cellTemplate : 'modules/stock/exit/templates/status.tmpl.html' }, - - { field : 'code', - width : 120, - displayName : 'TABLE.COLUMNS.CODE', - headerCellFilter : 'translate', - cellTemplate : 'modules/stock/exit/templates/code.tmpl.html' }, - - { field : 'description', - displayName : 'TABLE.COLUMNS.DESCRIPTION', - headerCellFilter : 'translate', - cellTemplate : 'modules/stock/exit/templates/description.tmpl.html' }, - - { field : 'lot', - width : 150, - displayName : 'TABLE.COLUMNS.LOT', - headerCellFilter : 'translate', - cellTemplate : 'modules/stock/exit/templates/lot.tmpl.html' }, - - { field : 'unit_price', - width : 150, - displayName : 'TABLE.COLUMNS.UNIT_PRICE', - headerCellFilter : 'translate', - cellTemplate : 'modules/stock/exit/templates/price.tmpl.html' }, - - { field : 'quantity', - width : 150, - displayName : 'TABLE.COLUMNS.QUANTITY', - headerCellFilter : 'translate', - cellTemplate : 'modules/stock/exit/templates/quantity.tmpl.html', - treeAggregationType : uiGridGroupingConstants.aggregation.SUM }, - - { field : 'unit_type', - width : 75, - displayName : 'TABLE.COLUMNS.UNIT', - headerCellFilter : 'translate', - cellTemplate : 'modules/stock/exit/templates/unit.tmpl.html' }, - - { field : 'available_lot', - width : 150, - displayName : 'TABLE.COLUMNS.AVAILABLE', - headerCellFilter : 'translate', - cellTemplate : 'modules/stock/exit/templates/available.tmpl.html' }, - - { field : 'amount', - width : 150, - displayName : 'TABLE.COLUMNS.AMOUNT', - headerCellFilter : 'translate', - cellTemplate : 'modules/stock/exit/templates/amount.tmpl.html' }, - - { field : 'expiration_date', - width : 150, - displayName : 'TABLE.COLUMNS.EXPIRATION_DATE', - headerCellFilter : 'translate', - cellTemplate : 'modules/stock/exit/templates/expiration.tmpl.html' }, - - { field : 'actions', width : 25, cellTemplate : 'modules/stock/exit/templates/actions.tmpl.html' }, + appScopeProvider: vm, + enableSorting: false, + enableColumnMenus: false, + columnDefs: [ + { + field: 'status', + width: 25, + displayName: '', + cellTemplate: 'modules/stock/exit/templates/status.tmpl.html' + }, + + { + field: 'code', + width: 120, + displayName: 'TABLE.COLUMNS.CODE', + headerCellFilter: 'translate', + cellTemplate: 'modules/stock/exit/templates/code.tmpl.html' + }, + + { + field: 'description', + displayName: 'TABLE.COLUMNS.DESCRIPTION', + headerCellFilter: 'translate', + cellTemplate: 'modules/stock/exit/templates/description.tmpl.html' + }, + + { + field: 'lot', + width: 150, + displayName: 'TABLE.COLUMNS.LOT', + headerCellFilter: 'translate', + cellTemplate: 'modules/stock/exit/templates/lot.tmpl.html' + }, + + { + field: 'unit_price', + width: 150, + displayName: 'TABLE.COLUMNS.UNIT_PRICE', + headerCellFilter: 'translate', + cellTemplate: 'modules/stock/exit/templates/price.tmpl.html' + }, + + { + field: 'quantity', + width: 150, + displayName: 'TABLE.COLUMNS.QUANTITY', + headerCellFilter: 'translate', + cellTemplate: 'modules/stock/exit/templates/quantity.tmpl.html', + treeAggregationType: uiGridGroupingConstants.aggregation.SUM + }, + + { + field: 'unit_type', + width: 75, + displayName: 'TABLE.COLUMNS.UNIT', + headerCellFilter: 'translate', + cellTemplate: 'modules/stock/exit/templates/unit.tmpl.html' + }, + + { + field: 'available_lot', + width: 150, + displayName: 'TABLE.COLUMNS.AVAILABLE', + headerCellFilter: 'translate', + cellTemplate: 'modules/stock/exit/templates/available.tmpl.html' + }, + + { + field: 'amount', + width: 150, + displayName: 'TABLE.COLUMNS.AMOUNT', + headerCellFilter: 'translate', + cellTemplate: 'modules/stock/exit/templates/amount.tmpl.html' + }, + + { + field: 'expiration_date', + width: 150, + displayName: 'TABLE.COLUMNS.EXPIRATION_DATE', + headerCellFilter: 'translate', + cellTemplate: 'modules/stock/exit/templates/expiration.tmpl.html' + }, + + { field: 'actions', width: 25, cellTemplate: 'modules/stock/exit/templates/actions.tmpl.html' }, ], - onRegisterApi : onRegisterApi, - data : vm.Stock.store.data, - fastWatch : true, - flatEntityAccess : true, + onRegisterApi: onRegisterApi, + data: vm.Stock.store.data, + fastWatch: true, + flatEntityAccess: true, }; vm.gridOptions = gridOptions; @@ -125,10 +145,10 @@ function StockExitController(Depots, Inventory, Notify, // exit type function selectExitType(exitType) { - vm.movement.exit_type = exitType; - mapExit[exitType].find(); + vm.movement.exit_type = exitType.label; + mapExit[exitType.label].find(); // FIXME: textarea default value must be translated in the view - vm.movement.description = $translate.instant(mapExit[exitType].description); + vm.movement.description = $translate.instant(mapExit[exitType.label].description); } // configure depot @@ -156,7 +176,7 @@ function StockExitController(Depots, Inventory, Notify, function configureItem(item) { item._initialised = true; // get lots - Stock.lots.read(null, { depot_uuid : vm.depot.uuid, inventory_uuid : item.inventory.inventory_uuid }) + Stock.lots.read(null, { depot_uuid: vm.depot.uuid, inventory_uuid: item.inventory.inventory_uuid }) .then(function (lots) { item.lots = lots; }) @@ -165,7 +185,7 @@ function StockExitController(Depots, Inventory, Notify, // init actions function moduleInit() { - vm.movement = { date : new Date(), entity : {} }; + vm.movement = { date: new Date(), entity: {} }; loadInventories(vm.depot); setupDepot(vm.depot); checkValidity(); @@ -174,7 +194,7 @@ function StockExitController(Depots, Inventory, Notify, // ============================ Inventories ========================== function loadInventories(depot) { var givenDepot = depot || vm.depot; - Stock.inventories.read(null, { depot_uuid : givenDepot.uuid }) + Stock.inventories.read(null, { depot_uuid: givenDepot.uuid }) .then(function (inventories) { vm.selectableInventories = angular.copy(inventories); }) @@ -193,52 +213,76 @@ function StockExitController(Depots, Inventory, Notify, // find patient function findPatient() { StockModal.openFindPatient() - .then(function (patient) { - if (!patient) { return; } - vm.movement.entity = { - uuid : patient.uuid, - type : 'patient', - instance : patient, - }; - }) - .catch(Notify.handleError); + .then(function (patient) { + if (!patient) { return; } + vm.movement.entity = { + uuid: patient.uuid, + type: 'patient', + instance: patient, + }; + setSelectedEntity(patient); + }) + .catch(Notify.handleError); } // find service function findService() { StockModal.openFindService() - .then(function (service) { - if (!service) { return; } - vm.movement.entity = { - uuid : service.uuid, - type : 'service', - instance : service, - }; - }) - .catch(Notify.handleError); + .then(function (service) { + if (!service) { return; } + vm.movement.entity = { + uuid: service.uuid, + type: 'service', + instance: service, + }; + + setSelectedEntity(service); + }) + .catch(Notify.handleError); } // find depot function findDepot() { - StockModal.openFindDepot({ depot : vm.depot }) - .then(function (depot) { - if (!depot) { return; } - vm.movement.entity = { - uuid : depot.uuid, - type : 'depot', - instance : depot, - }; - }) - .catch(Notify.handleError); + StockModal.openFindDepot({ depot: vm.depot }) + .then(function (depot) { + if (!depot) { return; } + vm.movement.entity = { + uuid: depot.uuid, + type: 'depot', + instance: depot, + }; + setSelectedEntity(depot); + }) + .catch(Notify.handleError); } // configure loss function configureLoss() { vm.movement.entity = { - uuid : null, - type : 'loss', - instance : {}, + uuid: null, + type: 'loss', + instance: {}, }; + setSelectedEntity(); + } + + // setSelectedEntity function implementation + // change name, text and display_nam into displayName + function setSelectedEntity(entity) { + if (!entity) { + vm.selectedEntity = {}; + return; + } + + var keys = ['name', 'text', 'display_name']; + keys.forEach(function (key) { + if (entity[key]) { + entity.displayName = entity[key]; + } + }); + + vm.reference = entity.reference || ''; + vm.displayName = entity.displayName; } // ================================ submit ================================ @@ -254,124 +298,124 @@ function StockExitController(Depots, Inventory, Notify, // submit patient function submitPatient() { var movement = { - depot_uuid : vm.depot.uuid, - entity_uuid : vm.movement.entity.uuid, - date : vm.movement.date, - description : vm.movement.description, - is_exit : 1, - flux_id : bhConstants.flux.TO_PATIENT, - user_id : Session.user.id, + depot_uuid: vm.depot.uuid, + entity_uuid: vm.movement.entity.uuid, + date: vm.movement.date, + description: vm.movement.description, + is_exit: 1, + flux_id: bhConstants.flux.TO_PATIENT, + user_id: Session.user.id, }; var lots = vm.Stock.store.data.map(function (row) { return { - inventory_uuid : row.inventory.inventory_uuid, // needed for tracking consumption - uuid : row.lot.uuid, - quantity : row.quantity, - unit_cost : row.lot.unit_cost, + inventory_uuid: row.inventory.inventory_uuid, // needed for tracking consumption + uuid: row.lot.uuid, + quantity: row.quantity, + unit_cost: row.lot.unit_cost, }; }); movement.lots = lots; return Stock.movements.create(movement) - .then(function (document) { - vm.Stock.store.clear(); - ReceiptModal.stockExitPatientReceipt(document.uuid, bhConstants.flux.TO_PATIENT); - }) - .catch(Notify.handleError); + .then(function (document) { + vm.Stock.store.clear(); + ReceiptModal.stockExitPatientReceipt(document.uuid, bhConstants.flux.TO_PATIENT); + }) + .catch(Notify.handleError); } // submit service function submitService() { var movement = { - depot_uuid : vm.depot.uuid, - entity_uuid : vm.movement.entity.uuid, - date : vm.movement.date, - description : vm.movement.description, - is_exit : 1, - flux_id : bhConstants.flux.TO_SERVICE, - user_id : Session.user.id, + depot_uuid: vm.depot.uuid, + entity_uuid: vm.movement.entity.uuid, + date: vm.movement.date, + description: vm.movement.description, + is_exit: 1, + flux_id: bhConstants.flux.TO_SERVICE, + user_id: Session.user.id, }; var lots = vm.Stock.store.data.map(function (row) { return { - inventory_uuid : row.inventory.inventory_uuid, // needed for tracking consumption - uuid : row.lot.uuid, - quantity : row.quantity, - unit_cost : row.lot.unit_cost, + inventory_uuid: row.inventory.inventory_uuid, // needed for tracking consumption + uuid: row.lot.uuid, + quantity: row.quantity, + unit_cost: row.lot.unit_cost, }; }); movement.lots = lots; return Stock.movements.create(movement) - .then(function (document) { - vm.Stock.store.clear(); - ReceiptModal.stockExitServiceReceipt(document.uuid, bhConstants.flux.TO_SERVICE); - }) - .catch(Notify.handleError); + .then(function (document) { + vm.Stock.store.clear(); + ReceiptModal.stockExitServiceReceipt(document.uuid, bhConstants.flux.TO_SERVICE); + }) + .catch(Notify.handleError); } // submit depot function submitDepot() { var movement = { - from_depot : vm.depot.uuid, - from_depot_is_warehouse : vm.depot.is_warehouse, - to_depot : vm.movement.entity.uuid, - date : vm.movement.date, - description : vm.movement.description, - user_id : Session.user.id, + from_depot: vm.depot.uuid, + from_depot_is_warehouse: vm.depot.is_warehouse, + to_depot: vm.movement.entity.uuid, + date: vm.movement.date, + description: vm.movement.description, + user_id: Session.user.id, }; var lots = vm.Stock.store.data.map(function (row) { return { - inventory_uuid : row.inventory.inventory_uuid, // needed for tracking consumption - uuid : row.lot.uuid, - quantity : row.quantity, - unit_cost : row.lot.unit_cost, + inventory_uuid: row.inventory.inventory_uuid, // needed for tracking consumption + uuid: row.lot.uuid, + quantity: row.quantity, + unit_cost: row.lot.unit_cost, }; }); movement.lots = lots; return Stock.movements.create(movement) - .then(function (document) { - vm.Stock.store.clear(); - ReceiptModal.stockExitDepotReceipt(document.uuid, bhConstants.flux.TO_OTHER_DEPOT); - }) - .catch(Notify.handleError); + .then(function (document) { + vm.Stock.store.clear(); + ReceiptModal.stockExitDepotReceipt(document.uuid, bhConstants.flux.TO_OTHER_DEPOT); + }) + .catch(Notify.handleError); } // submit loss function submitLoss() { var movement = { - depot_uuid : vm.depot.uuid, - entity_uuid : vm.movement.entity.uuid, - date : vm.movement.date, - description : vm.movement.description, - is_exit : 1, - flux_id : bhConstants.flux.TO_LOSS, - user_id : Session.user.id, + depot_uuid: vm.depot.uuid, + entity_uuid: vm.movement.entity.uuid, + date: vm.movement.date, + description: vm.movement.description, + is_exit: 1, + flux_id: bhConstants.flux.TO_LOSS, + user_id: Session.user.id, }; var lots = vm.Stock.store.data.map(function (row) { return { - inventory_uuid : row.inventory.inventory_uuid, // needed for tracking consumption - uuid : row.lot.uuid, - quantity : row.quantity, - unit_cost : row.lot.unit_cost, + inventory_uuid: row.inventory.inventory_uuid, // needed for tracking consumption + uuid: row.lot.uuid, + quantity: row.quantity, + unit_cost: row.lot.unit_cost, }; }); movement.lots = lots; return Stock.movements.create(movement) - .then(function (document) { - vm.Stock.store.clear(); - ReceiptModal.stockExitLossReceipt(document.uuid, bhConstants.flux.TO_LOSS); - }) - .catch(Notify.handleError); + .then(function (document) { + vm.Stock.store.clear(); + ReceiptModal.stockExitLossReceipt(document.uuid, bhConstants.flux.TO_LOSS); + }) + .catch(Notify.handleError); } moduleInit(); diff --git a/client/src/modules/templates/bhStockDistributionDestination.tmpl.html b/client/src/modules/templates/bhStockDistributionDestination.tmpl.html new file mode 100644 index 0000000000..9ec9532e80 --- /dev/null +++ b/client/src/modules/templates/bhStockDistributionDestination.tmpl.html @@ -0,0 +1,27 @@ +
+ +
\ No newline at end of file From e28decb89baedd552cd5cda084fde8d249a121a5 Mon Sep 17 00:00:00 2001 From: DedrickEnc Date: Wed, 26 Jul 2017 09:12:05 +0100 Subject: [PATCH 02/13] amend the code translation and filter only lot which are not empty --- client/src/i18n/en/inventory.json | 47 +++++----- client/src/i18n/fr/inventory.json | 47 +++++----- .../bhStockDistributionDestination.js | 1 - client/src/modules/stock/exit/exit.html | 89 ------------------- client/src/modules/stock/exit/exit.js | 12 ++- server/controllers/stock/core.js | 18 ++-- server/controllers/stock/index.js | 6 +- 7 files changed, 72 insertions(+), 148 deletions(-) diff --git a/client/src/i18n/en/inventory.json b/client/src/i18n/en/inventory.json index 52ccdc2c31..735eca0371 100644 --- a/client/src/i18n/en/inventory.json +++ b/client/src/i18n/en/inventory.json @@ -1,21 +1,26 @@ -{"INVENTORY":{"ADD_GROUP":"Add Inventory Group", -"ADD_METADATA":"Add Inventory Item", -"ADD_TYPE":"Add Inventory Type", -"ADD_UNIT":"Add Inventory unit form", -"CONFIGURATION":"Configurations", -"CONTAINS":"Contains", -"CREATE_ANOTHER":"Create another inventory item", -"EDIT_GROUP":"Edit inventory group", -"EDIT_METADATA":"Edit inventory", -"EDIT_TYPE":"Edit inventory type", -"EDIT_UNIT":"Edit inventory unit form", -"ELEMENT":"Element", -"PRICE_LIST_REPORT":"Inventory Prices Report", -"PRICES":"Inventory Prices", -"LIST":"Inventory Data List", -"LIST_METADATA":"Inventory", -"LIST_GROUP":"Inventory Groups", -"LIST_TYPE":"Inventory Types", -"LIST_UNIT":"Inventory Unit form", -"DEFAULT_QUANTITY_DEFINITION":"The default quantity allows you to customize the default quantity invoiced for. The invoicing module can change this quantity at invoice time.", -"REGISTRY": "Inventories Registry"}} \ No newline at end of file +{ + "INVENTORY": { + "ADD_GROUP": "Add Inventory Group", + "ADD_METADATA": "Add Inventory Item", + "ADD_TYPE": "Add Inventory Type", + "ADD_UNIT": "Add Inventory unit form", + "CODE" : "Iventory Code", + "CONFIGURATION": "Configurations", + "CONTAINS": "Contains", + "CREATE_ANOTHER": "Create another inventory item", + "EDIT_GROUP": "Edit inventory group", + "EDIT_METADATA": "Edit inventory", + "EDIT_TYPE": "Edit inventory type", + "EDIT_UNIT": "Edit inventory unit form", + "ELEMENT": "Element", + "PRICE_LIST_REPORT": "Inventory Prices Report", + "PRICES": "Inventory Prices", + "LIST": "Inventory Data List", + "LIST_METADATA": "Inventory", + "LIST_GROUP": "Inventory Groups", + "LIST_TYPE": "Inventory Types", + "LIST_UNIT": "Inventory Unit form", + "DEFAULT_QUANTITY_DEFINITION": "The default quantity allows you to customize the default quantity invoiced for. The invoicing module can change this quantity at invoice time.", + "REGISTRY": "Inventories Registry" + } +} \ No newline at end of file diff --git a/client/src/i18n/fr/inventory.json b/client/src/i18n/fr/inventory.json index 6c3aae4ecf..1b08c9ffe0 100644 --- a/client/src/i18n/fr/inventory.json +++ b/client/src/i18n/fr/inventory.json @@ -1,21 +1,26 @@ -{"INVENTORY":{"ADD_GROUP":"Ajouter Groupe d'Inventaires", -"ADD_METADATA":"Ajouter Inventaire", -"ADD_TYPE":"Ajouter Types d'Inventaires", -"ADD_UNIT":"Ajouter Forme d'Inventaires", -"CONFIGURATION":"Configurations", -"CONTAINS":"Contient", -"CREATE_ANOTHER":"Ajouter une Autre Inventaires", -"DEFAULT_QUANTITY_DEFINITION":"Ce champ suggérera le quantité par défaut dans le facture.", -"EDIT_GROUP":"Modifier Groupe d'inventaires", -"EDIT_METADATA":"Modifier Inventaire", -"EDIT_TYPE":"Modifier Types d'inventaires", -"EDIT_UNIT":"Modifier Forme d'inventaires", -"ELEMENT":"Élément", -"PRICE_LIST_REPORT":"Rapport des prix des articles et services", -"PRICES":"Tarification", -"LIST":"Liste des données d'inventaire", -"LIST_METADATA":"Inventaires", -"LIST_GROUP":"Groupes d'inventaires", -"LIST_TYPE":"Types d'inventaires", -"LIST_UNIT":"Formes d'inventaires", -"REGISTRY": "Registre des inventaires"}} \ No newline at end of file +{ + "INVENTORY": { + "ADD_GROUP": "Ajouter Groupe d'Inventaires", + "ADD_METADATA": "Ajouter Inventaire", + "ADD_TYPE": "Ajouter Types d'Inventaires", + "ADD_UNIT": "Ajouter Forme d'Inventaires", + "CODE" : "Code Inventaire", + "CONFIGURATION": "Configurations", + "CONTAINS": "Contient", + "CREATE_ANOTHER": "Ajouter une Autre Inventaires", + "DEFAULT_QUANTITY_DEFINITION": "Ce champ suggérera le quantité par défaut dans le facture.", + "EDIT_GROUP": "Modifier Groupe d'inventaires", + "EDIT_METADATA": "Modifier Inventaire", + "EDIT_TYPE": "Modifier Types d'inventaires", + "EDIT_UNIT": "Modifier Forme d'inventaires", + "ELEMENT": "Élément", + "PRICE_LIST_REPORT": "Rapport des prix des articles et services", + "PRICES": "Tarification", + "LIST": "Liste des données d'inventaire", + "LIST_METADATA": "Inventaires", + "LIST_GROUP": "Groupes d'inventaires", + "LIST_TYPE": "Types d'inventaires", + "LIST_UNIT": "Formes d'inventaires", + "REGISTRY": "Registre des inventaires" + } +} \ No newline at end of file diff --git a/client/src/js/components/bhStockDistributionDestination.js b/client/src/js/components/bhStockDistributionDestination.js index 6a6192d431..c955bb433c 100644 --- a/client/src/js/components/bhStockDistributionDestination.js +++ b/client/src/js/components/bhStockDistributionDestination.js @@ -13,7 +13,6 @@ DistributionDestinationController.$inject = []; /** * Stock Distribution Destination component - * */ function DistributionDestinationController() { var $ctrl = this; diff --git a/client/src/modules/stock/exit/exit.html b/client/src/modules/stock/exit/exit.html index 79d75b6394..9dfdba89ca 100644 --- a/client/src/modules/stock/exit/exit.html +++ b/client/src/modules/stock/exit/exit.html @@ -23,95 +23,6 @@
- - - - - - - - - - - Date: Wed, 26 Jul 2017 11:40:45 +0100 Subject: [PATCH 03/13] move uniformSelectedExitType function to a service, remove description from receipt, use moment for expiration date --- client/src/i18n/en/form.json | 1 + client/src/i18n/en/table.json | 1 + client/src/i18n/fr/form.json | 1 + client/src/i18n/fr/inventory.json | 2 +- client/src/i18n/fr/table.json | 1 + client/src/js/services/StockService.js | 19 ++++++++++++ client/src/js/services/util.js | 4 +++ client/src/modules/stock/exit/exit.js | 30 +++++++------------ .../stock/exit/templates/expiration.tmpl.html | 3 +- .../bhStockDistributionDestination.tmpl.html | 4 +-- .../stock_exit_patient.receipt.handlebars | 7 ----- 11 files changed, 43 insertions(+), 30 deletions(-) diff --git a/client/src/i18n/en/form.json b/client/src/i18n/en/form.json index ed90b41a34..030c49f711 100644 --- a/client/src/i18n/en/form.json +++ b/client/src/i18n/en/form.json @@ -232,6 +232,7 @@ "DATE_FROM": "Start", "DATE_REGISTRATION": "Registration Date", "DATE_TO": "End", + "DAYS" : "Days", "DEACTIVATE": "Deactivate", "DEBIT": "Debit", "DEBTOR_GROUP": "Debtor Group", diff --git a/client/src/i18n/en/table.json b/client/src/i18n/en/table.json index 159bb888a5..9be9608374 100644 --- a/client/src/i18n/en/table.json +++ b/client/src/i18n/en/table.json @@ -65,6 +65,7 @@ "ENTERPRISE_ID": "ID Enterprise", "EXCHANGE_RATE": "Exchange Rate", "EXPIRATION_DATE": "Expiration Date", + "EXPIRE_IN":"Expire In", "NUM_PIECE": "Num Doc", "ENTRY": "Entry", "EXIT": "Exit", diff --git a/client/src/i18n/fr/form.json b/client/src/i18n/fr/form.json index e097699556..251acc7397 100644 --- a/client/src/i18n/fr/form.json +++ b/client/src/i18n/fr/form.json @@ -232,6 +232,7 @@ "DATE_FROM": "Debut", "DATE_REGISTRATION": "Date d'enregistrement", "DATE_TO": "Fin", + "DAYS": "Jours", "DEACTIVATE": "Désactiver", "DEBIT": "Débit", "DEBTOR_GROUP": "Groupe Débiteur", diff --git a/client/src/i18n/fr/inventory.json b/client/src/i18n/fr/inventory.json index 1b08c9ffe0..5d18ccbb2a 100644 --- a/client/src/i18n/fr/inventory.json +++ b/client/src/i18n/fr/inventory.json @@ -4,7 +4,7 @@ "ADD_METADATA": "Ajouter Inventaire", "ADD_TYPE": "Ajouter Types d'Inventaires", "ADD_UNIT": "Ajouter Forme d'Inventaires", - "CODE" : "Code Inventaire", + "CODE" : "Code Item", "CONFIGURATION": "Configurations", "CONTAINS": "Contient", "CREATE_ANOTHER": "Ajouter une Autre Inventaires", diff --git a/client/src/i18n/fr/table.json b/client/src/i18n/fr/table.json index fa7b292edd..996798f595 100644 --- a/client/src/i18n/fr/table.json +++ b/client/src/i18n/fr/table.json @@ -65,6 +65,7 @@ "ERROR_TYPE": "Type d'erreur", "EXCHANGE_RATE": "Taux de change", "EXPIRATION_DATE": "Date d'expiration", + "EXPIRE_IN" : "Expire Dans", "NUM_PIECE": "N° Piece", "ENTRY": "Entrée", "EXIT": "Sortie", diff --git a/client/src/js/services/StockService.js b/client/src/js/services/StockService.js index 10ed8023d3..e705f74003 100644 --- a/client/src/js/services/StockService.js +++ b/client/src/js/services/StockService.js @@ -22,6 +22,7 @@ function StockService(Api, Filters, AppCache, Periods, $httpParamSerializer, Lan // API for stock integration var integration = new Api('/stock/integration'); +<<<<<<< 6280b18be710c21778a5db39a872828191177374 //Filter service var StockLotFilters = new Filters(); var filterLotCache = new AppCache('stock-lot-filters'); @@ -93,6 +94,23 @@ function StockService(Api, Filters, AppCache, Periods, $httpParamSerializer, Lan return $httpParamSerializer(options); }; + // uniformSelectedEntity function implementation + // change name, text and display_nam into displayName + function uniformSelectedEntity(entity) { + if (!entity) { + return {}; + } + + var keys = ['name', 'text', 'display_name']; + keys.forEach(function (key) { + if (entity[key]) { + entity.displayName = entity[key]; + } + }); + + return {reference : entity.reference || '', displayName : entity.displayName || ''}; + } + var service = { stocks : stocks, lots : lots, @@ -104,6 +122,7 @@ function StockService(Api, Filters, AppCache, Periods, $httpParamSerializer, Lan removeLotFilter : removeLotFilter, loadCachedLotFilters : loadCachedLotFilters, download : download, + uniformSelectedEntity : uniformSelectedEntity }; return service; diff --git a/client/src/js/services/util.js b/client/src/js/services/util.js index 74b25d2714..77d77b1350 100644 --- a/client/src/js/services/util.js +++ b/client/src/js/services/util.js @@ -80,6 +80,10 @@ function UtilService(moment) { return duration ? moment().diff(date, duration) : moment().diff(date); }; + service.getTimeFromToday = function (date, duration){ + return duration ? moment(date).diff(new Date(), duration) : moment(date).diff(new Date()); + } + /** * @function once * diff --git a/client/src/modules/stock/exit/exit.js b/client/src/modules/stock/exit/exit.js index 115a21f536..b5bb3d4404 100644 --- a/client/src/modules/stock/exit/exit.js +++ b/client/src/modules/stock/exit/exit.js @@ -23,6 +23,7 @@ function StockExitController(Depots, Inventory, Notify, Session, util, bhConstan loss: { description: 'STOCK.EXIT_LOSS', find: configureLoss, submit: submitLoss }, }; + vm.util = util; vm.Stock = new StockForm('StockExit'); vm.depot = {}; vm.movement = {}; @@ -119,7 +120,7 @@ function StockExitController(Depots, Inventory, Notify, Session, util, bhConstan { field: 'expiration_date', width: 150, - displayName: 'TABLE.COLUMNS.EXPIRATION_DATE', + displayName: 'TABLE.COLUMNS.EXPIRE_IN', headerCellFilter: 'translate', cellTemplate: 'modules/stock/exit/templates/expiration.tmpl.html' }, @@ -175,7 +176,6 @@ function StockExitController(Depots, Inventory, Notify, Session, util, bhConstan // get lots Stock.lots.read(null, { depot_uuid: vm.depot.uuid, inventory_uuid: item.inventory.inventory_uuid, includeEmptyLot : false }) .then(function (lots) { - console.log('les les retournes', lots); item.lots = lots; }) .catch(Notify.handleError); @@ -218,6 +218,7 @@ function StockExitController(Depots, Inventory, Notify, Session, util, bhConstan type: 'patient', instance: patient, }; + setSelectedEntity(patient); }) .catch(Notify.handleError); @@ -249,6 +250,7 @@ function StockExitController(Depots, Inventory, Notify, Session, util, bhConstan type: 'depot', instance: depot, }; + setSelectedEntity(depot); }) .catch(Notify.handleError); @@ -261,28 +263,18 @@ function StockExitController(Depots, Inventory, Notify, Session, util, bhConstan type: 'loss', instance: {}, }; + setSelectedEntity(); } - // setSelectedEntity function implementation - // change name, text and display_nam into displayName - function setSelectedEntity(entity) { - if (!entity) { - vm.selectedEntity = {}; - return; - } - - var keys = ['name', 'text', 'display_name']; - keys.forEach(function (key) { - if (entity[key]) { - entity.displayName = entity[key]; - } - }); - - vm.reference = entity.reference || ''; - vm.displayName = entity.displayName; + function setSelectedEntity (entity){ + var uniformEntity = Stock.uniformSelectedEntity(entity); + vm.reference = uniformEntity.reference; + vm.displayName = uniformEntity.displayName; } + + // ================================ submit ================================ function submit(form) { if (form.$invalid) { return; } diff --git a/client/src/modules/stock/exit/templates/expiration.tmpl.html b/client/src/modules/stock/exit/templates/expiration.tmpl.html index 7c5304bd4a..7c4b5daff7 100644 --- a/client/src/modules/stock/exit/templates/expiration.tmpl.html +++ b/client/src/modules/stock/exit/templates/expiration.tmpl.html @@ -1,3 +1,4 @@
- {{ row.entity.lot.expiration_date | date }} + {{grid.appScope.util.getTimeFromToday(row.entity.lot.expiration_date, 'days')}} + FORM.LABELS.DAYS
diff --git a/client/src/modules/templates/bhStockDistributionDestination.tmpl.html b/client/src/modules/templates/bhStockDistributionDestination.tmpl.html index 9ec9532e80..4c5fc876b4 100644 --- a/client/src/modules/templates/bhStockDistributionDestination.tmpl.html +++ b/client/src/modules/templates/bhStockDistributionDestination.tmpl.html @@ -16,9 +16,9 @@ {{$ctrl.selectedExitType.descriptionKey}}
- STOCK.CHOOSE_AGAIN + STOCK.CHOOSE_AGAIN
-
+
diff --git a/server/controllers/stock/reports/stock_exit_patient.receipt.handlebars b/server/controllers/stock/reports/stock_exit_patient.receipt.handlebars index 7167fbb091..3d2ed0af4b 100644 --- a/server/controllers/stock/reports/stock_exit_patient.receipt.handlebars +++ b/server/controllers/stock/reports/stock_exit_patient.receipt.handlebars @@ -42,13 +42,6 @@
- {{#if details.description}} -
- {{translate 'FORM.LABELS.DESCRIPTION'}}
- {{details.description}} -
- {{/if}} - From dd032c16eb2aa7d7d1fb89c7086f01545ae04058 Mon Sep 17 00:00:00 2001 From: DedrickEnc Date: Wed, 26 Jul 2017 12:16:42 +0100 Subject: [PATCH 04/13] add a new component for e2e, update e2e --- .../bhStockDistributionDestination.tmpl.html | 2 +- .../shared/components/bhFiscalPeriodSelect.js | 3 --- .../components/bhStockDistributionDestination.js | 12 ++++++++++++ test/end-to-end/shared/components/index.js | 1 + test/end-to-end/stock/stock.exit.page.js | 8 ++++---- 5 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 test/end-to-end/shared/components/bhStockDistributionDestination.js diff --git a/client/src/modules/templates/bhStockDistributionDestination.tmpl.html b/client/src/modules/templates/bhStockDistributionDestination.tmpl.html index 4c5fc876b4..637296cc17 100644 --- a/client/src/modules/templates/bhStockDistributionDestination.tmpl.html +++ b/client/src/modules/templates/bhStockDistributionDestination.tmpl.html @@ -1,5 +1,5 @@
- -
- - -
- -
- - -
- -
- + + diff --git a/client/src/modules/stock/entry/entry.js b/client/src/modules/stock/entry/entry.js index 2f88e58022..5c8c62238c 100644 --- a/client/src/modules/stock/entry/entry.js +++ b/client/src/modules/stock/entry/entry.js @@ -22,7 +22,8 @@ function StockEntryController(Depots, Inventory, Notify, var mapEntry = { purchase : { find: findPurchase, submit: submitPurchase }, donation : { find: angular.noop, submit: angular.noop }, // donation is not yet implemented - integration : { find: angular.noop, submit: submitIntegration }, + integration : { find: angular.noop, submit: submitIntegration}, + transfer_reception : {find: angular.noop, submit : submitTransferReception}, }; vm.Stock = new StockForm('StockEntry'); @@ -94,8 +95,8 @@ function StockEntryController(Depots, Inventory, Notify, // entry type function selectEntryType(entryType) { - vm.movement.entry_type = entryType; - mapEntry[entryType].find(); + vm.movement.entry_type = entryType.label; + mapEntry[entryType.label].find(); } // configure depot @@ -279,5 +280,11 @@ function StockEntryController(Depots, Inventory, Notify, .catch(Notify.handleError); } + //submit transfer reception + function submitTransferReception (){ + return; + + } + moduleInit(); } diff --git a/client/src/modules/stock/exit/exit.html b/client/src/modules/stock/exit/exit.html index 9dfdba89ca..daf6b71f32 100644 --- a/client/src/modules/stock/exit/exit.html +++ b/client/src/modules/stock/exit/exit.html @@ -23,12 +23,12 @@
- - + is-entry="false"> +
diff --git a/client/src/modules/stock/exit/exit.js b/client/src/modules/stock/exit/exit.js index 7eaca7b656..c9d8056935 100644 --- a/client/src/modules/stock/exit/exit.js +++ b/client/src/modules/stock/exit/exit.js @@ -271,9 +271,7 @@ function StockExitController(Depots, Inventory, Notify, Session, util, bhConstan var uniformEntity = Stock.uniformSelectedEntity(entity); vm.reference = uniformEntity.reference; vm.displayName = uniformEntity.displayName; - } - - + } // ================================ submit ================================ function submit(form) { diff --git a/client/src/modules/templates/bhStockDistributionDestination.tmpl.html b/client/src/modules/templates/bhStockDistributionDestination.tmpl.html deleted file mode 100644 index db086d6ec8..0000000000 --- a/client/src/modules/templates/bhStockDistributionDestination.tmpl.html +++ /dev/null @@ -1,24 +0,0 @@ -
- -
\ No newline at end of file diff --git a/client/src/modules/templates/bhStockEntryExitType.tmpl.html b/client/src/modules/templates/bhStockEntryExitType.tmpl.html new file mode 100644 index 0000000000..74a028dfde --- /dev/null +++ b/client/src/modules/templates/bhStockEntryExitType.tmpl.html @@ -0,0 +1,24 @@ +
+ +
\ No newline at end of file diff --git a/server/controllers/stock/reports/index.js b/server/controllers/stock/reports/index.js index 897ea2845b..5d6916c663 100644 --- a/server/controllers/stock/reports/index.js +++ b/server/controllers/stock/reports/index.js @@ -514,7 +514,6 @@ function stockEntryIntegrationReceipt(req, res, next) { * @param {string} documentUuid * @param {object} enterprise * @param {boolean} isExit - * @param {string} otherDepotUuid * @description return depot movement informations * @return {object} data */ From ac384c38a3e1486e4316210f24dacf15d226052d Mon Sep 17 00:00:00 2001 From: DedrickEnc Date: Fri, 28 Jul 2017 16:19:42 +0100 Subject: [PATCH 08/13] reception of transfer done, test update remain --- client/src/i18n/en/stock.json | 2 +- client/src/i18n/fr/stock.json | 2 +- client/src/modules/stock/entry/entry.js | 52 ++++++++- .../stock/entry/modals/findPurchase.modal.js | 2 +- .../entry/modals/findTransfer.modal.html | 53 +++++++++ .../stock/entry/modals/findTransfer.modal.js | 105 ++++++++++++++++++ .../stock/entry/modals/lots.modal.html | 8 +- .../modules/stock/entry/modals/lots.modal.js | 9 +- .../modals/templates/lot.expiration.tmpl.html | 6 +- .../modals/templates/lot.input.tmpl.html | 1 + ...tmpl.html => purchase_reference.tmpl.html} | 0 .../templates/transfer_reference.tmpl.html | 3 + client/src/modules/stock/stock.service.js | 19 ++++ server/controllers/stock/core.js | 21 +++- server/controllers/stock/index.js | 4 +- .../stock_entry_depot.receipt.handlebars | 4 +- 16 files changed, 265 insertions(+), 26 deletions(-) create mode 100644 client/src/modules/stock/entry/modals/findTransfer.modal.html create mode 100644 client/src/modules/stock/entry/modals/findTransfer.modal.js rename client/src/modules/stock/entry/modals/templates/{purchase.reference.tmpl.html => purchase_reference.tmpl.html} (100%) create mode 100644 client/src/modules/stock/entry/modals/templates/transfer_reference.tmpl.html diff --git a/client/src/i18n/en/stock.json b/client/src/i18n/en/stock.json index 4f69ad84e5..f6a2accc49 100644 --- a/client/src/i18n/en/stock.json +++ b/client/src/i18n/en/stock.json @@ -74,7 +74,7 @@ "EXIT_LOSS" : "Stock Exit - Loss" }, "RECEIVER" : "Recepteur", - "RECEPTION_TRANSFER" : "Reception transfer", + "RECEPTION_TRANSFER" : "Transfer", "RESPONSIBLE" : "Stock Manager", "SEARCH" : "Search", "SECURITY" : "Security Stock", diff --git a/client/src/i18n/fr/stock.json b/client/src/i18n/fr/stock.json index 6d040f6ffb..49639ecaa7 100644 --- a/client/src/i18n/fr/stock.json +++ b/client/src/i18n/fr/stock.json @@ -74,7 +74,7 @@ "EXIT_LOSS" : "Sortie de Stock - Perte" }, "RECEIVER" : "Recepteur", - "RECEPTION_TRANSFER" : "Reception Transfert", + "RECEPTION_TRANSFER" : "Transfert", "RESPONSIBLE" : "Gestionnaire du stock", "SEARCH" : "Chercher", "SECURITY" : "Stock de securité", diff --git a/client/src/modules/stock/entry/entry.js b/client/src/modules/stock/entry/entry.js index 5c8c62238c..2ddcdcfe34 100644 --- a/client/src/modules/stock/entry/entry.js +++ b/client/src/modules/stock/entry/entry.js @@ -23,7 +23,7 @@ function StockEntryController(Depots, Inventory, Notify, purchase : { find: findPurchase, submit: submitPurchase }, donation : { find: angular.noop, submit: angular.noop }, // donation is not yet implemented integration : { find: angular.noop, submit: submitIntegration}, - transfer_reception : {find: angular.noop, submit : submitTransferReception}, + transfer_reception : {find: findTransfer, submit : submitTransferReception}, }; vm.Stock = new StockForm('StockEntry'); @@ -158,6 +158,22 @@ function StockEntryController(Depots, Inventory, Notify, .catch(Notify.handleError); } + // find transfer + function findTransfer(params) { + StockModal.openFindTansfer({depot_uuid : vm.depot.uuid}) + .then(function(transfers) { + if (!transfers) { return; } + vm.movement.entity = { + uuid : transfers[0].uuid, + type : 'transfer_reception', + instance : transfers[0], + }; + + populate(transfers); + }) + .catch(Notify.handleError); + } + // populate the grid function populate(items) { if (!items.length) { return; } @@ -166,9 +182,12 @@ function StockEntryController(Depots, Inventory, Notify, vm.Stock.store.data.forEach(function (item, index) { item.inventory = inventoryStore.get(items[index].inventory_uuid); - item.unit_cost = items[index].unit_price; - item.quantity = items[index].balance; + item.unit_cost = items[index].unit_price || items[index].unit_cost; + item.quantity = items[index].balance || items[index].quantity; item.cost = item.quantity * item.unit_cost; + item.lot_uuid = items[index].uuid; + item.lot = items[index].label; + item.expiration_date = items[index].expiration_date; configureItem(item); }); } @@ -282,8 +301,33 @@ function StockEntryController(Depots, Inventory, Notify, //submit transfer reception function submitTransferReception (){ - return; + var movement = { + from_depot: vm.movement.entity.instance.depot_uuid, + to_depot: vm.depot.uuid, + document_uuid : vm.movement.entity.instance.document_uuid, + date: vm.movement.entity.instance.date, + description: vm.movement.entity.instance.description, + isExit: false, + user_id: Session.user.id, + }; + + var lots = vm.Stock.store.data.map(function (row) { + return { + uuid: row.lot_uuid, + quantity: row.quantity, + unit_cost: row.unit_cost, + }; + }); + movement.lots = lots; + + return Stock.movements.create(movement) + .then(function (document) { + vm.Stock.store.clear(); + vm.movement = {}; + ReceiptModal.stockEntryDepotReceipt(document.uuid, bhConstants.flux.FROM_OTHER_DEPOT); + }) + .catch(Notify.handleError); } moduleInit(); diff --git a/client/src/modules/stock/entry/modals/findPurchase.modal.js b/client/src/modules/stock/entry/modals/findPurchase.modal.js index 2320253b1d..06d585673b 100644 --- a/client/src/modules/stock/entry/modals/findPurchase.modal.js +++ b/client/src/modules/stock/entry/modals/findPurchase.modal.js @@ -23,7 +23,7 @@ function StockFindPurchaseModalController(Instance, Purchase, Notify, { field : 'reference', displayName : 'TABLE.COLUMNS.REFERENCE', headerCellFilter : 'translate', - cellTemplate : 'modules/stock/entry/modals/templates/purchase.reference.tmpl.html' }, + cellTemplate : 'modules/stock/entry/modals/templates/purchase_reference.tmpl.html' }, { field : 'date', cellFilter : 'date', diff --git a/client/src/modules/stock/entry/modals/findTransfer.modal.html b/client/src/modules/stock/entry/modals/findTransfer.modal.html new file mode 100644 index 0000000000..d3390b7cd6 --- /dev/null +++ b/client/src/modules/stock/entry/modals/findTransfer.modal.html @@ -0,0 +1,53 @@ + + + + + + + + \ No newline at end of file diff --git a/client/src/modules/stock/entry/modals/findTransfer.modal.js b/client/src/modules/stock/entry/modals/findTransfer.modal.js new file mode 100644 index 0000000000..5406381f4f --- /dev/null +++ b/client/src/modules/stock/entry/modals/findTransfer.modal.js @@ -0,0 +1,105 @@ +angular.module('bhima.controllers') + .controller('StockFindTransferModalController', StockFindTransferModalController); + +StockFindTransferModalController.$inject = [ + '$uibModalInstance', 'StockService', 'NotifyService', 'uiGridConstants', + 'GridFilteringService', 'ReceiptModal', 'data', +]; + +function StockFindTransferModalController(Instance, StockService, Notify, + uiGridConstants, Filtering, Receipts, data) { + var vm = this; + + // global + vm.selectedRow = {}; + + /* ======================= Grid configurations ============================ */ + vm.filterEnabled = false; + vm.gridOptions = { appScopeProvider: vm }; + + var filtering = new Filtering(vm.gridOptions); + + var columns = [ + { + field: 'reference', + displayName: 'TABLE.COLUMNS.REFERENCE', + headerCellFilter: 'translate', + cellTemplate: 'modules/stock/entry/modals/templates/transfer_reference.tmpl.html' + }, + { + field: 'date', + cellFilter: 'date', + filter: { condition: filtering.filterByDate }, + displayName: 'TABLE.COLUMNS.DATE', + headerCellFilter: 'translate', + sort: { priority: 0, direction: 'desc' }, + }, + { + field: 'depot_text', + displayName: 'FORM.LABELS.DEPOT', + headerCellFilter: 'translate' + }, + ]; + + vm.gridOptions.columnDefs = columns; + vm.gridOptions.multiSelect = false; + vm.gridOptions.enableFiltering = vm.filterEnabled; + vm.gridOptions.onRegisterApi = onRegisterApi; + vm.toggleFilter = toggleFilter; + + // bind methods + vm.submit = submit; + vm.cancel = cancel; + vm.showReceipt = showReceipt; + + function onRegisterApi(gridApi) { + vm.gridApi = gridApi; + vm.gridApi.selection.on.rowSelectionChanged(null, rowSelectionCallback); + } + + function rowSelectionCallback(row) { + vm.selectedRow = row.entity; + } + + /** toggle filter */ + function toggleFilter() { + vm.filterEnabled = !vm.filterEnabled; + vm.gridOptions.enableFiltering = vm.filterEnabled; + vm.gridApi.core.notifyDataChange(uiGridConstants.dataChange.COLUMN); + } + + /** get transfer document */ + function showReceipt(uuid) { + Receipts.stockExitDepotReceipt(uuid, true); + } + + /* ======================= End Grid ======================================== */ + StockService.movements.read(null, { + entity_uuid: data.depot_uuid, + is_exit: 1, + finalClauseParameter: 'GROUP BY document_uuid', + }) + .then(function (transfers) { + vm.gridOptions.data = transfers; + }) + .catch(Notify.errorHandler); + + // submit + function submit() { + if (!vm.selectedRow) { return; } + + return StockService.movements.read(null, { + document_uuid: vm.selectedRow.document_uuid, + }) + .then(function (transfers) { + Instance.close(transfers); + }) + .catch(Notify.errorHandler); + } + + // cancel + function cancel() { + Instance.dismiss(); + } + +} diff --git a/client/src/modules/stock/entry/modals/lots.modal.html b/client/src/modules/stock/entry/modals/lots.modal.html index 97540b040c..11ecbb87f4 100644 --- a/client/src/modules/stock/entry/modals/lots.modal.html +++ b/client/src/modules/stock/entry/modals/lots.modal.html @@ -14,7 +14,7 @@

{{ $ctrl.inventory.inventory.label }}

{{ $ctrl.inventory.inventory.label }}
{{ $ctrl.inventory.inventory.label }}
+
diff --git a/client/src/modules/stock/entry/modals/lots.modal.js b/client/src/modules/stock/entry/modals/lots.modal.js index aa810d3e50..d3fd6fd3f8 100644 --- a/client/src/modules/stock/entry/modals/lots.modal.js +++ b/client/src/modules/stock/entry/modals/lots.modal.js @@ -14,6 +14,7 @@ function StockDefineLotsModalController(Instance, Notify, uiGridConstants, Data, vm.gridApi = {}; vm.enterprise = Session.enterprise; vm.entryType = Data.entry_type; + /* ======================= Grid configurations ============================ */ vm.gridOptions = { @@ -90,9 +91,9 @@ function StockDefineLotsModalController(Instance, Notify, uiGridConstants, Data, return; } vm.gridOptions.data.push({ - is_valid : false, - lot : '', - expiration_date : new Date(), + is_valid : vm.entryType === 'transfer_reception' ? true : false, + lot : vm.inventory.lot || '', + expiration_date : new Date(vm.inventory.expiration_date) || new Date(), quantity : vm.remainingQuantity, }); } @@ -114,7 +115,7 @@ function StockDefineLotsModalController(Instance, Notify, uiGridConstants, Data, var sum = vm.gridOptions.data.reduce(sumQuantity, 0); var hasQuantity = (vm.inventory.quantity >= sum); var hasLotLabel = inventory.lot; - var hasExpiration = (new Date(inventory.expiration_date) > new Date()); + var hasExpiration = (new Date(inventory.expiration_date) >= new Date()); inventory.is_valid = (hasQuantity && hasLotLabel && hasExpiration); vm.remainingQuantity = (vm.inventory.quantity - sum >= 0) ? vm.inventory.quantity - sum : 0; diff --git a/client/src/modules/stock/entry/modals/templates/lot.expiration.tmpl.html b/client/src/modules/stock/entry/modals/templates/lot.expiration.tmpl.html index b7d684dfab..a9e91e51f2 100644 --- a/client/src/modules/stock/entry/modals/templates/lot.expiration.tmpl.html +++ b/client/src/modules/stock/entry/modals/templates/lot.expiration.tmpl.html @@ -1,5 +1,7 @@ -
- + diff --git a/client/src/modules/stock/entry/modals/templates/lot.input.tmpl.html b/client/src/modules/stock/entry/modals/templates/lot.input.tmpl.html index 9c9cf4f99e..ad39120509 100644 --- a/client/src/modules/stock/entry/modals/templates/lot.input.tmpl.html +++ b/client/src/modules/stock/entry/modals/templates/lot.input.tmpl.html @@ -1,5 +1,6 @@ \ No newline at end of file diff --git a/client/src/modules/stock/stock.service.js b/client/src/modules/stock/stock.service.js index 72b78b33f3..ee6dea706e 100644 --- a/client/src/modules/stock/stock.service.js +++ b/client/src/modules/stock/stock.service.js @@ -22,6 +22,7 @@ function StockModalService(Modal) { service.openFindDepot = openFindDepot; service.openFindPurchase = openFindPurchase; service.openDefineLots = openDefineLots; + service.openFindTansfer = openFindTansfer; /** search stock lots */ function openSearchLots(request) { @@ -149,6 +150,24 @@ function StockModalService(Modal) { return instance.result; } + /** search transfer */ + function openFindTansfer(request) { + var params = angular.extend(modalParameters, { + templateUrl : 'modules/stock/entry/modals/findTransfer.modal.html', + controller : 'StockFindTransferModalController', + controllerAs : '$ctrl', + size : 'md', + backdrop : 'static', + animation : false, + resolve : { + data : function dataProvider() { return request; }, + }, + }); + + var instance = Modal.open(params); + return instance.result; + } + /** lots definition */ function openDefineLots(request) { var params = angular.extend(modalParameters, { diff --git a/server/controllers/stock/core.js b/server/controllers/stock/core.js index 58e1002456..0e4f3fefbd 100644 --- a/server/controllers/stock/core.js +++ b/server/controllers/stock/core.js @@ -173,16 +173,25 @@ function getLotsDepot(depotUuid, params, finalClause) { * @param {object} params - A request query object */ function getLotsMovements(depotUuid, params) { + let finalClause; + if (depotUuid) { params.depot_uuid = depotUuid; } + if(params.finalClauseParameter){ + finalClause = 'GROUP BY document_uuid'; + delete params.finalClauseParameter; + } + const sql = ` - SELECT BUID(l.uuid) AS uuid, l.label, l.initial_quantity, m.quantity, d.text AS depot_text, - IF(is_exit = 1, "OUT", "IN") AS io, l.unit_cost, l.expiration_date, - BUID(l.inventory_uuid) AS inventory_uuid, BUID(l.origin_uuid) AS origin_uuid, - l.entry_date, i.code, i.text, BUID(m.depot_uuid) AS depot_uuid, m.is_exit, m.date, - BUID(m.document_uuid) AS document_uuid, m.flux_id, BUID(m.entity_uuid) AS entity_uuid, m.unit_cost, + SELECT + BUID(l.uuid) AS uuid, l.label, l.initial_quantity, m.quantity, m.reference, m.description, + d.text AS depot_text, IF(is_exit = 1, "OUT", "IN") AS io, l.unit_cost, + l.expiration_date, BUID(l.inventory_uuid) AS inventory_uuid, + BUID(l.origin_uuid) AS origin_uuid, l.entry_date, i.code, i.text, + BUID(m.depot_uuid) AS depot_uuid, m.is_exit, m.date, BUID(m.document_uuid) AS document_uuid, + m.flux_id, BUID(m.entity_uuid) AS entity_uuid, m.unit_cost, f.label AS flux_label, i.delay, iu.text AS unit_type FROM stock_movement m @@ -193,7 +202,7 @@ function getLotsMovements(depotUuid, params) { JOIN flux f ON f.id = m.flux_id `; - return getLots(sql, params); + return getLots(sql, params, finalClause); } /** diff --git a/server/controllers/stock/index.js b/server/controllers/stock/index.js index 44926c027b..63811206cb 100644 --- a/server/controllers/stock/index.js +++ b/server/controllers/stock/index.js @@ -111,8 +111,8 @@ function createMovement(req, res, next) { const params = req.body; const document = { - uuid : uuid.v4(), - date : new Date(params.date), + uuid : params.document_uuid || uuid.v4(), + date : moment(new Date(params.date)).format('YYYY-MM-DD').toString(), user : req.session.user.id, }; diff --git a/server/controllers/stock/reports/stock_entry_depot.receipt.handlebars b/server/controllers/stock/reports/stock_entry_depot.receipt.handlebars index 5f7189cfcf..94c25a175c 100644 --- a/server/controllers/stock/reports/stock_entry_depot.receipt.handlebars +++ b/server/controllers/stock/reports/stock_entry_depot.receipt.handlebars @@ -31,8 +31,8 @@

{{translate 'STOCK.FROM'}}

- {{translate 'STOCK.DEPOT'}}: {{exit.details.depot_name}}
- {{translate 'FORM.LABELS.DOCUMENT'}}: {{exit.details.document_reference}}
+ {{translate 'STOCK.DEPOT'}}: {{entry.details.otherDepotName}}
+ {{translate 'FORM.LABELS.DOCUMENT'}}: {{entry.details.document_reference}}

{{translate 'STOCK.TO'}}

From 7f0ea162b04ed849ac0682b2eb9e638932aaa866 Mon Sep 17 00:00:00 2001 From: DedrickEnc Date: Sat, 29 Jul 2017 13:49:08 +0100 Subject: [PATCH 09/13] stock movement depot to depot done --- client/src/i18n/en/form.json | 1 + client/src/i18n/fr/form.json | 1 + client/src/modules/stock/entry/entry.js | 10 +++---- .../stock/entry/modals/findTransfer.modal.js | 19 ++++++++---- .../modules/stock/entry/modals/lots.modal.js | 8 ++++- ...ence.tmpl.html => transfer_view.tmpl.html} | 2 +- .../templates/bhStockEntryExitType.tmpl.html | 1 - ...Destination.js => bhStockEntryExitType.js} | 0 test/end-to-end/shared/components/index.js | 2 +- test/end-to-end/stock/stock.entry.page.js | 29 ++++++++++++++----- test/end-to-end/stock/stock.entry.spec.js | 20 ++++++++++++- test/end-to-end/stock/stock.exit.page.js | 10 +++---- test/integration/stock.js | 9 +++--- 13 files changed, 79 insertions(+), 33 deletions(-) rename client/src/modules/stock/entry/modals/templates/{transfer_reference.tmpl.html => transfer_view.tmpl.html} (70%) rename test/end-to-end/shared/components/{bhStockDistributionDestination.js => bhStockEntryExitType.js} (100%) diff --git a/client/src/i18n/en/form.json b/client/src/i18n/en/form.json index 030c49f711..77cddec0c4 100644 --- a/client/src/i18n/en/form.json +++ b/client/src/i18n/en/form.json @@ -239,6 +239,7 @@ "DEBTOR_GROUP_FORM": "Form debtor group record", "DEFINE_UNTIL_DATE": "Define a limit date", "DEFAULT_QUANTITY": "Default Quantity", + "DEPOT": "Depot", "DESCRIPTION": "Description", "DESIGNATION": "Designation", "DETAIL_PREVIOUS": "Previous Year Details", diff --git a/client/src/i18n/fr/form.json b/client/src/i18n/fr/form.json index 251acc7397..8b9476342d 100644 --- a/client/src/i18n/fr/form.json +++ b/client/src/i18n/fr/form.json @@ -239,6 +239,7 @@ "DEBTOR_GROUP_FORM": "Formulaire d'enregistrement de groupe débiteur", "DEBTOR_CREDITOR": "Débiteur/Créditeur", "DEFINE_UNTIL_DATE": "Définir une date limite", + "DEPOT": "Depot", "DESCRIPTION": "Description", "DETAILS": "Details", "DEFAULTS": "Filtres par défaut", diff --git a/client/src/modules/stock/entry/entry.js b/client/src/modules/stock/entry/entry.js index 2ddcdcfe34..7727cb5280 100644 --- a/client/src/modules/stock/entry/entry.js +++ b/client/src/modules/stock/entry/entry.js @@ -198,10 +198,10 @@ function StockEntryController(Depots, Inventory, Notify, inventory : inventory, entry_type : vm.movement.entry_type, }) - .then(function (rows) { - if (!rows) { return; } - inventory.lots = rows.lots; - inventory.givenQuantity = rows.quantity; + .then(function (row) { + if (!row) { return; } + inventory.lots = row.lots; + inventory.givenQuantity = row.quantity; vm.hasValidInput = hasValidInput(); }) .catch(Notify.handleError); @@ -314,7 +314,7 @@ function StockEntryController(Depots, Inventory, Notify, var lots = vm.Stock.store.data.map(function (row) { return { uuid: row.lot_uuid, - quantity: row.quantity, + quantity: row.lots[0].quantity, unit_cost: row.unit_cost, }; }); diff --git a/client/src/modules/stock/entry/modals/findTransfer.modal.js b/client/src/modules/stock/entry/modals/findTransfer.modal.js index 5406381f4f..65c5b53244 100644 --- a/client/src/modules/stock/entry/modals/findTransfer.modal.js +++ b/client/src/modules/stock/entry/modals/findTransfer.modal.js @@ -20,12 +20,6 @@ function StockFindTransferModalController(Instance, StockService, Notify, var filtering = new Filtering(vm.gridOptions); var columns = [ - { - field: 'reference', - displayName: 'TABLE.COLUMNS.REFERENCE', - headerCellFilter: 'translate', - cellTemplate: 'modules/stock/entry/modals/templates/transfer_reference.tmpl.html' - }, { field: 'date', cellFilter: 'date', @@ -39,6 +33,18 @@ function StockFindTransferModalController(Instance, StockService, Notify, displayName: 'FORM.LABELS.DEPOT', headerCellFilter: 'translate' }, + { + field: 'description', + displayName: 'FORM.LABELS.DESCRIPTION', + headerCellFilter: 'translate' + }, + { + field: 'action', + displayName: '', + enableFiltering: false, + enableSorting: false, + cellTemplate: 'modules/stock/entry/modals/templates/transfer_view.tmpl.html' + } ]; vm.gridOptions.columnDefs = columns; @@ -90,6 +96,7 @@ function StockFindTransferModalController(Instance, StockService, Notify, return StockService.movements.read(null, { document_uuid: vm.selectedRow.document_uuid, + is_exit: 1, }) .then(function (transfers) { Instance.close(transfers); diff --git a/client/src/modules/stock/entry/modals/lots.modal.js b/client/src/modules/stock/entry/modals/lots.modal.js index d3fd6fd3f8..a84797edb9 100644 --- a/client/src/modules/stock/entry/modals/lots.modal.js +++ b/client/src/modules/stock/entry/modals/lots.modal.js @@ -91,11 +91,17 @@ function StockDefineLotsModalController(Instance, Notify, uiGridConstants, Data, return; } vm.gridOptions.data.push({ - is_valid : vm.entryType === 'transfer_reception' ? true : false, + is_valid : false, lot : vm.inventory.lot || '', expiration_date : new Date(vm.inventory.expiration_date) || new Date(), quantity : vm.remainingQuantity, }); + + // if it is a transfer reception, so force the validation on the single element + if(vm.entryType === 'transfer_reception') { + handleChange(vm.gridOptions.data[0]); + } + } // remove lot diff --git a/client/src/modules/stock/entry/modals/templates/transfer_reference.tmpl.html b/client/src/modules/stock/entry/modals/templates/transfer_view.tmpl.html similarity index 70% rename from client/src/modules/stock/entry/modals/templates/transfer_reference.tmpl.html rename to client/src/modules/stock/entry/modals/templates/transfer_view.tmpl.html index 1b507cd589..8683979ad8 100644 --- a/client/src/modules/stock/entry/modals/templates/transfer_reference.tmpl.html +++ b/client/src/modules/stock/entry/modals/templates/transfer_view.tmpl.html @@ -1,3 +1,3 @@ \ No newline at end of file diff --git a/client/src/modules/templates/bhStockEntryExitType.tmpl.html b/client/src/modules/templates/bhStockEntryExitType.tmpl.html index 74a028dfde..3d773b0066 100644 --- a/client/src/modules/templates/bhStockEntryExitType.tmpl.html +++ b/client/src/modules/templates/bhStockEntryExitType.tmpl.html @@ -17,7 +17,6 @@
-
diff --git a/test/end-to-end/shared/components/bhStockDistributionDestination.js b/test/end-to-end/shared/components/bhStockEntryExitType.js similarity index 100% rename from test/end-to-end/shared/components/bhStockDistributionDestination.js rename to test/end-to-end/shared/components/bhStockEntryExitType.js diff --git a/test/end-to-end/shared/components/index.js b/test/end-to-end/shared/components/index.js index fa47324cff..d44bbbf83d 100644 --- a/test/end-to-end/shared/components/index.js +++ b/test/end-to-end/shared/components/index.js @@ -33,5 +33,5 @@ module.exports = { transactionTypeSelect : require('./bhTransactionTypeSelect'), patientGroupSelect : require('./bhPatientGroupSelect'), supplierSelect : require('./bhSupplierSelect'), - stockDistributionDestination : require('./bhStockDistributionDestination'), + stockEntryExitType : require('./bhStockEntryExitType'), }; diff --git a/test/end-to-end/stock/stock.entry.page.js b/test/end-to-end/stock/stock.entry.page.js index 4c314dc236..42f6a00474 100644 --- a/test/end-to-end/stock/stock.entry.page.js +++ b/test/end-to-end/stock/stock.entry.page.js @@ -22,19 +22,29 @@ function StockEntryPage() { /** * @method setPurchase - * @param {string} reference - the patient reference + * @param {string} rowNumber - the purchase line on the modal */ page.setPurchase = function setPurchase(rowNumber) { - element(by.css('[name="btn-purchase"]')).click(); + components.stockEntryExitType.set('entry-exit-type-purchase'); GU.selectRow('PurchaseGrid', rowNumber); FU.modal.submit(); }; + /** + * @method setTransfer + * @param {string} rowNumber - movement line on the modal grid + */ + page.setTransfer = function setTransfer(rowNumber) { + components.stockEntryExitType.set('entry-exit-type-transfer-reception'); + GU.selectRow('TransferGrid', rowNumber); + FU.modal.submit(); + }; + /** * @method setIntegration */ page.setIntegration = function setIntegration() { - element(by.css('[name="btn-integration"]')).click(); + components.stockEntryExitType.set('entry-exit-type-integration'); }; /** @@ -86,7 +96,7 @@ function StockEntryPage() { * { label: '...', quantity: '...', expiration_date: '...' } * ] */ - page.setLots = function setLots(inventoryRowNumber, lotsArray, inventoryQuantity, inventoryUnitCost) { + page.setLots = function setLots(inventoryRowNumber, lotsArray, isTransferReception, inventoryQuantity, inventoryUnitCost) { // lots column const launchLots = GU.getCell(gridId, inventoryRowNumber, 3); @@ -107,20 +117,23 @@ function StockEntryPage() { $('[data-add-lot]').click(); } - lotsArray.forEach((lot, index) => { lotCell = GU.getCell(lotGridId, index, 1); quantityCell = GU.getCell(lotGridId, index, 2); expirationDateCell = GU.getCell(lotGridId, index, 3); // enter lot label - FU.input('row.entity.lot', lot.label, lotCell); + if(!isTransferReception){ + FU.input('row.entity.lot', lot.label, lotCell); + } // enter lot quantity FU.input('row.entity.quantity', lot.quantity, quantityCell); - + // enter lot expiration date - components.datePicker.set(lot.expiration_date, expirationDateCell); + if(!isTransferReception){ + components.datePicker.set(lot.expiration_date, expirationDateCell); + } if (index < lotsArray.length - 1) { // Add another lot line diff --git a/test/end-to-end/stock/stock.entry.spec.js b/test/end-to-end/stock/stock.entry.spec.js index 89cc4d432b..06637764d5 100644 --- a/test/end-to-end/stock/stock.entry.spec.js +++ b/test/end-to-end/stock/stock.entry.spec.js @@ -32,7 +32,7 @@ function StockExiTests() { { label: 'LX-THREE', quantity: 200, expiration_date: '2018-09-15' }, ]; - page.setLots(0, lots); + page.setLots(0, lots, false); // submit page.submit(); @@ -63,6 +63,24 @@ function StockExiTests() { page.setLots(0, lots, 1500, 0.09); + // submit + page.submit(); + }); + + it('Should entry stock from a transfer reception', () => { + // select the movement + page.setTransfer(0); + + page.setDate(new Date()); + + page.setDescription(DESCRIPTION.concat(' - Transfer reception')); + + const lots = [ + { quantity: 75} + ]; + + page.setLots(0, lots, true); + // submit page.submit(); }); diff --git a/test/end-to-end/stock/stock.exit.page.js b/test/end-to-end/stock/stock.exit.page.js index b17ff755f8..3dd072a0e4 100644 --- a/test/end-to-end/stock/stock.exit.page.js +++ b/test/end-to-end/stock/stock.exit.page.js @@ -24,8 +24,8 @@ function StockExitPage() { * @method setPatient * @param {string} reference - the patient reference */ - page.setPatient = function setDepot(reference) { - components.stockDistributionDestination.set('exit-type-patient'); + page.setPatient = function setPatient(reference) { + components.stockEntryExitType.set('entry-exit-type-patient'); components.findPatient.findById(reference); FU.modal.submit(); }; @@ -35,7 +35,7 @@ function StockExitPage() { * @param {string} service - the service name */ page.setService = function setService(service) { - components.stockDistributionDestination.set('exit-type-service'); + components.stockEntryExitType.set('entry-exit-type-service'); const modalContent = element(by.css('[class="modal-content"]')); FU.uiSelect('$ctrl.selected', service, modalContent); FU.modal.submit(); @@ -46,7 +46,7 @@ function StockExitPage() { * @param {string} depot - the depot name */ page.setDestinationDepot = function setDestinationDepot(depot) { - components.stockDistributionDestination.set('exit-type-depot'); + components.stockEntryExitType.set('entry-exit-type-depot'); const modalContent = element(by.css('[class="modal-content"]')); FU.uiSelect('$ctrl.selected', depot, modalContent); FU.modal.submit(); @@ -56,7 +56,7 @@ function StockExitPage() { * @method setLoss */ page.setLoss = function setLoss() { - components.stockDistributionDestination.set('exit-type-loss'); + components.stockEntryExitType.set('entry-exit-type-loss'); }; /** diff --git a/test/integration/stock.js b/test/integration/stock.js index b7412c78b7..b06777e353 100644 --- a/test/integration/stock.js +++ b/test/integration/stock.js @@ -138,9 +138,10 @@ describe('(/stock/) The Stock HTTP API', () => { // ============================================================================== const depotPrincipalUuid = 'f9caeb16-1684-43c5-a6c4-47dbac1df296'; - const depotPrincipalMvt = 14; // 10 initial plus 4 distributions + const depotPrincipalMvt = 12; // 10 initial plus 2 distributions const lotQuinineUuid = 'ae735e99-8faf-417b-aa63-9b404fca99ac'; + // create new stock lots it('POST /stock/lots create a new stock lots entry', () => agent.post('/stock/lots') .send(movementFirstLots) @@ -166,16 +167,16 @@ describe('(/stock/) The Stock HTTP API', () => { .catch(helpers.handler)); // list all movement relatives to 'Depot Principal' - it('GET /stock/lots/movements?depot_uuid=... returns movements for Depot Principal (14: 10 IN + 4 OUT)', () => agent.get(`/stock/lots/movements?depot_uuid=${depotPrincipalUuid}`) + it('GET /stock/lots/movements?depot_uuid=... returns movements for Depot Principal (12: 8 IN + 2 OUT)', () => agent.get(`/stock/lots/movements?depot_uuid=${depotPrincipalUuid}`) .then((res) => { helpers.api.listed(res, depotPrincipalMvt); }) .catch(helpers.handler)); // list all stock exit relatives to 'Depot Principal' - it('GET /stock/lots/movements?is_exit=1&depot_uuid=... returns exits for Depot Principal (4 OUT)', () => agent.get(`/stock/lots/movements?is_exit=1&depot_uuid=${depotPrincipalUuid}`) + it('GET /stock/lots/movements?is_exit=1&depot_uuid=... returns exits for Depot Principal (2 OUT)', () => agent.get(`/stock/lots/movements?is_exit=1&depot_uuid=${depotPrincipalUuid}`) .then((res) => { - helpers.api.listed(res, 4); + helpers.api.listed(res, 2); }) .catch(helpers.handler)); From 036edb22c66dfc5433f1d09e9b789e41eea76290 Mon Sep 17 00:00:00 2001 From: DedrickEnc Date: Sat, 29 Jul 2017 17:31:03 +0100 Subject: [PATCH 10/13] updating e2e test --- client/src/modules/stock/entry/entry.js | 1 + client/src/modules/stock/entry/modals/lots.modal.js | 5 +++-- test/data.sql | 3 ++- test/end-to-end/stock/stock.entry.page.js | 9 ++++----- test/end-to-end/stock/stock.entry.spec.js | 6 +++--- test/end-to-end/stock/stock.inventories.spec.js | 3 +-- test/end-to-end/stock/stock.lots.spec.js | 2 +- test/end-to-end/stock/stock.movements.spec.js | 10 +++++----- test/integration/stock.js | 9 ++++----- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/client/src/modules/stock/entry/entry.js b/client/src/modules/stock/entry/entry.js index 7727cb5280..295c8b45d0 100644 --- a/client/src/modules/stock/entry/entry.js +++ b/client/src/modules/stock/entry/entry.js @@ -194,6 +194,7 @@ function StockEntryController(Depots, Inventory, Notify, // ============================ lots management =========================== function setLots(inventory) { + console.log('inventaire', inventory); StockModal.openDefineLots({ inventory : inventory, entry_type : vm.movement.entry_type, diff --git a/client/src/modules/stock/entry/modals/lots.modal.js b/client/src/modules/stock/entry/modals/lots.modal.js index a84797edb9..3606f6cece 100644 --- a/client/src/modules/stock/entry/modals/lots.modal.js +++ b/client/src/modules/stock/entry/modals/lots.modal.js @@ -7,6 +7,7 @@ StockDefineLotsModalController.$inject = [ ]; function StockDefineLotsModalController(Instance, Notify, uiGridConstants, Data, Session) { + console.log('Data', Data); var vm = this; // globals @@ -86,14 +87,14 @@ function StockDefineLotsModalController(Instance, Notify, uiGridConstants, Data, // add lot function addLot() { - if (vm.remainingQuantity <= 0) { + if (vm.remainingQuantity <= 0 && vm.entryType !== 'integration') { vm.maxLotReached = true; return; } vm.gridOptions.data.push({ is_valid : false, lot : vm.inventory.lot || '', - expiration_date : new Date(vm.inventory.expiration_date) || new Date(), + expiration_date : vm.inventory.expiration_date ? new Date(vm.inventory.expiration_date) : new Date(), quantity : vm.remainingQuantity, }); diff --git a/test/data.sql b/test/data.sql index 20e8ea184a..5f48b5f0f2 100644 --- a/test/data.sql +++ b/test/data.sql @@ -452,7 +452,8 @@ INSERT INTO `stock_movement` (`uuid`, `lot_uuid`, `document_uuid`, `depot_uuid`, (HUID('6529ba0c-aef4-4527-b572-5ae77273de62'), HUID('6f80748b-1d94-4247-804e-d4be99e827d2'), HUID('682e11c0-93a7-49f8-b79b-a4bc8e3e6f47'), HUID('f9caeb16-1684-43c5-a6c4-47dbac1df296'), '', 1, '2017-02-02', 200, 0.8000, 0, 1), (HUID('a4ff7358-f1f8-4301-86e4-e9e6fe99bd31'), HUID('5a0e06c2-6ca7-4633-8b17-92e2a59db44c'), HUID('682e11c0-93a7-49f8-b79b-a4bc8e3e6f47'), HUID('f9caeb16-1684-43c5-a6c4-47dbac1df296'), '', 1, '2017-02-02', 20, 0.5000, 0, 1), (HUID('d8c83ad9-a3ea-4f9f-96f9-456a435f480d'), HUID('ef24cf1a-d5b9-4846-b70c-520e601c1ea6'), HUID('682e11c0-93a7-49f8-b79b-a4bc8e3e6f47'), HUID('f9caeb16-1684-43c5-a6c4-47dbac1df296'), '', 1, '2017-02-02', 50, 2.0000, 0, 1), - (HUID('f9aa33f1-65e2-4e37-89cb-843d27b2c586'), HUID('064ab1d9-5246-4402-ae8a-958fcdb07b35'), HUID('682e11c0-93a7-49f8-b79b-a4bc8e3e6f47'), HUID('f9caeb16-1684-43c5-a6c4-47dbac1df296'), '', 1, '2017-02-02', 100, 1.2000, 0, 1); + (HUID('f9aa33f1-65e2-4e37-89cb-843d27b2c586'), HUID('064ab1d9-5246-4402-ae8a-958fcdb07b35'), HUID('682e11c0-93a7-49f8-b79b-a4bc8e3e6f47'), HUID('f9caeb16-1684-43c5-a6c4-47dbac1df296'), '', 1, '2017-02-02', 100, 1.2000, 0, 1), + (HUID('e8502c3e-7483-11e7-a8de-507b9dd6de91'), HUID('064ab1d9-5246-4402-ae8a-958fcdb07b35'), HUID('0cc6c435-7484-11e7-a8de-507b9dd6de91'), HUID('f9caeb16-1684-43c5-a6c4-47dbac1df296'), HUID('d4bb1452-e4fa-4742-a281-814140246877'), 1, '2017-02-02', 75, 1.2000, 1, 1); -- general ledger data INSERT INTO `general_ledger` VALUES diff --git a/test/end-to-end/stock/stock.entry.page.js b/test/end-to-end/stock/stock.entry.page.js index 42f6a00474..eedae48af3 100644 --- a/test/end-to-end/stock/stock.entry.page.js +++ b/test/end-to-end/stock/stock.entry.page.js @@ -35,7 +35,7 @@ function StockEntryPage() { * @param {string} rowNumber - movement line on the modal grid */ page.setTransfer = function setTransfer(rowNumber) { - components.stockEntryExitType.set('entry-exit-type-transfer-reception'); + components.stockEntryExitType.set('entry-exit-type-transfer_reception'); GU.selectRow('TransferGrid', rowNumber); FU.modal.submit(); }; @@ -114,10 +114,9 @@ function StockEntryPage() { if (inventoryUnitCost) { FU.input('$ctrl.inventory.unit_cost', inventoryUnitCost); - - $('[data-add-lot]').click(); } - lotsArray.forEach((lot, index) => { + + lotsArray.forEach((lot, index) => { lotCell = GU.getCell(lotGridId, index, 1); quantityCell = GU.getCell(lotGridId, index, 2); expirationDateCell = GU.getCell(lotGridId, index, 3); @@ -133,7 +132,7 @@ function StockEntryPage() { // enter lot expiration date if(!isTransferReception){ components.datePicker.set(lot.expiration_date, expirationDateCell); - } + } if (index < lotsArray.length - 1) { // Add another lot line diff --git a/test/end-to-end/stock/stock.entry.spec.js b/test/end-to-end/stock/stock.entry.spec.js index 06637764d5..d1ec60bcda 100644 --- a/test/end-to-end/stock/stock.entry.spec.js +++ b/test/end-to-end/stock/stock.entry.spec.js @@ -61,11 +61,11 @@ function StockExiTests() { page.setItem(0, 'INV0'); - page.setLots(0, lots, 1500, 0.09); + page.setLots(0, lots, false, 1500, 0.09); // submit page.submit(); - }); + }); it('Should entry stock from a transfer reception', () => { // select the movement @@ -76,7 +76,7 @@ function StockExiTests() { page.setDescription(DESCRIPTION.concat(' - Transfer reception')); const lots = [ - { quantity: 75} + { quantity: 75}, ]; page.setLots(0, lots, true); diff --git a/test/end-to-end/stock/stock.inventories.spec.js b/test/end-to-end/stock/stock.inventories.spec.js index 551dc79669..8e945f5481 100644 --- a/test/end-to-end/stock/stock.inventories.spec.js +++ b/test/end-to-end/stock/stock.inventories.spec.js @@ -20,7 +20,7 @@ function StockInventoriesRegistryTests() { FU.buttons.search(); FU.uiSelect('$ctrl.bundle.depot_uuid', 'Depot Secondaire'); FU.modal.submit(); - GU.expectRowCount(gridId, 1 + depotGroupingRow); + GU.expectRowCount(gridId, 2 + depotGroupingRow); FU.buttons.search(); FU.uiSelect('$ctrl.bundle.depot_uuid', 'Depot Principal'); @@ -73,7 +73,6 @@ function StockInventoriesRegistryTests() { FU.modal.submit(); GU.expectRowCount(gridId, 3 + (2 * depotGroupingRow)); - // clear filters FU.buttons.clear(); }); diff --git a/test/end-to-end/stock/stock.lots.spec.js b/test/end-to-end/stock/stock.lots.spec.js index 61ca081e0f..bbd488c39b 100644 --- a/test/end-to-end/stock/stock.lots.spec.js +++ b/test/end-to-end/stock/stock.lots.spec.js @@ -60,7 +60,7 @@ function StockLotsRegistryTests() { it('find lots by inventory', () => { modal.setInventory('First Test Inventory Item'); modal.submit(); - GU.expectRowCount(gridId, 9 + (2 * depotGroupingRow)); + GU.expectRowCount(gridId, 8 + (2 * depotGroupingRow)); }); diff --git a/test/end-to-end/stock/stock.movements.spec.js b/test/end-to-end/stock/stock.movements.spec.js index b39f288dcc..7a29cfbded 100644 --- a/test/end-to-end/stock/stock.movements.spec.js +++ b/test/end-to-end/stock/stock.movements.spec.js @@ -27,7 +27,7 @@ function StockMovementsRegistryTests() { FU.buttons.search(); FU.radio('$ctrl.bundle.is_exit', 1); FU.modal.submit(); - GU.expectRowCount(gridId, 7 + depotGroupingRow); + GU.expectRowCount(gridId, 8 + depotGroupingRow); // clear filters FU.buttons.clear(); @@ -43,7 +43,7 @@ function StockMovementsRegistryTests() { FU.buttons.search(); FU.uiSelect('$ctrl.bundle.depot_uuid', 'Depot Principal'); FU.modal.submit(); - GU.expectRowCount(gridId, 16 + depotGroupingRow); + GU.expectRowCount(gridId, 17 + depotGroupingRow); // clear filters FU.buttons.clear(); @@ -54,7 +54,7 @@ function StockMovementsRegistryTests() { FU.buttons.search(); FU.uiSelect('$ctrl.bundle.inventory_uuid', 'First Test Inventory Item'); FU.modal.submit(); - GU.expectRowCount(gridId, 14 + (2 * depotGroupingRow)); + GU.expectRowCount(gridId, 13 + (2 * depotGroupingRow)); // clear filters FU.buttons.clear(); @@ -66,7 +66,7 @@ function StockMovementsRegistryTests() { FU.buttons.search(); FU.input('$ctrl.bundle.label', 'VITAMINE-A'); FU.modal.submit(); - GU.expectRowCount(gridId, 2 + depotGroupingRow); + GU.expectRowCount(gridId, 5 + depotGroupingRow); // clear filters FU.buttons.clear(); @@ -121,7 +121,7 @@ function StockMovementsRegistryTests() { FU.buttons.search(); components.dateInterval.range('02/02/2017', '02/02/2017'); FU.modal.submit(); - GU.expectRowCount(gridId, 5 + depotGroupingRow); + GU.expectRowCount(gridId, 8 + depotGroupingRow); FU.buttons.search(); components.dateInterval.range('01/01/2015', '30/01/2015'); diff --git a/test/integration/stock.js b/test/integration/stock.js index b06777e353..bab4b26f32 100644 --- a/test/integration/stock.js +++ b/test/integration/stock.js @@ -138,10 +138,9 @@ describe('(/stock/) The Stock HTTP API', () => { // ============================================================================== const depotPrincipalUuid = 'f9caeb16-1684-43c5-a6c4-47dbac1df296'; - const depotPrincipalMvt = 12; // 10 initial plus 2 distributions + const depotPrincipalMvt = 13; // 10 initial plus 2 distributions const lotQuinineUuid = 'ae735e99-8faf-417b-aa63-9b404fca99ac'; - // create new stock lots it('POST /stock/lots create a new stock lots entry', () => agent.post('/stock/lots') .send(movementFirstLots) @@ -167,16 +166,16 @@ describe('(/stock/) The Stock HTTP API', () => { .catch(helpers.handler)); // list all movement relatives to 'Depot Principal' - it('GET /stock/lots/movements?depot_uuid=... returns movements for Depot Principal (12: 8 IN + 2 OUT)', () => agent.get(`/stock/lots/movements?depot_uuid=${depotPrincipalUuid}`) + it('GET /stock/lots/movements?depot_uuid=... returns movements for Depot Principal (13: 9 IN + 2 OUT)', () => agent.get(`/stock/lots/movements?depot_uuid=${depotPrincipalUuid}`) .then((res) => { helpers.api.listed(res, depotPrincipalMvt); }) .catch(helpers.handler)); // list all stock exit relatives to 'Depot Principal' - it('GET /stock/lots/movements?is_exit=1&depot_uuid=... returns exits for Depot Principal (2 OUT)', () => agent.get(`/stock/lots/movements?is_exit=1&depot_uuid=${depotPrincipalUuid}`) + it('GET /stock/lots/movements?is_exit=1&depot_uuid=... returns exits for Depot Principal (3 OUT)', () => agent.get(`/stock/lots/movements?is_exit=1&depot_uuid=${depotPrincipalUuid}`) .then((res) => { - helpers.api.listed(res, 2); + helpers.api.listed(res, 3); }) .catch(helpers.handler)); From c2e794a07b233f1e9d1af90c7849348b70d8fc5a Mon Sep 17 00:00:00 2001 From: DedrickEnc Date: Mon, 31 Jul 2017 09:56:56 +0100 Subject: [PATCH 11/13] polish the entry exit component UI --- .../src/js/components/bhStockEntryExitType.js | 41 ++++++++++++++----- client/src/js/services/StockService.js | 1 - client/src/modules/stock/entry/entry.js | 23 ++++++++++- .../modules/stock/entry/modals/lots.modal.js | 1 - .../templates/bhStockEntryExitType.tmpl.html | 9 ++-- server/controllers/stock/index.js | 6 +-- .../stock/stock.inventories.spec.js | 6 +-- test/end-to-end/stock/stock.lots.spec.js | 6 +-- test/end-to-end/stock/stock.movements.spec.js | 20 ++++----- 9 files changed, 73 insertions(+), 40 deletions(-) diff --git a/client/src/js/components/bhStockEntryExitType.js b/client/src/js/components/bhStockEntryExitType.js index 79eb9574ed..a8e0742afe 100644 --- a/client/src/js/components/bhStockEntryExitType.js +++ b/client/src/js/components/bhStockEntryExitType.js @@ -4,9 +4,9 @@ angular.module('bhima.components') controller: StockEntryExitTypeController, bindings: { onEntryExitTypeSelectCallback: '&?', - reference : '
- {{type.descriptionKey}} - - {{ $ctrl.reference }} - {{ $ctrl.displayName }} - - - {{type.descriptionKey}} + {{type.descriptionKey}} + + {{$ctrl.display()}}
diff --git a/server/controllers/stock/index.js b/server/controllers/stock/index.js index 63811206cb..eac800f348 100644 --- a/server/controllers/stock/index.js +++ b/server/controllers/stock/index.js @@ -14,7 +14,7 @@ */ const uuid = require('node-uuid'); - +const moment = require('moment'); const db = require('../../lib/db'); const core = require('./core'); @@ -107,9 +107,9 @@ function createStock(req, res, next) { * POST /stock/movement * Create a new stock movement */ -function createMovement(req, res, next) { +function createMovement(req, res, next) { const params = req.body; - + const document = { uuid : params.document_uuid || uuid.v4(), date : moment(new Date(params.date)).format('YYYY-MM-DD').toString(), diff --git a/test/end-to-end/stock/stock.inventories.spec.js b/test/end-to-end/stock/stock.inventories.spec.js index 8e945f5481..4af87b1256 100644 --- a/test/end-to-end/stock/stock.inventories.spec.js +++ b/test/end-to-end/stock/stock.inventories.spec.js @@ -20,7 +20,7 @@ function StockInventoriesRegistryTests() { FU.buttons.search(); FU.uiSelect('$ctrl.bundle.depot_uuid', 'Depot Secondaire'); FU.modal.submit(); - GU.expectRowCount(gridId, 2 + depotGroupingRow); + GU.expectRowCount(gridId, 1 + depotGroupingRow); FU.buttons.search(); FU.uiSelect('$ctrl.bundle.depot_uuid', 'Depot Principal'); @@ -65,13 +65,13 @@ function StockInventoriesRegistryTests() { FU.buttons.search(); FU.radio('$ctrl.bundle.status', 3); FU.modal.submit(); - GU.expectRowCount(gridId, 1 + (depotGroupingRow)); + GU.expectRowCount(gridId, 2 + (depotGroupingRow)); // over maximum FU.buttons.search(); FU.radio('$ctrl.bundle.status', 4); FU.modal.submit(); - GU.expectRowCount(gridId, 3 + (2 * depotGroupingRow)); + GU.expectRowCount(gridId, 2 + (2 * depotGroupingRow)); // clear filters FU.buttons.clear(); diff --git a/test/end-to-end/stock/stock.lots.spec.js b/test/end-to-end/stock/stock.lots.spec.js index bbd488c39b..af34623318 100644 --- a/test/end-to-end/stock/stock.lots.spec.js +++ b/test/end-to-end/stock/stock.lots.spec.js @@ -25,9 +25,9 @@ function StockLotsRegistryTests() { const gridId = 'stock-lots-grid'; const depotGroupingRow = 1; - const LOT_FOR_ALLTIME = 16; + const LOT_FOR_ALLTIME = 15; const LOT_FOR_TODAY = 10; - const LOT_FOR_LAST_YEAR = 16; + const LOT_FOR_LAST_YEAR = 15; it(`finds ${LOT_FOR_TODAY} lot for today`, () => { @@ -73,7 +73,7 @@ function StockLotsRegistryTests() { it('find lots by entry date', () => { modal.setdateInterval('02/02/2017', '02/02/2017', 'entry-date'); modal.submit(); - GU.expectRowCount(gridId, 6 + (2 * depotGroupingRow)); + GU.expectRowCount(gridId, 4 + (2 * depotGroupingRow)); }); it('find lots by expiration date', () => { diff --git a/test/end-to-end/stock/stock.movements.spec.js b/test/end-to-end/stock/stock.movements.spec.js index 7a29cfbded..2540c3f649 100644 --- a/test/end-to-end/stock/stock.movements.spec.js +++ b/test/end-to-end/stock/stock.movements.spec.js @@ -21,7 +21,7 @@ function StockMovementsRegistryTests() { FU.buttons.search(); FU.radio('$ctrl.bundle.is_exit', 0); FU.modal.submit(); - GU.expectRowCount(gridId, 15 + (2 * depotGroupingRow)); + GU.expectRowCount(gridId, 14 + (2 * depotGroupingRow)); // exit movements FU.buttons.search(); @@ -38,7 +38,7 @@ function StockMovementsRegistryTests() { FU.buttons.search(); FU.uiSelect('$ctrl.bundle.depot_uuid', 'Depot Secondaire'); FU.modal.submit(); - GU.expectRowCount(gridId, 6 + depotGroupingRow); + GU.expectRowCount(gridId, 5 + depotGroupingRow); FU.buttons.search(); FU.uiSelect('$ctrl.bundle.depot_uuid', 'Depot Principal'); @@ -66,7 +66,7 @@ function StockMovementsRegistryTests() { FU.buttons.search(); FU.input('$ctrl.bundle.label', 'VITAMINE-A'); FU.modal.submit(); - GU.expectRowCount(gridId, 5 + depotGroupingRow); + GU.expectRowCount(gridId, 3 + depotGroupingRow); // clear filters FU.buttons.clear(); @@ -80,37 +80,37 @@ function StockMovementsRegistryTests() { FU.buttons.search(); FU.uiSelect('$ctrl.bundle.flux_id', 'Commande d\'achat'); FU.modal.submit(); - GU.expectRowCount(gridId, 23 + depotGroupingRow); + GU.expectRowCount(gridId, 22 + depotGroupingRow); // to patient FU.buttons.search(); FU.uiSelect('$ctrl.bundle.flux_id', 'Vers un patient'); FU.modal.submit(); - GU.expectRowCount(gridId, 23 + depotGroupingRow); + GU.expectRowCount(gridId, 22 + depotGroupingRow); // to depot FU.buttons.search(); FU.uiSelect('$ctrl.bundle.flux_id', 'Vers un depot'); FU.modal.submit(); - GU.expectRowCount(gridId, 23 + depotGroupingRow); + GU.expectRowCount(gridId, 22 + depotGroupingRow); // from depot FU.buttons.search(); FU.uiSelect('$ctrl.bundle.flux_id', 'En provenance d\'un depot'); FU.modal.submit(); - GU.expectRowCount(gridId, 23 + depotGroupingRow); + GU.expectRowCount(gridId, 22 + depotGroupingRow); // positive adjustment FU.buttons.search(); FU.uiSelect('$ctrl.bundle.flux_id', 'Ajustement (Positif)'); FU.modal.submit(); - GU.expectRowCount(gridId, 23 + depotGroupingRow); + GU.expectRowCount(gridId, 22 + depotGroupingRow); // negative adjustment FU.buttons.search(); FU.uiSelect('$ctrl.bundle.flux_id', 'Ajustement (Negatif)'); FU.modal.submit(); - GU.expectRowCount(gridId, 23 + depotGroupingRow); + GU.expectRowCount(gridId, 22 + depotGroupingRow); // clear filters FU.buttons.clear(); @@ -121,7 +121,7 @@ function StockMovementsRegistryTests() { FU.buttons.search(); components.dateInterval.range('02/02/2017', '02/02/2017'); FU.modal.submit(); - GU.expectRowCount(gridId, 8 + depotGroupingRow); + GU.expectRowCount(gridId, 6 + depotGroupingRow); FU.buttons.search(); components.dateInterval.range('01/01/2015', '30/01/2015'); From 999b9a8884ed97baeb1e747172dc1a04e64f870a Mon Sep 17 00:00:00 2001 From: DedrickEnc Date: Tue, 15 Aug 2017 10:48:04 +0100 Subject: [PATCH 12/13] fix(test and server): Fix the end to end test and the server side logic to filter stock movement by --- client/src/modules/stock/entry/entry.js | 2 +- server/controllers/stock/core.js | 3 ++- .../end-to-end/stock/stock.adjustment.spec.js | 2 +- test/end-to-end/stock/stock.entry.spec.js | 2 +- .../stock/stock.inventories.spec.js | 4 ++-- test/end-to-end/stock/stock.lots.spec.js | 8 ++++---- test/end-to-end/stock/stock.movements.spec.js | 20 +++++++++---------- 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/client/src/modules/stock/entry/entry.js b/client/src/modules/stock/entry/entry.js index d1e7185515..954e190619 100644 --- a/client/src/modules/stock/entry/entry.js +++ b/client/src/modules/stock/entry/entry.js @@ -345,7 +345,7 @@ function StockEntryController(Depots, Inventory, Notify, .then(function (document) { vm.Stock.store.clear(); vm.movement = {}; - ReceiptModal.stockEntryDepotReceipt(document.uuid, bhConstants.flux.FROM_OTHER_DEPOT); + ReceiptModal.stockEntryDepotReceipt(document.uuid, true); }) .catch(Notify.handleError); } diff --git a/server/controllers/stock/core.js b/server/controllers/stock/core.js index 0e4f3fefbd..d5e8584f9c 100644 --- a/server/controllers/stock/core.js +++ b/server/controllers/stock/core.js @@ -71,12 +71,13 @@ function getLots(sqlQuery, parameters, finalClauseParameter) { JOIN stock_movement m ON m.lot_uuid = l.uuid AND m.flux_id = ${flux.FROM_PURCHASE} JOIN depot d ON d.uuid = m.depot_uuid `; - db.convert(params, ['uuid', 'depot_uuid', 'lot_uuid', 'inventory_uuid']); + db.convert(params, ['uuid', 'depot_uuid', 'lot_uuid', 'inventory_uuid', 'document_uuid']); const filters = new FilterParser(params, { autoParseStatements : false }); filters.equals('uuid', 'uuid', 'l'); filters.equals('depot_text', 'text', 'd'); filters.equals('depot_uuid', 'depot_uuid', 'm'); + filters.equals('document_uuid', 'document_uuid', 'm'); filters.equals('lot_uuid', 'lot_uuid', 'm'); filters.equals('inventory_uuid', 'uuid', 'i'); filters.equals('text', 'text', 'i'); diff --git a/test/end-to-end/stock/stock.adjustment.spec.js b/test/end-to-end/stock/stock.adjustment.spec.js index ed3ed23363..839d9e53f6 100644 --- a/test/end-to-end/stock/stock.adjustment.spec.js +++ b/test/end-to-end/stock/stock.adjustment.spec.js @@ -52,4 +52,4 @@ function StockAdjustmentTests() { }); } -describe('Stock Adustment Test', StockAdjustmentTests); +describe('Stock Adjustment Test', StockAdjustmentTests); diff --git a/test/end-to-end/stock/stock.entry.spec.js b/test/end-to-end/stock/stock.entry.spec.js index d1ec60bcda..440a1b10a5 100644 --- a/test/end-to-end/stock/stock.entry.spec.js +++ b/test/end-to-end/stock/stock.entry.spec.js @@ -69,7 +69,7 @@ function StockExiTests() { it('Should entry stock from a transfer reception', () => { // select the movement - page.setTransfer(0); + page.setTransfer(1); page.setDate(new Date()); diff --git a/test/end-to-end/stock/stock.inventories.spec.js b/test/end-to-end/stock/stock.inventories.spec.js index 4af87b1256..e422c8618b 100644 --- a/test/end-to-end/stock/stock.inventories.spec.js +++ b/test/end-to-end/stock/stock.inventories.spec.js @@ -20,7 +20,7 @@ function StockInventoriesRegistryTests() { FU.buttons.search(); FU.uiSelect('$ctrl.bundle.depot_uuid', 'Depot Secondaire'); FU.modal.submit(); - GU.expectRowCount(gridId, 1 + depotGroupingRow); + GU.expectRowCount(gridId, 2 + depotGroupingRow); FU.buttons.search(); FU.uiSelect('$ctrl.bundle.depot_uuid', 'Depot Principal'); @@ -71,7 +71,7 @@ function StockInventoriesRegistryTests() { FU.buttons.search(); FU.radio('$ctrl.bundle.status', 4); FU.modal.submit(); - GU.expectRowCount(gridId, 2 + (2 * depotGroupingRow)); + GU.expectRowCount(gridId, 3 + (2 * depotGroupingRow)); // clear filters FU.buttons.clear(); diff --git a/test/end-to-end/stock/stock.lots.spec.js b/test/end-to-end/stock/stock.lots.spec.js index af34623318..0351f05077 100644 --- a/test/end-to-end/stock/stock.lots.spec.js +++ b/test/end-to-end/stock/stock.lots.spec.js @@ -25,9 +25,9 @@ function StockLotsRegistryTests() { const gridId = 'stock-lots-grid'; const depotGroupingRow = 1; - const LOT_FOR_ALLTIME = 15; + const LOT_FOR_ALLTIME = 16; const LOT_FOR_TODAY = 10; - const LOT_FOR_LAST_YEAR = 15; + const LOT_FOR_LAST_YEAR = 16; it(`finds ${LOT_FOR_TODAY} lot for today`, () => { @@ -67,13 +67,13 @@ function StockLotsRegistryTests() { it('find lot by name', () => { modal.setLotLabel('VITAMINE-A'); modal.submit(); - GU.expectRowCount(gridId, 1 + depotGroupingRow); + GU.expectRowCount(gridId, 3 + depotGroupingRow); }); it('find lots by entry date', () => { modal.setdateInterval('02/02/2017', '02/02/2017', 'entry-date'); modal.submit(); - GU.expectRowCount(gridId, 4 + (2 * depotGroupingRow)); + GU.expectRowCount(gridId, 6 + (2 * depotGroupingRow)); }); it('find lots by expiration date', () => { diff --git a/test/end-to-end/stock/stock.movements.spec.js b/test/end-to-end/stock/stock.movements.spec.js index 2540c3f649..9939efeff4 100644 --- a/test/end-to-end/stock/stock.movements.spec.js +++ b/test/end-to-end/stock/stock.movements.spec.js @@ -21,7 +21,7 @@ function StockMovementsRegistryTests() { FU.buttons.search(); FU.radio('$ctrl.bundle.is_exit', 0); FU.modal.submit(); - GU.expectRowCount(gridId, 14 + (2 * depotGroupingRow)); + GU.expectRowCount(gridId, 15 + (2 * depotGroupingRow)); // exit movements FU.buttons.search(); @@ -38,7 +38,7 @@ function StockMovementsRegistryTests() { FU.buttons.search(); FU.uiSelect('$ctrl.bundle.depot_uuid', 'Depot Secondaire'); FU.modal.submit(); - GU.expectRowCount(gridId, 5 + depotGroupingRow); + GU.expectRowCount(gridId, 6 + depotGroupingRow); FU.buttons.search(); FU.uiSelect('$ctrl.bundle.depot_uuid', 'Depot Principal'); @@ -66,7 +66,7 @@ function StockMovementsRegistryTests() { FU.buttons.search(); FU.input('$ctrl.bundle.label', 'VITAMINE-A'); FU.modal.submit(); - GU.expectRowCount(gridId, 3 + depotGroupingRow); + GU.expectRowCount(gridId, 5 + depotGroupingRow); // clear filters FU.buttons.clear(); @@ -80,37 +80,37 @@ function StockMovementsRegistryTests() { FU.buttons.search(); FU.uiSelect('$ctrl.bundle.flux_id', 'Commande d\'achat'); FU.modal.submit(); - GU.expectRowCount(gridId, 22 + depotGroupingRow); + GU.expectRowCount(gridId, 24 + depotGroupingRow); // to patient FU.buttons.search(); FU.uiSelect('$ctrl.bundle.flux_id', 'Vers un patient'); FU.modal.submit(); - GU.expectRowCount(gridId, 22 + depotGroupingRow); + GU.expectRowCount(gridId, 24 + depotGroupingRow); // to depot FU.buttons.search(); FU.uiSelect('$ctrl.bundle.flux_id', 'Vers un depot'); FU.modal.submit(); - GU.expectRowCount(gridId, 22 + depotGroupingRow); + GU.expectRowCount(gridId, 24 + depotGroupingRow); // from depot FU.buttons.search(); FU.uiSelect('$ctrl.bundle.flux_id', 'En provenance d\'un depot'); FU.modal.submit(); - GU.expectRowCount(gridId, 22 + depotGroupingRow); + GU.expectRowCount(gridId, 24 + depotGroupingRow); // positive adjustment FU.buttons.search(); FU.uiSelect('$ctrl.bundle.flux_id', 'Ajustement (Positif)'); FU.modal.submit(); - GU.expectRowCount(gridId, 22 + depotGroupingRow); + GU.expectRowCount(gridId, 24 + depotGroupingRow); // negative adjustment FU.buttons.search(); FU.uiSelect('$ctrl.bundle.flux_id', 'Ajustement (Negatif)'); FU.modal.submit(); - GU.expectRowCount(gridId, 22 + depotGroupingRow); + GU.expectRowCount(gridId, 24 + depotGroupingRow); // clear filters FU.buttons.clear(); @@ -121,7 +121,7 @@ function StockMovementsRegistryTests() { FU.buttons.search(); components.dateInterval.range('02/02/2017', '02/02/2017'); FU.modal.submit(); - GU.expectRowCount(gridId, 6 + depotGroupingRow); + GU.expectRowCount(gridId, 8 + depotGroupingRow); FU.buttons.search(); components.dateInterval.range('01/01/2015', '30/01/2015'); From fb2ec1ffd4e0ec79990a6bd6898ef734f7ab0a61 Mon Sep 17 00:00:00 2001 From: DedrickEnc Date: Thu, 17 Aug 2017 12:18:43 +0100 Subject: [PATCH 13/13] fix(review): Update the pull requst according the review suggestion --- client/src/i18n/en/depot.json | 23 ++++++--- .../src/js/components/bhStockEntryExitType.js | 34 +++++++------ client/src/js/services/util.js | 4 -- .../entry/modals/findTransfer.modal.html | 8 +-- .../stock/entry/modals/findTransfer.modal.js | 50 +++++++++++-------- client/src/modules/stock/exit/exit.js | 2 +- .../stock/exit/templates/expiration.tmpl.html | 3 +- .../templates/bhStockEntryExitType.tmpl.html | 36 +++++++------ server/controllers/stock/core.js | 6 +-- server/controllers/stock/index.js | 15 ++++-- test/data.sql | 2 +- .../shared/components/bhStockEntryExitType.js | 3 +- test/end-to-end/stock/stock.entry.page.js | 6 +-- test/end-to-end/stock/stock.exit.page.js | 8 +-- 14 files changed, 113 insertions(+), 87 deletions(-) diff --git a/client/src/i18n/en/depot.json b/client/src/i18n/en/depot.json index 8794f7182e..4e6978bbf9 100644 --- a/client/src/i18n/en/depot.json +++ b/client/src/i18n/en/depot.json @@ -1,8 +1,15 @@ -{"DEPOT":{"ADD_DEPOT":"Add a Depot", -"ALL_DEPOTS":"All Depots", -"DEPOTS_LIST":"Depots list", -"DESCRIPTION":"This module allows you to List, Create, Edit and Delete a Depot", -"EDIT_DEPOT":"Edit the information in a Depot", -"MAIN":{"TITLE":"Depot Management"}, -"NO_DEPOT":"No Depot", -"TITLE":"Depot Management"}} \ No newline at end of file +{ + "DEPOT": { + "ADD_DEPOT": "Add a Depot", + "ALL_DEPOTS": "All Depots", + "DEPOTS_LIST": "Depots list", + "DESCRIPTION": "This module allows you to List, Create, Edit and Delete a Depot", + "EDIT_DEPOT": "Edit the information in a Depot", + "ENTITY" : "Depot", + "MAIN": { + "TITLE": "Depot Management" + }, + "NO_DEPOT": "No Depot", + "TITLE": "Depot Management" + } +} \ No newline at end of file diff --git a/client/src/js/components/bhStockEntryExitType.js b/client/src/js/components/bhStockEntryExitType.js index a8e0742afe..564a462c1b 100644 --- a/client/src/js/components/bhStockEntryExitType.js +++ b/client/src/js/components/bhStockEntryExitType.js @@ -3,10 +3,10 @@ angular.module('bhima.components') templateUrl: 'modules/templates/bhStockEntryExitType.tmpl.html', controller: StockEntryExitTypeController, bindings: { - onEntryExitTypeSelectCallback: '&?', + onEntryExitTypeSelectCallback: '&', reference: ' \ No newline at end of file diff --git a/client/src/modules/stock/entry/modals/findTransfer.modal.js b/client/src/modules/stock/entry/modals/findTransfer.modal.js index 65c5b53244..71527a192c 100644 --- a/client/src/modules/stock/entry/modals/findTransfer.modal.js +++ b/client/src/modules/stock/entry/modals/findTransfer.modal.js @@ -9,16 +9,10 @@ StockFindTransferModalController.$inject = [ function StockFindTransferModalController(Instance, StockService, Notify, uiGridConstants, Filtering, Receipts, data) { var vm = this; - - // global - vm.selectedRow = {}; - - /* ======================= Grid configurations ============================ */ vm.filterEnabled = false; vm.gridOptions = { appScopeProvider: vm }; var filtering = new Filtering(vm.gridOptions); - var columns = [ { field: 'date', @@ -51,6 +45,9 @@ function StockFindTransferModalController(Instance, StockService, Notify, vm.gridOptions.multiSelect = false; vm.gridOptions.enableFiltering = vm.filterEnabled; vm.gridOptions.onRegisterApi = onRegisterApi; + vm.gridOptions.enableColumnMenus = false; + vm.gridOptions.fastWatch = true; + vm.gridOptions.flatEntityAccess = true; vm.toggleFilter = toggleFilter; // bind methods @@ -58,6 +55,9 @@ function StockFindTransferModalController(Instance, StockService, Notify, vm.cancel = cancel; vm.showReceipt = showReceipt; + vm.hasError = false; + vm.lo + function onRegisterApi(gridApi) { vm.gridApi = gridApi; vm.gridApi.selection.on.rowSelectionChanged(null, rowSelectionCallback); @@ -71,7 +71,7 @@ function StockFindTransferModalController(Instance, StockService, Notify, function toggleFilter() { vm.filterEnabled = !vm.filterEnabled; vm.gridOptions.enableFiltering = vm.filterEnabled; - vm.gridApi.core.notifyDataChange(uiGridConstants.dataChange.COLUMN); + vm.gridApi.core.notifyDataChange(uiGridConstants.dataChange.OPTIONS); } /** get transfer document */ @@ -79,29 +79,37 @@ function StockFindTransferModalController(Instance, StockService, Notify, Receipts.stockExitDepotReceipt(uuid, true); } - /* ======================= End Grid ======================================== */ - StockService.movements.read(null, { - entity_uuid: data.depot_uuid, - is_exit: 1, - finalClauseParameter: 'GROUP BY document_uuid', - }) + function load (){ + vm.loading = true; + + StockService.movements.read(null, { + entity_uuid: data.depot_uuid, + is_exit: 1, + groupByDocument : 1, + }) .then(function (transfers) { vm.gridOptions.data = transfers; }) - .catch(Notify.errorHandler); + .catch(function (err){ + vm.hasError = true; + Notify.errorHandler(err); + }) + .finally(function (){ + vm.loading = false; + }); + } // submit function submit() { - if (!vm.selectedRow) { return; } - + if(!vm.selectedRow) {return;} return StockService.movements.read(null, { document_uuid: vm.selectedRow.document_uuid, is_exit: 1, }) - .then(function (transfers) { - Instance.close(transfers); - }) - .catch(Notify.errorHandler); + .then(function (transfers) { + Instance.close(transfers); + }) + .catch(Notify.errorHandler); } // cancel @@ -109,4 +117,6 @@ function StockFindTransferModalController(Instance, StockService, Notify, Instance.dismiss(); } + load(); + } diff --git a/client/src/modules/stock/exit/exit.js b/client/src/modules/stock/exit/exit.js index c9d8056935..ac9206267b 100644 --- a/client/src/modules/stock/exit/exit.js +++ b/client/src/modules/stock/exit/exit.js @@ -174,7 +174,7 @@ function StockExitController(Depots, Inventory, Notify, Session, util, bhConstan function configureItem(item) { item._initialised = true; // get lots - Stock.lots.read(null, { depot_uuid: vm.depot.uuid, inventory_uuid: item.inventory.inventory_uuid, includeEmptyLot : false }) + Stock.lots.read(null, { depot_uuid: vm.depot.uuid, inventory_uuid: item.inventory.inventory_uuid, includeEmptyLot : 0 }) .then(function (lots) { item.lots = lots; }) diff --git a/client/src/modules/stock/exit/templates/expiration.tmpl.html b/client/src/modules/stock/exit/templates/expiration.tmpl.html index 7c4b5daff7..f05c6dff14 100644 --- a/client/src/modules/stock/exit/templates/expiration.tmpl.html +++ b/client/src/modules/stock/exit/templates/expiration.tmpl.html @@ -1,4 +1,3 @@
- {{grid.appScope.util.getTimeFromToday(row.entity.lot.expiration_date, 'days')}} - FORM.LABELS.DAYS +
diff --git a/client/src/modules/templates/bhStockEntryExitType.tmpl.html b/client/src/modules/templates/bhStockEntryExitType.tmpl.html index 946317f566..3a4f526bc3 100644 --- a/client/src/modules/templates/bhStockEntryExitType.tmpl.html +++ b/client/src/modules/templates/bhStockEntryExitType.tmpl.html @@ -1,20 +1,26 @@
-
- + \ No newline at end of file diff --git a/server/controllers/stock/core.js b/server/controllers/stock/core.js index d5e8584f9c..f9532491a1 100644 --- a/server/controllers/stock/core.js +++ b/server/controllers/stock/core.js @@ -130,7 +130,7 @@ function getLotsDepot(depotUuid, params, finalClause) { delete params.status; } - if(params.includeEmptyLot === 'false'){ + if(Number(params.includeEmptyLot) === 0){ exludeToken = 'HAVING quantity > 0'; delete params.includeEmptyLot; } @@ -180,9 +180,9 @@ function getLotsMovements(depotUuid, params) { params.depot_uuid = depotUuid; } - if(params.finalClauseParameter){ + if(params.groupByDocument === 1){ finalClause = 'GROUP BY document_uuid'; - delete params.finalClauseParameter; + delete params.groupByDocument; } const sql = ` diff --git a/server/controllers/stock/index.js b/server/controllers/stock/index.js index eac800f348..dca0d8a4ae 100644 --- a/server/controllers/stock/index.js +++ b/server/controllers/stock/index.js @@ -190,25 +190,30 @@ function depotMovement(document, params) { parameters.entity_uuid = parameters.entity_uuid ? db.bid(parameters.entity_uuid) : null; + const depot_uuid = isExit ? db.bid(parameters.from_depot) : db.bid(parameters.to_depot); + const entity_uuid = isExit ? db.bid(parameters.to_depot) : db.bid(parameters.from_depot); + const is_exit = isExit ? 1 : 0; + const flux_id = isExit ? core.flux.TO_OTHER_DEPOT : core.flux.FROM_OTHER_DEPOT; + parameters.lots.forEach((lot) => { record = { + depot_uuid, + entity_uuid, + is_exit, + flux_id, uuid : db.bid(uuid.v4()), lot_uuid : db.bid(lot.uuid), - depot_uuid : isExit ? db.bid(parameters.from_depot) : db.bid(parameters.to_depot), document_uuid : db.bid(document.uuid), quantity : lot.quantity, unit_cost : lot.unit_cost, date : document.date, - entity_uuid : isExit ? db.bid(parameters.to_depot) : db.bid(parameters.from_depot), - is_exit : isExit ? 1 : 0, - flux_id : isExit ? core.flux.TO_OTHER_DEPOT : core.flux.FROM_OTHER_DEPOT, description : parameters.description, user_id : document.user, }; transaction.addQuery('INSERT INTO stock_movement SET ?', [record]); - + isWarehouse = !!(parameters.from_depot_is_warehouse); // track distribution to patient diff --git a/test/data.sql b/test/data.sql index 5f48b5f0f2..af1b78709b 100644 --- a/test/data.sql +++ b/test/data.sql @@ -453,7 +453,7 @@ INSERT INTO `stock_movement` (`uuid`, `lot_uuid`, `document_uuid`, `depot_uuid`, (HUID('a4ff7358-f1f8-4301-86e4-e9e6fe99bd31'), HUID('5a0e06c2-6ca7-4633-8b17-92e2a59db44c'), HUID('682e11c0-93a7-49f8-b79b-a4bc8e3e6f47'), HUID('f9caeb16-1684-43c5-a6c4-47dbac1df296'), '', 1, '2017-02-02', 20, 0.5000, 0, 1), (HUID('d8c83ad9-a3ea-4f9f-96f9-456a435f480d'), HUID('ef24cf1a-d5b9-4846-b70c-520e601c1ea6'), HUID('682e11c0-93a7-49f8-b79b-a4bc8e3e6f47'), HUID('f9caeb16-1684-43c5-a6c4-47dbac1df296'), '', 1, '2017-02-02', 50, 2.0000, 0, 1), (HUID('f9aa33f1-65e2-4e37-89cb-843d27b2c586'), HUID('064ab1d9-5246-4402-ae8a-958fcdb07b35'), HUID('682e11c0-93a7-49f8-b79b-a4bc8e3e6f47'), HUID('f9caeb16-1684-43c5-a6c4-47dbac1df296'), '', 1, '2017-02-02', 100, 1.2000, 0, 1), - (HUID('e8502c3e-7483-11e7-a8de-507b9dd6de91'), HUID('064ab1d9-5246-4402-ae8a-958fcdb07b35'), HUID('0cc6c435-7484-11e7-a8de-507b9dd6de91'), HUID('f9caeb16-1684-43c5-a6c4-47dbac1df296'), HUID('d4bb1452-e4fa-4742-a281-814140246877'), 1, '2017-02-02', 75, 1.2000, 1, 1); + (HUID('e8502c3e-7483-11e7-a8de-507b9dd6de91'), HUID('064ab1d9-5246-4402-ae8a-958fcdb07b35'), HUID('0cc6c435-7484-11e7-a8de-507b9dd6de91'), HUID('f9caeb16-1684-43c5-a6c4-47dbac1df296'), HUID('d4bb1452-e4fa-4742-a281-814140246877'), 8, '2017-02-02', 75, 1.2000, 1, 1); -- general ledger data INSERT INTO `general_ledger` VALUES diff --git a/test/end-to-end/shared/components/bhStockEntryExitType.js b/test/end-to-end/shared/components/bhStockEntryExitType.js index c86b05bc17..c8e0b515fa 100644 --- a/test/end-to-end/shared/components/bhStockEntryExitType.js +++ b/test/end-to-end/shared/components/bhStockEntryExitType.js @@ -4,7 +4,8 @@ const FU = require('../FormUtils'); module.exports = { set : function set(id) { - const locator = by.id(id); + var prefix = 'entry-exit-type-'; + const locator = by.id(prefix.concat(id)); const target = element(locator); target.click(); diff --git a/test/end-to-end/stock/stock.entry.page.js b/test/end-to-end/stock/stock.entry.page.js index eedae48af3..cc5aa71b7b 100644 --- a/test/end-to-end/stock/stock.entry.page.js +++ b/test/end-to-end/stock/stock.entry.page.js @@ -25,7 +25,7 @@ function StockEntryPage() { * @param {string} rowNumber - the purchase line on the modal */ page.setPurchase = function setPurchase(rowNumber) { - components.stockEntryExitType.set('entry-exit-type-purchase'); + components.stockEntryExitType.set('purchase'); GU.selectRow('PurchaseGrid', rowNumber); FU.modal.submit(); }; @@ -35,7 +35,7 @@ function StockEntryPage() { * @param {string} rowNumber - movement line on the modal grid */ page.setTransfer = function setTransfer(rowNumber) { - components.stockEntryExitType.set('entry-exit-type-transfer_reception'); + components.stockEntryExitType.set('transfer_reception'); GU.selectRow('TransferGrid', rowNumber); FU.modal.submit(); }; @@ -44,7 +44,7 @@ function StockEntryPage() { * @method setIntegration */ page.setIntegration = function setIntegration() { - components.stockEntryExitType.set('entry-exit-type-integration'); + components.stockEntryExitType.set('integration'); }; /** diff --git a/test/end-to-end/stock/stock.exit.page.js b/test/end-to-end/stock/stock.exit.page.js index 3dd072a0e4..bd66f1880e 100644 --- a/test/end-to-end/stock/stock.exit.page.js +++ b/test/end-to-end/stock/stock.exit.page.js @@ -25,7 +25,7 @@ function StockExitPage() { * @param {string} reference - the patient reference */ page.setPatient = function setPatient(reference) { - components.stockEntryExitType.set('entry-exit-type-patient'); + components.stockEntryExitType.set('patient'); components.findPatient.findById(reference); FU.modal.submit(); }; @@ -35,7 +35,7 @@ function StockExitPage() { * @param {string} service - the service name */ page.setService = function setService(service) { - components.stockEntryExitType.set('entry-exit-type-service'); + components.stockEntryExitType.set('service'); const modalContent = element(by.css('[class="modal-content"]')); FU.uiSelect('$ctrl.selected', service, modalContent); FU.modal.submit(); @@ -46,7 +46,7 @@ function StockExitPage() { * @param {string} depot - the depot name */ page.setDestinationDepot = function setDestinationDepot(depot) { - components.stockEntryExitType.set('entry-exit-type-depot'); + components.stockEntryExitType.set('depot'); const modalContent = element(by.css('[class="modal-content"]')); FU.uiSelect('$ctrl.selected', depot, modalContent); FU.modal.submit(); @@ -56,7 +56,7 @@ function StockExitPage() { * @method setLoss */ page.setLoss = function setLoss() { - components.stockEntryExitType.set('entry-exit-type-loss'); + components.stockEntryExitType.set('loss'); }; /**