mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 18:54:30 -04:00
Timezone fix for recurring invoices
This commit is contained in:
parent
73f6646dd2
commit
93cc9e17ef
@ -14,6 +14,7 @@ use DateTime;
|
|||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Laracasts\Presenter\PresentableTrait;
|
use Laracasts\Presenter\PresentableTrait;
|
||||||
use Utils;
|
use Utils;
|
||||||
|
use Carbon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Invoice.
|
* Class Invoice.
|
||||||
@ -1159,28 +1160,24 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $this->start_date || strtotime($this->start_date) > strtotime('now')) {
|
$account = $this->account;
|
||||||
|
$timezone = $account->getTimezone();
|
||||||
|
|
||||||
|
if (! $this->start_date || Carbon::parse($this->start_date, $timezone)->isFuture()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->end_date && strtotime($this->end_date) < strtotime('now')) {
|
if ($this->end_date && Carbon::parse($this->end_date, $timezone)->isPast()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dayOfWeekToday = date('w');
|
|
||||||
$dayOfWeekStart = date('w', strtotime($this->start_date));
|
|
||||||
|
|
||||||
$dayOfMonthToday = date('j');
|
|
||||||
$dayOfMonthStart = date('j', strtotime($this->start_date));
|
|
||||||
|
|
||||||
if (! $this->last_sent_date) {
|
if (! $this->last_sent_date) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$date1 = new DateTime($this->last_sent_date);
|
$date1 = Carbon::parse($this->last_sent_date, $timezone);
|
||||||
$date2 = new DateTime();
|
$date2 = Carbon::now($timezone);
|
||||||
$diff = $date2->diff($date1);
|
$daysSinceLastSent = $date1->diffInDays($date2);
|
||||||
$daysSinceLastSent = $diff->format('%a');
|
$monthsSinceLastSent = $date1->diffInMonths($date2);
|
||||||
$monthsSinceLastSent = ($diff->format('%y') * 12) + $diff->format('%m');
|
|
||||||
|
|
||||||
if ($daysSinceLastSent == 0) {
|
if ($daysSinceLastSent == 0) {
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user