1import{a as de}from"./chunk-EWAYIMW7.js";import{a as it,b as fe,c as nt}from"./chunk-BSTYCAOR.js";import{a as se}from"./chunk-CHREDB3M.js";import{b as _e}from"./chunk-ONHJFHVL.js";import{a as re,d as le}from"./chunk-44AQN4J5.js";import{a as ae}from"./chunk-NSOZJJAW.js";import"./chunk-T7P7VUUB.js";import{a as et,b as tt}from"./chunk-YJ2KJ4P4.js";import"./chunk-65F53KNY.js";import"./chunk-H3HBDFN2.js";import"./chunk-EKM4FESO.js";import"./chunk-D6NVHQTR.js";import"./chunk-7XKIDQ66.js";import"./chunk-U2JC7MTA.js";import{a as We,b as Je,c as Qe,d as Xe,e as Ze}from"./chunk-YJEFWXPF.js";import"./chunk-G7CFJB5Y.js";import"./chunk-UQQVBTQR.js";import"./chunk-VNTIDOTL.js";import"./chunk-TFEWX4QM.js";import"./chunk-YCXAUP55.js";import"./chunk-JS7GI73G.js";import"./chunk-XEQORRAJ.js";import"./chunk-OE5AIQI5.js";import"./chunk-C4O65C37.js";import"./chunk-PVDG46DZ.js";import{Aa as Oe,Ca as Ye,Da as Ke,Ga as ze,Rb as Ge}from"./chunk-CF3GM535.js";import"./chunk-R2BFX75A.js";import"./chunk-44TLPJAW.js";import{t as Ue}from"./chunk-7LKKCJYU.js";import"./chunk-P5HUJZVF.js";import"./chunk-G7Q633Y4.js";import{a as Q,s as X,z as Z}from"./chunk-EIYPZSIE.js";import{Na as $e,Oa as Ne,Qa as qe,_a as Ae,ab as oe,hb as He,jb as je}from"./chunk-QZCS7IX6.js";import{Cc as Pe,Cd as Me,Cf as Re,Df as Le,Fa as l,Fd as Ie,Gf as Ve,Jb as B,K as Ee,Kb as Te,Mb as s,Nb as y,Ob as f,Pb as N,Ra as $,S as Fe,Tb as G,Ub as W,Uf as te,Vb as J,Vf as ie,Xa as R,Yf as ge,Zf as ne,ab as D,bc as q,ca as E,cb as m,dc as pe,eb as u,fa as w,ga as S,hb as j,ib as U,if as A,jb as C,kb as a,kc as p,lb as r,mb as h,mc as g,oa as P,pc as k,q as H,qf as O,rf as De,sc as b,tb as M,tc as z,uf as Y,v as ue,vb as v,wf as K,xb as d,yc as V,yf as ee,z as ke}from"./chunk-3JJIIS3U.js";import{a as Se,b as Be}from"./chunk-SI3YDIW4.js";var gt=(t,o)=>o.key;function _t(t,o){t&1&&(a(0,"div",2),h(1,"i",11),a(2,"span"),s(3,"H\xE4mtar periodisering..."),r()())}function ft(t,o){t&1&&(a(0,"div",3),s(1,"Periodiseringen kunde inte laddas."),r())}function bt(t,o){if(t&1&&(a(0,"div",12)(1,"label",13),s(2),r(),h(3,"p-inputNumber",14),r()),t&2){let e=o.$implicit;l(),C("for","period-"+e.key),l(),y(e.label),l(),C("inputId","period-"+e.key)("formControlName",e.key)("min",0)("maxFractionDigits",0)("showButtons",!1)}}function Ct(t,o){if(t&1&&(a(0,"div",4),j(1,bt,4,7,"div",12,gt),r()),t&2){let e=d();C("formGroup",e.form),l(),U(e.months)}}var be=(()=>{class t{constructor(){this.budgetService=E(de),this.sharedService=E(oe),this.data=E(Ne),this.dialogRef=E($e),this.months=[{key:"1",label:"Jan"},{key:"2",label:"Feb"},{key:"3",label:"Mars"},{key:"4",label:"April"},{key:"5",label:"Maj"},{key:"6",label:"Juni"},{key:"7",label:"Juli"},{key:"8",label:"Aug"},{key:"9",label:"Sep"},{key:"10",label:"Okt"},{key:"11",label:"Nov"},{key:"12",label:"Dec"}],this.form=new Y(Object.fromEntries(this.months.map(e=>[e.key,new K(1)]))),this.original=this.form.getRawValue(),this.periodsResource=ne({stream:()=>this.loadPeriods()}),this.applyLoadedEffect=z(()=>{let e=this.periodsResource.value();if(!e)return;let i={};for(let n of e)n.month>=1&&n.month<=12&&(i[String(n.month)]=n.value);this.form.patchValue(i),this.original=this.form.getRawValue()}),this.dialogRef.disableClose=!0}loadPeriods(){let e=this.data.target;return e.kind==="account"?this.budgetService.getAccountPeriods(e.budgetId,e.account).pipe(H(i=>i.periods??[])):this.budgetService.getLiquidityPeriods(e.budgetId,e.fieldId)}restore(){this.form.setValue(this.original)}resetToDefault(){this.form.setValue(Object.fromEntries(this.months.map(e=>[e.key,1])))}save(){let e=this.data.target,i=this.toWeights(this.form.getRawValue()),n=e.kind==="account"?this.budgetService.saveAccountPeriods(e.budgetId,e.account,i):this.budgetService.saveLiquidityPeriods(Be(Se({},i),{liquidityBudgetFieldId:e.fieldId,budgetId:e.budgetId}));this.sharedService.appLoader({show:!0}),n.pipe(Ee(()=>this.sharedService.appLoader({show:!1}))).subscribe({next:()=>{this.sharedService.openSnackBar({status:"success",message:"Periodiseringen sparades"}),this.data.onSaved(),this.dialogRef.close("saved")},error:()=>{this.sharedService.openSnackBar({status:"error",message:"Periodiseringen kunde inte sparas"})}})}toWeights(e){let i={};for(let[n,c]of Object.entries(e))i[n]=c??0;return i}static{this.\u0275fac=function(i){return new(i||t)}}static{this.\u0275cmp=$({type:t,selectors:[["app-financial-budget-periodise"]],decls:13,vars:5,consts:[[1,"mb-1","text-lg","font-semibold"],[1,"mb-6","text-sm","text-gray-500"],[1,"flex","items-center","gap-2","py-6"],[1,"rounded-lg","border","border-red-200","bg-red-50","p-4","text-red-700"],[1,"grid","grid-cols-2","gap-4","sm:grid-cols-3","lg:grid-cols-6",3,"formGroup"],[1,"mt-8","flex","flex-wrap","items-center","justify-between","gap-2"],[1,"flex","flex-wrap","gap-2"],["label","St\xE4ng","severity","secondary","variant","outlined","data-test","periodise-close",3,"onClick"],["label","\xC5terst\xE4ll","severity","secondary","variant","outlined","data-test","periodise-restore",3,"onClick","disabled"],["label","Nollst\xE4ll","severity","secondary","variant","outlined","data-test","periodise-reset",3,"onClick","disabled"],["label","Spara","severity","primary","data-test","periodise-save",3,"onClick","disabled"],["aria-hidden","true",1,"fa","fa-spinner","fa-spin"],[1,"flex","flex-col","gap-1"],[1,"text-sm","text-gray-600",3,"for"],["locale","sv-SE","inputStyleClass","periodise-input",3,"inputId","formControlName","min","maxFractionDigits","showButtons"]],template:function(i,n){i&1&&(a(0,"h2",0),s(1),r(),a(2,"p",1),s(3," Genom att l\xE4gga in siffror i tabellen nedan kan du peri
1odisera beloppet \xF6ver m\xE5naderna. Standard \xE4r att alla m\xE5nader har v\xE4rdet 1 \u2013 d\xE5 f\xE5r varje m\xE5nad 1/12 av \xE5rsbudgeten. \xC4ndra siffrorna f\xF6r att vikta om beloppet mellan m\xE5naderna. "),r(),m(4,_t,4,0,"div",2)(5,ft,2,0,"div",3)(6,Ct,3,1,"div",4),a(7,"div",5)(8,"div",6)(9,"oc-p-button",7),v("onClick",function(){return n.dialogRef.close()}),r(),a(10,"oc-p-button",8),v("onClick",function(){return n.restore()}),r(),a(11,"oc-p-button",9),v("onClick",function(){return n.resetToDefault()}),r()(),a(12,"oc-p-button",10),v("onClick",function(){return n.save()}),r()()),i&2&&(l(),y(n.data.title),l(3),u(n.periodsResource.isLoading()?4:n.periodsResource.error()?5:6),l(6),C("disabled",n.periodsResource.isLoading()||!!n.periodsResource.error()),l(),C("disabled",n.periodsResource.isLoading()||!!n.periodsResource.error()),l(),C("disabled",n.periodsResource.isLoading()||!!n.periodsResource.error()))},dependencies:[ie,O,De,Le,Ve,ae,A],styles:["[_nghost-%COMP%] .p-inputnumber, [_nghost-%COMP%] .periodise-input{width:100%}"],changeDetection:0})}}return t})();var yt=()=>({width:"56rem",maxHeight:"85vh"});function wt(t,o){t&1&&(a(0,"span",12),s(1,"F\xF6rhandsgranska utkast"),r())}function St(t,o){if(t&1&&(a(0,"tr")(1,"th",13),s(2,"Konto"),r(),a(3,"th",14),s(4),r(),a(5,"th",14),s(6,"Totalt"),r()()),t&2){let e=d(2);l(4),y(e.yearLabel())}}function Bt(t,o){if(t&1&&(a(0,"td",18),s(1),p(2,"transformAmount"),p(3,"czCurrency"),r(),a(4,"td",18),s(5),p(6,"transformAmount"),p(7,"czCurrency"),r()),t&2){let e=d(2).$implicit,i=d(2);l(),f(" ",g(3,5,g(2,2,e.sums.budget,i.format()),0)," "),l(4),f(" ",g(7,11,g(6,8,e.sums.budget,i.format()),0)," ")}}function kt(t,o){t&1&&h(0,"td")(1,"td")}function Et(t,o){if(t&1&&(a(0,"tr")(1,"td",17),s(2),r(),m(3,Bt,8,14)(4,kt,2,0),r()),t&2){let e=d().$implicit;B("budget-group",!e.total)("budget-total-bar",e.total),l(2),y(e.name),l(),u(e.sums?3:4)}}function Ft(t,o){if(t&1&&(a(0,"span",20),s(1),r()),t&2){let e=d(3).$implicit,i=d(2);l(),N("",i.commentLabel(),"-kommentar: ",e.adminComment)}}function Tt(t,o){if(t&1&&(a(0,"span",20),s(1),r()),t&2){let e=d(3).$implicit;l(),f("Er kommentar: ",e.comment)}}function Pt(t,o){if(t&1&&(a(0,"span",19),m(1,Ft,2,2,"span",20),m(2,Tt,2,1,"span",20),r()),t&2){let e=d(2).$implicit;l(),u(e.adminComment?1:-1),l(),u(e.comment?2:-1)}}function Mt(t,o){if(t&1&&(a(0,"tr")(1,"td"),s(2),m(3,Pt,3,2,"span",19),r(),a(4,"td",18),s(5),p(6,"czCurrency"),r(),a(7,"td",18),s(8),p(9,"czCurrency"),r()()),t&2){let e=d().$implicit,i=d(2);l(2),f(" ",e.label," "),l(),u(i.showComments()&&(e.adminComment||e.comment)?3:-1),l(2),y(g(6,4,e.control.value,0)),l(3),y(g(9,7,e.control.value,0))}}function It(t,o){if(t&1&&(a(0,"tr",16)(1,"td",17),s(2),r(),a(3,"td",21),s(4),p(5,"transformAmount"),p(6,"czCurrency"),r(),a(7,"td",21),s(8),p(9,"transformAmount"),p(10,"czCurrency"),r()()),t&2){let e=d().$implicit,i=d(2);l(2),y(e.name),l(2),f(" ",g(6,6,g(5,3,e.sums.budget,i.format()),0)," "),l(4),f(" ",g(10,12,g(9,9,e.sums.budget,i.format()),0)," ")}}function Dt(t,o){if(t&1&&m(0,Et,5,6,"tr",15)(1,Mt,10,10,"tr")(2,It,11,15,"tr",16),t&2){let e,i=o.$implicit;u((e=i.kind)==="sectionHeader"?0:e==="account"?1:e==="sum"?2:-1)}}function Rt(t,o){if(t&1&&(a(0,"p-table",11),R(1,St,7,1,"ng-template",null,0,k)(3,Dt,3,1,"ng-template",null,1,k),r()),t&2){let e=d();C("value",e.gridRows())("rowHover",!1)}}function Lt(t,o){if(t&1&&(a(0,"tr")(1,"th",13),s(2,"Post"),r(),a(3,"th",14),s(4),r()()),t&2){let e=d(2);l(4),y(e.yearLabel())}}function Vt(t,o){if(t&1&&(a(0,"span",20),s(1),r()),t&2){let e=d(2).$implicit,i=d(2);l(),N("",i.commentLabel(),"-kommentar: ",e.adminComment)}}function $t(t,o){if(t&1&&(a(0,"span",20),s(1),r()),t&2){let e=d(2).$implicit;l(),f("Er kommentar: ",e.comment)}}function Nt(t,o){if(t&1&&(a(0,"span",19),m(1,Vt,2,2,"span",20),m(2,$t,2,1,"span",20),r()),t&2){let e=d().$implicit;l(),u(e.adminComment?1:-1),l(),u(e.comment?2:-1)}}function qt(t,o){if(t&1&&(a(0,"tr")(1,"td"),s(2),m(3,Nt,3,2,"span",19),r(),a(4,"td",18),s(5),p(6,"transformAmount"),p(7,"czCurrency"),r()()),t&2){let e=o.$implicit,i=d(2);l(),B("font-semibold",e.bold),l(),f(" ",e.name," "),l(),u(i.showComments()&&(e.adminComment||e.comment)?3:-1),l(2),f(" ",g(7,8,g(6,5,e.customerValue,i.format()),0)," ")}}
1function At(t,o){if(t&1&&(a(0,"tr",22)(1,"td",17),s(2,"Likviditet"),r(),a(3,"td",21),s(4),p(5,"transformAmount"),p(6,"czCurrency"),r()()),t&2){let e=d(2);l(4),f(" ",g(6,4,g(5,1,e.liquiditySum(),e.format()),0)," ")}}function Ot(t,o){if(t&1&&(a(0,"p-table",11),R(1,Lt,5,1,"ng-template",null,0,k)(3,qt,8,11,"ng-template",null,1,k)(5,At,7,7,"ng-template",null,2,k),r()),t&2){let e=d();C("value",e.liquidityRows())("rowHover",!1)}}var rt=(()=>{class t{constructor(){this.visible=Pe(!1),this.gridRows=V([]),this.liquidityRows=V([]),this.liquiditySum=V(0),this.format=V.required(),this.yearLabel=V(""),this.commentLabel=V(""),this.activeView=P("budget"),this.showComments=P(!1),this.unitLabel=b(()=>this.format()==="TSEK"?"tusentals kronor":"kronor"),this.caption=b(()=>this.activeView()==="likviditet"?`Utkast till likviditetsrapport \xB7 belopp i ${this.format()}. Likviditet = \xE5rets resultat + avskrivningar \u2013 planenlig amortering.`:`Utkast \xB7 samtliga belopp i ${this.unitLabel()}. Skrivskyddad f\xF6rhandsgranskning.`)}print(){window.print()}static{this.\u0275fac=function(i){return new(i||t)}}static{this.\u0275cmp=$({type:t,selectors:[["app-budget-draft-preview-dialog"]],inputs:{visible:[1,"visible"],gridRows:[1,"gridRows"],liquidityRows:[1,"liquidityRows"],liquiditySum:[1,"liquiditySum"],format:[1,"format"],yearLabel:[1,"yearLabel"],commentLabel:[1,"commentLabel"]},outputs:{visible:"visibleChange"},decls:18,vars:15,consts:[["header",""],["body",""],["footer",""],["header","F\xF6rhandsgranska utkast","contentStyleClass","draft-preview-content",3,"visibleChange","visible","modal","dismissableMask"],[1,"mb-3","flex","flex-wrap","items-center","gap-4"],["role","tablist",1,"draft-segmented","inline-flex","p-1"],["type","button","role","tab",1,"cursor-pointer","border-0","px-4","py-[0.4rem]","font-semibold",3,"click"],["for","draft-toggle-comments",1,"draft-comments-toggle","inline-flex","cursor-pointer","items-center","gap-2"],["inputId","draft-toggle-comments",3,"ngModelChange","ngModel"],["label","Skriv ut","icon","fa-solid fa-print","severity","secondary","variant","outlined","data-test","draft-preview-print",1,"ml-auto",3,"onClick"],[1,"draft-caption","mb-4","italic"],[1,"w-full",3,"value","rowHover"],[1,"p-dialog-title"],["scope","col"],["scope","col",1,"whitespace-nowrap","text-right"],[3,"budget-group","budget-total-bar"],[1,"budget-sum"],[1,"font-semibold"],[1,"whitespace-nowrap","text-right"],[1,"draft-comment-lines","mt-1","block","pl-2","text-xs","italic"],[1,"block"],[1,"whitespace-nowrap","text-right","font-semibold"],[1,"budget-total-bar"]],template:function(i,n){if(i&1){let c=M();a(0,"p-dialog",3),J("visibleChange",function(x){return w(c),W(n.visible,x)||(n.visible=x),S(x)}),R(1,wt,2,0,"ng-template",null,0,k),a(3,"div",4)(4,"div",5)(5,"button",6),v("click",function(){return w(c),S(n.activeView.set("budget"))}),s(6," Budgetutkast "),r(),a(7,"button",6),v("click",function(){return w(c),S(n.activeView.set("likviditet"))}),s(8," Likviditetsrapport "),r()(),a(9,"label",7)(10,"p-toggleswitch",8),v("ngModelChange",function(x){return w(c),S(n.showComments.set(x))}),r(),a(11,"span"),s(12,"Visa kommentarer"),r()(),a(13,"oc-p-button",9),v("onClick",function(){return w(c),S(n.print())}),r()(),a(14,"p",10),s(15),r(),m(16,Rt,5,2,"p-table",11)(17,Ot,7,2,"p-table",11),r()}i&2&&(Te(q(14,yt)),G("visible",n.visible),C("modal",!0)("dismissableMask",!0),l(5),B("active",n.activeView()==="budget"),D("aria-selected",n.activeView()==="budget"),l(2),B("active",n.activeView()==="likviditet"),D("aria-selected",n.activeView()==="likviditet"),l(3),C("ngModel",n.showComments()),l(5),y(n.caption()),l(),u(n.activeView()==="budget"?16:17))},dependencies:[te,O,ee,Oe,A,se,le,re,Z,Q,X],styles:[".draft-segmented[_ngcontent-%COMP%]{border-radius:var(--oc-semantic-border-radius-lg, 10px);background:var(--oc-semantic-surface-hover)}.draft-segmented[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{background:transparent;border-radius:var(--oc-semantic-border-radius-sm, 8px);color:var(--oc-semantic-text-color)}.draft-segmented[_ngcontent-%COMP%] button.active[_ngcontent-%COMP%]{background:var(--p-togglebutton-content-checked-background);color:var(--p-togglebutton-content-checked-color)}.draft-comments-toggle[_ngcontent-%COMP%], .draft-caption[_ngcontent-%COMP%], .draft-comment-lines[_ngcontent-%COMP%]{color:var(--oc-semantic-text-color)}[_nghost-%COMP%] .p-datatable-thead>tr>th{padding:.75rem 1rem;border-bottom:1px solid var(--oc-semantic-content-border-color);color:var(--oc-semantic-text-color)}[_nghost-%COMP%] .p-datatable-tbody>tr>td{padding:.4rem 1rem;border-bottom:1px solid var(--oc-semantic-content-border-color)}[_nghost-%COMP%] .p-datatable-tbody>tr.budget-group>td, [_nghost-%COMP%] .p-datatable-tbody>tr.budget-total-bar>td{background:var(--oc-semantic-surface-hover)}[_nghost-%COMP%] .p-datatable-tbody>tr.budget-total-bar>td{font-weight:600}[_nghost-%COMP%] .p-datatable-tbody>tr.budget-sum>td{font-style:italic}"],changeDetection:0})}}return t})();function Ce(t){return t==="kilo"?"TSEK":"SEK"}function me(t,o){return o==="TSEK"?t/1e3:o==="MSEK"?t/1e6:t}function lt(t){return t==="TSEK"?1e3:t==="MSEK"?1e6:1}function dt(t,o){let e=0,i={format:o,prevYearKey:t.budgetInfo.annualYears?.[0]?.[0]?.substring(0,4)??"",ackYearKey:t.budgetInfo.annualYears?.[1]?.[0]?.substring(0,4)??"",previousBudgetKey:t.budgetInfo.previousBudget!=null?String(t.budgetInfo.previousBudget):"",budgetForm:new Y({}),accountsMap:new Map(t.accounts.map(F=>[F.number,F])),standaloneKey:()=>`x${e++}`,subKey:()=>`s${e++}`},n=t.budget.flatMap(F=>Yt(F,i)),{liquidityForm:c,liquidityRows:_,liquiditySums:x}=jt(t,o),{chargeBasisForm:I,chargeBasisSections:L}=Gt(t);return{budgetForm:i.budgetForm,liquidityForm:c,chargeBasisForm:I,gridRows:n,liquidityRows:_,liquiditySums:x,chargeBasisSections:L}}function he(t,o){let e=lt(o),i={};for(let n of t){let c=Math.round(me(n.amountInitRaw,o)),_=n.displayTotalInit,x=Math.round(n.control.value??0),I=x-_+c;i[n.accountKey]={amount:I*e,amountInit:c,total:x*e,totalInit:_,comment:n.comment}}return i}function ve(t,o){let e=lt(o),i={};for(let n of t)if(n.editable&&n.fieldId!=null&&n.control){let c=Math.abs(n.customerValue??0),_=n.control.value??0;i[String(n.fieldId)]=Math.abs(Math.round(c+(_-(n.displayInit??0))*e))}return i}function xe(t){let o={};
1for(let e of t)e.editable&&e.fieldId!=null&&(o[String(e.fieldId)]=e.comment);return o}function ye(t){let o={};for(let e of t)for(let i of e.rows)i.editable&&i.fieldId!=null&&i.control&&(o[String(i.fieldId)]=Math.round(i.control.value??0));return o}function st(t,o,e){let i=n=>Math.round(me(n,o));return t.map(n=>{if(n.kind==="account"){let x={Konto:n.label,[e.utfall]:i(n.utfall)};return e.budgetPrevYear&&(x[e.budgetPrevYear]=i(n.budgetPrevYear)),e.utfallAck&&(x[e.utfallAck]=i(n.utfallAck)),x[e.forslag]=i(n.forslag),x[e.budget]=n.control.value??0,x}let c=n.sums,_={Konto:n.name,[e.utfall]:c?i(c.utfall):""};return e.budgetPrevYear&&(_[e.budgetPrevYear]=c?i(c.budgetPrevYear):""),e.utfallAck&&(_[e.utfallAck]=c?i(c.utfallAck):""),_[e.forslag]=c?i(c.forslag):"",_[e.budget]=c?i(c.budget):"",_})}function Yt(t,o){if(t.aathType==="invisible")return[];if(t.aathType==="sum"||t.aathType==="sum2")return[{kind:"sectionHeader",groupKey:o.standaloneKey(),name:t.aathName,collapsible:!1,total:!0,sums:ce(t.sums,o)}];let e=[];t.aathName&&!(t.aathType==="normal"&&!t.sums)&&e.push({kind:"sectionHeader",groupKey:o.standaloneKey(),name:t.aathName,collapsible:!1,total:!1,sums:null});for(let i of t.subHeaders??[])e.push(...Kt(i,o));return t.sums&&t.aathType!=="heading"&&e.push({kind:"sum",groupKey:o.standaloneKey(),name:`Summa ${t.aathName}`,variant:"section",sums:ce(t.sums,o)}),e}function Kt(t,o){let e=!!t.aatshName,i=e?o.subKey():o.standaloneKey(),n=[];e&&n.push({kind:"sectionHeader",groupKey:i,name:t.aatshName,collapsible:!0,total:!1,sums:t.sums?ce(t.sums,o):null});for(let c of t.accounts??[])n.push(zt(c,i,o));return e&&t.sums&&n.push({kind:"sum",groupKey:i,name:`Summa ${t.aatshName}`,variant:"subHeader",sums:ce(t.sums,o)}),n}function zt(t,o,e){let i=t[0],n=i.abdAccount,c=t.filter(T=>T.abdModifier==="import"||T.abdModifier==="conzignus").reduce((T,pt)=>T+(pt.abdAmount||0),0),_=t.find(T=>T.abdModifier==="forening")?.abdAmount??0,x=c+_,I=e.accountsMap.get(n),L=I?.amount??_,F=Math.round(me(x,e.format)),we=new K(F);return e.budgetForm.addControl(String(n),we),{kind:"account",groupKey:o,accountKey:String(n),account:n,label:`${n} ${i.aaName??""}`.trim(),utfall:e.prevYearKey?i.utfall?.[e.prevYearKey]??0:0,utfallAck:e.ackYearKey?i.utfall?.[e.ackYearKey]??0:0,budgetPrevYear:e.previousBudgetKey?ct(i.budget?.[e.previousBudgetKey]):0,forslag:c,control:we,displayTotalInit:F,amountInitRaw:L,comment:I?.comment??"",adminComment:t.find(T=>T.abdModifier==="conzignus")?.abdComment??"",hasPeriods:t.some(T=>Ht(T.periods))}}function Ht(t){return Array.isArray(t)?t.length>0:!!t}function jt(t,o){let e=new Y({}),i=[],n=0,c=0;return t.liquidityBudget.forEach((_,x)=>{n+=_.propertyManagerValue||0,c+=_.customerValue||0;let I=_.liquidityBudgetFieldId!=null,L,F;I&&(F=Math.round(me(Math.abs(_.customerValue),o)),L=new K(F),e.addControl(String(_.liquidityBudgetFieldId),L)),i.push({name:_.name,bold:x===0,propertyManagerValue:_.propertyManagerValue,editable:I,showAsNegativeValue:!!_.showAsNegativeValue,control:L,displayInit:F,fieldId:_.liquidityBudgetFieldId??void 0,customerValue:_.customerValue,hasPeriods:!!_.hasPeriods,adminComment:_.propertyManagerComment??"",comment:_.customerComment??""})}),{liquidityForm:e,liquidityRows:i,liquiditySums:{propertyManager:n,customer:c}}}var Ut="Grund f\xF6r avgiftsuttag";function Gt(t){let o=new Y({}),e=[],i=null;for(let n of t.chargeBasisBudget??[]){if(n.sectionHeader){i={title:n.name,rows:[]},e.push(i);continue}i||(i={title:Ut,rows:[]},e.push(i));let c=!!n.inputField&&n.chargeBasisBudgetFieldId!=null,_;c&&(_=new K(ct(n.customerValue)),o.addControl(String(n.chargeBasisBudgetFieldId),_)),i.rows.push({name:n.name,propertyManagerValue:String(n.propertyManagerValue??""),customerValue:String(n.customerValue??""),heading:!!n.heading,suggestionHeading:!!n.suggestionHeading,editable:c,fieldId:n.chargeBasisBudgetFieldId??void 0,unitSuffix:n.chargeBasisBudgetFieldId===1,control:_})}return{chargeBasisForm:o,chargeBasisSections:e}}function ct(t){if(typeof t=="number")return t;let o=Number.parseFloat(String(t??"").replace(/\s/g,"").replace(",","."));return Number.isFinite(o)?o:0}function ce(t,o){let e=(t?.conzignus??0)+(t?.import??0);return{utfall:(o.prevYearKey?t?.[o.prevYearKey]:0)??0,utfallAck:(o.ackYearKey?t?.[o.ackYearKey]:0)??0,budgetPrevYear:t?.previousBudget??0,forslag:e,budget:e+(t?.forening??0)}}var Wt=()=>["/economy/financial-budgets"],mt=()=>["/economy/accounting"],ut=(t,o)=>({dates:t,account:o}),Jt=(t,o)=>o.title;function Qt(t,o){if(t&1){let e=M();a(0,"oc-p-button",12),v("onClick",function(){w(e);let n=d();return S(n.lock())}),r()}if(t&2){let e=d();C("disabled",e.isLocked())}}function Xt(t,o){t&1&&(a(0,"div",9),h(1,"i",13),a(2,"span"),s(3,"H\xE4mtar budget..."),r()())}function Zt(t,o){t&1&&(a(0,"div",10),s(1,"Budgeten kunde inte laddas."),r())}
1function ei(t,o){if(t&1&&(a(0,"th",32),s(1),r()),t&2){let e=d(3);l(),f("Budget ",e.budgetPrevYearLabel())}}function ti(t,o){if(t&1&&(a(0,"th",32),s(1),r()),t&2){let e=d(3);l(),f("Utfall ack. ",e.ackYearLabel())}}function ii(t,o){t&1&&h(0,"th",33)}function ni(t,o){if(t&1&&(a(0,"tr")(1,"th",31),s(2,"Konto"),r(),a(3,"th",32),s(4),r(),m(5,ei,2,1,"th",32),m(6,ti,2,1,"th",32),a(7,"th",32),s(8),r(),a(9,"th",32),s(10),r(),m(11,ii,1,0,"th",33),r()),t&2){let e=d(2);l(4),f("Utfall ",e.prevYearLabel()),l(),u(e.showBudgetPrevYear()?5:-1),l(),u(e.showUtfallAck()?6:-1),l(2),f("Budgetf\xF6rslag ",e.budgetYearLabel()),l(2),f("Budget ",e.budgetYearLabel()),l(),u(e.canEdit()?11:-1)}}function oi(t,o){if(t&1){let e=M();a(0,"button",39),v("click",function(){w(e);let n=d(2).$implicit,c=d(2);return S(c.toggleSection(n.groupKey))}),h(1,"i",40),a(2,"span",38),s(3),r()()}if(t&2){let e=d(2).$implicit,i=d(2);D("aria-expanded",!i.collapsedSections().has(e.groupKey)),l(),B("fa-chevron-down",!i.collapsedSections().has(e.groupKey))("fa-chevron-right",i.collapsedSections().has(e.groupKey)),l(2),y(e.name)}}function ai(t,o){if(t&1&&(a(0,"span",38),s(1),r()),t&2){let e=d(2).$implicit;l(),y(e.name)}}function ri(t,o){if(t&1&&(a(0,"td",41),s(1),p(2,"transformAmount"),p(3,"czCurrency"),r()),t&2){let e=d(3).$implicit,i=d(2);l(),f(" ",g(3,4,g(2,1,e.sums.budgetPrevYear,i.amountFormatType()),0)," ")}}function li(t,o){if(t&1&&(a(0,"td",41),s(1),p(2,"transformAmount"),p(3,"czCurrency"),r()),t&2){let e=d(3).$implicit,i=d(2);l(),f(" ",g(3,4,g(2,1,e.sums.utfallAck,i.amountFormatType()),0)," ")}}function di(t,o){if(t&1&&(a(0,"td",41),s(1),p(2,"transformAmount"),p(3,"czCurrency"),r(),m(4,ri,4,7,"td",41),m(5,li,4,7,"td",41),a(6,"td",41),s(7),p(8,"transformAmount"),p(9,"czCurrency"),r(),a(10,"td",42),s(11),p(12,"transformAmount"),p(13,"czCurrency"),r()),t&2){let e=d(2).$implicit,i=d(2);l(),f(" ",g(3,8,g(2,5,e.sums.utfall,i.amountFormatType()),0)," "),l(3),u(i.showBudgetPrevYear()?4:-1),l(),u(i.showUtfallAck()?5:-1),l(2),f(" ",g(9,14,g(8,11,e.sums.forslag,i.amountFormatType()),0)," "),l(4),f(" ",g(13,20,g(12,17,e.sums.budget,i.amountFormatType()),0)," ")}}function si(t,o){t&1&&h(0,"td")}function ci(t,o){t&1&&h(0,"td")}function mi(t,o){if(t&1&&(h(0,"td"),m(1,si,1,0,"td"),m(2,ci,1,0,"td"),h(3,"td")(4,"td")),t&2){let e=d(4);l(),u(e.showBudgetPrevYear()?1:-1),l(),u(e.showUtfallAck()?2:-1)}}function ui(t,o){t&1&&h(0,"td")}function pi(t,o){if(t&1&&(a(0,"tr")(1,"td"),m(2,oi,4,6,"button",37)(3,ai,2,1,"span",38),r(),m(4,di,14,23)(5,mi,5,2),m(6,ui,1,0,"td"),r()),t&2){let e=d().$implicit,i=d(2);B("budget-group",!e.total)("budget-total-bar",e.total),l(2),u(e.collapsible?2:3),l(2),u(e.sums?4:5),l(2),u(i.canEdit()?6:-1)}}function gi(t,o){if(t&1&&(a(0,"span",48),s(1),r()),t&2){let e=d(3).$implicit,i=d(2);l(),N("",i.commentLabel(),"-kommentar: ",e.adminComment)}}function _i(t,o){if(t&1&&(a(0,"span",48),s(1),r()),t&2){let e=d(3).$implicit;l(),f("Er kommentar: ",e.comment)}}function fi(t,o){if(t&1&&(a(0,"span",43),m(1,gi,2,2,"span",48),m(2,_i,2,1,"span",48),r()),t&2){let e=d(2).$implicit;l(),u(e.adminComment?1:-1),l(),u(e.comment?2:-1)}}function bi(t,o){if(t&1&&(a(0,"a",45),h(1,"i",49),r()),t&2){let e=d(2).$implicit;C("routerLink",q(3,mt))("queryParams",pe(4,ut,o,e.account)),D("aria-label","G\xE5 till konteringar p\xE5 konto "+e.account)}}function Ci(t,o){if(t&1&&(a(0,"td",41),s(1),p(2,"transformAmount"),p(3,"czCurrency"),r()),t&2){let e=d(2).$implicit,i=d(2);l(),f(" ",g(3,4,g(2,1,e.budgetPrevYear,i.amountFormatType()),0)," ")}}function hi(t,o){if(t&1&&(a(0,"a",45),h(1,"i",49),r()),t&2){let e=d(3).$implicit;C("routerLink",q(3,mt))("queryParams",pe(4,ut,o,e.account)),D("aria-label","G\xE5 till konteringar p\xE5 konto "+e.account)}}function vi(t,o){if(t&1&&(a(0,"td",41)(1,"span",44),s(2),p(3,"transformAmount"),p(4,"czCurrency"),m(5,hi,2,7,"a",45),r()()),t&2){let e,i=d(2).$implicit,n=d(2);l(2),f(" ",g(4,5,g(3,2,i.utfallAck,n.amountFormatType()),0)," "),l(3),u((e=n.accountingDatesAck())?5:-1,e)}}function xi(t,o){if(t&1&&h(0,"p-inputNumber",46),t&2){let e=d(2).$implicit;C("formControl",e.control)("useGrouping",!0)("maxFractionDigits",0)}}function yi(t,o){if(t&1&&(s(0),p(1,"czCurrency")),t&2){let e=d(2).$implicit;f(" ",g(1,1,e.control.value,0)," ")}}function wi(t,o){if(t&1){let e=M();a(0,"td",47)(1,"div",50)(2,"button",51),v("click",function(){w(e);let n=d(2).$implicit,c=d(2);return S(c.openPeriodiseDialog(n))}),h(3,"i",52),r(),a(4,"button",53),v("click",function(){w(e);let n=d(2).$implicit,c=d(2);return S(c.openCommentDialog(n))}),h(5,"i",54),r()()()}if(t&2){let e=d(2).$implicit;l(3),B("fa-solid",e.hasPeriods)("fa-regular",!e.hasPeriods),l(),C("pTooltip",e.comment?"Redigera":"Kommentera"),D("aria-label",e.comment?"Redigera kommentar":"L\xE4gg till kommentar"),l(),B("fa-solid",e.comment)("fa-regular",!e.comment)}}function Si(t,o){if(t&1&&(a(0,"tr",35)(1,"td"),s(2),m(3,fi,3,2,"span",43),r(),a(4,"td",41)(5,"span",44),s(6),p(7,"transformAmount"),p(8,"czCurrency"),m(9,bi,2,7,"a",45),r()(),m(10,Ci,4,7,"td",41),m(11,vi,6,8,"td",41),a(12,"td",41),s(13),p(14,"transformAmount"),p(15,"czCurrency"),r(),a(16,"td",41),m(17,xi,1,3,"p-inputNumber",46)(18,yi,2,4),r(),m(19,wi,6,10,"td",47),r()
1),t&2){let e,i=d().$implicit,n=d(2);l(2),f(" ",i.label," "),l(),u(n.showComments()&&(i.adminComment||i.comment)?3:-1),l(3),f(" ",g(8,12,g(7,9,i.utfall,n.amountFormatType()),0)," "),l(3),u((e=n.accountingDates())?9:-1,e),l(),u(n.showBudgetPrevYear()?10:-1),l(),u(n.showUtfallAck()?11:-1),l(2),f(" ",g(15,18,g(14,15,i.forslag,n.amountFormatType()),0)," "),l(4),u(n.canEdit()?17:18),l(2),u(n.canEdit()?19:-1)}}function Bi(t,o){if(t&1&&(a(0,"td",41),s(1),p(2,"transformAmount"),p(3,"czCurrency"),r()),t&2){let e=d(2).$implicit,i=d(2);l(),f(" ",g(3,4,g(2,1,e.sums.budgetPrevYear,i.amountFormatType()),0)," ")}}function ki(t,o){if(t&1&&(a(0,"td",41),s(1),p(2,"transformAmount"),p(3,"czCurrency"),r()),t&2){let e=d(2).$implicit,i=d(2);l(),f(" ",g(3,4,g(2,1,e.sums.utfallAck,i.amountFormatType()),0)," ")}}function Ei(t,o){t&1&&h(0,"td")}function Fi(t,o){if(t&1&&(a(0,"tr")(1,"td",38),s(2),r(),a(3,"td",41),s(4),p(5,"transformAmount"),p(6,"czCurrency"),r(),m(7,Bi,4,7,"td",41),m(8,ki,4,7,"td",41),a(9,"td",41),s(10),p(11,"transformAmount"),p(12,"czCurrency"),r(),a(13,"td",42),s(14),p(15,"transformAmount"),p(16,"czCurrency"),r(),m(17,Ei,1,0,"td"),r()),t&2){let e=d().$implicit,i=d(2);B("budget-subsum",e.variant==="subHeader")("budget-sum",e.variant==="section"),l(2),y(e.name),l(2),f(" ",g(6,14,g(5,11,e.sums.utfall,i.amountFormatType()),0)," "),l(3),u(i.showBudgetPrevYear()?7:-1),l(),u(i.showUtfallAck()?8:-1),l(2),f(" ",g(12,20,g(11,17,e.sums.forslag,i.amountFormatType()),0)," "),l(4),f(" ",g(16,26,g(15,23,e.sums.budget,i.amountFormatType()),0)," "),l(3),u(i.canEdit()?17:-1)}}function Ti(t,o){if(t&1&&m(0,pi,7,7,"tr",34)(1,Si,20,21,"tr",35)(2,Fi,18,29,"tr",36),t&2){let e,i=o.$implicit;u((e=i.kind)==="sectionHeader"?0:e==="account"?1:e==="sum"?2:-1)}}function Pi(t,o){if(t&1&&(a(0,"tr"),h(1,"th",31),a(2,"th",32),s(3,"Budgetutkast"),r(),a(4,"th",32),s(5),r()()),t&2){let e=d(2);l(5),y(e.isLocked()?"Summa":"Justering")}}function Mi(t,o){if(t&1&&(a(0,"span",48),s(1),r()),t&2){let e=d(2).$implicit,i=d(2);l(),N("",i.commentLabel(),"-kommentar: ",e.adminComment)}}function Ii(t,o){if(t&1&&(a(0,"span",48),s(1),r()),t&2){let e=d(2).$implicit;l(),f("Er kommentar: ",e.comment)}}function Di(t,o){if(t&1&&(a(0,"span",43),m(1,Mi,2,2,"span",48),m(2,Ii,2,1,"span",48),r()),t&2){let e=d().$implicit;l(),u(e.adminComment?1:-1),l(),u(e.comment?2:-1)}}function Ri(t,o){if(t&1){let e=M();a(0,"button",51),v("click",function(){w(e);let n=d(2).$implicit,c=d(2);return S(c.openLiquidityPeriodiseDialog(n))}),h(1,"i",52),r()}if(t&2){let e=d(2).$implicit;l(),B("fa-solid",e.hasPeriods)("fa-regular",!e.hasPeriods)}}function Li(t,o){if(t&1){let e=M();a(0,"button",58),v("click",function(){w(e);let n=d(2).$implicit,c=d(2);return S(c.openLiquidityCommentDialog(n))}),h(1,"i",54),r()}if(t&2){let e=d(2).$implicit;C("pTooltip",e.comment?"Redigera":"Kommentera"),D("aria-label",e.comment?"Redigera kommentar":"L\xE4gg till kommentar"),l(),B("fa-solid",e.comment)("fa-regular",!e.comment)}}function Vi(t,o){if(t&1&&(m(0,Ri,2,4,"button",56),m(1,Li,2,6,"button",57)),t&2){let e=d(3);u(e.isAuditor()?-1:0),l(),u(e.canEdit()?1:-1)}}function $i(t,o){t&1&&(a(0,"span",59),s(1,"\u2212"),r())}function Ni(t,o){if(t&1&&(a(0,"div",55),m(1,$i,2,0,"span",59),h(2,"p-inputNumber",60),r()),t&2){let e=d().$implicit;l(),u(e.showAsNegativeValue?1:-1),l(),C("formControl",e.control)("useGrouping",!0)("maxFractionDigits",0)("min",0)}}function qi(t,o){if(t&1&&(s(0),p(1,"transformAmount"),p(2,"czCurrency")),t&2){let e=d().$implicit,i=d(2);f(" ",g(2,4,g(1,1,e.customerValue,i.amountFormatType()),0)," ")}}function Ai(t,o){if(t&1&&(a(0,"tr")(1,"td"),s(2),m(3,Di,3,2,"span",43),r(),a(4,"td",41)(5,"span",44),m(6,Vi,2,2),s(7),p(8,"transformAmount"),p(9,"czCurrency"),r()(),a(10,"td",41),m(11,Ni,3,5,"div",55)(12,qi,3,7),r()()),t&2){let e=o.$implicit,i=d(2);l(),B("font-semibold",e.bold),l(),f(" ",e.name," "),l(),u(i.showComments()&&(e.adminComment||e.comment)?3:-1),l(3),u(e.editable&&e.fieldId!=null?6:-1),l(),f(" ",g(9,10,g(8,7,e.propertyManagerValue,i.amountFormatType()),0)," "),l(4),u(e.editable&&i.canEdit()?11:12)}}
1function Oi(t,o){if(t&1&&(a(0,"tr",61)(1,"td",38),s(2,"Likviditet"),r(),a(3,"td",42),s(4),p(5,"transformAmount"),p(6,"czCurrency"),r(),a(7,"td",42),s(8),p(9,"transformAmount"),p(10,"czCurrency"),r()()),t&2){let e=d(2);l(4),f(" ",g(6,5,g(5,2,e.liquiditySums().propertyManager,e.amountFormatType()),0)," "),l(4),f(" ",g(10,11,g(9,8,e.liquiditySums().customer,e.amountFormatType()),0)," ")}}function Yi(t,o){if(t&1&&(a(0,"tr"),h(1,"th",31),a(2,"th",32),s(3,"Budgetutkast"),r(),a(4,"th",32),s(5),r()()),t&2){let e=d(4);l(5),y(e.isLocked()?"Summa":"Justering")}}function Ki(t,o){t&1&&(a(0,"span"),s(1,"kr/kvm"),r())}function zi(t,o){if(t&1&&(a(0,"div",55),h(1,"p-inputNumber",64),a(2,"span"),s(3,"kr/kvm"),r()()),t&2){let e=d().$implicit;l(),C("formControl",e.control)("useGrouping",!0)("autofocus",!1)("maxFractionDigits",0)("min",0)}}function Hi(t,o){t&1&&(a(0,"span"),s(1,"kr/kvm"),r())}function ji(t,o){if(t&1&&(s(0),m(1,Hi,2,0,"span")),t&2){let e=d().$implicit;f(" ",e.customerValue," "),l(),u(e.unitSuffix?1:-1)}}function Ui(t,o){if(t&1&&(a(0,"tr")(1,"td"),s(2),r(),a(3,"td",41),s(4),m(5,Ki,2,0,"span"),r(),a(6,"td",41),m(7,zi,4,5,"div",55)(8,ji,2,2),r()()),t&2){let e=o.$implicit,i=d(4);B("budget-total-bar",e.suggestionHeading)("budget-charge-emphasis",e.suggestionHeading),l(),B("font-semibold",e.heading||e.suggestionHeading),l(),y(e.name),l(2),f(" ",e.propertyManagerValue," "),l(),u(e.unitSuffix?5:-1),l(2),u(e.editable&&i.canEdit()?7:8)}}function Gi(t,o){if(t&1&&(a(0,"section",17)(1,"h2",27),s(2),r(),a(3,"p-table",30),R(4,Yi,6,1,"ng-template",null,0,k)(6,Ui,9,10,"ng-template",null,1,k),r()()),t&2){let e=o.$implicit;l(2),y(e.title),l(),C("value",e.rows)("rowHover",!1)}}function Wi(t,o){if(t&1&&(j(0,Gi,8,3,"section",17,Jt),a(2,"section",17)(3,"p",62),s(4," Boka ett budgetm\xF6te med oss f\xF6r en djupare analys av ovanst\xE5ende siffror. "),r(),a(5,"p",63),s(6," *Ert nyckeltal sparande b\xF6r st\xE4llas i relation till en uppdaterad underh\xE5llsplan p\xE5 minst 50 \xE5r, se ert budget\xE4rende f\xF6r mer information. "),r(),a(7,"p",63),s(8," **R\xE4ntek\xE4nslighet visar den procentuella p\xE5verkan p\xE5 \xE5rsavgifter vid en r\xE4ntef\xF6r\xE4ndring p\xE5 er nuvarande l\xE5neskuld med en procentenhet. "),r()()),t&2){let e=d(2);U(e.chargeBasisSections())}}function Ji(t,o){t&1&&(a(0,"div",65),h(1,"ws-ticket",66),r()),t&2&&(l(),C("ticketId",o)("coreTicketView",!0))}function Qi(t,o){t&1&&(a(0,"section",17)(1,"p",67),s(2,"Inget \xE4rende finns kopplat till denna budget."),r()())}function Xi(t,o){if(t&1&&m(0,Ji,2,2,"div",65)(1,Qi,3,0,"section",17),t&2){let e,i=d(2);u((e=i.caseId())?0:1,e)}}function Zi(t,o){if(t&1){let e=M();a(0,"app-save-changes-bar",68),v("resetChanges",function(){w(e);let n=d(2);return S(n.reset())})("save",function(){w(e);let n=d(2);return S(n.save())}),r()}}function en(t,o){if(t&1){let e=M();a(0,"p-tabs",14),v("valueChange",function(n){w(e);let c=d();return S(c.activeTab.set(n??c.activeTab()))}),a(1,"p-tablist")(2,"p-tab",15),s(3,"Budget"),r(),a(4,"p-tab",16),s(5,"\xC4rende"),r()(),a(6,"p-tabpanels")(7,"p-tabpanel",15)(8,"section",17)(9,"div",18)(10,"div")(11,"h2",19),s(12,"Resultatbudget"),r(),a(13,"p",20),s(14),r()(),a(15,"div",21)(16,"label",22)(17,"p-toggleswitch",23),v("ngModelChange",function(n){w(e);let c=d();return S(c.showComments.set(n))}),r(),a(18,"span"),s(19,"Visa kommentarer"),r()(),a(20,"button",24),v("click",function(){w(e);let n=d();return S(n.exportCsv())}),h(21,"i",25),r()()(),a(22,"p-table",26),R(23,ni,12,6,"ng-template",null,0,k)(25,Ti,3,1,"ng-template",null,1,k),r()(),a(27,"section",17)(28,"h2",27),s(29,"Likviditet"),r(),a(30,"p",28),s(31," Likviditeten r\xE4knas ut genom att ta \xE5rets resultat och l\xE4gga p\xE5 Avskrivningar budget\xE5r, Planerat upptagande av nya l\xE5n och Uppl\xE5telse av ny yta samt dra av Planenlig amortering budget\xE5r, Extraamortering och Funktionsf\xF6rb\xE4ttrande investeringar. "),r(),a(32,"p",29),s(33),r(),a(34,"p-table",30),R(35,Pi,6,1,"ng-template",null,0,k)(37,Ai,13,13,"ng-template",null,1,k)(39,Oi,11,14,"ng-template",null,2,k),r()(),m(41,Wi,9,0),r(),a(42,"p-tabpanel",16),m(43,Xi,2,1),r()()(),m(44,Zi,1,0,"app-save-changes-bar")}if(t&2){let e=d();
1C("value",e.activeTab()),l(14),f("Samtliga belopp visas i ",e.amountFormatType()),l(3),C("ngModel",e.showComments()),l(5),C("value",e.visibleGridRows())("rowHover",!1)("stickyOffset",0),l(11),f("Notera att samtliga belopp anges i ",e.amountFormatType()),l(),C("value",e.liquidityRows())("rowHover",!1),l(7),u(e.showChargeBasis()?41:-1),l(2),u(e.activeTab()==="arende"?43:-1),l(),u(e.canEdit()&&e.activeTab()==="budget"&&e.hasUnsavedChanges()?44:-1)}}function tn(t,o){t&1&&(a(0,"div",10),s(1,"Budgeten kunde inte hittas."),r())}var ao=(()=>{class t{constructor(){this.budgetService=E(de),this.sharedService=E(oe),this.configService=E(He),this.toolsService=E(je),this.route=E(Me),this.dialog=E(qe),this.budgetId=ge(this.route.paramMap.pipe(H(e=>Number(e.get("id"))))),this.budgetResource=ne({params:()=>{let e=this.budgetId();return e&&Number.isFinite(e)?{id:e}:void 0},stream:({params:e})=>this.budgetService.getBudget(e.id)}),this.detail=b(()=>this.budgetResource.value()??null),this.budgetInfo=b(()=>this.detail()?.budgetInfo??null),this.clientInfo=ge(this.sharedService.clientInfoChange$,{initialValue:this.sharedService.clientInfo}),this.isAuditor=b(()=>this.clientInfo()?.contact?.role==="auditortool"),this.isLocked=b(()=>this.budgetInfo()?.locked==="true"||this.isAuditor()),this.canEdit=b(()=>!this.isLocked()),this.amountFormatType=b(()=>Ce(this.detail()?.reportValue)),this.activeTab=P("budget"),this.showComments=P(!0),this.caseId=b(()=>{let e=this.budgetInfo()?.caseId;return e&&e>0?e:null}),this.commentLabel=b(()=>this.configService.config?.clientName??""),this.viewModel=P(null),this.builtBudgetId=null,this.buildViewModelEffect=z(()=>{let e=this.detail();if(!e){this.builtBudgetId=null,this.viewModel.set(null);return}e.budgetInfo.id!==this.builtBudgetId&&(this.builtBudgetId=e.budgetInfo.id,this.viewModel.set(dt(e,Ce(e.reportValue))))}),this.model=this.viewModel.asReadonly(),this.budgetForm=b(()=>this.model()?.budgetForm??null),this.liquidityForm=b(()=>this.model()?.liquidityForm??null),this.gridRows=b(()=>this.model()?.gridRows??[]),this.accountRows=b(()=>this.gridRows().filter(e=>e.kind==="account")),this.liquidityRows=b(()=>this.model()?.liquidityRows??[]),this.liquiditySums=b(()=>this.model()?.liquiditySums??{propertyManager:0,customer:0}),this.chargeBasisForm=b(()=>this.model()?.chargeBasisForm??null),this.chargeBasisSections=b(()=>this.model()?.chargeBasisSections??[]),this.showChargeBasis=b(()=>!!this.configService.config?.budgetsFeeCollectionTable&&this.chargeBasisSections().length>0),this.hasUnsavedChanges=P(!1),this.pristine=null,this.trackChangesEffect=z(e=>{let i=this.model();if(this.hasUnsavedChanges.set(!1),!i){this.pristine=null;return}this.pristine={budget:i.budgetForm.getRawValue(),liquidity:i.liquidityForm.getRawValue(),chargeBasis:i.chargeBasisForm.getRawValue(),comments:new Map([...this.accountRows(),...this.liquidityRows()].map(c=>[c,c.comment]))};let n=ke(i.budgetForm.valueChanges,i.liquidityForm.valueChanges,i.chargeBasisForm.valueChanges).subscribe({next:()=>this.hasUnsavedChanges.set(!0)});e(()=>n.unsubscribe())}),this.collapsedSections=P(new Set),this.visibleGridRows=b(()=>{let e=this.collapsedSections();return this.gridRows().filter(i=>i.kind==="sectionHeader"||!e.has(i.groupKey))}),this.titleText=b(()=>`Ett\xE5rsbudget ${this.budgetYearLabel()}`),this.metaText=b(()=>{let e=this.budgetInfo();return e&&[e.updater?`Skapad av ${e.updater}`:null,e.updated?`Uppdaterad ${e.updated}`:null].filter(Boolean).join(" \xB7 ")||null}),this.budgetYearLabel=b(()=>{let e=this.budgetInfo();return e?_e(e.year,e.financialYearEndMonth):""}),this.prevYearLabel=b(()=>{let e=this.budgetInfo()?.annualYears?.[0];if(!e)return"";let i=e[0]?.substring(0,4)??"",n=e[1]?.substring(0,4)??"";return i===n?i:`${i}/${n}`}),this.ackYearLabel=b(()=>{let e=this.budgetInfo()?.annualYears?.[1];if(!e)return"";let i=e[0]?.substring(0,4)??"",n=e[1]?.substring(0,4)??"";return i===n?i:`${i}/${n}`}),this.budgetPrevYearLabel=b(()=>{let e=this.budgetInfo();return e?.previousBudget?_e(e.previousBudget,e.financialYearEndMonth):""}),this.showBudgetPrevYear=b(()=>!!this.budgetInfo()?.previousBudget),this.showUtfallAck=b(()=>!!this.budgetInfo()?.annualYears?.[1]),this.accountingDates=b(()=>{let e=this.budgetInfo()?.annualYears?.[0];return e?.[0]&&e[1]?`${e[0]}|${e[1]}`:null}),this.accountingDatesAck=b(()=>{let e=this.budgetInfo()?.annualYears?.[1];return e?.[0]&&e[1]?`${e[0]}|${e[1]}`:null}),this.draftPreviewVisible=P(!1)}reloadBudget(){this.builtBudgetId=null,this.budgetResource.reload()}exportCsv(){let e=st(this.gridRows(),this.amountFormatType(),{utfall:`Utfall ${this.prevYearLabel()}`,budgetPrevYear:this.showBudgetPrevYear()?`Budget ${this.budgetPrevYearLabel()}`:void 0,utfallAck:this.showUtfallAck()?`Utfall ack. ${this.ackYearLabel()}`:void 0,forslag:`Budgetf\xF6rslag ${this.budgetYearLabel()}`,budget:`Budget ${this.budgetYearLabel()}`});this.toolsService.downloadCsvFile(e,`Resultatbudget ${this.budgetYearLabel()}`)}toggleSection(e){this.collapsedSections.update(i=>{let n=new Set(i);return n.has(e)?n.delete(e):n.add(e),n})}showDraft(){this.draftPreviewVisible.set(!0)}showBudgetDraft(e){let i=this.budgetInfo();if(!i)return;let n=e?"&comments=true":"";window.open(`/shared/rapporter/budgetPopup.php?year=${i.year}&dimObject=${i.dimensionObjectId}${n}`,`Budget ${i.year}`,"width=800,height=600,top=30,left=80,menubar=yes,scrollbars=yes")}showLiquidityReportDraft(){let e=this.budgetInfo();e&&window.open(`/shared/rapporter/liquidityBudgetPopup.php?year=${e.year}&dimObject=${e.dimensionObjectId}&showCompleteData=false`,`Likviditetsrapport ${e.year}`,"width=800,height=600,top=30,left=80,menubar=yes,scrollbars=yes")}openCommentDialog(e){this.dialog.open(fe,{data:{comment:e.comment,label:e.label,updateComment:i=>this.applyComment(e,i)}})}applyComment(e,i){e.comment=i,this.budgetForm()?.markAllAsTouched(),this.hasUnsavedChanges.set(!0)}openLiquidityCommentDialog(e){e.fieldId!=null&&this.dialog.open(fe,{data:{comment:e.comment,label:e.name,description:"L\xE4gg till en kommentar f\xF6r den h\xE4r raden. Den visas under raden i budgeten.",updateComment:i=>this.applyLiquidityComment(e,i)}})}applyLiquidityComment(e,i){e.comment=i,this.hasUnsavedChanges.set(!0)}openPeriodiseDialog(e){let i=this.budgetInfo();i&&this.dialog.open(be,{data:{title:`Periodisera kontot: ${e.label}`,target:{kind:"account",budgetId:i.id,account:e.account},onSaved:()=>e.hasPeriods=!0}})}openLiquidityPeriodiseDialog(e){let i=this.budgetInfo();!i||e.fieldId==null||this.dialog.open(be,{data:{title:`Periodisera: ${e.name}`,target:{kind:"liquidity",budgetId:i.id,fieldId:e.fieldId},onSaved:()=>e.hasPeriods=!0}})}reset(){let e=this.model(),i=this.pristine;!e||!i||(e.budgetForm.reset(i.budget),e.liquidityForm.reset(i.liquidity),e.chargeBasisForm.reset(i.chargeBasis),i.comments.forEac
1h((n,c)=>c.comment=n),this.hasUnsavedChanges.set(!1))}save(){let e=this.budgetInfo();if(!e||!this.canEdit())return;let i=this.amountFormatType();this.sharedService.appLoader({show:!0});let n=[this.budgetService.saveBudget(e.id,he(this.accountRows(),i)),this.budgetService.saveLiquidityBudget(e.id,ve(this.liquidityRows(),i)),this.budgetService.saveLiquidityBudgetComments(e.id,xe(this.liquidityRows()))],c=ye(this.chargeBasisSections());Object.keys(c).length>0&&n.push(this.budgetService.saveChargeBasisBudget(e.id,c)),ue(n).subscribe({next:()=>{this.sharedService.openSnackBar({status:"success",message:"Budgeten sparades"}),this.reloadBudget()},error:()=>{this.sharedService.appLoader({show:!1}),this.sharedService.openSnackBar({status:"error",message:"Budgeten kunde inte sparas"})},complete:()=>this.sharedService.appLoader({show:!1})})}lock(){let e=this.budgetInfo();if(!e||!this.canEdit())return;this.dialog.open(Ae,{data:{text:'Om du l\xE5ser budgeten kan inga fler \xE4ndringar g\xF6ras i den. Klicka p\xE5 "Bekr\xE4fta" f\xF6r att l\xE5sa, avbryt annars.'}}).afterClosed().subscribe({next:n=>{if(n!==!0)return;let c=this.amountFormatType();this.sharedService.appLoader({show:!0});let _=[this.budgetService.saveLiquidityBudget(e.id,ve(this.liquidityRows(),c)),this.budgetService.saveLiquidityBudgetComments(e.id,xe(this.liquidityRows()))],x=ye(this.chargeBasisSections());Object.keys(x).length>0&&_.push(this.budgetService.saveChargeBasisBudget(e.id,x)),ue(_).pipe(Fe(()=>this.budgetService.lockBudget(e.id,he(this.accountRows(),c)))).subscribe({next:()=>{this.sharedService.openSnackBar({status:"success",message:"Budgeten \xE4r l\xE5st"}),this.reloadBudget()},error:()=>{this.sharedService.appLoader({show:!1}),this.sharedService.openSnackBar({status:"error",message:"Budgeten kunde inte l\xE5sas"})},complete:()=>this.sharedService.appLoader({show:!1})})}})}canDeactivate(){let e=this.budgetForm();if(!e||this.isLocked())return!0;let i=[...Object.values(e.controls),...Object.values(this.liquidityForm()?.controls??{}),...Object.values(this.chargeBasisForm()?.controls??{})];return this.sharedService.confirmBeforeLeaving(i)}static{this.\u0275fac=function(i){return new(i||t)}}static{this.\u0275cmp=$({type:t,selectors:[["app-financial-budget"]],decls:11,vars:13,consts:[["header",""],["body",""],["footer",""],["backLabel","Budgetar",3,"title","subtitle","backLink"],["infoContent","","section","financial-budgets"],["actions","","label","Visa budgetutkast","icon","fa-solid fa-file-lines","severity","secondary",3,"onClick"],["actions","","label","Visa budgetutkast med kommentarer","icon","fa-solid fa-file-invoice-dollar","severity","secondary",3,"onClick"],["actions","","label","Visa utkast till likviditetsrapport","icon","fa-solid fa-calculator","severity","secondary",3,"onClick"],["actions","","label","L\xE5s budget","icon","fa-solid fa-lock","severity","secondary",3,"disabled"],[1,"flex","items-center","gap-2"],[1,"rounded-lg","border","border-red-200","bg-red-50","p-4","text-red-700"],[3,"visibleChange","visible","gridRows","liquidityRows","liquiditySum","format","yearLabel","commentLabel"],["actions","","label","L\xE5s budget","icon","fa-solid fa-lock","severity","secondary",3,"onClick","disabled"],[1,"fa","fa-spinner","fa-spin"],[1,"mt-4","block",3,"valueChange","value"],["value","budget"],["value","arende"],[1,"budget-card"],[1,"mb-4","flex","flex-wrap","items-center","justify-between","gap-4"],[1,"budget-card-title"],[1,"budget-card-subtitle","mt-1","text-sm"],[1,"flex","items-center","gap-4"],["for","toggle-comments",1,"budget-comments-toggle"],["inputId","toggle-comments",3,"ngModelChange","ngModel"],["type","button","aria-label","Ladda ned CSV-fil",1,"budget-icon-button",3,"click"],["aria-hidden","true",1,"fa","fa-file-csv"],["stickyTableHeader","",1,"w-full",3,"value","rowHover","stickyOffset"],[1,"budget-card-title","mb-3"],[1,"budget-card-copy"],[1,"budget-card-copy","italic"],[1,"w-full",3,"value","rowHover"],["scope","col"],["scope","col",1,"whitespace-nowrap","text-right"],["scope","col","aria-label","\xC5tg\xE4rder",1,"w-[1%]","whitespace-nowrap"],[3,"budget-group","budget-total-bar"],[1,"budget-account"],[3,"budget-subsum","budget-sum"],["type","button",1,"inline-flex","cursor-pointer","items-center","border-0","bg-transparent","p-0","text-left","text-inherit"],[1,"font-semibold"],["type","button",1,"inline-flex","cursor-pointer","items-center","border-0","bg-transparent","p-0","text-left","text-inherit",3,"click"],["aria-hidden","true",1,"fa-solid","mr-2","text-gray-500"],[1,"whitespace-nowrap","text-right"],[1,"whitespace-nowrap","text-right","font-semibold"],[1,"budget-comment-lines"],[1,"inline-flex","items-center","justify-end","gap-2"],["target","_blank","rel","noopener","pTooltip","Klicka f\xF6r att g\xE5 till konteringar p\xE5 detta konto f\xF6r denna period","tooltipPosition","top","appendTo","body",1,"budget-accounting-link","hover:opacity-70",3,"routerLink","queryParams"],["mode","decimal","locale","sv-SE","inputStyleClass","budget-input",3,"formControl","useGrouping","maxFractionDigits"],[1,"w-[1%]","whitespace-nowrap"],[1,"block"],["aria-hidden","true",1,"fa-regular","fa-arrow-up-right-from-square"],[1,"inline-flex","items-center","justify-end","gap-1"],["type","button","aria-label","Periodisera kontot","pTooltip","Periodisera","tooltipPosition","top","tooltipStyleClass","budget-tooltip","appendTo","body",1,"budget-icon-button",3,"click"],[1,"fa-puzzle-piece"],["type","button","tooltipPosition","top","tooltipStyleClass","budget-tooltip","appendTo","body",1,"budget-icon-button",3,"click","pTooltip"],[1,"fa-comment"],[1,"flex","items-center","justify-end","gap-1"],["type","button","aria-label","Periodisera kontot","pTooltip","Periodisera","tooltipPosition","top","tooltipStyleClass","budget-tooltip","appendTo","body",1,"budget-icon-button"],["type","button","tooltipPosition","top","tooltipStyleClass","budget-tooltip","appendTo","body","data-test","liquidity-comment-btn",1,"budget-icon-button",3,"pTooltip"],["type","button","tooltipPosition","top","tooltipStyleClass","budget-tooltip","appendTo","body","data-test","liquidity-comment-btn",1,"budget-icon-button",3,"click","pTooltip"],["aria-hidden","true"],["mode","decimal","locale","sv-SE","inputStyleClass","budget-input",3,"formControl","useGrouping","maxFractionDigits","min"],[1,"budget-total-bar"],[1,"budget-charge-note-bold"],[1,"budget-charge-note"],["mode","decimal","locale","sv-SE","inputStyleClass","budget-input",3,"formControl","useGrouping","autofocus","maxFractionDigits","min"],[1,"mt-6","block"],[3,"ticketId","coreTicketView"],[1,"mg0"],[3,"resetChanges","save"]],template:function(i,n){i&1&&(a(0,"oc-content-header",3),h(1,"app-help-section-content",4),a(2,"oc-p-button",5),v("onClick",function(){return n.showBudgetDraft(!1)}),r(),a(3,"oc-p-button",6),v("onClick",function(){return n.showBudgetDraft(!0)}),r(),a(4,"oc-p-button",7),v("onClick",function(){return n.showLiquidityReportDraft()}),r(),m(5,Qt,1,1,"oc-p-button",8),r(),m(6,Xt,4,0,"div",9)(7,Zt,2,0,"div",10)(8,en,45,12)(9,tn,2,0,"div",10),a(10,"app-budget-draft-preview-dialog",11),J("visibleChange",function(_){return W(n.draftPreviewVisible,_)||(n.draftPreviewVisible=_),_}),r()),i&2&&(C("title",n.titleText())("subtitle",n.metaText())("backLink",q(12,Wt)),l(5),u(n.isAuditor()?-1:5),l(),u(n.budgetResource.isLoading()?6:n.budgetResource.error()?7:n.budgetInfo()?8:9),l(4),G("visible",n.draftPreviewVisible),C("gridRows",n.gridRows())("liquidityRows",n.liquidityRows())("liquiditySum",n.liquiditySums().customer)("format",n.amountFormatType())("yearLabel",n.budgetYearLabel())("commentLabel",n.commentLabel()))},dependencies:[ie,O,Re,te,ee,le,re,ae,se,Ue,Ie,Ze,We,Je,Xe,Qe,Ge,Ke,Ye,A,ze,Z,tt,et,rt,it,nt,Q,X],styles:["[_nghost-%COMP%] .oc-content-header-title-group{flex:1 1 100%}[_nghost-%COMP%] .oc-content-header-actions{margin-left:auto;flex-wrap:wrap;justify-content:flex-end}[_nghost-%COMP%] .oc-content-header-actions .p-button-label{white-space:normal}[_nghost-%COMP%] .p-tabpanels{min-width:0}.budget-card[_ngcontent-%COMP%]{display:block;margin-top:1.5rem;padding:1.5rem;border:1px solid var(--oc-semantic-content-border-color, #e5e7eb);border-radius:var(--oc-semantic-border-radius-lg, 12px);background:var(--oc-semantic-content-background, #ffffff)}.budget-card-title[_ngcontent-%COMP%]{font-size:1.125rem;font-weight:700;color:var(--oc-semantic-text-color, #1f2937)}.budget-card-subtitle[_ngcontent-%COMP%]{color:var(--oc-semantic-text-color, #6b7280)}.budget-comments-toggle[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.5rem;cursor:pointer;color:var(--oc-semantic-text-color, #1f2937)}.budget-icon-button[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;padding:.4rem;border:0;border-radius:var(--oc-semantic-border-radius-sm, 6px);background:transparent;color:var(--oc-semantic-text-color, #4b5563);cursor:pointer}.budget-icon-button[_ngcontent-%COMP%]:hover{background:var(--oc-semantic-surface-hover, #f3f4f6)}.budget-comment-lines[_ngcontent-%COMP%]{display:block;padding-left:.5rem;margin-top:.25rem;font-size:.75rem;font-style:italic;color:var(--oc-semantic-text-color, #6b7280)}.budget-card-copy[_ngcontent-%COMP%]{margin:0 0 .5rem;color:var(--oc-semantic-text-color, #4b5563)}[_nghost-%COMP%] .p-datatable{overflow-x:auto;overflow-y:hidden}[_nghost-%COMP%] .p-datatable, [_nghost-%COMP%] .p-datatable-table-container{scrollbar-width:thin;scrollbar-color:rgb(0 0 0 / 25%) transparent}[_nghost-%COMP%] .p-datatable::-webkit-scrollbar, [_nghost-%COMP%] .p-datatable-table-container::-webkit-scrollbar{height:.5rem}[_nghost-%COMP%] .p-datatable::-webkit-scrollbar-thumb, [_nghost-%COMP%] .p-datatable-table-container::-webkit-scrollbar-thumb{background:#00000040;border-radius:9999px}[_nghost-%COMP%] .p-datatable-thead>tr>th{padding:.75rem 1rem;border-bottom:1px solid var(--oc-semantic-content-border-color, #e5e7eb);color:var(--oc-semantic-text-color, #1f2937)}[_nghost-%COMP%] .p-datatable-tbody>tr>td, [_nghost-%COMP%] .p-datatable-tfoot>tr>td{padding:.4rem 1rem;border-bottom:1px solid var(--oc-semantic-content-border-color, #f1f2f4);vertical-align:middle}[_nghost-%COMP%] .p-datatable-tbody>tr.budget-group>td{background:var(--oc-semantic-surface-hover, #faf6f2)}[_nghost-%COMP%] .p-datatable-tbody>tr.budget-total-bar>td, [_nghost-%COMP%] .p-datatable-tfoot>tr.budget-total-bar>td{background:var(--oc-semantic-surface-hover, #faf6f2);font-weight:600}[_nghost-%COMP%] .p-datatable-tbody>tr.budget-subsum>td, [_nghost-%COMP%] .p-datatable-tbody>tr.budget-sum>td{font-style:italic}.budget-accounting-link[_ngcontent-%COMP%]{color:var(--p-button-link-color, #1d4ed8)}[_nghost-%COMP%] input.budget-input{width:8rem;text-align:right}[_nghost-%COMP%] .p-datatable-tbody>tr.budget-charge-emphasis>td{font-style:italic}.budget-charge-note-bold[_ngcontent-%COMP%]{margin:0 0 .5rem;font-weight:700;color:var(--oc-semantic-text-color, #1f2937)}.budget-charge-note[_ngcontent-%COMP%]{margin:0;font-size:.75rem;font-style:italic;color:var(--oc-semantic-text-color, #6b7280)} .p-tooltip.budget-tooltip{max-width:12rem}"]})}}return t})();export{ao as FinancialBudgetComponent};
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.