1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
invoiceninja/app/Models/AccountGatewaySettings.php

72 lines
1.4 KiB
PHP
Raw Normal View History

2017-01-30 20:40:43 +01:00
<?php
namespace App\Models;
2016-09-15 12:41:09 +02:00
2017-03-14 22:27:09 +01:00
use Utils;
2016-09-15 12:41:09 +02:00
/**
2017-01-30 20:40:43 +01:00
* Class AccountGatewaySettings.
2016-09-15 12:41:09 +02:00
*/
class AccountGatewaySettings extends EntityModel
{
/**
* @var array
*/
protected $dates = ['updated_at'];
2017-03-14 14:18:31 +01:00
/**
* @var array
*/
protected $fillable = [
'fee_amount',
'fee_percent',
'fee_tax_name1',
'fee_tax_rate1',
'fee_tax_name2',
'fee_tax_rate2',
];
2016-09-15 12:41:09 +02:00
/**
* @var bool
*/
protected static $hasPublicId = false;
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function gatewayType()
{
return $this->belongsTo('App\Models\GatewayType');
}
public function setCreatedAtAttribute($value)
{
// to Disable created_at
}
2017-03-14 22:27:09 +01:00
public function areFeesEnabled()
{
return floatval($this->fee_amount) || floatval($this->fee_percent);
}
2017-03-17 11:13:27 +01:00
public function hasTaxes()
{
return floatval($this->fee_tax_rate1) || floatval($this->fee_tax_rate1);
}
2017-03-14 22:27:09 +01:00
public function feesToString()
{
$parts = [];
2017-03-16 16:32:46 +01:00
if (floatval($this->fee_amount) != 0) {
2017-03-14 22:27:09 +01:00
$parts[] = Utils::formatMoney($this->fee_amount);
}
2017-03-16 16:32:46 +01:00
if (floatval($this->fee_percent) != 0) {
2017-03-16 15:03:17 +01:00
$parts[] = (floor($this->fee_percent * 1000) / 1000) . '%';
2017-03-14 22:27:09 +01:00
}
return join(' + ', $parts);
}
2016-09-15 12:41:09 +02:00
}