| Server IP : 162.214.74.102 / Your IP : 216.73.217.80 Web Server : Apache System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64 User : lrsys ( 1015) PHP Version : 5.6.40 Disable Function : exec,passthru,shell_exec,system MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/lrsys/public_html/lrsys_apps/imobles/ui/lib/nature_operation/ |
Upload File : |
/* global bootbox, _L */
var optionsProducts = [];
var states = [];
$(document).ready(function () {
var rowExceptionIcms = $("#rowExceptionIcms").val();
var rowExceptionIpi = $("#rowExceptionIpi").val();
var rowExceptionIssqn = $("#rowExceptionIssqn").val();
var rowExceptionPis = $("#rowExceptionPis").val();
var rowExceptionCofins = $("#rowExceptionCofins").val();
var rowExceptionSimples = $("#rowExceptionSimples").val();
var _url = $("#_url").val();
$(".progress").hide();
$("#emsg").hide();
$('.amount').autoNumeric('init', {aSep: ind_mil, aDec: ind_decimal, mDec: 2, aSign: curr_code + ' '});
$('.percent4').autoNumeric('init', {aSep: ind_mil, aDec: ind_decimal, mDec: 4});
$('.percent').autoNumeric('init', {aSep: ind_mil, aDec: ind_decimal, mDec: 2});
verificaICMS($('#icms_st').val());
$('#icms_st').on("change", function (e) {
verificaICMS($(this).val());
});
function verificaICMS(val) {
if (val == 10 || val == 30) {
$("#icms_div_st").removeClass("hide");
$(".icms_base").addClass("hide");
$(".icms_baseDiferimento").addClass("hide");
$(".icms_alqPresumido").addClass("hide");
} else if (val == 20) {
$(".icms_base").removeClass("hide");
$("#icms_div_st").addClass("hide");
$(".icms_baseDiferimento").addClass("hide");
$(".icms_alqPresumido").addClass("hide");
} else if (val == 51) {
$(".icms_base").removeClass("hide");
$(".icms_baseDiferimento").removeClass("hide");
$("#icms_div_st").addClass("hide");
$(".icms_alqPresumido").addClass("hide");
} else if (val == 60 || val == 70) {
$("#icms_div_st").removeClass("hide");
$(".icms_base").removeClass("hide");
$(".icms_baseDiferimento").addClass("hide");
$(".icms_alqPresumido").addClass("hide");
} else if (val == 90) {
$("#icms_div_st").removeClass("hide");
$(".icms_base").removeClass("hide");
$(".icms_baseDiferimento").removeClass("hide");
$(".icms_alqPresumido").removeClass("hide");
} else {
$("#icms_div_st").addClass("hide");
$(".icms_base").addClass("hide");
$(".icms_baseDiferimento").addClass("hide");
$(".icms_alqPresumido").addClass("hide");
}
}
verificaIPI($('#ipi_st').val());
$('#ipi_st').on("change", function (e) {
verificaIPI($(this).val());
});
function verificaIPI(val) {
if (val == 'ZZ') {
$(".ipi_st_ZZ").addClass("hide");
} else {
$(".ipi_st_ZZ").removeClass("hide");
}
}
verificaCRT($('#crt').val());
$('#crt').on("change", function (e) {
verificaCRT($(this).val())
});
function verificaCRT(val) {
if (val == '1') {
$(".li-icms").addClass("hide");
$(".li-simple").removeClass("hide");
$('.nav-tabs a[href="#simples"]').tab('show');
} else {
$(".li-icms").removeClass("hide");
$(".li-simple").addClass("hide");
$('.nav-tabs a[href="#icms"]').tab('show');
}
}
verificaSimplesST($("#simples_st").val());
$('#simples_st').on("change", function (e) {
verificaSimplesST($(this).val());
});
function verificaSimplesST(val) {
if (val == '101') {
$(".simples_alqCredito").removeClass("hide");
$(".simples_base").addClass("hide");
$(".simples_aliquote").addClass("hide");
$(".simples_st").addClass("hide");
$(".simples_icms_st_alq").addClass("hide");
$(".simples_icms_st_base").addClass("hide");
$(".simples_icms_st_valor_adicionado").addClass("hide");
$(".simples_alqRetido").addClass("hide");
$(".simples_baseRetido").addClass("hide");
$(".simple500").addClass("hide");
} else if (val == '201' || val == '900') {
$(".simples_alqCredito").removeClass("hide");
$(".simples_base").removeClass("hide");
$(".simples_aliquote").removeClass("hide");
$(".simples_st").removeClass("hide");
$(".simples_icms_st_alq").removeClass("hide");
$(".simples_icms_st_base").removeClass("hide");
$(".simples_icms_st_valor_adicionado").removeClass("hide");
$(".simples_alqRetido").addClass("hide");
$(".simples_baseRetido").addClass("hide");
$(".simple500").addClass("hide");
} else if (val == '202' || val == '203') {
$(".simples_alqCredito").addClass("hide");
$(".simples_base").removeClass("hide");
$(".simples_aliquote").removeClass("hide");
$(".simples_st").removeClass("hide");
$(".simples_icms_st_alq").removeClass("hide");
$(".simples_icms_st_base").removeClass("hide");
$(".simples_icms_st_valor_adicionado").removeClass("hide");
$(".simples_alqRetido").addClass("hide");
$(".simples_baseRetido").addClass("hide");
$(".simple500").addClass("hide");
} else if (val == '500') {
$(".simples_alqCredito").addClass("hide");
$(".simples_base").addClass("hide");
$(".simples_aliquote").addClass("hide");
$(".simples_st").removeClass("hide");
$(".simple500").removeClass("hide");
$(".simples_icms_st_alq").addClass("hide");
$(".simples_icms_st_base").addClass("hide");
$(".simples_icms_st_valor_adicionado").addClass("hide");
$(".simples_alqRetido").removeClass("hide");
$(".simples_baseRetido").removeClass("hide");
} else {
$(".simples_alqCredito").addClass("hide");
$(".simples_base").addClass("hide");
$(".simples_aliquote").addClass("hide");
$(".simples_st").addClass("hide");
$(".simples_icms_st_alq").addClass("hide");
$(".simples_icms_st_base").addClass("hide");
$(".simples_icms_st_valor_adicionado").addClass("hide");
$(".simples_alqRetido").addClass("hide");
$(".simples_baseRetido").addClass("hide");
$(".simple500").addClass("hide");
}
}
////////////////////////modal IPI enqudramento/////////////
var $modal_ipi_framework = $('#ajax-modal');
$('#list_ipi_framework').on('click', function (e) {
e.preventDefault();
// create the backdrop and wait for next modal to be triggered
$('body').modalmanager('loading');
setTimeout(function () {
$modal_ipi_framework.load(_url + 'ps/modal_ipi_framework/', '', function () {
$modal_ipi_framework.modal();
});
}, 1000);
});
var $submit = $("#submit");
var $ibox_form = $('#nature_form');
$submit.on('click', function (e) {
e.preventDefault();
$ibox_form.block({message: block_msg});
$.post(_url + "nature_operation/post/", $("#nature_form").serialize())
.done(function (data) {
if ($.isNumeric(data)) {
location.reload();
} else {
$ibox_form.unblock();
var body = $("html, body");
body.animate({scrollTop: 0}, '1000', 'swing');
$("#emsgbody").html(data);
$("#emsg").show("slow");
loadProducts();
}
});
});
///EXCEPTION
var $modal = $('#ajax-modal');
$('.add_exception').on('click', function () {
var table = $(this).attr('data-table');
var type = $(this).attr('data-type');
var title = $(this).attr('data-title');
$modal.load(_url + 'nature_operation/modal_exception/', {type: $(this).attr('data-type'), title: $(this).attr('data-title'), exception: ""}, function () {
$modal.modal();
// $("#modal_add_product #update_row").val("");
$('#modal_form #modal_update_table').val(table);
$('#modal_form #modal_type').val(type);
$('#modal_form #rowNcmException').val(0);
$('#modal_form #modal_title').val(title);
$('#modal_form #rowProduct').val(0);
prepareFormException();
});
});
function prepareFormException() {
var rowNcmException = $('#modal_form #rowNcmException').val();
var rowProducts = $('#modal_form #rowProduct').val();
//necessrio nesse theme para o option funcionar
$('#modal_form .select2').select2({
theme: "bootstrap"
});
$("#modal_form #selectAllDestiny").on('click', function () {
if ($(this).is(":checked")) {
$(".optionDestiny").prop("checked", true);
} else {
$(".optionDestiny").prop("checked", false);
}
});
//////PRODUTOS
var addProducts = false;
$('#modal_form #modal_add_product').on('click', function () {
if (!addProducts) {
$('#modal_form #modal_lista-regra-produtos').find('tbody')
.append(
'<tr class="">\n\
<td><input type="hidden" name="products" id="modal_product_' + rowProducts + '" ><span id="modal_label_product_' + rowProducts + '"></span><div id="modal_div_product_' + rowProducts + '"><select style="width:100%" class="select2" id="modal_product_value_' + rowProducts + '"></select></div>\n\
</td>\n\
<td class="middle col-xs-1"> \n\
<span class="btn btn-success btn-xs ok_product" id="modal_ok_product_' + rowProducts + '" data-row="' + rowProducts + '" ><i class="fa fa-check"></i> </span> <span class="btn btn-danger btn-xs modal_delete_product" data-row="' + rowProducts + '" ><i class="fa fa-trash"></i> </span></td></tr>'
);
findDataSelect("#modal_product_value_" + rowProducts, "ps/ajax-list", _L['Select product']);
rowProducts++;
addProducts = true;
} else {
bootbox.alert(_L['Select product']);
}
});
//adicionar linha do ncm
$('#modal_form #modal_lista-regra-produtos').on("click", ".ok_product", function (e) {
if ($("#modal_product_value_" + $(this).attr("data-row")).val() != null && $("#modal_product_value_" + $(this).attr("data-row")).val() != "" && $("#modal_product_value_" + $(this).attr("data-row")).val().length > 0) {
$("#modal_div_product_" + $(this).attr("data-row")).addClass('hide');
$("#modal_product_" + $(this).attr("data-row")).val($("#modal_product_value_" + $(this).attr("data-row")).val());
$("#modal_label_product_" + $(this).attr("data-row")).html(getProduct($("#modal_product_value_" + $(this).attr("data-row")).val()));
$("#modal_ok_product_" + $(this).attr("data-row")).addClass('hide');
addProducts = false;
} else {
bootbox.alert(_L['Select product']);
}
});
//remover linha do ncm
$('#modal_form #modal_lista-regra-produtos').on("click", ".modal_delete_product", function (e) {
$(this).closest('tr').remove();
addProducts = false;
});
////////FIM DOS PRODUTOS
var addNCM = false;
$('#modal_form #modal_add_ncm').on('click', function () {
if (!addNCM) {
$('#modal_form #modal_lista-regra-ncms').find('tbody')
.append(
'<tr class="">\n\
<td><input class="ncm form-control" type="text" name="ncm" id="modal_ncm_value_' + rowNcmException + '"></td>\n\
<td class="middle col-xs-1"> \n\
<span class="btn btn-success btn-xs ok_ncm" id="modal_ok_ncm_' + rowNcmException + '" data-row="' + rowNcmException + '" ><i class="fa fa-check"></i> </span> <span class="btn btn-danger btn-xs modal_delete_ncm" data-row="' + rowNcmException + '" ><i class="fa fa-trash"></i> </span></td></tr>'
);
//adiciona mascara para o ncm
$("#modal_form #modal_ncm_value_" + rowNcmException).mask("9999.99.99");
addNCM = true;
rowNcmException++;
} else {
bootbox.alert(_L['Input the NCM']);
}
});
//adicionar linha do ncm
$('#modal_form #modal_lista-regra-ncms').on("click", ".ok_ncm", function (e) {
if ($("#modal_form #modal_ncm_value_" + $(this).attr("data-row")).val() != null && $("#modal_ncm_value_" + $(this).attr("data-row")).val() != "" && $("#modal_ncm_value_" + $(this).attr("data-row")).val().length > 0) {
$("#modal_form #modal_ncm_value_" + $(this).attr("data-row")).attr('readonly', 'readonly');
$("#modal_ok_ncm_" + $(this).attr("data-row")).addClass('hide');
addNCM = false;
} else {
bootbox.alert(_L['Input the NCM']);
}
});
//remover linha do ncm
$('#modal_form #modal_lista-regra-ncms').on("click", ".modal_delete_ncm", function (e) {
$(this).closest('tr').remove();
addNCM = false;
});
///ações do exceptiom como de cima, controle dos exception por group
$('#modal_form .amount').autoNumeric('init', {aSep: ind_mil, aDec: ind_decimal, mDec: 2, aSign: curr_code + ' '});
$('#modal_form .percent4').autoNumeric('init', {aSep: ind_mil, aDec: ind_decimal, mDec: 4});
$('#modal_form .percent').autoNumeric('init', {aSep: ind_mil, aDec: ind_decimal, mDec: 2});
modalVerificaICMS($('#modal_form #modal_icms_st').val());
$('#modal_form #modal_icms_st').on("change", function (e) {
modalVerificaICMS($(this).val());
});
function modalVerificaICMS(val) {
if (val == 10 || val == 30) {
$("#modal_form #modal_icms_div_st").removeClass("hide");
$("#modal_form .icms_base").addClass("hide");
$("#modal_form .icms_baseDiferimento").addClass("hide");
$("#modal_form .icms_alqPresumido").addClass("hide");
} else if (val == 20) {
$("#modal_form .icms_base").removeClass("hide");
$("#modal_form #modal_icms_div_st").addClass("hide");
$("#modal_form .icms_baseDiferimento").addClass("hide");
$("#modal_form .icms_alqPresumido").addClass("hide");
} else if (val == 51) {
$("#modal_form .icms_base").removeClass("hide");
$("#modal_form .icms_baseDiferimento").removeClass("hide");
$("#modal_form #modal_icms_div_st").addClass("hide");
$("#modal_form .icms_alqPresumido").addClass("hide");
} else if (val == 60 || val == 70) {
$("#modal_form #modal_icms_div_st").removeClass("hide");
$("#modal_form .icms_base").removeClass("hide");
$("#modal_form .icms_baseDiferimento").addClass("hide");
$("#modal_form .icms_alqPresumido").addClass("hide");
} else if (val == 90) {
$("#modal_form #modal_icms_div_st").removeClass("hide");
$("#modal_form .icms_base").removeClass("hide");
$("#modal_form .icms_baseDiferimento").removeClass("hide");
$("#modal_form .icms_alqPresumido").removeClass("hide");
} else {
$("#modal_form #modal_icms_div_st").addClass("hide");
$("#modal_form .icms_base").addClass("hide");
$("#modal_form .icms_baseDiferimento").addClass("hide");
$("#modal_form .icms_alqPresumido").addClass("hide");
}
}
modalVerificaIPI($('#modal_form #modal_ipi_st').val());
$('#modal_form #modal_ipi_st').on("change", function (e) {
modalVerificaIPI($(this).val());
});
function modalVerificaIPI(val) {
if (val == 'ZZ') {
$("#modal_form .ipi_st_ZZ").addClass("hide");
} else {
$("#modal_form .ipi_st_ZZ").removeClass("hide");
}
}
modalVerificaSimplesST($("#modal_form #modal_simples_st").val());
$('#modal_form #modal_simples_st').on("change", function (e) {
modalVerificaSimplesST($(this).val());
});
function modalVerificaSimplesST(val) {
if (val == '101') {
$("#modal_form .simples_alqCredito").removeClass("hide");
$("#modal_form .simples_base").addClass("hide");
$("#modal_form .simples_aliquote").addClass("hide");
$("#modal_form .simples_st").addClass("hide");
$("#modal_form .simples_icms_st_alq").addClass("hide");
$("#modal_form .simples_icms_st_base").addClass("hide");
$("#modal_form .simples_icms_st_valor_adicionado").addClass("hide");
$("#modal_form .simples_alqRetido").addClass("hide");
$("#modal_form .simples_baseRetido").addClass("hide");
$("#modal_form .simple500").addClass("hide");
} else if (val == '201' || val == '900') {
$("#modal_form .simples_alqCredito").removeClass("hide");
$("#modal_form .simples_base").removeClass("hide");
$("#modal_form .simples_aliquote").removeClass("hide");
$("#modal_form .simples_st").removeClass("hide");
$("#modal_form .simples_icms_st_alq").removeClass("hide");
$("#modal_form .simples_icms_st_base").removeClass("hide");
$("#modal_form .simples_icms_st_valor_adicionado").removeClass("hide");
$("#modal_form .simples_alqRetido").addClass("hide");
$("#modal_form .simples_baseRetido").addClass("hide");
$("#modal_form .simple500").addClass("hide");
} else if (val == '202' || val == '203') {
$("#modal_form .simples_alqCredito").addClass("hide");
$("#modal_form .simples_base").removeClass("hide");
$("#modal_form .simples_aliquote").removeClass("hide");
$("#modal_form .simples_st").removeClass("hide");
$("#modal_form .simples_icms_st_alq").removeClass("hide");
$("#modal_form .simples_icms_st_base").removeClass("hide");
$("#modal_form .simples_icms_st_valor_adicionado").removeClass("hide");
$("#modal_form .simples_alqRetido").addClass("hide");
$("#modal_form .simples_baseRetido").addClass("hide");
$("#modal_form .simple500").addClass("hide");
} else if (val == '500') {
$("#modal_form .simples_alqCredito").addClass("hide");
$("#modal_form .simples_base").addClass("hide");
$("#modal_form .simples_aliquote").addClass("hide");
$("#modal_form .simples_st").removeClass("hide");
$("#modal_form .simple500").removeClass("hide");
$("#modal_form .simples_icms_st_alq").addClass("hide");
$("#modal_form .simples_icms_st_base").addClass("hide");
$("#modal_form .simples_icms_st_valor_adicionado").addClass("hide");
$("#modal_form .simples_alqRetido").removeClass("hide");
$("#modal_form .simples_baseRetido").removeClass("hide");
} else {
$("#modal_form .simples_alqCredito").addClass("hide");
$("#modal_form .simples_base").addClass("hide");
$("#modal_form .simples_aliquote").addClass("hide");
$("#modal_form .simples_st").addClass("hide");
$("#modal_form .simples_icms_st_alq").addClass("hide");
$("#modal_form .simples_icms_st_base").addClass("hide");
$("#modal_form .simples_icms_st_valor_adicionado").addClass("hide");
$("#modal_form .simples_alqRetido").addClass("hide");
$("#modal_form .simples_baseRetido").addClass("hide");
$("#modal_form .simple500").addClass("hide");
}
}
////////////////////////modal IPI enqudramento/////////////
var $modal_modal_ipi_framework = $('#ajax-modal-2');
$('#modal_form #modal_list_ipi_framework').on('click', function (e) {
e.preventDefault();
$modal_modal_ipi_framework.load(_url + 'ps/modal_ipi_framework/', '', function () {
$modal_modal_ipi_framework.modal();
});
});
$("#modal_form #modal_submit").on('click', function (e) {
e.preventDefault();
//validação dos itens ainda, se não foram inseridos
if (addNCM) {
bootbox.alert(_L['Input the NCM']);
return;
}
if (addProducts) {
bootbox.alert(_L['Select product']);
return;
}
var dados = $("#modal_form").serializeFormJSON();
var stateDestiny = "";
//alert(JSON.stringify(dados));
//carrega os estados, sigla, para listar na table
if (dados.destino !== undefined) {
if((dados.destino+"").indexOf(',') !== -1){
var i = 0;
for (i = 0; i < dados.destino.length; i++) {
stateDestiny = stateDestiny + ", " + getState(dados.destino[i]);
}
}else{
stateDestiny = ", " + getState(dados.destino);
}
}
var productsSelect = "";
if (dados.products !== undefined) {
if((dados.products+"").indexOf(',') !== -1){
var i = 0;
for (i = 0; i < dados.products.length; i++) {
productsSelect = productsSelect + getProduct(dados.products[i]) + "<br/>";
}
}else{
productsSelect = getProduct(dados.products);
}
}
//ACRESCENTA Na TABELA DE EXCEÇÃO DO ICMS
if (dados.modal_type == 'icms') {
var textcfop = '';
if (dados.icms_cfop !== undefined) {
textcfop = dados.icms_cfop;
}
if ($('#modal_form #modal_update_row').val() == '') {
$('#' + $('#modal_form #modal_update_table').val()).find('tbody')
.append('<tr>\n\
<td class="edit_regra" data-type="icms" id="exception_icms_destiny_' + rowExceptionIcms + '" data-row="' + rowExceptionIcms + '">' + stateDestiny.substr(1) + '</td>\n\
<td class="edit_regra" data-type="icms" id="exception_icms_products_' + rowExceptionIcms + '" data-row="' + rowExceptionIcms + '">' + productsSelect + '</td>\n\
<td class="edit_regra" data-type="icms" id="exception_icms_cfop_' + rowExceptionIcms + '" data-row="' + rowExceptionIcms + '" > ' + textcfop + '</td>\n\
<td class="edit_regra" data-type="icms" id="exception_icms_st_' + rowExceptionIcms + '" data-row="' + rowExceptionIcms + '">' + getSt('icms' + dados.icms_st) + '</td>\n\
<td class="nowrap">\n\
<input type="hidden" class="" id="icms_data_exception_' + rowExceptionIcms + '" name="icms_exception[]" value=\'' + JSON.stringify(dados) + '\'></input>\n\
<button class="btn btn-default btn-xs clonar_regra" data-type="icms" data-row="' + rowExceptionIcms + '" type="button" title="Clonar Regra"><i class="fa fa-fw fa-clone"></i></button>\n\
<button class="btn btn-default btn-xs btn-danger remove_regra" type="button" ><i class="fa fa-fw fa-remove"></i>\n\
</button>\n\
</td>\n\
</tr>');
rowExceptionIcms++;
} else {
$("#exception_icms_destiny_" + $('#modal_form #modal_update_row').val()).html(stateDestiny.substr(1));
$("#exception_icms_products_" + $('#modal_form #modal_update_row').val()).html(productsSelect);
$("#exception_icms_cfop_" + $('#modal_form #modal_update_row').val()).html(textcfop);
$("#exception_icms_st_" + $('#modal_form #modal_update_row').val()).html(getSt('icms' + dados.icms_st));
$("#icms_data_exception_" + $('#modal_form #modal_update_row').val()).val(JSON.stringify(dados));
}
} else if (dados.modal_type == 'ipi') {
if ($('#modal_form #modal_update_row').val() == '') {
$('#' + $('#modal_form #modal_update_table').val()).find('tbody')
.append('<tr>\n\
<td class="edit_regra" data-type="ipi" id="exception_ipi_destiny_' + rowExceptionIpi + '" data-row="' + rowExceptionIpi + '">' + stateDestiny.substr(1) + '</td>\n\
<td class="edit_regra" data-type="ipi" id="exception_ipi_products_' + rowExceptionIpi + '" data-row="' + rowExceptionIpi + '">' + productsSelect + '</td>\n\
<td class="edit_regra" data-type="ipi" id="exception_ipi_st_' + rowExceptionIpi + '" data-row="' + rowExceptionIpi + '">' + getSt("ipi" + dados.ipi_st) + '</td>\n\
<td class="nowrap">\n\
<input type="hidden" class="" id="ipi_data_exception_' + rowExceptionIpi + '" name="ipi_exception[]" value=\'' + JSON.stringify(dados) + '\'></input>\n\
<button class="btn btn-default btn-xs clonar_regra" data-type="ipi" data-row="' + rowExceptionIpi + '" type="button" title="Clonar Regra"><i class="fa fa-fw fa-clone"></i></button>\n\
<button class="btn btn-default btn-xs btn-danger remove_regra" type="button" ><i class="fa fa-fw fa-remove"></i>\n\
</button>\n\
</td>\n\
</tr>');
rowExceptionIpi++;
} else {
$("#exception_ipi_destiny_" + $('#modal_form #modal_update_row').val()).html(stateDestiny.substr(1));
$("#exception_ipi_products_" + $('#modal_form #modal_update_row').val()).html(productsSelect);
$("#exception_ipi_st_" + $('#modal_form #modal_update_row').val()).html(getSt("ipi" + dados.ipi_st));
$("#ipi_data_exception_" + $('#modal_form #modal_update_row').val()).val(JSON.stringify(dados));
}
} else if (dados.modal_type == 'issqn') {
if ($('#modal_form #modal_update_row').val() == '') {
$('#' + $('#modal_form #modal_update_table').val()).find('tbody')
.append('<tr>\n\
<td class="edit_regra" data-type="issqn" id="exception_issqn_destiny_' + rowExceptionIssqn + '" data-row="' + rowExceptionIssqn + '">' + stateDestiny.substr(1) + '</td>\n\
<td class="edit_regra" data-type="issqn" id="exception_issqn_products_' + rowExceptionIssqn + '" data-row="' + rowExceptionIssqn + '">' + productsSelect + '</td>\n\
<td class="edit_regra" data-type="issqn" id="exception_issqn_st_' + rowExceptionIssqn + '" data-row="' + rowExceptionIssqn + '">' + getSt("issqn" + dados.issqn_st) + '</td>\n\
<td class="nowrap">\n\
<input type="hidden" class="" id="issqn_data_exception_' + rowExceptionIssqn + '" name="issqn_exception[]" value=\'' + JSON.stringify(dados) + '\'></input>\n\
<button class="btn btn-default btn-xs clonar_regra" data-type="issqn" data-row="' + rowExceptionIssqn + '" type="button" title="Clonar Regra"><i class="fa fa-fw fa-clone"></i></button>\n\
<button class="btn btn-default btn-xs btn-danger remove_regra" type="button" ><i class="fa fa-fw fa-remove"></i>\n\
</button>\n\
</td>\n\
</tr>');
rowExceptionIssqn++;
} else {
$("#exception_issqn_destiny_" + $('#modal_form #modal_update_row').val()).html(stateDestiny.substr(1));
$("#exception_issqn_products_" + $('#modal_form #modal_update_row').val()).html(productsSelect);
$("#exception_issqn_st_" + $('#modal_form #modal_update_row').val()).html(getSt("issqn" + dados.issqn_st));
$("#issqn_data_exception_" + $('#modal_form #modal_update_row').val()).val(JSON.stringify(dados));
}
} else if (dados.modal_type == 'pis') {
if ($('#modal_form #modal_update_row').val() == '') {
$('#' + $('#modal_form #modal_update_table').val()).find('tbody')
.append('<tr>\n\
<td class="edit_regra" data-type="pis" id="exception_pis_destiny_' + rowExceptionPis + '" data-row="' + rowExceptionPis + '">' + stateDestiny.substr(1) + '</td>\n\
<td class="edit_regra" data-type="pis" id="exception_pis_products_' + rowExceptionPis + '" data-row="' + rowExceptionPis + '">' + productsSelect + '</td>\n\
<td class="edit_regra" data-type="pis" id="exception_pis_st_' + rowExceptionPis + '" data-row="' + rowExceptionPis + '">' + getSt("pis_cofins_" + dados.pis_st) + '</td>\n\
<td class="nowrap">\n\
<input type="hidden" class="" id="pis_data_exception_' + rowExceptionPis + '" name="pis_exception[]" value=\'' + JSON.stringify(dados) + '\'></input>\n\
<button class="btn btn-default btn-xs clonar_regra" data-type="pis" data-row="' + rowExceptionPis + '" type="button" title="Clonar Regra"><i class="fa fa-fw fa-clone"></i></button>\n\
<button class="btn btn-default btn-xs btn-danger remove_regra" type="button" ><i class="fa fa-fw fa-remove"></i>\n\
</button>\n\
</td>\n\
</tr>');
rowExceptionPis++;
} else {
$("#exception_pis_destiny_" + $('#modal_form #modal_update_row').val()).html(stateDestiny.substr(1));
$("#exception_pis_products_" + $('#modal_form #modal_update_row').val()).html(productsSelect);
$("#exception_pis_st_" + $('#modal_form #modal_update_row').val()).html(getSt("pis_cofins_" + dados.pis_st));
$("#pis_data_exception_" + $('#modal_form #modal_update_row').val()).val(JSON.stringify(dados));
}
} else if (dados.modal_type == 'cofins') {
if ($('#modal_form #modal_update_row').val() == '') {
$('#' + $('#modal_form #modal_update_table').val()).find('tbody')
.append('<tr>\n\
<td class="edit_regra" data-type="cofins" id="exception_cofins_destiny_' + rowExceptionCofins + '" data-row="' + rowExceptionCofins + '">' + stateDestiny.substr(1) + '</td>\n\
<td class="edit_regra" data-type="cofins" id="exception_cofins_products_' + rowExceptionCofins + '" data-row="' + rowExceptionCofins + '">' + productsSelect + '</td>\n\
<td class="edit_regra" data-type="cofins" id="exception_cofins_st_' + rowExceptionCofins + '" data-row="' + rowExceptionCofins + '">' + getSt("pis_cofins_" + dados.cofins_st) + '</td>\n\
<td class="nowrap">\n\
<input type="hidden" class="" id="cofins_data_exception_' + rowExceptionCofins + '" name="cofins_exception[]" value=\'' + JSON.stringify(dados) + '\'></input>\n\
<button class="btn btn-default btn-xs clonar_regra" data-type="cofins" data-row="' + rowExceptionCofins + '" type="button" title="Clonar Regra"><i class="fa fa-fw fa-clone"></i></button>\n\
<button class="btn btn-default btn-xs btn-danger remove_regra" type="button" ><i class="fa fa-fw fa-remove"></i>\n\
</button>\n\
</td>\n\
</tr>');
rowExceptionCofins++;
} else {
$("#exception_cofins_destiny_" + $('#modal_form #modal_update_row').val()).html(stateDestiny.substr(1));
$("#exception_cofins_products_" + $('#modal_form #modal_update_row').val()).html(productsSelect);
$("#exception_cofins_st_" + $('#modal_form #modal_update_row').val()).html(getSt("pis_cofins_" + dados.cofins_st));
$("#cofins_data_exception_" + $('#modal_form #modal_update_row').val()).val(JSON.stringify(dados));
}
}else if (dados.modal_type == 'simples') {
var textcfop = '';
if (dados.simples_cfop !== undefined) {
textcfop = dados.simples_cfop;
}
if ($('#modal_form #modal_update_row').val() == '') {
$('#' + $('#modal_form #modal_update_table').val()).find('tbody')
.append('<tr>\n\
<td class="edit_regra" data-type="simples" id="exception_simples_destiny_' + rowExceptionSimples + '" data-row="' + rowExceptionSimples + '">' + stateDestiny.substr(1) + '</td>\n\
<td class="edit_regra" data-type="simples" id="exception_simples_products_' + rowExceptionSimples + '" data-row="' + rowExceptionSimples + '">' + productsSelect + '</td>\n\
<td class="edit_regra" data-type="simples" id="exception_simples_cfop_' + rowExceptionSimples + '" data-row="' + rowExceptionSimples + '" > ' + textcfop + '</td>\n\
<td class="edit_regra" data-type="simples" id="exception_simples_st_' + rowExceptionSimples + '" data-row="' + rowExceptionSimples + '">' + getSt('simples' + dados.simples_st) + '</td>\n\
<td class="nowrap">\n\
<input type="hidden" class="" id="simples_data_exception_' + rowExceptionSimples + '" name="simples_exception[]" value=\'' + JSON.stringify(dados) + '\'></input>\n\
<button class="btn btn-default btn-xs clonar_regra" data-type="simples" data-row="' + rowExceptionSimples + '" type="button" title="Clonar Regra"><i class="fa fa-fw fa-clone"></i></button>\n\
<button class="btn btn-default btn-xs btn-danger remove_regra" type="button" ><i class="fa fa-fw fa-remove"></i>\n\
</button>\n\
</td>\n\
</tr>');
rowExceptionSimples++;
} else {
$("#exception_simples_destiny_" + $('#modal_form #modal_update_row').val()).html(stateDestiny.substr(1));
$("#exception_simples_products_" + $('#modal_form #modal_update_row').val()).html(productsSelect);
$("#exception_simples_cfop_" + $('#modal_form #modal_update_row').val()).html(textcfop);
$("#exception_simples_st_" + $('#modal_form #modal_update_row').val()).html(getSt('simples' + dados.simles_st));
$("#simples_data_exception_" + $('#modal_form #modal_update_row').val()).val(JSON.stringify(dados));
}
}
$modal.modal('hide');
});
}
$('.table tbody').on('click', 'tr .edit_regra', function (e) {
var array = JSON.parse($("#" + $(this).attr('data-type') + "_data_exception_" + $(this).attr('data-row')).val());
var select = $(this).attr('data-row');
$modal.load(_url + 'nature_operation/modal_exception/', {type: array.modal_type, title: array.modal_title, exception: $("#" + $(this).attr('data-type') + "_data_exception_" + $(this).attr('data-row')).val()}, function () {
$modal.modal();
$('#modal_form #modal_type').val(array.modal_type);
$('#modal_form #modal_update_row').val(select);
$('#modal_form #modal_update_table').val(array.modal_update_table);
prepareFormException();
});
});
$('.table tbody').on('click', 'tr td .clonar_regra', function (e) {
var array = JSON.parse($("#" + $(this).attr('data-type') + "_data_exception_" + $(this).attr('data-row')).val());
var select = $(this).attr('data-row');
$modal.load(_url + 'nature_operation/modal_exception/', {type: array.modal_type, title: array.modal_title, exception: $("#" + $(this).attr('data-type') + "_data_exception_" + $(this).attr('data-row')).val()}, function () {
$modal.modal();
$('#modal_form #modal_type').val(array.modal_type);
$('#modal_form #modal_update_table').val(array.modal_update_table);
prepareFormException();
});
});
$('.table tbody').on('click', 'tr td .remove_regra', function (e) {
$(this).closest('tr').remove();
});
loadProducts();
function loadProducts() {
//carrega os segmentos
$.getJSON($("#_url").val() + 'ps/ajax-list', function (j) {
optionsProducts = j
});
}
;
function getProduct(value) {
vari = 0;
for (i = 0; i < optionsProducts.length; i++) {
if (optionsProducts[i].id == value) {
return optionsProducts[i].text;
}
}
return "";
}
loadState();
function loadState() {
//carrega os segmentos
$.getJSON($("#_url").val() + 'ajax/state-list', function (j) {
states = j;
});
}
;
function getState(value) {
vari = 0;
for (i = 0; i < states.length; i++) {
if (states[i].id == value) {
return states[i].uf_state;
}
}
return "";
}
function getSt(val) {
switch (val + "") {
case 'icms00':
return _L['00 - Fully taxed'];
break;
case 'icms10':
return _L['10 - Taxed and with ICMS tax collection for tax substitution'];
break;
case 'icms20':
return _L['20 - With reduction of base of calculation'];
break;
case 'icms30':
return _L['30 - Exempt or not taxed and with ICMS tax collection for tax substitution'];
break;
case 'icms40':
return _L['40 - Exempt'];
break;
case 'icms41':
return _L['41 - Not taxed'];
break;
case 'icms50':
return _L['50 - Suspension'];
break;
case 'icms51':
return _L['51 - Deferral'];
break;
case 'icms60':
return _L['60 - ICMS charged previously for tax substitution'];
break;
case 'icms70':
return _L['70 - With reduction of calculation base and collection of ICMS by tax substitution'];
break;
case 'icms90':
return _L['90 - Other'];
break;
case 'ipi50':
return _L['50 - Taxable income'];
break;
case 'ipi51':
return _L['51 - Taxed income with zero rate'];
break;
case 'ipi52':
return _L['52 - Exempt output'];
break;
case 'ipi53':
return _L['53 - Non-taxable outflow'];
break;
case 'ipi54':
return _L['54 - Immune output'];
break;
case 'ipi55':
return _L['55 - Output with suspension'];
break;
case 'ipi99':
return _L['99 - Other exits'];
break;
case 'ipiZZ':
return _L['Presumed'];
break;
case 'issqn00':
return _L['Taxed'];
break;
case 'issqn01':
return _L['Exempt'];
break;
case 'issqn02':
return _L['Other situation'];
break;
case "pis_cofins_01" :
return "01 - Operação tributável (alíquota normal, cumulativo ou não)";
break;
case "pis_cofins_02" :
return "02 - Operação tributável (alíquota diferenciada)";
break;
case "pis_cofins_03" :
return "03 - Operação tributável (alíquota por unidade de produto)";
break;
case "pis_cofins_04" :
return "04 - Operação tributável (tributação monofásica, alíquota zero)";
break;
case "pis_cofins_05" :
return "05 - Operação Tributável (Substituição Tributária)";
break;
case "pis_cofins_06" :
return "06 - Operação tributável (alíquota zero)";
break;
case "pis_cofins_07" :
return "07 - Operação isenta da contribuição";
break;
case "pis_cofins_08" :
return "08 - Operação sem incidência da contribuição";
break;
case "pis_cofins_09" :
return "09 - Operação com suspensão da contribuição";
break;
case "pis_cofins_49" :
return "49 - Outras Operações de Saída";
break;
case "pis_cofins_50" :
return "50 - Operação com Direito a Crédito - Vinculada Exclusivamente a Receita Tributada no Mercado Interno";
break;
case "pis_cofins_51" :
return "51 - Operação com Direito a Crédito – Vinculada Exclusivamente a Receita Não Tributada no Mercado Interno";
break;
case "pis_cofins_52" :
return "52 - Operação com Direito a Crédito - Vinculada Exclusivamente a Receita de Exportação";
break;
case "pis_cofins_53" :
return "53 - Operação com Direito a Crédito - Vinculada a Receitas Tributadas e Não-Tributadas no Mercado Interno";
break;
case "pis_cofins_54" :
return "54 - Operação com Direito a Crédito - Vinculada a Receitas Tributadas no Mercado Interno e de Exportação";
break;
case "pis_cofins_55" :
return "55 - Operação com Direito a Crédito - Vinculada a Receitas Não-Tributadas no Mercado Interno e de Exportação";
break;
case "pis_cofins_56" :
return "56 - Operação com Direito a Crédito - Vinculada a Receitas Tributadas e Não-Tributadas no Mercado Interno, e de Exportação";
break;
case "pis_cofins_60" :
return "60 - Crédito Presumido - Operação de Aquisição Vinculada Exclusivamente a Receita Tributada no Mercado Interno";
break;
case "pis_cofins_61" :
return "61 - Crédito Presumido - Operação de Aquisição Vinculada Exclusivamente a Receita Não-Tributada no Mercado Interno";
break;
case "pis_cofins_62" :
return "62 - Crédito Presumido - Operação de Aquisição Vinculada Exclusivamente a Receita de Exportação";
break;
case "pis_cofins_63" :
return "63 - Crédito Presumido - Operação de Aquisição Vinculada a Receitas Tributadas e Não-Tributadas no Mercado Interno";
break;
case "pis_cofins_64" :
return "64 - Crédito Presumido - Operação de Aquisição Vinculada a Receitas Tributadas no Mercado Interno e de Exportação";
break;
case "pis_cofins_65" :
return "65 - Crédito Presumido - Operação de Aquisição Vinculada a Receitas Não-Tributadas no Mercado Interno e de Exportação";
break;
case "pis_cofins_66" :
return "66 - Crédito Presumido - Operação de Aquisição Vinculada a Receitas Tributadas e Não-Tributadas no Mercado Interno, e de Exportação";
break;
case "pis_cofins_67" :
return "67 - Crédito Presumido - Outras Operações";
break;
case "pis_cofins_70" :
return "70 - Operação de Aquisição sem Direito a Crédito";
break;
case "pis_cofins_71" :
return "71 - Operação de Aquisição com Isenção";
break;
case "pis_cofins_72" :
return "72 - Operação de Aquisição com Suspensão";
break;
case "pis_cofins_73" :
return "73 - Operação de Aquisição a Alíquota Zero";
break;
case "pis_cofins_74" :
return "74 - Operação de Aquisição sem Incidência da Contribuição";
break;
case "pis_cofins_75" :
return "75 - Operação de Aquisição por Substituição Tributária";
break;
case "pis_cofins_98" :
return "98 - Outras Operações de Entrada";
break;
case "pis_cofins_99" :
return "99 - Outras operações";
break;
case "simples101" :
return "101 - Tributada com permissão de crédito";
break;
case "simples102" :
return "102 - Tributada sem permissão de crédito";
break;
case "simples103" :
return "103 - Isenção do ICMS para faixa de receita bruta";
break;
case "simples201" :
return "201 - Tributada com permissão de crédito e com cobrança do ICMS por ST";
break;
case "simples202" :
return "202 - Tributada sem permissão de crédito e com cobrança do ICMS por ST";
break;
case "simples203" :
return "203 - Isenção do ICMS para faixa de receita bruta e com cobrança do ICMS por ST";
break;
case "simples300" :
return "300 - Imune";
break;
case "simples400" :
return "400 - Não tributada";
break;
case "simples500" :
return "500 - ICMS cobrado anteriormente por ST ou por antecipação";
break;
case "simples900" :
return "900 - Outros";
break;
default :
return '';
}
}
});