Changeset - 0eb014aeeb2e
[Not reviewed]
0 4 1
Brett Smith - 6 years ago 2018-07-10 15:36:07
brettcsmith@brettcsmith.org
patreon: New importer for payouts.
5 files changed with 64 insertions and 1 deletions:
0 comments (0 inline, 0 general)
README.rst
Show inline comments
 
import2ledger
 
=============
 

	
 
Introduction
 
------------
 

	
 
import2ledger provides a Python library and CLI tool to read financial data from various popular sources and generate entries for text-based accounting books from them.
 

	
 
Installation
 
------------
 

	
 
This is a pretty normal Python module, so if you have a favorite way to install those, it will probably work.  If you just want to install it to run the script locally, try running from the source directory::
 

	
 
  $ python3 -m pip install --user -U --upgrade-strategy only-if-needed .
 

	
 
Configuring import2ledger
 
-------------------------
 

	
 
Since different organizations follow different accounting rules, you need to define an entry template for each kind of data that you want to be able to import.  You do that in a configuration file.  By default, import2ledger reads a configuration file at ``~/.config/import2ledger.ini``.  You can specify a different path with the ``-C`` option, and you can specify that multiple times to read multiple configuration files in order.
 

	
 
Writing templates
 
~~~~~~~~~~~~~~~~~
 

	
 
A template looks like a Ledger entry with a couple of differences:
 

	
 
* You don't write the first payee line.
 
* Instead of writing specific currency amounts, you write simple expressions to calculate amounts.
 

	
 
Here's a simple template for Patreon patron payments::
 

	
 
  [DEFAULT]
 
  patreon income ledger entry =
 
    ;Tag: Value
 
    Income:Patreon  -{amount}
 
    Accrued:Accounts Receivable:Patreon  {amount}
 

	
 
Let's walk through this line by line.
 

	
 
Every setting in your configuration file has to be in a section.  ``[DEFAULT]`` is the default section, and import2ledger reads configuration settings from here if you don't specify another one.  This documentation explains how to use sections later.
 

	
 
``patreon income ledger entry =`` specifies which entry template this is.  Every template is found from a setting with a name in the pattern ``<SOURCE> <TYPE> ledger entry``.  The remaining lines are indented further than this name; this defines a multiline value.  Don't worry about the exact indentation of your template; import2ledger will indent its output nicely.
 

	
 
The first line of the template is a Ledger tag.  The program will leave all kinds of tags and Ledger comments alone, except to indent them nicely.
 

	
 
The next two lines split the money across accounts.  They follow almost the same format as they do in Ledger: there's an account named, followed by a tab or two or more spaces, and then an expression.  Each time import2ledger generates an entry, it will evaluate this expression using the data it imported to calculate the actual currency amount to write.  Your expression can use numbers, basic arithmetic operators (including parentheses for grouping), and imported data referred to as ``{variable_name}``.
 

	
 
import2ledger uses decimal math to calculate each amount, and rounds to the number of digits appropriate for that currency.  If the amount of currency being imported doesn't split evenly, spare change will be allocated to the last split to keep the entry balanced on both sides.
 

	
 
Refer to the `Python documentation for INI file structure <https://docs.python.org/3/library/configparser.html#supported-ini-file-structure>`_ for full details of the syntax.  Note that import2ledger doesn't use ``;`` as a comment prefix, since that's the primary comment prefix in Ledger.
 

	
 
Template variables
 
~~~~~~~~~~~~~~~~~~
 

	
 
import2ledger templates have access to a few variables for each transaction that can be included anywhere in the entry, not just amount expressions.  In other parts of the entry, they're treated as strings, and you can control their formatting using `Python's format string syntax <https://docs.python.org/3/library/string.html#formatstrings>`_.  For example, this template customizes the payee line and sets different payees for each side of the transaction::
 

	
 
  patreon income ledger entry =
 
    {date}  Patreon payment from {payee}
 
    Income:Patreon  -{amount}
 
    ;Payee: {payee}
 
    Accrued:Accounts Receivable:Patreon  {amount}
 
    ;Payee: Patreon
 

	
 
Templates automatically detect whether or not you have a custom payee line by checking if the first line begins with a date variable.  If it does, it's assumed to be your payee line.  Otherwise, the template uses a default payee line of ``{date} {payee}``.
 

	
 
Every template can use the following variables:
 

	
 
================== ==========================================================
 
Name               Contents
 
================== ==========================================================
 
amount             The total amount of the transaction, as a simple decimal
 
                   number (not currency-formatted)
 
------------------ ----------------------------------------------------------
 
currency           The three-letter code for the transaction currency
 
------------------ ----------------------------------------------------------
 
date               The date of the transaction, in your configured output
 
                   format
 
------------------ ----------------------------------------------------------
 
payee              The name of the transaction payee
 
------------------ ----------------------------------------------------------
 
source_abspath     The absolute path of the file being imported
 
------------------ ----------------------------------------------------------
 
source_absdir      The absolute path of the directory that contains the file
 
                   being imported
 
------------------ ----------------------------------------------------------
 
source_dir         The path of the directory that contains the file being
 
                   imported, as specified on the command line
 
------------------ ----------------------------------------------------------
 
source_name        The filename of the file being imported
 
------------------ ----------------------------------------------------------
 
source_path        The path of the file being imported, as specified on the
 
                   command line
 
------------------ ----------------------------------------------------------
 
source_stem        The filename of the file being imported, with its
 
                   extension removed
 
================== ==========================================================
 

	
 
Specific importers and hooks may provide additional variables.
 

	
 
Supported templates
 
~~~~~~~~~~~~~~~~~~~
 

	
 
You can define the following templates.
 

	
 
Amazon Affiliate Program
 
^^^^^^^^^^^^^^^^^^^^^^^^
 

	
 
``amazon earnings ledger entry``
 
  Imports one transaction per month, summarizing all earnings over the month.  Generated from Amazon's "Fee Earnings" report CSV.
 

	
 
Benevity
 
^^^^^^^^
 

	
 
``benevity donations ledger entry``
 
  Imports one transaction per row in Benevity's donations report CSV.
 

	
 
  This template can use these variables:
 

	
 
  ================ ===========================================================
 
  Name             Contents
 
  ================ ===========================================================
 
  comment          The comment from the donor
 
  ---------------- -----------------------------------------------------------
 
  corporation      The name of the participating corporation
 
  ---------------- -----------------------------------------------------------
 
  disbursement_id  The ID of the dirbursement from Benevity that includes this
 
                   donation
 
  ---------------- -----------------------------------------------------------
 
  donation_amount  The amount donated by the individual donor named
 
  ---------------- -----------------------------------------------------------
 
  frequency        The frequency of this donation as indicated in the report
 
  ---------------- -----------------------------------------------------------
 
  match_amount     The amount of the donation match by the participating
 
                   corporation
 
  ---------------- -----------------------------------------------------------
 
  project          The Project named in this row
 
  ---------------- -----------------------------------------------------------
 
  transaction_id   The ID of this specific donation
 
  ================ ===========================================================
 

	
 
BrightFunds
 
^^^^^^^^^^^
 

	
 
``brightfunds donorreport ledger entry``
 
  Imports one transaction per row in donor report XLS files that BrightFunds mails each month to recipients.
 

	
 
  This template can use these variables:
 

	
 
  ================ ===========================================================
 
  Name             Contents
 
  ================ ===========================================================
 
  company_name     The company name as reported in the spreadsheet
 
  ---------------- -----------------------------------------------------------
 
  corporation      The company name as detected by the importer (this is
 
                   usually what you want)
 
  ---------------- -----------------------------------------------------------
 
  donor_name       The donor name as reported in the spreadsheet (usually you
 
                   want to use ``payee`` instead)
 
  ---------------- -----------------------------------------------------------
 
  donor_email      The donor's e-mail address as reported in the spreadsheet
 
  ---------------- -----------------------------------------------------------
 
  on_behalf_of     From the corresponding spreadsheet column
 
  ---------------- -----------------------------------------------------------
 
  fund             From the corresponding spreadsheet column
 
  ---------------- -----------------------------------------------------------
 
  type             From the corresponding spreadsheet column
 
  ================ ===========================================================
 

	
 
O'Reilly Media
 
^^^^^^^^^^^^^^
 

	
 
``oreilly payments ledger entry``
 
  Imports one transaction per payment.  Generated from CSV export of O'Reilly's payment history.
 

	
 
  This template can use these variables:
 

	
 
  ================ ===========================================================
 
  Name             Contents
 
  ================ ===========================================================
 
  paid_date        From the corresponding spreadsheet column.  This is usually
 
                   the end of the month, while the actual transaction date
 
                   might be slightly off.
 
  ---------------- -----------------------------------------------------------
 

	
 
``oreilly royalties ledger entry``
 
  Imports one transaction per royalty period (usually a month, historically a quarter).  Generated from CSV export of O'Reilly's royalties statement.
 

	
 
  This template can use these variables:
 

	
 
  ================ ===========================================================
 
  Name             Contents
 
  ================ ===========================================================
 
  start_date       From the corresponding spreadsheet column
 
  ---------------- -----------------------------------------------------------
 
  paid_date        From the corresponding spreadsheet column.  This
 
                   corresponds to a row in the payment history as well.
 
  ---------------- -----------------------------------------------------------
 

	
 
Patreon
 
^^^^^^^
 

	
 
``patreon income ledger entry``
 
  Imports one transaction per patron per month.  Generated from Patreon's monthly patron report CSVs.
 

	
 
``patreon payout ledger entry``
 
  Imports one transaction per month for that month's payout.  Generated from Patreon's payout report CSV.
 

	
 
  This template can use these variables:
 

	
 
  =============== ===========================================================
 
  Name            Contents
 
  =============== ===========================================================
 
  pledges_amount  A decimal with the amount paid out by Patreon to pledges
 
                  you've made
 
  --------------- -----------------------------------------------------------
 
  transfer_amount A decimal with the amount paid out by Patreon to your bank
 
                  account
 
  =============== ===========================================================
 

	
 
``patreon cardfees ledger entry``
 
  Imports one expense transaction per month for that month's credit card fees.  Generated from Patreon's earnings report CSV.
 

	
 
``patreon servicefees ledger entry``
 
  Imports one expense transaction per month for that month's Patreon service fees.  Generated from Patreon's earnings report CSV.
 

	
 
``patreon vat ledger entry``
 
  Imports one transaction per country per month each time Patreon withheld VAT.  Generated from Patreon's VAT report CSV.
 

	
 
  This template can use these variables:
 

	
 
  ============== ============================================================
 
  Name           Contents
 
  ============== ============================================================
 
  country_name   The full name of the country VAT was withheld for
 
  -------------- ------------------------------------------------------------
 
  country_code   The two-letter ISO country code of the country VAT was
 
                 withheld for
 
  ============== ============================================================
 

	
 
Stripe
 
^^^^^^
 

	
 
``stripe payment ledger entry``
 
  Imports one transaction per payment.  Generated from Stripe's payments CSV export.
 

	
 
  This template can use these variables:
 

	
 
  ============== ==========================================================
 
  Name           Contents
 
  ============== ==========================================================
 
  customer_id    The id assigned to this customer by Stripe
 
  -------------- ----------------------------------------------------------
 
  customer_email The customer's e-mail address
 
  -------------- ----------------------------------------------------------
 
  description    The description given to the payment when it was created
 
  -------------- ----------------------------------------------------------
 
  fee            The amount of fees charged by Stripe for this payment, as
 
                 a plain decimal number
 
  -------------- ----------------------------------------------------------
 
  payment_id     The id assigned to this payment by Stripe
 
  -------------- ----------------------------------------------------------
 
  payout_id      The id of the associated Stripe payout
 
  -------------- ----------------------------------------------------------
 
  tax            The amount of tax withheld by Stripe for this payment, as
 
                 a plain decimal number
 
  ============== ==========================================================
 

	
 
``stripe payout ledger entry``
 
  Imports one transaction per payment.  Generated from Stripe's payouts CSV export.
 

	
 
  This template can use these variables:
 

	
 
  ========================== ==============================================
 
  Name           Contents
 
  ========================== ==============================================
 
  adjustment_count           Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  adjustment_gross           Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  adjustment_fees            Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  adjustment_net             Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  balance_txid               Stripe ID of the balance transaction
 
  -------------------------- ----------------------------------------------
 
  collected_fee_count        Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  collected_fee_gross        Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  collected_fee_refund_count Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  collected_fee_refund_gross Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  destination_id             Stripe ID of the payout destination account
 
  -------------------------- ----------------------------------------------
 
  failure_txid               Stripe ID of the failure balance transaction
 
  -------------------------- ----------------------------------------------
 
  payment_count              Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  payment_gross              Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  payment_fees               Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  payment_net                Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  payout_id                  Stripe ID of this payout
 
  -------------------------- ----------------------------------------------
 
  refund_count               Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  refund_gross               Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  refund_fees                Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  refund_net                 Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  total_count                Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  total_gross                Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  total_fees                 Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  total_net                  Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  validation_count           Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  validation_fees            Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  retried_payout_count       Decimal from the corresponding CSV column
 
  -------------------------- ----------------------------------------------
 
  retried_payout_net         Decimal from the corresponding CSV column
 
  ========================== ==============================================
 

	
 
Other output options
 
~~~~~~~~~~~~~~~~~~~~
 

	
 
Various options control how import2ledger formats dates and currency amounts.  Run ``import2ledger --help`` for a full list; they're listed under the "default overrides" section.  You can specify these in your configuration file, too.  Just change any dashes (``-``) in the option name to underscores (``_``), and separate the switch name from your value with ``=``.  For example, add this to your configuration file to use ISO 8601-formatted dates in your Ledger entries::
 

	
 
  date_format = %%Y-%%m-%%d
 

	
 
(``%`` is a special character in the configuration file syntax.  ``%%`` represents a literal percent sign.)
 

	
 
Configuration sections
 
~~~~~~~~~~~~~~~~~~~~~~
 

	
 
If you keep different sets of books, it might be helpful to have different configuration settings for each.  For example, you might adjust the templates for each set of books to use different accounts or tags.  Or you might just need to change the formatting of dates or currency amounts.
 

	
 
import2ledger makes this easy by letting you define a new section of options, and then using them all when you import transactions.  For example, say you keep two sets of books, one for US accounts and another for European accounts.  You could write a configuration file like::
 

	
 
  [us]
 
  date_format = %%m/%%d/%%Y
 
  signed_currencies = USD
 

	
 
  [eu]
 
  date_format = %%d.%%m.%%Y
 
  signed_currencies = EUR
 

	
 
When you run import2ledger, you can tell it to load options from one of these sections with the option ``--use-config NAME``, or ``-c NAME`` for short.  In this example, ``import2ledger -c eu`` would load the settings for your European books.  import2ledger looks for configuration settings in the following places, and uses the first setting it finds:
 

	
 
1. The configuration section you specify with ``-c``
 
2. Command-line options
 
3. The ``[DEFAULT]`` configuration section
 
4. import2ledger defaults
 

	
 
Running import2ledger
 
---------------------
 

	
 
Once you've written a configuration file with your templates and any other configuration you need, you can run it with data to import::
 

	
 
  $ import2ledger [options …] file1.csv [file2.csv …]
 

	
 
import2ledger will read all the data sources and generate bookkeeping entries from them.
 

	
 
import2ledger needs to be able to seek within the source files.  Because of that, your input files need to be normal files, or symlinks to them.  Special files like devices and FIFOs aren't supported by import2ledger.
 

	
 
Exit status
 
~~~~~~~~~~~
 

	
 
import2ledger reports the following exit codes:
 

	
 
========= =================================================================
 
Exit code Meaning
 
========= =================================================================
 
0         Imported data from all source files
 
--------- -----------------------------------------------------------------
 
1         Internal error (probably a bug)
 
--------- -----------------------------------------------------------------
 
2         Error in the user's settings, such as a formatting error in a
 
          template or date, or a reference to a nonexistent file or
 
          configuration file section
 
--------- -----------------------------------------------------------------
 
11-99     Failed to import data from at least one source file.  The exit
 
          code is 10 + the number of files that couldn't be imported, up
 
          to the maximum exit code of 99.
 
========= =================================================================
import2ledger/importers/patreon.py
Show inline comments
 
import pathlib
 
import re
 

	
 
from . import _csv
 
from .. import strparse
 

	
 
class IncomeImporter(_csv.CSVImporterBase):
 
    NEEDED_FIELDS = frozenset([
 
        'FirstName',
 
        'LastName',
 
        'Pledge',
 
        'Status',
 
    ])
 
    COPIED_FIELDS = {
 
        'Pledge': 'amount',
 
    }
 
    ENTRY_SEED = {
 
        'currency': 'USD',
 
    }
 

	
 
    def __init__(self, input_file):
 
        super().__init__(input_file)
 
        match = re.search(r'(?:\b|_)(\d{4}-\d{2}-\d{2})(?:\b|_)',
 
                          pathlib.Path(input_file.name).name)
 
        if match:
 
            self.entry_seed['date'] = strparse.date(match.group(1), '%Y-%m-%d')
 

	
 
    def _read_row(self, row):
 
        if row['Status'] != 'Processed':
 
            return None
 
        else:
 
            return {
 
                'payee': '{0[FirstName]} {0[LastName]}'.format(row),
 
            }
 

	
 

	
 
