diff --git a/VERSION.txt b/VERSION.txt index c0204ea277af..b62d8ef8ec05 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.10.16 \ No newline at end of file +5.10.17 \ No newline at end of file diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 2c1a731228ad..382a577102d7 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -15,7 +15,6 @@ use App\Jobs\Cron\AutoBillCron; use App\Jobs\Cron\RecurringExpensesCron; use App\Jobs\Cron\RecurringInvoicesCron; use App\Jobs\Cron\SubscriptionCron; -use App\Jobs\Cron\UpdateCalculatedFields; use App\Jobs\Invoice\InvoiceCheckLateWebhook; use App\Jobs\Ninja\AdjustEmailQuota; use App\Jobs\Ninja\BankTransactionSync; @@ -33,6 +32,7 @@ use App\Jobs\Util\SchedulerCheck; use App\Jobs\Util\UpdateExchangeRates; use App\Jobs\Util\VersionCheck; use App\Models\Account; +use App\PaymentDrivers\Rotessa\Jobs\TransactionReport; use App\Utils\Ninja; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; @@ -65,12 +65,12 @@ class Kernel extends ConsoleKernel /* Checks for scheduled tasks */ $schedule->job(new TaskScheduler())->hourlyAt(10)->withoutOverlapping()->name('task-scheduler-job')->onOneServer(); + /* Checks Rotessa Transactions */ + $schedule->job(new TransactionReport())->dailyAt('01:48')->withoutOverlapping()->name('rotessa-transaction-report')->onOneServer(); + /* Stale Invoice Cleanup*/ $schedule->job(new CleanStaleInvoiceOrder())->hourlyAt(30)->withoutOverlapping()->name('stale-invoice-job')->onOneServer(); - /* Stale Invoice Cleanup*/ - $schedule->job(new UpdateCalculatedFields())->hourlyAt(40)->withoutOverlapping()->name('update-calculated-fields-job')->onOneServer(); - /* Checks for large companies and marked them as is_large */ $schedule->job(new CompanySizeCheck())->dailyAt('23:20')->withoutOverlapping()->name('company-size-job')->onOneServer(); diff --git a/app/Http/Controllers/CompanyGatewayController.php b/app/Http/Controllers/CompanyGatewayController.php index 56fc9ce0c1ff..552374bfd2bc 100644 --- a/app/Http/Controllers/CompanyGatewayController.php +++ b/app/Http/Controllers/CompanyGatewayController.php @@ -567,9 +567,9 @@ class CompanyGatewayController extends BaseController { //Throttle here - if (Cache::has("throttle_polling:import_customers:{$company_gateway->company->company_key}:{$company_gateway->hashed_id}")) { - return response()->json(['message' => 'Please wait whilst your previous attempts complete.'], 200); - } + // if (Cache::has("throttle_polling:import_customers:{$company_gateway->company->company_key}:{$company_gateway->hashed_id}")) { + // return response()->json(['message' => 'Please wait whilst your previous attempts complete.'], 200); + // } dispatch(function () use ($company_gateway) { MultiDB::setDb($company_gateway->company->db); diff --git a/app/Http/ViewComposers/Components/Rotessa/AccountComponent.php b/app/Http/ViewComposers/Components/Rotessa/AccountComponent.php index e161b3a1216f..c7702b4e66a3 100644 --- a/app/Http/ViewComposers/Components/Rotessa/AccountComponent.php +++ b/app/Http/ViewComposers/Components/Rotessa/AccountComponent.php @@ -27,16 +27,13 @@ class AccountComponent extends Component 'routing_number' => null, 'institution_number' => null, 'transit_number' => null, - 'bank_name' => ' ', + 'bank_name' => null, 'account_number' => null, 'country' => 'US', "authorization_type" => 'Online' ]; - public array $account; - - public function __construct(array $account) { - $this->account = $account; + public function __construct(public array $account) { $this->attributes = $this->newAttributeBag(Arr::only($this->account, $this->fields) ); } diff --git a/app/Http/ViewComposers/Components/Rotessa/AddressComponent.php b/app/Http/ViewComposers/Components/Rotessa/AddressComponent.php index b26222b18c53..836bbf00ff4f 100644 --- a/app/Http/ViewComposers/Components/Rotessa/AddressComponent.php +++ b/app/Http/ViewComposers/Components/Rotessa/AddressComponent.php @@ -25,10 +25,7 @@ class AddressComponent extends Component 'country' => 'US' ]; - public array $address; - - public function __construct(array $address) { - $this->address = $address; + public function __construct(public array $address) { if(strlen($this->address['state']) > 2 ) { $this->address['state'] = $this->address['country'] == 'US' ? array_search($this->address['state'], USStates::$states) : CAProvinces::getAbbreviation($this->address['state']); } diff --git a/app/Http/ViewComposers/Components/Rotessa/ContactComponent.php b/app/Http/ViewComposers/Components/Rotessa/ContactComponent.php index 3557cd05351f..e5419856a6e8 100644 --- a/app/Http/ViewComposers/Components/Rotessa/ContactComponent.php +++ b/app/Http/ViewComposers/Components/Rotessa/ContactComponent.php @@ -18,9 +18,9 @@ class ContactComponent extends Component $contact = collect($contact->client->contacts->firstWhere('is_primary', 1)->toArray())->merge([ 'home_phone' =>$contact->client->phone, - 'custom_identifier' => $contact->client->number, + 'custom_identifier' => $contact->client->client_hash, 'name' =>$contact->client->name, - 'id' => $contact->client->contact_key, + 'id' => null, ] )->all(); $this->attributes = $this->newAttributeBag(Arr::only($contact, $this->fields) ); diff --git a/app/Http/ViewComposers/Components/RotessaComponents.php b/app/Http/ViewComposers/Components/RotessaComponents.php deleted file mode 100644 index b984d0bb2339..000000000000 --- a/app/Http/ViewComposers/Components/RotessaComponents.php +++ /dev/null @@ -1,123 +0,0 @@ -client->contacts->firstWhere('is_primary', 1)->toArray())->merge([ - 'home_phone' =>$contact->client->phone, - 'custom_identifier' => $contact->client->number, - 'name' =>$contact->client->name, - 'id' => null - ] )->all(); - - $this->attributes = $this->newAttributeBag(Arr::only($contact, $this->fields) ); - } - - private $fields = [ - 'name', - 'email', - 'home_phone', - 'phone', - 'custom_identifier', - 'customer_type' , - 'id' - ]; - - private $defaults = [ - 'customer_type' => "Business", - 'customer_identifier' => null, - 'id' => null - ]; - - public function render() - { - return render('gateways.rotessa.components.contact', array_merge($this->defaults, $this->attributes->getAttributes() ) ); - } -} - -// Address Component -class AddressComponent extends Component -{ - private $fields = [ - 'address_1', - 'address_2', - 'city', - 'postal_code', - 'province_code', - 'country' - ]; - - private $defaults = [ - 'country' => 'US' - ]; - - public array $address; - - public function __construct(array $address) { - $this->address = $address; - if(strlen($this->address['state']) > 2 ) { - $this->address['state'] = $this->address['country'] == 'US' ? array_search($this->address['state'], USStates::$states) : CAProvinces::getAbbreviation($this->address['state']); - } - - $this->attributes = $this->newAttributeBag( - Arr::only(Arr::mapWithKeys($this->address, function ($item, $key) { - return in_array($key, ['address1','address2','state'])?[ (['address1'=>'address_1','address2'=>'address_2','state'=>'province_code'])[$key] => $item ] :[ $key => $item ]; - }), - $this->fields) ); - } - - - public function render() - { - return render('gateways.rotessa.components.address',array_merge( $this->defaults, $this->attributes->getAttributes() ) ); - } -} - -// AmericanBankInfo Component -class AccountComponent extends Component -{ - private $fields = [ - 'bank_account_type', - 'routing_number', - 'institution_number', - 'transit_number', - 'bank_name', - 'country', - 'account_number' - ]; - - private $defaults = [ - 'bank_account_type' => null, - 'routing_number' => null, - 'institution_number' => null, - 'transit_number' => null, - 'bank_name' => ' ', - 'account_number' => null, - 'country' => 'US', - "authorization_type" => 'Online' - ]; - - public array $account; - - public function __construct(array $account) { - $this->account = $account; - $this->attributes = $this->newAttributeBag(Arr::only($this->account, $this->fields) ); - } - - public function render() - { - return render('gateways.rotessa.components.account', array_merge($this->attributes->getAttributes(), $this->defaults) ); - } -} diff --git a/app/Jobs/Cron/UpdateCalculatedFields.php b/app/Jobs/Cron/UpdateCalculatedFields.php deleted file mode 100644 index 465108c96800..000000000000 --- a/app/Jobs/Cron/UpdateCalculatedFields.php +++ /dev/null @@ -1,105 +0,0 @@ -with('tasks')->whereHas('tasks', function ($query) { - $query->where('updated_at', '>', now()->subHours(2)); - }) - ->cursor() - ->each(function ($project) { - - $project->current_hours = $this->calculateDuration($project); - $project->save(); - }); - - - - } else { - //multiDB environment, need to - foreach (MultiDB::$dbs as $db) { - MultiDB::setDB($db); - - - Project::query()->with('tasks')->whereHas('tasks', function ($query) { - $query->where('updated_at', '>', now()->subHours(2)); - }) - ->cursor() - ->each(function ($project) { - $project->current_hours = $this->calculateDuration($project); - $project->save(); - }); - - //Clean password resets table - \DB::connection($db)->table('password_resets')->where('created_at', '<', now()->subHour())->delete(); - - } - } - } - - private function calculateDuration($project): int - { - $duration = 0; - - $project->tasks->each(function ($task) use (&$duration) { - - if(is_iterable(json_decode($task->time_log))) { - - foreach(json_decode($task->time_log) as $log) { - - if(!is_array($log)) - continue; - - $start_time = $log[0]; - $end_time = $log[1] == 0 ? time() : $log[1]; - - $duration += $end_time - $start_time; - - } - } - - }); - - return (int) round(($duration / 60 / 60), 0); - - } -} diff --git a/app/Jobs/Mailgun/ProcessMailgunWebhook.php b/app/Jobs/Mailgun/ProcessMailgunWebhook.php index 69be326cd288..b0f1ed65aaac 100644 --- a/app/Jobs/Mailgun/ProcessMailgunWebhook.php +++ b/app/Jobs/Mailgun/ProcessMailgunWebhook.php @@ -94,7 +94,9 @@ class ProcessMailgunWebhook implements ShouldQueue } MultiDB::findAndSetDbByCompanyKey($this->request['event-data']['tags'][0]); - $company = Company::query()->where('company_key', $this->request['event-data']['tags'][0])->first(); + + /** @var \App\Models\Company $company */ + $company = Company::where('company_key', $this->request['event-data']['tags'][0])->first(); if ($company && $this->request['event-data']['event'] == 'complained' && config('ninja.notification.slack')) { $company->notification(new EmailSpamNotification($company))->ninja(); @@ -195,7 +197,7 @@ class ProcessMailgunWebhook implements ShouldQueue 'date' => \Carbon\Carbon::parse($this->request['event-data']['timestamp'])->format('Y-m-d H:i:s') ?? '', ]; - if($sl) { + if($sl instanceof SystemLog) { $data = $sl->log; $data['history']['events'][] = $event; $this->updateSystemLog($sl, $data); diff --git a/app/Jobs/Subscription/CleanStaleInvoiceOrder.php b/app/Jobs/Subscription/CleanStaleInvoiceOrder.php index ddf7ce404856..d8295ed9f54d 100644 --- a/app/Jobs/Subscription/CleanStaleInvoiceOrder.php +++ b/app/Jobs/Subscription/CleanStaleInvoiceOrder.php @@ -95,6 +95,8 @@ class CleanStaleInvoiceOrder implements ShouldQueue ->each(function ($invoice) { $invoice->service()->removeUnpaidGatewayFees(); }); + + \DB::connection($db)->table('password_resets')->where('created_at', '<', now()->subHours(12))->delete(); } } diff --git a/app/Mail/TemplateEmail.php b/app/Mail/TemplateEmail.php index 78f45c372d1d..1c5be18e9859 100644 --- a/app/Mail/TemplateEmail.php +++ b/app/Mail/TemplateEmail.php @@ -65,7 +65,7 @@ class TemplateEmail extends Mailable } $link_string = '