From 9cdd8a00ee39a763f203ee093a48e23cb67922e1 Mon Sep 17 00:00:00 2001 From: Jonathan Niles Date: Tue, 5 May 2020 12:46:26 +0100 Subject: [PATCH 01/29] test: refactor fee center GridAction tests This commit refactors a lot of the tests in the Fee Center/Distribution Center modules so that they are more precise using GridRow instead of GridAction. It should make our test more stable and predictable. --- .../distribution_center.html | 54 +++++++++---------- .../distribution_center.js | 6 +-- .../distribution_key/distribution_key.html | 54 +++++++++---------- .../distribution_key/distribution_key.js | 9 ++-- .../templates/action.tmpl.html | 14 ++--- .../templates/setting.tmpl.html | 17 +++--- .../fee_center/templates/action.tmpl.html | 2 +- .../templates/transaction-id.cell.html | 2 +- .../distribution_feescenters.page.js | 8 ++- .../distribution_feescenters.spec.js | 7 +-- .../distribution_key.page.js | 21 ++++---- .../distribution_key.spec.js | 12 ++--- test/end-to-end/feeCenter/fee_center.spec.js | 2 +- test/end-to-end/journal/journal.page.js | 4 +- 14 files changed, 108 insertions(+), 104 deletions(-) diff --git a/client/src/modules/distribution_center/distribution_center.html b/client/src/modules/distribution_center/distribution_center.html index 9be5276da8..9a4bf76b2f 100644 --- a/client/src/modules/distribution_center/distribution_center.html +++ b/client/src/modules/distribution_center/distribution_center.html @@ -1,10 +1,10 @@ -
-
-
    -
  1. TREE.FINANCE
  2. -
  3. TREE.DITRIBUTION_AUX_FEES_CENTERS
  4. -
- +
+
+
    +
  1. TREE.FINANCE
  2. +
  3. TREE.DITRIBUTION_AUX_FEES_CENTERS
  4. +
