nds_type removed, autofill some fields

remotes/origin/yandex
Bachurin Sergey 12 years ago
parent 8308a7adec
commit 5d82bb08b4
  1. 3
      project/docs/forms/aktrabot.py
  2. 3
      project/docs/forms/faktura.py
  3. 3
      project/docs/forms/invoice.py
  4. 3
      project/docs/forms/nakladn.py
  5. 7
      project/docs/forms/platejka.py
  6. 349
      project/docs/migrations/0007_auto__del_field_faktura_nds_type__del_field_invoice_nds_type__del_fiel.py
  7. 1
      project/docs/models/base_models.py
  8. 1
      project/docs/models/platejka.py
  9. 4
      project/docs/urls.py
  10. 7
      project/docs/utils.py
  11. 2
      project/docs/views/__init__.py
  12. 15
      project/docs/views/ajax.py
  13. 7
      project/docs/views/aktrabot.py
  14. 8
      project/docs/views/base_views.py
  15. 7
      project/docs/views/invoice.py
  16. 2
      project/static/css/style.css
  17. 9
      project/static/js/docs/common/calc_nds.js
  18. 9
      project/static/js/docs/platejka.form.js
  19. 7
      project/static/js/lib/jquery.formset.js
  20. 4
      project/templates/docs/aktrabot/as_pdf.html
  21. 1
      project/templates/docs/aktrabot/form.html
  22. 1
      project/templates/docs/faktura/form.html
  23. 4
      project/templates/docs/invoice/as_pdf.html
  24. 3
      project/templates/docs/invoice/form.html
  25. 1
      project/templates/docs/nakladn/form.html
  26. 6
      project/templates/docs/parts/faktura_form_plat_doc_items.html
  27. 10
      project/templates/docs/parts/faktura_form_tbl_items.html
  28. 4
      project/templates/docs/parts/form_tbl_items.html
  29. 1
      project/templates/docs/platejka/form.html
  30. 26
      project/templates/docs/stub_js.html

@ -13,13 +13,12 @@ class AktRabotForm(BaseModelForm):
model = AktRabot
fields = ('doc_num', 'doc_date',
'bank_account', 'client', 'invoice',
'nds_type', 'nds_value',
'nds_value',
'doc_text',
)
_radioselect = forms.RadioSelect
_textarea = forms.Textarea(attrs={'cols': 80, 'rows': 3})
widgets = {
'nds_type': _radioselect,
'doc_text': _textarea,
}

@ -15,13 +15,12 @@ class FakturaForm(BaseModelForm):
fields = ('doc_num', 'doc_date',
'bank_account', 'client', 'invoice',
'doc_reason',
'nds_type', 'nds_value',
'nds_value',
'doc_text', 'fixes', 'avance', 'currency', 'sender', 'receiver',
)
_radioselect = forms.RadioSelect
_textarea = forms.Textarea(attrs={'cols': 80, 'rows': 3})
widgets = {
'nds_type': _radioselect,
'doc_text': _textarea,
}

@ -13,13 +13,12 @@ class InvoiceForm(BaseModelForm):
model = Invoice
fields = ('doc_num', 'doc_date',
'bank_account', 'client',
'nds_type', 'nds_value',
'nds_value',
'doc_text',
)
_radioselect = forms.RadioSelect
_textarea = forms.Textarea(attrs={'cols': 80, 'rows': 3})
widgets = {
'nds_type': _radioselect,
'doc_text': _textarea,
}

@ -14,13 +14,12 @@ class NakladnForm(BaseModelForm):
fields = ('doc_num', 'doc_date',
'bank_account', 'client', 'invoice',
'doc_reason',
'nds_type', 'nds_value',
'nds_value',
'doc_text',
)
_radioselect = forms.RadioSelect
_textarea = forms.Textarea(attrs={'cols': 80, 'rows': 3})
widgets = {
'nds_type': _radioselect,
'doc_text': _textarea,
}