class PayoutImporter(_csv.CSVImporterBase):
 
    AMOUNT_KEY = 'Total funds deducted from creator balance'
 
    PLEDGE_KEY = 'Funds used for pledges to other creators'
 
    TRANSFER_KEY = 'Funds transferred to you'
 
    NEEDED_FIELDS = frozenset([
 
        'Month',
 
        TRANSFER_KEY,
 
        PLEDGE_KEY,
 
        AMOUNT_KEY,
 
    ])
 
    ENTRY_SEED = {
 
        'currency': 'USD',
 
        'payee': 'Patreon',
 
    }
 

	
 
    def _read_row(self, row):
 
        amount = strparse.currency_decimal(row[self.AMOUNT_KEY])
 
        if not amount:
 
            return None
 
        else:
 
            return {
 
                'amount': amount,
 
                'date': strparse.date(row['Month'], '%Y-%m'),
 
                'pledges_amount': strparse.currency_decimal(row[self.PLEDGE_KEY]),
 
                'transfer_amount': strparse.currency_decimal(row[self.TRANSFER_KEY]),
 
            }
 

	
 

	
 
class FeeImporterBase(_csv.CSVImporterBase):
 
    ENTRY_SEED = {
 
        'currency': 'USD',
 
        'payee': "Patreon",
 
    }
 

	
 
    def _read_row(self, row):
 
        return {
 
            'amount': row[self.AMOUNT_FIELD],
 
            'date': strparse.date(row['Month'], '%Y-%m'),
 
        }
 

	
 

	
 
class ServiceFeesImporter(FeeImporterBase):
 
    AMOUNT_FIELD = 'Patreon Fee'
 
    NEEDED_FIELDS = frozenset(['Month', AMOUNT_FIELD])
 

	
 

	
 
class CardFeesImporter(FeeImporterBase):
 
    AMOUNT_FIELD = 'Processing Fees'
 
    NEEDED_FIELDS = frozenset(['Month', AMOUNT_FIELD])
 

	
 

	
 
class VATImporter(FeeImporterBase):
 
    AMOUNT_FIELD = 'Vat Charged'
 
    NEEDED_FIELDS = frozenset(['Month', AMOUNT_FIELD])
 
    COPIED_FIELDS = {
 
        'Country Code': 'country_code',
 
        'Country Name': 'country_name',
 
    }
setup.py
Show inline comments
 
#!/usr/bin/env python3
 

	
 
import sys
 

	
 
from setuptools import setup, find_packages
 

	
 
REQUIREMENTS = {
 
    'install_requires': [
 
        'babel',
 
        'enum34;python_version<"3.4"',
 
    ],
 
    'setup_requires': ['pytest-runner'],
 
    'extras_require': {
 
        'brightfunds': ['xlrd'],
 
        'nbpy2017': ['beautifulsoup4', 'html5lib'],
 
    },
 
}
 

	
 
all_extras_require = [
 
    req for reqlist in REQUIREMENTS['extras_require'].values() for req in reqlist
 
]
 

	
 
REQUIREMENTS['extras_require']['all_importers'] = all_extras_require
 
REQUIREMENTS['tests_require'] = [
 
    'pytest',
 
    'PyYAML',
 
    *all_extras_require,
 
]
 

	
 
setup(
 
    name='import2ledger',
 
    description="Import different sources of financial data to Ledger",
 
    version='0.5',
 
    version='0.6',
 
    author='Brett Smith',
 
    author_email='brettcsmith@brettcsmith.org',
 
    license='GNU AGPLv3+',
 

	
 
    packages=find_packages(include=['import2ledger', 'import2ledger.*']),
 
    entry_points={
 
        'console_scripts': ['import2ledger = import2ledger.__main__:main'],
 
    },
 

	
 
    **REQUIREMENTS,
 
)
tests/data/PatreonPayouts.csv
Show inline comments
 
new file 100644
 
Month,Funds transferred to you,Funds used for pledges to other creators,Total funds deducted from creator balance
 
2018-03,$0,$0,$0
 
2018-04,$123.45,$0,$123.45
 
2018-05,"$2,345.67",$0,"$2,345.67"
tests/data/imports.yml
Show inline comments
 
- source: PatreonPatronReport_2017-09-01.csv
 
  importer: patreon.IncomeImporter
 
  expect:
 
    - payee: Alex Jones
 
      date: !!python/object/apply:datetime.date [2017, 9, 1]
 
      amount: !!python/object/apply:decimal.Decimal ["1500.00"]
 
      currency: USD
 
    - payee: Dakota Doe
 
      date: !!python/object/apply:datetime.date [2017, 9, 1]
 
      amount: !!python/object/apply:decimal.Decimal ["12.00"]
 
      currency: USD
 

	
 
- source: PatreonEarnings.csv
 
  importer: patreon.ServiceFeesImporter
 
  expect:
 
    - payee: Patreon
 
      date: !!python/object/apply:datetime.date [2017, 9, 1]
 
      amount: !!python/object/apply:decimal.Decimal ["61.73"]
 
      currency: USD
 
    - payee: Patreon
 
      date: !!python/object/apply:datetime.date [2017, 10, 1]
 
      amount: !!python/object/apply:decimal.Decimal ["117.03"]
 
      currency: USD
 

	
 
- source: PatreonEarnings.csv
 
  importer: patreon.CardFeesImporter
 
  expect:
 
    - payee: Patreon
 
      date: !!python/object/apply:datetime.date [2017, 9, 1]
 
      amount: !!python/object/apply:decimal.Decimal ["52.47"]
 
      currency: USD
 
    - payee: Patreon
 
      date: !!python/object/apply:datetime.date [2017, 10, 1]
 
      amount: !!python/object/apply:decimal.Decimal ["99.47"]
 
      currency: USD
 

	
 
