Applies flat disount to the cart.

@param float Discount amount
@param int Coupon id
@return array
@throws IncorrectDiscount
164473
public function applyFlatDiscount($amount, $couponId = null)
    {
        if ($amount > $this->subtotal) {
            throw new IncorrectDiscount('The discount amount cannot be more that subtotal of the cart');
        }

        $this->discount = round($amount, 2);
        $this->discountPercentage = 0;
        $this->couponId = $couponId;

        $cartData = $this->cartUpdates($isNewItem = false, $keepDiscount = true);

        event(new DiscountApplied($cartData));

        return $cartData;
    }
206407
public function addDiscArt()
    {
        $config = \OxidEsales\Eshop\Core\Registry::getConfig();
        $articleIds = $this->_getActionIds('oxarticles.oxid');
        $discountListId = $config->getRequestParameter('synchoxid');

        // adding
        if ($config->getRequestParameter('all')) {
            $articleTable = $this->_getViewName('oxarticles');
            $articleIds = $this->_getAll(parent::_addFilter("select $articleTable.oxid " . $this->_getQuery()));
        }
        if ($discountListId && $discountListId != self::NEW_DISCOUNT_LIST_ID && is_array($articleIds)) {
            foreach ($articleIds as $articleId) {
                $this->addArticleToDiscount($discountListId, $articleId);
            }
        }
    }
7243
protected function getCouponCodeDiscountLine()
    {
        $result = array(
            Tag::ItemNumber => $this->order['details']['BT']->coupon_code,
            Tag::Product => $this->t('discount'),
            Tag::Quantity => 1,
            Meta::UnitPriceInc => (float) $this->order['details']['BT']->coupon_discount,
            Tag::VatRate => null,
            Meta::VatRateSource => static::VatRateSource_Strategy,
            Meta::StrategySplit => true,
        );

        return $result;
    }
106921
public function tax($amountNotTaxable = 0, $grossTax = true, $rounded = false, $withDiscount = true)
    {
        $discountTaxable = ($withDiscount) ? !config('laracart.discountTaxable', false) : false;
        $totalDiscount = ($withDiscount) ? $this->getDiscount(false) : 0;

        if (!$this->taxable) {
            $amountNotTaxable = $this->price * $this->qty;
        }

        if (config('laracart.tax_by_item')) {
            $itemCount = 0;
            $totalTax = 0;
            while ($itemCount < $this->qty) {
                $totalTax += round($this->price * $this->tax, 2);
                $itemCount++;
            }

            if ($grossTax && config('laracart.discountsAlreadyTaxed', false)) {
                $totalTax = $totalTax - ($totalDiscount - ($totalDiscount / (1 + $this->tax)));
            } else {
                if ($totalDiscount < 0 || $totalDiscount > $this->price) {
                    return $totalTax - ($totalDiscount - $this->price);
                }
            }

            if ($rounded) {
                return LaraCart::formatMoney(
                    ($totalTax - $amountNotTaxable),
                    $this->locale,
                    $this->internationalFormat,
                    false
                );
            }

            return $totalTax - $amountNotTaxable;
        }

        $totalTax = $this->tax * ($this->subTotal(false, $discountTaxable, true, false) - $amountNotTaxable);

        if (config('laracart.discountsAlreadyTaxed', false) && $withDiscount) {
            $totalTax = $totalTax - ($this->getDiscount(false) - ($this->getDiscount(false) / (1 + $this->tax)));
        }

        if ($rounded) {
            return LaraCart::formatMoney(
                $totalTax,
                $this->locale,
                $this->internationalFormat,
                false
            );
        }

        return $totalTax;
    }
796157
public function getTotalWithCoupons()
    {
        $total = $this->getTotal();
        $totalWithCoupons = $total;

        $this->coupons->each(function (Coupon $coupon) use ($total, &$totalWithCoupons) {
            /**
             * @var Coupon $coupon
             */
            $totalWithCoupons -= $coupon->apply($total);
        });

        return $totalWithCoupons;
    }
