protected function _createMonetaryRebateProducts( MShop_Order_Item_Base_Interface $base,
		$productCode, $rebate, $quantity = 1, $warehouse = 'default' )
	{
		$orderProducts = array();
		$prices = $this->_getPriceByTaxRate( $base );

		krsort( $prices );

		if( empty( $prices ) ) {
			$prices = array( '0.00' => MShop_Factory::createManager( $this->_getContext(), 'price' )->createItem() );
		}

		foreach( $prices as $taxrate => $price )
		{
			if( abs( $rebate ) < 0.01 ) {
				break;
			}

			$amount = $price->getValue() + $price->getCosts();

			if( $amount > 0 && $amount < $rebate )
			{
				$value = $price->getValue() + $price->getCosts();
				$rebate -= $value;
			}
			else
			{
				$value = $rebate;
				$rebate = '0.00';
			}

			$orderProduct = $this->_createProduct( $productCode, $quantity, $warehouse );

			$price = $orderProduct->getPrice();
			$price->setValue( -$value );
			$price->setRebate( $value );
			$price->setTaxRate( $taxrate );

			$orderProduct->setPrice( $price );

			$orderProducts[] = $orderProduct;
		}

		return $orderProducts;
	}
protected function _createMonetaryRebateProducts( MShop_Order_Item_Base_Interface $base,
		$productCode, $rebate, $quantity = 1, $warehouse = 'default' )
	{
		$orderProducts = array();
		$prices = $this->_getPriceByTaxRate( $base );

		krsort( $prices );

		if( empty( $prices ) ) {
			$prices = array( '0.00' => MShop_Factory::createManager( $this->_getContext(), 'price' )->createItem() );
		}

		foreach( $prices as $taxrate => $price )
		{
			if( abs( $rebate ) < 0.01 ) {
				break;
			}

			$amount = $price->getValue() + $price->getCosts();

			if( $amount > 0 && $amount < $rebate )
			{
				$value = $price->getValue() + $price->getCosts();
				$rebate -= $value;
			}
			else
			{
				$value = $rebate;
				$rebate = '0.00';
			}

			$orderProduct = $this->_createProduct( $productCode, $quantity, $warehouse );

			$price = $orderProduct->getPrice();
			$price->setValue( -$value );
			$price->setRebate( $value );
			$price->setTaxRate( $taxrate );

			$orderProduct->setPrice( $price );

			$orderProducts[] = $orderProduct;
		}

		return $orderProducts;
	}
protected function _createMonetaryRebateProducts ( MShop_Order_Item_Base_Interface $ base , $ productCode , $ rebate , $ quantity = 1 , $ warehouse = 'default' ) { $ orderProducts = array ( ) ; $ prices = $ this -> _getPriceByTaxRate ( $ base ) ; krsort ( $ prices ) ; if ( empty ( $ prices ) ) { $ prices = array ( '0.00' => MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'price' ) -> createItem ( ) ) ; } foreach ( $ prices as $ taxrate => $ price ) { if ( abs ( $ rebate ) < 0.01 ) { break ; } $ amount = $ price -> getValue ( ) + $ price -> getCosts ( ) ; if ( $ amount > 0 && $ amount < $ rebate ) { $ value = $ price -> getValue ( ) + $ price -> getCosts ( ) ; $ rebate -= $ value ; } else { $ value = $ rebate ; $ rebate = '0.00' ; } $ orderProduct = $ this -> _createProduct ( $ productCode , $ quantity , $ warehouse ) ; $ price = $ orderProduct -> getPrice ( ) ; $ price -> setValue ( - $ value ) ; $ price -> setRebate ( $ value ) ; $ price -> setTaxRate ( $ taxrate ) ; $ orderProduct -> setPrice ( $ price ) ; $ orderProducts [ ] = $ orderProduct ; } return $ orderProducts ; }
Creates the order products for monetary rebates.

@param MShop_Order_Item_Base_Interface Basket object
@param string $productCode Unique product code
@param float $rebate Rebate amount that should be granted
@param integer $quantity Number of products in basket
@param string $warehouse Unique code of the warehouse the product is from
@return MShop_Order_Item_Base_Product_Interface[] Order products with monetary rebates
Creates the order products for monetary rebates .