This looks exactly like huge block of code in `foundation-database/public/functions/postbankreconciliation.sql`. We can't copy and paste stuff like this. If it's slightly different, the commonality needs to be composed in to a function and it can be parameterized to accommodate the differences.