|
|
|
|
@ -87,7 +87,8 @@ class InvoiceDetailView(APIView): |
|
|
|
|
def post(request, invoice_id): |
|
|
|
|
if request.user.is_authenticated and (request.user.groups.filter(name__in=['managers','lead_managers']).exists() |
|
|
|
|
or request.user.is_superuser): |
|
|
|
|
bill_id = request.JSON.get('bill_id', None) |
|
|
|
|
invoice_id = int(invoice_id) |
|
|
|
|
bill_id = request.JSON.get('bill', None) |
|
|
|
|
is_open = request.JSON.get('is_open', None) |
|
|
|
|
method = request.JSON.get('method', None) |
|
|
|
|
status = request.JSON.get('status', None) |
|
|
|
|
@ -105,15 +106,18 @@ class InvoiceDetailView(APIView): |
|
|
|
|
except Bill.DoesNotExist: |
|
|
|
|
return Response('Не найден счёт с id=%s' % bill_id, status=404) |
|
|
|
|
|
|
|
|
|
method = get_real_name(elem=method, array=Invoice.BILL_METHOD) |
|
|
|
|
status = get_real_name(elem=status, array=Invoice.BILL_METHOD) |
|
|
|
|
method = get_real_name(elem=method[0], array=Invoice.BILL_METHOD) |
|
|
|
|
status = get_real_name(elem=status[0], array=Invoice.BILL_STATUSES) |
|
|
|
|
|
|
|
|
|
if bill.check_validate() and is_open: |
|
|
|
|
if bill.check_validate(invoice_id) and is_open: |
|
|
|
|
return Response("Уже есть платёж открывающий курс", status=400) |
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
invoice = Invoice.objects.get(id=invoice_id) |
|
|
|
|
except Invoice.DoesNotExist: |
|
|
|
|
if not invoice_id == 0: |
|
|
|
|
return Response("Платёж не найден", status=404) |
|
|
|
|
|
|
|
|
|
if bill.check_pay(): |
|
|
|
|
return Response( |
|
|
|
|
"Нельзя добавить новый платёж, так как один из платежей по счёту уже оплачен", status=400) |
|
|
|
|
|