mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
commit
182d5db064
@ -1 +1 @@
|
|||||||
5.3.13
|
5.3.14
|
@ -12,9 +12,9 @@
|
|||||||
namespace App\Jobs\Cron;
|
namespace App\Jobs\Cron;
|
||||||
|
|
||||||
use App\Factory\RecurringExpenseToExpenseFactory;
|
use App\Factory\RecurringExpenseToExpenseFactory;
|
||||||
use App\Jobs\RecurringInvoice\SendRecurring;
|
|
||||||
use App\Libraries\MultiDB;
|
use App\Libraries\MultiDB;
|
||||||
use App\Models\RecurringExpense;
|
use App\Models\RecurringExpense;
|
||||||
|
use App\Models\RecurringInvoice;
|
||||||
use App\Utils\Traits\GeneratesCounter;
|
use App\Utils\Traits\GeneratesCounter;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
@ -64,11 +64,8 @@ class RecurringExpensesCron
|
|||||||
$recurring_expenses = RecurringExpense::where('next_send_date', '<=', now()->toDateTimeString())
|
$recurring_expenses = RecurringExpense::where('next_send_date', '<=', now()->toDateTimeString())
|
||||||
->whereNotNull('next_send_date')
|
->whereNotNull('next_send_date')
|
||||||
->whereNull('deleted_at')
|
->whereNull('deleted_at')
|
||||||
|
->where('status_id', RecurringInvoice::STATUS_ACTIVE)
|
||||||
->where('remaining_cycles', '!=', '0')
|
->where('remaining_cycles', '!=', '0')
|
||||||
// ->whereHas('client', function ($query) {
|
|
||||||
// $query->where('is_deleted',0)
|
|
||||||
// ->where('deleted_at', NULL);
|
|
||||||
// })
|
|
||||||
->with('company')
|
->with('company')
|
||||||
->cursor();
|
->cursor();
|
||||||
|
|
||||||
@ -80,6 +77,8 @@ class RecurringExpensesCron
|
|||||||
if (!$recurring_expense->company->is_disabled) {
|
if (!$recurring_expense->company->is_disabled) {
|
||||||
$this->generateExpense($recurring_expense);
|
$this->generateExpense($recurring_expense);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,6 +89,10 @@ class RecurringExpensesCron
|
|||||||
|
|
||||||
$expense->number = $this->getNextExpenseNumber($expense);
|
$expense->number = $this->getNextExpenseNumber($expense);
|
||||||
$expense->save();
|
$expense->save();
|
||||||
|
|
||||||
|
$recurring_expense->next_send_date = $recurring_expense->nextSendDate();
|
||||||
|
$recurring_expense->remaining_cycles = $recurring_expense->remainingCycles();
|
||||||
|
$recurring_expense->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,10 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Models\RecurringInvoice;
|
||||||
use App\Services\Recurring\RecurringService;
|
use App\Services\Recurring\RecurringService;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
class RecurringExpense extends BaseModel
|
class RecurringExpense extends BaseModel
|
||||||
{
|
{
|
||||||
@ -114,4 +116,52 @@ class RecurringExpense extends BaseModel
|
|||||||
{
|
{
|
||||||
return new RecurringService($this);
|
return new RecurringService($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function nextSendDate() :?Carbon
|
||||||
|
{
|
||||||
|
if (!$this->next_send_date) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($this->frequency_id) {
|
||||||
|
case RecurringInvoice::FREQUENCY_DAILY:
|
||||||
|
return Carbon::parse($this->next_send_date)->startOfDay()->addDay();
|
||||||
|
case RecurringInvoice::FREQUENCY_WEEKLY:
|
||||||
|
return Carbon::parse($this->next_send_date)->startOfDay()->addWeek();
|
||||||
|
case RecurringInvoice::FREQUENCY_TWO_WEEKS:
|
||||||
|
return Carbon::parse($this->next_send_date)->startOfDay()->addWeeks(2);
|
||||||
|
case RecurringInvoice::FREQUENCY_FOUR_WEEKS:
|
||||||
|
return Carbon::parse($this->next_send_date)->startOfDay()->addWeeks(4);
|
||||||
|
case RecurringInvoice::FREQUENCY_MONTHLY:
|
||||||
|
return Carbon::parse($this->next_send_date)->startOfDay()->addMonthNoOverflow();
|
||||||
|
case RecurringInvoice::FREQUENCY_TWO_MONTHS:
|
||||||
|
return Carbon::parse($this->next_send_date)->startOfDay()->addMonthsNoOverflow(2);
|
||||||
|
case RecurringInvoice::FREQUENCY_THREE_MONTHS:
|
||||||
|
return Carbon::parse($this->next_send_date)->startOfDay()->addMonthsNoOverflow(3);
|
||||||
|
case RecurringInvoice::FREQUENCY_FOUR_MONTHS:
|
||||||
|
return Carbon::parse($this->next_send_date)->startOfDay()->addMonthsNoOverflow(4);
|
||||||
|
case RecurringInvoice::FREQUENCY_SIX_MONTHS:
|
||||||
|
return Carbon::parse($this->next_send_date)->startOfDay()->addMonthsNoOverflow(6);
|
||||||
|
case RecurringInvoice::FREQUENCY_ANNUALLY:
|
||||||
|
return Carbon::parse($this->next_send_date)->startOfDay()->addYear();
|
||||||
|
case RecurringInvoice::FREQUENCY_TWO_YEARS:
|
||||||
|
return Carbon::parse($this->next_send_date)->startOfDay()->addYears(2);
|
||||||
|
case RecurringInvoice::FREQUENCY_THREE_YEARS:
|
||||||
|
return Carbon::parse($this->next_send_date)->startOfDay()->addYears(3);
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function remainingCycles() : int
|
||||||
|
{
|
||||||
|
if ($this->remaining_cycles == 0) {
|
||||||
|
return 0;
|
||||||
|
} elseif ($this->remaining_cycles == -1) {
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
return $this->remaining_cycles - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@ return [
|
|||||||
'require_https' => env('REQUIRE_HTTPS', true),
|
'require_https' => env('REQUIRE_HTTPS', true),
|
||||||
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
||||||
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
||||||
'app_version' => '5.3.13',
|
'app_version' => '5.3.14',
|
||||||
'app_tag' => '5.3.13',
|
'app_tag' => '5.3.14',
|
||||||
'minimum_client_version' => '5.0.16',
|
'minimum_client_version' => '5.0.16',
|
||||||
'terms_version' => '1.0.1',
|
'terms_version' => '1.0.1',
|
||||||
'api_secret' => env('API_SECRET', ''),
|
'api_secret' => env('API_SECRET', ''),
|
||||||
|
@ -107,8 +107,6 @@ input:checked ~ .dot {
|
|||||||
<hr>
|
<hr>
|
||||||
<div class="py-2 text-sm my-3 text-white">Branded client portal: "https://billing.yourcompany.com"</div>
|
<div class="py-2 text-sm my-3 text-white">Branded client portal: "https://billing.yourcompany.com"</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="py-2 text-sm my-3 text-white">Custom background for invoices & quotes</div>
|
|
||||||
<hr>
|
|
||||||
<div class="py-2 text-sm my-3 text-white">Priority support</div>
|
<div class="py-2 text-sm my-3 text-white">Priority support</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="py-2 text-sm my-3 text-white">+ Much more!</div>
|
<div class="py-2 text-sm my-3 text-white">+ Much more!</div>
|
||||||
@ -192,8 +190,6 @@ input:checked ~ .dot {
|
|||||||
<hr>
|
<hr>
|
||||||
<div class="py-2 text-sm my-3 text-white">Branded client portal: "https://billing.yourcompany.com"</div>
|
<div class="py-2 text-sm my-3 text-white">Branded client portal: "https://billing.yourcompany.com"</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="py-2 text-sm my-3 text-white">Custom background for invoices & quotes</div>
|
|
||||||
<hr>
|
|
||||||
<div class="py-2 text-sm my-3 text-white">Priority support</div>
|
<div class="py-2 text-sm my-3 text-white">Priority support</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="py-2 text-sm my-3 text-white">+ Much more!</div>
|
<div class="py-2 text-sm my-3 text-white">+ Much more!</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user