Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/AccountPage/AccountList.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ class AccountList extends PureComponent {
}

showList() {
const filteredList = this.props.accounts;
const filteredList = this.props.accounts.filter((item) => {
return item.isDeleted !== 1;
});

if (this.props.loading) {
return <Spinner />;
Expand Down
52 changes: 30 additions & 22 deletions src/components/Dashboard/Overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,26 +133,30 @@ const Overview = (props) => {
props.navigation.navigate('Account');
}}
/>
{props.accounts.map((account) => {
const {title, id, openingBalance} = account;
{props.accounts
.filter((item) => {
return item.isDeleted !== 1;
})
.map((account) => {
const {title, id, openingBalance} = account;

const totalBalance = currencify(
getSum(getTransactionsByAccount(id), account),
);
const totalBalance = currencify(
getSum(getTransactionsByAccount(id), account),
);

return (
<RoundBoxButton
id={id}
key={id}
selectedItem={props?.selectedItem?.account}
title={title}
subtitle={'$ ' + totalBalance}
onPress={() => {
props.selectAccount(id);
}}
/>
);
})}
return (
<RoundBoxButton
id={id}
key={id}
selectedItem={props?.selectedItem?.account}
title={title}
subtitle={'$ ' + totalBalance}
onPress={() => {
props.selectAccount(id);
}}
/>
);
})}
</ScrollView>
</View>
</View>
Expand Down Expand Up @@ -238,10 +242,14 @@ const Overview = (props) => {
props.transactions,
(record) => record.month,
);

let showHeader = props.selectedItem.category ? groupedRecords[record.month].filter(
(r) => r.categoryId === props.selectedItem.category,
).indexOf(record) === 0 : groupedRecords[record.month].indexOf(record) === 0;

let showHeader = props.selectedItem.category
? groupedRecords[record.month]
.filter(
(r) => r.categoryId === props.selectedItem.category,
)
.indexOf(record) === 0
: groupedRecords[record.month].indexOf(record) === 0;
return (
<React.Fragment key={record.id}>
{showHeader && (
Expand Down
15 changes: 14 additions & 1 deletion src/helpers/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,19 @@ export const init = () => {
},
);
});

db.transaction((tx) => {
tx.executeSql(
'ALTER TABLE accounts ADD COLUMN isDeleted INTEGER',
[],
() => {
resolve();
},
(err) => {
reject(err);
},
);
});
});

return promise;
Expand Down Expand Up @@ -242,7 +255,7 @@ export const removeAccount = (id) => {
const promise = new Promise((resolve, reject) => {
db.transaction((tx) => {
tx.executeSql(
'DELETE FROM accounts where id = (?)',
'UPDATE accounts SET isDeleted=1 WHERE id=?',
[id],
(_, result) => {
resolve(result);
Expand Down