@ -10,14 +10,14 @@ from .. import consts
class PlatejkaForm(BaseModelForm):
"""Форма редактирования платежного поручения."""
conditional_fields = ['nds_type', 'nds_value',
conditional_fields = ['nds_value',
'tax_status', 'tax_base', 'tax_type', 'tax_bk', 'tax_okato', 'tax_period',]
class Meta:
model = Platejka
fields = ('platej_type', 'doc_num', 'doc_date',
'bank_account', 'client',
'nds_type', 'nds_value', # поля только для перевода денег
'nds_value', # поля только для перевода денег
# поля только для оплаты налогов
'tax_status', 'tax_base', 'tax_type', 'tax_num', 'tax_date', 'tax_bk', 'tax_okato', 'tax_period',
# опять общие поля
@ -27,7 +27,6 @@ class PlatejkaForm(BaseModelForm):
_textarea = forms.Textarea(attrs={'cols': 80, 'rows': 5})
widgets = {
#'platej_type': _radioselect,
'nds_type': _radioselect,
'doc_info': _textarea,
}
@ -45,10 +44,8 @@ class PlatejkaForm(BaseModelForm):
platej_type = cleaned_data.get('platej_type')
if platej_type == consts.PLATEJ_TYPE_COMMERCE: # коммерческое (перевод денег)
nds_type = cleaned_data.get('nds_type')
nds_value = cleaned_data.get('nds_value')
if not nds_type: set_field_error(self, 'nds_type')
if not nds_value: set_field_error(self, 'nds_value')
elif platej_type == consts.PLATEJ_TYPE_TAX: # налоги

@ -0,0 +1,349 @@
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Deleting field 'Faktura.nds_type'
db.delete_column(u'docs_faktura', 'nds_type')
# Deleting field 'Invoice.nds_type'
db.delete_column(u'docs_invoice', 'nds_type')
# Deleting field 'Nakladn.nds_type'
db.delete_column(u'docs_nakladn', 'nds_type')
# Deleting field 'AktRabot.nds_type'
db.delete_column(u'docs_aktrabot', 'nds_type')
def backwards(self, orm):
# Adding field 'Faktura.nds_type'
db.add_column(u'docs_faktura', 'nds_type',
self.gf('django.db.models.fields.PositiveSmallIntegerField')(default=1),
keep_default=False)
# Adding field 'Invoice.nds_type'
db.add_column(u'docs_invoice', 'nds_type',
self.gf('django.db.models.fields.PositiveSmallIntegerField')(default=1),
keep_default=False)
# Adding field 'Nakladn.nds_type'
db.add_column(u'docs_nakladn', 'nds_type',
self.gf('django.db.models.fields.PositiveSmallIntegerField')(default=1),
keep_default=False)
# Adding field 'AktRabot.nds_type'
db.add_column(u'docs_aktrabot', 'nds_type',
self.gf('django.db.models.fields.PositiveSmallIntegerField')(default=1),
keep_default=False)
models = {
u'auth.group': {
'Meta': {'object_name': 'Group'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
u'auth.permission': {
'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
u'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
u'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
u'customer.bankaccount': {
'Meta': {'ordering': "['-created_at']", 'object_name': 'BankAccount'},
'account': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
'address': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
'bik': ('django.db.models.fields.CharField', [], {'max_length': '10'}),
'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_main': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'korr_account': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'bank_accounts'", 'to': u"orm['auth.User']"})
},
u'customer.client': {
'Meta': {'ordering': "['name', '-created_at']", 'object_name': 'Client'},
'address': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
'bank_account': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '20', 'blank': 'True'}),
'bank_address': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '256', 'blank': 'True'}),
'bank_bik': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '10', 'blank': 'True'}),
'bank_korr_account': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '20', 'blank': 'True'}),
'bank_name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '256', 'blank': 'True'}),
'contact_email': ('django.db.models.fields.EmailField', [], {'default': "''", 'max_length': '50', 'blank': 'True'}),
'contact_icq': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '20', 'blank': 'True'}),
'contact_name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '50', 'blank': 'True'}),
'contact_other': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '256', 'blank': 'True'}),
'contact_phone': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '50', 'blank': 'True'}),
'contact_skype': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '20', 'blank': 'True'}),
'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'inn': ('django.db.models.fields.CharField', [], {'max_length': '12'}),
'kpp': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '9', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '256', 'db_index': 'True'}),
'okpo': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '10', 'blank': 'True'}),
'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'clients'", 'to': u"orm['auth.User']"})
},
'docs.aktrabot': {
'Meta': {'ordering': "('-doc_date',)", 'object_name': 'AktRabot'},
'bank_account': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['customer.BankAccount']"}),
'client': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['customer.Client']"}),
'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'doc_date': ('django.db.models.fields.DateField', [], {}),
'doc_num': ('django.db.models.fields.PositiveIntegerField', [], {}),
'doc_text': ('django.db.models.fields.TextField', [], {'default': "''", 'max_length': '1000', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'invoice': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'related_name': "'+'", 'null': 'True', 'blank': 'True', 'to': "orm['docs.Invoice']"}),
'nds_value': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '0'}),
'signed_status': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['auth.User']"})
},
'docs.aktrabotitem': {
'Meta': {'ordering': "('created_at',)", 'object_name': 'AktRabotItem'},
'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'aktrabot_items'", 'to': "orm['docs.AktRabot']"}),
'price': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
'qty': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '3'}),
'total_price': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
'units': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
},
'docs.aktsverki': {
'Meta': {'ordering': "('-doc_date',)", 'object_name': 'AktSverki'},
'client': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['customer.Client']"}),
'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'doc_date': ('django.db.models.fields.DateField', [], {}),
'doc_mesto': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
'doc_num': ('django.db.models.fields.PositiveIntegerField', [], {}),
'end_date': ('django.db.models.fields.DateField', [], {}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'saldo_credit': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2', 'blank': 'True'}),
'saldo_debit': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2', 'blank': 'True'}),
'signed_status': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'start_date': ('django.db.models.fields.DateField', [], {}),
'total_credit': ('django.db.models.fields.DecimalField', [], {'default': "'0.00'", 'max_digits': '10', 'decimal_places': '2', 'blank': 'True'}),
'total_debit': ('django.db.models.fields.DecimalField', [], {'default': "'0.00'", 'max_digits': '10', 'decimal_places': '2', 'blank': 'True'}),
'total_saldo': ('django.db.models.fields.DecimalField', [], {'default': "'0.00'", 'max_digits': '10', 'decimal_places': '2', 'blank': 'True'}),
'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['auth.User']"})
},
'docs.aktsverkiitem': {
'Meta': {'ordering': "('created_at',)", 'object_name': 'AktSverkiItem'},
'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'credit': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2', 'blank': 'True'}),
'debit': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'aktsverki_items'", 'to': "orm['docs.AktSverki']"}),
'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
},
'docs.country': {
'Meta': {'object_name': 'Country'},
'code': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '10'})
},
'docs.currency': {
'Meta': {'object_name': 'Currency'},
'code': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '10'})
},
'docs.dover': {
'Meta': {'ordering': "('-doc_date',)", 'object_name': 'Dover'},
'client': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['customer.Client']"}),
'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'doc_date': ('django.db.models.fields.DateField', [], {}),
'doc_expire_date': ('django.db.models.fields.DateField', [], {}),
'doc_num': ('django.db.models.fields.PositiveIntegerField', [], {}),
'dover_doc': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
'dover_doc_date': ('django.db.models.fields.DateField', [], {}),
'dover_name': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
'dover_passport_date': ('django.db.models.fields.DateField', [], {}),
'dover_passport_num': ('django.db.models.fields.CharField', [], {'max_length': '10'}),
'dover_passport_org': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
'dover_passport_ser': ('django.db.models.fields.CharField', [], {'max_length': '10'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['auth.User']"})
},
'docs.doveritem': {
'Meta': {'ordering': "('created_at',)", 'object_name': 'DoverItem'},
'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'dover_items'", 'to': "orm['docs.Dover']"}),
'qty': ('django.db.models.fields.PositiveIntegerField', [], {}),
'units': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
},
'docs.faktura': {
'Meta': {'ordering': "('-doc_date',)", 'object_name': 'Faktura'},
'avance': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'bank_account': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['customer.BankAccount']"}),
'client': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['customer.Client']"}),
'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'currency': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['docs.Currency']", 'null': 'True'}),
'doc_date': ('django.db.models.fields.DateField', [], {}),
'doc_num': ('django.db.models.fields.PositiveIntegerField', [], {}),
'doc_reason': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '256', 'blank': 'True'}),
'doc_text': ('django.db.models.fields.TextField', [], {'default': "''", 'max_length': '1000', 'blank': 'True'}),
'fixes': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'invoice': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'related_name': "'+'", 'null': 'True', 'blank': 'True', 'to': "orm['docs.Invoice']"}),
'nds_value': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '0'}),
'receiver': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'receiver_fakturas'", 'null': 'True', 'to': u"orm['customer.Client']"}),
'sender': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'sender_fakturas'", 'null': 'True', 'to': u"orm['customer.Client']"}),
'signed_status': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['auth.User']"}),
'user_is_sender': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
},
'docs.fakturaitem': {
'Meta': {'ordering': "('created_at',)", 'object_name': 'FakturaItem'},
'country_code': ('django.db.models.fields.CharField', [], {'max_length': '10'}),
'country_name': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'gtd': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '256', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'faktura_items'", 'to': "orm['docs.Faktura']"}),
'price': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
'qty': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '3'}),
'total_price': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
'units': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
'units_kod': ('django.db.models.fields.CharField', [], {'max_length': '10'}),
'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
},
'docs.invoice': {
'Meta': {'ordering': "('-doc_date',)", 'object_name': 'Invoice'},
'bank_account': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['customer.BankAccount']"}),
'client': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['customer.Client']"}),
'closed_status': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'doc_date': ('django.db.models.fields.DateField', [], {}),
'doc_num': ('django.db.models.fields.PositiveIntegerField', [], {}),
'doc_text': ('django.db.models.fields.TextField', [], {'default': "''", 'max_length': '1000', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'nds_value': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '0'}),
'paid_status': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '1'}),
'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['auth.User']"})
},
'docs.invoiceitem': {
'Meta': {'ordering': "('created_at',)", 'object_name': 'InvoiceItem'},
'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'invoice_items'", 'to': "orm['docs.Invoice']"}),
'price': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
'qty': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '3'}),
'total_price': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
'units': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
},
'docs.measure': {
'Meta': {'object_name': 'Measure'},
'code': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '10'})
},
'docs.nakladn': {
'Meta': {'ordering': "('-doc_date',)", 'object_name': 'Nakladn'},
'bank_account': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['customer.BankAccount']"}),
'client': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['customer.Client']"}),
'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'doc_date': ('django.db.models.fields.DateField', [], {}),
'doc_num': ('django.db.models.fields.PositiveIntegerField', [], {}),
'doc_reason': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '256', 'blank': 'True'}),
'doc_text': ('django.db.models.fields.TextField', [], {'default': "''", 'max_length': '1000', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'invoice': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'related_name': "'+'", 'null': 'True', 'blank': 'True', 'to': "orm['docs.Invoice']"}),
'nds_value': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '0'}),
'signed_status': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['auth.User']"})
},
'docs.nakladnitem': {
'Meta': {'ordering': "('created_at',)", 'object_name': 'NakladnItem'},
'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'nakladn_items'", 'to': "orm['docs.Nakladn']"}),
'price': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
'qty': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '3'}),
'total_price': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
'units': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
},
'docs.platdoc': {
'Meta': {'object_name': 'PlatDoc'},
'doc_date': ('django.db.models.fields.DateField', [], {}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'num': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'plat_docs'", 'to': "orm['docs.Faktura']"})
},
'docs.platejka': {
'Meta': {'ordering': "('-doc_date',)", 'object_name': 'Platejka'},
'bank_account': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['customer.BankAccount']"}),
'client': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['customer.Client']"}),
'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'doc_date': ('django.db.models.fields.DateField', [], {}),
'doc_info': ('django.db.models.fields.TextField', [], {'max_length': '1000'}),
'doc_num': ('django.db.models.fields.PositiveIntegerField', [], {}),
'doc_total': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'nds_type': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '1'}),
'nds_value': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '0'}),
'payment_order': ('django.db.models.fields.CharField', [], {'max_length': '10'}),
'payment_type': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '1'}),
'platej_type': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '1'}),
'tax_base': ('django.db.models.fields.CharField', [], {'default': "u'\\u0422\\u041f'", 'max_length': '10'}),
'tax_bk': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
'tax_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
'tax_num': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '50', 'blank': 'True'}),
'tax_okato': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
'tax_period': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
'tax_status': ('django.db.models.fields.CharField', [], {'default': "u'01'", 'max_length': '10'}),
'tax_type': ('django.db.models.fields.CharField', [], {'default': "u'\\u041d\\u0421'", 'max_length': '10'}),
'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'+'", 'to': u"orm['auth.User']"})
}
}
complete_apps = ['docs']

