Skip to content

Commit

Permalink
Merge branch 'actualbudget:master' into budget-type-switch-bug-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
paulsukow authored Nov 21, 2023
2 parents 8e52794 + cd6bd9e commit 843f236
Show file tree
Hide file tree
Showing 27 changed files with 182 additions and 52 deletions.
3 changes: 3 additions & 0 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"version": "6.2.1",
"license": "MIT",
"description": "An API for Actual",
"engines": {
"node": ">=18.12.0"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion packages/desktop-client/src/browser-preload.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ global.Actual = {
return worker;
},

setTheme: () => {},
setTheme: theme => {
window.__actionsForMenu.saveGlobalPrefs({ theme: theme });
},
};

document.addEventListener('keydown', e => {
Expand Down
4 changes: 3 additions & 1 deletion packages/desktop-client/src/components/ManageRules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ function ManageRulesContent({
await dispatch(initiallyLoadPayees());
}

undo.setUndoState('openModal', 'manage-rules');
if (payeeId) {
undo.setUndoState('openModal', 'manage-rules');
}

loadData();

Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-client/src/components/Modals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export default function Modals() {
return (
<ManageRulesModal
modalProps={modalProps}
payeeId={options.payeeId}
payeeId={options?.payeeId}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ function AccountHeader({ name, amount, style = {} }) {
return (
<View
style={{
flex: '1 0 auto',
flex: 1,
flexDirection: 'row',
marginTop: 10,
marginRight: 10,
color: theme.pageTextLight,
width: '100%',
...style,
}}
>
Expand Down Expand Up @@ -54,13 +55,14 @@ function AccountCard({ account, updated, getBalanceQuery, onSelect }) {
return (
<View
style={{
flex: '1 0 auto',
flex: 1,
flexDirection: 'row',
backgroundColor: theme.tableBackground,
boxShadow: `0 1px 1px ${theme.mobileAccountShadow}`,
borderRadius: 6,
marginTop: 10,
marginRight: 10,
width: '100%',
}}
data-testid="account"
>
Expand All @@ -78,7 +80,7 @@ function AccountCard({ account, updated, getBalanceQuery, onSelect }) {
>
<View
style={{
flex: '1 auto',
flex: 1,
margin: '10px 0',
}}
>
Expand Down
37 changes: 37 additions & 0 deletions packages/desktop-client/src/components/budget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ type BudgetProps = {
moveCategory: BoundActions['moveCategory'];
moveCategoryGroup: BoundActions['moveCategoryGroup'];
loadPrefs: BoundActions['loadPrefs'];
addNotification: BoundActions['addNotification'];
};

function Budget(props: BudgetProps) {
Expand Down Expand Up @@ -246,7 +247,28 @@ function Budget(props: BudgetProps) {
setIsAddingGroup(false);
};

const categoryNameAlreadyExistsNotification = name => {
props.addNotification({
type: 'error',
message: `Category ‘${name}’ already exists in group (May be Hidden)`,
});
};

const onSaveCategory = async category => {
let exists =
(await props.getCategories()).grouped
.filter(g => g.id === category.cat_group)[0]
.categories.filter(
c => c.name.toUpperCase() === category.name.toUpperCase(),
)
.filter(c => (category.id === 'new' ? true : c.id !== category.id))
.length > 0;

if (exists) {
categoryNameAlreadyExistsNotification(category.name);
return;
}

if (category.id === 'new') {
let id = await props.createCategory(
category.name,
Expand Down Expand Up @@ -355,6 +377,21 @@ function Budget(props: BudgetProps) {
};

const onReorderCategory = async sortInfo => {
let cats = await props.getCategories();
let moveCandidate = cats.list.filter(c => c.id === sortInfo.id)[0];
let exists =
cats.grouped
.filter(g => g.id === sortInfo.groupId)[0]
.categories.filter(
c => c.name.toUpperCase() === moveCandidate.name.toUpperCase(),
)
.filter(c => c.id !== moveCandidate.id).length > 0;

if (exists) {
categoryNameAlreadyExistsNotification(moveCandidate.name);
return;
}

props.moveCategory(sortInfo.id, sortInfo.groupId, sortInfo.targetId);
setCategoryGroups(state =>
moveCategory(state, sortInfo.id, sortInfo.groupId, sortInfo.targetId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import Input, { defaultInputStyle } from './Input';
import View from './View';

type InputWithContentProps = ComponentProps<typeof Input> & {
leftContent: ReactNode;
rightContent: ReactNode;
leftContent?: ReactNode;
rightContent?: ReactNode;
inputStyle?: CSSProperties;
focusStyle?: CSSProperties;
style?: CSSProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class AmountInput extends PureComponent {
...style,
}}
>
<View style={{ overflowY: 'auto' }}>{input}</View>
<View style={{ overflowY: 'auto', overflowX: 'hidden' }}>{input}</View>

{/* <Animated.View
style={{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
import React, { useRef, useState } from 'react';
import React, { type MutableRefObject, useRef, useState } from 'react';

import evalArithmetic from 'loot-core/src/shared/arithmetic';
import { amountToInteger } from 'loot-core/src/shared/util';

import { useMergedRefs } from '../../hooks/useMergedRefs';
import Add from '../../icons/v1/Add';
import Subtract from '../../icons/v1/Subtract';
import { theme } from '../../style';
import { type CSSProperties, theme } from '../../style';
import Button from '../common/Button';
import InputWithContent from '../common/InputWithContent';
import View from '../common/View';
import useFormat from '../spreadsheet/useFormat';

type AmountInputProps = {
id?: string;
inputRef?: MutableRefObject<HTMLInputElement>;
initialValue: number;
zeroSign?: '-' | '+';
onChange?: (value: number) => void;
onBlur?: () => void;
style?: CSSProperties;
textStyle?: CSSProperties;
focused?: boolean;
};

export function AmountInput({
id,
inputRef,
Expand All @@ -22,7 +34,7 @@ export function AmountInput({
style,
textStyle,
focused,
}) {
}: AmountInputProps) {
let format = useFormat();
let [negative, setNegative] = useState(
(initialValue === 0 && zeroSign === '-') || initialValue < 0,
Expand All @@ -49,8 +61,8 @@ export function AmountInput({
setValue(value ? value : '');
}

let ref = useRef();
let mergedRef = useMergedRefs(inputRef, ref);
let ref = useRef<HTMLInputElement>();
let mergedRef = useMergedRefs<HTMLInputElement>(inputRef, ref);

function onInputAmountBlur(e) {
fireChange(value, negative);
Expand Down
4 changes: 0 additions & 4 deletions packages/desktop-client/src/global-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ export function handleGlobalEvents(actions, store) {
// to update.
});

global.Actual.setTheme = theme => {
actions.saveGlobalPrefs({ theme });
};

listen('server-error', info => {
actions.addGenericErrorNotification();
});
Expand Down
8 changes: 8 additions & 0 deletions packages/desktop-electron/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,3 +407,11 @@ ipcMain.on('apply-update', () => {
ipcMain.on('update-menu', (event, isBudgetOpen) => {
updateMenu(isBudgetOpen);
});

ipcMain.on('set-theme', theme => {
let obj = { theme: theme };

clientWin.webContents.executeJavaScript(
`window.__actionsForMenu && window.__actionsForMenu.saveGlobalPrefs(${obj})`,
);
});
4 changes: 3 additions & 1 deletion packages/desktop-electron/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,7 @@ contextBridge.exposeInMainWorld('Actual', {
return socketPromise;
},

setTheme: () => {},
setTheme: theme => {
ipcRenderer.send('set-theme', theme);
},
});
65 changes: 33 additions & 32 deletions packages/loot-core/src/server/accounts/ofx2json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,48 +44,49 @@ function getStmtTrn(data) {
}

function getBankStmtTrn(ofx) {
const msg = ofx?.['BANKMSGSRSV1'];
const stmtTrnRs = msg?.['STMTTRNRS'];
const stmtRs = stmtTrnRs?.['STMTRS'];
const tranList = stmtRs?.['BANKTRANLIST'];
// Could be an array or a single object.
// Somes values could be an array or a single object.
// xml2js serializes single item to an object and multiple to an array.
const stmtTrn = tranList?.['STMTTRN'];

if (!Array.isArray(stmtTrn)) {
return [stmtTrn];
}
return stmtTrn;
const msg = ofx?.['BANKMSGSRSV1'];
const stmtTrnRs = getAsArray(msg?.['STMTTRNRS']);
const result = stmtTrnRs.flatMap(s => {
const stmtRs = s?.['STMTRS'];
const tranList = stmtRs?.['BANKTRANLIST'];
const stmtTrn = tranList?.['STMTTRN'];
return getAsArray(stmtTrn);
});
return result;
}

function getCcStmtTrn(ofx) {
const msg = ofx?.['CREDITCARDMSGSRSV1'];
const stmtTrnRs = msg?.['CCSTMTTRNRS'];
const stmtRs = stmtTrnRs?.['CCSTMTRS'];
const tranList = stmtRs?.['BANKTRANLIST'];
// Could be an array or a single object.
// Some values could be an array or a single object.
// xml2js serializes single item to an object and multiple to an array.
const stmtTrn = tranList?.['STMTTRN'];

if (!Array.isArray(stmtTrn)) {
return [stmtTrn];
}
return stmtTrn;
const msg = ofx?.['CREDITCARDMSGSRSV1'];
const stmtTrnRs = getAsArray(msg?.['CCSTMTTRNRS']);
const result = stmtTrnRs.flatMap(s => {
const stmtRs = s?.['CCSTMTRS'];
const tranList = stmtRs?.['BANKTRANLIST'];
const stmtTrn = tranList?.['STMTTRN'];
return getAsArray(stmtTrn);
});
return result;
}

function getInvStmtTrn(ofx) {
const msg = ofx?.['INVSTMTMSGSRSV1'];
const stmtTrnRs = msg?.['INVSTMTTRNRS'];
const stmtRs = stmtTrnRs?.['INVSTMTRS'];
const tranList = stmtRs?.['INVTRANLIST'];
// Could be an array or a single object.
// Somes values could be an array or a single object.
// xml2js serializes single item to an object and multiple to an array.
const stmtTrn = tranList?.['INVBANKTRAN']?.flatMap(t => t?.['STMTTRN']);
const msg = ofx?.['INVSTMTMSGSRSV1'];
const stmtTrnRs = getAsArray(msg?.['INVSTMTTRNRS']);
const result = stmtTrnRs.flatMap(s => {
const stmtRs = s?.['INVSTMTRS'];
const tranList = stmtRs?.['INVTRANLIST'];
const stmtTrn = tranList?.['INVBANKTRAN']?.flatMap(t => t?.['STMTTRN']);
return getAsArray(stmtTrn);
});
return result;
}

if (!Array.isArray(stmtTrn)) {
return [stmtTrn];
}
return stmtTrn;
function getAsArray(value) {
return Array.isArray(value) ? value : [value];
}

function mapOfxTransaction(stmtTrn): OFXTransaction {
Expand Down
11 changes: 11 additions & 0 deletions packages/loot-core/src/server/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,17 @@ export async function insertCategory(

let id_;
await batchMessages(async () => {
// Dont allow duplicated names in groups
const existingCatInGroup = await first(
`SELECT id FROM categories WHERE cat_group = ? and UPPER(name) = ? LIMIT 1`,
[category.cat_group, category.name.toUpperCase()],
);
if (existingCatInGroup) {
throw new Error(
`Category ‘${category.name}’ already exists in group ‘${category.cat_group}’`,
);
}

if (atEnd) {
const lastCat = await first(`
SELECT sort_order FROM categories WHERE tombstone = 0 ORDER BY sort_order DESC, id DESC LIMIT 1
Expand Down
2 changes: 1 addition & 1 deletion packages/loot-core/src/shared/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export function getNumberFormat({ format, hideFraction } = numberFormatConfig) {

switch (format) {
case 'space-comma':
locale = 'en-ZA';
locale = 'en-SE';
regex = /[^-0-9,]/g;
separator = ',';
break;
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/1833.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [Shazib]
---

Not allowed duplicated Category names in Category Groups
6 changes: 6 additions & 0 deletions upcoming-release-notes/1885.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [jfdoming]
---

Fix crash when hitting undo after applying a rule to some transactions
6 changes: 6 additions & 0 deletions upcoming-release-notes/1916.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [joel-jeremy]
---

Fix mobile accounts page padding regression.
6 changes: 6 additions & 0 deletions upcoming-release-notes/1921.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [joel-jeremy]
---

Experimental ofx parser: Support multiple months in ofx file
6 changes: 6 additions & 0 deletions upcoming-release-notes/1926.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [Shazib]
---

Fix issue with electron builds being stuck on a blank screen.
6 changes: 6 additions & 0 deletions upcoming-release-notes/1929.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [miqh]
---

Fix flickering scroll bar that may appear when interacting with the new transaction input amount.
Loading

0 comments on commit 843f236

Please sign in to comment.