Custom fields and custom calculations

Hi there,

I am using the sales commission feature in the sales invoice doctype.
By default, the total commission is calculated based on the total net value of the invoice.
However, I would like to add an item table where I can add items.
The total net value of the invoice is then to be reduced by the total value of the items in the table.
The ‘new’ and reduced net value is then used as the base for calculating the total commission.

How can this be achieved?