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,
|
'actionLinks' => $actionLinks,
|
||||||
'showBreadcrumbs' => false,
|
'showBreadcrumbs' => false,
|
||||||
'vendor' => $vendor,
|
'vendor' => $vendor,
|
||||||
'totalexpense' => $vendor->getTotalExpense(),
|
|
||||||
'title' => trans('texts.view_vendor'),
|
'title' => trans('texts.view_vendor'),
|
||||||
'hasRecurringInvoices' => false,
|
'hasRecurringInvoices' => false,
|
||||||
'hasQuotes' => false,
|
'hasQuotes' => false,
|
||||||
|
@ -321,12 +321,14 @@ class Vendor extends EntityModel
|
|||||||
/**
|
/**
|
||||||
* @return float|int
|
* @return float|int
|
||||||
*/
|
*/
|
||||||
public function getTotalExpense()
|
public function getTotalExpenses()
|
||||||
{
|
{
|
||||||
return DB::table('expenses')
|
return DB::table('expenses')
|
||||||
->where('vendor_id', '=', $this->id)
|
->select('expense_currency_id', DB::raw('SUM(amount) as amount'))
|
||||||
->whereNull('deleted_at')
|
->whereVendorId($this->id)
|
||||||
->sum('amount');
|
->whereIsDeleted(false)
|
||||||
|
->groupBy('expense_currency_id')
|
||||||
|
->get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
{!! Button::normal(trans('texts.projects'))->asLinkTo(URL::to('/projects'))->appendIcon(Icon::create('list')) !!}
|
{!! Button::normal(trans('texts.projects'))->asLinkTo(URL::to('/projects'))->appendIcon(Icon::create('list')) !!}
|
||||||
@endif
|
@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')) !!}
|
{!! Button::primary(mtrans($entityType, "new_{$entityType}"))->asLinkTo(url(Utils::pluralizeEntityType($entityType) . '/create/' . (isset($clientId) ? $clientId : '')))->appendIcon(Icon::create('plus-sign')) !!}
|
||||||
@endif
|
@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') }}
|
<h3>{{ trans('texts.standing') }}
|
||||||
<table class="table" style="width:100%">
|
<table class="table" style="width:100%">
|
||||||
<tr>
|
<tr>
|
||||||
<td><small>{{ trans('texts.balance') }}</small></td>
|
<td style="vertical-align: top"><small>{{ trans('texts.balance') }}</small></td>
|
||||||
<td style="text-align: right">{{ Utils::formatMoney($totalexpense, $vendor->getCurrencyId()) }}</td>
|
<td style="text-align: right">
|
||||||
|
@foreach ($vendor->getTotalExpenses() as $currency)
|
||||||
|
<p>{{ Utils::formatMoney($currency->amount, $currency->expense_currency_id) }}</p>
|
||||||
|
@endforeach
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</h3>
|
</h3>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user