Skip to content

A local-first personal finance app

[Feature] Add option to control the "cleared state" in Rules (#482)

shall0passd36417e41227
diff --git a/packages/desktop-client/src/components/accounts/TransactionList.js b/packages/desktop-client/src/components/accounts/TransactionList.js
index 2cd9e4312d..ead417d157 100644
--- a/packages/desktop-client/src/components/accounts/TransactionList.js
+++ b/packages/desktop-client/src/components/accounts/TransactionList.js
@@ -133,7 +133,8 @@ export default function TransactionList({
if (
newTransaction[field] == null ||
newTransaction[field] === '' ||
- newTransaction[field] === 0
+ newTransaction[field] === 0 ||
+ newTransaction[field] === false
) {
newTransaction[field] = diff[field];
}
diff --git a/packages/desktop-client/src/components/modals/EditRule.js b/packages/desktop-client/src/components/modals/EditRule.js
index e30e1ff246..e31d429d06 100644
--- a/packages/desktop-client/src/components/modals/EditRule.js
+++ b/packages/desktop-client/src/components/modals/EditRule.js
@@ -284,7 +284,8 @@ let actionFields = [
'date',
'amount',
'category',
- 'account'
+ 'account',
+ 'cleared'
].map(field => [field, mapField(field)]);
function ActionEditor({ ops, action, editorStyle, onChange, onDelete, onAdd }) {
let { field, op, value, type, error, inputKey = 'initial' } = action;
diff --git a/packages/desktop-client/src/components/util/GenericInput.js b/packages/desktop-client/src/components/util/GenericInput.js
index 8d8c6aeaf0..1d5bd0e951 100644
--- a/packages/desktop-client/src/components/util/GenericInput.js
+++ b/packages/desktop-client/src/components/util/GenericInput.js
@@ -7,6 +7,7 @@ import Autocomplete from 'loot-design/src/components/Autocomplete';
import CategoryAutocomplete from 'loot-design/src/components/CategorySelect';
import { View, Input } from 'loot-design/src/components/common';
import DateSelect from 'loot-design/src/components/DateSelect';
+import { Checkbox } from 'loot-design/src/components/forms';
import PayeeAutocomplete from 'loot-design/src/components/PayeeAutocomplete';
import RecurringSchedulePicker from 'loot-design/src/components/RecurringSchedulePicker';
@@ -149,6 +150,16 @@ export default function GenericInput({
}
break;
+ case 'boolean':
+ content = (
+ <Checkbox
+ checked={value}
+ value={value}
+ onChange={e => onChange(!value)}
+ />
+ );
+ break;
+
default:
if (multi) {
content = (
diff --git a/packages/loot-core/src/shared/rules.js b/packages/loot-core/src/shared/rules.js
index bfc7c98f45..f19b4358d0 100644
--- a/packages/loot-core/src/shared/rules.js
+++ b/packages/loot-core/src/shared/rules.js
@@ -57,6 +57,8 @@ export function mapField(field, opts) {
return 'amount (inflow)';
case 'amount-outflow':
return 'amount (outflow)';
+ case 'cleared':
+ return 'cleared';
default:
return field;
}
@@ -154,6 +156,10 @@ export function parse(item) {
let parsed = item.value == null ? '' : item.value;
return { ...item, value: parsed };
}
+ case 'boolean': {
+ let parsed = item.value;
+ return { ...item, value: parsed };
+ }
default:
}
@@ -174,6 +180,10 @@ export function unparse({ error, inputKey, ...item }) {
let unparsed = item.value == null ? '' : item.value;
return { ...item, value: unparsed };
}
+ case 'boolean': {
+ let unparsed = item.value == null ? false : item.value;
+ return { ...item, value: unparsed };
+ }
default:
}