Skip to content

Commit

Permalink
Merge pull request #3433 from ColoredCow/fix/invoice-difference-calcu…
Browse files Browse the repository at this point in the history
…lations

#3431/Display Invoice Changes and Percentages in Invoice Screen
  • Loading branch information
P4NK4J authored Feb 28, 2024
2 parents a725a09 + 02df446 commit 1404217
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Modules/Invoice/Entities/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ public function invoiceAmountDifference()
->where('client_id', $this->client_id)->where('project_id', $this->project_id)
->orderBy('sent_on', 'DESC')
->first();
$lastMonthAmount = $lastMonthAmountDetail ? (float) $lastMonthAmountDetail->amount + (float) $lastMonthAmountDetail->gst : 0;
$lastMonthAmount = $lastMonthAmountDetail ? (float) $lastMonthAmountDetail->amount : 0;
if ($this->client->type == 'indian') {
$lastMonthAmount = $lastMonthAmountDetail ? (float) $lastMonthAmountDetail->amount + (float) $lastMonthAmountDetail->gst : 0;
}
$amountDifference = $currentMonthAmount - $lastMonthAmount;
if ($lastMonthAmount != 0) {
$percentage = number_format($amountDifference / $lastMonthAmount * 100, 2);
Expand Down

0 comments on commit 1404217

Please sign in to comment.