- source: PatreonVat.csv
 
  importer: patreon.VATImporter
 
  expect:
 
    - payee: Patreon
 
      date: !!python/object/apply:datetime.date [2017, 9, 1]
 
      amount: !!python/object/apply:decimal.Decimal ["2.00"]
 
      currency: USD
 
      country_code: AT
 
      country_name: Austria
 
    - payee: Patreon
 
      date: !!python/object/apply:datetime.date [2017, 9, 1]
 
      amount: !!python/object/apply:decimal.Decimal ["3.30"]
 
      currency: USD
 
      country_code: BE
 
      country_name: Belgium
 
    - payee: Patreon
 
      date: !!python/object/apply:datetime.date [2017, 10, 1]
 
      amount: !!python/object/apply:decimal.Decimal ["0.40"]
 
      currency: USD
 
      country_code: BG
 
      country_name: Bulgaria
 
    - payee: Patreon
 
      date: !!python/object/apply:datetime.date [2017, 10, 1]
 
      amount: !!python/object/apply:decimal.Decimal ["6.05"]
 
      currency: USD
 
      country_code: CZ
 
      country_name: Czech Republic
 

	
 
- source: PatreonPayouts.csv
 
  importer: patreon.PayoutImporter
 
  expect:
 
    - payee: Patreon
 
      date: !!python/object/apply:datetime.date [2018, 4, 1]
 
      amount: !!python/object/apply:decimal.Decimal ["123.45"]
 
      pledges_amount: !!python/object/apply:decimal.Decimal ["0"]
 
      transfer_amount: !!python/object/apply:decimal.Decimal ["123.45"]
 
      currency: USD
 
    - payee: Patreon
 
      date: !!python/object/apply:datetime.date [2018, 5, 1]
 
      amount: !!python/object/apply:decimal.Decimal ["2345.67"]
 
      pledges_amount: !!python/object/apply:decimal.Decimal ["0"]
 
      transfer_amount: !!python/object/apply:decimal.Decimal ["2345.67"]
 
      currency: USD
 

	
 
- source: StripePayments.csv
 
  importer: stripe.PaymentImporter
 
  expect:
 
    - payee: Dakota Smith
 
      date: !!python/object/apply:datetime.date [2017, 11, 8]
 
      amount: !!python/object/apply:decimal.Decimal ["100.00"]
 
      fee: !!python/object/apply:decimal.Decimal ["3"]
 
      tax: !!python/object/apply:decimal.Decimal ["0"]
 
      currency: USD
 
      payment_id: ch_oxuish6phae2Raighooghi3U
 
      customer_id: cus_DohSheeQu8eng3
 
      customer_email: one@example.org
 
      payout_id: po_aeYees2ahtier8ohju7Eeyie
 
      description: "Payment for invoice #102"
 
    - payee: Dakota Jones
 
      date: !!python/object/apply:datetime.date [2017, 10, 28]
 
      amount: !!python/object/apply:decimal.Decimal ["50.00"]
 
      fee: !!python/object/apply:decimal.Decimal ["1.4"]
 
      tax: !!python/object/apply:decimal.Decimal ["0"]
 
      currency: USD
 
      payment_id: ch_hHee9ef1aeyee1ruo7ochee9
 
      customer_id: cus_iepae2Iecae8Ei
 
      customer_email: two@example.org
 
      payout_id: po_aeYees2ahtier8ohju7Eeyie
 
      description: "Payment for invoice #100"
 

	
 
