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.
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
– Daniel Omine