Show unpaid column in customer/vendor list

This commit is contained in:
Batuhan Baş
2018-10-10 18:18:15 +03:00
parent 56d64b35a1
commit 4980b29940
5 changed files with 12 additions and 7 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';
@ -74,13 +75,15 @@ class Vendor extends Model
public function getUnpaidAttribute()
{
$amount = 0;
$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;
}
}