Skip to content

Commit

Permalink
chore: add subfolders for reports
Browse files Browse the repository at this point in the history
Adds subfolders for reports to each top-level module.

Closes Third-Culture-Software#4146
  • Loading branch information
jniles committed Jul 17, 2020
1 parent d8fd687 commit 430f7bf
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 19 deletions.
2 changes: 1 addition & 1 deletion client/src/js/components/bhNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ function NavigationController($location, $rootScope, Tree, AppCache, Notify, $tr
function loadTreeUnits() {
Tree.units()
.then(units => {

Tree.sortByTranslationKey(units);

$ctrl.units = units;

calculateUnitIndex($ctrl.units);
Expand Down
16 changes: 15 additions & 1 deletion client/src/js/services/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,27 @@ function Tree($http, $translate, util, TreeClass) {
.then(data => new TreeClass(data));
}

/** recursively sort an array of BHIMA units respecting translation keys. */
function hasChildren(unit) {
return unit.children && unit.children.length > 0;
}

/**
* @function sortByTranslationKey
*
* @description
* Recursively sort an array of BHIMA units respecting translation keys.
*
*/
function sortByTranslationKey(unitArray) {
if (angular.isUndefined(unitArray)) {
return;
}

unitArray.sort((a, b) => {
// push parents to the bottom of the list
if (hasChildren(a)) { return 1; }
if (hasChildren(b)) { return -1; }

const aValue = $translate.instant(a.key);
const bValue = $translate.instant(b.key);
return aValue.localeCompare(bValue);
Expand Down
34 changes: 17 additions & 17 deletions server/models/bhima.sql
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ INSERT INTO unit VALUES
(189, 'IPR Tax Configuration','TREE.IPR_TAX_CONFIGURATION','IPR Tax Configuration', 57,'/ipr_tax/configuration'),
(190, 'Payroll Rubric Configuration','TREE.PAYROLL_RUB_CONFIGURATION','',57,'/payroll/rubric_configuration'),
(191, 'Account Configuration','TREE.PAYROLL_ACCOUNT_CONFIGURATION','Account Configuration', 57,'/payroll/account_configuration'),
(192, 'Operating report', 'TREE.OPERATING_ACCOUNT', 'The report of operating', 144, '/reports/operating'),
(192, 'Operating Report', 'TREE.OPERATING_ACCOUNT', 'The report of operating', 144, '/reports/operating'),
(193, 'Weekend Configuration','TREE.WEEKEND_CONFIGURATION','Weekend Configuration', 57,'/payroll/weekend_configuration'),
(194, 'Payroll Configuration','TREE.PAYROLL_CONFIGURATION','Payroll Configuration', 57,'/payroll'),
(195, 'Role management','TREE.ROLE_MANAGEMENT','Roles Management', 1,'/roles'),
(195, 'Role Management','TREE.ROLE_MANAGEMENT','Roles Management', 1,'/roles'),
(197, 'Stock Exit Report','TREE.STOCK_EXIT_REPORT','Stock Exit Report', 144,'/reports/stock_exit'),
(199, 'Annual Clients Report', 'REPORT.CLIENTS.TITLE', 'Annual Clients Report', 144, '/reports/annual-clients-report'),
(200, 'Multiple Payroll','TREE.MULTI_PAYROLL','Multiple Payroll', 57,'/multiple_payroll'),
Expand All @@ -97,13 +97,13 @@ INSERT INTO unit VALUES
(209, 'Accounts Report Multiple','TREE.REPORTS_MULTIPLE_ACCOUNTS','',144,'/reports/account_report_multiple'),
(210, 'Unbalanced Invoice Payments','REPORT.UNPAID_INVOICE_PAYMENTS_REPORT.TITLE','',144,'/reports/unpaid-invoice-payments'),
(211, 'Income Expenses by Month', 'REPORT.PROFIT_AND_LOSS_BY_MONTH', 'The report of income and expenses', 144, '/reports/income_expense_by_month'),
(213, 'Stock value Report','TREE.STOCK_VALUE','',144,'/reports/stock_value'),
(213, 'Stock Value Report','TREE.STOCK_VALUE','',144,'/reports/stock_value'),
(214, '[OHADA] Compte de resultat','TREE.OHADA_RESULT_ACCOUNT','',144,'/reports/ohada_profit_loss'),
(216, 'Income Expenses by Year', 'REPORT.PROFIT_AND_LOSS_BY_YEAR', 'The report of income and expenses', 144, '/reports/income_expense_by_year'),
(217, 'Tags','TREE.TAGS','', 1,'/tags'),
(218, 'Fee Center Management','TREE.FEE_CENTER_MANAGEMENT','', 0,'/fee_center'),
(219, 'Fee Center Management','TREE.FEE_CENTER','', 218,'/fee_center'),
(220, 'Distributions fees Centers','TREE.DITRIBUTION_AUX_FEES_CENTERS','', 218,'/distribution_center'),
(220, 'Distributions Fee Centers','TREE.DITRIBUTION_AUX_FEES_CENTERS','', 218,'/distribution_center'),
(221, 'Update Distributions','TREE.UPDATE_DISTRIBUTION','', 218,'/distribution_center/update'),
(222, 'Fee Center Report', 'TREE.FEE_CENTER_REPORT', 'Fee Center Report', 144, '/reports/feeCenter'),
(223, 'Distribution keys', 'TREE.DISTRIBUTION_KEYS', 'Distribution keys', 218, '/distribution_center/distribution_key'),
Expand All @@ -113,7 +113,7 @@ INSERT INTO unit VALUES
(228, 'Ward Configurations', 'TREE.WARD_CONFIGURATION', 'Ward configuration module', 227, '/ward/configuration'),
(229, 'Visits Registry', 'TREE.VISITS_REGISTRY', 'Visits registry', 12, '/patients/visits'),
(230, 'Break Even Reference','TREE.BREAK_EVEN_REFERENCE','Break Even Reference', 1,'/break_even_reference'),
(231, 'Break-even Report', 'TREE.BREAK_EVEN_REPORT', 'Break-even Report', 144, '/reports/breakEven'),
(231, 'Break Even Report', 'TREE.BREAK_EVEN_REPORT', 'Break-even Report', 144, '/reports/breakEven'),
(232, 'Break Even By Fee Center', 'TREE.BREAK_EVEN_FEE_CENTER_REPORT', 'Break-even By Fee Center Report', 144, '/reports/breakEvenFeeCenter'),
(233, 'Dashboards Folder', 'TREE.DASHBOARDS.TITLE', 'Tableaux de bord', 0, '/DASHBOARDS_FOLDER'),
(234, 'Indicators Files Registry', 'TREE.DASHBOARDS.INDICATORS_FILES_REGISTRY', 'Registre des fiches des indicateurs', 233, '/dashboards/indicators_files_registry'),
Expand All @@ -127,32 +127,32 @@ INSERT INTO unit VALUES
(242, 'Entity Management','ENTITY.MANAGEMENT','',241,'/entities'),
(243, 'Entity Group', 'ENTITY.GROUP.TITLE', 'Entity Group', 241, '/entity_group'),
(244, 'Monthly Balance', 'TREE.MONTHLY_BALANCE', 'Monthly Balance', 144, '/reports/monthlyBalance'),
(245, 'Debtor summary report', 'REPORT.DEBTOR_SUMMARY.TITLE', 'Debtor summary report', 144, '/reports/debtorSummary'),
(246, 'Client debts report', 'TREE.CLIENT_DEBTS_REPORT', 'Client debts report', 144, '/reports/clientDebts'),
(247, 'Client support report', 'TREE.CLIENT_SUPPORT_REPORT', 'Client support report', 144, '/reports/clientSupport'),
(248, 'Analysis of cashboxes', 'REPORT.ANALYSIS_AUX_CASHBOXES.TITLE', 'Analysis of auxiliary cashboxes', 144, '/reports/analysisAuxiliaryCash'),
(245, 'Debtor Summary Report', 'REPORT.DEBTOR_SUMMARY.TITLE', 'Debtor summary report', 144, '/reports/debtorSummary'),
(246, 'Client Debts Report', 'TREE.CLIENT_DEBTS_REPORT', 'Client debts report', 144, '/reports/clientDebts'),
(247, 'Client Support Report', 'TREE.CLIENT_SUPPORT_REPORT', 'Client support report', 144, '/reports/clientSupport'),
(248, 'Analysis of Cashboxes', 'REPORT.ANALYSIS_AUX_CASHBOXES.TITLE', 'Analysis of auxiliary cashboxes', 144, '/reports/analysisAuxiliaryCash'),
(249, 'Realized Profit Report', 'TREE.REALIZED_PROFIT_REPORT', 'Realized profit report', 144, '/reports/realizedProfit'),
(250, 'Sytem usage statistic', 'REPORT.SYSTEM_USAGE_STAT.TITLE', 'Sytem usage statistic', 144, '/reports/systemUsageStat'),
(251, 'indexes', 'TREE.INDEXES','The payrall-index', 57,'/PAYROLL_INDEX_FOLDER'),
(250, 'System Usage Statistic', 'REPORT.SYSTEM_USAGE_STAT.TITLE', 'Sytem usage statistic', 144, '/reports/systemUsageStat'),
(251, 'Indexes', 'TREE.INDEXES','The payroll index', 57,'/PAYROLL_INDEX_FOLDER'),
(252, 'Staffing indexes management','TREE.STAFFING_INDICES_MANAGEMENT','Staffing indices management',251 ,'/staffing_indices'),
(253, 'Multiple Payroll by indice','TREE.MULTI_PAYROLL_INDICE','Multiple Payroll (indice)', 251,'/multiple_payroll_indice'),
(253, 'Multiple Payroll by Indice','TREE.MULTI_PAYROLL_INDICE','Multiple Payroll (indice)', 251,'/multiple_payroll_indice'),
(254, 'Data Collection', 'TREE.DATA_COLLECTION', '', 0, '/data_collection'),
(255, 'Fill Form', 'TREE.FILL_FORM', '', 254, '/fill_form'),
(256, 'Display Metadata', 'TREE.DISPLAY_METADATA', '', 254, '/display_metadata'),
(257, 'Data Kit', 'TREE.DATA_KIT', 'Data Kit', 254, '/data_kit'),
(258, 'Data Collector Management', 'TREE.FORMS_MANAGEMENT', '', 257, '/data_collector_management'),
(259, 'Choices list management', 'TREE.CHOICES_LIST_MANAGEMENT', '', 257, '/choices_list_management'),
(259, 'Choices List Management', 'TREE.CHOICES_LIST_MANAGEMENT', '', 257, '/choices_list_management'),
(260, 'Survey Form', 'TREE.FORMS_CONFIGURATION', '', 257, '/survey_form'),
(261, 'Data Kit Report', 'TREE.DATA_KIT_REPORT', 'Data Kit Report', 144, '/reports/dataKit'),
(262, 'Stock Requisition','TREE.STOCK_REQUISITION','Stock Requisition', 160,'/stock/requisition'),
(263, 'Configuration Analysis Tools','TREE.CONFIGURATION_ANALYSIS_TOOLS','Configuration Analysis Tools', 1,'/configuration_analysis_tools'),
(264, 'Configurable Analysis Report','TREE.CONFIGURABLE_ANALYSIS_REPORT','Configurable Analysis Report', 144,'/reports/configurable_analysis_report'),
(265, 'Purchase order analysis', 'TREE.PURCHASE_ORDER_ANALYSIS', 'Purchase order analysis', 144, '/reports/purchaseOrderAnalysis'),
(265, 'Purchase Order Analysis', 'TREE.PURCHASE_ORDER_ANALYSIS', 'Purchase order analysis', 144, '/reports/purchaseOrderAnalysis'),
(266, 'Inventory Changes Report', 'REPORT.INVENTORY_CHANGE.TITLE', 'Inventory Changes Report', 144, '/reports/inventoryChanges'),
(267, 'Monthly consumption report', 'TREE.MONTHLY_CONSUMPTION', 'Monthly consumption report', 144, '/reports/monthlyConsumptionReport'),
(268, '[Stock] Consumption graph','TREE.STOCK_CONSUMPTION_GRAPH_REPORT','Stock Consumption graph report', 144,'/reports/stock_consumption_graph_report'),
(267, 'Monthly Consumption Report', 'TREE.MONTHLY_CONSUMPTION', 'Monthly consumption report', 144, '/reports/monthlyConsumptionReport'),
(268, '[Stock] Consumption Graph','TREE.STOCK_CONSUMPTION_GRAPH_REPORT','Stock Consumption graph report', 144,'/reports/stock_consumption_graph_report'),
(269, 'Inventory Adjustment', 'TREE.INVENTORY_ADJUSTMENT', 'Inventory Adjustment', 160, '/stock/inventory-adjustment'),
(270, 'compare invoiced to received','TREE.COMPARE_INVOICED_RECEIVED','Compare invoiced items to received stock', 144,'/reports/invoicedReceivedStock'),
(270, 'Compare Invoiced to Received','TREE.COMPARE_INVOICED_RECEIVED','Compare invoiced items to received stock', 144,'/reports/invoicedReceivedStock'),
(271, 'Collection Capacity Report', 'TREE.COLLECTION_CAPACITY_REPORT', 'Collection Capacity Report', 144, '/reports/collectionCapacity');

-- Reserved system account type
Expand Down
1 change: 1 addition & 0 deletions server/models/migrations/next/migrate.sql
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,4 @@ ALTER TABLE `province` DROP INDEX `province_1`;
ALTER TABLE `sector` DROP INDEX `sector_1`;

ALTER TABLE `village` DROP INDEX `village_1`;

191 changes: 191 additions & 0 deletions server/models/migrations/next/units.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
/*
Migration of the unit IDs to put reports in proper folders.
*/

INSERT IGNORE INTO unit (`id`, `name`, `key`, `description`, `parent`, `path`) VALUES
(280, 'Hospital Reports', 'TREE.REPORTS', 'reports for the hospital modules', 12, '/HOSPITAL_FOLDER/reports'),
(281, 'Finance Reports', 'TREE.REPORTS', 'reports for the accounting/finance module', 5, '/FINANCE_FOLDER/reports'),
(282, 'Stock Reports', 'TREE.REPORTS', 'reports for the stock modules', 160, '/STOCK_FOLDER/reports'),
(283, 'HR Reports', 'TREE.REPORTS', 'reports for the HR/Payroll modules', 57, '/PAYROLL_FOLDER/reports'),
(284, 'Data Kit Reports', 'TREE.REPORTS', 'reports for the data collection modules', 254, '/data_collection/reports'),
(285, 'Purchase Reports', 'TREE.REPORTS', 'reports for the purchasing modules', 154, '/PURCHASE_FOLDER/reports'),
(286, 'Fee Center Reports', 'TREE.REPORTS', 'reports for the fee center modules', 218, '/fee_center/reports'),
(287, 'Inventory Reports', 'TREE.REPORTS', 'reports for the inventory modules', 218, '/inventory/reports');

-- FINANCE

-- Cash Flow
UPDATE `unit` SET `parent` = 281 WHERE id = 145;

-- Cash Report
UPDATE `unit` SET `parent` = 281 WHERE id = 149;

-- Balance Sheet Report
UPDATE `unit` SET name = "Balance Sheet", `parent` = 281 WHERE id = 150;

-- Aged Debtors Report
UPDATE `unit` SET name = "Aged Debtors", `parent` = 281 WHERE id = 151;

-- Account Report
UPDATE `unit` SET `parent` = 281 WHERE id = 152;

-- Cashflow by Service
UPDATE `unit` SET `parent` = 281 WHERE id = 153;

-- Open Debtors
UPDATE `unit` SET `parent` = 281 WHERE id = 157;

-- Aged Creditors
UPDATE `unit` SET `parent` = 281 WHERE id = 168;

-- Account Statement (Simple)
UPDATE `unit` SET `parent` = 281 WHERE id = 170;

-- Profit and Loss Statement
UPDATE `unit` SET name = "Profit & Loss Statement", `parent` = 281 WHERE id = 180;

-- Compte d'Exploitation (PCGC P&L)
UPDATE `unit` SET name = "Operating Accounts Report", `parent` = 281 WHERE id = 192;

-- Annual Clients Report
UPDATE `unit` SET `parent` = 281 WHERE id = 199;

-- Bilan (OHADA Balance Sheet
UPDATE `unit` SET `parent` = 281 WHERE id = 206;

-- Account References Report
UPDATE `unit` SET `parent` = 281 WHERE id = 207;

-- Account Statement (Multiple)
UPDATE `unit` SET `parent` = 281 WHERE id = 209;

-- Monthly Analysis of Balance
UPDATE `unit` SET name = "Monthly Analysis of Balance", `parent` = 281 WHERE id = 244;

-- Unpaid/Unbalanced Invoices Report
UPDATE `unit` SET `parent` = 281 WHERE id = 210;

-- Proft and Loss by Month
UPDATE `unit` SET name = "Profit & Loss by Month", `parent` = 281 WHERE id = 211;

-- Compte de Resultat (OHADA P&L)
UPDATE `unit` SET `parent` = 281 WHERE id = 214;

-- Profit and Loss by Year
UPDATE `unit` SET name = "Profit & Loss by Year", `parent` = 281 WHERE id = 216;

-- Monthly Analysis of the Balance Sheet
UPDATE `unit` SET name = "Monthly Analysis of Balance", `parent` = 281 WHERE id = 244;

-- Debtor Summary Report
UPDATE `unit` SET `parent` = 281 WHERE id = 245;

-- Client Debts Report
UPDATE `unit` SET `parent` = 281 WHERE id = 246;

-- Debtor Summary Report
UPDATE `unit` SET `parent` = 281 WHERE id = 245;

-- Client Debts Report
UPDATE `unit` SET `parent` = 281 WHERE id = 246;

-- Client Support Report
UPDATE `unit` SET `parent` = 281 WHERE id = 247;

-- Analysis of Auxiliary Cashboxes
UPDATE `unit` SET `parent` = 281 WHERE id = 248;

-- Realized Profit Report
UPDATE `unit` SET `parent` = 281 WHERE id = 249;

-- Recovery Capacity Report
UPDATE `unit` SET name = "Recovery Capacity Report", `parent` = 281 WHERE id = 271;

-- Configurable Analysis Tools Report
UPDATE `unit` SET `parent` = 281 WHERE id = 264;

-- HOSPITAL REPORTS

-- Patient Standing Report
UPDATE `unit` SET `parent` = 280 WHERE id = 202;

-- Visit Report
UPDATE `unit` SET `parent` = 280 WHERE id = 239;

-- System Usage Statistics
UPDATE `unit` SET `parent` = 280 WHERE id = 250;

-- STOCK REPORTS

-- stock report
UPDATE `unit` SET `parent` = 282 WHERE id = 181;

-- stock sheet report
UPDATE `unit` SET `parent` = 282 WHERE id = 182;

-- stock exit report
UPDATE `unit` SET `parent` = 282 WHERE id = 197;

-- stock value report
UPDATE `unit` SET `parent` = 282 WHERE id = 213;

-- stock entry report
UPDATE `unit` SET `parent` = 282 WHERE id = 240;

-- monthly consumption report
UPDATE `unit` SET `parent` = 282 WHERE id = 267;

-- Consumption Graph
UPDATE `unit` SET `parent` = 282 WHERE id = 268;

-- Compare Invoiced to Received Report
UPDATE `unit` SET `parent` = 282 WHERE id = 270;

-- HR REPORTS

-- Employee Standing Report
UPDATE `unit` SET `parent` = 283 WHERE id = 201;

-- Data Kit Reports

-- Data Collect Report
UPDATE `unit` SET `parent` = 284 WHERE id = 261;

-- PURCHASE REPORTS

-- Purchase Order Analysis
UPDATE `unit` SET `parent` = 285 WHERE id = 265;

-- FEE CENTER REPORTS

-- Fee Center Report
UPDATE `unit` SET `parent` = 286 WHERE id = 222;

-- Break Even Report
UPDATE `unit` SET `parent` = 286 WHERE id = 231;

-- Break Even By Fee Center Report
UPDATE `unit` SET `parent` = 286 WHERE id = 232;

-- Indicator Report
UPDATE `unit` SET `parent` = 286 WHERE id = 238;

-- INVENTORY REPORTS

-- Inventory Changes Report
UPDATE `unit` SET `parent` = 287 WHERE id = 266;


-- remove previous report folder
DELETE FROM role_unit where unit_id = 144;
DELETE FROM unit WHERE id = 144;

-- update roles to reflect new permissions
CREATE TEMPORARY TABLE ru AS
SELECT DISTINCT role_uuid, unit.parent as `unit_id` FROM role_unit JOIN unit ON role_unit.unit_id = unit.id;

ALTER TABLE `role_unit` ADD CONSTRAINT `tmp_ru_unique_key` UNIQUE (`role_uuid`, `unit_id`);

INSERT IGNORE INTO `role_unit` SELECT HUID(uuid()), role_uuid, unit_id FROM ru;

ALTER TABLE `role_unit` DROP KEY `tmp_ru_unique_key`;

0 comments on commit 430f7bf

Please sign in to comment.