This commit is contained in:
Hillel Coren 2019-11-11 20:33:57 +02:00
parent f7f186b689
commit bb0ccfa71d
8 changed files with 599 additions and 332 deletions

View File

@ -102,13 +102,23 @@ const String kGatewayTypeBankTransfer = '2';
const String kGatewayTypePayPal = '3'; const String kGatewayTypePayPal = '3';
const String kGatewayTypeBitcoin = '4'; const String kGatewayTypeBitcoin = '4';
//const String kGatewayTypeDwolla = '5'; //const String kGatewayTypeDwolla = '5';
const String kGatewayTypeCustom1 = '6'; const String kGatewayTypeCustom = '6';
const String kGatewayTypeAlipay = '7'; const String kGatewayTypeAlipay = '7';
const String kGatewayTypeSofort = '8'; const String kGatewayTypeSofort = '8';
const String kGatewayTypeGoCardless = '9'; const String kGatewayTypeGoCardless = '9';
const String kGatewayTypeApplePay = '10'; const String kGatewayTypeApplePay = '10';
const String kGatewayTypeCustom2 = '11';
const String kGatewayTypeCustom3 = '12'; const kGatewayTypes = {
kGatewayTypeCreditCard: 'credit_card',
kGatewayTypeBankTransfer: 'bank_transfer',
kGatewayTypePayPal: 'paypal',
kGatewayTypeBitcoin: 'bitcoin',
kGatewayTypeCustom: 'custom',
kGatewayTypeAlipay: 'alipay',
kGatewayTypeSofort: 'sofort',
kGatewayTypeGoCardless: 'gocardless',
kGatewayTypeApplePay: 'apple_pay',
};
const String kGatewayStripe = 'd14dd26a37cecc30fdd65700bfb55b23'; const String kGatewayStripe = 'd14dd26a37cecc30fdd65700bfb55b23';

View File

@ -62,6 +62,7 @@ abstract class CompanyGatewayEntity extends Object
customValue1: '', customValue1: '',
customValue2: '', customValue2: '',
config: '', config: '',
feesAndLimitsMap: BuiltMap<String, FeesAndLimitsSettings>(),
); );
} }
@ -98,55 +99,17 @@ abstract class CompanyGatewayEntity extends Object
@BuiltValueField(wireName: 'custom_value2') @BuiltValueField(wireName: 'custom_value2')
String get customValue2; String get customValue2;
@nullable @BuiltValueField(wireName: 'fees_and_limits')
@BuiltValueField(wireName: 'min_limit') BuiltMap<String, FeesAndLimitsSettings> get feesAndLimitsMap;
double get minLimit;
@nullable
@BuiltValueField(wireName: 'max_limit')
double get maxLimit;
@nullable
@BuiltValueField(wireName: 'fee_amount')
double get feeAmount;
@nullable
@BuiltValueField(wireName: 'fee_percent')
double get feePercent;
@nullable
@BuiltValueField(wireName: 'fee_cap')
double get feeCap;
@nullable
@BuiltValueField(wireName: 'fee_tax_rate1')
double get taxRate1;
@nullable
@BuiltValueField(wireName: 'fee_tax_name1')
String get taxName1;
@nullable
@BuiltValueField(wireName: 'fee_tax_rate2')
double get taxRate2;
@nullable
@BuiltValueField(wireName: 'fee_tax_name2')
String get taxName2;
@nullable
@BuiltValueField(wireName: 'fee_tax_rate3')
double get taxRate3;
@nullable
@BuiltValueField(wireName: 'fee_tax_name3')
String get taxName3;
String get config; String get config;
Map<String, dynamic> get parsedConfig => Map<String, dynamic> get parsedConfig =>
config.isEmpty ? <String, dynamic>{} : jsonDecode(config); config.isEmpty ? <String, dynamic>{} : jsonDecode(config);
FeesAndLimitsSettings getSettingsForGatewayTypeId(String gatewayTypeId) =>
feesAndLimitsMap.containsKey(gatewayTypeId) ?? FeesAndLimitsSettings();
@override @override
String get listDisplayName { String get listDisplayName {
return gateway.name; return gateway.name;
@ -229,3 +192,59 @@ abstract class CompanyGatewayEntity extends Object
static Serializer<CompanyGatewayEntity> get serializer => static Serializer<CompanyGatewayEntity> get serializer =>
_$companyGatewayEntitySerializer; _$companyGatewayEntitySerializer;
} }
abstract class FeesAndLimitsSettings
implements Built<FeesAndLimitsSettings, FeesAndLimitsSettingsBuilder> {
factory FeesAndLimitsSettings({String id}) {
return _$FeesAndLimitsSettings._();
}
FeesAndLimitsSettings._();
@nullable
@BuiltValueField(wireName: 'min_limit')
double get minLimit;
@nullable
@BuiltValueField(wireName: 'max_limit')
double get maxLimit;
@nullable
@BuiltValueField(wireName: 'fee_amount')
double get feeAmount;
@nullable
@BuiltValueField(wireName: 'fee_percent')
double get feePercent;
@nullable
@BuiltValueField(wireName: 'fee_cap')
double get feeCap;
@nullable
@BuiltValueField(wireName: 'fee_tax_rate1')
double get taxRate1;
@nullable
@BuiltValueField(wireName: 'fee_tax_name1')
String get taxName1;
@nullable
@BuiltValueField(wireName: 'fee_tax_rate2')
double get taxRate2;
@nullable
@BuiltValueField(wireName: 'fee_tax_name2')
String get taxName2;
@nullable
@BuiltValueField(wireName: 'fee_tax_rate3')
double get taxRate3;
@nullable
@BuiltValueField(wireName: 'fee_tax_name3')
String get taxName3;
static Serializer<FeesAndLimitsSettings> get serializer =>
_$feesAndLimitsSettingsSerializer;
}

View File

@ -12,6 +12,8 @@ Serializer<CompanyGatewayItemResponse> _$companyGatewayItemResponseSerializer =
new _$CompanyGatewayItemResponseSerializer(); new _$CompanyGatewayItemResponseSerializer();
Serializer<CompanyGatewayEntity> _$companyGatewayEntitySerializer = Serializer<CompanyGatewayEntity> _$companyGatewayEntitySerializer =
new _$CompanyGatewayEntitySerializer(); new _$CompanyGatewayEntitySerializer();
Serializer<FeesAndLimitsSettings> _$feesAndLimitsSettingsSerializer =
new _$FeesAndLimitsSettingsSerializer();
class _$CompanyGatewayListResponseSerializer class _$CompanyGatewayListResponseSerializer
implements StructuredSerializer<CompanyGatewayListResponse> { implements StructuredSerializer<CompanyGatewayListResponse> {
@ -139,6 +141,12 @@ class _$CompanyGatewayEntitySerializer
'update_details', 'update_details',
serializers.serialize(object.updateDetails, serializers.serialize(object.updateDetails,
specifiedType: const FullType(bool)), specifiedType: const FullType(bool)),
'fees_and_limits',
serializers.serialize(object.feesAndLimitsMap,
specifiedType: const FullType(BuiltMap, const [
const FullType(String),
const FullType(FeesAndLimitsSettings)
])),
'config', 'config',
serializers.serialize(object.config, serializers.serialize(object.config,
specifiedType: const FullType(String)), specifiedType: const FullType(String)),
@ -161,72 +169,6 @@ class _$CompanyGatewayEntitySerializer
..add(serializers.serialize(object.customValue2, ..add(serializers.serialize(object.customValue2,
specifiedType: const FullType(String))); specifiedType: const FullType(String)));
} }
if (object.minLimit != null) {
result
..add('min_limit')
..add(serializers.serialize(object.minLimit,
specifiedType: const FullType(double)));
}
if (object.maxLimit != null) {
result
..add('max_limit')
..add(serializers.serialize(object.maxLimit,
specifiedType: const FullType(double)));
}
if (object.feeAmount != null) {
result
..add('fee_amount')
..add(serializers.serialize(object.feeAmount,
specifiedType: const FullType(double)));
}
if (object.feePercent != null) {
result
..add('fee_percent')
..add(serializers.serialize(object.feePercent,
specifiedType: const FullType(double)));
}
if (object.feeCap != null) {
result
..add('fee_cap')
..add(serializers.serialize(object.feeCap,
specifiedType: const FullType(double)));
}
if (object.taxRate1 != null) {
result
..add('fee_tax_rate1')
..add(serializers.serialize(object.taxRate1,
specifiedType: const FullType(double)));
}
if (object.taxName1 != null) {
result
..add('fee_tax_name1')
..add(serializers.serialize(object.taxName1,
specifiedType: const FullType(String)));
}
if (object.taxRate2 != null) {
result
..add('fee_tax_rate2')
..add(serializers.serialize(object.taxRate2,
specifiedType: const FullType(double)));
}
if (object.taxName2 != null) {
result
..add('fee_tax_name2')
..add(serializers.serialize(object.taxName2,
specifiedType: const FullType(String)));
}
if (object.taxRate3 != null) {
result
..add('fee_tax_rate3')
..add(serializers.serialize(object.taxRate3,
specifiedType: const FullType(double)));
}
if (object.taxName3 != null) {
result
..add('fee_tax_name3')
..add(serializers.serialize(object.taxName3,
specifiedType: const FullType(String)));
}
if (object.isChanged != null) { if (object.isChanged != null) {
result result
..add('isChanged') ..add('isChanged')
@ -322,6 +264,152 @@ class _$CompanyGatewayEntitySerializer
result.customValue2 = serializers.deserialize(value, result.customValue2 = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
break; break;
case 'fees_and_limits':
result.feesAndLimitsMap.replace(serializers.deserialize(value,
specifiedType: const FullType(BuiltMap, const [
const FullType(String),
const FullType(FeesAndLimitsSettings)
])) as BuiltMap<dynamic, dynamic>);
break;
case 'config':
result.config = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'isChanged':
result.isChanged = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'created_at':
result.createdAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
break;
case 'updated_at':
result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
break;
case 'archived_at':
result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
break;
case 'is_deleted':
result.isDeleted = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'user_id':
result.createdUserId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'assigned_user_id':
result.assignedUserId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'id':
result.id = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
}
}
return result.build();
}
}
class _$FeesAndLimitsSettingsSerializer
implements StructuredSerializer<FeesAndLimitsSettings> {
@override
final Iterable<Type> types = const [
FeesAndLimitsSettings,
_$FeesAndLimitsSettings
];
@override
final String wireName = 'FeesAndLimitsSettings';
@override
Iterable<Object> serialize(
Serializers serializers, FeesAndLimitsSettings object,
{FullType specifiedType = FullType.unspecified}) {
final result = <Object>[];
if (object.minLimit != null) {
result
..add('min_limit')
..add(serializers.serialize(object.minLimit,
specifiedType: const FullType(double)));
}
if (object.maxLimit != null) {
result
..add('max_limit')
..add(serializers.serialize(object.maxLimit,
specifiedType: const FullType(double)));
}
if (object.feeAmount != null) {
result
..add('fee_amount')
..add(serializers.serialize(object.feeAmount,
specifiedType: const FullType(double)));
}
if (object.feePercent != null) {
result
..add('fee_percent')
..add(serializers.serialize(object.feePercent,
specifiedType: const FullType(double)));
}
if (object.feeCap != null) {
result
..add('fee_cap')
..add(serializers.serialize(object.feeCap,
specifiedType: const FullType(double)));
}
if (object.taxRate1 != null) {
result
..add('fee_tax_rate1')
..add(serializers.serialize(object.taxRate1,
specifiedType: const FullType(double)));
}
if (object.taxName1 != null) {
result
..add('fee_tax_name1')
..add(serializers.serialize(object.taxName1,
specifiedType: const FullType(String)));
}
if (object.taxRate2 != null) {
result
..add('fee_tax_rate2')
..add(serializers.serialize(object.taxRate2,
specifiedType: const FullType(double)));
}
if (object.taxName2 != null) {
result
..add('fee_tax_name2')
..add(serializers.serialize(object.taxName2,
specifiedType: const FullType(String)));
}
if (object.taxRate3 != null) {
result
..add('fee_tax_rate3')
..add(serializers.serialize(object.taxRate3,
specifiedType: const FullType(double)));
}
if (object.taxName3 != null) {
result
..add('fee_tax_name3')
..add(serializers.serialize(object.taxName3,
specifiedType: const FullType(String)));
}
return result;
}
@override
FeesAndLimitsSettings deserialize(
Serializers serializers, Iterable<Object> serialized,
{FullType specifiedType = FullType.unspecified}) {
final result = new FeesAndLimitsSettingsBuilder();
final iterator = serialized.iterator;
while (iterator.moveNext()) {
final key = iterator.current as String;
iterator.moveNext();
final dynamic value = iterator.current;
switch (key) {
case 'min_limit': case 'min_limit':
result.minLimit = serializers.deserialize(value, result.minLimit = serializers.deserialize(value,
specifiedType: const FullType(double)) as double; specifiedType: const FullType(double)) as double;
@ -366,42 +454,6 @@ class _$CompanyGatewayEntitySerializer
result.taxName3 = serializers.deserialize(value, result.taxName3 = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
break; break;
case 'config':
result.config = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'isChanged':
result.isChanged = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'created_at':
result.createdAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
break;
case 'updated_at':
result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
break;
case 'archived_at':
result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
break;
case 'is_deleted':
result.isDeleted = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'user_id':
result.createdUserId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'assigned_user_id':
result.assignedUserId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'id':
result.id = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
} }
} }
@ -619,27 +671,7 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity {
@override @override
final String customValue2; final String customValue2;
@override @override
final double minLimit; final BuiltMap<String, FeesAndLimitsSettings> feesAndLimitsMap;
@override
final double maxLimit;
@override
final double feeAmount;
@override
final double feePercent;
@override
final double feeCap;
@override
final double taxRate1;
@override
final String taxName1;
@override
final double taxRate2;
@override
final String taxName2;
@override
final double taxRate3;
@override
final String taxName3;
@override @override
final String config; final String config;
@override @override
@ -672,17 +704,7 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity {
this.updateDetails, this.updateDetails,
this.customValue1, this.customValue1,
this.customValue2, this.customValue2,
this.minLimit, this.feesAndLimitsMap,
this.maxLimit,
this.feeAmount,
this.feePercent,
this.feeCap,
this.taxRate1,
this.taxName1,
this.taxRate2,
this.taxName2,
this.taxRate3,
this.taxName3,
this.config, this.config,
this.isChanged, this.isChanged,
this.createdAt, this.createdAt,
@ -712,6 +734,10 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity {
throw new BuiltValueNullFieldError( throw new BuiltValueNullFieldError(
'CompanyGatewayEntity', 'updateDetails'); 'CompanyGatewayEntity', 'updateDetails');
} }
if (feesAndLimitsMap == null) {
throw new BuiltValueNullFieldError(
'CompanyGatewayEntity', 'feesAndLimitsMap');
}
if (config == null) { if (config == null) {
throw new BuiltValueNullFieldError('CompanyGatewayEntity', 'config'); throw new BuiltValueNullFieldError('CompanyGatewayEntity', 'config');
} }
@ -738,17 +764,7 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity {
updateDetails == other.updateDetails && updateDetails == other.updateDetails &&
customValue1 == other.customValue1 && customValue1 == other.customValue1 &&
customValue2 == other.customValue2 && customValue2 == other.customValue2 &&
minLimit == other.minLimit && feesAndLimitsMap == other.feesAndLimitsMap &&
maxLimit == other.maxLimit &&
feeAmount == other.feeAmount &&
feePercent == other.feePercent &&
feeCap == other.feeCap &&
taxRate1 == other.taxRate1 &&
taxName1 == other.taxName1 &&
taxRate2 == other.taxRate2 &&
taxName2 == other.taxName2 &&
taxRate3 == other.taxRate3 &&
taxName3 == other.taxName3 &&
config == other.config && config == other.config &&
isChanged == other.isChanged && isChanged == other.isChanged &&
createdAt == other.createdAt && createdAt == other.createdAt &&
@ -780,17 +796,21 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity {
$jc( $jc(
$jc( $jc(
$jc( $jc(
$jc($jc($jc($jc($jc($jc($jc($jc($jc($jc(0, gateway.hashCode), gatewayId.hashCode), acceptedCreditCards.hashCode), showBillingAddress.hashCode), showShippingAddress.hashCode), updateDetails.hashCode), customValue1.hashCode), customValue2.hashCode), minLimit.hashCode), 0,
maxLimit.hashCode), gateway
feeAmount.hashCode), .hashCode),
feePercent.hashCode), gatewayId
feeCap.hashCode), .hashCode),
taxRate1.hashCode), acceptedCreditCards
taxName1.hashCode), .hashCode),
taxRate2.hashCode), showBillingAddress
taxName2.hashCode), .hashCode),
taxRate3.hashCode), showShippingAddress
taxName3.hashCode), .hashCode),
updateDetails.hashCode),
customValue1.hashCode),
customValue2.hashCode),
feesAndLimitsMap.hashCode),
config.hashCode), config.hashCode),
isChanged.hashCode), isChanged.hashCode),
createdAt.hashCode), createdAt.hashCode),
@ -813,17 +833,7 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity {
..add('updateDetails', updateDetails) ..add('updateDetails', updateDetails)
..add('customValue1', customValue1) ..add('customValue1', customValue1)
..add('customValue2', customValue2) ..add('customValue2', customValue2)
..add('minLimit', minLimit) ..add('feesAndLimitsMap', feesAndLimitsMap)
..add('maxLimit', maxLimit)
..add('feeAmount', feeAmount)
..add('feePercent', feePercent)
..add('feeCap', feeCap)
..add('taxRate1', taxRate1)
..add('taxName1', taxName1)
..add('taxRate2', taxRate2)
..add('taxName2', taxName2)
..add('taxRate3', taxRate3)
..add('taxName3', taxName3)
..add('config', config) ..add('config', config)
..add('isChanged', isChanged) ..add('isChanged', isChanged)
..add('createdAt', createdAt) ..add('createdAt', createdAt)
@ -878,49 +888,13 @@ class CompanyGatewayEntityBuilder
String get customValue2 => _$this._customValue2; String get customValue2 => _$this._customValue2;
set customValue2(String customValue2) => _$this._customValue2 = customValue2; set customValue2(String customValue2) => _$this._customValue2 = customValue2;
double _minLimit; MapBuilder<String, FeesAndLimitsSettings> _feesAndLimitsMap;
double get minLimit => _$this._minLimit; MapBuilder<String, FeesAndLimitsSettings> get feesAndLimitsMap =>
set minLimit(double minLimit) => _$this._minLimit = minLimit; _$this._feesAndLimitsMap ??=
new MapBuilder<String, FeesAndLimitsSettings>();
double _maxLimit; set feesAndLimitsMap(
double get maxLimit => _$this._maxLimit; MapBuilder<String, FeesAndLimitsSettings> feesAndLimitsMap) =>
set maxLimit(double maxLimit) => _$this._maxLimit = maxLimit; _$this._feesAndLimitsMap = feesAndLimitsMap;
double _feeAmount;
double get feeAmount => _$this._feeAmount;
set feeAmount(double feeAmount) => _$this._feeAmount = feeAmount;
double _feePercent;
double get feePercent => _$this._feePercent;
set feePercent(double feePercent) => _$this._feePercent = feePercent;
double _feeCap;
double get feeCap => _$this._feeCap;
set feeCap(double feeCap) => _$this._feeCap = feeCap;
double _taxRate1;
double get taxRate1 => _$this._taxRate1;
set taxRate1(double taxRate1) => _$this._taxRate1 = taxRate1;
String _taxName1;
String get taxName1 => _$this._taxName1;
set taxName1(String taxName1) => _$this._taxName1 = taxName1;
double _taxRate2;
double get taxRate2 => _$this._taxRate2;
set taxRate2(double taxRate2) => _$this._taxRate2 = taxRate2;
String _taxName2;
String get taxName2 => _$this._taxName2;
set taxName2(String taxName2) => _$this._taxName2 = taxName2;
double _taxRate3;
double get taxRate3 => _$this._taxRate3;
set taxRate3(double taxRate3) => _$this._taxRate3 = taxRate3;
String _taxName3;
String get taxName3 => _$this._taxName3;
set taxName3(String taxName3) => _$this._taxName3 = taxName3;
String _config; String _config;
String get config => _$this._config; String get config => _$this._config;
@ -972,17 +946,7 @@ class CompanyGatewayEntityBuilder
_updateDetails = _$v.updateDetails; _updateDetails = _$v.updateDetails;
_customValue1 = _$v.customValue1; _customValue1 = _$v.customValue1;
_customValue2 = _$v.customValue2; _customValue2 = _$v.customValue2;
_minLimit = _$v.minLimit; _feesAndLimitsMap = _$v.feesAndLimitsMap?.toBuilder();
_maxLimit = _$v.maxLimit;
_feeAmount = _$v.feeAmount;
_feePercent = _$v.feePercent;
_feeCap = _$v.feeCap;
_taxRate1 = _$v.taxRate1;
_taxName1 = _$v.taxName1;
_taxRate2 = _$v.taxRate2;
_taxName2 = _$v.taxName2;
_taxRate3 = _$v.taxRate3;
_taxName3 = _$v.taxName3;
_config = _$v.config; _config = _$v.config;
_isChanged = _$v.isChanged; _isChanged = _$v.isChanged;
_createdAt = _$v.createdAt; _createdAt = _$v.createdAt;
@ -1024,17 +988,7 @@ class CompanyGatewayEntityBuilder
updateDetails: updateDetails, updateDetails: updateDetails,
customValue1: customValue1, customValue1: customValue1,
customValue2: customValue2, customValue2: customValue2,
minLimit: minLimit, feesAndLimitsMap: feesAndLimitsMap.build(),
maxLimit: maxLimit,
feeAmount: feeAmount,
feePercent: feePercent,
feeCap: feeCap,
taxRate1: taxRate1,
taxName1: taxName1,
taxRate2: taxRate2,
taxName2: taxName2,
taxRate3: taxRate3,
taxName3: taxName3,
config: config, config: config,
isChanged: isChanged, isChanged: isChanged,
createdAt: createdAt, createdAt: createdAt,
@ -1049,6 +1003,9 @@ class CompanyGatewayEntityBuilder
try { try {
_$failedField = 'gateway'; _$failedField = 'gateway';
gateway.build(); gateway.build();
_$failedField = 'feesAndLimitsMap';
feesAndLimitsMap.build();
} catch (e) { } catch (e) {
throw new BuiltValueNestedFieldError( throw new BuiltValueNestedFieldError(
'CompanyGatewayEntity', _$failedField, e.toString()); 'CompanyGatewayEntity', _$failedField, e.toString());
@ -1060,4 +1017,215 @@ class CompanyGatewayEntityBuilder
} }
} }
class _$FeesAndLimitsSettings extends FeesAndLimitsSettings {
@override
final double minLimit;
@override
final double maxLimit;
@override
final double feeAmount;
@override
final double feePercent;
@override
final double feeCap;
@override
final double taxRate1;
@override
final String taxName1;
@override
final double taxRate2;
@override
final String taxName2;
@override
final double taxRate3;
@override
final String taxName3;
factory _$FeesAndLimitsSettings(
[void Function(FeesAndLimitsSettingsBuilder) updates]) =>
(new FeesAndLimitsSettingsBuilder()..update(updates)).build();
_$FeesAndLimitsSettings._(
{this.minLimit,
this.maxLimit,
this.feeAmount,
this.feePercent,
this.feeCap,
this.taxRate1,
this.taxName1,
this.taxRate2,
this.taxName2,
this.taxRate3,
this.taxName3})
: super._();
@override
FeesAndLimitsSettings rebuild(
void Function(FeesAndLimitsSettingsBuilder) updates) =>
(toBuilder()..update(updates)).build();
@override
FeesAndLimitsSettingsBuilder toBuilder() =>
new FeesAndLimitsSettingsBuilder()..replace(this);
@override
bool operator ==(Object other) {
if (identical(other, this)) return true;
return other is FeesAndLimitsSettings &&
minLimit == other.minLimit &&
maxLimit == other.maxLimit &&
feeAmount == other.feeAmount &&
feePercent == other.feePercent &&
feeCap == other.feeCap &&
taxRate1 == other.taxRate1 &&
taxName1 == other.taxName1 &&
taxRate2 == other.taxRate2 &&
taxName2 == other.taxName2 &&
taxRate3 == other.taxRate3 &&
taxName3 == other.taxName3;
}
@override
int get hashCode {
return $jf($jc(
$jc(
$jc(
$jc(
$jc(
$jc(
$jc(
$jc(
$jc(
$jc($jc(0, minLimit.hashCode),
maxLimit.hashCode),
feeAmount.hashCode),
feePercent.hashCode),
feeCap.hashCode),
taxRate1.hashCode),
taxName1.hashCode),
taxRate2.hashCode),
taxName2.hashCode),
taxRate3.hashCode),
taxName3.hashCode));
}
@override
String toString() {
return (newBuiltValueToStringHelper('FeesAndLimitsSettings')
..add('minLimit', minLimit)
..add('maxLimit', maxLimit)
..add('feeAmount', feeAmount)
..add('feePercent', feePercent)
..add('feeCap', feeCap)
..add('taxRate1', taxRate1)
..add('taxName1', taxName1)
..add('taxRate2', taxRate2)
..add('taxName2', taxName2)
..add('taxRate3', taxRate3)
..add('taxName3', taxName3))
.toString();
}
}
class FeesAndLimitsSettingsBuilder
implements Builder<FeesAndLimitsSettings, FeesAndLimitsSettingsBuilder> {
_$FeesAndLimitsSettings _$v;
double _minLimit;
double get minLimit => _$this._minLimit;
set minLimit(double minLimit) => _$this._minLimit = minLimit;
double _maxLimit;
double get maxLimit => _$this._maxLimit;
set maxLimit(double maxLimit) => _$this._maxLimit = maxLimit;
double _feeAmount;
double get feeAmount => _$this._feeAmount;
set feeAmount(double feeAmount) => _$this._feeAmount = feeAmount;
double _feePercent;
double get feePercent => _$this._feePercent;
set feePercent(double feePercent) => _$this._feePercent = feePercent;
double _feeCap;
double get feeCap => _$this._feeCap;
set feeCap(double feeCap) => _$this._feeCap = feeCap;
double _taxRate1;
double get taxRate1 => _$this._taxRate1;
set taxRate1(double taxRate1) => _$this._taxRate1 = taxRate1;
String _taxName1;
String get taxName1 => _$this._taxName1;
set taxName1(String taxName1) => _$this._taxName1 = taxName1;
double _taxRate2;
double get taxRate2 => _$this._taxRate2;
set taxRate2(double taxRate2) => _$this._taxRate2 = taxRate2;
String _taxName2;
String get taxName2 => _$this._taxName2;
set taxName2(String taxName2) => _$this._taxName2 = taxName2;
double _taxRate3;
double get taxRate3 => _$this._taxRate3;
set taxRate3(double taxRate3) => _$this._taxRate3 = taxRate3;
String _taxName3;
String get taxName3 => _$this._taxName3;
set taxName3(String taxName3) => _$this._taxName3 = taxName3;
FeesAndLimitsSettingsBuilder();
FeesAndLimitsSettingsBuilder get _$this {
if (_$v != null) {
_minLimit = _$v.minLimit;
_maxLimit = _$v.maxLimit;
_feeAmount = _$v.feeAmount;
_feePercent = _$v.feePercent;
_feeCap = _$v.feeCap;
_taxRate1 = _$v.taxRate1;
_taxName1 = _$v.taxName1;
_taxRate2 = _$v.taxRate2;
_taxName2 = _$v.taxName2;
_taxRate3 = _$v.taxRate3;
_taxName3 = _$v.taxName3;
_$v = null;
}
return this;
}
@override
void replace(FeesAndLimitsSettings other) {
if (other == null) {
throw new ArgumentError.notNull('other');
}
_$v = other as _$FeesAndLimitsSettings;
}
@override
void update(void Function(FeesAndLimitsSettingsBuilder) updates) {
if (updates != null) updates(this);
}
@override
_$FeesAndLimitsSettings build() {
final _$result = _$v ??
new _$FeesAndLimitsSettings._(
minLimit: minLimit,
maxLimit: maxLimit,
feeAmount: feeAmount,
feePercent: feePercent,
feeCap: feeCap,
taxRate1: taxRate1,
taxName1: taxName1,
taxRate2: taxRate2,
taxName2: taxName2,
taxRate3: taxRate3,
taxName3: taxName3);
replace(_$result);
return _$result;
}
}
// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,lines_longer_than_80_chars,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new // ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,lines_longer_than_80_chars,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new

View File

@ -59,6 +59,7 @@ Serializers _$serializers = (new Serializers().toBuilder()
..add(ExpenseState.serializer) ..add(ExpenseState.serializer)
..add(ExpenseStatusEntity.serializer) ..add(ExpenseStatusEntity.serializer)
..add(ExpenseUIState.serializer) ..add(ExpenseUIState.serializer)
..add(FeesAndLimitsSettings.serializer)
..add(GatewayEntity.serializer) ..add(GatewayEntity.serializer)
..add(GatewayTokenEntity.serializer) ..add(GatewayTokenEntity.serializer)
..add(GatewayTokenItemResponse.serializer) ..add(GatewayTokenItemResponse.serializer)
@ -346,6 +347,7 @@ Serializers _$serializers = (new Serializers().toBuilder()
..addBuilderFactory(const FullType(BuiltList, const [const FullType(String)]), () => new ListBuilder<String>()) ..addBuilderFactory(const FullType(BuiltList, const [const FullType(String)]), () => new ListBuilder<String>())
..addBuilderFactory(const FullType(BuiltMap, const [const FullType(String), const FullType(ExpenseEntity)]), () => new MapBuilder<String, ExpenseEntity>()) ..addBuilderFactory(const FullType(BuiltMap, const [const FullType(String), const FullType(ExpenseEntity)]), () => new MapBuilder<String, ExpenseEntity>())
..addBuilderFactory(const FullType(BuiltList, const [const FullType(String)]), () => new ListBuilder<String>()) ..addBuilderFactory(const FullType(BuiltList, const [const FullType(String)]), () => new ListBuilder<String>())
..addBuilderFactory(const FullType(BuiltMap, const [const FullType(String), const FullType(FeesAndLimitsSettings)]), () => new MapBuilder<String, FeesAndLimitsSettings>())
..addBuilderFactory(const FullType(BuiltMap, const [const FullType(String), const FullType(GroupEntity)]), () => new MapBuilder<String, GroupEntity>()) ..addBuilderFactory(const FullType(BuiltMap, const [const FullType(String), const FullType(GroupEntity)]), () => new MapBuilder<String, GroupEntity>())
..addBuilderFactory(const FullType(BuiltList, const [const FullType(String)]), () => new ListBuilder<String>()) ..addBuilderFactory(const FullType(BuiltList, const [const FullType(String)]), () => new ListBuilder<String>())
..addBuilderFactory(const FullType(BuiltMap, const [const FullType(String), const FullType(InvoiceEntity)]), () => new MapBuilder<String, InvoiceEntity>()) ..addBuilderFactory(const FullType(BuiltMap, const [const FullType(String), const FullType(InvoiceEntity)]), () => new MapBuilder<String, InvoiceEntity>())

View File

@ -94,21 +94,23 @@ class CompanyGatewayScreen extends StatelessWidget {
store.dispatch(FilterCompanyGatewaysByState(state)); store.dispatch(FilterCompanyGatewaysByState(state));
}, },
), ),
floatingActionButton: userCompany.canCreate(EntityType.companyGateway) floatingActionButton: FloatingActionButton(
? FloatingActionButton(
heroTag: 'company_gateway_fab', heroTag: 'company_gateway_fab',
backgroundColor: Theme.of(context).primaryColorDark, backgroundColor: Theme.of(context).primaryColorDark,
onPressed: () { onPressed: () {
if (state.settingsUIState.isFiltered) {
} else {
store.dispatch(EditCompanyGateway( store.dispatch(EditCompanyGateway(
companyGateway: CompanyGatewayEntity(), context: context)); companyGateway: CompanyGatewayEntity(), context: context));
}
}, },
child: Icon( child: Icon(
Icons.add, Icons.add,
color: Colors.white, color: Colors.white,
), ),
tooltip: localization.newCompanyGateway, tooltip: localization.newCompanyGateway,
) ),
: null,
); );
} }
} }

View File

@ -37,6 +37,7 @@ class _CompanyGatewayEditState extends State<CompanyGatewayEdit>
final FocusScopeNode _focusNode = FocusScopeNode(); final FocusScopeNode _focusNode = FocusScopeNode();
TabController _controller; TabController _controller;
String _gatewayTypeId;
@override @override
void initState() { void initState() {
@ -184,11 +185,37 @@ class _CompanyGatewayEditState extends State<CompanyGatewayEdit>
), ),
ListView( ListView(
children: <Widget>[ children: <Widget>[
if (companyGateway.gatewayId == kGatewayStripe)
FormCard(
children: <Widget>[
AppDropdownButton(
labelText: localization.paymentType,
value: _gatewayTypeId,
items: [
DropdownMenuItem(
child: Text(localization.creditCard),
value: kGatewayTypeCreditCard,
),
DropdownMenuItem(
child: Text(localization.bankTransfer),
value: kGatewayTypeBankTransfer,
),
],
onChanged: (value) {
setState(() {
_gatewayTypeId = value;
});
},
),
],
),
LimitEditor( LimitEditor(
gatewayTypeId: _gatewayTypeId,
viewModel: viewModel, viewModel: viewModel,
companyGateway: companyGateway, companyGateway: companyGateway,
), ),
FeesEditor( FeesEditor(
gatewayTypeId: _gatewayTypeId,
viewModel: viewModel, viewModel: viewModel,
companyGateway: companyGateway, companyGateway: companyGateway,
), ),
@ -380,10 +407,11 @@ class _GatewayConfigFieldState extends State<GatewayConfigField> {
} }
class LimitEditor extends StatefulWidget { class LimitEditor extends StatefulWidget {
const LimitEditor({this.companyGateway, this.viewModel}); const LimitEditor({this.companyGateway, this.viewModel, this.gatewayTypeId});
final CompanyGatewayEntity companyGateway; final CompanyGatewayEntity companyGateway;
final CompanyGatewayEditVM viewModel; final CompanyGatewayEditVM viewModel;
final String gatewayTypeId;
@override @override
_LimitEditorState createState() => _LimitEditorState(); _LimitEditorState createState() => _LimitEditorState();
@ -418,20 +446,22 @@ class _LimitEditorState extends State<LimitEditor> {
_maxController.removeListener(_onChanged); _maxController.removeListener(_onChanged);
final companyGateway = widget.companyGateway; final companyGateway = widget.companyGateway;
final settings =
companyGateway.getSettingsForGatewayTypeId(widget.gatewayTypeId);
if (companyGateway.minLimit != null) { if (settings.minLimit != null) {
_enableMin = true; _enableMin = true;
} }
if (companyGateway.maxLimit != null) { if (settings.maxLimit != null) {
_enableMax = true; _enableMax = true;
} }
_minController.text = formatNumber( _minController.text = formatNumber(
(companyGateway.minLimit ?? 0).toDouble(), context, (settings.minLimit ?? 0).toDouble(), context,
formatNumberType: FormatNumberType.input); formatNumberType: FormatNumberType.input);
_maxController.text = formatNumber( _maxController.text = formatNumber(
(companyGateway.maxLimit ?? 0).toDouble(), context, (settings.maxLimit ?? 0).toDouble(), context,
formatNumberType: FormatNumberType.input); formatNumberType: FormatNumberType.input);
_minController.addListener(_onChanged); _minController.addListener(_onChanged);
@ -444,14 +474,17 @@ class _LimitEditorState extends State<LimitEditor> {
_debouncer.run(() { _debouncer.run(() {
final viewModel = widget.viewModel; final viewModel = widget.viewModel;
final companyGateway = viewModel.companyGateway; final companyGateway = viewModel.companyGateway;
final settings =
companyGateway.getSettingsForGatewayTypeId(widget.gatewayTypeId);
final updatedGateway = companyGateway.rebuild((b) => b final updatedSettings = settings.rebuild((b) => b
..minLimit = _enableMin ? parseDouble(_minController.text.trim()) : null ..minLimit = _enableMin ? parseDouble(_minController.text.trim()) : null
..maxLimit = ..maxLimit =
_enableMax ? parseDouble(_maxController.text.trim()) : null); _enableMax ? parseDouble(_maxController.text.trim()) : null);
if (companyGateway != updatedGateway) { if (settings != updatedSettings) {
viewModel.onChanged(updatedGateway); viewModel.onChanged(companyGateway.rebuild((b) =>
b..feesAndLimitsMap[widget.gatewayTypeId] = updatedSettings));
} }
}); });
} }
@ -548,10 +581,11 @@ class _LimitEditorState extends State<LimitEditor> {
} }
class FeesEditor extends StatefulWidget { class FeesEditor extends StatefulWidget {
const FeesEditor({this.companyGateway, this.viewModel}); const FeesEditor({this.companyGateway, this.viewModel, this.gatewayTypeId});
final CompanyGatewayEntity companyGateway; final CompanyGatewayEntity companyGateway;
final CompanyGatewayEditVM viewModel; final CompanyGatewayEditVM viewModel;
final String gatewayTypeId;
@override @override
_FeesEditorState createState() => _FeesEditorState(); _FeesEditorState createState() => _FeesEditorState();
@ -584,15 +618,17 @@ class _FeesEditorState extends State<FeesEditor> {
]; ];
final companyGateway = widget.companyGateway; final companyGateway = widget.companyGateway;
final settings =
companyGateway.getSettingsForGatewayTypeId(widget.gatewayTypeId);
_controllers _controllers
.forEach((dynamic controller) => controller.removeListener(_onChanged)); .forEach((dynamic controller) => controller.removeListener(_onChanged));
_amountController.text = formatNumber(companyGateway.feeAmount, context, _amountController.text = formatNumber(settings.feeAmount, context,
formatNumberType: FormatNumberType.input); formatNumberType: FormatNumberType.input);
_percentController.text = formatNumber(companyGateway.feePercent, context, _percentController.text = formatNumber(settings.feePercent, context,
formatNumberType: FormatNumberType.input); formatNumberType: FormatNumberType.input);
_capController.text = formatNumber(companyGateway.feeCap, context, _capController.text = formatNumber(settings.feeCap, context,
formatNumberType: FormatNumberType.input); formatNumberType: FormatNumberType.input);
_controllers _controllers
@ -605,19 +641,22 @@ class _FeesEditorState extends State<FeesEditor> {
_debouncer.run(() { _debouncer.run(() {
final viewModel = widget.viewModel; final viewModel = widget.viewModel;
final companyGateway = viewModel.companyGateway; final companyGateway = viewModel.companyGateway;
final settings =
companyGateway.getSettingsForGatewayTypeId(widget.gatewayTypeId);
final amount = parseDouble(_amountController.text.trim()); final amount = parseDouble(_amountController.text.trim());
final percent = parseDouble(_percentController.text.trim()); final percent = parseDouble(_percentController.text.trim());
final cap = parseDouble(_capController.text.trim()); final cap = parseDouble(_capController.text.trim());
final feesEnabled = amount != 0 || percent != 0; final feesEnabled = amount != 0 || percent != 0;
final updatedGateway = companyGateway.rebuild((b) => b final updatedSettings = settings.rebuild((b) => b
..feeAmount = feesEnabled ? amount : null ..feeAmount = feesEnabled ? amount : null
..feePercent = feesEnabled ? percent : null ..feePercent = feesEnabled ? percent : null
..feeCap = feesEnabled ? cap : null); ..feeCap = feesEnabled ? cap : null);
if (companyGateway != updatedGateway) { if (settings != updatedSettings) {
viewModel.onChanged(updatedGateway); viewModel.onChanged(companyGateway.rebuild((b) =>
b..feesAndLimitsMap[widget.gatewayTypeId] = updatedSettings));
} }
}); });
} }
@ -628,6 +667,8 @@ class _FeesEditorState extends State<FeesEditor> {
final viewModel = widget.viewModel; final viewModel = widget.viewModel;
final companyGateway = viewModel.companyGateway; final companyGateway = viewModel.companyGateway;
final company = viewModel.state.selectedCompany; final company = viewModel.state.selectedCompany;
final settings =
companyGateway.getSettingsForGatewayTypeId(widget.gatewayTypeId);
return FormCard( return FormCard(
children: <Widget>[ children: <Widget>[
@ -645,23 +686,39 @@ class _FeesEditorState extends State<FeesEditor> {
), ),
if (company.settings.enableFirstItemTaxRate) if (company.settings.enableFirstItemTaxRate)
TaxRateDropdown( TaxRateDropdown(
onSelected: (taxRate) => onSelected: (taxRate) => viewModel.onChanged(companyGateway.rebuild(
viewModel.onChanged(companyGateway.rebuild((b) => b (b) => b
..feesAndLimitsMap[widget.gatewayTypeId] =
settings.rebuild((b) => b
..taxRate1 = taxRate.rate ..taxRate1 = taxRate.rate
..taxName1 = taxRate.name)), ..taxName1 = taxRate.name))),
labelText: localization.tax, labelText: localization.tax,
initialTaxName: companyGateway.taxName1, initialTaxName: settings.taxName1,
initialTaxRate: companyGateway.taxRate1, initialTaxRate: settings.taxRate1,
), ),
if (company.settings.enableSecondItemTaxRate) if (company.settings.enableSecondItemTaxRate)
TaxRateDropdown( TaxRateDropdown(
onSelected: (taxRate) => onSelected: (taxRate) => viewModel.onChanged(companyGateway.rebuild(
viewModel.onChanged(companyGateway.rebuild((b) => b (b) => b
..feesAndLimitsMap[widget.gatewayTypeId] =
settings.rebuild((b) => b
..taxRate2 = taxRate.rate ..taxRate2 = taxRate.rate
..taxName2 = taxRate.name)), ..taxName2 = taxRate.name))),
labelText: localization.tax, labelText: localization.tax,
initialTaxName: companyGateway.taxName2, initialTaxName: settings.taxName2,
initialTaxRate: companyGateway.taxRate2, initialTaxRate: settings.taxRate2,
),
if (company.settings.enableThirdItemTaxRate)
TaxRateDropdown(
onSelected: (taxRate) => viewModel.onChanged(companyGateway.rebuild(
(b) => b
..feesAndLimitsMap[widget.gatewayTypeId] =
settings.rebuild((b) => b
..taxRate3 = taxRate.rate
..taxName3 = taxRate.name))),
labelText: localization.tax,
initialTaxName: settings.taxName3,
initialTaxRate: settings.taxRate3,
), ),
], ],
); );

View File

@ -1,5 +1,6 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:invoiceninja_flutter/constants.dart';
import 'package:invoiceninja_flutter/data/models/entities.dart'; import 'package:invoiceninja_flutter/data/models/entities.dart';
import 'package:invoiceninja_flutter/ui/app/FieldGrid.dart'; import 'package:invoiceninja_flutter/ui/app/FieldGrid.dart';
import 'package:invoiceninja_flutter/ui/app/buttons/edit_icon_button.dart'; import 'package:invoiceninja_flutter/ui/app/buttons/edit_icon_button.dart';
@ -33,6 +34,29 @@ class _CompanyGatewayViewState extends State<CompanyGatewayView> {
final companyGateway = viewModel.companyGateway; final companyGateway = viewModel.companyGateway;
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final Map<String, String> fields = {};
for (var gatewayTypeId in kGatewayTypes.keys)
if (companyGateway.feesAndLimitsMap.containsKey(gatewayTypeId)) {
final settings =
companyGateway.getSettingsForGatewayTypeId(gatewayTypeId);
fields[localization.feeAmount] = settings.feeAmount == null
? null
: formatNumber(settings.feeAmount, context);
fields[localization.feePercent] = settings.feePercent == null
? null
: formatNumber(settings.feePercent, context,
formatNumberType: FormatNumberType.percent);
fields[localization.feeCap] = settings.feeCap == null
? null
: formatNumber(settings.feeCap, context);
fields[localization.minLimit] = settings.minLimit == null
? null
: formatNumber(settings.minLimit, context);
fields[localization.maxLimit] = settings.maxLimit == null
? null
: formatNumber(settings.maxLimit, context);
}
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
leading: !isMobile(context) leading: !isMobile(context)
@ -79,23 +103,7 @@ class _CompanyGatewayViewState extends State<CompanyGatewayView> {
color: Theme.of(context).backgroundColor, color: Theme.of(context).backgroundColor,
height: 12.0, height: 12.0,
), ),
FieldGrid({ FieldGrid({}),
localization.feeAmount: companyGateway.feeAmount == null
? null
: formatNumber(companyGateway.feeAmount, context),
localization.feePercent: companyGateway.feePercent == null
? null
: formatNumber(companyGateway.feePercent, context,
formatNumberType: FormatNumberType.percent),
localization.feeCap: companyGateway.feeCap == null
? null
: formatNumber(companyGateway.feeCap, context),
localization.minLimit: companyGateway.minLimit == null
? null
: formatNumber(companyGateway.minLimit, context),
companyGateway.maxLimit == null ? null : localization.maxLimit:
formatNumber(companyGateway.maxLimit, context),
}),
], ],
), ),
); );

View File

@ -72,6 +72,7 @@ class SettingsList extends StatelessWidget {
section: kSettingsLocalization, section: kSettingsLocalization,
viewModel: viewModel, viewModel: viewModel,
), ),
if (showAll)
SettingsListTile( SettingsListTile(
section: kSettingsOnlinePayments, section: kSettingsOnlinePayments,
viewModel: viewModel, viewModel: viewModel,