Schedule reports

This commit is contained in:
Hillel Coren 2024-01-22 12:47:10 +02:00
parent 96b41d217c
commit c11754b099
3 changed files with 57 additions and 6 deletions

View File

@ -3,6 +3,7 @@ import 'package:built_collection/built_collection.dart';
import 'package:built_value/serializer.dart'; import 'package:built_value/serializer.dart';
import 'package:invoiceninja_flutter/constants.dart'; import 'package:invoiceninja_flutter/constants.dart';
import 'package:invoiceninja_flutter/data/models/dashboard_model.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/main_app.dart';
import 'package:invoiceninja_flutter/redux/app/app_state.dart'; import 'package:invoiceninja_flutter/redux/app/app_state.dart';
import 'package:invoiceninja_flutter/data/models/models.dart'; import 'package:invoiceninja_flutter/data/models/models.dart';
@ -84,8 +85,8 @@ abstract class ScheduleEntity extends Object
static const TEMPLATES = [ static const TEMPLATES = [
TEMPLATE_EMAIL_STATEMENT, TEMPLATE_EMAIL_STATEMENT,
TEMPLATE_EMAIL_RECORD,
TEMPLATE_EMAIL_REPORT, TEMPLATE_EMAIL_REPORT,
TEMPLATE_EMAIL_RECORD,
]; ];
@override @override
@ -218,6 +219,9 @@ abstract class ScheduleParameters
? EntityType.invoice.toString() ? EntityType.invoice.toString()
: null, : null,
entityId: action == ScheduleEntity.TEMPLATE_EMAIL_RECORD ? '' : null, entityId: action == ScheduleEntity.TEMPLATE_EMAIL_RECORD ? '' : null,
reportName: action == ScheduleEntity.TEMPLATE_EMAIL_REPORT
? ExportType.invoices.name
: null,
); );
} }
@ -252,6 +256,9 @@ abstract class ScheduleParameters
@BuiltValueField(wireName: 'entity_id') @BuiltValueField(wireName: 'entity_id')
String? get entityId; String? get entityId;
@BuiltValueField(wireName: 'report_name')
String? get reportName;
static Serializer<ScheduleParameters> get serializer => static Serializer<ScheduleParameters> get serializer =>
_$scheduleParametersSerializer; _$scheduleParametersSerializer;
} }

View File

@ -337,6 +337,13 @@ class _$ScheduleParametersSerializer
..add(serializers.serialize(value, ..add(serializers.serialize(value,
specifiedType: const FullType(String))); specifiedType: const FullType(String)));
} }
value = object.reportName;
if (value != null) {
result
..add('report_name')
..add(serializers.serialize(value,
specifiedType: const FullType(String)));
}
return result; return result;
} }
@ -390,6 +397,10 @@ class _$ScheduleParametersSerializer
result.entityId = serializers.deserialize(value, result.entityId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String?; specifiedType: const FullType(String)) as String?;
break; break;
case 'report_name':
result.reportName = serializers.deserialize(value,
specifiedType: const FullType(String)) as String?;
break;
} }
} }
@ -904,6 +915,8 @@ class _$ScheduleParameters extends ScheduleParameters {
final String? entityType; final String? entityType;
@override @override
final String? entityId; final String? entityId;
@override
final String? reportName;
factory _$ScheduleParameters( factory _$ScheduleParameters(
[void Function(ScheduleParametersBuilder)? updates]) => [void Function(ScheduleParametersBuilder)? updates]) =>
@ -918,7 +931,8 @@ class _$ScheduleParameters extends ScheduleParameters {
this.status, this.status,
this.clients, this.clients,
this.entityType, this.entityType,
this.entityId}) this.entityId,
this.reportName})
: super._(); : super._();
@override @override
@ -942,7 +956,8 @@ class _$ScheduleParameters extends ScheduleParameters {
status == other.status && status == other.status &&
clients == other.clients && clients == other.clients &&
entityType == other.entityType && entityType == other.entityType &&
entityId == other.entityId; entityId == other.entityId &&
reportName == other.reportName;
} }
int? __hashCode; int? __hashCode;
@ -959,6 +974,7 @@ class _$ScheduleParameters extends ScheduleParameters {
_$hash = $jc(_$hash, clients.hashCode); _$hash = $jc(_$hash, clients.hashCode);
_$hash = $jc(_$hash, entityType.hashCode); _$hash = $jc(_$hash, entityType.hashCode);
_$hash = $jc(_$hash, entityId.hashCode); _$hash = $jc(_$hash, entityId.hashCode);
_$hash = $jc(_$hash, reportName.hashCode);
_$hash = $jf(_$hash); _$hash = $jf(_$hash);
return __hashCode ??= _$hash; return __hashCode ??= _$hash;
} }
@ -974,7 +990,8 @@ class _$ScheduleParameters extends ScheduleParameters {
..add('status', status) ..add('status', status)
..add('clients', clients) ..add('clients', clients)
..add('entityType', entityType) ..add('entityType', entityType)
..add('entityId', entityId)) ..add('entityId', entityId)
..add('reportName', reportName))
.toString(); .toString();
} }
} }
@ -1024,6 +1041,10 @@ class ScheduleParametersBuilder
String? get entityId => _$this._entityId; String? get entityId => _$this._entityId;
set entityId(String? entityId) => _$this._entityId = entityId; set entityId(String? entityId) => _$this._entityId = entityId;
String? _reportName;
String? get reportName => _$this._reportName;
set reportName(String? reportName) => _$this._reportName = reportName;
ScheduleParametersBuilder(); ScheduleParametersBuilder();
ScheduleParametersBuilder get _$this { ScheduleParametersBuilder get _$this {
@ -1038,6 +1059,7 @@ class ScheduleParametersBuilder
_clients = $v.clients?.toBuilder(); _clients = $v.clients?.toBuilder();
_entityType = $v.entityType; _entityType = $v.entityType;
_entityId = $v.entityId; _entityId = $v.entityId;
_reportName = $v.reportName;
_$v = null; _$v = null;
} }
return this; return this;
@ -1070,7 +1092,8 @@ class ScheduleParametersBuilder
status: status, status: status,
clients: _clients?.build(), clients: _clients?.build(),
entityType: entityType, entityType: entityType,
entityId: entityId); entityId: entityId,
reportName: reportName);
} catch (_) { } catch (_) {
late String _$failedField; late String _$failedField;
try { try {

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:invoiceninja_flutter/constants.dart'; import 'package:invoiceninja_flutter/constants.dart';
import 'package:invoiceninja_flutter/data/models/dashboard_model.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/data/models/models.dart';
import 'package:invoiceninja_flutter/redux/credit/credit_selectors.dart'; import 'package:invoiceninja_flutter/redux/credit/credit_selectors.dart';
import 'package:invoiceninja_flutter/redux/invoice/invoice_selectors.dart'; import 'package:invoiceninja_flutter/redux/invoice/invoice_selectors.dart';
@ -232,7 +233,26 @@ class _ScheduleEditState extends State<ScheduleEdit> {
), ),
if (schedule.template == if (schedule.template ==
ScheduleEntity.TEMPLATE_EMAIL_REPORT) ...[ 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()),
],
),
] else if (schedule.template == ] else if (schedule.template ==
ScheduleEntity.TEMPLATE_EMAIL_STATEMENT) ...[ ScheduleEntity.TEMPLATE_EMAIL_STATEMENT) ...[
FormCard(children: [ FormCard(children: [
@ -342,6 +362,7 @@ class _ScheduleEditState extends State<ScheduleEdit> {
] else if (schedule.template == ] else if (schedule.template ==
ScheduleEntity.TEMPLATE_EMAIL_RECORD) ...[ ScheduleEntity.TEMPLATE_EMAIL_RECORD) ...[
FormCard( FormCard(
isLast: true,
children: [ children: [
AppDropdownButton<String>( AppDropdownButton<String>(
labelText: localization.type, labelText: localization.type,