GeriLife / wellbeing

Welbeing activity log and visualization tool.
http://geri.life
GNU Affero General Public License v3.0
13 stars 6 forks source link

Adding residency to existing resident throws incorrect error #563

Closed brylie closed 3 years ago

brylie commented 4 years ago

The logic to prevent overlapping user residencies is not working correctly. I am trying to add a non-overlapping residency to a resident that has no active residency and get the following error:

Error: This user already has an active residency [500]
  at Object.addNewResidencyWithExistingResident (server/methods/residencies.js:28:11)
  at packages/simple_rest.js:383:33
  at packages/simple_json-routes.js:98:9

Steps to reproduce:

  1. Create a new resident and residency
    • move in: 2020-10-01
    • move out: 2020-10-10
  2. Add a new residency for existing resident
    • select the resident
    • move in: 2020-07-01
    • move out: 2020-07-10

The logic should allow the additional residency for a given resident, so long as the dates do not overlap. It should not matter whether the current residency is inactive, so long as there are no overlapping dates (and the old residency end date is prior to the newer residency start date).

Only creating a new residency for a date later than the move in date for an active residency (meaning no move out date) should be disallowed.