diff --git a/ERD/Backend_ERD.drawio.png b/ERD/Backend_ERD.drawio.png index 669f28e..d9c1c6b 100644 Binary files a/ERD/Backend_ERD.drawio.png and b/ERD/Backend_ERD.drawio.png differ diff --git a/equipment_tracker/transactions/serializers.py b/equipment_tracker/transactions/serializers.py index fea196a..cf1709a 100644 --- a/equipment_tracker/transactions/serializers.py +++ b/equipment_tracker/transactions/serializers.py @@ -159,11 +159,11 @@ class TransactionSerializer(serializers.HyperlinkedModelSerializer): ) # Transaction Status Validation - # Check if the update involves the transaction status - if 'transaction_status' in validated_data: + # Check if the update involves changing the transaction status + if 'transaction_status' in validated_data and validated_data.get('transaction_status') != instance.transaction_status: # For already finalized/done transactions (Rejected or Finalized ones) - # Do not allow any changes to already finalized transactions + # Do not allow any changes to status for already finalized transactions if instance.transaction_status in ['Rejected', 'Finalized']: raise serializers.ValidationError( "Unable to update rejected or finalized transaction. Please create a new one" @@ -236,7 +236,7 @@ class TransactionSerializer(serializers.HyperlinkedModelSerializer): ) # If the transaction changes from Borrowed to Finalized and there are no breakages, label the selected equipment's statuses as Available again from Borrowed - if instance.transaction_status == "Borrowed" and validated_data.get('transaction_status') == "Finalized": + if instance.transaction_status == "Returned: Pending Checking" and validated_data.get('transaction_status') == "Finalized": equipments = instance.equipments.all() # Iterate through each of those equipment instances and change their status field to "Available" # This updates the status field of all equipment instances in a single query