mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Make recurrence end date inclusive
This commit is contained in:
parent
36696f28af
commit
8de96b6d05
@ -1093,41 +1093,6 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Recurr\Exception\MissingData
|
||||
*
|
||||
* @return bool|\Recurr\RecurrenceCollection
|
||||
*/
|
||||
public function getSchedule()
|
||||
{
|
||||
if (! $this->start_date || ! $this->is_recurring || ! $this->frequency_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$startDate = $this->getOriginal('last_sent_date') ?: $this->getOriginal('start_date');
|
||||
$startDate .= ' ' . $this->account->recurring_hour . ':00:00';
|
||||
$startDate = $this->account->getDateTime($startDate);
|
||||
$endDate = $this->end_date ? $this->account->getDateTime($this->getOriginal('end_date')) : null;
|
||||
$timezone = $this->account->getTimezone();
|
||||
|
||||
$rule = $this->getRecurrenceRule();
|
||||
$rule = new \Recurr\Rule("{$rule}", $startDate, $endDate, $timezone);
|
||||
|
||||
// Fix for months with less than 31 days
|
||||
$transformerConfig = new \Recurr\Transformer\ArrayTransformerConfig();
|
||||
$transformerConfig->enableLastDayOfMonthFix();
|
||||
|
||||
$transformer = new \Recurr\Transformer\ArrayTransformer();
|
||||
$transformer->setConfig($transformerConfig);
|
||||
$dates = $transformer->transform($rule);
|
||||
|
||||
if (count($dates) < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $dates;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $invoice_date
|
||||
*
|
||||
|
@ -116,6 +116,41 @@ trait HasRecurrence
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Recurr\Exception\MissingData
|
||||
*
|
||||
* @return bool|\Recurr\RecurrenceCollection
|
||||
*/
|
||||
public function getSchedule()
|
||||
{
|
||||
if (! $this->start_date || ! $this->frequency_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$startDate = $this->getOriginal('last_sent_date') ?: $this->getOriginal('start_date');
|
||||
$startDate .= ' ' . $this->account->recurring_hour . ':00:00';
|
||||
$startDate = $this->account->getDateTime($startDate);
|
||||
$endDate = $this->end_date ? $this->account->getDateTime($this->getOriginal('end_date')) : null;
|
||||
$timezone = $this->account->getTimezone();
|
||||
|
||||
$rule = $this->getRecurrenceRule();
|
||||
$rule = new \Recurr\Rule("{$rule}", $startDate);
|
||||
|
||||
// Fix for months with less than 31 days
|
||||
$transformerConfig = new \Recurr\Transformer\ArrayTransformerConfig();
|
||||
$transformerConfig->enableLastDayOfMonthFix();
|
||||
|
||||
$transformer = new \Recurr\Transformer\ArrayTransformer();
|
||||
$transformer->setConfig($transformerConfig);
|
||||
$dates = $transformer->transform($rule);
|
||||
|
||||
if (count($dates) < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $dates;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
@ -183,7 +218,7 @@ trait HasRecurrence
|
||||
}
|
||||
|
||||
if ($this->end_date) {
|
||||
$rule .= 'UNTIL=' . $this->getOriginal('end_date');
|
||||
$rule .= 'UNTIL=' . $this->getOriginal('end_date') . ' 24:00:00';
|
||||
}
|
||||
|
||||
return $rule;
|
||||
|
Loading…
Reference in New Issue
Block a user