accrual: Wire is a single payment method.
This commit is contained in:
parent
42b3e6ca17
commit
7a0fa4fb57
3 changed files with 22 additions and 18 deletions
|
@ -88,6 +88,7 @@ from typing import (
|
||||||
Iterator,
|
Iterator,
|
||||||
List,
|
List,
|
||||||
Mapping,
|
Mapping,
|
||||||
|
Match,
|
||||||
NamedTuple,
|
NamedTuple,
|
||||||
Optional,
|
Optional,
|
||||||
Sequence,
|
Sequence,
|
||||||
|
@ -434,17 +435,17 @@ class BalanceReport(BaseReport):
|
||||||
|
|
||||||
|
|
||||||
class OutgoingReport(BaseReport):
|
class OutgoingReport(BaseReport):
|
||||||
PAYMENT_METHODS = {
|
class PaymentMethods(enum.Enum):
|
||||||
'ach': 'ACH',
|
ach = 'ACH'
|
||||||
'check': 'Check',
|
check = 'Check'
|
||||||
'creditcard': 'Credit Card',
|
creditcard = 'Credit Card'
|
||||||
'debitcard': 'Debit Card',
|
debitcard = 'Debit Card'
|
||||||
'fxwire': 'International Wire',
|
paypal = 'PayPal'
|
||||||
'paypal': 'PayPal',
|
vendorportal = 'Vendor Portal'
|
||||||
'uswire': 'Domestic Wire',
|
wire = 'Wire'
|
||||||
'vendorportal': 'Vendor Portal',
|
fxwire = wire
|
||||||
}
|
uswire = wire
|
||||||
PAYMENT_METHOD_RE = re.compile(rf'^([a-z]{{3}})\s+({"|".join(PAYMENT_METHODS)})$')
|
|
||||||
|
|
||||||
def __init__(self, rt_wrapper: rtutil.RT, out_file: TextIO) -> None:
|
def __init__(self, rt_wrapper: rtutil.RT, out_file: TextIO) -> None:
|
||||||
super().__init__(out_file)
|
super().__init__(out_file)
|
||||||
|
@ -563,17 +564,20 @@ class OutgoingReport(BaseReport):
|
||||||
ticket_id, payment_method_count,
|
ticket_id, payment_method_count,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
match = self.PAYMENT_METHOD_RE.fullmatch(payment_method)
|
currency, method_key = payment_method.lower().split(None, 1)
|
||||||
|
try:
|
||||||
|
method_enum = self.PaymentMethods[method_key]
|
||||||
|
except KeyError:
|
||||||
|
match: Optional[Match] = None
|
||||||
|
else:
|
||||||
|
match = re.fullmatch(r'[a-z]{3}', currency)
|
||||||
if match is None:
|
if match is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
"cannot set payment-method for rt:%s: invalid value %r",
|
"cannot set payment-method for rt:%s: invalid value %r",
|
||||||
ticket_id, payment_method,
|
ticket_id, payment_method,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
cf_targets['payment-method'] = '{} {}'.format(
|
cf_targets['payment-method'] = f'{currency.upper()} {method_enum.value}'
|
||||||
match.group(1).upper(),
|
|
||||||
self.PAYMENT_METHODS[match.group(2)],
|
|
||||||
)
|
|
||||||
|
|
||||||
cf_updates = {
|
cf_updates = {
|
||||||
f'CF_{key}': value
|
f'CF_{key}': value
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -5,7 +5,7 @@ from setuptools import setup
|
||||||
setup(
|
setup(
|
||||||
name='conservancy_beancount',
|
name='conservancy_beancount',
|
||||||
description="Plugin, library, and reports for reading Conservancy's books",
|
description="Plugin, library, and reports for reading Conservancy's books",
|
||||||
version='1.5.5',
|
version='1.5.6',
|
||||||
author='Software Freedom Conservancy',
|
author='Software Freedom Conservancy',
|
||||||
author_email='info@sfconservancy.org',
|
author_email='info@sfconservancy.org',
|
||||||
license='GNU AGPLv3+',
|
license='GNU AGPLv3+',
|
||||||
|
|
|
@ -546,7 +546,7 @@ def test_outgoing_report_fx_amounts(accrual_postings, caplog):
|
||||||
])
|
])
|
||||||
assert rt_client.edits == {'520': {
|
assert rt_client.edits == {'520': {
|
||||||
'CF_payment-amount': 'EUR 1,000.00 ($1,100.00)',
|
'CF_payment-amount': 'EUR 1,000.00 ($1,100.00)',
|
||||||
'CF_payment-method': 'EUR International Wire',
|
'CF_payment-method': 'EUR Wire',
|
||||||
}}
|
}}
|
||||||
assert 'payment-method:' not in output.getvalue()
|
assert 'payment-method:' not in output.getvalue()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue