Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hillelcoren committed Jul 13, 2023
2 parents 70cf4ea + 75b5392 commit 86188a0
Show file tree
Hide file tree
Showing 15 changed files with 120 additions and 43 deletions.
20 changes: 20 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=

void main({bool isTesting = false}) async {
WidgetsFlutterBinding.ensureInitialized();
_registerErrorHandlers();

try {
SecurityContext.defaultContext.setTrustedCertificatesBytes(
Expand Down Expand Up @@ -277,3 +278,22 @@ Future<AppState> _initialState(bool isTesting) async {
currentRoute: browserRoute,
);
}

void _registerErrorHandlers() {
/*
// * Show some error UI if any uncaught exception happens
FlutterError.onError = (FlutterErrorDetails details) {
FlutterError.presentError(details);
//errorLogger.logError(details.exception, details.stack);
};
// * Handle errors from the underlying platform/OS
PlatformDispatcher.instance.onError = (Object error, StackTrace stack) {
//errorLogger.logError(error, stack);
return true;
};
*/

ErrorWidget.builder = (FlutterErrorDetails details) {
return Center(child: Text(details.toString()));
};
}
13 changes: 9 additions & 4 deletions lib/ui/app/invoice/invoice_item_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class InvoiceItemListTile extends StatelessWidget {

final store = StoreProvider.of<AppState>(context);
final state = store.state;
final company = state.company;
final client = state.clientState.get(invoice.clientId);
final precision =
state.staticState.currencyMap[client.currencyId]?.precision ?? 2;
Expand Down Expand Up @@ -80,25 +81,29 @@ class InvoiceItemListTile extends StatelessWidget {
}

final List<String> parts = [];
if (invoiceItem.customValue1.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.product1) &&
invoiceItem.customValue1.isNotEmpty) {
parts.add(formatCustomValue(
context: context,
field: CustomFieldType.product1,
value: invoiceItem.customValue1));
}
if (invoiceItem.customValue2.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.product2) &&
invoiceItem.customValue2.isNotEmpty) {
parts.add(formatCustomValue(
context: context,
field: CustomFieldType.product2,
value: invoiceItem.customValue2));
}
if (invoiceItem.customValue3.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.product3) &&
invoiceItem.customValue3.isNotEmpty) {
parts.add(formatCustomValue(
context: context,
field: CustomFieldType.product3,
value: invoiceItem.customValue3));
}
if (invoiceItem.customValue4.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.product4) &&
invoiceItem.customValue4.isNotEmpty) {
parts.add(formatCustomValue(
context: context,
field: CustomFieldType.product4,
Expand Down
7 changes: 6 additions & 1 deletion lib/ui/app/lists/activity_list_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';

// Package imports:
import 'package:flutter_redux/flutter_redux.dart';
import 'package:invoiceninja_flutter/constants.dart';

// Project imports:
import 'package:invoiceninja_flutter/data/models/entities.dart';
Expand Down Expand Up @@ -45,7 +46,11 @@ class ActivityListTile extends StatelessWidget {
final purchaseOrder =
state.purchaseOrderState.map[activity.purchaseOrderId];

String title = localization.lookup('activity_${activity.activityTypeId}');
String key = 'activity_${activity.activityTypeId}';
if (activity.activityTypeId == kActivityCreatePayment) {
key += payment.isOnline ? '_online' : '_manual';
}
String title = localization.lookup(key);
title = activity.getDescription(
title,
localization.system,
Expand Down
12 changes: 8 additions & 4 deletions lib/ui/client/view/client_view_overview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,32 @@ class ClientOverview extends StatelessWidget {
statics.currencyMap[client.currencyId]?.name;
}

if (client.customValue1.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.client1) &&
client.customValue1.isNotEmpty) {
final label1 = company.getCustomFieldLabel(CustomFieldType.client1);
fields[label1] = formatCustomValue(
context: context,
field: CustomFieldType.client1,
value: client.customValue1);
}
if (client.customValue2.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.client2) &&
client.customValue2.isNotEmpty) {
final label2 = company.getCustomFieldLabel(CustomFieldType.client2);
fields[label2] = formatCustomValue(
context: context,
field: CustomFieldType.client2,
value: client.customValue2);
}
if (client.customValue3.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.client3) &&
client.customValue3.isNotEmpty) {
final label3 = company.getCustomFieldLabel(CustomFieldType.client3);
fields[label3] = formatCustomValue(
context: context,
field: CustomFieldType.client3,
value: client.customValue3);
}
if (client.customValue4.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.client4) &&
client.customValue4.isNotEmpty) {
final label4 = company.getCustomFieldLabel(CustomFieldType.client4);
fields[label4] = formatCustomValue(
context: context,
Expand Down
12 changes: 8 additions & 4 deletions lib/ui/expense/view/expense_view_overview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,32 @@ class ExpenseOverview extends StatelessWidget {
}

final fields = <String, String>{};
if (expense.customValue1.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.expense1) &&
expense.customValue1.isNotEmpty) {
final label1 = company.getCustomFieldLabel(CustomFieldType.expense1);
fields[label1] = formatCustomValue(
context: context,
field: CustomFieldType.expense1,
value: expense.customValue1);
}
if (expense.customValue2.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.expense2) &&
expense.customValue2.isNotEmpty) {
final label2 = company.getCustomFieldLabel(CustomFieldType.expense2);
fields[label2] = formatCustomValue(
context: context,
field: CustomFieldType.expense2,
value: expense.customValue2);
}
if (expense.customValue3.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.expense3) &&
expense.customValue3.isNotEmpty) {
final label3 = company.getCustomFieldLabel(CustomFieldType.expense3);
fields[label3] = formatCustomValue(
context: context,
field: CustomFieldType.expense3,
value: expense.customValue3);
}
if (expense.customValue4.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.expense4) &&
expense.customValue4.isNotEmpty) {
final label4 = company.getCustomFieldLabel(CustomFieldType.expense4);
fields[label4] = formatCustomValue(
context: context,
Expand Down
12 changes: 8 additions & 4 deletions lib/ui/invoice/view/invoice_view_overview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,28 +210,32 @@ class InvoiceOverview extends StatelessWidget {
}
};

if (invoice.customValue1.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.invoice1) &&
invoice.customValue1.isNotEmpty) {
final label1 = company.getCustomFieldLabel(CustomFieldType.invoice1);
fields[label1] = formatCustomValue(
context: context,
field: CustomFieldType.invoice1,
value: invoice.customValue1);
}
if (invoice.customValue2.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.invoice2) &&
invoice.customValue2.isNotEmpty) {
final label2 = company.getCustomFieldLabel(CustomFieldType.invoice2);
fields[label2] = formatCustomValue(
context: context,
field: CustomFieldType.invoice2,
value: invoice.customValue2);
}
if (invoice.customValue3.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.invoice3) &&
invoice.customValue3.isNotEmpty) {
final label3 = company.getCustomFieldLabel(CustomFieldType.invoice3);
fields[label3] = formatCustomValue(
context: context,
field: CustomFieldType.invoice3,
value: invoice.customValue3);
}
if (invoice.customValue4.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.invoice4) &&
invoice.customValue4.isNotEmpty) {
final label4 = company.getCustomFieldLabel(CustomFieldType.invoice4);
fields[label4] = formatCustomValue(
context: context,
Expand Down
12 changes: 8 additions & 4 deletions lib/ui/product/view/product_view_overview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,35 @@ class _ProductOverviewState extends State<ProductOverview> {
localization.lookup(kTaxCategories[product.taxCategoryId]);
}

if (product.customValue1.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.product1) &&
product.customValue1.isNotEmpty) {
final label1 = company.getCustomFieldLabel(CustomFieldType.product1);
fields[label1] = formatCustomValue(
context: context,
field: CustomFieldType.product1,
value: product.customValue1);
}

if (product.customValue2.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.product2) &&
product.customValue2.isNotEmpty) {
final label2 = company.getCustomFieldLabel(CustomFieldType.product2);
fields[label2] = formatCustomValue(
context: context,
field: CustomFieldType.product2,
value: product.customValue2);
}

if (product.customValue3.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.product3) &&
product.customValue3.isNotEmpty) {
final label3 = company.getCustomFieldLabel(CustomFieldType.product3);
fields[label3] = formatCustomValue(
context: context,
field: CustomFieldType.product3,
value: product.customValue3);
}

if (product.customValue4.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.product4) &&
product.customValue4.isNotEmpty) {
final label4 = company.getCustomFieldLabel(CustomFieldType.product4);
fields[label4] = formatCustomValue(
context: context,
Expand Down
12 changes: 8 additions & 4 deletions lib/ui/project/view/project_view_overview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,32 @@ class _ProjectOverviewState extends State<ProjectOverview> {
formatNumberType: FormatNumberType.money, clientId: project.clientId),
};

if (project.customValue1.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.project1) &&
project.customValue1.isNotEmpty) {
final label1 = company.getCustomFieldLabel(CustomFieldType.project1);
fields[label1] = formatCustomValue(
context: context,
field: CustomFieldType.project1,
value: project.customValue1);
}
if (project.customValue2.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.project2) &&
project.customValue2.isNotEmpty) {
final label2 = company.getCustomFieldLabel(CustomFieldType.project2);
fields[label2] = formatCustomValue(
context: context,
field: CustomFieldType.project2,
value: project.customValue2);
}
if (project.customValue3.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.project3) &&
project.customValue3.isNotEmpty) {
final label3 = company.getCustomFieldLabel(CustomFieldType.project3);
fields[label3] = formatCustomValue(
context: context,
field: CustomFieldType.project3,
value: project.customValue3);
}
if (project.customValue2.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.project4) &&
project.customValue2.isNotEmpty) {
final label4 = company.getCustomFieldLabel(CustomFieldType.project4);
fields[label4] = formatCustomValue(
context: context,
Expand Down
9 changes: 6 additions & 3 deletions lib/ui/reports/credit_item_report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,12 @@ ReportResult lineItemReport(
break;
case CreditItemReportFields.profit:
case CreditItemReportFields.markup:
final cost = productId == null
? 0.0
: (productMap[productId].cost * lineItem.quantity);
var cost = 0.0;
if (lineItem.productCost != 0) {
cost = lineItem.productCost;
} else {
cost = productId == null ? 0.0 : productMap[productId].cost;
}
value = lineItem.netTotal(credit, precision) - cost;
if (column == CreditItemReportFields.markup && cost != 0) {
value = '${round(value / cost * 100, 2)}%';
Expand Down
9 changes: 6 additions & 3 deletions lib/ui/reports/invoice_item_report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,12 @@ ReportResult lineItemReport(
break;
case InvoiceItemReportFields.profit:
case InvoiceItemReportFields.markup:
final cost = productId == null
? 0.0
: (productMap[productId].cost * lineItem.quantity);
var cost = 0.0;
if (lineItem.productCost != 0) {
cost = lineItem.productCost;
} else {
cost = productId == null ? 0.0 : productMap[productId].cost;
}
value = lineItem.netTotal(invoice, precision) - cost;
if (column == InvoiceItemReportFields.markup && cost != 0) {
value = '${round(value / cost * 100, 2)}%';
Expand Down
9 changes: 6 additions & 3 deletions lib/ui/reports/quote_item_report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,12 @@ ReportResult lineItemReport(
break;
case QuoteItemReportFields.profit:
case QuoteItemReportFields.markup:
final cost = productId == null
? 0.0
: (productMap[productId].cost * lineItem.quantity);
var cost = 0.0;
if (lineItem.productCost != 0) {
cost = lineItem.productCost;
} else {
cost = productId == null ? 0.0 : productMap[productId].cost;
}
value = lineItem.netTotal(invoice, precision) - cost;
if (column == QuoteItemReportFields.markup && cost != 0) {
value = '${round(value / cost * 100, 2)}%';
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/settings/payment_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class _PaymentSettingsState extends State<PaymentSettings> {
entityType: EntityType.paymentType,
entityList:
memoizedPaymentTypeList(state.staticState.paymentTypeMap),
labelText: localization.paymentType,
labelText: localization.defaultPaymentType,
entityId: settings.defaultPaymentTypeId,
onSelected: (paymentType) => viewModel.onSettingsChanged(
settings.rebuild(
Expand Down
13 changes: 9 additions & 4 deletions lib/ui/task/view/task_view_overview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,35 @@ class _TaskOverviewState extends State<TaskOverview> {
company.taskStatusMap[task.statusId]?.name ?? '';
}

if (task.customValue1.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.task1) &&
task.customValue1.isNotEmpty) {
final label1 = company.getCustomFieldLabel(CustomFieldType.task1);
fields[label1] = formatCustomValue(
context: context,
field: CustomFieldType.task1,
value: task.customValue1);
}
if (task.customValue2.isNotEmpty) {

if (company.hasCustomField(CustomFieldType.task2) &&
task.customValue2.isNotEmpty) {
final label2 = company.getCustomFieldLabel(CustomFieldType.task2);
fields[label2] = formatCustomValue(
context: context,
field: CustomFieldType.task2,
value: task.customValue2);
}

if (task.customValue3.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.task3) &&
task.customValue3.isNotEmpty) {
final label3 = company.getCustomFieldLabel(CustomFieldType.task3);
fields[label3] = formatCustomValue(
context: context,
field: CustomFieldType.task3,
value: task.customValue3);
}

if (task.customValue4.isNotEmpty) {
if (company.hasCustomField(CustomFieldType.task4) &&
task.customValue4.isNotEmpty) {
final label4 = company.getCustomFieldLabel(CustomFieldType.task4);
fields[label4] = formatCustomValue(
context: context,
Expand Down
Loading

0 comments on commit 86188a0

Please sign in to comment.