From d2c989df2d3aaf477e2fb0a5415d6fe1d6632eba Mon Sep 17 00:00:00 2001
From: Bachurin Sergey
Date: Mon, 11 Aug 2014 11:14:19 +0300
Subject: [PATCH] no requisits - no invoices
---
project/customer/models.py | 21 +++++++++++++++++++++
project/templates/docs/_base/base_list.html | 5 ++++-
project/templates/docs/invoice/as_pdf.html | 4 ++++
3 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/project/customer/models.py b/project/customer/models.py
index 6afb6df..1ad9e64 100644
--- a/project/customer/models.py
+++ b/project/customer/models.py
@@ -157,6 +157,27 @@ class UserProfile(models.Model):
return self.name.strip() == ''
return False
+ def get_main_bank_account(self):
+ try:
+ bank_accounts = BankAccount.objects.filter(user=self.user, is_main=True)[0]
+ except:
+ return None
+
+ def check_main_reqs_not_filled(self):
+ result = self.check_name_not_filled() or self.inn == '' or self.address == '' or \
+ self.get_boss_fio() == '' or self.get_main_bank_account() == ''
+ print result
+ if result:
+ print 111
+ return True
+
+ if self.is_ip():
+ print 222
+ return self.ogrn == ''
+ elif self.is_org():
+ print 333
+ return self.kpp == ''
+
def get_company_name(self):
"""`ИП ФИО` или `Название Организации`."""
if self.profile_type == consts.IP_PROFILE:
diff --git a/project/templates/docs/_base/base_list.html b/project/templates/docs/_base/base_list.html
index 536e93e..8b05850 100644
--- a/project/templates/docs/_base/base_list.html
+++ b/project/templates/docs/_base/base_list.html
@@ -3,7 +3,9 @@
{% block title %}{{ padeji_mnoj.imenit|capfirst }}{% endblock %}
{% block content %}
-
+{% if user.profile.check_main_reqs_not_filled %}
+Документор не может создать ничего, пока вы не добавите в него свои реквизиты. Заполните хотя бы те поля, которые отмечены * на странице Мои реквизиты.
+{% else %}
{% url url_prefix|add:'add' as url_add %}
{% if page or obj_list_count_before_filtering > 0 %}
@@ -116,6 +118,7 @@
{% endblock %}
{% endif %}
+{% endif %}
{% endblock %}
{% block dialogs %}
diff --git a/project/templates/docs/invoice/as_pdf.html b/project/templates/docs/invoice/as_pdf.html
index a04bcad..134176b 100644
--- a/project/templates/docs/invoice/as_pdf.html
+++ b/project/templates/docs/invoice/as_pdf.html
@@ -34,11 +34,15 @@