mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-11 20:44:32 -05:00
Goals: Add option to percent goal to use available funds (#1254)
This commit is contained in:
@@ -90,13 +90,14 @@ async function processTemplate(month, force) {
|
||||
// so the remainders don't get skiped
|
||||
if (remainder_found) lowestPriority = remainder_priority;
|
||||
|
||||
let sheetName = monthUtils.sheetForMonth(month);
|
||||
let available_start = await getSheetValue(sheetName, `to-budget`);
|
||||
for (let priority = 0; priority <= lowestPriority; priority++) {
|
||||
// setup scaling for remainder
|
||||
let remainder_scale = 1;
|
||||
if (priority === lowestPriority) {
|
||||
let sheetName = monthUtils.sheetForMonth(month);
|
||||
let budgetAvailable = await getSheetValue(sheetName, `to-budget`);
|
||||
remainder_scale = Math.round(budgetAvailable / remainder_weight_total);
|
||||
let available_now = await getSheetValue(sheetName, `to-budget`);
|
||||
remainder_scale = Math.round(available_now / remainder_weight_total);
|
||||
}
|
||||
|
||||
for (let c = 0; c < categories.length; c++) {
|
||||
@@ -150,6 +151,7 @@ async function processTemplate(month, force) {
|
||||
month,
|
||||
priority,
|
||||
remainder_scale,
|
||||
available_start,
|
||||
force,
|
||||
);
|
||||
if (to_budget != null) {
|
||||
@@ -252,6 +254,7 @@ async function applyCategoryTemplate(
|
||||
month,
|
||||
priority,
|
||||
remainder_scale,
|
||||
available_start,
|
||||
force,
|
||||
) {
|
||||
let current_month = `${month}-01`;
|
||||
@@ -493,6 +496,8 @@ async function applyCategoryTemplate(
|
||||
let monthlyIncome = 0;
|
||||
if (template.category.toLowerCase() === 'all income') {
|
||||
monthlyIncome = await getSheetValue(sheetName, `total-income`);
|
||||
} else if (template.category.toLowerCase() === 'available funds') {
|
||||
monthlyIncome = available_start;
|
||||
} else {
|
||||
let income_category = (await db.getCategories()).find(
|
||||
c =>
|
||||
|
||||
6
upcoming-release-notes/1254.md
Normal file
6
upcoming-release-notes/1254.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Enhancements
|
||||
authors: [youngcw]
|
||||
---
|
||||
|
||||
Goals: Add 'available funds' option to the percentage goal
|
||||
Reference in New Issue
Block a user