added discount location setting

This commit is contained in:
denisdulici
2020-03-26 16:20:31 +03:00
parent 795ddf8aeb
commit eedb5b30a6
15 changed files with 405 additions and 309 deletions

View File

@ -41,12 +41,20 @@ class Localisation extends Controller
'after' => trans('settings.localisation.percent.after'),
];
$discount_locations = [
'no' => trans('general.disabled'),
'item' => trans('settings.localisation.discount_location.item'),
'total' => trans('settings.localisation.discount_location.total'),
'both' => trans('settings.localisation.discount_location.both'),
];
return view('settings.localisation.edit', compact(
'setting',
'timezones',
'date_formats',
'date_separators',
'percent_positions'
'percent_positions',
'discount_locations'
));
}
}

View File

@ -13,6 +13,13 @@ class BillItem extends Model
protected $table = 'bill_items';
/**
* The accessors to append to the model's array form.
*
* @var array
*/
protected $appends = ['discount'];
/**
* Attributes that should be mass-assignable.
*
@ -100,12 +107,12 @@ class BillItem extends Model
*
* @return string
*/
public function getDiscountRateAttribute($value)
public function getDiscountAttribute()
{
if (setting('localisation.percent_position', 'after') === 'after') {
$text = ($this->discount_type === 'normal') ? $value . '%' : $value;
$text = ($this->discount_type === 'normal') ? $this->discount_rate . '%' : $this->discount_rate;
} else {
$text = ($this->discount_type === 'normal') ? '%' . $value : $value;
$text = ($this->discount_type === 'normal') ? '%' . $this->discount_rate : $this->discount_rate;
}
return $text;

View File

@ -12,6 +12,13 @@ class InvoiceItem extends Model
protected $table = 'invoice_items';
/**
* The accessors to append to the model's array form.
*
* @var array
*/
protected $appends = ['discount'];
/**
* Attributes that should be mass-assignable.
*
@ -99,12 +106,12 @@ class InvoiceItem extends Model
*
* @return string
*/
public function getDiscountRateAttribute($value)
public function getDiscountAttribute()
{
if (setting('localisation.percent_position', 'after') === 'after') {
$text = ($this->discount_type === 'normal') ? $value . '%' : $value;
$text = ($this->discount_type === 'normal') ? $this->discount_rate . '%' : $this->discount_rate;
} else {
$text = ($this->discount_type === 'normal') ? '%' . $value : $value;
$text = ($this->discount_type === 'normal') ? '%' . $this->discount_rate : $this->discount_rate;
}
return $text;