@ -44,7 +44,6 @@ class BaseNdsModel(BaseModel):
"""Расширение абстрактной модели бух.формы - НДС.
Доп. поля под тип и ставку НДС.
"""
nds_type = models.PositiveSmallIntegerField(u'НДС', choices=consts.NDS_TYPE_CHOICES, default=consts.NDS_TYPE_NO)
nds_value = models.PositiveSmallIntegerField(u'Ставка НДС', choices=consts.NDS_VALUE_CHOICES, default=consts.NDS_VALUE_0)
class Meta(BaseModel.Meta):

@ -21,7 +21,6 @@ class Platejka(BaseModel):
doc_info = models.TextField(u'Назначение платежа', max_length=1000)
# поля только для перевода денег (коммерческое)
nds_type = models.PositiveSmallIntegerField(u'НДС', choices=consts.NDS_TYPE_CHOICES, default=consts.NDS_TYPE_NO)
nds_value = models.PositiveSmallIntegerField(u'Ставка НДС', choices=consts.NDS_VALUE_CHOICES, default=consts.NDS_VALUE_0)
# поля только для оплаты налогов (налоговое)

@ -2,7 +2,7 @@
from django.conf.urls import *
from .views import (InvoiceViews, AktRabotViews, AktSverkiViews, DoverViews, PlatejkaViews, NakladnViews, FakturaViews)
from .views import getview, index, get_pair, get_invoices, get_tbl_items
from .views import getview, index, get_pair, get_invoices, get_tbl_items, get_client_by_invoice
urlpatterns = patterns('docs.views',
@ -58,8 +58,10 @@ for name, klass in klasses:
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_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'),
url(r'^ajax_get_client_by_invoice/(?P<invoice_id>\d+)/$', get_client_by_invoice, name='ajax_get_client_by_invoice'),
)
# доп. обработчики: создать Документ по Счету

