def clean_total_refund_amount(self):
initial = self.cleaned_data.get('<STR_LIT>', <NUM_LIT:0>)<EOL>total = self.cleaned_data['<STR_LIT>']<EOL>summed_refunds = sum([v for k,v in self.cleaned_data.items() if k.startswith('<STR_LIT>')])<EOL>if not self.cleaned_data.get('<STR_LIT:id>'):<EOL><INDENT>raise ValidationError('<STR_LIT>')<EOL><DEDENT>if summed_refunds != total:<EOL><INDENT>raise ValidationError(_('<STR_LIT>'))<EOL><DEDENT>elif summed_refunds > self.cleaned_data['<STR_LIT:id>'].amountPaid + self.cleaned_data['<STR_LIT:id>'].refunds:<EOL><INDENT>raise ValidationError(_('<STR_LIT>'))<EOL><DEDENT>elif total < initial:<EOL><INDENT>raise ValidationError(_('<STR_LIT>'))<EOL><DEDENT>return total<EOL>
The Javascript should ensure that the hidden input is updated, but double check it here.