コード例 #1
0
 def label_from_instance(self, obj):
     attributes = obj.product.product_class.variant_attributes.all()
     variant_label = smart_text(obj)
     label = '%(variant_label)s - %(price)s' % {
         'variant_label': variant_label,
         'price': gross(obj.get_price(discounts=self.discounts))}
     return label
コード例 #2
0
ファイル: views.py プロジェクト: globalic/ecommerce-1
def capture_payment(request, order_pk, payment_pk):
    order = get_object_or_404(Order, pk=order_pk)
    payment = get_object_or_404(order.payments, pk=payment_pk)
    amount = order.get_total().quantize('0.01').gross
    form = CapturePaymentForm(request.POST or None,
                              payment=payment,
                              initial={'amount': amount})
    if form.is_valid() and form.capture():
        amount = form.cleaned_data['amount']
        msg = _('Captured %(amount)s') % {'amount': gross(amount)}
        payment.order.create_history_entry(comment=msg, user=request.user)
        messages.success(request, msg)
        return redirect('dashboard:order-details', order_pk=order.pk)
    status = 400 if form.errors else 200
    ctx = {
        'captured': payment.captured_amount,
        'currency': payment.currency,
        'form': form,
        'order': order,
        'payment': payment
    }
    return TemplateResponse(request,
                            'dashboard/order/modal_capture.html',
                            ctx,
                            status=status)
コード例 #3
0
def refund_payment(request, order_pk, payment_pk):
    order = get_object_or_404(Order, pk=order_pk)
    payment = get_object_or_404(order.payments, pk=payment_pk)
    amount = payment.captured_amount
    form = RefundPaymentForm(request.POST or None,
                             payment=payment,
                             initial={'amount': amount})
    if form.is_valid() and form.refund():
        amount = form.cleaned_data['amount']
        msg = pgettext_lazy('Dashboard message related to a payment',
                            'Refunded %(amount)s') % {
                                'amount': gross(amount)
                            }
        payment.order.create_history_entry(comment=msg, user=request.user)
        messages.success(request, msg)
        return redirect('dashboard:order-details', order_pk=order.pk)
    status = 400 if form.errors else 200
    ctx = {
        'captured': payment.captured_amount,
        'currency': payment.currency,
        'form': form,
        'order': order,
        'payment': payment
    }
    return TemplateResponse(request,
                            'dashboard/order/modal/refund.html',
                            ctx,
                            status=status)
コード例 #4
0
ファイル: utils.py プロジェクト: jonathanmeier5/saleor
def price_as_dict(price):
    if not price:
        return None
    return {'currency': price.currency,
            'gross': price.gross,
            'grossLocalized': prices_i18n.gross(price),
            'net': price.net,
            'netLocalized': prices_i18n.net(price)}
コード例 #5
0
ファイル: utils.py プロジェクト: NyanKiyoshi/weekly-saleor
def price_as_dict(price):
    if not price:
        return None
    return {'currency': price.currency,
            'gross': price.gross,
            'grossLocalized': prices_i18n.gross(price),
            'net': price.net,
            'netLocalized': prices_i18n.net(price)}
コード例 #6
0
ファイル: forms.py プロジェクト: globalic/ecommerce-1
 def label_from_instance(self, obj):
     attributes = obj.product.attributes.all()
     variant_label = obj.display_variant(attributes)
     label = '%(variant_label)s - %(price)s' % {
         'variant_label': variant_label,
         'price': gross(obj.get_price(discounts=self.discounts))
     }
     return label
コード例 #7
0
ファイル: forms.py プロジェクト: zeus512/saleor
 def label_from_instance(self, obj):
     variant_label = smart_text(obj)
     label = pgettext_lazy(
         'Variant choice field label', '%(variant_label)s - %(price)s') % {
             'variant_label': variant_label,
             'price': gross(obj.get_price(discounts=self.discounts))
         }
     return label
コード例 #8
0
ファイル: forms.py プロジェクト: glosoftgroup/Hardware
 def label_from_instance(self, obj):
     variant_label = smart_text(obj)
     label = pgettext_lazy(
         'Variant choice field label',
         '%(variant_label)s - %(price)s') % {
             'variant_label': variant_label,
             'price': gross(obj.get_price(discounts=self.discounts))}
     return label
コード例 #9
0
ファイル: views.py プロジェクト: alangunning/saleor
def capture_payment(request, order_pk, payment_pk):
    order = get_object_or_404(Order, pk=order_pk)
    payment = get_object_or_404(order.payments, pk=payment_pk)
    amount = order.get_total().quantize('0.01').gross
    form = CapturePaymentForm(request.POST or None, payment=payment,
                              initial={'amount': amount})
    if form.is_valid() and form.capture():
        amount = form.cleaned_data['amount']
        msg = _('Captured %(amount)s') % {'amount': gross(amount)}
        payment.order.create_history_entry(comment=msg, user=request.user)
        messages.success(request, msg)
        return redirect('dashboard:order-details', order_pk=order.pk)
    status = 400 if form.errors else 200
    ctx = {'captured': payment.captured_amount, 'currency': payment.currency,
           'form': form, 'order': order, 'payment': payment}
    return TemplateResponse(request, 'dashboard/order/modal_capture.html', ctx,
                            status=status)