@ -12,9 +12,6 @@ def get_nds(key):
def extract_nds(obj):
"""Если НДС содержится в цене, извлекает и возвращает его."""
nds = Decimal('0.00')
if obj.parent.nds_type == consts.NDS_TYPE_IN: # ндс в сумме, извлечь его
nds_rate = get_nds(obj.parent.nds_value)/100
nds = obj.price * (1 - 1/(1+nds_rate))
return nds
@ -30,10 +27,6 @@ def calc_clean_total_price(obj):
def calc_total_nds(obj):
"""Считает сумму налога."""
total_nds = Decimal('0.00')
if obj.parent.nds_type == consts.NDS_TYPE_IN: # ндс в сумме
total_nds = extract_nds(obj) * obj.qty
elif obj.parent.nds_type == consts.NDS_TYPE_OUT: # ндс сверх суммы
total_price = obj.price * obj.qty
nds_rate = get_nds(obj.parent.nds_value)/100
total_nds = total_price * nds_rate

@ -11,7 +11,7 @@ from .dover import DoverViews
from .platejka import PlatejkaViews
from .nakladn import NakladnViews
from .faktura import FakturaViews
from .ajax import get_pair, get_invoices, get_tbl_items
from .ajax import get_pair, get_invoices, get_tbl_items, get_client_by_invoice
#from .sfv import SfvViews

@ -27,11 +27,13 @@ def get_pair(request, model, param1, val1, param2):
return HttpResponse(json.dumps(data), mimetype='application/json')
def get_invoices(request, client_id):
def get_invoices(request, client_id=None):
if not request.is_ajax():
return HttpResponseBadRequest()
if client_id:
invoices = Invoice.objects.filter(client__id=client_id)
else:
invoices = Invoice.objects.filter(user=request.user)
invoices = {invoice.id: '%s от %s' % (invoice.doc_num, invoice.doc_date) for invoice in invoices}
return HttpResponse(json.dumps(invoices), mimetype='application/json')
@ -45,3 +47,12 @@ def get_tbl_items(request, invoice_id):
data = serializers.serialize('json', invoice.invoice_items.all())
return HttpResponse(json.dumps(data), mimetype='application/json')
def get_client_by_invoice(request, invoice_id):
if not request.is_ajax():
return HttpResponseBadRequest()
invoice = Invoice.objects.get(pk=invoice_id)
return HttpResponse(json.dumps([invoice.client.id,]), mimetype='application/json')

@ -71,12 +71,5 @@ class AktRabotViews(BaseItemsViews, AddByInvoiceMethodMixin):
obj.sum_total_nds += utils.calc_total_nds(item)
obj.sum_full_total_price += utils.calc_full_total_price(item)
if obj.nds_type == consts.NDS_TYPE_NO: # не учитывать ндс
s = u'Без налога (НДС)'
elif obj.nds_type == consts.NDS_TYPE_IN: # ндс в сумме
s = u'В том числе НДС (%s)' % obj.get_nds_value_display()
elif obj.nds_type == consts.NDS_TYPE_OUT: # ндс сверх суммы
s = u'Итого НДС (%s)' % obj.get_nds_value_display()
else:
s = u''
obj.nds_itogo_text = s

