function addRecurringExpenses() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var recurringSheet = ss.getSheetByName("Recurring Expenses"); var mainSheet = ss.getSheetByName("Expenses");
var today = new Date(); var recurringData = recurringSheet.getDataRange().getValues();
for (var i = 1; i < recurringData.length; i++) { var nextDueDate = new Date(recurringData[5]); // Column F: Next Due Date var frequency = recurringData[4]; // Column E: Frequency in days
if (today >= nextDueDate) { mainSheet.appendRow([ today, // Date recurringData[0], // Expense Name recurringData[1], // Category recurringData[2], // Amount "Yes" // Recurring ]);
// Update the Next Due Date recurringSheet.getRange(i + 1, 6).setValue(new Date(nextDueDate.getTime() + frequency * 24 * 60 * 60 * 1000)); } } }
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.