Deductions & credits

Do I claim the cost of the animal where I got the proceeds in 2023, however, the animal was purchased in 2022 or can I offset the income from the animal sale against the purchase of another animal in the same year (2023)?