Modeling customer/supplier roles.

17 views
Skip to first unread message

Leandro França

unread,
Mar 24, 2015, 10:04:14 AM3/24/15
to rubyonra...@googlegroups.com
Hi there,

I'm trying to decide the best approach for a person/company/customer/supplier model.
I researching about STI and polymorphic associations, but cant decide which way to go.

- Companies and persons can be, at the same time, customers or suppliers. They can have many roles.
- Company and person share many basic information (addresses, telephones, emails, etc).

Any advices?

Thanks in advance,
Leandro


Scott Ribe

unread,
Mar 24, 2015, 10:09:43 AM3/24/15
to rubyonra...@googlegroups.com, Leandro França
On Mar 24, 2015, at 8:04 AM, Leandro França <leandroay...@gmail.com> wrote:
>
> Any advices?

Don't make customers & suppliers separate models/tables. Make them attributes of a single model. It seems that ***EVERY*** business/accounting package on earth makes this same mistake. For anybody in a "broker" type business line, where it's common to both buy & sell from the same companies, this is a huge annoyance.

As for company vs person, I don't have a terribly strong opinion to offer about 1 model with attribute vs 2 models with inherited base.

--
Scott Ribe
scott...@elevated-dev.com
http://www.elevated-dev.com/
https://www.linkedin.com/in/scottribe/
(303) 722-0567 voice





Scott Ribe

unread,
Mar 24, 2015, 10:11:13 AM3/24/15
to rubyonra...@googlegroups.com, Leandro França
On Mar 24, 2015, at 8:08 AM, Scott Ribe <scott...@elevated-dev.com> wrote:
>
> On Mar 24, 2015, at 8:04 AM, Leandro França <leandroay...@gmail.com> wrote:
>>
>> Any advices?
>
> Don't make customers & suppliers separate models/tables. Make them attributes of a single model. It seems that ***EVERY*** business/accounting package on earth makes this same mistake. For anybody in a "broker" type business line, where it's common to both buy & sell from the same companies, this is a huge annoyance.
>
> As for company vs person, I don't have a terribly strong opinion to offer about 1 model with attribute vs 2 models with inherited base.

Hit send too quickly...

You may not even want companies designated via attributes as customer or supplier. You may just want companies, and let the transaction history tell you who's a customer and who's a supplier, as that can change at any time.

Leandro França

unread,
Mar 24, 2015, 10:20:21 AM3/24/15
to rubyonra...@googlegroups.com, leandroay...@gmail.com
Hey Scott, thanks for your quick reply.

I'm inclined to think 2 models with inheritance base for Person/Company, using STI. 
Altho it would be good  to associate a person with a company.

About supplies and customers, I think I cant rely only on transaction history. 
Many customers for example only have maintenance contracts which will not be registered in this system. 
But I need to know they are customers if they open a support ticket or to send a satisfaction survey, for example.
Reply all
Reply to author
Forward
0 new messages