Skip to content

Instantly share code, notes, and snippets.

@andersonfreitas
Last active January 11, 2017 17:10
Show Gist options
  • Save andersonfreitas/45a94e97f441ba749a3e to your computer and use it in GitHub Desktop.
Save andersonfreitas/45a94e97f441ba749a3e to your computer and use it in GitHub Desktop.
<p>Bookmarklet: <a href="javascript:(function()%7Bfunction%20callback()%7BcalcImpostos()%7Dvar%20s%3Ddocument.createElement(%22script%22)%3Bs.src%3D%22https%3A%2F%2Fgist.githubusercontent.com%2Fandersonfreitas%2F45a94e97f441ba749a3e%2Fraw%2Fnfe-impostos.js%22%3Bif(s.addEventListener)%7Bs.addEventListener(%22load%22%2Ccallback%2Cfalse)%7Delse%20if(s.readyState)%7Bs.onreadystatechange%3Dcallback%7Ddocument.body.appendChild(s)%3B%7D)()" class="bookmarklet">Impostos NF-e</a></p>
var calcImpostos = function() {
var valorString = $("#ctl00_body_tbValor").val();
var valor = parseFloat(valorString.replace(".", "").replace(",", "."));
var irrf = 0.015 * valor; // 1.5%
var csll = 0.01 * valor; // 1.0%
var cofins = 0.03 * valor; // 3.0%
var pis = 0.0065 * valor; // 0.65%
irrf = irrf.toFixed(2).replace(".", "");
csll = csll.toFixed(2).replace(".", "");
cofins = cofins.toFixed(2).replace(".", "");
pis = pis.toFixed(2).replace(".", "");
$("#ctl00_body_tbIRRF").val(FmtValorMonetario(irrf));
$("#ctl00_body_tbCSLL").val(FmtValorMonetario(csll));
$("#ctl00_body_tbCOFINS").val(FmtValorMonetario(cofins));
$("#ctl00_body_tbPISPASEP").val(FmtValorMonetario(pis));
}
@andersonfreitas
Copy link
Author

Substitua a URL por:
https://rawgit.com/andersonfreitas/45a94e97f441ba749a3e/raw/nfe-impostos.js

No FF 50.1 começou a dar erro "blocked due to MIME type mismatch (X-Content-Type-Options: nosniff)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment