Merged Air51/dokumentor.ru into master

remotes/origin/mitri4
Air51 9 years ago
commit 58cbe9378a
  1. 16
      project/docs/models/faktura.py
  2. 2
      project/docs/urls.py
  3. 28
      project/docs/views/ajax.py
  4. 7
      project/static/css/style.css
  5. 2
      project/templates/base.html
  6. 8
      project/templates/docs/faktura/form.html
  7. 19
      project/templates/docs/faktura/form_tbl_items.html
  8. 1
      project/templates/docs/parts/form_field_receiver.html
  9. 1
      project/templates/docs/parts/form_field_sender.html
  10. 25
      project/templates/docs/stub_js.html

@ -50,9 +50,9 @@ class Faktura(BaseInvoiceModel, SignedStatusFieldMixin, InvoiceFieldMixin, Linke
class FakturaItem(BaseItemInvoiceModel):
"""Табличная часть фактуры"""
units_kod = models.CharField(u'Код единицы измерения', max_length=10)
units_kod = models.CharField(u'Код единицы измерения', max_length=10, blank=True, default=u'-')
parent = models.ForeignKey(Faktura, related_name='faktura_items')
country_code = models.CharField(u'Код страны', max_length=10)
country_code = models.CharField(u'Код страны', max_length=10, blank=True, default=u'-')
country_name = models.CharField(u'Название страны', max_length=256)
gtd = models.CharField(u'Основание', max_length=256, blank=True, default='')
ntd = models.CharField(u'Номер транспортной декларации', max_length=256, blank=True, default='')
@ -62,15 +62,3 @@ class FakturaItem(BaseItemInvoiceModel):
verbose_name = u'Табл. часть фактуры'
verbose_name_plural = u'Табл. части фактур'
app_label="docs"
#class PlatDoc(models.Model):
# """Платёжные документы"""
# parent = models.ForeignKey(Faktura, related_name='plat_docs')
# num = models.CharField(u'Номер', max_length=30)
# doc_date = models.DateField('Дата')
#
# class Meta:
# verbose_name = u'Платёжный документ'
# verbose_name_plural = u'Платёжные документы'
# app_label="docs"

@ -60,7 +60,7 @@ for name, klass in klasses:
url(r'^%s/(?P<id>\d+)/email/ajax/$' % name, getview, {'klass': klass, 'oper': 'email_ajax',},
name='docs_%s_email_ajax' % name),
url(r'^ajax_get_pair/(?P<model>\w+)/(?P<param1>\w+)/(?P<param2>\w+)/(?P<val1>\w+)/$', get_pair, name='ajax_get_pair'),
url(r'^ajax_get_pair/(?P<model>\w+)/(?P<param1>\w+)/(?P<param2>\w+)/(?P<val1>.+)/$', get_pair, name='ajax_get_pair'),
url(r'^ajax_get_invoices/$', get_invoices, name='ajax_get_invoices'),
url(r'^ajax_get_invoices/(?P<client_id>\d+)/$', get_invoices, name='ajax_get_invoices'),
url(r'^ajax_get_tbl_items/(?P<invoice_id>\d+)/$', get_tbl_items, name='ajax_get_tbl_items'),

@ -15,6 +15,11 @@ def get_pair(request, model, param1, val1, param2):
if not request.is_ajax():
return HttpResponseBadRequest()
if model not in ('Country', 'Measure',):
return HttpResponseBadRequest()
raise_if_no_profile(request)
kwargs = {param1: val1}
try:
@ -34,10 +39,11 @@ def get_invoices(request, client_id=None):
raise_if_no_profile(request)
invoices = Invoice.objects.get_all(request.user.profile)
if client_id:
invoices = Invoice.objects.filter(client__id=client_id)
else:
invoices = Invoice.objects.filter(company=request.user.profile)
invoices = invoices.filter(client_id=client_id)
invoices = {invoice.id: '%s от %s' % (invoice.doc_num, invoice.doc_date) for invoice in invoices}
return HttpResponse(json.dumps(invoices), mimetype='application/json')
@ -47,7 +53,9 @@ def get_tbl_items(request, invoice_id):
if not request.is_ajax():
return HttpResponseBadRequest()
invoice = Invoice.objects.get(pk=invoice_id)
raise_if_no_profile(request)
invoice = Invoice.objects.get(company=request.user.profile, pk=invoice_id)
data = serializers.serialize('json', invoice.invoice_items.all())
return HttpResponse(json.dumps(data), mimetype='application/json')
@ -57,7 +65,9 @@ def get_client_by_invoice(request, invoice_id):
if not request.is_ajax():
return HttpResponseBadRequest()
invoice = Invoice.objects.get(pk=invoice_id)
raise_if_no_profile(request)
invoice = Invoice.objects.get(company=request.user.profile, pk=invoice_id)
return HttpResponse(json.dumps([invoice.client.id, invoice.client.name]), mimetype='application/json')
@ -66,18 +76,24 @@ def toggle_doc_status(request, doc_type, doc_id, doc_attr):
if not request.is_ajax() or request.method != 'POST':
return HttpResponseBadRequest()
raise_if_no_profile(request)
model_ = get_model('docs', doc_type)
doc = model_.objects.get(pk=doc_id)
doc = model_.objects.get(company=request.user.profile, pk=doc_id)
choices_ = doc._meta.get_field_by_name(doc_attr)[0].get_choices()
choices = [i[0] for i in choices_[1:]]
prev_val = getattr(doc, doc_attr)
try:
next_index = choices.index(prev_val) + 1
next_val = choices[next_index]
except:
next_val = choices[0]
setattr(doc, doc_attr, next_val)
doc.save()
next_text = dict(choices_)[next_val]
return HttpResponse(json.dumps([next_text, next_val]), mimetype='application/json')

@ -475,8 +475,6 @@ a.delete { vertical-align: top; }
.doc-form table.doc-list td.name { width: 590px; }
.doc-form table.doc-list td.name input[type=text] { width: 584px; }
.doc-form table.factura-doc-list td.name { width: 260px; }
.doc-form table.factura-doc-list td.name input[type=text] { width: 250px; }
.doc-form table.doc-list td.qty { width: 140px; }
.doc-form table.doc-list td.qty input { width: 135px; }
.doc-form table.doc-list td.units { width: 90px; }
@ -491,6 +489,11 @@ a.delete { vertical-align: top; }
.doc-form table.doc-list td.ntd input { width: 84px; }
.doc-form table.doc-list td.DELETE {width: 48px;}
.doc-form table.factura-doc-list td.name { width: 260px; }
.doc-form table.factura-doc-list td.name input[type=text] { width: 250px; }
.doc-form table.factura-doc-list td.units input { width: 166px; }
.doc-form table.factura-doc-list td.country_name input { width: 132px; }
.doc-form table.doc-list.aktsverki td.name input[type=text] { width: 432px; }
.doc-form table.doc-list.aktsverki td.debit input[type=text] { width: 96px; }
.doc-form table.doc-list.aktsverki td.credit input[type=text] { width: 96px; }

@ -9,7 +9,7 @@
<title>{% block title %}{% endblock %} | Документор</title>
<link rel="shortcut icon" href="{{ STATIC_URL }}favicon.ico" />
<link rel="stylesheet" href="{{ STATIC_URL }}css/ui-lightness/jquery-ui-1.10.3.custom.css" />
<link rel="stylesheet" href="{{ STATIC_URL }}css/style.css" />
<link rel="stylesheet" href="{{ STATIC_URL }}css/style.css?t=1489534321" />
{% render_block "css" %}
</head>

@ -32,14 +32,12 @@
</div>
<div class="block" style="border-bottom: 1px solid #777; padding: 0 20px 15px 0;">
{% include 'docs/parts/form_field.html' with field=form.nds_value id="nds_value" classes="left" label="НДС" no_clear_after="True" %}
{% include 'docs/parts/form_field.html' with field=form.nds_value id="nds_value" label="НДС" no_clear_after="True" %}
</div>
{% if formset %}
<div class="block" style="border-bottom: 1px solid #777; padding: 0 20px 15px 0;">
{% include 'docs/parts/faktura_form_tbl_items.html' %}
</div>
{% include 'docs/faktura/form_tbl_items.html' %}
{% endif %}
</div>
{% endblock %}

@ -3,11 +3,11 @@
<table id="tbl_items" class="factura-doc-list doc-list">
<tr>
<th>Наименование</th>
<th colspan='2'>Ед. изм.</th>
<th>Ед. изм.</th>
<th>Кол-во</th>
<th>Цена</th>
<th>Сумма</th>
<th colspan='2'>Страна</th>
<th>Страна</th>
<th>№ таможенной декларации</th>
<th></th>
</tr>
@ -16,6 +16,7 @@
<tr class="row_tbl_items row {% cycle 'even' 'odd' %}" {% if iform.DELETE.value %}style='display:none;'{% endif %}>
{{ iform.id }}
{{ iform.parent }}
<td class="name">
{{ iform.name.errors }}
{{ iform.name }}
@ -24,9 +25,8 @@
{{ iform.units.errors }}
{{ iform.units }}
</td>
<td class="units_kod">
{{ iform.units_kod.errors }}
{{ iform.units_kod }}
<td class="units_kod" style="display:none; visibility:collapse;">
{{ iform.units_kod.as_hidden }}
</td>
<td class="qty">
{{ iform.qty.errors }}
@ -40,14 +40,13 @@
{{ iform.total_price.errors }}
{{ iform.total_price }}
</td>
<td class="country_code">
{{ iform.country_code.errors }}
{{ iform.country_code }}
</td>
<td class="country_name">
{{ iform.country_name.errors }}
{{ iform.country_name }}
</td>
<td class="country_code" style="display:none; visibility:collapse;">
{{ iform.country_code.as_hidden }}
</td>
<td class="ntd">
{{ iform.ntd.errors }}
{{ iform.ntd }}
@ -59,7 +58,7 @@
{% endfor %}
<tr>
<td colspan="4">
<td colspan="3">
</td>
<td class="itogo-td itogo-td1"><span>Итого</span></td>
<td class="itogo-td itogo-td2"><span id="itogo"></span></td>

@ -1,4 +1,3 @@
{% include 'docs/parts/form_client_choices.html' with client_group="receiver_group" id="receiver_choices" classes="field" label="Получатель" default=receiver_choice %}
{% include 'docs/parts/form_field_client.html' with field=form.receiver id="receiver" classes="field" label="Получатель" %}
<hr />

@ -1,3 +1,2 @@
{% include 'docs/parts/form_client_choices.html' with client_group="sender_group" id="sender_choices" classes="field" label="Отправитель" label1='Подставить мои данные' default=sender_choice %}
{% include 'docs/parts/form_field_client.html' with field=form.sender id="sender" classes="field" label="Отправитель" %}
<hr />

@ -9,29 +9,28 @@
prefix: '{{ formset.prefix }}',
formCssClass: 'dynamic-form',
});
var get_pair = function(model, class1, class2, name1, name2) {
$('body').on('focusout', '.' + class1 + ' input', function() {
var get_pair = function(model, class1, class2, param1, param2) {
$('body').on('selectChoice change', '.' + class1 + ' input', function() {
var $this = $(this);
var $code_input = $this.closest('.row_tbl_items').find('.' + class2 + ' input');
var code_input_val = $code_input.val();
var this_val = $this.val();
var $other_input = $this.closest('.row_tbl_items').find('.' + class2 + ' input');
$.get('/my/docs/ajax_get_pair/' + model + '/' + name1 + '/' + name2 + '/' + $this.val() + '/', function(data){
$.get('/my/docs/ajax_get_pair/' + model + '/' + param1 + '/' + param2 + '/' + this_val + '/', function(data) {
if (data['val']) {
$code_input.val(data['val']);
if (($code_input.val() != '')&&(($code_input.val() != code_input_val))) {
$code_input.css('color', 'red')
} else {
$code_input.css('color', 'black')
$other_input.val(data['val']);
$this.css('color', 'black')
}
$this.css('color', 'black');
else {
$other_input.val('-');
$this.css('color', 'red')
}
});
})
}
get_pair('Country', 'country_code', 'country_name', 'code', 'name');
{# model должна быть разрешена в docs.views.get_pair #}
get_pair('Country', 'country_name', 'country_code', 'name', 'code');
get_pair('Measure', 'units', 'units_kod', 'name', 'code');
get_pair('Measure', 'units_kod', 'units', 'code', 'name');
$('#id_client').on('change', function() {
var client_id = $(this).val();

Loading…
Cancel
Save