solve recurring invoice starts_at condition

This commit is contained in:
harshjagad20
2021-12-06 16:13:20 +05:30
parent b543f6d389
commit 8026c205cc

View File

@ -20,6 +20,10 @@ class RecurringInvoice extends Model
'id', 'id',
]; ];
protected $dates = [
'starts_at'
];
public const NONE = 'NONE'; public const NONE = 'NONE';
public const COUNT = 'COUNT'; public const COUNT = 'COUNT';
public const DATE = 'DATE'; public const DATE = 'DATE';
@ -259,7 +263,10 @@ class RecurringInvoice extends Model
public function generateInvoice() public function generateInvoice()
{ {
if (Carbon::now()->format('Y-m-d H:i:s') < $this->starts_at) { if (Carbon::now()->lessThan($this->starts_at)) {
return;
}
if ($this->limit_by == 'DATE') { if ($this->limit_by == 'DATE') {
$startDate = Carbon::today()->format('Y-m-d'); $startDate = Carbon::today()->format('Y-m-d');
@ -288,7 +295,6 @@ class RecurringInvoice extends Model
$this->updateNextInvoiceDate(); $this->updateNextInvoiceDate();
} }
} }
}
public function createInvoice() public function createInvoice()
{ {