You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.8 KiB
87 lines
2.8 KiB
# -*- coding: utf-8 -*-
|
|
from django.conf import settings
|
|
from django.http import HttpResponseForbidden, HttpResponse
|
|
|
|
from commons.pdf_tools import render_pdf_to_string
|
|
from customer.models import License
|
|
from customer.utils import raise_if_no_profile
|
|
|
|
|
|
def create_payment_account(request, order_num=None):
|
|
if not request.user.is_authenticated():
|
|
raise HttpResponseForbidden
|
|
|
|
raise_if_no_profile(request)
|
|
|
|
lic = License.objects.get(pk=order_num)
|
|
pay_form = lic.payform
|
|
customer = request.user.profile
|
|
|
|
response = HttpResponse(content_type='application/pdf')
|
|
|
|
profile = {
|
|
'is_org': True,
|
|
'get_company_name': settings.OWNER['NAME'],
|
|
'address': settings.OWNER['ADDRESS'],
|
|
'phone': settings.OWNER['PHONE'],
|
|
'get_full_phone': settings.OWNER['PHONE'],
|
|
'inn': settings.OWNER['INN'],
|
|
'kpp': settings.OWNER['KPP'],
|
|
'get_boss_fio': settings.OWNER['BOSS'],
|
|
'get_boss_title': settings.OWNER['POSITION_BOSS'],
|
|
'get_glavbuh_fio': settings.OWNER['GB'],
|
|
'boss_sign': {
|
|
'path': settings.OWNER['SIGN_BOSS']
|
|
},
|
|
'glavbuh_sign': {
|
|
'path': settings.OWNER['SIGN_GB']
|
|
},
|
|
'stamp': {
|
|
'path': settings.OWNER['STAMP']
|
|
}
|
|
}
|
|
|
|
if pay_form == 0:
|
|
response['Content-Disposition'] = \
|
|
f'attachment; filename="Schet_{order_num}_Dokumentor-ru.pdf"'
|
|
|
|
obj = {
|
|
'bank_account': {
|
|
'name': settings.OWNER['BANK'],
|
|
'account': settings.OWNER['BANK_ACC'],
|
|
'korr_account': settings.OWNER['CORR_ACC'],
|
|
'bik': settings.OWNER['BIK']
|
|
},
|
|
'client': {
|
|
'name': customer.get_company_name(),
|
|
'get_inn_and_kpp': customer.get_inn_and_kpp(),
|
|
'address': customer.address,
|
|
'contact_phone': customer.get_full_phone()
|
|
},
|
|
'doc_num': order_num,
|
|
'doc_date': lic.order_date,
|
|
'total_price': lic.pay_sum,
|
|
'sum_total_nds': 0,
|
|
'nds_itogo_text': 'Без налога (НДС)',
|
|
'sum_total_price': lic.pay_sum,
|
|
'sum_full_total_price': lic.pay_sum
|
|
}
|
|
|
|
obj_items = [{
|
|
'name': f'Лицензия на ПО Dokumentor на {lic.get_term()}',
|
|
'units': 'услуги',
|
|
'qty': 1,
|
|
'price': lic.pay_sum,
|
|
'total_price': lic.pay_sum
|
|
}]
|
|
|
|
dictionary = {
|
|
'obj': obj,
|
|
'doc_sign': True,
|
|
'obj_items': obj_items,
|
|
'profile': profile,
|
|
}
|
|
|
|
pdf = render_pdf_to_string(request, 'docs/invoice/as_pdf.html', dictionary)
|
|
response.write(pdf)
|
|
return response
|
|
|