feat: lots of changes

This commit is contained in:
2024-05-05 00:04:51 +02:00
parent d5643bbf5f
commit d148cc9c61
32 changed files with 509 additions and 61 deletions
+7 -8
View File
@@ -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,
)