1234341
protected function updateTotals($keepDiscount = false)
    {
        $this->setSubtotal();

        if (! $keepDiscount) {
            $this->discount = $this->discountPercentage = 0;
            $this->couponId = null;
        }

        $this->setShippingCharges();

        $this->netTotal = round($this->subtotal - $this->discount + $this->shippingCharges, 2);

        $this->tax = round(($this->netTotal * config('cart_manager.tax_percentage')) / 100, 2);

        $this->total = round($this->netTotal + $this->tax, 2);

        $this->setPayableAndRoundOff();
    }
1234332
public function setOrderDiscountAmount($amount, $name = 'Discount', $description = 'Order Discount') {
        $obj = Icepay_Order_Product::create()
                ->setProductID('02')
                ->setProductName($name)
                ->setDescription($description)
                ->setQuantity('1')
                ->setUnitPrice(-$amount)
                ->setVATCategory(Icepay_Order_VAT::getCategoryForPercentage(-1));

        $this->addProduct($obj);

        return $this;
    }
1011761
public function getLineItemsByDiscount(PromotionDiscountEntity $discount, Cart $cart, SalesChannelContext $context): array
    {
        /** @var array $nonPromotionLineItemsKeys */
        $nonPromotionLineItemsKeys = $this->getNonPromotionLineItemsKeys($cart);

        if (count($nonPromotionLineItemsKeys) === 0) {
            return [];
        }

        if (!$discount->isConsiderAdvancedRules()) {
            return $nonPromotionLineItemsKeys;
        }

        /** @var RuleCollection|null $discountRuleCollection */
        $discountRuleCollection = $discount->getDiscountRules();

        // discount has no rules, therefore all lineItems match discount
        if (!$discountRuleCollection instanceof RuleCollection) {
            return $nonPromotionLineItemsKeys;
        }

        /** @var array $lineItems */
        $lineItems = $this->getNonPromotionLineItems($cart);

        $matchingLineItems = [];

        // get all lineItems where rule is matching without respecting any advanced rule
        /** @var LineItem $lineItem */
        foreach ($lineItems as $lineItem) {
            $itemScope = new LineItemScope($lineItem, $context);
            if ($this->doesRuleCollectionMatchsLineItem($discountRuleCollection, $itemScope)) {
                $matchingLineItems[$lineItem->getKey()] = $lineItem;
            }
        }

        return $matchingLineItems;
    }
416520
public function getDiscount($format = true)
    {
        $amount = 0;

        if ($this->coupon) {
            $amount = $this->coupon->forItem($this);
        } elseif (app('laracart')->findCoupon($this->code)) {
            $amount = $this->discount;
        }

        if ($amount < 0) {
            $amount = $this->price;
        }

        return LaraCart::formatMoney(
            $amount,
            $this->locale,
            $this->internationalFormat,
            $format
        );
    }
399027
protected function _calcVoucherDiscount()
    {
        if (\OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('bl_showVouchers') && ($this->_oVoucherDiscount === null || ($this->_blUpdateNeeded && !$this->isAdmin()))) {
            $this->_oVoucherDiscount = $this->_getPriceObject();

            // calculating price to apply discount
            $dPrice = $this->_oDiscountProductsPriceList->getSum($this->isCalculationModeNetto()) - $this->_oTotalDiscount->getPrice();

            // recalculating
            if (count($this->_aVouchers)) {
                $oLang = \OxidEsales\Eshop\Core\Registry::getLang();
                foreach ($this->_aVouchers as $sVoucherId => $oStdVoucher) {
                    $oVoucher = oxNew(\OxidEsales\Eshop\Application\Model\Voucher::class);
                    try { // checking
                        $oVoucher->load($oStdVoucher->sVoucherId);

                        if (!$this->_blSkipVouchersAvailabilityChecking) {
                            $oVoucher->checkBasketVoucherAvailability($this->_aVouchers, $dPrice);
                            $oVoucher->checkUserAvailability($this->getBasketUser());
                        }

                        // assigning real voucher discount value as this is the only place where real value is calculated
                        $dVoucherdiscount = $oVoucher->getDiscountValue($dPrice);

                        if ($dVoucherdiscount > 0) {
                            $dVatPart = ($dPrice - $dVoucherdiscount) / $dPrice * 100;

                            if (!$this->_aDiscountedVats) {
                                if ($oPriceList = $this->getDiscountProductsPrice()) {
                                    $this->_aDiscountedVats = $oPriceList->getVatInfo($this->isCalculationModeNetto());
                                }
                            }

                            // apply discount to vat
                            foreach ($this->_aDiscountedVats as $sKey => $dVat) {
                                $this->_aDiscountedVats[$sKey] = \OxidEsales\Eshop\Core\Price::percent($dVat, $dVatPart);
                            }
                        }

                        // accumulating discount value
                        $this->_oVoucherDiscount->add($dVoucherdiscount);

                        // collecting formatted for preview
                        $oStdVoucher->fVoucherdiscount = $oLang->formatCurrency($dVoucherdiscount, $this->getBasketCurrency());
                        $oStdVoucher->dVoucherdiscount = $dVoucherdiscount;

                        // subtracting voucher discount
                        $dPrice = $dPrice - $dVoucherdiscount;
                    } catch (\OxidEsales\Eshop\Core\Exception\VoucherException $oEx) {
                        // removing voucher on error
                        $oVoucher->unMarkAsReserved();
                        unset($this->_aVouchers[$sVoucherId]);

                        // storing voucher error info
                        \OxidEsales\Eshop\Core\Registry::getUtilsView()->addErrorToDisplay($oEx, false, true);
                    }
                }
            }
        }
    }
29279
public function setDiscount($discount)
    {
        $discount = (float) $discount;

        if ($discount > 1) {
            $discount = min(max($discount, 0), 100);
            $discount = $discount / 100;
        }

        $this->set('discount', $discount);
    }
374088
public function getDiscount()
    {
        $discount = 0.00;

        $coupons = $this->facade->getCurrentCoupons();

        if (\count($coupons) > 0) {
            $couponsKept = $this->sortCoupons($coupons);

            $discount = $this->getEffect($couponsKept);

            // Just In Case test
            $checkoutTotalPrice = $this->facade->getCartTotalTaxPrice();

            if ($discount >= $checkoutTotalPrice) {
                $discount = $checkoutTotalPrice;
            }
        }

        return $discount;
    }
