Commit cbba1f41 authored by fnux's avatar fnux

Add admin bill generation endpoint

parent d47c94ba
Pipeline #1403 failed with stage
in 2 minutes and 50 seconds
......@@ -72,6 +72,7 @@ class OrderSerializer(serializers.ModelSerializer):
model = Order
fields = ['uuid', 'owner', 'description', 'creation_date', 'starting_date', 'ending_date',
'bill', 'recurring_period', 'recurring_price', 'one_time_price', 'replaced_by']
read_only_fields = ['replaced_by']
###
......
......@@ -302,6 +302,22 @@ class AdminBillViewSet(BillViewSet):
serializer = self.get_serializer(unpaid_bills, many=True)
return Response(serializer.data)
@action(detail=False, methods=['post'])
def generate(self, request):
users = get_user_model().objects.all()
generated_bills = []
for user in users:
now = timezone.now()
generated_bills = generated_bills + Bill.generate_for(
year=now.year,
month=now.month,
user=user)
return Response(
map(lambda b: b.reference, generated_bills),
status=status.HTTP_200_OK)
class AdminOrderViewSet(mixins.ListModelMixin,
mixins.RetrieveModelMixin,
mixins.CreateModelMixin,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment