Exemple #1
0
 /**
  * @deprecated: Constructor will be private within few next releases
  * It is not possible to calculate correct tax rate for a given nett and gross
  * Dedicated class will be introduced to allow building price with these data but
  * acquiring tax value will be prohibited
  *
  * Building price is only possible using:
  * - buildByGross()
  * - buildByNett()
  * - buildEmpty()
  *
  * @param float $nett
  * @param float $gross
  * @param string $currencySymbol
  */
 public function __construct($nett = 0.0, $gross = 0.0, $currencySymbol, $tax = null)
 {
     //var_dump($tax);
     //todo: check tax
     $this->currency = new Currency($currencySymbol);
     $this->nett = new Money($nett);
     $this->gross = new Money($gross);
     if ($this->nett->isGreaterThan($this->gross)) {
         throw new \LogicException('Nett must not be greater than gross');
     }
     if (is_null($tax)) {
         $this->tax = Tax::build($nett, $gross);
         $this->mixedTax = true;
     } else {
         $this->tax = new Tax($tax);
         $this->tax->validate($nett, $gross);
     }
 }