Skip to content

Commit

Permalink
Show outstanding in customer/vendor list #89
Browse files Browse the repository at this point in the history
  • Loading branch information
Batuhan Baş committed Oct 10, 2018
1 parent 45c14ca commit 56d64b3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
12 changes: 9 additions & 3 deletions app/Models/Expense/Vendor.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,16 @@ public function getLogoAttribute($value)
return $this->getMedia('logo')->last();
}

public function getAmountAttribute()
public function getUnpaidAttribute()
{
$invoice_total = $this->bills()->notPaid()->sum('amount');
$amount = 0;
$bills = $this->bills()->accrued()->notPaid()->get();

return $invoice_total;
foreach ($bills as $bill) {

$bill_amount = $bill->amount - $bill->paid;
$amount += $this->dynamicConvert(setting('general.default_currency'), $bill_amount, $bill->currency_code, $bill->currency_rate, false);
}
return $amount;
}
}
12 changes: 9 additions & 3 deletions app/Models/Income/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,16 @@ public function onCloning($src, $child = null)
$this->user_id = null;
}

public function getAmountAttribute()
public function getUnpaidAttribute()
{
$invoice_total = $this->invoices()->notPaid()->sum('amount');
$amount = 0;
$invoices = $this->invoices()->accrued()->notPaid()->get();

return $invoice_total;
foreach ($invoices as $invoice) {

$invoice_amount = $invoice->amount - $invoice->paid;
$amount += $this->dynamicConvert(setting('general.default_currency'), $invoice_amount, $invoice->currency_code, $invoice->currency_rate, false);
}
return $amount;
}
}
1 change: 1 addition & 0 deletions resources/lang/en-GB/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
'disable' => 'Disable',
'select_all' => 'Select All',
'unselect_all' => 'Unselect All',
'outstanding' => 'Outstanding',
'title' => [
'new' => 'New :type',
'edit' => 'Edit :type',
Expand Down
6 changes: 3 additions & 3 deletions resources/views/expenses/vendors/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
<table class="table table-striped table-hover" id="tbl-vendors">
<thead>
<tr>
<th class="col-md-4">@sortablelink('name', trans('general.name'))</th>
<th class="col-md-3">@sortablelink('name', trans('general.name'))</th>
<th class="col-md-3 hidden-xs">@sortablelink('email', trans('general.email'))</th>
<th class="col-md-2">@sortablelink('phone', trans('general.phone'))</th>
<th class="col-md-1 hidden-xs">@sortablelink('amount', trans('general.amount'))</th>
<th class="col-md-2 hidden-xs">@sortablelink('outstanding', trans('general.outstanding'))</th>
<th class="col-md-1 hidden-xs">@sortablelink('enabled', trans_choice('general.statuses', 1))</th>
<th class="col-md-1 text-center">{{ trans('general.actions') }}</th>
</tr>
Expand All @@ -47,7 +47,7 @@
<td><a href="{{ url('expenses/vendors/' . $item->id) }}">{{ $item->name }}</a></td>
<td class="hidden-xs">{{ !empty($item->email) ? $item->email : trans('general.na') }}</td>
<td>{{ $item->phone }}</td>
<td>@money($item->amount, setting('general.default_currency'), true)</td>
<td>@money($item->unpaid, setting('general.default_currency'), true)</td>
<td class="hidden-xs">
@if ($item->enabled)
<span class="label label-success">{{ trans('general.enabled') }}</span>
Expand Down
6 changes: 3 additions & 3 deletions resources/views/incomes/customers/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
<table class="table table-striped table-hover" id="tbl-customers">
<thead>
<tr>
<th class="col-md-4">@sortablelink('name', trans('general.name'))</th>
<th class="col-md-3">@sortablelink('name', trans('general.name'))</th>
<th class="col-md-3 hidden-xs">@sortablelink('email', trans('general.email'))</th>
<th class="col-md-2">@sortablelink('phone', trans('general.phone'))</th>
<th class="col-md-1 hidden-xs">@sortablelink('amounts', trans('general.amount'))</th>
<th class="col-md-2 hidden-xs">@sortablelink('outstanding', trans('general.outstanding'))</th>
<th class="col-md-1 hidden-xs">@sortablelink('enabled', trans_choice('general.statuses', 1))</th>
<th class="col-md-1 text-center">{{ trans('general.actions') }}</th>
</tr>
Expand All @@ -47,7 +47,7 @@
<td><a href="{{ url('incomes/customers/' . $item->id) }}">{{ $item->name }}</a></td>
<td class="hidden-xs">{{ !empty($item->email) ? $item->email : trans('general.na') }}</td>
<td>{{ $item->phone }}</td>
<td>@money($item->amount, setting('general.default_currency'), true)</td>
<td>@money($item->unpaid, setting('general.default_currency'), true)</td>
<td class="hidden-xs">
@if ($item->enabled)
<span class="label label-success">{{ trans('general.enabled') }}</span>
Expand Down

0 comments on commit 56d64b3

Please sign in to comment.