Company gateway view

This commit is contained in:
Hillel Coren 2020-08-12 17:57:50 +03:00
parent 1295cc23bd
commit c63669d7b0
5 changed files with 50 additions and 60 deletions

View File

@ -238,6 +238,7 @@ const kNotificationEvents = [
];
const String kGatewayStripe = 'd14dd26a37cecc30fdd65700bfb55b23';
const String kGatewayCustom = '54faab2ab6e3223dbe848b1686490baa';
const String kClientPortalModeSubdomain = 'subdomain';
const String kClientPortalModeDomain = 'domain';

View File

@ -140,6 +140,8 @@ abstract class CompanyGatewayEntity extends Object
return gateway.name;
}
bool get isCustom => gatewayId == kGatewayCustom;
bool supportsCard(int cardType) => acceptedCreditCards & cardType > 0;
CompanyGatewayEntity addCard(int cardType) =>

View File

@ -278,18 +278,13 @@ abstract class CompanyEntity extends Object
}
return matchesStrings(
haystacks: [
subdomain,
displayName,
companyKey
],
haystacks: [subdomain, displayName, companyKey],
needle: filter,
);
}
@override
String matchesFilterValue(String filter) {
for (final user in users) {
final value = user.matchesFilterValue(filter);
if (value != null) {
@ -310,11 +305,7 @@ abstract class CompanyEntity extends Object
}
return matchesStringsValue(
haystacks: [
subdomain,
displayName,
companyKey
],
haystacks: [subdomain, displayName, companyKey],
needle: filter,
);
}
@ -350,15 +341,13 @@ abstract class CompanyEntity extends Object
bool get hasCustomSurcharge =>
hasCustomField(CustomFieldType.surcharge1) ||
hasCustomField(CustomFieldType.surcharge2) ||
hasCustomField(CustomFieldType.surcharge3) ||
hasCustomField(CustomFieldType.surcharge4);
hasCustomField(CustomFieldType.surcharge2) ||
hasCustomField(CustomFieldType.surcharge3) ||
hasCustomField(CustomFieldType.surcharge4);
String getCustomFieldLabel(String field) {
if (customFields.containsKey(field)) {
return customFields[field]
.split('|')
.first;
return customFields[field].split('|').first;
} else {
return '';
}
@ -366,9 +355,7 @@ abstract class CompanyEntity extends Object
String getCustomFieldType(String field) {
if ((customFields[field] ?? '').contains('|')) {
final value = customFields[field]
.split('|')
.last;
final value = customFields[field].split('|').last;
if ([kFieldTypeSingleLineText, kFieldTypeDate, kFieldTypeSwitch]
.contains(value)) {
return value;
@ -405,9 +392,7 @@ abstract class CompanyEntity extends Object
}
// TODO make sure to clear everything
CompanyEntity get coreCompany =>
rebuild((b) =>
b
CompanyEntity get coreCompany => rebuild((b) => b
..clients.clear()
..products.clear()
..invoices.clear()
@ -418,8 +403,8 @@ abstract class CompanyEntity extends Object
..projects.clear()
..vendors.clear()
..expenses.clear()
//..designs.clear()
//..companyGateways.clear()
//..designs.clear()
//..companyGateways.clear()
);
bool isModuleEnabled(EntityType entityType) {
@ -435,7 +420,7 @@ abstract class CompanyEntity extends Object
}
if ((entityType == EntityType.invoice ||
entityType == EntityType.payment) &&
entityType == EntityType.payment) &&
enabledModules & kModuleInvoices == 0) {
return false;
} else if (entityType == EntityType.credit &&
@ -503,6 +488,8 @@ abstract class GatewayEntity extends Object
String get fields;
bool get supportsTokenBilling => [kGatewayStripe].contains(id);
Map<String, dynamic> get parsedFields =>
fields.isEmpty ? <String, dynamic>{} : jsonDecode(fields);
@ -571,7 +558,6 @@ abstract class GatewayEntity extends Object
FormatNumberType get listDisplayAmountType => null;
}
abstract class UserCompanyEntity
implements Built<UserCompanyEntity, UserCompanyEntityBuilder> {
factory UserCompanyEntity() {
@ -583,10 +569,9 @@ abstract class UserCompanyEntity
user: UserEntity(),
token: TokenEntity(),
account: AccountEntity(),
notifications: BuiltMap<String, BuiltList<String>>().rebuild((b) =>
b
notifications: BuiltMap<String, BuiltList<String>>().rebuild((b) => b
..[kNotificationChannelEmail] =
BuiltList<String>(<String>[kNotificationsAll])),
BuiltList<String>(<String>[kNotificationsAll])),
);
}
@ -656,7 +641,7 @@ abstract class UserCompanyEntity
bool receivesAllNotifications(String channel) =>
notifications.containsKey(channel) &&
notifications[channel].contains(kNotificationsAll);
notifications[channel].contains(kNotificationsAll);
bool canView(EntityType entityType) => can(UserPermission.view, entityType);
@ -861,9 +846,9 @@ abstract class SettingsEntity
groupSettings?.customMessagePaidInvoice ??
companySettings?.customMessagePaidInvoice,
customMessageUnapprovedQuote:
clientSettings?.customMessageUnapprovedQuote ??
groupSettings?.customMessageUnapprovedQuote ??
companySettings?.customMessageUnapprovedQuote,
clientSettings?.customMessageUnapprovedQuote ??
groupSettings?.customMessageUnapprovedQuote ??
companySettings?.customMessageUnapprovedQuote,
lockSentInvoices: clientSettings?.lockSentInvoices ??
groupSettings?.lockSentInvoices ??
companySettings?.lockSentInvoices,
@ -1069,7 +1054,7 @@ abstract class SettingsEntity
groupSettings?.requireQuoteSignature ??
companySettings?.requireQuoteSignature,
name:
clientSettings?.name ?? groupSettings?.name ?? companySettings?.name,
clientSettings?.name ?? groupSettings?.name ?? companySettings?.name,
companyLogo: clientSettings?.companyLogo ??
groupSettings?.companyLogo ??
companySettings?.companyLogo,
@ -1083,7 +1068,7 @@ abstract class SettingsEntity
groupSettings?.address2 ??
companySettings?.address2,
city:
clientSettings?.city ?? groupSettings?.city ?? companySettings?.city,
clientSettings?.city ?? groupSettings?.city ?? companySettings?.city,
state: clientSettings?.state ??
groupSettings?.state ??
companySettings?.state,
@ -1966,7 +1951,7 @@ abstract class SettingsEntity
abstract class CompanyItemResponse
implements Built<CompanyItemResponse, CompanyItemResponseBuilder> {
factory CompanyItemResponse([void updates(CompanyItemResponseBuilder b)]) =
_$CompanyItemResponse;
_$CompanyItemResponse;
CompanyItemResponse._();

View File

@ -633,6 +633,7 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
//return 'Invitations: ${uiState.invoiceUIState.editing.invitations}';
//return 'Selection: ${clientUIState.selectedId}';
//return '${clientState.map[clientUIState.selectedId].gatewayTokens}';
//return 'gatewayId: ${companyGatewayState.map[companyGatewayUIState.selectedId].gatewayId}';
return '\n\nURL: ${authState.url}\nRoute: ${uiState.currentRoute}\nPrev: ${uiState.previousRoute}\nIs Loaded: ${isLoaded ? 'Yes' : 'No'}\nis Large: ${(company?.isLarge ?? false) ? 'Yes' : 'No'}\nCompany: $companyUpdated${userCompanyState.isStale ? ' [S]' : ''}\nStatic: $staticUpdated${staticState.isStale ? ' [S]' : ''}\n';
}
}

View File

@ -7,6 +7,7 @@ import 'package:invoiceninja_flutter/redux/company_gateway/company_gateway_selec
import 'package:invoiceninja_flutter/ui/app/FieldGrid.dart';
import 'package:invoiceninja_flutter/ui/app/entities/entity_list_tile.dart';
import 'package:invoiceninja_flutter/ui/app/entity_header.dart';
import 'package:invoiceninja_flutter/ui/app/icon_message.dart';
import 'package:invoiceninja_flutter/ui/app/lists/list_divider.dart';
import 'package:invoiceninja_flutter/ui/app/view_scaffold.dart';
import 'package:invoiceninja_flutter/ui/company_gateway/view/company_gateway_view_vm.dart';
@ -64,13 +65,13 @@ class _CompanyGatewayViewState extends State<CompanyGatewayView> {
isFilter: widget.isFilter,
entity: companyGateway,
onBackPressed: () => viewModel.onBackPressed(),
body: ListView(
children: <Widget>[
EntityHeader(
entity: companyGateway,
label: localization.processed,
value: formatNumber(processed, context)),
ListDivider(),
body: ListView(children: <Widget>[
EntityHeader(
entity: companyGateway,
label: localization.processed,
value: formatNumber(processed, context)),
ListDivider(),
if (companyGateway.gateway.supportsTokenBilling) ...[
EntitiesListTile(
isFilter: widget.isFilter,
entityType: EntityType.client,
@ -83,23 +84,23 @@ class _CompanyGatewayViewState extends State<CompanyGatewayView> {
companyGateway.id, state.clientState.map)
.present(localization.active, localization.archived),
),
ListDivider(),
EntitiesListTile(
isFilter: widget.isFilter,
entityType: EntityType.payment,
title: localization.payments,
onTap: () => viewEntitiesByType(
context: context,
entityType: EntityType.payment,
filterEntity: companyGateway),
subtitle: memoizedPaymentStatsForCompanyGateway(
companyGateway.id, state.paymentState.map)
.present(localization.active, localization.archived),
),
ListDivider(),
FieldGrid(fields),
],
),
ListDivider(),
EntitiesListTile(
isFilter: widget.isFilter,
entityType: EntityType.payment,
title: localization.payments,
onTap: () => viewEntitiesByType(
context: context,
entityType: EntityType.payment,
filterEntity: companyGateway),
subtitle: memoizedPaymentStatsForCompanyGateway(
companyGateway.id, state.paymentState.map)
.present(localization.active, localization.archived),
),
ListDivider(),
FieldGrid(fields),
]),
);
}
}