How to model Product/Stock?

Asked

Viewed 392 times

2

I started a modeling for Products thinking of the same as:

  • Purchased for Resell
  • Produced for Sale
  • Perishable or not

So far so good, but when I started thinking about stock control based on this model my head tied a knot, on account of the control of Manufacturing Lots and on account of being or not perishable.

Below the first version of my Product entity.

A brief explanation about relationships:

Supplier refers to products purchased for resale

Company for products produced by my company

Measure a table that holds if the product is measured in KG, L or P, PP, M etc.

public class Produto implements Serializable {

    @Basic
    private int ativo;
    @Column(length=400)
    @Basic
    private String caminhoImagem;
    @Basic
    private double largura;
    @Basic
    private double peso;
    @Column(length=70)
    @Basic
    private String cor;
    @Basic
    private String valorCompra;
    @Column(length=150)
    @Basic
    private String nome;
    @Basic
    private double profundidade;
    @Column(length=200)
    @Basic
    private String descricao;
    @OneToOne(targetEntity = TipoProdutoEnum.class)
    private TipoProdutoEnum tipoProdutoEnum1;
    @Temporal(TemporalType.TIMESTAMP)
    @Basic
    private Date dataAtualizacao;
    @Basic
    private double altura;
    @Basic
    private String valorVenda;
    @OneToOne(targetEntity = MedidaProduto.class)
    private MedidaProduto medidaProduto;
    @Basic
    private double quantidadeMaxima;
    @Basic
    private double quantidadeMinima;
    @Temporal(TemporalType.TIMESTAMP)
    @Basic
    private Date dataDesativacao;
    @Id
    @GeneratedValue(generator="seq_produto",strategy=GenerationType.SEQUENCE)
    @SequenceGenerator(name="seq_produto",sequenceName="seq_produto",allocationSize=1)
    private Long id;
    @Basic
    private double quantidadeAtual;
    @OneToOne(targetEntity = Fornecedor.class)
    private Fornecedor fornecedor;
    @OneToOne(targetEntity = Empresa.class)
    private Empresa empresa;
    @Temporal(TemporalType.TIMESTAMP)
    @Basic
    private Date dataCadastro;
}

When I started to think about stock control I saw that I mixed a little the concepts and in the matter of production control I am completely lost.

  • 1

    you may have some flag that identifies a sale as a resale but in practice, sale and resale are the same thing. I suggest starting to "uncomplicate" the problem there. As for perishables do not think too much now because it will tie the head anyway. The important thing is to model in a modular way, that is where you can fit and disengage various rules without affecting the structure. An example of how perishables get complicated is "refrigerator", "freezer", "dry". This influences shipping/packaging. Another is, uneven weight. A cut of meat is never perfect in relation to weight. And so on

1 answer

4


Yes, mixed the concepts. Product is product, lot is lot. Everything you deal with in general, abstract, is product. Think of the product as a document that talks about the product. It has no relation to physical items. At least this is the understanding in most modeling.

In this document there may even be information about the number of existing units in it. I said "can" because there are models where this is wrong, you can have warehouses, for example. Some think that even when you only have one warehouse (in industries it is very rare to only have one, and the description of the question seems to indicate that there are at least two) the ideal is that this information is in the most suitable location. I can’t tell you what’s best for your case.

But if you have quantities of batches produced, if those batches have validity, specific quality control, you have to control that separately. Note that there we still have something abstract, because the lot is still only a document.

You only enter the concrete when you speak of the unit itself (although the registration is not only a document). And there are cases where it is necessary to register each unit produced, typical case when it needs the serial number (it is not any serial use that needs the individual registration).

Another example of what might not be quite as you think: it is common for the product to have several possible suppliers (even if the unit only has one).

Some types used in the dice scare me a little, mainly the selling value be String.

You may be modeling on top of something not real. This is always complicated, because in theory anything can be valid. There is no right or wrong in modeling in the total abstract. With the real need is that you can say what is right or not, and always for that situation of the moment.

  • 1

    Show, already gave to clarify some things. The sale value as String was only forgetfulness.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.