Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hillelcoren committed May 24, 2024
2 parents f961e97 + 5eb9c74 commit 42220ef
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 42 deletions.
25 changes: 10 additions & 15 deletions lib/data/models/invoice_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -923,10 +923,17 @@ abstract class InvoiceEntity extends Object
isSent &&
!isCancelledOrReversed) {
return true;
// Make sure past due/expired match even if the email bounced
} else if (status.id == kInvoiceStatusPastDue && isInvoice && isPastDue) {
}

if (status.id == kInvoiceStatusBounced && isInvoice && isBounced) {
return true;
} else if (status.id == kQuoteStatusBounced && isQuote && isBounced) {
return true;
} else if (status.id == kQuoteStatusExpired && isQuote && isPastDue) {
} else if (status.id == kCreditStatusBounced && isCredit && isBounced) {
return true;
} else if (status.id == kPurchaseOrderStatusBounced &&
isPurchaseOrder &&
isBounced) {
return true;
}
}
Expand Down Expand Up @@ -1353,18 +1360,6 @@ abstract class InvoiceEntity extends Object
return kRecurringInvoiceStatusPending;
}
} else {
if (isBounced) {
if (isInvoice) {
return kInvoiceStatusBounced;
} else if (isQuote) {
return kQuoteStatusBounced;
} else if (isCredit) {
return kCreditStatusBounced;
} else if (isPurchaseOrder) {
return kPurchaseOrderStatusBounced;
}
}

if (isPastDue) {
if (isInvoice) {
return kInvoiceStatusPastDue;
Expand Down
72 changes: 47 additions & 25 deletions lib/ui/app/entities/entity_status_chip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:invoiceninja_flutter/data/models/models.dart';
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
import 'package:invoiceninja_flutter/utils/colors.dart';
import 'package:invoiceninja_flutter/utils/localization.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';

class EntityStatusChip extends StatelessWidget {
const EntityStatusChip({
Expand All @@ -29,16 +30,17 @@ class EntityStatusChip extends StatelessWidget {
Widget build(BuildContext context) {
final store = StoreProvider.of<AppState>(context);
final state = store.state;
final localization = AppLocalization.of(context);
final localization = AppLocalization.of(context)!;
String? label = '';
Color? color;
bool isBounced = false;

if (showState && !entity!.isActive) {
if (entity!.isArchived) {
label = localization!.archived;
label = localization.archived;
color = Colors.orange;
} else if (entity!.isDeleted!) {
label = localization!.deleted;
label = localization.deleted;
color = state.prefState.colorThemeModel!.colorDanger;
}
} else {
Expand All @@ -55,6 +57,7 @@ class EntityStatusChip extends StatelessWidget {
label = kInvoiceStatuses[statusId];
color = InvoiceStatusColors(state.prefState.colorThemeModel)
.colors[statusId];
isBounced = invoice.isBounced;
break;
case EntityType.recurringInvoice:
final invoice = entity as InvoiceEntity;
Expand All @@ -69,18 +72,21 @@ class EntityStatusChip extends StatelessWidget {
label = kQuoteStatuses[statusId];
color = QuoteStatusColors(state.prefState.colorThemeModel)
.colors[statusId];
isBounced = quote.isBounced;
break;
case EntityType.credit:
final credit = entity as InvoiceEntity;
label = kCreditStatuses[credit.calculatedStatusId];
color = CreditStatusColors(state.prefState.colorThemeModel)
.colors[credit.calculatedStatusId];
isBounced = credit.isBounced;
break;
case EntityType.purchaseOrder:
final purchaseOrder = entity as InvoiceEntity;
label = kPurchaseOrderStatuses[purchaseOrder.calculatedStatusId];
color = PurchaseOrderStatusColors(state.prefState.colorThemeModel)
.colors[purchaseOrder.calculatedStatusId];
isBounced = purchaseOrder.isBounced;
break;
case EntityType.transaction:
final transaction = entity as TransactionEntity;
Expand Down Expand Up @@ -108,12 +114,12 @@ class EntityStatusChip extends StatelessWidget {
final task = entity as TaskEntity;
final status = state.taskStatusState.get(task.statusId);
label = task.isInvoiced
? localization!.invoiced
? localization.invoiced
: task.isRunning
? localization!.running
? localization.running
: status.name.isNotEmpty
? status.name
: localization!.logged;
: localization.logged;
color = task.isInvoiced
? state.prefState.colorThemeModel!.colorSuccess
: task.isRunning
Expand All @@ -127,7 +133,7 @@ class EntityStatusChip extends StatelessWidget {
return SizedBox();
}

label = localization!.lookup(label);
label = localization.lookup(label);

if (label.isEmpty) {
label = localization.logged;
Expand All @@ -136,25 +142,41 @@ class EntityStatusChip extends StatelessWidget {

return Padding(
padding: EdgeInsets.only(left: addGap ? 16 : 0),
child: DecoratedBox(
decoration: BoxDecoration(
color: color,
borderRadius: BorderRadius.all(Radius.circular(kBorderRadius)),
),
child: ConstrainedBox(
constraints: BoxConstraints(
minWidth: width ?? 100,
maxWidth: width ?? 200,
),
child: Padding(
padding: EdgeInsets.symmetric(vertical: 6, horizontal: 4),
child: Text(
label,
style: TextStyle(fontSize: 13, color: Colors.white),
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
child: Tooltip(
message: isBounced ? localization.emailBounced : '',
child: Stack(
alignment: Alignment.centerLeft,
children: [
DecoratedBox(
decoration: BoxDecoration(
color: color,
borderRadius: BorderRadius.all(Radius.circular(kBorderRadius)),
),
child: ConstrainedBox(
constraints: BoxConstraints(
minWidth: width ?? 100,
maxWidth: width ?? 200,
),
child: Padding(
padding: EdgeInsets.symmetric(vertical: 6, horizontal: 4),
child: Text(
label,
style: TextStyle(fontSize: 13, color: Colors.white),
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
),
),
),
),
),
if (isBounced)
Padding(
padding: const EdgeInsets.only(left: 4),
child: Icon(
MdiIcons.alertCircleOutline,
size: 16,
),
),
],
),
),
);
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/bank_account/bank_account_list_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ class BankAccountListItem extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(toTitleCase(bankAccount.type) +
(bankAccount.disabledUpstream
? ' • ${localization!.disabled}'
(bankAccount.isDisconnected
? ' • ${localization!.disconnected}'
: '')),
EntityStateLabel(bankAccount),
],
Expand Down
6 changes: 6 additions & 0 deletions lib/utils/i18n.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mixin LocalizationsProvider on LocaleCodeAware {
static final Map<String, Map<String, String>> _localizedValues = {
'en': {
// STARTER: lang key - do not remove comment
'disconnected': 'Disconnected',
'reconnect': 'Reconnect',
'e_invoice_settings': 'E-Invoice Settings',
'calculate': 'Calculate',
Expand Down Expand Up @@ -115510,6 +115511,11 @@ mixin LocalizationsProvider on LocaleCodeAware {
_localizedValues[localeCode]!['reconnect'] ??
_localizedValues['en']!['reconnect']!;

String get disconnected =>
_localizedValues[localeCode]!['disconnected'] ??
_localizedValues['en']!['disconnected']!;


// STARTER: lang field - do not remove comment

String lookup(String? key, {String? overrideLocaleCode}) {
Expand Down

0 comments on commit 42220ef

Please sign in to comment.