Added some tests for important entity methods.

This commit is contained in:
Jan Böhmer 2019-11-09 00:31:42 +01:00
parent 0663a00df8
commit 89258bc102
18 changed files with 480 additions and 160 deletions

View file

@ -130,25 +130,15 @@ class Pricedetail extends DBElement
*********************************************************************************/
/**
* Get the orderdetails of this pricedetails.
* Get the orderdetail to which this pricedetail belongs to this pricedetails.
*
* @return Orderdetail the orderdetails object
* @return Orderdetail The orderdetail this price belongs to.
*/
public function getOrderdetails(): Orderdetail
public function getOrderdetail(): Orderdetail
{
return $this->orderdetail;
}
/**
* Returns the price associated with this pricedetail.
* It is given in current currency and for the price related quantity.
* @return float
*/
public function getPriceFloat() : float
{
return (float) $this->price;
}
/**
* Returns the price associated with this pricedetail.
* It is given in current currency and for the price related quantity.
@ -159,16 +149,6 @@ class Pricedetail extends DBElement
return $this->price;
}
/**
* Returns the price associated with this pricedetail as integer.
* It is given in current currency and for the price related quantity, in parts of 0.00001 (5 digits)
* @return int
*/
public function getPriceInt() : int
{
return (int) str_replace('.', '', $this->price);
}
/**
* Get the price for a single unit in the currency associated with this price detail.
*
@ -179,7 +159,6 @@ class Pricedetail extends DBElement
* in the database, you have to pass the "price_related_quantity" count as $multiplier.
*
* @return string the price as a bcmath string
*/
public function getPricePerUnit($multiplier = 1.0) : string
{
@ -201,7 +180,7 @@ class Pricedetail extends DBElement
*/
public function getPriceRelatedQuantity(): float
{
if ($this->orderdetail && $this->orderdetail->getPart() && !$this->orderdetail->getPart()->useFloatAmount()) {
if ($this->orderdetail && $this->orderdetail->getPart() && !$this->orderdetail->getPart()->useFloatAmount()) {
$tmp = round($this->price_related_quantity);
return $tmp < 1 ? 1 : $tmp;
}