Merge branch 'develop'

This commit is contained in:
Hillel Coren 2024-01-30 18:21:49 +02:00
commit 423ec923c3
7 changed files with 41 additions and 29 deletions

View File

@ -501,6 +501,10 @@ abstract class PaymentEntity extends Object
bool get isOnline => companyGatewayId.isNotEmpty;
double get convertedExchangeRate => exchangeRate == 0 ? 1 : exchangeRate;
double get convertedAmount => completedAmount * convertedExchangeRate;
bool get isCompletedOrPartiallyRefunded => [
kPaymentStatusCompleted,
kPaymentStatusPartiallyRefunded

View File

@ -1,15 +1,12 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
import 'package:invoiceninja_flutter/data/models/client_model.dart';
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
import 'package:invoiceninja_flutter/ui/app/icon_text.dart';
import 'package:invoiceninja_flutter/utils/localization.dart';
import 'package:url_launcher/url_launcher.dart';
enum PortalLinkStyle {
icons,
buttons,
dropdown,
}
@ -30,9 +27,6 @@ class PortalLinks extends StatelessWidget {
@override
Widget build(BuildContext context) {
final store = StoreProvider.of<AppState>(context);
final state = store.state;
final prefState = state.prefState;
final localization = AppLocalization.of(context);
var viewLinkWithHash = viewLink;
@ -49,23 +43,7 @@ class PortalLinks extends StatelessWidget {
showToast(localization!.copiedToClipboard.replaceFirst(':value ', ''));
};
if (style == PortalLinkStyle.icons) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
IconButton(
onPressed: viewLinkPressed,
icon: Icon(Icons.open_in_new),
tooltip: prefState.enableTooltips ? localization!.viewPortal : '',
),
IconButton(
onPressed: copyLinkPressed,
icon: Icon(Icons.copy),
tooltip: prefState.enableTooltips ? localization!.copyLink : '',
),
],
);
} else if (style == PortalLinkStyle.dropdown) {
if (style == PortalLinkStyle.dropdown) {
return PopupMenuButton<String>(
itemBuilder: (BuildContext context) => [
PopupMenuItem(

View File

@ -393,7 +393,7 @@ class _ClientViewFullwidthState extends State<ClientViewFullwidth>
viewLink: contact.silentLink,
copyLink: contact.link,
client: client,
style: PortalLinkStyle.icons,
style: PortalLinkStyle.buttons,
),
SizedBox(height: 16),
] else

View File

@ -80,7 +80,7 @@ class PaymentEditVM {
onSavePressed: (BuildContext context) {
Debouncer.runOnComplete(() {
final payment = store.state.paymentUIState.editing!;
final localization = navigatorKey.localization;
final localization = navigatorKey.localization!;
final navigator = navigatorKey.currentState;
double amount = 0;
payment.invoices.forEach((invoice) => amount += invoice.amount);
@ -89,17 +89,28 @@ class PaymentEditVM {
showDialog<ErrorDialog>(
context: navigatorKey.currentContext!,
builder: (BuildContext context) {
return ErrorDialog(localization!.creditPaymentError);
return ErrorDialog(localization.creditPaymentError);
});
return null;
} else if (!state.company.enableApplyingPayments &&
payment.invoices.isEmpty &&
payment.credits.isEmpty) {
showDialog<ErrorDialog>(
context: navigatorKey.currentContext!,
builder: (BuildContext context) {
return ErrorDialog(
localization.pleaseSelectAnInvoiceOrCredit);
});
return null;
}
final Completer<PaymentEntity> completer = Completer<PaymentEntity>();
store.dispatch(
SavePaymentRequest(completer: completer, payment: payment));
return completer.future.then((savedPayment) {
showToast(payment.isNew
? localization!.createdPayment
: localization!.updatedPayment);
? localization.createdPayment
: localization.updatedPayment);
if (state.prefState.isMobile) {
store.dispatch(UpdateCurrentRoute(PaymentViewScreen.route));
if (payment.isNew) {

View File

@ -36,6 +36,7 @@ enum ProfitAndLossReportFields {
currency,
transaction_reference,
record_state,
converted_amount,
}
var memoizedProfitAndLossReport = memo9((
@ -179,6 +180,9 @@ ReportResult profitAndLossReport(
value = AppLocalization.of(navigatorKey.currentContext!)!
.lookup(payment.entityState);
break;
case ProfitAndLossReportFields.converted_amount:
value = payment.convertedAmount;
break;
}
if (!ReportResult.matchField(
@ -194,6 +198,9 @@ ReportResult profitAndLossReport(
row.add(payment.getReportEntityType());
} else if (value.runtimeType == bool) {
row.add(payment.getReportBool(value: value));
} else if (column == ProfitAndLossReportFields.converted_amount) {
row.add(payment.getReportDouble(
value: value, currencyId: userCompany.company.currencyId));
} else if (value.runtimeType == double || value.runtimeType == int) {
row.add(payment.getReportDouble(
value: value, currencyId: client.currencyId));
@ -286,6 +293,9 @@ ReportResult profitAndLossReport(
value = AppLocalization.of(navigatorKey.currentContext!)!
.lookup(expense.entityState);
break;
case ProfitAndLossReportFields.converted_amount:
value = expense.convertedAmount;
break;
}
if (!ReportResult.matchField(
@ -301,6 +311,9 @@ ReportResult profitAndLossReport(
row.add(expense.getReportEntityType());
} else if (value.runtimeType == bool) {
row.add(expense.getReportBool(value: value));
} else if (column == ProfitAndLossReportFields.converted_amount) {
row.add(expense.getReportDouble(
value: value, currencyId: userCompany.company.currencyId));
} else if (value.runtimeType == double || value.runtimeType == int) {
row.add(expense.getReportDouble(
value: value, currencyId: expense.currencyId));

View File

@ -299,7 +299,7 @@ class _VendorViewFullwidthState extends State<VendorViewFullwidth>
viewLink: contact.silentLink,
copyLink: contact.link,
client: null,
style: PortalLinkStyle.icons,
style: PortalLinkStyle.buttons,
),
SizedBox(height: 16),
] else

View File

@ -18,6 +18,8 @@ mixin LocalizationsProvider on LocaleCodeAware {
static final Map<String, Map<String, String>> _localizedValues = {
'en': {
// STARTER: lang key - do not remove comment
'please_select_an_invoice_or_credit':
'Please select an invoice or credit',
'mobile_version': 'Mobile Version',
'venmo': 'Venmo',
'mercado_pago': 'Mercado Pago',
@ -114273,6 +114275,10 @@ mixin LocalizationsProvider on LocaleCodeAware {
_localizedValues[localeCode]!['mobile_version'] ??
_localizedValues['en']!['mobile_version']!;
String get pleaseSelectAnInvoiceOrCredit =>
_localizedValues[localeCode]!['please_select_an_invoice_or_credit'] ??
_localizedValues['en']!['please_select_an_invoice_or_credit']!;
// STARTER: lang field - do not remove comment
String lookup(String? key) {