Fix #1440 -- API confusion about creating free orders

This commit is contained in:
Raphael Michel
2019-10-11 09:00:46 +02:00
parent 361488f3e6
commit b9a911dd97
3 changed files with 25 additions and 2 deletions

View File

@@ -858,6 +858,9 @@ class OrderCreateSerializer(I18nAwareModelSerializer):
order.total = sum([p.price for p in order.positions.all()]) + sum([f.value for f in order.fees.all()])
order.save(update_fields=['total'])
if order.total == Decimal('0.00') and validated_data.get('status') == Order.STATUS_PAID and not payment_provider:
payment_provider = 'free'
if order.total == Decimal('0.00') and validated_data.get('status') != Order.STATUS_PAID:
order.status = Order.STATUS_PAID
order.save()