Merge pull request #544 from batuhawk/1.3-dev

Show unpaid cloumn  in customer/vendor list
This commit is contained in:
Denis Duliçi 2018-10-10 18:32:16 +03:00 committed by GitHub
commit 3ee62388ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 14 deletions

View File

@ -4,12 +4,13 @@ namespace App\Models\Expense;
use App\Models\Model;
use Bkwld\Cloner\Cloneable;
use App\Traits\Currencies;
use Sofa\Eloquence\Eloquence;
use App\Traits\Media;
class Vendor extends Model
{
use Cloneable, Eloquence, Media;
use Cloneable, Currencies, Eloquence, Media;
protected $table = 'vendors';
@ -71,10 +72,18 @@ class Vendor extends Model
return $this->getMedia('logo')->last();
}
public function getAmountAttribute()
public function getUnpaidAttribute()
{
$invoice_total = $this->bills()->notPaid()->sum('amount');
$amount = 0;
return $invoice_total;
$bills = $this->bills()->accrued()->notPaid()->get();
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;
}
}

View File

@ -4,12 +4,13 @@ namespace App\Models\Income;
use App\Models\Model;
use Bkwld\Cloner\Cloneable;
use App\Traits\Currencies;
use Illuminate\Notifications\Notifiable;
use Sofa\Eloquence\Eloquence;
class Customer extends Model
{
use Cloneable, Eloquence, Notifiable;
use Cloneable, Currencies, Eloquence, Notifiable;
protected $table = 'customers';
@ -65,10 +66,18 @@ class Customer extends Model
$this->user_id = null;
}
public function getAmountAttribute()
public function getUnpaidAttribute()
{
$invoice_total = $this->invoices()->notPaid()->sum('amount');
$amount = 0;
return $invoice_total;
$invoices = $this->invoices()->accrued()->notPaid()->get();
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;
}
}

View File

@ -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('unpaid', trans('general.unpaid'))</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>
@ -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>

View File

@ -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('unpaid', trans('general.unpaid'))</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>
@ -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>