fava icon indicating copy to clipboard operation
fava copied to clipboard

Sort importable files by date and account name

Open gerdemb opened this issue 9 months ago • 0 comments

The list of importable files on /beancount/import/ is sorted by file name. I find it much more useful if they are sorted by date and then by account name.

I added the following code to the function def import_data(self) -> list[FileImporters] in ingest.py just before the return to sort them.

        # Sort ret by the date and account attribute of infos[0] if it exists
        ret = sorted(
            ret, 
            key=lambda x: (
                x.importers[0].date is None, 
                x.importers[0].date,
                x.importers[0].account
            ) if x.importers 
            else (True, None, None)
        )

gerdemb avatar Sep 26 '23 18:09 gerdemb