Open Chris-Petty opened 1 month ago
@Chris-Petty totally agree we should just make it required...
low effort, good first issue, so bumping priority to should have
@andreievg I literally did the changes here https://github.com/msupply-foundation/open-msupply/commit/034633acfc2142bb7aa60148dadbae3811c4b20c so I think it's too easy even for a first issue 😆. I just pulled it out into an issue because it was too much of a refactor to sneak into a PR I was doing at the time
THough I suppose there is checking I didn't break the front end!
Why not just remove the r#type
field completely? Don't think you should be able to update an invoice line's type once it is created should you??
@lache-melvin good point I agree
The suggestion
There is an optional struct field
UpdateStockOutLine.r#type
that results in always throwing an error if you don't provide a value. In which case, it's not optional! So howsabout it isn't?TANGENT: The front end shouldn't be able to specify the type IMO! Bad frontend code (say a plugin??? We'd NEVER write bad code 😁) could send the wrong type. The backend surely could derive the type from the parent record... it already does various queries figuring how to apply/validate/backdate the request, one more indexed query of
invoice
surely is negligible!Example use case
Why should we invest time in this?
Annoying working with an Option when it's mandatory. Slows dev down. Makes mistakes. Type system should prevent mistakes not create them.
Are there any risks associated with this change?
Breaks frontend maybe?
How much effort is required?
I already did it but reverted the commit. 034633acfc21
Agreed Solution
Make
r.r#type
required?