From 937af81a094230a7217781c426affa59cdb1f4b2 Mon Sep 17 00:00:00 2001 From: Anuj Gupta Date: Wed, 29 Mar 2017 14:43:32 +0530 Subject: [PATCH] Automatically apply better SUM formula upon adding new round. Progress for legalese/legalese.com#216 --- captable.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/captable.js b/captable.js index a87fe35..fe9040f 100644 --- a/captable.js +++ b/captable.js @@ -1141,6 +1141,7 @@ function addRound(capsheet) { capSheet.addMajorColumn(round); // Useful locators + var investorBeginRow = capSheet.getCategoryRowCaptable("discount") + 1; var newInvestorsRow = capSheet.getCategoryRowCaptable("amount raised"); var roundColumn = capSheet.getRoundColumnByName(round); var totalColumn = capSheet.getRoundColumnByName("TOTAL"); @@ -1170,6 +1171,11 @@ function addRound(capsheet) { } } + // Set SUM Forumla for "amount raised" row so it automatically picks up new rows + var lastCol = capSheet.captablesheet.getLastColumn(); + var sumRow = capSheet.captablesheet.getRange(newInvestorsRow, 2, 1, lastCol - 1); + sumRow.setFormula("=SUM(INDIRECT(ADDRESS(" + investorBeginRow + ",COLUMN())):INDIRECT(ADDRESS(ROW()-1,COLUMN())))"); + ctLog("Inserting 2 rows into Entities at row: " + i); // Insert 2 investors into the Entities Sheet if(i < entitiesNumRows) {