mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fix total balance for vendor with multiple expense currencies
This commit is contained in:
parent
cd97904b75
commit
6e8f87a198
@ -82,7 +82,6 @@ class VendorController extends BaseController
|
||||
'actionLinks' => $actionLinks,
|
||||
'showBreadcrumbs' => false,
|
||||
'vendor' => $vendor,
|
||||
'totalexpense' => $vendor->getTotalExpense(),
|
||||
'title' => trans('texts.view_vendor'),
|
||||
'hasRecurringInvoices' => false,
|
||||
'hasQuotes' => false,
|
||||
|
@ -321,12 +321,14 @@ class Vendor extends EntityModel
|
||||
/**
|
||||
* @return float|int
|
||||
*/
|
||||
public function getTotalExpense()
|
||||
public function getTotalExpenses()
|
||||
{
|
||||
return DB::table('expenses')
|
||||
->where('vendor_id', '=', $this->id)
|
||||
->whereNull('deleted_at')
|
||||
->sum('amount');
|
||||
->select('expense_currency_id', DB::raw('SUM(amount) as amount'))
|
||||
->whereVendorId($this->id)
|
||||
->whereIsDeleted(false)
|
||||
->groupBy('expense_currency_id')
|
||||
->get();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@
|
||||
{!! Button::normal(trans('texts.projects'))->asLinkTo(URL::to('/projects'))->appendIcon(Icon::create('list')) !!}
|
||||
@endif
|
||||
|
||||
@if (Auth::user()->can('create', $entityType))
|
||||
@if (Auth::user()->can('create', $entityType) && empty($vendorId))
|
||||
{!! Button::primary(mtrans($entityType, "new_{$entityType}"))->asLinkTo(url(Utils::pluralizeEntityType($entityType) . '/create/' . (isset($clientId) ? $clientId : '')))->appendIcon(Icon::create('plus-sign')) !!}
|
||||
@endif
|
||||
|
||||
|
8
resources/views/vendors/show.blade.php
vendored
8
resources/views/vendors/show.blade.php
vendored
@ -153,8 +153,12 @@
|
||||
<h3>{{ trans('texts.standing') }}
|
||||
<table class="table" style="width:100%">
|
||||
<tr>
|
||||
<td><small>{{ trans('texts.balance') }}</small></td>
|
||||
<td style="text-align: right">{{ Utils::formatMoney($totalexpense, $vendor->getCurrencyId()) }}</td>
|
||||
<td style="vertical-align: top"><small>{{ trans('texts.balance') }}</small></td>
|
||||
<td style="text-align: right">
|
||||
@foreach ($vendor->getTotalExpenses() as $currency)
|
||||
<p>{{ Utils::formatMoney($currency->amount, $currency->expense_currency_id) }}</p>
|
||||
@endforeach
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</h3>
|
||||
|
Loading…
x
Reference in New Issue
Block a user