Skip to content

Instantly share code, notes, and snippets.

@makasim
Created October 30, 2018 09:18
Show Gist options
  • Save makasim/18183bbeb3bda24845f0b747e12dcd4a to your computer and use it in GitHub Desktop.
Save makasim/18183bbeb3bda24845f0b747e12dcd4a to your computer and use it in GitHub Desktop.
<?php
namespace Ecom\Price\Model;
use Makasim\Values\ValuesTrait;
class Price
{
use ValuesTrait;
/**
* Must return ISO4217 currency code
*
* @return string
*/
public function getCurrency()
{
return $this->getSelfValue('currency');
}
/**
* Must be ISO4217 currency code
*
* @param string $currency
*/
public function setCurrency($currency)
{
$this->setSelfValue('currency', $currency);
}
/**
* The percent rate in a range 0..100
*
* @return float
*/
public function getTaxRate()
{
return $this->getSelfValue('taxRate', null, 'float');
}
/**
* The percent rate in a range 0..100
*
* @param float $taxRate
*/
public function setTaxRate($taxRate)
{
$this->setSelfValue('taxRate', $taxRate);
}
/**
* @return float
*/
public function getTaxWithDiscount()
{
return $this->getSelfValue('taxWithDiscount', null, 'float');
}
/**
* @param float $tax
*/
public function setTaxWithDiscount($tax)
{
$this->setSelfValue('taxWithDiscount', $tax);
}
/**
* @return float
*/
public function getTax()
{
return $this->getSelfValue('tax', null, 'float');
}
/**
* @param float $tax
*/
public function setTax($tax)
{
$this->setSelfValue('tax', $tax);
}
/**
* @return float
*/
public function getDiscount()
{
return $this->getSelfValue('discount', null, 'float');
}
/**
* @param float $discount
*/
public function setDiscount($discount)
{
$this->setSelfValue('discount', $discount);
}
/**
* @return float
*/
public function getDiscountTax()
{
return $this->getSelfValue('discountTax', null, 'float');
}
/**
* @param float $discountTax
*/
public function setDiscountTax($discountTax)
{
$this->setSelfValue('discountTax', $discountTax);
}
/**
* @return float
*/
public function getDiscountWithTax()
{
return $this->getSelfValue('discountWithTax', null, 'float');
}
/**
* @param float $discountWithTax
*/
public function setDiscountWithTax($discountWithTax)
{
$this->setSelfValue('discountWithTax', $discountWithTax);
}
/**
* The percent discount fraction in a range 0..100
*
* @return float
*/
public function getDiscountFraction()
{
return $this->getSelfValue('discountFraction', null, 'float');
}
/**
* The percent discount fraction in a range 0..100
*
* @param float $discountFraction
*/
public function setDiscountFraction($discountFraction)
{
$this->setSelfValue('discountFraction', $discountFraction);
}
/**
* @return float
*/
public function getAmount()
{
return $this->getSelfValue('amount', null, 'float');
}
/**
* @param float $amount
*/
public function setAmount($amount)
{
$this->setSelfValue('amount', $amount);
}
/**
* @return float
*/
public function getAmountWithDiscount()
{
return $this->getSelfValue('amountWithDiscount', null, 'float');
}
/**
* @param float $amountWithDiscount
*/
public function setAmountWithDiscount($amountWithDiscount)
{
$this->setSelfValue('amountWithDiscount', $amountWithDiscount);
}
/**
* @return float
*/
public function getAmountWithTax()
{
return $this->getSelfValue('amountWithTax', null, 'float');
}
/**
* @param float $amountWithTax
*/
public function setAmountWithTax($amountWithTax)
{
$this->setSelfValue('amountWithTax', $amountWithTax);
}
/**
* @return float
*/
public function getAmountWithDiscountTax()
{
return $this->getSelfValue('amountWithDiscountTax', null, 'float');
}
/**
* @param float $amountWithDiscountTax
*/
public function setAmountWithDiscountTax($amountWithDiscountTax)
{
$this->setSelfValue('amountWithDiscountTax', $amountWithDiscountTax);
}
/**
* @return Price
*/
public static function zero($currency = null)
{
$zero = new static();
$zero->setCurrency($currency);
$zero->setAmount(0);
$zero->setAmountWithTax(0);
$zero->setAmountWithDiscountTax(0);
$zero->setAmountWithDiscount(0);
$zero->setDiscount(0);
$zero->setDiscountFraction(0);
$zero->setDiscountTax(0);
$zero->setDiscountWithTax(0);
$zero->setTax(0);
$zero->setTaxWithDiscount(0);
$zero->setTaxRate(0);
return $zero;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment