def label_from_instance(self, obj): """Return a friendly label for the shipping method.""" price_html = format_price(obj.price.gross, obj.price.currency) min_delivery_time = str(obj.min_delivery_time) max_delivery_time = str(obj.max_delivery_time) label = mark_safe( 'Courier: %s | Price: %s | Estimated time: %s - %s days' % (obj.shipping_method, price_html, min_delivery_time, max_delivery_time)) return label
def label_from_instance(self, obj): """Return a friendly label for the shipping method.""" price_html = format_price(obj.price.gross, obj.price.currency) label = mark_safe('%s %s' % (obj.shipping_method, price_html)) return label
def test_normalize_same_as_formatted(value): formatted_price = prices_i18n.format_price(value, 'USD', normalize=True) net = prices_i18n.net(Price(net=value, currency='USD')) assert not formatted_price == net
def test_format_normalize_price_three_digits(value, expected): normalized_price = prices_i18n.format_price(value, 'BHD', normalize=True) assert normalized_price == expected
def test_format_normalize_price_no_digits(): formatted_price = prices_i18n.format_price(123, 'JPY', normalize=True) assert formatted_price == '¥123'
def test_format_normalize_price(value, expected): formatted_price = prices_i18n.format_price(value, 'USD', normalize=True) assert formatted_price == '$%s' % expected
def test_format_price_invalid_value(): result = prices_i18n.format_price("invalid", "USD") assert result == ""
def label_from_instance(self, obj): price_html = format_price(obj.price.gross, obj.price.currency) label = mark_safe('%s %s' % (obj.shipping_method, price_html)) return label
def test_format_price_invalid_value(): result = prices_i18n.format_price('invalid', 'USD') assert result == ''
def label_from_instance(self, obj): """Return a friendly label for the shipping method.""" price_html = format_price(obj.price.gross, obj.price.currency) label = mark_safe('%s %s' % (obj.shipping_method, price_html)) return label
def test_format_price_invalid_value(): result = prices_i18n.format_price('invalid', 'USD') assert result == ''
def label_from_instance(self, obj): # Mexer aqui para API de Correios price_html = format_price(obj.price.gross, obj.price.currency) label = mark_safe('%s' % (obj.shipping_method)) return label
def format_price(value: Decimal, currency=None, html=False, normalize=False): return prices_i18n.format_price(value, currency=currency or settings.DEFAULT_CURRENCY, html=html, normalize=normalize)