Didn't read the whole thing, but if it's a country wide legal requirement - isn't there a standard solution developed by SAP already? Have you checked the SAP notes?
I might be wrong but it suspiciously looks like you might be reinventing the bicycle here or doing some unnecessary customization...