46 lines
No EOL
1.1 KiB
PHP
46 lines
No EOL
1.1 KiB
PHP
<?php
|
|
namespace App\Services\Yard;
|
|
|
|
use App\Services\Util;
|
|
|
|
class MarginItems
|
|
{
|
|
public $price_from;
|
|
public $range;
|
|
public $rest_amount;
|
|
|
|
public $balance;
|
|
|
|
public $value_margin;
|
|
public $new_price_net;
|
|
public $trading_margin;
|
|
|
|
public $value_commission;
|
|
public $commission;
|
|
|
|
public function __construct($price_from, $values)
|
|
{
|
|
$this->price_from = $price_from;
|
|
$this->range = $values['range'];
|
|
$this->rest_amount = $values['rest_amount'];
|
|
$this->balance = $values['balance'];
|
|
$this->trading_margin = $values['trading_margin'];
|
|
$this->commission = $values['commission'];
|
|
$this->calculate();
|
|
}
|
|
|
|
public function calculate(){
|
|
$this->value_margin = $this->balance / 100 * $this->trading_margin;
|
|
$this->new_price_net = $this->balance - $this->value_margin;
|
|
if($this->commission > 0){
|
|
$this->value_commission = $this->balance / 100 * $this->commission;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function getFormatted($key)
|
|
{
|
|
return isset($this->{$key}) ? Util::formatNumber($this->{$key}) : "";
|
|
}
|
|
} |