fixed discount percentage #297
This commit is contained in:
parent
acf8247c98
commit
c37203076c
@ -170,18 +170,16 @@ class Bill extends Model
|
||||
*/
|
||||
public function getDiscountAttribute()
|
||||
{
|
||||
$discount = 0;
|
||||
$percent = 0;
|
||||
|
||||
foreach ($this->totals as $total) {
|
||||
if ($total->code != 'discount') {
|
||||
continue;
|
||||
}
|
||||
$discount = $this->totals()->where('code', 'discount')->value('amount');
|
||||
|
||||
$discount = number_format((($total->amount * 100) / $this->amount), 0);
|
||||
if ($discount) {
|
||||
$sub_total = $this->totals()->where('code', 'sub_total')->value('amount');
|
||||
|
||||
break;
|
||||
$percent = number_format((($discount * 100) / $sub_total), 0);
|
||||
}
|
||||
|
||||
return $discount;
|
||||
return $percent;
|
||||
}
|
||||
}
|
||||
|
@ -172,18 +172,16 @@ class Invoice extends Model
|
||||
*/
|
||||
public function getDiscountAttribute()
|
||||
{
|
||||
$discount = 0;
|
||||
$percent = 0;
|
||||
|
||||
foreach ($this->totals as $total) {
|
||||
if ($total->code != 'discount') {
|
||||
continue;
|
||||
}
|
||||
$discount = $this->totals()->where('code', 'discount')->value('amount');
|
||||
|
||||
$discount = number_format((($total->amount * 100) / $this->amount), 0);
|
||||
if ($discount) {
|
||||
$sub_total = $this->totals()->where('code', 'sub_total')->value('amount');
|
||||
|
||||
break;
|
||||
$percent = number_format((($discount * 100) / $sub_total), 0);
|
||||
}
|
||||
|
||||
return $discount;
|
||||
return $percent;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user