From fc5e060269fdbd517a2f0967ba9600001820363f Mon Sep 17 00:00:00 2001 From: lomamech Date: Mon, 2 Dec 2024 20:25:50 +0100 Subject: [PATCH] - Fixed display error in the Cashflow report. - Added a new summary section to improve budget report. closes #7897 --- client/src/i18n/en/form.json | 1 + client/src/i18n/en/report.json | 3 + client/src/i18n/en/table.json | 4 + client/src/i18n/en/vouchers.json | 1 + client/src/i18n/fr/form.json | 1 + client/src/i18n/fr/report.json | 3 + client/src/i18n/fr/table.json | 4 + client/src/i18n/fr/vouchers.json | 1 + .../budget_report/budget_report.config.js | 18 +++ .../generate/budget_report/budget_report.html | 15 ++ .../reports/generate/cashflow/cashflow.html | 9 ++ .../reports/budget_analytical/index.js | 129 +++++++++++++++++- .../budget_analytical/report.handlebars | 93 ++++++++++--- .../finance/reports/cashflow/index.js | 22 ++- .../reports/cashflow/reportGlobal.handlebars | 2 +- .../cashflow/reportSynthetic.handlebars | 2 +- server/models/06-bhima.sql | 6 +- server/models/migrations/next/migrate.sql | 8 ++ test/integration/accountReferenceType.js | 2 +- test/integration/transactionType.js | 2 +- 20 files changed, 301 insertions(+), 25 deletions(-) diff --git a/client/src/i18n/en/form.json b/client/src/i18n/en/form.json index 289ff25710..0f8054d1e0 100644 --- a/client/src/i18n/en/form.json +++ b/client/src/i18n/en/form.json @@ -369,6 +369,7 @@ "BILLING_DATE": "Billing Date", "BREAK_EVEN": "Break Even", "BUDGET": "Budget", + "BUDGET_ANALYSIS": "Budget analysis", "BULK_QUANTITY": "Bulk quantity", "BY": "by", "BY_ID": "By Id", diff --git a/client/src/i18n/en/report.json b/client/src/i18n/en/report.json index b2b8698199..afff3a012c 100644 --- a/client/src/i18n/en/report.json +++ b/client/src/i18n/en/report.json @@ -59,12 +59,14 @@ "EXPENSES": "Expenses", "HIDE_TITLE_ACCOUNT": "Hide Title Account", "HIDE_UNUSED_ACCOUNTS": "Hide Unused Accounts or Accounts with Zero Values", + "INCLUDE_SUMMARY_SECTION": "Include summary section", "MAX_5_YEAR": "Please note that the budget analysis period is limited to a maximum of 5 years.", "PERCENTAGE_VARIATION_COMPARED": "Percentage Variation Compared to the Budget", "REALIZATION" : "Actuals", "REVENUS": "Income", "SET_NUMBER_YEAR": "Set the Number of Years for Analysis", "SHOW_ONLY_TITLE_ACCOUNT": "Display Only the Title Account", + "SUMMARY_SECTION": "Summary section", "VARIATION_IN_AMOUNT": "Variation in Amount" }, "BY_ASC": "By Ascending Order", @@ -135,6 +137,7 @@ "TITLE": "Configurable Analysis Report" }, "CONFIGURATION": "Report Configuration", + "CONSIDER_TRANSFER_MOVEMENTS_REVENUE": "Consider transfer movements as revenue.", "DELETE": "Delete Report", "DOWNLOAD": "Download", "EMPLOYEE_STANDING": { diff --git a/client/src/i18n/en/table.json b/client/src/i18n/en/table.json index e76d28ba7a..4404020c6d 100644 --- a/client/src/i18n/en/table.json +++ b/client/src/i18n/en/table.json @@ -152,6 +152,7 @@ "LAST_PAYMENT": "Last Payment", "LISTS": "Registered price list", "LOADING": "Fetching data from the server.", + "LOCAL_CASH_REVENUES": "Local Cash Revenues", "LOCKED": "Locked", "LOCKEDQ": "Locked?", "LOT": "Lot / Batch", @@ -228,6 +229,7 @@ "RESULT": "Result", "RESULTS": "Results", "RESULT_ACCOUNT_SCT": "Result Account section", + "RESULT_WITHOUT_ACCOUNTS": "Result Without Accounts:", "RUBRICS": "Rubrics", "SEE_SITUATION_ALL_EMPLOYEES": "See the overall situation of all employees", "SECTOR": "Sector", @@ -258,9 +260,11 @@ "TOTAL_DEBT": "Total Debt", "TOTAL_DISTRIBUTE": "Total Distributions", "TOTAL_DISTRIBUTION_COST": "Total distribution cost", + "TOTAL_FINANCEMENT": "Total financement", "TOTAL_GENERAL": "Total General", "TOTAL_INVOICE": "Total invoice", "TOTAL_MEDICAL_CARE_EMPLOYEE": "Total medical care provided to the employee", + "TOTAL_SUBSIDIES": "Total subsidies", "TOTAL_UNICORPORATED_CHARGE": "Total unincorporated cost", "TOTAL_UNICORPORARED_PRODUCT": "Total unincorporated product", "TRANSACTION": "Transaction", diff --git a/client/src/i18n/en/vouchers.json b/client/src/i18n/en/vouchers.json index 945f7e7612..0da21d08df 100644 --- a/client/src/i18n/en/vouchers.json +++ b/client/src/i18n/en/vouchers.json @@ -80,6 +80,7 @@ "SUPPORT_INCOME": "Support Incomes", "TITLE": "Simple Voucher", "TRANSFER": "Money Transfer", + "TRANSFER_MONEY_DISBURSEMENT": "Money Disbursement", "TRANSFER_PATIENT_INVOICE_AMOUNT": "Patient Invoice Debt Transfer", "STOCK_INTEGRATION" : "Stock Integration", "STOCK_EXIT":"Stock Exit", diff --git a/client/src/i18n/fr/form.json b/client/src/i18n/fr/form.json index ff71ed313b..ee5664b6d2 100644 --- a/client/src/i18n/fr/form.json +++ b/client/src/i18n/fr/form.json @@ -372,6 +372,7 @@ "BILLING_DATE": "Date Facturation", "BREAK_EVEN": "Seuil de rentabilité", "BUDGET": "Budget", + "BUDGET_ANALYSIS": "Analyse du budget", "BULK_QUANTITY": "Quantité en vrac", "BY_ID": "Par id", "BY_NAME": "Par nom", diff --git a/client/src/i18n/fr/report.json b/client/src/i18n/fr/report.json index 4996fffc02..7864024cba 100644 --- a/client/src/i18n/fr/report.json +++ b/client/src/i18n/fr/report.json @@ -59,12 +59,14 @@ "EXPENSES": "Dépenses", "HIDE_TITLE_ACCOUNT": "Cacher le compte de titre", "HIDE_UNUSED_ACCOUNTS": "Cacher le compte non utilisé ou dont les valeurs sont égales à zéro", + "INCLUDE_SUMMARY_SECTION": "Inclure une section récapitulative", "MAX_5_YEAR": "Veuillez noter que la période d'analyse budgétaire est limitée à un maximum de 5 années.", "PERCENTAGE_VARIATION_COMPARED": "Variation en pourcentage par rapport au budget", "REALIZATION" : "Réalisation", "REVENUS": "Revenus", "SET_NUMBER_YEAR": "Définir le Nombre d'années pour l'Analyse", "SHOW_ONLY_TITLE_ACCOUNT": "Afficher uniquement le compte de titre", + "SUMMARY_SECTION": "Section récapitulative", "VARIATION_IN_AMOUNT": "Variation en chiffre" }, "BY_ASC": "Par ordre croissant", @@ -117,6 +119,7 @@ "TITLE": "Rapport d'analyse configurable" }, "CONFIGURATION" : "Configuration rapport", + "CONSIDER_TRANSFER_MOVEMENTS_REVENUE": "Considérer les mouvements de transfert comme des recettes.", "DELETE" : "Supprimer un rapport", "DOWNLOAD" : "Télécharger", "EMPLOYEE_STANDING" : { diff --git a/client/src/i18n/fr/table.json b/client/src/i18n/fr/table.json index 1bf7c19d20..bb488d5bfa 100644 --- a/client/src/i18n/fr/table.json +++ b/client/src/i18n/fr/table.json @@ -152,6 +152,7 @@ "LAST_PAYMENT": "Derniere Paiement", "LISTS": "Liste des prix enregistrés", "LOADING": "Récupération des données à partir du serveur.", + "LOCAL_CASH_REVENUES": "Recettes locales", "LOCKED": "Bloquée", "LOCKEDQ": "Bloquée ?", "LONGITUDE": "Longitude", @@ -228,6 +229,7 @@ "RESULT": "Résultat", "RESULTS": "Résultats", "RESULT_ACCOUNT_SCT": "Section Compte Résultat", + "RESULT_WITHOUT_ACCOUNTS": "Résultat sans les comptes:", "RUBRICS": "Rubriques", "SEE_SITUATION_ALL_EMPLOYEES": "Voir la situation globale de tous les employés", "SECTOR": "Secteur", @@ -259,8 +261,10 @@ "TOTAL_GENERAL": "Total général", "TOTAL_DISTRIBUTE": "Total de répartition", "TOTAL_DISTRIBUTION_COST": "Total du coût de la distribution", + "TOTAL_FINANCEMENT": "Total financement", "TOTAL_INVOICE": "Total de la facture", "TOTAL_MEDICAL_CARE_EMPLOYEE": "Total des soins médicaux accordés à l'employé", + "TOTAL_SUBSIDIES": "Total subventions", "TOTAL_UNICORPORATED_CHARGE": "Total charge non incorporé", "TOTAL_UNICORPORARED_PRODUCT": "Total produit non incorporé", "TRANSACTION": "Transaction", diff --git a/client/src/i18n/fr/vouchers.json b/client/src/i18n/fr/vouchers.json index c3f26dedee..bec978f58f 100644 --- a/client/src/i18n/fr/vouchers.json +++ b/client/src/i18n/fr/vouchers.json @@ -80,6 +80,7 @@ "SUPPORT_INCOME": "Paiement Prise en charge", "TITLE": "Bordereau de transfert", "TRANSFER": "Transfert d'argent", + "TRANSFER_MONEY_DISBURSEMENT": "Transfert: Décaissement d'argent", "TRANSFER_PATIENT_INVOICE_AMOUNT": "Prise en Charge de Facture de Patient", "STOCK_INTEGRATION" : "Intégration Stock", "STOCK_EXIT":"Sortie de stock", diff --git a/client/src/modules/reports/generate/budget_report/budget_report.config.js b/client/src/modules/reports/generate/budget_report/budget_report.config.js index be2f112b93..cd5cf8fd5d 100644 --- a/client/src/modules/reports/generate/budget_report/budget_report.config.js +++ b/client/src/modules/reports/generate/budget_report/budget_report.config.js @@ -16,6 +16,8 @@ function BudgetReportController($sce, Notify, SavedReports, AppCache, reportData filter : 'default', }; + vm.reportDetails.include_summary_section = 0; + vm.previewGenerated = false; checkCachedConfiguration(); @@ -31,6 +33,18 @@ function BudgetReportController($sce, Notify, SavedReports, AppCache, reportData vm.reportDetails = angular.copy(report); }; + vm.onChangeIncludeSection = value => { + if (value === 0) { + vm.reportDetails.cashboxesIds = []; + } + + vm.reportDetails.include_summary_section = value; + }; + + vm.onSelectCashboxes = (cashboxesIds) => { + vm.reportDetails.cashboxesIds = cashboxesIds; + }; + vm.numberYears = [ { id : 1 }, { id : 2 }, { id : 3 }, { id : 4 }, { id : 5 }, ]; @@ -38,6 +52,10 @@ function BudgetReportController($sce, Notify, SavedReports, AppCache, reportData vm.preview = function preview(form) { if (form.$invalid) { return null; } + if (vm.reportDetails.include_summary_section === 0) { + vm.reportDetails.cashboxesIds = []; + } + // update cached configuration cache.reportDetails = angular.copy(vm.reportDetails); diff --git a/client/src/modules/reports/generate/budget_report/budget_report.html b/client/src/modules/reports/generate/budget_report/budget_report.html index feb3215adc..9ed34c9d24 100644 --- a/client/src/modules/reports/generate/budget_report/budget_report.html +++ b/client/src/modules/reports/generate/budget_report/budget_report.html @@ -76,6 +76,21 @@

