Ignore:
Timestamp:
16 Mar 2015, 10:02:14 (10 years ago)
Author:
Henrik Bettermann
Message:

Prepare contract payment receipt.

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

    r12766 r12772  
    5656    return None
    5757
     58
    5859def get_payments_from_payer_id(payer_id):
    5960    """Get payments by payer id.
     
    6465    result_set = [x for x in cat.searchResults(
    6566        payer_id=(payer_id, payer_id))]
     67    if len(result_set):
     68        return result_set
     69    return None
     70
     71
     72def get_payments_from_payable_id(payable_id):
     73    """Get payments by payer id.
     74
     75    If no such payment can be found in catalog, return none.
     76    """
     77    cat = getUtility(ICatalog, name='payments_catalog')
     78    result_set = [x for x in cat.searchResults(
     79        payable_id=(payable_id, payable_id))]
    6680    if len(result_set):
    6781        return result_set
  • main/waeup.ikoba/trunk/src/waeup/ikoba/payments/tests/test_payment.py

    r12753 r12772  
    3636    Payment, get_payment_providers, PaymentItem, format_payment_item_values,
    3737    get_payment, get_payments_from_payer_id, find_payable_from_payable_id,
    38     find_payer_from_payer_id, format_amount,
     38    find_payer_from_payer_id, get_payments_from_payable_id, format_amount,
    3939    )
    4040from waeup.ikoba.testing import (FunctionalLayer, FunctionalTestCase)
     
    169169        self.assertTrue(result[0] is p1)
    170170        self.assertTrue(get_payments_from_payer_id('not-valid') is None)
     171
     172    def test_get_payments_from_payable_id(self):
     173        # we can lookup payments.
     174        self.getRootFolder()['app'] = Company()
     175        app = self.getRootFolder()['app']
     176        setSite(app)
     177        p1 = Payment(FakePayer(), FakePayable())
     178        app['payments']['1'] = p1
     179        p_id = p1.payment_id
     180        result = get_payments_from_payable_id('PAYABLE_01')
     181        self.assertTrue(result[0] is p1)
     182        self.assertTrue(get_payments_from_payable_id('not-valid') is None)
    171183
    172184    def test_find_payable_from_payable_id(self):
Note: See TracChangeset for help on using the changeset viewer.