diff --git a/apiserver/apiserver/api/serializers.py b/apiserver/apiserver/api/serializers.py index a6ddb51..e77d648 100644 --- a/apiserver/apiserver/api/serializers.py +++ b/apiserver/apiserver/api/serializers.py @@ -214,6 +214,7 @@ class MemberSerializer(serializers.ModelSerializer): email = fields.UserEmailField(serializers.EmailField) phone = serializers.CharField() protocoin = serializers.SerializerMethodField() + total_protocoin = serializers.SerializerMethodField() class Meta: model = models.Member @@ -257,6 +258,11 @@ class MemberSerializer(serializers.ModelSerializer): total = transactions.aggregate(Sum('protocoin'))['protocoin__sum'] or 0 return total + def get_total_protocoin(self, obj): + transactions = models.Transaction.objects + total = transactions.aggregate(Sum('protocoin'))['protocoin__sum'] or 0 + return total + def update(self, instance, validated_data): instance.user.email = validated_data.get('email', instance.user.email) instance.user.save() diff --git a/webclient/src/Paymaster.js b/webclient/src/Paymaster.js index 46e98e4..63cd02e 100644 --- a/webclient/src/Paymaster.js +++ b/webclient/src/Paymaster.js @@ -94,6 +94,8 @@ export function Paymaster(props) {

Current balance: ₱ {user.member.protocoin.toFixed(2)}

+

Total circulation: ₱ {user.member.total_protocoin.toFixed(2)}

+ Buy any amount of Protocoin: