0

I am making a software to store all my company invoices (and then infer some statistics about it).

The idea is:

  • My company issues invoices to it's clients.
  • My company receive invoices from it's suppliers.

I made this class model to this problem.

>Class model

But after looking at it again I realised that this may not be the best model since I have companies that are my suppliers and my clients at the same time and that would force me to have TaxPayers instances that are Clients and Suppliers at the same time which is easy to implement in the persistent layer but hard to manage in the domain layer.

Any suggestions to improve this model?

EDIT: This may not be relevent for the question but I am using PHP 7.2 (Symfony framework 4.1 + Doctrine 2.6 for the persistent layer) + MySQL 8.0

Thanks!

  • 2
    My recommendation: do not use inheritance until you know for sure you need polymorphism. If an invoice has references from which company it comes and to whom it is adressed, the information if it is a "client invoice" or "supplier invoice" is already there, no need to represent this also by different subtypes. – Doc Brown Nov 18 '18 at 20:00
1

In my opinion, a company-issued invoice to a payee is different from a supplier invoice sent by the supplier to pay. The two entities are treated differently in many aspects, specially in accounting (A/R vs. A/P). In addition, the identification of each will be different. For example, a company invoice is almost always sequential whereas a supplier invoice could have a number our system can't predict. It is not clear what do you want to do with the supplier-issued invoice. In some applications, the details of the received invoice is not entered into the system but if you plan to store the items, then this is another point of difference between the two types of invoices. The company controls its items and item keys it uses, however, the system can't do the same for the supplier invoice. In summary, while the two entities look the same, there are important differences between them such that, a separate set of classes should be created to support each type.

On a different note, it is good to consider an ER diagram or show the primary keys on the model.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.