f-klubben / stregsystemet

The very public stregsystem repo
Other
37 stars 47 forks source link

Reimbursement of latest bought items #424

Open TheRumle opened 3 months ago

TheRumle commented 3 months ago

As seen in #418, #215 and #188 we would like to be able to re-imburse items. Here is my suggestion on how one could do it. Heavily inspired by @joandrsn #215 PR.

What makes this BL tedious is that all sale information must be 'preserved' - however, if we just put a field into the Sale entity we have create a filter on all existing logic - for instance, we don't want to make people 'coffee master' by considering reimbursed coffee. Therefore, making a 'is_reimbursed' field seems like a bad idea to me. I have instead created is_reimbursed to establish when it can occur. I decided to create the Reimbursement class, and use it to keep track of who reimburses what, and for how much. I see a couple of critical things about my approach and would like to discuss them

  1. It does not go through the existing entities, therefore no logging, admin info, etc exists for it. I need help adding this.
  2. It deletes the existing sale. I find this to be the best way to represent that the sale was an error, and did not occur. We do lose data, but it is not correct data (unless someone abuses the feature)
  3. The code is yet another place to ensure correct state representation of related entities inventory, accounts, etc. We already suffer from this - introducing more places to keep track of entity behaviour feel icky.