REPORT.BUDGET_REPORT.TITLE

+ + + +
+ + +
+ REPORT.UTIL.PREVIEW diff --git a/client/src/modules/reports/generate/cashflow/cashflow.html b/client/src/modules/reports/generate/cashflow/cashflow.html index dd147361c0..69c8318b56 100644 --- a/client/src/modules/reports/generate/cashflow/cashflow.html +++ b/client/src/modules/reports/generate/cashflow/cashflow.html @@ -36,6 +36,15 @@

REPORT.CASHFLOW.TITLE

required="true"> +
+
+ +
+
+
diff --git a/server/controllers/finance/reports/cashflow/index.js b/server/controllers/finance/reports/cashflow/index.js index 28e2938811..f6643990ef 100644 --- a/server/controllers/finance/reports/cashflow/index.js +++ b/server/controllers/finance/reports/cashflow/index.js @@ -185,6 +185,8 @@ function report(req, res, next) { const options = _.clone(req.query); const data = {}; + const isTransferAsRevenue = parseInt(options.is_transfer_as_revenue, 10); + const checkDetailledOption = ((options.modeReport === 'associated_account') || (options.modeReport === 'global_analysis') || (options.modeReport === 'synthetic_analysis') @@ -324,7 +326,7 @@ function report(req, res, next) { SELECT a.number AS account_number, a.label AS account_label, SUM(gl.credit_equiv - gl.debit_equiv) AS balance, - gl.transaction_type_id, tt.type AS transaction_type, tt.text AS transaction_text, + gl.transaction_type_id, tt.type AS transaction_type, IF(tt.type = 5, 'income', tt.text) AS transaction_text, gl.account_id, gl.period_id FROM general_ledger AS gl JOIN account AS a ON a.id = gl.account_id @@ -381,6 +383,24 @@ function report(req, res, next) { return db.exec(queryRun, paramsRun); }) .then(rows => { + // FIXME: @lomamech + // that this is an IMCK-specific hack + // When the isTransferAsRevenue option is enabled, + // all transfers (transactions with transaction_type_id === 5) + // are treated as income by updating their transaction_type to 'income'. + if (isTransferAsRevenue) { + // eslint-disable-next-line no-param-reassign + rows = rows.map(item => { + if (item.transaction_type_id === 5) { + return { + ...item, + transaction_type : 'income', + }; + } + return item; + }); + } + if ((options.modeReport !== 'global_analysis') && (options.modeReport !== 'synthetic_analysis')) { const incomes = _.chain(rows).filter({ transaction_type : 'income' }).groupBy('transaction_text').value(); const expenses = _.chain(rows).filter({ transaction_type : 'expense' }).groupBy('transaction_text').value(); diff --git a/server/controllers/finance/reports/cashflow/reportGlobal.handlebars b/server/controllers/finance/reports/cashflow/reportGlobal.handlebars index 3dc24157f9..cb7b208b20 100644 --- a/server/controllers/finance/reports/cashflow/reportGlobal.handlebars +++ b/server/controllers/finance/reports/cashflow/reportGlobal.handlebars @@ -74,7 +74,7 @@ {{translate key}} {{#each ../periods as |period| }} - {{debcred (look ../../incomeGlobalsTotalByincomeGlobalsTextKeys key period) ../../metadata.enterprise.currency_id}} + {{debcred (look ../../incomeGlobalsTotalByTextKeys key period) ../../metadata.enterprise.currency_id}} {{/each}} diff --git a/server/controllers/finance/reports/cashflow/reportSynthetic.handlebars b/server/controllers/finance/reports/cashflow/reportSynthetic.handlebars index 4b72936922..8a818c9637 100644 --- a/server/controllers/finance/reports/cashflow/reportSynthetic.handlebars +++ b/server/controllers/finance/reports/cashflow/reportSynthetic.handlebars @@ -87,7 +87,7 @@ {{translate key}} {{#each ../periods as |period| }} - {{debcred (look ../../incomeGlobalsTotalByincomeGlobalsTextKeys key period) ../../metadata.enterprise.currency_id}} + {{debcred (look ../../incomeGlobalsTotalByTextKeys key period) ../../metadata.enterprise.currency_id}} {{/each}} {{/each}} diff --git a/server/models/06-bhima.sql b/server/models/06-bhima.sql index 4812dc928b..a4b5850322 100644 --- a/server/models/06-bhima.sql +++ b/server/models/06-bhima.sql @@ -354,7 +354,8 @@ INSERT IGNORE INTO `transaction_type` (`text`, `type`, `fixed`) VALUES ('VOUCHERS.SIMPLE.PROVISIONING_PRINCIPAL', 'income', 1), ('VOUCHERS.SIMPLE.TRANSFER_FUNDS_BANKS', 'expense', 1), ('VOUCHERS.SIMPLE.EXIT_FUNDS_BANK', 'expense', 1), - ('VOUCHERS.SIMPLE.BANK_CASH_APPROVALS', 'income', 1); + ('VOUCHERS.SIMPLE.BANK_CASH_APPROVALS', 'income', 1), + ('VOUCHERS.SIMPLE.TRANSFER_MONEY_DISBURSEMENT', 'expense', 1); -- Stock Movement Flux INSERT IGNORE INTO `flux` VALUES @@ -451,7 +452,8 @@ INSERT IGNORE INTO `account_reference_type` (`id`, `label`, `fixed`) VALUES (4, 'FORM.LABELS.BREAK_EVEN', 1), (5, 'FORM.LABELS.ANALYSIS_TOOLS.TITLE', 1), (6, 'FORM.LABELS.INCOME_CASH_FLOW', 1), -(7, 'FORM.LABELS.EXPENSE_CASH_FLOW', 1); +(7, 'FORM.LABELS.EXPENSE_CASH_FLOW', 1), +(8, 'FORM.LABELS.BUDGET_ANALYSIS', 1); -- Default Discharge types INSERT IGNORE INTO `discharge_type` (`id`, `label`) VALUES diff --git a/server/models/migrations/next/migrate.sql b/server/models/migrations/next/migrate.sql index f0f66d30f3..5ade73037f 100644 --- a/server/models/migrations/next/migrate.sql +++ b/server/models/migrations/next/migrate.sql @@ -5,3 +5,11 @@ ALTER TABLE `debtor_group` MODIFY `email` VARCHAR(150) DEFAULT ''; ALTER TABLE `enterprise` MODIFY `email` VARCHAR(150) DEFAULT NULL; ALTER TABLE `supplier` MODIFY `email` VARCHAR(150) DEFAULT NULL; ALTER TABLE `user` MODIFY `email` VARCHAR(150) DEFAULT NULL; + +/* + * @author: lomamech + * @date: 2024-11-27 + * @description: Fix and Update Cashflow Report and Budget Report #7897 + */ + +INSERT INTO `account_reference_type` (`id`, `label`, `fixed`) VALUES (8, 'FORM.LABELS.BUDGET_ANALYSIS', 1); diff --git a/test/integration/accountReferenceType.js b/test/integration/accountReferenceType.js index 1a34f376ad..67b57a272d 100644 --- a/test/integration/accountReferenceType.js +++ b/test/integration/accountReferenceType.js @@ -3,7 +3,7 @@ const helpers = require('./helpers'); describe('test/integration/accountReferenceType Account Reference Type API', () => { - const numAccountReferenceType = 7; + const numAccountReferenceType = 8; const newAccountReferenceType = { label : 'Test Account Reference Type', diff --git a/test/integration/transactionType.js b/test/integration/transactionType.js index beba84b4c6..e25da04850 100644 --- a/test/integration/transactionType.js +++ b/test/integration/transactionType.js @@ -5,7 +5,7 @@ const helpers = require('./helpers'); describe('test/integration/transactionType Transaction Type API', () => { // default number of transaction type (TT) - const TT_DEFAULT = 25; + const TT_DEFAULT = 26; const newTT = { text : 'My New Transaction Type',