def percent_surcharge(self): try: settings = get_shop_payment_settings() except KeyError: # happens GS profile application if registry entries not present # yet return Decimal('0') surcharge = settings.percent_surcharge if surcharge: return format_amount(Decimal(str(surcharge))) else: return ''
def costs(self): try: settings = get_shop_payment_settings() except KeyError: # happens GS profile application if registry entries not present # yet return Decimal('0') costs = settings.cash_on_delivery_costs if costs: costs = Decimal(str(costs)) else: costs = Decimal('0') return format_amount(costs)
def gross(val): return format_amount(val + (val / Decimal(100) * shipping_vat))
def description(self): settings = get_shop_shipping_settings() currency = get_shop_settings().currency show_currency = get_shop_settings().show_currency if show_currency == 'symbol': currency = CURRENCY_LITERALS[currency] shipping_limit_from_gross = settings.shipping_limit_from_gross free_shipping_limit = Decimal(str(settings.free_shipping_limit)) flat_shipping_cost = Decimal(str(settings.flat_shipping_cost)) item_shipping_cost = Decimal(str(settings.item_shipping_cost)) shipping_vat = Decimal(str(settings.shipping_vat)) def gross(val): return format_amount(val + (val / Decimal(100) * shipping_vat)) # no shipping costs if not flat_shipping_cost and not item_shipping_cost: return _(u"free_shipping", default=u"Free Shipping") # no free shipping limit if not free_shipping_limit: # flat and item costs defined if flat_shipping_cost and item_shipping_cost: msg = _(u"no_free_shipping_flat_and_item", default=u"Minimum ${flat} ${currency} or ${item} " u"${currency} per item in cart") return Message(msg, mapping={ 'flat': gross(flat_shipping_cost), 'item': gross(item_shipping_cost), 'currency': currency, }) # flat costs only if flat_shipping_cost and not item_shipping_cost: msg = _(u"no_free_shipping_flat_only", default=u"Flat ${flat} ${currency}") return Message(msg, mapping={ 'flat': gross(flat_shipping_cost), 'currency': currency, }) # item costs only if not flat_shipping_cost and item_shipping_cost: msg = _(u"no_free_shipping_item_only", default=u"${item} ${currency} per item in cart") return Message(msg, mapping={ 'item': gross(item_shipping_cost), 'currency': currency, }) # free shipping above limit # flat and item costs defined if flat_shipping_cost and item_shipping_cost: # from gross if shipping_limit_from_gross: msg = _(u"free_shipping_limit_flat_and_item_gross", default=u"Minimum ${flat} ${currency} or " u"${item} ${currency} per item in cart. Free " u"shipping if gross purchase price above " u"${limit} ${currency}") # from net else: msg = _(u"free_shipping_limit_flat_and_item_net", default=u"Minimum ${flat} ${currency} or " u"${item} ${currency} per item in cart. Free " u"shipping if net purchase price above " u"${limit} ${currency}") return Message(msg, mapping={ 'flat': gross(flat_shipping_cost), 'item': gross(item_shipping_cost), 'limit': format_amount(free_shipping_limit), 'currency': currency, }) # flat costs only if flat_shipping_cost and not item_shipping_cost: # from gross if shipping_limit_from_gross: msg = _(u"free_shipping_limit_flat_only_gross", default=u"Flat ${flat} ${currency}. Free " u"shipping if gross purchase price above " u"${limit} ${currency}") # from net else: msg = _(u"free_shipping_limit_flat_only_net", default=u"Flat ${flat} ${currency}. Free " u"shipping if net purchase price above " u"${limit} ${currency}") return Message(msg, mapping={ 'flat': gross(flat_shipping_cost), 'limit': format_amount(free_shipping_limit), 'currency': currency, }) # item costs only if not flat_shipping_cost and item_shipping_cost: # from gross if shipping_limit_from_gross: msg = _(u"free_shipping_limit_item_only_gross", default=u"${item} ${currency} per item in " u"cart. Free shipping if gross purchase " u"price above ${limit} ${currency}") # from net else: msg = _(u"free_shipping_limit_item_only_net", default=u"${item} ${currency} per item in " u"cart. Free shipping if net purchase " u"price above ${limit} ${currency}") return Message(msg, mapping={ 'item': gross(item_shipping_cost), 'limit': format_amount(free_shipping_limit), 'currency': currency, })