Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_pdf_file(request, customer_id, sys_type):
- sys_type = customer_id
- area = "pdf"
- site_credit = site_credit1
- time_now = timezone.now()
- customers = get_object_or_404(CustomerInfo, pk=customer_id)
- due_taka_track = customers.duetaka_set.all()
- if due_taka_track == None:
- due_taka_track = 0
- unpaid_taka = int(customers.customer_price -
- customers.customer_due_taka_info)
- due_taka_track = customers.duetaka_set.all()
- sum_cost_taka = due_taka_track.aggregate(
- sp=Sum('customer_due')).get('sp', 0)
- if sum_cost_taka == None:
- sum_cost_taka = 0
- total_paid_taka = sum_cost_taka + customers.customer_due_taka_info
- payment_status = 'complete'
- payment_message = ' '
- remain_taka='Full Paid '
- remain_msg=''
- if customers.customer_due_taka_info < customers.customer_price:
- payment_status = 'incomplete'
- payment_message = 'সম্পূর্ন টাকা পরিষোধ করা হয়নি'
- remain_msg='টাকা বাকী আছে'
- baki_ase="পাওনা আছে "
- remain_taka = customers.customer_price - customers.customer_due_taka_info
- context = {'customers': customers,
- 'sys_type': sys_type,
- 'area': area,
- 'site_credit': site_credit,
- 'site_name': 'Moon Telecom',
- 'sys_type': sys_type,
- 'due_taka_track': due_taka_track,
- 'total_paid_taka': total_paid_taka,
- 'payment_message': payment_message,
- 'time_now': time_now,
- 'unpaid_taka': unpaid_taka,
- 'payment_message': payment_message,
- 'remain_taka': remain_taka,
- 'sum_cost_taka': sum_cost_taka,
- 'remain_msg': remain_msg}
- html_string = render_to_string('shop/pdf_invoice.html', context).encode(encoding="UTF-8")
- response = HttpResponse(content_type='application/pdf')
- response['Content-Disposition'] = 'inline; filename=invoice' + \
- str(customers.id)+customers.customer_uid + customers.customer_name + '.pdf'
- HTML(string=html_string).write_pdf(response)
- return response
Add Comment
Please, Sign In to add comment