Skip to content

A local-first personal finance app

Allow goal template 'by' matches to compound (#860)

shall0passadf205db8676
diff --git a/packages/loot-core/src/server/budget/goaltemplates.js b/packages/loot-core/src/server/budget/goaltemplates.js
index 3083935296..90ce80aa12 100644
--- a/packages/loot-core/src/server/budget/goaltemplates.js
+++ b/packages/loot-core/src/server/budget/goaltemplates.js
@@ -131,7 +131,6 @@ async function applyCategoryTemplate(category, template_lines, month, force) {
let current_month = new Date(`${month}-01`);
// remove lines for past dates, calculate repeating dates
- let got_by = false;
template_lines = template_lines.filter(template => {
switch (template.type) {
case 'by':
@@ -175,29 +174,16 @@ async function applyCategoryTemplate(category, template_lines, month, force) {
});
if (template_lines.length > 1) {
- template_lines = template_lines
- .sort((a, b) => {
- if (a.type === 'by' && !a.annual) {
- return differenceInCalendarMonths(
- new Date(`${a.month}-01`),
- new Date(`${b.month}-01`),
- );
- } else {
- return a.type.localeCompare(b.type);
- }
- })
- .filter(el => {
- if (el.type === 'by') {
- if (!got_by) {
- got_by = true;
- return el;
- } else {
- return null;
- }
- } else {
- return el;
- }
- });
+ template_lines = template_lines.sort((a, b) => {
+ if (a.type === 'by' && !a.annual) {
+ return differenceInCalendarMonths(
+ new Date(`${a.month}-01`),
+ new Date(`${b.month}-01`),
+ );
+ } else {
+ return a.type.localeCompare(b.type);
+ }
+ });
}
let to_budget = 0;
diff --git a/upcoming-release-notes/860.md b/upcoming-release-notes/860.md
new file mode 100644
index 0000000000..d2bc818d97
--- /dev/null
+++ b/upcoming-release-notes/860.md
@@ -0,0 +1,6 @@
+---
+category: Enhancement
+authors: [shall0pass]
+---
+
+Allow goal template 'by' matches to compound
\ No newline at end of file