Changeset - 087b3274e7d2
[Not reviewed]
0 4 0
Brett Smith - 3 years ago 2021-01-19 19:23:51
brettcsmith@brettcsmith.org
ledger: Dedicated reporting tab for Expenses:Payroll.

To better accommodate the new payroll-type metadata.
4 files changed with 13 insertions and 2 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reports/ledger.py
Show inline comments
...
 
@@ -83,24 +83,25 @@ PROGNAME = 'ledger-report'
 
logger = logging.getLogger('conservancy_beancount.reports.ledger')
 

	
 
class LedgerODS(core.BaseODS[data.Posting, None]):
 
    CORE_COLUMNS: Sequence[str] = [
 
        'Date',
 
        data.Metadata.human_name('entity'),
 
        'Description',
 
        'Original Amount',
 
        'Booked Amount',
 
    ]
 
    ACCOUNT_COLUMNS: Dict[str, Sequence[str]] = collections.OrderedDict([
 
        ('Income', ['project', 'rt-id', 'receipt', 'income-type', 'memo']),
 
        ('Expenses:Payroll', ['project', 'rt-id', 'payroll-type', 'expense-type', 'receipt', 'approval']),
 
        ('Expenses', ['project', 'rt-id', 'receipt', 'approval', 'expense-type']),
 
        ('Equity', ['project', 'rt-id']),
 
        ('Assets:Receivable', ['project', 'rt-id', 'invoice', 'approval', 'contract', 'purchase-order']),
 
        ('Liabilities:Payable', ['project', 'rt-id', 'invoice', 'approval', 'contract', 'purchase-order']),
 
        ('Assets:PayPal', ['rt-id', 'paypal-id', 'receipt', 'approval']),
 
        ('Assets', ['rt-id', 'receipt', 'approval', 'bank-statement']),
 
        ('Liabilities', ['rt-id', 'receipt', 'approval', 'bank-statement']),
 
    ])
 
    CLASSIFICATION_COLUMN = "Account Classification"
 
    # Excel 2003 was limited to 65,536 rows per worksheet.
 
    # While we can probably count on all our users supporting more modern
 
    # formats (Excel 2007 supports over 1 million rows per worksheet),
setup.py
Show inline comments
 
#!/usr/bin/env python3
 

	
 
from setuptools import setup
 

	
 
setup(
 
    name='conservancy_beancount',
 
    description="Plugin, library, and reports for reading Conservancy's books",
 
    version='1.15.4',
 
    version='1.15.5',
 
    author='Software Freedom Conservancy',
 
    author_email='info@sfconservancy.org',
 
    license='GNU AGPLv3+',
 

	
 
    install_requires=[
 
        'babel>=2.6',  # Debian:python3-babel
 
        'beancount>=2.2',  # Debian:beancount
 
        'GitPython>=2.0',  # Debian:python3-git
 
        # 1.4.1 crashes when trying to save some documents.
 
        'odfpy>=1.4.0,!=1.4.1',  # Debian:python3-odf
 
        'pdfminer.six>=20200101',
 
        'PyYAML>=3.0',  # Debian:python3-yaml
tests/books/ledger.beancount
Show inline comments
 
2018-01-01 open Equity:OpeningBalance
 
2018-01-01 open Assets:Checking
 
  classification: "Cash"
 
2018-01-01 open Assets:PayPal
 
  classification: "Cash"
 
2018-01-01 open Assets:Prepaid
 
  classification: "Prepaid expenses"
 
2018-01-01 open Assets:Receivable:Accounts
 
  classification: "Accounts receivable"
 
2018-01-01 open Expenses:Other
 
  classification: "Other expenses"
 
2018-01-01 open Expenses:Payroll
 
  classification: "Payroll expenses"
 
2018-01-01 open Income:Other
 
  classification: "Other income"
 
2018-01-01 open Liabilities:CreditCard
 
  classification: "Accounts payable"
 
2018-01-01 open Liabilities:Payable:Accounts
 
  classification: "Accounts payable"
 
2018-01-01 open Liabilities:UnearnedIncome
 
  classification: "Unearned income"
 

	
 
2018-02-28 * "Opening balance"
 
  Equity:OpeningBalance  -10,000 USD
 
  Assets:Checking         10,000 USD
tests/test_reports_ledger.py
Show inline comments
...
 
@@ -25,33 +25,36 @@ from beancount import loader as bc_loader
 
from conservancy_beancount import data
 
from conservancy_beancount.reports import core
 
from conservancy_beancount.reports import ledger
 

	
 
clean_account_meta = contextlib.contextmanager(testutil.clean_account_meta)
 

	
 
Acct = data.Account
 

	
 
_ledger_load = bc_loader.load_file(testutil.test_path('books/ledger.beancount'))
 
DEFAULT_REPORT_SHEETS = [
 
    'Balance',
 
    'Income',
 
    'Expenses:Payroll',
 
    'Expenses',
 
    'Equity',
 
    'Assets:Receivable',
 
    'Liabilities:Payable',
 
    'Assets:PayPal',
 
    'Assets',
 
    'Liabilities',
 
]
 
PROJECT_REPORT_SHEETS = DEFAULT_REPORT_SHEETS[:5] + [
 
PROJECT_REPORT_SHEETS = [
 
    *DEFAULT_REPORT_SHEETS[:2],
 
    *DEFAULT_REPORT_SHEETS[3:6],
 
    'Assets:Prepaid',
 
    'Liabilities:UnearnedIncome',
 
    'Liabilities:Payable',
 
]
 
OVERSIZE_RE = re.compile(
 
    r'^([A-Za-z0-9:]+) has ([0-9,]+) rows, over size ([0-9,]+)$'
 
)
 
START_DATE = datetime.date(2018, 3, 1)
 
MID_DATE = datetime.date(2019, 3, 1)
 
STOP_DATE = datetime.date(2020, 3, 1)
 

	
 
REPORT_KWARGS = [
...
 
@@ -393,24 +396,29 @@ def test_report_filter_totals(ledger_entries, tot_accts, report_kwargs):
 
@pytest.mark.parametrize('accounts', [
 
    ('Income', 'Expenses'),
 
    ('Assets:Receivable', 'Liabilities:Payable'),
 
])
 
def test_account_names_report(ledger_entries, accounts, report_kwargs):
 
    txn_filter = report_kwargs.get('txn_filter')
 
    postings, report = build_report(ledger_entries, START_DATE, STOP_DATE,
 
                                    accounts, **report_kwargs)
 
    expected = dict(ExpectedPostings.group_by_account(postings))
 
    for account in iter_accounts(ledger_entries):
 
        if not account.startswith(accounts):
 
            ExpectedPostings.check_not_in_report(report.document, account)
 
        # This account is reportable but has no postings
 
        elif account == 'Expenses:Payroll':
 
            ExpectedPostings.check_in_report(
 
                report.document, account, START_DATE, STOP_DATE, txn_filter,
 
            )
 
        elif txn_filter is None:
 
            expected[account].check_report(report.document, START_DATE, STOP_DATE)
 
        else:
 
            expected[account].check_txn_report(
 
                report.document, txn_filter, START_DATE, STOP_DATE,
 
            )
 

	
 
def run_main(arglist, config=None):
 
    if config is None:
 
        config = testutil.TestConfig(
 
            books_path=testutil.test_path('books/ledger.beancount'),
 
            rt_client=testutil.RTClient(),
0 comments (0 inline, 0 general)