Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:invoiceninja/flutter-client into…
Browse files Browse the repository at this point in the history
… develop
  • Loading branch information
hillelcoren committed Jan 23, 2024
2 parents 9d238ba + 414a7ff commit 17a82c1
Show file tree
Hide file tree
Showing 14 changed files with 236 additions and 57 deletions.
36 changes: 36 additions & 0 deletions lib/constants.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:invoiceninja_flutter/data/models/import_model.dart';

class Constants {
//static String get hostedApiUrl => kReleaseMode ? kAppProductionUrl : kAppStagingUrl;
static String get hostedApiUrl => kAppProductionUrl;
Expand Down Expand Up @@ -410,6 +412,10 @@ const String kGatewayTypeInstantBankPay = '21';
const String kGatewayTypeFPX = '22';
const String kGatewayTypeKlarna = '23';
const String kGatewayTypeBacs = '24';
const String kGatewayTypeVenmo = '25';
const String kGatewayTypeMercadoPago = '26';
const String kGatewayTypeMyBank = '27';
const String kGatewayTypePayLater = '28';

const kGatewayTypes = {
kGatewayTypeCreditCard: 'credit_card',
Expand All @@ -436,6 +442,10 @@ const kGatewayTypes = {
kGatewayTypeFPX: 'fpx',
kGatewayTypeKlarna: 'klarna',
kGatewayTypeBacs: 'bacs',
kGatewayTypeVenmo: 'venmo',
kGatewayTypeMercadoPago: 'mercado_pago',
kGatewayTypeMyBank: 'my_bank',
kGatewayTypePayLater: 'pay_later',
};

const String kNotificationChannelEmail = 'email';
Expand Down Expand Up @@ -674,6 +684,32 @@ const String kReportPurchaseOrderItem = 'purchase_order_item';
const String kReportVendor = 'vendor';
const String kReportTransaction = 'transaction';

final kReportMap = {
kReportClient: ExportType.clients,
kReportClientContact: ExportType.client_contacts,
kReportCredit: ExportType.credits,
kReportCreditItem: null,
kReportDocument: ExportType.documents,
kReportExpense: ExportType.expenses,
kReportInvoice: ExportType.invoices,
kReportPayment: ExportType.payments,
kReportProduct: ExportType.products,
kReportProfitAndLoss: ExportType.profitloss,
kReportTask: ExportType.tasks,
kReportTaskItem: null,
kReportInvoiceTax: ExportType.tax_summary,
kReportPaymentTax: null,
kReportQuote: ExportType.quotes,
kReportInvoiceItem: ExportType.invoice_items,
kReportQuoteItem: ExportType.quote_items,
kReportRecurringExpense: null,
kReportRecurringInvoice: ExportType.recurring_invoices,
kReportPurchaseOrder: null,
kReportPurchaseOrderItem: null,
kReportVendor: null,
kReportTransaction: null,
};

const String kPdfFieldsClientDetails = 'client_details';
const String kPdfFieldsCompanyDetails = 'company_details';
const String kPdfFieldsCompanyAddress = 'company_address';
Expand Down
9 changes: 8 additions & 1 deletion lib/data/models/schedule_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:built_collection/built_collection.dart';
import 'package:built_value/serializer.dart';
import 'package:invoiceninja_flutter/constants.dart';
import 'package:invoiceninja_flutter/data/models/dashboard_model.dart';
import 'package:invoiceninja_flutter/data/models/import_model.dart';
import 'package:invoiceninja_flutter/main_app.dart';
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
import 'package:invoiceninja_flutter/data/models/models.dart';
Expand Down Expand Up @@ -84,8 +85,8 @@ abstract class ScheduleEntity extends Object

static const TEMPLATES = [
TEMPLATE_EMAIL_STATEMENT,
TEMPLATE_EMAIL_RECORD,
TEMPLATE_EMAIL_REPORT,
TEMPLATE_EMAIL_RECORD,
];

@override
Expand Down Expand Up @@ -218,6 +219,9 @@ abstract class ScheduleParameters
? EntityType.invoice.toString()
: null,
entityId: action == ScheduleEntity.TEMPLATE_EMAIL_RECORD ? '' : null,
reportName: action == ScheduleEntity.TEMPLATE_EMAIL_REPORT
? ExportType.invoices.name
: null,
);
}

Expand Down Expand Up @@ -252,6 +256,9 @@ abstract class ScheduleParameters
@BuiltValueField(wireName: 'entity_id')
String? get entityId;

@BuiltValueField(wireName: 'report_name')
String? get reportName;

static Serializer<ScheduleParameters> get serializer =>
_$scheduleParametersSerializer;
}
31 changes: 27 additions & 4 deletions lib/data/models/schedule_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/ui/app/presenters/entity_presenter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class EntityPresenter {
isNarrow) {
return name;
} else {
return '$type $name';
return '$type: $name';
}
}

Expand Down
4 changes: 4 additions & 0 deletions lib/ui/reports/expense_report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ enum ExpenseReportFields {
converted_amount,
status,
record_state,
is_invoiced,
}