1341798
function collect_posts() {
    global $db, $currencies, $messageStack, $order;
    global $discount_coupon;
    // remove discount coupon by request
    if (isset($_POST['dc_redeem_code']) && strtoupper($_POST['dc_redeem_code']) == 'REMOVE') {
      unset($_POST['dc_redeem_code']);
      unset($_SESSION['cc_id']);
      $messageStack->add_session('checkout_payment', TEXT_REMOVE_REDEEM_COUPON, 'caution');
    }
//    print_r($_SESSION);
    // bof: Discount Coupon zoned always validate coupon for payment address changes
    // eof: Discount Coupon zoned always validate coupon for payment address changes
    if ((isset($_POST['dc_redeem_code']) && $_POST['dc_redeem_code'] != '') || (isset($discount_coupon->fields['coupon_code']) && $discount_coupon->fields['coupon_code'] != '')) {
      // set current Discount Coupon based on current or existing
      if (isset($_POST['dc_redeem_code']) && $discount_coupon->fields['coupon_code'] == '') {
        $dc_check = $_POST['dc_redeem_code'];
      } else {
        $dc_check = $discount_coupon->fields['coupon_code'];
      }



      $sql = "select coupon_id, coupon_amount, coupon_type, coupon_minimum_order, uses_per_coupon, uses_per_user,
              restrict_to_products, restrict_to_categories, coupon_zone_restriction
              from " . TABLE_COUPONS . "
              where coupon_code= :couponCodeEntered
              and coupon_active='Y'
              and coupon_type !='G'";

      $sql = $db->bindVars($sql, ':couponCodeEntered', $dc_check, 'string');

      $coupon_result=$db->Execute($sql);

      if ($coupon_result->fields['coupon_type'] != 'G') {

        if ($coupon_result->RecordCount() < 1 ) {
          $messageStack->add_session('redemptions', TEXT_INVALID_REDEEM_COUPON,'caution');
          $this->clear_posts();
          zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL',true, false));
        }
        $order_total = $this->get_order_total($coupon_result->fields['coupon_id']);

// left for total order amount vs qualified order amount just switch the commented lines
//        if ($order_total['totalFull'] < $coupon_result->fields['coupon_minimum_order']) {
        if (strval($order_total['orderTotal']) < $coupon_result->fields['coupon_minimum_order']) {

          $messageStack->add_session('redemptions', sprintf(TEXT_INVALID_REDEEM_COUPON_MINIMUM, $currencies->format($coupon_result->fields['coupon_minimum_order'])),'caution');
          $this->clear_posts();
          zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL',true, false));
        }

        // JTD - added missing code here to handle coupon product restrictions
        // look through the items in the cart to see if this coupon is valid for any item in the cart
        $products = $_SESSION['cart']->get_products();
        $foundvalid = true;

        if ($foundvalid == true) {
          $foundvalid = false;
          for ($i=0; $i<sizeof($products); $i++) {
            if (is_product_valid($products[$i]['id'], $coupon_result->fields['coupon_id'])) {
              $foundvalid = true;
              continue;
            }
          }
        }

        if (!$foundvalid) {
          $this->clear_posts();
        }

        if (!$foundvalid) zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, 'credit_class_error_code=' . $this->code . '&credit_class_error=' . urlencode(TEXT_INVALID_COUPON_PRODUCT . ' ' . $dc_check), 'SSL',true, false));
        // JTD - end of additions of missing code to handle coupon product restrictions

        $date_query=$db->Execute("select coupon_start_date from " . TABLE_COUPONS . "
                                  where coupon_start_date <= now() and
                                  coupon_code='" . zen_db_prepare_input($dc_check) . "'");

        if ($date_query->RecordCount() < 1 ) {
          $messageStack->add_session('redemptions', TEXT_INVALID_STARTDATE_COUPON,'caution');
          $this->clear_posts();
          zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false));
        }

        $date_query=$db->Execute("select coupon_expire_date from " . TABLE_COUPONS . "
                                  where coupon_expire_date >= now() and
                                  coupon_code='" . zen_db_prepare_input($dc_check) . "'");

        if ($date_query->RecordCount() < 1 ) {
          $messageStack->add_session('redemptions', TEXT_INVALID_FINISHDATE_COUPON,'caution');
          $this->clear_posts();
          zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false));
        }

        $coupon_count = $db->Execute("select coupon_id from " . TABLE_COUPON_REDEEM_TRACK . "
                                      where coupon_id = '" . (int)$coupon_result->fields['coupon_id']."'");

        $coupon_count_customer = $db->Execute("select coupon_id from " . TABLE_COUPON_REDEEM_TRACK . "
                                               where coupon_id = '" . $coupon_result->fields['coupon_id']."' and
                                               customer_id = '" . (int)$_SESSION['customer_id'] . "'");

        if ($coupon_count->RecordCount() >= $coupon_result->fields['uses_per_coupon'] && $coupon_result->fields['uses_per_coupon'] > 0) {
          $messageStack->add_session('redemptions', TEXT_INVALID_USES_COUPON . $coupon_result->fields['uses_per_coupon'] . TIMES ,'caution');
          $this->clear_posts();
          zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false));
        }

        if ($coupon_count_customer->RecordCount() >= $coupon_result->fields['uses_per_user'] && $coupon_result->fields['uses_per_user'] > 0) {
          $messageStack->add_session('redemptions', sprintf(TEXT_INVALID_USES_USER_COUPON, $dc_check) . $coupon_result->fields['uses_per_user'] . ($coupon_result->fields['uses_per_user'] == 1 ? TIME : TIMES) ,'caution');
          $this->clear_posts();
          zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false));
        }

        $_SESSION['cc_id'] = $coupon_result->fields['coupon_id'];
        if ($_SESSION['cc_id'] > 0) {
          $sql = "select coupon_id, coupon_amount, coupon_type, coupon_minimum_order, uses_per_coupon, uses_per_user,
                  restrict_to_products, restrict_to_categories, coupon_zone_restriction, coupon_code
                  from " . TABLE_COUPONS . "
                  where coupon_id= :couponIDEntered
                  and coupon_active='Y'";
          $sql = $db->bindVars($sql, ':couponIDEntered', $_SESSION['cc_id'], 'string');

          $coupon_result=$db->Execute($sql);

          $foundvalid = true;

          $check_flag = false;

          // base restrictions zone restrictions for Delivery or Billing address
          switch($coupon_result->fields['coupon_type']) {
            case 'S': // shipping
              // use delivery address
              $check_zone_country_id = $order->delivery['country']['id'];
              break;
            case 'F': // amount
              // use billing address
              $check_zone_country_id = $order->billing['country']['id'];
              break;
            case 'O': // amount off and free shipping
              // use delivery address
              $check_zone_country_id = $order->delivery['country']['id'];
              break;
            case 'P': // percentage
              // use billing address
              $check_zone_country_id = $order->billing['country']['id'];
              break;
            case 'E': // percentage and Free Shipping
              // use delivery address
              $check_zone_country_id = $order->delivery['country']['id'];
              break;
            default:
              // use billing address
              $check_zone_country_id = $order->billing['country']['id'];
              break;
          }

//          $sql = "select zone_id, zone_country_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . $coupon_result->fields['coupon_zone_restriction'] . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id";
          $sql = "select zone_id, zone_country_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . $coupon_result->fields['coupon_zone_restriction'] . "' and zone_country_id = '" . $check_zone_country_id . "' order by zone_id";
          $check = $db->Execute($sql);

          // base restrictions zone restrictions for Delivery or Billing address
          switch($coupon_result->fields['coupon_type']) {
            case 'S': // shipping
              // use delivery address
              $check_zone_id = $order->delivery['zone_id'];
              break;
            case 'F': // amount
              // use billing address
              $check_zone_id = $order->billing['zone_id'];
              break;
            case 'O': // amount off and free shipping
              // use delivery address
              $check_zone_id = $order->delivery['zone_id'];
              break;
            case 'P': // percentage
              // use billing address
              $check_zone_id = $order->billing['zone_id'];
              break;
            case 'E': // percentage and free shipping
              // use delivery address
              $check_zone_id = $order->delivery['zone_id'];
              break;
            default:
              // use billing address
              $check_zone_id = $order->billing['zone_id'];
              break;
          }

          if ($coupon_result->fields['coupon_zone_restriction'] > 0) {
            while (!$check->EOF) {
              if ($check->fields['zone_id'] < 1) {
                $check_flag = true;
                break;
//              } elseif ($check->fields['zone_id'] == $order->billing['zone_id']) {
              } elseif ($check->fields['zone_id'] == $check_zone_id) {
                $check_flag = true;
                break;
              }
              $check->MoveNext();
            }
            $foundvalid = $check_flag;
          }
          // remove if fails address validation
          if (!$foundvalid) {
            $messageStack->add_session('checkout_payment', TEXT_REMOVE_REDEEM_COUPON_ZONE, 'caution');
            $this->clear_posts();
            if (!$foundvalid) zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL',true, false));
          } else {
          //      if ($_POST['submit_redeem_coupon_x'] && !$_POST['gv_redeem_code']) zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, 'credit_class_error_code=' . $this->code . '&credit_class_error=' . urlencode(TEST_NO_REDEEM_CODE), 'SSL', true, false));
            $messageStack->add('checkout', TEXT_VALID_COUPON,'success');
          }
        }
      } else {
        $messageStack->add_session('redemptions', TEXT_INVALID_REDEEM_COUPON,'caution');
        $this->clear_posts();
        zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL',true, false));
      }

    }
  }
