Assuming I have a list of objects that have the following properties

> 
> **String name, BigDecimal addThis, BigDecimal minusThis**
> 
> 
> 

What I need to do is group the list by name, then combine addThis and minus this using the formula below:

```
total = total + addThis
total = total - minusThis

```

in other words, if addThis is not null, the value should be added to total, if minusThis is not null, the value should be deducted to total. 

The expected output should be something like this:
[name1:56.789, name2:6778.78, name3:676767.788]

How will I do it in Groovy?

I know that I can use `groupBy` and `collectEntries` but computing for the total confuses me.