NDS in front

prod
Dmitriy Shesterkin 9 years ago
parent cb39a7720a
commit b1e23781d5
  1. 1
      src/docs/forms/aktrabot.py
  2. 29
      src/dokumentor/static/css/style.css
  3. 60
      src/dokumentor/static/js/formset-events.js
  4. 2
      src/dokumentor/templates/docs/aktrabot/form.html
  5. 13
      src/dokumentor/templates/docs/parts/form_tbl_items.html
  6. 18
      src/dokumentor/templates/docs/stub_js.html

@ -26,7 +26,6 @@ class AktRabotForm(BaseModelForm):
'doc_text': _textarea, 'doc_text': _textarea,
'nds_method': forms.RadioSelect() 'nds_method': forms.RadioSelect()
} }
# nds_method = forms.ChoiceField(widget=forms.RadioSelect())
class AktRabotAdminForm(AktRabotForm): class AktRabotAdminForm(AktRabotForm):

@ -487,8 +487,8 @@ a.delete { vertical-align: top; }
.doc-form table.doc-list {border-collapse:collapse;position:relative;} .doc-form table.doc-list {border-collapse:collapse;position:relative;}
.doc-form table.doc-list td {border:4px solid #fff;} .doc-form table.doc-list td {border:4px solid #fff;}
.doc-form table.doc-list .itogo-td {background:#313942;height:30px;font-size:20px;color:#fff;padding:5px 10px;border-bottom:2px solid #313942;border-top:2px solid #313942;} .doc-form table.doc-list .itogo-td {background:#313942;height:30px;font-size:20px;color:#fff;padding:5px 10px;border-bottom:2px solid #313942;border-top:2px solid #313942;}
.doc-form table.doc-list .itogo-td1 {} .doc-form table.doc-list .itogo-nds-td {height:30px;font-size:20px;color:#313942;padding:5px 10px;}
.doc-form table.doc-list .itogo-td2 {}
.doc-form table.doc-list .add-row {position:absolute;} .doc-form table.doc-list .add-row {position:absolute;}
.doc-form table.doc-list .add-row:hover {text-decoration:none;} .doc-form table.doc-list .add-row:hover {text-decoration:none;}
@ -831,3 +831,28 @@ input[type=number] {
font-size: 13px; font-size: 13px;
color: #498dd0; color: #498dd0;
} }
.nds-method {
margin-top: 38px;
margin-left: 10px;
}
#id_nds_method li {
display: inline-block;
}
#id_nds_method label {
font-size: 16px;
font-style: normal;
cursor: pointer;
}
#itogo {
display: block;
}
#decryption {
font-size:11px;
display:none;
margin-top: 5px;
}

