- Timestamp:
- 9 Mar 2015, 00:53:07 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/payment.py
r12671 r12696 25 25 from zope.component import getUtilitiesFor 26 26 from zope.event import notify 27 from waeup.ikoba.interfaces import MessageFactory as _ 27 28 from waeup.ikoba.utils.helpers import attrs_to_fields 29 from waeup.ikoba.utils.logger import Logger 28 30 from waeup.ikoba.payments.interfaces import ( 29 31 IPayment, STATE_UNPAID, STATE_FAILED, STATE_PAID, … … 31 33 IPaymentGatewayServicesLister, 32 34 ) 33 from waeup.ikoba.utils.logger import Logger 35 36 37 def format_payment_item_values(payment_item_values, currency): 38 """Format tuples (description, currency, amount) for output. 39 40 `currency` passed in is the 'target' currency. 41 42 Returns a list of formated values. Last item is total sum. 43 XXX: we do not really respect currency. If different items 44 have different currencies, we are choked. 45 """ 46 result = [] 47 total = decimal.Decimal("0.00") 48 for descr, item_currency, amount in payment_item_values: 49 total += amount 50 if item_currency != currency: 51 raise ValueError( 52 "Different currencies in payment items not supported.") 53 result.append((descr, '%s %0.2f' % (item_currency, amount))) 54 result.append((_('Total'), '%s %0.2f' % (currency, total))) 55 return result 34 56 35 57
Note: See TracChangeset for help on using the changeset viewer.