[{"data":1,"prerenderedAt":2947},["ShallowReactive",2],{"doc:\u002Fadvanced-data-transformation-and-cleaning\u002Fexcel-formula-equivalents-in-pandas\u002Fsln-db-and-ddb-depreciation-functions-in-python":3,"surround:\u002Fadvanced-data-transformation-and-cleaning\u002Fexcel-formula-equivalents-in-pandas\u002Fsln-db-and-ddb-depreciation-functions-in-python":2913,"ancestors:\u002Fadvanced-data-transformation-and-cleaning\u002Fexcel-formula-equivalents-in-pandas\u002Fsln-db-and-ddb-depreciation-functions-in-python":2922,"children:\u002Fadvanced-data-transformation-and-cleaning\u002Fexcel-formula-equivalents-in-pandas\u002Fsln-db-and-ddb-depreciation-functions-in-python":2927,"related:\u002Fadvanced-data-transformation-and-cleaning\u002Fexcel-formula-equivalents-in-pandas\u002Fsln-db-and-ddb-depreciation-functions-in-python":2928},{"id":4,"title":5,"body":6,"dateModified":2881,"datePublished":2881,"description":2882,"extension":2883,"faq":2884,"keyword":2893,"kind":2894,"meta":2895,"navigation":147,"path":2903,"seo":2904,"slug":2907,"stem":2908,"topics":2909,"type":2911,"__hash__":2912},"docs\u002Fadvanced-data-transformation-and-cleaning\u002Fexcel-formula-equivalents-in-pandas\u002Fsln-db-and-ddb-depreciation-functions-in-python\u002Findex.md","SLN, DB and DDB Depreciation Functions in Python",{"type":7,"value":8,"toc":2869},"minimark",[9,49,54,82,93,97,100,344,347,351,370,772,782,886,890,904,1109,1121,1125,1131,1468,1480,1536,1540,1543,2490,2499,2741,2745,2780,2784,2806,2810,2816,2822,2828,2834,2838,2865],[10,11,12,13,17,18,21,22,25,26,29,30,33,34,36,37,39,40,42,43,48],"p",{},"Excel has five depreciation functions, and finance models use all of them: ",[14,15,16],"code",{},"SLN"," for straight line, ",[14,19,20],{},"SYD"," for sum-of-years' digits, ",[14,23,24],{},"DB"," for fixed-declining balance, ",[14,27,28],{},"DDB"," for double-declining balance and ",[14,31,32],{},"VDB"," for declining balance with a switch to straight line. They look interchangeable, but each has quirks that a Python translation must copy exactly to produce the same numbers: ",[14,35,24],{}," rounds its rate to three decimal places and prorates the first and last years by a month count; ",[14,38,28],{}," never switches to straight line, so it stops short of the salvage value unless the last periods happen to catch up; ",[14,41,32],{}," does switch. A naive \"multiply book value by a rate\" gets close and is wrong in the last years — exactly where auditors look. This page implements each function, lays the results out as a schedule with pandas, and checks every period against the spreadsheet's own calculation. It belongs to ",[44,45,47],"a",{"href":46},"\u002Fadvanced-data-transformation-and-cleaning\u002Fexcel-formula-equivalents-in-pandas\u002F","Excel Formula Equivalents in pandas",".",[50,51,53],"h2",{"id":52},"prerequisites","Prerequisites",[55,56,61],"pre",{"className":57,"code":58,"language":59,"meta":60,"style":60},"language-bash shiki shiki-themes github-light github-dark-high-contrast","pip install pandas openpyxl\n","bash","",[14,62,63],{"__ignoreMap":60},[64,65,68,72,76,79],"span",{"class":66,"line":67},"line",1,[64,69,71],{"class":70},"sMTad","pip",[64,73,75],{"class":74},"srMev"," install",[64,77,78],{"class":74}," pandas",[64,80,81],{"class":74}," openpyxl\n",[10,83,84,85,88,89,48],{},"The functions use only standard Python; pandas builds the schedules. The check writes the same formulas into a workbook and recalculates it with LibreOffice (",[14,86,87],{},"soffice","), whose depreciation functions follow Excel's definitions. The example asset costs 30,000, has a salvage value of 3,000 and a useful life of 5 years. For month-by-month schedules with disposals and a full asset register, see ",[44,90,92],{"href":91},"\u002Fautomating-reporting-workflows\u002Fbuilding-finance-and-operations-reports\u002Fbuild-a-fixed-asset-depreciation-schedule\u002F","Build a Fixed Asset Depreciation Schedule",[50,94,96],{"id":95},"step-1-sln-and-syd","Step 1 — SLN and SYD",[10,98,99],{},"Straight line spreads the depreciable amount evenly; sum-of-years' digits weights early years more heavily, using the remaining life over the sum of the years' digits:",[55,101,105],{"className":102,"code":103,"language":104,"meta":60,"style":60},"language-python shiki shiki-themes github-light github-dark-high-contrast","def sln(cost, salvage, life):\n    return (cost - salvage) \u002F life\n\ndef syd(cost, salvage, life, per):\n    return (cost - salvage) * (life - per + 1) * 2 \u002F (life * (life + 1))\n\nCOST, SALVAGE, LIFE = 30_000, 3_000, 5\nprint(\"SLN:\", sln(COST, SALVAGE, LIFE))\nprint(\"SYD:\", [round(syd(COST, SALVAGE, LIFE, p), 2) for p in range(1, LIFE + 1)])\n","python",[14,106,107,121,142,149,160,213,218,251,278],{"__ignoreMap":60},[64,108,109,113,117],{"class":66,"line":67},[64,110,112],{"class":111},"s-kum","def",[64,114,116],{"class":115},"s_Opv"," sln",[64,118,120],{"class":119},"skGVy","(cost, salvage, life):\n",[64,122,124,127,130,133,136,139],{"class":66,"line":123},2,[64,125,126],{"class":111},"    return",[64,128,129],{"class":119}," (cost ",[64,131,132],{"class":111},"-",[64,134,135],{"class":119}," salvage) ",[64,137,138],{"class":111},"\u002F",[64,140,141],{"class":119}," life\n",[64,143,145],{"class":66,"line":144},3,[64,146,148],{"emptyLinePlaceholder":147},true,"\n",[64,150,152,154,157],{"class":66,"line":151},4,[64,153,112],{"class":111},[64,155,156],{"class":115}," syd",[64,158,159],{"class":119},"(cost, salvage, life, per):\n",[64,161,163,165,167,169,171,174,177,179,182,185,189,192,194,197,200,202,204,206,208,210],{"class":66,"line":162},5,[64,164,126],{"class":111},[64,166,129],{"class":119},[64,168,132],{"class":111},[64,170,135],{"class":119},[64,172,173],{"class":111},"*",[64,175,176],{"class":119}," (life ",[64,178,132],{"class":111},[64,180,181],{"class":119}," per ",[64,183,184],{"class":111},"+",[64,186,188],{"class":187},"sP0c6"," 1",[64,190,191],{"class":119},") ",[64,193,173],{"class":111},[64,195,196],{"class":187}," 2",[64,198,199],{"class":111}," \u002F",[64,201,176],{"class":119},[64,203,173],{"class":111},[64,205,176],{"class":119},[64,207,184],{"class":111},[64,209,188],{"class":187},[64,211,212],{"class":119},"))\n",[64,214,216],{"class":66,"line":215},6,[64,217,148],{"emptyLinePlaceholder":147},[64,219,221,224,227,230,232,235,238,241,243,246,248],{"class":66,"line":220},7,[64,222,223],{"class":187},"COST",[64,225,226],{"class":119},", ",[64,228,229],{"class":187},"SALVAGE",[64,231,226],{"class":119},[64,233,234],{"class":187},"LIFE",[64,236,237],{"class":111}," =",[64,239,240],{"class":187}," 30_000",[64,242,226],{"class":119},[64,244,245],{"class":187},"3_000",[64,247,226],{"class":119},[64,249,250],{"class":187},"5\n",[64,252,254,257,260,263,266,268,270,272,274,276],{"class":66,"line":253},8,[64,255,256],{"class":187},"print",[64,258,259],{"class":119},"(",[64,261,262],{"class":74},"\"SLN:\"",[64,264,265],{"class":119},", sln(",[64,267,223],{"class":187},[64,269,226],{"class":119},[64,271,229],{"class":187},[64,273,226],{"class":119},[64,275,234],{"class":187},[64,277,212],{"class":119},[64,279,281,283,285,288,291,294,297,299,301,303,305,307,310,313,315,318,321,324,327,329,332,334,336,339,341],{"class":66,"line":280},9,[64,282,256],{"class":187},[64,284,259],{"class":119},[64,286,287],{"class":74},"\"SYD:\"",[64,289,290],{"class":119},", [",[64,292,293],{"class":187},"round",[64,295,296],{"class":119},"(syd(",[64,298,223],{"class":187},[64,300,226],{"class":119},[64,302,229],{"class":187},[64,304,226],{"class":119},[64,306,234],{"class":187},[64,308,309],{"class":119},", p), ",[64,311,312],{"class":187},"2",[64,314,191],{"class":119},[64,316,317],{"class":111},"for",[64,319,320],{"class":119}," p ",[64,322,323],{"class":111},"in",[64,325,326],{"class":187}," range",[64,328,259],{"class":119},[64,330,331],{"class":187},"1",[64,333,226],{"class":119},[64,335,234],{"class":187},[64,337,338],{"class":111}," +",[64,340,188],{"class":187},[64,342,343],{"class":119},")])\n",[10,345,346],{},"Straight line charges 5,400 a year. Sum-of-years' digits divides the 27,000 depreciable amount in the proportions 5:4:3:2:1 out of 15, so year 1 carries 9,000 and year 5 only 1,800. Both total exactly 27,000 over the life, ending at the salvage value. These two are the easy cases; the declining-balance functions are where the details live.",[50,348,350],{"id":349},"step-2-db-fixed-declining-balance-with-a-rounded-rate","Step 2 — DB: fixed-declining balance with a rounded rate",[10,352,353,356,357,360,361,365,366,369],{},[14,354,355],{},"DB(cost, salvage, life, period, [month])"," applies a fixed rate to the book value each year. Excel computes the rate as ",[14,358,359],{},"1 − (salvage\u002Fcost)^(1\u002Flife)"," and ",[362,363,364],"em",{},"rounds it to three decimals","; the optional ",[14,367,368],{},"month"," argument is the number of months in the first year, which prorates the first year and adds a stub period at the end:",[55,371,373],{"className":102,"code":372,"language":104,"meta":60,"style":60},"def db(cost, salvage, life, period, month=12):\n    rate = round(1 - (salvage \u002F cost) ** (1 \u002F life), 3)\n    book = cost\n    for p in range(1, period + 1):\n        if p == 1:\n            dep = cost * rate * month \u002F 12\n        elif p == life + 1:\n            dep = book * rate * (12 - month) \u002F 12\n        else:\n            dep = book * rate\n        book -= dep\n    return dep\n\nprint(\"DB rate:\", round(1 - (SALVAGE \u002F COST) ** (1 \u002F LIFE), 3))\nprint(\"DB full years:\", [round(db(COST, SALVAGE, LIFE, p), 2) for p in range(1, LIFE + 1)])\nprint(\"DB, 7 months in year 1:\", [round(db(COST, SALVAGE, LIFE, p, month=7), 2) for p in range(1, LIFE + 2)])\n",[14,374,375,394,438,448,472,487,512,530,558,565,579,591,598,603,652,707],{"__ignoreMap":60},[64,376,377,379,382,385,388,391],{"class":66,"line":67},[64,378,112],{"class":111},[64,380,381],{"class":115}," db",[64,383,384],{"class":119},"(cost, salvage, life, period, month",[64,386,387],{"class":111},"=",[64,389,390],{"class":187},"12",[64,392,393],{"class":119},"):\n",[64,395,396,399,401,404,406,408,411,414,416,419,422,425,427,429,432,435],{"class":66,"line":123},[64,397,398],{"class":119},"    rate ",[64,400,387],{"class":111},[64,402,403],{"class":187}," round",[64,405,259],{"class":119},[64,407,331],{"class":187},[64,409,410],{"class":111}," -",[64,412,413],{"class":119}," (salvage ",[64,415,138],{"class":111},[64,417,418],{"class":119}," cost) ",[64,420,421],{"class":111},"**",[64,423,424],{"class":119}," (",[64,426,331],{"class":187},[64,428,199],{"class":111},[64,430,431],{"class":119}," life), ",[64,433,434],{"class":187},"3",[64,436,437],{"class":119},")\n",[64,439,440,443,445],{"class":66,"line":144},[64,441,442],{"class":119},"    book ",[64,444,387],{"class":111},[64,446,447],{"class":119}," cost\n",[64,449,450,453,455,457,459,461,463,466,468,470],{"class":66,"line":151},[64,451,452],{"class":111},"    for",[64,454,320],{"class":119},[64,456,323],{"class":111},[64,458,326],{"class":187},[64,460,259],{"class":119},[64,462,331],{"class":187},[64,464,465],{"class":119},", period ",[64,467,184],{"class":111},[64,469,188],{"class":187},[64,471,393],{"class":119},[64,473,474,477,479,482,484],{"class":66,"line":162},[64,475,476],{"class":111},"        if",[64,478,320],{"class":119},[64,480,481],{"class":111},"==",[64,483,188],{"class":187},[64,485,486],{"class":119},":\n",[64,488,489,492,494,497,499,502,504,507,509],{"class":66,"line":215},[64,490,491],{"class":119},"            dep ",[64,493,387],{"class":111},[64,495,496],{"class":119}," cost ",[64,498,173],{"class":111},[64,500,501],{"class":119}," rate ",[64,503,173],{"class":111},[64,505,506],{"class":119}," month ",[64,508,138],{"class":111},[64,510,511],{"class":187}," 12\n",[64,513,514,517,519,521,524,526,528],{"class":66,"line":220},[64,515,516],{"class":111},"        elif",[64,518,320],{"class":119},[64,520,481],{"class":111},[64,522,523],{"class":119}," life ",[64,525,184],{"class":111},[64,527,188],{"class":187},[64,529,486],{"class":119},[64,531,532,534,536,539,541,543,545,547,549,551,554,556],{"class":66,"line":253},[64,533,491],{"class":119},[64,535,387],{"class":111},[64,537,538],{"class":119}," book ",[64,540,173],{"class":111},[64,542,501],{"class":119},[64,544,173],{"class":111},[64,546,424],{"class":119},[64,548,390],{"class":187},[64,550,410],{"class":111},[64,552,553],{"class":119}," month) ",[64,555,138],{"class":111},[64,557,511],{"class":187},[64,559,560,563],{"class":66,"line":280},[64,561,562],{"class":111},"        else",[64,564,486],{"class":119},[64,566,568,570,572,574,576],{"class":66,"line":567},10,[64,569,491],{"class":119},[64,571,387],{"class":111},[64,573,538],{"class":119},[64,575,173],{"class":111},[64,577,578],{"class":119}," rate\n",[64,580,582,585,588],{"class":66,"line":581},11,[64,583,584],{"class":119},"        book ",[64,586,587],{"class":111},"-=",[64,589,590],{"class":119}," dep\n",[64,592,594,596],{"class":66,"line":593},12,[64,595,126],{"class":111},[64,597,590],{"class":119},[64,599,601],{"class":66,"line":600},13,[64,602,148],{"emptyLinePlaceholder":147},[64,604,606,608,610,613,615,617,619,621,623,625,627,629,632,634,636,638,640,642,645,648,650],{"class":66,"line":605},14,[64,607,256],{"class":187},[64,609,259],{"class":119},[64,611,612],{"class":74},"\"DB rate:\"",[64,614,226],{"class":119},[64,616,293],{"class":187},[64,618,259],{"class":119},[64,620,331],{"class":187},[64,622,410],{"class":111},[64,624,424],{"class":119},[64,626,229],{"class":187},[64,628,199],{"class":111},[64,630,631],{"class":187}," COST",[64,633,191],{"class":119},[64,635,421],{"class":111},[64,637,424],{"class":119},[64,639,331],{"class":187},[64,641,199],{"class":111},[64,643,644],{"class":187}," LIFE",[64,646,647],{"class":119},"), ",[64,649,434],{"class":187},[64,651,212],{"class":119},[64,653,655,657,659,662,664,666,669,671,673,675,677,679,681,683,685,687,689,691,693,695,697,699,701,703,705],{"class":66,"line":654},15,[64,656,256],{"class":187},[64,658,259],{"class":119},[64,660,661],{"class":74},"\"DB full years:\"",[64,663,290],{"class":119},[64,665,293],{"class":187},[64,667,668],{"class":119},"(db(",[64,670,223],{"class":187},[64,672,226],{"class":119},[64,674,229],{"class":187},[64,676,226],{"class":119},[64,678,234],{"class":187},[64,680,309],{"class":119},[64,682,312],{"class":187},[64,684,191],{"class":119},[64,686,317],{"class":111},[64,688,320],{"class":119},[64,690,323],{"class":111},[64,692,326],{"class":187},[64,694,259],{"class":119},[64,696,331],{"class":187},[64,698,226],{"class":119},[64,700,234],{"class":187},[64,702,338],{"class":111},[64,704,188],{"class":187},[64,706,343],{"class":119},[64,708,710,712,714,717,719,721,723,725,727,729,731,733,736,739,741,744,746,748,750,752,754,756,758,760,762,764,766,768,770],{"class":66,"line":709},16,[64,711,256],{"class":187},[64,713,259],{"class":119},[64,715,716],{"class":74},"\"DB, 7 months in year 1:\"",[64,718,290],{"class":119},[64,720,293],{"class":187},[64,722,668],{"class":119},[64,724,223],{"class":187},[64,726,226],{"class":119},[64,728,229],{"class":187},[64,730,226],{"class":119},[64,732,234],{"class":187},[64,734,735],{"class":119},", p, ",[64,737,368],{"class":738},"sa561",[64,740,387],{"class":111},[64,742,743],{"class":187},"7",[64,745,647],{"class":119},[64,747,312],{"class":187},[64,749,191],{"class":119},[64,751,317],{"class":111},[64,753,320],{"class":119},[64,755,323],{"class":111},[64,757,326],{"class":187},[64,759,259],{"class":119},[64,761,331],{"class":187},[64,763,226],{"class":119},[64,765,234],{"class":187},[64,767,338],{"class":111},[64,769,196],{"class":187},[64,771,343],{"class":119},[10,773,774,775,778,779,781],{},"The exact rate would be 0.36904…; Excel uses 0.369. That rounding is why a reimplementation with the unrounded rate drifts a few units per year from the spreadsheet. With ",[14,776,777],{},"month=7"," — an asset bought in June of a calendar year — the first year carries only 7\u002F12 of a year's charge, and a sixth period picks up the remaining 5\u002F12 at the end. Because the rate is rounded, the book value after the last period lands near but not exactly on the salvage value; ",[14,780,24],{}," does not force it.",[783,784,792,793,792,797,792,801,792,809,792,819,792,830,792,837,792,843,792,848,792,852,792,856,792,861,792,868,792,873,792,877,792,880,792,883],"svg",{"viewBox":785,"role":786,"ariaLabelledBy":787,"xmlns":790,"style":791},"4 0 752 207","img",[788,789],"dep-db-t","dep-db-d","http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg","width:100%;max-width:752px;height:auto;display:block;margin:1.5rem auto;font-family:Inter,ui-sans-serif,system-ui,sans-serif","\n  ",[794,795,796],"title",{"id":788},"Two declining-balance functions, two different rules",[798,799,800],"desc",{"id":789},"DB uses a fixed rate calculated from cost, salvage and life and rounded to three decimals, with an optional partial first year and a stub period at the end. DDB uses twice the straight-line rate on the remaining book value, never goes below salvage, and never switches to straight line.",[802,803],"rect",{"x":804,"y":805,"width":806,"height":807,"fill":808},"4","0","752","207","#ffffff",[802,810],{"x":811,"y":812,"width":813,"height":814,"rx":815,"fill":816,"stroke":817,"style":818},"20.0","16.0","351.0","175.0","14","#f0f4ff","var(--brand,#5b5cf0)","stroke-width:2px",[820,821,823],"g",{"transform":822},"translate(182.5,29.0) scale(1.083)",[824,825],"path",{"d":826,"fill":827,"stroke":828,"style":829},"M5 9h14 M4 15h14 M10 4l-2 16 M16 4l-2 16","none","var(--brand-strong,#4338ca)","stroke-width:1.66px;stroke-linecap:round;stroke-linejoin:round",[831,832,836],"text",{"x":833,"y":834,"style":835},"195.5","78.0","font-size:14px;font-weight:700;fill:var(--brand-strong,#4338ca);text-anchor:middle","DB (fixed-declining)",[66,838],{"x1":839,"y1":840,"x2":841,"y2":840,"stroke":817,"style":842},"36.0","91.0","355.0","stroke-width:1px",[831,844,847],{"x":833,"y":845,"style":846},"111.0","font-size:12px;font-weight:400;fill:var(--text,#172033);text-anchor:middle","rate = 1 − (salvage\u002Fcost)^(1\u002Flife)",[831,849,851],{"x":833,"y":850,"style":846},"137.0","rounded to 3 decimals",[831,853,855],{"x":833,"y":854,"style":846},"163.0","month argument: partial first year",[802,857],{"x":858,"y":812,"width":813,"height":814,"rx":815,"fill":859,"stroke":860,"style":818},"389.0","#d9f4f1","var(--teal,#0f9488)",[820,862,864],{"transform":863},"translate(551.5,29.0) scale(1.083)",[824,865],{"d":866,"fill":827,"stroke":867,"style":829},"M12 3l9 5-9 5-9-5z M3 13l9 5 9-5 M3 17l9 5 9-5","var(--teal-ink,#0b6157)",[831,869,872],{"x":870,"y":834,"style":871},"564.5","font-size:14px;font-weight:700;fill:var(--teal-ink,#0b6157);text-anchor:middle","DDB (double-declining)",[66,874],{"x1":875,"y1":840,"x2":876,"y2":840,"stroke":860,"style":842},"405.0","724.0",[831,878,879],{"x":870,"y":845,"style":846},"factor ÷ life × book value",[831,881,882],{"x":870,"y":850,"style":846},"capped so book ≥ salvage",[831,884,885],{"x":870,"y":854,"style":846},"never switches to straight line",[50,887,889],{"id":888},"step-3-ddb-double-declining-without-a-switch","Step 3 — DDB: double-declining, without a switch",[10,891,892,895,896,899,900,903],{},[14,893,894],{},"DDB(cost, salvage, life, period, [factor])"," charges ",[14,897,898],{},"factor \u002F life"," of the remaining book value each period (factor 2 by default), but never takes book value below salvage. It does ",[362,901,902],{},"not"," switch to straight line when that would give a larger charge:",[55,905,907],{"className":102,"code":906,"language":104,"meta":60,"style":60},"def ddb(cost, salvage, life, period, factor=2):\n    book = cost\n    for p in range(1, period + 1):\n        dep = min(book * factor \u002F life, max(book - salvage, 0))\n        book -= dep\n    return dep\n\ncharges = [round(ddb(COST, SALVAGE, LIFE, p), 2) for p in range(1, LIFE + 1)]\nprint(\"DDB:\", charges, \"| total:\", round(sum(charges), 2), \"of\", COST - SALVAGE)\n",[14,908,909,925,933,955,992,1000,1006,1010,1064],{"__ignoreMap":60},[64,910,911,913,916,919,921,923],{"class":66,"line":67},[64,912,112],{"class":111},[64,914,915],{"class":115}," ddb",[64,917,918],{"class":119},"(cost, salvage, life, period, factor",[64,920,387],{"class":111},[64,922,312],{"class":187},[64,924,393],{"class":119},[64,926,927,929,931],{"class":66,"line":123},[64,928,442],{"class":119},[64,930,387],{"class":111},[64,932,447],{"class":119},[64,934,935,937,939,941,943,945,947,949,951,953],{"class":66,"line":144},[64,936,452],{"class":111},[64,938,320],{"class":119},[64,940,323],{"class":111},[64,942,326],{"class":187},[64,944,259],{"class":119},[64,946,331],{"class":187},[64,948,465],{"class":119},[64,950,184],{"class":111},[64,952,188],{"class":187},[64,954,393],{"class":119},[64,956,957,960,962,965,968,970,973,975,978,981,983,985,988,990],{"class":66,"line":151},[64,958,959],{"class":119},"        dep ",[64,961,387],{"class":111},[64,963,964],{"class":187}," min",[64,966,967],{"class":119},"(book ",[64,969,173],{"class":111},[64,971,972],{"class":119}," factor ",[64,974,138],{"class":111},[64,976,977],{"class":119}," life, ",[64,979,980],{"class":187},"max",[64,982,967],{"class":119},[64,984,132],{"class":111},[64,986,987],{"class":119}," salvage, ",[64,989,805],{"class":187},[64,991,212],{"class":119},[64,993,994,996,998],{"class":66,"line":162},[64,995,584],{"class":119},[64,997,587],{"class":111},[64,999,590],{"class":119},[64,1001,1002,1004],{"class":66,"line":215},[64,1003,126],{"class":111},[64,1005,590],{"class":119},[64,1007,1008],{"class":66,"line":220},[64,1009,148],{"emptyLinePlaceholder":147},[64,1011,1012,1015,1017,1020,1022,1025,1027,1029,1031,1033,1035,1037,1039,1041,1043,1045,1047,1049,1051,1053,1055,1057,1059,1061],{"class":66,"line":253},[64,1013,1014],{"class":119},"charges ",[64,1016,387],{"class":111},[64,1018,1019],{"class":119}," [",[64,1021,293],{"class":187},[64,1023,1024],{"class":119},"(ddb(",[64,1026,223],{"class":187},[64,1028,226],{"class":119},[64,1030,229],{"class":187},[64,1032,226],{"class":119},[64,1034,234],{"class":187},[64,1036,309],{"class":119},[64,1038,312],{"class":187},[64,1040,191],{"class":119},[64,1042,317],{"class":111},[64,1044,320],{"class":119},[64,1046,323],{"class":111},[64,1048,326],{"class":187},[64,1050,259],{"class":119},[64,1052,331],{"class":187},[64,1054,226],{"class":119},[64,1056,234],{"class":187},[64,1058,338],{"class":111},[64,1060,188],{"class":187},[64,1062,1063],{"class":119},")]\n",[64,1065,1066,1068,1070,1073,1076,1079,1081,1083,1085,1088,1091,1093,1095,1098,1100,1102,1104,1107],{"class":66,"line":280},[64,1067,256],{"class":187},[64,1069,259],{"class":119},[64,1071,1072],{"class":74},"\"DDB:\"",[64,1074,1075],{"class":119},", charges, ",[64,1077,1078],{"class":74},"\"| total:\"",[64,1080,226],{"class":119},[64,1082,293],{"class":187},[64,1084,259],{"class":119},[64,1086,1087],{"class":187},"sum",[64,1089,1090],{"class":119},"(charges), ",[64,1092,312],{"class":187},[64,1094,647],{"class":119},[64,1096,1097],{"class":74},"\"of\"",[64,1099,226],{"class":119},[64,1101,223],{"class":187},[64,1103,410],{"class":111},[64,1105,1106],{"class":187}," SALVAGE",[64,1108,437],{"class":119},[10,1110,1111,1112,1114,1115,1117,1118,1120],{},"Year 1 charges 40% of 30,000 — 12,000 — and each following year 40% of what remains. With these figures the cap bites in the last year — book value is not allowed below 3,000 — and the total happens to reach the full 27,000. With a lower salvage value, or a longer life, ",[14,1113,28],{}," leaves part of the depreciable amount undepreciated at the end of the life, because the declining charge shrinks faster than the remaining amount. That is the behaviour to reproduce if a workbook uses ",[14,1116,28],{},"; it is usually not the accounting treatment people intend, which is what ",[14,1119,32],{}," is for.",[50,1122,1124],{"id":1123},"step-4-vdb-declining-balance-that-switches-to-straight-line","Step 4 — VDB: declining balance that switches to straight line",[10,1126,1127,1130],{},[14,1128,1129],{},"VDB(cost, salvage, life, start, end, [factor], [no_switch])"," returns the depreciation between two periods. By default it switches to straight line when the straight-line charge over the remaining life exceeds the declining charge, so the asset always reaches its salvage value:",[55,1132,1134],{"className":102,"code":1133,"language":104,"meta":60,"style":60},"def vdb_schedule(cost, salvage, life, factor=2, switch=True):\n    book, out = cost, []\n    for p in range(1, life + 1):\n        declining = book * factor \u002F life\n        straight = (book - salvage) \u002F (life - p + 1)\n        dep = max(declining, straight) if switch else declining\n        dep = min(dep, max(book - salvage, 0))\n        out.append(dep)\n        book -= dep\n    return out\n\ndef vdb(cost, salvage, life, start, end, factor=2):\n    return sum(vdb_schedule(cost, salvage, life, factor)[int(start):int(end)])\n\nlow_salvage = 1_000\nprint(\"DDB, salvage 1,000:\", [round(ddb(COST, low_salvage, LIFE, p), 2) for p in range(1, LIFE + 1)])\nprint(\"VDB, salvage 1,000:\", [round(vdb(COST, low_salvage, LIFE, p - 1, p), 2) for p in range(1, LIFE + 1)])\n",[14,1135,1136,1160,1170,1193,1210,1238,1262,1285,1290,1298,1305,1309,1325,1346,1350,1360,1410],{"__ignoreMap":60},[64,1137,1138,1140,1143,1146,1148,1150,1153,1155,1158],{"class":66,"line":67},[64,1139,112],{"class":111},[64,1141,1142],{"class":115}," vdb_schedule",[64,1144,1145],{"class":119},"(cost, salvage, life, factor",[64,1147,387],{"class":111},[64,1149,312],{"class":187},[64,1151,1152],{"class":119},", switch",[64,1154,387],{"class":111},[64,1156,1157],{"class":187},"True",[64,1159,393],{"class":119},[64,1161,1162,1165,1167],{"class":66,"line":123},[64,1163,1164],{"class":119},"    book, out ",[64,1166,387],{"class":111},[64,1168,1169],{"class":119}," cost, []\n",[64,1171,1172,1174,1176,1178,1180,1182,1184,1187,1189,1191],{"class":66,"line":144},[64,1173,452],{"class":111},[64,1175,320],{"class":119},[64,1177,323],{"class":111},[64,1179,326],{"class":187},[64,1181,259],{"class":119},[64,1183,331],{"class":187},[64,1185,1186],{"class":119},", life ",[64,1188,184],{"class":111},[64,1190,188],{"class":187},[64,1192,393],{"class":119},[64,1194,1195,1198,1200,1202,1204,1206,1208],{"class":66,"line":151},[64,1196,1197],{"class":119},"        declining ",[64,1199,387],{"class":111},[64,1201,538],{"class":119},[64,1203,173],{"class":111},[64,1205,972],{"class":119},[64,1207,138],{"class":111},[64,1209,141],{"class":119},[64,1211,1212,1215,1217,1220,1222,1224,1226,1228,1230,1232,1234,1236],{"class":66,"line":162},[64,1213,1214],{"class":119},"        straight ",[64,1216,387],{"class":111},[64,1218,1219],{"class":119}," (book ",[64,1221,132],{"class":111},[64,1223,135],{"class":119},[64,1225,138],{"class":111},[64,1227,176],{"class":119},[64,1229,132],{"class":111},[64,1231,320],{"class":119},[64,1233,184],{"class":111},[64,1235,188],{"class":187},[64,1237,437],{"class":119},[64,1239,1240,1242,1244,1247,1250,1253,1256,1259],{"class":66,"line":215},[64,1241,959],{"class":119},[64,1243,387],{"class":111},[64,1245,1246],{"class":187}," max",[64,1248,1249],{"class":119},"(declining, straight) ",[64,1251,1252],{"class":111},"if",[64,1254,1255],{"class":119}," switch ",[64,1257,1258],{"class":111},"else",[64,1260,1261],{"class":119}," declining\n",[64,1263,1264,1266,1268,1270,1273,1275,1277,1279,1281,1283],{"class":66,"line":220},[64,1265,959],{"class":119},[64,1267,387],{"class":111},[64,1269,964],{"class":187},[64,1271,1272],{"class":119},"(dep, ",[64,1274,980],{"class":187},[64,1276,967],{"class":119},[64,1278,132],{"class":111},[64,1280,987],{"class":119},[64,1282,805],{"class":187},[64,1284,212],{"class":119},[64,1286,1287],{"class":66,"line":253},[64,1288,1289],{"class":119},"        out.append(dep)\n",[64,1291,1292,1294,1296],{"class":66,"line":280},[64,1293,584],{"class":119},[64,1295,587],{"class":111},[64,1297,590],{"class":119},[64,1299,1300,1302],{"class":66,"line":567},[64,1301,126],{"class":111},[64,1303,1304],{"class":119}," out\n",[64,1306,1307],{"class":66,"line":581},[64,1308,148],{"emptyLinePlaceholder":147},[64,1310,1311,1313,1316,1319,1321,1323],{"class":66,"line":593},[64,1312,112],{"class":111},[64,1314,1315],{"class":115}," vdb",[64,1317,1318],{"class":119},"(cost, salvage, life, start, end, factor",[64,1320,387],{"class":111},[64,1322,312],{"class":187},[64,1324,393],{"class":119},[64,1326,1327,1329,1332,1335,1338,1341,1343],{"class":66,"line":600},[64,1328,126],{"class":111},[64,1330,1331],{"class":187}," sum",[64,1333,1334],{"class":119},"(vdb_schedule(cost, salvage, life, factor)[",[64,1336,1337],{"class":187},"int",[64,1339,1340],{"class":119},"(start):",[64,1342,1337],{"class":187},[64,1344,1345],{"class":119},"(end)])\n",[64,1347,1348],{"class":66,"line":605},[64,1349,148],{"emptyLinePlaceholder":147},[64,1351,1352,1355,1357],{"class":66,"line":654},[64,1353,1354],{"class":119},"low_salvage ",[64,1356,387],{"class":111},[64,1358,1359],{"class":187}," 1_000\n",[64,1361,1362,1364,1366,1369,1371,1373,1375,1377,1380,1382,1384,1386,1388,1390,1392,1394,1396,1398,1400,1402,1404,1406,1408],{"class":66,"line":709},[64,1363,256],{"class":187},[64,1365,259],{"class":119},[64,1367,1368],{"class":74},"\"DDB, salvage 1,000:\"",[64,1370,290],{"class":119},[64,1372,293],{"class":187},[64,1374,1024],{"class":119},[64,1376,223],{"class":187},[64,1378,1379],{"class":119},", low_salvage, ",[64,1381,234],{"class":187},[64,1383,309],{"class":119},[64,1385,312],{"class":187},[64,1387,191],{"class":119},[64,1389,317],{"class":111},[64,1391,320],{"class":119},[64,1393,323],{"class":111},[64,1395,326],{"class":187},[64,1397,259],{"class":119},[64,1399,331],{"class":187},[64,1401,226],{"class":119},[64,1403,234],{"class":187},[64,1405,338],{"class":111},[64,1407,188],{"class":187},[64,1409,343],{"class":119},[64,1411,1413,1415,1417,1420,1422,1424,1427,1429,1431,1433,1436,1438,1440,1442,1444,1446,1448,1450,1452,1454,1456,1458,1460,1462,1464,1466],{"class":66,"line":1412},17,[64,1414,256],{"class":187},[64,1416,259],{"class":119},[64,1418,1419],{"class":74},"\"VDB, salvage 1,000:\"",[64,1421,290],{"class":119},[64,1423,293],{"class":187},[64,1425,1426],{"class":119},"(vdb(",[64,1428,223],{"class":187},[64,1430,1379],{"class":119},[64,1432,234],{"class":187},[64,1434,1435],{"class":119},", p ",[64,1437,132],{"class":111},[64,1439,188],{"class":187},[64,1441,309],{"class":119},[64,1443,312],{"class":187},[64,1445,191],{"class":119},[64,1447,317],{"class":111},[64,1449,320],{"class":119},[64,1451,323],{"class":111},[64,1453,326],{"class":187},[64,1455,259],{"class":119},[64,1457,331],{"class":187},[64,1459,226],{"class":119},[64,1461,234],{"class":187},[64,1463,338],{"class":111},[64,1465,188],{"class":187},[64,1467,343],{"class":119},[10,1469,1470,1471,1473,1474,1476,1477,1479],{},"With a salvage value of 1,000, ",[14,1472,28],{}," charges 1,555.20 in year 5 and ends with a book value of 2,332.80 — 1,332.80 short of salvage. ",[14,1475,32],{}," switches to straight line in year 4, when the remaining amount spread over the two remaining years is larger than the declining charge, and depreciates exactly to 1,000. This implementation covers whole periods, which is how ",[14,1478,32],{}," is nearly always used; Excel's version also accepts fractional start and end periods, which a model using them would need to add.",[783,1481,792,1487,792,1490,792,1493,792,1497,792,1503,792,1509,792,1516,792,1521,792,1524,792,1528,792,1531],{"viewBox":1482,"role":786,"ariaLabelledBy":1483,"xmlns":790,"style":1486},"4 0 727 100",[1484,1485],"dep-ddb-vdb-t","dep-ddb-vdb-d","width:100%;max-width:727px;height:auto;display:block;margin:1.5rem auto;font-family:Inter,ui-sans-serif,system-ui,sans-serif",[794,1488,1489],{"id":1484},"Book value after five years, salvage 1,000",[798,1491,1492],{"id":1485},"With a cost of 30,000, a five-year life and a salvage value of 1,000, DDB leaves a book value of 2,332.80 after five years because it never switches method. VDB switches to straight line in year four and ends exactly at the 1,000 salvage value.",[802,1494],{"x":804,"y":805,"width":1495,"height":1496,"fill":808},"727","100",[802,1498],{"x":811,"y":812,"width":1499,"height":1500,"rx":743,"fill":1501,"stroke":1502,"style":842},"130.7","28.0","#e7ebef","var(--line,#cdd5e6)",[831,1504,1508],{"x":1505,"y":1506,"style":1507},"85.4","34.5","font-size:12.5px;font-weight:700;fill:var(--text,#172033);text-anchor:middle","DDB (no switch)",[802,1510],{"x":1511,"y":812,"width":1512,"height":1500,"rx":743,"fill":1513,"stroke":1514,"style":1515},"160.7","465.5","#fce9e9","var(--danger,#dc2626)","stroke-width:1.5px",[831,1517,1520],{"x":1518,"y":1506,"style":1519},"634.2","font-size:12px;font-weight:700;fill:var(--accent-ink,#be185d);text-anchor:start","2,332.80 left",[802,1522],{"x":811,"y":1523,"width":1499,"height":1500,"rx":743,"fill":1501,"stroke":1502,"style":842},"56.0",[831,1525,1527],{"x":1505,"y":1526,"style":1507},"74.5","VDB (switches)",[802,1529],{"x":1511,"y":1523,"width":1530,"height":1500,"rx":743,"fill":859,"stroke":860,"style":1515},"199.5",[831,1532,1535],{"x":1533,"y":1526,"style":1534},"368.3","font-size:12px;font-weight:700;fill:var(--teal-ink,#0b6157);text-anchor:start","1,000 = salvage",[50,1537,1539],{"id":1538},"step-5-schedules-in-pandas-checked-against-the-spreadsheet","Step 5 — Schedules in pandas, checked against the spreadsheet",[10,1541,1542],{},"Lay all five methods out side by side, then write the equivalent formulas into a workbook, recalculate, and compare every period:",[55,1544,1546],{"className":102,"code":1545,"language":104,"meta":60,"style":60},"import subprocess\nimport pandas as pd\nfrom openpyxl import Workbook, load_workbook\n\nyears = range(1, LIFE + 1)\nsched = pd.DataFrame({\n    \"Year\": list(years),\n    \"SLN\": [sln(COST, SALVAGE, LIFE)] * LIFE,\n    \"SYD\": [syd(COST, SALVAGE, LIFE, p) for p in years],\n    \"DB\": [db(COST, SALVAGE, LIFE, p) for p in years],\n    \"DDB\": [ddb(COST, SALVAGE, LIFE, p) for p in years],\n    \"VDB\": [vdb(COST, SALVAGE, LIFE, p - 1, p) for p in years],\n}).round(2)\nprint(sched.to_string(index=False))\n\nwb = Workbook()\nws = wb.active\nfor i, p in enumerate(years, start=1):\n    ws.append([f\"=SLN({COST},{SALVAGE},{LIFE})\", f\"=SYD({COST},{SALVAGE},{LIFE},{p})\", f\"=DB({COST},{SALVAGE},{LIFE},{p})\",\n               f\"=DDB({COST},{SALVAGE},{LIFE},{p})\", f\"=VDB({COST},{SALVAGE},{LIFE},{p - 1},{p})\",\n               f\"=DB({COST},{SALVAGE},{LIFE},{p},7)\", f\"=DDB({COST},{low_salvage},{LIFE},{p})\"])\nwb.save(\"dep.xlsx\")\nsubprocess.run([\"soffice\", \"--headless\", \"--convert-to\", \"xlsx\", \"--outdir\", \"calc\", \"dep.xlsx\"], check=True, capture_output=True)\ncalc = load_workbook(\"calc\u002Fdep.xlsx\", data_only=True).active\nours = [[sln(COST, SALVAGE, LIFE), syd(COST, SALVAGE, LIFE, p), db(COST, SALVAGE, LIFE, p), ddb(COST, SALVAGE, LIFE, p),\n         vdb(COST, SALVAGE, LIFE, p - 1, p), db(COST, SALVAGE, LIFE, p, 7), ddb(COST, low_salvage, LIFE, p)] for p in years]\ndiffs = [abs(calc.cell(r, c).value - ours[r - 1][c - 1]) for r in range(1, LIFE + 1) for c in range(1, 8)]\nprint(f\"{len(diffs)} values compared, largest difference: {max(diffs):.10f}\")\n",[14,1547,1548,1556,1569,1582,1586,1609,1619,1633,1661,1691,1719,1747,1781,1790,1807,1811,1821,1831,1856,1977,2072,2154,2165,2224,2250,2313,2372,2450],{"__ignoreMap":60},[64,1549,1550,1553],{"class":66,"line":67},[64,1551,1552],{"class":111},"import",[64,1554,1555],{"class":119}," subprocess\n",[64,1557,1558,1560,1563,1566],{"class":66,"line":123},[64,1559,1552],{"class":111},[64,1561,1562],{"class":119}," pandas ",[64,1564,1565],{"class":111},"as",[64,1567,1568],{"class":119}," pd\n",[64,1570,1571,1574,1577,1579],{"class":66,"line":144},[64,1572,1573],{"class":111},"from",[64,1575,1576],{"class":119}," openpyxl ",[64,1578,1552],{"class":111},[64,1580,1581],{"class":119}," Workbook, load_workbook\n",[64,1583,1584],{"class":66,"line":151},[64,1585,148],{"emptyLinePlaceholder":147},[64,1587,1588,1591,1593,1595,1597,1599,1601,1603,1605,1607],{"class":66,"line":162},[64,1589,1590],{"class":119},"years ",[64,1592,387],{"class":111},[64,1594,326],{"class":187},[64,1596,259],{"class":119},[64,1598,331],{"class":187},[64,1600,226],{"class":119},[64,1602,234],{"class":187},[64,1604,338],{"class":111},[64,1606,188],{"class":187},[64,1608,437],{"class":119},[64,1610,1611,1614,1616],{"class":66,"line":215},[64,1612,1613],{"class":119},"sched ",[64,1615,387],{"class":111},[64,1617,1618],{"class":119}," pd.DataFrame({\n",[64,1620,1621,1624,1627,1630],{"class":66,"line":220},[64,1622,1623],{"class":74},"    \"Year\"",[64,1625,1626],{"class":119},": ",[64,1628,1629],{"class":187},"list",[64,1631,1632],{"class":119},"(years),\n",[64,1634,1635,1638,1641,1643,1645,1647,1649,1651,1654,1656,1658],{"class":66,"line":253},[64,1636,1637],{"class":74},"    \"SLN\"",[64,1639,1640],{"class":119},": [sln(",[64,1642,223],{"class":187},[64,1644,226],{"class":119},[64,1646,229],{"class":187},[64,1648,226],{"class":119},[64,1650,234],{"class":187},[64,1652,1653],{"class":119},")] ",[64,1655,173],{"class":111},[64,1657,644],{"class":187},[64,1659,1660],{"class":119},",\n",[64,1662,1663,1666,1669,1671,1673,1675,1677,1679,1682,1684,1686,1688],{"class":66,"line":280},[64,1664,1665],{"class":74},"    \"SYD\"",[64,1667,1668],{"class":119},": [syd(",[64,1670,223],{"class":187},[64,1672,226],{"class":119},[64,1674,229],{"class":187},[64,1676,226],{"class":119},[64,1678,234],{"class":187},[64,1680,1681],{"class":119},", p) ",[64,1683,317],{"class":111},[64,1685,320],{"class":119},[64,1687,323],{"class":111},[64,1689,1690],{"class":119}," years],\n",[64,1692,1693,1696,1699,1701,1703,1705,1707,1709,1711,1713,1715,1717],{"class":66,"line":567},[64,1694,1695],{"class":74},"    \"DB\"",[64,1697,1698],{"class":119},": [db(",[64,1700,223],{"class":187},[64,1702,226],{"class":119},[64,1704,229],{"class":187},[64,1706,226],{"class":119},[64,1708,234],{"class":187},[64,1710,1681],{"class":119},[64,1712,317],{"class":111},[64,1714,320],{"class":119},[64,1716,323],{"class":111},[64,1718,1690],{"class":119},[64,1720,1721,1724,1727,1729,1731,1733,1735,1737,1739,1741,1743,1745],{"class":66,"line":581},[64,1722,1723],{"class":74},"    \"DDB\"",[64,1725,1726],{"class":119},": [ddb(",[64,1728,223],{"class":187},[64,1730,226],{"class":119},[64,1732,229],{"class":187},[64,1734,226],{"class":119},[64,1736,234],{"class":187},[64,1738,1681],{"class":119},[64,1740,317],{"class":111},[64,1742,320],{"class":119},[64,1744,323],{"class":111},[64,1746,1690],{"class":119},[64,1748,1749,1752,1755,1757,1759,1761,1763,1765,1767,1769,1771,1773,1775,1777,1779],{"class":66,"line":593},[64,1750,1751],{"class":74},"    \"VDB\"",[64,1753,1754],{"class":119},": [vdb(",[64,1756,223],{"class":187},[64,1758,226],{"class":119},[64,1760,229],{"class":187},[64,1762,226],{"class":119},[64,1764,234],{"class":187},[64,1766,1435],{"class":119},[64,1768,132],{"class":111},[64,1770,188],{"class":187},[64,1772,1681],{"class":119},[64,1774,317],{"class":111},[64,1776,320],{"class":119},[64,1778,323],{"class":111},[64,1780,1690],{"class":119},[64,1782,1783,1786,1788],{"class":66,"line":600},[64,1784,1785],{"class":119},"}).round(",[64,1787,312],{"class":187},[64,1789,437],{"class":119},[64,1791,1792,1794,1797,1800,1802,1805],{"class":66,"line":605},[64,1793,256],{"class":187},[64,1795,1796],{"class":119},"(sched.to_string(",[64,1798,1799],{"class":738},"index",[64,1801,387],{"class":111},[64,1803,1804],{"class":187},"False",[64,1806,212],{"class":119},[64,1808,1809],{"class":66,"line":654},[64,1810,148],{"emptyLinePlaceholder":147},[64,1812,1813,1816,1818],{"class":66,"line":709},[64,1814,1815],{"class":119},"wb ",[64,1817,387],{"class":111},[64,1819,1820],{"class":119}," Workbook()\n",[64,1822,1823,1826,1828],{"class":66,"line":1412},[64,1824,1825],{"class":119},"ws ",[64,1827,387],{"class":111},[64,1829,1830],{"class":119}," wb.active\n",[64,1832,1834,1836,1839,1841,1844,1847,1850,1852,1854],{"class":66,"line":1833},18,[64,1835,317],{"class":111},[64,1837,1838],{"class":119}," i, p ",[64,1840,323],{"class":111},[64,1842,1843],{"class":187}," enumerate",[64,1845,1846],{"class":119},"(years, ",[64,1848,1849],{"class":738},"start",[64,1851,387],{"class":111},[64,1853,331],{"class":187},[64,1855,393],{"class":119},[64,1857,1859,1862,1865,1868,1872,1874,1877,1880,1882,1884,1886,1888,1890,1892,1894,1897,1899,1901,1904,1906,1908,1910,1912,1914,1916,1918,1920,1922,1924,1926,1928,1930,1932,1934,1936,1938,1940,1943,1945,1947,1949,1951,1953,1955,1957,1959,1961,1963,1965,1967,1969,1971,1973,1975],{"class":66,"line":1858},19,[64,1860,1861],{"class":119},"    ws.append([",[64,1863,1864],{"class":111},"f",[64,1866,1867],{"class":74},"\"=SLN(",[64,1869,1871],{"class":1870},"sSjpA","{",[64,1873,223],{"class":187},[64,1875,1876],{"class":1870},"}",[64,1878,1879],{"class":74},",",[64,1881,1871],{"class":1870},[64,1883,229],{"class":187},[64,1885,1876],{"class":1870},[64,1887,1879],{"class":74},[64,1889,1871],{"class":1870},[64,1891,234],{"class":187},[64,1893,1876],{"class":1870},[64,1895,1896],{"class":74},")\"",[64,1898,226],{"class":119},[64,1900,1864],{"class":111},[64,1902,1903],{"class":74},"\"=SYD(",[64,1905,1871],{"class":1870},[64,1907,223],{"class":187},[64,1909,1876],{"class":1870},[64,1911,1879],{"class":74},[64,1913,1871],{"class":1870},[64,1915,229],{"class":187},[64,1917,1876],{"class":1870},[64,1919,1879],{"class":74},[64,1921,1871],{"class":1870},[64,1923,234],{"class":187},[64,1925,1876],{"class":1870},[64,1927,1879],{"class":74},[64,1929,1871],{"class":1870},[64,1931,10],{"class":119},[64,1933,1876],{"class":1870},[64,1935,1896],{"class":74},[64,1937,226],{"class":119},[64,1939,1864],{"class":111},[64,1941,1942],{"class":74},"\"=DB(",[64,1944,1871],{"class":1870},[64,1946,223],{"class":187},[64,1948,1876],{"class":1870},[64,1950,1879],{"class":74},[64,1952,1871],{"class":1870},[64,1954,229],{"class":187},[64,1956,1876],{"class":1870},[64,1958,1879],{"class":74},[64,1960,1871],{"class":1870},[64,1962,234],{"class":187},[64,1964,1876],{"class":1870},[64,1966,1879],{"class":74},[64,1968,1871],{"class":1870},[64,1970,10],{"class":119},[64,1972,1876],{"class":1870},[64,1974,1896],{"class":74},[64,1976,1660],{"class":119},[64,1978,1980,1983,1986,1988,1990,1992,1994,1996,1998,2000,2002,2004,2006,2008,2010,2012,2014,2016,2018,2020,2022,2025,2027,2029,2031,2033,2035,2037,2039,2041,2043,2045,2047,2049,2051,2054,2056,2058,2060,2062,2064,2066,2068,2070],{"class":66,"line":1979},20,[64,1981,1982],{"class":111},"               f",[64,1984,1985],{"class":74},"\"=DDB(",[64,1987,1871],{"class":1870},[64,1989,223],{"class":187},[64,1991,1876],{"class":1870},[64,1993,1879],{"class":74},[64,1995,1871],{"class":1870},[64,1997,229],{"class":187},[64,1999,1876],{"class":1870},[64,2001,1879],{"class":74},[64,2003,1871],{"class":1870},[64,2005,234],{"class":187},[64,2007,1876],{"class":1870},[64,2009,1879],{"class":74},[64,2011,1871],{"class":1870},[64,2013,10],{"class":119},[64,2015,1876],{"class":1870},[64,2017,1896],{"class":74},[64,2019,226],{"class":119},[64,2021,1864],{"class":111},[64,2023,2024],{"class":74},"\"=VDB(",[64,2026,1871],{"class":1870},[64,2028,223],{"class":187},[64,2030,1876],{"class":1870},[64,2032,1879],{"class":74},[64,2034,1871],{"class":1870},[64,2036,229],{"class":187},[64,2038,1876],{"class":1870},[64,2040,1879],{"class":74},[64,2042,1871],{"class":1870},[64,2044,234],{"class":187},[64,2046,1876],{"class":1870},[64,2048,1879],{"class":74},[64,2050,1871],{"class":1870},[64,2052,2053],{"class":119},"p ",[64,2055,132],{"class":111},[64,2057,188],{"class":187},[64,2059,1876],{"class":1870},[64,2061,1879],{"class":74},[64,2063,1871],{"class":1870},[64,2065,10],{"class":119},[64,2067,1876],{"class":1870},[64,2069,1896],{"class":74},[64,2071,1660],{"class":119},[64,2073,2075,2077,2079,2081,2083,2085,2087,2089,2091,2093,2095,2097,2099,2101,2103,2105,2107,2109,2112,2114,2116,2118,2120,2122,2124,2126,2128,2131,2133,2135,2137,2139,2141,2143,2145,2147,2149,2151],{"class":66,"line":2074},21,[64,2076,1982],{"class":111},[64,2078,1942],{"class":74},[64,2080,1871],{"class":1870},[64,2082,223],{"class":187},[64,2084,1876],{"class":1870},[64,2086,1879],{"class":74},[64,2088,1871],{"class":1870},[64,2090,229],{"class":187},[64,2092,1876],{"class":1870},[64,2094,1879],{"class":74},[64,2096,1871],{"class":1870},[64,2098,234],{"class":187},[64,2100,1876],{"class":1870},[64,2102,1879],{"class":74},[64,2104,1871],{"class":1870},[64,2106,10],{"class":119},[64,2108,1876],{"class":1870},[64,2110,2111],{"class":74},",7)\"",[64,2113,226],{"class":119},[64,2115,1864],{"class":111},[64,2117,1985],{"class":74},[64,2119,1871],{"class":1870},[64,2121,223],{"class":187},[64,2123,1876],{"class":1870},[64,2125,1879],{"class":74},[64,2127,1871],{"class":1870},[64,2129,2130],{"class":119},"low_salvage",[64,2132,1876],{"class":1870},[64,2134,1879],{"class":74},[64,2136,1871],{"class":1870},[64,2138,234],{"class":187},[64,2140,1876],{"class":1870},[64,2142,1879],{"class":74},[64,2144,1871],{"class":1870},[64,2146,10],{"class":119},[64,2148,1876],{"class":1870},[64,2150,1896],{"class":74},[64,2152,2153],{"class":119},"])\n",[64,2155,2157,2160,2163],{"class":66,"line":2156},22,[64,2158,2159],{"class":119},"wb.save(",[64,2161,2162],{"class":74},"\"dep.xlsx\"",[64,2164,437],{"class":119},[64,2166,2168,2171,2174,2176,2179,2181,2184,2186,2189,2191,2194,2196,2199,2201,2203,2206,2209,2211,2213,2215,2218,2220,2222],{"class":66,"line":2167},23,[64,2169,2170],{"class":119},"subprocess.run([",[64,2172,2173],{"class":74},"\"soffice\"",[64,2175,226],{"class":119},[64,2177,2178],{"class":74},"\"--headless\"",[64,2180,226],{"class":119},[64,2182,2183],{"class":74},"\"--convert-to\"",[64,2185,226],{"class":119},[64,2187,2188],{"class":74},"\"xlsx\"",[64,2190,226],{"class":119},[64,2192,2193],{"class":74},"\"--outdir\"",[64,2195,226],{"class":119},[64,2197,2198],{"class":74},"\"calc\"",[64,2200,226],{"class":119},[64,2202,2162],{"class":74},[64,2204,2205],{"class":119},"], ",[64,2207,2208],{"class":738},"check",[64,2210,387],{"class":111},[64,2212,1157],{"class":187},[64,2214,226],{"class":119},[64,2216,2217],{"class":738},"capture_output",[64,2219,387],{"class":111},[64,2221,1157],{"class":187},[64,2223,437],{"class":119},[64,2225,2227,2230,2232,2235,2238,2240,2243,2245,2247],{"class":66,"line":2226},24,[64,2228,2229],{"class":119},"calc ",[64,2231,387],{"class":111},[64,2233,2234],{"class":119}," load_workbook(",[64,2236,2237],{"class":74},"\"calc\u002Fdep.xlsx\"",[64,2239,226],{"class":119},[64,2241,2242],{"class":738},"data_only",[64,2244,387],{"class":111},[64,2246,1157],{"class":187},[64,2248,2249],{"class":119},").active\n",[64,2251,2253,2256,2258,2261,2263,2265,2267,2269,2271,2274,2276,2278,2280,2282,2284,2287,2289,2291,2293,2295,2297,2300,2302,2304,2306,2308,2310],{"class":66,"line":2252},25,[64,2254,2255],{"class":119},"ours ",[64,2257,387],{"class":111},[64,2259,2260],{"class":119}," [[sln(",[64,2262,223],{"class":187},[64,2264,226],{"class":119},[64,2266,229],{"class":187},[64,2268,226],{"class":119},[64,2270,234],{"class":187},[64,2272,2273],{"class":119},"), syd(",[64,2275,223],{"class":187},[64,2277,226],{"class":119},[64,2279,229],{"class":187},[64,2281,226],{"class":119},[64,2283,234],{"class":187},[64,2285,2286],{"class":119},", p), db(",[64,2288,223],{"class":187},[64,2290,226],{"class":119},[64,2292,229],{"class":187},[64,2294,226],{"class":119},[64,2296,234],{"class":187},[64,2298,2299],{"class":119},", p), ddb(",[64,2301,223],{"class":187},[64,2303,226],{"class":119},[64,2305,229],{"class":187},[64,2307,226],{"class":119},[64,2309,234],{"class":187},[64,2311,2312],{"class":119},", p),\n",[64,2314,2316,2319,2321,2323,2325,2327,2329,2331,2333,2335,2337,2339,2341,2343,2345,2347,2349,2351,2354,2356,2358,2360,2363,2365,2367,2369],{"class":66,"line":2315},26,[64,2317,2318],{"class":119},"         vdb(",[64,2320,223],{"class":187},[64,2322,226],{"class":119},[64,2324,229],{"class":187},[64,2326,226],{"class":119},[64,2328,234],{"class":187},[64,2330,1435],{"class":119},[64,2332,132],{"class":111},[64,2334,188],{"class":187},[64,2336,2286],{"class":119},[64,2338,223],{"class":187},[64,2340,226],{"class":119},[64,2342,229],{"class":187},[64,2344,226],{"class":119},[64,2346,234],{"class":187},[64,2348,735],{"class":119},[64,2350,743],{"class":187},[64,2352,2353],{"class":119},"), ddb(",[64,2355,223],{"class":187},[64,2357,1379],{"class":119},[64,2359,234],{"class":187},[64,2361,2362],{"class":119},", p)] ",[64,2364,317],{"class":111},[64,2366,320],{"class":119},[64,2368,323],{"class":111},[64,2370,2371],{"class":119}," years]\n",[64,2373,2375,2378,2380,2382,2385,2388,2390,2393,2395,2397,2400,2402,2404,2407,2409,2412,2414,2416,2418,2420,2422,2424,2426,2428,2430,2432,2435,2437,2439,2441,2443,2445,2448],{"class":66,"line":2374},27,[64,2376,2377],{"class":119},"diffs ",[64,2379,387],{"class":111},[64,2381,1019],{"class":119},[64,2383,2384],{"class":187},"abs",[64,2386,2387],{"class":119},"(calc.cell(r, c).value ",[64,2389,132],{"class":111},[64,2391,2392],{"class":119}," ours[r ",[64,2394,132],{"class":111},[64,2396,188],{"class":187},[64,2398,2399],{"class":119},"][c ",[64,2401,132],{"class":111},[64,2403,188],{"class":187},[64,2405,2406],{"class":119},"]) ",[64,2408,317],{"class":111},[64,2410,2411],{"class":119}," r ",[64,2413,323],{"class":111},[64,2415,326],{"class":187},[64,2417,259],{"class":119},[64,2419,331],{"class":187},[64,2421,226],{"class":119},[64,2423,234],{"class":187},[64,2425,338],{"class":111},[64,2427,188],{"class":187},[64,2429,191],{"class":119},[64,2431,317],{"class":111},[64,2433,2434],{"class":119}," c ",[64,2436,323],{"class":111},[64,2438,326],{"class":187},[64,2440,259],{"class":119},[64,2442,331],{"class":187},[64,2444,226],{"class":119},[64,2446,2447],{"class":187},"8",[64,2449,1063],{"class":119},[64,2451,2453,2455,2457,2459,2462,2464,2467,2470,2472,2475,2477,2479,2481,2484,2486,2488],{"class":66,"line":2452},28,[64,2454,256],{"class":187},[64,2456,259],{"class":119},[64,2458,1864],{"class":111},[64,2460,2461],{"class":74},"\"",[64,2463,1871],{"class":1870},[64,2465,2466],{"class":187},"len",[64,2468,2469],{"class":119},"(diffs)",[64,2471,1876],{"class":1870},[64,2473,2474],{"class":74}," values compared, largest difference: ",[64,2476,1871],{"class":1870},[64,2478,980],{"class":187},[64,2480,2469],{"class":119},[64,2482,2483],{"class":111},":.10f",[64,2485,1876],{"class":1870},[64,2487,2461],{"class":74},[64,2489,437],{"class":119},[10,2491,2492,2493,2495,2496,2498],{},"The schedule shows the five methods' very different shapes for the same asset: level for SLN, steep then shallow for SYD, DB and DDB, and VDB tracking DDB until it switches. All 35 spreadsheet values — five methods, plus DB with a partial first year and DDB with the lower salvage, for five years each — match the Python functions to rounding error. Keeping this comparison as a test protects the quirks (the rounded ",[14,2494,24],{}," rate, the missing ",[14,2497,28],{}," switch) from being \"fixed\" by someone who assumes they are bugs.",[783,2500,792,2506,792,2509,792,2512,792,2517,792,2522,792,2526,792,2532,792,2536,792,2540,792,2544,792,2548,792,2552,792,2556,792,2560,792,2564,792,2567,792,2571,792,2573,792,2577,792,2579,792,2581,792,2583,792,2585,792,2587,792,2589,792,2591,792,2594,792,2597,792,2600,792,2602,792,2605,792,2607,792,2610,792,2612,792,2615,792,2617,792,2620,792,2622,792,2625,792,2628,792,2631,792,2633,792,2635,792,2637,792,2639,792,2641,792,2644,792,2646,792,2649,792,2651,792,2653,792,2656,792,2659,792,2661,792,2663,792,2665,792,2667,792,2669,792,2671,792,2673,792,2676,792,2678,792,2681,792,2684,792,2688,792,2690,792,2692,792,2694,792,2696,792,2698,792,2701,792,2703,792,2706,792,2708,792,2711,792,2714,792,2718,792,2720,792,2722,792,2724,792,2726,792,2728,792,2731,792,2733,792,2736,792,2738],{"viewBox":2501,"role":786,"ariaLabelledBy":2502,"xmlns":790,"style":2505},"187 0 385 224",[2503,2504],"dep-sched-t","dep-sched-d","width:100%;max-width:385px;height:auto;display:block;margin:1.5rem auto;font-family:Inter,ui-sans-serif,system-ui,sans-serif",[794,2507,2508],{"id":2503},"Five methods, one asset",[798,2510,2511],{"id":2504},"For an asset costing 30,000 with 3,000 salvage over five years, SLN charges 5,400 every year, SYD 9,000 falling to 1,800, DB 11,070 falling to 1,754.95, and DDB and VDB 12,000 falling to 888. All five total close to or exactly 27,000.",[802,2513],{"x":2514,"y":805,"width":2515,"height":2516,"fill":808},"187","385","224",[802,2518],{"x":2519,"y":812,"width":2520,"height":2521,"rx":805,"fill":1501,"stroke":1502,"style":842},"203.6","32.0","24.0",[802,2523],{"x":2524,"y":812,"width":2525,"height":2521,"rx":805,"fill":1501,"stroke":1502,"style":842},"235.6","49.5",[831,2527,2531],{"x":2528,"y":2529,"style":2530},"260.4","33.0","font-size:11px;font-weight:600;fill:var(--muted,#5b6780);text-anchor:middle","A",[802,2533],{"x":2534,"y":812,"width":2535,"height":2521,"rx":805,"fill":1501,"stroke":1502,"style":842},"285.2","56.9",[831,2537,2539],{"x":2538,"y":2529,"style":2530},"313.6","B",[802,2541],{"x":2542,"y":812,"width":2543,"height":2521,"rx":805,"fill":1501,"stroke":1502,"style":842},"342.0","57.1",[831,2545,2547],{"x":2546,"y":2529,"style":2530},"370.6","C",[802,2549],{"x":2550,"y":812,"width":2551,"height":2521,"rx":805,"fill":1501,"stroke":1502,"style":842},"399.1","77.0",[831,2553,2555],{"x":2554,"y":2529,"style":2530},"437.6","D",[802,2557],{"x":2558,"y":812,"width":2559,"height":2521,"rx":805,"fill":1501,"stroke":1502,"style":842},"476.1","80.2",[831,2561,2563],{"x":2562,"y":2529,"style":2530},"516.3","E",[802,2565],{"x":2519,"y":2566,"width":2520,"height":1500,"rx":805,"fill":1501,"stroke":1502,"style":842},"40.0",[831,2568,331],{"x":2569,"y":2570,"style":2530},"219.6","59.0",[802,2572],{"x":2524,"y":2566,"width":2525,"height":1500,"rx":805,"fill":816,"stroke":817,"style":1515},[831,2574,2576],{"x":2528,"y":2570,"style":2575},"font-size:10.5px;font-weight:700;fill:var(--brand-strong,#4338ca);text-anchor:middle","Year",[802,2578],{"x":2534,"y":2566,"width":2535,"height":1500,"rx":805,"fill":816,"stroke":817,"style":1515},[831,2580,16],{"x":2538,"y":2570,"style":2575},[802,2582],{"x":2542,"y":2566,"width":2543,"height":1500,"rx":805,"fill":816,"stroke":817,"style":1515},[831,2584,20],{"x":2546,"y":2570,"style":2575},[802,2586],{"x":2550,"y":2566,"width":2551,"height":1500,"rx":805,"fill":816,"stroke":817,"style":1515},[831,2588,24],{"x":2554,"y":2570,"style":2575},[802,2590],{"x":2558,"y":2566,"width":2559,"height":1500,"rx":805,"fill":816,"stroke":817,"style":1515},[831,2592,2593],{"x":2562,"y":2570,"style":2575},"DDB \u002F VDB",[802,2595],{"x":2519,"y":2596,"width":2520,"height":1500,"rx":805,"fill":1501,"stroke":1502,"style":842},"68.0",[831,2598,312],{"x":2569,"y":2599,"style":2530},"87.0",[802,2601],{"x":2524,"y":2596,"width":2525,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2603,331],{"x":2528,"y":2599,"style":2604},"font-size:10.5px;font-weight:400;fill:var(--text,#172033);text-anchor:middle",[802,2606],{"x":2534,"y":2596,"width":2535,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2608,2609],{"x":2538,"y":2599,"style":2604},"5,400",[802,2611],{"x":2542,"y":2596,"width":2543,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2613,2614],{"x":2546,"y":2599,"style":2604},"9,000",[802,2616],{"x":2550,"y":2596,"width":2551,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2618,2619],{"x":2554,"y":2599,"style":2604},"11,070.00",[802,2621],{"x":2558,"y":2596,"width":2559,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2623,2624],{"x":2562,"y":2599,"style":2604},"12,000",[802,2626],{"x":2519,"y":2627,"width":2520,"height":1500,"rx":805,"fill":1501,"stroke":1502,"style":842},"96.0",[831,2629,434],{"x":2569,"y":2630,"style":2530},"115.0",[802,2632],{"x":2524,"y":2627,"width":2525,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2634,312],{"x":2528,"y":2630,"style":2604},[802,2636],{"x":2534,"y":2627,"width":2535,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2638,2609],{"x":2538,"y":2630,"style":2604},[802,2640],{"x":2542,"y":2627,"width":2543,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2642,2643],{"x":2546,"y":2630,"style":2604},"7,200",[802,2645],{"x":2550,"y":2627,"width":2551,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2647,2648],{"x":2554,"y":2630,"style":2604},"6,985.17",[802,2650],{"x":2558,"y":2627,"width":2559,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2652,2643],{"x":2562,"y":2630,"style":2604},[802,2654],{"x":2519,"y":2655,"width":2520,"height":1500,"rx":805,"fill":1501,"stroke":1502,"style":842},"124.0",[831,2657,804],{"x":2569,"y":2658,"style":2530},"143.0",[802,2660],{"x":2524,"y":2655,"width":2525,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2662,434],{"x":2528,"y":2658,"style":2604},[802,2664],{"x":2534,"y":2655,"width":2535,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2666,2609],{"x":2538,"y":2658,"style":2604},[802,2668],{"x":2542,"y":2655,"width":2543,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2670,2609],{"x":2546,"y":2658,"style":2604},[802,2672],{"x":2550,"y":2655,"width":2551,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2674,2675],{"x":2554,"y":2658,"style":2604},"4,407.64",[802,2677],{"x":2558,"y":2655,"width":2559,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2679,2680],{"x":2562,"y":2658,"style":2604},"4,320",[802,2682],{"x":2519,"y":2683,"width":2520,"height":1500,"rx":805,"fill":1501,"stroke":1502,"style":842},"152.0",[831,2685,2687],{"x":2569,"y":2686,"style":2530},"171.0","5",[802,2689],{"x":2524,"y":2683,"width":2525,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2691,804],{"x":2528,"y":2686,"style":2604},[802,2693],{"x":2534,"y":2683,"width":2535,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2695,2609],{"x":2538,"y":2686,"style":2604},[802,2697],{"x":2542,"y":2683,"width":2543,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2699,2700],{"x":2546,"y":2686,"style":2604},"3,600",[802,2702],{"x":2550,"y":2683,"width":2551,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2704,2705],{"x":2554,"y":2686,"style":2604},"2,781.22",[802,2707],{"x":2558,"y":2683,"width":2559,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2709,2710],{"x":2562,"y":2686,"style":2604},"2,592",[802,2712],{"x":2519,"y":2713,"width":2520,"height":1500,"rx":805,"fill":1501,"stroke":1502,"style":842},"180.0",[831,2715,2717],{"x":2569,"y":2716,"style":2530},"199.0","6",[802,2719],{"x":2524,"y":2713,"width":2525,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2721,2687],{"x":2528,"y":2716,"style":2604},[802,2723],{"x":2534,"y":2713,"width":2535,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2725,2609],{"x":2538,"y":2716,"style":2604},[802,2727],{"x":2542,"y":2713,"width":2543,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2729,2730],{"x":2546,"y":2716,"style":2604},"1,800",[802,2732],{"x":2550,"y":2713,"width":2551,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2734,2735],{"x":2554,"y":2716,"style":2604},"1,754.95",[802,2737],{"x":2558,"y":2713,"width":2559,"height":1500,"rx":805,"fill":808,"stroke":1502,"style":842},[831,2739,2740],{"x":2562,"y":2716,"style":2604},"888",[50,2742,2744],{"id":2743},"common-pitfalls","Common pitfalls",[2746,2747,2748,2756,2762,2768,2774],"ul",{},[2749,2750,2751,2755],"li",{},[2752,2753,2754],"strong",{},"Using the exact DB rate."," Excel rounds it to three decimals; use the rounded rate to match.",[2749,2757,2758,2761],{},[2752,2759,2760],{},"Forgetting DB's month argument."," A partial first year adds a stub period after the life.",[2749,2763,2764,2767],{},[2752,2765,2766],{},"Expecting DDB to reach salvage."," It does not switch to straight line; use VDB for that.",[2749,2769,2770,2773],{},[2752,2771,2772],{},"Rounding each period before carrying the book value."," Keep full precision, round only for display.",[2749,2775,2776,2779],{},[2752,2777,2778],{},"No comparison with the spreadsheet."," Test every method, period by period.",[50,2781,2783],{"id":2782},"conclusion","Conclusion",[10,2785,2786,2787,2789,2790,2792,2793,2795,2796,2798,2799,2802,2803,2805],{},"Excel's depreciation functions are short to implement and easy to get subtly wrong: ",[14,2788,16],{}," divides the depreciable amount evenly, ",[14,2791,20],{}," weights it by the remaining years' digits, ",[14,2794,24],{}," applies a fixed rate rounded to three decimals with an optional partial first year, ",[14,2797,28],{}," applies ",[14,2800,2801],{},"factor ÷ life"," to the book value without ever switching to straight line, and ",[14,2804,32],{}," switches when straight line gives more. Implement each separately, build schedules with pandas, and check every period against the spreadsheet functions before relying on the Python version.",[50,2807,2809],{"id":2808},"frequently-asked-questions","Frequently asked questions",[10,2811,2812,2815],{},[2752,2813,2814],{},"How do I calculate straight-line depreciation in Python?","\nSubtract the salvage value from the cost and divide by the useful life, which is what Excel's SLN function returns for each period.",[10,2817,2818,2821],{},[2752,2819,2820],{},"Why doesn't my Python DB calculation match Excel?","\nExcel rounds the fixed-declining rate to three decimal places. Calculate the rate as 1 minus salvage divided by cost to the power of one over life, round it to three decimals, then apply it.",[10,2823,2824,2827],{},[2752,2825,2826],{},"Does Excel's DDB depreciate down to the salvage value?","\nNot necessarily. DDB never switches to straight line, so with some inputs the book value stays above salvage at the end of the life. VDB switches and reaches the salvage value.",[10,2829,2830,2833],{},[2752,2831,2832],{},"What is the difference between DDB and VDB?","\nDDB returns the double-declining charge for one period without switching method. VDB returns the depreciation between two periods and by default switches to straight line when that gives a larger charge.",[50,2835,2837],{"id":2836},"related","Related",[2746,2839,2840,2846,2851,2858],{},[2749,2841,2842,2843,2845],{},"Up one level: ",[44,2844,47],{"href":46}," — spreadsheet functions in Python.",[2749,2847,2848,2850],{},[44,2849,92],{"href":91}," — a full monthly register.",[2749,2852,2853,2857],{},[44,2854,2856],{"href":2855},"\u002Fadvanced-data-transformation-and-cleaning\u002Fexcel-formula-equivalents-in-pandas\u002Fpmt-npv-and-irr-in-python\u002F","PMT, NPV and IRR in Python"," — other finance functions.",[2749,2859,2860,2864],{},[44,2861,2863],{"href":2862},"\u002Fadvanced-data-transformation-and-cleaning\u002Fexcel-formula-equivalents-in-pandas\u002Fipmt-ppmt-effect-and-nominal-equivalents-in-python\u002F","IPMT, PPMT, EFFECT and NOMINAL Equivalents in Python"," — loan and rate functions.",[2866,2867,2868],"style",{},"html pre.shiki code .sMTad, html code.shiki .sMTad{--shiki-default:#6F42C1;--shiki-dark:#FFB757}html pre.shiki code .srMev, html code.shiki .srMev{--shiki-default:#032F62;--shiki-dark:#ADDCFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .s-kum, html code.shiki .s-kum{--shiki-default:#D73A49;--shiki-dark:#FF9492}html pre.shiki code .s_Opv, html code.shiki .s_Opv{--shiki-default:#6F42C1;--shiki-dark:#DBB7FF}html pre.shiki code .skGVy, html code.shiki .skGVy{--shiki-default:#24292E;--shiki-dark:#F0F3F6}html pre.shiki code .sP0c6, html code.shiki .sP0c6{--shiki-default:#005CC5;--shiki-dark:#91CBFF}html pre.shiki code .sa561, html code.shiki .sa561{--shiki-default:#E36209;--shiki-dark:#FFB757}html pre.shiki code .sSjpA, html code.shiki .sSjpA{--shiki-default:#005CC5;--shiki-dark:#FF9492}",{"title":60,"searchDepth":123,"depth":123,"links":2870},[2871,2872,2873,2874,2875,2876,2877,2878,2879,2880],{"id":52,"depth":123,"text":53},{"id":95,"depth":123,"text":96},{"id":349,"depth":123,"text":350},{"id":888,"depth":123,"text":889},{"id":1123,"depth":123,"text":1124},{"id":1538,"depth":123,"text":1539},{"id":2743,"depth":123,"text":2744},{"id":2782,"depth":123,"text":2783},{"id":2808,"depth":123,"text":2809},{"id":2836,"depth":123,"text":2837},"2026-10-02","Reproduce Excel's depreciation functions exactly in Python: SLN straight line, SYD sum-of-years digits, DB fixed-declining balance with its three-decimal rate and partial first year, DDB double-declining balance that never switches to straight line, and VDB with its switch — each implemented, laid out as a schedule with pandas, and checked period by period against the spreadsheet functions.","md",[2885,2887,2889,2891],{"q":2814,"a":2886},"Subtract the salvage value from the cost and divide by the useful life, which is what Excel's SLN function returns for each period.",{"q":2820,"a":2888},"Excel rounds the fixed-declining rate to three decimal places. Calculate the rate as 1 minus salvage divided by cost to the power of one over life, round it to three decimals, then apply it.",{"q":2826,"a":2890},"Not necessarily. DDB never switches to straight line, so with some inputs the book value stays above salvage at the end of the life. VDB switches and reaches the salvage value.",{"q":2832,"a":2892},"DDB returns the double-declining charge for one period without switching method. VDB returns the depreciation between two periods and by default switches to straight line when that gives a larger charge.","sln db and ddb depreciation functions in python",null,{"breadcrumb":2896},[2897,2899,2902],{"name":2898,"item":138},"Home",{"name":2900,"item":2901},"Advanced Data Transformation and Cleaning for Excel Automation","\u002Fadvanced-data-transformation-and-cleaning\u002F",{"name":47,"item":46},"\u002Fadvanced-data-transformation-and-cleaning\u002Fexcel-formula-equivalents-in-pandas\u002Fsln-db-and-ddb-depreciation-functions-in-python",{"title":2905,"description":2906},"SLN, SYD, DB, DDB and VDB Equivalents in Python","Implement Excel depreciation functions in Python: SLN, SYD, DB with the rounded rate and month argument, DDB without a straight-line switch, VDB with it, pandas schedules and a period-by-period spreadsheet check.","sln-db-and-ddb-depreciation-functions-in-python","advanced-data-transformation-and-cleaning\u002Fexcel-formula-equivalents-in-pandas\u002Fsln-db-and-ddb-depreciation-functions-in-python\u002Findex",[2910],"formula-equivalents","how-to","RpJkYlCmFPzmZkvtgrahe_bQlQTh9yu9cPhlohyWVNM",[2914,2918],{"title":2915,"path":2916,"stem":2917,"children":-1},"SEQUENCE and RANDARRAY Equivalents in Python","\u002Fadvanced-data-transformation-and-cleaning\u002Fexcel-formula-equivalents-in-pandas\u002Fsequence-and-randarray-equivalents-in-python","advanced-data-transformation-and-cleaning\u002Fexcel-formula-equivalents-in-pandas\u002Fsequence-and-randarray-equivalents-in-python\u002Findex",{"title":2919,"path":2920,"stem":2921,"children":-1},"STDEV.S, STDEV.P, VAR.S and VAR.P in pandas and NumPy","\u002Fadvanced-data-transformation-and-cleaning\u002Fexcel-formula-equivalents-in-pandas\u002Fstdev-and-var-equivalents-in-pandas","advanced-data-transformation-and-cleaning\u002Fexcel-formula-equivalents-in-pandas\u002Fstdev-and-var-equivalents-in-pandas\u002Findex",[2923,2925],{"path":2924,"title":47},"\u002Fadvanced-data-transformation-and-cleaning\u002Fexcel-formula-equivalents-in-pandas",{"path":2926,"title":2900},"\u002Fadvanced-data-transformation-and-cleaning",[],[2929,2932,2935,2938,2941,2944],{"path":2930,"title":2931,"kind":2911},"\u002Fadvanced-data-transformation-and-cleaning\u002Fmerging-and-joining-excel-dataframes\u002Fvlookup-equivalent-in-pandas-for-excel-files","The VLOOKUP Equivalent in pandas for Excel Files",{"path":2933,"title":2934,"kind":2911},"\u002Fadvanced-data-transformation-and-cleaning\u002Fcleaning-excel-data-with-pandas\u002Fextract-numbers-and-codes-from-text-with-pandas","Extract Numbers and Codes from Text with pandas",{"path":2936,"title":2937,"kind":2911},"\u002Fadvanced-data-transformation-and-cleaning\u002Fcleaning-excel-data-with-pandas\u002Fsplit-full-names-into-first-and-last-names-with-pandas","Split Full Names into First and Last Names with pandas",{"path":2939,"title":2940,"kind":2911},"\u002Fadvanced-data-transformation-and-cleaning\u002Fcreating-pivot-tables-from-excel-data\u002Fbin-values-into-ranges-with-pandas-cut","Bin Values into Ranges Like Excel FREQUENCY with pd.cut",{"path":2942,"title":2943,"kind":2911},"\u002Fadvanced-data-transformation-and-cleaning\u002Fcreating-pivot-tables-from-excel-data\u002Fcalculate-percent-of-total-per-group-in-pandas","Calculate Percent of Total per Group in pandas",{"path":2945,"title":2946,"kind":2911},"\u002Fadvanced-data-transformation-and-cleaning\u002Fcreating-pivot-tables-from-excel-data\u002Fcount-distinct-values-per-group-in-pandas","Count Distinct Values per Group in pandas",1790972088603]