1228212
public function getCouponAbsoluteValue(
        CartInterface $cart,
        CouponInterface $coupon
    ) {
        $currency = $this
            ->currencyWrapper
            ->get();

        $couponPrice = Money::create(
            0,
            $currency
        );

        $value = $coupon->getValue();
        preg_match($this->regexp(), $value, $match);
        $m = (int) $match[1];
        $n = (int) $match[2];
        $expressionValue = isset($match[3]) ? $match[3] : '';
        $modifiers = isset($match[4]) ? $match[4] : '';

        $totalElements = 0;
        $moneys = [];
        $freePerGroup = $m - $n;
        $freePerGroup = max($freePerGroup, 0);

        foreach ($cart->getCartLines() as $cartLine) {
            $purchasable = $cartLine->getPurchasable();
            $expressionEvaluator = $this->getExpressionLanguageInstance();
            $expressionResult =
                (
                    empty($expressionValue) ||
                    $expressionEvaluator->evaluate($expressionValue, [
                        'purchasable' => $purchasable,
                    ])
                ) &&
                $this->evaluatePurchasableType($purchasable, $modifiers);

            if (true === $expressionResult) {
                $partialElements = $cartLine->getQuantity();
                $totalElements += $partialElements;
                for ($i = 0; $i < $partialElements; ++$i) {
                    $partialPurchasable = $cartLine->getPurchasable();
                    $moneys[] = $partialPurchasable->getReducedPrice()->getAmount() > 0
                        ? $partialPurchasable->getReducedPrice()
                        : $partialPurchasable->getPrice();
                }
            }
        }

        usort($moneys, function (MoneyInterface $a, MoneyInterface $b) {
            $aCurrency = $a->getCurrency();
            $bPriceInACurrency = $this
                ->currencyConverter
                ->convertMoney(
                    $b,
                    $aCurrency
                );

            return $a->isGreaterThan($bPriceInACurrency)
                ? 1
                : -1;
        });
        $groups = floor($totalElements / $m);
        if ($groups > 0) {
            $nbMoneys = $groups * $freePerGroup;
            $moneysToDiscount = array_slice($moneys, 0, $nbMoneys);

            foreach ($moneysToDiscount as $moneyToDiscount) {
                $couponPrice = $couponPrice->add(
                    $this
                        ->currencyConverter
                        ->convertMoney(
                            $moneyToDiscount,
                            $currency
                        )
                );
            }
        }

        return $couponPrice;
    }