+
@@ -49,21 +49,21 @@
-
+
-
- -
+
+ +
-
+
@@ -73,23 +73,23 @@
- -
-
+ +
+
- - - -
-
-
\ No newline at end of file + ui-grid-resize-columns> + + + +
+
+
diff --git a/client/src/modules/distribution_center/distribution_center.js b/client/src/modules/distribution_center/distribution_center.js index 4454def80f..2923643147 100644 --- a/client/src/modules/distribution_center/distribution_center.js +++ b/client/src/modules/distribution_center/distribution_center.js @@ -21,7 +21,6 @@ function DistributionCenterController(DistributionCenters, Notify, uiGridConstan vm.toggleFilter = toggleFilter; // global variables vm.gridApi = {}; - vm.filterEnabled = false; vm.setting = setting; vm.loading = false; vm.distribution = distribution; @@ -48,6 +47,7 @@ function DistributionCenterController(DistributionCenters, Notify, uiGridConstan displayName : 'TABLE.COLUMNS.FEE_CENTER', headerCellFilter : 'translate', aggregationType : uiGridConstants.aggregationTypes.count, + aggregationHideLabel : true, }, { field : 'trans_id', displayName : 'TABLE.COLUMNS.TRANSACTION', @@ -116,8 +116,7 @@ function DistributionCenterController(DistributionCenters, Notify, uiGridConstan } function toggleFilter() { - vm.filterEnabled = !vm.filterEnabled; - vm.gridOptions.enableFiltering = vm.filterEnabled; + vm.gridOptions.enableFiltering = !vm.gridOptions.enableFiltering; vm.gridApi.core.notifyDataChange(uiGridConstants.dataChange.COLUMN); } @@ -160,7 +159,6 @@ function DistributionCenterController(DistributionCenters, Notify, uiGridConstan // distribution function distribution(data) { - const filtersSnapshot = DistributionCenters.filters.formatHTTP(); DistributionCenters.openDistributionModal(data) .then((changes) => { if (changes) { diff --git a/client/src/modules/distribution_center/distribution_key/distribution_key.html b/client/src/modules/distribution_center/distribution_key/distribution_key.html index d8581799fd..b965151c1a 100644 --- a/client/src/modules/distribution_center/distribution_key/distribution_key.html +++ b/client/src/modules/distribution_center/distribution_key/distribution_key.html @@ -1,35 +1,35 @@ -
-
-
    -
  1. TREE.FINANCE
  2. -
  3. TREE.DISTRIBUTION_KEYS
  4. -
- -
-
+
+
+
    +
  1. TREE.FEE_CENTER_MANAGEMENT
  2. +
  3. TREE.DISTRIBUTION_KEYS
  4. +
+ +
+
-
-
+
+
- -
-
-
+
+
+
- - - -
-
-
\ No newline at end of file + ui-grid-resize-columns> + + + +
+
+
diff --git a/client/src/modules/distribution_center/distribution_key/distribution_key.js b/client/src/modules/distribution_center/distribution_key/distribution_key.js index 8eebdf42ae..6e22f7da2b 100644 --- a/client/src/modules/distribution_center/distribution_key/distribution_key.js +++ b/client/src/modules/distribution_center/distribution_key/distribution_key.js @@ -3,7 +3,7 @@ angular.module('bhima.controllers') DistributionKeyController.$inject = [ 'DistributionCenterService', 'NotifyService', 'uiGridConstants', - '$state', 'GridGroupingService', 'uiGridGroupingConstants', + 'GridGroupingService', 'uiGridGroupingConstants', ]; /** @@ -13,7 +13,7 @@ DistributionKeyController.$inject = [ * It's responsible for editing and updating a Distribution Center */ function DistributionKeyController(DistributionCenters, Notify, uiGridConstants, - $state, Grouping, uiGridGroupingConstants) { + Grouping, uiGridGroupingConstants) { const vm = this; // bind methods @@ -22,7 +22,6 @@ function DistributionKeyController(DistributionCenters, Notify, uiGridConstants, // global variables vm.gridApi = {}; - vm.filterEnabled = false; vm.loading = false; // options for the UI grid @@ -77,14 +76,12 @@ function DistributionKeyController(DistributionCenters, Notify, uiGridConstants, } function toggleFilter() { - vm.filterEnabled = !vm.filterEnabled; - vm.gridOptions.enableFiltering = vm.filterEnabled; + vm.gridOptions.enableFiltering = !vm.gridOptions.enableFiltering; vm.gridApi.core.notifyDataChange(uiGridConstants.dataChange.COLUMN); } // settings distribution keys function settings(distributions) { - const dataSettings = distributions[0].row.entity; const settingsValues = []; diff --git a/client/src/modules/distribution_center/templates/action.tmpl.html b/client/src/modules/distribution_center/templates/action.tmpl.html index a3d3865d24..bb0e678445 100644 --- a/client/src/modules/distribution_center/templates/action.tmpl.html +++ b/client/src/modules/distribution_center/templates/action.tmpl.html @@ -1,15 +1,15 @@ -
- - FORM.BUTTONS.ACTIONS +
+ + FORM.BUTTONS.ACTIONS -
\ No newline at end of file +
diff --git a/client/src/modules/distribution_center/templates/setting.tmpl.html b/client/src/modules/distribution_center/templates/setting.tmpl.html index 450bc98f37..ae7bcc0171 100644 --- a/client/src/modules/distribution_center/templates/setting.tmpl.html +++ b/client/src/modules/distribution_center/templates/setting.tmpl.html @@ -1,15 +1,18 @@ -
- - FORM.BUTTONS.ACTIONS +
+ + FORM.BUTTONS.ACTIONS -
\ No newline at end of file +
diff --git a/client/src/modules/fee_center/templates/action.tmpl.html b/client/src/modules/fee_center/templates/action.tmpl.html index 13f66fbc91..145fee79fe 100644 --- a/client/src/modules/fee_center/templates/action.tmpl.html +++ b/client/src/modules/fee_center/templates/action.tmpl.html @@ -1,5 +1,5 @@
- + FORM.BUTTONS.ACTIONS diff --git a/client/src/modules/journal/templates/transaction-id.cell.html b/client/src/modules/journal/templates/transaction-id.cell.html index 1c300e30d3..559e9befb4 100644 --- a/client/src/modules/journal/templates/transaction-id.cell.html +++ b/client/src/modules/journal/templates/transaction-id.cell.html @@ -1,5 +1,5 @@ -
+
diff --git a/test/end-to-end/distributionFeesCenters/distribution_feescenters.page.js b/test/end-to-end/distributionFeesCenters/distribution_feescenters.page.js index 05eed058d7..e9631ffcf8 100644 --- a/test/end-to-end/distributionFeesCenters/distribution_feescenters.page.js +++ b/test/end-to-end/distributionFeesCenters/distribution_feescenters.page.js @@ -9,6 +9,7 @@ const GA = require('../shared/GridAction'); const GU = require('../shared/GridUtils'); const FU = require('../shared/FormUtils'); +const GridRow = require('../shared/GridRow'); const components = require('../shared/components'); const gridId = 'distribution-center-grid'; @@ -74,8 +75,10 @@ class DistributionPage { await FU.buttons.submit(); - const { rowIndex } = await GU.getGridIndexesMatchingText(this.gridId, dataset.label); - await GA.clickOnMethod(rowIndex, this.actionLinkColumn, 'distribution', this.gridId); + // get the grid row + const row = new GridRow(dataset.trans_id); + await row.dropdown().click(); + await row.method('distribution').click(); await components.currencyInput.set(1000, 'principal_1'); await components.currencyInput.set(145, 'principal_2'); @@ -110,6 +113,7 @@ class DistributionPage { const { rowIndex } = await GU.getGridIndexesMatchingText(this.gridId, dataset.uuid); await GA.clickOnMethod(rowIndex, this.actionLinkUpdateColumn, 'edit', this.gridId); + await components.currencyInput.set(1000, 'principal_1'); await components.currencyInput.set(100, 'principal_2'); await components.currencyInput.set(500, 'principal_3'); diff --git a/test/end-to-end/distributionFeesCenters/distribution_feescenters.spec.js b/test/end-to-end/distributionFeesCenters/distribution_feescenters.spec.js index 2e0b82a1da..a32ecf4a7b 100644 --- a/test/end-to-end/distributionFeesCenters/distribution_feescenters.spec.js +++ b/test/end-to-end/distributionFeesCenters/distribution_feescenters.spec.js @@ -19,17 +19,18 @@ describe('Distribution Auxiliary Fee Center', () => { periodTo_id : 201812, profitCenter : 0, label : 'Auxiliary 1', + trans_id : 'TPA37', }; - it('Set Distribution By Percentage', async () => { + it('set distribution by percentage', async () => { await page.setDistributionPercentage(dataset); }); - it('Set Automatic Distribution of Invoice', async () => { + it('set automatic distribution of invoice', async () => { await page.setDistributionAutomatic(dataset); }); - it('Set Manual Distribution by Value', async () => { + it('set manual distribution by value', async () => { await page.setDistributionManual(datasetManual); }); }); diff --git a/test/end-to-end/distributionFeesCenters/distribution_key.page.js b/test/end-to-end/distributionFeesCenters/distribution_key.page.js index c76ca6584e..8d94af25f5 100644 --- a/test/end-to-end/distributionFeesCenters/distribution_key.page.js +++ b/test/end-to-end/distributionFeesCenters/distribution_key.page.js @@ -1,4 +1,3 @@ -/* eslint-disable lines-between-class-members */ /* global element, by */ /** @@ -6,16 +5,14 @@ * behaviour so it is a Fee Center page object */ -const GA = require('../shared/GridAction'); -const GU = require('../shared/GridUtils'); const FU = require('../shared/FormUtils'); +const GridRow = require('../shared/GridRow'); const components = require('../shared/components'); class FeeCenterPage { constructor() { this.gridId = 'distribution-key-center-grid'; this.rubricGrid = element(by.id(this.gridId)); - this.actionLinkColumn = 4; } /** @@ -28,9 +25,15 @@ class FeeCenterPage { .count(); } + async openDropdownSettingsMenu(label) { + const row = new GridRow(label); + await row.dropdown().click(); + await row.method('setting').click(); + } + async setDistributionKey(label) { - const { rowIndex } = await GU.getGridIndexesMatchingText(this.gridId, label); - await GA.clickOnMethod(rowIndex, this.actionLinkColumn, 'setting', this.gridId); + await this.openDropdownSettingsMenu(label); + await components.percentageInput.set(50, 'principal_1'); await components.percentageInput.set(25, 'principal_2'); await components.percentageInput.set(25, 'principal_3'); @@ -40,8 +43,7 @@ class FeeCenterPage { // Reset Distribution Keys for an auxiliary fee center async resetDistributionKey(label) { - const { rowIndex } = await GU.getGridIndexesMatchingText(this.gridId, label); - await GA.clickOnMethod(rowIndex, this.actionLinkColumn, 'setting', this.gridId); + await this.openDropdownSettingsMenu(label); await $('[data-method="reset"]').click(); await components.notification.hasSuccess(); } @@ -49,8 +51,7 @@ class FeeCenterPage { // Prevent initialization of distribution keys greater than 100 percent // Prevent initialization of distribution keys less than 100 percent async preventGreaterLess100(label) { - const { rowIndex } = await GU.getGridIndexesMatchingText(this.gridId, label); - await GA.clickOnMethod(rowIndex, this.actionLinkColumn, 'setting', this.gridId); + await this.openDropdownSettingsMenu(label); await components.percentageInput.set(19, 'principal_1'); await components.percentageInput.set(45, 'principal_2'); await components.percentageInput.set(76, 'principal_3'); diff --git a/test/end-to-end/distributionFeesCenters/distribution_key.spec.js b/test/end-to-end/distributionFeesCenters/distribution_key.spec.js index 3accc6a4f7..b1c8b9e4c8 100644 --- a/test/end-to-end/distributionFeesCenters/distribution_key.spec.js +++ b/test/end-to-end/distributionFeesCenters/distribution_key.spec.js @@ -6,16 +6,16 @@ describe('Distribution keys Management', () => { before(() => helpers.navigate('#!/distribution_center/distribution_key')); const Page = new DistributionKeysPage(); - const labelAuxiliary1 = 'Auxiliary 2 (1)'; - const labelAuxiliary2 = 'Auxiliary 2 (3)'; - const resetAuxiliary2 = 'Auxiliary 3 (1)'; + const labelAuxiliary1 = 'Auxiliary 2'; + const labelAuxiliary2 = 'Auxiliary 2'; + const resetAuxiliary2 = 'Auxiliary 3'; const distributionKeyElements = 10; - it('Set Distribution key for an Auxiliary Fee Center', async () => { + it('set distribution key for an Auxiliary Fee Center', async () => { await Page.setDistributionKey(labelAuxiliary1); }); - it('Prevent initialization of distribution keys greater than 100 percent', async () => { + it('prevent initialization of distribution keys greater than 100 percent', async () => { await Page.preventGreaterLess100(labelAuxiliary2); }); @@ -27,7 +27,7 @@ describe('Distribution keys Management', () => { expect(await Page.getDistributionKeyCount()).to.equal(distributionKeyElements); }); - it('Reset Distributions key for an Auxiliary Fee Center', async () => { + it('reset distributions key for an Auxiliary Fee Center', async () => { await Page.resetDistributionKey(resetAuxiliary2); }); }); diff --git a/test/end-to-end/feeCenter/fee_center.spec.js b/test/end-to-end/feeCenter/fee_center.spec.js index fc859b351e..5e4ea82f6f 100644 --- a/test/end-to-end/feeCenter/fee_center.spec.js +++ b/test/end-to-end/feeCenter/fee_center.spec.js @@ -80,7 +80,7 @@ describe('Fee Center Management', () => { await Page.errorEditFeeCenter(ErrorfeeCenterUpdate.label, ErrorfeeCenterUpdate); }); - it('don\'t create when incorrect Fee Center', async () => { + it('does not create a Fee Center with incorrect information', async () => { await Page.errorOnCreateFeeCenter(); }); }); diff --git a/test/end-to-end/journal/journal.page.js b/test/end-to-end/journal/journal.page.js index 1df47b72be..468a606f83 100644 --- a/test/end-to-end/journal/journal.page.js +++ b/test/end-to-end/journal/journal.page.js @@ -21,7 +21,7 @@ class JournalPage { return Promise.all(rows .map(async (row, index) => { - const attr = await row.$(`[data-row]`).getAttribute('data-row'); + const attr = await row.$(`[data-rowcol]`).getAttribute('data-rowcol'); if (attr === transId) { await GU.selectRow(this.gridId, index); } @@ -35,7 +35,7 @@ class JournalPage { return Promise.all(rows .map(async (row, index) => { - const attr = await row.$(`[data-row]`).getAttribute('data-row'); + const attr = await row.$(`[data-rowcol]`).getAttribute('data-rowcol'); if (transIds.includes(attr)) { await GU.selectRow(this.gridId, index); } From 1d26e7ced4c5c79969e8e39abca85ca4123c99df Mon Sep 17 00:00:00 2001 From: Artur Neumann Date: Tue, 5 May 2020 17:02:05 +0545 Subject: [PATCH 02/29] run installation tests in CI fixes #3998 --- .travis.yml | 32 ++++++++++++++++++++++++-------- sh/install-tests.sh | 0 sh/travis.sh | 26 ++++++++++++++++---------- 3 files changed, 40 insertions(+), 18 deletions(-) mode change 100644 => 100755 sh/install-tests.sh diff --git a/.travis.yml b/.travis.yml index 5b32b9f0e1..d86598834b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,24 +12,40 @@ env: - CHROME_REVISION=706915 - CHROMEDRIVER_VERSION="79.0.3945.36" +matrix: + include: + - env: TEST_TYPE=e2e + services: + - mysql + - redis + - env: + TEST_TYPE=installation + services: + - mysql + - redis + - env: + TEST_TYPE=installation + addons: + mariadb: '10.5' + services: + - redis + before_install: - ./sh/setup-ci-env.sh - - ./sh/travis.sh - -services: - - mysql - - redis + - sudo ./sh/travis.sh language: node_js node_js: - lts/erbium before_script: - - yarn build - - yarn webdriver-manager update --versions.chrome=$CHROMEDRIVER_VERSION --gecko false + - sh -c "if [ '$TEST_TYPE' = 'e2e' ]; then yarn build; fi" + - sh -c "if [ '$TEST_TYPE' = 'e2e' ]; then yarn webdriver-manager update --versions.chrome=$CHROMEDRIVER_VERSION --gecko false; fi" script: - - yarn test:ends + - sh -c "if [ '$TEST_TYPE' = 'e2e' ]; then yarn test:ends; fi" + - sh -c "if [ '$TEST_TYPE' = 'installation' ]; then ./sh/install-tests.sh; fi" + git: depth: 3 diff --git a/sh/install-tests.sh b/sh/install-tests.sh old mode 100644 new mode 100755 diff --git a/sh/travis.sh b/sh/travis.sh index 716180c96f..fb941633bc 100755 --- a/sh/travis.sh +++ b/sh/travis.sh @@ -7,21 +7,27 @@ set -a source .env.development set +a +mysql --version + # setup usernames and permissions mysql -h $DB_HOST -u root -e "GRANT ALL PRIVILEGES ON *.* TO '$DB_USER'@'$DB_HOST' IDENTIFIED BY '$DB_PASS' WITH GRANT OPTION;" mysql -h $DB_HOST -u root -e "FLUSH PRIVILEGES;" -echo "Downloading chrome revision: $CHROME_REVISION" -echo "Download URL: https://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/$CHROME_REVISION/chrome-linux.zip" +if [ "$TEST_TYPE" = 'e2e' ] +then + + echo "Downloading chrome revision: $CHROME_REVISION" + echo "Download URL: https://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/$CHROME_REVISION/chrome-linux.zip" -wget -q -O chrome.zip "https://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/$CHROME_REVISION/chrome-linux.zip" -unzip -q chrome.zip -rm chrome.zip + wget -q -O chrome.zip "https://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/$CHROME_REVISION/chrome-linux.zip" + unzip -q chrome.zip + rm chrome.zip -echo "Downloaded chrome version: $($PWD/chrome-linux/chrome --version)" + echo "Downloaded chrome version: $($PWD/chrome-linux/chrome --version)" -sudo ln -sf "$PWD/chrome-linux/chrome" /usr/bin/chromium -sudo ln -sf /usr/bin/chromium /usr/bin/chromium-browser -sudo ln -sf /usr/bin/chromium /usr/bin/google-chrome + sudo ln -sf "$PWD/chrome-linux/chrome" /usr/bin/chromium + sudo ln -sf /usr/bin/chromium /usr/bin/chromium-browser + sudo ln -sf /usr/bin/chromium /usr/bin/google-chrome -sudo groupadd -r chrome && sudo useradd -r -g chrome -G audio,video chrome + sudo groupadd -r chrome && sudo useradd -r -g chrome -G audio,video chrome +fi From d0138f36a514591e99983266fd9a6d8e0e15bb85 Mon Sep 17 00:00:00 2001 From: Artur Neumann Date: Wed, 6 May 2020 14:52:14 +0545 Subject: [PATCH 03/29] document how to use docker to start MySQL server --- docs/en/for-developers/installing-bhima.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/en/for-developers/installing-bhima.md b/docs/en/for-developers/installing-bhima.md index d2c9817107..40ce1bc0e0 100644 --- a/docs/en/for-developers/installing-bhima.md +++ b/docs/en/for-developers/installing-bhima.md @@ -122,6 +122,13 @@ sql-mode = STRICT_ALL_TABLES sudo service mysql restart ``` +To start a MySQL server using docker you can use: +`docker run --name mysql5.7 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=MyPassword -d mysql:5.7 --sql-mode='STRICT_ALL_TABLES'` +this will start a MySQL server that listens on port 3306 (the default MySQL port) on your localhost. +Additionally, you have to set `DB_HOST` in the `.env` file to `127.0.0.1`, leaving it to `localhost` will make the `mysql` command trying to connect via socket, what is not possible when using docker. + +If you have already a MySQL server running on port 3306 of your localhost, start docker without the port-forwarding (`-p 3306:3306`), use `docker inspect mysql5.7` to find the IP of the container and use that IP in the `.env` file as `DB_HOST`. + The database structure is contained in the `server/models/*.sql` files. You can execute these one by one in the order below, or simply run `yarn build:db`. 1. `server/models/schema.sql` From 74b0a023e03f0811215904598a5a32419f5277a5 Mon Sep 17 00:00:00 2001 From: mbayopanda Date: Wed, 6 May 2020 13:22:51 +0100 Subject: [PATCH 04/29] Add loading indicator Close #4434 --- .../stock/entry/modals/findPurchase.modal.js | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/client/src/modules/stock/entry/modals/findPurchase.modal.js b/client/src/modules/stock/entry/modals/findPurchase.modal.js index be513b48a5..ae25bbb5f1 100644 --- a/client/src/modules/stock/entry/modals/findPurchase.modal.js +++ b/client/src/modules/stock/entry/modals/findPurchase.modal.js @@ -9,7 +9,7 @@ StockFindPurchaseModalController.$inject = [ function StockFindPurchaseModalController( Instance, Purchase, Notify, - uiGridConstants, Filtering, Receipts, bhConstants + uiGridConstants, Filtering, Receipts, bhConstants, ) { const vm = this; @@ -89,20 +89,27 @@ function StockFindPurchaseModalController( } /* ======================= End Grid ======================================== */ - - Purchase.search({ detailed : 1, status_id : [2, 4] }) - .then(purchases => { - vm.gridOptions.data = purchases; - }) - .catch(Notify.errorHandler); + function load() { + vm.loading = true; + Purchase.search({ detailed : 1, status_id : [2, 4] }) + .then(purchases => { + vm.gridOptions.data = purchases; + }) + .catch(() => { + vm.hasError = true; + }) + .finally(() => { + vm.loading = false; + }); + } // submit function submit() { - if (!vm.selectedRow) { return null; } + if (!vm.selectedRow || (vm.selectedRow && !vm.selectedRow.uuid)) { return null; } return Purchase.stockBalance(vm.selectedRow.uuid) .then(handlePurchaseInformation) - .catch(Notify.errorHandler); + .catch(Notify.handleError); } // display the supplier name @@ -117,4 +124,6 @@ function StockFindPurchaseModalController( function cancel() { Instance.close(); } + + load(); } From 74bab8baa9ade482aada216d3b8ce240c3c1188e Mon Sep 17 00:00:00 2001 From: mbayopanda Date: Wed, 6 May 2020 15:18:29 +0100 Subject: [PATCH 05/29] Fix self requisition Close #4422 --- client/src/js/components/bhDepotSelect.js | 0 .../components/bhDepotSelect/bhDepotSelect.js | 2 ++ .../requisition/modals/action.modal.html | 1 + server/controllers/inventory/depots/index.js | 25 +++++++++++++++++++ 4 files changed, 28 insertions(+) delete mode 100644 client/src/js/components/bhDepotSelect.js diff --git a/client/src/js/components/bhDepotSelect.js b/client/src/js/components/bhDepotSelect.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/client/src/js/components/bhDepotSelect/bhDepotSelect.js b/client/src/js/components/bhDepotSelect/bhDepotSelect.js index 8cc56f79d2..4d3d5cfee4 100644 --- a/client/src/js/components/bhDepotSelect/bhDepotSelect.js +++ b/client/src/js/components/bhDepotSelect/bhDepotSelect.js @@ -8,6 +8,7 @@ angular.module('bhima.components') onSelectCallback : '&', label : '@?', required : ' { const options = { text : (text || '').toLowerCase(), + exception : $ctrl.exception, }; return Depots.searchByName(options); diff --git a/client/src/modules/stock/requisition/modals/action.modal.html b/client/src/modules/stock/requisition/modals/action.modal.html index c9ce67df52..81f4c69ceb 100644 --- a/client/src/modules/stock/requisition/modals/action.modal.html +++ b/client/src/modules/stock/requisition/modals/action.modal.html @@ -51,6 +51,7 @@ diff --git a/server/controllers/inventory/depots/index.js b/server/controllers/inventory/depots/index.js index 7cdc9cb58d..bdfd5655a4 100644 --- a/server/controllers/inventory/depots/index.js +++ b/server/controllers/inventory/depots/index.js @@ -116,6 +116,14 @@ function list(req, res, next) { options.user_id = req.session.user.id; } + if (options.exception && Array.isArray(options.exception)) { + options.exception = options.exception.map(depotUuid => { + return db.bid(depotUuid); + }).join(','); + } else if (options.exception && typeof options.exception === 'string') { + options.exception = db.bid(options.exception); + } + options.enterprise_id = req.session.enterprise.id; const filters = new FilterParser(options, { tableAlias : 'd' }); @@ -138,6 +146,10 @@ function list(req, res, next) { 'user_id', 'd.uuid IN (SELECT depot_permission.depot_uuid FROM depot_permission WHERE depot_permission.user_id = ?)', ); + filters.custom( + 'exception', + 'd.uuid NOT IN (?)', + ); filters.fullText('text', 'text', 'd'); filters.equals('is_warehouse', 'is_warehouse', 'd'); filters.equals('uuid', 'uuid', 'd'); @@ -174,6 +186,7 @@ function hasUuids(uuids, filters) { function searchByName(req, res, next) { const options = {}; options.text = req.query.text; + options.exception = req.query.exception; options.limit = req.query.limit || 10; options.enterprise_id = req.session.enterprise.id; @@ -181,6 +194,14 @@ function searchByName(req, res, next) { return next(new BadRequest('text attribute must be specified for a name search')); } + if (options.exception && Array.isArray(options.exception)) { + options.exception = options.exception.map(depotUuid => { + return db.bid(depotUuid); + }).join(','); + } else if (options.exception && typeof options.exception === 'string') { + options.exception = db.bid(options.exception); + } + const filters = new FilterParser(options, { tableAlias : 'd' }); const sql = ` @@ -197,6 +218,10 @@ function searchByName(req, res, next) { LEFT JOIN country c ON c.uuid = p.country_uuid `; + filters.custom( + 'exception', + 'd.uuid NOT IN (?)', + ); filters.fullText('text', 'text', 'd'); filters.equals('enterprise_id', 'enterprise_id', 'd'); filters.setOrder('ORDER BY d.text'); From 1c5420e1eb79cd39e13b02d6bc5ef1f669bdce9d Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 7 May 2020 05:54:21 +0000 Subject: [PATCH 06/29] chore(deps-dev): bump standard-version from 7.1.0 to 8.0.0 Bumps [standard-version](https://github.com/conventional-changelog/standard-version) from 7.1.0 to 8.0.0. - [Release notes](https://github.com/conventional-changelog/standard-version/releases) - [Changelog](https://github.com/conventional-changelog/standard-version/blob/master/CHANGELOG.md) - [Commits](https://github.com/conventional-changelog/standard-version/compare/v7.1.0...v8.0.0) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- yarn.lock | 74 +++++++++++++++++++--------------------------------- 2 files changed, 28 insertions(+), 48 deletions(-) diff --git a/package.json b/package.json index 99c1a58bf1..6909589aa6 100644 --- a/package.json +++ b/package.json @@ -149,7 +149,7 @@ "qs": "^6.9.4", "release-it": "^13.5.8", "sinon": "^9.0.2", - "standard-version": "^7.0.0", + "standard-version": "^8.0.0", "typescript": "^3.7.5" }, "homepage": "https://docs.bhi.ma", diff --git a/yarn.lock b/yarn.lock index b28f851b47..392a56fb45 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1994,7 +1994,7 @@ conventional-changelog-conventionalcommits@4.2.3, conventional-changelog-convent lodash "^4.17.15" q "^1.5.1" -conventional-changelog-core@^4.1.1: +conventional-changelog-core@^4.1.4: version "4.1.4" resolved "https://registry.yarnpkg.com/conventional-changelog-core/-/conventional-changelog-core-4.1.4.tgz#39be27fca6ef20a0f998d7a3a1e97cfa8a055cb6" integrity sha512-LO58ZbEpp1Ul+y/vOI8rJRsWkovsYkCFbOCVgi6UnVfU8WC0F8K8VQQwaBZWWUpb6JvEiN4GBR5baRP2txZ+Vg== @@ -2071,16 +2071,16 @@ conventional-changelog-writer@^4.0.11: split "^1.0.0" through2 "^3.0.0" -conventional-changelog@3.1.15: - version "3.1.15" - resolved "https://registry.yarnpkg.com/conventional-changelog/-/conventional-changelog-3.1.15.tgz#103d0b550436cf83e8a59ba88be82ece2613cd9f" - integrity sha512-CoWM+Z9bYyF00QzNpTnxkCLiuLAeRocJz3C/foFjvhsdltdtkJgMChp7GytQNjm4pT7JFBVJTpqLHTpxNtOzaA== +conventional-changelog@3.1.18: + version "3.1.18" + resolved "https://registry.yarnpkg.com/conventional-changelog/-/conventional-changelog-3.1.18.tgz#7da0a5ab34a604b920b8bf71c6cf5d952f0e805e" + integrity sha512-aN6a3rjgV8qwAJj3sC/Lme2kvswWO7fFSGQc32gREcwIOsaiqBaO6f2p0NomFaPDnTqZ+mMZFLL3hlzvEnZ0mQ== dependencies: conventional-changelog-angular "^5.0.6" conventional-changelog-atom "^2.0.3" conventional-changelog-codemirror "^2.0.3" conventional-changelog-conventionalcommits "^4.2.3" - conventional-changelog-core "^4.1.1" + conventional-changelog-core "^4.1.4" conventional-changelog-ember "^2.0.4" conventional-changelog-eslint "^3.0.4" conventional-changelog-express "^2.0.1" @@ -8288,16 +8288,21 @@ semver-greatest-satisfied-range@^1.1.0: resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== -semver@6.3.0, semver@^6.0.0, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" - integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== +semver@7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.1.1.tgz#29104598a197d6cbe4733eeecbe968f7b43a9667" + integrity sha512-WfuG+fl6eh3eZ2qAf6goB7nhiCd7NPXhmyFxigB/TOkQyeLP8w8GsVehvtGNtnNmyboz4TgeK40B1Kbql/8c5A== semver@7.3.2: version "7.3.2" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938" integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ== +semver@^6.0.0, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" + integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== + send@0.17.1: version "0.17.1" resolved "https://registry.yarnpkg.com/send/-/send-0.17.1.tgz#c1d8b059f7900f7466dd4938bdc44e11ddb376c8" @@ -8666,13 +8671,13 @@ standard-as-callback@^2.0.1: resolved "https://registry.yarnpkg.com/standard-as-callback/-/standard-as-callback-2.0.1.tgz#ed8bb25648e15831759b6023bdb87e6b60b38126" integrity sha512-NQOxSeB8gOI5WjSaxjBgog2QFw55FV8TkS6Y07BiB3VJ8xNTvUYm0wl0s8ObgQ5NhdpnNfigMIKjgPESzgr4tg== -standard-version@^7.0.0: - version "7.1.0" - resolved "https://registry.yarnpkg.com/standard-version/-/standard-version-7.1.0.tgz#021dd79eac749548677c876d5a94791df50f1f36" - integrity sha512-bHY2E/1tYGeVl+0XSXFivb+54h2fA4pWJocXAd6FGbtSFUvGsnfmMbIXYDxrYErpq7oEqoKreV8xTAp78WoATA== +standard-version@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/standard-version/-/standard-version-8.0.0.tgz#3bb1ab495702cf01a9dc602b2b91df1ade6f008e" + integrity sha512-cS/U9yhYPHfyokFce6e/H3U8MaKwZKSGzH25J776sChrae/doDQjsl3vCQ0hW1MSzdrUTb7pir4ApjnbDt/TAg== dependencies: chalk "2.4.2" - conventional-changelog "3.1.15" + conventional-changelog "3.1.18" conventional-changelog-config-spec "2.1.0" conventional-changelog-conventionalcommits "4.2.3" conventional-recommended-bump "6.0.5" @@ -8683,9 +8688,9 @@ standard-version@^7.0.0: find-up "4.1.0" fs-access "1.0.1" git-semver-tags "3.0.1" - semver "6.3.0" + semver "7.1.1" stringify-package "1.0.1" - yargs "15.0.2" + yargs "15.3.1" static-extend@^0.1.1: version "0.1.2" @@ -9969,14 +9974,6 @@ yargs-parser@^11.1.1: camelcase "^5.0.0" decamelize "^1.2.0" -yargs-parser@^16.1.0: - version "16.1.0" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-16.1.0.tgz#73747d53ae187e7b8dbe333f95714c76ea00ecf1" - integrity sha512-H/V41UNZQPkUMIT5h5hiwg4QKIY1RPvoBV4XcjUbRM8Bk2oKqqyZ0DIEbTFZB0XjbtSPG8SAa/0DxCQmiRgzKg== - dependencies: - camelcase "^5.0.0" - decamelize "^1.2.0" - yargs-parser@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-5.0.0.tgz#275ecf0d7ffe05c77e64e7c86e4cd94bf0e1228a" @@ -10009,10 +10006,10 @@ yargs@13.3.2, yargs@^13.3.0: y18n "^4.0.0" yargs-parser "^13.1.2" -yargs@15.0.2: - version "15.0.2" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.0.2.tgz#4248bf218ef050385c4f7e14ebdf425653d13bd3" - integrity sha512-GH/X/hYt+x5hOat4LMnCqMd8r5Cv78heOMIJn1hr7QPPBqfeC6p89Y78+WB9yGDvfpCvgasfmWLzNzEioOUD9Q== +yargs@15.3.1, yargs@^15.3.1: + version "15.3.1" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.3.1.tgz#9505b472763963e54afe60148ad27a330818e98b" + integrity sha512-92O1HWEjw27sBfgmXiixJWT5hRBp2eobqXicLtPBIDBhYB+1HpwZlXmbW2luivBJHBzki+7VyCLRtAkScbTBQA== dependencies: cliui "^6.0.0" decamelize "^1.2.0" @@ -10024,7 +10021,7 @@ yargs@15.0.2: string-width "^4.2.0" which-module "^2.0.0" y18n "^4.0.0" - yargs-parser "^16.1.0" + yargs-parser "^18.1.1" yargs@^12.0.5: version "12.0.5" @@ -10044,23 +10041,6 @@ yargs@^12.0.5: y18n "^3.2.1 || ^4.0.0" yargs-parser "^11.1.1" -yargs@^15.3.1: - version "15.3.1" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.3.1.tgz#9505b472763963e54afe60148ad27a330818e98b" - integrity sha512-92O1HWEjw27sBfgmXiixJWT5hRBp2eobqXicLtPBIDBhYB+1HpwZlXmbW2luivBJHBzki+7VyCLRtAkScbTBQA== - dependencies: - cliui "^6.0.0" - decamelize "^1.2.0" - find-up "^4.1.0" - get-caller-file "^2.0.1" - require-directory "^2.1.1" - require-main-filename "^2.0.0" - set-blocking "^2.0.0" - string-width "^4.2.0" - which-module "^2.0.0" - y18n "^4.0.0" - yargs-parser "^18.1.1" - yargs@^7.1.0: version "7.1.0" resolved "https://registry.yarnpkg.com/yargs/-/yargs-7.1.0.tgz#6ba318eb16961727f5d284f8ea003e8d6154d0c8" From 17cdec841f197f9797a66b3dc9b34c2d82d30673 Mon Sep 17 00:00:00 2001 From: Jonathan Niles Date: Thu, 30 Apr 2020 11:05:22 +0100 Subject: [PATCH 07/29] chore(payroll): add employee reference to pay grid Adds the reference of the employee to the multiple payroll grid. Includes proper sorting and summing. Also puts their information in the dropdown menu. Closes #4351. --- .../multiple_payroll/multiple_payroll.js | 28 ++++++++++--------- .../multiple_payroll.service.js | 8 ++---- .../templates/action.tmpl.html | 13 +++++---- .../purchases/templates/cellStatus.tmpl.html | 2 +- .../payroll/multiplePayroll/find.js | 7 +++-- .../payroll/multiplePayroll/index.js | 8 +++--- 6 files changed, 33 insertions(+), 33 deletions(-) diff --git a/client/src/modules/multiple_payroll/multiple_payroll.js b/client/src/modules/multiple_payroll/multiple_payroll.js index a50dd876f6..b18a456d3d 100644 --- a/client/src/modules/multiple_payroll/multiple_payroll.js +++ b/client/src/modules/multiple_payroll/multiple_payroll.js @@ -5,7 +5,7 @@ angular.module('bhima.controllers') MultiplePayrollController.$inject = [ 'MultiplePayrollService', 'NotifyService', 'GridSortingService', 'GridColumnService', 'GridStateService', '$state', - 'ModalService', 'util', 'ReceiptModal', 'uiGridConstants', 'SessionService', + 'ModalService', 'ReceiptModal', 'uiGridConstants', 'SessionService', ]; /** @@ -17,8 +17,8 @@ MultiplePayrollController.$inject = [ * reordering, and many more features. */ function MultiplePayrollController( - MultiplePayroll, Notify, - Sorting, Columns, GridState, $state, Modals, util, Receipts, uiGridConstants, Session, + MultiplePayroll, Notify, Sorting, Columns, GridState, $state, + Modals, Receipts, uiGridConstants, Session, ) { const vm = this; const cacheKey = 'multiple-payroll-grid'; @@ -31,19 +31,22 @@ function MultiplePayrollController( vm.clearGridState = clearGridState; vm.toggleInlineFilter = toggleInlineFilter; - // date format function - vm.format = util.formatDate; - vm.loading = false; vm.activePosting = true; vm.activeConfig = true; const columnDefs = [{ + field : 'reference', + displayName : 'TABLE.COLUMNS.REFERENCE', + headerCellFilter : 'translate', + aggregationType : uiGridConstants.aggregationTypes.count, + aggregationHideLabel : true, + footerCellClass : 'text-center', + sortingAlgorithm : Sorting.algorithms.sortByReference, + }, { field : 'display_name', displayName : 'FORM.LABELS.EMPLOYEE_NAME', headerCellFilter : 'translate', - aggregationType : uiGridConstants.aggregationTypes.count, - aggregationHideLabel : true, }, { field : 'code', displayName : 'FORM.LABELS.CODE', @@ -52,11 +55,13 @@ function MultiplePayrollController( field : 'net_salary', displayName : 'FORM.LABELS.NET_SALARY', headerCellFilter : 'translate', + cellClass : 'text-right', cellFilter : 'currency:row.entity.currency_id', }, { field : 'balance', displayName : 'FORM.LABELS.BALANCE', headerCellFilter : 'translate', + cellClass : 'text-right', cellFilter : 'currency:row.entity.currency_id', }, { field : 'status_id', @@ -82,9 +87,7 @@ function MultiplePayrollController( flatEntityAccess : true, fastWatch : true, columnDefs, - onRegisterApi : function onRegisterApi(api) { - vm.gridApi = api; - }, + onRegisterApi : (api) => { vm.gridApi = api; }, }; const gridColumns = new Columns(vm.gridOptions, cacheKey); @@ -105,7 +108,7 @@ function MultiplePayrollController( MultiplePayroll.filters.replaceFilters(changes); MultiplePayroll.cacheFilters(); vm.latestViewFilters = MultiplePayroll.filters.formatView(); - return load(MultiplePayroll.filters.formatHTTP(true)); + load(MultiplePayroll.filters.formatHTTP(true)); } }); } @@ -301,7 +304,6 @@ function MultiplePayrollController( Notify.warn('FORM.WARNINGS.ATTENTION_PAYSLIPS'); } else { const idPeriod = vm.latestViewFilters.defaultFilters[0]._value; - Receipts.payrollReport(idPeriod, employeesRef, currencyId, socialCharge, conversionRate); } } else { diff --git a/client/src/modules/multiple_payroll/multiple_payroll.service.js b/client/src/modules/multiple_payroll/multiple_payroll.service.js index b6f6123792..8dbc8a317e 100644 --- a/client/src/modules/multiple_payroll/multiple_payroll.service.js +++ b/client/src/modules/multiple_payroll/multiple_payroll.service.js @@ -17,7 +17,7 @@ MultiplePayrollService.$inject = [ */ function MultiplePayrollService( Api, TransactionTypeStore, Modal, Filters, Periods, Languages, - $httpParamSerializer, AppCache, Transactions + $httpParamSerializer, AppCache, Transactions, ) { const service = new Api('/multiple_payroll/'); const multiplePayrollFilters = new Filters(); @@ -119,13 +119,9 @@ function MultiplePayrollService( function openSearchModal(filters) { return Modal.open({ templateUrl : 'modules/multiple_payroll/modals/search.modal.html', - size : 'md', - animation : false, - keyboard : false, - backdrop : 'static', controller : 'MultiPayrollSearchModalController as $ctrl', resolve : { - filters : function filtersProvider() { return filters; }, + filters : () => filters, }, }).result; } diff --git a/client/src/modules/multiple_payroll/templates/action.tmpl.html b/client/src/modules/multiple_payroll/templates/action.tmpl.html index 1b8ef96b40..38b69c3d1b 100644 --- a/client/src/modules/multiple_payroll/templates/action.tmpl.html +++ b/client/src/modules/multiple_payroll/templates/action.tmpl.html @@ -1,19 +1,20 @@ -
- + \ No newline at end of file +
diff --git a/client/src/modules/purchases/templates/cellStatus.tmpl.html b/client/src/modules/purchases/templates/cellStatus.tmpl.html index baeec44a5e..e1026e2517 100644 --- a/client/src/modules/purchases/templates/cellStatus.tmpl.html +++ b/client/src/modules/purchases/templates/cellStatus.tmpl.html @@ -1,4 +1,4 @@ -
+
PURCHASES.STATUS.WAITING_CONFIRMATION
PURCHASES.STATUS.CONFIRMED
PURCHASES.STATUS.RECEIVED
diff --git a/server/controllers/payroll/multiplePayroll/find.js b/server/controllers/payroll/multiplePayroll/find.js index 5cbe99ccff..c7d2a580fe 100644 --- a/server/controllers/payroll/multiplePayroll/find.js +++ b/server/controllers/payroll/multiplePayroll/find.js @@ -8,7 +8,6 @@ const db = require('../../../lib/db'); const FilterParser = require('../../../lib/filter'); - function find(options) { // ensure epected options are parsed appropriately as binary @@ -33,7 +32,7 @@ function find(options) { payroll.working_day, payroll.total_day, payroll.daily_salary, payroll.amount_paid, payroll.status_id, payroll.status, (payroll.net_salary - payroll.amount_paid) AS balance FROM( - SELECT BUID(employee.uuid) AS employee_uuid, employee.reference, employee.code, employee.date_embauche, + SELECT BUID(employee.uuid) AS employee_uuid, em.text AS reference, employee.code, employee.date_embauche, employee.nb_enfant,employee.individual_salary, creditor_group.account_id, BUID(employee.creditor_uuid) AS creditor_uuid, UPPER(patient.display_name) AS display_name, patient.sex, BUID(paiement.uuid) AS uuid, @@ -42,6 +41,7 @@ function find(options) { paiement.net_salary, paiement.working_day, paiement.total_day, paiement.daily_salary, paiement.amount_paid, paiement.status_id, paiement_status.text AS status FROM employee + JOIN entity_map em ON employee.creditor_uuid = em.uuid JOIN creditor ON creditor.uuid = employee.creditor_uuid JOIN creditor_group ON creditor_group.uuid = creditor.group_uuid JOIN patient ON patient.uuid = employee.patient_uuid @@ -53,7 +53,7 @@ function find(options) { JOIN paiement_status ON paiement_status.id = paiement.status_id WHERE paiement.payroll_configuration_id = '${options.payroll_configuration_id}' UNION - SELECT BUID(employee.uuid) AS employee_uuid, employee.reference, employee.code, employee.date_embauche, + SELECT BUID(employee.uuid) AS employee_uuid, em.text as reference, employee.code, employee.date_embauche, employee.nb_enfant, employee.individual_salary, creditor_group.account_id, BUID(employee.creditor_uuid) AS creditor_uuid, UPPER(patient.display_name) AS display_name, patient.sex, NULL AS 'paiement_uuid', '${options.payroll_configuration_id}' AS payroll_configuration_id, @@ -62,6 +62,7 @@ function find(options) { 0 AS total_day, 0 AS daily_salary, 0 AS amount_paid, 1 AS status_id, 'PAYROLL_STATUS.WAITING_FOR_CONFIGURATION' AS status FROM employee + JOIN entity_map em ON employee.creditor_uuid = em.uuid JOIN creditor ON creditor.uuid = employee.creditor_uuid JOIN creditor_group ON creditor_group.uuid = creditor.group_uuid JOIN patient ON patient.uuid = employee.patient_uuid diff --git a/server/controllers/payroll/multiplePayroll/index.js b/server/controllers/payroll/multiplePayroll/index.js index bd27c31875..781111e719 100644 --- a/server/controllers/payroll/multiplePayroll/index.js +++ b/server/controllers/payroll/multiplePayroll/index.js @@ -10,8 +10,8 @@ * @requires db */ -const find = require('./find'); -const getConfig = require('./getConfig'); +const { find } = require('./find'); +const { getConfigurationData } = require('./getConfig'); const manageConfig = require('./manageConfig'); const setMultiConfiguration = require('./setMultiConfiguration'); @@ -23,7 +23,7 @@ const makeCommitment = require('./makeCommitment'); * @description search Payroll payments */ function search(req, res, next) { - find.find(req.query) + find(req.query) .then((rows) => { res.status(200).json(rows); }) @@ -35,7 +35,7 @@ function configuration(req, res, next) { const params = req.query; const payrollConfigurationId = req.params.id; - getConfig.getConfigurationData(payrollConfigurationId, params) + getConfigurationData(payrollConfigurationId, params) .then((rows) => { const dataManaged = manageConfig.manageConfigurationData(rows, params); res.status(200).json(dataManaged); From c341819699fe6b0ac88a8a3db4b3770e80c45222 Mon Sep 17 00:00:00 2001 From: Jonathan Niles Date: Thu, 30 Apr 2020 12:00:18 +0100 Subject: [PATCH 08/29] chore(employees): refactor registry & search modal Refactors significant amounts of the employee registry and search modal. Provides a better UI experience and standard HTML like the rest of our modules. --- .../src/modules/employees/employee.service.js | 14 +- .../modules/employees/registry/registry.js | 42 ++-- .../employees/registry/search.modal.html | 212 +++++++++--------- .../employees/registry/search.modal.js | 29 ++- .../employees/templates/action.cell.html | 2 +- 5 files changed, 143 insertions(+), 156 deletions(-) diff --git a/client/src/modules/employees/employee.service.js b/client/src/modules/employees/employee.service.js index 6883ba1393..7275539957 100644 --- a/client/src/modules/employees/employee.service.js +++ b/client/src/modules/employees/employee.service.js @@ -1,7 +1,9 @@ angular.module('bhima.services') .service('EmployeeService', EmployeeService); -EmployeeService.$inject = ['FilterService', '$uibModal', 'PrototypeApiService', 'appcache', 'LanguageService', '$httpParamSerializer']; +EmployeeService.$inject = [ + 'FilterService', '$uibModal', 'PrototypeApiService', 'appcache', 'LanguageService', '$httpParamSerializer', +]; /** * @class EmployeeService @@ -96,14 +98,8 @@ function EmployeeService(Filters, $uibModal, Api, AppCache, Languages, $httpPara function openSearchModal(params) { return $uibModal.open({ templateUrl : 'modules/employees/registry/search.modal.html', - size : 'md', - keyboard : false, - animation : false, - backdrop : 'static', controller : 'EmployeeRegistryModalController as ModalCtrl', - resolve : { - filters : function paramsProvider() { return params; }, - }, + resolve : { filters : () => params }, }).result; } @@ -118,7 +114,7 @@ function EmployeeService(Filters, $uibModal, Api, AppCache, Languages, $httpPara return $httpParamSerializer(options); } - // transform patient to employee + // transform patient to employee function patientToEmployee(data) { return service.$http.post(`/employees/patient_employee`, data) .then(service.util.unwrapHttpResponse); diff --git a/client/src/modules/employees/registry/registry.js b/client/src/modules/employees/registry/registry.js index 3bee59509d..601be1fc41 100644 --- a/client/src/modules/employees/registry/registry.js +++ b/client/src/modules/employees/registry/registry.js @@ -4,17 +4,18 @@ angular.module('bhima.controllers') EmployeeRegistryController.$inject = [ '$state', 'EmployeeService', 'NotifyService', 'AppCache', 'util', 'ReceiptModal', 'uiGridConstants', 'GridColumnService', 'bhConstants', - 'GridStateService', + 'GridStateService', 'GridSortingService', ]; /** * Employee Registry Controller * + * @description * This module is responsible for the management of Employe Registry. */ function EmployeeRegistryController( $state, Employees, Notify, AppCache, util, Receipts, uiGridConstants, Columns, - bhConstants, GridState + bhConstants, GridState, Sorting, ) { const vm = this; @@ -33,18 +34,17 @@ function EmployeeRegistryController( const columnDefs = [ { - field : 'code', - displayName : 'TABLE.COLUMNS.REGISTRATION_NUMBER', + field : 'reference', + displayName : 'TABLE.COLUMNS.REFERENCE', aggregationType : uiGridConstants.aggregationTypes.count, aggregationHideLabel : true, headerCellFilter : 'translate', footerCellClass : 'text-center', + sortingAlgorithm : Sorting.algorithms.sortByReference, }, { - field : 'reference', - displayName : 'TABLE.COLUMNS.REFERENCE', - aggregationType : uiGridConstants.aggregationTypes.count, - aggregationHideLabel : true, + field : 'code', + displayName : 'TABLE.COLUMNS.REGISTRATION_NUMBER', headerCellFilter : 'translate', footerCellClass : 'text-center', }, @@ -54,13 +54,6 @@ function EmployeeRegistryController( headerCellFilter : 'translate', sort : { direction : uiGridConstants.ASC, priority : 1 }, }, - { - field : 'locked', - displayName : 'FORM.LABELS.LOCKED', - headerCellFilter : 'translate', - width : 30, - cellTemplate : '/modules/employees/templates/locked.cell.html', - }, { field : 'is_medical', displayName : 'FORM.LABELS.MEDICAL_STAFF', @@ -154,6 +147,13 @@ function EmployeeRegistryController( headerCellFilter : 'translate', visible : false, }, + { + field : 'locked', + displayName : 'FORM.LABELS.LOCKED', + headerCellFilter : 'translate', + width : 30, + cellTemplate : '/modules/employees/templates/locked.cell.html', + }, { name : 'actions', displayName : '', @@ -162,7 +162,6 @@ function EmployeeRegistryController( }, ]; - /** TODO manage column : last_transaction */ vm.uiGridOptions = { appScopeProvider : vm, showColumnFooter : true, @@ -171,10 +170,7 @@ function EmployeeRegistryController( flatEntityAccess : true, fastWatch : true, columnDefs, - }; - - vm.uiGridOptions.onRegisterApi = function onRegisterApi(gridApi) { - vm.gridApi = gridApi; + onRegisterApi : (api) => { vm.gridApi = api; }, }; const columnConfig = new Columns(vm.uiGridOptions, cacheKey); @@ -197,10 +193,6 @@ function EmployeeRegistryController( Notify.handleError(error); } - function isEmpty(object) { - return Object.keys(object).length === 0; - } - // this function loads employees from the database with search parameters // if passed in. function load(parameters) { @@ -235,7 +227,7 @@ function EmployeeRegistryController( Employees.cacheFilters(); vm.latestViewFilters = Employees.filters.formatView(); - return load(Employees.filters.formatHTTP(true)); + load(Employees.filters.formatHTTP(true)); }); } diff --git a/client/src/modules/employees/registry/search.modal.html b/client/src/modules/employees/registry/search.modal.html index c5d26c8d04..87796d418d 100644 --- a/client/src/modules/employees/registry/search.modal.html +++ b/client/src/modules/employees/registry/search.modal.html @@ -4,133 +4,133 @@ data-modal="employee-search" novalidate> -