process_turn.py 689 B

1234567891011121314151617181920212223
  1. from src.models.storage_turn_model import storage_turn_model
  2. from src.logic.abstract_process import abstract_process
  3. class process_turn(abstract_process):
  4. @classmethod
  5. def create(self, transactions):
  6. """Создать обработку"""
  7. res = dict()
  8. for t in transactions:
  9. k = (t.warehouse, t.nomenclature, t.measurement_unit)
  10. v = t.amount * t.transaction_type
  11. if k in res.keys():
  12. res[k] += v
  13. else:
  14. res[k] = v
  15. ts = list()
  16. for k, v in res.items():
  17. t = storage_turn_model("Turn", k[0], v, k[1], k[2])
  18. ts.append(t)
  19. return ts