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

enums: refactor BorrowerDocumentType as document_type table #383

Open
yolile opened this issue Aug 21, 2024 · 5 comments
Open

enums: refactor BorrowerDocumentType as document_type table #383

yolile opened this issue Aug 21, 2024 · 5 comments
Labels
chore status: discussion topic: models Relating to the ORM or database integration

Comments

@yolile
Copy link
Member

yolile commented Aug 21, 2024

Following from #362 (comment) we could consider having a settings table where we put all the current enums instead of hard coding them. This is especially relevant for document types, as lenders can request for new types when they are onboarded. The table should be fine for now but in the future we could also consider adding a form on the OCP admin page for managing settings.

@jpmckinney
Copy link
Member

jpmckinney commented Aug 21, 2024

Enums with no associated logic (and that have demand for configurability) can be made into tables (and even associated with specific lenders, if e.g. not all document options should be available for applications to all lenders). This includes:

Another option, instead of putting these entirely in the DB, is to have a "main list" with all options as a enum, and then a Lender has a JSON field or similar to limit the options. (This option is only interesting if we want to change the least code.)


Most enums are central to application logic, so they should probably remain enums:

Some related only to statistics, that are less important (but also less demand for configurability?):

  • BorrowerSize
  • StatisticType
  • StatisticCustomRange

@jpmckinney jpmckinney added topic: models Relating to the ORM or database integration chore labels Aug 21, 2024
@yolile
Copy link
Member Author

yolile commented Aug 22, 2024

Enums with no associated logic (and that have demand for configurability) can be made into tables (and even associated with specific lenders, if e.g. not all document options should be available for applications to all lenders).

Agree

Most enums are central to application logic, so they should probably remain enums:

Agree

Right now we need to add a new document type for one lender, so I will prioritize this issue.

Statistic* will probably disappear anyway (as part of #322)

BorrowerSize is related to lender/credit products so it could be a good candidate for the table option

@yolile
Copy link
Member Author

yolile commented Aug 24, 2024

Right now we need to add a new document type for one lender, so I will prioritize this issue.

As I won't have time to implement this before I'm back I did #396 for now (but with #362 implemented at least I didn't have to touch also the front end to add the new type)

@yolile
Copy link
Member Author

yolile commented Sep 10, 2024

After thinking more about this, I think we probably only need a document_type table, with a document description and name (and code). Currently, credit_product has required_document_types, which is a JSON of document type and boolean values pairs. I guess we could keep that and in the front end query the document's description and names based on the code. With this approach at least we won't need to redeploy the backend only to add new document types.

@jpmckinney
Copy link
Member

Sounds good to me!

@yolile yolile changed the title enums: refactor as settings enums: refactor BorrowerDocumentType as document_type table Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore status: discussion topic: models Relating to the ORM or database integration
Projects
None yet
Development

No branches or pull requests

2 participants