|
|
|
|
@ -1,8 +1,8 @@ |
|
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
from django.conf import settings |
|
|
|
|
from django.http import HttpResponseForbidden, HttpResponse |
|
|
|
|
|
|
|
|
|
from commons.pdf_tools import render_pdf_to_string |
|
|
|
|
from commons.utils import get_owner_data, get_owner_bank |
|
|
|
|
from customer.models import License |
|
|
|
|
from customer.utils import raise_if_no_profile |
|
|
|
|
|
|
|
|
|
@ -19,39 +19,14 @@ def create_payment_account(request, order_num=None): |
|
|
|
|
|
|
|
|
|
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'] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
profile = get_owner_data() |
|
|
|
|
|
|
|
|
|
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'] |
|
|
|
|
}, |
|
|
|
|
'bank_account': get_owner_bank(), |
|
|
|
|
'client': { |
|
|
|
|
'name': customer.get_company_name(), |
|
|
|
|
'get_inn_and_kpp': customer.get_inn_and_kpp(), |
|
|
|
|
@ -85,3 +60,54 @@ def create_payment_account(request, order_num=None): |
|
|
|
|
pdf = render_pdf_to_string(request, 'docs/invoice/as_pdf.html', dictionary) |
|
|
|
|
response.write(pdf) |
|
|
|
|
return response |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_certificate_of_completion(request, order_num=None): |
|
|
|
|
if not request.user.is_authenticated(): |
|
|
|
|
raise HttpResponseForbidden |
|
|
|
|
|
|
|
|
|
raise_if_no_profile(request) |
|
|
|
|
|
|
|
|
|
lic = License.objects.get(pk=order_num) |
|
|
|
|
customer = request.user.profile |
|
|
|
|
|
|
|
|
|
profile = get_owner_data() |
|
|
|
|
response = HttpResponse(content_type='application/pdf') |
|
|
|
|
response['Content-Disposition'] = f'attachment; filename="Akt_{order_num}_Dokumentor-ru.pdf"' |
|
|
|
|
|
|
|
|
|
obj = { |
|
|
|
|
'bank_account': get_owner_bank(), |
|
|
|
|
'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/aktrabot/as_pdf.html', dictionary) |
|
|
|
|
response.write(pdf) |
|
|
|
|
|
|
|
|
|
return response |
|
|
|
|
|