- source: StripePayouts.csv
 
  importer: stripe.PayoutImporter
 
  expect:
 
    - payee: Stripe
 
      date: !!python/object/apply:datetime.date [2017, 11, 30]
 
      amount: !!python/object/apply:decimal.Decimal ["-50"]
 
      currency: USD
 
      payment_count: !!python/object/apply:decimal.Decimal ["0"]
 
      payment_gross: !!python/object/apply:decimal.Decimal ["0"]
 
      payment_fees: !!python/object/apply:decimal.Decimal ["0"]
 
      payment_net: !!python/object/apply:decimal.Decimal ["0"]
 
      refund_count: !!python/object/apply:decimal.Decimal ["1"]
 
      refund_gross: !!python/object/apply:decimal.Decimal ["-50"]
 
      refund_fees: !!python/object/apply:decimal.Decimal ["0"]
 
      refund_net: !!python/object/apply:decimal.Decimal ["-50"]
 
      collected_fee_count: !!python/object/apply:decimal.Decimal ["0"]
 
      collected_fee_gross: !!python/object/apply:decimal.Decimal ["0"]
 
      collected_fee_refund_count: !!python/object/apply:decimal.Decimal ["0"]
 
      collected_fee_refund_gross: !!python/object/apply:decimal.Decimal ["0"]
 
      adjustment_count: !!python/object/apply:decimal.Decimal ["0"]
 
      adjustment_gross: !!python/object/apply:decimal.Decimal ["0"]
 
      adjustment_fees: !!python/object/apply:decimal.Decimal ["0"]
 
      adjustment_net: !!python/object/apply:decimal.Decimal ["0"]
 
      validation_count: !!python/object/apply:decimal.Decimal ["0"]
 
      validation_fees: !!python/object/apply:decimal.Decimal ["0"]
 
      retried_payout_count: !!python/object/apply:decimal.Decimal ["0"]
 
      retried_payout_net: !!python/object/apply:decimal.Decimal ["0"]
 
      total_count: !!python/object/apply:decimal.Decimal ["1"]
 
      total_gross: !!python/object/apply:decimal.Decimal ["-50"]
 
      total_fees: !!python/object/apply:decimal.Decimal ["0"]
 
      total_net: !!python/object/apply:decimal.Decimal ["-50"]
 
      payout_id: po_faegh6aeghishuethuoSoT2i
 
      destination_id: ba_chu0Woop5queewi2Ea1Aibah
 
      balance_txid: txn_EiKahrazei3aeMohk7EeDigh
 
      failure_txid: ""
 
    - payee: Stripe
 
      date: !!python/object/apply:datetime.date [2017, 11, 29]
 
      amount: !!python/object/apply:decimal.Decimal ["146.50"]
 
      currency: USD
 
      payment_count: !!python/object/apply:decimal.Decimal ["2"]
 
      payment_gross: !!python/object/apply:decimal.Decimal ["150"]
 
      payment_fees: !!python/object/apply:decimal.Decimal ["3.5"]
 
      payment_net: !!python/object/apply:decimal.Decimal ["146.5"]
 
      refund_count: !!python/object/apply:decimal.Decimal ["0"]
 
      refund_gross: !!python/object/apply:decimal.Decimal ["0"]
 
      refund_fees: !!python/object/apply:decimal.Decimal ["0"]
 
      refund_net: !!python/object/apply:decimal.Decimal ["0"]
 
      collected_fee_count: !!python/object/apply:decimal.Decimal ["0"]
 
      collected_fee_gross: !!python/object/apply:decimal.Decimal ["0"]
 
      collected_fee_refund_count: !!python/object/apply:decimal.Decimal ["0"]
 
      collected_fee_refund_gross: !!python/object/apply:decimal.Decimal ["0"]
 
      adjustment_count: !!python/object/apply:decimal.Decimal ["0"]
 
      adjustment_gross: !!python/object/apply:decimal.Decimal ["0"]
 
      adjustment_fees: !!python/object/apply:decimal.Decimal ["0"]
 
      adjustment_net: !!python/object/apply:decimal.Decimal ["0"]
 
      validation_count: !!python/object/apply:decimal.Decimal ["0"]
 
      validation_fees: !!python/object/apply:decimal.Decimal ["0"]
 
      retried_payout_count: !!python/object/apply:decimal.Decimal ["0"]
 
      retried_payout_net: !!python/object/apply:decimal.Decimal ["0"]
 
      total_count: !!python/object/apply:decimal.Decimal ["2"]
 
      total_gross: !!python/object/apply:decimal.Decimal ["150"]
 
      total_fees: !!python/object/apply:decimal.Decimal ["3.5"]
 
      total_net: !!python/object/apply:decimal.Decimal ["146.5"]
 
      payout_id: po_Do9pathoo9Pu8jaePhahJa0e
 
      destination_id: ba_chu0Woop5queewi2Ea1Aibah
 
      balance_txid: txn_ahsaixiene6Thie1aiti3tuo
 
      failure_txid: ""
 

	
 
- source: nbpy2017a.html
 
  importer: nbpy2017.InvoiceImporter
 
  expect:
 
    - payee: Python Person A
 
      ledger template: nbpy2017 invoice ledger entry
 
      date: !!python/object/apply:datetime.date [2017, 10, 19]
 
      amount: !!python/object/apply:decimal.Decimal ["80.00"]
 
      tickets_sold: !!python/object/apply:decimal.Decimal ["1"]
 
      ticket_rate: !!python/object/apply:decimal.Decimal ["21.25"]
 
      shirts_sold: !!python/object/apply:decimal.Decimal ["1"]
 
      shirt_rate: !!python/object/apply:decimal.Decimal ["25.50"]
 
      currency: USD
 
      status: Invoice
 
      invoice_id: "83"
 
      invoice_date: !!python/object/apply:datetime.date [2017, 10, 19]
 
    - payee: Python Person A
 
      ledger template: nbpy2017 payment ledger entry
 
      date: !!python/object/apply:datetime.date [2017, 10, 19]
 
      amount: !!python/object/apply:decimal.Decimal ["80.00"]
 
      tickets_sold: !!python/object/apply:decimal.Decimal ["1"]
 
      ticket_rate: !!python/object/apply:decimal.Decimal ["21.25"]
 
      shirts_sold: !!python/object/apply:decimal.Decimal ["1"]
 
      shirt_rate: !!python/object/apply:decimal.Decimal ["25.50"]
 
      currency: USD
 
      status: Payment
 
      invoice_id: "83"
 
      invoice_date: !!python/object/apply:datetime.date [2017, 10, 19]
 
      payment_id: ch_ahr0ue8lai1ohqu4Gei4Biem
 
      stripe_id: ch_ahr0ue8lai1ohqu4Gei4Biem
 

	
 
- source: nbpy2017b.html
 
  importer: nbpy2017.InvoiceImporter
 
  expect:
 
    - payee: Python Person B
 
      ledger template: nbpy2017 invoice ledger entry
 
      date: !!python/object/apply:datetime.date [2017, 12, 3]
 
      amount: !!python/object/apply:decimal.Decimal ["50.00"]
 
      tickets_sold: !!python/object/apply:decimal.Decimal ["1"]
 
      ticket_rate: !!python/object/apply:decimal.Decimal ["42.50"]
 
      shirts_sold: !!python/object/apply:decimal.Decimal ["0"]
 
      shirt_rate: !!python/object/apply:decimal.Decimal ["25.50"]
 
      status: Invoice
 
      currency: USD
 
      invoice_date: !!python/object/apply:datetime.date [2017, 12, 3]
 
      invoice_id: "304"
 
    - payee: Python Person B
 
      ledger template: nbpy2017 payment ledger entry
 
      date: !!python/object/apply:datetime.date [2017, 12, 3]
 
      amount: !!python/object/apply:decimal.Decimal ["50.00"]
 
      tickets_sold: !!python/object/apply:decimal.Decimal ["1"]
 
      ticket_rate: !!python/object/apply:decimal.Decimal ["42.50"]
 
      shirts_sold: !!python/object/apply:decimal.Decimal ["0"]
 
      shirt_rate: !!python/object/apply:decimal.Decimal ["25.50"]
 
      status: Payment
 
      currency: USD
 
      invoice_date: !!python/object/apply:datetime.date [2017, 12, 3]
 
      payment_id: ch_eishei9aiY8aiqu4lieYiu9i
 
      stripe_id: ch_eishei9aiY8aiqu4lieYiu9i
 
      invoice_id: "304"
 

	
 
