Company gateway settings

This commit is contained in:
Hillel Coren 2020-08-23 17:53:43 +03:00
parent 157bdfb685
commit 04d55dabc3
7 changed files with 118 additions and 38 deletions

View File

@ -86,6 +86,11 @@ abstract class CompanyGatewayEntity extends Object
CompanyGatewayEntity._();
static const AUTO_BILL_ALWAYS = 'always';
static const AUTO_BILL_OPT_IN = 'optin';
static const AUTO_BILL_OPT_OUT = 'optout';
static const AUTO_BILL_DISABLED = 'disabled';
@override
@memoized
int get hashCode;
@ -129,6 +134,12 @@ abstract class CompanyGatewayEntity extends Object
String get config;
@nullable
String get autobill;
@nullable
String get label;
Map<String, dynamic> get parsedConfig =>
config.isEmpty ? <String, dynamic>{} : jsonDecode(config);

View File

@ -177,6 +177,18 @@ class _$CompanyGatewayEntitySerializer
'id',
serializers.serialize(object.id, specifiedType: const FullType(String)),
];
if (object.autobill != null) {
result
..add('autobill')
..add(serializers.serialize(object.autobill,
specifiedType: const FullType(String)));
}
if (object.label != null) {
result
..add('label')
..add(serializers.serialize(object.label,
specifiedType: const FullType(String)));
}
if (object.isChanged != null) {
result
..add('isChanged')
@ -267,6 +279,14 @@ class _$CompanyGatewayEntitySerializer
result.config = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'autobill':
result.autobill = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'label':
result.label = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'isChanged':
result.isChanged = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
@ -649,6 +669,10 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity {
@override
final String config;
@override
final String autobill;
@override
final String label;
@override
final bool isChanged;
@override
final int createdAt;
@ -682,6 +706,8 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity {
this.customValue3,
this.customValue4,
this.config,
this.autobill,
this.label,
this.isChanged,
this.createdAt,
this.updatedAt,
@ -775,6 +801,8 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity {
customValue3 == other.customValue3 &&
customValue4 == other.customValue4 &&
config == other.config &&
autobill == other.autobill &&
label == other.label &&
isChanged == other.isChanged &&
createdAt == other.createdAt &&
updatedAt == other.updatedAt &&
@ -806,28 +834,18 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity {
$jc(
$jc(
$jc(
$jc(
$jc(
0,
gateway
.hashCode),
gatewayId
.hashCode),
acceptedCreditCards
.hashCode),
showBillingAddress
.hashCode),
showShippingAddress
.hashCode),
updateDetails
.hashCode),
feesAndLimitsMap
.hashCode),
customValue1.hashCode),
customValue2.hashCode),
customValue3.hashCode),
customValue4.hashCode),
config.hashCode),
$jc($jc($jc($jc(0, gateway.hashCode), gatewayId.hashCode), acceptedCreditCards.hashCode),
showBillingAddress.hashCode),
showShippingAddress.hashCode),
updateDetails.hashCode),
feesAndLimitsMap.hashCode),
customValue1.hashCode),
customValue2.hashCode),
customValue3.hashCode),
customValue4.hashCode),
config.hashCode),
autobill.hashCode),
label.hashCode),
isChanged.hashCode),
createdAt.hashCode),
updatedAt.hashCode),
@ -853,6 +871,8 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity {
..add('customValue3', customValue3)
..add('customValue4', customValue4)
..add('config', config)
..add('autobill', autobill)
..add('label', label)
..add('isChanged', isChanged)
..add('createdAt', createdAt)
..add('updatedAt', updatedAt)
@ -926,6 +946,14 @@ class CompanyGatewayEntityBuilder
String get config => _$this._config;
set config(String config) => _$this._config = config;
String _autobill;
String get autobill => _$this._autobill;
set autobill(String autobill) => _$this._autobill = autobill;
String _label;
String get label => _$this._label;
set label(String label) => _$this._label = label;
bool _isChanged;
bool get isChanged => _$this._isChanged;
set isChanged(bool isChanged) => _$this._isChanged = isChanged;
@ -976,6 +1004,8 @@ class CompanyGatewayEntityBuilder
_customValue3 = _$v.customValue3;
_customValue4 = _$v.customValue4;
_config = _$v.config;
_autobill = _$v.autobill;
_label = _$v.label;
_isChanged = _$v.isChanged;
_createdAt = _$v.createdAt;
_updatedAt = _$v.updatedAt;
@ -1020,6 +1050,8 @@ class CompanyGatewayEntityBuilder
customValue3: customValue3,
customValue4: customValue4,
config: config,
autobill: autobill,
label: label,
isChanged: isChanged,
createdAt: createdAt,
updatedAt: updatedAt,

View File

@ -629,7 +629,7 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
//return 'Last Updated: ${userCompanyStates.map((state) => state.lastUpdated).join(',')}';
//return 'Names: ${userCompanyStates.map((state) => state.company.id).join(',')}';
//return 'Client Count: ${userCompanyState.clientState.list.length}, Last Updated: ${userCompanyState.lastUpdated}';
//return 'Token: ${credentials.token} - ${userCompanyStates.map((state) => state?.token?.token ?? '').where((name) => name.isNotEmpty).join(',')}';
return 'Token: ${credentials.token} - ${userCompanyStates.map((state) => state?.token?.token ?? '').where((name) => name.isNotEmpty).join(',')}';
//return 'Payment Terms: ${company.settings.defaultPaymentTerms}';
//return 'Invitations: ${uiState.invoiceUIState.editing.invitations}';
//return 'Selection: ${clientUIState.selectedId}';

View File

@ -129,8 +129,33 @@ class _CompanyGatewayEditState extends State<CompanyGatewayEdit>
),
ListView(
children: <Widget>[
FormCard(children: <Widget>[
DecoratedFormField(
label: localization.label,
initialValue: companyGateway.label,
onChanged: (String value) => viewModel.onChanged(
companyGateway.rebuild((b) => b..label = value.trim())),
),
if (state.staticState.gatewayMap[companyGateway.gatewayId]
.supportsTokenBilling)
AppDropdownButton<String>(
labelText: localization.autoBill,
value: companyGateway.autobill,
onChanged: (dynamic value) => null,
items: [
CompanyGatewayEntity.AUTO_BILL_ALWAYS,
CompanyGatewayEntity.AUTO_BILL_OPT_IN,
CompanyGatewayEntity.AUTO_BILL_OPT_OUT,
CompanyGatewayEntity.AUTO_BILL_DISABLED
]
.map((value) => DropdownMenuItem(
child: Text(value),
value: value,
))
.toList())
]),
FormCard(
children: <Widget>[
children: [
SwitchListTile(
activeColor: Theme.of(context).accentColor,
title: Text(localization.updateAddress),

View File

@ -15,6 +15,7 @@ mixin LocalizationsProvider on LocaleCodeAware {
static final Map<String, Map<String, String>> _localizedValues = {
'en': {
// STARTER: lang key - do not remove comment
'label': 'Label',
'client_number': 'Client Number',
'auto_convert': 'Auto Convert',
'company_name': 'Company Name',
@ -4393,6 +4394,8 @@ mixin LocalizationsProvider on LocaleCodeAware {
String get autoConvert => _localizedValues[localeCode]['auto_convert'] ?? '';
String get label => _localizedValues[localeCode]['label'] ?? '';
String lookup(String key) {
final lookupKey = toSnakeCase(key);

View File

@ -49,11 +49,13 @@ class WebUtils {
static void registerWebView(String html) {
// ignore: undefined_prefixed_name
/*
ui.platformViewRegistry.registerViewFactory(
html,
(int viewId) => IFrameElement()
..src = html
..style.border = 'none');
*/
}
static void warnChanges(Store<AppState> store) {

View File

@ -217,21 +217,28 @@ packages:
name: device_info
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.2+6"
version: "0.4.2+7"
device_info_platform_interface:
dependency: transitive
description:
name: device_info_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
extended_image:
dependency: transitive
description:
name: extended_image
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
extended_image_library:
dependency: transitive
description:
name: extended_image_library
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.3"
version: "0.3.0"
extension:
dependency: transitive
description:
@ -431,7 +438,7 @@ packages:
name: google_sign_in
url: "https://pub.dartlang.org"
source: hosted
version: "4.5.1"
version: "4.5.3"
google_sign_in_platform_interface:
dependency: transitive
description:
@ -501,7 +508,7 @@ packages:
name: image_picker
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.7+4"
version: "0.6.7+6"
image_picker_platform_interface:
dependency: transitive
description:
@ -515,7 +522,7 @@ packages:
name: in_app_purchase
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.4+3"
version: "0.3.4+4"
intl:
dependency: "direct main"
description:
@ -557,7 +564,7 @@ packages:
name: local_auth
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
version: "0.6.3+1"
logging:
dependency: transitive
description:
@ -648,7 +655,7 @@ packages:
name: package_info
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.1"
version: "0.4.3"
path:
dependency: transitive
description:
@ -662,7 +669,7 @@ packages:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.11"
version: "1.6.14"
path_provider_linux:
dependency: transitive
description:
@ -795,21 +802,21 @@ packages:
name: share
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.4+3"
version: "0.6.4+5"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.8"
version: "0.5.10"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.2+1"
version: "0.0.2+2"
shared_preferences_macos:
dependency: transitive
description:
@ -982,7 +989,7 @@ packages:
name: timeago
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.26"
version: "2.0.27"
timing:
dependency: transitive
description:
@ -1115,7 +1122,7 @@ packages:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1"
version: "0.1.2"
xml:
dependency: transitive
description: