meta_receipt: Accept paypal-id in lieu of receipt for PayPal credits.
This commit is contained in:
parent
381160f0de
commit
a0a3b04e50
2 changed files with 14 additions and 2 deletions
|
@ -42,14 +42,24 @@ class MetaReceipt(core._RequireLinksPostingMetadataHook):
|
|||
receipt_error = error
|
||||
else:
|
||||
return
|
||||
|
||||
if not post.units.number:
|
||||
post_amount = 0
|
||||
elif post.units.number > 0:
|
||||
post_amount = 1
|
||||
else:
|
||||
post_amount = -1
|
||||
|
||||
if post.account.is_checking():
|
||||
fallback_key = 'check'
|
||||
elif (post.account.is_under('Liabilities:CreditCard')
|
||||
and (post.units.number or 0) < 0):
|
||||
elif post.account.is_under('Liabilities:CreditCard') and post_amount == -1:
|
||||
fallback_key = 'invoice'
|
||||
elif post.account.is_under('Assets:PayPal') and post_amount == 1:
|
||||
fallback_key = 'paypal-id'
|
||||
else:
|
||||
yield receipt_error
|
||||
return
|
||||
|
||||
try:
|
||||
self._check_links(txn, post, fallback_key)
|
||||
except errormod.Error as fallback_error:
|
||||
|
|
|
@ -59,6 +59,8 @@ ACCOUNTS = [AccountForTesting._make(t) for t in [
|
|||
('Assets:Bank:CheckCard', PostType.BOTH, 'check'),
|
||||
('Assets:Cash', PostType.BOTH, None),
|
||||
('Assets:Checking', PostType.BOTH, 'check'),
|
||||
('Assets:PayPal', PostType.CREDIT, 'paypal-id'),
|
||||
('Assets:PayPal', PostType.DEBIT, None),
|
||||
('Assets:Savings', PostType.BOTH, None),
|
||||
('Liabilities:CreditCard', PostType.CREDIT, None),
|
||||
('Liabilities:CreditCard', PostType.DEBIT, 'invoice'),
|
||||
|
|
Loading…
Reference in a new issue