mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 10:34:30 -04:00
Fix last day of month recurrence
This commit is contained in:
parent
9f5e47cc09
commit
e7c61e9c0b
@ -1128,32 +1128,6 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
return $dates;
|
return $dates;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return null
|
|
||||||
*/
|
|
||||||
public function getNextSendDate()
|
|
||||||
{
|
|
||||||
if (! $this->is_public) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->start_date && ! $this->last_sent_date) {
|
|
||||||
$startDate = $this->getOriginal('start_date') . ' ' . $this->account->recurring_hour . ':00:00';
|
|
||||||
|
|
||||||
return $this->account->getDateTime($startDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $schedule = $this->getSchedule()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count($schedule) < 2) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $schedule[1]->getStart();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param null $invoice_date
|
* @param null $invoice_date
|
||||||
*
|
*
|
||||||
|
@ -14,6 +14,7 @@ trait HasRecurrence
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
public function shouldSendToday()
|
public function shouldSendToday()
|
||||||
{
|
{
|
||||||
if (! $this->user->confirmed) {
|
if (! $this->user->confirmed) {
|
||||||
@ -78,6 +79,68 @@ trait HasRecurrence
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function shouldSendToday()
|
||||||
|
{
|
||||||
|
if (! $this->user->confirmed) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$account = $this->account;
|
||||||
|
$timezone = $account->getTimezone();
|
||||||
|
|
||||||
|
if (! $this->start_date || Carbon::parse($this->start_date, $timezone)->isFuture()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->end_date && Carbon::parse($this->end_date, $timezone)->isPast()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $this->last_sent_date) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// check we don't send a few hours early due to timezone difference
|
||||||
|
if (Utils::isNinja() && Carbon::now()->format('Y-m-d') != Carbon::now($timezone)->format('Y-m-d')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nextSendDate = $this->getNextSendDate();
|
||||||
|
|
||||||
|
if (! $nextSendDate) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->account->getDateTime() >= $nextSendDate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
public function getNextSendDate()
|
||||||
|
{
|
||||||
|
if (! $this->is_public) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->start_date && ! $this->last_sent_date) {
|
||||||
|
$startDate = $this->getOriginal('start_date') . ' ' . $this->account->recurring_hour . ':00:00';
|
||||||
|
|
||||||
|
return $this->account->getDateTime($startDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $schedule = $this->getSchedule()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($schedule) < 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $schedule[1]->getStart();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
@ -125,16 +188,4 @@ trait HasRecurrence
|
|||||||
|
|
||||||
return $rule;
|
return $rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public function shouldSendToday()
|
|
||||||
{
|
|
||||||
if (!$nextSendDate = $this->getNextSendDate()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->account->getDateTime() >= $nextSendDate;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user