|
@@ -188,17 +188,27 @@ class InvoiceDataView(APIView):
|
|
|
|
|
|
def get(self, request):
|
|
|
tenant = request.user.employee.tenant
|
|
|
- invoice_id = request.GET.get('invoice_id')
|
|
|
-
|
|
|
pay = Pay.objects.filter(
|
|
|
Q(status=Pay.PAY, invoice_id=None,tenant=tenant) | Q(status=Pay.CONFIRM, invoice_id=None,tenant=tenant))\
|
|
|
.aggregate(amount=Sum('amount'))
|
|
|
- print(22222, pay)
|
|
|
- invoice = Invoice.objects.filter(invoice_id=invoice_id)
|
|
|
- print(11111111111,invoice)
|
|
|
+ data = {
|
|
|
+ 'invoice_name': "",
|
|
|
+ 'tax_no': "",
|
|
|
+ 'company_address': "",
|
|
|
+ 'phone_no': "",
|
|
|
+ 'deposit_bank': "",
|
|
|
+ 'bank_account': "",
|
|
|
+ 'invoice_sum': "",
|
|
|
+ 'consignee': "",
|
|
|
+ 'consignee_tel': "",
|
|
|
+ 'consignee_address': "",
|
|
|
+ }
|
|
|
try:
|
|
|
- if pay:
|
|
|
- data = {
|
|
|
+ if not pay['amount']:
|
|
|
+ return CustomError('未开具发票!')
|
|
|
+ invoice = Invoice.objects.filter(tenant=tenant).order_by('-id').first()
|
|
|
+ if invoice:
|
|
|
+ data = {
|
|
|
'invoice_name': invoice['invoice_name'],
|
|
|
'tax_no': invoice['tax_no'],
|
|
|
'company_address': invoice['company_address'],
|
|
@@ -209,9 +219,9 @@ class InvoiceDataView(APIView):
|
|
|
'consignee': invoice['consignee'],
|
|
|
'consignee_tel': invoice['consignee_tel'],
|
|
|
'consignee_address': invoice['company_address'],
|
|
|
- }
|
|
|
+ }
|
|
|
else:
|
|
|
- return CustomError('未开具发票!')
|
|
|
+ data['invoice_sum']=pay['amount']
|
|
|
except Exception as e:
|
|
|
return response_error(str(e))
|
|
|
return response_ok(data)
|