开发者

Invoice model recommendation

I just started to develop an invoice app. I would like to hear your opinions and recommendations about this dilemma.

The invoice has a client section. The client can be selected from a drop-do开发者_运维技巧wn select menu or it can be entered directly into a text field. Let's say it's just a one time purchase and the client won't ever come back. Should I have these two columns: client_id and client_field so either of those two can be filled out? The negative side is that a lot of client_field will be empty. Or should I not use a client_field and just add a new client even thought that client will only be used once?


Be consistent and use a separate client model and client_id even for clients that only appear once. If you have both client_id and client_model you will have extra complexity:

  • Your validation will have to check both and ensure that everything is consistent.
  • You will have to o.client.try(:name) || o.client_field and such all over the place just to display data.
  • If you change the structure of your client records in the future you will have to reformat your "table within a table" client_field kludge.
  • Any database based reporting will go from simple SQL to a monstrosity of LEFT JOINs and CASE statements.

And those are just a couple things off the top of my head.

If you're worried about having a dropdown with a lot of entries — and you should be worried about any dropdown with more than ~20 entries — then go with just an autocompleting text input or limit the dropdown to the top ~20 clients and use a autocompleting text input for the rest (or perhaps even a JavaScript based combo-box); there's a good chance that the dropdown won't even get used by your users, accountants and other people that do a lot of data entry and invoicing often hate having to reach for the mouse.


Is there anything wrong with having an auto-complete field where, if submitted without a matching ID, you will just create the client and link them in?

That's what's expected from the stand-point of the user and it's how applications like QuickBooks have worked for years.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