added discount location setting
This commit is contained in:
@ -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'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user