Skip to content

Scope billing data to the locations a user is allowed - #3

Open
drizzentic wants to merge 1 commit into
mainfrom
location-scoped-billing-data
Open

drizzentic wants to merge 1 commit into
mainfrom
location-scoped-billing-data

Conversation

@drizzentic

Copy link
Copy Markdown
Member

Adds billing_locationBasedBillingFilter, a hibernate filter declared on the billing mappings and enabled per session by the datafilter module, which it discovers through filters/hibernate/billing_location.json. Bills and everything hanging off them are scoped through the location of the cash point they were created at, which is what BillSearch.locationUuid already filters on, and billable services, billable drugs and their prices through their own location. A catalogue entry with no location is global and stays visible everywhere, the way the includeGlobal searches and the billing strategies' fallback treat it.

Which locations a user is allowed is not decided here: the allowedlocation module resolves them from the allowed_location user property it also scopes the login location picker with, so one user property and one set of allowedlocation.* global properties drive both. The only setting added here is billing.dataFilter.enabled, which defaults to false, so an existing installation behaves exactly as it did until an administrator turns it on.

datafilter and allowedlocation are provided-scope dependencies, kept off the test classpath: datafilter's BeanFactoryPostProcessor is picked up by core's component scan of org.openmrs, so its presence alone would enable the filter in every context sensitive test while no module is started to register the listener that sets its parameter, and hibernate rejects the next query on an enabled filter whose parameter is unset. BillingLocationFilterTest enables the filter on the session itself instead, which needs neither module.

Adds billing_locationBasedBillingFilter, a hibernate filter declared on the
billing mappings and enabled per session by the datafilter module, which it
discovers through filters/hibernate/billing_location.json. Bills and everything
hanging off them are scoped through the location of the cash point they were
created at, which is what BillSearch.locationUuid already filters on, and
billable services, billable drugs and their prices through their own location.
A catalogue entry with no location is global and stays visible everywhere, the
way the includeGlobal searches and the billing strategies' fallback treat it.

Which locations a user is allowed is not decided here: the allowedlocation
module resolves them from the allowed_location user property it also scopes the
login location picker with, so one user property and one set of
allowedlocation.* global properties drive both. The only setting added here is
billing.dataFilter.enabled, which defaults to false, so an existing
installation behaves exactly as it did until an administrator turns it on.

datafilter and allowedlocation are provided-scope dependencies, kept off the
test classpath: datafilter's BeanFactoryPostProcessor is picked up by core's
component scan of org.openmrs, so its presence alone would enable the filter in
every context sensitive test while no module is started to register the
listener that sets its parameter, and hibernate rejects the next query on an
enabled filter whose parameter is unset. BillingLocationFilterTest enables the
filter on the session itself instead, which needs neither module.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant