<commit_before><?php

namespace Dime\TimetrackerBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Dime\TimetrackerBundle\Model\DimeEntityInterface;
use JMS\Serializer\Annotation as JMS;

/**
 * Class StandardDiscount
 * @package Dime\TimetrackerBundle\Entity
 * @ORM\Entity(repositoryClass="Dime\TimetrackerBundle\Entity\StandardDiscountRepository")
 * @ORM\Table(name="standard_discounts")
 */
class StandardDiscount extends Entity implements DimeEntityInterface
{

	/**
	 * @var
	 * @ORM\Column(type="string")
	 */
	protected $name;

	/**
	 * @var
	 * @ORM\Column(type="decimal", precision=10, scale=2)
	 */
	protected $value;

	/**
	 * @var
	 * @ORM\Column(type="boolean", nullable=true)
	 */
	protected $percentage;

	/**
	 * @var
	 * @ORM\Column(type="boolean", nullable=true)
	 */
	protected $minus;

    /**
     * @JMS\VirtualProperty
     * @JMS\SerializedName("getCalculatedDiscount")
     *
     * @return fload
     */
    public function getCalculatedDiscount($subtotal=0)
    {
        if($this->percentage)
            return $this->value * $subtotal;
        else
            return $this->value;
    }

	/**
	 * @return mixed
	 */
	public function getName()
	{<commit_msg>Added: Proper Monetary Value Support to Offer.<commit_after><?php

namespace Dime\TimetrackerBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Dime\TimetrackerBundle\Model\DimeEntityInterface;
use JMS\Serializer\Annotation as JMS;
use Swo\Money\lib\Money\Money;

/**
 * Class StandardDiscount
 * @package Dime\TimetrackerBundle\Entity
 * @ORM\Entity(repositoryClass="Dime\TimetrackerBundle\Entity\StandardDiscountRepository")
 * @ORM\Table(name="standard_discounts")
 */
class StandardDiscount extends Entity implements DimeEntityInterface
{

	/**
	 * @var
	 * @ORM\Column(type="string")
	 */
	protected $name;

	/**
	 * @var
	 * @ORM\Column(type="decimal", precision=10, scale=2)
	 */
	protected $value;

	/**
	 * @var
	 * @ORM\Column(type="boolean", nullable=true)
	 */
	protected $percentage;

	/**
	 * @var
	 * @ORM\Column(type="boolean", nullable=true)
	 */
	protected $minus;

	/**
	 * @param Money $subtotal
	 *
	 * @return Money
	 */
    public function getCalculatedDiscount(Money $subtotal)
    {
        if($this->percentage)
            return $subtotal->multiply(floatval($this->value));
        else
            return Money::CHF($this->value);
    }

	/**
	 * @return mixed
	 */
	public function getName()
	{
{'fraction_non_alphanumeric': 0.14640198511166252, 'fraction_numerical': 0.0028949545078577337, 'mean_word_length': 3.513059701492537, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4862716', 'n_tokens_mistral': 826, 'n_tokens_neox': 773, 'n_words': 137}