diff --git a/VERSION.txt b/VERSION.txt index 81badfbf4a7c..ba678f2d2cf2 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.2.13 \ No newline at end of file +5.2.14 \ No newline at end of file diff --git a/app/Console/Commands/CreateAccount.php b/app/Console/Commands/CreateAccount.php index 689ba262b0b5..b6c51e992858 100644 --- a/app/Console/Commands/CreateAccount.php +++ b/app/Console/Commands/CreateAccount.php @@ -91,6 +91,8 @@ class CreateAccount extends Command $account = Account::factory()->create(); $company = Company::factory()->create([ 'account_id' => $account->id, + 'portal_domain' => config('ninja.app_url'), + 'portal_mode' => 'domain', ]); $account->default_company_id = $company->id; diff --git a/app/Jobs/Util/ReminderJob.php b/app/Jobs/Util/ReminderJob.php index 4c55aa8bc64c..b530105643e2 100644 --- a/app/Jobs/Util/ReminderJob.php +++ b/app/Jobs/Util/ReminderJob.php @@ -174,8 +174,8 @@ class ReminderJob implements ShouldQueue /**Refresh Invoice values*/ $invoice = $invoice->calc()->getInvoice(); - $invoice->client->service()->updateBalance($this->invoice->balance - $temp_invoice_balance)->save(); - $invoice->ledger()->updateInvoiceBalance($this->invoice->balance - $temp_invoice_balance, "Late Fee Adjustment for invoice {$this->invoice->number}"); + $invoice->client->service()->updateBalance($invoice->balance - $temp_invoice_balance)->save(); + $invoice->ledger()->updateInvoiceBalance($invoice->balance - $temp_invoice_balance, "Late Fee Adjustment for invoice {$this->invoice->number}"); return $invoice; } diff --git a/app/Listeners/Credit/CreditCreatedNotification.php b/app/Listeners/Credit/CreditCreatedNotification.php index 6c60f2f4e104..2181d58d8b70 100644 --- a/app/Listeners/Credit/CreditCreatedNotification.php +++ b/app/Listeners/Credit/CreditCreatedNotification.php @@ -38,7 +38,7 @@ class CreditCreatedNotification implements ShouldQueue { MultiDB::setDb($event->company->db); - $first_notification_sent = true; + // $first_notification_sent = true; $credit = $event->credit; @@ -60,7 +60,7 @@ class CreditCreatedNotification implements ShouldQueue $methods = $this->findUserNotificationTypes($credit->invitations()->first(), $company_user, 'credit', ['all_notifications', 'credit_created', 'credit_created_all']); /* If one of the methods is email then we fire the EntitySentMailer */ - if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) { + if (($key = array_search('mail', $methods)) !== false) { unset($methods[$key]); @@ -69,7 +69,7 @@ class CreditCreatedNotification implements ShouldQueue NinjaMailerJob::dispatch($nmo); /* This prevents more than one notification being sent */ - $first_notification_sent = false; + // $first_notification_sent = false; } /* Override the methods in the Notification Class */ diff --git a/app/Listeners/Credit/CreditEmailedNotification.php b/app/Listeners/Credit/CreditEmailedNotification.php index a3afd0cf2f42..c3a1ef17bf93 100644 --- a/app/Listeners/Credit/CreditEmailedNotification.php +++ b/app/Listeners/Credit/CreditEmailedNotification.php @@ -38,7 +38,7 @@ class CreditEmailedNotification implements ShouldQueue { MultiDB::setDb($event->company->db); - $first_notification_sent = true; + // $first_notification_sent = true; $credit = $event->invitation->credit; $credit->last_sent_date = now(); @@ -56,14 +56,15 @@ class CreditEmailedNotification implements ShouldQueue $methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'credit', ['all_notifications', 'credit_sent', 'credit_sent_all']); - if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) { + if (($key = array_search('mail', $methods)) !== false) { + // if (($key = array_search('mail', $methods))) { unset($methods[$key]); $nmo->to_user = $user; NinjaMailerJob::dispatch($nmo); - $first_notification_sent = false; + // $first_notification_sent = false; } // $notification->method = $methods; diff --git a/app/Listeners/Invoice/InvoiceCreatedNotification.php b/app/Listeners/Invoice/InvoiceCreatedNotification.php index 22513a0a6c85..49f4af309518 100644 --- a/app/Listeners/Invoice/InvoiceCreatedNotification.php +++ b/app/Listeners/Invoice/InvoiceCreatedNotification.php @@ -52,17 +52,15 @@ class InvoiceCreatedNotification implements ShouldQueue /* The User */ $user = $company_user->user; - /* This is only here to handle the alternate message channels - ie Slack */ // $notification = new EntitySentNotification($event->invitation, 'invoice'); /* Returns an array of notification methods */ $methods = $this->findUserNotificationTypes($invoice->invitations()->first(), $company_user, 'invoice', ['all_notifications', 'invoice_created', 'invoice_created_all']); - /* If one of the methods is email then we fire the EntitySentMailer */ - if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) { + // if (($key = array_search('mail', $methods))) { + if (($key = array_search('mail', $methods)) !== false) { unset($methods[$key]); - $nmo->to_user = $user; @@ -70,6 +68,7 @@ class InvoiceCreatedNotification implements ShouldQueue /* This prevents more than one notification being sent */ $first_notification_sent = false; + } /* Override the methods in the Notification Class */ diff --git a/app/Listeners/Invoice/InvoiceEmailedNotification.php b/app/Listeners/Invoice/InvoiceEmailedNotification.php index 4123e9ecd61d..09d56d53491a 100644 --- a/app/Listeners/Invoice/InvoiceEmailedNotification.php +++ b/app/Listeners/Invoice/InvoiceEmailedNotification.php @@ -63,7 +63,7 @@ class InvoiceEmailedNotification implements ShouldQueue $methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'invoice', ['all_notifications', 'invoice_sent', 'invoice_sent_all']); /* If one of the methods is email then we fire the EntitySentMailer */ - if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) { + if (($key = array_search('mail', $methods))) { unset($methods[$key]); diff --git a/app/Listeners/Invoice/InvoiceFailedEmailNotification.php b/app/Listeners/Invoice/InvoiceFailedEmailNotification.php index dd3cc6f5103b..3f6551de4159 100644 --- a/app/Listeners/Invoice/InvoiceFailedEmailNotification.php +++ b/app/Listeners/Invoice/InvoiceFailedEmailNotification.php @@ -58,7 +58,7 @@ class InvoiceFailedEmailNotification $methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'invoice', ['all_notifications', 'invoice_sent', 'invoice_sent_all']); - if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) { + if (($key = array_search('mail', $methods))) { unset($methods[$key]); $nmo->to_user = $user; diff --git a/app/Listeners/Quote/QuoteCreatedNotification.php b/app/Listeners/Quote/QuoteCreatedNotification.php index 209e9dbc74e2..c258b0d33c51 100644 --- a/app/Listeners/Quote/QuoteCreatedNotification.php +++ b/app/Listeners/Quote/QuoteCreatedNotification.php @@ -60,7 +60,7 @@ class QuoteCreatedNotification implements ShouldQueue $methods = $this->findUserNotificationTypes($quote->invitations()->first(), $company_user, 'quote', ['all_notifications', 'quote_created', 'quote_created_all']); /* If one of the methods is email then we fire the EntitySentMailer */ - if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) { + if (($key = array_search('mail', $methods))) { unset($methods[$key]); diff --git a/app/Listeners/Quote/QuoteEmailedNotification.php b/app/Listeners/Quote/QuoteEmailedNotification.php index 2adc1e3ef20c..c601dbfa18ef 100644 --- a/app/Listeners/Quote/QuoteEmailedNotification.php +++ b/app/Listeners/Quote/QuoteEmailedNotification.php @@ -38,7 +38,7 @@ class QuoteEmailedNotification implements ShouldQueue { MultiDB::setDb($event->company->db); - $first_notification_sent = true; + // $first_notification_sent = true; $quote = $event->invitation->quote; $quote->last_sent_date = now(); @@ -57,7 +57,7 @@ class QuoteEmailedNotification implements ShouldQueue $methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'quote', ['all_notifications', 'quote_sent', 'quote_sent_all']); - if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) { + if (($key = array_search('mail', $methods)) !== false) { unset($methods[$key]); @@ -65,7 +65,7 @@ class QuoteEmailedNotification implements ShouldQueue NinjaMailerJob::dispatch($nmo); - $first_notification_sent = false; + // $first_notification_sent = false; } // $notification->method = $methods; diff --git a/app/Mail/Admin/EntityCreatedObject.php b/app/Mail/Admin/EntityCreatedObject.php index f8b426a798fc..c4cfc886c5d0 100644 --- a/app/Mail/Admin/EntityCreatedObject.php +++ b/app/Mail/Admin/EntityCreatedObject.php @@ -23,7 +23,7 @@ class EntityCreatedObject public $entity; - public $contact; + public $client; public $company; @@ -49,7 +49,7 @@ class EntityCreatedObject /* Set customized translations _NOW_ */ $t->replace(Ninja::transformTranslations($this->entity->company->settings)); - $this->contact = $this->entity->invitations()->first()->contact; + $this->client = $this->entity->client; $this->company = $this->entity->company; $this->setTemplate(); @@ -100,7 +100,7 @@ class EntityCreatedObject ctrans( $this->template_subject, [ - 'client' => $this->contact->present()->name(), + 'client' => $this->client->present()->name(), 'invoice' => $this->entity->number, ] ); @@ -112,7 +112,7 @@ class EntityCreatedObject $this->template_body, [ 'amount' => $this->getAmount(), - 'client' => $this->contact->present()->name(), + 'client' => $this->client->present()->name(), 'invoice' => $this->entity->number, ] ); diff --git a/app/Mail/TestMailServer.php b/app/Mail/TestMailServer.php index 20d9a7b9b63d..7308c19ab75d 100644 --- a/app/Mail/TestMailServer.php +++ b/app/Mail/TestMailServer.php @@ -19,13 +19,13 @@ class TestMailServer extends Mailable { // use Queueable, SerializesModels; - public $message; + public $support_messages; public $from_email; - public function __construct($message, $from_email) + public function __construct($support_messages, $from_email) { - $this->message = $message; + $this->support_messages = $support_messages; $this->from_email = $from_email; } @@ -39,7 +39,7 @@ class TestMailServer extends Mailable return $this->from(config('mail.from.address'), config('mail.from.name')) ->subject(ctrans('texts.email')) ->markdown('email.support.message', [ - 'message' => $this->message, + 'support_message' => $this->support_messages, 'system_info' => '', 'laravel_log' => [], ]); diff --git a/app/Models/Gateway.php b/app/Models/Gateway.php index fa95888fb63d..32fc20999409 100644 --- a/app/Models/Gateway.php +++ b/app/Models/Gateway.php @@ -87,10 +87,10 @@ class Gateway extends StaticModel case 20: case 56: return [GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true], - GatewayType::BANK_TRANSFER => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable']], + GatewayType::BANK_TRANSFER => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable','charge.succeeded']], GatewayType::ALIPAY => ['refund' => false, 'token_billing' => false], GatewayType::APPLE_PAY => ['refund' => false, 'token_billing' => false], - GatewayType::SOFORT => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable']]]; //Stripe + GatewayType::SOFORT => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']]]; //Stripe break; case 39: return [GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true]]; //Checkout diff --git a/app/PaymentDrivers/Stripe/ACH.php b/app/PaymentDrivers/Stripe/ACH.php index a46bd4462b3a..502ed7059e48 100644 --- a/app/PaymentDrivers/Stripe/ACH.php +++ b/app/PaymentDrivers/Stripe/ACH.php @@ -105,7 +105,7 @@ class ACH $this->stripe->init(); - $bank_account = Customer::retrieveSource($request->customer, $request->source, $this->stripe->stripe_connect_auth); + $bank_account = Customer::retrieveSource($request->customer, ['source' => $request->source], $this->stripe->stripe_connect_auth); try { $bank_account->verify(['amounts' => request()->transactions]); diff --git a/app/Utils/Traits/CompanySettingsSaver.php b/app/Utils/Traits/CompanySettingsSaver.php index 928ab0cd01e3..7d3de2afde27 100644 --- a/app/Utils/Traits/CompanySettingsSaver.php +++ b/app/Utils/Traits/CompanySettingsSaver.php @@ -36,6 +36,7 @@ trait CompanySettingsSaver */ public function saveSettings($settings, $entity) { + /* No Settings, No Save!*/ if (! $settings) { return; @@ -58,14 +59,17 @@ trait CompanySettingsSaver } } + if(property_exists($settings, 'translations')) + { //this pass will handle any null values that are in the translations - foreach ($settings->translations as $key => $value) { - if (is_null($settings->translations[$key])) { - $settings->translations[$key] = ''; + foreach ($settings->translations as $key => $value) { + if (is_null($settings->translations[$key])) { + $settings->translations[$key] = ''; + } } - } - $company_settings->translations = $settings->translations; + $company_settings->translations = $settings->translations; + } $entity->settings = $company_settings; diff --git a/app/Utils/Traits/GeneratesCounter.php b/app/Utils/Traits/GeneratesCounter.php index 97810afd67e3..e478b4cbedba 100644 --- a/app/Utils/Traits/GeneratesCounter.php +++ b/app/Utils/Traits/GeneratesCounter.php @@ -24,6 +24,7 @@ use App\Models\Task; use App\Models\Timezone; use App\Models\Vendor; use Illuminate\Support\Carbon; +use Illuminate\Support\Str; /** * Class GeneratesCounter. @@ -343,17 +344,24 @@ trait GeneratesCounter { $check = false; + $check_counter = 1; do { + $number = $this->padCounter($counter, $padding); $number = $this->applyNumberPattern($entity, $number, $pattern); $number = $this->prefixCounter($number, $prefix); - $check = $class::whereCompanyId($entity->company_id)->whereNumber($number)->withTrashed()->first(); + $check = $class::whereCompanyId($entity->company_id)->whereNumber($number)->withTrashed()->exists(); $counter++; + $check_counter++; + + if($check_counter > 100) + return $number . "_" . Str::random(5); + } while ($check); return $number; @@ -364,7 +372,7 @@ trait GeneratesCounter public function checkNumberAvailable($class, $entity, $number) :bool { - if ($entity = $class::whereCompanyId($entity->company_id)->whereNumber($number)->withTrashed()->first()) + if ($entity = $class::whereCompanyId($entity->company_id)->whereNumber($number)->withTrashed()->exists()) return false; return true; diff --git a/database/migrations/2021_07_21_213344_change_english_languages_tables.php b/database/migrations/2021_07_21_213344_change_english_languages_tables.php new file mode 100644 index 000000000000..a065a475250c --- /dev/null +++ b/database/migrations/2021_07_21_213344_change_english_languages_tables.php @@ -0,0 +1,33 @@ +name = 'English - United States'; + $language->save(); + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} diff --git a/database/seeders/LanguageSeeder.php b/database/seeders/LanguageSeeder.php index e03c95b2c5d3..c5cd8a32fec9 100644 --- a/database/seeders/LanguageSeeder.php +++ b/database/seeders/LanguageSeeder.php @@ -24,7 +24,7 @@ class LanguageSeeder extends Seeder // https://www.loc.gov/standards/iso639-2/php/code_list.php $languages = [ - ['id' => 1, 'name' => 'English', 'locale' => 'en'], + ['id' => 1, 'name' => 'English - United States', 'locale' => 'en'], ['id' => 2, 'name' => 'Italian', 'locale' => 'it'], ['id' => 3, 'name' => 'German', 'locale' => 'de'], ['id' => 4, 'name' => 'French', 'locale' => 'fr'], diff --git a/tests/Feature/CompanyTest.php b/tests/Feature/CompanyTest.php index 538ef194ffce..8ec6928f283c 100644 --- a/tests/Feature/CompanyTest.php +++ b/tests/Feature/CompanyTest.php @@ -100,6 +100,7 @@ class CompanyTest extends TestCase $settings->invoice_design_id = '2'; $settings->quote_design_id = '1'; +nlog($settings); $company->settings = $settings; $response = $this->withHeaders([