コード例 #10
0
ファイル: views.py プロジェクト: maciekiks/saleor
def refund_payment(request, order_pk, payment_pk):
    order = get_object_or_404(Order, pk=order_pk)
    payment = get_object_or_404(order.payments, pk=payment_pk)
    amount = payment.captured_amount
    form = RefundPaymentForm(request.POST or None, payment=payment,
                             initial={'amount': amount})
    if form.is_valid() and form.refund():
        amount = form.cleaned_data['amount']
        msg = pgettext_lazy(
            'Dashboard message related to a payment',
            'Refunded %(amount)s') % {'amount': gross(amount)}
        payment.order.create_history_entry(comment=msg, user=request.user)
        messages.success(request, msg)
        return redirect('dashboard:order-details', order_pk=order.pk)
    status = 400 if form.errors else 200
    ctx = {'captured': payment.captured_amount, 'currency': payment.currency,
           'form': form, 'order': order, 'payment': payment}
    return TemplateResponse(request, 'dashboard/order/modal_refund.html', ctx,
                            status=status)
コード例 #11
0
ファイル: views.py プロジェクト: AWalters15/saleor
def capture_payment(request, order_pk, payment_pk):
    order = get_object_or_404(Order, pk=order_pk)
    payment = get_object_or_404(order.payments, pk=payment_pk)
    amount = order.get_total().quantize("0.01").gross
    form = CapturePaymentForm(request.POST or None, payment=payment, initial={"amount": amount})
    if form.is_valid() and form.capture():
        amount = form.cleaned_data["amount"]
        msg = _("Captured %(amount)s") % {"amount": gross(amount)}
        payment.order.create_history_entry(comment=msg, user=request.user)
        messages.success(request, msg)
        return redirect("dashboard:order-details", order_pk=order.pk)
    status = 400 if form.errors else 200
    ctx = {
        "captured": payment.captured_amount,
        "currency": payment.currency,
        "form": form,
        "order": order,
        "payment": payment,
    }
    return TemplateResponse(request, "dashboard/order/modal_capture.html", ctx, status=status)
コード例 #12
0
ファイル: types.py プロジェクト: patrys/saleor
 def resolve_gross_localized(self, info):
     return prices_i18n.gross(self)
def gross_in_currency(price, currency):  # noqa
    converted_price = exchange_currency(price, currency)
    return prices_i18n.gross(converted_price)
コード例 #14
0
 def choice(self, obj):
     label = obj.display_variant(self.attributes)
     label += ' - ' + gross(obj.get_price())
     return (self.field.prepare_value(obj), label)
コード例 #15
0
def discount_as_negative(discount, html=False):
    zero = Price(0, currency=discount.amount.currency)
    return gross(zero - discount.amount, html=html)
コード例 #16
0
ファイル: api.py プロジェクト: jonathanmeier5/saleor
 def resolve_gross_localized(self, args, context, info):
     return prices_i18n.gross(self)
コード例 #17
0
ファイル: views.py プロジェクト: nidhinkandoth/saleor
 def get_variant_label(variant, discounts):
     return '%s, %s, %s' % (
         variant.sku, variant.display_product(),
         gross(variant.get_price_per_item(discounts)))
コード例 #18
0
ファイル: forms.py プロジェクト: tynanook/saleor
 def choice(self, obj):
     label = obj.display_variant(self.attributes)
     label += ' - ' + gross(obj.get_price())
     return (self.field.prepare_value(obj), label)
コード例 #19
0
ファイル: views.py プロジェクト: akjanik/saleor
 def get_variant_label(variant):
     return '%s, %s, %s' % (variant.sku, variant.display_product(),
                            gross(variant.product.price))
コード例 #20
0
ファイル: test_prices.py プロジェクト: tungd/django-prices
def test_templatetag_i18n_gross_normalize(price_fixture):
    gross = prices_i18n.gross(price_fixture, normalize=True)
    assert gross == '$15'
コード例 #21
0
ファイル: test_prices.py プロジェクト: tungd/django-prices
def test_templatetag_i18n_gross_html_normalize(price_fixture):
    gross = prices_i18n.gross(price_fixture, html=True, normalize=True)
    assert gross == '<span class="currency">$</span>15'
コード例 #22
0
ファイル: test_prices.py プロジェクト: tungd/django-prices
def test_templatetag_i18n_gross(price_fixture):
    gross = prices_i18n.gross(price_fixture)
    assert gross == '$15.00'
コード例 #23
0
ファイル: api.py プロジェクト: maciekiks/saleor
 def resolve_gross_localized(self, args, context, info):
     return prices_i18n.gross(self)
コード例 #24
0
 def resolve_gross_localized(self, info):
     return prices_i18n.gross(self)
コード例 #25
0
ファイル: forms.py プロジェクト: AlexzanderIvanov/saleor
 def label_from_instance(self, obj):
     attributes = obj.product.attributes.all()
     variant_label = obj.display_variant(attributes)
     label = '%(variant_label)s - %(price)s' % {
         'variant_label': variant_label, 'price': gross(obj.get_price())}
     return label
def gross_in_currency(price, currency):  # noqa
    converted_price = exchange_currency(price, currency)
    return prices_i18n.gross(converted_price)