mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Timezone fix for recurring invoices
This commit is contained in:
parent
462032f2fc
commit
9543dd3a34
@ -14,6 +14,7 @@ use DateTime;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Laracasts\Presenter\PresentableTrait;
|
||||
use Utils;
|
||||
use Carbon;
|
||||
|
||||
/**
|
||||
* Class Invoice.
|
||||
@ -1166,28 +1167,24 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
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;
|
||||
}
|
||||
|
||||
if ($this->end_date && strtotime($this->end_date) < strtotime('now')) {
|
||||
if ($this->end_date && Carbon::parse($this->end_date, $timezone)->isPast()) {
|
||||
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) {
|
||||
return true;
|
||||
} else {
|
||||
$date1 = new DateTime($this->last_sent_date);
|
||||
$date2 = new DateTime();
|
||||
$diff = $date2->diff($date1);
|
||||
$daysSinceLastSent = $diff->format('%a');
|
||||
$monthsSinceLastSent = ($diff->format('%y') * 12) + $diff->format('%m');
|
||||
$date1 = Carbon::parse($this->last_sent_date, $timezone);
|
||||
$date2 = Carbon::now($timezone);
|
||||
$daysSinceLastSent = $date1->diffInDays($date2);
|
||||
$monthsSinceLastSent = $date1->diffInMonths($date2);
|
||||
|
||||
if ($daysSinceLastSent == 0) {
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user