- source: nbpy2017c.html
 
  importer: nbpy2017.InvoiceImporter
 
  expect:
 
    - payee: Python Person C
 
      ledger template: nbpy2017 invoice ledger entry
 
      date: !!python/object/apply:datetime.date [2017, 10, 5]
 
      amount: !!python/object/apply:decimal.Decimal ["55.00"]
 
      tickets_sold: !!python/object/apply:decimal.Decimal ["1"]
 
      ticket_rate: !!python/object/apply:decimal.Decimal ["21.25"]
 
      shirts_sold: !!python/object/apply:decimal.Decimal ["1"]
 
      shirt_rate: !!python/object/apply:decimal.Decimal ["25.50"]
 
      status: Invoice
 
      currency: USD
 
      invoice_date: !!python/object/apply:datetime.date [2017, 10, 5]
 
      invoice_id: "11"
 
    - payee: Python Person C
 
      ledger template: nbpy2017 payment ledger entry
 
      date: !!python/object/apply:datetime.date [2017, 10, 5]
 
      amount: !!python/object/apply:decimal.Decimal ["55.00"]
 
      tickets_sold: !!python/object/apply:decimal.Decimal ["1"]
 
      ticket_rate: !!python/object/apply:decimal.Decimal ["21.25"]
 
      shirts_sold: !!python/object/apply:decimal.Decimal ["1"]
 
      shirt_rate: !!python/object/apply:decimal.Decimal ["25.50"]
 
      status: Payment
 
      currency: USD
 
      invoice_date: !!python/object/apply:datetime.date [2017, 10, 5]
 
      payment_id: ch_daer0ahwoh9oDeiqu2eimoD7
 
      stripe_id: ch_daer0ahwoh9oDeiqu2eimoD7
 
      invoice_id: "11"
 

	
 
- source: AmazonAffiliateEarnings.csv
 
  importer: amazon.EarningsImporter
 
  expect:
 
    - payee: Amazon
 
      date: !!python/object/apply:datetime.date [2016, 12, 20]
 
      amount: !!python/object/apply:decimal.Decimal ["4.24"]
 
      currency: USD
 
    - payee: Amazon
 
      date: !!python/object/apply:datetime.date [2017, 1, 7]
 
      amount: !!python/object/apply:decimal.Decimal ["-.08"]
 
      currency: USD
 

	
 
- source: Benevity.csv
 
  importer: benevity.DonationsImporter
 
  expect:
 
    - date: !!python/object/apply:datetime.date [2017, 10, 28]
 
      currency: USD
 
      disbursement_id: ABCDE12345
 
      amount: !!python/object/apply:decimal.Decimal [20]
 
      donation_amount: !!python/object/apply:decimal.Decimal [20]
 
      match_amount: !!python/object/apply:decimal.Decimal [0]
 
      payee: Dakota Smith
 
      corporation: Company A
 
      project: ""
 
      comment: ""
 
      frequency: One-time
 
      transaction_id: 67890QWERT
 
    - date: !!python/object/apply:datetime.date [2017, 10, 30]
 
      currency: USD
 
      disbursement_id: ABCDE12345
 
      amount: !!python/object/apply:decimal.Decimal [25]
 
      donation_amount: !!python/object/apply:decimal.Decimal [25]
 
      match_amount: !!python/object/apply:decimal.Decimal [0]
 
      payee: Dakota Smith
 
      corporation: Company A
 
      project: ""
 
      comment: ""
 
      frequency: One-time
 
      transaction_id: 67890WERTY
 
    - date: !!python/object/apply:datetime.date [2017, 10, 19]
 
      currency: USD
 
      disbursement_id: ABCDE12345
 
      amount: !!python/object/apply:decimal.Decimal [10]
 
      donation_amount: !!python/object/apply:decimal.Decimal [0]
 
      match_amount: !!python/object/apply:decimal.Decimal [10]
 
      payee: Anonymous
 
      corporation: Company B
 
      project: ""
 
      comment: ""
 
      frequency: Unknown
 
      transaction_id: 67890ERTYU
 
    - date: !!python/object/apply:datetime.date [2017, 10, 19]
 
      currency: USD
 
      disbursement_id: ABCDE12345
 
      amount: !!python/object/apply:decimal.Decimal [20]
 
      donation_amount: !!python/object/apply:decimal.Decimal [0]
 
      match_amount: !!python/object/apply:decimal.Decimal [20]
 
      payee: Anonymous
 
      corporation: Company B
 
      project: ""
 
      comment: ""
 
      frequency: Unknown
 
      transaction_id: 67890RTYUI
 
    - date: !!python/object/apply:datetime.date [2017, 10, 19]
 
      currency: USD
 
      disbursement_id: ABCDE12345
 
      amount: !!python/object/apply:decimal.Decimal [30]
 
      donation_amount: !!python/object/apply:decimal.Decimal [30]
 
      match_amount: !!python/object/apply:decimal.Decimal [0]
 
      payee: Anonymous
 
      corporation: Company B
 
      project: ""
 
      comment: ""
 
      frequency: Recurring
 
      transaction_id: 67890TYUIO
 

	
 
- source: BrightFunds.xls
 
  importer: brightfunds.DonorReportImporter
 
  expect:
 
    - date: !!python/object/apply:datetime.date [2017, 10, 20]
 
      currency: USD
 
      amount: !!python/object/apply:decimal.Decimal [120]
 
      payee: Dakota Smith
 
      corporation: Company
 
      company_name: ""
 
      designation: ""
 
      donor_name: Company
 
      donor_email: ""
 
      fund: ""
 
      on_behalf_of: Dakota Smith
 
      type: Matched Donation
 

	
 
