mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
Merge pull request #7132 from turbo124/v5-develop
Localize dates in Client Portal
This commit is contained in:
commit
1db4a9fad9
@ -276,6 +276,9 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
|
||||
public function locale()
|
||||
{
|
||||
if(!$this->language())
|
||||
return 'en';
|
||||
|
||||
return $this->language()->locale ?: 'en';
|
||||
}
|
||||
|
||||
|
@ -96,8 +96,13 @@ return [
|
||||
'prefix_indexes' => true,
|
||||
'strict' => env('DB_STRICT', false),
|
||||
'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',
|
||||
'ssl_mode' => env('SSL_MODE',''),
|
||||
// 'options' => Ninja::isHosted() ? config('ninja.db_options') : [],
|
||||
'options' => [
|
||||
PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false,
|
||||
PDO::MYSQL_ATTR_SSL_KEY => env("DB_CLIENT_KEY", ''),
|
||||
PDO::MYSQL_ATTR_SSL_CERT => env("DB_CLIENT_CERT", ''),
|
||||
PDO::MYSQL_ATTR_SSL_CA => env("DB_CA_CERT", ''),
|
||||
],
|
||||
],
|
||||
|
||||
'db-ninja-01a' => [
|
||||
|
@ -60,6 +60,7 @@ return [
|
||||
],
|
||||
|
||||
'db_options' => [
|
||||
PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false,
|
||||
PDO::MYSQL_ATTR_SSL_KEY => env("DB_CLIENT_KEY", ''),
|
||||
PDO::MYSQL_ATTR_SSL_CERT => env("DB_CLIENT_CERT", ''),
|
||||
PDO::MYSQL_ATTR_SSL_CA => env("DB_CA_CERT", ''),
|
||||
|
@ -56,7 +56,7 @@
|
||||
{{ App\Utils\Number::formatMoney($credit->balance, $credit->client) }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm leading-5 text-gray-500">
|
||||
{{ $credit->formatDate($credit->date, $credit->client->date_format()) }}
|
||||
{{ $credit->translateDate($credit->date, $credit->client->date_format(), $credit->client->locale()) }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm leading-5 text-gray-500">
|
||||
{{ $credit->public_notes }}
|
||||
|
@ -79,7 +79,7 @@
|
||||
{{ $invoice->number }}
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm leading-5 text-gray-500 whitespace-nowrap">
|
||||
{{ $invoice->formatDate($invoice->date, $invoice->client->date_format()) }}
|
||||
{{ $invoice->translateDate($invoice->date, $invoice->client->date_format(), $invoice->client->locale()) }}
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm leading-5 text-gray-500 whitespace-nowrap">
|
||||
{{ App\Utils\Number::formatMoney($invoice->amount, $invoice->client) }}
|
||||
@ -88,7 +88,7 @@
|
||||
{{ App\Utils\Number::formatMoney($invoice->balance, $invoice->client) }}
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm leading-5 text-gray-500 whitespace-nowrap">
|
||||
{{ $invoice->formatDate($invoice->due_date, $invoice->client->date_format()) }}
|
||||
{{ $invoice->translateDate($invoice->due_date, $invoice->client->date_format(), $invoice->client->locale()) }}
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm leading-5 text-gray-500 whitespace-nowrap">
|
||||
{!! App\Models\Invoice::badgeForStatus($invoice->status) !!}
|
||||
|
@ -54,7 +54,7 @@
|
||||
{{ $payment->number }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm leading-5 text-gray-500">
|
||||
{{ $payment->formatDate($payment->date, $payment->client->date_format()) }}
|
||||
{{ $payment->translateDate($payment->date, $payment->client->date_format(), $payment->client->locale()) }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm leading-5 text-gray-500">
|
||||
{{ optional($payment->type)->name }}
|
||||
|
@ -74,13 +74,13 @@
|
||||
{{ $quote->number }}
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm leading-5 text-gray-500 whitespace-nowrap">
|
||||
{{ $quote->formatDate($quote->date, $quote->client->date_format()) }}
|
||||
{{ $quote->translateDate($quote->date, $quote->client->date_format(), $quote->client->locale()) }}
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm leading-5 text-gray-500 whitespace-nowrap">
|
||||
{{ App\Utils\Number::formatMoney($quote->amount, $quote->client) }}
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm leading-5 text-gray-500 whitespace-nowrap">
|
||||
{{ $quote->formatDate($quote->due_date, $quote->client->date_format()) }}
|
||||
{{ $quote->translateDate($quote->due_date, $quote->client->date_format(), $quote->client->locale()) }}
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm leading-5 text-gray-500 whitespace-nowrap">
|
||||
{!! App\Models\Quote::badgeForStatus($quote->status_id) !!}
|
||||
|
@ -50,10 +50,10 @@
|
||||
{{ \App\Models\RecurringInvoice::frequencyForKey($invoice->frequency_id) }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm leading-5 text-gray-500">
|
||||
{{ $invoice->formatDate($invoice->date, $invoice->client->date_format()) }}
|
||||
{{ $invoice->translateDate($invoice->date, $invoice->client->date_format(), $invoice->client->locale()) }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm leading-5 text-gray-500">
|
||||
{{ $invoice->formatDate($invoice->next_send_date, $invoice->client->date_format()) }}
|
||||
{{ $invoice->translateDate($invoice->next_send_date, $invoice->client->date_format(), $invoice->client->locale()) }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm leading-5 text-gray-500">
|
||||
{{ $invoice->remaining_cycles == '-1' ? ctrans('texts.endless') : $invoice->remaining_cycles }}
|
||||
|
@ -63,7 +63,7 @@
|
||||
{{ App\Utils\Number::formatMoney($recurring_invoice->amount, $recurring_invoice->client) }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm leading-5 text-gray-500">
|
||||
{{ $recurring_invoice->formatDate($recurring_invoice->date, $recurring_invoice->client->date_format()) }}
|
||||
{{ $recurring_invoice->translateDate($recurring_invoice->date, $recurring_invoice->client->date_format(), $recurring_invoice->client->locale()) }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm leading-5 text-gray-500">
|
||||
<a href="{{ route('client.recurring_invoice.show', $recurring_invoice->hashed_id) }}"
|
||||
|
@ -50,7 +50,7 @@
|
||||
{{ App\Utils\Number::formatMoney($invoice->amount, $invoice->client) }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm leading-5 text-gray-500">
|
||||
{{ $invoice->formatDate($invoice->date, $invoice->client->date_format()) }}
|
||||
{{ $invoice->translateDate($invoice->date, $invoice->client->date_format(), $invoice->client->locale()) }}
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
@ -124,7 +124,7 @@
|
||||
{{ App\Utils\Number::formatMoney($invoice->amount, $invoice->client) }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm leading-5 text-gray-500">
|
||||
{{ $invoice->formatDate($invoice->date, $invoice->client->date_format()) }}
|
||||
{{ $invoice->translateDate($invoice->date, $invoice->client->date_format(), $invoice->client->locale()) }}
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
|
@ -67,7 +67,7 @@
|
||||
{{ ctrans('texts.invoice_date') }}
|
||||
</dt>
|
||||
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
{{ $invoice->formatDate($invoice->date, $invoice->client->date_format()) }}
|
||||
{{ $invoice->translateDate($invoice->date, $invoice->client->date_format(), $invoice->client->locale()) }}
|
||||
</dd>
|
||||
@endif
|
||||
</div>
|
||||
|
@ -27,7 +27,7 @@
|
||||
{{ ctrans('texts.expires') }}
|
||||
</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
{{ $client->formatDate($account->plan_expires, $client->date_format()) }}
|
||||
{{ $client->translateDate($account->plan_expires, $client->date_format(), $client->locale()) }}
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
|
@ -62,7 +62,7 @@
|
||||
{{ ctrans('texts.quote_date') }}
|
||||
</dt>
|
||||
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
{{ $quote->formatDate($quote->date, $quote->client->date_format()) }}
|
||||
{{ $quote->translateDate($quote->date, $quote->client->date_format(), $quote->client->locale()) }}
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||
|
@ -18,7 +18,7 @@
|
||||
{{ ctrans('texts.start_date') }}
|
||||
</dt>
|
||||
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
{{ $invoice->formatDate($invoice->start_date, $invoice->client->date_format()) }}
|
||||
{{ $invoice->translateDate($invoice->start_date, $invoice->client->date_format(), $invoice->client->locale()) }}
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||
@ -26,7 +26,7 @@
|
||||
{{ ctrans('texts.next_send_date') }}
|
||||
</dt>
|
||||
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
{{ $invoice->formatDate($invoice->next_send_date, $invoice->client->date_format()) }}
|
||||
{{ $invoice->translateDate($invoice->next_send_date, $invoice->client->date_format(), $invoice->client->locale()) }}
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||
|
@ -19,7 +19,7 @@
|
||||
{{ ctrans('texts.start_date') }}
|
||||
</dt>
|
||||
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
{{ $invoice->formatDate($invoice->start_date, $invoice->client->date_format()) }}
|
||||
{{ $invoice->translateDate($invoice->start_date, $invoice->client->date_format(), $invoice->client->locale()) }}
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||
@ -27,7 +27,7 @@
|
||||
{{ ctrans('texts.next_send_date') }}
|
||||
</dt>
|
||||
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
{{ $invoice->formatDate($invoice->next_send_date, $invoice->client->date_format()) }}
|
||||
{{ $invoice->translateDate($invoice->next_send_date, $invoice->client->date_format(), $invoice->client->locale()) }}
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||
|
@ -51,10 +51,14 @@ class CreditsTest extends TestCase
|
||||
|
||||
$company = Company::factory()->create(['account_id' => $account->id]);
|
||||
$company->settings = CompanySettings::defaults();
|
||||
$company->settings->language_id = "1";
|
||||
$company->save();
|
||||
|
||||
$client = Client::factory()->create(['company_id' => $company->id, 'user_id' => $user->id]);
|
||||
$client->settings = ClientSettings::defaults();
|
||||
$settings = $client->settings;
|
||||
$settings->language_id = "1";
|
||||
$client->settings = $settings;
|
||||
$client->save();
|
||||
|
||||
ClientContact::factory()->count(2)->create([
|
||||
@ -63,7 +67,7 @@ class CreditsTest extends TestCase
|
||||
'company_id' => $company->id,
|
||||
]);
|
||||
|
||||
Credit::factory()->create([
|
||||
$c1 = Credit::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'company_id' => $company->id,
|
||||
'client_id' => $client->id,
|
||||
@ -72,7 +76,7 @@ class CreditsTest extends TestCase
|
||||
'status_id' => Credit::STATUS_SENT,
|
||||
]);
|
||||
|
||||
Credit::factory()->create([
|
||||
$c2 = Credit::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'company_id' => $company->id,
|
||||
'client_id' => $client->id,
|
||||
@ -81,7 +85,7 @@ class CreditsTest extends TestCase
|
||||
'status_id' => Credit::STATUS_SENT,
|
||||
]);
|
||||
|
||||
Credit::factory()->create([
|
||||
$c3 = Credit::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'company_id' => $company->id,
|
||||
'client_id' => $client->id,
|
||||
@ -92,6 +96,10 @@ class CreditsTest extends TestCase
|
||||
|
||||
$this->actingAs($client->contacts->first(), 'contact');
|
||||
|
||||
$c1->load('client');
|
||||
$c2->load('client');
|
||||
$c3->load('client');
|
||||
|
||||
Livewire::test(CreditsTable::class, ['company' => $company])
|
||||
->assertDontSee('testing-number-01')
|
||||
->assertSee('testing-number-02')
|
||||
@ -108,7 +116,13 @@ class CreditsTest extends TestCase
|
||||
|
||||
$company = Company::factory()->create(['account_id' => $account->id]);
|
||||
|
||||
|
||||
$client = Client::factory()->create(['company_id' => $company->id, 'user_id' => $user->id]);
|
||||
$client->settings = ClientSettings::defaults();
|
||||
$settings = $client->settings;
|
||||
$settings->language_id = "1";
|
||||
$client->settings = $settings;
|
||||
$client->save();
|
||||
|
||||
ClientContact::factory()->count(2)->create([
|
||||
'user_id' => $user->id,
|
||||
|
@ -13,6 +13,7 @@
|
||||
namespace Tests\Feature\ClientPortal;
|
||||
|
||||
|
||||
use App\DataMapper\ClientSettings;
|
||||
use App\Http\Livewire\InvoicesTable;
|
||||
use App\Models\Account;
|
||||
use App\Models\Client;
|
||||
@ -49,8 +50,14 @@ class InvoicesTest extends TestCase
|
||||
);
|
||||
|
||||
$company = Company::factory()->create(['account_id' => $account->id]);
|
||||
$company->settings->language_id = "1";
|
||||
$company->save();
|
||||
|
||||
$client = Client::factory()->create(['company_id' => $company->id, 'user_id' => $user->id]);
|
||||
$settings = $client->settings;
|
||||
$settings->language_id = "1";
|
||||
$client->settings = $settings;
|
||||
$client->save();
|
||||
|
||||
ClientContact::factory()->count(2)->create([
|
||||
'user_id' => $user->id,
|
||||
@ -58,21 +65,21 @@ class InvoicesTest extends TestCase
|
||||
'company_id' => $company->id,
|
||||
]);
|
||||
|
||||
$sent = Invoice::factory()->create([
|
||||
$sent = Invoice::factory()->for($client)->create([
|
||||
'user_id' => $user->id,
|
||||
'company_id' => $company->id,
|
||||
'client_id' => $client->id,
|
||||
'status_id' => Invoice::STATUS_SENT,
|
||||
]);
|
||||
|
||||
$paid = Invoice::factory()->create([
|
||||
$paid = Invoice::factory()->for($client)->create([
|
||||
'user_id' => $user->id,
|
||||
'company_id' => $company->id,
|
||||
'client_id' => $client->id,
|
||||
'status_id' => Invoice::STATUS_PAID,
|
||||
]);
|
||||
|
||||
$unpaid = Invoice::factory()->create([
|
||||
$unpaid = Invoice::factory()->for($client)->create([
|
||||
'user_id' => $user->id,
|
||||
'company_id' => $company->id,
|
||||
'client_id' => $client->id,
|
||||
|
Loading…
Reference in New Issue
Block a user