ledger: Change default report dates.
The old defaults were optimized for the audit report. The new defaults provide more helpful ad hoc reports. The latter will be run more often and more quickly, so it's worth optimizing the defaults for them.
This commit is contained in:
parent
9782e7203a
commit
efe9bd8855
2 changed files with 21 additions and 7 deletions
|
@ -417,7 +417,7 @@ def parse_arguments(arglist: Optional[Sequence[str]]=None) -> argparse.Namespace
|
|||
metavar='DATE',
|
||||
type=cliutil.date_arg,
|
||||
help="""Date to start reporting entries, inclusive, in YYYY-MM-DD format.
|
||||
The default is the beginning of the last full fiscal year.
|
||||
The default is one year ago.
|
||||
""")
|
||||
parser.add_argument(
|
||||
'--end', '--stop', '-e',
|
||||
|
@ -425,7 +425,8 @@ The default is the beginning of the last full fiscal year.
|
|||
metavar='DATE',
|
||||
type=cliutil.date_arg,
|
||||
help="""Date to stop reporting entries, exclusive, in YYYY-MM-DD format.
|
||||
The default is the end of the begin date's fiscal year.
|
||||
The default is a year after the start date, or 30 days from today if the start
|
||||
date was also not specified.
|
||||
""")
|
||||
parser.add_argument(
|
||||
'--account', '-a',
|
||||
|
@ -472,6 +473,17 @@ metadata to match. A single ticket number is a shortcut for
|
|||
args.sheet_names = list(LedgerODS.ACCOUNT_COLUMNS)
|
||||
return args
|
||||
|
||||
def diff_year(date: datetime.date, diff: int) -> datetime.date:
|
||||
new_year = date.year + diff
|
||||
try:
|
||||
return date.replace(year=new_year)
|
||||
except ValueError:
|
||||
# The original date is Feb 29, which doesn't exist in the new year.
|
||||
if diff < 0:
|
||||
return datetime.date(new_year, 2, 28)
|
||||
else:
|
||||
return datetime.date(new_year, 3, 1)
|
||||
|
||||
def main(arglist: Optional[Sequence[str]]=None,
|
||||
stdout: TextIO=sys.stdout,
|
||||
stderr: TextIO=sys.stderr,
|
||||
|
@ -483,11 +495,13 @@ def main(arglist: Optional[Sequence[str]]=None,
|
|||
config = configmod.Config()
|
||||
config.load_file()
|
||||
|
||||
fy = config.fiscal_year_begin()
|
||||
today = datetime.date.today()
|
||||
if args.start_date is None:
|
||||
args.start_date = fy.first_date(fy.for_date() - 1)
|
||||
if args.stop_date is None:
|
||||
args.stop_date = fy.next_fy_date(args.start_date)
|
||||
args.start_date = diff_year(today, -1)
|
||||
if args.stop_date is None:
|
||||
args.stop_date = today + datetime.timedelta(days=30)
|
||||
elif args.stop_date is None:
|
||||
args.stop_date = diff_year(args.start_date, 1)
|
||||
|
||||
returncode = 0
|
||||
books_loader = config.books_loader()
|
||||
|
|
2
setup.py
2
setup.py
|
@ -5,7 +5,7 @@ from setuptools import setup
|
|||
setup(
|
||||
name='conservancy_beancount',
|
||||
description="Plugin, library, and reports for reading Conservancy's books",
|
||||
version='1.2.0',
|
||||
version='1.2.1',
|
||||
author='Software Freedom Conservancy',
|
||||
author_email='info@sfconservancy.org',
|
||||
license='GNU AGPLv3+',
|
||||
|
|
Loading…
Reference in a new issue