[ledger] support filter by date

This commit is contained in:
Anantha Kumaran 2022-08-28 12:12:08 +05:30
parent 64deaecf3e
commit 60fef80904
2 changed files with 8 additions and 4 deletions

View File

@ -35,6 +35,7 @@ function renderTransactions(postings: Posting[]) {
const rows = _.map(postings, (p) => {
const purchase = formatCurrency(p.amount);
let market = "",
date = p.timestamp.format("DD MMM YYYY"),
change = "",
changePercentage = "",
changeClass = "",
@ -61,7 +62,7 @@ function renderTransactions(postings: Posting[]) {
}
const markup = `
<tr class="${p.timestamp.month() % 2 == 0 ? "has-background-white-ter" : ""}">
<td>${p.timestamp.format("DD MMM YYYY")}</td>
<td>${date}</td>
<td>${p.payee}</td>
<td>${p.account}</td>
<td class='has-text-right'>${purchase}</td>
@ -73,6 +74,7 @@ function renderTransactions(postings: Posting[]) {
</tr>
`;
return {
date: date,
markup: markup,
posting: p
};
@ -89,7 +91,7 @@ function renderTransactions(postings: Posting[]) {
}
function filterTransactions(
rows: { posting: Posting; markup: string }[],
rows: { date: string; posting: Posting; markup: string }[],
filter: string
) {
let filterRegex = new RegExp(".*", "i");
@ -100,7 +102,9 @@ function filterTransactions(
return _.filter(
rows,
(r) =>
filterRegex.test(r.posting.account) || filterRegex.test(r.posting.payee)
filterRegex.test(r.posting.account) ||
filterRegex.test(r.posting.payee) ||
filterRegex.test(r.date)
);
}

View File

@ -287,7 +287,7 @@
<div class="level-item">
<div class="field">
<p class="control">
<input class="d3-posting-filter input" style="width: 440px" type="text" placeholder="filter by account or description">
<input class="d3-posting-filter input" style="width: 440px" type="text" placeholder="filter by account or description or date">
</p>
</div>
</div>