Skip to content
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

Automatically add number of employees to cost centers in step-down cost allocation reports #5977

Merged

Conversation

jmcameron
Copy link
Collaborator

@jmcameron jmcameron commented Oct 5, 2021

This PR adds/updates the number of employees for each cost center based on the query proposed by @jniles in its issue:

Closes #5962

I think I was able to verify that computes the correct number of employees for each cost center both in bhima_test and in the vanga dataset (after applying the employees and cost center update scripts from @jniles and @lomamech (respectively).

To use: Go to the "Allocation Keys" page and click on the [Update] button. That will update the cost_center_allocation_base_value table with the items that it can compute (currently only num employees).

This does not work completely yet, because

  • For bhima_test, the sample data does not set appropriate services and link them to cost centers for the new cost centers
  • For vanga, the code to construct the data for the step-down cost allocation is producing empty data. Further work is needed to connect all the pieces.
  • Did not test on imck, etc.

const missingCenters = [];
for (let i = 0; i < computables.length; i++) {
const basis = computables[i];
const data = await allocationQuantities(basis.id);
Copy link
Collaborator Author

@jmcameron jmcameron Oct 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jniles How do I deal with this?

FIXED.

@jmcameron jmcameron force-pushed the cost-allocation-num-employees branch from 6145aa3 to b527329 Compare October 5, 2021 10:55
Copy link
Contributor

@jniles jniles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be awesome if this showed up in the cost center allocation registry. Can you get that working?

image

It would also look good to put this on the modal, but in an uneditable state.

@jmcameron
Copy link
Collaborator Author

jmcameron commented Oct 5, 2021

It would be awesome if this showed up in the cost center allocation registry. Can you get that working?

It would also look good to put this on the modal, but in an uneditable state.

Ok, I'll see what I can do.

-Jonathan

Copy link
Contributor

@mbayopanda mbayopanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The query for getting employees as cost center basis works well, and the concern is we cannot see this computed basis in the allocation_bases registry:

image

@jmcameron jmcameron force-pushed the cost-allocation-num-employees branch from b527329 to 5988683 Compare October 6, 2021 10:35
const newQuantity = ccData[basis.name];
// See if there is an existing quantity
const qRecordId = await db.exec(findQRec, [cc.id, basis.id]);
if (qRecordId.length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just delete these values and rewrite? I.e. if we are computing the number of employees, just clear out the old values and then do an INSERT for the rest?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to do that after the demo. By doing drop and insert, I can do it with transactions and clean it up. Lets get this out so we can use it for the demo.

@jmcameron jmcameron force-pushed the cost-allocation-num-employees branch from 5988683 to a534540 Compare October 6, 2021 11:39
Copy link
Contributor

@jniles jniles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this with the Vanga database, and it works like a charm. Thanks!

bors r+

@bors
Copy link
Contributor

bors bot commented Oct 6, 2021

Build succeeded:

@bors bors bot merged commit ac71c48 into IMA-WorldHealth:master Oct 6, 2021
@jmcameron jmcameron deleted the cost-allocation-num-employees branch October 6, 2021 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create automatic allocation basis calculation for "number of employees" basis
3 participants