Disable auto billing on recurring invoices and generated invoices if disabled in client portal

This commit is contained in:
David Bomba 2022-12-09 08:31:22 +11:00
parent 7c50231c26
commit a2e94bb27e

View File

@ -12,6 +12,7 @@
namespace App\Http\Livewire\RecurringInvoices;
use App\Models\Invoice;
use Livewire\Component;
class UpdateAutoBilling extends Component
@ -24,6 +25,12 @@ class UpdateAutoBilling extends Component
if ($this->invoice->auto_bill == 'optin' || $this->invoice->auto_bill == 'optout') {
$this->invoice->auto_bill_enabled = ! $this->invoice->auto_bill_enabled;
$this->invoice->saveQuietly();
Invoice::where('recurring_id', $this->invoice->id)
->whereIn('status_id', [2,3])
->where('is_deleted',0)
->where('balance', '>', 0)
->update(['auto_bill_enabled' => $this->invoice->auto_bill_enabled]);
}
}