Thank you for your reply.
I created an example ledger, hoping it will help.
;; -*- mode: beancount; -*-
2016-12-01 open Assets:Bank EUR
2016-12-01 open Assets:AccountReceivable EUR
2016-12-01 open Income:Customer1 EUR
2016-12-01 open Expenses:Personal EUR
2016-12-01 open Expenses:Utilities EUR
2016-12-01 open Equity:Salary EUR
2016-12-01 * "Customer1" "Invoice 2016-1" ^invoice2016-1
Assets:AccountReceivable 1000 EUR
Income:Customer1
2016-12-15 * "Customer1" "invoice 2016-1" ^invoice2016-1
Assets:Bank 1000 EUR
Assets:AccountReceivable
2017-12-01 * "Customer1" "Invoice 2017-1" ^invoice2017-1
Assets:AccountReceivable 1000 EUR
Income:Customer1
2017-12-15 * "Customer1" "invoice 2017-1" ^invoice2017-1
Assets:Bank 1000 EUR
Assets:AccountReceivable
2017-12-16 * "Caffè"
Expenses:Personal 1 EUR
Assets:Bank
2017-12-17 * "TheInternet" "internet bill december"
Expenses:Utilities 20 EUR ; 50% deductible
Assets:Bank
2017-12-20 * "Salary"
Assets:Bank -500 EUR
Equity:Salary
2017-12-31 query "2017" "
SELECT sum(position) as earnings
FROM year = 2017 OPEN ON 2017-01-01 CLOSE ON 2018-01-01 CLEAR
WHERE account = 'Equity:Earnings:Current'
"
This is a simplified example that I hope may be useful for explaining my doubts.
If I run the last query:
$ bean-query example.beancount "run '2017 all'"
earnings
--------
-979 EUR
This output is correct but it's not what I need, I would like to get the same concept as Equity:Earnings:Current but without Expenses:Personal and with only half of Expenses:Utilities (50% deductible)