This explaination is for the benefit of computer scientists/software engineers. Accountants learn this stuff in Accounting 101.
At the end of an accounting cycle which is usually a year and at the end of a calendar year (i.e. December 31) for most companies; you "close the books" for that period. Note that companies can, and many do, have year ends other than December 31. Further, an accounting cycle could be a 52/53 week period. Retailers use this approach to enhance comparibility.
If you want to understand the accounting cycle and closing entries, this is a good explaination. This YouTube video explains closing entries. (This YouTube channel has lots of good information about accounting.)
So this is the entire accounting cycle (with some helpful videos that explain specific steps):
How do you explain all this to a computer? It amazes me how dumb computers really are. They understand none of this. Each detail of each step needs to be explained.
It seems that what I need to do is use the fundamental accounting concepts to define the high level concepts like "Assets", "Liabilities", "Equity", "Revenue", "Expenses", "Net Income (Loss)", "Net Cash Flow", and so forth. I need to explain which of those are REAL (permanent) accounts and which are NOMINAL (temporary) accounts to enable the closing process to be automated. These relations can all be expressed using XBRL definition relations.
How the chart of accounts is mapped into those high level concepts is done using the roll up relations represended by XBRL calcuations.
I created all of this for the not-for-profit XBRL taxonomy. See here for human readable information. See here for machine readable information.