Test the sats fee of a buy and a sell

This commit is contained in:
ai-bot committed 2026-11-15 10:42:50 +00:00
1 parent e35384cfa5
commit 558aa5cde1
1 file changed
+14 -14
+14 -14
View File
@@ -203,27 +203,27 @@ class TaxTestCase(unittest.TestCase):
def test_fees_follow_section_3_2(self): def test_fees_follow_section_3_2(self):
market_id = create_market("Børs_01") 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", create_transaction(market_id=market_id, date="2024-01-10",
leg_in_sats=100000000, leg_out_ore=20000000, fee_ore=50000) leg_in_sats=100000000, leg_out_ore=20000000)
# A buy fee in sats lowers the sats received, the cost stays. # 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", create_transaction(market_id=market_id, date="2024-02-10",
leg_in_sats=100000000, leg_out_ore=20000000, fee_sats=100000) leg_in_sats=100000000, leg_out_ore=20000000, fee_sats=1000000)
# A sell fee in NOK lowers the proceeds. # A sell fee in sats is taken on top of what is sold, at the same cost.
create_transaction(market_id=market_id, date="2024-03-10", sale = create_transaction(market_id=market_id, date="2024-03-10",
leg_in_ore=30000000, leg_out_sats=100000000, fee_ore=100000) leg_in_ore=50000000, leg_out_sats=99900000,
fee_sats=100000)
ledger.rebuild() ledger.rebuild()
lots = lots_of(market_id) lots = lots_of(market_id)
self.assertEqual(lots[0]["sats_original"], 100000000) self.assertEqual(lots[0]["sats_original"], 100000000)
self.assertEqual(lots[0]["cost_ore_original"], 20050000) self.assertEqual(lots[0]["cost_ore_original"], 20000000)
self.assertEqual(lots[1]["sats_original"], 99900000) self.assertEqual(lots[1]["sats_original"], 99000000)
self.assertEqual(lots[1]["cost_ore_original"], 20000000) self.assertEqual(lots[1]["cost_ore_original"], 20000000)
# The buy must not have consumed anything: its sats fee only lowered the # 99 900 000 sold plus the 100 000 fee: exactly the first lot.
# sats it received, so the second lot is untouched. self.assertEqual(sum(row["sats"] for row in consumptions(sale)), 100000000)
self.assertEqual(lots[0]["sats_remaining"], 0) self.assertEqual(lots[0]["sats_remaining"], 0)
self.assertEqual(lots[1]["sats_remaining"], 99900000) # Proceeds 500 000 kr, cost 200 000 kr (FIFO).
# Proceeds 300 000 kr minus the 1 000 kr fee, cost 200 500 kr (FIFO). self.assertEqual(tax.report(2024)["totals"]["gevinst_ore"], 30000000)
self.assertEqual(tax.report(2024)["totals"]["gevinst_ore"], 9850000)
def test_gift_received_sets_the_cost_basis(self): def test_gift_received_sets_the_cost_basis(self):
market_id = create_market("Lommebok", kind="wallet") market_id = create_market("Lommebok", kind="wallet")