fixes
This commit is contained in:
@@ -44,16 +44,12 @@ class CreditUsageLogSerializer(serializers.ModelSerializer):
|
||||
read_only_fields = ['created_at', 'account']
|
||||
|
||||
def get_client_cost(self, obj) -> str:
|
||||
"""Calculate client-facing cost from credits * default_credit_price_usd"""
|
||||
"""Calculate client-facing cost from credits * default_credit_price_usd (price per credit)"""
|
||||
from igny8_core.business.billing.models import BillingConfiguration
|
||||
try:
|
||||
config = BillingConfiguration.get_config()
|
||||
price_per_credit = config.default_credit_price_usd
|
||||
client_cost = Decimal(obj.credits_used) * price_per_credit
|
||||
return str(client_cost.quantize(Decimal('0.0001')))
|
||||
except Exception:
|
||||
# Fallback to cost_usd if billing config unavailable
|
||||
return str(obj.cost_usd) if obj.cost_usd else '0.0000'
|
||||
config = BillingConfiguration.get_config()
|
||||
price_per_credit = config.default_credit_price_usd
|
||||
client_cost = Decimal(obj.credits_used) * price_per_credit
|
||||
return str(client_cost.quantize(Decimal('0.0001')))
|
||||
|
||||
def get_site_name(self, obj) -> Optional[str]:
|
||||
"""Get the site name if available"""
|
||||
|
||||
Reference in New Issue
Block a user