mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 00:34:35 -04:00
Fixes for hasrecurrence trait
This commit is contained in:
parent
4db72d11e1
commit
b906e1e92f
@ -95,9 +95,24 @@ class StoreRecurringInvoiceRequest extends Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
||||||
//$input['line_items'] = json_encode($input['line_items']);
|
|
||||||
$this->replace($input);
|
if(isset($input['auto_bill']))
|
||||||
}
|
$input['auto_bill_enabled'] = $this->setAutoBillFlag($input['auto_bill']);
|
||||||
|
|
||||||
|
$this->replace($input);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setAutoBillFlag($auto_bill)
|
||||||
|
{
|
||||||
|
if($auto_bill == 'always')
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if($auto_bill == 'off')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//todo do we need to handle optin / optout here?
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function messages()
|
public function messages()
|
||||||
{
|
{
|
||||||
|
@ -85,6 +85,22 @@ class UpdateRecurringInvoiceRequest extends Request
|
|||||||
|
|
||||||
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
||||||
|
|
||||||
|
if(isset($input['auto_bill']))
|
||||||
|
$input['auto_bill_enabled'] = $this->setAutoBillFlag($input['auto_bill']);
|
||||||
|
|
||||||
$this->replace($input);
|
$this->replace($input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function setAutoBillFlag($auto_bill)
|
||||||
|
{
|
||||||
|
if($auto_bill == 'always')
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if($auto_bill == 'off')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//todo do we need to handle optin / optout here?
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -104,6 +104,7 @@ class RecurringInvoice extends BaseModel
|
|||||||
'next_send_date',
|
'next_send_date',
|
||||||
'remaining_cycles',
|
'remaining_cycles',
|
||||||
'auto_bill',
|
'auto_bill',
|
||||||
|
'auto_bill_enabled',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
|
@ -53,13 +53,13 @@ trait HasRecurrence
|
|||||||
*/
|
*/
|
||||||
public function setDayOfMonth($date, $day_of_month)
|
public function setDayOfMonth($date, $day_of_month)
|
||||||
{
|
{
|
||||||
$data = Carbon::parse($date);
|
$carbon_date = Carbon::parse($date);
|
||||||
|
|
||||||
$set_date = $date->copy()->setUnitNoOverflow('day', $day_of_month, 'month');
|
$set_date = $carbon_date->copy()->setUnitNoOverflow('day', $day_of_month, 'month');
|
||||||
|
|
||||||
//If the set date is less than the original date we need to add a month.
|
//If the set date is less than the original date we need to add a month.
|
||||||
//If we are overflowing dates, then we need to diff the dates and ensure it doesn't equal 0
|
//If we are overflowing dates, then we need to diff the dates and ensure it doesn't equal 0
|
||||||
if($set_date->lte($date) || $set_date->diffInDays($date) == 0)
|
if($set_date->lte($date) || $set_date->diffInDays($carbon_date) == 0)
|
||||||
$set_date->addMonthNoOverflow();
|
$set_date->addMonthNoOverflow();
|
||||||
|
|
||||||
if($day_of_month == '31')
|
if($day_of_month == '31')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user