From fb38a8decfcc0093bbd602b375f63860f45e1d2a Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 3 Dec 2023 10:44:09 +0200 Subject: [PATCH 1/3] Customize PayPal gateway options --- lib/constants.dart | 1 + lib/redux/static/static_selectors.dart | 38 +++++++++++++++---- .../edit/company_gateway_edit.dart | 4 +- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/lib/constants.dart b/lib/constants.dart index 9e98c16b913..8832de1e712 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -487,6 +487,7 @@ const String kGatewayStripe = 'd14dd26a37cecc30fdd65700bfb55b23'; const String kGatewayStripeConnect = 'd14dd26a47cecc30fdd65700bfb67b34'; const String kGatewayAuthorizeNet = '3b6621f970ab18887c4f6dca78d3f8bb'; const String kGatewayCheckoutCom = '3758e7f7c6f4cecf0f4f348b9a00f456'; +const String kGatewayPayPalREST = '80af24a6a691230bbec33e930ab40665'; const String kGatewayPayPalExpress = '38f2c48af60c7dd69e04248cbb24c36e'; const String kGatewayPayPalPlatform = '80af24a6a691230bbec33e930ab40666'; const String kGatewayWePay = '8fdeed552015b3c7b44ed6c8ebd9e992'; diff --git a/lib/redux/static/static_selectors.dart b/lib/redux/static/static_selectors.dart index daac75a0048..684fa92ff7a 100644 --- a/lib/redux/static/static_selectors.dart +++ b/lib/redux/static/static_selectors.dart @@ -1,5 +1,6 @@ // Package imports: import 'package:built_collection/built_collection.dart'; +import 'package:invoiceninja_flutter/constants.dart'; import 'package:memoize/memoize.dart'; // Project imports: @@ -127,13 +128,36 @@ List sizeList(BuiltMap sizeMap) { return list; } -var memoizedGatewayList = memo1( - (BuiltMap gatewayMap) => gatewayList(gatewayMap)); - -List gatewayList(BuiltMap gatewayMap) { - final list = gatewayMap.keys - .where((gatewayId) => gatewayMap[gatewayId]!.isVisible) - .toList(); +var memoizedGatewayList = memo2( + (BuiltMap gatewayMap, bool isHosted) => + gatewayList(gatewayMap, isHosted)); + +List gatewayList( + BuiltMap gatewayMap, bool isHosted) { + final list = gatewayMap.keys.where((gatewayId) { + final gateway = gatewayMap[gatewayId]!; + + if (!gateway.isVisible) { + return false; + } + + if (isHosted) { + if ([ + kGatewayPayPalExpress, + kGatewayPayPalREST, + ].contains(gateway.id)) { + return false; + } + } else { + if ([ + kGatewayPayPalPlatform, + ].contains(gateway.id)) { + return false; + } + } + + return true; + }).toList(); list.sort((idA, idB) => gatewayMap[idA]!.sortOrder.compareTo(gatewayMap[idB]!.sortOrder)); diff --git a/lib/ui/company_gateway/edit/company_gateway_edit.dart b/lib/ui/company_gateway/edit/company_gateway_edit.dart index 1df7333e65b..38acc60f854 100644 --- a/lib/ui/company_gateway/edit/company_gateway_edit.dart +++ b/lib/ui/company_gateway/edit/company_gateway_edit.dart @@ -152,8 +152,8 @@ class _CompanyGatewayEditState extends State EntityDropdown( autofocus: true, entityType: EntityType.gateway, - entityList: - memoizedGatewayList(state.staticState.gatewayMap), + entityList: memoizedGatewayList( + state.staticState.gatewayMap, state.isHosted), labelText: localization.provider, entityId: companyGateway.gatewayId, onSelected: (SelectableEntity? gateway) { From af17248b6bfe00eaa9c6f906a3e6095b2bc5a6f0 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 3 Dec 2023 11:15:40 +0200 Subject: [PATCH 2/3] Add mising lang values --- lib/utils/i18n.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/utils/i18n.dart b/lib/utils/i18n.dart index cf7de56f2fe..7122288800d 100644 --- a/lib/utils/i18n.dart +++ b/lib/utils/i18n.dart @@ -18,6 +18,8 @@ mixin LocalizationsProvider on LocaleCodeAware { static final Map> _localizedValues = { 'en': { // STARTER: lang key - do not remove comment + 'payment_type_credit': 'Payment Type Credit', + 'payment_type_debit': 'Payment Type Debit', 'send_emails_to': 'Send Emails To', 'primary_contact': 'Primary Contact', 'all_contacts': 'All Contacts', From 0b3c1e86a34f24c523bdf184ed0d256a8f74ccda Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 3 Dec 2023 11:16:26 +0200 Subject: [PATCH 3/3] Update version --- .github/workflows/flatpak.yml | 2 +- flatpak/com.invoiceninja.InvoiceNinja.metainfo.xml | 1 + lib/constants.dart | 2 +- pubspec.foss.yaml | 2 +- pubspec.yaml | 2 +- snap/snapcraft.yaml | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/flatpak.yml b/.github/workflows/flatpak.yml index 0c913bf5b1c..0d57e9fd93a 100644 --- a/.github/workflows/flatpak.yml +++ b/.github/workflows/flatpak.yml @@ -86,7 +86,7 @@ jobs: draft: false prerelease: false title: "Latest Release" - automatic_release_tag: "v5.0.144" + automatic_release_tag: "v5.0.145" files: | ${{ github.workspace }}/artifacts/Invoice-Ninja-Archive ${{ github.workspace }}/artifacts/Invoice-Ninja-Hash diff --git a/flatpak/com.invoiceninja.InvoiceNinja.metainfo.xml b/flatpak/com.invoiceninja.InvoiceNinja.metainfo.xml index 147b2f6aa53..2e550992d97 100644 --- a/flatpak/com.invoiceninja.InvoiceNinja.metainfo.xml +++ b/flatpak/com.invoiceninja.InvoiceNinja.metainfo.xml @@ -50,6 +50,7 @@ + diff --git a/lib/constants.dart b/lib/constants.dart index 8832de1e712..d991b266aa3 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -4,7 +4,7 @@ class Constants { } // TODO remove version once #46609 is fixed -const String kClientVersion = '5.0.144'; +const String kClientVersion = '5.0.145'; const String kMinServerVersion = '5.0.4'; const String kAppName = 'Invoice Ninja'; diff --git a/pubspec.foss.yaml b/pubspec.foss.yaml index f9c20a94f14..0c56cccfdd1 100644 --- a/pubspec.foss.yaml +++ b/pubspec.foss.yaml @@ -1,6 +1,6 @@ name: invoiceninja_flutter description: Client for Invoice Ninja -version: 5.0.144+144 +version: 5.0.145+145 homepage: https://invoiceninja.com documentation: https://invoiceninja.github.io publish_to: none diff --git a/pubspec.yaml b/pubspec.yaml index 06db291adfc..7bafb445e27 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: invoiceninja_flutter description: Client for Invoice Ninja -version: 5.0.144+144 +version: 5.0.145+145 homepage: https://invoiceninja.com documentation: https://invoiceninja.github.io publish_to: none diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 5f26dc3e93c..5e56b8e37a0 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: invoiceninja -version: '5.0.144' +version: '5.0.145' summary: Create invoices, accept payments, track expenses & time tasks description: "### Note: if the app fails to run using `snap run invoiceninja` it may help to run `/snap/invoiceninja/current/bin/invoiceninja` instead