368212
public function getTotalAmount()
    {
        $total_amount = $this->unit_price * $this->quantity;

        if (!empty($this->total_discount_amount)) {
            return $total_amount - $this->total_discount_amount;
        }
        return $total_amount;
    }
1362909
public function getDiscountsAmount()
    {
        $discountsAmount = 0;

        if (count($this->getDiscounts())) {
            // Discount amount based on global ticket discounts
            foreach ($this->getDiscounts() as $discount) {
                /** @var \Argentum\Common\Discount $discount */
                $discountsAmount += $discount->getAmount();
            }
        } else {
            // Discount amount based on items discounts
            foreach ($this->getItems() as $item) {
                /** @var \Argentum\Common\Item $item */
                $discountsAmount += $item->getDiscount();
            }
        }

        return $discountsAmount;
    }
90273
public function ApplyDiscount(TdbShopDiscount $oDiscount)
    {
        $iCurrentPosition = $this->getItemPointer();
        $this->GoToStart();

        $dTotalDiscountValue = 0;
        $bIsAbsoluteDiscount = ('absolut' == $oDiscount->fieldValueType);
        if ($bIsAbsoluteDiscount) {
            $dTotalDiscountValue = $oDiscount->fieldValue;
        }

        $totalDiscountValueItemCalculated = 0;
        while ($oItem = &$this->Next()) {
            if ((!$bIsAbsoluteDiscount || $dTotalDiscountValue > 0) && $oDiscount->AllowDiscountForArticle($oItem)) {
                $oDiscountToPass = clone $oDiscount;
                $oItem->ApplyDiscount($oDiscountToPass, $dTotalDiscountValue);
                $totalDiscountValueItemCalculated += $oDiscountToPass->dRealValueUsed;
            }
        }
        $totalDiscountValueOverAll = $oDiscount->GetValue();
        if ($totalDiscountValueOverAll !== $totalDiscountValueItemCalculated) {
            $missingDiscountValue = $totalDiscountValueOverAll - $totalDiscountValueItemCalculated;
            $this->reducePriceForItemsAffectedByDiscount($oDiscount, $missingDiscountValue);
        }
        $this->setItemPointer($iCurrentPosition);
    }