Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Central Mess: Modified monthly bill API
Browse files Browse the repository at this point in the history
csg4786 committed Apr 21, 2024
1 parent bf41c03 commit f55e797
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions FusionIIIT/applications/central_mess/api/views.py
Original file line number Diff line number Diff line change
@@ -138,25 +138,31 @@ def post(self, request):
amount = data['amount']
rebate_count = data['rebate_count']
rebate_amount = data['rebate_amount']
#nonveg_total_bill = data['nonveg_total_bill']
total_bill = data['amount']-(data['rebate_count']*data['rebate_amount'])
paid = data['paid']

username = get_object_or_404(User,username=request.user.username)
idd = ExtraInfo.objects.get(user=username)
student = Student.objects.get(id=idd.id)


obj = Monthly_bill(
student_id = student,
month = month,
year = year,
amount = amount,
rebate_count = rebate_count,
rebate_amount = rebate_amount,
# nonveg_total_bill = nonveg_total_bill,
paid = paid
)
obj.save()
try:
reg_main = Monthly_bill.objects.get(student_id=student, year = year, month = month)
reg_main.amount = amount
reg_main.rebate_count = rebate_count
reg_main.rebate_amount = rebate_amount
reg_main.total_bill = total_bill
except Monthly_bill.DoesNotExist:
reg_main = Monthly_bill.objects.create(
student_id=student,
month = month,
year = year,
amount = amount,
rebate_amount = rebate_amount,
rebate_count = rebate_count,
total_bill = total_bill,
paid = paid
)
reg_main.save()
return Response({'status':200})

class PaymentsApi(APIView):

0 comments on commit f55e797

Please sign in to comment.