mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Entity translations
This commit is contained in:
parent
4080c47e9b
commit
15b18dfc8f
@ -88,7 +88,7 @@ class ZipDocuments implements ShouldQueue
|
||||
|
||||
foreach ($documents as $document) {
|
||||
|
||||
$zipFile->addFromString($document->name, $document->getFile());
|
||||
$zipFile->addFromString($this->buildFileName($document), $document->getFile());
|
||||
|
||||
}
|
||||
|
||||
@ -112,7 +112,12 @@ class ZipDocuments implements ShouldQueue
|
||||
$zipFile->close();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function buildFileName($document) :string
|
||||
{
|
||||
$filename = $document->name;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -712,4 +712,8 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
];
|
||||
}
|
||||
|
||||
public function translate_entity()
|
||||
{
|
||||
return ctrans('texts.client');
|
||||
}
|
||||
}
|
||||
|
@ -549,4 +549,9 @@ class Company extends BaseModel
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function translate_entity()
|
||||
{
|
||||
return ctrans('texts.company');
|
||||
}
|
||||
}
|
||||
|
@ -314,4 +314,9 @@ class Credit extends BaseModel
|
||||
'credit_status' => $credit->status_id ?: 1,
|
||||
];
|
||||
}
|
||||
|
||||
public function translate_entity()
|
||||
{
|
||||
return ctrans('texts.credit');
|
||||
}
|
||||
}
|
||||
|
@ -101,4 +101,9 @@ class Expense extends BaseModel
|
||||
{
|
||||
return $this->belongsTo(Client::class);
|
||||
}
|
||||
|
||||
public function translate_entity()
|
||||
{
|
||||
return ctrans('texts.expense');
|
||||
}
|
||||
}
|
||||
|
@ -560,4 +560,9 @@ class Invoice extends BaseModel
|
||||
'invoice_status' => $invoice->status_id ?: 1,
|
||||
];
|
||||
}
|
||||
|
||||
public function translate_entity()
|
||||
{
|
||||
return ctrans('texts.invoice');
|
||||
}
|
||||
}
|
||||
|
@ -337,4 +337,8 @@ class Payment extends BaseModel
|
||||
];
|
||||
}
|
||||
|
||||
public function translate_entity()
|
||||
{
|
||||
return ctrans('texts.payment');
|
||||
}
|
||||
}
|
||||
|
@ -64,4 +64,9 @@ class Product extends BaseModel
|
||||
{
|
||||
return $this->morphMany(Document::class, 'documentable');
|
||||
}
|
||||
}
|
||||
|
||||
public function translate_entity()
|
||||
{
|
||||
return ctrans('texts.product');
|
||||
}
|
||||
}
|
@ -78,4 +78,8 @@ class Project extends BaseModel
|
||||
return $this->hasMany(Task::class);
|
||||
}
|
||||
|
||||
public function translate_entity()
|
||||
{
|
||||
return ctrans('texts.project');
|
||||
}
|
||||
}
|
||||
|
@ -311,4 +311,9 @@ class Quote extends BaseModel
|
||||
{
|
||||
return $this->calc()->getTotal();
|
||||
}
|
||||
|
||||
public function translate_entity()
|
||||
{
|
||||
return ctrans('texts.quote');
|
||||
}
|
||||
}
|
||||
|
@ -239,5 +239,8 @@ class RecurringExpense extends BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function translate_entity()
|
||||
{
|
||||
return ctrans('texts.recurring_expense');
|
||||
}
|
||||
}
|
||||
|
@ -505,4 +505,9 @@ class RecurringInvoice extends BaseModel
|
||||
{
|
||||
return $this->belongsTo(Subscription::class);
|
||||
}
|
||||
|
||||
public function translate_entity()
|
||||
{
|
||||
return ctrans('texts.recurring_invoice');
|
||||
}
|
||||
}
|
||||
|
@ -488,5 +488,9 @@ class RecurringQuote extends BaseModel
|
||||
return new RecurringService($this);
|
||||
}
|
||||
|
||||
public function translate_entity()
|
||||
{
|
||||
return ctrans('texts.recurring_quote');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -147,4 +147,9 @@ class Task extends BaseModel
|
||||
|
||||
return round($duration);
|
||||
}
|
||||
}
|
||||
|
||||
public function translate_entity()
|
||||
{
|
||||
return ctrans('texts.task');
|
||||
}
|
||||
}
|
@ -449,4 +449,9 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
{
|
||||
return new UserService($this);
|
||||
}
|
||||
|
||||
public function translate_entity()
|
||||
{
|
||||
return ctrans('texts.user');
|
||||
}
|
||||
}
|
||||
|
@ -104,4 +104,9 @@ class Vendor extends BaseModel
|
||||
{
|
||||
return $this->belongsTo(User::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function translate_entity()
|
||||
{
|
||||
return ctrans('texts.vendor');
|
||||
}
|
||||
}
|
||||
|
157
tests/Unit/EntityTranslationTest.php
Normal file
157
tests/Unit/EntityTranslationTest.php
Normal file
@ -0,0 +1,157 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\Account;
|
||||
use App\Models\Client;
|
||||
use App\Models\Company;
|
||||
use App\Models\Credit;
|
||||
use App\Models\Expense;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Models\Product;
|
||||
use App\Models\Project;
|
||||
use App\Models\Quote;
|
||||
use App\Models\RecurringExpense;
|
||||
use App\Models\RecurringInvoice;
|
||||
use App\Models\RecurringQuote;
|
||||
use App\Models\Task;
|
||||
use App\Models\User;
|
||||
use App\Models\Vendor;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\MockAccountData;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
class EntityTranslationTest extends TestCase
|
||||
{
|
||||
|
||||
public $faker;
|
||||
|
||||
public function setUp() :void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->faker = \Faker\Factory::create();
|
||||
}
|
||||
|
||||
public function testTranslations()
|
||||
{
|
||||
$account = Account::factory()->create([
|
||||
'hosted_client_count' => 1000,
|
||||
'hosted_company_count' => 1000
|
||||
]);
|
||||
|
||||
|
||||
$company = Company::factory()->create([
|
||||
'account_id' => $account->id,
|
||||
]);
|
||||
|
||||
$u = User::factory()->create([
|
||||
'email' => $this->faker->email,
|
||||
'account_id' => $account->id
|
||||
]);
|
||||
|
||||
$client = Client::factory()->create([
|
||||
'company_id' => $company->id,
|
||||
'user_id' => $u->id
|
||||
]);
|
||||
|
||||
$credit = Credit::factory()->create([
|
||||
'company_id' => $company->id,
|
||||
'user_id' => $u->id,
|
||||
'client_id' => $client->id,
|
||||
]);
|
||||
|
||||
$expense = Expense::factory()->create([
|
||||
'company_id' => $company->id,
|
||||
'user_id' => $u->id,
|
||||
'client_id' => $client->id,
|
||||
]);
|
||||
|
||||
$invoice = Invoice::factory()->create([
|
||||
'company_id' => $company->id,
|
||||
'user_id' => $u->id,
|
||||
'client_id' => $client->id,
|
||||
]);
|
||||
|
||||
$payment = Payment::factory()->create([
|
||||
'company_id' => $company->id,
|
||||
'user_id' => $u->id,
|
||||
'client_id' => $client->id,
|
||||
]);
|
||||
|
||||
$product = Product::factory()->create([
|
||||
'company_id' => $company->id,
|
||||
'user_id' => $u->id,
|
||||
]);
|
||||
|
||||
$project = Project::factory()->create([
|
||||
'company_id' => $company->id,
|
||||
'user_id' => $u->id,
|
||||
'client_id' => $client->id,
|
||||
]);
|
||||
|
||||
$quote = Quote::factory()->create([
|
||||
'company_id' => $company->id,
|
||||
'user_id' => $u->id,
|
||||
'client_id' => $client->id,
|
||||
]);
|
||||
|
||||
$recurring_expense = RecurringExpense::factory()->create([
|
||||
'company_id' => $company->id,
|
||||
'user_id' => $u->id,
|
||||
'client_id' => $client->id,
|
||||
]);
|
||||
|
||||
$recurring_invoice = RecurringInvoice::factory()->create([
|
||||
'company_id' => $company->id,
|
||||
'user_id' => $u->id,
|
||||
'client_id' => $client->id,
|
||||
]);
|
||||
|
||||
$recurring_quote = RecurringQuote::factory()->create([
|
||||
'company_id' => $company->id,
|
||||
'user_id' => $u->id,
|
||||
'client_id' => $client->id,
|
||||
]);
|
||||
|
||||
$task = Task::factory()->create([
|
||||
'company_id' => $company->id,
|
||||
'user_id' => $u->id,
|
||||
'client_id' => $client->id,
|
||||
]);
|
||||
|
||||
$vendor = Vendor::factory()->create([
|
||||
'company_id' => $company->id,
|
||||
'user_id' => $u->id,
|
||||
]);
|
||||
|
||||
$this->assertEquals(ctrans('texts.user'), $u->translate_entity());
|
||||
$this->assertEquals(ctrans('texts.company'), $company->translate_entity());
|
||||
$this->assertEquals(ctrans('texts.client'), $client->translate_entity());
|
||||
$this->assertEquals(ctrans('texts.credit'), $credit->translate_entity());
|
||||
$this->assertEquals(ctrans('texts.expense'), $expense->translate_entity());
|
||||
$this->assertEquals(ctrans('texts.invoice'), $invoice->translate_entity());
|
||||
$this->assertEquals(ctrans('texts.payment'), $payment->translate_entity());
|
||||
$this->assertEquals(ctrans('texts.product'), $product->translate_entity());
|
||||
$this->assertEquals(ctrans('texts.project'), $project->translate_entity());
|
||||
$this->assertEquals(ctrans('texts.quote'), $quote->translate_entity());
|
||||
$this->assertEquals(ctrans('texts.recurring_expense'), $recurring_expense->translate_entity());
|
||||
$this->assertEquals(ctrans('texts.recurring_invoice'), $recurring_invoice->translate_entity());
|
||||
$this->assertEquals(ctrans('texts.recurring_quote'), $recurring_quote->translate_entity());
|
||||
$this->assertEquals(ctrans('texts.task'), $task->translate_entity());
|
||||
$this->assertEquals(ctrans('texts.vendor'), $vendor->translate_entity());
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user