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

Multiple Payroll "Configuration" modal will increase the base salary indefinitely if the currency is switched too many times. #7966

Open
jniles opened this issue Jan 12, 2025 · 4 comments

Comments

@jniles
Copy link
Collaborator

jniles commented Jan 12, 2025

In the Human Resources > Payroll Multiple configuration modal for an individual employee, when a user changes the currency two unexpected things occur:

  1. The currency in the bh-currency-input does not update (it always shows the enterprise currency, I would assume).
  2. The "base salary" increases indefinitely by running the exchange rate algorithm multiple times and updated the base value. This is a huge bug! Instead, the original base salary should be cached and all exchanges should be run against the cached value.

Here is a demonstration of the bug:
PayrollCurrencyBug

When fixing this issue, the following improvements could also be made:

  1. Instead of "Employee Indice:2" in the header of the modal, we should display the employee's name in the modal body.
  2. We could also put the payment period in the modal body as well.
  3. Instead of disabled inputs, let's just use Static Controls to render the options that cannot be displayed.
  4. The "Jours Feries", etc, are all days. Let's put the units on the inputs. For the best user experience, it should say "Holidays" "None", or "1 day", "2 days", etc. But "0 days" is also likely acceptable.
  5. The "Money" input should occur above the "Base Salary" input.
@jniles
Copy link
Collaborator Author

jniles commented Jan 15, 2025

I'm going to tackle this in my latest HR refactor.

@jniles
Copy link
Collaborator Author

jniles commented Jan 17, 2025

So, according to our documentation (https://docs.bhi.ma/fr/payroll/payroll_multiple), the employees are always paid in the enterprise currency. Therefore, this currency selection should only change the view value.

However, this presents a problem. What happens if the user changes to view in a different currency (for example, USD$ instead of the enterprise FC), then makes a change to the base salary or advantages? What do we do? Do we modify the value using the exchange rate of today?

And what happens if the employee goes to be paid later (say, a week later)? Do we use the exchange rate of the configuration date or the payment date?

To avoid this confusion, I propose we remove the ability to be change currencies on this configuration modal. I think it just makes things confusing, and buggy. Instead, the salary will be fixed in the enterprise currency and paid using whatever currency they want at the cashbox.

@lomamech what do you think of the idea to remove the currency change on this page? Will it cause any issue for any production site? For example, IMCK?

@jniles
Copy link
Collaborator Author

jniles commented Jan 17, 2025

A different option is that we could keep the ability to change currency, but erase all changes the user made to salary values when they switch currencies.

This would allow the user to modify the salary of an employee or benefits, in a non-enterprise currency, if that is needed. However, it would guarantee that we can't get into this kind of cycle bug where we keep running the exchange() operation on the same values over and over again.

@jniles
Copy link
Collaborator Author

jniles commented Jan 20, 2025

I am going with the option of removing the currency from this modal, since production sites do not seem to choose other currencies in their configuration anyway.

See #4956 (comment) for more context.

jniles added a commit to jniles/bhima that referenced this issue Jan 20, 2025
Complete rewrite of the multiple_payroll payment configuration modal to
be less brittle and provide a better user experience.

I've completely removed the option for the user to set the currency
since no production sites were using it in practice, and it had some
serious bugs.  This reduces the number of imports into the modal and
removes the need to do any currency conversion.

Additionally, I've provided additionally context in the modal about the
employee, their grade, function, number of dependents, etc., to give the
user all the context needed for configuration of the employee.

Closes Third-Culture-Software#7966.
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