diff --git a/client/src/i18n/en/form.json b/client/src/i18n/en/form.json index 43d717e662..b21af18787 100644 --- a/client/src/i18n/en/form.json +++ b/client/src/i18n/en/form.json @@ -238,6 +238,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 7eaa65e60b..2195fc4016 100644 --- a/client/src/i18n/fr/form.json +++ b/client/src/i18n/fr/form.json @@ -238,6 +238,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 @@
- {{ row.entity.reference }} + TABLE.COLUMNS.RECEIPT
\ 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 32cb843d6e..f9aa1b3b55 100644 --- a/test/end-to-end/shared/components/index.js +++ b/test/end-to-end/shared/components/index.js @@ -28,5 +28,5 @@ module.exports = { fiscalPeriodSelect : require('./bhFiscalPeriodSelect'), debtorGroupSelect : require('./bhDebtorGroupSelect'), multipleDebtorGroupSelect : require('./bhMultipleDebtorGroupSelect'), - 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 dd740387c0..9cb1f9e31f 100644 --- a/test/integration/stock.js +++ b/test/integration/stock.js @@ -134,7 +134,7 @@ describe('(/stock/) The Stock HTTP API', () => { // ============================================================================== const depot_principal_uuid = 'f9caeb16-1684-43c5-a6c4-47dbac1df296'; - const depot_principal_mvt = 14; // 10 initial plus 4 distributions + const depot_principal_mvt = 12; // 10 initial plus 2 distributions const lot_quinine_uuid = 'ae735e99-8faf-417b-aa63-9b404fca99ac'; // create new stock lots @@ -162,16 +162,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=${depot_principal_uuid}`) + it('GET /stock/lots/movements?depot_uuid=... returns movements for Depot Principal (12: 8 IN + 2 OUT)', () => agent.get(`/stock/lots/movements?depot_uuid=${depot_principal_uuid}`) .then((res) => { helpers.api.listed(res, depot_principal_mvt); }) .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=${depot_principal_uuid}`) + 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=${depot_principal_uuid}`) .then((res) => { - helpers.api.listed(res, 4); + helpers.api.listed(res, 2); }) .catch(helpers.handler));