mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 11:24:34 -04:00
Working on recurringDates Array
This commit is contained in:
parent
89dcd43e47
commit
2b877d3414
@ -219,7 +219,11 @@ class RecurringInvoice extends BaseModel
|
|||||||
{
|
{
|
||||||
if ($this->remaining_cycles == 0) {
|
if ($this->remaining_cycles == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
}
|
||||||
|
else if($this->remaining_cycles == -1) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
return $this->remaining_cycles - 1;
|
return $this->remaining_cycles - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -298,5 +302,43 @@ class RecurringInvoice extends BaseModel
|
|||||||
public function recurringDates()
|
public function recurringDates()
|
||||||
{
|
{
|
||||||
//todo send back a list of the next send dates and due dates
|
//todo send back a list of the next send dates and due dates
|
||||||
|
|
||||||
|
/* Return early if nothing to send back! */
|
||||||
|
if( $this->status_id == self::STATUS_COMPLETED ||
|
||||||
|
$this->status_id == self::STATUS_DRAFT ||
|
||||||
|
$this->status_id == self::STATUS_CANCELLED ||
|
||||||
|
$this->remaining_cycles == 0) {
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Endless - lets send 10 back*/
|
||||||
|
$iterations = $this->remaining_cycles;
|
||||||
|
|
||||||
|
if($this->remaining_cycles == -1)
|
||||||
|
$iterations = 10;
|
||||||
|
|
||||||
|
$next_send_date = $this->next_send_date;
|
||||||
|
$due_date_days = $this->due_date_days;
|
||||||
|
|
||||||
|
if(!$due_date_days)
|
||||||
|
$due_date_days = 1;
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
for($x=0; $x<$iterations; $x++)
|
||||||
|
{
|
||||||
|
|
||||||
|
$data[] = [
|
||||||
|
'next_send_date' => $next_send_date->format('Y-m-d'),
|
||||||
|
'due_date' => $next_send_date->addDays($due_date_days)->format('Y-m-d')
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,8 @@ class AddIsPublicToDocumentsTable extends Migration
|
|||||||
|
|
||||||
Schema::table('recurring_invoices', function (Blueprint $table) {
|
Schema::table('recurring_invoices', function (Blueprint $table) {
|
||||||
$table->integer('remaining_cycles')->nullable()->change();
|
$table->integer('remaining_cycles')->nullable()->change();
|
||||||
|
$table->dropColumn('start_date');
|
||||||
|
$table->integer('due_date_days')->nullable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user