The error comes if the total sum of the entries are not zero.
Typically I have only seen this error in connections with customizations. Typically any kind of customizations changing in the posting processes, or when using other code to create and post entries. And typically it’s related to roundings, currency, vat etc.
And I’ve never heard about the post inventory cost batch would cause it. So my guess that something is customized.
What can you do? You have to start debugging! You need to check each individual entry generated by the batch job, until you find the error. [:)] So if it contains a lot of entries, then you start by filtering the amount of posts. So ranges might post fine, others not. So run with the debugger on break when the error happens, so that you can start tracing back the error.