mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-08 14:04:50 +00:00
Fix: Use amounts in base currency for customer charts (#403)
Previously, the customer chart used the total/amount fields to calculate net profits/expenses/etc. If the currency the expense (for example) was created in differed from the base currency of the company, the chart would display wrong amounts. This change addresses the issue by always using the base currency field.
This commit is contained in:
@@ -61,7 +61,7 @@ class CustomerStatsController extends Controller
|
||||
)
|
||||
->whereCompany()
|
||||
->whereCustomer($customer->id)
|
||||
->sum('total') ?? 0
|
||||
->sum('base_total') ?? 0
|
||||
);
|
||||
array_push(
|
||||
$expenseTotals,
|
||||
@@ -71,7 +71,7 @@ class CustomerStatsController extends Controller
|
||||
)
|
||||
->whereCompany()
|
||||
->whereUser($customer->id)
|
||||
->sum('amount') ?? 0
|
||||
->sum('base_amount') ?? 0
|
||||
);
|
||||
array_push(
|
||||
$receiptTotals,
|
||||
@@ -81,7 +81,7 @@ class CustomerStatsController extends Controller
|
||||
)
|
||||
->whereCompany()
|
||||
->whereCustomer($customer->id)
|
||||
->sum('amount') ?? 0
|
||||
->sum('base_amount') ?? 0
|
||||
);
|
||||
array_push(
|
||||
$netProfits,
|
||||
@@ -103,21 +103,21 @@ class CustomerStatsController extends Controller
|
||||
)
|
||||
->whereCompany()
|
||||
->whereCustomer($customer->id)
|
||||
->sum('total');
|
||||
->sum('base_total');
|
||||
$totalReceipts = Payment::whereBetween(
|
||||
'payment_date',
|
||||
[$startDate->format('Y-m-d'), $start->format('Y-m-d')]
|
||||
)
|
||||
->whereCompany()
|
||||
->whereCustomer($customer->id)
|
||||
->sum('amount');
|
||||
->sum('base_amount');
|
||||
$totalExpenses = Expense::whereBetween(
|
||||
'expense_date',
|
||||
[$startDate->format('Y-m-d'), $start->format('Y-m-d')]
|
||||
)
|
||||
->whereCompany()
|
||||
->whereUser($customer->id)
|
||||
->sum('amount');
|
||||
->sum('base_amount');
|
||||
$netProfit = (int) $totalReceipts - (int) $totalExpenses;
|
||||
|
||||
$chartData = [
|
||||
|
||||
Reference in New Issue
Block a user