@ -1,4 +1,5 @@
$(function() { $(function() {
var nds = '';
var fix_float_input = function (e) { var fix_float_input = function (e) {
var el = $(this); var el = $(this);
@ -9,6 +10,7 @@ $(function() {
var calc_summa = function (e) { var calc_summa = function (e) {
console.log('calc_summa'); console.log('calc_summa');
console.log($('#id_nds_method input:checked').val());
var el = $(this); var el = $(this);
var qty = parseFloat(el.closest('tr.row').find('td.qty input').val()); var qty = parseFloat(el.closest('tr.row').find('td.qty input').val());
@ -26,9 +28,29 @@ $(function() {
}; };
var calc_itogo_nds = function() { var calc_itogo_nds = function() {
$('#itogo_nds_text').html('НДС ' + $('#id_nds_value option:selected').text()); var itogo_sum = 0;
var nds = parseFloat($('#id_nds_value').val()) * parseFloat($('#itogo').html()) / 100; $('#tbl_items').find('.total_price input:visible').each(function() {
$('#itogo_nds').html(nds.toFixed(2)); var itogo_sum_row = $(this).val() ? parseFloat($(this).val()) : 0;
itogo_sum += itogo_sum_row;
});
if ($('#id_nds_value').val() && $('#itogo').html()) {
console.log('----','NDS %',$('#id_nds_value').val());
console.log('----','Total %',$('#itogo').html());
console.log('----','Metod %', parseInt($('#id_nds_method input:checked').val()));
if (parseInt($('#id_nds_method input:checked').val())) {
nds = parseFloat($('#id_nds_value').val()) * parseFloat(itogo_sum) / 100;
} else {
nds = (parseFloat(itogo_sum) / (100 + parseFloat($('#id_nds_value').val()))) * parseFloat($('#id_nds_value').val());
}
// console.log(nds.toFixed(2))
$('#totalNds').html(nds.toFixed(2));
} else {
$('#totalNds').html('');
}
}; };
window.calc_itogo = function (e) { window.calc_itogo = function (e) {
@ -38,7 +60,17 @@ $(function() {
itogo_sum += itogo_sum_row; itogo_sum += itogo_sum_row;
}); });
if (itogo_sum) { if (itogo_sum) {
$('#itogo').html(itogo_sum.toFixed(2)); if (parseInt($('#id_nds_method input:checked').val())) {
console.log('add');
nds = parseFloat($('#id_nds_value').val()) * parseFloat(itogo_sum) / 100;
$('#itogo').html(parseFloat(itogo_sum.toFixed(2)) + parseFloat(nds.toFixed(2)));
} else {
nds = (parseFloat(itogo_sum) / (100 + parseFloat($('#id_nds_value').val()))) * parseFloat($('#id_nds_value').val());
var totalWithoutNds = parseFloat(itogo_sum.toFixed(2)) - parseFloat(nds).toFixed(2);
$('#decryption').html(totalWithoutNds + ' + НДС');
$('#itogo').html(itogo_sum.toFixed(2));
}
} else { } else {
$('#itogo').html(''); $('#itogo').html('');
} }
@ -64,7 +96,25 @@ $(function() {
$("#tbl_items tr.row td.price input").blur(window.calc_itogo); $("#tbl_items tr.row td.price input").blur(window.calc_itogo);
$("#tbl_items tr.row td.total_price input").blur(window.calc_itogo); $("#tbl_items tr.row td.total_price input").blur(window.calc_itogo);
$('#id_nds_value').change(calc_itogo_nds); $('#id_nds_value').on('change', function(){
calc_itogo_nds();
calc_itogo();
if (!parseInt($('#id_nds_method input:checked').val())) {
$('#decryption').show();
} else {
$('#decryption').hide();
}
});
$('#id_nds_method').on('change', function () {
console.log('id_nds_method change');
calc_itogo();
if (!parseInt($('#id_nds_method input:checked').val())) {
$('#decryption').show();
} else {
$('#decryption').hide();
}
});
}; };
window.set_events(); window.set_events();

@ -18,7 +18,7 @@
<div class="block" style="border-bottom: 1px solid #777; padding: 0 20px 15px 0;"> <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" classes="left" label="НДС" no_clear_after="True" %}
{% include 'docs/parts/form_field.html' with field=form.nds_method id="nds_method" classes="left nds-method" no_clear_after="True" %} {% include 'docs/parts/form_field.html' with field=form.nds_method id="nds_method" classes="left nds-method hidden" no_clear_after="True" %}
{% if formset %} {% if formset %}
{% include 'docs/parts/form_tbl_items.html' %} {% include 'docs/parts/form_tbl_items.html' %}

@ -30,11 +30,22 @@
</tr> </tr>
{% endfor %} {% endfor %}
<tr id="blockTotalNds" class="hidden">
<td colspan="3">
</td>
<td class="itogo-nds-td"><span>НДС</span></td>
<td class="itogo-nds-td"><span id="totalNds"></span></td>
<td></td>
</tr>
<tr> <tr>
<td colspan="3"> <td colspan="3">
</td> </td>
<td class="itogo-td itogo-td1"><span>Итого</span></td> <td class="itogo-td itogo-td1"><span>Итого</span></td>
<td class="itogo-td itogo-td2"><span id="itogo"></span></td> <td class="itogo-td itogo-td2">
<span id="itogo"></span>
<span id="decryption"></span>
</td>
<td></td> <td></td>
</tr> </tr>

@ -106,6 +106,22 @@
}); });
// block nds method
$('#id_nds_value').on('change',function () {
console.log($('#id_nds_value').val());
if ($('#id_nds_value').val() > 0) {
$('#nds_method').show();
$('#blockTotalNds').show();
} else {
$('#nds_method').hide();
$('#decryption').hide();
$('#blockTotalNds').hide();
}
});
$('#id_invoice').on('change', function() { $('#id_invoice').on('change', function() {
@ -114,7 +130,7 @@
//console.log(invoice_id); //console.log(invoice_id);
if (invoice_id) { if (invoice_id) {
// TODO: needed preloader or remade function // TODO: needed loader or remade function
$.each($('.row_tbl_items'), function(index, item){ $.each($('.row_tbl_items'), function(index, item){
$(item).find('a.delete-row').trigger('click'); $(item).find('a.delete-row').trigger('click');

Loading…
Cancel
Save