feat: lots of changes
This commit is contained in:
+7
-8
@@ -5,20 +5,19 @@ from shop.models import OrderLine, Tax, Product, Order, Customer
|
||||
from django.db.models import QuerySet
|
||||
|
||||
|
||||
def create_order_line_for_product(
|
||||
product: Product, quantity: Decimal, tax: Tax, order: Order
|
||||
):
|
||||
price = product.prices.last().price
|
||||
base_total = round(price * quantity, 2)
|
||||
taxes = round(base_total * (tax.value / Decimal("100")), 2)
|
||||
def create_order_line_for_product(product: Product, quantity: Decimal, order: Order):
|
||||
price = product.prices.last()
|
||||
base_total = round(price.price * quantity, 2)
|
||||
tax_value = price.tax.value / Decimal("100")
|
||||
taxes = round(base_total * tax_value, 2)
|
||||
|
||||
return OrderLine.objects.create(
|
||||
order=order,
|
||||
product=product,
|
||||
quantity=quantity,
|
||||
price=price,
|
||||
price=price.price,
|
||||
base_total=base_total,
|
||||
tax_value=tax.value,
|
||||
tax_value=tax_value,
|
||||
taxes=taxes,
|
||||
total=base_total + taxes,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user