Skip to content
Snippets Groups Projects
Unverified Commit e589163b authored by Martin French's avatar Martin French Committed by GitHub
Browse files

[Goals] Negate schedule amount to budget if income (#2125)

* Negate schedule amount to budget if income

* Release notes

* Determine sign at initial calc

To ensure no unintended impact to remainder calcs etc.

* Lint fixes
parent d2b86d10
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@ export async function goalsSchedule(
last_month_balance,
to_budget,
errors,
category,
) {
if (!scheduleFlag) {
scheduleFlag = true;
......@@ -34,12 +35,15 @@ export async function goalsSchedule(
const conditions = rule.serialize().conditions;
const { date: dateConditions, amount: amountCondition } =
extractScheduleConds(conditions);
const sign = category.is_income ? 1 : -1;
const target =
amountCondition.op === 'isbetween'
? -Math.round(
amountCondition.value.num1 + amountCondition.value.num2,
) / 2
: -amountCondition.value;
? (sign *
Math.round(
amountCondition.value.num1 + amountCondition.value.num2,
)) /
2
: sign * amountCondition.value;
const next_date_string = getNextDate(
dateConditions,
monthUtils._parse(current_month),
......
......@@ -590,6 +590,7 @@ async function applyCategoryTemplate(
last_month_balance,
to_budget,
errors,
category,
);
to_budget = goalsReturn.to_budget;
errors = goalsReturn.errors;
......
---
category: Bugfix
authors: [mk-french]
---
Goals: Negate schedule amount to budget if income
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment