else:
self.fields['amount'].help_text = 'Invoice total value is {}{}'.format(settings.CURRENCY_SYMBOL, invoice.total_amount - invoice.total_vat)
- if not settings.EU_VAT:
+ if not invoice.total_vat:
del self.fields['vatamount']
else:
self.fields['vatamount'].validators = [MinValueValidator(0), MaxValueValidator(total['remaining']['vatamount'])]
else:
form = PurchasedVoucherRefundForm()
- if settings.EU_VAT:
+ if invoice.total_vat > 0:
note = 'You are about to refund {}{} ({}{} + {}{} VAT) for invoice {}. Please confirm that this is what you want!'.format(settings.CURRENCY_SYMBOL, invoice.total_amount, settings.CURRENCY_SYMBOL, invoice.total_amount - invoice.total_vat, settings.CURRENCY_SYMBOL, invoice.total_vat, invoice.id)
else:
note = 'You are about to refund {}{} for invoice {}. Please confirm that this is what you want!'.format(settings.CURRENCY_SYMBOL, invoice.total_amount, invoice.id)
), label="Cancel method")
confirm = forms.BooleanField(help_text="Confirm that you want to cancel or refund this sponsorship!")
- def __init__(self, *args, **kwargs):
+ def __init__(self, invoice, *args, **kwargs):
+ self.invoice = invoice
super().__init__(*args, **kwargs)
- if not settings.EU_VAT:
+ if not invoice.total_vat:
self.fields['customrefundamount'].label = 'Custom refund amount'
del self.fields['customrefundamountvat']
self.add_error('customrefundamount', 'This field is required when doing custom amount refund')
elif Decimal(d['customrefundamount'] <= 0):
self.add_error('customrefundamount', 'Must be >0 when performing custom refund')
- if settings.EU_VAT and d['customrefundamountvat'] is None:
+ if self.invoice.total_vat and d['customrefundamountvat'] is None:
self.add_error('customrefundamountvat', 'This field is required when doing custom amount refund')
else:
if d['customrefundamount'] is not None:
self.add_error('customrefundamount', 'This field must be left empty when doing non-custom refund')
- if settings.EU_VAT and d['customrefundamountvat'] is not None:
+ if self.invoice.total_vat and d['customrefundamountvat'] is not None:
self.add_error('customrefundamountvat', 'This field must be left empty when doing non-custom refund')
return d
return HttpResponseRedirect("../")
if request.method == 'POST':
- form = SponsorRefundForm(data=request.POST)
+ form = SponsorRefundForm(invoice, data=request.POST)
if form.is_valid():
class _AbortValidation(Exception):
pass
# Custom amount
if form.cleaned_data['customrefundamount'] > total_refunds['remaining']['amount']:
form.add_error('customrefundamount', "Only {} {} non-vat remains to be refunded on this invoice".format(settings.CURRENCY_SYMBOL, total_refunds['remaining']['amount']))
- if settings.EU_VAT and form.cleaned_data['customrefundamountvat'] > total_refunds['remaining']['vatamount']:
+ if invoice.total_vat and form.cleaned_data['customrefundamountvat'] > total_refunds['remaining']['vatamount']:
form.add_error('customrefundamountvat', "Only {} {} VAT remains to be refunded on this invoice".format(settings.CURRENCY_SYMBOL, total_refunds['remaining']['vatamount']))
elif form.cleaned_data['refundamount'] == "2":
# No refund, just cancel
elif form.cleaned_data['refundamount'] == "1":
# Refund the specific amount
to_refund = form.cleaned_data['customrefundamount']
- if settings.EU_VAT:
+ if invoice.total_vat:
to_refund_vat = form.cleaned_data['customrefundamountvat']
else:
to_refund_vat = 0
# Fall through and re-render form
pass
else:
- form = SponsorRefundForm()
+ form = SponsorRefundForm(invoice)
return render(request, 'confsponsor/admin_sponsor_refund.html', {
'conference': conference,