Used to set the discount coupon

@return float
548245
public function setCoupon($coupon)
    {
        if ($coupon->value > 0) {
            $this->coupon['value'] = $coupon->value;
        }
        elseif ($coupon->discount > 0) {
            $this->coupon['percent'] = $coupon->discount;
        }
        session(['coupon' => $coupon]);
    }
771710
protected function _calcBasketDiscount()
    {
        // resetting
        $this->_aDiscounts = [];

        // P using prices sum which has discount, not sum of skipped discounts
        $dOldPrice = $this->_oDiscountProductsPriceList->getSum($this->isCalculationModeNetto());

        // add basket discounts
        if ($this->_oTotalDiscount !== null && isset($this->_isForOrderRecalculation) && $this->_isForOrderRecalculation) {
            //if total discount was set on order recalculation
            $oTotalPrice = $this->getTotalDiscount();
            $oDiscount = oxNew(\OxidEsales\Eshop\Application\Model\Discount::class);
            $oDiscount->oxdiscount__oxaddsum = new \OxidEsales\Eshop\Core\Field($oTotalPrice->getPrice());
            $oDiscount->oxdiscount__oxaddsumtype = new \OxidEsales\Eshop\Core\Field('abs');
            $aDiscounts[] = $oDiscount;
        } else {
            // discounts for basket
            $aDiscounts = \OxidEsales\Eshop\Core\Registry::get(\OxidEsales\Eshop\Application\Model\DiscountList::class)->getBasketDiscounts($this, $this->getBasketUser());
        }

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

        /** @var \oxDiscount $oDiscount */
        foreach ($aDiscounts as $oDiscount) {
            // storing applied discounts
            $oStdDiscount = $oDiscount->getSimpleDiscount();

            // skipping bundle discounts
            if ($oDiscount->oxdiscount__oxaddsumtype->value == 'itm') {
                continue;
            }

            // saving discount info
            $oStdDiscount->dDiscount = $oDiscount->getAbsValue($dOldPrice);

            $dVatPart = 100 - $oDiscount->getPercentage($dOldPrice);

            // if discount is more than basket sum
            if ($dOldPrice < $oStdDiscount->dDiscount) {
                $oStdDiscount->dDiscount = $dOldPrice;
                $dVatPart = 0;
            }

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

            //storing discount
            if ($oStdDiscount->dDiscount != 0) {
                $this->_aDiscounts[$oDiscount->getId()] = $oStdDiscount;
                // subtracting product price after discount
                $dOldPrice = $dOldPrice - $oStdDiscount->dDiscount;
            }
        }
    }
513596
public function getTotalPrice( $precision = 2 ) {

		$price	= ( $this->price - $this->discount ) * $this->purchase;

		return round( $price, $precision );
	}
741970
public function discount()
    {
        return $this->formatAmount($this->invoice->subtotal + $this->invoice->tax - $this->invoice->total);
    }
500754
public function DiscountForm()
    {
        $form = DiscountCodeForm::create(
            $this,
            "DiscountForm",
            ShoppingCartFactory::create()->getCurrent()
        );
        
        $this->extend("updateDiscountForm", $form);
        
        return $form;
    }
907745
public function discount($throwErrors = false)
    {
        $subTotal = app(LaraCart::SERVICE)->subTotal(false);

        if (config('laracart.discountOnFees', false)) {
            $subTotal = $subTotal + app(LaraCart::SERVICE)->feeTotals(false);
        }

        $total = $subTotal - $this->value;

        if ($total < 0) {
            return $subTotal;
        }

        return $this->value;
    }
1134236
protected function setSubtotal()
    {
        $this->subtotal = round($this->items->sum(function ($cartItem) {
            return $cartItem->price * $cartItem->quantity;
        }), 2);
    }
1241631
public function getDiscount() : ?int 
    {
        if ( ! $this->hasDiscount()) {
            $this->setDiscount($this->getDefaultDiscount());
        }
        return $this->discount;
    }
628961
public function save()
    {
        parent::save();

        $sOxId = $this->getEditObjectId();
        $aParams = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("editval");

        $oDiscount = oxNew(\OxidEsales\Eshop\Application\Model\Discount::class);
        if ($sOxId != "-1") {
            $oDiscount->load($sOxId);
        } else {
            $aParams['oxdiscount__oxid'] = null;
        }

        // checkbox handling
        if (!isset($aParams['oxdiscount__oxactive'])) {
            $aParams['oxdiscount__oxactive'] = 0;
        }

        //disabling derived items
        if ($oDiscount->isDerived()) {
            return;
        }

        //$aParams = $oAttr->ConvertNameArray2Idx( $aParams);
        $oDiscount->setLanguage(0);
        $oDiscount->assign($aParams);
        $oDiscount->setLanguage($this->_iEditLang);
        $oDiscount = \OxidEsales\Eshop\Core\Registry::getUtilsFile()->processFiles($oDiscount);
        try {
            $oDiscount->save();
        } catch (\oxInputException $exception) {
            $newException = oxNew(\OxidEsales\Eshop\Core\Exception\ExceptionToDisplay::class);
            $newException->setMessage($exception->getMessage());
            $this->addTplParam('discount_title', $aParams['oxdiscount__oxtitle']);

            if (false !== strpos($exception->getMessage(), 'DISCOUNT_ERROR_OXSORT')) {
                $messageArgument = \OxidEsales\Eshop\Core\Registry::getLang()->translateString('DISCOUNT_MAIN_SORT', \OxidEsales\Eshop\Core\Registry::getLang()->getTplLanguage(), true);
                $newException->setMessageArgs($messageArgument);
            }

            \OxidEsales\Eshop\Core\Registry::getUtilsView()->addErrorToDisplay($newException);

            return;
        }

        // set oxid if inserted
        $this->setEditObjectId($oDiscount->getId());
    }
330805
public function getTax()
    {
        $amount = 0;

        if ($this->Price && $this->TaxRate) {
            $amount = (($this->Price - $this->Discount) / 100) * $this->TaxRate;
        }
        
        return $amount;
    }
438881
protected function getDiscountPriceValueAttribute()
    {
        $obPriceModel = $this->getPriceObject($this->getActivePriceType());
        $this->setActivePriceType(null);

        if (empty($obPriceModel)) {
            return 0;
        }

        $fPrice = $obPriceModel->discount_price_value;
        $fPrice = CurrencyHelper::instance()->convert($fPrice, $this->getActiveCurrency());

        return $fPrice;
    }
1030419
function annual_discount_percentage() {
			return floor( $this->annual_savings() / ( $this->monthly_price * 12 * ( $this->is_unlimited() ? 1 : $this->licenses ) ) * 100 );
		}
277910
public function _getDiscountedProductsSum()
    {
        if ($oProductsPrice = $this->getDiscountProductsPrice()) {
            $dPrice = $oProductsPrice->getSum($this->isCalculationModeNetto());
        }

        // subtracting total discount
        if ($oPrice = $this->getTotalDiscount()) {
            $dPrice -= $oPrice->getPrice();
        }

        if ($oVoucherPrice = $this->getVoucherDiscount()) {
            $dPrice -= $oVoucherPrice->getPrice();
        }

        return $dPrice;
    }
787559
public function process()
	{
		$view = $this->getView();
		$context = $this->_getContext();

		switch( $view->param( 'b-action' ) )
		{
			case 'coupon-delete':

				if( ( $coupon = $view->param( 'b-coupon' ) ) != '' )
				{
					$this->_clearCached();
					$cntl = Controller_Frontend_Factory::createController( $context, 'basket' );
					$cntl->deleteCoupon( $coupon );
				}

				break;

			default:

				if( ( $coupon = $view->param( 'b-coupon' ) ) != '' )
				{
					$this->_clearCached();
					$cntl = Controller_Frontend_Factory::createController( $context, 'basket' );

					/** client/html/basket/standard/coupon/allowed
					 * Number of coupon codes a customer is allowed to enter
					 *
					 * This configuration option enables shop owners to limit the number of coupon
					 * codes that can be added by a customer to his current basket. By default, only
					 * one coupon code is allowed per order.
					 *
					 * Coupon codes are valid until a payed order is placed by the customer. The
					 * "count" of the codes is decreased afterwards. If codes are not personalized
					 * the codes can be reused in the next order until their "count" reaches zero.
					 *
					 * @param integer Positive number of coupon codes including zero
					 * @since 2014.05
					 * @category User
					 * @category Developer
					 */
					$allowed = $context->getConfig()->get( 'client/html/basket/standard/coupon/allowed', 1 );

					if( $allowed <= count( $cntl->get()->getCoupons() ) ) {
						throw new Client_Html_Exception( sprintf( 'Number of coupon codes exceeds the limit' ) );
					}

					$cntl->addCoupon( $coupon );
				}

				break;
		}

		parent::process();
	}
779614
public function setUpgradeDiscount($discount)
    {
        if ($this->ordering <= 1) {
            $discount = 0;
        }

        $discount = (float) min(1, max(0, $discount));
        $this->setValue('upgrade_discount', $discount);

        return $this;
    }
895007
public function getTotalTax()
    {
        $amount = 0;

        if ($this->Price && $this->TaxRate && $this->Quantity) {
            $amount = ((($this->Price * $this->Quantity) - $this->Discount) / 100) * $this->TaxRate;
        }
        
        return $amount;
    }
215914
public function totals()
    {
        setlocale(LC_MONETARY, config('cart_manager.LC_MONETARY'));

        $totals = ['Subtotal' => money_format('%n', $this->subtotal)];

        if ($this->discount > 0) {
            $totals['Discount'] = money_format('%n', $this->discount);
        }

        if ($this->shippingCharges > 0) {
            $totals['Shipping charges'] = money_format('%n', $this->shippingCharges);
        }

        if ($this->subtotal != $this->netTotal) {
            $totals['Net total'] = money_format('%n', $this->netTotal);
        }

        $totals['Tax'] = money_format('%n', $this->tax);

        if ($this->roundOff != 0) {
            $totals['Total'] = money_format('%n', $this->total);
            $totals['Round off'] = money_format('%n', $this->roundOff);
        }

        $totals['Payable'] = money_format('%n', $this->payable);

        return $totals;
    }