From 558aa5cde1f3a69e9d48ef56e852035b2cc7cf73 Mon Sep 17 00:00:00 2001 From: ai-bot Date: Sun, 15 Nov 2026 10:42:50 +0000 Subject: [PATCH] Test the sats fee of a buy and a sell --- tests/test_tax.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/test_tax.py b/tests/test_tax.py index 4f768ff..ae206c3 100644 --- a/tests/test_tax.py +++ b/tests/test_tax.py @@ -203,27 +203,27 @@ class TaxTestCase(unittest.TestCase): def test_fees_follow_section_3_2(self): market_id = create_market("Børs_01") - # A buy fee in NOK raises the cost basis. + # 1,0 BTC for 200 000 kr: 0,2 ore per sat. create_transaction(market_id=market_id, date="2024-01-10", - leg_in_sats=100000000, leg_out_ore=20000000, fee_ore=50000) - # A buy fee in sats lowers the sats received, the cost stays. + leg_in_sats=100000000, leg_out_ore=20000000) + # A buy fee in sats lowers the sats received; the cost is the kroner paid. create_transaction(market_id=market_id, date="2024-02-10", - leg_in_sats=100000000, leg_out_ore=20000000, fee_sats=100000) - # A sell fee in NOK lowers the proceeds. - create_transaction(market_id=market_id, date="2024-03-10", - leg_in_ore=30000000, leg_out_sats=100000000, fee_ore=100000) + leg_in_sats=100000000, leg_out_ore=20000000, fee_sats=1000000) + # A sell fee in sats is taken on top of what is sold, at the same cost. + sale = create_transaction(market_id=market_id, date="2024-03-10", + leg_in_ore=50000000, leg_out_sats=99900000, + fee_sats=100000) ledger.rebuild() lots = lots_of(market_id) self.assertEqual(lots[0]["sats_original"], 100000000) - self.assertEqual(lots[0]["cost_ore_original"], 20050000) - self.assertEqual(lots[1]["sats_original"], 99900000) + self.assertEqual(lots[0]["cost_ore_original"], 20000000) + self.assertEqual(lots[1]["sats_original"], 99000000) self.assertEqual(lots[1]["cost_ore_original"], 20000000) - # The buy must not have consumed anything: its sats fee only lowered the - # sats it received, so the second lot is untouched. + # 99 900 000 sold plus the 100 000 fee: exactly the first lot. + self.assertEqual(sum(row["sats"] for row in consumptions(sale)), 100000000) self.assertEqual(lots[0]["sats_remaining"], 0) - self.assertEqual(lots[1]["sats_remaining"], 99900000) - # Proceeds 300 000 kr minus the 1 000 kr fee, cost 200 500 kr (FIFO). - self.assertEqual(tax.report(2024)["totals"]["gevinst_ore"], 9850000) + # Proceeds 500 000 kr, cost 200 000 kr (FIFO). + self.assertEqual(tax.report(2024)["totals"]["gevinst_ore"], 30000000) def test_gift_received_sets_the_cost_basis(self): market_id = create_market("Lommebok", kind="wallet")