1import{Da as te,I as oe,Xb as Ge,b as $e,q as qe}from"./chunk-KAXNKA6Y.js";import"./chunk-7B5EAB4N.js";import"./chunk-P4AWLXSQ.js";import"./chunk-KRRZGW2D.js";import"./chunk-QLBE3UGC.js";import"./chunk-NKPQKUAK.js";import"./chunk-NEUHW5A3.js";import"./chunk-LEQJ4IIU.js";import"./chunk-TFLZ2IQR.js";import{G as S,e as Te,u as G}from"./chunk-LYNHHBB7.js";import{b as w}from"./chunk-NRR7AH3C.js";import{$ as Oe,b as Fe,g as K,ha as Ue}from"./chunk-XV5UGDTZ.js";import{$ as Z,B as ve,Ba as X,C as Se,D as H,E as j,Ha as Y,Oa as ee,W as Me,Ya as Ne,Z as Q,Za as xe,_ as W,_a as De,aa as J,ab as Le,b as ge,cb as Ae,d as v,g as V,h as P,jb as we,m as k,mb as Be,o as O,ob as Ie,p as U,s as $,sb as Re,tb as Ve,vb as Pe,wb as ke,z as q}from"./chunk-NQAP53SD.js";import{$a as b,Ab as pe,Ba as _,Bb as a,Cb as C,Dc as ze,Ga as M,Ha as F,Ic as he,J as y,Kc as _e,Kf as B,Lf as I,Ma as N,Nf as R,Pa as m,Qb as A,Wb as ne,X as T,Ya as x,Yb as ue,Zb as fe,_ as ie,_a as D,ab as g,ba as z,bb as r,bg as Ee,ca as h,cb as n,cg as ye,db as c,dg as be,hb as E,kb as u,la as le,mb as f,oe as re,pb as L,ub as me,vb as ce,wb as de,xa as l,yf as Ce}from"./chunk-DF25LJWB.js";import"./chunk-O7S4L63H.js";var ot=()=>({prefix:"R$ ",thousands:".",decimal:",",align:"right"});function at(o,d){if(o&1){let e=E();r(0,"nz-col",0)(1,"nz-alert",14),u("nzOnClose",function(){let i=z(e).$implicit,s=f();return h(s.closeErrorAlert(i))}),n()()}if(o&2){let e=d.$implicit;l(),L("nzMessage",e)}}function st(o,d){if(o&1&&(r(0,"nz-col",5)(1,"nz-form-item")(2,"nz-form-label",15),a(3,"Conta de origem (d\xE9bito)"),n(),c(4,"app-filtro-contas-bancarias",16),n()(),r(5,"nz-col",5)(6,"nz-form-item")(7,"nz-form-label",15),a(8,"Conta de destino (cr\xE9dito)"),n(),c(9,"app-filtro-contas-bancarias",16),n()()),o&2){let e=f();l(4),m("formControl",e.contaDebitoControl)("pessoas_uuids",e.personsUuids)("noClearOnInit",!1),l(5),m("formControl",e.contaCreditoControl)("pessoas_uuids",e.personsUuids)("noClearOnInit",!1)}}var se=(()=>{class o{constructor(e,t){this.fb=e,this.api=t,this.nzData=ie(Ee,{optional:!0})??{},this.modalRef=ie(ye),this.isSaving=!1,this.errorList=[],this.personsUuids=[],this.typeOperationDebit=oe.Debito,this.typeOperationCredit=oe.Credito,this.isEdit=!1,this.enterpriseReady=!1,this.form=this.fb.group({tipo:[{value:"TRANSFERENCIA",disabled:!!this.nzData?.lockTipo},v.required],data:[null,v.required],valor:[null,[v.required,v.min(.01)]],descricao:[null],conta_debito_uuid:[null],conta_credito_uuid:[null],plano_debito_uuid:[null],plano_credito_uuid:[null]})}get contaDebitoControl(){return this.form.get("conta_debito_uuid")}get contaCreditoControl(){return this.form.get("conta_credito_uuid")}ngOnInit(){this.nzData?.uuid||this.nzData?.data?(this.isEdit=!0,this.loadEntry()):this.initEnterpriseFromLoggedUser()}initEnterpriseFromLoggedUser(e){let t=G();this.api.get(`/users/${t}`).subscribe(i=>{let s=i.data?.empresas?.[0]?.empresa?.uuid;this.personsUuids=s?[s]:[],this.enterpriseReady=!!s,e?.()})}loadEntry(){let e=this.nzData?.uuid??this.nzData?.data?.uuid;e&&this.api.get(`/misc-entries/${e}`).subscribe(t=>{let i=t.data,s=i.conta_debito?.pessoa?.uuid??i.conta_credito?.pessoa?.uuid,p=()=>{this.form.patchValue({tipo:i.tipo,data:i.data,valor:Number(i.valor),descricao:i.descricao,conta_debito_uuid:i.conta_debito?.uuid,conta_credito_uuid:i.conta_credito?.uuid,plano_debito_uuid:i.plano_debito?.uuid,plano_credito_uuid:i.plano_credito?.uuid})};s?(this.personsUuids=[s],this.enterpriseReady=!0,queueMicrotask(()=>p())):this.initEnterpriseFromLoggedUser(()=>queueMicrotask(()=>p()))})}submit(){if(this.form.invalid){this.form.markAllAsTouched();return}let e=this.form.getRawValue(),t=Te({tipo:e.tipo,data:S(e.data),valor:e.valor,descricao:e.descricao,conta_debito_uuid:this.contaDebitoControl.value,conta_credito_uuid:this.contaCreditoControl.value,plano_debito_uuid:e.plano_debito_uuid,plano_credito_uuid:e.plano_credito_uuid});this.isSaving=!0;let i=this.nzData?.uuid??this.nzData?.data?.uuid;(i?this.api.patch(`/misc-entries/${i}`,t):this.api.post("/misc-entries",t)).pipe(y(()=>{this.isSaving=!1})).subscribe({next:p=>{this.modalRef.close(!0)},error:p=>{Array.isArray(p.error?.message)?this.errorList=p.error.message:this.errorList=[p.error?.message??"Erro ao salvar"]}})}closeErrorAlert(e){this.errorList=this.errorList.filter(t=>t!==e)}static{this.\u0275fac=function(t){return new(t||o)(_(q),_(w))}}static{this.\u0275cmp=M({type:o,selectors:[["app-misc-entry-form"]],standalone:!1,decls:36,vars:17,consts:[["nzSpan","24"],["nz-row","","nzGutter","14","nzAlign","bottom","nz-form","","nzLayout","vertical",3,"ngSubmit","formGroup"],["nz-col","","nzSpan","24","nzRequired",""],["formControlName","tipo"],["nzValue","TRANSFERENCIA","nzLabel","Transfer\xEAncia entre contas"],["nzSpan","12"],["customFormControlName","plano_debito_uuid","nzMode","default","nzShowSearch","",3,"required","customFormGroup","accountPlaceHolder","operationType","financeiro"],["customFormControlName","plano_credito_uuid","nzMode","default","nzShowSearch","",3,"required","customFormGroup","accountPlaceHolder","operationType","financeiro"],["nzSpan","8"],["nzRequired",""],["formControlName","data",2,"width","100%",3,"nzFormat"],["nz-input","","type","text","formControlName","valor","currencyMask","",3,"options"],["nz-input","","rows","3","formControlName","descricao"],["nz-button","","nzType","primary","type","submit","nzBlock","",3,"disabled","nzLoading"],["nzShowIcon","","nzType","error","nzCloseable","",2,"margin-bottom","12px",3,"nzOnClose","nzMessage"],["nz-col","","nzSpan","24"],["nz-col","","nzSpan","24",2,"width","100%",3,"formControl","pessoas_uuids","noClearOnInit"]],template:function(t,i){t&1&&(b(0,at,2,1,"nz-col",0,D),r(2,"form",1),u("ngSubmit",function(){return i.submit()}),r(3,"nz-col",0)(4,"nz-form-item")(5,"nz-form-label",2),a(6,"Tipo"),n(),r(7,"nz-form-control")(8,"nz-select",3),c(9,"nz-option",4),n()()()(),N(10,st,10,6),r(11,"nz-col",5),c(12,"app-filter-account-plan",6),n(),r(13,"nz-col",5),c(14,"app-filter-account-plan",7),n(),r(15,"nz-col",8)(16,"nz-form-item")(17,"nz-form-label",9),a(18,"Data"),n(),r(19,"nz-form-control"),c(20,"nz-date-picker",10),n()()(),r(21,"nz-col",8)(22,"nz-form-item")(23,"nz-form-label",9),a(24,"Valor"),n(),r(25,"nz-form-control"),c(26,"input",11),n()()(),r(27,"nz-col",0)(28,"nz-form-item")(29,"nz-form-label"),a(30,"Hist\xF3rico"),n(),r(31,"nz-form-control"),c(32,"textarea",12),n()()(),r(33,"nz-col",0)(34,"button",13),a(35," Salvar "),n()()()),t&2&&(g(i.errorList),l(2),m("formGroup",i.form),l(8),x(i.enterpriseReady?10:-1),l(2),m("required",!1)("customFormGroup",i.form)("accountPlaceHolder","Plano de contas (d\xE9bito)")("operationType",i.typeOperationDebit)("financeiro",!0),l(2),m("required",!1)("customFormGroup",i.form)("accountPlaceHolder","Plano de contas (cr\xE9dito)")("operationType",i.typeOperationCredit)("financeiro",!0),l(6),m("nzFormat","dd/MM/yyyy"),l(6),m("options",A(16,ot)),l(8),m("disabled",i.form.invali
1d)("nzLoading",i.isSaving))},dependencies:[qe,$e,te,K,R,B,I,ee,j,H,W,Q,J,Z,Fe,X,Y,k,ge,V,P,O,U,$],encapsulation:2})}}return o})();var He={TRANSFERENCIA:"Transfer\xEAncia entre contas"};var lt=["miscEntriesTable"],mt=()=>({y:"65vh"}),ct=(o,d)=>d.uuid;function dt(o,d){if(o&1&&c(0,"app-filtro-contas-bancarias",9),o&2){let e=f();m("noClearOnInit",!1)("pessoas_uuids",e.personsUuids)("formControl",e.contaBancariaFilterControl)}}function pt(o,d){if(o&1){let e=E();r(0,"nz-col",16)(1,"nz-alert",21),u("nzOnClose",function(){let i=z(e).$implicit,s=f();return h(s.onCloseError(i))}),n()()}if(o&2){let e=d.$implicit;l(),L("nzMessage",e)}}function ut(o,d){if(o&1){let e=E();r(0,"tr")(1,"td"),a(2),ne(3,"date"),n(),r(4,"td"),a(5),n(),r(6,"td"),a(7),n(),r(8,"td"),a(9),n(),r(10,"td"),a(11),n(),r(12,"td",19),a(13),ne(14,"currency"),n(),r(15,"td",20)(16,"a",22),u("click",function(){let i=z(e).$implicit,s=f();return h(s.openEditModal(i))}),c(17,"span",23),n(),r(18,"a",24),u("nzOnConfirm",function(){let i=z(e).$implicit,s=f();return h(s.deleteEntry(i.uuid))}),c(19,"span",25),n()()()}if(o&2){let e=d.$implicit,t=f();l(2),C(fe(3,6,e.data,"dd/MM/yyyy","UTC")),l(3),C(t.typeLabels[e.tipo]||e.tipo),l(2),C(t.formatAccount(e.conta_debito)),l(2),C(t.formatAccount(e.conta_credito)),l(2),C(e.descricao||"-"),l(2),C(ue(14,10,e.valor,"BRL"))}}var je=(()=>{class o{constructor(e,t,i){this.api=e,this.fb=t,this.modalService=i,this.tableBodyEl=null,this.scrollListener=s=>this.onTableScroll(s),this.allEntries=[],this.displayedEntries=[],this.isLoading=!1,this.hasSearched=!1,this.errorList=[],this.typeLabels=He,this.personsUuids=[],this.batchSize=20,this.scrollThreshold=120,this.searchForm=this.fb.group({data_inicio:[null],data_fim:[null],conta_bancaria_uuid:[null],tipo:[null]}),this.getEnterpriseUuid()}ngAfterViewInit(){this.bindTableBodyScroll()}ngOnDestroy(){this.tableBodyEl?.removeEventListener("scroll",this.scrollListener)}getEnterpriseUuid(){let e=G();this.api.get(`/users/${e}`).subscribe(t=>{let i=t.data?.empresas?.[0]?.empresa?.uuid;this.personsUuids=i?[i]:[]})}get contaBancariaFilterControl(){return this.searchForm.get("conta_bancaria_uuid")}get hasActiveFilters(){let{data_inicio:e,data_fim:t,conta_bancaria_uuid:i,tipo:s}=this.searchForm.value||{};return!!(e||t||i||s)}searchEntries(){if(!this.hasActiveFilters)return;this.isLoading=!0,this.errorList=[];let e=this.searchForm.value,t={};e.data_inicio&&(t.data_inicio=S(e.data_inicio)),e.data_fim&&(t.data_fim=S(e.data_fim)),e.conta_bancaria_uuid&&(t.conta_bancaria_uuid=e.conta_bancaria_uuid),e.tipo&&(t.tipo=e.tipo),this.api.post("/misc-entries/list",t).pipe(y(()=>{this.isLoading=!1,this.scheduleBindTableBodyScroll()})).subscribe({next:i=>{this.allEntries=i.data??[],this.hasSearched=!0,this.resetDisplayedEntries()},error:i=>{Array.isArray(i.error?.message)?this.errorList=i.error.message:this.errorList=[i.error?.message??"Erro ao buscar lan\xE7amentos"]}})}clearResults(){this.allEntries=[],this.displayedEntries=[],this.hasSearched=!1}resetDisplayedEntries(){this.displayedEntries=[],this.appendNextBatch(),this.scheduleBindTableBodyScroll()}appendNextBatch(){if(this.displayedEntries.length>=this.allEntries.length)return;let e=this.allEntries.slice(this.displayedEntries.length,this.displayedEntries.length+this.batchSize);this.displayedEntries=[...this.displayedEntries,...e]}bindTableBodyScroll(){let e=this.miscEntriesTableRef?.nativeElement?.querySelector(".ant-table-body");e&&(this.tableBodyEl&&this.tableBodyEl!==e&&this.tableBodyEl.removeEventListener("scroll",this.scrollListener),this.tableBodyEl=e,e.addEventListener("scroll",this.scrollListener))}scheduleBindTableBodyScroll(){requestAnimationFrame(()=>this.bindTableBodyScroll())}onTableScroll(e){let t=e.target;if(!t)return;t.scrollTop+t.clientHeight>=t.scrollHeight-this.scrollThreshold&&this.appendNextBatch()}openCreateModal(){this.modalService.create({nzTitle:"Cadastrar lan\xE7amento avulso",nzContent:se,nzFooter:null,nzWidth:"720px",nzData:{lockTipo:!1}}).afterClose.subscribe(t=>{t&&this.clearResults()})}openEditModal(e){this.modalService.create({nzTitle:"Editar lan\xE7amento avulso",nzContent:se,nzFooter:null,nzWidth:"720px",nzData:{uuid:e.uuid,data:e,lockTipo:!0}}).afterClose.subscribe(i=>{i&&this.hasSearched&&this.searchEntries()})}deleteEntry(e){this.isLoading=!0,this.api.delete(`/misc-entries/${e}`).pipe(y(()=>{this.isLoading=!1})).subscribe({next:()=>{this.hasSearched&&this.searchEntries()},error:t=>{Array.isArray(t.error?.message)?this.errorList=t.error.message:this.errorList=[t.error?.message??"Erro ao excluir lan\xE7amento"]}})}formatAccount(e){return e?`${e.banco?.codigo?`${e.banco.codigo} - `:""}${e.agencia}/${e.numero}`:"-"}onCloseError(e){this.errorList=this.errorList.filter(t=>t!==e)}static{this.\u0275fac=function(t){return new(t||o)(_(w),_(q),_(be))}}static{this.\u0275cmp=M({type:o,selectors:[["app-misc-entries-main"]],viewQuery:function(t,i){if(t&1&&me(lt,5,le),t&2){let s;ce(s=de())&&(i.miscEntriesTableRef=s.first)}},standalone:!1,decls:62,vars:13,consts:[["miscEntriesTable","","dynamicTable",""],["nzBackIcon","",3,"nzGhost"],["nz-button","","nzType","primary",3,"click"],["nz-icon","","nzType","plus"],["nz-form","","nzLayout","vertical","nz-row","","nzGutter","12",3,"ngSubmit","formGroup"],["nz-col","","nzSpan","5"],["formControlName","data_inicio",2,"width","100%",3,"nzFormat"],["formControlName","data_fim",2,"width","100%",3,"nzFormat"],["nz-col","","nzSpan","8"],["nz-col","","nzSpan","24",2,"width","100%",3,"noClearOnInit","pessoas_uuids","formControl"],["nz-col","","nzSpan","4"],["nz-col","","nzSpan","24"],["formControlName","tipo","nzAllowClear","","nzPlaceHolder","Todos","nz-col","","nzSpan","24",2,"width","100%"],["nzValue","TRANSFERENCIA","nzLabel","Transfer\xEAncia entre contas"],["nz-col","","nzSpan","2"],["nz-button","","nzType","primary","type","submit","nzBlock","","nz-tooltip","",2,"margin-top","29px",3,"disabled","nzTooltipTitle"],["nzSpan","24"],[1,"table-container"],["nzSize","small",1,"misc-entries-table",3,"nzData","nzLoading","nzFrontPagination","nzShowPagination","nzScroll"],["nzAlign","right"],["nzAlign","center"],["nzShowIcon","","nzType","error","nzCloseable","",2,"margin-bottom","12px",3,"nzOnClose","nzMessage"],["nz-button","","nzType","link",3,"click"],["nz-icon","","nzType","edit"],["nz-button","","nzType","link","nzDanger","","nz-popconfirm","","nzPopconfirmTitle","Excluir este lan\xE7amento?",3,"nzOnConfirm"],["nz-icon","","nzType","delete"]],template:function(t,i){if(t&1){let s=E();r(0,"nz-page-header",1)(1,"nz-page-header-title"),a(2,"Lan\xE7amentos Avulsos"),n(),r(3,"nz-page-header-subtitle"),a(4,"Registrar transfer\xEAncias e outros lan\xE7amentos fora de contas a pagar"),n(),r(5,"nz-page-header-extra")(6,"button",2),u("click",function(){return z(s),h(i.openCreateModal())}),c(7,"span",3),a(8," Cadastrar "),n()(),r(9,"nz-page-header-content")(10,"form",4),u("ngSubmit",function(){return z(s),h(i.searchEntries())}),r(11,"div",5)(12,"nz-form-item")(13,"nz-form-label"),a(14,"Data inicial"),n(),c(15,"nz-date-picker",6),n()(),r(16,"div",5)(17,"nz-form-item")(18,"nz-form-label"),a(19,"Data final"),n(),c(20,"nz-date-picker",7),n()(),r(21,"div",8)(22,"nz-form-item")(23,"nz-form-label"),a(24,"Conta banc\xE1ria"),n(),N(25,dt,1,3,"app-filtro-contas-bancarias",9),n()(),r(26,"div",10)(27,"nz-form-item")(28,"nz-form-label",11),a(29,"Tipo"),n(),r(30,"nz-select",12),c(31,"nz-option",13),n()()(),r(32,"div",14)(33,"nz-form-item")(34,"nz-form-control")(35,"button",15),a(36," Buscar "),n()()()()(),b(37,pt,2,1,"nz-col",16,D),r(39,"div",17)(40,"nz-table",18,0)(43,"thead")(44,"tr")(45,"th"),a(46,"Data"),n(),r(47,"th"),a(48,"Tipo"),n(),r(49,"th"),a(50,"Conta d\xE9bito"),n(),r(51,"th"),a(52,"Conta cr\xE9dito"),n(),r(53,"th"),a(54,"Hist\xF3rico"),n(),r(55,"th",19),a(56,"Valor"),n(),r(57,"th",20),a(58,"A\xE7\xF5es"),n()()(),r(59,"tbody"),b(60,ut,20,13,"tr",null,ct),n()()()()()}if(t&2){let s=pe(42);m("nzGhost",!1),l(10),m("formGroup",i.searchForm),l(5),m("nzFormat","dd/MM/yyyy"),l(5),m("nzFormat","dd/MM/yyyy"),l(5),x(i.personsUuids.length?25:-1),l(10),m("disabled",!i.hasActiveFilters)("nzTooltipTitle",i.hasActiveFilters?"":"Selecione pelo menos um filtro"),l(2),g(i.errorList),l(3),m("nzData",i.displayedEntries)("nzLoading",i.isLoading)("nzFrontPagination",!1)("nzShowPagination",!1)("nzScroll",A(12,mt)),l(20),g(s.data)}},dependencies:[te,K,R,B,I,ee,j,H,W,Q,J,Z,Ce,Ae,Ne,xe,De,Le,X,Y,Ve,we,Be,ke,Re,Pe,Ie,Me,Oe,k,V,P,O,U,$,he,ze],styles:[".table-container[_ngcontent-%COMP%]{padding:0}[_nghost-%COMP%] .misc-entries-table .ant-table-header{overflow:visible!important}"]})}}return o}
1)();var ft=[{path:"",component:je}],Qe=(()=>{class o{static{this.\u0275fac=function(t){return new(t||o)}}static{this.\u0275mod=F({type:o})}static{this.\u0275inj=T({imports:[re.forChild(ft),re]})}}return o})();var ei=(()=>{class o{static{this.\u0275fac=function(t){return new(t||o)}}static{this.\u0275mod=F({type:o})}static{this.\u0275inj=T({imports:[_e,Qe,Ge,Ue,Se,ve]})}}return o})();export{ei as MiscEntriesModule};
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.