- Timestamp:
- 11 Mar 2015, 10:07:50 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/customers/contracts.py
r12718 r12727 33 33 IContractSelectProduct, ICustomersUtils, ISampleContract, 34 34 ISampleContractProcess, ISampleContractEdit, ISampleContractOfficialUse) 35 from waeup.ikoba.payments.interfaces import IPayer, IPayableFinder 35 from waeup.ikoba.payments.interfaces import IPayer, IPayableFinder, IPayable 36 36 from waeup.ikoba.payments.payment import PaymentItem 37 37 from waeup.ikoba.utils.helpers import attrs_to_fields … … 276 276 # there should not be more than one result really. 277 277 return result[0] 278 279 280 class PayableContract(grok.Adapter): 281 """Adapter to adapt IContracts to IPayable. 282 """ 283 284 grok.context(IContract) 285 grok.implements(IPayable) 286 287 def __init__(self, context): 288 self.context = context 289 currencies = set([x.currency for x in context.product_options]) 290 if len(currencies) > 1: 291 raise ValueError( 292 "Only contracts with same currency for all options allowed.") 293 return 294 295 @property 296 def payable_id(self): 297 return self.context.contract_id 298 299 @property 300 def title(self): 301 return self.context.title 302 303 @property 304 def currency(self): 305 if not len(self.context.product_options): 306 return None 307 return self.context.product_options[0].currency 308 309 @property 310 def payment_items(self): 311 result = [] 312 for num, option in enumerate(self.context.product_options): 313 item = PaymentItem() 314 item.item_id = u'%s' % num 315 item.title = option.title 316 item.amount = option.fee 317 result.append(item) 318 return tuple(result)
Note: See TracChangeset for help on using the changeset viewer.