articleGetTotalPrice function

double? articleGetTotalPrice()

Implementation

double? articleGetTotalPrice(){
  double _price = currentArticle.discPriceProduct;
  bool _priceSelected = true;

  if (currentArticle.group.isEmpty){
    if (_price != 0)
      return _price;
    return currentArticle.priceProduct;
  }

  PriceData? _select;
  for (var _group in currentArticle.group){
    for (var _variant in _group.price)
      if (_variant.selected) {
        _select = _variant;
        if (_variant.priceUnit == "+")
          _price += _variant.price;
        else
          _price -= _variant.price;
      }
    if (_select == null)
      _priceSelected = false;
  }
  if (!_priceSelected)
    return null;
  return _price;
}