Merge pull request #3322 from imhayatunnabi/fix/mathematical-calculations
Mathematical Calculation Bugs
This commit is contained in:
commit
e523979ad6
|
|
@ -546,11 +546,19 @@ abstract class Report
|
|||
|
||||
public function divArithmeticAmount(&$current, $amount)
|
||||
{
|
||||
if ($amount == 0) {
|
||||
throw new \InvalidArgumentException('Division by zero is not allowed');
|
||||
}
|
||||
|
||||
$current = $current / $amount;
|
||||
}
|
||||
|
||||
public function modArithmeticAmount(&$current, $amount)
|
||||
{
|
||||
if ($amount == 0) {
|
||||
throw new \InvalidArgumentException('Modulo by zero is not allowed');
|
||||
}
|
||||
|
||||
$current = $current % $amount;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -355,7 +355,11 @@ class Document extends Model
|
|||
if ($discount) {
|
||||
$sub_total = $this->totals->where('code', 'sub_total')->makeHidden('title')->pluck('amount')->first();
|
||||
|
||||
$percent = number_format((($discount * 100) / $sub_total), 0);
|
||||
if ($sub_total && $sub_total > 0) {
|
||||
$percent = number_format((($discount * 100) / $sub_total), 0);
|
||||
} else {
|
||||
$percent = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $percent;
|
||||
|
|
|
|||
|
|
@ -126,8 +126,12 @@ class TaxSummary extends Report
|
|||
}
|
||||
|
||||
if ($date_field == 'paid_at') {
|
||||
$rate = ($item->amount * 100) / $type_item->amount;
|
||||
$item_amount = ($item_total->amount / 100) * $rate;
|
||||
if ($type_item->amount != 0) {
|
||||
$rate = ($item->amount * 100) / $type_item->amount;
|
||||
$item_amount = ($item_total->amount / 100) * $rate;
|
||||
} else {
|
||||
$item_amount = $item_total->amount;
|
||||
}
|
||||
} else {
|
||||
$item_amount = $item_total->amount;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue