Changeset 12753


Ignore:
Timestamp:
12 Mar 2015, 11:02:24 (10 years ago)
Author:
Henrik Bettermann
Message:

Add helper function get_payments_from_payer_id.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/payments
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/payments/payment.py

    r12749 r12753  
    5757    return None
    5858
     59def get_payments_from_payer_id(payer_id):
     60    """Get payments by payer id.
     61
     62    If no such payment can be found in catalog, return none.
     63    """
     64    cat = getUtility(ICatalog, name='payments_catalog')
     65    result_set = [x for x in cat.searchResults(
     66        payer_id=(payer_id, payer_id))]
     67    if len(result_set):
     68        return result_set
     69    return None
     70
    5971
    6072def find_payable_from_payable_id(payable_id):
  • main/waeup.ikoba/trunk/src/waeup/ikoba/payments/tests/test_payment.py

    r12752 r12753  
    3535from waeup.ikoba.payments.payment import (
    3636    Payment, get_payment_providers, PaymentItem, format_payment_item_values,
    37     get_payment, find_payable_from_payable_id, find_payer_from_payer_id,
    38     format_amount,
     37    get_payment, get_payments_from_payer_id, find_payable_from_payable_id,
     38    find_payer_from_payer_id, format_amount,
    3939    )
    4040from waeup.ikoba.testing import (FunctionalLayer, FunctionalTestCase)
     
    157157        self.assertTrue(result is p1)
    158158        self.assertTrue(get_payment('not-valid') is None)
     159
     160    def test_get_payments_from_payer_id(self):
     161        # we can lookup payments.
     162        self.getRootFolder()['app'] = Company()
     163        app = self.getRootFolder()['app']
     164        setSite(app)
     165        p1 = Payment(FakePayer(), FakePayable())
     166        app['payments']['1'] = p1
     167        p_id = p1.payment_id
     168        result = get_payments_from_payer_id('PAYER_01')
     169        self.assertTrue(result[0] is p1)
     170        self.assertTrue(get_payments_from_payer_id('not-valid') is None)
    159171
    160172    def test_find_payable_from_payable_id(self):
Note: See TracChangeset for help on using the changeset viewer.