One way this could be done is via the optimization tool. If we ignore companies for the time being, as this can be done using a batch macro, then the attached example shows how the optimization tool could be used to solve this for one GL transaction at a time. You could loop through each GL transaction again via a batch macro.
You could also do it the other way round, i.e. trying to match one VISA transaction against any number of GL transactions.
Unfortunately many to many on either side is not something my brain wants to think about this late on a Tuesday night.
Of course the process may fail to consolidate in which case the optimization tool may throw a fatal error, again that is not something I'm considering with this single example!