Merge pull request #5613 from turbo124/v5-develop

Fixes for reset counter
This commit is contained in:
David Bomba 2021-05-05 11:11:04 +10:00 committed by GitHub
commit d55a5df148
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 20 deletions

View File

@ -47,6 +47,7 @@ class InvoiceEmailActivity implements ShouldQueue
$fields->user_id = $event->invitation->invoice->user_id;
$fields->company_id = $event->invitation->invoice->company_id;
$fields->client_contact_id = $event->invitation->invoice->client_contact_id;
$fields->client_id = $event->invitation->invoice->client_id;
$fields->activity_type_id = Activity::EMAIL_INVOICE;
$this->activity_repo->save($fields, $event->invitation->invoice, $event->event_vars);

View File

@ -48,6 +48,7 @@ class QuoteEmailActivity implements ShouldQueue
$fields->user_id = $event->invitation->quote->user_id;
$fields->company_id = $event->invitation->quote->company_id;
$fields->client_contact_id = $event->invitation->quote->client_contact_id;
$fields->client_id = $event->invitation->quote->client_id;
$fields->activity_type_id = Activity::EMAIL_QUOTE;
$this->activity_repo->save($fields, $event->invitation->quote, $event->event_vars);

View File

@ -431,54 +431,55 @@ trait GeneratesCounter
$reset_date = Carbon::parse($client->getSetting('reset_counter_date'), $timezone->name);
if (! $reset_date->isToday() || ! $client->getSetting('reset_counter_date')) {
if (! $reset_date->lte(now()) || ! $client->getSetting('reset_counter_date')) {
return false;
}
switch ($reset_counter_frequency) {
case RecurringInvoice::FREQUENCY_DAILY:
$reset_date->addDay();
now()->addDay();
break;
case RecurringInvoice::FREQUENCY_WEEKLY:
$reset_date->addWeek();
now()->addWeek();
break;
case RecurringInvoice::FREQUENCY_TWO_WEEKS:
$reset_date->addWeeks(2);
now()->addWeeks(2);
break;
case RecurringInvoice::FREQUENCY_FOUR_WEEKS:
$reset_date->addWeeks(4);
now()->addWeeks(4);
break;
case RecurringInvoice::FREQUENCY_MONTHLY:
$reset_date->addMonth();
now()->addMonth();
break;
case RecurringInvoice::FREQUENCY_TWO_MONTHS:
$reset_date->addMonths(2);
now()->addMonths(2);
break;
case RecurringInvoice::FREQUENCY_THREE_MONTHS:
$reset_date->addMonths(3);
now()->addMonths(3);
break;
case RecurringInvoice::FREQUENCY_FOUR_MONTHS:
$reset_date->addMonths(4);
now()->addMonths(4);
break;
case RecurringInvoice::FREQUENCY_SIX_MONTHS:
$reset_date->addMonths(6);
now()->addMonths(6);
break;
case RecurringInvoice::FREQUENCY_ANNUALLY:
$reset_date->addYear();
now()->addYear();
break;
case RecurringInvoice::FREQUENCY_TWO_YEARS:
$reset_date->addYears(2);
now()->addYears(2);
break;
}
$settings = $client->company->settings;
$settings->reset_counter_date = $reset_date->format($client->date_format());
$settings->reset_counter_date = $reset_date->format('Y-m-d');
$settings->invoice_number_counter = 1;
$settings->quote_number_counter = 1;
$settings->credit_number_counter = 1;
$client->company->settings = $settings;
$client->company->save();
}
private function resetCompanyCounters($company)
@ -487,7 +488,7 @@ trait GeneratesCounter
$reset_date = Carbon::parse($company->settings->reset_counter_date, $timezone->name);
if (! $reset_date->isToday() || ! $company->settings->reset_counter_date) {
if (! $reset_date->lte(now()) || ! $company->settings->reset_counter_date) {
return false;
}

12
composer.lock generated
View File

@ -9746,16 +9746,16 @@
},
{
"name": "turbo124/beacon",
"version": "1.0.14",
"version": "1.0.16",
"source": {
"type": "git",
"url": "https://github.com/turbo124/beacon.git",
"reference": "177d72f42dce4b2555b9870f07de37ecceefe864"
"reference": "17b6fc4370422a935ff7f2038c5167945905533f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/turbo124/beacon/zipball/177d72f42dce4b2555b9870f07de37ecceefe864",
"reference": "177d72f42dce4b2555b9870f07de37ecceefe864",
"url": "https://api.github.com/repos/turbo124/beacon/zipball/17b6fc4370422a935ff7f2038c5167945905533f",
"reference": "17b6fc4370422a935ff7f2038c5167945905533f",
"shasum": ""
},
"require": {
@ -9803,9 +9803,9 @@
"turbo124"
],
"support": {
"source": "https://github.com/turbo124/beacon/tree/1.0.14"
"source": "https://github.com/turbo124/beacon/tree/1.0.16"
},
"time": "2021-05-04T13:58:59+00:00"
"time": "2021-05-05T01:09:24+00:00"
},
{
"name": "turbo124/laravel-gmail",