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

Limit the ability to incur debt on a specific account #7980

Open
jniles opened this issue Jan 22, 2025 · 2 comments
Open

Limit the ability to incur debt on a specific account #7980

jniles opened this issue Jan 22, 2025 · 2 comments
Assignees

Comments

@jniles
Copy link
Collaborator

jniles commented Jan 22, 2025

At Vanga, we have received the request to limit the invoicing of a patient if they are associated with a debtor group that has maxed out its debt limit. That is, when we check to load the debtor group, the invoicing module should show warning that disables the submission of the debtor group has a balance over the limit.

Design

To accomplish this, I'll rename the max_credit field on the debtor_group table to max_debt. I'll change the translation keys around this to "Overdraft Limit", with the description talking about how this will prevent billing patients after the account balance surpasses the limit.

Then, I'll add two checks to the PatientInvoiceFormService when the patient is loaded. First, it will check the account balance using the AccountService.getBalance() function. Next, it will call DebtorGroup.read() to check the max_debt field from the patient's debtor group. If the max_debt value is non-zero, and the account balance (debit - credit) exceeds the max_debt value, the PatientInvoiceFormService will set an error flag informing the user that this patient's debtor group has a debt that exceeds the institution's policy, and the patient cannot be billed in this debtor group.

Finally, I'll add the same logic to the patientInvoice.create.js service-side controller to prevent the creation of invoices via the API if the same conditions aren't met.

Considerations

Some implementation notes:

  1. We could limit credit/debit balances on the account itself, instead of the debtor group. However, this would force us to have a good UI/UX to resolve issues across the entire application (purchasing, vouchers, transaction edit modal, etc). That design is too big a challenge for this issue.
  2. This will not protect the debtor group from being "over drafted" in the traditional sense. If the limit is $500 on a debtor group, they can still process a bill for $510. However, the next invoice will fail. This seems like a reasonable tradeoff to me.
  3. To prevent users from working around this restriction by never posting, the account balance will be the balance including the posting journal. This means that a debtor group may exceed its max debt dynamically between two invoices. It also means that clever accountants cannot work around the issue by simply never posting.
@jniles jniles self-assigned this Jan 24, 2025
@jniles
Copy link
Collaborator Author

jniles commented Jan 24, 2025

It sounds like we will need to do another release with the final updates to reports from @lomamech. I'll take this opportunity to add in this change requested by Vanga, since they are encountering administrative difficulties over account spending limits.

@jniles
Copy link
Collaborator Author

jniles commented Jan 26, 2025

Note: this will also need to be applied to the "Prise en charge" journal voucher method too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant