mirror of
https://github.com/actualbudget/actual.git
synced 2026-04-29 02:54:09 -05:00
Improve handling of schedules that are missing a date (#601)
* Fix adding date back to a schedule that lost its date * Propagate errors when searching matching transactions * Make the error more visible * Block removing the date field on schedule-linked rules
This commit is contained in:
@@ -146,6 +146,7 @@ const TransactionRow = React.memo(function TransactionRow({
|
||||
export default function SimpleTransactionsTable({
|
||||
transactions,
|
||||
schedules,
|
||||
renderEmpty,
|
||||
fields = ['date', 'payee', 'amount'],
|
||||
style
|
||||
}) {
|
||||
@@ -185,6 +186,7 @@ export default function SimpleTransactionsTable({
|
||||
<Table
|
||||
style={style}
|
||||
items={serializedTransactions}
|
||||
renderEmpty={renderEmpty}
|
||||
headers={
|
||||
<>
|
||||
<SelectCell
|
||||
|
||||
@@ -172,6 +172,7 @@ export function ConditionEditor({
|
||||
ops,
|
||||
condition,
|
||||
editorStyle,
|
||||
isSchedule,
|
||||
onChange,
|
||||
onDelete,
|
||||
onAdd
|
||||
@@ -214,7 +215,10 @@ export function ConditionEditor({
|
||||
<View style={{ flex: 1 }}>{valueEditor}</View>
|
||||
|
||||
<Stack direction="row">
|
||||
<EditorButtons onAdd={onAdd} onDelete={onDelete} />
|
||||
<EditorButtons
|
||||
onAdd={onAdd}
|
||||
onDelete={isSchedule && field === 'date' ? null : onDelete}
|
||||
/>
|
||||
</Stack>
|
||||
</Editor>
|
||||
);
|
||||
@@ -395,6 +399,7 @@ export function ConditionsList({
|
||||
conditions,
|
||||
conditionFields,
|
||||
editorStyle,
|
||||
isSchedule,
|
||||
onChangeConditions
|
||||
}) {
|
||||
function addCondition(index) {
|
||||
@@ -523,6 +528,7 @@ export function ConditionsList({
|
||||
editorStyle={editorStyle}
|
||||
ops={ops}
|
||||
condition={cond}
|
||||
isSchedule={isSchedule}
|
||||
onChange={(name, value) => {
|
||||
updateCondition(cond, name, value);
|
||||
}}
|
||||
@@ -567,6 +573,8 @@ export default function EditRule({
|
||||
let dispatch = useDispatch();
|
||||
let scrollableEl = useRef();
|
||||
|
||||
let isSchedule = actions.some(action => action.op === 'link-schedule');
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(initiallyLoadPayees());
|
||||
|
||||
@@ -769,6 +777,7 @@ export default function EditRule({
|
||||
conditions={conditions}
|
||||
conditionFields={conditionFields}
|
||||
editorStyle={editorStyle}
|
||||
isSchedule={isSchedule}
|
||||
onChangeConditions={conds => setConditions(conds)}
|
||||
/>
|
||||
</View>
|
||||
|
||||
@@ -290,13 +290,18 @@ export default function ScheduleDetails() {
|
||||
let unsubscribe;
|
||||
|
||||
if (state.schedule && state.transactionsMode === 'matched') {
|
||||
let { conditions } = updateScheduleConditions(
|
||||
let { error, conditions } = updateScheduleConditions(
|
||||
state.schedule,
|
||||
state.fields
|
||||
);
|
||||
|
||||
dispatch({ type: 'set-transactions', transactions: [] });
|
||||
|
||||
if (error) {
|
||||
dispatch({ type: 'form-error', error });
|
||||
return;
|
||||
}
|
||||
|
||||
// *Extremely* gross hack because the rules are not mapped to
|
||||
// public names automatically. We really should be doing that
|
||||
// at the database layer
|
||||
@@ -695,6 +700,22 @@ export default function ScheduleDetails() {
|
||||
)}
|
||||
|
||||
<SimpleTransactionsTable
|
||||
renderEmpty={
|
||||
state.transactionsMode === 'matched' &&
|
||||
(() => (
|
||||
<View
|
||||
style={{ padding: 20, color: colors.n4, textAlign: 'center' }}
|
||||
>
|
||||
{state.error ? (
|
||||
<Text style={{ color: colors.r4 }}>
|
||||
Could not search: {state.error}
|
||||
</Text>
|
||||
) : (
|
||||
'No transactions found'
|
||||
)}
|
||||
</View>
|
||||
))
|
||||
}
|
||||
transactions={state.transactions}
|
||||
fields={['date', 'payee', 'amount']}
|
||||
style={{
|
||||
|
||||
@@ -268,8 +268,8 @@ export async function updateSchedule({ schedule, conditions, resetNextDate }) {
|
||||
oldConditions.find(c => c.field === 'account')
|
||||
) ||
|
||||
!deepEqual(
|
||||
stripType(oldConditions.find(c => c.field === 'date')),
|
||||
stripType(newConditions.find(c => c.field === 'date'))
|
||||
stripType(oldConditions.find(c => c.field === 'date') || {}),
|
||||
stripType(newConditions.find(c => c.field === 'date') || {})
|
||||
)
|
||||
) {
|
||||
await setNextDate({
|
||||
|
||||
Reference in New Issue
Block a user