var memoizedExpenseReport = memo10((
Expand Down Expand Up @@ -284,6 +285,9 @@ ReportResult expenseReport(
value = AppLocalization.of(navigatorKey.currentContext!)!
.lookup(expense.entityState);
break;
case ExpenseReportFields.is_invoiced:
value = expense.isInvoiced;
break;
}

if (!ReportResult.matchField(
Expand Down
16 changes: 16 additions & 0 deletions lib/ui/reports/reports_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,13 @@ class ReportsScreen extends StatelessWidget {
viewModel.onExportPressed(context);
},
),
AppTextButton(
label: localization.schedule,
isInHeader: true,
onPressed: () {
viewModel.onSchedulePressed(context);
},
),
],
Padding(
padding: const EdgeInsets.only(right: 8),
Expand Down Expand Up @@ -538,6 +545,15 @@ class ReportsScreen extends StatelessWidget {
},
),
),
SizedBox(width: kGutterWidth),
Expanded(
child: AppButton(
label: localization.schedule,
onPressed: () {
viewModel.onSchedulePressed(context);
},
),
),
],
),
),
Expand Down
12 changes: 12 additions & 0 deletions lib/ui/reports/reports_screen_vm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import 'package:flutter/widgets.dart';
import 'package:built_collection/built_collection.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
import 'package:invoiceninja_flutter/data/models/import_model.dart';
import 'package:invoiceninja_flutter/data/models/schedule_model.dart';
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
import 'package:invoiceninja_flutter/ui/reports/credit_item_report.dart';
import 'package:invoiceninja_flutter/ui/reports/purchase_order_item_report.dart';
import 'package:invoiceninja_flutter/ui/reports/purchase_order_report.dart';
Expand Down Expand Up @@ -81,6 +84,7 @@ class ReportsScreenVM {
required this.onReportColumnsChanged,
required this.onReportFiltersChanged,
required this.onExportPressed,
required this.onSchedulePressed,
required this.onReportSorted,
required this.groupTotals,
required this.reportResult,
Expand All @@ -94,6 +98,7 @@ class ReportsScreenVM {
final GroupTotals groupTotals;
final Function(BuildContext, List<String>) onReportColumnsChanged;
final Function(BuildContext) onExportPressed;
final Function(BuildContext) onSchedulePressed;
final Function(BuildContext, BuiltMap<String?, String?>)
onReportFiltersChanged;
final Function(String?, bool) onReportSorted;
Expand Down Expand Up @@ -457,6 +462,13 @@ class ReportsScreenVM {
));
});
},
onSchedulePressed: (context) async {
createEntity(
entity: ScheduleEntity(ScheduleEntity.TEMPLATE_EMAIL_REPORT)
.rebuild((b) => b
..parameters.reportName =
kReportMap[report]?.name ?? ExportType.invoices.name));
},
onExportPressed: (context) async {
final localization = AppLocalization.of(context);
final reportState = state.uiState.reportsUIState;
Expand Down
44 changes: 43 additions & 1 deletion lib/ui/schedule/edit/schedule_edit.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:invoiceninja_flutter/constants.dart';
import 'package:invoiceninja_flutter/data/models/dashboard_model.dart';
import 'package:invoiceninja_flutter/data/models/import_model.dart';
import 'package:invoiceninja_flutter/data/models/models.dart';
import 'package:invoiceninja_flutter/redux/credit/credit_selectors.dart';
import 'package:invoiceninja_flutter/redux/invoice/invoice_selectors.dart';
Expand Down Expand Up @@ -232,7 +233,47 @@ class _ScheduleEditState extends State<ScheduleEdit> {
),
if (schedule.template ==
ScheduleEntity.TEMPLATE_EMAIL_REPORT) ...[
//
FormCard(
isLast: true,
children: [
AppDropdownButton<String>(
value: schedule.parameters.reportName,
labelText: localization.report,
onChanged: (dynamic value) {
setState(() {
viewModel.onChanged(schedule.rebuild(
(b) => b..parameters.reportName = value));
});
},
items: ExportType.values
.map((importType) => DropdownMenuItem<String>(
value: importType.name,
child:
Text(localization.lookup('$importType'))))
.toList()),
AppDropdownButton<DateRange>(
labelText: localization.dateRange,
blankValue: null,
value: parameters.dateRange!.isNotEmpty
? DateRange.valueOf(
toCamelCase(parameters.dateRange!))
: null,
onChanged: (dynamic value) {
viewModel.onChanged(schedule.rebuild((b) => b
..parameters.dateRange =
(value as DateRange).snakeCase));
},
items: DateRange.values
.where((value) => value != DateRange.custom)
.map((dateRange) => DropdownMenuItem<DateRange>(
child: Text(localization
.lookup(dateRange.toString())),
value: dateRange,
))
.toList(),
),
],
),
] else if (schedule.template ==
ScheduleEntity.TEMPLATE_EMAIL_STATEMENT) ...[
FormCard(children: [
Expand Down Expand Up @@ -342,6 +383,7 @@ class _ScheduleEditState extends State<ScheduleEdit> {
] else if (schedule.template ==
ScheduleEntity.TEMPLATE_EMAIL_RECORD) ...[
FormCard(
isLast: true,
children: [
AppDropdownButton<String>(
labelText: localization.type,
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/schedule/schedule_list_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class ScheduleListItem extends StatelessWidget {
}
subtitle +=
' • ' + localization.lookup(kFrequencies[schedule.frequencyId]);
} else if (schedule.template == ScheduleEntity.TEMPLATE_EMAIL_REPORT) {
title += ': ' + localization.lookup(schedule.parameters.reportName);
}

return DismissibleEntity(
Expand Down
Loading

0 comments on commit 17a82c1

Please sign in to comment.