mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 23:57:33 -05: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 Laracasts\Presenter\PresentableTrait;
 | 
			
		||||
use Utils;
 | 
			
		||||
use Carbon;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Class Invoice.
 | 
			
		||||
@ -1159,28 +1160,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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user