-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix cashflow report improve budget report #7900
base: master
Are you sure you want to change the base?
Fix cashflow report improve budget report #7900
Conversation
10b12c4
to
3820350
Compare
Here is a PR correcting the Display error on the Cashflow report and adding the summary section on the Budget report |
Can you remove the yarn.lock file? Also, your migration SQL file refers to tables that do not exist. |
7bcae6e
to
19daa52
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested this yet with any live data, but here is a review of the code.
There are a few things that should be caught before submitting a PR, like the missing translation tokens, the removal of yarn.lock
, and the migration file hard coding the name of a database.
There are a lot of decisions I didn't understand, such as changing the transaction type "TRANSFER" to income
. That shouldn't have been done without an issue explaining why all the sites (Vanga, Sona Bata, Bandunduville) need to change their transfer transaction types to income
. Then we could all discuss why this makes sense or doesn't make sense, but I'm alarmed that it was just slipped in without even a mention in the PR description.
client/src/modules/reports/generate/budget_report/budget_report.config.js
Outdated
Show resolved
Hide resolved
|
||
const fiscalYear = await Fiscal.lookupFiscalYear(fiscalYearId); | ||
|
||
if (includeSummarySection) { | ||
const cashboxesIds = _.values(params.cashboxesIds); | ||
const dataCashboxes = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does dataCashboxes need to be an object? It seems like you could just work with the values directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right
let firstIncomeConfigurationReferences = 0; | ||
let secondIncomeConfigurationReferences = 0; | ||
|
||
if (includeSummarySection) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you help me understand this block of code? Why are the first two lines being treated differently?
And where is the ORDER BY
or sort()
command that guarantees the order they come out in? Because it could be random.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section is really a hack, Summary section is presented as follows
This section is really a hack, Summary section is presented as follows, Result equals the difference between the total of Income Total - Expenses Total, Result Without Accounts: : 71, 75, 77 and Result Without Accounts: : 71 should evaluate the result without the sum of the balance of the following accounts 71, 75 and 77 but the challenge I had was to obtain the balance of these specific accounts, that's why I had opted for using the account references by adding the Budget Analysis type account references and when creating the references I made the first grouping 71, 75 and 77 and the second 71 (also equivalent to grants)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am worried this will break in the future without a deterministic ordering. Is there any way we can make sure this data is sorted in the correct display order before merging?
As an example, suppose that MySQL gets an update that makes the shorter group_concat()
strings be put first. Or suppose a production server crashes and we need to restore it from backup, and it reorders the data. I think this should have some sorting/ordering to make sure that doesn't happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
referen
@jniles After trying to make the summary section dynamic, I encountered the following constraint: how to distinguish the value of the subsidies represented by account 71 in the configuration?
Because in the current configuration I have configured the account references so that the subsidies are associated with the second reference, while accounts 71, 75 and 77 are grouped under the first reference. After creating a new transaction type, I make sure that this section remains compliant with the report template.
What do you think of this hack or trick, if not we will have to find another way to distinguish the subsidy accounts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lomamech that seems fine to me.
server/models/06-bhima.sql
Outdated
@@ -332,7 +332,7 @@ INSERT IGNORE INTO `transaction_type` (`id`, `text`, `type`, `fixed`) VALUES | |||
(2, 'VOUCHERS.SIMPLE.CASH_PAYMENT', 'income', 1), | |||
(3, 'VOUCHERS.SIMPLE.CONVENTION_PAYMENT', 'income', 1), | |||
(4, 'VOUCHERS.SIMPLE.SUPPORT_INCOME', 'income', 1), | |||
(5, 'VOUCHERS.SIMPLE.TRANSFER', 'other', 1), | |||
(5, 'VOUCHERS.SIMPLE.TRANSFER', 'income', 1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change, and we should talk about it.
Why are all transfers considered income? I think the majority of account to account transfers at Vanga (for example, from the auxiliary cashbox to the primary cashbox) are marked as "transfers". Same for transfers to and from the bank.
Why is a transfer an income?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the change of transfer type transaction, I had chosen to modify the type to allow the analysis of transfers coming from the auxiliary cash registers of the receipts, but since this will have repercussions on the other production sites, I have the following proposal: add in the interface of the cashflow report the possibility of considering the transfers as being receipts and the default value will be false., @jniles @jmcameron What do you think about this proposal which would resolve the IMCK problem without disturbing other production sites?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm okay with that hack as a solution. Alternatively, we could create a custom "cash transfer" transaction type for IMCK that has the type_id "income" that IMCK could start to use for caisse-to-caisse transfers instead and then it would show up here.
Ultimately, I think this speaks to a larger issue in BHIMA - we don't separate "cash" and "unrealized revenue" very well. I thought we had an issue about this, but I cannot find it. We probably should model this in the account_type
or account_category
which would have greater refinement of the type of transaction. Instead of simply having "asset", "liability", etc, as our account types, we would have sub-categories, such as "bank", "credit card", "caisse", "mpesa", all of which are subcategories of the "cash" account. Then, instead of analyzing transaction types, we would be looking at flows into and out of the cash accounts, which I think is likely the spirit of the cashflow report.
Of course, this would mean that all institutions would need to classify their chart of accounts correctly, but that seems like a good requirement to have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But regarding the cashflow report, I just think to add the option to consider the transfer in the income category, like that we will not need to add new types of transaction_type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm okay with this for IMCK.
19daa52
to
8b6afb8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is much better, thank you!
I am still concerned about the sorting issue. Is there anyway we can guarantee the output sort?
let firstIncomeConfigurationReferences = 0; | ||
let secondIncomeConfigurationReferences = 0; | ||
|
||
if (includeSummarySection) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am worried this will break in the future without a deterministic ordering. Is there any way we can make sure this data is sorted in the correct display order before merging?
As an example, suppose that MySQL gets an update that makes the shorter group_concat()
strings be put first. Or suppose a production server crashes and we need to restore it from backup, and it reorders the data. I think this should have some sorting/ordering to make sure that doesn't happen.
server/models/06-bhima.sql
Outdated
@@ -332,7 +332,7 @@ INSERT IGNORE INTO `transaction_type` (`id`, `text`, `type`, `fixed`) VALUES | |||
(2, 'VOUCHERS.SIMPLE.CASH_PAYMENT', 'income', 1), | |||
(3, 'VOUCHERS.SIMPLE.CONVENTION_PAYMENT', 'income', 1), | |||
(4, 'VOUCHERS.SIMPLE.SUPPORT_INCOME', 'income', 1), | |||
(5, 'VOUCHERS.SIMPLE.TRANSFER', 'other', 1), | |||
(5, 'VOUCHERS.SIMPLE.TRANSFER', 'income', 1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm okay with that hack as a solution. Alternatively, we could create a custom "cash transfer" transaction type for IMCK that has the type_id "income" that IMCK could start to use for caisse-to-caisse transfers instead and then it would show up here.
Ultimately, I think this speaks to a larger issue in BHIMA - we don't separate "cash" and "unrealized revenue" very well. I thought we had an issue about this, but I cannot find it. We probably should model this in the account_type
or account_category
which would have greater refinement of the type of transaction. Instead of simply having "asset", "liability", etc, as our account types, we would have sub-categories, such as "bank", "credit card", "caisse", "mpesa", all of which are subcategories of the "cash" account. Then, instead of analyzing transaction types, we would be looking at flows into and out of the cash accounts, which I think is likely the spirit of the cashflow report.
Of course, this would mean that all institutions would need to classify their chart of accounts correctly, but that seems like a good requirement to have.
8b6afb8
to
273a302
Compare
|
273a302
to
7abfeb1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks okay to me. I'll wait for @jmcameron to provide his feedback as well, since he is more familiar with the budget work at IMCK.
client/src/modules/reports/generate/budget_report/budget_report.config.js
Outdated
Show resolved
Hide resolved
@@ -381,6 +383,22 @@ function report(req, res, next) { | |||
return db.exec(queryRun, paramsRun); | |||
}) | |||
.then(rows => { | |||
// When the isTransferAsRevenue option is enabled, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a FIXME that this is an IMCK-specific hack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lomamech I encourage you to add an issue about this so we can generalize it later -- or base it on some environment variable that can be set for IMCK and ignored by other sites.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lomamech I encountered an error in basic tests (npm run test
or npm run build:db
). While building the database, complains:
[build] default data
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1064 (42000) at line 351: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT IGNORE INTO `flux` VALUES
(1, 'STOCK_FLUX.FROM_PURCHASE'),
(2, 'STO' at line 11
failed to import default data into DB 2/2
failed to build DB
I'm about to merge more PRs, so please merge with master again after you fix this issue.
Thanks
7abfeb1
to
c490269
Compare
|
8820f4f
to
fc5e060
Compare
@jmcameron I just updated my PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've started working through the code. I'll work on this more when the test issue below is resolved.
I encountered another testing problem. One of the end-to-end tests fails because you added an account reference type but did not update a related test. To reproduce the error, do this:
npx install playwright chromium
npm run test:e2e-1
fc5e060
to
a205d0c
Compare
I just did it |
a205d0c
to
077ef7e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed the code a couple of times. I'm satisfied with it, but I request that @jniles take one more look at it to see if all the issues he brought up have been addressed.
I tested it with the IMCK database and the budget report seems to work well. I was not completely sure how to reproduce the Cash flow report error, but I tested it and it seemed to work correctly.
All tests pass on my local test server.
@lomamech One suggestion for an improvement to the budget report.
At the end of the summary section, you list the Cashbox accounts but you use the phrase (English):
"This report concerns these accounts"
Since many accounts are shown in the report, this is confusing. I suggest you to change this to:
"This report concerns these cashbox accounts"
@lomamech I will be merging in other bump PRs, so I encourage you to merge with master once you have completed any changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me. Thanks for all your work on this @lomamech !
@@ -16,6 +16,8 @@ function BudgetReportController($sce, Notify, SavedReports, AppCache, reportData | |||
filter : 'default', | |||
}; | |||
|
|||
vm.reportDetails.include_summary_section = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
vm.numberYears = [ | ||
{ id : 1 }, { id : 2 }, { id : 3 }, { id : 4 }, { id : 5 }, | ||
]; | ||
|
||
vm.preview = function preview(form) { | ||
if (form.$invalid) { return null; } | ||
|
||
if (vm.reportDetails.include_summary_section === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
let firstIncomeConfigurationReferences = 0; | ||
let secondIncomeConfigurationReferences = 0; | ||
|
||
if (includeSummarySection) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lomamech that seems fine to me.
How to Perform the Test with the BHIMA Test Database
To do this, you will need to unlock the following debtor groups:
After posting the entries to the general ledger, proceed as follows:
These references will enable the analysis of financial performance by calculating the total revenue minus the total expenses. Afterward, proceed with a specific analysis:
To integrate this evaluation into the BHIMA system, we have added a new reference titled "Account Type Reference – Budget Analysis". This reference is configured to: Identify and group revenue related to non-medical activities. Once the two account references are created and ordered such that the second account reference represents the total grants (this is a workaround), it enables the evaluation of local revenue excluding grants, the total grants, and the total revenue. The budget report interface is structured as follows: To view the summary section, simply click on "Yes". This will allow you to select a cashbox, particularly the main cashbox. An Overview of the Report |
d05f4f5
to
305cb41
Compare
@jniles @jmcameron I have just completed the description on how to test my latest PR using the Test Database. For this, I had to make several additions to the test database. |
@lomamech Sorry this PR is taking a while to merge! I think that some of the added items have caused some of the end-to-end tests to fail. In
In
The rest of the end-to-end tests pass. Please fix these tests. |
f8d65e0
to
0a80338
Compare
- Added a new summary section to improve budget report. closes Third-Culture-Software#7897
0a80338
to
edb6294
Compare
|
I am still getting test errors using |
Okay, I think I fixed it. @jmcameron see if it works on your machine. |
closes #7897