DocBlocks

This commit is contained in:
1day2die 2021-11-07 18:02:53 +01:00
parent 9ac391d75b
commit 487040f06a
2 changed files with 28 additions and 9 deletions

View file

@ -53,7 +53,13 @@ class Payment extends Model
{ {
return $this->belongsTo(User::class); return $this->belongsTo(User::class);
} }
public function formatToCurrency($value,$locale = 'de_DE')
/**
* @param float/int
* @param string
* @return string
*/
public function formatToCurrency($value,$locale = 'en_US')
{ {
$formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY); $formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);
return $formatter->formatCurrency($value, $this->currency_code); return $formatter->formatCurrency($value, $this->currency_code);

View file

@ -41,28 +41,41 @@ class PaypalProduct extends Model
} }
/** /**
* @param float/int
* @param string $locale * @param string $locale
* @return string * @return string
*/ */
public function formatToCurrency($value,$locale = 'de_DE') public function formatToCurrency($value,$locale = 'en_US')
{ {
$formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY); $formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);
return $formatter->formatCurrency($value, $this->currency_code); return $formatter->formatCurrency($value, $this->currency_code);
} }
public function getTaxPercent(){ /**
* @desc Returns the tax in % or 0 if less than 0
* @return int
*/
public function getTaxPercent()
{
$tax = Configuration::getValueByKey("SALES_TAX"); $tax = Configuration::getValueByKey("SALES_TAX");
if ( $tax < 0 ) { return $tax < 0 ? 0 : $tax;
return 0;
}
return $tax;
} }
public function getTaxValue(){ /**
* @desc Returns the total tax value.
* @return float
*/
public function getTaxValue()
{
return $this->price*$this->getTaxPercent()/100; return $this->price*$this->getTaxPercent()/100;
} }
public function getTotalPrice(){ /**
* @desc Returns the total price incl. tax
* @return float
*/
public function getTotalPrice()
{
return $this->price+($this->getTaxValue()); return $this->price+($this->getTaxValue());
} }
} }