Merge pull request #544 from batuhawk/1.3-dev
Show unpaid cloumn in customer/vendor list
This commit is contained in:
commit
3ee62388ee
@ -4,12 +4,13 @@ namespace App\Models\Expense;
|
|||||||
|
|
||||||
use App\Models\Model;
|
use App\Models\Model;
|
||||||
use Bkwld\Cloner\Cloneable;
|
use Bkwld\Cloner\Cloneable;
|
||||||
|
use App\Traits\Currencies;
|
||||||
use Sofa\Eloquence\Eloquence;
|
use Sofa\Eloquence\Eloquence;
|
||||||
use App\Traits\Media;
|
use App\Traits\Media;
|
||||||
|
|
||||||
class Vendor extends Model
|
class Vendor extends Model
|
||||||
{
|
{
|
||||||
use Cloneable, Eloquence, Media;
|
use Cloneable, Currencies, Eloquence, Media;
|
||||||
|
|
||||||
protected $table = 'vendors';
|
protected $table = 'vendors';
|
||||||
|
|
||||||
@ -71,10 +72,18 @@ class Vendor extends Model
|
|||||||
return $this->getMedia('logo')->last();
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,13 @@ namespace App\Models\Income;
|
|||||||
|
|
||||||
use App\Models\Model;
|
use App\Models\Model;
|
||||||
use Bkwld\Cloner\Cloneable;
|
use Bkwld\Cloner\Cloneable;
|
||||||
|
use App\Traits\Currencies;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
use Sofa\Eloquence\Eloquence;
|
use Sofa\Eloquence\Eloquence;
|
||||||
|
|
||||||
class Customer extends Model
|
class Customer extends Model
|
||||||
{
|
{
|
||||||
use Cloneable, Eloquence, Notifiable;
|
use Cloneable, Currencies, Eloquence, Notifiable;
|
||||||
|
|
||||||
protected $table = 'customers';
|
protected $table = 'customers';
|
||||||
|
|
||||||
@ -65,10 +66,18 @@ class Customer extends Model
|
|||||||
$this->user_id = null;
|
$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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,10 +33,10 @@
|
|||||||
<table class="table table-striped table-hover" id="tbl-vendors">
|
<table class="table table-striped table-hover" id="tbl-vendors">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<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-3 hidden-xs">@sortablelink('email', trans('general.email'))</th>
|
||||||
<th class="col-md-2">@sortablelink('phone', trans('general.phone'))</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 hidden-xs">@sortablelink('enabled', trans_choice('general.statuses', 1))</th>
|
||||||
<th class="col-md-1 text-center">{{ trans('general.actions') }}</th>
|
<th class="col-md-1 text-center">{{ trans('general.actions') }}</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -47,7 +47,7 @@
|
|||||||
<td><a href="{{ url('expenses/vendors/' . $item->id) }}">{{ $item->name }}</a></td>
|
<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 class="hidden-xs">{{ !empty($item->email) ? $item->email : trans('general.na') }}</td>
|
||||||
<td>{{ $item->phone }}</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">
|
<td class="hidden-xs">
|
||||||
@if ($item->enabled)
|
@if ($item->enabled)
|
||||||
<span class="label label-success">{{ trans('general.enabled') }}</span>
|
<span class="label label-success">{{ trans('general.enabled') }}</span>
|
||||||
|
@ -33,10 +33,10 @@
|
|||||||
<table class="table table-striped table-hover" id="tbl-customers">
|
<table class="table table-striped table-hover" id="tbl-customers">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<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-3 hidden-xs">@sortablelink('email', trans('general.email'))</th>
|
||||||
<th class="col-md-2">@sortablelink('phone', trans('general.phone'))</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 hidden-xs">@sortablelink('enabled', trans_choice('general.statuses', 1))</th>
|
||||||
<th class="col-md-1 text-center">{{ trans('general.actions') }}</th>
|
<th class="col-md-1 text-center">{{ trans('general.actions') }}</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -47,7 +47,7 @@
|
|||||||
<td><a href="{{ url('incomes/customers/' . $item->id) }}">{{ $item->name }}</a></td>
|
<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 class="hidden-xs">{{ !empty($item->email) ? $item->email : trans('general.na') }}</td>
|
||||||
<td>{{ $item->phone }}</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">
|
<td class="hidden-xs">
|
||||||
@if ($item->enabled)
|
@if ($item->enabled)
|
||||||
<span class="label label-success">{{ trans('general.enabled') }}</span>
|
<span class="label label-success">{{ trans('general.enabled') }}</span>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user