Show outstanding in customer/vendor list #89
This commit is contained in:
@ -71,10 +71,16 @@ class Vendor extends Model
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -65,10 +65,16 @@ class Customer extends Model
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user