@ -648,8 +648,14 @@ class BaseItemsViews(BaseViews):
else:
pformset = None
formset = self.ITEM_FORMSET_CLASS(self.request.POST or None, prefix=self.ITEM_FORM_PREFIX, instance=obj)
if self.request.method == 'POST':
formset = self.ITEM_FORMSET_CLASS(self.request.POST, prefix=self.ITEM_FORM_PREFIX, instance=obj)
#print formset.forms[0].data['faktura_items-0-DELETE']
form = self.FORM_CLASS(self.request.user, data=self.request.POST or None, instance=obj)
else:
formset = self.ITEM_FORMSET_CLASS(prefix=self.ITEM_FORM_PREFIX, instance=obj)
form = self.FORM_CLASS(self.request.user, instance=obj)
if form.is_valid() and formset.is_valid() and ((not pformset) or (pformset and pformset.is_valid())):
new_obj = form.save()

@ -76,12 +76,5 @@ class InvoiceViews(BaseItemsViews):
obj.sum_total_nds += utils.calc_total_nds(item)
obj.sum_full_total_price += utils.calc_full_total_price(item)
if obj.nds_type == consts.NDS_TYPE_NO: # не учитывать ндс
s = u'Без налога (НДС)'
elif obj.nds_type == consts.NDS_TYPE_IN: # ндс в сумме
s = u'В том числе НДС (%s)' % obj.get_nds_value_display()
elif obj.nds_type == consts.NDS_TYPE_OUT: # ндс сверх суммы
s = u'Итого НДС (%s)' % obj.get_nds_value_display()
else:
s = u''
obj.nds_itogo_text = s

@ -103,7 +103,7 @@ a.delete { vertical-align: top; }
.doc-form { padding-left: 2px; }
.doc-form input[type=text], input[type=password], textarea, option { padding-left: 2px; margin-left: 0; }
.doc-form #doc_date, .doc-form #nds_type,
.doc-form #doc_date,
.doc-form #doc_mesto, .doc-form #end_date,
.doc-form #doc_expire_date, .doc-form #dover_doc_date, .doc-form #dover_passport_num
{ margin-left: 10px; }

