2
I am trying to make a system for sale of açaí. In an açaí can add many ingredients like paçoca, milk powder, fruit and etc... Açaí can also be sold in 250ml, 500ml and 750ml pots. Depending on which pot is sold, a quantity of N will be removed from the stock. The same applies to added ingredients. It is worth remembering that the establishment also sells water bottle, juices, soft drinks, which are still products!
Anyway, I’m trying to make the model, and until then I find myself like this:
I defined that a Ingredient and a Product are a type of Item, because they have stock, has a price (which in case of the ingredient will add to the final price of the product), therefore they inherit from the abstract class Item. The class Ingredient has a list of categories that can be added, for example: Milk powder can be added in the category Acai, but never in the category Soda pop.
I want to know if the model is good, I thought about the possibility of using the default Decorator, but I don’t know if I’ll have problems entering the database. I will use C# and Fluent Nhibernate with Mysql. Anyway, how to solve the 250ml/750ml Pot problem? And the fact that not all ingredients are compatible with all products, I made a good approach to the problem?
I accept suggestions on any part of the model to try to solve problem, as long as there are no scams to write to the database (which is also subject to changes).
EDIT Following advice, I changed the diagram and this is now: Solved the problem of a product can come to spend X inputs. But now I find myself in the following situation. If my client buys a bottle of water from a supplier, he sells the whole bottle of water without spending any inputs, the bottle is the stock itself, how to solve? I thought about creating a stock class, but how could I connect to the stock Input and Product at the same time?
In what other category
Leite em pó
can be added in addition toAçaí
? Some ingredient can be added in the categoryRefrigerante
?– Caffé
It seems to me that you are trying to solve with a single model an immense amount of problems (stock of inputs, control of inputs used in the manufacture of the product, stock of products, ...) and these problems seem to be not yet well formulated - for now there is only a general notion of all problems. My suggestion: choose the most important problem, define it well, design a model that suits you, implement, validate. Choose the next problem, define it well, refactor the model, implement, validate. Repeat the cycle.
– Caffé
I think it is important to separate the concept of stock from the concept of the final product sold, because in practice, they are different things. The banana you put in the açaí is not an item, nor the açaí, because you buy in a "format" and sell fractionated. Just like an item in a building store stock is cement, and you can sell 1kg of cement separately (fractionated). In stock you have 60kg cement bags. Better not mix concepts forcibly. The stock has kilos of banana, açaí has units. The stock has quantities of açaí, which are fractionated and turn products.
– Bacco
@Caffé I believe not, I wanted to leave free for the user to define this, because if he wants to create the vitamin product and say that there are things that can be increased, he can do this.
– Latrova
@Bacco Because of lack of knowledge in planning I do not understand the subject well, however, does this not generate duplicate content? In stock I have Açai 800ml, and in Item I have Açai, too? How does the input relate to the product? Is the stock of the input or the product? And when the product is whole?
– Latrova
@Lizard Vc has products that "relate" to the stock. You can have a product table with a reference like this: The product Açai 750ml "discounts" 0.75 L from açaí stock, if the stock entry is in liters, for example. The optional Banana discounts 50g of the Kg of banana, and so on.
– Bacco
@Bacco then I’ll have to create a spending table? My customer when registering a new product will inform that the product X spends Y of so many ingredients?
– Latrova
@Lizard is what I would normally do in this case, but there are a lot more details that a good stock has to have to close round (conciliation of losses, etc). It is up to you to evaluate what is best in the real case. There are many possibilities for me to comment here. There is no universal rule, each case is a case.
– Bacco
I will follow the advice of both of you and remodel. I will then edit with the changes to (if you want) evaluate
– Latrova
I added a reply with a suggested template. Feel free to ask I can add more details.
– Caffé