diff --git a/extra/boss_sign.png b/extra/boss_sign.png
new file mode 100644
index 0000000..464d498
Binary files /dev/null and b/extra/boss_sign.png differ
diff --git a/extra/gb_sign.png b/extra/gb_sign.png
new file mode 100644
index 0000000..464d498
Binary files /dev/null and b/extra/gb_sign.png differ
diff --git a/extra/stamp.png b/extra/stamp.png
new file mode 100644
index 0000000..6ae1032
Binary files /dev/null and b/extra/stamp.png differ
diff --git a/src/customer/models.py b/src/customer/models.py
index 53eca00..d82f46e 100644
--- a/src/customer/models.py
+++ b/src/customer/models.py
@@ -194,9 +194,6 @@ class UserProfile(models.Model):
verbose_name = 'Реквизиты (профиль)'
verbose_name_plural = 'Реквизиты (профили)'
- def __unicode__(self):
- return '%s, ИНН %s' % (self.get_company_name()[0:30], self.inn or 'не указан')
-
def __str__(self):
return '%s, ИНН %s' % (self.get_company_name()[0:30], self.inn or 'не указан')
@@ -600,16 +597,15 @@ class License(models.Model):
if self.status == 0:
if self.payform == 0:
- url = reverse('customer_license_get_doc', kwargs={'order_num': self.id})
+ url = reverse(
+ 'customer_license_get_payment_account',
+ kwargs={'order_num': self.id}
+ )
return f'Оплата безналичным платежом'
-
+ # redirect to pay terminal with data
elif self.payform == 1:
return f'Оплата банковской картой'
- elif self.payform == 2:
- url = reverse('customer_license_get_doc', kwargs={'order_num': self.id})
- return f'Скачать квитанцию'
-
elif self.status in [1, 2]:
url = '#'
cost_str = f'{self.pay_sum} ' \
diff --git a/src/customer/urls.py b/src/customer/urls.py
index 44634c8..7f64136 100644
--- a/src/customer/urls.py
+++ b/src/customer/urls.py
@@ -17,11 +17,16 @@ urlpatterns = [
url(r'^license/$', license.order_license, name='customer_order_license'),
url(r'^delete_license/(?P\d+)/$', license.delete_license,
name='customer_delete_license'),
- url(r'^get_doc/(?P\d+)/$', documents.get_doc,
- name='customer_license_get_doc'),
- url(r'^payment/result/$', license.payment_result, name='yamoney_result'),
- url(r'^payment/success/$', license.payment_success, name='yamoney_success'),
- url(r'^payment/fail/$', license.payment_fail, name='yamoney_fail'),
+ # for delete
+ # url(r'^get_doc/(?P\d+)/$', documents.get_doc,
+ # name='customer_license_get_doc'),
+
+ url(r'^get_payment_account/(?P\d+)/$', documents.create_payment_account,
+ name='customer_license_get_payment_account'),
+ # for delete
+ # url(r'^payment/result/$', license.payment_result, name='yamoney_result'),
+ # url(r'^payment/success/$', license.payment_success, name='yamoney_success'),
+ # url(r'^payment/fail/$', license.payment_fail, name='yamoney_fail'),
# for delete
# url(r'^license_list/$', license.license_list, name='customer_license_list'),
# url(r'^paid_list/$', license.paid_list, name='customer_paid_list'),
@@ -81,6 +86,5 @@ urlpatterns = [
url(r'^clients/(?P\d+)/delete/ajax/$', clients_ajax.clients_delete_ajax,
name='customer_clients_delete_ajax'),
- # url(r'^tmp_upload/ajax/$', profile.tmp_upload, name='upload_tmp_file'),
url(r'^upload-image/ajax/$', profile.upload_image, name='upload-image'),
]
diff --git a/src/customer/views/documents.py b/src/customer/views/documents.py
index 065cef8..3447402 100644
--- a/src/customer/views/documents.py
+++ b/src/customer/views/documents.py
@@ -1,109 +1,87 @@
# -*- coding: utf-8 -*-
-import os
-import re
-
from django.conf import settings
-from django.http import Http404, HttpResponseForbidden, HttpResponse
-
-from xlwt import easyxf
-from xlrd import open_workbook
-from xlutils.copy import copy
-from pytils.numeral import rubles
+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
-XLS_ROOT = os.path.join(settings.TEMPLATES[0]['DIRS'][0], 'xls')
-
-
-def get_doc(request, order_num=None):
+def create_payment_account(request, order_num=None):
if not request.user.is_authenticated():
raise HttpResponseForbidden
raise_if_no_profile(request)
- license = License.objects.get(pk=order_num)
- pm = license.payform
- data = request.user.profile
- if pm == 0:
- tmp_name = 'bill.xls'
- file_name = f"Invoice No.{order_num}.xls"
- elif pm == 2:
- tmp_name = '4pd.xls'
- file_name = f"Kvitanciya na oplatu zakaza No.{order_num}.xls"
- else:
- raise Http404()
-
- response = HttpResponse(content_type="application/vnd.ms-excel")
- response['Content-Disposition'] = f'attachment; filename={file_name}'
-
- rb = open_workbook(os.path.join(XLS_ROOT, tmp_name), on_demand=True, formatting_info=True)
- wb = copy(rb)
- ws = wb.get_sheet(0)
-
- # отключить колонтитулы
- ws.show_headers = 0
- ws.print_headers = 0
- ws.header_str = b''
- ws.footer_str = b''
-
- # заполняем счет
- if pm == 0:
- style0 = easyxf('font: name Times New Roman, height 280, bold True;')
- style0_center = \
- easyxf('font: name Times New Roman, height 280, bold True; align: horiz center')
- style1 = easyxf('font: name Times New Roman, height 180;')
- style2 = easyxf('font: name Times New Roman, height 180, bold True;')
- style3 = easyxf('font: name Times New Roman, height 180;'
- 'border: top thin, left thin, right thin, bottom thin;'
- )
- style4 = easyxf('font: name Times New Roman, height 180, bold True;'
- 'border: top thin, left thin, right thin, bottom thin;'
- )
- style4.num_format_str = "#,##0.00"
-
- ws.write(11, 0, f"СЧЕТ № {order_num} от {license.order_date.strftime('%d.%m.%Y')}",
- style0_center)
- ws.write(13, 0, f"Покупатель: {data.name}", style1)
- ws.write(16, 2, f"Лицензия Dokumentor.ru на {license.get_term()}", style3)
-
- style3.num_format_str = "#,##0.00"
-
- ws.write(16, 36, license.pay_sum, style3)
- ws.write(16, 44, license.pay_sum, style3)
- ws.write(17, 44, license.pay_sum, style4)
- ws.write(19, 44, license.pay_sum, style4)
- ws.write(21, 0, f"Всего наименование 1, на сумму {license.pay_sum},00 руб.", style1)
- ws.write(23, 0, f"{rubles(license.pay_sum).capitalize()}.", style2)
-
- ws.insert_bitmap(os.path.join(XLS_ROOT, 'stamp.bmp'), 26, 12, y=3, scale_y=1.1)
-
- # заполняем квитанцию
- elif pm == 2:
- style0 = easyxf('font: name Times New Roman, height 160, bold True;'
- 'border: bottom thin;'
- )
- style1 = easyxf('font: name Times New Roman, height 160, bold True;'
- 'border: bottom thin;'
- 'align: horiz center;'
- )
-
- # заполняем оригинал
- ws.write(11, 4, f"Лицензия Dokumentor.ru на {license.get_term()}", style1)
- ws.write(13, 13, data.get_boss_fio(), style0)
- ws.write(14, 13, re.sub("^\s+|\n|\r|\s+$", ' ', data.address), style0)
- ws.write(15, 11, license.pay_sum, style1)
-
- # заполняем копию
- ws.write(31, 4, u"Лицензия Dokumentor.ru на %s" % (license.get_term()), style1)
- ws.write(33, 13, data.get_boss_fio(), style0)
- ws.write(34, 13, re.sub("^\s+|\n|\r|\s+$", ' ', data.address), style0)
- ws.write(35, 11, license.pay_sum, style1)
-
- else:
- raise Http404()
-
- wb.save(response)
-
- return response
+ 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
diff --git a/src/docs/views/invoice.py b/src/docs/views/invoice.py
index f804718..30f8f83 100644
--- a/src/docs/views/invoice.py
+++ b/src/docs/views/invoice.py
@@ -46,7 +46,7 @@ class InvoiceViews(BaseItemsViews):
# для генерации pdf/xls
PDF_TEMPLATE = 'docs/invoice/as_pdf.html'
XLS_TEMPLATE = 'invoice.xls'
- FILENAME = u'Счет № %s, %s' # без расширения
+ FILENAME = 'Счет № %s, %s' # без расширения
MAYBE_SIGNED = True
# --- грамматика для вывода наименований в шаблонах
diff --git a/src/dokumentor/settings/common.py b/src/dokumentor/settings/common.py
index dd016dd..d3bd7cc 100644
--- a/src/dokumentor/settings/common.py
+++ b/src/dokumentor/settings/common.py
@@ -219,7 +219,7 @@ CMS_PLACEHOLDER_CONF = {
},
}
-CMS_PERMISSION = True
+CMS_PERMISSION = False
BROKER_URL = e.get('CELERY_BROKER_URL')
CELERY_RESULT_BACKEND = e.get('CELERY_RESULT_BACKEND')
@@ -281,7 +281,8 @@ THUMBNAIL_PROCESSORS = (
)
RAVEN_CONFIG = {
- 'dsn': 'http://02d524ef0d044bdfae0b39546b752cb2:1e025305594d4532ae93125372dcde50@sentry.mitri4.pro/1',
+ 'dsn': 'http://02d524ef0d044bdfae0b39546b752cb2:'
+ '1e025305594d4532ae93125372dcde50@sentry.mitri4.pro/1',
# If you are using git, you can also automatically configure the
# release based on the git info.
'release': raven.fetch_git_sha(ROOT_DIR),
@@ -308,6 +309,24 @@ DADATA_SECRET_KEY = '9c5c3fdfba74af122730db650346b3e91586abc7'
SITE_URL = 'https://dokumentor.ru'
+OWNER = {
+ 'NAME': 'ООО "СетьИнвест"',
+ 'INN': '5190051810',
+ 'KPP': '519001001',
+ 'ADDRESS': '183036, г. Мурманск, ул. Скальная, д. 29, оф. 49',
+ 'PHONE': '+7 (909) 560-88-80',
+ 'BANK': 'ФИЛИАЛ "САНКТ-ПЕТЕРБУРГСКИЙ" АО "АЛЬФА-БАНК"',
+ 'BANK_ACC': '40702810532160002516',
+ 'BIK': '044030786',
+ 'CORR_ACC': '30101810600000000786',
+ 'POSITION_BOSS': 'Руководитель организации',
+ 'BOSS': 'Костенко А.Ю',
+ 'GB': 'Костенко Д.Ю',
+ 'STAMP': os.path.join(ROOT_DIR, 'extra', 'stamp.png'),
+ 'SIGN_BOSS': os.path.join(ROOT_DIR, 'extra', 'boss_sign.png'),
+ 'SIGN_GB': os.path.join(ROOT_DIR, 'extra', 'gb_sign.png')
+}
+
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
diff --git a/src/dokumentor/urls.py b/src/dokumentor/urls.py
index 0f3ce07..e26af0c 100644
--- a/src/dokumentor/urls.py
+++ b/src/dokumentor/urls.py
@@ -5,6 +5,7 @@ from django.conf.urls import include, url
import autocomplete_light
from django.conf.urls.static import static
from django.contrib import admin
+from django.views.generic import RedirectView
admin.autodiscover()
autocomplete_light.autodiscover()
@@ -14,8 +15,11 @@ admin.site.index_title = 'Документор'
admin.site.site_title = 'Документор'
urlpatterns = [
- # Uncomment the next line to enable the admin:
+
url(r'^admin/', include(admin.site.urls)),
+ url(r'^favicon\.ico$',
+ RedirectView.as_view(url=settings.STATIC_URL + 'favicon.ico')
+ ),
url(r'autocomplete/', include('autocomplete_light.urls')),
url(r'^$', 'pages.views.site_index', name='site_index'),
url(r'^my/', include('customer.urls')),
diff --git a/templates/xls/4pd.xls b/templates/xls/4pd.xls
deleted file mode 100644
index e80d8f8..0000000
Binary files a/templates/xls/4pd.xls and /dev/null differ
diff --git a/templates/xls/act.xls b/templates/xls/act.xls
deleted file mode 100644
index 2bf0d97..0000000
Binary files a/templates/xls/act.xls and /dev/null differ
diff --git a/templates/xls/bill.xls b/templates/xls/bill.xls
deleted file mode 100644
index 43458d5..0000000
Binary files a/templates/xls/bill.xls and /dev/null differ
diff --git a/templates/xls/stamp.bmp b/templates/xls/stamp.bmp
deleted file mode 100644
index 28d9b39..0000000
Binary files a/templates/xls/stamp.bmp and /dev/null differ
diff --git a/templates/xls/stamp1.bmp b/templates/xls/stamp1.bmp
deleted file mode 100644
index c1bc52f..0000000
Binary files a/templates/xls/stamp1.bmp and /dev/null differ