Ignore:
Timestamp:
7 Mar 2015, 04:18:42 (10 years ago)
Author:
uli
Message:

Add adapter to turn lists of product opitons into payment items.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/customers/contracts.py

    r12681 r12683  
    3232    IContractSelectProduct, ICustomersUtils, ISampleContract,
    3333    ISampleContractProcess, ISampleContractEdit, ISampleContractOfficialUse)
     34from waeup.ikoba.payments.interfaces import IPaymentItem
     35from waeup.ikoba.payments.payment import PaymentItem
    3436from waeup.ikoba.utils.helpers import attrs_to_fields
    3537
     
    5658
    5759ContractsContainer = attrs_to_fields(ContractsContainer)
     60
     61
     62def payment_items_from_contract(contract):
     63    """Turn contract product options into payment items.
     64    """
     65    result = []
     66    for num, option in enumerate(contract.product_options):
     67        item = PaymentItem()
     68        item.item_id = u'%s' % num
     69        item.title = option.title
     70        item.amount = option.fee
     71        result.append(item)
     72    return result
    5873
    5974
Note: See TracChangeset for help on using the changeset viewer.