Show unpaid column in customer/vendor list
This commit is contained in:
parent
56d64b35a1
commit
4980b29940
@ -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';
|
||||||
|
|
||||||
@ -74,13 +75,15 @@ class Vendor extends Model
|
|||||||
public function getUnpaidAttribute()
|
public function getUnpaidAttribute()
|
||||||
{
|
{
|
||||||
$amount = 0;
|
$amount = 0;
|
||||||
|
|
||||||
$bills = $this->bills()->accrued()->notPaid()->get();
|
$bills = $this->bills()->accrued()->notPaid()->get();
|
||||||
|
|
||||||
foreach ($bills as $bill) {
|
foreach ($bills as $bill) {
|
||||||
|
|
||||||
$bill_amount = $bill->amount - $bill->paid;
|
$bill_amount = $bill->amount - $bill->paid;
|
||||||
|
|
||||||
$amount += $this->dynamicConvert(setting('general.default_currency'), $bill_amount, $bill->currency_code, $bill->currency_rate, false);
|
$amount += $this->dynamicConvert(setting('general.default_currency'), $bill_amount, $bill->currency_code, $bill->currency_rate, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $amount;
|
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';
|
||||||
|
|
||||||
@ -68,13 +69,15 @@ class Customer extends Model
|
|||||||
public function getUnpaidAttribute()
|
public function getUnpaidAttribute()
|
||||||
{
|
{
|
||||||
$amount = 0;
|
$amount = 0;
|
||||||
|
|
||||||
$invoices = $this->invoices()->accrued()->notPaid()->get();
|
$invoices = $this->invoices()->accrued()->notPaid()->get();
|
||||||
|
|
||||||
foreach ($invoices as $invoice) {
|
foreach ($invoices as $invoice) {
|
||||||
|
|
||||||
$invoice_amount = $invoice->amount - $invoice->paid;
|
$invoice_amount = $invoice->amount - $invoice->paid;
|
||||||
|
|
||||||
$amount += $this->dynamicConvert(setting('general.default_currency'), $invoice_amount, $invoice->currency_code, $invoice->currency_rate, false);
|
$amount += $this->dynamicConvert(setting('general.default_currency'), $invoice_amount, $invoice->currency_code, $invoice->currency_rate, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $amount;
|
return $amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,6 @@ return [
|
|||||||
'disable' => 'Disable',
|
'disable' => 'Disable',
|
||||||
'select_all' => 'Select All',
|
'select_all' => 'Select All',
|
||||||
'unselect_all' => 'Unselect All',
|
'unselect_all' => 'Unselect All',
|
||||||
'outstanding' => 'Outstanding',
|
|
||||||
'title' => [
|
'title' => [
|
||||||
'new' => 'New :type',
|
'new' => 'New :type',
|
||||||
'edit' => 'Edit :type',
|
'edit' => 'Edit :type',
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
<th class="col-md-3">@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-2 hidden-xs">@sortablelink('outstanding', trans('general.outstanding'))</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>
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
<th class="col-md-3">@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-2 hidden-xs">@sortablelink('outstanding', trans('general.outstanding'))</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>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user