mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Fixes for carbon types
This commit is contained in:
parent
6f5daf6f2a
commit
e4377f3378
@ -1 +1 @@
|
||||
5.10.0
|
||||
5.10.1
|
@ -40,10 +40,10 @@ class BulkInvoiceRequest extends Request
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
if(\Illuminate\Support\Facades\Cache::has($this->ip()."|".$this->input('action', 0)."|".$this->input('ids', '')."|".$user->company()->company_key))
|
||||
if(\Illuminate\Support\Facades\Cache::has($this->ip()."|".$this->input('action', 0)."|".json_encode($this->input('ids', ''))."|".$user->company()->company_key))
|
||||
throw new DuplicatePaymentException('Duplicate request.', 429);
|
||||
|
||||
\Illuminate\Support\Facades\Cache::put(($this->ip()."|".$this->input('action', 0)."|".$this->input('ids', '')."|".$user->company()->company_key), true, 1);
|
||||
\Illuminate\Support\Facades\Cache::put(($this->ip()."|".$this->input('action', 0)."|".json_encode($this->input('ids', ''))."|".$user->company()->company_key), true, 1);
|
||||
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ class StoreInvoiceRequest extends Request
|
||||
$client = \App\Models\Client::withTrashed()->find($input['client_id']);
|
||||
|
||||
if($client) {
|
||||
$input['due_date'] = \Illuminate\Support\Carbon::parse($input['date'])->addDays($client->getSetting('payment_terms'))->format('Y-m-d');
|
||||
$input['due_date'] = \Illuminate\Support\Carbon::parse($input['date'])->addDays((int)$client->getSetting('payment_terms'))->format('Y-m-d');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ class UpdateInvoiceRequest extends Request
|
||||
//handles edge case where we need for force set the due date of the invoice.
|
||||
if((isset($input['partial_due_date']) && strlen($input['partial_due_date']) > 1) && (!array_key_exists('due_date', $input) || (empty($input['due_date']) && empty($this->invoice->due_date)))) {
|
||||
$client = \App\Models\Client::withTrashed()->find($input['client_id']);
|
||||
$input['due_date'] = \Illuminate\Support\Carbon::parse($input['date'])->addDays($client->getSetting('payment_terms'))->format('Y-m-d');
|
||||
$input['due_date'] = \Illuminate\Support\Carbon::parse($input['date'])->addDays((int)$client->getSetting('payment_terms'))->format('Y-m-d');
|
||||
}
|
||||
|
||||
$this->replace($input);
|
||||
|
@ -105,7 +105,7 @@ class StoreQuoteRequest extends Request
|
||||
if(isset($input['partial_due_date']) && (!isset($input['due_date']) || strlen($input['due_date']) <= 1)) {
|
||||
$client = \App\Models\Client::withTrashed()->find($input['client_id']);
|
||||
$valid_days = ($client && strlen($client->getSetting('valid_until')) >= 1) ? $client->getSetting('valid_until') : 7;
|
||||
$input['due_date'] = \Carbon\Carbon::parse($input['date'])->addDays($valid_days)->format('Y-m-d');
|
||||
$input['due_date'] = \Carbon\Carbon::parse($input['date'])->addDays((int)$valid_days)->format('Y-m-d');
|
||||
}
|
||||
|
||||
$this->replace($input);
|
||||
|
@ -71,7 +71,7 @@ class SystemMaintenance implements ShouldQueue
|
||||
}
|
||||
|
||||
Invoice::with('invitations')
|
||||
->whereBetween('created_at', [now()->subYear(), now()->subDays($delete_pdf_days)])
|
||||
->whereBetween('created_at', [now()->subYear(), now()->subDays((int)$delete_pdf_days)])
|
||||
->withTrashed()
|
||||
->cursor()
|
||||
->each(function ($invoice) {
|
||||
@ -81,7 +81,7 @@ class SystemMaintenance implements ShouldQueue
|
||||
});
|
||||
|
||||
Quote::with('invitations')
|
||||
->whereBetween('created_at', [now()->subYear(), now()->subDays($delete_pdf_days)])
|
||||
->whereBetween('created_at', [now()->subYear(), now()->subDays((int)$delete_pdf_days)])
|
||||
->withTrashed()
|
||||
->cursor()
|
||||
->each(function ($quote) {
|
||||
@ -91,7 +91,7 @@ class SystemMaintenance implements ShouldQueue
|
||||
});
|
||||
|
||||
Credit::with('invitations')
|
||||
->whereBetween('created_at', [now()->subYear(), now()->subDays($delete_pdf_days)])
|
||||
->whereBetween('created_at', [now()->subYear(), now()->subDays((int)$delete_pdf_days)])
|
||||
->withTrashed()
|
||||
->cursor()
|
||||
->each(function ($credit) {
|
||||
@ -107,7 +107,7 @@ class SystemMaintenance implements ShouldQueue
|
||||
return;
|
||||
}
|
||||
|
||||
Backup::where('created_at', '<', now()->subDays($delete_backup_days))
|
||||
Backup::where('created_at', '<', now()->subDays((int)$delete_backup_days))
|
||||
->cursor()
|
||||
->each(function ($backup) {
|
||||
nlog("deleting {$backup->filename}");
|
||||
|
@ -684,7 +684,7 @@ class RecurringInvoice extends BaseModel
|
||||
return null;
|
||||
}
|
||||
|
||||
return $new_date->addDays($client_payment_terms); //add the number of days in the payment terms to the date
|
||||
return $new_date->addDays((int)$client_payment_terms); //add the number of days in the payment terms to the date
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -569,7 +569,7 @@ class RecurringQuote extends BaseModel
|
||||
return null;
|
||||
}
|
||||
|
||||
return $new_date->addDays($client_payment_terms); //add the number of days in the payment terms to the date
|
||||
return $new_date->addDays((int)$client_payment_terms); //add the number of days in the payment terms to the date
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,6 +37,50 @@ trait ChartQueries
|
||||
", ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
|
||||
}
|
||||
|
||||
public function getAggregateExpenseQuery($start_date, $end_date)
|
||||
{
|
||||
$user_filter = $this->is_admin ? '' : 'AND expenses.user_id = '.$this->user->id;
|
||||
|
||||
return DB::select("
|
||||
SELECT
|
||||
sum(expenses.amount / IFNULL(CAST(JSON_UNQUOTE(JSON_EXTRACT(clients.settings, '$.currency_id')) AS SIGNED), :company_currency2)) as amount,
|
||||
IFNULL(expenses.currency_id, :company_currency) as currency_id
|
||||
FROM expenses
|
||||
JOIN clients
|
||||
ON expenses.client_id=clients.id
|
||||
WHERE expenses.is_deleted = 0
|
||||
AND expenses.company_id = :company_id
|
||||
AND (expenses.date BETWEEN :start_date AND :end_date)
|
||||
{$user_filter}
|
||||
GROUP BY currency_id
|
||||
", ['company_currency2' => $this->company->settings->currency_id, 'company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
|
||||
}
|
||||
|
||||
public function getAggregateExpenseChartQuery($start_date, $end_date)
|
||||
{
|
||||
|
||||
$user_filter = $this->is_admin ? '' : 'AND expenses.user_id = '.$this->user->id;
|
||||
|
||||
return DB::select("
|
||||
SELECT
|
||||
sum(expenses.amount / IFNULL(CAST(JSON_UNQUOTE(JSON_EXTRACT(clients.settings, '$.currency_id')) AS SIGNED), :company_currency)) as total,
|
||||
expenses.date
|
||||
FROM expenses
|
||||
JOIN clients
|
||||
ON expenses.client_id=clients.id
|
||||
WHERE (expenses.date BETWEEN :start_date AND :end_date)
|
||||
AND expenses.company_id = :company_id
|
||||
AND expenses.is_deleted = 0
|
||||
{$user_filter}
|
||||
GROUP BY expenses.date
|
||||
", [
|
||||
'company_currency' => $this->company->settings->currency_id,
|
||||
'company_id' => $this->company->id,
|
||||
'start_date' => $start_date,
|
||||
'end_date' => $end_date,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getExpenseChartQuery($start_date, $end_date, $currency_id)
|
||||
{
|
||||
|
||||
@ -88,6 +132,53 @@ trait ChartQueries
|
||||
]);
|
||||
}
|
||||
|
||||
public function getAggregatePaymentQuery($start_date, $end_date)
|
||||
{
|
||||
|
||||
$user_filter = $this->is_admin ? '' : 'AND payments.user_id = '.$this->user->id;
|
||||
|
||||
return DB::select("
|
||||
SELECT sum(payments.amount / payments.exchange_rate) as amount,
|
||||
IFNULL(payments.currency_id, :company_currency) as currency_id
|
||||
FROM payments
|
||||
WHERE payments.is_deleted = 0
|
||||
{$user_filter}
|
||||
AND payments.company_id = :company_id
|
||||
AND (payments.date BETWEEN :start_date AND :end_date)
|
||||
GROUP BY currency_id
|
||||
", [
|
||||
'company_currency' => $this->company->settings->currency_id,
|
||||
'company_id' => $this->company->id,
|
||||
'start_date' => $start_date,
|
||||
'end_date' => $end_date,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getAggregatePaymentChartQuery($start_date, $end_date)
|
||||
{
|
||||
|
||||
$user_filter = $this->is_admin ? '' : 'AND payments.user_id = '.$this->user->id;
|
||||
|
||||
return DB::select("
|
||||
SELECT
|
||||
sum((payments.amount - payments.refunded) / payments.exchange_rate) as total,
|
||||
payments.date,
|
||||
IFNULL(payments.currency_id, :company_currency) AS currency_id
|
||||
FROM payments
|
||||
WHERE payments.company_id = :company_id
|
||||
AND payments.is_deleted = 0
|
||||
{$user_filter}
|
||||
AND payments.status_id IN (4,5,6)
|
||||
AND (payments.date BETWEEN :start_date AND :end_date)
|
||||
GROUP BY payments.date
|
||||
", [
|
||||
'company_currency' => $this->company->settings->currency_id,
|
||||
'company_id' => $this->company->id,
|
||||
'start_date' => $start_date,
|
||||
'end_date' => $end_date,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getPaymentChartQuery($start_date, $end_date, $currency_id)
|
||||
{
|
||||
|
||||
@ -142,28 +233,54 @@ trait ChartQueries
|
||||
", ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
|
||||
}
|
||||
|
||||
public function getRevenueQueryX($start_date, $end_date)
|
||||
public function getAggregateOutstandingQuery($start_date, $end_date)
|
||||
{
|
||||
|
||||
$user_filter = $this->is_admin ? '' : 'AND clients.user_id = '.$this->user->id;
|
||||
|
||||
return DB::select("
|
||||
SELECT
|
||||
sum(invoices.paid_to_date) as paid_to_date,
|
||||
sum(invoices.balance / IFNULL(CAST(JSON_UNQUOTE(JSON_EXTRACT(clients.settings, '$.currency_id')) AS SIGNED), :company_currency2)) as amount,
|
||||
COUNT(invoices.id) as outstanding_count,
|
||||
IFNULL(CAST(JSON_UNQUOTE(JSON_EXTRACT( clients.settings, '$.currency_id' )) AS SIGNED), :company_currency) AS currency_id
|
||||
FROM clients
|
||||
JOIN invoices
|
||||
on invoices.client_id = clients.id
|
||||
WHERE invoices.company_id = :company_id
|
||||
WHERE invoices.status_id IN (2,3)
|
||||
AND invoices.company_id = :company_id
|
||||
AND clients.is_deleted = 0
|
||||
{$user_filter}
|
||||
AND invoices.is_deleted = 0
|
||||
AND invoices.amount > 0
|
||||
AND invoices.status_id IN (3,4)
|
||||
AND invoices.balance > 0
|
||||
AND (invoices.date BETWEEN :start_date AND :end_date)
|
||||
GROUP BY currency_id
|
||||
", ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
|
||||
", [
|
||||
'company_currency2' => $this->company->settings->currency_id,
|
||||
'company_currency' => $this->company->settings->currency_id,
|
||||
'company_id' => $this->company->id,
|
||||
'start_date' => $start_date,
|
||||
'end_date' => $end_date]);
|
||||
|
||||
}
|
||||
|
||||
public function getAggregateRevenueQuery($start_date, $end_date)
|
||||
{
|
||||
$user_filter = $this->is_admin ? '' : 'AND payments.user_id = '.$this->user->id;
|
||||
|
||||
return DB::select("
|
||||
SELECT
|
||||
sum((payments.amount - payments.refunded) * payments.exchange_rate) as paid_to_date,
|
||||
payments.currency_id AS currency_id
|
||||
FROM payments
|
||||
WHERE payments.company_id = :company_id
|
||||
AND payments.is_deleted = 0
|
||||
{$user_filter}
|
||||
AND payments.status_id IN (1,4,5,6)
|
||||
AND (payments.date BETWEEN :start_date AND :end_date)
|
||||
GROUP BY payments.currency_id
|
||||
", ['company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
|
||||
}
|
||||
|
||||
|
||||
public function getRevenueQuery($start_date, $end_date)
|
||||
{
|
||||
$user_filter = $this->is_admin ? '' : 'AND payments.user_id = '.$this->user->id;
|
||||
@ -182,6 +299,30 @@ trait ChartQueries
|
||||
", ['company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
|
||||
}
|
||||
|
||||
|
||||
public function getAggregateInvoicesQuery($start_date, $end_date)
|
||||
{
|
||||
$user_filter = $this->is_admin ? '' : 'AND clients.user_id = '.$this->user->id;
|
||||
|
||||
return DB::select("
|
||||
SELECT
|
||||
sum(invoices.amount / IFNULL(CAST(JSON_UNQUOTE(JSON_EXTRACT(clients.settings, '$.currency_id')) AS SIGNED), :company_currency2)) as invoiced_amount,
|
||||
IFNULL(CAST(JSON_UNQUOTE(JSON_EXTRACT( clients.settings, '$.currency_id' )) AS SIGNED), :company_currency) AS currency_id
|
||||
FROM clients
|
||||
JOIN invoices
|
||||
on invoices.client_id = clients.id
|
||||
WHERE invoices.status_id IN (2,3,4)
|
||||
AND invoices.company_id = :company_id
|
||||
{$user_filter}
|
||||
AND invoices.amount > 0
|
||||
AND clients.is_deleted = 0
|
||||
AND invoices.is_deleted = 0
|
||||
AND (invoices.date BETWEEN :start_date AND :end_date)
|
||||
GROUP BY invoices.company_id
|
||||
", ['company_currency2' => $this->company->settings->currency_id, 'company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
|
||||
}
|
||||
|
||||
|
||||
public function getInvoicesQuery($start_date, $end_date)
|
||||
{
|
||||
$user_filter = $this->is_admin ? '' : 'AND clients.user_id = '.$this->user->id;
|
||||
@ -204,6 +345,32 @@ trait ChartQueries
|
||||
", ['company_currency' => $this->company->settings->currency_id, 'company_id' => $this->company->id, 'start_date' => $start_date, 'end_date' => $end_date]);
|
||||
}
|
||||
|
||||
public function getAggregateOutstandingChartQuery($start_date, $end_date)
|
||||
{
|
||||
$user_filter = $this->is_admin ? '' : 'AND clients.user_id = '.$this->user->id;
|
||||
|
||||
return DB::select("
|
||||
SELECT
|
||||
sum(invoices.balance / IFNULL(CAST(JSON_UNQUOTE(JSON_EXTRACT(clients.settings, '$.currency_id')) AS SIGNED), :company_currency)) as total,
|
||||
invoices.date
|
||||
FROM clients
|
||||
JOIN invoices
|
||||
on invoices.client_id = clients.id
|
||||
WHERE invoices.status_id IN (2,3,4)
|
||||
AND invoices.company_id = :company_id
|
||||
AND clients.is_deleted = 0
|
||||
AND invoices.is_deleted = 0
|
||||
{$user_filter}
|
||||
AND (invoices.date BETWEEN :start_date AND :end_date)
|
||||
GROUP BY invoices.company_id
|
||||
", [
|
||||
'company_currency' => (int) $this->company->settings->currency_id,
|
||||
'company_id' => $this->company->id,
|
||||
'start_date' => $start_date,
|
||||
'end_date' => $end_date,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getOutstandingChartQuery($start_date, $end_date, $currency_id)
|
||||
{
|
||||
$user_filter = $this->is_admin ? '' : 'AND clients.user_id = '.$this->user->id;
|
||||
@ -234,6 +401,32 @@ trait ChartQueries
|
||||
}
|
||||
|
||||
|
||||
public function getAggregateInvoiceChartQuery($start_date, $end_date)
|
||||
{
|
||||
$user_filter = $this->is_admin ? '' : 'AND clients.user_id = '.$this->user->id;
|
||||
|
||||
return DB::select("
|
||||
SELECT
|
||||
sum(invoices.amount / IFNULL(CAST(JSON_UNQUOTE(JSON_EXTRACT(clients.settings, '$.currency_id')) AS SIGNED), :company_currency)) as total,
|
||||
invoices.date
|
||||
FROM clients
|
||||
JOIN invoices
|
||||
on invoices.client_id = clients.id
|
||||
WHERE invoices.company_id = :company_id
|
||||
AND clients.is_deleted = 0
|
||||
AND invoices.is_deleted = 0
|
||||
{$user_filter}
|
||||
AND invoices.status_id IN (2,3,4)
|
||||
AND (invoices.date BETWEEN :start_date AND :end_date)
|
||||
GROUP BY invoices.company_id
|
||||
", [
|
||||
'company_currency' => (int) $this->company->settings->currency_id,
|
||||
'company_id' => $this->company->id,
|
||||
'start_date' => $start_date,
|
||||
'end_date' => $end_date,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getInvoiceChartQuery($start_date, $end_date, $currency_id)
|
||||
{
|
||||
$user_filter = $this->is_admin ? '' : 'AND clients.user_id = '.$this->user->id;
|
||||
|
@ -88,6 +88,12 @@ class ChartService
|
||||
$data[$key]['expenses'] = $this->getExpenseChartQuery($start_date, $end_date, $key);
|
||||
}
|
||||
|
||||
|
||||
$data[999]['invoices'] = $this->getAggregateInvoiceChartQuery($start_date, $end_date);
|
||||
$data[999]['outstanding'] = $this->getAggregateOutstandingChartQuery($start_date, $end_date);
|
||||
$data[999]['payments'] = $this->getAggregatePaymentChartQuery($start_date, $end_date);
|
||||
$data[999]['expenses'] = $this->getAggregateExpenseChartQuery($start_date, $end_date);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
@ -123,6 +129,17 @@ class ChartService
|
||||
|
||||
}
|
||||
|
||||
$aggregate_revenue = $this->getAggregateRevenueQuery($start_date, $end_date);
|
||||
$aggregate_outstanding = $this->getAggregateOutstandingQuery($start_date, $end_date);
|
||||
$aggregate_expenses = $this->getAggregateExpenseQuery($start_date, $end_date);
|
||||
$aggregate_invoices = $this->getAggregateInvoicesQuery($start_date, $end_date);
|
||||
|
||||
$data[999]['invoices'] = $aggregate_invoices !== false ? $aggregate_invoices : new \stdClass();
|
||||
$data[999]['expense'] = $aggregate_expenses !== false ? $aggregate_expenses : new \stdClass();
|
||||
$data[999]['outstanding'] = $aggregate_outstanding !== false ? $aggregate_outstanding : new \stdClass();
|
||||
$data[999]['revenue'] = $aggregate_revenue !== false ? $aggregate_revenue : new \stdClass();
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ class UpdateReminder extends AbstractService
|
||||
|
||||
if (is_null($this->invoice->reminder1_sent) &&
|
||||
$this->settings->schedule_reminder1 == 'after_invoice_date') {
|
||||
$reminder_date = Carbon::parse($this->invoice->date)->startOfDay()->addDays($this->settings->num_days_reminder1);
|
||||
$reminder_date = Carbon::parse($this->invoice->date)->startOfDay()->addDays((int)$this->settings->num_days_reminder1);
|
||||
|
||||
if ($reminder_date->gt(now())) {
|
||||
$date_collection->push($reminder_date);
|
||||
@ -58,7 +58,7 @@ class UpdateReminder extends AbstractService
|
||||
($this->invoice->partial_due_date || $this->invoice->due_date) &&
|
||||
$this->settings->schedule_reminder1 == 'before_due_date') {
|
||||
$partial_or_due_date = ($this->invoice->partial > 0 && isset($this->invoice->partial_due_date)) ? $this->invoice->partial_due_date : $this->invoice->due_date;
|
||||
$reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->subDays($this->settings->num_days_reminder1);
|
||||
$reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->subDays((int)$this->settings->num_days_reminder1);
|
||||
// nlog("1. {$reminder_date->format('Y-m-d')}");
|
||||
|
||||
if ($reminder_date->gt(now())) {
|
||||
@ -71,7 +71,7 @@ class UpdateReminder extends AbstractService
|
||||
$this->settings->schedule_reminder1 == 'after_due_date') {
|
||||
|
||||
$partial_or_due_date = ($this->invoice->partial > 0 && isset($this->invoice->partial_due_date)) ? $this->invoice->partial_due_date : $this->invoice->due_date;
|
||||
$reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->addDays($this->settings->num_days_reminder1);
|
||||
$reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->addDays((int)$this->settings->num_days_reminder1);
|
||||
// nlog("2. {$reminder_date->format('Y-m-d')}");
|
||||
|
||||
if ($reminder_date->gt(now())) {
|
||||
@ -81,7 +81,7 @@ class UpdateReminder extends AbstractService
|
||||
|
||||
if (is_null($this->invoice->reminder2_sent) &&
|
||||
$this->settings->schedule_reminder2 == 'after_invoice_date') {
|
||||
$reminder_date = Carbon::parse($this->invoice->date)->startOfDay()->addDays($this->settings->num_days_reminder2);
|
||||
$reminder_date = Carbon::parse($this->invoice->date)->startOfDay()->addDays((int)$this->settings->num_days_reminder2);
|
||||
|
||||
if ($reminder_date->gt(now())) {
|
||||
$date_collection->push($reminder_date);
|
||||
@ -93,7 +93,7 @@ class UpdateReminder extends AbstractService
|
||||
$this->settings->schedule_reminder2 == 'before_due_date') {
|
||||
|
||||
$partial_or_due_date = ($this->invoice->partial > 0 && isset($this->invoice->partial_due_date)) ? $this->invoice->partial_due_date : $this->invoice->due_date;
|
||||
$reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->subDays($this->settings->num_days_reminder2);
|
||||
$reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->subDays((int)$this->settings->num_days_reminder2);
|
||||
// nlog("3. {$reminder_date->format('Y-m-d')}");
|
||||
|
||||
if ($reminder_date->gt(now())) {
|
||||
@ -106,7 +106,7 @@ class UpdateReminder extends AbstractService
|
||||
$this->settings->schedule_reminder2 == 'after_due_date') {
|
||||
|
||||
$partial_or_due_date = ($this->invoice->partial > 0 && isset($this->invoice->partial_due_date)) ? $this->invoice->partial_due_date : $this->invoice->due_date;
|
||||
$reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->addDays($this->settings->num_days_reminder2);
|
||||
$reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->addDays((int)$this->settings->num_days_reminder2);
|
||||
// nlog("4. {$reminder_date->format('Y-m-d')}");
|
||||
|
||||
if ($reminder_date->gt(now())) {
|
||||
@ -116,7 +116,7 @@ class UpdateReminder extends AbstractService
|
||||
|
||||
if (is_null($this->invoice->reminder3_sent) &&
|
||||
$this->settings->schedule_reminder3 == 'after_invoice_date') {
|
||||
$reminder_date = Carbon::parse($this->invoice->date)->startOfDay()->addDays($this->settings->num_days_reminder3);
|
||||
$reminder_date = Carbon::parse($this->invoice->date)->startOfDay()->addDays((int)$this->settings->num_days_reminder3);
|
||||
|
||||
if ($reminder_date->gt(now())) {
|
||||
$date_collection->push($reminder_date);
|
||||
@ -128,7 +128,7 @@ class UpdateReminder extends AbstractService
|
||||
$this->settings->schedule_reminder3 == 'before_due_date') {
|
||||
|
||||
$partial_or_due_date = ($this->invoice->partial > 0 && isset($this->invoice->partial_due_date)) ? $this->invoice->partial_due_date : $this->invoice->due_date;
|
||||
$reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->subDays($this->settings->num_days_reminder3);
|
||||
$reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->subDays((int)$this->settings->num_days_reminder3);
|
||||
// nlog("5. {$reminder_date->format('Y-m-d')}");
|
||||
|
||||
if ($reminder_date->gt(now())) {
|
||||
@ -141,7 +141,7 @@ class UpdateReminder extends AbstractService
|
||||
$this->settings->schedule_reminder3 == 'after_due_date') {
|
||||
|
||||
$partial_or_due_date = ($this->invoice->partial > 0 && isset($this->invoice->partial_due_date)) ? $this->invoice->partial_due_date : $this->invoice->due_date;
|
||||
$reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->addDays($this->settings->num_days_reminder3);
|
||||
$reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->addDays((int)$this->settings->num_days_reminder3);
|
||||
// nlog("6. {$reminder_date->format('Y-m-d')}");
|
||||
|
||||
if ($reminder_date->gt(now())) {
|
||||
|
@ -35,7 +35,7 @@ class MarkSent
|
||||
|
||||
if ($this->quote->due_date != '' || $this->client->getSetting('valid_until') == '') {
|
||||
} else {
|
||||
$this->quote->due_date = Carbon::parse($this->quote->date)->addDays($this->client->getSetting('valid_until'));
|
||||
$this->quote->due_date = Carbon::parse($this->quote->date)->addDays((int)$this->client->getSetting('valid_until'));
|
||||
}
|
||||
|
||||
$this->quote
|
||||
|
@ -46,7 +46,7 @@ class UpdateReminder extends AbstractService
|
||||
|
||||
if (is_null($this->quote->reminder1_sent) &&
|
||||
$this->settings->quote_schedule_reminder1 == 'after_quote_date') {
|
||||
$reminder_date = Carbon::parse($this->quote->date)->startOfDay()->addDays($this->settings->quote_num_days_reminder1);
|
||||
$reminder_date = Carbon::parse($this->quote->date)->startOfDay()->addDays((int)$this->settings->quote_num_days_reminder1);
|
||||
|
||||
if ($reminder_date->gt(now())) {
|
||||
$date_collection->push($reminder_date);
|
||||
@ -57,7 +57,7 @@ class UpdateReminder extends AbstractService
|
||||
($this->quote->partial_due_date || $this->quote->due_date) &&
|
||||
$this->settings->quote_schedule_reminder1 == 'before_valid_until_date') {
|
||||
$partial_or_due_date = ($this->quote->partial > 0 && isset($this->quote->partial_due_date)) ? $this->quote->partial_due_date : $this->quote->due_date;
|
||||
$reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->subDays($this->settings->quote_num_days_reminder1);
|
||||
$reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->subDays((int)$this->settings->quote_num_days_reminder1);
|
||||
// nlog("1. {$reminder_date->format('Y-m-d')}");
|
||||
|
||||
if ($reminder_date->gt(now())) {
|
||||
@ -70,7 +70,7 @@ class UpdateReminder extends AbstractService
|
||||
$this->settings->quote_schedule_reminder1 == 'after_valid_until_date') {
|
||||
|
||||
$partial_or_due_date = ($this->quote->partial > 0 && isset($this->quote->partial_due_date)) ? $this->quote->partial_due_date : $this->quote->due_date;
|
||||
$reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->addDays($this->settings->quote_num_days_reminder1);
|
||||
$reminder_date = Carbon::parse($partial_or_due_date)->startOfDay()->addDays((int)$this->settings->quote_num_days_reminder1);
|
||||
// nlog("2. {$reminder_date->format('Y-m-d')}");
|
||||
|
||||
if ($reminder_date->gt(now())) {
|
||||
|
@ -32,13 +32,13 @@ trait MakesReminders
|
||||
|
||||
switch ($schedule_reminder) {
|
||||
case 'after_invoice_date':
|
||||
return Carbon::parse($this->date)->addDays($num_days_reminder)->startOfDay()->addSeconds($offset)->isSameDay(Carbon::now());
|
||||
return Carbon::parse($this->date)->addDays((int)$num_days_reminder)->startOfDay()->addSeconds($offset)->isSameDay(Carbon::now());
|
||||
case 'before_due_date':
|
||||
$partial_or_due_date = ($this->partial > 0 && isset($this->partial_due_date)) ? $this->partial_due_date : $this->due_date;
|
||||
return Carbon::parse($partial_or_due_date)->subDays($num_days_reminder)->startOfDay()->addSeconds($offset)->isSameDay(Carbon::now());
|
||||
return Carbon::parse($partial_or_due_date)->subDays((int)$num_days_reminder)->startOfDay()->addSeconds($offset)->isSameDay(Carbon::now());
|
||||
case 'after_due_date':
|
||||
$partial_or_due_date = ($this->partial > 0 && isset($this->partial_due_date)) ? $this->partial_due_date : $this->due_date;
|
||||
return Carbon::parse($partial_or_due_date)->addDays($num_days_reminder)->startOfDay()->addSeconds($offset)->isSameDay(Carbon::now());
|
||||
return Carbon::parse($partial_or_due_date)->addDays((int)$num_days_reminder)->startOfDay()->addSeconds($offset)->isSameDay(Carbon::now());
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ return [
|
||||
'require_https' => env('REQUIRE_HTTPS', true),
|
||||
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
||||
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
||||
'app_version' => env('APP_VERSION', '5.10.0'),
|
||||
'app_tag' => env('APP_TAG', '5.10.0'),
|
||||
'app_version' => env('APP_VERSION', '5.10.1'),
|
||||
'app_tag' => env('APP_TAG', '5.10.1'),
|
||||
'minimum_client_version' => '5.0.16',
|
||||
'terms_version' => '1.0.1',
|
||||
'api_secret' => env('API_SECRET', false),
|
||||
|
Loading…
Reference in New Issue
Block a user