From d6fa8b989f1daadad2c9074e00ae1a5913505138 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Mon, 11 Apr 2022 21:23:59 +0000 Subject: [PATCH] Fix negative transaction bug --- apiserver/apiserver/api/serializers.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apiserver/apiserver/api/serializers.py b/apiserver/apiserver/api/serializers.py index 66bf20c..32a8e2c 100644 --- a/apiserver/apiserver/api/serializers.py +++ b/apiserver/apiserver/api/serializers.py @@ -81,9 +81,11 @@ class TransactionSerializer(serializers.ModelSerializer): if validated_data['account_type'] != 'Clearing': if validated_data['amount'] == 0: - raise ValidationError(dict(account_type='You can\'t have a $0.00 {} transaction. Do you want "Membership Adjustment"?'.format(validated_data['account_type']))) - elif validated_data['amount'] < 0.1: - raise ValidationError(dict(amount='Don\'t try and trick me.')) + raise ValidationError(dict(account_type='Can\'t have a $0.00 {} transaction. Do you want "Membership Adjustment"?'.format(validated_data['account_type']))) + + if validated_data['category'] != 'Reimburse': + if validated_data['amount'] < 0: + raise ValidationError(dict(category='Can\'t have a negative {} transaction. Do you want "Reimbursement"?'.format(validated_data['category']))) if validated_data['account_type'] == 'PayPal': msg = 'Manual PayPal transaction added:\n' + str(validated_data)