[ {"name": "1200.00 over three years divides evenly: 400.00 a year, down to nothing", "args": [{"minor": 120000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, 3], "expect": [{"year": 1, "openingValue": {"minor": 120000, "currency": "GBP"}, "charge": {"minor": 40000, "currency": "GBP"}, "closingValue": {"minor": 80000, "currency": "GBP"}}, {"year": 2, "openingValue": {"minor": 80000, "currency": "GBP"}, "charge": {"minor": 40000, "currency": "GBP"}, "closingValue": {"minor": 40000, "currency": "GBP"}}, {"year": 3, "openingValue": {"minor": 40000, "currency": "GBP"}, "charge": {"minor": 40000, "currency": "GBP"}, "closingValue": {"minor": 0, "currency": "GBP"}}]}, {"name": "1000.00 over three years does not divide evenly and the odd penny is kept, not dropped", "args": [{"minor": 100000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, 3], "expect": [{"year": 1, "openingValue": {"minor": 100000, "currency": "GBP"}, "charge": {"minor": 33334, "currency": "GBP"}, "closingValue": {"minor": 66666, "currency": "GBP"}}, {"year": 2, "openingValue": {"minor": 66666, "currency": "GBP"}, "charge": {"minor": 33333, "currency": "GBP"}, "closingValue": {"minor": 33333, "currency": "GBP"}}, {"year": 3, "openingValue": {"minor": 33333, "currency": "GBP"}, "charge": {"minor": 33333, "currency": "GBP"}, "closingValue": {"minor": 0, "currency": "GBP"}}]}, {"name": "a residual value is written down to, not through", "args": [{"minor": 100000, "currency": "GBP"}, {"minor": 10000, "currency": "GBP"}, 3], "expect": [{"year": 1, "openingValue": {"minor": 100000, "currency": "GBP"}, "charge": {"minor": 30000, "currency": "GBP"}, "closingValue": {"minor": 70000, "currency": "GBP"}}, {"year": 2, "openingValue": {"minor": 70000, "currency": "GBP"}, "charge": {"minor": 30000, "currency": "GBP"}, "closingValue": {"minor": 40000, "currency": "GBP"}}, {"year": 3, "openingValue": {"minor": 40000, "currency": "GBP"}, "charge": {"minor": 30000, "currency": "GBP"}, "closingValue": {"minor": 10000, "currency": "GBP"}}]}, {"name": "100.00 over seven years: four years carry the odd penny and the asset still lands on zero", "args": [{"minor": 10000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, 7], "expect": [{"year": 1, "openingValue": {"minor": 10000, "currency": "GBP"}, "charge": {"minor": 1429, "currency": "GBP"}, "closingValue": {"minor": 8571, "currency": "GBP"}}, {"year": 2, "openingValue": {"minor": 8571, "currency": "GBP"}, "charge": {"minor": 1429, "currency": "GBP"}, "closingValue": {"minor": 7142, "currency": "GBP"}}, {"year": 3, "openingValue": {"minor": 7142, "currency": "GBP"}, "charge": {"minor": 1429, "currency": "GBP"}, "closingValue": {"minor": 5713, "currency": "GBP"}}, {"year": 4, "openingValue": {"minor": 5713, "currency": "GBP"}, "charge": {"minor": 1429, "currency": "GBP"}, "closingValue": {"minor": 4284, "currency": "GBP"}}, {"year": 5, "openingValue": {"minor": 4284, "currency": "GBP"}, "charge": {"minor": 1428, "currency": "GBP"}, "closingValue": {"minor": 2856, "currency": "GBP"}}, {"year": 6, "openingValue": {"minor": 2856, "currency": "GBP"}, "charge": {"minor": 1428, "currency": "GBP"}, "closingValue": {"minor": 1428, "currency": "GBP"}}, {"year": 7, "openingValue": {"minor": 1428, "currency": "GBP"}, "charge": {"minor": 1428, "currency": "GBP"}, "closingValue": {"minor": 0, "currency": "GBP"}}]}, {"name": "a one year life charges everything in year one", "args": [{"minor": 50000, "currency": "GBP"}, {"minor": 10000, "currency": "GBP"}, 1], "expect": [{"year": 1, "openingValue": {"minor": 50000, "currency": "GBP"}, "charge": {"minor": 40000, "currency": "GBP"}, "closingValue": {"minor": 10000, "currency": "GBP"}}]}, {"name": "an asset already at its residual value has nothing to depreciate", "args": [{"minor": 75000, "currency": "GBP"}, {"minor": 75000, "currency": "GBP"}, 4], "expect": [{"year": 1, "openingValue": {"minor": 75000, "currency": "GBP"}, "charge": {"minor": 0, "currency": "GBP"}, "closingValue": {"minor": 75000, "currency": "GBP"}}, {"year": 2, "openingValue": {"minor": 75000, "currency": "GBP"}, "charge": {"minor": 0, "currency": "GBP"}, "closingValue": {"minor": 75000, "currency": "GBP"}}, {"year": 3, "openingValue": {"minor": 75000, "currency": "GBP"}, "charge": {"minor": 0, "currency": "GBP"}, "closingValue": {"minor": 75000, "currency": "GBP"}}, {"year": 4, "openingValue": {"minor": 75000, "currency": "GBP"}, "charge": {"minor": 0, "currency": "GBP"}, "closingValue": {"minor": 75000, "currency": "GBP"}}]}, {"name": "a worthless asset gives a schedule of zeroes rather than an error", "args": [{"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, 2], "expect": [{"year": 1, "openingValue": {"minor": 0, "currency": "GBP"}, "charge": {"minor": 0, "currency": "GBP"}, "closingValue": {"minor": 0, "currency": "GBP"}}, {"year": 2, "openingValue": {"minor": 0, "currency": "GBP"}, "charge": {"minor": 0, "currency": "GBP"}, "closingValue": {"minor": 0, "currency": "GBP"}}]}, {"name": "an awkward residual value still closes exactly on it", "args": [{"minor": 100000, "currency": "GBP"}, {"minor": 33333, "currency": "GBP"}, 3], "expect": [{"year": 1, "openingValue": {"minor": 100000, "currency": "GBP"}, "charge": {"minor": 22223, "currency": "GBP"}, "closingValue": {"minor": 77777, "currency": "GBP"}}, {"year": 2, "openingValue": {"minor": 77777, "currency": "GBP"}, "charge": {"minor": 22222, "currency": "GBP"}, "closingValue": {"minor": 55555, "currency": "GBP"}}, {"year": 3, "openingValue": {"minor": 55555, "currency": "GBP"}, "charge": {"minor": 22222, "currency": "GBP"}, "closingValue": {"minor": 33333, "currency": "GBP"}}]}, {"name": "yen has no minor unit, so the odd unit is a whole yen", "args": [{"minor": 1000, "currency": "JPY"}, {"minor": 0, "currency": "JPY"}, 3], "expect": [{"year": 1, "openingValue": {"minor": 1000, "currency": "JPY"}, "charge": {"minor": 334, "currency": "JPY"}, "closingValue": {"minor": 666, "currency": "JPY"}}, {"year": 2, "openingValue": {"minor": 666, "currency": "JPY"}, "charge": {"minor": 333, "currency": "JPY"}, "closingValue": {"minor": 333, "currency": "JPY"}}, {"year": 3, "openingValue": {"minor": 333, "currency": "JPY"}, "charge": {"minor": 333, "currency": "JPY"}, "closingValue": {"minor": 0, "currency": "JPY"}}]}, {"name": "a zero year life is an error, not an instant write-off", "args": [{"minor": 100000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, 0], "expectError": "years must be at least 1"}, {"name": "a fractional life is an error", "args": [{"minor": 100000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, 2.5], "expectError": "years must be at least 1"}, {"name": "a residual value above cost is an error, not negative depreciation", "args": [{"minor": 100000, "currency": "GBP"}, {"minor": 150000, "currency": "GBP"}, 3], "expectError": "residual value must not exceed cost"}, {"name": "a negative residual value is an error: disposal costs are not depreciation", "args": [{"minor": 100000, "currency": "GBP"}, {"minor": -100, "currency": "GBP"}, 3], "expectError": "residual value must not be negative"}, {"name": "a negative cost is an error: a credit is not an asset", "args": [{"minor": -100000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, 3], "expectError": "cost must not be negative"}, {"name": "costing in one currency and scrapping in another is an error", "args": [{"minor": 100000, "currency": "GBP"}, {"minor": 10000, "currency": "EUR"}, 3], "expectError": "currency mismatch"} ]