- source: OReillyRoyalties.csv
 
  importer: oreilly.RoyaltiesImporter
 
  expect:
 
    - date: !!python/object/apply:datetime.date [2018, 3, 31]
 
      start_date: !!python/object/apply:datetime.date [2018, 3, 1]
 
      paid_date: null
 
      currency: USD
 
      amount: !!python/object/apply:decimal.Decimal ["11.96"]
 
      payee: "O'Reilly Media, Inc."
 
    - date: !!python/object/apply:datetime.date [2018, 2, 28]
 
      start_date: !!python/object/apply:datetime.date [2018, 2, 1]
 
      paid_date: !!python/object/apply:datetime.date [2018, 3, 29]
 
      currency: USD
 
      amount: !!python/object/apply:decimal.Decimal ["20.83"]
 
      payee: "O'Reilly Media, Inc."
 
    - date: !!python/object/apply:datetime.date [2018, 1, 31]
 
      start_date: !!python/object/apply:datetime.date [2018, 1, 1]
 
      paid_date: !!python/object/apply:datetime.date [2018, 3, 29]
 
      currency: USD
 
      amount: !!python/object/apply:decimal.Decimal ["8.51"]
 
      payee: "O'Reilly Media, Inc."
 
    - date: !!python/object/apply:datetime.date [2017, 3, 31]
 
      start_date: !!python/object/apply:datetime.date [2017, 3, 1]
 
      paid_date: !!python/object/apply:datetime.date [2017, 4, 28]
 
      currency: USD
 
      amount: !!python/object/apply:decimal.Decimal ["26.91"]
 
      payee: "O'Reilly Media, Inc."
 
    - date: !!python/object/apply:datetime.date [2017, 1, 31]
 
      start_date: !!python/object/apply:datetime.date [2017, 1, 1]
 
      paid_date: !!python/object/apply:datetime.date [2017, 4, 28]
 
      currency: USD
 
      amount: !!python/object/apply:decimal.Decimal ["12.33"]
 
      payee: "O'Reilly Media, Inc."
 
    - date: !!python/object/apply:datetime.date [2016, 12, 31]
 
      start_date: !!python/object/apply:datetime.date [2016, 12, 1]
 
      paid_date: !!python/object/apply:datetime.date [2017, 4, 28]
 
      currency: USD
 
      amount: !!python/object/apply:decimal.Decimal ["9.15"]
 
      payee: "O'Reilly Media, Inc."
 
    - date: !!python/object/apply:datetime.date [2016, 9, 30]
 
      start_date: !!python/object/apply:datetime.date [2016, 9, 1]
 
      paid_date: !!python/object/apply:datetime.date [2016, 12, 16]
 
      currency: USD
 
      amount: !!python/object/apply:decimal.Decimal ["26.19"]
 
      payee: "O'Reilly Media, Inc."
 
    - date: !!python/object/apply:datetime.date [2016, 8, 31]
 
      start_date: !!python/object/apply:datetime.date [2016, 8, 1]
 
      paid_date: !!python/object/apply:datetime.date [2016, 11, 30]
 
      currency: USD
 
      amount: !!python/object/apply:decimal.Decimal ["27.58"]
 
      payee: "O'Reilly Media, Inc."
 
    - date: !!python/object/apply:datetime.date [2010, 3, 31]
 
      start_date: !!python/object/apply:datetime.date [2010, 1, 1]
 
      paid_date: !!python/object/apply:datetime.date [2010, 3, 31]
 
      currency: USD
 
      amount: !!python/object/apply:decimal.Decimal ["73.85"]
 
      payee: "O'Reilly Media, Inc."
 

	
 
- source: OReillyPayments.csv
 
  importer: oreilly.PaymentsImporter
 
  expect:
 
    - date: !!python/object/apply:datetime.date [2018, 3, 29]
 
      paid_date: !!python/object/apply:datetime.date [2018, 3, 29]
 
      currency: USD
 
      amount: !!python/object/apply:decimal.Decimal ["29.34"]
 
      payee: "O'Reilly Media, Inc."
 
    - date: !!python/object/apply:datetime.date [2017, 4, 27]
 
      paid_date: !!python/object/apply:datetime.date [2017, 4, 28]
 
      currency: USD
 
      amount: !!python/object/apply:decimal.Decimal ["26.91"]
 
      payee: "O'Reilly Media, Inc."
 
    - date: !!python/object/apply:datetime.date [2017, 4, 24]
 
      paid_date: !!python/object/apply:datetime.date [2017, 4, 28]
 
      currency: USD
 
      amount: !!python/object/apply:decimal.Decimal ["21.48"]
 
      payee: "O'Reilly Media, Inc."
 
    - date: !!python/object/apply:datetime.date [2016, 12, 16]
 
      paid_date: !!python/object/apply:datetime.date [2016, 12, 16]
 
      currency: USD
 
      amount: !!python/object/apply:decimal.Decimal ["26.19"]
 
      payee: "O'Reilly Media, Inc."
 
    - date: !!python/object/apply:datetime.date [2016, 11, 29]
 
      paid_date: !!python/object/apply:datetime.date [2016, 11, 30]
 
      currency: USD
 
      amount: !!python/object/apply:decimal.Decimal ["27.58"]
 
      payee: "O'Reilly Media, Inc."
 
    - date: !!python/object/apply:datetime.date [2010, 3, 31]
 
      paid_date: !!python/object/apply:datetime.date [2010, 3, 31]
 
      currency: USD
 
      amount: !!python/object/apply:decimal.Decimal ["73.85"]
 
      payee: "O'Reilly Media, Inc."
0 comments (0 inline, 0 general)