diff --git a/uncloud/uncloud_pay/models.py b/uncloud/uncloud_pay/models.py index 43064e4..32d3eac 100644 --- a/uncloud/uncloud_pay/models.py +++ b/uncloud/uncloud_pay/models.py @@ -180,6 +180,12 @@ class Bill(models.Model): valid = models.BooleanField(default=True) + @property + def reference(self): + return "{}_{}".format( + self.owner.username, + self.creation_date.strftime("%Y-%m-%d-%H%M")) + @property def records(self): bill_records = [] diff --git a/uncloud/uncloud_pay/serializers.py b/uncloud/uncloud_pay/serializers.py index d763590..60ddc75 100644 --- a/uncloud/uncloud_pay/serializers.py +++ b/uncloud/uncloud_pay/serializers.py @@ -83,5 +83,5 @@ class BillSerializer(serializers.ModelSerializer): records = BillRecordSerializer(many=True, read_only=True) class Meta: model = Bill - fields = ['owner', 'total', 'due_date', 'creation_date', + fields = ['reference', 'owner', 'total', 'due_date', 'creation_date', 'starting_date', 'ending_date', 'records', 'final']