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->user_id = $event->invitation->invoice->user_id;
$fields->company_id = $event->invitation->invoice->company_id; $fields->company_id = $event->invitation->invoice->company_id;
$fields->client_contact_id = $event->invitation->invoice->client_contact_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; $fields->activity_type_id = Activity::EMAIL_INVOICE;
$this->activity_repo->save($fields, $event->invitation->invoice, $event->event_vars); $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->user_id = $event->invitation->quote->user_id;
$fields->company_id = $event->invitation->quote->company_id; $fields->company_id = $event->invitation->quote->company_id;
$fields->client_contact_id = $event->invitation->quote->client_contact_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; $fields->activity_type_id = Activity::EMAIL_QUOTE;
$this->activity_repo->save($fields, $event->invitation->quote, $event->event_vars); $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); $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; return false;
} }
switch ($reset_counter_frequency) { switch ($reset_counter_frequency) {
case RecurringInvoice::FREQUENCY_DAILY: case RecurringInvoice::FREQUENCY_DAILY:
$reset_date->addDay(); now()->addDay();
break; break;
case RecurringInvoice::FREQUENCY_WEEKLY: case RecurringInvoice::FREQUENCY_WEEKLY:
$reset_date->addWeek(); now()->addWeek();
break; break;
case RecurringInvoice::FREQUENCY_TWO_WEEKS: case RecurringInvoice::FREQUENCY_TWO_WEEKS:
$reset_date->addWeeks(2); now()->addWeeks(2);
break; break;
case RecurringInvoice::FREQUENCY_FOUR_WEEKS: case RecurringInvoice::FREQUENCY_FOUR_WEEKS:
$reset_date->addWeeks(4); now()->addWeeks(4);
break; break;
case RecurringInvoice::FREQUENCY_MONTHLY: case RecurringInvoice::FREQUENCY_MONTHLY:
$reset_date->addMonth(); now()->addMonth();
break; break;
case RecurringInvoice::FREQUENCY_TWO_MONTHS: case RecurringInvoice::FREQUENCY_TWO_MONTHS:
$reset_date->addMonths(2); now()->addMonths(2);
break; break;
case RecurringInvoice::FREQUENCY_THREE_MONTHS: case RecurringInvoice::FREQUENCY_THREE_MONTHS:
$reset_date->addMonths(3); now()->addMonths(3);
break; break;
case RecurringInvoice::FREQUENCY_FOUR_MONTHS: case RecurringInvoice::FREQUENCY_FOUR_MONTHS:
$reset_date->addMonths(4); now()->addMonths(4);
break; break;
case RecurringInvoice::FREQUENCY_SIX_MONTHS: case RecurringInvoice::FREQUENCY_SIX_MONTHS:
$reset_date->addMonths(6); now()->addMonths(6);
break; break;
case RecurringInvoice::FREQUENCY_ANNUALLY: case RecurringInvoice::FREQUENCY_ANNUALLY:
$reset_date->addYear(); now()->addYear();
break; break;
case RecurringInvoice::FREQUENCY_TWO_YEARS: case RecurringInvoice::FREQUENCY_TWO_YEARS:
$reset_date->addYears(2); now()->addYears(2);
break; break;
} }
$settings = $client->company->settings; $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->invoice_number_counter = 1;
$settings->quote_number_counter = 1; $settings->quote_number_counter = 1;
$settings->credit_number_counter = 1; $settings->credit_number_counter = 1;
$client->company->settings = $settings; $client->company->settings = $settings;
$client->company->save(); $client->company->save();
} }
private function resetCompanyCounters($company) private function resetCompanyCounters($company)
@ -487,7 +488,7 @@ trait GeneratesCounter
$reset_date = Carbon::parse($company->settings->reset_counter_date, $timezone->name); $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; return false;
} }

12
composer.lock generated
View File

@ -9746,16 +9746,16 @@
}, },
{ {
"name": "turbo124/beacon", "name": "turbo124/beacon",
"version": "1.0.14", "version": "1.0.16",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/turbo124/beacon.git", "url": "https://github.com/turbo124/beacon.git",
"reference": "177d72f42dce4b2555b9870f07de37ecceefe864" "reference": "17b6fc4370422a935ff7f2038c5167945905533f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/turbo124/beacon/zipball/177d72f42dce4b2555b9870f07de37ecceefe864", "url": "https://api.github.com/repos/turbo124/beacon/zipball/17b6fc4370422a935ff7f2038c5167945905533f",
"reference": "177d72f42dce4b2555b9870f07de37ecceefe864", "reference": "17b6fc4370422a935ff7f2038c5167945905533f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -9803,9 +9803,9 @@
"turbo124" "turbo124"
], ],
"support": { "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", "name": "turbo124/laravel-gmail",