amount update

This commit is contained in:
Abhishek Mali
2025-12-22 19:22:01 +05:30
parent cdb6cab57d
commit 1bce2be826
9 changed files with 152 additions and 27 deletions

View File

@@ -92,5 +92,20 @@ class Invoice extends Model
return $this->hasMany(InvoiceInstallment::class);
}
// App\Models\Invoice.php
public function totalPaid()
{
return $this->installments()->sum('amount');
}
public function remainingAmount()
{
return max(
($this->final_amount_with_gst ?? 0) - $this->totalPaid(),
0
);
}
}