And the optimization problem at this point in time is that -ideally- you want to have some amount of excess generation on your solar panels, then time shift that with batteries to a point in time when power is more expensive, and have some amount of excess capacity in batteries so you can also sell that power; versus the (amortized) cost of that extra capacity; and/or what will actually fit on your roof.
This varies per house/plot, per contract, and per latitude. But in some situations you can end up at net 0 or better.