function calc_subtot(event)
{
     var tpre;
     var cant,puni,dcto,iva,ice,irbp,pvp;
     var subtot,tdcto,tice,tiva,tirbp,subtot,total;
     var efectivo,tarjeta,anticipo,transf,cambio;
     
     if(document.getElementById("tpre")){tpre=document.getElementById("tpre").value ||0;}
     
     if(document.getElementById("cant")){cant=document.getElementById("cant").value ||0;}
     if(document.getElementById("pvp")){pvp=document.getElementById("pvp").value ||0;}
     
     if(document.getElementById("dcto")){dcto=document.getElementById("dcto").value ||0;}
     if(document.getElementById("iva")){iva=document.getElementById("iva").value ||0;}
     if(document.getElementById("ice")){ice=document.getElementById("ice").value ||0;}
     if(document.getElementById("irbp")){irbp=document.getElementById("irbp").value ||0;}
     
     if(tpre==2)
     {
          puni=pvp/(1+iva/100);
          if(document.getElementById("puni")){document.getElementById("puni").value=parseFloat(puni);}
     }
     if(document.getElementById("puni")){puni=document.getElementById("puni").value ||0;}
     if(document.getElementById("subtot")){subtot=document.getElementById("subtot").value ||0;}
     if(document.getElementById("total")){total=document.getElementById("total").value ||0;}
     if(document.getElementById("anticipo")){tarjeta=document.getElementById("anticipo").value ||0;}
     if(document.getElementById("efectivo")){efectivo=document.getElementById("efectivo").value ||0;}
     if(document.getElementById("tarjeta")){tarjeta=document.getElementById("tarjeta").value ||0;}
     if(document.getElementById("transf")){tarjeta=document.getElementById("transf").value ||0;}
     
     subtot=puni;
     tdcto=subtot*dcto/100;
     tice=subtot*ice/100;
     subtot=subtot-tdcto+tice;
     tiva=subtot*iva/100;
     tirbp=cant*irbp;
     subtot=subtot+tiva;
     
     pvp=subtot;
     pvp=pvp.toFixed(2);
     
     subtot=subtot*cant;
     subtot=subtot.toFixed(2);
     
     if(total==0){total=subtot;}
     
     cambio=0;
//      if(efectivo>total && total>0)
     if(parseFloat(efectivo)>parseFloat(total) && parseFloat(total)>0)
     {cambio=efectivo-total;}
     
     if(document.getElementById("pvp")){document.getElementById("pvp").value=parseFloat(pvp);}
     if(document.getElementById("subtot")){document.getElementById("subtot").value=parseFloat(subtot);}

     console.log(total);
     console.log(efectivo);
     console.log(cambio);
     
     
     if(document.getElementById("cambio"))
     {
          document.getElementById("cambio").value=cambio.toFixed(2);
          document.getElementById('cambio').style.color='navy';
          document.getElementById('cambio').style.fontSize='1.2em';
          document.getElementById('cambio_ele').setAttribute("hide","");
          if(cambio>0)
          {
               document.getElementById('cambio').style.color='darkred';
               document.getElementById('cambio_ele').removeAttribute("hide");
          }
     }

     

}
