def test_create_order_with_gift_card( checkout_with_gift_card, customer_user, shipping_method, is_anonymous_user ): checkout_user = None if is_anonymous_user else customer_user checkout = checkout_with_gift_card checkout.user = checkout_user checkout.billing_address = customer_user.default_billing_address checkout.shipping_address = customer_user.default_billing_address checkout.shipping_method = shipping_method checkout.save() subtotal = calculations.checkout_subtotal(checkout) shipping_price = calculations.checkout_shipping_price(checkout) total_gross_without_gift_cards = ( subtotal.gross + shipping_price.gross - checkout.discount ) gift_cards_balance = checkout.get_total_gift_cards_balance() order = create_order( checkout=checkout, order_data=prepare_order_data( checkout=checkout, tracking_code="tracking_code", discounts=None ), user=customer_user if not is_anonymous_user else AnonymousUser(), redirect_url="https://www.example.com", ) assert order.gift_cards.count() == 1 assert order.gift_cards.first().current_balance.amount == 0 assert order.total.gross == (total_gross_without_gift_cards - gift_cards_balance)
def test_calculations_checkout_shipping_price_with_vatlayer( vatlayer, settings, checkout_with_item): settings.PLUGINS = ["saleor.plugins.vatlayer.plugin.VatlayerPlugin"] checkout_shipping_price = calculations.checkout_shipping_price( checkout=checkout_with_item, lines=list(checkout_with_item)) assert checkout_shipping_price == TaxedMoney(net=Money("0", "USD"), gross=Money("0", "USD"))