PageSourceSearch

https://grapco-capex-infraestructura.web.app/assets/FormulaPolinomica-CmoqaNow.js

js grapco-capex-infraestructura.web.app collected 2026-10-10 02:43:18 UTC 7,631 bytes, 1 lines download raw bytes

1import{r as n,j as s}from"./react-D6tooQTO.js";import{c as H,bs as Q,bt as V,bu as W,bv as X,bw as A,bx as F,s as w,by as Y,bz as Z,n as j,bA as $,bB as ss}from"./libs-BAvXY5Vg.js";import{I as K}from"./index-DyJXeE6k.js";import"./firebase-C582-8Fb.js";const O="grapco_polinomica",l=()=>`m${Date.now().toString(36)}${Math.floor(Math.random()*1e4).toString(36)}`,es=()=>{try{return JSON.parse(localStorage.getItem(O)||"null")}catch{return null}},as=C=>{try{localStorage.setItem(O,JSON.stringify(C))}catch{}},os=[{id:l(),desc:"Mano de obra",simbolo:"47",a:.3,io:100,ir:100},{id:l(),desc:"Cemento",simbolo:"21",a:.2,io:100,ir:100},{id:l(),desc:"Acero",simbolo:"03",a:.15,io:100,ir:100},{id:l(),desc:"Agregados",simbolo:"05",a:.1,io:100,ir:100},{id:l(),desc:"Maquinaria y equipo",simbolo:"48",a:.1,io:100,ir:100},{id:l(),desc:"Gastos generales / varios",simbolo:"39",a:.15,io:100,ir:100}];function rs({base:C}){H();const p=es(),[i,R]=n.useState(()=>p?.mono||os),[b,z]=n.useState(()=>p?.monto??""),M=(e=i,a=b)=>as({mono:e,monto:a}),c=e=>{R(e),M(e)},d=(e,a,o)=>c(i.map(t=>t.id===e?{...t,[a]:a==="desc"||a==="simbolo"?o:o===""?"":Number(o)}:t)),J=()=>c([...i,{id:l(),desc:"Nuevo monomio",simbolo:"",a:0,io:100,ir:100}]),q=e=>c(i.filter(a=>a.id!==e)),m=Q(i),T=()=>{m&&c(Y(i))},{K:r,aportes:N}=n.useMemo(()=>({K:W(i),aportes:V(i)}),[i]),{reajustado:B,reajuste:g}=Z(b,r),[h,G]=n.useState(X),u=A(h),[v,k]=n.useState(u[0]||""),[f,S]=n.useState(u[u.length-1]||""),[L,I]=n.useState(!1),[y,U]=n.useState(""),P=()=>{if(!v||!f){j("Elige mes base y mes actual.","error");return}let e=0;const a=[],o=i.map(t=>{const x=$(h,v,t.simbolo),E=$(h,f,t.simbolo);return x!=null&&E!=null?(e++,{...t,io:x,ir:E}):(t.simbolo&&a.push(t.simbolo),t)});c(o),j(e?`Índices aplicados a ${e} monomio(s)${a.length?` · sin IU ${a.join(", ")}`:""}.`:"No hay índices para esos códigos IU.",e?"ok":"error")},D=()=>{U(JSON.stringify(h,null,2)),I(!0)},_=()=>{try{const e=JSON.parse(y);if(!e||typeof e!="object")throw new Error("formato");ss(e),G(e);const a=A(e);k(a[0]||""),S(a[a.length-1]||""),I(!1),j("Tabla de índices IU guardada.","ok")}catch{j('JSON inválido. Revisa el formato { "2026-06": { "47": 106.5, … } }.',"error")}};return s.jsxs("div",{className:"polinomica",children:[s.jsxs("p",{className:"hint",children:["Reajuste de precios por ",s.jsx("b",{children:"Fórmula Polinómica"})," (Índices Unificados de Construcción). El factor",s.jsx("b",{children:" K = Σ a·(Ir/Io)"}
1),": coeficiente × índice actual / índice base. Los coeficientes deben sumar ",s.jsx("b",{children:"1.0000"}),"."]}),s.jsxs("div",{className:"iu-bar",children:[s.jsx("span",{className:"iu-lbl",children:"Índices INEI (IU)"}),s.jsxs("label",{children:["Mes base",s.jsx("select",{value:v,onChange:e=>k(e.target.value),children:u.map(e=>s.jsx("option",{value:e,children:F(e)},e))})]}),s.jsx("span",{className:"iu-arrow",children:"→"}),s.jsxs("label",{children:["Mes actual",s.jsx("select",{value:f,onChange:e=>S(e.target.value),children:u.map(e=>s.jsx("option",{value:e,children:F(e)},e))})]}),s.jsx("button",{className:"btn-ghost sm",onClick:P,children:"↧ Autollenar Io/Ir"}),s.jsxs("button",{className:"btn-ghost sm",onClick:D,children:[s.jsx(K,{n:"lapiz",s:14})," Editar índices"]})]}),L&&s.jsxs("div",{className:"iu-editor",children:[s.jsxs("p",{className:"hint",children:["Pega los ",s.jsx("b",{children:"Índices Unificados"})," de INEI por mes. Formato: ",s.jsx("code",{children:'{ "2026-06": { "47": 106.5, "21": 103.2, … } }'})," · Códigos IU: 47 MO · 21 Cemento · 03 Acero · 05 Agregados · 48 Maquinaria · 39 General."]}),s.jsx("textarea",{className:"cons-prompt-ta",value:y,onChange:e=>U(e.target.value),rows:7}),s.jsxs("div",{className:"iu-editor-acc",children:[s.jsx("button",{className:"btn-primario",onClick:_,children:"Guardar índices"}),s.jsx("button",{className:"btn-sec",onClick:()=>I(!1),children:"Cancelar"})]})]}),s.jsx("div",{className:"cot-tabla-wrap poli-tbl",children:s.jsxs("table",{className:"tabla",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Monomio"}),s.jsx("th",{children:"I.U."}),s.jsx("th",{className:"r",children:"Coef. (a)"}),s.jsx("th",{className:"r",children:"Índice base (Io)"}),s.jsx("th",{className:"r",children:"Índice actual (Ir)"}),s.jsx("th",{className:"r",children:"Ir/Io"}),s.jsx("th",{className:"r",children:"Aporte"}),s.jsx("th",{})]})}),s.jsxs("tbody",{children:[i.map((e,a)=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx("input",{className:"cons-inp",value:e.desc,onChange:o=>d(e.id,"desc",o.target.value)})}),s.jsx("td",{children:s.jsx("input",{className:"cons-inp xs",value:e.simbolo,onChange:o=>d(e.id,"simbolo",o.target.value)})}),s.jsx("td",{className:"r",children:s.jsx("input",{className:"cel-num xs",type:"number",step:"0.01",value:e.a,onChange:o=>d(e.id,"a",o.target.value)})}),s.jsx("td",{className:"r",children:s.jsx("input",{className:"cel-num xs",type:"number",value:e.io,onChange:o=>d(e.id,"io",o.target.value)})}),s.jsx("td",{className:"r",children:s.jsx("input",{className:"cel-num xs",type:"number",value:e.ir,onChange:o=>d(e.id,"ir",o.target.value)})}),s.jsx("td",{className:"r mut",children:((Number(e.ir)||0)/(Number(e.io)||1)).toFixed(4)}),s.jsx("td",{className:"r",children:N[a].toFixed(4)}),s.jsx("td",{children:s.jsx("button",{className:"cel-x",onClick:()=>q(e.id),children:"×"})})]},e.id)),s.jsxs("tr",{className:"fila-strong",children:[s.jsx("td",{colSpan:2,children:"Suma de coeficientes"}),s.jsx("td",{className:`r ${Math.abs(m-1)>.001?"cambiado":""}`,children:m.toFixed(4)}),s.jsx("td",{colSpan:3}),s.jsxs("td",{className:"r",children:["K = ",r.toFixed(4)]}),s.jsx("td",{})]})]})]})}),r>0&&s.jsxs("div",{className:"poli-chart",children:[s.jsxs("div",{className:"rec-card-h",children:["Aporte al factor K ",s.jsx("span",{className:"mut",children:"· qué índices mueven el reajuste"})]}),s.jsx("div",{className:"rk-list",children:i.map((e,a)=>({m:e,ap:N[a]})).sort((e,a)=>a.ap-e.ap).map(({m:e,ap:a},o)=>{const t=Math.max(...N,1e-4),x=r?a/r*100:0;return s.jsxs("div",{className:"rk-item",children:[s.jsxs("div",{className:"rk-top",children:[s.jsx("span",{className:"rk-rank",children:o+1}),s.jsxs("span",{className:"rk-name",title:e.desc,children:[e.desc,e.simbolo&&s.jsxs("span",{className:"mut",children:[" · IU ",e.simbolo]})]}),s.jsxs("span",{className:"rk-val",children:[a.toFixed(4)," ",s.jsxs("i",{className:"rk-u",children:[x.toFixed(0),"%"]})]})]}),s.jsx("div",{className:"rk-track",children:s.jsx("span",{className:"rk-fill",style:{width:`${Math.max(3,a/t*100)}%`}})})]},e.id)})})]}),s.jsxs("div",{className:"poli-acc",children:[s.jsx("button",{className:"btn-ghost sm",onClick:J,children:"+ Monomio"}),Math.abs(m-1)>.001&&s.jsx("button",{className:"btn-ghost sm",onClick:T,children:"Normalizar a 1.0000"}),Math.abs(m-1)>.001&&s.jsxs("span",{className:"poli-warn",children:[s.jsx(K,{n:"aviso",s:14}
1)," Los coeficientes deben sumar 1.0000"]})]}),s.jsxs("div",{className:"poli-result",children:[s.jsxs("div",{className:"poli-monto",children:[s.jsx("label",{children:"Monto a reajustar (S/.)"}),s.jsx("input",{type:"number",value:b,onChange:e=>{z(e.target.value),M(i,e.target.value)},placeholder:"Ej. 1 250 000"})]}),s.jsxs("div",{className:"poli-k",children:[s.jsx("span",{children:"Factor K"}),s.jsx("b",{children:r.toFixed(4)})]}),s.jsxs("div",{className:"poli-rj",children:[s.jsx("span",{children:"Reajuste"}),s.jsxs("b",{className:g>=0?"up":"down",children:[g>=0?"+":"",w(g)]})]}),s.jsxs("div",{className:"poli-total",children:[s.jsx("span",{children:"Monto reajustado"}),s.jsx("b",{children:w(B)})]})]})]})}export{rs as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.