Beispiel #1
0
def get_fees(event, request, total, invoice_address, provider):
    fees = []

    if provider and total != 0:
        provider = event.get_payment_providers().get(provider)
        if provider:
            payment_fee = provider.calculate_fee(total)

            if payment_fee:
                payment_fee_tax_rule = event.settings.tax_rate_default or TaxRule.zero()
                if payment_fee_tax_rule.tax_applicable(invoice_address):
                    payment_fee_tax = payment_fee_tax_rule.tax(payment_fee, base_price_is='gross')
                    fees.append(OrderFee(
                        fee_type=OrderFee.FEE_TYPE_PAYMENT,
                        value=payment_fee,
                        tax_rate=payment_fee_tax.rate,
                        tax_value=payment_fee_tax.tax,
                        tax_rule=payment_fee_tax_rule
                    ))
                else:
                    fees.append(OrderFee(
                        fee_type=OrderFee.FEE_TYPE_PAYMENT,
                        value=payment_fee,
                        tax_rate=Decimal('0.00'),
                        tax_value=Decimal('0.00'),
                        tax_rule=payment_fee_tax_rule
                    ))

    for recv, resp in fee_calculation_for_cart.send(sender=event, request=request, invoice_address=invoice_address,
                                                    total=total):
        fees += resp

    return fees
Beispiel #2
0
def get_fees(event, request, total, invoice_address, provider):
    fees = []

    if provider and total != 0:
        provider = event.get_payment_providers().get(provider)
        if provider:
            payment_fee = provider.calculate_fee(total)

            if payment_fee:
                payment_fee_tax_rule = event.settings.tax_rate_default or TaxRule.zero(
                )
                if payment_fee_tax_rule.tax_applicable(invoice_address):
                    payment_fee_tax = payment_fee_tax_rule.tax(
                        payment_fee, base_price_is='gross')
                    fees.append(
                        OrderFee(fee_type=OrderFee.FEE_TYPE_PAYMENT,
                                 value=payment_fee,
                                 tax_rate=payment_fee_tax.rate,
                                 tax_value=payment_fee_tax.tax,
                                 tax_rule=payment_fee_tax_rule))
                else:
                    fees.append(
                        OrderFee(fee_type=OrderFee.FEE_TYPE_PAYMENT,
                                 value=payment_fee,
                                 tax_rate=Decimal('0.00'),
                                 tax_value=Decimal('0.00'),
                                 tax_rule=payment_fee_tax_rule))

    for recv, resp in fee_calculation_for_cart.send(
            sender=event, request=request, invoice_address=invoice_address):
        fees += resp

    return fees