feat(billing): add calculate_total_new_price utility for dynamic payment calculation

This commit is contained in:
2025-07-27 15:17:47 +05:00
parent ee54386fd5
commit e3c2d4450f
2 changed files with 37 additions and 2 deletions
+4 -2
View File
@@ -15,6 +15,7 @@ from api.tasks import add_new_devices_to_omada
from apibase.env import BASE_DIR, env
from django.db.models import Prefetch
import logging
from .utils import calculate_total_new_price
from .models import Device, Payment, Topup, WalletTransaction
from .serializers import (
@@ -103,8 +104,9 @@ class ListCreatePaymentView(StaffEditorPermissionMixin, generics.ListCreateAPIVi
{"message": "device_ids are required."},
status=status.HTTP_400_BAD_REQUEST,
)
# Create payment
amount = 100
amount = calculate_total_new_price(
number_of_devices=number_of_devices, number_of_months=number_of_months
)
payment = Payment.objects.create(
amount=amount,
number_of_months=number_of_months,