|
@@ -1,3 +1,6 @@
|
|
|
+import datetime
|
|
|
+from src.errors.argument_exception import argument_exception
|
|
|
+from src.models.transaction_model import transaction_model
|
|
|
from src.storage.storage_prototype import storage_prototype
|
|
|
from src.export.exporter_factory import exporter_factory
|
|
|
from src.logic.process_factory import process_factory
|
|
@@ -48,6 +51,30 @@ class storage_service:
|
|
|
rests = processing.create(transactions)
|
|
|
return rests
|
|
|
|
|
|
+ def take_recipe(self, recipe, turns, storage_, strg):
|
|
|
+ recipe_need = {}
|
|
|
+ for recipe_row in recipe.rows:
|
|
|
+ recipe_need[recipe_row.nomenclature.name] = recipe_row.size
|
|
|
+
|
|
|
+ transactions = []
|
|
|
+ for turn in turns:
|
|
|
+ if recipe_need[turn.nomen.name] > turn.remains:
|
|
|
+ raise argument_exception(
|
|
|
+ "Не удалось произвести списание! Остатков на складе не достаточно!"
|
|
|
+ )
|
|
|
+ transactions.append(
|
|
|
+ transaction_model(
|
|
|
+ storage=storage_,
|
|
|
+ nomen=turn.nomen,
|
|
|
+ operation=False,
|
|
|
+ countes=recipe_need[turn.nomen.name],
|
|
|
+ unit=turn.unit,
|
|
|
+ period=datetime.now(),
|
|
|
+ )
|
|
|
+ )
|
|
|
+
|
|
|
+ strg.data[storage.transaction_key()] += transactions
|
|
|
+
|
|
|
@property
|
|
|
def data(self) -> list:
|
|
|
return self.__data
|