@ -1,11 +1,4 @@
function calc_nds(summa, nds_rate, nds_type) {
switch (nds_type) {
case 2: // ндс в сумме
nds_rate = nds_rate/100;
return summa * (1 - 1 / (1 + nds_rate));
case 3: // ндс сверх суммы
function calc_nds(summa, nds_rate) {
return summa * nds_rate/100;
default:
return 0;
}
}

@ -6,7 +6,6 @@ DOC.taxes = null;
DOC.doc_info = null;
DOC.CONSTS = {
'platej_type': {'commerce': 1, 'tax': 2}, // типы платежных поручений
'nds_type': {'no': 1, 'in': 2, 'out': 3}, // # виды НДС
'nds_value': {0: 1, 10: 2, 18: 3} // # ставка НДС
};
@ -45,11 +44,9 @@ function make_summa() {
var ptype = DOC.platej_type.val();
var el_doc_total = $('input#id_doc_total', DOC.form);
var el_nds_type = $('input[name=nds_type]:checked', DOC.form);
var el_nds_value = $('select[name=nds_value]', DOC.form);
var doc_total = parseFloat(el_doc_total.val().replace(",", "."));
var nds_type = parseInt(el_nds_type.val().replace(",", "."));
var nds_value = parseInt(el_nds_value.val().replace(",", "."));
var add_text = '';
@ -65,8 +62,7 @@ function make_summa() {
// добавить в текст ндс
if (ptype == DOC.CONSTS.platej_type.commerce) { // перевод денег
if (!isNaN(doc_total) && !isNaN(nds_type) && !isNaN(nds_value)) {
if (nds_type == DOC.CONSTS.nds_type['in'] || nds_type == DOC.CONSTS.nds_type['out']) {
if (!isNaN(doc_total) && !isNaN(nds_value)) {
var nds_rate = 0;
switch (nds_value) {
case DOC.CONSTS.nds_value[0]: nds_rate = 0; break;
@ -74,7 +70,7 @@ function make_summa() {
case DOC.CONSTS.nds_value[18]: nds_rate = 18; break;
}
if (nds_rate > 0) {
var nds = calc_nds(doc_total, nds_rate, nds_type);
var nds = calc_nds(doc_total, nds_rate);
add_text += ', в т.ч. НДС (' + nds_rate + '%): ' +
nds.toFixed(2).toString().replace(".", ",") + ' руб.';
}
@ -83,7 +79,6 @@ function make_summa() {
}
}
}
}
var doc_info_val = DOC.doc_info.val();
if (doc_info_val)

@ -58,7 +58,8 @@
// We're dealing with an inline formset; rather than remove
// this form from the DOM, we'll mark it as deleted and hide
// it, then let Django handle the deleting:
del.val('on');
//del.val('on');
del.prop('checked', true);
row.hide();
} else {
row.remove();
@ -105,9 +106,6 @@
if (del.length) {
// If you specify "can_delete = True" when creating an inline formset,
// Django adds a checkbox to each form in the formset.
// Replace the default checkbox with a hidden field:
del.before('<input type="hidden" name="' + del.attr('name') +'" id="' + del.attr('id') +'" />');
del.remove();
}
if (hasChildElements(row)) {
insertDeleteLink(row);
@ -163,7 +161,6 @@
row = options.formTemplate.clone(true).removeClass('formset-custom-template'),
buttonRow = $(this).parents('tr.' + options.formCssClass + '-add').get(0) || this;
applyExtraClasses(row, formCount);
console.log(options);
if (options.beforeadd) options.beforeadd(row);
row.insertBefore($(buttonRow)).show();
row.find('input,select,textarea,label').each(function() {

@ -95,11 +95,7 @@
<tr class="row font_10 bold">
<td colspan="5">{{ obj.nds_itogo_text|safe }}:</td>
<td class="borders">
{% if obj.nds_type == 1 %}
---
{% else %}
{{ obj.sum_total_nds|floatformat:2 }}
{% endif %}
</td>
</tr>

@ -16,7 +16,6 @@
<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_type id="nds_type" classes="left" label_inline="True" %}
{% if formset %}
<br />

@ -28,7 +28,6 @@
<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_type id="nds_type" classes="left" label_inline="True" %}
{% if formset %}
<br />

@ -115,11 +115,7 @@
</td>
<td class="borders">
<b>
{% if obj.nds_type == 1 %} {# не учитывать ндс #}
---
{% else %}
{{ obj.sum_total_nds|floatformat:2 }}
{% endif %}
</b>
</td>
</tr>

@ -15,7 +15,6 @@
<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_type id="nds_type" classes="left" label_inline="True" %}
{% if formset %}
<br />
@ -44,7 +43,7 @@
$("#tbl_items tr.row td.price input").blur(calc_itogo);
$("#tbl_items tr.row td.total_price input").blur(calc_itogo);
$('input[name=nds_type]').change(calc_itogo_nds);
//$('input[name=nds_type]').change(calc_itogo_nds);
$('#id_nds_value').change(calc_itogo_nds);
$("#tbl_items tr.row td.qty input").blur(calc_itogo_nds);

@ -20,7 +20,6 @@
<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_type id="nds_type" classes="left" label_inline="True" %}
{% if formset %}
<br />

@ -7,8 +7,8 @@
<th style="width: 72px">От</th>
</tr>
{% for pform in pformset %}
<tr class="row {% cycle 'even' 'odd' %} plat_form">
{% for pform in pformset.forms %}
<tr class="row {% cycle 'even' 'odd' %} plat_form" {% if pform.DELETE.value %}style='display:none;'{% endif %}>
<td class="name">
{{ pform.num.errors }}
{{ pform.num }}
@ -19,7 +19,7 @@
</td>
{{ pform.id }}
<td class="DELETE center">
{{ pform.DELETE }}
<span style='display:none;'>{{ pform.DELETE }}</span>
</td>
</tr>
{% endfor %}

@ -11,8 +11,10 @@
<th style="width: 44px; text-align: center">Удалить</th>
</tr>
{% for iform in formset %}
<tr class="row_tbl_items row {% cycle 'even' 'odd' %}">
{% for iform in formset.forms %}
<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 }}
@ -45,10 +47,8 @@
{{ iform.country_name.errors }}
{{ iform.country_name }}
</td>
{{ iform.id }}
{{ iform.parent }}
<td class="DELETE center">
{{ iform.DELETE }}
{% if iform.instance.pk %}<span style='display:none;'>{{ iform.DELETE }}</span>{% endif %}
</td>
</tr>
{% endfor %}

@ -11,7 +11,7 @@
</tr>
{% for iform in formset %}
<tr class="row_tbl_items row {% cycle 'even' 'odd' %}">
<tr class="row_tbl_items row {% cycle 'even' 'odd' %}" {% if iform.DELETE.value %}style='display:none;'{% endif %}>
{% for field in iform %}
{% if field.name == "id" or field.name == "parent" %}
{{ field }}
@ -25,7 +25,7 @@
{% endif %}
{% endfor %}
<td class="DELETE center">
{{ iform.DELETE }}
{% if iform.instance.pk %}<span style='display:none;'>{{ iform.DELETE }}</span>{% endif %}
</td>
</tr>
{% endfor %}

@ -52,7 +52,6 @@
{# коммерческие реквизиты #}
<div class="commerce">
{% include 'docs/parts/form_field.html' with field=form.nds_value id="nds_value" classes="field left" label="НДС" no_clear_after="True" %}
{% include 'docs/parts/form_field.html' with field=form.nds_type id="nds_type" classes="field left" label_inline="True" %}
</div>
</div>
<div class="clear"></div>

@ -2,10 +2,12 @@
<script type="text/javascript">
$(document).ready(function() {
$('tr.plat_form').formset({
prefix: '{{ pformset.prefix }}'
prefix: '{{ pformset.prefix }}',
formCssClass: 'plat_dynamic-form',
});
$('tr.row_tbl_items').formset({
prefix: '{{ formset.prefix }}'
prefix: '{{ formset.prefix }}',
formCssClass: 'dynamic-form',
});
var get_pair = function(model, class1, class2, name1, name2) {
$('body').on('focusout', '.' + class1 + ' input', function() {
@ -52,15 +54,33 @@
$('#id_invoice').on('change', function() {
var invoice_id = $(this).val();
$.each($('.row_tbl_items'), function(index, item){
$(item).find('a.delete-row').trigger('click');
});
$.get('/my/docs/ajax_get_client_by_invoice/' + invoice_id, function(data) {
var client = data[0];
$('#id_client').val(client);
})
$.get('/my/docs/ajax_get_tbl_items/' + invoice_id, function(data) {
var items = JSON.parse(data);
console.log(items.length);
$.each(items, function(index, item){
var name = item['fields']['name'];
var units = item['fields']['units'];
var qty = item['fields']['qty'];
var price = item['fields']['price'];
var total_price = item['fields']['total_price'];
$('#tbl_items a.add-row').trigger('click');
var $last_row = $('.row_tbl_items:visible').last();
$last_row.find('.name input').val(name);
$last_row.find('.units input').val(units);
$last_row.find('.qty input').val(qty);
$last_row.find('.price input').val(price);
$last_row.find('.total_price input').val(total_price);
$.get('/my/docs/ajax_get_pair/Measure/name/code/' + units + '/', function(data){
if (data['val']) {
$last_row.find('.units_kod input').val(data['val']);
}
});
})
})
})

Loading…
Cancel
Save