/**
 * @file oitem.cpp
 * @author Jan Holáň, xholan11 (xholan11@vutbr.cz)
 * @brief translated with gcc version 12.2.1
 * @version 0.1
 * @date 2023-05-01
 * 
 * @copyright Copyright (c) 2023
 * 
 */

#include "WarehousePickingOpt.h"

OItem::OItem(int Customer, int Product, string Address, int Qty)
    : Customer(Customer),
      Product(Product),
      Address(Address),
      Qty(Qty)
{
  this->waddress = new WAddress(Address);
}

OItem::~OItem() {}

float OItem::getWeight()
{
  return this->weight;
}

float OItem::getVolume()
{
  return this->volume;
}

void OItem::countWeightAndVolume()
{
  if (this->item_spec.find(ItemSpecification::Type::Unit) == this->item_spec.end())
  {
    throw exception();
  }

  auto ref = this->item_spec.at(ItemSpecification::Type::Unit);
  this->weight = ref.Weight * this->Qty;              // compute weight
  this->volume = (ref.X * ref.Y * ref.Z) * this->Qty; // compute volume
}