From 6efe373c55b6be7c78322686cb4661a2defd0b0b Mon Sep 17 00:00:00 2001 From: = Date: Sun, 1 Aug 2021 15:46:40 +1000 Subject: [PATCH 01/10] Client merge --- app/Models/Client.php | 26 +++++++- app/Services/Client/ClientService.php | 6 ++ app/Services/Client/Merge.php | 86 +++++++++++++++++++++++++++ 3 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 app/Services/Client/Merge.php diff --git a/app/Models/Client.php b/app/Models/Client.php index 5bbfcc8af0..894d928a03 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -15,7 +15,11 @@ use App\DataMapper\ClientSettings; use App\DataMapper\CompanySettings; use App\DataMapper\FeesAndLimits; use App\Models\CompanyGateway; +use App\Models\Expense; use App\Models\Presenters\ClientPresenter; +use App\Models\Project; +use App\Models\Quote; +use App\Models\Task; use App\Services\Client\ClientService; use App\Utils\Traits\AppSetup; use App\Utils\Traits\GeneratesCounter; @@ -153,6 +157,16 @@ class Client extends BaseModel implements HasLocalePreference return $this->hasMany(ClientGatewayToken::class); } + public function expenses() + { + return $this->hasMany(Expense::class)->withTrashed(); + } + + public function projects() + { + return $this->hasMany(Project::class)->withTrashed(); + } + /** * Retrieves the specific payment token per * gateway - per payment method. @@ -217,6 +231,16 @@ class Client extends BaseModel implements HasLocalePreference return $this->hasMany(Invoice::class)->withTrashed(); } + public function quotes() + { + return $this->hasMany(Quote::class)->withTrashed(); + } + + public function tasks() + { + return $this->hasMany(Task::class)->withTrashed(); + } + public function recurring_invoices() { return $this->hasMany(RecurringInvoice::class)->withTrashed(); @@ -774,7 +798,7 @@ class Client extends BaseModel implements HasLocalePreference public function payments() { - return $this->hasMany(Payment::class); + return $this->hasMany(Payment::class)->withTrashed(); } public function timezone_offset() diff --git a/app/Services/Client/ClientService.php b/app/Services/Client/ClientService.php index 2355639f70..12cbcf7b3a 100644 --- a/app/Services/Client/ClientService.php +++ b/app/Services/Client/ClientService.php @@ -12,6 +12,7 @@ namespace App\Services\Client; use App\Models\Client; +use App\Services\Client\Merge; use App\Services\Client\PaymentMethod; use App\Utils\Number; use Illuminate\Database\Eloquent\Collection; @@ -77,6 +78,11 @@ class ClientService return (new PaymentMethod($this->client, $amount))->run(); } + public function merge(Client $mergable_client) + { + return (new Merge($this->client))->run($mergable_client); + } + public function save() :Client { $this->client->save(); diff --git a/app/Services/Client/Merge.php b/app/Services/Client/Merge.php new file mode 100644 index 0000000000..03fe5b866d --- /dev/null +++ b/app/Services/Client/Merge.php @@ -0,0 +1,86 @@ +client = $client; + } + + public function run(Client $mergable_client) + { + + $this->client->balance += $mergable_client->balance; + $this->client->paid_to_date += $mergable_client->paid_to_date; + $this->client->save(); + + $this->updateLedger($mergable_client->balance); + + $mergable_client->activities()->update(['client_id' => $this->client->id]); + $mergable_client->contacts()->update(['client_id' => $this->client->id]); + $mergable_client->gateway_tokens()->update(['client_id' => $this->client->id]); + $mergable_client->credits()->update(['client_id' => $this->client->id]); + $mergable_client->expenses()->update(['client_id' => $this->client->id]); + $mergable_client->invoices()->update(['client_id' => $this->client->id]); + $mergable_client->payments()->update(['client_id' => $this->client->id]); + $mergable_client->projects()->update(['client_id' => $this->client->id]); + $mergable_client->quotes()->update(['client_id' => $this->client->id]); + $mergable_client->recurring_invoices()->update(['client_id' => $this->client->id]); + $mergable_client->tasks()->update(['client_id' => $this->client->id]); + $mergable_client->contacts()->update(['client_id' => $this->client->id]); + $mergable_client->documents()->update(['client_id' => $this->client->id]); + + $mergable_client->forceDelete(); + + return $this; + } + + private function updateLedger($adjustment) + { + $balance = 0; + + $company_ledger = CompanyLedger::whereClientId($this->client->id) + ->orderBy('id', 'DESC') + ->first(); + + $company_ledger = $this->ledger(); + + if ($company_ledger) { + $balance = $company_ledger->balance; + } + + $company_ledger = CompanyLedgerFactory::create($this->client->company_id, $this->client->user_id); + $company_ledger->client_id = $this->client->id; + $company_ledger->adjustment = $adjustment; + $company_ledger->notes = "Balance update after merging " . $mergable_client->present()->name(); + $company_ledger->balance = $balance + $adjustment; + $company_ledger->activity_id = Activity::UPDATE_CLIENT + $company_ledger->save(); + + } + +} \ No newline at end of file From b95b80fc3246ffae787d9b1650b9ef47f56c1a6c Mon Sep 17 00:00:00 2001 From: = Date: Sun, 1 Aug 2021 17:21:08 +1000 Subject: [PATCH 02/10] Merging Clients --- app/Services/Client/ClientService.php | 4 +- app/Services/Client/Merge.php | 69 ++++++--- tests/Feature/Client/ClientMergeTest.php | 180 +++++++++++++++++++++++ 3 files changed, 228 insertions(+), 25 deletions(-) create mode 100644 tests/Feature/Client/ClientMergeTest.php diff --git a/app/Services/Client/ClientService.php b/app/Services/Client/ClientService.php index 12cbcf7b3a..840a3b7a97 100644 --- a/app/Services/Client/ClientService.php +++ b/app/Services/Client/ClientService.php @@ -80,7 +80,9 @@ class ClientService public function merge(Client $mergable_client) { - return (new Merge($this->client))->run($mergable_client); + $this->client = (new Merge($this->client, $mergable_client))->run(); + + return $this; } public function save() :Client diff --git a/app/Services/Client/Merge.php b/app/Services/Client/Merge.php index 03fe5b866d..23c19f04e1 100644 --- a/app/Services/Client/Merge.php +++ b/app/Services/Client/Merge.php @@ -25,38 +25,61 @@ use App\Utils\Traits\MakesHash; class Merge extends AbstractService { + public $client; - public function __construct(Client $client) + public $mergable_client; + + public function __construct(Client $client, Client $mergable_client) { $this->client = $client; + $this->mergable_client = $mergable_client; } - public function run(Client $mergable_client) + public function run() { - $this->client->balance += $mergable_client->balance; - $this->client->paid_to_date += $mergable_client->paid_to_date; + $this->client->balance += $this->mergable_client->balance; + $this->client->paid_to_date += $this->mergable_client->paid_to_date; $this->client->save(); - $this->updateLedger($mergable_client->balance); + $this->updateLedger($this->mergable_client->balance); - $mergable_client->activities()->update(['client_id' => $this->client->id]); - $mergable_client->contacts()->update(['client_id' => $this->client->id]); - $mergable_client->gateway_tokens()->update(['client_id' => $this->client->id]); - $mergable_client->credits()->update(['client_id' => $this->client->id]); - $mergable_client->expenses()->update(['client_id' => $this->client->id]); - $mergable_client->invoices()->update(['client_id' => $this->client->id]); - $mergable_client->payments()->update(['client_id' => $this->client->id]); - $mergable_client->projects()->update(['client_id' => $this->client->id]); - $mergable_client->quotes()->update(['client_id' => $this->client->id]); - $mergable_client->recurring_invoices()->update(['client_id' => $this->client->id]); - $mergable_client->tasks()->update(['client_id' => $this->client->id]); - $mergable_client->contacts()->update(['client_id' => $this->client->id]); - $mergable_client->documents()->update(['client_id' => $this->client->id]); + $this->mergable_client->activities()->update(['client_id' => $this->client->id]); + $this->mergable_client->contacts()->update(['client_id' => $this->client->id]); + $this->mergable_client->gateway_tokens()->update(['client_id' => $this->client->id]); + $this->mergable_client->credits()->update(['client_id' => $this->client->id]); + $this->mergable_client->expenses()->update(['client_id' => $this->client->id]); + $this->mergable_client->invoices()->update(['client_id' => $this->client->id]); + $this->mergable_client->payments()->update(['client_id' => $this->client->id]); + $this->mergable_client->projects()->update(['client_id' => $this->client->id]); + $this->mergable_client->quotes()->update(['client_id' => $this->client->id]); + $this->mergable_client->recurring_invoices()->update(['client_id' => $this->client->id]); + $this->mergable_client->tasks()->update(['client_id' => $this->client->id]); + $this->mergable_client->documents()->update(['documentable_id' => $this->client->id]); - $mergable_client->forceDelete(); + nlog("count =" .$this->mergable_client->contacts->count()); - return $this; + /* Loop through contacts an only merge distinct contacts by email */ + $this->mergable_client->contacts->each(function ($contact){ + + $exist = $this->client->contacts->contains(function ($client_contact) use($contact){ + nlog("{$client_contact->email} == {$contact->email}"); + return $client_contact->email == $contact->email; + }); + + if(!$exist) + { + nlog("doesn't exist - merging"); + $contact->client_id = $this->client->id; + $contact->save(); + } + + }); + + nlog($this->client->contacts->fresh()->count()); + $this->mergable_client->forceDelete(); + + return $this->client; } private function updateLedger($adjustment) @@ -67,8 +90,6 @@ class Merge extends AbstractService ->orderBy('id', 'DESC') ->first(); - $company_ledger = $this->ledger(); - if ($company_ledger) { $balance = $company_ledger->balance; } @@ -76,9 +97,9 @@ class Merge extends AbstractService $company_ledger = CompanyLedgerFactory::create($this->client->company_id, $this->client->user_id); $company_ledger->client_id = $this->client->id; $company_ledger->adjustment = $adjustment; - $company_ledger->notes = "Balance update after merging " . $mergable_client->present()->name(); + $company_ledger->notes = "Balance update after merging " . $this->mergable_client->present()->name(); $company_ledger->balance = $balance + $adjustment; - $company_ledger->activity_id = Activity::UPDATE_CLIENT + $company_ledger->activity_id = Activity::UPDATE_CLIENT; $company_ledger->save(); } diff --git a/tests/Feature/Client/ClientMergeTest.php b/tests/Feature/Client/ClientMergeTest.php new file mode 100644 index 0000000000..c990b20133 --- /dev/null +++ b/tests/Feature/Client/ClientMergeTest.php @@ -0,0 +1,180 @@ +faker = Factory::create(); + $this->buildCache(true); + } + + public function testSearchingForContacts() + { + + $account = Account::factory()->create(); + + $this->user = User::factory()->create([ + 'account_id' => $account->id, + 'email' => $this->faker->safeEmail + ]); + + $this->company = Company::factory()->create([ + 'account_id' => $account->id + ]); + + $this->client = Client::factory()->create([ + 'user_id' => $this->user->id, + 'company_id' => $this->company->id + ]); + + $this->primary_contact = ClientContact::factory()->create([ + 'user_id' => $this->user->id, + 'client_id' => $this->client->id, + 'company_id' => $this->company->id, + 'is_primary' => 1, + ]); + + ClientContact::factory()->count(2)->create([ + 'user_id' => $this->user->id, + 'client_id' => $this->client->id, + 'company_id' => $this->company->id, + ]); + + ClientContact::factory()->create([ + 'user_id' => $this->user->id, + 'client_id' => $this->client->id, + 'company_id' => $this->company->id, + 'email' => 'search@gmail.com' + ]); + + + $this->assertEquals(4, $this->client->contacts->count()); + $this->assertTrue($this->client->contacts->contains(function ($contact) { + return $contact->email == 'search@gmail.com'; + })); + + $this->assertFalse($this->client->contacts->contains(function ($contact) { + return $contact->email == 'false@gmail.com'; + })); + + } + + public function testMergeClients() + { + + $account = Account::factory()->create(); + + $user = User::factory()->create([ + 'account_id' => $account->id, + 'email' => $this->faker->safeEmail + ]); + + $company = Company::factory()->create([ + 'account_id' => $account->id + ]); + + $client = Client::factory()->create([ + 'user_id' => $user->id, + 'company_id' => $company->id + ]); + + $primary_contact = ClientContact::factory()->create([ + 'user_id' => $user->id, + 'client_id' => $client->id, + 'company_id' => $company->id, + 'is_primary' => 1, + ]); + + ClientContact::factory()->count(2)->create([ + 'user_id' => $user->id, + 'client_id' => $client->id, + 'company_id' => $company->id, + ]); + + ClientContact::factory()->create([ + 'user_id' => $user->id, + 'client_id' => $client->id, + 'company_id' => $company->id, + 'email' => 'search@gmail.com' + ]); + //4contacts + + $mergable_client = Client::factory()->create([ + 'user_id' => $user->id, + 'company_id' => $company->id + ]); + + $primary_contact = ClientContact::factory()->create([ + 'user_id' => $user->id, + 'client_id' => $mergable_client->id, + 'company_id' => $company->id, + 'is_primary' => 1, + ]); + + ClientContact::factory()->count(2)->create([ + 'user_id' => $user->id, + 'client_id' => $mergable_client->id, + 'company_id' => $company->id, + ]); + + ClientContact::factory()->create([ + 'user_id' => $user->id, + 'client_id' => $mergable_client->id, + 'company_id' => $company->id, + 'email' => 'search@gmail.com' + ]); + //4 contacts + + $this->assertEquals(4, $client->contacts->count()); + $this->assertEquals(4, $mergable_client->contacts->count()); + + $client = $client->service()->merge($mergable_client)->save(); + + // nlog($client->contacts->fresh()->toArray()); + // $this->assertEquals(7, $client->fresh()->contacts->count()); + + } + +} From 70b452907635147e0e59fa2ab76f4e7e779db7ea Mon Sep 17 00:00:00 2001 From: = Date: Sun, 1 Aug 2021 21:03:30 +1000 Subject: [PATCH 03/10] Tests for merging clients --- app/Services/Client/Merge.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/Services/Client/Merge.php b/app/Services/Client/Merge.php index 23c19f04e1..942558aa91 100644 --- a/app/Services/Client/Merge.php +++ b/app/Services/Client/Merge.php @@ -67,12 +67,11 @@ class Merge extends AbstractService return $client_contact->email == $contact->email; }); - if(!$exist) + if($exist) { - nlog("doesn't exist - merging"); - $contact->client_id = $this->client->id; + $contact->delete(); $contact->save(); - } + } }); From 1d58a87a24377bf279740a678e7f67c59eb63018 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 2 Aug 2021 07:41:46 +1000 Subject: [PATCH 04/10] dispatchNow inside email entity --- app/Jobs/Entity/EmailEntity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Jobs/Entity/EmailEntity.php b/app/Jobs/Entity/EmailEntity.php index 32829c030a..f8e4ae5aff 100644 --- a/app/Jobs/Entity/EmailEntity.php +++ b/app/Jobs/Entity/EmailEntity.php @@ -119,7 +119,7 @@ class EmailEntity implements ShouldQueue $nmo->reminder_template = $this->reminder_template; $nmo->entity = $this->entity; - NinjaMailerJob::dispatch($nmo); + NinjaMailerJob::dispatchNow($nmo); /* Mark entity sent */ $this->entity->service()->markSent()->save(); From bce7667aa5480856834a279d4a1c47806ff52f16 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 2 Aug 2021 09:20:38 +1000 Subject: [PATCH 05/10] Fix translations for import email --- app/Jobs/Util/Import.php | 5 +++++ app/Repositories/ActivityRepository.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index e256105de3..8086b3a845 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -91,6 +91,7 @@ use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Validator; use Illuminate\Support\Str; use Turbo124\Beacon\Facades\LightLogs; +use Illuminate\Support\Facades\App; class Import implements ShouldQueue { @@ -244,6 +245,10 @@ class Import implements ShouldQueue // $this->fixData(); try{ + App::forgetInstance('translator'); + $t = app('translator'); + $t->replace(Ninja::transformTranslations($this->company->settings)); + Mail::to($this->user->email, $this->user->name()) ->send(new MigrationCompleted($this->company, implode("
",$check_data))); } diff --git a/app/Repositories/ActivityRepository.php b/app/Repositories/ActivityRepository.php index ce31e331ce..ec0beef03b 100644 --- a/app/Repositories/ActivityRepository.php +++ b/app/Repositories/ActivityRepository.php @@ -125,7 +125,7 @@ class ActivityRepository extends BaseRepository $design = Design::find($entity_design_id); - if(!$entity->invitations()->exists()){ + if(!$entity->invitations()->exists() || !$design){ nlog("No invitations for entity {$entity->id} - {$entity->number}"); return; } From 413719b72cc4cafd263b42c34075b17586734689 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 2 Aug 2021 11:08:03 +1000 Subject: [PATCH 06/10] Fixes for correct include for Design --- app/Http/Controllers/PreviewController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/PreviewController.php b/app/Http/Controllers/PreviewController.php index 8861ca321a..ba81318fcf 100644 --- a/app/Http/Controllers/PreviewController.php +++ b/app/Http/Controllers/PreviewController.php @@ -218,7 +218,7 @@ class PreviewController extends BaseController /* Catch all in case migration doesn't pass back a valid design */ if(!$design) - $design = Design::find(2); + $design = \App\Models\Design::find(2); if ($design->is_custom) { $options = [ From efe3f517789fc65a35ec9c30245fe5971055ed51 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 2 Aug 2021 13:12:33 +1000 Subject: [PATCH 07/10] Notify end user to connect with Stripe Connect on hosted platform --- app/Jobs/Util/Import.php | 14 ++++- app/Mail/Migration/StripeConnectMigration.php | 55 +++++++++++++++++++ app/Services/Client/Merge.php | 4 -- resources/lang/en/texts.php | 2 + .../email/migration/max_companies.blade.php | 1 + .../email/migration/stripe_connect.blade.php | 7 +++ 6 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 app/Mail/Migration/StripeConnectMigration.php create mode 100644 resources/views/email/migration/stripe_connect.blade.php diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index 8086b3a845..25db49aa85 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -35,11 +35,14 @@ use App\Http\ValidationRules\ValidCompanyGatewayFeesAndLimitsRule; use App\Http\ValidationRules\ValidUserForCompany; use App\Jobs\Company\CreateCompanyTaskStatuses; use App\Jobs\Company\CreateCompanyToken; +use App\Jobs\Mail\NinjaMailerJob; +use App\Jobs\Mail\NinjaMailerObject; use App\Jobs\Ninja\CheckCompanyData; use App\Jobs\Ninja\CompanySizeCheck; use App\Jobs\Util\VersionCheck; use App\Libraries\MultiDB; use App\Mail\MigrationCompleted; +use App\Mail\Migration\StripeConnectMigration; use App\Models\Activity; use App\Models\Client; use App\Models\ClientContact; @@ -87,11 +90,11 @@ use Illuminate\Http\UploadedFile; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Carbon; +use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Validator; use Illuminate\Support\Str; use Turbo124\Beacon\Facades\LightLogs; -use Illuminate\Support\Facades\App; class Import implements ShouldQueue { @@ -1386,7 +1389,16 @@ class Import implements ShouldQueue $modified['fees_and_limits'] = $this->cleanFeesAndLimits($modified['fees_and_limits']); } + /* On Hosted platform we need to advise Stripe users to connect with Stripe Connect */ if(Ninja::isHosted() && $modified['gateway_key'] == 'd14dd26a37cecc30fdd65700bfb55b23'){ + + $nmo = new NinjaMailerObject; + $nmo->mailable = new StripeConnectMigration($this->company); + $nmo->company = $this->company; + $nmo->settings = $this->company->settings; + $nmo->to_user = $this->user; + NinjaMailerJob::dispatch($nmo); + $modified['gateway_key'] = 'd14dd26a47cecc30fdd65700bfb67b34'; $modified['fees_and_limits'] = []; } diff --git a/app/Mail/Migration/StripeConnectMigration.php b/app/Mail/Migration/StripeConnectMigration.php new file mode 100644 index 0000000000..93fda725af --- /dev/null +++ b/app/Mail/Migration/StripeConnectMigration.php @@ -0,0 +1,55 @@ +company = $company; + } + + /** + * Build the message. + * + * @return $this + */ + public function build() + { + $this->settings = $this->company->settings; + $this->logo = $this->company->present()->logo(); + $this->whitelabel = $this->company->account->isPaid(); + + return $this->from(config('mail.from.address'), config('mail.from.name')) + ->subject(ctrans('texts.stripe_connect_migration_title')) + ->view('email.migration.stripe_connect'); + } +} diff --git a/app/Services/Client/Merge.php b/app/Services/Client/Merge.php index 942558aa91..e254000b23 100644 --- a/app/Services/Client/Merge.php +++ b/app/Services/Client/Merge.php @@ -57,13 +57,10 @@ class Merge extends AbstractService $this->mergable_client->tasks()->update(['client_id' => $this->client->id]); $this->mergable_client->documents()->update(['documentable_id' => $this->client->id]); - nlog("count =" .$this->mergable_client->contacts->count()); - /* Loop through contacts an only merge distinct contacts by email */ $this->mergable_client->contacts->each(function ($contact){ $exist = $this->client->contacts->contains(function ($client_contact) use($contact){ - nlog("{$client_contact->email} == {$contact->email}"); return $client_contact->email == $contact->email; }); @@ -75,7 +72,6 @@ class Merge extends AbstractService }); - nlog($this->client->contacts->fresh()->count()); $this->mergable_client->forceDelete(); return $this->client; diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 40038652eb..eed12cf3f4 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -4287,6 +4287,8 @@ $LANG = array( 'company_deleted' => 'Company deleted', 'company_deleted_body' => 'Company [ :company ] was deleted by :user', 'back_to' => 'Back to :url', + 'stripe_connect_migration_title' => 'Connect your Stripe Account', + 'stripe_connect_migration_desc' => 'Invoice Ninja v5 uses Stripe Connect to link your Stripe account to Invoice Ninja. This provides an additional layer of security for your account. Now that you data has migrated, you will need to Authorize Stripe to accept payments in v5.

To do this, navigate to Settings > Online Payments > Configure Gateways. Click on Stripe Connect and then under Settings click Setup Gateway. This will take you to Stripe to authorize Invoice Ninja and on your return your account will be successfully linked!', ); return $LANG; diff --git a/resources/views/email/migration/max_companies.blade.php b/resources/views/email/migration/max_companies.blade.php index 6dd1b45a93..11bb1484f1 100644 --- a/resources/views/email/migration/max_companies.blade.php +++ b/resources/views/email/migration/max_companies.blade.php @@ -1,6 +1,7 @@ @component('email.template.admin', ['logo' => $logo, 'settings' => $settings])

{{ ctrans('texts.max_companies') }}

+

{{ ctrans('texts.max_companies_desc') }}

@endcomponent diff --git a/resources/views/email/migration/stripe_connect.blade.php b/resources/views/email/migration/stripe_connect.blade.php new file mode 100644 index 0000000000..6e7be3c2c0 --- /dev/null +++ b/resources/views/email/migration/stripe_connect.blade.php @@ -0,0 +1,7 @@ +@component('email.template.admin', ['logo' => $logo, 'settings' => $settings]) +
+

{{ ctrans('texts.stripe_connect_migration_title') }}

+ +

{{ ctrans('texts.stripe_connect_migration_desc') }}

+
+@endcomponent From c64e9cc73909f49742cf03ddc530cca9fcf616ee Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 3 Aug 2021 07:01:28 +1000 Subject: [PATCH 08/10] place check whether a recurring invoice should be automatically sent --- app/Jobs/RecurringInvoice/SendRecurring.php | 4 ++-- app/Services/User/UserService.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Jobs/RecurringInvoice/SendRecurring.php b/app/Jobs/RecurringInvoice/SendRecurring.php index 70e249f580..96ed926e73 100644 --- a/app/Jobs/RecurringInvoice/SendRecurring.php +++ b/app/Jobs/RecurringInvoice/SendRecurring.php @@ -86,14 +86,14 @@ class SendRecurring implements ShouldQueue $this->recurring_invoice->save(); //Admin notification for recurring invoice sent. - if ($invoice->invitations->count() >= 1) { + if ($invoice->invitations->count() >= 1 ) { $invoice->entityEmailEvent($invoice->invitations->first(), 'invoice', 'email_template_invoice'); } nlog("Invoice {$invoice->number} created"); $invoice->invitations->each(function ($invitation) use ($invoice) { - if ($invitation->contact && strlen($invitation->contact->email) >=1) { + if ($invitation->contact && strlen($invitation->contact->email) >=1 && $invoice->client->getSetting('auto_email_invoice')) { try{ EmailEntity::dispatch($invitation, $invoice->company); diff --git a/app/Services/User/UserService.php b/app/Services/User/UserService.php index 5b44632420..bcecad59ac 100644 --- a/app/Services/User/UserService.php +++ b/app/Services/User/UserService.php @@ -39,7 +39,7 @@ class UserService $nmo->to_user = $this->user; $nmo->settings = $company->settings; - NinjaMailerJob::dispatch($nmo); + NinjaMailerJob::dispatch($nmo, true); Ninja::registerNinjaUser($this->user); From 98e82f3ea65fb8f98715844ba5ae4825e7ed9201 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 3 Aug 2021 07:40:42 +1000 Subject: [PATCH 09/10] slow down web hook requests if the are too fast for usgit status --- app/Http/Requests/Payments/PaymentWebhookRequest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Requests/Payments/PaymentWebhookRequest.php b/app/Http/Requests/Payments/PaymentWebhookRequest.php index ea11d0af20..50bc276c14 100644 --- a/app/Http/Requests/Payments/PaymentWebhookRequest.php +++ b/app/Http/Requests/Payments/PaymentWebhookRequest.php @@ -74,9 +74,9 @@ class PaymentWebhookRequest extends Request { // For testing purposes we'll slow down the webhook processing by 2 seconds // to make sure webhook request doesn't came before our processing. - if (app()->environment() !== 'production') { + //if (app()->environment() !== 'production') { sleep(2); - } + //} // Some gateways, like Checkout, we can dynamically pass payment hash, // which we will resolve here and get payment information from it. From 4f4ae1b48e94559af1afef27a9cea36322d6fbd4 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 3 Aug 2021 07:57:56 +1000 Subject: [PATCH 10/10] Stripe Connect Fees and Limits --- app/Jobs/Util/Import.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index 25db49aa85..7b01cc890c 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -1400,7 +1400,10 @@ class Import implements ShouldQueue NinjaMailerJob::dispatch($nmo); $modified['gateway_key'] = 'd14dd26a47cecc30fdd65700bfb67b34'; - $modified['fees_and_limits'] = []; + + //why do we set this to a blank array? + //$modified['fees_and_limits'] = []; + } $company_gateway = CompanyGateway::create($modified);