From 8e34d0ed0d146dc9d46f480946b0758c862ce6ea Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 10 Mar 2023 16:37:17 +1100 Subject: [PATCH 1/4] Updates for RandomDataSeeder --- composer.lock | 76 ++++++------ database/seeders/RandomDataSeeder.php | 167 ++++++++++++++++++-------- 2 files changed, 152 insertions(+), 91 deletions(-) diff --git a/composer.lock b/composer.lock index d2bf544f4253..c450d418938f 100644 --- a/composer.lock +++ b/composer.lock @@ -380,16 +380,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.261.6", + "version": "3.261.8", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "63b03ec821473861af58439f1a35173e904d0f8c" + "reference": "9c38c82b7d3fb2b15957e71cae3957450e131ed8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/63b03ec821473861af58439f1a35173e904d0f8c", - "reference": "63b03ec821473861af58439f1a35173e904d0f8c", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/9c38c82b7d3fb2b15957e71cae3957450e131ed8", + "reference": "9c38c82b7d3fb2b15957e71cae3957450e131ed8", "shasum": "" }, "require": { @@ -468,9 +468,9 @@ "support": { "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.261.6" + "source": "https://github.com/aws/aws-sdk-php/tree/3.261.8" }, - "time": "2023-03-07T19:21:12+00:00" + "time": "2023-03-09T19:23:27+00:00" }, { "name": "bacon/bacon-qr-code", @@ -2171,16 +2171,16 @@ }, { "name": "google/apiclient-services", - "version": "v0.289.1", + "version": "v0.289.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-api-php-client-services.git", - "reference": "df7e6cbab08f60509b3f360d8286c194ad2930e2" + "reference": "937f83a927db2d09db7eebb69ce2ac4114559bd7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/df7e6cbab08f60509b3f360d8286c194ad2930e2", - "reference": "df7e6cbab08f60509b3f360d8286c194ad2930e2", + "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/937f83a927db2d09db7eebb69ce2ac4114559bd7", + "reference": "937f83a927db2d09db7eebb69ce2ac4114559bd7", "shasum": "" }, "require": { @@ -2209,9 +2209,9 @@ ], "support": { "issues": "https://github.com/googleapis/google-api-php-client-services/issues", - "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.289.1" + "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.289.0" }, - "time": "2023-03-01T17:20:18+00:00" + "time": "2023-02-26T01:10:11+00:00" }, { "name": "google/auth", @@ -2605,16 +2605,16 @@ }, { "name": "guzzlehttp/psr7", - "version": "2.4.3", + "version": "2.4.4", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "67c26b443f348a51926030c83481b85718457d3d" + "reference": "3cf1b6d4f0c820a2cf8bcaec39fc698f3443b5cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/67c26b443f348a51926030c83481b85718457d3d", - "reference": "67c26b443f348a51926030c83481b85718457d3d", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/3cf1b6d4f0c820a2cf8bcaec39fc698f3443b5cf", + "reference": "3cf1b6d4f0c820a2cf8bcaec39fc698f3443b5cf", "shasum": "" }, "require": { @@ -2704,7 +2704,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.4.3" + "source": "https://github.com/guzzle/psr7/tree/2.4.4" }, "funding": [ { @@ -2720,7 +2720,7 @@ "type": "tidelift" } ], - "time": "2022-10-26T14:07:24+00:00" + "time": "2023-03-09T13:19:02+00:00" }, { "name": "guzzlehttp/uri-template", @@ -14427,16 +14427,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.11.0", + "version": "1.11.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", "shasum": "" }, "require": { @@ -14474,7 +14474,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" }, "funding": [ { @@ -14482,7 +14482,7 @@ "type": "tidelift" } ], - "time": "2022-03-03T13:19:32+00:00" + "time": "2023-03-08T13:26:56+00:00" }, { "name": "netresearch/jsonmapper", @@ -15020,16 +15020,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.5", + "version": "1.10.6", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "1fb6f494d82455151ecf15c5c191923f5d84324e" + "reference": "50d089a3e0904b0fe7e2cf2d4fd37d427d64235a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1fb6f494d82455151ecf15c5c191923f5d84324e", - "reference": "1fb6f494d82455151ecf15c5c191923f5d84324e", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/50d089a3e0904b0fe7e2cf2d4fd37d427d64235a", + "reference": "50d089a3e0904b0fe7e2cf2d4fd37d427d64235a", "shasum": "" }, "require": { @@ -15059,7 +15059,7 @@ ], "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.10.5" + "source": "https://github.com/phpstan/phpstan/tree/1.10.6" }, "funding": [ { @@ -15075,7 +15075,7 @@ "type": "tidelift" } ], - "time": "2023-03-07T16:48:45+00:00" + "time": "2023-03-09T16:55:12+00:00" }, { "name": "phpunit/php-code-coverage", @@ -15397,16 +15397,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.4", + "version": "9.6.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "9125ee085b6d95e78277dc07aa1f46f9e0607b8d" + "reference": "86e761949019ae83f49240b2f2123fb5ab3b2fc5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9125ee085b6d95e78277dc07aa1f46f9e0607b8d", - "reference": "9125ee085b6d95e78277dc07aa1f46f9e0607b8d", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/86e761949019ae83f49240b2f2123fb5ab3b2fc5", + "reference": "86e761949019ae83f49240b2f2123fb5ab3b2fc5", "shasum": "" }, "require": { @@ -15439,8 +15439,8 @@ "sebastian/version": "^3.0.2" }, "suggest": { - "ext-soap": "*", - "ext-xdebug": "*" + "ext-soap": "To be able to generate mocks based on WSDL files", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" }, "bin": [ "phpunit" @@ -15479,7 +15479,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.4" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.5" }, "funding": [ { @@ -15495,7 +15495,7 @@ "type": "tidelift" } ], - "time": "2023-02-27T13:06:37+00:00" + "time": "2023-03-09T06:34:10+00:00" }, { "name": "sebastian/cli-parser", diff --git a/database/seeders/RandomDataSeeder.php b/database/seeders/RandomDataSeeder.php index 60fbf0707813..2790b34bba05 100644 --- a/database/seeders/RandomDataSeeder.php +++ b/database/seeders/RandomDataSeeder.php @@ -11,37 +11,41 @@ namespace Database\Seeders; -use App\DataMapper\ClientSettings; -use App\DataMapper\CompanySettings; -use App\Events\Payment\PaymentWasCreated; -use App\Helpers\Invoice\InvoiceSum; -use App\Helpers\Invoice\InvoiceSumInclusive; -use App\Models\Account; +use App\Models\User; +use App\Utils\Ninja; +use App\Models\Quote; use App\Models\Client; -use App\Models\ClientContact; -use App\Models\Company; -use App\Models\CompanyGateway; -use App\Models\CompanyToken; use App\Models\Credit; -use App\Models\GroupSetting; +use App\Models\Vendor; +use App\Models\Account; +use App\Models\Company; use App\Models\Invoice; use App\Models\Payment; +use App\Models\Product; use App\Models\PaymentHash; use App\Models\PaymentType; -use App\Models\Product; -use App\Models\Quote; -use App\Models\RecurringInvoice; -use App\Models\User; -use App\Repositories\CreditRepository; -use App\Repositories\InvoiceRepository; -use App\Repositories\QuoteRepository; -use App\Utils\Ninja; -use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Seeder; -use Illuminate\Support\Facades\Cache; -use Illuminate\Support\Facades\Hash; -use Illuminate\Support\Facades\Schema; use Illuminate\Support\Str; +use App\Models\CompanyToken; +use App\Models\GroupSetting; +use App\Models\ClientContact; +use App\Models\VendorContact; +use App\Models\CompanyGateway; +use Illuminate\Database\Seeder; +use App\Models\RecurringInvoice; +use App\DataMapper\ClientSettings; +use App\DataMapper\CompanySettings; +use App\Helpers\Invoice\InvoiceSum; +use Illuminate\Support\Facades\Hash; +use App\Repositories\QuoteRepository; +use Illuminate\Support\Facades\Cache; +use App\Repositories\CreditRepository; +use Illuminate\Support\Facades\Schema; +use App\Repositories\InvoiceRepository; +use Illuminate\Database\Eloquent\Model; +use App\Events\Payment\PaymentWasCreated; +use App\Helpers\Invoice\InvoiceSumInclusive; +use App\Models\BankIntegration; +use App\Models\BankTransaction; class RandomDataSeeder extends Seeder { @@ -117,6 +121,58 @@ class RandomDataSeeder extends Seeder 'settings' => null, ]); + + $permission_users = [ + 'permissions', + 'products', + 'invoices', + 'quotes', + 'clients', + 'vendors', + 'tasks', + 'expenses', + 'projects', + 'credits', + 'payments', + 'bank_transactions', + 'purchase_orders', + ]; + + foreach ($permission_users as $p_user) { + nlog($p_user); + $user = User::firstOrNew([ + 'email' => "{$p_user}@example.com", + ]); + + $user->first_name = ucfirst($p_user); + $user->last_name = 'Example'; + $user->password = Hash::make('password'); + $user->account_id = $account->id; + $user->email_verified_at = now(); + $user->save(); + + $company_token = CompanyToken::create([ + 'user_id' => $user->id, + 'company_id' => $company->id, + 'account_id' => $account->id, + 'name' => 'test token', + 'token' => \Illuminate\Support\Str::random(64), + ]); + + $user->companies()->attach($company->id, [ + 'account_id' => $account->id, + 'is_owner' => 0, + 'is_admin' => 0, + 'is_locked' => 0, + 'notifications' => CompanySettings::notificationDefaults(), + 'permissions' => '', + 'settings' => null, + ]); + + $user = null; + } + + $user = User::firstOrNew([ 'email' => 'user@example.com', ]); @@ -147,35 +203,6 @@ class RandomDataSeeder extends Seeder ]); - $user = User::firstOrNew([ - 'email' => 'permissions@example.com', - ]); - - $user->first_name = 'Permissions'; - $user->last_name = 'Example'; - $user->password = Hash::make('password'); - $user->account_id = $account->id; - $user->email_verified_at = now(); - $user->save(); - - $company_token = CompanyToken::create([ - 'user_id' => $user->id, - 'company_id' => $company->id, - 'account_id' => $account->id, - 'name' => 'test token', - 'token' => \Illuminate\Support\Str::random(64), - ]); - - $user->companies()->attach($company->id, [ - 'account_id' => $account->id, - 'is_owner' => 0, - 'is_admin' => 0, - 'is_locked' => 0, - 'notifications' => CompanySettings::notificationDefaults(), - 'permissions' => '', - 'settings' => null, - ]); - $client = Client::factory()->create([ 'user_id' => $user->id, @@ -195,6 +222,28 @@ class RandomDataSeeder extends Seeder 'password' => Hash::make('password'), ]); + + + $vendor = Vendor::factory()->create([ + 'user_id' => $user->id, + 'company_id' => $company->id, + 'name' => 'cypress' + ]); + + $vendor->number = $vendor->getNextVendorNumber($vendor); + $vendor->save(); + + VendorContact::factory()->create([ + 'user_id' => $user->id, + 'vendor_id' => $vendor->id, + 'company_id' => $company->id, + 'is_primary' => 1, + 'email' => 'cypress_vendor@example.com', + 'password' => Hash::make('password'), + ]); + + + /* Product Factory */ Product::factory()->count(2)->create(['user_id' => $user->id, 'company_id' => $company->id]); @@ -304,6 +353,18 @@ class RandomDataSeeder extends Seeder 'name' => 'Default Client Settings', ]); + $bi = BankIntegration::factory()->create([ + 'account_id' => $account->id, + 'user_id' => $user->id, + 'company_id' => $company->id, + ]); + + BankTransaction::factory()->create([ + 'bank_integration_id' => $bi->id, + 'user_id' => $user->id, + 'company_id' => $company->id, + ]); + if (config('ninja.testvars.stripe')) { $cg = new CompanyGateway; $cg->company_id = $company->id; From e62f6ebba4fc020a8b6edbf5e5222b18fcb3c2a7 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 10 Mar 2023 17:06:42 +1100 Subject: [PATCH 2/4] Minor fixes for seeder --- database/seeders/RandomDataSeeder.php | 1 - 1 file changed, 1 deletion(-) diff --git a/database/seeders/RandomDataSeeder.php b/database/seeders/RandomDataSeeder.php index 2790b34bba05..a2ff960ea9ea 100644 --- a/database/seeders/RandomDataSeeder.php +++ b/database/seeders/RandomDataSeeder.php @@ -121,7 +121,6 @@ class RandomDataSeeder extends Seeder 'settings' => null, ]); - $permission_users = [ 'permissions', 'products', From 3286ff52eee3f62aa36a8caf6899763c8805a84b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 10 Mar 2023 17:38:30 +1100 Subject: [PATCH 3/4] Tests for dynamic payment type test --- app/Models/PaymentType.php | 42 +++++++++++++++++++++++++++ database/seeders/RandomDataSeeder.php | 2 +- lang/en/texts.php | 3 +- tests/Unit/PaymentTypeTest.php | 40 +++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 tests/Unit/PaymentTypeTest.php diff --git a/app/Models/PaymentType.php b/app/Models/PaymentType.php index 298d17e53e33..e6222ba941c4 100644 --- a/app/Models/PaymentType.php +++ b/app/Models/PaymentType.php @@ -74,6 +74,48 @@ class PaymentType extends StaticModel const KLARNA = 47; const Interac_E_Transfer = 48; + public array $type_names = [ + self::CREDIT => 'payment_type_Credit', + self::ACH => 'payment_type_ACH', + self::VISA => 'payment_type_Visa Card', + self::MASTERCARD => 'payment_type_MasterCard', + self::AMERICAN_EXPRESS => 'payment_type_American Express', + self::DISCOVER => 'payment_type_Discover Card', + self::DINERS => 'payment_type_Diners Card', + self::EUROCARD => 'payment_type_EuroCard', + self::NOVA => 'payment_type_Nova', + self::CREDIT_CARD_OTHER => 'payment_type_Credit Card Other', + self::PAYPAL => 'payment_type_PayPal', + self::CHECK => 'payment_type_Check', + self::CARTE_BLANCHE => 'payment_type_Carte Blanche', + self::UNIONPAY => 'payment_type_UnionPay', + self::JCB => 'payment_type_JCB', + self::LASER => 'payment_type_Laser', + self::MAESTRO => 'payment_type_Maestro', + self::SOLO => 'payment_type_Solo', + self::SWITCH => 'payment_type_Switch', + self::ALIPAY => 'payment_type_Alipay', + self::SOFORT => 'payment_type_Sofort', + self::SEPA => 'payment_type_SEPA', + self::GOCARDLESS => 'payment_type_GoCardless', + self::CRYPTO => 'payment_type_Crypto', + self::MOLLIE_BANK_TRANSFER => 'payment_type_Mollie Bank Transfer', + self::KBC => 'payment_type_KBC/CBC', + self::BANCONTACT => 'payment_type_Bancontact', + self::IDEAL => 'payment_type_iDEAL', + self::HOSTED_PAGE => 'payment_type_Hosted Page', + self::GIROPAY => 'payment_type_GiroPay', + self::PRZELEWY24 => 'payment_type_Przelewy24', + self::EPS => 'payment_type_EPS', + self::DIRECT_DEBIT => 'payment_type_Direct Debit', + self::BECS => 'payment_type_BECS', + self::ACSS => 'payment_type_ACSS', + self::INSTANT_BANK_PAY => 'payment_type_Instant Bank Pay', + self::FPX => 'fpx', + self::KLARNA => 'payment_type_Klarna', + self::Interac_E_Transfer => 'payment_type_Interac E Transfer', + ]; + public static function parseCardType($cardName) { $cardTypes = [ diff --git a/database/seeders/RandomDataSeeder.php b/database/seeders/RandomDataSeeder.php index a2ff960ea9ea..502f0987c253 100644 --- a/database/seeders/RandomDataSeeder.php +++ b/database/seeders/RandomDataSeeder.php @@ -138,7 +138,7 @@ class RandomDataSeeder extends Seeder ]; foreach ($permission_users as $p_user) { - nlog($p_user); + $user = User::firstOrNew([ 'email' => "{$p_user}@example.com", ]); diff --git a/lang/en/texts.php b/lang/en/texts.php index 20c7c4ee9335..3534284820ee 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -4852,7 +4852,6 @@ $LANG = array( 'cash_vs_accrual_help' => 'Turn on for accrual reporting, turn off for cash basis reporting.', 'expense_paid_report' => 'Expensed reporting', 'expense_paid_report_help' => 'Turn on for reporting all expenses, turn off for reporting only paid expenses', - 'payment_type_Klarna' => 'Klarna', 'online_payment_email_help' => 'Send an email when an online payment is made', 'manual_payment_email_help' => 'Send an email when manually entering a payment', 'mark_paid_payment_email_help' => 'Send an email when marking an invoice as paid', @@ -5015,6 +5014,8 @@ $LANG = array( 'authorization_failure' => 'Insufficient permissions to perform this action', 'authorization_sms_failure' => 'Please verify your account to send emails.', 'white_label_body' => 'Thank you for purchasing a white label license.

Your license key is:

:license_key', + 'payment_type_Klarna' => 'Klarna', + 'payment_type_Interac E Transfer' => 'Interac E Transfer', ); diff --git a/tests/Unit/PaymentTypeTest.php b/tests/Unit/PaymentTypeTest.php new file mode 100644 index 000000000000..92440ad31efd --- /dev/null +++ b/tests/Unit/PaymentTypeTest.php @@ -0,0 +1,40 @@ +type_names as $type) + {nlog($type); + $this->assertTrue(Lang::has("texts.{$type}")); + } + } +} From ab6dfc7ff5c114a0fceca294a42810d63d5cef98 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 10 Mar 2023 17:49:43 +1100 Subject: [PATCH 4/4] Ensure payment types are returned --- app/Models/Payment.php | 7 +++++-- app/Models/PaymentType.php | 8 ++++++++ app/Services/Pdf/PdfBuilder.php | 4 ++-- app/Services/PdfMaker/Design.php | 2 +- resources/views/portal/ninja2020/payments/show.blade.php | 6 +++--- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/Models/Payment.php b/app/Models/Payment.php index 1a6e79830707..b6f8296a4c3d 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -299,11 +299,14 @@ class Payment extends BaseModel public function translatedType() { - if (! $this->type) { + if (! $this->type_id) { return ''; } - return ctrans('texts.payment_type_'.$this->type->name); + $pt = new PaymentType(); + + return $pt->name($this->type_id); + } public function gateway_type() diff --git a/app/Models/PaymentType.php b/app/Models/PaymentType.php index e6222ba941c4..9170b3d53d21 100644 --- a/app/Models/PaymentType.php +++ b/app/Models/PaymentType.php @@ -148,4 +148,12 @@ class PaymentType extends StaticModel return self::CREDIT_CARD_OTHER; } } + + public function name($id) + { + if(isset($this->type_names[$id])) + return ctrans("texts.".$this->type_names[$id]); + + return ctrans('texts.manual_entry'); + } } diff --git a/app/Services/Pdf/PdfBuilder.php b/app/Services/Pdf/PdfBuilder.php index c57fef889f33..eb2feebc3bf7 100644 --- a/app/Services/Pdf/PdfBuilder.php +++ b/app/Services/Pdf/PdfBuilder.php @@ -244,7 +244,7 @@ class PdfBuilder $element['elements'][] = ['element' => 'td', 'content' => $invoice->number]; $element['elements'][] = ['element' => 'td', 'content' => $this->translateDate($payment->date, $this->service->config->date_format, $this->service->config->locale) ?: ' ']; - $element['elements'][] = ['element' => 'td', 'content' => $payment->type ? $payment->type->name : ctrans('texts.manual_entry')]; + $element['elements'][] = ['element' => 'td', 'content' => $payment->translatedType()]; $element['elements'][] = ['element' => 'td', 'content' => $this->service->config->formatMoney($payment->pivot->amount) ?: ' ']; $tbody[] = $element; @@ -279,7 +279,7 @@ class PdfBuilder return [ ['element' => 'p', 'content' => \sprintf('%s: %s', ctrans('texts.amount_paid'), $this->service->config->formatMoney($this->payment_amount_total))], - ['element' => 'p', 'content' => \sprintf('%s: %s', ctrans('texts.payment_method'), $payment->type ? $payment->type->name : ctrans('texts.manual_entry'))], + ['element' => 'p', 'content' => \sprintf('%s: %s', ctrans('texts.payment_method'), $payment->translatedType())], ['element' => 'p', 'content' => \sprintf('%s: %s', ctrans('texts.payment_date'), $this->translateDate($payment->date, $this->service->config->date_format, $this->service->config->locale) ?: ' ')], ]; } diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index a2d4927a6ebd..7bc942eb51b5 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -601,7 +601,7 @@ class Design extends BaseDesign $element['elements'][] = ['element' => 'td', 'content' => $invoice->number]; $element['elements'][] = ['element' => 'td', 'content' => $this->translateDate($payment->date, $this->client->date_format(), $this->client->locale()) ?: ' ']; - $element['elements'][] = ['element' => 'td', 'content' => $payment->type ? $payment->type->name : ctrans('texts.manual_entry')]; + $element['elements'][] = ['element' => 'td', 'content' => $payment->translatedType()]; $element['elements'][] = ['element' => 'td', 'content' => Number::formatMoney($payment->pivot->amount, $this->client) ?: ' ']; $tbody[] = $element; diff --git a/resources/views/portal/ninja2020/payments/show.blade.php b/resources/views/portal/ninja2020/payments/show.blade.php index 546f55a89dee..80c443d700ad 100644 --- a/resources/views/portal/ninja2020/payments/show.blade.php +++ b/resources/views/portal/ninja2020/payments/show.blade.php @@ -49,16 +49,16 @@ @endif - @if(!empty($payment->type?->name) && !is_null($payment->type?->name)) +
{{ ctrans('texts.method') }}
- {{ $payment->type?->name }} + {{ $payment->translatedType() }}
- @endif + @if(!empty($payment->formattedAmount()) && !is_null($payment->formattedAmount()))