fix recurrent spendings
This commit is contained in:
@@ -19,7 +19,6 @@ class TransactionFilterSelection {
|
||||
this.amountRange = const TxAmountRange(),
|
||||
this.query = '',
|
||||
this.monthOnly = false,
|
||||
this.recurringOnly = false,
|
||||
});
|
||||
|
||||
final Set<String> labelIds;
|
||||
@@ -30,14 +29,10 @@ class TransactionFilterSelection {
|
||||
/// When true, list is limited to the selected calendar month.
|
||||
final bool monthOnly;
|
||||
|
||||
/// When true, only transactions marked recurring are shown.
|
||||
final bool recurringOnly;
|
||||
|
||||
bool get hasActiveExtras =>
|
||||
flow != TxFlowFilter.all ||
|
||||
amountRange.isActive ||
|
||||
query.trim().isNotEmpty ||
|
||||
recurringOnly;
|
||||
query.trim().isNotEmpty;
|
||||
}
|
||||
|
||||
/// How label series are drawn on the overview chart.
|
||||
@@ -502,7 +497,6 @@ class _TransactionFilterDialogState extends State<_TransactionFilterDialog> {
|
||||
late final Set<String> _selected;
|
||||
late TxFlowFilter _flow;
|
||||
late bool _monthOnly;
|
||||
late bool _recurringOnly;
|
||||
late final TextEditingController _queryController;
|
||||
late final TextEditingController _labelSearchController;
|
||||
late final TextEditingController _exactAmountController;
|
||||
@@ -516,7 +510,6 @@ class _TransactionFilterDialogState extends State<_TransactionFilterDialog> {
|
||||
_selected = Set<String>.of(initial.labelIds);
|
||||
_flow = initial.flow;
|
||||
_monthOnly = initial.monthOnly;
|
||||
_recurringOnly = initial.recurringOnly;
|
||||
_queryController = TextEditingController(text: initial.query);
|
||||
_labelSearchController = TextEditingController();
|
||||
|
||||
@@ -602,7 +595,6 @@ class _TransactionFilterDialogState extends State<_TransactionFilterDialog> {
|
||||
amountRange: _amountResult,
|
||||
query: _queryController.text.trim(),
|
||||
monthOnly: _monthOnly,
|
||||
recurringOnly: _recurringOnly,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -718,24 +710,6 @@ class _TransactionFilterDialogState extends State<_TransactionFilterDialog> {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
CheckboxListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
dense: true,
|
||||
value: _recurringOnly,
|
||||
onChanged: (value) {
|
||||
setState(() => _recurringOnly = value ?? false);
|
||||
},
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
secondary: const Icon(Icons.event_repeat, size: 20),
|
||||
title: const Text('Recurring only'),
|
||||
subtitle: Text(
|
||||
'Only transactions marked as recurring',
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: colors.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
Text('Amount', style: sectionStyle),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
@@ -12,13 +12,16 @@ import '../providers/tx_meta_provider.dart';
|
||||
import '../utils/helpers.dart';
|
||||
import '../utils/look_ahead.dart';
|
||||
|
||||
Future<void> showCreateRecurringTemplateSheet(BuildContext context) {
|
||||
Future<void> showCreateRecurringTemplateSheet(
|
||||
BuildContext context, {
|
||||
BankTransaction? initialTx,
|
||||
}) {
|
||||
return showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
useSafeArea: true,
|
||||
showDragHandle: true,
|
||||
builder: (context) => const _RecurringTemplateSheet(),
|
||||
builder: (context) => _RecurringTemplateSheet(initialTx: initialTx),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -36,9 +39,10 @@ Future<void> showEditRecurringTemplateSheet(
|
||||
}
|
||||
|
||||
class _RecurringTemplateSheet extends StatefulWidget {
|
||||
const _RecurringTemplateSheet({this.existing});
|
||||
const _RecurringTemplateSheet({this.existing, this.initialTx});
|
||||
|
||||
final RecurringTemplate? existing;
|
||||
final BankTransaction? initialTx;
|
||||
|
||||
@override
|
||||
State<_RecurringTemplateSheet> createState() =>
|
||||
@@ -71,15 +75,28 @@ class _RecurringTemplateSheetState extends State<_RecurringTemplateSheet> {
|
||||
_labelId = existing?.labelId;
|
||||
_currency = existing?.currency ?? 'EUR';
|
||||
|
||||
if (existing?.sourceTxId != null) {
|
||||
BankTransaction? seed = widget.initialTx;
|
||||
if (seed == null && existing?.sourceTxId != null) {
|
||||
final txs = context.read<BankController>().transactions;
|
||||
for (final tx in txs) {
|
||||
if (tx.id == existing!.sourceTxId) {
|
||||
_pickedTx = tx;
|
||||
seed = tx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (seed != null) {
|
||||
_pickedTx = seed;
|
||||
_currency = seed.currency;
|
||||
_source = RecurringTemplateSource.transaction;
|
||||
if (_nameController.text.trim().isEmpty) {
|
||||
_nameController.text = seed.description;
|
||||
}
|
||||
if (existing == null) {
|
||||
_dayController.text =
|
||||
'${(DateTime.tryParse(seed.date)?.day ?? 1).clamp(1, 28)}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -252,7 +269,9 @@ class _RecurringTemplateSheetState extends State<_RecurringTemplateSheet> {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(
|
||||
widget.existing == null ? 'New recurring template' : 'Edit template',
|
||||
widget.existing == null
|
||||
? 'New recurring spending'
|
||||
: 'Edit recurring spending',
|
||||
style: theme.textTheme.titleLarge,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
Reference in New Issue
Block a user