diff --git a/VMW_to_AVGO_ESPP_and_RSU.xlsx b/VMW_to_AVGO_ESPP_and_RSU.xlsx index 4a5ba82..3e8aa1b 100644 Binary files a/VMW_to_AVGO_ESPP_and_RSU.xlsx and b/VMW_to_AVGO_ESPP_and_RSU.xlsx differ diff --git a/worksheet/config.gs b/worksheet/config.gs index 609f4da..156e6e7 100644 --- a/worksheet/config.gs +++ b/worksheet/config.gs @@ -18,6 +18,11 @@ const enableMergeProcessing = false const datasheetNames = ["ESPP","RSU"] const referenceName = "Reference" +const summaryName = "Summary" + +const sharesCashCellA1Notation = "B25" +const sharesStockCellA1Notation = "B26" +const totalVMWCellA1Notation = "B29" // the row in which the costBasisColName can be found. // TODO: this is a monumental hack. Could also use a search, a NamedRange, diff --git a/worksheet/github_hickeng_financial_vmw_avgo_merger_data_ESPP.json b/worksheet/github_hickeng_financial_vmw_avgo_merger_data_ESPP.json index 4b4d3fa..83ce379 100644 --- a/worksheet/github_hickeng_financial_vmw_avgo_merger_data_ESPP.json +++ b/worksheet/github_hickeng_financial_vmw_avgo_merger_data_ESPP.json @@ -98,11 +98,11 @@ {"sheet":1,"id":"L14","data":"=ROUND(0.85*MIN(E14,F14),2)","type":"formula","format":"int_2dp","propagate":{"end":"L26"},"dataclass":"info"}, {"sheet":1,"id":"M2","data":"From eTrade","format":"int_3dp"}, {"sheet":1,"id":"M3","data":"Input - alternate for cross check","format":"int_3dp"}, -{"sheet":1,"id":"M4","data":"Share amounts from eTrade","format":"int_3dp","note":"The quantities of converted shares from eTrade lots.\nThe colour of the cell will alter slightly if the value here does not equal the value calculated via AVGO ratio.\nYou can toggle whether to use this manual value or the calculated value in the Tweaks on the first Sheet."}, +{"sheet":1,"id":"M4","data":"Share amounts from eTrade","format":"int_3dp","note":"The quantities of converted shares from eTrade lots.\nThe colour of the cell will alter slightly if the value here does not equal the value calculated via AVGO ratio.\nYou can toggle whether to use this manual value or the calculated value in the Tweaks on the first Sheet.\n\nIf this is the lot from which a fraction was taken by etrade then you should add then fractional AVGO quantity back into this value and check the Fraction box. See the note on the fraction column."}, {"sheet":1,"id":"M5","data":"=SUM(M7:M26)","type":"formula","format":"int_3dp","dataclass":"info"}, {"sheet":1,"id":"M7","format":"int_3dp","validation":{"type":"NUMBER_GREATER_THAN_OR_EQUAL_TO","values":0,"enforced":true,"help":""},"propagate":{"end":"M26"},"dataclass":"in_opt"}, {"sheet":1,"id":"M28","data":"=SUM(M7:M26)","type":"formula","format":"int_3dp","dataclass":"info"}, -{"sheet":1,"id":"N3","data":"Use for fraction","format":"int_3dp","note":"If the fractional share should come out of a specific lot, or set of lots, check those lots here. If multiple are selected the sheet will spread the fraction equally over those lots, accounting for differences in cost-basis.\n\nFor me, eTrade took the entire fraction from a single lot and I expect that's what happened for most people.\n\nIf it came out of an ESPP lot, that's a sale and will incur the ordinary income portion of tax shown in column \"Income & short term gain\".\n\n"}, +{"sheet":1,"id":"N3","data":"Use for fraction","format":"int_3dp","note":"If the fractional share should come out of a specific lot, or set of lots, check those lots here. If multiple are selected the sheet will spread the fraction equally over those lots, accounting for differences in cost-basis.\n\nFor me, eTrade took the entire fraction from a single lot and I expect that's what happened for most people.\n\nIf it came out of an ESPP lot, that's a sale and will incur the ordinary income portion of tax shown in column \"Income & short term gain\".\n\nThe fractional quantity should be added back into \"Share amounts from eTrade\" column for the lot that eTrade took it from.\nThis is done because we need the cost-basis of the lot calculated _before_ that fraction is removed as it's a serial conversion - convert entire lot, THEN sell factional part.\nIt also avoids substantial complexity in formulae.\n"}, {"sheet":1,"id":"N4","format":"int_3dp"}, {"sheet":1,"id":"N5","data":"=COUNTIF(N7:N26, TRUE)","type":"formula"}, {"sheet":1,"id":"N7","type":"checkbox","format":"int_3dp","validation":{"type":"CHECKBOX","enforced":false,"help":""},"propagate":{"end":"N26"},"dataclass":"in"}, diff --git a/worksheet/github_hickeng_financial_vmw_avgo_merger_data_RSU.json b/worksheet/github_hickeng_financial_vmw_avgo_merger_data_RSU.json index 3c9c112..a8036d3 100644 --- a/worksheet/github_hickeng_financial_vmw_avgo_merger_data_RSU.json +++ b/worksheet/github_hickeng_financial_vmw_avgo_merger_data_RSU.json @@ -144,11 +144,11 @@ {"sheet":2,"id":"H86","data":"=SUM(H7:H84)","type":"formula","format":"financial","dataclass":"info"}, {"sheet":2,"id":"I2","data":"From eTrade","format":"int_3dp"}, {"sheet":2,"id":"I3","data":"Input - alternate for cross check","format":"int_3dp"}, -{"sheet":2,"id":"I4","data":"Share amounts from eTrade","format":"int_3dp","note":"The quantities of converted shares from eTrade lots.\nThe colour of the cell will alter slightly if the value here does not equal the value calculated via AVGO ratio.\nYou can toggle whether to use this manual value or the calculated value in the Tweaks on the first Sheet."}, +{"sheet":2,"id":"I4","data":"Share amounts from eTrade","format":"int_3dp","note":"The quantities of converted shares from eTrade lots.\nThe colour of the cell will alter slightly if the value here does not equal the value calculated via AVGO ratio.\nYou can toggle whether to use this manual value or the calculated value in the Tweaks on the first Sheet.\n\nIf this is the lot from which a fraction was taken by etrade then you should add then fractional AVGO quantity back into this value and check the Fraction box. See the note on the fraction column."}, {"sheet":2,"id":"I5","data":"=SUM(I7:I84)","type":"formula","format":"int_3dp","dataclass":"info"}, {"sheet":2,"id":"I7","format":"int_3dp","validation":{"type":"NUMBER_GREATER_THAN_OR_EQUAL_TO","values":0,"enforced":true,"help":""},"propagate":{"end":"I84"},"dataclass":"in_opt"}, {"sheet":2,"id":"I86","data":"=SUM(I7:I84)","type":"formula","format":"int_3dp","dataclass":"info"}, -{"sheet":2,"id":"J3","data":"Use for fraction","format":"int_3dp","note":"If the fractional share should come out of a specific lot, or set of lots, check those lots here. If multiple are selected the sheet will spread the fraction equally over those lots, accounting for differences in cost-basis.\nYou REALLY don't want it to come out of an ESPP lot as that's a sale and will incur the ordinary income portion of tax shown in column AB.\nFor me, eTrade took the entire fraction from a single lot and I expect that's what happened for most people."}, +{"sheet":2,"id":"J3","data":"Use for fraction","format":"int_3dp","note":"If the fractional share should come out of a specific lot, or set of lots, check those lots here. If multiple are selected the sheet will spread the fraction equally over those lots, accounting for differences in cost-basis.\n\nFor me, eTrade took the entire fraction from a single lot and I expect that's what happened for most people.\n\nIf it came out of an ESPP lot, that's a sale and will incur the ordinary income portion of tax shown in column \"Income & short term gain\".\n\nThe fractional quantity should be added back into \"Share amounts from eTrade\" column for the lot that eTrade took it from.\nThis is done because we need the cost-basis of the lot calculated _before_ that fraction is removed as it's a serial conversion - convert entire lot, THEN sell factional part.\nIt also avoids substantial complexity in formulae.\n"}, {"sheet":2,"id":"J5","data":"=COUNTIF(#REF!, TRUE)","type":"formula"}, {"sheet":2,"id":"J7","type":"checkbox","format":"int_3dp","validation":{"type":"CHECKBOX","enforced":false,"help":""},"propagate":{"end":"J84"},"dataclass":"in"}, {"sheet":2,"id":"J86","data":"=COUNTIF(J7:J84, TRUE)","type":"formula"}, @@ -211,7 +211,7 @@ {"sheet":2,"id":"X86","data":"=SUM(X7:X84)","type":"formula","format":"int_4dp","dataclass":"info"}, {"sheet":2,"id":"Y4","data":"active qty","format":"financial"}, {"sheet":2,"id":"Y5","data":"=SUM(Y7:Y84)","type":"formula","format":"int_4dp","dataclass":"info"}, -{"sheet":2,"id":"Y7","data":"=SWITCH(Reference!$E$4,\"eTradeHoldingRatio\",V7, \"eTradeLotQtyRatio\",W7,\"manualLotRatio\",X7)","type":"formula","format":"int_6dp","propagate":{"end":"Y84"},"dataclass":"info"}, +{"sheet":2,"id":"Y7","data":"=SWITCH(Reference!$E$4,\"eTradeHoldingRatio\",V7, \"eTradeLotQtyRatio\",W7,\"manualLotRatio\",X7)","type":"formula","format":"int_3dp","propagate":{"end":"Y84"},"dataclass":"info"}, {"sheet":2,"id":"Y86","data":"=SUM(Y7:Y84)","type":"formula","format":"int_4dp","dataclass":"info"}, {"sheet":2,"id":"Z3","data":"Alternate gain calculation","format":"financial"}, {"sheet":2,"id":"Z4","data":"Gain (cash+FMV AVGO-basis)","format":"financial"}, diff --git a/worksheet/github_hickeng_financial_vmw_avgo_merger_data_Reference.json b/worksheet/github_hickeng_financial_vmw_avgo_merger_data_Reference.json index aab8bee..9611e2f 100644 --- a/worksheet/github_hickeng_financial_vmw_avgo_merger_data_Reference.json +++ b/worksheet/github_hickeng_financial_vmw_avgo_merger_data_Reference.json @@ -1,4 +1,4 @@ -{"sheet":0,"id":"_","name":"Reference","conditional_formatting":{"type":"","criteria":"","args":[],"ranges":[],"effect":[]}}, +{"sheet":3,"id":"_","name":"Reference","conditional_formatting":{"type":"","criteria":"","args":[],"ranges":[],"effect":[]}}, {"sheet":3,"id":"A1","data":"This Sheet is a collection of reference values used by the others. I do not expect anyone to need to make changes to these values."}, {"sheet":3,"id":"A3","data":"VMW final sale price"}, {"sheet":3,"id":"A4","data":"Cash ratio (calculated)"}, diff --git a/worksheet/github_hickeng_financial_vmw_avgo_merger_data_Summary.json b/worksheet/github_hickeng_financial_vmw_avgo_merger_data_Summary.json index 02af8ad..6206cc2 100644 --- a/worksheet/github_hickeng_financial_vmw_avgo_merger_data_Summary.json +++ b/worksheet/github_hickeng_financial_vmw_avgo_merger_data_Summary.json @@ -9,7 +9,7 @@ {"sheet":0,"id":"A8","data":"=\"Calculated - intermediate or informational\"","type":"formula","dataclass":"info"}, {"sheet":0,"id":"A9","data":"Labels"}, {"sheet":0,"id":"A10","data":"Example cell with additional note","note":"Sample note to illustrate the visual indication (black triangle in top right corner) of a cell note.\n"}, -{"sheet":0,"id":"A12","data":"Github Release: v0.1.2"}, +{"sheet":0,"id":"A12","data":"Github Release: v0.1.3"}, {"sheet":0,"id":"A22","data":"Inputs (eTrade transaction log)"}, {"sheet":0,"id":"A24","data":"Necessary"}, {"sheet":0,"id":"A25","data":"Shares liquidated for cash (vmw)","note":"This comes from the eTrade transaction log"}, @@ -50,7 +50,7 @@ {"sheet":0,"id":"C11","data":"5. 2023 W2 values go into G26 to G30 as indicated at the cells"}, {"sheet":0,"id":"C12","data":"6. 2022 total federal tax paid goes into G25 - used to calculate safe harbor amounts"}, {"sheet":0,"id":"C13","data":"7. Enter values into the RSU and ESPP sheets - if you need to add a row, you can insert, select the entire row above or below without unhiding columns, fill into the new row, and replace the values with yours. Sanity check the SUM ranges in the totals row includes the full range."}, -{"sheet":0,"id":"C17","data":"8. For the fractional share - if you're providing the manual values for number of shares, add the fractional amount back into any lot it came from if deducted. This avoids needing a single row with different handling based on whether the manual value has a fraction removed or not."}, +{"sheet":0,"id":"C17","data":"8. For the fractional share - if you're providing the manual values for number of shares, add the fractional amount back into any lot it came from if deducted in \"Share amounts from eTrade\". This avoids needing a single row with different handling based on whether the manual value has a fraction removed or not."}, {"sheet":0,"id":"C19","data":"9. Look for the little black triangles in the top right corner of cells, including headers. This indicates a note. Generally I've tried to add notes useful to explaining how the sheet and any given calculation works"}, {"sheet":0,"id":"C20","data":"10. Look for the horizontal paired arrows between column labels in the RSU and ESPP sheets - these allow you to expand the hidden columns if you want to see the informational and intermediate calculations"}, {"sheet":0,"id":"C40","data":"Fractional Share"}, diff --git a/worksheet/optimize-lot-selections.gs b/worksheet/optimize-lot-selections.gs index 9792e31..eb7f86c 100644 --- a/worksheet/optimize-lot-selections.gs +++ b/worksheet/optimize-lot-selections.gs @@ -3,9 +3,6 @@ var esppPrefer = 16 var cashPreference = "cash" var stockPreference = "shares" var balancePreference = "balance" -var totalShares = 9545 -var maxCashShares = 4573 -var maxStockShares = 4972 var lotPreferenceCSV = "Lot Share Type,Lot Vest Date,AVGO shares,AVGO cost basis,Equity Ratio,Description\n" @@ -57,7 +54,16 @@ function optimizeVMW() { function optimize() { var referenceSheet = app.getSheetByName(referenceName) + var summarySheet = app.getSheetByName(summaryName) var balanceRatioCell = referenceSheet.getRange(balanceRatioA1Notation) + var avgoTargetCell = summarySheet.getRange(sharesStockCellA1Notation) + var cashTargetCell = summarySheet.getRange(sharesCashCellA1Notation) + var totalVMWCell = summarySheet.getRange(totalVMWCellA1Notation) + + totalShares = totalVMWCell.getValue() + maxCashShares = cashTargetCell.getValue() + maxStockShares = avgoTargetCell.getValue() + var lotSet = [] @@ -314,24 +320,3 @@ function compareBasis(a, b) { return a.vmwBasis - b.vmwBasis } - - - - - - - - - - - - - - - - - - - - -