Skip to content

Commit 423ec92

Browse files
committed
Merge branch 'develop'
2 parents eafe0d6 + 900ddf5 commit 423ec92

File tree

7 files changed

+41
-29
lines changed

7 files changed

+41
-29
lines changed

lib/data/models/payment_model.dart

+4
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,10 @@ abstract class PaymentEntity extends Object
501501

502502
bool get isOnline => companyGatewayId.isNotEmpty;
503503

504+
double get convertedExchangeRate => exchangeRate == 0 ? 1 : exchangeRate;
505+
506+
double get convertedAmount => completedAmount * convertedExchangeRate;
507+
504508
bool get isCompletedOrPartiallyRefunded => [
505509
kPaymentStatusCompleted,
506510
kPaymentStatusPartiallyRefunded

lib/ui/app/portal_links.dart

+1-23
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter/services.dart';
3-
import 'package:flutter_redux/flutter_redux.dart';
43
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
54
import 'package:invoiceninja_flutter/data/models/client_model.dart';
6-
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
75
import 'package:invoiceninja_flutter/ui/app/icon_text.dart';
86
import 'package:invoiceninja_flutter/utils/localization.dart';
97
import 'package:url_launcher/url_launcher.dart';
108

119
enum PortalLinkStyle {
12-
icons,
1310
buttons,
1411
dropdown,
1512
}
@@ -30,9 +27,6 @@ class PortalLinks extends StatelessWidget {
3027

3128
@override
3229
Widget build(BuildContext context) {
33-
final store = StoreProvider.of<AppState>(context);
34-
final state = store.state;
35-
final prefState = state.prefState;
3630
final localization = AppLocalization.of(context);
3731

3832
var viewLinkWithHash = viewLink;
@@ -49,23 +43,7 @@ class PortalLinks extends StatelessWidget {
4943
showToast(localization!.copiedToClipboard.replaceFirst(':value ', ''));
5044
};
5145

52-
if (style == PortalLinkStyle.icons) {
53-
return Row(
54-
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
55-
children: [
56-
IconButton(
57-
onPressed: viewLinkPressed,
58-
icon: Icon(Icons.open_in_new),
59-
tooltip: prefState.enableTooltips ? localization!.viewPortal : '',
60-
),
61-
IconButton(
62-
onPressed: copyLinkPressed,
63-
icon: Icon(Icons.copy),
64-
tooltip: prefState.enableTooltips ? localization!.copyLink : '',
65-
),
66-
],
67-
);
68-
} else if (style == PortalLinkStyle.dropdown) {
46+
if (style == PortalLinkStyle.dropdown) {
6947
return PopupMenuButton<String>(
7048
itemBuilder: (BuildContext context) => [
7149
PopupMenuItem(

lib/ui/client/view/client_view_fullwidth.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ class _ClientViewFullwidthState extends State<ClientViewFullwidth>
393393
viewLink: contact.silentLink,
394394
copyLink: contact.link,
395395
client: client,
396-
style: PortalLinkStyle.icons,
396+
style: PortalLinkStyle.buttons,
397397
),
398398
SizedBox(height: 16),
399399
] else

lib/ui/payment/edit/payment_edit_vm.dart

+15-4
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class PaymentEditVM {
8080
onSavePressed: (BuildContext context) {
8181
Debouncer.runOnComplete(() {
8282
final payment = store.state.paymentUIState.editing!;
83-
final localization = navigatorKey.localization;
83+
final localization = navigatorKey.localization!;
8484
final navigator = navigatorKey.currentState;
8585
double amount = 0;
8686
payment.invoices.forEach((invoice) => amount += invoice.amount);
@@ -89,17 +89,28 @@ class PaymentEditVM {
8989
showDialog<ErrorDialog>(
9090
context: navigatorKey.currentContext!,
9191
builder: (BuildContext context) {
92-
return ErrorDialog(localization!.creditPaymentError);
92+
return ErrorDialog(localization.creditPaymentError);
93+
});
94+
return null;
95+
} else if (!state.company.enableApplyingPayments &&
96+
payment.invoices.isEmpty &&
97+
payment.credits.isEmpty) {
98+
showDialog<ErrorDialog>(
99+
context: navigatorKey.currentContext!,
100+
builder: (BuildContext context) {
101+
return ErrorDialog(
102+
localization.pleaseSelectAnInvoiceOrCredit);
93103
});
94104
return null;
95105
}
106+
96107
final Completer<PaymentEntity> completer = Completer<PaymentEntity>();
97108
store.dispatch(
98109
SavePaymentRequest(completer: completer, payment: payment));
99110
return completer.future.then((savedPayment) {
100111
showToast(payment.isNew
101-
? localization!.createdPayment
102-
: localization!.updatedPayment);
112+
? localization.createdPayment
113+
: localization.updatedPayment);
103114
if (state.prefState.isMobile) {
104115
store.dispatch(UpdateCurrentRoute(PaymentViewScreen.route));
105116
if (payment.isNew) {

lib/ui/reports/profit_loss_report.dart

+13
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ enum ProfitAndLossReportFields {
3636
currency,
3737
transaction_reference,
3838
record_state,
39+
converted_amount,
3940
}
4041

4142
var memoizedProfitAndLossReport = memo9((
@@ -179,6 +180,9 @@ ReportResult profitAndLossReport(
179180
value = AppLocalization.of(navigatorKey.currentContext!)!
180181
.lookup(payment.entityState);
181182
break;
183+
case ProfitAndLossReportFields.converted_amount:
184+
value = payment.convertedAmount;
185+
break;
182186
}
183187

184188
if (!ReportResult.matchField(
@@ -194,6 +198,9 @@ ReportResult profitAndLossReport(
194198
row.add(payment.getReportEntityType());
195199
} else if (value.runtimeType == bool) {
196200
row.add(payment.getReportBool(value: value));
201+
} else if (column == ProfitAndLossReportFields.converted_amount) {
202+
row.add(payment.getReportDouble(
203+
value: value, currencyId: userCompany.company.currencyId));
197204
} else if (value.runtimeType == double || value.runtimeType == int) {
198205
row.add(payment.getReportDouble(
199206
value: value, currencyId: client.currencyId));
@@ -286,6 +293,9 @@ ReportResult profitAndLossReport(
286293
value = AppLocalization.of(navigatorKey.currentContext!)!
287294
.lookup(expense.entityState);
288295
break;
296+
case ProfitAndLossReportFields.converted_amount:
297+
value = expense.convertedAmount;
298+
break;
289299
}
290300

291301
if (!ReportResult.matchField(
@@ -301,6 +311,9 @@ ReportResult profitAndLossReport(
301311
row.add(expense.getReportEntityType());
302312
} else if (value.runtimeType == bool) {
303313
row.add(expense.getReportBool(value: value));
314+
} else if (column == ProfitAndLossReportFields.converted_amount) {
315+
row.add(expense.getReportDouble(
316+
value: value, currencyId: userCompany.company.currencyId));
304317
} else if (value.runtimeType == double || value.runtimeType == int) {
305318
row.add(expense.getReportDouble(
306319
value: value, currencyId: expense.currencyId));

lib/ui/vendor/view/vendor_view_fullwidth.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ class _VendorViewFullwidthState extends State<VendorViewFullwidth>
299299
viewLink: contact.silentLink,
300300
copyLink: contact.link,
301301
client: null,
302-
style: PortalLinkStyle.icons,
302+
style: PortalLinkStyle.buttons,
303303
),
304304
SizedBox(height: 16),
305305
] else

lib/utils/i18n.dart

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ mixin LocalizationsProvider on LocaleCodeAware {
1818
static final Map<String, Map<String, String>> _localizedValues = {
1919
'en': {
2020
// STARTER: lang key - do not remove comment
21+
'please_select_an_invoice_or_credit':
22+
'Please select an invoice or credit',
2123
'mobile_version': 'Mobile Version',
2224
'venmo': 'Venmo',
2325
'mercado_pago': 'Mercado Pago',
@@ -114273,6 +114275,10 @@ mixin LocalizationsProvider on LocaleCodeAware {
114273114275
_localizedValues[localeCode]!['mobile_version'] ??
114274114276
_localizedValues['en']!['mobile_version']!;
114275114277

114278+
String get pleaseSelectAnInvoiceOrCredit =>
114279+
_localizedValues[localeCode]!['please_select_an_invoice_or_credit'] ??
114280+
_localizedValues['en']!['please_select_an_invoice_or_credit']!;
114281+
114276114282
// STARTER: lang field - do not remove comment
114277114283

114278114284
String lookup(String? key) {

0 commit comments

Comments
 (0)