@seniorsistemas/yms-integration 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/seniorsistemas-yms-integration.umd.js +2922 -1185
- package/bundles/seniorsistemas-yms-integration.umd.js.map +1 -1
- package/bundles/seniorsistemas-yms-integration.umd.min.js +1 -1
- package/bundles/seniorsistemas-yms-integration.umd.min.js.map +1 -1
- package/esm2015/index.js +9 -1
- package/esm2015/seniorsistemas-yms-integration.js +48 -38
- package/esm2015/src/devices/balancas/balancas.service.js +4 -1
- package/esm2015/src/devices/balancas/visualiar-balanca/visualizar-balanca.component.js +8 -25
- package/esm2015/src/devices/balancas/weightScale.js +1 -1
- package/esm2015/src/devices/cancelas/cancelas.service.js +5 -1
- package/esm2015/src/devices/cancelas/controlador-cancela/controlador-cancela.component.js +91 -21
- package/esm2015/src/devices/cancelas/gate.js +1 -1
- package/esm2015/src/devices/dock/dock.module.js +12 -0
- package/esm2015/src/devices/dock/dock.service.js +22 -0
- package/esm2015/src/erp-senior/components/nota-form/nota-form.component.js +24 -9
- package/esm2015/src/erp-senior/core/entities/agenda/agenda.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/cidade/cidade.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/contrato-compra/contrato-compra.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/contrato-compra-item/contrato-compra-item.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/derivacao/derivacao.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/devolucao/devolucao.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/empresa/empresa.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/estado/estado.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/expedicao/expedicao.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/familia-produto/familia-produto.js +5 -7
- package/esm2015/src/erp-senior/core/entities/familia-produto/familia-produto.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/filial/filial.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/log-integracao/log-integracao.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/motorista/motorista.js +1 -1
- package/esm2015/src/erp-senior/core/entities/ordem-compra/ordem-compra.module.js +7 -2
- package/esm2015/src/erp-senior/core/entities/pais/pais.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/pedido-venda/pedido-venda.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/pedido-venda-item/pedido-venda-item.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/pessoa/pessoa.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/pessoa-endereco/pessoa-endereco-dto.js +1 -5
- package/esm2015/src/erp-senior/core/entities/pessoa-endereco/pessoa-endereco.js +1 -7
- package/esm2015/src/erp-senior/core/entities/pessoa-endereco/pessoa-endereco.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/pessoa-fisica/pessoa-fisica.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/pessoa-juridica/pessoa-juridica.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/processo-avulso/processo-avulso.module.js +7 -2
- package/esm2015/src/erp-senior/core/entities/produto/produto.js +1 -9
- package/esm2015/src/erp-senior/core/entities/produto/produto.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/recebimento-contrato/recebimento.module.js +7 -2
- package/esm2015/src/erp-senior/core/entities/recebimento-ordem-compra/recebimento-ordem-compra.module.js +11 -12
- package/esm2015/src/erp-senior/core/entities/royalty/royalty.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/safra/safra.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/transgenia/transgenia.js +1 -1
- package/esm2015/src/erp-senior/core/entities/transportadora/transportadora.module.js +2 -2
- package/esm2015/src/erp-senior/core/entities/unidade-medida/unidade-medida.module.js +2 -2
- package/esm2015/src/erp-senior/core/verifica-nota-fiscal/verificaNotaFiscal.js +9 -1
- package/esm2015/src/erp-senior/devolucao/form/devolucao-form.component.js +12 -7
- package/esm2015/src/erp-senior/expedicao/form/expedicao-form.component.js +15 -21
- package/esm2015/src/erp-senior/processo-avulso/form/processo-avulso-form.component.js +7 -2
- package/esm2015/src/erp-senior/recebimento/contrato-form/contrato-form.component.js +20 -4
- package/esm2015/src/erp-senior/recebimento/form/recebimento-form.component.js +242 -199
- package/esm2015/src/erp-senior/recebimento-ordem-compra/form/recebimento-ordem-compra-form.component.js +29 -20
- package/esm2015/src/erp-senior/recebimento-ordem-compra/ordem-compra-form/ordem-compra-form.component.js +13 -4
- package/esm2015/src/sam-senior/components/credencial-form/credencial-form.component.js +126 -0
- package/esm2015/src/sam-senior/components/scheduling/lobby.service.js +22 -0
- package/esm2015/src/sam-senior/components/scheduling/scheduling.component.js +191 -0
- package/esm2015/src/sam-senior/components/scheduling/shechuling.service.js +40 -0
- package/esm2015/src/sam-senior/components/visited-info/visited-info.component.js +59 -0
- package/esm2015/src/sam-senior/components/visited-info/visited-info.service.js +26 -0
- package/esm2015/src/sam-senior/components/visitor-edit/visitor-edit-form/visitante-form/visitor-edit-form.component.js +84 -0
- package/esm2015/src/sam-senior/components/visitor-edit/visitor-edit-list/visitor-edit-list.component.js +364 -0
- package/esm2015/src/sam-senior/components/visitor-list/visitor-list.component.js +64 -0
- package/esm2015/src/sam-senior/components/visitor-list/visitor-list.service.js +26 -0
- package/esm2015/src/sam-senior/components/visitor-list.module.js +36 -0
- package/esm2015/src/sam-senior/core/entity-service.js +102 -0
- package/esm2015/src/sam-senior/core/lookup.js +184 -0
- package/esm2015/src/sam-senior/core/utils.js +26 -0
- package/esm2015/src/sam-senior/entities/credential-card-dto.js +9 -0
- package/esm2015/src/sam-senior/entities/lobby-dto.js +3 -0
- package/esm2015/src/sam-senior/entities/scheduling-dto.js +3 -0
- package/esm2015/src/sam-senior/entities/scheduling-visitors.js +3 -0
- package/esm2015/src/sam-senior/entities/scheduling.js +26 -0
- package/esm2015/src/sam-senior/entities/visited.js +3 -0
- package/esm2015/src/sam-senior/entities/visitor-credentials-dto.js +6 -0
- package/esm2015/src/sam-senior/entities/visitor-dto.js +1 -0
- package/esm2015/src/sam-senior/entities/visitor-situation.js +10 -0
- package/esm2015/src/sam-senior/form/form-sam.component.js +61 -0
- package/esm2015/src/sam-senior/models/card-credential.js +7 -0
- package/esm2015/src/sam-senior/models/visit-situation.js +8 -0
- package/esm2015/src/sam-senior/models/visitor-situation.js +10 -0
- package/esm2015/src/sam-senior/models/visitor.js +23 -0
- package/esm2015/src/sam-senior/sam-senior.module.js +75 -0
- package/esm2015/src/utils/build-form-field.js +28 -0
- package/esm5/index.js +9 -1
- package/esm5/seniorsistemas-yms-integration.js +48 -38
- package/esm5/src/devices/balancas/balancas.service.js +4 -1
- package/esm5/src/devices/balancas/visualiar-balanca/visualizar-balanca.component.js +8 -25
- package/esm5/src/devices/balancas/weightScale.js +1 -1
- package/esm5/src/devices/cancelas/cancelas.service.js +5 -1
- package/esm5/src/devices/cancelas/controlador-cancela/controlador-cancela.component.js +94 -21
- package/esm5/src/devices/cancelas/gate.js +1 -1
- package/esm5/src/devices/dock/dock.module.js +15 -0
- package/esm5/src/devices/dock/dock.service.js +25 -0
- package/esm5/src/erp-senior/components/nota-form/nota-form.component.js +24 -9
- package/esm5/src/erp-senior/core/entities/agenda/agenda.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/cidade/cidade.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/contrato-compra/contrato-compra.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/contrato-compra-item/contrato-compra-item.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/derivacao/derivacao.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/devolucao/devolucao.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/empresa/empresa.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/estado/estado.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/expedicao/expedicao.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/familia-produto/familia-produto.js +5 -7
- package/esm5/src/erp-senior/core/entities/familia-produto/familia-produto.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/filial/filial.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/log-integracao/log-integracao.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/motorista/motorista.js +1 -1
- package/esm5/src/erp-senior/core/entities/ordem-compra/ordem-compra.module.js +7 -2
- package/esm5/src/erp-senior/core/entities/pais/pais.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/pedido-venda/pedido-venda.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/pedido-venda-item/pedido-venda-item.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/pessoa/pessoa.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/pessoa-endereco/pessoa-endereco-dto.js +1 -5
- package/esm5/src/erp-senior/core/entities/pessoa-endereco/pessoa-endereco.js +1 -7
- package/esm5/src/erp-senior/core/entities/pessoa-endereco/pessoa-endereco.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/pessoa-fisica/pessoa-fisica.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/pessoa-juridica/pessoa-juridica.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/processo-avulso/processo-avulso.module.js +7 -2
- package/esm5/src/erp-senior/core/entities/produto/produto.js +1 -9
- package/esm5/src/erp-senior/core/entities/produto/produto.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/recebimento-contrato/recebimento.module.js +7 -2
- package/esm5/src/erp-senior/core/entities/recebimento-ordem-compra/recebimento-ordem-compra.module.js +11 -12
- package/esm5/src/erp-senior/core/entities/royalty/royalty.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/safra/safra.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/transgenia/transgenia.js +1 -1
- package/esm5/src/erp-senior/core/entities/transportadora/transportadora.module.js +2 -2
- package/esm5/src/erp-senior/core/entities/unidade-medida/unidade-medida.module.js +2 -2
- package/esm5/src/erp-senior/core/verifica-nota-fiscal/verificaNotaFiscal.js +9 -1
- package/esm5/src/erp-senior/devolucao/form/devolucao-form.component.js +12 -7
- package/esm5/src/erp-senior/expedicao/form/expedicao-form.component.js +15 -21
- package/esm5/src/erp-senior/processo-avulso/form/processo-avulso-form.component.js +7 -2
- package/esm5/src/erp-senior/recebimento/contrato-form/contrato-form.component.js +21 -4
- package/esm5/src/erp-senior/recebimento/form/recebimento-form.component.js +244 -203
- package/esm5/src/erp-senior/recebimento-ordem-compra/form/recebimento-ordem-compra-form.component.js +29 -20
- package/esm5/src/erp-senior/recebimento-ordem-compra/ordem-compra-form/ordem-compra-form.component.js +14 -4
- package/esm5/src/sam-senior/components/credencial-form/credencial-form.component.js +144 -0
- package/esm5/src/sam-senior/components/scheduling/lobby.service.js +25 -0
- package/esm5/src/sam-senior/components/scheduling/scheduling.component.js +199 -0
- package/esm5/src/sam-senior/components/scheduling/shechuling.service.js +43 -0
- package/esm5/src/sam-senior/components/visited-info/visited-info.component.js +56 -0
- package/esm5/src/sam-senior/components/visited-info/visited-info.service.js +29 -0
- package/esm5/src/sam-senior/components/visitor-edit/visitor-edit-form/visitante-form/visitor-edit-form.component.js +87 -0
- package/esm5/src/sam-senior/components/visitor-edit/visitor-edit-list/visitor-edit-list.component.js +384 -0
- package/esm5/src/sam-senior/components/visitor-list/visitor-list.component.js +82 -0
- package/esm5/src/sam-senior/components/visitor-list/visitor-list.service.js +29 -0
- package/esm5/src/sam-senior/components/visitor-list.module.js +37 -0
- package/esm5/src/sam-senior/core/entity-service.js +107 -0
- package/esm5/src/sam-senior/core/lookup.js +229 -0
- package/esm5/src/sam-senior/core/utils.js +28 -0
- package/esm5/src/sam-senior/entities/credential-card-dto.js +13 -0
- package/esm5/src/sam-senior/entities/lobby-dto.js +7 -0
- package/esm5/src/sam-senior/entities/scheduling-dto.js +7 -0
- package/esm5/src/sam-senior/entities/scheduling-visitors.js +7 -0
- package/esm5/src/sam-senior/entities/scheduling.js +30 -0
- package/esm5/src/sam-senior/entities/visited.js +7 -0
- package/esm5/src/sam-senior/entities/visitor-credentials-dto.js +8 -0
- package/esm5/src/sam-senior/entities/visitor-dto.js +1 -0
- package/esm5/src/sam-senior/entities/visitor-situation.js +10 -0
- package/esm5/src/sam-senior/form/form-sam.component.js +64 -0
- package/esm5/src/sam-senior/models/card-credential.js +7 -0
- package/esm5/src/sam-senior/models/visit-situation.js +8 -0
- package/esm5/src/sam-senior/models/visitor-situation.js +10 -0
- package/esm5/src/sam-senior/models/visitor.js +32 -0
- package/esm5/src/sam-senior/sam-senior.module.js +76 -0
- package/esm5/src/utils/build-form-field.js +29 -0
- package/fesm2015/seniorsistemas-yms-integration.js +2763 -1193
- package/fesm2015/seniorsistemas-yms-integration.js.map +1 -1
- package/fesm5/seniorsistemas-yms-integration.js +2888 -1169
- package/fesm5/seniorsistemas-yms-integration.js.map +1 -1
- package/index.d.ts +7 -0
- package/package.json +3 -3
- package/seniorsistemas-yms-integration.d.ts +47 -37
- package/seniorsistemas-yms-integration.metadata.json +1 -1
- package/src/devices/balancas/balancas.service.d.ts +1 -0
- package/src/devices/balancas/visualiar-balanca/visualizar-balanca.component.d.ts +2 -11
- package/src/devices/balancas/weightScale.d.ts +2 -2
- package/src/devices/cancelas/cancelas.service.d.ts +1 -0
- package/src/devices/cancelas/controlador-cancela/controlador-cancela.component.d.ts +12 -8
- package/src/devices/cancelas/gate.d.ts +2 -0
- package/src/devices/dock/dock.module.d.ts +2 -0
- package/src/devices/dock/dock.service.d.ts +10 -0
- package/src/erp-senior/components/nota-form/nota-form.component.d.ts +7 -1
- package/src/erp-senior/core/entities/motorista/motorista.d.ts +3 -0
- package/src/erp-senior/core/entities/pessoa-endereco/pessoa-endereco-dto.d.ts +2 -0
- package/src/erp-senior/core/entities/pessoa-endereco/pessoa-endereco.d.ts +2 -0
- package/src/erp-senior/core/entities/transgenia/transgenia.d.ts +2 -0
- package/src/erp-senior/core/verifica-nota-fiscal/verificaNotaFiscal.d.ts +2 -0
- package/src/erp-senior/devolucao/form/devolucao-form.component.d.ts +2 -0
- package/src/erp-senior/processo-avulso/form/processo-avulso-form.component.d.ts +2 -0
- package/src/erp-senior/recebimento/contrato-form/contrato-form.component.d.ts +10 -4
- package/src/erp-senior/recebimento/form/recebimento-form.component.d.ts +25 -10
- package/src/erp-senior/recebimento-ordem-compra/form/recebimento-ordem-compra-form.component.d.ts +4 -2
- package/src/erp-senior/recebimento-ordem-compra/ordem-compra-form/ordem-compra-form.component.d.ts +6 -2
- package/src/sam-senior/components/credencial-form/credencial-form.component.d.ts +29 -0
- package/src/sam-senior/components/scheduling/lobby.service.d.ts +9 -0
- package/src/sam-senior/components/scheduling/scheduling.component.d.ts +43 -0
- package/src/sam-senior/components/scheduling/shechuling.service.d.ts +14 -0
- package/src/sam-senior/components/visited-info/visited-info.component.d.ts +15 -0
- package/src/sam-senior/components/visited-info/visited-info.service.d.ts +10 -0
- package/src/sam-senior/components/visitor-edit/visitor-edit-form/visitante-form/visitor-edit-form.component.d.ts +22 -0
- package/src/sam-senior/components/visitor-edit/visitor-edit-list/visitor-edit-list.component.d.ts +56 -0
- package/src/sam-senior/components/visitor-list/visitor-list.component.d.ts +16 -0
- package/src/sam-senior/components/visitor-list/visitor-list.service.d.ts +10 -0
- package/src/sam-senior/components/visitor-list.module.d.ts +5 -0
- package/src/sam-senior/core/entity-service.d.ts +35 -0
- package/src/sam-senior/core/lookup.d.ts +38 -0
- package/src/sam-senior/core/utils.d.ts +18 -0
- package/src/sam-senior/entities/credential-card-dto.d.ts +12 -0
- package/src/sam-senior/entities/lobby-dto.d.ts +5 -0
- package/src/sam-senior/entities/scheduling-dto.d.ts +11 -0
- package/src/sam-senior/entities/scheduling-visitors.d.ts +6 -0
- package/src/sam-senior/entities/scheduling.d.ts +12 -0
- package/src/sam-senior/entities/visited.d.ts +4 -0
- package/src/sam-senior/entities/visitor-credentials-dto.d.ts +6 -0
- package/src/sam-senior/entities/visitor-dto.d.ts +10 -0
- package/src/sam-senior/entities/visitor-situation.d.ts +8 -0
- package/src/sam-senior/form/form-sam.component.d.ts +18 -0
- package/src/sam-senior/models/card-credential.d.ts +16 -0
- package/src/sam-senior/models/visit-situation.d.ts +6 -0
- package/src/sam-senior/models/visitor-situation.d.ts +8 -0
- package/src/sam-senior/models/visitor.d.ts +24 -0
- package/src/sam-senior/sam-senior.module.d.ts +6 -0
- package/src/utils/build-form-field.d.ts +9 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("rxjs"),require("rxjs/operators"),require("@angular/common"),require("@angular/core"),require("@ngx-translate/core"),require("@seniorsistemas/angular-components"),require("primeng/message"),require("primeng/table"),require("@angular/common/http"),require("primeng/api"),require("@seniorsistemas/yms-routines"),require("@angular/animations"),require("@seniorsistemas/platform-components"),require("@stomp/ng2-stompjs"),require("ngx-cookie-service"),require("sockjs-client"),require("primeng/components/dynamicdialog/dynamicdialog"),require("primeng/primeng"),require("@seniorsistemas/yms-components"),require("@angular/router"),require("primeng/inputswitch"),require("primeng/inputtext"),require("@angular/forms"),require("primeng/components/common/messageservice"),require("moment"),require("ngx-highlightjs"),require("primeng/accordion"),require("primeng/confirmdialog"),require("primeng/dialog"),require("primeng/dropdown"),require("primeng/panel"),require("angular2-hotkeys"),require("primeng/components/common/api"),require("highlight.js/lib/languages/json"),require("highlight.js/lib/languages/xml")):"function"==typeof define&&define.amd?define("@seniorsistemas/yms-integration",["exports","rxjs","rxjs/operators","@angular/common","@angular/core","@ngx-translate/core","@seniorsistemas/angular-components","primeng/message","primeng/table","@angular/common/http","primeng/api","@seniorsistemas/yms-routines","@angular/animations","@seniorsistemas/platform-components","@stomp/ng2-stompjs","ngx-cookie-service","sockjs-client","primeng/components/dynamicdialog/dynamicdialog","primeng/primeng","@seniorsistemas/yms-components","@angular/router","primeng/inputswitch","primeng/inputtext","@angular/forms","primeng/components/common/messageservice","moment","ngx-highlightjs","primeng/accordion","primeng/confirmdialog","primeng/dialog","primeng/dropdown","primeng/panel","angular2-hotkeys","primeng/components/common/api","highlight.js/lib/languages/json","highlight.js/lib/languages/xml"],t):t(((e=e||self).seniorsistemas=e.seniorsistemas||{},e.seniorsistemas["yms-integration"]={}),e.rxjs,e.rxjs.operators,e.ng.common,e.ng.core,e.core$1,e.angularComponents,e.message,e.table,e.ng.common.http,e.api,e.ymsRoutines,e.ng.animations,e.platformComponents,e.ng2Stompjs,e.ngxCookieService,e.SockJS,e.dynamicdialog,e.primeng,e.ymsComponents,e.ng.router,e.inputswitch,e.inputtext,e.ng.forms,e.messageservice,e._moment,e.ngxHighlightjs,e.accordion,e.confirmdialog,e.dialog,e.dropdown,e.panel,e.angular2Hotkeys,e.api$1,e.jsonx,e.xmlx)}(this,function(e,t,a,r,o,i,n,s,l,d,c,p,u,m,f,h,g,v,y,b,F,S,D,C,T,k,_,I,M,R,A,E,L,N,O,G){"use strict";O=O&&Object.prototype.hasOwnProperty.call(O,"default")?O["default"]:O,G=G&&Object.prototype.hasOwnProperty.call(G,"default")?G["default"]:G;var x=function(e,t){return(x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var a in t)t.hasOwnProperty(a)&&(e[a]=t[a])})(e,t)};function q(e,t){function a(){this.constructor=e}x(e,t),e.prototype=null===t?Object.create(t):(a.prototype=t.prototype,new a)}var w=function(){return(w=Object.assign||function(e){for(var t,a=1,r=arguments.length;a<r;a++)for(var o in t=arguments[a])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function P(e,t,a,r){var o,i=arguments.length,n=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,a):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,a,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(n=(i<3?o(n):i>3?o(t,a,n):o(t,a))||n);return i>3&&n&&Object.defineProperty(t,a,n),n}function j(e,t){return function(a,r){t(a,r,e)}}function V(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function U(e){var t="function"==typeof Symbol&&Symbol.iterator,a=t&&e[t],r=0;if(a)return a.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function B(e,t){var a="function"==typeof Symbol&&e[Symbol.iterator];if(!a)return e;var r,o,i=a.call(e),n=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)n.push(r.value)}catch(s){o={error:s}}finally{try{r&&!r.done&&(a=i["return"])&&a.call(i)}finally{if(o)throw o.error}}return n}function z(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(B(arguments[t]));return e}var $=function(){function e(e,a,r){this._client=e;var o=JSON.parse(a.get("com.senior.token")),i=o.access_token,n=o.username.split("@")[1];this._subscriptionUrl="/topic/"+n+"/"+i+"/yms/"+r+"/",this._unsubscribe$=new t.Subject}return e.prototype.connect=function(e){var t=this;this._client.connectObservable.pipe(a.takeUntil(this._unsubscribe$)).subscribe(function(a){return e(t._subscriptionUrl,t._client,a)})},e.prototype.dispose=function(){this._unsubscribe$.next(),this._unsubscribe$.complete()},e}(),Y=function(){function e(e){this.messageService=e}return e.prototype.getListQueryParams=function(e){var t=e.page,a=void 0===t?0:t,r=e.size,o=void 0===r?10:r,i=e.sort,n=void 0===i?[]:i,s=e.filterQuery,l=void 0===s?"":s,c=e.displayFields,p=void 0===c?[]:c,u=new d.HttpParams;return u=(u=u.append("size",String(o))).append("offset",String(a)),n&&n.length&&(u=u.append("orderby",n.map(function(e){var t="";return 1===e.order?t=" asc":-1===e.order&&(t=" desc"),""+e.field+t}).join(", "))),l&&(u=u.append("filter",l)),p&&p.length&&(u=u.append("displayfields",p.join())),u},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var r=a.status?String(a.status):"Error",o=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:r,detail:o})}return t.throwError(a)})},e}(),H=function(e){function t(t,a){var r=e.call(this,a)||this;return r.http=t,r.messageService=a,r.url="yms/integration/",r}return q(t,e),t.prototype.listGateByArea=function(e){var t=this.getListQueryParams({size:1e3,page:0,displayFields:["*"],filterQuery:"area.id eq '"+e+"'"});return this.http.get(this.url+"entities/gate",{params:t})},t.prototype.openGate=function(e){return this.http.post(this.url+"actions/openGate",{ip:e}).pipe(this.defaultCatch())},t.prototype.closeGate=function(e){return this.http.post(this.url+"actions/closeGate",{ip:e}).pipe(this.defaultCatch())},t=P([o.Injectable(),V("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Y),Q=function(){function e(){}return e=P([p.ControleCircuito({header:"Cancelas",name:"yms.integracao.devices"}),p.ControleOperacao({header:"Cancelas",name:"yms.integracao.devices"})],e)}(),K=function(e){function r(a,r,o){var i=e.call(this)||this;return i.service=a,i.translate=r,i.permissionsService=o,i.successState="default",i.canOpenGate=!1,i.canCloseGate=!1,i.unsubscribe$=new t.Subject,i.gates$=new t.Subject,i}return q(r,e),r.prototype.ngOnInit=function(){var e=this;this.service.listGateByArea(this.sequenciaCircuito.area.id).pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(t){return e.gates$.next(t.contents)}),this.permissionsService.get("gate").pipe(a.map(function(t){t.Open&&(e.canOpenGate=!0),t.Close&&(e.canCloseGate=!0)})).toPromise()},r.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},r.prototype.model=function(e){var t=this;return[{label:this.translate.instant("yms.integration.open_gate"),visible:this.canOpenGate,command:function(){return t.openGate(e)}},{label:this.translate.instant("yms.integration.close_gate"),visible:this.canCloseGate,command:function(){return t.closeGate(e)}}]},r.prototype.openGate=function(e){var t=this;this.loading=e.id,this.service.openGate(e.ip).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return t.loading=undefined})).subscribe(function(a){return t.successState=e.id})},r.prototype.closeGate=function(e){var t=this;this.loading=e.id,this.service.closeGate(e.ip).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return t.loading=undefined})).subscribe(function(a){return t.successState=e.id})},P([o.Input(),V("design:type",Object)],r.prototype,"sequenciaCircuito",void 0),r=P([o.Component({selector:"controlador-cancela-component",template:'<div>\n <p-table [value]="gates$ | async">\n <ng-template pTemplate="header">\n <tr>\n <th>{{\'yms.integration.gate_ip\' | translate}}</th>\n <th>{{\'yms.integration.gate_type\' | translate}}</th>\n <th></th>\n </tr>\n </ng-template>\n <ng-template pTemplate="body" let-rowData>\n <tr \n [@success]="successState === rowData.id ? successState : \'default\'" \n (@success.done)="successState = \'default\'"\n >\n <td>{{rowData.ip}}</td>\n <td>{{rowData.type | translate}}</td>\n <td>\n <span *sLoadingState="loading === rowData.id">\n <s-button priority="default" [auxiliary]="true" label="Ações" [model]="model(rowData)">\n </s-button>\n </span>\n </td>\n </tr>\n </ng-template>\n </p-table>\n</div>',animations:[u.trigger("success",[u.state("*",u.style({backgroundColor:"#0C9348",opacity:.5})),u.state("default",u.style({backgroundColor:"#FFF",opacity:1})),u.transition("* => default",u.animate("1.2s ease-in")),u.transition("default => *",u.animate("0s"))])]}),V("design:paramtypes",[H,i.TranslateService,m.PermissionsService])],r)}(Q),J=function(){function e(e){this.dispatcher=e,this.dispatcher.dispatch(K)}return e=P([o.NgModule({imports:[r.CommonModule,l.TableModule,i.TranslateModule,s.MessageModule,n.ButtonModule,n.LoadingStateModule,m.PermissionsModule.forChild([{name:"gate",actions:["Open","Close"],uri:"res://senior.com.br/yms/devices/gate"}])],declarations:[K],entryComponents:[K],exports:[K],providers:[H]}),V("design:paramtypes",[p.IntegrationDispatcher])],e)}(),X=function(e){function t(t,a){var r=e.call(this,a)||this;return r.http=t,r.messageService=a,r.urlIntegration="yms/integration/",r.urlBalanca="yms/balanca/",r}return q(t,e),t.prototype.getWeightScaleByArea=function(e){var t={displayFields:["description","code"],page:0,size:1e3,filterQuery:"area.id eq '"+e+"'"};return this.http.get(this.urlIntegration+"entities/weightScale",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t.prototype.fallbackCall=function(e,t){return this.http.post(this.urlBalanca+"actions/manualWeight",{code:e,weight:t}).pipe(this.defaultCatch())},t.prototype.getWeightScaleByCode=function(e){var t={displayFields:["description","code"],page:0,size:10,filterQuery:"code eq '"+e+"'"};return this.http.get(this.urlIntegration+"entities/weightScale",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t=P([o.Injectable(),V("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Y),W=function(){function e(){}return e=P([p.ControleCircuito({header:"Balanças",name:"yms.integracao.devices"}),p.ControleOperacao({header:"Balanças",name:"yms.integracao.devices"})],e)}(),Z=function(e){function r(a,r,o){var i=e.call(this)||this;return i.service=a,i.client=r,i.cookieService=o,i.loading=!1,i.websocket=new $(i.client,i.cookieService,"integration"),i.unsubscribe$=new t.Subject,i.weightScales$=new t.BehaviorSubject([]),i.weightScaleValues=new Map,i}return q(r,e),r.prototype.ngOnInit=function(){var e=this;this.sequenciaCircuito&&(this.loading=!0,this.service.getWeightScaleByArea(this.sequenciaCircuito.area.id).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loading=!1})).subscribe(function(t){var a=t.contents;e.weightScales$.next(a),a.forEach(function(t){e.weightScaleValues.set(t.id,0)})}),this.websocket.connect(function(t,r){r.subscribe(t+"wsWeightScale").pipe(a.map(function(e){return e.body}),a.map(function(e){return JSON.parse(e).data}),a.takeUntil(e.unsubscribe$)).subscribe(function(t){if(e.weightScales$.value.length){var a=e.weightScales$.value.findIndex(function(e){return e.id===t.weightScale.id});if(!(a<0)){var r=e.weightScales$.value[a];e.weightScaleValues.set(r.id,t.weight)}}})}))},r.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},P([o.Input(),V("design:type",Object)],r.prototype,"sequenciaCircuito",void 0),r=P([o.Component({selector:"visualizar-balanca-component",template:'<div *sLoadingState="loading">\n <p-table [value]="weightScales$ | async">\n <ng-template pTemplate="header">\n <tr>\n <th>Código</th>\n <th>Descrição</th>\n <th>Peso</th>\n </tr>\n </ng-template>\n <ng-template let-rowData pTemplate="body">\n <tr>\n <td>{{rowData.code}}</td>\n <td>{{rowData.description}}</td>\n <td>{{weightScaleValues.get(rowData.id)}}</td>\n </tr>\n </ng-template>\n </p-table>\n</div>'}),V("design:paramtypes",[X,f.StompService,h.CookieService])],r)}(W),ee=function(e){function t(){var t=e.call(this)||this,a=t.getCookieObject("com.senior.token").access_token,r=t.getCookie("com.senior.base.url")+"/websocket/subscription";return t.socketProvider=function(){return new g(r)},t.configureConfig(a),t}return q(t,e),t.prototype.getCookieObject=function(e){var t=this.getCookie(e);return t?JSON.parse(t):t},t.prototype.getCookie=function(e){try{for(var t=e+"=",a=decodeURIComponent(document.cookie).split(";"),r=0;r<a.length;r++){for(var o=a[r];" "==o.charAt(0);)o=o.substring(1);if(0==o.indexOf(t))return o.substring(t.length,o.length)}return null}catch(i){return null}},t.prototype.configureConfig=function(e){this.url=this.socketProvider,this.headers={"content-type":"application/json",Authorization:"Bearer "+e,"Access-Control-Allow-Origin":"*"},this.heartbeat_in=1e4,this.heartbeat_out=1e4,this.reconnect_delay=15e3,this.debug=!1},t}(f.StompConfig),te=function(){function e(e){this.dispatcher=e,this.dispatcher.dispatch(Z)}return e=P([o.NgModule({imports:[r.CommonModule,l.TableModule,s.MessageModule,n.LoadingStateModule],declarations:[Z],entryComponents:[Z],exports:[Z],providers:[X,h.CookieService,f.StompService,{provide:f.StompConfig,useClass:ee}]}),V("design:paramtypes",[p.IntegrationDispatcher])],e)}(),ae=function(e){function t(t,a){var r=e.call(this,a)||this;return r.http=t,r.url="yms/integration/",r.patioUrl="yms/patio/",r}return q(t,e),t.prototype.getCamerasByArea=function(e){var t={page:0,size:1e3,filterQuery:"area.id eq '"+e+"'",displayFields:["id","description","ip"]};return this.http.get(this.url+"entities/camera",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t.prototype.takeSnapshot=function(e){return this.http.get(this.url+"queries/fetchSnapshot",{params:{ip:e.ip}}).pipe(this.defaultCatch())},t.prototype.saveSnapshotInCircuit=function(e){return this.http.post(this.patioUrl+"actions/adicionaImagemExecucaoCircuito",e).pipe(this.defaultCatch())},t=P([o.Injectable(),V("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Y),re=function(){function e(e,a,r,o){this.dialogRef=e,this.dialogConfig=a,this.service=r,this.messageService=o,this.loading=!1,this.unsubscribe$=new t.Subject}return e.prototype.ngOnInit=function(){this.imageUrl=this.dialogConfig.data.url},e.prototype.save=function(){var e=this;this.loading=!0;var t=this.dialogConfig.data.execucaoCircuito,r=this.dialogConfig.data.cameraIp;this.service.saveSnapshotInCircuit({execucaoCircuitoId:t.id,alvoId:t.sequenciaCircuito.id,cameraIp:r,imagemUrl:this.imageUrl}).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loading=!1})).subscribe(function(){e.messageService.add({severity:"success",summary:"Salvo com sucesso!",detail:"Imagem salva com sucesso"}),e.dialogRef.close()})},e.prototype.close=function(e){this.dialogRef.close(e)},e=P([o.Component({selector:"view-image-component",template:'\n <s-loading-state [loading]="loading">\n <img [src]="imageUrl" width="100%">\n <br>\n </s-loading-state>\n\n <div style="position: absolute; bottom: 0; width: 670px; padding-top: 10px; border-top: 1px solid #ccc;" [style.pointer-events]="loading ? \'none\' : \'all\'">\n <s-button priority="primary" label="Salvar" (onClick)="save()"></s-button>\n <s-button priority="link" label="Cancelar" (onClick)="close()"></s-button>\n </div> \n '}),V("design:paramtypes",[c.DynamicDialogRef,c.DynamicDialogConfig,ae,c.MessageService])],e)}(),oe=function(){function e(){}return e=P([p.ControleOperacao({header:"Câmeras",name:"yms.integracao.devices"}),p.ControleCircuito({header:"Câmeras",name:"yms.integracao.devices"})],e)}(),ie=function(e){function r(a,r){var o=e.call(this)||this;return o.service=a,o.dialogService=r,o.loadingAll=!1,o.loading=[],o.unsubscribe$=new t.Subject,o.cameras$=new t.Subject,o}return q(r,e),r.prototype.ngOnInit=function(){var e=this;this.loadingAll=!0,this.service.getCamerasByArea(this.sequenciaCircuito.area.id).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loadingAll=!1})).subscribe(function(t){var a=t.contents;return e.cameras$.next(a)})},r.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},r.prototype.takeSnapshot=function(e){var t=this;this.loading.push(e.id),this.service.takeSnapshot(e).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){var a=t.loading.indexOf(e.id);t.loading.splice(a,1)})).subscribe(function(a){var r=a.url;t.dialogService.open(re,{header:e.description,width:"700px",height:"600px",contentStyle:{height:"500px",overflow:"hidden"},data:{url:r,cameraIp:e.ip,execucaoCircuito:t.execucaoCircuito}})})},P([o.Input(),V("design:type",Object)],r.prototype,"sequenciaCircuito",void 0),P([o.Input(),V("design:type",Object)],r.prototype,"execucaoCircuito",void 0),r=P([o.Component({selector:"snapshot-component",template:'<div class="lista-cameras" *sLoadingState="loadingAll">\n <div class="camera" *ngFor="let camera of cameras$ | async">\n <span *sLoadingState="loading.includes(camera.id)">\n <div class="info">\n <div class="info-title">\n Descrição\n </div>\n <div class="info-data">\n {{camera.description}}\n </div>\n </div>\n\n <div class="info">\n <div class="info-title">\n IP\n </div>\n <div class="info-data">\n {{camera.ip}}\n </div>\n </div>\n\n <s-button priority="default" [auxiliary]="true" iconClass="fa fa-camera" (onClick)="takeSnapshot(camera)">\n </s-button>\n </span>\n </div>\n</div>',providers:[c.DialogService],styles:[".lista-cameras{display:flex;flex-direction:column}.lista-cameras .camera{width:100%;height:60px;border-bottom:1px solid #ccc;padding-left:20px}.lista-cameras .camera .info{width:40%;margin-top:5px;display:inline-block}.lista-cameras .camera .info .info-title{display:block;font-size:12px}.lista-cameras .camera .info .info-data{display:inline-block;font-size:16px;font-weight:800}"]}),V("design:paramtypes",[ae,c.DialogService])],r)}(oe),ne=function(){function e(e){this.dispatcher=e,this.dispatcher.dispatch(ie)}return e=P([o.NgModule({imports:[r.CommonModule,n.ButtonModule,n.LoadingStateModule,v.DynamicDialogModule],declarations:[ie,re],entryComponents:[ie,re],exports:[ie],providers:[ae]}),V("design:paramtypes",[p.IntegrationDispatcher])],e)}(),se=function(e){function t(t,a){var r=e.call(this,a)||this;return r.http=t,r.messageService=a,r.url="yms/integration/",r}return q(t,e),t.prototype.getLprByArea=function(e){var t={page:0,size:1e3,filterQuery:"area.id eq '"+e+"'",displayFields:["id","stream","description","area.*"]};return this.http.get(this.url+"entities/lprConfiguration",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t.prototype.fallbackCall=function(e,t){return this.http.post(this.url+"actions/lprEventPublish",{stream:e,licencePlate:t}).pipe(this.defaultCatch())},t.prototype.getLprByCode=function(e){var t={page:0,size:10,filterQuery:"stream eq '"+e+"'",displayFields:["id","stream","description","locked"]};return this.http.get(this.url+"entities/lprConfiguration",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t=P([o.Injectable(),V("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Y),le=function(){function e(){}return e=P([o.NgModule({providers:[se]})],e)}(),de=function(e){function t(t,a){var r=e.call(this,a)||this;return r.http=t,r.messageService=a,r.url="yms/integration/",r}return q(t,e),t.prototype.listLogByCircuit=function(e,t){return t.filterQuery="execucaoCircuitoId eq '"+e+"'",this.http.get(this.url+"entities/logCircuit",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t=P([o.Injectable(),V("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Y),ce=function(){function e(){}return e=P([p.CircuitoFinalizado({header:"Logs com dispositivos",name:"yms.integracao.devices"})],e)}(),pe=function(e){function r(a,r){var o=e.call(this)||this;return o.logsService=a,o.translate=r,o.unsubscribe$=new t.Subject,o}return q(r,e),r.prototype.ngOnInit=function(){this.columns=[{field:"username",header:this.translate.instant("yms.integration.usuario")},{field:"log",header:this.translate.instant("yms.integration.log")},{field:"createdDate",header:this.translate.instant("yms.integration.created_date")}]},r.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},r.prototype.onGridChange=function(e){var t=e.rows,a=e.first/t;this.updateGrid({size:t,page:a,sort:[{field:"createdDate",order:-1}]})},r.prototype.updateGrid=function(e){var t=this;this.loading=!0;var r=e.page,o=e.size,i=e.sort;this.logsService.listLogByCircuit(this.execucaoCircuito.id,{page:r,size:o,sort:i}).pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(e){var a=e.contents,r=e.totalElements;t.logsData=a,t.totalRecords=r})},P([o.Input(),V("design:type",Object)],r.prototype,"execucaoCircuito",void 0),r=P([o.Component({template:'<p-table [columns]="columns" [value]="logsData" [paginator]="true" [lazy]="true" [totalRecords]="totalRecords"\nrows="10" [rowsPerPageOptions]="[10, 20, 50, 100]" (onLazyLoad)="onGridChange($event)">\n <ng-template pTemplate="header" let-columns>\n <tr>\n <th *ngFor="let column of columns">{{ column.header }}</th>\n </tr>\n </ng-template>\n <ng-template pTemplate="body" let-rowData>\n <tr>\n <td>{{rowData.username}}</td>\n <td [pTooltip]="rowData.log">{{rowData.log}}</td>\n <td>{{rowData.createdDate | date: \'dd/MM/yyyy hh:mm:ss\'}}</td>\n </tr>\n </ng-template>\n</p-table>\n'}),V("design:paramtypes",[de,i.TranslateService])],r)}(ce),ue=function(){function e(e){e.dispatch(pe)}return e=P([o.NgModule({declarations:[pe],entryComponents:[pe],providers:[de],imports:[r.CommonModule,l.TableModule,i.TranslateModule,y.TooltipModule,n.LoadingStateModule]}),V("design:paramtypes",[p.IntegrationDispatcher])],e)}(),me=function(e){function t(t,a){var r=e.call(this,a)||this;return r.http=t,r}return q(t,e),t.prototype.agendas=function(e){return this.http.get("yms/patio/entities/agenda",{params:this.getListQueryParams(e)}).pipe(this.defaultCatch())},t.prototype.ultimaPlacaLida=function(e){return this.http.post("yms/integration/queries/getLastValidPlateByLpr",{stream:e}).pipe(this.defaultCatch())},t.prototype.getPortarias=function(e){return this.http.get("yms/integration/entities/lobby",{params:this.getListQueryParams({page:0,size:100,filterQuery:"planta.id eq '"+e+"'",displayFields:["description","entranceLpr.*","lprs.*","planta.*"]})}).pipe(this.defaultCatch())},t.prototype.executarEntrada=function(e,t){return this.http.post("yms/integration/actions/executeLobby",{lobbyId:e,plate:t}).pipe(this.defaultCatch())},t=P([o.Injectable(),V("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Y),fe=function(){function e(){}return e=P([p.ControleUnificado({header:"Periféricos",name:"yms.integracao.devices"})],e)}(),he=function(e){function r(a,r){var o=e.call(this)||this;return o.selectPlantService=a,o.portariaService=r,o.unsubscribe$=new t.Subject,o}return q(r,e),r.prototype.ngOnInit=function(){var e=this,t=this.selectPlantService.getPlant();this.portariaService.getPortarias(t.id).pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(t){var a=t.contents;return e.portarias=a})},r.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},r=P([o.Component({selector:"portarias",template:'\n <h3>Portarias</h3>\n <div class="separator"></div>\n <div class="ui-g">\n <portaria-entrada *ngFor="let portaria of portarias" class="ui-md-4" [portaria]="portaria"></portaria-entrada>\n </div>\n '}),V("design:paramtypes",[b.SelectPlantService,me])],r)}(fe),ge=function(){function e(e,a,r,o){this.dialogRef=e,this.dialogConfig=a,this.portariaService=r,this.router=o,this.unsubscribe$=new t.Subject}return e.prototype.ngOnInit=function(){var e=this;this.veiculo=this.dialogConfig.data.veiculo,this.portaria=this.dialogConfig.data.portaria,this.loading=!0,this.portariaService.agendas({size:100,page:0,displayFields:["veiculo.primario.*","tipoAgendamento.*","descricao","externalTenant","dataEsperadaAgendamento"],filterQuery:"veiculo.primario.placa eq '"+this.veiculo+"' and status eq 'AGENDADO' and planta eq '"+this.portaria.planta.id+"'"}).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loading=!1})).subscribe(function(t){var a=t.contents;e.agendas=a,e.agendas.length?1===e.agendas.length&&(e.selected=e.agendas[0]):e.chegadaSimplificada()})},e.prototype.chegadaSimplificada=function(){this.router.navigate(["execucao-circuito/new"],{queryParams:{veiculo:this.veiculo,navigateTo:"processo-entrada"}}),this.dialogRef.close()},e.prototype.chegada=function(){this.selected&&(this.router.navigate(["execucao-circuito/"+this.selected.id]),this.dialogRef.close())},e.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},e.prototype.getColumns=function(){return[{field:"descricao",label:"Descrição"},{field:"dataEsperadaAgendamento",label:"Data"},{field:"tipoAgendamento",label:"Tipo de Agendamento"},{field:"externalTenant",label:"Parceiro"}]},e=P([o.Component({template:'\n <div style="width: 100%; height: calc(100% - 50px); overflow: auto;">\n <div *sLoadingState="loading">\n <p-table [value]="agendas" [columns]="getColumns()" selectionMode="single" [(selection)]="selected" dataKey="id">\n <ng-template pTemplate="header" let-columns>\n <tr>\n <th style="width: 50px;"></th>\n <th *ngFor="let column of columns">{{column.label}}</th>\n </tr>\n </ng-template>\n <ng-template pTemplate="body" let-rowData>\n <tr [pSelectableRow]="rowData">\n <td style="width: 50px;">\n <p-tableRadioButton [value]="rowData"></p-tableRadioButton>\n </td>\n <td>{{rowData[\'descricao\']}}</td>\n <td>{{rowData[\'dataEsperadaAgendamento\'] | date: \'dd/MM/yyyy HH:mm\'}}</td>\n <td>{{rowData[\'tipoAgendamento\']?.descricao}}</td>\n <td>{{rowData[\'externalTenant\']?.descricao}}</td>\n </tr>\n </ng-template>\n </p-table>\n </div>\n </div>\n <div style="position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: flex-end; height: 40px; align-items: center;">\n <s-button priority="primary" label="Registrar chegada" [disabled]="!selected" (onClick)="chegada()"></s-button>\n <s-button priority="primary" label="Registrar chegada simplificada" (onClick)="chegadaSimplificada()"></s-button>\n </div>\n '}),V("design:paramtypes",[c.DynamicDialogRef,c.DynamicDialogConfig,me,F.Router])],e)}(),ve=function(){function e(e){this.dialogRef=e}return e.prototype["continue"]=function(){this.dialogRef.close({placa:this.placa})},e=P([o.Component({template:'\n <p>Não foi encontrada uma leitura de placa. Deseja informar a placa para realizar a entrada?</p>\n <div class="separator"></div>\n <input pInputText type="text" pattern="[A-Z0-9]{6,10}" maxlength="10" placeholder="Digite a placa" [(ngModel)]="placa" #placaInput>\n \n <div style="position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: flex-end; height: 40px; align-items: center;">\n <s-button priority="primary" label="Continuar" [disabled]="!placa || !placaInput.validity.valid" (onClick)="continue()"></s-button>\n </div>\n '}),V("design:paramtypes",[c.DynamicDialogRef])],e)}(),ye=function(){function e(e,a,r,o){this.dialogService=e,this.portariaService=a,this.loading=!1,this.unsubscribe$=new t.Subject,this.websocket=new $(r,o,"integration")}return e.prototype.ngOnInit=function(){var e=this;this.websocket.connect(function(t,r){r.subscribe(t+"wsLprLockUnlocked").pipe(a.map(function(e){return e.body}),a.map(function(e){return JSON.parse(e).data}),a.takeUntil(e.unsubscribe$)).subscribe(function(t){return e.portaria.lprs=e.portaria.lprs.map(function(e){return e.stream===t.stream?w({},e,{locked:t.locked}):e})})})},e.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},e.prototype.readPlaque=function(){var e=this;this.loading=!0,this.portariaService.ultimaPlacaLida(this.portaria.entranceLpr.stream).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loading=!1})).subscribe(function(t){var a=t.plate;if(!a)return e.placaNaoEncontrada();e.openAgendas(a)})},e.prototype.placaNaoEncontrada=function(){var e=this;this.dialogService.open(ve,{header:"Placa não encontrada",style:{display:"flex","flex-direction":"column"},height:"80%",styleClass:"ui-g-12 ui-md-8",contentStyle:{"overflow-y":"auto",height:"100%","max-height":"100%",flex:1}}).onClose.pipe(a.filter(function(e){return!!e})).subscribe(function(t){return e.openAgendas(t.placa)})},e.prototype.openAgendas=function(e){var t=this;this.portariaService.executarEntrada(this.portaria.id,e).pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(){t.dialogService.open(ge,{header:"Agendamentos | "+e.toUpperCase(),style:{display:"flex","flex-direction":"column"},height:"80%",styleClass:"ui-g-12 ui-md-8",contentStyle:{"overflow-y":"auto",height:"100%","max-height":"100%",flex:1},data:{veiculo:e,portaria:t.portaria}})})},P([o.Input(),V("design:type",Object)],e.prototype,"portaria",void 0),e=P([o.Component({selector:"portaria-entrada",template:'\n <div class="card-entrada" *sLoadingState="loading">\n <div class="portaria-card">\n <h4>{{portaria?.description}}</h4>\n <s-button style="float: right" [auxiliary]="true" iconClass="fas fa-camera" priority="default" (onClick)="readPlaque()"></s-button>\n </div>\n <div class="portaria-card" *ngFor="let lpr of portaria.lprs">\n <h4>{{lpr.description || lpr.stream}}</h4>\n <p-inputSwitch styleClass="lprInputSwitch" [ngModel]="lpr.locked" [readonly]="true"></p-inputSwitch>\n </div>\n </div>\n ',providers:[c.DialogService],styles:[":host{display:block;padding:10px}.card-entrada{border-radius:20px;border:1px solid #ccc;padding:10px}.card-entrada .portaria-card{min-height:40px;display:flex;justify-content:space-between;align-items:center}"]}),V("design:paramtypes",[c.DialogService,me,f.StompService,h.CookieService])],e)}(),be=function(){function e(e){e.dispatch(he)}return e=P([o.NgModule({imports:[r.CommonModule,C.FormsModule,F.RouterModule,n.ButtonModule,l.TableModule,n.LoadingStateModule,S.InputSwitchModule,D.InputTextModule,v.DynamicDialogModule,d.HttpClientModule,b.SelectPlantModule,s.MessageModule],declarations:[he,ye,ge,ve],entryComponents:[he,ge,ve],providers:[me,h.CookieService,f.StompService,{provide:f.StompConfig,useClass:ee}]}),V("design:paramtypes",[p.IntegrationDispatcher])],e)}(),Fe=function(){function e(e,t,a,r){this.http=e,this.messageService=t,this.entityUrl=a,this.actionsUrl=r,this.http=e,this.messageService=t,this.entityUrl=a,this.actionsUrl=r,this.defaultCatch=this.defaultCatch.bind(this)}return e.prototype.getListQueryParams=function(e){var t=e.page,a=void 0===t?0:t,r=e.size,o=void 0===r?10:r,i=e.sort,n=void 0===i?[]:i,s=e.filterQuery,l=void 0===s?"":s,c=e.displayFields,p=void 0===c?[]:c,u=new d.HttpParams;return u=(u=u.append("size",String(o))).append("offset",String(a)),n&&n.length&&(u=u.append("orderby",n.map(function(e){var t="";return 1===e.order?t=" asc":-1===e.order&&(t=" desc"),""+e.field+t}).join(", "))),l&&(u=u.append("filter",l)),p&&p.length&&(u=u.append("displayfields",p.join())),u},e.prototype.getBodyParams=function(e){var t=e.page,a=void 0===t?0:t,r=e.size,o=void 0===r?10:r,i=e.sort,n=void 0===i?[]:i,s=e.filterQuery,l=void 0===s?"":s,d=e.displayFields,c=void 0===d?[]:d,p={};return p.size=o,p.offset=a,n&&n.length&&(p.orderBy=n.map(function(e){var t="";return 1===e.order?t=" asc":-1===e.order&&(t=" desc"),""+e.field+t}).join(", ")),l&&(p.filter=l),c&&c.length&&(p.displayfields=c.join()),p},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var r=a.status?String(a.status):"Error",o=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:r,detail:o})}return t.throwError(a)})},e.prototype.list=function(e){return this.http.get(this.entityUrl,{params:this.getListQueryParams(e)}).pipe(this.defaultCatch())},e.prototype.get=function(e){return this.http.get(this.entityUrl+"/"+e).pipe(this.defaultCatch())},e.prototype.insert=function(e){return this.http.post(""+this.entityUrl,e).pipe(this.defaultCatch())},e.prototype.update=function(e,t){return this.http.put(this.entityUrl+"/"+e,t).pipe(this.defaultCatch())},e.prototype["delete"]=function(e){return this.http["delete"](this.entityUrl+"/"+e).pipe(this.defaultCatch())},e.prototype.listCustomFilter=function(e,t){return this.http.post(this.actionsUrl+"/"+t,this.getBodyParams(e)).pipe(this.defaultCatch())},e}(),Se=new o.InjectionToken("integration_environment"),De=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/agenda",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o._agendaUrl=r.project.domain+"/patio",o}return q(t,e),t.prototype.atualizarAgenda=function(e){return this.http.post(this._agendaUrl+"/actions/atualizarAgenda",{agenda:e}).pipe(this.defaultCatch())},t.prototype.retornaModelosValidacao=function(e){return this.http.post("yms/agenda/queries/retornaModelosDeValidacao",{tipoAgendamentoId:e}).pipe(this.defaultCatch())},t.prototype.checarRevalidacao=function(e){return this.http.post("yms/agenda/actions/checarRevalidacao",e).pipe(this.defaultCatch())},t.prototype.listExternalAgenda=function(e){return this.http.get("yms/agenda/entities/agenda",{params:this.getListQueryParams(e)}).pipe(this.defaultCatch())},t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),Ce=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/recebimentoContrato",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o._baseUrl=r.project.domain+"/"+r.project.service,o}return q(t,e),t.prototype.registrarChegadaVeiculoComRecebimento=function(e){return this.http.post(this._baseUrl+"/actions/registrarChegadaDeVeiculoComRecebimento",e).pipe(this.defaultCatch())},t.prototype.insertContratoRecebimento=function(e,t){return this.http.post(this.entityUrl+"/recebimento/"+e+"/contratos",t).pipe(this.defaultCatch())},t.prototype.insertContratoRecebimentoItem=function(e,t){return this.http.post(this.entityUrl+"/contratoRecebimento/"+e+"/itens",t).pipe(this.defaultCatch())},t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),Te=function(){function e(e,t,a){this.override=e,this.agendaService=t,this.recebimentoService=a,this.RECEBIMENTO_KEY="ERP_SENIOR_RECEBIMENTO"}return e.prototype.initialize=function(){var e=this;this.override.addOverride(this.RECEBIMENTO_KEY,function(t){return e.functionToOverride(t)})},e.prototype.remove=function(){this.override.disposeOverride(this.RECEBIMENTO_KEY)},e.prototype.functionToOverride=function(e){var r=this;return this.agendaService.atualizarAgenda(e.agenda).pipe(a.mergeMap(function(t){return r.recebimentoService.list({filterQuery:"agenda.id eq '"+e.agenda.id+"'",page:0,size:1})}),a.map(function(e){var t=e.contents;return t.length?t[0]:null}),a.mergeMap(function(a){return a?r.recebimentoService.registrarChegadaVeiculoComRecebimento({recebimento:a,circuito:e.circuito.id,sequenciaInicial:e.sequencia.id,vagaInicial:(e.vaga||{}).id}):t.throwError("Os dados da guia ERP Senior não foram informados")}))},e=P([o.Injectable(),V("design:paramtypes",[p.ChegadaVeiculoOverride,De,Ce])],e)}(),ke=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/expedicao",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o._baseUrl=r.project.domain+"/"+r.project.service,o}return q(t,e),t.prototype.registrarChegadaVeiculoComExpedicao=function(e){return this.http.post(this._baseUrl+"/actions/registrarChegadaDeVeiculoComExpedicao",e).pipe(this.defaultCatch())},t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,c.MessageService,Object])],t)}(Fe),_e=function(){function e(e,t,a){this.override=e,this.agendaService=t,this.expedicaoService=a,this.EXPEDICAO_KEY="ERP_SENIOR_EXPEDICAO"}return e.prototype.initialize=function(){var e=this;this.override.addOverride(this.EXPEDICAO_KEY,function(t){return e.functionToOverride(t)})},e.prototype.remove=function(){this.override.disposeOverride(this.EXPEDICAO_KEY)},e.prototype.functionToOverride=function(e){var r=this;return this.agendaService.atualizarAgenda(e.agenda).pipe(a.mergeMap(function(t){return r.expedicaoService.list({filterQuery:"agenda.id eq '"+e.agenda.id+"'",page:0,size:1})}),a.map(function(e){var t=e.contents;return t.length?t[0]:null}),a.mergeMap(function(a){return a?r.expedicaoService.registrarChegadaVeiculoComExpedicao({expedicao:a,circuito:e.circuito.id,sequenciaInicial:e.sequencia.id,vagaInicial:(e.vaga||{}).id}):t.throwError("Não foi possível encontrar os dados de expedição")}))},e=P([o.Injectable(),V("design:paramtypes",[p.ChegadaVeiculoOverride,De,ke])],e)}(),Ie=function(){function e(e,t){this.http=e,this.messageService=t,this.baseUrl="yms/integration/"}return e.prototype.getProcessConfigurationErp=function(e){return this.http.get(this.baseUrl+"queries/getErpProcessConfigurationByTipoAgendamento",{params:{idTipoAgendamento:e}}).pipe(this.defaultCatch())},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var r=a.status?String(a.status):"Error",o=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:r,detail:o})}return t.throwError(a)})},e=P([o.Injectable(),V("design:paramtypes",[d.HttpClient,c.MessageService])],e)}(),Me="ERP Senior",Re=function(){function e(){}return e=P([p.Agendamento({header:Me,name:"yms.integracao.erpagrox"}),p.ChegadaVeiculo({header:Me,name:"yms.integracao.erpagrox",icon:"fal fa-book"})],e)}(),Ae=function(e){function r(a,r){var o=e.call(this)||this;return o.integrationCallback=a,o.integrationService=r,o.header=Me,o.loading=!1,o.unsubscribe$=new t.Subject,o}return q(r,e),r.prototype.ngOnInit=function(){var e=this;this.integrationCallback.onAgendamentoSaved().pipe(a.takeUntil(this.unsubscribe$),a.mergeMap(function(r){return e.agenda=r,e.loading=!0,e.agenda?e.integrationService.getProcessConfigurationErp(e.agenda.tipoAgendamento.id).pipe(a.finalize(function(){return e.loading=!1})):t.empty()})).subscribe(function(t){return e.tipoProcessoErpAtual=t.id})},r.prototype.ngOnChanges=function(){},r.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},r=P([o.Component({template:'\n <div *ngIf="agenda">\n <div [ngSwitch]="tipoProcessoErpAtual">\n <recebimento-form *ngSwitchCase="\'RECEBIMENTO_CONTRATO\'" [agenda]="agenda"></recebimento-form>\n <expedicao-form *ngSwitchCase="\'EXPEDICAO\'" [agenda]="agenda"></expedicao-form>\n <devolucao-form *ngSwitchCase="\'DEVOLUCAO\'" [agenda]="agenda"></devolucao-form>\n <recebimento-ordem-compra-form *ngSwitchCase="\'RECEBIMENTO_ORDEM_COMPRA\'" [agenda]="agenda"></recebimento-ordem-compra-form>\n <processo-avulso-form *ngSwitchCase="\'PROCESSO_AVULSO\'" [agenda]="agenda"></processo-avulso-form>\n <div *ngSwitchDefault>\n <s-loading-state [loading]="loading">\n <h3 *ngIf="!loading" style="text-align: center;">\n ATENÇÃO, não existe Tipo de Processo configurado para esse tipo de agendamento.\n </h3>\n <h3 *ngIf="loading" style="text-align: center;"> Carregando configurações </h3>\n </s-loading-state>\n </div>\n </div>\n </div>\n '}),V("design:paramtypes",[p.IntegrationEventsCallback,Ie])],r)}(Re),Ee="Informações fiscais",Le=function(){function e(){}return e=P([p.ControleCircuito({header:Ee,name:"yms.integracao.erpagrox"}),p.ControleOperacao({header:Ee,name:"yms.integracao.erpagrox"}),p.CircuitoFinalizado({header:Ee,name:"yms.integracao.erpagrox"})],e)}(),Ne=function(e){function r(a){var r=e.call(this)||this;return r.integrationService=a,r.ngUnsubscribe=new t.Subject,r}return q(r,e),r.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete()},r.prototype.ngOnInit=function(){var e=this;this.integrationService.getProcessConfigurationErp(this.agenda.tipoAgendamento.id).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.tipoProcessoErpAtual=t.id})},P([o.Input(),V("design:type",Object)],r.prototype,"agenda",void 0),r=P([o.Component({template:'\n <div *ngIf="agenda">\n <div [ngSwitch]="tipoProcessoErpAtual">\n <recebimento-info *ngSwitchCase="\'RECEBIMENTO_CONTRATO\'" [agenda]="agenda"></recebimento-info>\n <expedicao-info *ngSwitchCase="\'EXPEDICAO\'" [agenda]="agenda"></expedicao-info>\n <devolucao-info *ngSwitchCase="\'DEVOLUCAO\'" [agenda]="agenda"></devolucao-info> \n <recebimento-ordem-compra-info *ngSwitchCase="\'RECEBIMENTO_ORDEM_COMPRA\'" [agenda]="agenda"></recebimento-ordem-compra-info>\n <processo-avulso-info *ngSwitchCase="\'PROCESSO_AVULSO\'" [agenda]="agenda"></processo-avulso-info>\n </div>\n </div>\n '}),V("design:paramtypes",[Ie])],r)}(Le),Oe=function(){function e(e,t){this.http=e,this.messageService=t,this.http=e,this.messageService=t,this.defaultCatch=this.defaultCatch.bind(this)}return e.prototype.commitFiles=function(e){return this.http.post("platform/field_customization/actions/commitObject",{objects:e}).pipe(this.defaultCatch())},e.prototype.deleteFiles=function(e){return this.http.post("platform/field_customization/actions/deleteObjects",e).pipe(this.defaultCatch())},e.prototype.getFiles=function(e){var t=this,a=[];e.value.custom&&(a=e.value.custom.fieldCustomization||[],delete e.value.custom.fieldCustomization);var r=[],o={};return a.forEach(function(e){var a=e.domain,i=e.service,n=e.entity,s=e.toDelete,l=e.toInsert;if(!t.isEmpty(l)){var d=Object.keys(l).map(function(e){return{version:l[e].version,fileName:l[e].name,objectId:l[e].objectId}});t.isEmpty(d)||r.push.apply(r,z(d))}if(!t.isEmpty(s)){var c=[];Object.keys(s).forEach(function(e){var t=(s[e]||[]).map(function(t){return{field:e,objectId:t}});c.push.apply(c,z(t))}),o={domain:a,service:i,entityName:n,objects:c}}}),{filesToCommit:r,filesToDelete:o}},e.prototype.isEmpty=function(e){return Array.isArray(e)?0===e.length:0===Object.entries(e).length&&e.constructor===Object},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var r=a.status?String(a.status):"Error",o=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:r,detail:o})}return t.throwError(a)})},e=P([o.Injectable(),V("design:paramtypes",[d.HttpClient,T.MessageService])],e)}(),Ge=function(){function e(e,t){this.messageService=e,this.translate=t}return e.prototype.verificaSeNotaFiscalEstaDuplicada=function(e,t,a){if(""==e)return!1;var r=a.filter(function(t){return t.id==e});return void 0!==t&&r.length<=0&&(t=t.value).length>0&&(r=t.filter(function(t){return!(t.notas.length<=0)&&t.notas.filter(function(t){return t.chaveNotaFiscal==e}).length>0})),r.length>0&&(this.messageService.add({severity:"error",summary:this.translate.instant("yms.integration.titulo_nota_fical_ja_exite"),detail:this.translate.instant("yms.integration.conteudo_nota_fical_ja_exite")}),!0)},e=P([o.Injectable(),V("design:paramtypes",[T.MessageService,i.TranslateService])],e)}(),xe=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/ordemCompra",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o.environment=r,o}return q(t,e),t.prototype.listOrdensCompra=function(e){return this.http.post(this.environment.project.domain+"/"+this.environment.project.service+"/queries/pesquisarOrdensCompra",e).pipe(this.defaultCatch())},t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),qe=[n.FieldType.Integer,n.FieldType.Double],we=/^\d+\b$/,Pe=function(e,t){return e.concat(t.filter(function(t){return!e.includes(t)}))},je=function(e,t){var a=Ve(e,t),r=a.isValidValue;return!(a.typeExists&&!r)},Ve=function(e,t){switch(e){case n.FieldType.Time:case n.FieldType.Date:case n.FieldType.DateTime:return{isValidValue:!1,typeExists:!0};case n.FieldType.Integer:case n.FieldType.Double:default:return{isValidValue:t.match(we),typeExists:qe.includes(e)}}},Ue=function(e,t){return 0===Object.keys(e.controls).filter(function(a){var r=e.get(a).errors?e.get(a).errors.required:e.get(a).errors;return t[a]&&!t[a].visualizar&&r}).length},Be=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},ze={style:{display:"flex","flex-direction":"column"},height:"80%",styleClass:"ui-g-12 ui-md-4",contentStyle:{"overflow-y":"auto",height:"auto","max-height":"none","margin-bottom":"0",flex:1}},$e=k;function Ye(e,t,a,r){void 0===e&&(e={}),void 0===t&&(t=[]);return t.map(function(t){return t.indexOf(".")>0?Be(e,t):e[t]}).join(a).split("-").reduce(function(e,t){return void 0===e&&(e=" "),void 0===t&&(t=" "),e.trim()&&t.trim()?e+" - "+t:e.trim()&&!t.trim()?""+e:!e.trim()&&t.trim()?""+t:void 0})||(r?"yms.erp.sem_descricao":" - ")}var He,Qe=function(e,t,r,o,i,s,l){void 0===l&&(l="");var d=t.map(function(e){return{field:e,order:1}}),c=e.filter(function(e){var t=e.type;return je(t,s)}).map(function(e){var t=e.name,a=e.type;return"number"==typeof s||a===n.FieldType.Integer?t+" eq "+s:a==n.FieldType.Date?t+" eq '"+$e(s).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+$e(s).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+$e(s).format()+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+s.replace(/'/g,"\\'")+"'))":t+" eq '"+s+"'"}).join(" or ");l&&l.trim()&&(c=c?"("+c+") and "+l:l);var p=Pe(t,r);return i.list({sort:d,filterQuery:c,displayFields:p}).pipe(a.map(function(e){return w({},e,{contents:e.contents.map(function(e){return w({},e,{label:Ye(e,t,o)})})})}))},Ke=function(e,t,r,o,i,s,l){void 0===l&&(l="");var d=s.first,c=s.rows,p=s.multiSortMeta,u=s.filterData,m=d/c,f=p,h=e.filter(function(e){var t=e.name;return u[t]!=undefined&&""!=u[t]}).map(function(e){var t=e.name,a=e.type,r=u[t];return"number"==typeof r||a===n.FieldType.Integer?t+" eq "+r:a==n.FieldType.Date?t+" eq '"+$e(r).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+$e(r).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+$e(r).format()+"'":a==n.FieldType.Enum?t+" eq '"+r+"'":a==n.FieldType.Lookup?t+" eq '"+r.id+"'":a==n.FieldType.String&&-1!==t.indexOf(".")?"containing("+t+", '"+r.replace(/'/g,"\\'")+"')":a==n.FieldType.String&&-1===t.indexOf(".")?"containing(lower("+t+"),lower('"+r.replace(/'/g,"\\'")+"'))":t+" eq '"+r+"'"}).join(" and ");h=l&&l.trim()?h.concat(h?" and ":"").concat(l):h;var g=Pe(t,r);return i.list({page:m,sort:f,filterQuery:h,displayFields:g}).pipe(a.map(function(e){return w({},e,{contents:e.contents.map(function(e){return w({},e,{label:Ye(e,t,o)})})})}))},Je=k,Xe=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);a.createdDate=a.createdDate&&Je(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Je(a.lastModifiedDate).toDate();return a.label=Ye(a,["codigo","nome","fantasia"]," - "),a},e.toDto=function(e,t){var a=w({},e);return a.createdDate=a.createdDate&&Je(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Je(a.lastModifiedDate).format(),delete a.label,a},e}(),We=k,Ze=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);a.createdDate=a.createdDate&&We(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&We(a.lastModifiedDate).toDate();return a.label=Ye(a,["codigo","nome","cpfCnpj"]," - "),a},e.toDto=function(e,t){var a=w({},e);return a.createdDate=a.createdDate&&We(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&We(a.lastModifiedDate).format(),delete a.label,a},e}(),et=k,tt=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);a.createdDate=a.createdDate&&et(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&et(a.lastModifiedDate).toDate();return a.label=["id","pessoa.codigo","pessoa.nome","pessoa.site","pessoa.situacao","pessoa.cliente","pessoa.fornecedor","pessoa.representante","cnpj","nomeFantasia","inscricaoEstadual","inscricaoMunicipal","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Pessoa"!==t&&a.pessoa&&(a.pessoa=Ze.fromDto(a.pessoa,"PessoaJuridica")),a},e.toDto=function(e,t){var a=w({},e);return a.createdDate=a.createdDate&&et(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&et(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.pessoa&&(a.pessoa=Ze.toDto(a.pessoa,"PessoaJuridica")),a},e}(),at=k,rt=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);a.createdDate=a.createdDate&&at(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&at(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),a},e.toDto=function(e,t){var a=w({},e);return a.createdDate=a.createdDate&&at(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&at(a.lastModifiedDate).format(),delete a.label,a},e}(),ot=k,it=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);a.createdDate=a.createdDate&&ot(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&ot(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","abreviatura","pais.id","pais.codigo","pais.descricao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Pais"!==t&&a.pais&&(a.pais=rt.fromDto(a.pais,"Estado")),a},e.toDto=function(e,t){var a=w({},e);return a.createdDate=a.createdDate&&ot(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&ot(a.lastModifiedDate).format(),delete a.label,"Pais"!==t&&a.pais&&(a.pais=rt.toDto(a.pais,"Estado")),a},e}(),nt=k,st=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);a.createdDate=a.createdDate&&nt(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&nt(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","estado.id","estado.codigo","estado.descricao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Estado"!==t&&a.estado&&(a.estado=it.fromDto(a.estado,"Cidade")),a},e.toDto=function(e,t){var a=w({},e);return a.createdDate=a.createdDate&&nt(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&nt(a.lastModifiedDate).format(),delete a.label,"Estado"!==t&&a.estado&&(a.estado=it.toDto(a.estado,"Cidade")),a},e}(),lt=k,dt=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);a.createdDate=a.createdDate&<(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&<(a.lastModifiedDate).toDate();return a.label=Ye(a,["codigo","endereco"]," - "),"Pessoa"!==t&&a.pessoa&&(a.pessoa=Ze.fromDto(a.pessoa,"PessoaEndereco")),"Cidade"!==t&&a.cidade&&(a.cidade=st.fromDto(a.cidade,"PessoaEndereco")),a},e.toDto=function(e,t){var a=w({},e);return a.createdDate=a.createdDate&<(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&<(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.pessoa&&(a.pessoa=Ze.toDto(a.pessoa,"PessoaEndereco")),"Cidade"!==t&&a.cidade&&(a.cidade=st.toDto(a.cidade,"PessoaEndereco")),a},e}(),ct=k,pt=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);a.createdDate=a.createdDate&&ct(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&ct(a.lastModifiedDate).toDate();return a.label=Ye(a,["codigo","nome","empresa.nome"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Xe.fromDto(a.empresa,"Filial")),"PessoaJuridica"!==t&&a.pessoaJuridica&&(a.pessoaJuridica=tt.fromDto(a.pessoaJuridica,"Filial")),"PessoaEndereco"!==t&&a.endereco&&(a.endereco=dt.fromDto(a.endereco,"Filial")),a},e.toDto=function(e,t){var a=w({},e);return a.createdDate=a.createdDate&&ct(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&ct(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Xe.toDto(a.empresa,"Filial")),"PessoaJuridica"!==t&&a.pessoaJuridica&&(a.pessoaJuridica=tt.toDto(a.pessoaJuridica,"Filial")),"PessoaEndereco"!==t&&a.endereco&&(a.endereco=dt.toDto(a.endereco,"Filial")),a},e}(),ut=k,mt=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);a.createdDate=a.createdDate&&ut(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&ut(a.lastModifiedDate).toDate();return a.label=Ye(a,["codigo","descricao","tipo"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Xe.fromDto(a.empresa,"Produto")),"Filial"!==t&&a.filial&&(a.filial=pt.fromDto(a.filial,"Produto")),a},e.toDto=function(e,t){var a=w({},e);return a.createdDate=a.createdDate&&ut(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&ut(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Xe.toDto(a.empresa,"Produto")),"Filial"!==t&&a.filial&&(a.filial=pt.toDto(a.filial,"Produto")),a},e}(),ft=k,ht=function(){function e(e,a,r,o,i){this.dialogRef=e,this.dialogConfig=a,this.ordemCompraService=r,this.translate=o,this.fb=i,this.ordemCompraLookupDisplayFields=["codigo","empresa.nome"],this.ordemCompraAdvancedDisplayFields=["id","codigo","empresa.nome","filial.nome","pessoa.nome"],this.ordemCompraLookupSeparator=" - ",this.ngUnsubscribe=new t.Subject}return e.prototype.ngOnInit=function(){var e=this.dialogConfig.data;this.agenda=e.agenda,this.filial=e.filial,this.fornecedor=e.fornecedor,this.ordensCompra=e.ordens.map(function(e){var t=e.ordemCompra;return t?t.id:undefined}).filter(function(e){return!!e}),this.formGroup=this.getForm(),this.ordemCompraSearchFields=this.getOrdemCompraFields(),this.ordemCompraSearchGridFields=this.getOrdemCompraGridFields()},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete()},e.prototype.onOrdemCompraLookupRequest=function(e){var t=this,a=this.ordemCompraLookupDisplayFields.map(function(e){return{field:e,order:"Asc"}})[0],r={numero:+e.replace(/\D/g,"")},o=this.filial;o&&o.empresa&&o.empresa.id&&(r.empresaId=o.empresa.id),this.ordemCompraService.listOrdensCompra(w({},r,{pessoaId:(this.fornecedor||{id:undefined}).id,filialId:(o||{id:undefined}).id,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,ordensCompraSelecionados:this.ordensCompra,pagina:{limit:30,offset:0,listaOrdenacao:[{campo:a.field,ordenacao:a.order}]}})).subscribe(function(e){t.ordemCompraLookupSuggestions=e.contents.map(mt.fromDto)})},e.prototype.onOrdemCompraSearchRequest=function(e){var t=this,a=e.first,r=e.rows,o=e.multiSortMeta,i=e.filterData,n=a/r,s=this.getOrdemCompraFields().filter(function(e){var t=e.name;return i[t]!=undefined&&""!=i[t]}).reduce(function(e,t){var a;return w({},e,((a={})[t.name]=i[t.name],a))},{}),l=this.filial;l&&l.empresa&&l.empresa.id&&(s.empresaId=l.empresa.id),s.dataEmissao=s.dataEmissao&&ft(s.dataEmissao).format("YYYY-MM-DD");var d=(o||[]).length?{field:o[0].field,order:1===o[0].order?"Asc":"Desc"}:{field:"numero",order:"Asc"};this.ordemCompraService.listOrdensCompra(w({},s,{pessoaId:(this.fornecedor||{id:undefined}).id,filialId:(l||{id:undefined}).id,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,ordensCompraSelecionados:this.ordensCompra,pagina:{limit:r,offset:n,listaOrdenacao:[{campo:d.field,ordenacao:d.order}]}})).subscribe(function(e){t.ordemCompraSearchGridData=e.contents.map(mt.fromDto),t.ordemCompraSearchTotalRecords=e.totalElements})},e.prototype.getRecPagina=function(e,t,a){return{offset:e/t,limit:t,listaOrdenacao:a&&a.length?a.map(function(e){return{campo:e.field,ordenacao:1===e.order?"Asc":"Desc"}}):[]}},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var r=e.get(a);r instanceof C.FormControl?r.markAsDirty({onlySelf:!0}):r instanceof C.FormGroup?t.validateAllFormFields(r):r instanceof C.FormArray&&r.controls.forEach(function(e){return t.validateAllFormFields(e)})})},e.prototype.save=function(){if(!this.formGroup.valid)return this.validateAllFormFields(this.formGroup);this.close(this.formGroup.get("ordemCompra").value)},e.prototype.close=function(e){this.dialogRef.close(e)},e.prototype.getForm=function(){return this.fb.group({ordemCompra:[undefined,C.Validators.required]})},e.prototype.getOrdemCompraFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.ordem_compra_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")}),new n.FormField({name:"filial.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial")})]},e.prototype.getOrdemCompraGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.ordem_compra_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")}),new n.FormField({name:"filial.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_nome")})]},e=P([o.Component({template:'<form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-g-12 ui-md-6">\n <label for="ordemCompra">Ordem Compra</label>\n <s-lookup dataKey="id" name="ordemCompra"\n formControlName="ordemCompra" [searchFields]="ordemCompraSearchFields"\n [searchGridFields]="ordemCompraSearchGridFields"\n [searchGridData]="ordemCompraSearchGridData" [multiple]="false"\n [lookupSuggestions]="ordemCompraLookupSuggestions"\n (onLookupRequest)="onOrdemCompraLookupRequest($event)"\n (onSearchRequest)="onOrdemCompraSearchRequest($event)"\n lookupDisplayField="label" [searchTotalRecords]="ordemCompraSearchTotalRecords"\n [searchTitle]="\'yms.erp.recebimento_ordem_compra_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: ordemCompraSearchTotalRecords}">\n </s-lookup>\n </div>\n </div>\n \n <div style="margin-top: 10px;">\n <div class="separator"></div>\n <s-button style="float: right;" [label]="\'save\' | translate" priority="primary" (onClick)="save()"></s-button>\n <s-button style="float: right;" [label]="\'cancel\' | translate" priority="link" (onClick)="close()"></s-button>\n </div>\n</form>'}),V("design:paramtypes",[c.DynamicDialogRef,c.DynamicDialogConfig,xe,i.TranslateService,C.FormBuilder])],e)}(),gt=function(){function e(){}return e.prototype.focusFirstInvalidInput=function(){var e=Array.from(document.getElementsByClassName("ng-invalid")).find(function(e){return"FORM"!==e.nodeName});if(e)if("P-CALENDAR"===e.nodeName){var t=e.getAttribute("ng-reflect-input-id"),a=document.getElementById(t);a&&a.focus()}else if("S-LOOKUP"===e.nodeName){var r=this.getNestedInput(e.firstElementChild);r&&r.focus()}else e.focus()},e.prototype.getNestedInput=function(e){return"INPUT"===e.nodeName?e:this.getNestedInput(e.firstElementChild)},e=P([o.Injectable()],e)}(),vt=function(){function e(e,t,a){this.http=t,this.messageService=a,this.baseUrl=e.project.domain+"/"+e.project.service}return e.prototype.pesquisarDocumento=function(e){return this.http.post(this.baseUrl+"/queries/pesquisarDocumento",e).pipe(this.defaultCatch())},e.prototype.pesquisarDocumentoValidaNotaEmUso=function(e){return this.http.post(this.baseUrl+"/queries/pesquisarDocumentoValidaNotaEmUso",e).pipe(this.defaultCatch())},e.prototype.pesquisarDocumentoGenerico=function(e){return this.http.post("yms/integration/queries/pesquisarDocumentoGenerico",e).pipe(this.defaultCatch())},e.prototype.executarAuditoria=function(e){return this.http.post(this.baseUrl+"/actions/executarAuditoria",e).pipe(this.defaultCatch())},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var r=a.status?String(a.status):"Error",o=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:r,detail:o})}return t.throwError(a)})},e=P([o.Injectable(),j(0,o.Inject(Se)),V("design:paramtypes",[Object,d.HttpClient,c.MessageService])],e)}(),yt=function(){function e(e,a,r,o,i,n){var s=this;this.notaValidatorService=a,this.dialogConfig=r,this.confirmationService=o,this.dialogRef=i,this.verificaNotaFiscal=n,this.loading=!1,this.unsubscribe$=new t.Subject,this.validateNotaFiscal=function(e){if(e&&e.documentos[0]){var t=e.documentos[0];if(t.itens&&t.itens.length)if(t.itens[0].produto&&s.produto&&t.itens[0].produto.id!==s.produto.id)s.addErrorIfProdutoIsDifferent();else{var a={chave:s.formGroup.get("chaveNotaFiscal").value,serie:t.serie,serieLegal:t.serieLegal,numero:t.numero};s.fornecedor?(t.fornecedor||{id:undefined}).id&&t.fornecedor.id!==s.fornecedor.id?s.confirmAndAddNovoFornecedor(a,t.fornecedor,t.origemMercadoria):(s.formGroup.get("serieNotaFiscal").setValue(t.serie),s.formGroup.get("serieLegalNotaFiscal").setValue(t.serieLegal),s.formGroup.get("numeroNotaFiscal").setValue(t.numero),s.desabilitaCamposNotaFiscal()):s.closeAndReturnNota(a,t.fornecedor,t.origemMercadoria)}}},this.camposPreenchidosValidation=function(e){var t=e.get("chaveNotaFiscal").value,a=e.get("serieNotaFiscal").value,r=e.get("numeroNotaFiscal").value;return t||a||r?null:{erroMultiplosCampos:!0}},this.formGroup=e.group({chaveNotaFiscal:[undefined],serieNotaFiscal:[undefined],serieLegalNotaFiscal:[undefined],numeroNotaFiscal:[undefined]},{validators:this.camposPreenchidosValidation})}return e.prototype.ngOnInit=function(){this.filialId=this.dialogConfig.data.filial.id,this.fornecedor=this.dialogConfig.data.fornecedor,this.produto=this.dialogConfig.data.produto,this.fornecedorNotasTokens=this.dialogConfig.data.fornecedorNotasTokens,this.contratos=this.dialogConfig.data.contratos},e.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},e.prototype.save=function(){var e=this.formGroup.get("chaveNotaFiscal").value;if(!this.verificaNotaFiscal.verificaSeNotaFiscalEstaDuplicada(e,this.contratos,this.fornecedorNotasTokens)){if(e||this.removeErrorChaveNota(),!this.formGroup.valid)return this.validateAllFormFields(this.formGroup);this.habilitaCamposNotaFiscal(),this.close(this.formGroup.value)}},e.prototype.close=function(e){this.dialogRef.close(e)},e.prototype.onBlurNotaFiscal=function(){var e=this,t=this.formGroup.get("chaveNotaFiscal").value;this.verificaNotaFiscal.verificaSeNotaFiscalEstaDuplicada(t,this.contratos,this.fornecedorNotasTokens)||(this.removeErrorChaveNota(),this.loading=!0,this.notaValidatorService.pesquisarDocumentoValidaNotaEmUso({chaveDocumento:(t||"").trim(),filialId:this.filialId}).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loading=!1})).subscribe(this.validateNotaFiscal))},e.prototype.confirmAndAddNovoFornecedor=function(e,t,a){var r=this;this.confirmationService.confirm({header:"O fornecedor vinculado a nota não é o mesmo que o selecionado",message:"O fornecedor vinculado a nota não é o mesmo que o selecionado. Deseja adicionar um novo fornecedor ou cancelar a operação?",acceptLabel:"Adicionar um novo fornecedor",rejectLabel:"Cancelar operação",accept:function(){return r.closeAndReturnNota(e,t,a)},reject:function(){return r.formGroup.get("chaveNotaFiscal").setValue(undefined)}})},e.prototype.addErrorIfProdutoIsDifferent=function(){this.formGroup.get("chaveNotaFiscal").setErrors({errorChaveNota:!0})},e.prototype.removeErrorChaveNota=function(){this.formGroup.get("chaveNotaFiscal").setErrors(null)},e.prototype.closeAndReturnNota=function(e,t,a){this.dialogRef.close({addFornecedor:!0,infoNota:e,fornecedor:t,origemMercadoria:a})},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var r=e.get(a);r instanceof C.FormControl?r.markAsDirty({onlySelf:!0}):r instanceof C.FormGroup&&t.validateAllFormFields(r)}),e.markAsDirty({onlySelf:!0})},e.prototype.habilitaCamposNotaFiscal=function(){this.formGroup.get("serieNotaFiscal").enable(),this.formGroup.get("serieLegalNotaFiscal").enable(),this.formGroup.get("numeroNotaFiscal").enable()},e.prototype.desabilitaCamposNotaFiscal=function(){this.formGroup.get("serieNotaFiscal").disable(),this.formGroup.get("serieLegalNotaFiscal").disable(),this.formGroup.get("numeroNotaFiscal").disable()},e=P([o.Component({template:'<form [formGroup]="formGroup">\n <div class="ui-g ui-fluid" *sLoadingState="loading">\n <div class="ui-g-12">\n <label for="chaveNotaFiscal">{{\'yms.erp.recebimento_chave_nota_fiscal\' | translate}}</label>\n <input pInputText type="text" formControlName="chaveNotaFiscal" (blur)="onBlurNotaFiscal()">\n <s-control-errors [control]="formGroup.controls.chaveNotaFiscal" [errorMessages]="{ errorChaveNota: \'yms.erp.produto_nota_error_detail\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12">\n <label for="serieNotaFiscal">{{\'yms.erp.recebimento_serie_nota_fiscal\' | translate}}</label>\n <input pInputText type="text" formControlName="serieNotaFiscal">\n </div>\n <div class="ui-g-12">\n <label for="serieLegalNotaFiscal">{{\'yms.erp.recebimento_serie_legal_nota_fiscal\' | translate}}</label>\n <input pInputText type="text" formControlName="serieLegalNotaFiscal">\n </div>\n <div class="ui-g-12">\n <label for="numeroNotaFiscal">{{\'yms.erp.recebimento_numero_nota_fiscal\' | translate}}</label>\n <input pInputText type="text" formControlName="numeroNotaFiscal">\n </div>\n </div>\n\n <s-control-errors [control]="formGroup" [errorMessages]="{ erroMultiplosCampos: \'yms.erp.nota_fiscal_no_value\' | translate }"></s-control-errors>\n\n <s-button label="Cancelar" (onClick)="close()" priority="link"></s-button>\n <s-button label="Salvar" (onClick)="save()"></s-button>\n</form>\n\n<p-confirmDialog appendTo="body"></p-confirmDialog>',providers:[c.ConfirmationService]}),V("design:paramtypes",[C.FormBuilder,vt,c.DynamicDialogConfig,c.ConfirmationService,c.DynamicDialogRef,Ge])],e)}(),bt=function(){function e(){}return e=P([o.NgModule({imports:[r.CommonModule,C.ReactiveFormsModule,v.DynamicDialogModule,D.InputTextModule,n.ButtonModule,n.ControlErrorsModule,i.TranslateModule,n.LoadingStateModule,M.ConfirmDialogModule],declarations:[yt],entryComponents:[yt]})],e)}(),Ft=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"agenda",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/agenda"}])],providers:[De],declarations:[],exports:[]})],e)}(),St=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/cidade",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o}return q(t,e),t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),Dt=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"cidade",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/cidade"}])],providers:[St],declarations:[],exports:[]})],e)}(),Ct=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/contratoCompraItem",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o.environment=r,o}return q(t,e),t.prototype.pesquisarItensContratoCompra=function(e){return this.http.post(this.environment.project.domain+"/"+this.environment.project.service+"/queries/pesquisarItensContratoCompra",e).pipe(this.defaultCatch())},t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),Tt=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"contratoCompraItem",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/contratoCompraItem"}])],providers:[Ct],declarations:[],exports:[]})],e)}(),kt=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/contratoCompra",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o.environment=r,o}return q(t,e),t.prototype.listContratosCompra=function(e){return this.http.post(this.environment.project.domain+"/"+this.environment.project.service+"/queries/pesquisarContratosCompra",e).pipe(this.defaultCatch())},t.prototype.getItens=function(e,t){return this.http.get(this.entityUrl+"/"+e+"/itens/"+t).pipe(this.defaultCatch())},t.prototype.updateItens=function(e,t,a){return this.http.put(this.entityUrl+"/"+e+"/itens/"+t,a).pipe(this.defaultCatch())},t.prototype.listItens=function(e,t){return this.http.get(this.entityUrl+"/"+e+"/itens",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t.prototype.insertItens=function(e,t){return this.http.post(this.entityUrl+"/"+e+"/itens",t).pipe(this.defaultCatch())},t.prototype.deleteItens=function(e,t){return this.http["delete"](this.entityUrl+"/"+e+"/itens/"+t).pipe(this.defaultCatch())},t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),_t=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"contratoCompra",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/contratoCompra"}])],providers:[kt],declarations:[],exports:[]})],e)}(),It=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/derivacao",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o}return q(t,e),t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),Mt=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"derivacao",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/derivacao"}])],providers:[It],declarations:[],exports:[]})],e)}(),Rt=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/empresa",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o}return q(t,e),t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),At=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"empresa",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/empresa"}])],providers:[Rt],declarations:[],exports:[]})],e)}(),Et=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/estado",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o}return q(t,e),t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),Lt=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"estado",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/estado"}])],providers:[Et],declarations:[],exports:[]})],e)}(),Nt=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/familiaProduto",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o}return q(t,e),t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),Ot=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"familiaProduto",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/familiaProduto"}])],providers:[Nt],declarations:[],exports:[]})],e)}(),Gt=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/filial",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o.baseUrl=r.project.domain+"/"+r.project.service+"/",o}return q(t,e),t.prototype.listFiliais=function(e){return this.http.post(this.baseUrl+"queries/pesquisarFiliais",e).pipe(this.defaultCatch())},t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),xt=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"filial",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/filial"}])],providers:[Gt],declarations:[],exports:[]})],e)}(),qt=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/pais",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o}return q(t,e),t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),wt=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"pais",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/pais"}])],providers:[qt],declarations:[],exports:[]})],e)}(),Pt=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/pedidoVendaItem",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o.queriesUrl=r.project.domain+"/"+r.project.service+"/queries",o}return q(t,e),t.prototype.pesquisarItensPedidoVenda=function(e){return this.http.post(this.queriesUrl+"/pesquisarItensPedidoVenda",e).pipe(this.defaultCatch())},t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),jt=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"pedidoVendaItem",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/pedidoVendaItem"}])],providers:[Pt],declarations:[],exports:[]})],e)}(),Vt=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/pedidoVenda",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o.queriesUrl=r.project.domain+"/"+r.project.service+"/queries",o}return q(t,e),t.prototype.getItens=function(e,t){return this.http.get(this.entityUrl+"/"+e+"/itens/"+t).pipe(this.defaultCatch())},t.prototype.pesquisarPedidosVenda=function(e){return this.http.post(this.queriesUrl+"/pesquisarPedidosVenda",e).pipe(this.defaultCatch())},t.prototype.updateItens=function(e,t,a){return this.http.put(this.entityUrl+"/"+e+"/itens/"+t,a).pipe(this.defaultCatch())},t.prototype.listItens=function(e,t){return this.http.get(this.entityUrl+"/"+e+"/itens",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t.prototype.insertItens=function(e,t){return this.http.post(this.entityUrl+"/"+e+"/itens",t).pipe(this.defaultCatch())},t.prototype.deleteItens=function(e,t){return this.http["delete"](this.entityUrl+"/"+e+"/itens/"+t).pipe(this.defaultCatch())},t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),Ut=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"pedidoVenda",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/pedidoVenda"}])],providers:[Vt],declarations:[],exports:[]})],e)}(),Bt=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/pessoaEndereco",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o}return q(t,e),t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),zt=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"pessoaEndereco",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/pessoaEndereco"}])],providers:[Bt],declarations:[],exports:[]})],e)}(),$t=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/pessoaFisica",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o}return q(t,e),t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),Yt=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"pessoaFisica",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/pessoaFisica"}])],providers:[$t],declarations:[],exports:[]})],e)}(),Ht=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/pessoaJuridica",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o}return q(t,e),t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),Qt=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"pessoaJuridica",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/pessoaJuridica"}])],providers:[Ht],declarations:[],exports:[]})],e)}(),Kt=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/pessoa",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o}return q(t,e),t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),Jt=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"pessoa",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/pessoa"}])],providers:[Kt],declarations:[],exports:[]})],e)}(),Xt=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/produto",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o.environment=r,o}return q(t,e),t.prototype.listProdutosRecebimento=function(e){return this.http.post(this.environment.project.domain+"/"+this.environment.project.service+"/queries/pesquisarProdutoRecebimento",e).pipe(this.defaultCatch())},t.prototype.listProdutos=function(e){return this.http.post(this.environment.project.domain+"/"+this.environment.project.service+"/queries/pesquisarProduto",e).pipe(this.defaultCatch())},t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),Wt=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"produto",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/produto"}])],providers:[Xt],declarations:[],exports:[]})],e)}(),Zt=function(){function e(){this.messageSource=new t.BehaviorSubject({id:null,change:!1}),this.current=this.messageSource.asObservable()}return e.prototype.hasChange=function(e){var t={id:e,change:!0};this.messageSource.next(t)},e.prototype.hasChangeSave=function(e){var t={id:e,change:!1};this.messageSource.next(t)},Object.defineProperty(e.prototype,"change",{get:function(){return this.messageSource.value},enumerable:!0,configurable:!0}),e=P([o.Injectable(),V("design:paramtypes",[])],e)}(),ea=function(){return function(){}}(),ta=function(){function e(){this.messageSource=new t.BehaviorSubject(undefined),this.current=this.messageSource.asObservable()}return e.prototype.changeData=function(e){return this.messageSource.next(e),e},e.prototype.getProcessData=function(){return this.messageSource.value},e.prototype.changeDataErp=function(e){var t=this.messageSource.value?this.messageSource.value:e;return t.filialId=e.filialId,t.chaveIntegracao=e.chaveIntegracao,t.produtoId=e.produtoId,t.transgeniaId=e.transgeniaId,t.transportadoraId=e.transportadoraId,this.changeData(t)},e.prototype.changeDataVeiculo=function(e,t){var a=this.messageSource.value?this.messageSource.value:new ea;return a.veiculoId=e,a.eixos=t,this.changeData(a)},e.prototype.changeDataMotorista=function(e){var t=this.messageSource.value?this.messageSource.value:new ea;return t.motoristaId=e,this.changeData(t)},e.prototype.changeDataAgenda=function(e,t,a,r){var o=this.messageSource.value?this.messageSource.value:new ea;return o.agendaId=e,o.motoristaId=t,o.veiculoId=a,o.eixos=r,this.changeData(o)},e.prototype.builderErpProcessData=function(e,t){return e.chaveIntegracao=null!=t.get("chaveNotaFiscal")?t.get("chaveNotaFiscal").value:null,e.filialId=this.getFieldFormGroup(t,"filial"),e.produtoId=this.getFieldFormGroup(t,"produto"),e.transgeniaId=this.getFieldFormGroup(t,"transgenia"),e.transportadoraId=this.getFieldFormGroup(t,"transportadora"),e.fornecedores=this.listarIdsFornecedores(t.getRawValue().fornecedores),e},e.prototype.builderErpProcessDataValidaNotaNoContrato=function(e,t){return(e=this.builderErpProcessData(e,t)).recebimentoTemNota=this.verificaSeTemNotaNoContratoNoFornecedo(t.getRawValue().fornecedores),e},e.prototype.verificaSeTemNotaNoContratoNoFornecedo=function(e){var t=this,a=!1,r=[];null!=e&&e.filter(function(e){return null!=e.contratos&&e.contratos!=undefined}).forEach(function(e){return r.push(e.contratos)});var o=[];return null!=r&&r.filter(function(e){return null!=e&&e!=undefined}).forEach(function(e){return o.push(a=t.verificaSeContratosTemNota(e))}),a},e.prototype.verificaSeContratosTemNota=function(e){var t=!0;return e.filter(function(e){return null!=e&&e!=undefined}).forEach(function(e){return t=t&&e.notas.length>0}),t},e.prototype.builderErpProcessDataValidaNotaNaOrdemCompra=function(e,t){return(e=this.builderErpProcessData(e,t)).recebimentoTemNota=this.verificaSeTemNotaNaOrdemCompraDoFornecedo(t.getRawValue().fornecedores),e},e.prototype.verificaSeTemNotaNaOrdemCompraDoFornecedo=function(e){var t=this,a=!1,r=[];null!=e&&e.filter(function(e){return null!=e.ordens&&e.ordens!=undefined}).forEach(function(e){return r.push(e.ordens)});var o=[];return null!=r&&r.filter(function(e){return null!=e&&e!=undefined}).forEach(function(e){return o.push(a=t.verificaSeOrdemCompraTemNota(e))}),a},e.prototype.verificaSeOrdemCompraTemNota=function(e){var t=!0;return e.filter(function(e){return null!=e&&e!=undefined}).forEach(function(e){return t=t&&e.notas.length>0}),t},e.prototype.getFieldFormGroup=function(e,t){return null==e.get(t)||null==e.get(t).value?null:e.get(t).value.id},e.prototype.listarIdsFornecedores=function(e){var t=[];return null!=e&&e.filter(function(e){return null!=e.fornecedor&&e.fornecedor!=undefined}).forEach(function(e){return t.push(e.fornecedor)}),t.map(function(e){return e.id})},e=P([o.Injectable(),V("design:paramtypes",[])],e)}(),aa=function(){function e(){this.messageSource=new t.BehaviorSubject(!1),this.current=this.messageSource.asObservable()}return e.prototype.enableRevalidation=function(){this.messageSource.next(!0)},Object.defineProperty(e.prototype,"enable",{get:function(){return this.messageSource.value},enumerable:!0,configurable:!0}),e=P([o.Injectable(),V("design:paramtypes",[])],e)}(),ra=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"recebimentoContrato",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/recebimentoContrato"}])],providers:[Ce,ta,aa,Zt],declarations:[],exports:[]})],e)}(),oa=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/royalty",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o}return q(t,e),t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),ia=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"royalty",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/royalty"}])],providers:[oa],declarations:[],exports:[]})],e)}(),na=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/safra",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o}return q(t,e),t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),sa=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"safra",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/safra"}])],providers:[na],declarations:[],exports:[]})],e)}(),la=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/transportadora",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o}return q(t,e),t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),da=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"transportadora",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/transportadora"}])],providers:[la],declarations:[],exports:[]})],e)}(),ca=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/unidadeMedida",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o}return q(t,e),t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),pa=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"unidadeMedida",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/unidadeMedida"}])],providers:[ca],declarations:[],exports:[]})],e)}(),ua=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"expedicao",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/expedicao"}])],providers:[ke]})],e)}(),ma=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/devolucao",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o._baseUrl=r.project.domain+"/"+r.project.service,o}return q(t,e),t.prototype.registrarChegadaVeiculoComDevolucao=function(e){return this.http.post(this._baseUrl+"/actions/registrarChegadaDeVeiculoComDevolucao",e).pipe(this.defaultCatch())},t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),fa=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"devolucao",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/devolucao"}])],providers:[ma,ta,aa],declarations:[],exports:[]})],e)}(),ha=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"ordemCompra",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/ordem-compra"}])],providers:[xe],declarations:[],exports:[]})],e)}(),ga=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/recebimentoOrdemCompra",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o._baseUrl=r.project.domain+"/"+r.project.service,o}return q(t,e),t.prototype.registrarChegadaVeiculoRecebimentoOrdemCompra=function(e){return this.http.post(this._baseUrl+"/actions/registrarChegadaDeVeiculoComRecebimentoOrdemCompra",e).pipe(this.defaultCatch())},t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),va=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"recebimentoOrdemCompra",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/recebimentoOrdemCompra"}])],providers:[ga,ta,aa],declarations:[],exports:[]})],e)}(),ya=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/transgenia",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o}return q(t,e),t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,c.MessageService,Object])],t)}(Fe),ba=function(){function e(){}return e=P([o.NgModule({providers:[ya]})],e)}(),Fa=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/"+r.project.service+"/entities/processoAvulso",r.project.domain+"/"+r.project.service+"/actions")||this;return o.http=t,o.messageService=a,o}return q(t,e),t.prototype.registrarChegada=function(e){return this.http.post(this.actionsUrl+"/registrarChegadaDeVeiculoComProcessoAvulso",e).pipe(this.defaultCatch())},t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,c.MessageService,Object])],t)}(Fe),Sa=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"processoAvulso",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/processoAvulso"}])],providers:[Fa,ta,aa]})],e)}(),Da=function(e){function t(t,a,r){var o=e.call(this,t,a,r.project.domain+"/erp/entities/logIntegracao",r.project.domain+"/erp/actions")||this;return o.http=t,o.messageService=a,o.environment=r,o}return q(t,e),t=P([o.Injectable(),j(2,o.Inject(Se)),V("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(Fe),Ca=function(){function e(){}return e=P([o.NgModule({imports:[m.PermissionsModule.forChild([{name:"logIntegracao",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp_data/entities/logIntegracao"}])],providers:[Da],declarations:[],exports:[]})],e)}(),Ta=function(){function e(){}return e=P([o.NgModule({imports:[At,Jt,Yt,Qt,wt,Lt,Dt,zt,xt,da,Wt,pa,ia,Ot,sa,Ut,jt,_t,Tt,ra,Ft,Mt,ua,fa,ha,va,ba,m.PermissionsModule,Sa,Ca],providers:[Ie,vt],exports:[]})],e)}(),ka=function(){function e(e,t,a){this.override=e,this.agendaService=t,this.devolucaoService=a,this.DEVOLUCAO_KEY="ERP_SENIOR_DEVOLUCAO"}return e.prototype.initialize=function(){var e=this;this.override.addOverride(this.DEVOLUCAO_KEY,function(t){return e.functionToOverride(t)})},e.prototype.remove=function(){this.override.disposeOverride(this.DEVOLUCAO_KEY)},e.prototype.functionToOverride=function(e){var r=this;return this.agendaService.atualizarAgenda(e.agenda).pipe(a.mergeMap(function(t){return r.devolucaoService.list({filterQuery:"agenda.id eq '"+e.agenda.id+"'",page:0,size:1})}),a.map(function(e){var t=e.contents;return t.length?t[0]:null}),a.mergeMap(function(a){return a?r.devolucaoService.registrarChegadaVeiculoComDevolucao({devolucao:a,circuito:e.circuito.id,sequenciaInicial:e.sequencia.id,vagaInicial:(e.vaga||{}).id}):t.throwError("Não foi possível encontrar os dados de devolução")}))},e=P([o.Injectable(),V("design:paramtypes",[p.ChegadaVeiculoOverride,De,ma])],e)}(),_a=k,Ia=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);a.createdDate=a.createdDate&&_a(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&_a(a.lastModifiedDate).toDate();return a.label=Ye(a,["descricao"]," - "),a},e.toDto=function(e,t){var a=w({},e);return a.createdDate=a.createdDate&&_a(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&_a(a.lastModifiedDate).format(),delete a.label,a},e}(),Ma=k,Ra=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);a.createdDate=a.createdDate&&Ma(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Ma(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","quantidadeDecimais","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),a},e.toDto=function(e,t){var a=w({},e);return a.createdDate=a.createdDate&&Ma(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Ma(a.lastModifiedDate).format(),delete a.label,a},e}(),Aa=k,Ea=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);a.createdDate=a.createdDate&&Aa(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Aa(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Empresa"!==t&&a.empresa&&(a.empresa=Xe.fromDto(a.empresa,"Royalty")),a},e.toDto=function(e,t){var a=w({},e);return a.createdDate=a.createdDate&&Aa(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Aa(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Xe.toDto(a.empresa,"Royalty")),a},e}(),La=k,Na=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);a.createdDate=a.createdDate&&La(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&La(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","situacao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Empresa"!==t&&a.empresa&&(a.empresa=Xe.fromDto(a.empresa,"FamiliaProduto")),a},e.toDto=function(e,t){var a=w({},e);return a.createdDate=a.createdDate&&La(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&La(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Xe.toDto(a.empresa,"FamiliaProduto")),a},e}(),Oa=k,Ga=function(){function e(){this.produtoMisto=!1,this.comprado=!1}return e.fromDto=function(e,t){var a=w({},e);a.createdDate=a.createdDate&&Oa(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Oa(a.lastModifiedDate).toDate();return a.label=Ye(a,["codigo","descricao"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Xe.fromDto(a.empresa,"Produto")),"UnidadeMedida"!==t&&a.unidadeMedida&&(a.unidadeMedida=Ra.fromDto(a.unidadeMedida,"Produto")),"UnidadeMedida"!==t&&a.unidadeMedidaAgroG5&&(a.unidadeMedidaAgroG5=Ra.fromDto(a.unidadeMedidaAgroG5,"Produto")),"Royalty"!==t&&a.royalty&&(a.royalty=Ea.fromDto(a.royalty,"Produto")),"FamiliaProduto"!==t&&a.familia&&(a.familia=Na.fromDto(a.familia,"Produto")),a},e.toDto=function(e,t){var a=w({},e);return a.createdDate=a.createdDate&&Oa(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Oa(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Xe.toDto(a.empresa,"Produto")),"UnidadeMedida"!==t&&a.unidadeMedida&&(a.unidadeMedida=Ra.toDto(a.unidadeMedida,"Produto")),"UnidadeMedida"!==t&&a.unidadeMedidaAgroG5&&(a.unidadeMedidaAgroG5=Ra.toDto(a.unidadeMedidaAgroG5,"Produto")),"Royalty"!==t&&a.royalty&&(a.royalty=Ea.toDto(a.royalty,"Produto")),"FamiliaProduto"!==t&&a.familia&&(a.familia=Na.toDto(a.familia,"Produto")),a},e}(),xa=k,qa=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);a.createdDate=a.createdDate&&xa(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&xa(a.lastModifiedDate).toDate();return a.label=Ye(a,["codigo","descricao"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Xe.fromDto(a.empresa,"Derivacao")),"Produto"!==t&&a.produto&&(a.produto=Ga.fromDto(a.produto,"Derivacao")),a},e.toDto=function(e,t){var a=w({},e);return a.createdDate=a.createdDate&&xa(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&xa(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Xe.toDto(a.empresa,"Derivacao")),"Produto"!==t&&a.produto&&(a.produto=Ga.toDto(a.produto,"Derivacao")),a},e}(),wa=k,Pa=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);a.createdDate=a.createdDate&&wa(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&wa(a.lastModifiedDate).toDate();return a.label=Ye(a,["codigo","pessoa.nome","pessoa.cpfCnpj"]," - "),"Pessoa"!==t&&a.pessoa&&(a.pessoa=Ze.fromDto(a.pessoa,"Transportadora")),"PessoaEndereco"!==t&&a.endereco&&(a.endereco=dt.fromDto(a.endereco,"Transportadora")),a},e.toDto=function(e,t){var a=w({},e);return a.createdDate=a.createdDate&&wa(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&wa(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.pessoa&&(a.pessoa=Ze.toDto(a.pessoa,"Transportadora")),"PessoaEndereco"!==t&&a.endereco&&(a.endereco=dt.toDto(a.endereco,"Transportadora")),a},e}(),ja=k,Va=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);a.createdDate=a.createdDate&&ja(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&ja(a.lastModifiedDate).toDate();return a.label=[""].map(function(e){return a[e]}).join(" - "),"Pessoa"!==t&&a.fornecedor&&(a.fornecedor=Ze.fromDto(a.fornecedor,"Devolucao")),"Filial"!==t&&a.filial&&(a.filial=pt.fromDto(a.filial,"Devolucao")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Pa.fromDto(a.transportadora,"Devolucao")),"Produto"!==t&&a.produto&&(a.produto=Ga.fromDto(a.produto,"Devolucao")),"Agenda"!==t&&a.agenda&&(a.agenda=Ia.fromDto(a.agenda,"Devolucao")),"PessoaEndereco"!==t&&a.origemMercadoria&&(a.origemMercadoria=dt.fromDto(a.origemMercadoria,"Recebimento")),"Derivacao"!==t&&a.derivacao&&(a.derivacao=qa.fromDto(a.derivacao,"Devolucao")),a},e.toDto=function(e,t){var a=w({},e);return a.createdDate=a.createdDate&&ja(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&ja(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.fornecedor&&(a.fornecedor=Ze.toDto(a.fornecedor,"Devolucao")),"Filial"!==t&&a.filial&&(a.filial=pt.toDto(a.filial,"Devolucao")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Pa.toDto(a.transportadora,"Devolucao")),"Produto"!==t&&a.produto&&(a.produto=Ga.toDto(a.produto,"Devolucao")),"Agenda"!==t&&a.agenda&&(a.agenda=Ia.toDto(a.agenda,"Devolucao")),"PessoaEndereco"!==t&&a.origemMercadoria&&(a.origemMercadoria=dt.toDto(a.origemMercadoria,"Devolucao")),a},e}();!function(e){e.AGUARDANDO_CONFIRMACAO="AGUARDANDO_CONFIRMACAO_SOLICITANTE",e.AGENDADO="AGENDADO",e.AGUARDANDO_CONFIRMACAO_SOLICITANTE="AGUARDANDO_CONFIRMACAO",e.REJEITADO_POR_VALIDACAO="REJEITADO_POR_VALIDACAO",e.CANCELADO="CANCELADO"}(He||(He={}));var Ua,Ba,za=function(){function e(e,a,r,o,i,n,s,l,d,c,p,u,m,f,h,g,v,y){this.fb=e,this.router=a,this.translate=r,this.filialService=o,this.pessoaService=i,this.produtoService=n,this.derivacaoService=s,this.origemMercadoriaService=l,this.transportadoraService=d,this.devolucaoService=c,this.messageService=p,this.route=u,this.override=m,this.confirmationService=f,this.agendaService=h,this.erpProcessService=g,this.erpFormConfigService=v,this.hasChangeService=y,this.filialLookupDisplayFields=["codigo","nome","empresa.nome"],this.filialAdvancedDisplayFields=["id","codigo","nome","empresa.nome"],this.filialLookupSeparator=" - ",this.fornecedorLookupDisplayFields=["codigo","nome"],this.fornecedorAdvancedDisplayFields=["id","codigo","nome"],this.fornecedorLookupSeparator=" - ",this.produtoLookupDisplayFields=["codigo","descricao"],this.produtoAdvancedDisplayFields=["id","codigo","descricao"],this.produtoLookupSeparator=" - ",this.derivacaoLookupDisplayFields=["codigo","descricao"],this.derivacaoAdvancedDisplayFields=["id","codigo","descricao"],this.derivacaoLookupSeparator=" - ",this.origemMercadoriaLookupDisplayFields=["codigo","endereco"],this.origemMercadoriaAdvancedDisplayFields=["id","codigo","endereco","numero"],this.origemMercadoriaLookupSeparator=" - ",this.transportadoraLookupDisplayFields=["codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraAdvancedDisplayFields=["id","codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraLookupSeparator=" - ",this.disableButtonSave=!1,this.totalEixosContratados=0,this.totalEixosComposicao=0,this.ngUnsubscribe=new t.Subject,this.formGroup=this.getFormGroup()}return e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete(),this.override.remove()},e.prototype.ngAfterViewInit=function(){var e=this;this.override.initialize(),this.saveAndInitButton=document.getElementById("init"),this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.ngOnInit=function(){var e=this;this.filialSearchFields=this.getFilialSearchFields(),this.filialSearchGridFields=this.getFilialSearchGridFields(),this.fornecedorSearchFields=this.getFornecedorSearchFields(),this.produtoSearchFields=this.getProdutoSearchFields(),this.derivacaoSearchFields=this.getDerivacaoSearchFields(),this.origemMercadoriaSearchFields=this.getOrigemMercadoriaSearchFields(),this.transportadoraSearchFields=this.getTransportadoraSearchFields(),this.transportadoraSearchGridFields=this.getTransportadoraSearchGridFields(),this.route.params.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.agenda;"new"!=a&&e.getDevolucao(a)}),this.getEmpresaFilial(),this.filialValueChanges();this.checkValuesChanges("produto","derivacao",this.derivacaoService,function(e){return"produto.id eq '"+e.id+"' and situacao eq 'ATIVO'"},["codigo","descricao"],10,!0,!0);this.checkValuesChanges("fornecedor","origemMercadoria",this.origemMercadoriaService,function(e){return"pessoa.id eq '"+e.id+"'"},["codigo","endereco"],10,!1,!0),this.agenda&&this.agenda.externalTenant&&this.setTransportadora(this.agenda.externalTenant.cnpj),this.totalEixosComposicao=this.agenda&&this.agenda.veiculo&&this.agenda.veiculo.eixos||0;this.agenda&&!["AGUARDANDO_CONFIRMACAO_SOLICITANTE","AGENDADO","AGUARDANDO_CONFIRMACAO","EM_EXECUCAO","REJEITADO_POR_VALIDACAO"].includes(this.agenda.status)&&(this.formGroup.disable(),this.disableButtonSave=!0),this.createdByErpDisableForm(),this.erpProcessService.current.subscribe(function(t){return e.erpProcessData=t}),this.erpFormConfigService.current.subscribe(function(t){return e.enableRevalidation=t})},e.prototype.createdByErpDisableForm=function(){this.agenda&&this.agenda.createdByErp&&(this.formGroup.get("filial").disable(),this.formGroup.get("fornecedor").disable(),this.formGroup.get("produto").disable(),this.formGroup.get("derivacao").disable(),this.formGroup.get("origemMercadoria").disable(),this.formGroup.get("transportadora").disable(),this.formGroup.get("contratos").disable())},e.prototype.getEmpresaFilial=function(){var e=this,t=this.agenda.planta||{cnpj:[]};1===t.cnpj.length&&this.filialService.list({page:0,size:1,filterQuery:"pessoa.cpfCnpj eq '"+t.cnpj[0]+"'",displayFields:["*","empresa.nome"]}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;1===a.length&&e.formGroup.get("filial").setValue(pt.fromDto(a[0]))})},e.prototype.filialValueChanges=function(){var e=this;this.formGroup.get("filial").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){if(t)return e.formGroup.get("produto").enable();e.formGroup.get("produto").setValue(undefined),e.formGroup.get("produto").disable()})},e.prototype.checkValuesChanges=function(e,t,r,o,i,n,s,l){var d=this;void 0===n&&(n=1),this.formGroup.get(e).valueChanges.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return s&&d.formGroup.get(t).setValidators(e?C.Validators.required:C.Validators.nullValidator),l&&d.formGroup.get(t).setValue(null),!!e||(d.formGroup.get(t).setValue(undefined),d.formGroup.get(t).disable(),!1)}),a.mergeMap(function(e){var t=o(e);return r.list({filterQuery:t,page:0,size:n})})).subscribe(function(e){var a=e.contents;if(a.length){if(1===a.length){var r=a[0][i[0]]?a[0][i[0]].toString():"",o=a[0][i[1]]?a[0][i[1]].toString():"";o.trim()||r.trim()?a[0].label=r+" - "+o:a[0].label=d.translate.instant("yms.erp.derivacao_sem_descricao"),d.formGroup.get(t).setValue(a[0])}a.length>1?d.formGroup.get(t).enable():d.formGroup.get(t).disable()}else d.formGroup.get(t).enable()})},e.prototype.getDevolucao=function(e){var t=this;this.devolucaoService.list({filterQuery:"agenda.id eq '"+e+"'",size:1,page:0}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;if(a.length){t.totalEixosContratados=a[0].eixos||0,t.totalEixosComposicao=a[0].agenda&&a[0].agenda.veiculo&&a[0].agenda.veiculo.eixos||0;var r=Va.fromDto(a[0]);t.formGroup.enable(),t.formGroup.patchValue(r)}}),this.formCarregado=!0},e.prototype.onFilialLookupRequest=function(e){var t=this,r=this.getFilialSearchFields().filter(function(t){var a=t.type;return je(a,e)}).reduce(function(t,a){var r,o,i=a.name;return a.type===n.FieldType.Integer?w({},t,((r={})[i]=e.replace(/\D/,""),r)):w({},t,((o={})[i]=e,o))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:10,offset:0}});this.filialService.listFiliais(r).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.filialLookupSuggestions=e.filiais.map(function(e){return pt.fromDto(e)})})},e.prototype.onFilialSearchRequest=function(e){var t=this,r=e.first,o=e.rows,i=e.multiSortMeta,s=e.filterData,l=r/o,d=i,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getFilialSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,r,o=t.name,i=t.type,l=s[o];return i===n.FieldType.Integer?w({},e,((a={})[o]=(""+l).replace(/\D/,""),a)):w({},e,((r={})[o]=l,r))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:o,offset:l,listaOrdenacao:c?[w({},c)]:null}});this.filialService.listFiliais(p).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.filialSearchGridData=e.filiais.map(pt.fromDto),t.filialSearchTotalRecords=e.qtdTotalRegistros})},e.prototype.onFornecedorLookupRequest=function(e){var t=this;Qe(this.fornecedorSearchFields,this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields,this.fornecedorLookupSeparator,this.pessoaService,e," fornecedor eq true ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.fornecedorLookupSuggestions=e.contents})},e.prototype.onFornecedorSearchRequest=function(e){var t=this;Ke(this.fornecedorSearchFields,this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields,this.fornecedorLookupSeparator,this.pessoaService,e," fornecedor eq true ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.fornecedorSearchGridData=e.contents,t.fornecedorSearchTotalRecords=e.totalElements})},e.prototype.onProdutoLookupRequest=function(e){var t=this,r=this.formGroup.get("filial").value,o=this.agenda.tipoAgendamento;this.produtoService.listProdutos({pesquisa:e,empresaId:r?r.empresa.id:null,filialId:r?r.id:null,tipoAgendamentoId:o?o.id:null,situacao:"ATIVO",pagina:{limit:100,offset:0}}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.produtoLookupSuggestions=e.produtos.map(Ga.fromDto)})},e.prototype.onProdutoSearchRequest=function(e){var t=this,r=e.first,o=e.rows,i=e.multiSortMeta,s=e.filterData,l=r/o,d=i,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getProdutoSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,r,o=t.name,i=t.type,l=s[o];return i===n.FieldType.Integer?w({},e,((a={})[o]=(""+l).replace(/\D/,""),a)):w({},e,((r={})[o]=l,r))},{pagina:{limit:o,offset:l,listaOrdenacao:c?[w({},c)]:null}}),u=this.formGroup.get("filial").value,m=this.agenda.tipoAgendamento;this.produtoService.listProdutos(w({},p,{empresaId:u?u.empresa.id:null,filialId:u?u.id:null,situacao:"ATIVO",tipoAgendamentoId:m?m.id:null})).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.produtoSearchTotalRecords=e.qtdTotalRegistros,t.produtoSearchGridData=e.produtos.map(Ga.fromDto)})},e.prototype.onDerivacaoLookupRequest=function(e){var t=this;Qe(this.derivacaoSearchFields,this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields,this.derivacaoLookupSeparator,this.derivacaoService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.derivacaoLookupSuggestions=e.contents})},e.prototype.onDerivacaoSearchRequest=function(e){var t=this;Ke(this.derivacaoSearchFields,this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields,this.derivacaoLookupSeparator,this.derivacaoService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.derivacaoSearchGridData=e.contents,t.derivacaoSearchTotalRecords=e.totalElements})},e.prototype.onOrigemMercadoriaLookupRequest=function(e){var t=this;Qe(this.origemMercadoriaSearchFields,this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields,this.origemMercadoriaLookupSeparator,this.origemMercadoriaService,e," pessoa.id eq '"+this.formGroup.get("fornecedor").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.origemMercadoriaLookupSuggestions=e.contents})},e.prototype.onOrigemMercadoriaSearchRequest=function(e){var t=this;Ke(this.origemMercadoriaSearchFields,this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields,this.origemMercadoriaLookupSeparator,this.origemMercadoriaService,e," pessoa.id eq '"+this.formGroup.get("fornecedor").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.origemMercadoriaSearchGridData=e.contents,t.origemMercadoriaSearchTotalRecords=e.totalElements})},e.prototype.onTransportadoraLookupRequest=function(e){var t=this;Qe(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraLookupSuggestions=e.contents})},e.prototype.onTransportadoraSearchRequest=function(e){var t=this;Ke(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraSearchGridData=e.contents,t.transportadoraSearchTotalRecords=e.totalElements})},e.prototype.setTransportadora=function(e){var t=this;if(e){var r="pessoa.cpfCnpj eq '"+e.replace(".","").replace("/","").replace("-","")+"'";this.transportadoraService.list({filterQuery:r,page:0,size:10}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;if(1===a.length){var r=a[0].codigo?a[0].codigo.toString():"",o=a[0].descricao?a[0].descricao.toString():"";o.trim()||r.trim()?a[0].label=r+" - "+o:a[0].label=t.translate.instant("yms.erp.derivacao_sem_descricao"),t.formGroup.get("transportadora").setValue(a[0])}})}},e.prototype.onSave=function(e){var t=this;return this.formGroup.get("agenda").setValue(this.agenda),this.formGroup.invalid&&this.validateAllFormFields(this.formGroup),this.loading=!0,this.isNew()||!this.enableRevalidation?this.saveAndInit(e):(this.erpProcessData=this.erpProcessService.builderErpProcessData(this.erpProcessData,this.formGroup),this.erpProcessService.changeDataErp(this.erpProcessData),this.agendaService.checarRevalidacao(this.erpProcessData).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){a.requerRevalidacao?t.atualizaAgendaParaRejeitadoPorValidacao():t.saveAndInit(e)}))},e.prototype.atualizaAgendaParaRejeitadoPorValidacao=function(){var e=this;this.confirmationService.confirm({header:this.translate.instant("yms.patio.agenda_revalidacao_title"),message:this.translate.instant("yms.patio.agenda_revalidacao_message"),accept:function(){e.hasChangeService.hasChangeSave(e.agenda.id),e.agenda.status=He.REJEITADO_POR_VALIDACAO,e.agenda.motorista={id:e.erpProcessData.motoristaId},e.agenda.veiculo={id:e.erpProcessData.veiculoId},e.agendaService.atualizarAgenda(e.agenda).pipe(a.takeUntil(e.ngUnsubscribe),a.concatMap(function(t){return e.getSaveObservable()}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.successMessage(),e.router.navigate(["/chegada-veiculo"],{relativeTo:e.route})})},reject:function(){return e.loading=!1}})},e.prototype.saveAndInit=function(e){var t=this;this.getSaveObservable().pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){t.formGroup.get("id").setValue(a.id||null),t.successMessage(),e&&t.saveAndInitButton&&(t.hasChangeService.hasChangeSave(t.agenda.id),t.saveAndInitButton.click())})},e.prototype.successMessage=function(){this.messageService.add({severity:"success",summary:this.translate.instant("saved_message_title"),detail:this.translate.instant("saved_message_content")})},e.prototype.addMessage=function(e,t,a){this.messageService.add({severity:e,summary:this.translate.instant(t),detail:this.translate.instant(a)})},e.prototype.getSaveObservable=function(){var e=this.formGroup.getRawValue(),t=Va.toDto(e);return this.isNew()&&!e.id?this.devolucaoService.insert(t):this.devolucaoService.update(this.formGroup.value.id,t)},e.prototype.isNew=function(){return!this.formGroup.value.id},e.prototype.getFormGroup=function(){return this.fb.group({id:[undefined],filial:[undefined,C.Validators.required],fornecedor:[undefined,C.Validators.required],produto:[{value:undefined,disabled:!0},C.Validators.required],derivacao:[{value:undefined,disabled:!0},C.Validators.required],origemMercadoria:[{value:undefined,disabled:!0},C.Validators.required],transportadora:[undefined],agenda:[undefined,C.Validators.required],chaveNotaFiscal:[undefined],numeroNotaFiscal:[undefined],serieNotaFiscal:[undefined],numeroNotaFiscalProdutor:[undefined],serieNotaFiscalProdutor:[undefined]})},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var r=e.get(a);r instanceof C.FormControl?r.markAsDirty({onlySelf:!0}):r instanceof C.FormGroup&&t.validateAllFormFields(r)})},e.prototype.getFilialSearchFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")})]},e.prototype.getFilialSearchGridFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")})]},e.prototype.getFornecedorSearchFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_codigo")})]},e.prototype.getProdutoSearchFields=function(){return[new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.produto_descricao")}),new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.produto_codigo")})]},e.prototype.getDerivacaoSearchFields=function(){return[new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.derivacao_descricao")}),new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.derivacao_codigo")})]},e.prototype.getOrigemMercadoriaSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_endereco_codigo")}),new n.FormField({name:"numero",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_endereco_numero")}),new n.FormField({name:"endereco",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_endereco_endereco")})]},e.prototype.getTransportadoraSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_descricao")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getTransportadoraSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},P([o.Input(),V("design:type",Ia)],e.prototype,"agenda",void 0),e=P([o.Component({selector:"devolucao-form",template:'<p-confirmDialog [acceptLabel]="\'yes\' | translate" acceptIcon="" [rejectLabel]="\'no\' | translate" rejectIcon=""></p-confirmDialog>\n<div *sLoadingState="loading">\n <form [formGroup]="formGroup">\n <div class="ui-fluid ui-g"> \n <div class="ui-md-6 ui-g-12 required">\n <label for="filial">{{\'yms.erp.devolucao_filial\' | translate}}</label>\n <s-lookup dataKey="id" id="filial" name="filial" formControlName="filial"\n [searchFields]="filialSearchFields" [searchGridFields]="filialSearchGridFields"\n [searchGridData]="filialSearchGridData" [multiple]="false"\n [lookupSuggestions]="filialLookupSuggestions"\n (onLookupRequest)="onFilialLookupRequest($event)"\n (onSearchRequest)="onFilialSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="filialSearchTotalRecords"\n [searchTitle]="\'yms.erp.filial_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: filialSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'filial\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n \n <div class="ui-md-6 ui-g-12 required">\n <label for="fornecedor">{{\'yms.erp.devolucao_fornecedor\' | translate}}</label>\n <s-lookup dataKey="id" id="fornecedor" name="fornecedor" formControlName="fornecedor"\n [searchFields]="fornecedorSearchFields" [searchGridFields]="fornecedorSearchFields"\n [searchGridData]="fornecedorSearchGridData" [multiple]="false"\n [lookupSuggestions]="fornecedorLookupSuggestions"\n (onLookupRequest)="onFornecedorLookupRequest($event)"\n (onSearchRequest)="onFornecedorSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="fornecedorSearchTotalRecords"\n [searchTitle]="\'yms.erp.fornecedor_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: fornecedorSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'fornecedor\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n \n <div class="ui-md-6 ui-g-12 required">\n <label for="produto">{{\'yms.erp.devolucao_produto\' | translate}}</label>\n <s-lookup dataKey="id" id="produto" name="produto" formControlName="produto"\n [searchFields]="produtoSearchFields" [searchGridFields]="produtoSearchFields"\n [searchGridData]="produtoSearchGridData" [multiple]="false"\n [lookupSuggestions]="produtoLookupSuggestions"\n (onLookupRequest)="onProdutoLookupRequest($event)"\n (onSearchRequest)="onProdutoSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="produtoSearchTotalRecords"\n [searchTitle]="\'yms.erp.produto_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: produtoSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'produto\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div> \n \n <div class="ui-md-6 ui-g-12" [ngClass]="{\'required\': formGroup.get(\'produto\').value}">\n <label for="derivacao">{{\'yms.erp.devolucao_derivacao\' | translate}}</label>\n <s-lookup dataKey="id" id="derivacao" name="derivacao" formControlName="derivacao"\n [searchFields]="derivacaoSearchFields" [searchGridFields]="derivacaoSearchFields"\n [searchGridData]="derivacaoSearchGridData" [multiple]="false"\n [lookupSuggestions]="derivacaoLookupSuggestions"\n (onLookupRequest)="onDerivacaoLookupRequest($event)"\n (onSearchRequest)="onDerivacaoSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="derivacaoSearchTotalRecords"\n [searchTitle]="\'yms.erp.derivacao_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: derivacaoSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'derivacao\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n \n <div class="ui-md-6 ui-g-12 required">\n <label for="origemMercadoria">{{\'yms.erp.devolucao_origem_mercadoria\' | translate}}</label>\n <s-lookup dataKey="id" id="origemMercadoria" name="origemMercadoria" formControlName="origemMercadoria"\n [searchFields]="origemMercadoriaSearchFields" [searchGridFields]="origemMercadoriaSearchFields"\n [searchGridData]="origemMercadoriaSearchGridData" [multiple]="false"\n [lookupSuggestions]="origemMercadoriaLookupSuggestions"\n (onLookupRequest)="onOrigemMercadoriaLookupRequest($event)"\n (onSearchRequest)="onOrigemMercadoriaSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="origemMercadoriaSearchTotalRecords"\n [searchTitle]="\'yms.erp.origem_mercadoria_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: origemMercadoriaSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'origemMercadoria\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n \n \n <div class="ui-md-6 ui-g-12">\n <label for="transportadora">{{\'yms.erp.devolucao_transportadora\' | translate}}</label>\n <s-lookup dataKey="id" id="transportadora" name="transportadora" formControlName="transportadora"\n [searchFields]="transportadoraSearchFields" [searchGridFields]="transportadoraSearchFields"\n [searchGridData]="transportadoraSearchGridData" [multiple]="false"\n [lookupSuggestions]="transportadoraLookupSuggestions"\n (onLookupRequest)="onTransportadoraLookupRequest($event)"\n (onSearchRequest)="onTransportadoraSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="transportadoraSearchTotalRecords"\n [searchTitle]="\'yms.erp.transportadora_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: transportadoraSearchTotalRecords}">\n </s-lookup>\n </div>\n \n <div class="ui-md-6 ui-g-12">\n <label for="chaveNotaFiscal">{{\'yms.erp.devolucao_chave_nota_fiscal\' | translate}}</label>\n <input type="text" id="chaveNotaFiscal" name="chaveNotaFiscal" pInputText formControlName="chaveNotaFiscal"> \n </div>\n \n <div class="ui-md-6 ui-g-12">\n <label for="numeroNotaFiscal">{{\'yms.erp.devolucao_numero_nota_fiscal\' | translate}}</label>\n <input type="text" id="numeroNotaFiscal" name="numeroNotaFiscal" pInputText formControlName="numeroNotaFiscal"> \n </div>\n \n <div class="ui-md-6 ui-g-12">\n <label for="serieNotaFiscal">{{\'yms.erp.devolucao_serie_nota_fiscal\' | translate}}</label>\n <input type="text" id="serieNotaFiscal" name="serieNotaFiscal" pInputText formControlName="serieNotaFiscal"> \n </div>\n \n <div class="ui-md-6 ui-g-12">\n <label for="numeroNotaFiscalProdutor">{{\'yms.erp.devolucao_numero_nota_fiscal_produtor\' | translate}}</label>\n <input type="text" id="numeroNotaFiscalProdutor" name="numeroNotaFiscalProdutor" pInputText formControlName="numeroNotaFiscalProdutor"> \n </div>\n \n <div class="ui-md-6 ui-g-12">\n <label for="serieNotaFiscalProdutor">{{\'yms.erp.devolucao_serie_nota_fiscal_produtor\' | translate}}</label>\n <input type="text" id="serieNotaFiscalProdutor" name="serieNotaFiscalProdutor" pInputText formControlName="serieNotaFiscalProdutor"> \n </div>\n <div class="ui-g-12" style="text-align: right;" *ngIf="totalEixosContratados || totalEixosComposicao">\n <label for="totalEixosContratados" float="right" style="display: inline;">{{totalEixosContratados}} {{\'yms.erp.total_eixos_contratados\' | translate}} / </label>\n <label for="totalEixosComposicao" float="right" style="display: inline;">{{totalEixosComposicao}} {{\'yms.erp.total_eixos_composicao\' | translate}}</label>\n </div>\n </div>\n </form>\n \n <div style="margin: 5px 0 5px 0;">\n <s-button priority="primary" [label]="\'save\' | translate" (onClick)="onSave()" [disabled]="loading || disableButtonSave"></s-button>\n <s-button *ngIf="saveAndInitButton" priority="primary" [label]="\'save_and_init\' | translate" (onClick)="onSave(true)" [disabled]="disableButtonSave"></s-button>\n </div>\n</div>\n'}),V("design:paramtypes",[C.FormBuilder,F.Router,i.TranslateService,Gt,Kt,Xt,It,Bt,la,ma,c.MessageService,F.ActivatedRoute,ka,c.ConfirmationService,De,ta,aa,Zt])],e)}(),$a=function(){function e(e){this.devolucaoService=e,this.loading=!0,this.unsubscribe$=new t.Subject}return e.prototype.ngAfterViewInit=function(){var e=this;this.devolucaoService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",page:0,size:1}).pipe(a.takeUntil(this.unsubscribe$),a.switchMap(function(e){var a=e.contents;return a.length?t.of(a[0]):t.throwError("Devolução não encontrado.")}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){return e.devolucao=Va.fromDto(t)})},P([o.Input(),V("design:type",Object)],e.prototype,"agenda",void 0),e=P([o.Component({selector:"devolucao-info",template:'\n <div *sLoadingState="loading" style="padding: 20px;">\n <div class="detail-pane" *ngIf="agenda">\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_fornecedor\' | translate}}</span>\n <span class="data">{{devolucao?.fornecedor?.nome}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_transportadora\' | translate}}</span>\n <span class="data">{{devolucao?.transportadora?.nome}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_produto\' | translate}}</span>\n <span class="data">{{devolucao?.produto?.descricao}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_derivacao\' | translate}}</span>\n <span class="data">{{devolucao?.derivacao?.descricao}}</span>\n </div>\n \n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_chave_nota_fiscal\' | translate}}</span>\n <span class="data">{{devolucao?.chaveNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_numero_nota_fiscal\' | translate}}</span>\n <span class="data">{{devolucao?.numeroNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_serie_nota_fiscal\' | translate}}</span>\n <span class="data">{{devolucao?.serieNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_numero_nota_fiscal_produtor\' | translate}}</span>\n <span class="data">{{devolucao?.numeroNotaFiscalProdutor}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_serie_nota_fiscal_produtor\' | translate}}</span>\n <span class="data">{{devolucao?.serieNotaFiscalProdutor}}</span>\n </div> \n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_origem_mercadoria\' | translate}}</span>\n <span class="data">{{devolucao?.origemMercadoria?.cep}} - {{devolucao?.origemMercadoria?.endereco}}</span>\n </div>\n </div>\n </div>\n ',styles:[".detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}"]}),V("design:paramtypes",[ma])],e)}(),Ya=k,Ha=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);a.createdDate=a.createdDate&&Ya(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Ya(a.lastModifiedDate).toDate();return a.label=["id","clienteFaturamento.id","clienteFaturamento.codigo","clienteFaturamento.nome","clienteRemessa.id","clienteRemessa.codigo","clienteRemessa.nome","filial.id","filial.codigo","filial.nome","transportadora.id","transportadora.codigo","transportadora.placaVeiculo","pedidoVenda.id","agenda.id","agenda.descricao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Pessoa"!==t&&a.clienteFaturamento&&(a.clienteFaturamento=Ze.fromDto(a.clienteFaturamento,"Recebimento")),"Pessoa"!==t&&a.clienteRemessa&&(a.clienteRemessa=Ze.fromDto(a.clienteRemessa,"Recebimento")),"Filial"!==t&&a.filial&&(a.filial=pt.fromDto(a.filial,"Recebimento")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Pa.fromDto(a.transportadora,"Recebimento")),"Agenda"!==t&&a.agenda&&(a.agenda=Ia.fromDto(a.agenda,"Recebimento")),a},e.toDto=function(e,t){var a=w({},e);return a.createdDate=a.createdDate&&Ya(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Ya(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.clienteFaturamento&&(a.clienteFaturamento=Ze.toDto(a.clienteFaturamento,"Recebimento")),"Pessoa"!==t&&a.clienteRemessa&&(a.clienteRemessa=Ze.toDto(a.clienteRemessa,"Recebimento")),"Filial"!==t&&a.filial&&(a.filial=pt.toDto(a.filial,"Recebimento")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Pa.toDto(a.transportadora,"Recebimento")),"Agenda"!==t&&a.agenda&&(a.agenda=Ia.toDto(a.agenda,"Recebimento")),a},e}(),Qa=k,Ka=function(){function e(e,a,r,o,i,n,s,l,d,c,p,u,m,f,h,g,v,y,b,F){this.expedicaoService=e,this.router=a,this.route=r,this.messageService=o,this.formBuilder=i,this.translate=n,this.hotkeysService=s,this.fieldCustomization=l,this.focusService=d,this.pessoaService=c,this.filialService=p,this.transportadoraService=u,this.pedidoVendaService=m,this.pedidoVendaItemService=f,this.agendaService=h,this.override=g,this.confirmationService=v,this.erpProcessService=y,this.erpFormConfigService=b,this.hasChangeService=F,this.localeConfig={},this.currencyLocaleOptions={},this.permissions={},this.allPermissions={},this.mainPanelCollapsed=!1,this.visibleDialog=!1,this.formCarregado=!1,this.clienteFaturamentoLookupDisplayFields=["codigo","nome","cpfCnpj"],this.clienteFaturamentoAdvancedDisplayFields=["id","codigo","nome"],this.clienteFaturamentoLookupSeparator=" - ",this.clienteRemessaLookupDisplayFields=["codigo","nome","cpfCnpj"],this.clienteRemessaAdvancedDisplayFields=["id","codigo","nome"],this.clienteRemessaLookupSeparator=" - ",this.filialLookupDisplayFields=["codigo","nome"],this.filialAdvancedDisplayFields=["id","codigo","nome"],this.filialLookupSeparator=" - ",this.transportadoraLookupDisplayFields=["codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraAdvancedDisplayFields=["id","codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraLookupSeparator=" - ",this.pedidoVendaLookupDisplayFields=["numero","cliente"],this.pedidoVendaAdvancedDisplayFields=["id","numero","filial.nome","filial.codigo","pessoa.id","pessoa.codigo","pessoa.nome"],this.pedidoVendaLookupSeparator=" - ",this.pedidoVendaItemLookupDisplayFields=["sequencia","sku.descricao"],this.pedidoVendaItemAdvancedDisplayFields=["id","sequencia","sku.descricao"],this.pedidoVendaItemLookupSeparator=" - ",this.agendaLookupDisplayFields=["id","descricao"],this.agendaAdvancedDisplayFields=["id","descricao"],this.agendaLookupSeparator=" - ",this.disableButtonSave=!1,this.disableOrdersButtons=!0,this.totalEixosContratados=0,this.totalEixosComposicao=0,this.ordersValid=!0,this.ngUnsubscribe=new t.Subject,this.formGroup=this.getFormGroup(),this.pedidoVendaForm=this.getPedidoVendaForm(),this.itemFormGroup=this.getOrdemVendaItemForm()}return e.prototype.ngOnInit=function(){var e=this;this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)}),this.route.params.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.agenda;"new"!=a?e.getExpedicao(a):e.buscarFilial()}),this.clienteFaturamentoSearchFields=this.getClienteSearchFields(),this.clienteFaturamentoSearchGridFields=this.getClienteSearchGridFields(),this.clienteRemessaSearchFields=this.getClienteSearchFields(),this.clienteRemessaSearchGridFields=this.getClienteSearchGridFields(),this.filialSearchFields=this.getFilialSearchFields(),this.filialSearchGridFields=this.getFilialSearchGridFields(),this.transportadoraSearchFields=this.getTransportadoraSearchFields(),this.transportadoraSearchGridFields=this.getTransportadoraSearchGridFields(),this.pedidoVendaSearchFields=this.getPedidoVendaSearchFields(),this.pedidoVendaSearchGridFields=this.getPedidoVendaSearchGridFields(),this.pedidoVendaItemSearchFields=this.getPedidoVendaItemSearchFields(),this.pedidoVendaItemSearchGridFields=this.getPedidoVendaItemSearchGridFields(),this.agendaSearchFields=this.getAgendaSearchFields(),this.agendaSearchGridFields=this.getAgendaSearchGridFields(),this.setHotkeys(),this.agenda&&this.agenda.externalTenant&&this.setTransportadora(this.agenda.externalTenant.cnpj),this.totalEixosComposicao=this.agenda&&this.agenda.veiculo&&this.agenda.veiculo.eixos||0;this.agenda&&!["AGUARDANDO_CONFIRMACAO_SOLICITANTE","AGENDADO","AGUARDANDO_CONFIRMACAO","EM_EXECUCAO","REJEITADO_POR_VALIDACAO"].includes(this.agenda.status)&&(this.formGroup.disable(),this.disableButtonSave=!0),this.agenda&&this.agenda.createdByErp&&(this.formGroup.get("filial").disable(),this.formGroup.get("transportadora").disable(),this.formGroup.get("clienteRemessa").disable(),this.formGroup.get("clienteFaturamento").disable(),this.pedidoVendaForm.disable(),this.itemFormGroup.disable(),this.disableOrdersButtons=!0),this.setPedidosValueChanges(),this.erpProcessService.current.subscribe(function(t){return e.erpProcessData=t}),this.erpFormConfigService.current.subscribe(function(t){return e.enableRevalidation=t}),this.revalidacaoTransportadora(),this.verificaSeTemAlteracao()},e.prototype.verificaSeTemAlteracao=function(){var e=this;this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.revalidacaoTransportadora=function(){var e=this;this.formGroup.get("transportadora").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=e.formGroup.get("transportadora").value;e.erpProcessService&&a&&(e.erpProcessData.transportadoraId=a.id,e.erpProcessService.changeData(e.erpProcessData))})},e.prototype.abrirPedidoVenda=function(e){var t=document.getElementById("pedidoVenda").getElementsByTagName("button");t.length&&(this.pedidoVendaForm.patchValue({pedidoVenda:e}),t[0].click())},e.prototype.excluirPedidoVenda=function(e){this.formGroup.get("pedidos").removeAt(e)},e.prototype.abrirPedidoVendaItem=function(e,t){this.itemFormGroup.patchValue(t||{item:undefined,quantidade:1}),this.pedidoAtual=e,this.visibleDialog=!0},e.prototype.excluirPedidoVendaItem=function(e,t){var a=t.get("itens").value.findIndex(function(t){return t.item.id===e});a>=0&&t.get("itens").removeAt(a)},e.prototype.setPedidosValueChanges=function(){var e=this;this.formGroup.get("pedidos").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(){var t=e.formGroup.get("pedidos").length;e.ordersValid=t>0,e.formGroup.get("filial")[t>=1?"disable":"enable"]()})},e.prototype.selecionarPedidoVenda=function(e){if(this.formGroup.get("pedidos").value.find(function(t){return t.pedidoVenda.id===e.id}))return this.addMessage("warn",this.translate.instant("yms.erp.pedido_venda_search_already_selected_summary"),this.translate.instant("yms.erp.pedido_venda_search_already_selected_detail"));this.formGroup.get("pedidos").push(this.getOrdemVendaForm(e,!0)),e&&1===this.formGroup.get("pedidos").length&&!this.formGroup.get("clienteFaturamento").value&&this.buscarClienteAFaturar(e)},e.prototype.selecionarPedidoVendaItem=function(){var e=this.itemFormGroup.value,t=this.pedidoAtual.get("itens").value;if(t&&e&&e.item&&t.find(function(t){return t.item.id===e.item.id}))return this.addMessage("warn",this.translate.instant("yms.erp.item_pedido_venda_search_already_selected_summary"),this.translate.instant("yms.erp.item_pedido_venda_search_already_selected_detail"));var a=this.getOrdemVendaItemForm();a.patchValue(w({},this.itemFormGroup.value)),a.get("item").value!=undefined&&(this.pedidoAtual.get("itens").push(a),this.visibleDialog=!1)},e.prototype.selecionarPedidoVendaItemAutomaticamente=function(e,t){if(e&&1===e.length){var a=this.getOrdemVendaItemForm(),r=this.getPedidos().filter(function(e){return!(!e||!e.value.pedidoVenda)&&e.value.pedidoVenda.id===t.id});this.itemFormGroup.get("item").setValue(1===e.length?e[0]:{}),this.itemFormGroup.get("quantidade").setValue(1),a.patchValue(w({},this.itemFormGroup.value)),r[0].get("itens").push(a),this.visibleDialog=!1}},e.prototype.getPedidos=function(){return this.formGroup.get("pedidos").controls},e.prototype.buildTokens=function(e){return e.map(function(e){var t=e&&e.item?e.item:e,a=t.sku?t.sku:t.produto;return{id:t.id,label:"Produto: "+a.descricao+", Sequencia: "+t.sequencia}})},e.prototype.ngAfterViewInit=function(){var e=this,t=document.getElementsByTagName("input"),a=Array.from(t).find(function(e){return!e.disabled});a&&a.focus(),this.override.initialize(),this.saveAndInitButton=document.getElementById("init"),this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete(),this.override.remove()},e.prototype.setHotkeys=function(){var e=this;this.hotkeysService.add(new L.Hotkey("alt+shift+s",function(){return(e.isNew()||e.permissions.editar)&&e.onSave(),!1},["INPUT","SELECT","TEXTAREA"])),this.hotkeysService.add(new L.Hotkey("alt+shift+c",function(){return e.onCancel(),!1},["INPUT","SELECT","TEXTAREA"]))},e.prototype.isNew=function(){return!this.formGroup.value.id},e.prototype.updateSuggestions=function(e){e.agenda&&(e.agenda.label=this.getSuggestionValue(["id","descricao"],"agenda",e,this.agendaLookupSeparator),e.agenda.label.trim()===this.agendaLookupSeparator.trim()&&delete e.agenda.label)},e.prototype.getSuggestionValue=function(e,t,a,r){var o=this;return e.map(function(e){return o.getProp(a,t+"."+e)}).reduce(function(e,t){return""+e+r+t})},e.prototype.onRouteDataChange=function(e){var t=e.localeConfig.number,a=t.currencySymbol,r=t.thousandsSeparator,o=t.decimalSeparator;if(this.localeConfig=e.localeConfig,this.currencyLocaleOptions={align:"left",prefix:a,thousands:r,decimal:o},this.permissions=e.allPermissions.expedicao,this.allPermissions=e.allPermissions,e.entity){this.permissions.editar||this.formGroup.disable();var i=Ha.fromDto(e.entity);this.updateSuggestions(i),this.formGroup.patchValue(i)}else this.formGroup.patchValue(new Ha)},e.prototype.onCancel=function(){this.goBack()},e.prototype.onSendFile=function(e,a){var r=[];return this.fieldCustomization.isEmpty(e)||r.push(this.fieldCustomization.deleteFiles(e)),this.fieldCustomization.isEmpty(a)||r.push(this.fieldCustomization.commitFiles(a)),this.fieldCustomization.isEmpty(r)?t.of({}):t.forkJoin(r)},e.prototype.setValuesPedidoBiodisel=function(){var e=this.formGroup.get("numeroPedidoCliente").value,t=this.formGroup.get("itemPedidoCliente").value,a=this.formGroup.get("pedidos").value;(a||[]).map(function(a){a&&a.itens&&a.itens.length&&(a.itens[0].numeroPedidoCliente=e,a.itens[0].itemPedidoCliente=t)}),this.formGroup.get("pedidos").patchValue(a)},e.prototype.getValuesPedidoBiodisel=function(){var e=this.formGroup.get("pedidos").value,t=this.formGroup.get("numeroPedidoCliente"),a=this.formGroup.get("itemPedidoCliente");(e||[]).map(function(e){if(!t.value||!a.value){var r=e&&e.itens&&e.itens.length?e.itens[0].pedido:null;r&&r.itens&&r.itens.length&&1===r.itens.length&&(t.patchValue(r.itens[0].numeroPedidoCliente),a.patchValue(r.itens[0].itemPedidoCliente))}})},e.prototype.onSave=function(e){var t=this;if(this.formGroup.get("agenda").setValue(this.agenda),this.ordersValid=this.formGroup.get("pedidos").length>0,this.formGroup.invalid||!this.ordersValid)return this.validateAllFormFields(this.formGroup);this.setValuesPedidoBiodisel();var r=this.fieldCustomization.getFiles(this.formGroup),o=r.filesToDelete,i=r.filesToCommit;return this.loading=!0,this.isNew()||!this.enableRevalidation?this.saveAndInit(o,i,e):(this.erpProcessData=this.erpProcessService.builderErpProcessData(this.erpProcessData,this.formGroup),this.erpProcessService.changeDataErp(this.erpProcessData),this.agendaService.checarRevalidacao(this.erpProcessData).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){a.requerRevalidacao?t.atualizaAgendaParaRejeitadoPorValidacao():t.saveAndInit(o,i,e)}))},e.prototype.atualizaAgendaParaRejeitadoPorValidacao=function(){var e=this;this.confirmationService.confirm({header:this.translate.instant("yms.patio.agenda_revalidacao_title"),message:this.translate.instant("yms.patio.agenda_revalidacao_message"),accept:function(){e.hasChangeService.hasChangeSave(e.agenda.id),e.agenda.status=He.REJEITADO_POR_VALIDACAO,e.agenda.motorista={id:e.erpProcessData.motoristaId},e.agenda.veiculo={id:e.erpProcessData.veiculoId},e.agendaService.atualizarAgenda(e.agenda).pipe(a.takeUntil(e.ngUnsubscribe),a.concatMap(function(t){return e.getSaveObservable()}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.successMessage(),e.router.navigate(["/chegada-veiculo"],{relativeTo:e.route})})},reject:function(){return e.loading=!1}})},e.prototype.saveAndInit=function(e,t,a){var r=this;this.atualizaExpedicao(e,t,function(){r.hasChangeService.hasChangeSave(r.agenda.id),a&&r.saveAndInitButton&&(r.hasChangeService.hasChangeSave(r.agenda.id),r.saveAndInitButton.click())})},e.prototype.successMessage=function(){this.messageService.add({severity:"success",summary:this.translate.instant("saved_message_title"),detail:this.translate.instant("saved_message_content")})},e.prototype.atualizaExpedicao=function(e,r,o){var i=this;return this.getSaveObservable().pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return i.loading=!1})).subscribe(function(n){i.formGroup.get("id").setValue(n.id||null),i.onSendFile(e,r).pipe(a.takeUntil(i.ngUnsubscribe),a.catchError(function(e){return i.loading=!1,t.throwError(e)})).subscribe(function(){i.addMessage("success","saved_message_title","saved_message_content"),o()})})},e.prototype.setTransportadora=function(e){var t=this;if(e){var r="pessoa.cpfCnpj eq '"+e.replace(".","").replace("/","").replace("-","")+"'";this.transportadoraService.list({filterQuery:r,page:0,size:10}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;if(1===a.length){var r=a[0].codigo?a[0].codigo.toString():"",o=a[0].descricao?a[0].descricao.toString():"";o.trim()||r.trim()?a[0].label=r+" - "+o:a[0].label=t.translate.instant("yms.erp.derivacao_sem_descricao"),t.formGroup.get("transportadora").setValue(a[0])}})}},e.prototype.getProp=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},e.prototype.getExpedicao=function(e){var t=this;this.loading=!0,this.expedicaoService.list({filterQuery:"agenda.id eq '"+e+"'",size:1,page:0}).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(e){var a=e.contents;if(a.length){t.totalEixosContratados=a[0].eixos||0,t.totalEixosComposicao=a[0].agenda&&a[0].agenda.veiculo&&a[0].agenda.veiculo.eixos||0;var r=Ha.fromDto(a[0]);t.formGroup.enable(),t.formGroup.patchValue(r),r.pedidos.forEach(function(e){var a=t.getOrdemVendaForm();a.patchValue(e),e.itens.forEach(function(e){var r=t.getOrdemVendaItemForm();r.patchValue(e),a.get("itens").push(r)}),t.formGroup.get("pedidos").push(a)}),t.getValuesPedidoBiodisel(),t.formCarregado=!0}else t.buscarFilial()})},e.prototype.onClienteFaturamentoLookupRequest=function(e){var t=this;Qe(this.clienteFaturamentoSearchFields,this.clienteFaturamentoLookupDisplayFields,this.clienteFaturamentoAdvancedDisplayFields,this.clienteFaturamentoLookupSeparator,this.pessoaService,e,"cliente eq true").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.clienteFaturamentoLookupSuggestions=e.contents})},e.prototype.onClienteFaturamentoSearchRequest=function(e){var t=this,r=e.first,o=e.rows,i=e.multiSortMeta,s=e.filterData,l=r/o,d=i,c=this.getClienteSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,r=s[t];return"number"==typeof r?t+" eq "+r:a==n.FieldType.Date?t+" eq '"+Qa(r).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Qa(r).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Qa(r).format()+"'":a==n.FieldType.Enum?t+" eq '"+r+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+r.replace(/'/g,"\\'")+"'))":a==n.FieldType.Lookup?t+" eq '"+r.id+"'":t+" eq '"+r+"'"}).join(" and ");c=c+(c?" and ":"")+"situacao eq ATIVO and cliente eq true";var p=Pe(this.clienteFaturamentoLookupDisplayFields,this.clienteFaturamentoAdvancedDisplayFields);this.pessoaService.list({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return w({},e,{contents:e.contents.map(function(e){return w({},e,{label:t.clienteFaturamentoLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.clienteFaturamentoLookupSeparator)})})})})).subscribe(function(e){t.clienteFaturamentoSearchGridData=e.contents,t.clienteFaturamentoSearchTotalRecords=e.totalElements})},e.prototype.onClienteRemessaLookupRequest=function(e){var t=this;Qe(this.clienteRemessaSearchFields,this.clienteRemessaLookupDisplayFields,this.clienteRemessaAdvancedDisplayFields,this.clienteRemessaLookupSeparator,this.pessoaService,e,"cliente eq true").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.clienteRemessaLookupSuggestions=e.contents})},e.prototype.onClienteRemessaSearchRequest=function(e){var t=this,r=e.first,o=e.rows,i=e.multiSortMeta,s=e.filterData,l=r/o,d=i,c=this.getClienteSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,r=s[t];return"number"==typeof r?t+" eq "+r:a==n.FieldType.Date?t+" eq '"+Qa(r).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Qa(r).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Qa(r).format()+"'":a==n.FieldType.Enum?t+" eq '"+r+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+r.replace(/'/g,"\\'")+"'))":t+" eq '"+r+"'"}).join(" and ");c=c+(c?" and ":"")+"situacao eq ATIVO and cliente eq true";var p=Pe(this.clienteRemessaLookupDisplayFields,this.clienteRemessaAdvancedDisplayFields);this.pessoaService.list({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return w({},e,{contents:e.contents.map(function(e){return w({},e,{label:t.clienteRemessaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.clienteRemessaLookupSeparator)})})})})).subscribe(function(e){t.clienteRemessaSearchGridData=e.contents,t.clienteRemessaSearchTotalRecords=e.totalElements})},e.prototype.onFilialSelect=function(e){this.disableOrdersButtons=!e||this.agenda.createdByErp},e.prototype.onFilialLookupRequest=function(e){var t=this,r=this.getFilialSearchFields().filter(function(t){var a=t.type;return je(a,e)}).reduce(function(t,a){var r,o,i=a.name;return a.type===n.FieldType.Integer?w({},t,((r={})[i]=e.replace(/\D/,""),r)):w({},t,((o={})[i]=e,o))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:10,offset:0}});this.filialService.listFiliais(r).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.filialLookupSuggestions=e.filiais.map(function(e){return pt.fromDto(e)})})},e.prototype.onFilialSearchRequest=function(e){var t=this,r=e.first,o=e.rows,i=e.multiSortMeta,s=e.filterData,l=r/o,d=i,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getFilialSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,r,o=t.name,i=t.type,l=s[o];return i===n.FieldType.Integer?w({},e,((a={})[o]=(""+l).replace(/\D/,""),a)):w({},e,((r={})[o]=l,r))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:o,offset:l,listaOrdenacao:c?[w({},c)]:null}});this.filialService.listFiliais(p).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.filialSearchGridData=e.filiais.map(pt.fromDto),t.filialSearchTotalRecords=e.qtdTotalRegistros})},e.prototype.onTransportadoraLookupRequest=function(e){var t=this;Qe(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraLookupSuggestions=e.contents})},e.prototype.onTransportadoraSearchRequest=function(e){var t=this;Ke(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraSearchGridData=e.contents,t.transportadoraSearchTotalRecords=e.totalElements})},e.prototype.onPedidoVendaLookupRequest=function(e){var t=this,r=this.pedidoVendaLookupDisplayFields.map(function(e){return{field:e,order:1}}),o=this.getPedidoVendaSearchFields().filter(function(t){var a=t.type;return je(a,e)}).map(function(t){var a=t.name,r=t.type;return"number"==typeof e?a+" eq "+e:r==n.FieldType.Date?a+" eq '"+Qa(e).format("YYYY-MM-DD")+"'":r==n.FieldType.Time?a+" eq '"+Qa(e).format("HH:mm:ss")+"'":r==n.FieldType.DateTime?a+" eq '"+Qa(e).format()+"'":r==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or ");o=o+(o?" and ":"")+"situacaoPedido eq ABERTO_TOTAL or situacaoPedido eq ABERTO_PARCIAL";var i=this.formGroup.get("pedidos").value||[],s="";i.map(function(e){return!!(e&&e.pedidoVenda&&e.pedidoVenda.id)&&(s+=" and (id ne '"+e.pedidoVenda.id+"')")}),i.length&&s&&(o+=s);var l=Pe(this.pedidoVendaLookupDisplayFields,this.pedidoVendaAdvancedDisplayFields);this.pedidoVendaService.list({sort:r,filterQuery:o,displayFields:l}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return w({},e,{contents:e.contents.map(function(e){return w({},e,{label:t.pedidoVendaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.pedidoVendaLookupSeparator)})})})})).subscribe(function(e){t.pedidoVendaLookupSuggestions=e.contents})},e.prototype.getRecPagina=function(e,t,a){return{offset:e/t,limit:t,listaOrdenacao:a&&a.length?a.map(function(e){return{campo:e.field,ordenacao:1===e.order?"Asc":"Desc"}}):[]}},e.prototype.onPedidoVendaSearchRequest=function(e){var t=this,r=e.first,o=e.rows,i=e.multiSortMeta,n=e.filterData,s=i||[],l=this.formGroup.get("filial").value,d=this.formGroup.get("pedidos").value||[],c=[];d.map(function(e){return!!(e&&e.pedidoVenda&&e.pedidoVenda.id)&&c.push(e.pedidoVenda.id)});var p={pessoaId:n.cliente?n.cliente.id:null,filialId:l?l.id:null,tipoAgendamentoId:this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,filialPedido:n.filialPedido,pedidosSelecionados:c,numero:n.numero,pagina:this.getRecPagina(r,o,s)};this.pedidoVendaService.pesquisarPedidosVenda(p).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return w({},e,{contents:e.contents.map(function(e){return w({},e,{label:t.pedidoVendaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.pedidoVendaLookupSeparator)})})})})).subscribe(function(e){t.pedidoVendaSearchGridData=e.contents,t.pedidoVendaSearchTotalRecords=e.totalElements})},e.prototype.onPedidoVendaItemLookupRequest=function(e){var t=this,r=this.pedidoVendaItemLookupDisplayFields.map(function(e){return{field:e,order:1}}),o=(this.formGroup.get("filial").value||{}).id,i={pedidoId:(this.pedidoAtual.get("pedidoVenda").value||{}).id,filialId:o,sequencia:isNaN(e)?null:e,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,pagina:this.getRecPagina(0,10,r)};this.pedidoVendaItemService.pesquisarItensPedidoVenda(i).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return w({},e,{contents:e.contents.map(function(e){return w({},e,{label:t.pedidoVendaItemLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.pedidoVendaItemLookupSeparator)})})})})).subscribe(function(e){t.pedidoVendaItemLookupSuggestions=e.contents})},e.prototype.onPedidoVendaItemSearchRequest=function(e){var t=this,r=e.first,o=e.rows,i=e.multiSortMeta,n=e.filterData,s=i,l=(this.formGroup.get("filial").value||{}).id,d={pedidoId:(this.pedidoAtual.get("pedidoVenda").value||{}).id,filialId:l,sequencia:n.sequencia,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,pagina:this.getRecPagina(r,o,s)};this.pedidoVendaItemService.pesquisarItensPedidoVenda(d).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return w({},e,{contents:e.contents.map(function(e){return w({},e,{label:t.pedidoVendaItemLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.pedidoVendaItemLookupSeparator)})})})})).subscribe(function(e){t.pedidoVendaItemSearchGridData=e.contents,t.pedidoVendaItemSearchTotalRecords=e.totalElements})},e.prototype.getAutomaticItensOrder=function(e){var t=this;if(e&&e.id){var r=this.pedidoVendaItemLookupDisplayFields.map(function(e){return{field:e,order:1}}),o=(this.formGroup.get("filial").value||{}).id,i={pedidoId:e.id,filialId:o,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,pagina:this.getRecPagina(0,10,r)};this.pedidoVendaItemService.pesquisarItensPedidoVenda(i).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return w({},e,{contents:e.contents.map(function(e){return w({},e,{label:t.pedidoVendaItemLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.pedidoVendaItemLookupSeparator)})})})})).subscribe(function(a){t.selecionarPedidoVendaItemAutomaticamente(a.contents,e)})}},e.prototype.onAgendaLookupRequest=function(e){var t=this,r=this.agendaLookupDisplayFields.map(function(e){return{field:e,order:1}}),o=this.getAgendaSearchFields().filter(function(t){var a=t.type;return je(a,e)}).map(function(t){var a=t.name,r=t.type;return"number"==typeof e?a+" eq "+e:r==n.FieldType.Date?a+" eq '"+Qa(e).format("YYYY-MM-DD")+"'":r==n.FieldType.Time?a+" eq '"+Qa(e).format("HH:mm:ss")+"'":r==n.FieldType.DateTime?a+" eq '"+Qa(e).format()+"'":r==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or "),i=Pe(this.agendaLookupDisplayFields,this.agendaAdvancedDisplayFields);this.agendaService.listExternalAgenda({sort:r,filterQuery:o,displayFields:i}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return w({},e,{contents:e.contents.map(function(e){return w({},e,{label:t.agendaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.agendaLookupSeparator)})})})})).subscribe(function(e){t.agendaLookupSuggestions=e.contents})},e.prototype.onAgendaSearchRequest=function(e){var t=this,r=e.first,o=e.rows,i=e.multiSortMeta,s=e.filterData,l=r/o,d=i,c=this.getAgendaSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,r=s[t];return"number"==typeof r?t+" eq "+r:a==n.FieldType.Date?t+" eq '"+Qa(r).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Qa(r).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Qa(r).format()+"'":a==n.FieldType.Enum?t+" eq '"+r+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+r.replace(/'/g,"\\'")+"'))":t+" eq '"+r+"'"}).join(" and "),p=Pe(this.agendaLookupDisplayFields,this.agendaAdvancedDisplayFields);this.agendaService.listExternalAgenda({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return w({},e,{contents:e.contents.map(function(e){return w({},e,{label:t.agendaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.agendaLookupSeparator)})})})})).subscribe(function(e){t.agendaSearchGridData=e.contents,t.agendaSearchTotalRecords=e.totalElements})},e.prototype.getFormGroup=function(){return this.formBuilder.group({id:[{value:undefined,disabled:!0},C.Validators.compose([])],clienteFaturamento:[{value:undefined,disabled:!1},C.Validators.compose([C.Validators.required])],clienteRemessa:[{value:undefined,disabled:!1}],filial:[{value:undefined,disabled:!1},C.Validators.compose([C.Validators.required])],transportadora:[{value:undefined,disabled:!1},C.Validators.compose([])],pedidos:this.formBuilder.array([]),agenda:[{value:undefined,disabled:!1},C.Validators.compose([C.Validators.required])],numeroAgendamentoCliente:[{value:undefined,disabled:!1},C.Validators.compose([])],numeroPedidoCliente:[{value:undefined,disabled:!1},C.Validators.compose([])],itemPedidoCliente:[{value:undefined,disabled:!1},C.Validators.compose([])],createdBy:[{value:undefined,disabled:!0},C.Validators.compose([])],createdDate:[{value:undefined,disabled:!0},C.Validators.compose([])],lastModifiedBy:[{value:undefined,disabled:!0},C.Validators.compose([])],lastModifiedDate:[{value:undefined,disabled:!0},C.Validators.compose([])]})},e.prototype.getClienteSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.pessoa_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.pessoa_nome"),type:n.FieldType.String}),new n.FormField({name:"cpfCnpj",label:this.translate.instant("yms.erp.pessoa_cpfCnpj"),type:n.FieldType.String})]},e.prototype.getClienteSearchGridFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.pessoa_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.pessoa_nome"),type:n.FieldType.String}),new n.FormField({name:"cpfCnpj",label:this.translate.instant("yms.erp.pessoa_cpfCnpj"),type:n.FieldType.String}),new n.FormField({name:"site",label:this.translate.instant("yms.erp.pessoa_site"),type:n.FieldType.String})]},e.prototype.getFilialSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.filial_nome"),type:n.FieldType.String})]},e.prototype.getFilialSearchGridFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.filial_nome"),type:n.FieldType.String})]},e.prototype.getTransportadoraSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_descricao")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getTransportadoraSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getPedidoVendaSearchFields=function(){var e=this,r=new t.Subject,o=new t.Subject;return[new n.FormField({name:"numero",label:this.translate.instant("yms.erp.pedido_venda_numero"),type:n.FieldType.Integer}),new n.FormField({name:"filialPedido",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"cliente",label:this.translate.instant("yms.erp.pessoa_cliente_label"),type:n.FieldType.Lookup,searchFields:this.getClienteSearchFields(),searchGridFields:this.getClienteSearchGridFields(),suggestionsObservable:r,searchObservable:o,emptyMessage:"Nenhuma sugestão encontrada",size:{sm:12,md:12,lg:12,xl:12},onLookupRequest:function(t){Qe(e.clienteFaturamentoSearchFields,e.clienteFaturamentoLookupDisplayFields,e.clienteFaturamentoAdvancedDisplayFields,e.clienteFaturamentoLookupSeparator,e.pessoaService,t,"situacao eq ATIVO and cliente eq true").pipe(a.takeUntil(e.ngUnsubscribe)).subscribe(function(e){return r.next(e.contents)})},onSearchRequest:function(t){Ke(e.clienteFaturamentoSearchFields,e.clienteFaturamentoLookupDisplayFields,e.clienteFaturamentoAdvancedDisplayFields,e.clienteFaturamentoLookupSeparator,e.pessoaService,t,"situacao eq ATIVO and cliente eq true").pipe(a.takeUntil(e.ngUnsubscribe)).subscribe(function(e){o.next({totalRecords:e.totalElements,gridData:e.contents})})},dataKey:"id",lookupDisplayField:"label",searchTitle:this.translate.instant("yms.erp.pessoa_cliente_label"),searchEmptyTitle:this.translate.instant("yms.erp.nothing_found"),filterLabel:this.translate.instant("yms.erp.filter"),filterTitle:this.translate.instant("yms.integration.filters"),clearLabel:this.translate.instant("yms.erp.clear"),cancelLabel:this.translate.instant("yms.erp.cancel"),selectLabel:this.translate.instant("yms.erp.select"),tooltip:this.translate.instant("yms.erp.pessoa_cliente_label")})]},e.prototype.getPedidoVendaSearchGridFields=function(){return[new n.FormField({name:"numero",label:this.translate.instant("yms.erp.pedido_venda_numero"),type:n.FieldType.Integer}),new n.FormField({name:"filial.nome",label:this.translate.instant("yms.erp.filial"),type:n.FieldType.String}),new n.FormField({name:"filial.codigo",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"pessoa.nome",label:this.translate.instant("yms.erp.pessoa_cliente_label"),type:n.FieldType.Integer}),new n.FormField({name:"pessoa.codigo",label:this.translate.instant("yms.erp.pessoa_cliente_codigo_label"),type:n.FieldType.Integer})]},e.prototype.getPedidoVendaItemSearchFields=function(){return[new n.FormField({name:"sequencia",label:this.translate.instant("yms.erp.pedido_venda_item_sequencia"),type:n.FieldType.Integer})]},e.prototype.getPedidoVendaItemSearchGridFields=function(){return z(this.getPedidoVendaItemSearchFields(),[new n.FormField({name:"sku.descricao",label:this.translate.instant("yms.erp.produto"),type:n.FieldType.String})])},e.prototype.getAgendaSearchFields=function(){return[new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.agenda_descricao"),type:n.FieldType.String})]},e.prototype.getAgendaSearchGridFields=function(){return[new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.agenda_descricao"),type:n.FieldType.String})]},e.prototype.getDerivacaoSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.derivacao_codigo"),type:n.FieldType.String}),new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.derivacao_descricao"),type:n.FieldType.String})]},e.prototype.getDerivacaoSearchGridFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.derivacao_codigo"),type:n.FieldType.String}),new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.derivacao_descricao"),type:n.FieldType.String})]},e.prototype.goBack=function(){this.router.navigate(["../"],{relativeTo:this.route.parent})},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var r=e.get(a);r instanceof C.FormControl?r.markAsDirty({onlySelf:!0}):r instanceof C.FormGroup&&t.validateAllFormFields(r)}),this.focusService.focusFirstInvalidInput()},e.prototype.getSaveObservable=function(){var e,t=this.formGroup.getRawValue(),a=Ha.toDto(t);if(this.isNew()&&!t.id)e=this.expedicaoService.insert(a);else{var r=t.id;e=this.expedicaoService.update(r,a)}return e},e.prototype.validateVisualization=function(){Ue(this.formGroup,this.allPermissions)||this.addMessage("error","yms.erp.cannot_visualize_form_summary","yms.erp.cannot_visualize_form_detail")},e.prototype.addMessage=function(e,t,a){this.messageService.add({severity:e,summary:this.translate.instant(t),detail:this.translate.instant(a)})},e.prototype.getPedidoVendaForm=function(){return this.formBuilder.group({pedidoVenda:[undefined]})},e.prototype.getOrdemVendaForm=function(e,t){return t&&this.getAutomaticItensOrder(e),this.formBuilder.group({id:[undefined],pedidoVenda:[e],itens:this.formBuilder.array([])})},e.prototype.getOrdemVendaItemForm=function(e){return this.formBuilder.group({id:[undefined],pedido:[undefined],item:[e],quantidade:[undefined],numeroPedidoCliente:[undefined],itemPedidoCliente:[undefined]})},e.prototype.buscarFilial=function(){var e=this,t=this.agenda.planta||{cnpj:[]};1===t.cnpj.length?(this.filialService.list({page:0,size:1,filterQuery:"pessoa.cpfCnpj eq '"+t.cnpj[0]+"'",displayFields:["*","empresa.nome"]}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;1===a.length&&(e.formGroup.get("filial").setValue(pt.fromDto(a[0])),e.disableOrdersButtons=!1)}),this.formCarregado=!0):this.formCarregado=!0},e.prototype.buscarClienteAFaturar=function(e){var t=this;this.pessoaService.list({size:1,page:0,filterQuery:"id eq '"+e.pessoa.id+"'"}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;1===(a||[]).length&&t.formGroup.get("clienteFaturamento").setValue(Ze.fromDto(a[0]))})},P([o.Input(),V("design:type",Ia)],e.prototype,"agenda",void 0),P([o.Input(),V("design:type",Boolean)],e.prototype,"revalidacao",void 0),P([o.ViewChild("customTemplate"),V("design:type",o.TemplateRef)],e.prototype,"customTemplate",void 0),P([o.ViewChild("customFormFields"),V("design:type",o.TemplateRef)],e.prototype,"customFormFields",void 0),e=P([o.Component({selector:"expedicao-form",template:'<div *sLoadingState="loading">\n <form [formGroup]="formGroup">\n <div class="ui-g">\n <div class="ui-g-12 ui-md-12">\n <label class="required-h3">Pedidos:</label>\n <s-button label="Adicionar pedido" priority="default" (onClick)="abrirPedidoVenda()" [disabled]="disableButtonSave || disableOrdersButtons"></s-button>\n <div class="error-required-message" [hidden]="ordersValid">{{\'yms.erp.error_required\' | translate}}</div>\n <p-accordion>\n <p-accordionTab *ngFor="let pedido of getPedidos(); let i = index">\n <p-header>\n Pedido: {{ pedido.get(\'pedidoVenda\')?.value?.numero }}\n </p-header>\n \n <div style="margin: 10px 0; display: block;">\n <s-button label="Adicionar item do pedido" priority="default" size="small"\n (onClick)="abrirPedidoVendaItem(pedido)" [disabled]="disableButtonSave || disableOrdersButtons"></s-button>\n <s-button label="Excluir pedido" priority="default" size="small"\n (onClick)="excluirPedidoVenda(i)" [disabled]="disableButtonSave || disableOrdersButtons"></s-button>\n </div>\n \n <s-token-list [tokens]="buildTokens(pedido.get(\'itens\')?.value)" [removableTokens]="true"\n (tokenRemoved)="excluirPedidoVendaItem($event.id, pedido)">\n </s-token-list>\n </p-accordionTab>\n </p-accordion>\n <div style="display: inline-block;" class="separator"></div>\n </div>\n </div>\n <div class="ui-fluid">\n <div class="ui-g">\n <div [attr.data-hidden]="true" class="ui-g-12 ui-md-6">\n <label for="id">{{"yms.erp.recebimento_id" | translate}}</label>\n <input #idFormInput type="text" id="id" name="id" pInputText formControlName="id"\n autocomplete="off" />\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="filial">{{"yms.erp.expedicao_filial" | translate}}</label>\n <s-lookup dataKey="id" id="filial" name="filial" formControlName="filial"\n [searchFields]="filialSearchFields" [searchGridFields]="filialSearchGridFields"\n [searchGridData]="filialSearchGridData" [multiple]="false"\n [lookupSuggestions]="filialLookupSuggestions" (onLookupRequest)="onFilialLookupRequest($event)"\n (onSearchRequest)="onFilialSearchRequest($event)" lookupDisplayField="label"\n (onSelect)="onFilialSelect($event)"\n [searchTotalRecords]="filialSearchTotalRecords"\n [searchTitle]="\'yms.erp.filial_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: filialSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'filial\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="clienteFaturamento">{{"yms.erp.expedicao_cliente_faturamento" | translate}}</label>\n <s-lookup dataKey="id" id="clienteFaturamento" name="clienteFaturamento"\n formControlName="clienteFaturamento" [searchFields]="clienteFaturamentoSearchFields"\n [searchGridFields]="clienteFaturamentoSearchGridFields"\n [searchGridData]="clienteFaturamentoSearchGridData" [multiple]="false"\n [lookupSuggestions]="clienteFaturamentoLookupSuggestions"\n (onLookupRequest)="onClienteFaturamentoLookupRequest($event)"\n (onSearchRequest)="onClienteFaturamentoSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="clienteFaturamentoSearchTotalRecords"\n [searchTitle]="\'yms.erp.cliente_faturamento_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: clienteFaturamentoSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'clienteFaturamento\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="clienteRemessa">{{"yms.erp.expedicao_cliente_remessa" | translate}}</label>\n <s-lookup dataKey="id" id="clienteRemessa" name="clienteRemessa" formControlName="clienteRemessa"\n [searchFields]="clienteRemessaSearchFields" [searchGridFields]="clienteRemessaSearchGridFields"\n [searchGridData]="clienteRemessaSearchGridData" [multiple]="false"\n [lookupSuggestions]="clienteRemessaLookupSuggestions"\n (onLookupRequest)="onClienteRemessaLookupRequest($event)"\n (onSearchRequest)="onClienteRemessaSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="clienteRemessaSearchTotalRecords"\n [searchTitle]="\'yms.erp.cliente_remessa_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: clienteRemessaSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'clienteRemessa\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="transportadora">{{"yms.erp.expedicao_transportadora" | translate}}</label>\n <s-lookup dataKey="id" id="transportadora" name="transportadora" formControlName="transportadora"\n [searchFields]="transportadoraSearchFields" [searchGridFields]="transportadoraSearchGridFields"\n [searchGridData]="transportadoraSearchGridData" [multiple]="false"\n [lookupSuggestions]="transportadoraLookupSuggestions"\n (onLookupRequest)="onTransportadoraLookupRequest($event)"\n (onSearchRequest)="onTransportadoraSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="transportadoraSearchTotalRecords"\n [searchTitle]="\'yms.erp.transportadora_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: transportadoraSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="numeroAgendamentoCliente">Número agendamento do cliente</label>\n <input type="text" pInputText formControlName="numeroAgendamentoCliente" pattern="[0-9]+$">\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="numeroPedidoCliente">Número pedido do cliente</label>\n <input type="text" pInputText formControlName="numeroPedidoCliente" pattern="[0-9]+$">\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="itemPedidoCliente">Item pedido do cliente</label>\n <input type="text" pInputText formControlName="itemPedidoCliente" pattern="[0-9]+$">\n </div>\n <div class="ui-g-12" style="text-align: right;" *ngIf="totalEixosContratados || totalEixosComposicao">\n <label for="totalEixosContratados" float="right" style="display: inline;">{{totalEixosContratados}} {{\'yms.erp.total_eixos_contratados\' | translate}} / </label>\n <label for="totalEixosComposicao" float="right" style="display: inline;">{{totalEixosComposicao}} {{\'yms.erp.total_eixos_composicao\' | translate}}</label>\n </div>\n </div>\n </div>\n </form>\n\n <div style="margin: 5px 0 5px 0;">\n <s-button priority="primary" [label]="\'save\' | translate" (onClick)="onSave()" [disabled]="disableButtonSave"></s-button>\n <s-button *ngIf="saveAndInitButton" priority="primary" [label]="\'save_and_init\' | translate" (onClick)="onSave(true)" [disabled]="disableButtonSave"></s-button>\n </div>\n\n <form [formGroup]="pedidoVendaForm" [hidden]="true">\n <s-lookup dataKey="id" id="pedidoVenda" name="pedidoVenda" formControlName="pedidoVenda"\n [searchFields]="pedidoVendaSearchFields" [searchGridFields]="pedidoVendaSearchGridFields"\n [searchGridData]="pedidoVendaSearchGridData" [multiple]="false"\n [lookupSuggestions]="pedidoVendaLookupSuggestions" (onLookupRequest)="onPedidoVendaLookupRequest($event)"\n (onSearchRequest)="onPedidoVendaSearchRequest($event)" lookupDisplayField="label"\n (onSelect)="selecionarPedidoVenda($event)" [searchTotalRecords]="pedidoVendaSearchTotalRecords"\n [searchTitle]="\'yms.erp.pedido_venda_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate" [filterLabel]="\'yms.erp.filter\' | translate"\n [clearLabel]="\'yms.erp.clear\' | translate" [cancelLabel]="\'yms.erp.cancel\' | translate"\n [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: pedidoVendaSearchTotalRecords}">\n </s-lookup>\n </form>\n\n <p-dialog [(visible)]="visibleDialog" styleClass="s-lookup-modal" [modal]="true">\n <p-header>\n Adicionar item\n </p-header>\n\n <form [formGroup]="itemFormGroup">\n <div class="ui-fluid">\n <div class="ui-g">\n <div class="ui-g-12 ui-md-6">\n <label for="item">Item do pedido</label>\n <s-lookup dataKey="id" id="item" name="item" formControlName="item"\n [searchFields]="pedidoVendaItemSearchFields"\n [searchGridFields]="pedidoVendaItemSearchGridFields"\n [searchGridData]="pedidoVendaItemSearchGridData" [multiple]="false"\n [lookupSuggestions]="pedidoVendaItemLookupSuggestions"\n (onLookupRequest)="onPedidoVendaItemLookupRequest($event)"\n (onSearchRequest)="onPedidoVendaItemSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="pedidoVendaItemSearchTotalRecords"\n [searchTitle]="\'yms.erp.expedicao_pedido_venda_itens_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: pedidoVendaItemSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="quantidade">Quantidade</label>\n <input type="number" pInputText formControlName="quantidade">\n </div>\n </div>\n </div>\n </form>\n\n <p-footer>\n <s-button [label]="\'select\' | translate" (onClick)="selecionarPedidoVendaItem()"></s-button>\n </p-footer>\n </p-dialog>\n</div>',styles:[".required-h3{font-size:1.17rem;font-weight:700}.required-h3::after{content:'*';color:#c13018;font-weight:400;margin-left:5px;font-size:14px}.error-required-message{color:#c13018;margin-top:5px;font-size:12px}.separator{width:100%;margin:5px 0;height:1px;background-color:#ccc}.input-error{color:#c13018}.detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nota-error{color:#c13018}"]}),V("design:paramtypes",[ke,F.Router,F.ActivatedRoute,T.MessageService,C.FormBuilder,i.TranslateService,L.HotkeysService,Oe,gt,Kt,Gt,la,Vt,Pt,De,_e,c.ConfirmationService,ta,aa,Zt])],e)}(),Ja=function(){function e(e){this.expedicaoService=e,this.loading=!0,this.unsubscribe$=new t.Subject}return e.prototype.ngAfterViewInit=function(){var e=this;this.expedicaoService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",page:0,size:1}).pipe(a.takeUntil(this.unsubscribe$),a.switchMap(function(e){var a=e.contents;return a.length?t.of(a[0]):t.throwError("Dados de expedição não encontrados")}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){return e.expedicao=Ha.fromDto(t)})},P([o.Input(),V("design:type",Object)],e.prototype,"agenda",void 0),e=P([o.Component({selector:"expedicao-info",template:'\n <div *sLoadingState="loading" style="padding: 20px">\n <div class="detail-pane" *ngIf="agenda && expedicao">\n <div class="detail-span">\n <span class="title">{{\'yms.erp.expedicao_filial\' | translate}}</span>\n <span class="data">{{expedicao.filial?.codigo}} - {{expedicao.filial?.nome}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.expedicao_cliente_faturamento\' | translate}}</span>\n <span class="data">{{expedicao.clienteFaturamento?.nome}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.expedicao_cliente_remessa\' | translate}}</span>\n <span class="data">{{expedicao.clienteRemessa?.nome}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.expedicao_transportadora\' | translate}}</span>\n <span class="data">{{expedicao.transportadora?.pessoa?.nomeFantasia}}</span>\n </div>\n </div>\n </div>\n ',styles:[".detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}"]}),V("design:paramtypes",[ke])],e)}(),Xa=function(){function e(){}return e=P([p.CircuitoFinalizado({header:"Logs de integração YMS/ERP",name:"yms.integracao.erpagrox"})],e)}(),Wa=function(e){function r(a,r,o){var i=e.call(this)||this;return i.route=a,i.logIntegracaoService=r,i.translate=o,i.allPermissions={},i.permissions={},i.localeConfig={},i.currentListParams={page:0,size:10,sort:[],filterData:{}},i.serverError=!1,i.ngUnsubscribe=new t.Subject,i.xmlFormatter=require("xml-formatter")||function(e,t){return e},i}return q(r,e),r.prototype.ngOnInit=function(){var e=this;this.gridColumns=this.getGridColumns(),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)})},r.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete()},r.prototype.onRouteDataChange=function(e){this.allPermissions=e.allPermissions,this.permissions=e.allPermissions.logIntegracao,this.localeConfig=e.localeConfig},r.prototype.onSearch=function(){this.resetGrid()},r.prototype.onGridChange=function(e){var t=e.rows,a=e.first/t,r=e.multiSortMeta;return this.updateGrid({page:a,size:t,sort:r})},r.prototype.getProp=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},r.prototype.getGridColumns=function(){return[{field:"nome",header:this.translate.instant("yms.integration.log_integracao_nome")},{field:"entradaEm",header:this.translate.instant("yms.integration.log_integracao_entrada_em")},{field:"saidaEm",header:this.translate.instant("yms.integration.log_integracao_saida_em")}]},r.prototype.updateGrid=function(e){var t=this;void 0===e&&(e={}),this.showLoader=!0,this.currentListParams=w({},this.currentListParams,e);var r=this.currentListParams,o=r.page,i=r.size;this.logIntegracaoService.list({page:o,size:i,sort:[{field:"entradaEm",order:-1}],filterQuery:"agenda eq '"+this.agenda.id+"'",displayFields:["*"]}).pipe(a.takeUntil(this.ngUnsubscribe),a.catchError(function(e){throw t.serverError=!0,e}),a.finalize(function(){t.showLoader=!1})).subscribe(function(e){t.selection=[],t.gridData=e.contents,t.totalRecords=e.totalElements,t.serverError=!1})},r.prototype.getPayload=function(e){return"{"==e[0]?JSON.stringify(JSON.parse(e),null,2):"<"===e[0]?this.xmlFormatter(e):e},r.prototype.resetGrid=function(e){e&&(this.currentListParams=w({},this.currentListParams,e)),this.currentListParams=w({},this.currentListParams,{page:0,sort:[]}),this.table.reset()},r.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var r=e.get(a);r instanceof C.FormControl?r.markAsDirty({onlySelf:!0}):r instanceof C.FormGroup&&t.validateAllFormFields(r)})},P([o.Input(),V("design:type",Ia)],r.prototype,"agenda",void 0),P([o.ViewChild("logIntegracaoTable"),V("design:type",l.Table)],r.prototype,"table",void 0),P([o.ViewChild("customTemplate"),V("design:type",o.TemplateRef)],r.prototype,"customTemplate",void 0),P([o.ViewChild("customFilterFields"),V("design:type",o.TemplateRef)],r.prototype,"customFilterFields",void 0),P([o.ViewChild("customGridColgroup"),V("design:type",o.TemplateRef)],r.prototype,"customGridColgroup",void 0),P([o.ViewChild("customGridHeader"),V("design:type",o.TemplateRef)],r.prototype,"customGridHeader",void 0),P([o.ViewChild("customGridBody"),V("design:type",o.TemplateRef)],r.prototype,"customGridBody",void 0),r=P([o.Component({template:'<div *sLoadingState="showLoader">\n <s-empty-state *ngIf="serverError" iconClass="fa fa-exclamation-triangle" title="{{\'yms.integration.error_server_title\' | translate}}"\n primaryActionLabel="{{\'yms.integration.error_server_try_again\' | translate}}" (primaryAction)="resetGrid()"\n description="{{\'yms.integration.error_server_description\' | translate}}"></s-empty-state>\n <s-empty-state *ngIf="gridData && !gridData.length" [title]="\'yms.integration.log_integracao_empty_state_title\' | translate"\n [description]="\'yms.integration.log_integracao_empty_state_description\' | translate"></s-empty-state>\n <div [attr.data-hidden]="!gridData?.length || serverError">\n <div class="ui-g">\n <div class="ui-g-12">\n <p-table #logIntegracaoTable [value]="gridData" [columns]="gridColumns" dataKey="id" [lazy]="true" [scrollable]="true"\n [resizableColumns]="true" [paginator]="true" [totalRecords]="totalRecords"\n rows="10" [rowsPerPageOptions]="[10, 20, 50, 100]" [(selection)]="selection" (onLazyLoad)="onGridChange($event)" >\n <ng-template pTemplate="colgroup" let-columns *ngIf="!customGridColgroup else customGridColgroup">\n <colgroup>\n <col *ngFor="let col of columns" [style.width]="col.width">\n \x3c!--{CA:GRID_COLGROUP_COLUMNS:START}--\x3e\n \x3c!--{CA:GRID_COLGROUP_COLUMNS:END}--\x3e\n </colgroup>\n </ng-template>\n <ng-template pTemplate="header" let-columns *ngIf="!customGridHeader else customGridHeader">\n <tr>\n <th style="width: 50px">\n \n </th>\n <th *ngFor="let col of columns; let i = index" [ngStyle]="i === 0 ? {\'width\': \'200px\'} : {\'width\': \'150px\'}" pResizableColumn>\n <div class="senior-header">\n <span class="senior-header-title">{{col.header}}</span>\n </div>\n </th>\n \x3c!--{CA:GRID_HEADER_COLUMNS:START}--\x3e\n \x3c!--{CA:GRID_HEADER_COLUMNS:END}--\x3e\n </tr>\n </ng-template>\n <ng-template pTemplate="body" let-rowData let-columns let-expanded="expanded" *ngIf="!customGridBody else customGridBody">\n <tr [pSelectableRow]="rowData">\n <td style="width: 50px;">\n <a href="#" [pRowToggler]="rowData">\n <i [ngClass]="expanded ? \'pi pi-chevron-down\' : \'pi pi-chevron-right\'"></i>\n </a>\n </td>\n <td (click)="selection = [rowData]" style="width: 200px">\n <span>{{getProp(rowData, \'nome\') || (\'yms.integration.list_grid_empty_field\' | translate)}}</span>\n </td>\n <td (click)="selection = [rowData]" style="width: 150px">\n <span>{{getProp(rowData, \'entradaEm\') | localizedDate | async}}</span>\n </td>\n <td (click)="selection = [rowData]" style="width: 150px">\n <span>{{getProp(rowData, \'saidaEm\') | localizedDate | async}}</span>\n </td>\n \x3c!--{CA:GRID_BODY_COLUMNS:START}--\x3e\n \x3c!--{CA:GRID_BODY_COLUMNS:END}--\x3e\n </tr>\n </ng-template>\n <ng-template pTemplate="rowexpansion" let-rowData>\n <td colspan="4">\n <p-tabView>\n <p-tabPanel header="Payload de entrada">\n <pre *ngIf="rowData.entrada">\n <code [highlight]="getPayload(rowData.entrada)" [languages]="[\'json\', \'xml\']">\n </code>\n </pre>\n <s-empty-state *ngIf="!rowData.entrada" [title]="\'Não há informação\' | translate"\n [description]="\'Não há informações a serem exibidas\' | translate">\n </s-empty-state>\n </p-tabPanel>\n <p-tabPanel header="Payload de saída">\n <pre *ngIf="rowData.saida">\n <code [highlight]="getPayload(rowData.saida)" [languages]="[\'json\', \'xml\']">\n </code>\n </pre>\n <s-empty-state *ngIf="!rowData.saida" [title]="\'Não há informação\' | translate"\n [description]="\'Não há informações a serem exibidas\' | translate">\n </s-empty-state>\n </p-tabPanel>\n <p-tabPanel header="Stack Trace">\n <pre *ngIf="rowData.stackTrace">\n <code [highlight]="getPayload(rowData.stackTrace)" [languages]="[\'json\', \'xml\']">\n </code>\n </pre>\n <s-empty-state *ngIf="!rowData.stackTrace" [title]="\'Não há informação\' | translate"\n [description]="\'Não há informações a serem exibidas\' | translate">\n </s-empty-state>\n </p-tabPanel>\n </p-tabView>\n <div class="separator"></div>\n </td>\n </ng-template>\n <ng-template pTemplate="paginatorright">\n <span [translate]="\'yms.integration.total_records\'" [translateParams]="{value: totalRecords}"></span>\n </ng-template>\n \x3c!--{CA:GRID_TEMPLATES:START}--\x3e\n \x3c!--{CA:GRID_TEMPLATES:END}--\x3e\n </p-table>\n </div>\n </div>\n </div>\n</div>\n\x3c!--{CA:FILE_CONTENTS:START}--\x3e\n\x3c!--{CA:FILE_CONTENTS:END}--\x3e',providers:[N.ConfirmationService],styles:[".required-h3{font-size:1.17rem;font-weight:700}.required-h3::after{content:'*';color:#c13018;font-weight:400;margin-left:5px;font-size:14px}.error-required-message{color:#c13018;margin-top:5px;font-size:12px}.separator{width:100%;margin:5px 0;height:1px;background-color:#ccc}.input-error{color:#c13018}.detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nota-error{color:#c13018}"]}),V("design:paramtypes",[F.ActivatedRoute,Da,i.TranslateService])],r)}(Xa),Za=function(){function e(){}return e.fromDto=function(e){var t=w({},e);return t.filial=pt.fromDto(t.filial),t},e.toDto=function(e){var t=w({},e);return t.filial=pt.toDto(t.filial),t},e}(),er=function(){function e(e,t,a){this.override=e,this.agendaService=t,this.processoAvulsoService=a,this.AVULSO_KEY="ERP_SENIOR_PROCESSO_AVULSO"}return e.prototype.initialize=function(){var e=this;this.override.addOverride(this.AVULSO_KEY,function(t){return e.functionToOverride(t)})},e.prototype.remove=function(){this.override.disposeOverride(this.AVULSO_KEY)},e.prototype.functionToOverride=function(e){var r=this;return this.agendaService.atualizarAgenda(e.agenda).pipe(a.mergeMap(function(t){return r.processoAvulsoService.list({filterQuery:"agenda.id eq '"+e.agenda.id+"'",page:0,size:1})}),a.map(function(e){var t=e.contents;return t.length?t[0]:null}),a.mergeMap(function(a){return a?r.processoAvulsoService.registrarChegada({processoAvulso:a,circuito:e.circuito.id,sequenciaInicial:e.sequencia.id,vagaInicial:(e.vaga||{}).id}):t.throwError("Os dados da guia ERP Senior não foram informados")}))},e=P([o.Injectable(),V("design:paramtypes",[p.ChegadaVeiculoOverride,De,Fa])],e)}(),tr=function(){function e(e,a,r,o,i,n,s,l,d,c,p,u,m){this.fb=e,this.router=a,this.route=r,this.filialService=o,this.processoAvulsoService=i,this.messageService=n,this.processoAvulsoOverride=s,this.translate=l,this.confirmationService=d,this.agendaService=c,this.erpProcessService=p,this.erpFormConfigService=u,this.hasChangeService=m,this.loading=!1,this.filialLookupDisplayFields=["codigo","nome","empresa.nome"],this.filialAdvancedDisplayFields=["id","codigo","nome","empresa.nome"],this.filialLookupSeparator=" - ",this.formCarregado=!1,this.ngUnsubscribe=new t.Subject}return e.prototype.ngOnInit=function(){var e=this;this.formGroup=this.fb.group({id:[undefined],filial:[undefined,C.Validators.required],agenda:[undefined]}),this.filialSearchFields=this.getFilialSearchFields(),this.filialSearchGridFields=this.getFilialSearchGridFields(),this.getProcessoAvulso(),this.formGroup.get("filial").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=e.formGroup.get("filial").value;e.erpProcessService&&a&&(e.erpProcessData.filialId=a.id,e.erpProcessService.changeData(e.erpProcessData))}),this.processoAvulsoOverride.initialize(),this.erpProcessService.current.subscribe(function(t){return e.erpProcessData=t}),this.erpFormConfigService.current.subscribe(function(t){return e.enableRevalidation=t}),this.verificaSeTemAlteracao()},e.prototype.verificaSeTemAlteracao=function(){var e=this;this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.ngAfterViewInit=function(){var e=this;this.saveAndInitButton=document.getElementById("init"),this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete(),this.processoAvulsoOverride.remove()},e.prototype.onSave=function(e){var t=this;return this.formGroup.invalid?this.validateAllFormFields(this.formGroup):(this.loading=!0,this.isNew()||!this.enableRevalidation?this.saveAndInit(e):(this.erpProcessData=this.erpProcessService.builderErpProcessData(this.erpProcessData,this.formGroup),this.erpProcessService.changeDataErp(this.erpProcessData),this.agendaService.checarRevalidacao(this.erpProcessData).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){a.requerRevalidacao?t.atualizaAgendaParaRejeitadoPorValidacao():t.saveAndInit(e)})))},e.prototype.atualizaAgendaParaRejeitadoPorValidacao=function(){var e=this;this.confirmationService.confirm({header:this.translate.instant("yms.patio.agenda_revalidacao_title"),message:this.translate.instant("yms.patio.agenda_revalidacao_message"),accept:function(){e.hasChangeService.hasChangeSave(e.agenda.id),e.agenda.status=He.REJEITADO_POR_VALIDACAO,e.agenda.motorista={id:e.erpProcessData.motoristaId},e.agenda.veiculo={id:e.erpProcessData.veiculoId},e.agendaService.atualizarAgenda(e.agenda).pipe(a.takeUntil(e.ngUnsubscribe),a.concatMap(function(t){return e.getSaveObservable()}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.successMessage(),e.router.navigate(["/chegada-veiculo"],{relativeTo:e.route})})},reject:function(){return e.loading=!1}})},e.prototype.saveAndInit=function(e){var t=this;this.getSaveObservable().pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){t.formGroup.patchValue(w({},Za.fromDto(a))),t.successMessage(),t.hasChangeService.hasChangeSave(t.agenda.id),e&&t.saveAndInitButton&&(t.hasChangeService.hasChangeSave(t.agenda.id),t.saveAndInitButton.click())})},e.prototype.successMessage=function(){this.messageService.add({severity:"success",summary:this.translate.instant("saved_message_title"),detail:this.translate.instant("saved_message_content")})},e.prototype.isNew=function(){return!this.formGroup.value.id},e.prototype.onFilialLookupRequest=function(e){var t=this,r=this.getFilialSearchFields().filter(function(t){var a=t.type;return je(a,e)}).reduce(function(t,a){var r,o,i=a.name;return a.type===n.FieldType.Integer?w({},t,((r={})[i]=e.replace(/\D/,""),r)):w({},t,((o={})[i]=e,o))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:10,offset:0}});this.filialService.listFiliais(r).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.filialLookupSuggestions=e.filiais.map(function(e){return pt.fromDto(e)})})},e.prototype.onFilialSearchRequest=function(e){var t=this,r=e.first,o=e.rows,i=e.multiSortMeta,s=e.filterData,l=r/o,d=i,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getFilialSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,r,o=t.name,i=t.type,l=s[o];return i===n.FieldType.Integer?w({},e,((a={})[o]=(""+l).replace(/\D/,""),a)):w({},e,((r={})[o]=l,r))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:o,offset:l,listaOrdenacao:c?[w({},c)]:null}});this.filialService.listFiliais(p).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.filialSearchGridData=e.filiais.map(pt.fromDto),t.filialSearchTotalRecords=e.qtdTotalRegistros})},e.prototype.getSaveObservable=function(){var e=this.formGroup.value;e.agenda=this.agenda;var t=Za.toDto(e);return e.id?this.processoAvulsoService.update(e.id,t):this.processoAvulsoService.insert(t)},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var r=e.get(a);r instanceof C.FormControl?r.markAsDirty({onlySelf:!0}):r instanceof C.FormGroup?t.validateAllFormFields(r):r instanceof C.FormArray&&r.controls.forEach(function(e){return t.validateAllFormFields(e)})})},e.prototype.getProcessoAvulso=function(){var e=this;this.processoAvulsoService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",size:1,page:0}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;if(!a||a.length<=0)return e.buscarFilial();var r=a[0];e.formGroup.patchValue(w({},Za.fromDto(r))),e.formCarregado=!0})},e.prototype.getFilialSearchFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")})]},e.prototype.getFilialSearchGridFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")})]},e.prototype.buscarFilial=function(){var e=this,t=this.agenda.planta||{cnpj:[]};1===t.cnpj.length&&this.filialService.list({page:0,size:1,filterQuery:"pessoa.cpfCnpj eq '"+t.cnpj[0]+"'",displayFields:["*","empresa.nome"]}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;1===a.length&&e.formGroup.get("filial").setValue(pt.fromDto(a[0]))}),this.formCarregado=!0},P([o.Input(),V("design:type",Ia)],e.prototype,"agenda",void 0),e=P([o.Component({selector:"processo-avulso-form",template:'<div *sLoadingState="loading">\n <form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-md-6 ui-g-12 required">\n <label for="filial">{{\'yms.erp.recebimento_ordem_compra_filial\' | translate}}</label>\n <s-lookup dataKey="id" id="filial" name="filial" formControlName="filial"\n [searchFields]="filialSearchFields" [searchGridFields]="filialSearchGridFields"\n [searchGridData]="filialSearchGridData" [multiple]="false"\n [lookupSuggestions]="filialLookupSuggestions" (onLookupRequest)="onFilialLookupRequest($event)"\n (onSearchRequest)="onFilialSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="filialSearchTotalRecords"\n [searchTitle]="\'yms.erp.filial_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: filialSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'filial\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n </div>\n </form>\n\n <div style="margin: 5px 0 5px 0;">\n <s-button priority="primary" [label]="\'save\' | translate" (onClick)="onSave()"\n [disabled]="loading"></s-button>\n <s-button *ngIf="saveAndInitButton" priority="primary" [label]="\'save_and_init\' | translate"\n (onClick)="onSave(true)" [disabled]="loading"></s-button>\n </div>\n</div>'}),V("design:paramtypes",[C.FormBuilder,F.Router,F.ActivatedRoute,Gt,Fa,c.MessageService,er,i.TranslateService,c.ConfirmationService,De,ta,aa,Zt])],e)}(),ar=function(){function e(e){this.processoAvulsoService=e,this.loading=!1,this.unsubscribe$=new t.Subject}return e.prototype.ngAfterViewInit=function(){var e=this;this.processoAvulsoService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",page:0,size:1}).pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(t){var a=t.contents;!a||a.length<=0||(e.processoAvulso=Za.fromDto(a[0]))})},P([o.Input(),V("design:type",Ia)],e.prototype,"agenda",void 0),e=P([o.Component({selector:"processo-avulso-info",template:'\n <div *sLoadingState="loading" style="padding: 20px;">\n <div class="detail-pane" *ngIf="agenda">\n <div class="detail-span">\n <span class="title">{{\'yms.erp.filial\' | translate}}</span>\n <span class="data">{{processoAvulso?.filial?.nome}} - {{processoAvulso?.filial?.codigo}}</span>\n </div>\n </div>\n </div>\n '}),V("design:paramtypes",[Fa])],e)}(),rr=k,or=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);a.competenciaInicial=a.competenciaInicial&&rr(a.competenciaInicial).toDate(),a.competenciaFinal=a.competenciaFinal&&rr(a.competenciaFinal).toDate(),a.createdDate=a.createdDate&&rr(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&rr(a.lastModifiedDate).toDate();return a.label=Ye(a,["codigo","descricao"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Xe.fromDto(a.empresa,"Safra")),a},e.toDto=function(e,t){var a=w({},e);return a.competenciaInicial=a.competenciaInicial&&rr(a.competenciaInicial).format("YYYY-MM-DD"),a.competenciaFinal=a.competenciaFinal&&rr(a.competenciaFinal).format("YYYY-MM-DD"),a.createdDate=a.createdDate&&rr(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&rr(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Xe.toDto(a.empresa,"Safra")),a},e}(),ir=k,nr=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);a.createdDate=a.createdDate&&ir(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&ir(a.lastModifiedDate).toDate();return a.label=[""].map(function(e){return a[e]}).join(" - "),"Agenda"!==t&&a.agenda&&(a.agenda=Ia.fromDto(a.agenda,"RecebimentoOrdemCompra")),"Empresa"!==t&&a.empresa&&(a.empresa=Xe.fromDto(a.empresa,"RecebimentoOrdemCompra")),"Filial"!==t&&a.filial&&(a.filial=pt.fromDto(a.filial,"RecebimentoOrdemCompra")),"PessoaEndereco"!==t&&a.origemMercadoria&&(a.origemMercadoria=dt.fromDto(a.origemMercadoria,"RecebimentoOrdemCompra")),"Produto"!==t&&a.produto&&(a.produto=Ga.fromDto(a.produto,"RecebimentoOrdemCompra")),"Derivacao"!==t&&a.derivacao&&(a.derivacao=qa.fromDto(a.derivacao,"RecebimentoOrdemCompra")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Pa.fromDto(a.transportadora,"RecebimentoOrdemCompra")),"Safra"!==t&&a.safra&&(a.safra=or.fromDto(a.safra,"RecebimentoOrdemCompra")),"OrdemCompra"!==t&&a.ordemCompra&&(a.ordemCompra=mt.fromDto(a.ordemCompra,"RecebimentoOrdemCompra")),a.fornecedores=a.fornecedores.map(function(e){return w({},e,{fornecedor:Ze.fromDto(e.fornecedor),origemMercadoria:dt.fromDto(e.origemMercadoria),ordens:e.ordens.map(mt.fromDto)})}),a},e.toDto=function(e,t){var a=w({},e);return a.createdDate=a.createdDate&&ir(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&ir(a.lastModifiedDate).format(),delete a.label,"Agenda"!==t&&a.agenda&&(a.agenda=Ia.toDto(a.agenda,"RecebimentoOrdemCompra")),"Empresa"!==t&&a.empresa&&(a.empresa=Xe.toDto(a.empresa,"RecebimentoOrdemCompra")),"Filial"!==t&&a.filial&&(a.filial=pt.toDto(a.filial,"RecebimentoOrdemCompra")),"Produto"!==t&&a.produto&&(a.produto=Ga.toDto(a.produto,"RecebimentoOrdemCompra")),"Derivacao"!==t&&a.derivacao&&(a.derivacao=qa.toDto(a.derivacao,"RecebimentoOrdemCompra")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Pa.toDto(a.transportadora,"RecebimentoOrdemCompra")),"Safra"!==t&&a.safra&&(a.safra=or.toDto(a.safra,"RecebimentoOrdemCompra")),"OrdemCompra"!==t&&a.ordemCompra&&(a.ordemCompra=mt.toDto(a.ordemCompra,"RecebimentoOrdemCompra")),a},e}(),sr=function(){function e(e,t,a){this.override=e,this.agendaService=t,this.recebimentoOrdemCompraService=a,this.RECEBIMENTO_ORDEMCOMPRA_KEY="ERP_SENIOR_RECEBIMENTO_ORDEMCOMPRA_KEY"}return e.prototype.initialize=function(){var e=this;this.override.addOverride(this.RECEBIMENTO_ORDEMCOMPRA_KEY,function(t){return e.functionToOverride(t)})},e.prototype.remove=function(){this.override.disposeOverride(this.RECEBIMENTO_ORDEMCOMPRA_KEY)},e.prototype.functionToOverride=function(e){var r=this;return this.agendaService.atualizarAgenda(e.agenda).pipe(a.mergeMap(function(t){return r.recebimentoOrdemCompraService.list({filterQuery:"agenda.id eq '"+e.agenda.id+"'",page:0,size:1})}),a.map(function(e){var t=e.contents;return t.length?t[0]:null}),a.mergeMap(function(a){return a?r.recebimentoOrdemCompraService.registrarChegadaVeiculoRecebimentoOrdemCompra({recebimentoOrdemCompra:a,circuito:e.circuito.id,sequenciaInicial:e.sequencia.id,vagaInicial:(e.vaga||{}).id}):t.throwError("Não foi possível encontrar os dados de Recebimento de ordem de compra")}))},e=P([o.Injectable(),V("design:paramtypes",[p.ChegadaVeiculoOverride,De,ga])],e)}(),lr=function(){function e(e,a,r,o,i,n,s,l,d,c,p,u,m,f,h,g,v,y,b,F,S,D,C){var T=this;this.formBuilder=e,this.translate=a,this.filialService=r,this.pessoaService=o,this.produtoService=i,this.derivacaoService=n,this.transportadoraService=s,this.ordemCompraService=l,this.recebimentoOrdemCompraService=d,this.messageService=c,this.route=p,this.router=u,this.origemMercadoriaService=m,this.safraService=f,this.override=h,this.notaValidatorService=g,this.confirmationService=v,this.dialogService=y,this.agendaService=b,this.erpProcessService=F,this.erpFormConfigService=S,this.verificaNotaFiscal=D,this.hasChangeService=C,this.derivacaoLookupDisplayFields=["codigo","descricao"],this.derivacaoAdvancedDisplayFields=["id","codigo","descricao"],this.derivacaoLookupSeparator=" - ",this.filialLookupDisplayFields=["codigo","nome","empresa.nome"],this.filialAdvancedDisplayFields=["id","codigo","nome","empresa.nome"],this.filialLookupSeparator=" - ",this.fornecedorLookupDisplayFields=["codigo","nome","cpfCnpj"],this.fornecedorAdvancedDisplayFields=["id","codigo","nome"],this.fornecedorLookupSeparator=" - ",this.ordemCompraLookupDisplayFields=["codigo","empresa.nome"],this.ordemCompraAdvancedDisplayFields=["id","codigo","empresa.nome","filial.nome","pessoa.nome"],this.ordemCompraLookupSeparator=" - ",this.origemMercadoriaLookupDisplayFields=["codigo","endereco"],this.origemMercadoriaAdvancedDisplayFields=["id","codigo","endereco","numero"],this.origemMercadoriaLookupSeparator=" - ",this.produtoLookupDisplayFields=["codigo","descricao"],this.produtoAdvancedDisplayFields=["id","codigo","descricao"],this.produtoLookupSeparator=" - ",this.safraLookupDisplayFields=["codigo","descricao"],this.safraAdvancedDisplayFields=["id","codigo","descricao"],this.safraLookupSeparator=" - ",this.transportadoraLookupDisplayFields=["codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraAdvancedDisplayFields=["id","codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraLookupSeparator=" - ",this.disableButtonSave=!1,this.totalEixosContratados=0,this.totalEixosComposicao=0,this.erroChaveNota=!1,this.erroFornecedores=!1,this.notasTokens=[],this.fornecedorNotasTokens=[],this.fornecedorNotas=[],this.formCarregado=!1,this.ordemCompraSelecionado=null,this.ngUnsubscribe=new t.Subject,this.onFilialValueChange=function(e,t){T.changeFormGroupValue(e,"produto",t)},this.onFornecedorChange=function(e,t){T.changeFormGroupValue(e,"origemMercadoria",t),T.changeFormGroupValue(e,"ordens",t)},this.onChangeRevalidation=function(e){T.erpProcessData&&T.formGroup&&(T.erpProcessData=T.erpProcessService.builderErpProcessData(T.erpProcessData,T.formGroup),T.erpProcessService.changeData(T.erpProcessData))},this.formGroup=this.getFormGroup()}return e.prototype.ngOnInit=function(){var e=this;this.route.params.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.agenda;if("new"==a)return e.configureForm();e.getRecebimentoOrdemCompra(a)}),this.formGroup.get("filial").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.formGroup.get("fornecedores").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.formGroup.get("transportadora").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.derivacaoSearchFields=this.getDerivacaoSearchFields(),this.filialSearchFields=this.getFilialSearchFields(),this.filialSearchGridFields=this.getFilialSearchGridFields(),this.fornecedorSearchFields=this.getFornecedorSearchFields(),this.origemMercadoriaSearchFields=this.getOrigemMercadoriaSearchFields(),this.produtoSearchFields=this.getProdutoSearchFields(),this.safraSearchFields=this.getSafraSearchFields(),this.safraSearchGridFields=this.getSafraSearchGridFields(),this.transportadoraSearchFields=this.getTransportadoraSearchFields(),this.transportadoraSearchGridFields=this.getTransportadoraSearchGridFields(),this.ordemCompraSearchFields=this.getOrdemCompraFields(),this.ordemCompraSearchGridFields=this.getOrdemCompraGridFields(),this.agenda&&this.agenda.externalTenant&&this.setTransportadora(this.agenda.externalTenant.cnpj),this.getEmpresaFilial(),this.totalEixosComposicao=this.agenda&&this.agenda.veiculo&&this.agenda.veiculo.eixos||0;this.agenda&&!["AGUARDANDO_CONFIRMACAO_SOLICITANTE","AGENDADO","AGUARDANDO_CONFIRMACAO","EM_EXECUCAO","REJEITADO_POR_VALIDACAO"].includes(this.agenda.status)&&(this.formGroup.disable(),this.disableButtonSave=!0),this.createdByErpDisableForm(),this.erpProcessService.current.subscribe(function(t){return e.erpProcessData=t}),this.erpFormConfigService.current.subscribe(function(t){return e.enableRevalidation=t}),this.verificaSeTemAlteracao()},e.prototype.verificaSeTemAlteracao=function(){var e=this;this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.ngAfterViewInit=function(){this.override.initialize(),this.saveAndInitButton=document.getElementById("init")},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete(),this.override.remove()},e.prototype.createdByErpDisableForm=function(){this.agenda&&this.agenda.createdByErp&&(this.createdByErp=!0,this.formGroup.get("filial").disable(),this.formGroup.get("produto").disable(),this.formGroup.get("derivacao").disable(),this.formGroup.get("transportadora").value&&this.formGroup.get("transportadora").disable())},e.prototype.configureForm=function(){var e=this;this.valueChanges(this.formGroup,"filial",this.onFilialValueChange);this.checkValuesChanges(this.formGroup,"produto","derivacao",this.derivacaoService,function(e){return"produto.id eq '"+e.id+"' and situacao eq 'ATIVO'"},["codigo","descricao"],function(e){return qa.fromDto(e)},10,!0,!0),this.formGroup.get("fornecedores").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){t&&t.length>0?(e.formGroup.get("produto").disable(),e.formGroup.get("derivacao").disable()):(e.formGroup.get("produto").enable(),e.formGroup.get("derivacao").enable())}),this.createdByErpDisableForm(),this.formCarregado=!0},e.prototype.getEmpresaFilial=function(){var e=this,t=this.agenda.planta||{cnpj:[]};if(1===t.cnpj.length){var r="pessoa.cpfCnpj eq '"+t.cnpj[0]+"'";this.filialService.list({filterQuery:r,page:0,size:10}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;if(1===a.length){var r=a[0],o=a[0].empresa;r.label=r.codigo+" - "+r.nome,o.label=o.codigo+" - "+o.nome,e.formGroup.get("empresa").setValue(o),e.formGroup.get("filial").setValue(r),e.formGroup.get("filial").enable(),e.formGroup.get("produto").enable(),e.formGroup.get("ordemCompra").enable()}})}},e.prototype.checkValuesChanges=function(e,t,r,o,i,n,s,l,d,c){var p=this;void 0===l&&(l=1),e.get(t).valueChanges.pipe(a.takeUntil(this.ngUnsubscribe),a.debounceTime(500),a.filter(function(t){return d&&e.get(r).setValidators(t?C.Validators.required:C.Validators.nullValidator),c&&e.get(r).setValue(null),!!t||(e.get(r).setValue(null),e.get(r).disable(),!1)}),a.mergeMap(function(e){var t=i(e);return o.list({filterQuery:t,page:0,size:l})})).subscribe(function(t){var a=t.contents;if(!a||!a.length||a.length>1)return e.get(r).enable();1===a.length&&(a[0].label=p.translate.instant(Ye(a[0],n," - ",!0)),e.get(r).setValue(s(a[0]))),a.length>1?e.get(r).enable():e.get(r).disable()})},e.prototype.onBlurChaveNotaFiscal=function(){var e=this;if(!this.verificaNotaFiscal.verificaSeNotaFiscalEstaDuplicada(this.chaveNotaFiscal,this.ordens,this.fornecedorNotasTokens)){this.removeNotaError();var t=this.chaveNotaFiscal;t&&(this.loading=!0,this.mensagemBuscandoNota(),this.notaValidatorService.pesquisarDocumentoValidaNotaEmUso({filialId:this.formGroup.get("filial").value&&this.formGroup.get("filial").value.id||null,chaveDocumento:t.trim()||""}).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.adicionarNovaNota(t)}))}},e.prototype.valueChanges=function(e,t,r){e.get(t).valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return r(t,e)})},e.prototype.changeFormGroupValue=function(e,t,a){if(!e)return a.get(t).setValue(undefined),void a.get(t).disable();a.get(t).enable()},e.prototype.getRecebimentoOrdemCompra=function(e){var t=this;this.loading=!0,this.recebimentoOrdemCompraService.list({filterQuery:"agenda.id eq '"+e+"'",size:1,page:0}).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(e){var a=e.contents;if(!a.length)return t.formCarregado=!0,t.configureForm();t.totalEixosContratados=a[0].eixos||0,t.totalEixosComposicao=a[0].agenda&&a[0].agenda.veiculo&&a[0].agenda.veiculo.eixos||0;var r=nr.fromDto(a[0]);t.formGroup.enable(),t.formGroup.patchValue(r),r.fornecedores.forEach(function(e){var a=t.getFornecedorForm(e);t.getFornecedores().push(a),e.ordens.forEach(function(e){var r=t.getOrdemCompraForm(e);t.getOrdensCompra(a).push(r),e.notas.forEach(function(e){var a=t.getNotaForm(e);t.getNotas(r).push(a)})})}),t.configureForm()})},e.prototype.onFilialLookupRequest=function(e){var t=this,r=this.getFilialSearchFields().filter(function(t){var a=t.type;return je(a,e)}).reduce(function(t,a){var r,o,i=a.name;return a.type===n.FieldType.Integer?w({},t,((r={})[i]=e.replace(/\D/,""),r)):w({},t,((o={})[i]=e,o))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:10,offset:0}});this.filialService.listFiliais(r).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.filialLookupSuggestions=e.filiais.map(function(e){return pt.fromDto(e)})})},e.prototype.onFilialSearchRequest=function(e){var t=this,r=e.first,o=e.rows,i=e.multiSortMeta,s=e.filterData,l=r/o,d=i,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getFilialSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,r,o=t.name,i=t.type,l=s[o];return i===n.FieldType.Integer?w({},e,((a={})[o]=(""+l).replace(/\D/,""),a)):w({},e,((r={})[o]=l,r))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:o,offset:l,listaOrdenacao:c?[w({},c)]:null}});this.filialService.listFiliais(p).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.filialSearchGridData=e.filiais.map(pt.fromDto),t.filialSearchTotalRecords=e.qtdTotalRegistros})},e.prototype.onFornecedorLookupRequest=function(e){var t=this;Qe(this.fornecedorSearchFields,this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields,this.fornecedorLookupSeparator,this.pessoaService,e," fornecedor eq true ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.fornecedorLookupSuggestions=e.contents})},e.prototype.onFornecedorSearchRequest=function(e){var t=this;Ke(this.fornecedorSearchFields,this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields,this.fornecedorLookupSeparator,this.pessoaService,e," fornecedor eq true ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.fornecedorSearchGridData=e.contents,t.fornecedorSearchTotalRecords=e.totalElements})},e.prototype.onOrigemMercadoriaLookupRequest=function(e,t){var r=this;Qe(this.origemMercadoriaSearchFields,this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields,this.origemMercadoriaLookupSeparator,this.origemMercadoriaService,t," pessoa.id eq '"+e.get("fornecedor").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){r.origemMercadoriaLookupSuggestions=e.contents})},e.prototype.onOrigemMercadoriaSearchRequest=function(e,t){var r=this;Ke(this.origemMercadoriaSearchFields,this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields,this.origemMercadoriaLookupSeparator,this.origemMercadoriaService,t," pessoa.id eq '"+e.get("fornecedor").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){r.origemMercadoriaSearchGridData=e.contents,r.origemMercadoriaSearchTotalRecords=e.totalElements})},e.prototype.onDerivacaoLookupRequest=function(e){var t=this;Qe(this.derivacaoSearchFields,this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields,this.derivacaoLookupSeparator,this.derivacaoService,e," produto.id eq '"+this.formGroup.get("produto").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.derivacaoLookupSuggestions=e.contents})},e.prototype.onDerivacaoSearchRequest=function(e){var t=this;Ke(this.derivacaoSearchFields,this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields,this.derivacaoLookupSeparator,this.derivacaoService,e," produto.id eq '"+this.formGroup.get("produto").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.derivacaoSearchGridData=e.contents,t.derivacaoSearchTotalRecords=e.totalElements})},e.prototype.onOrdemCompraLookupRequest=function(e,t){var r=this;Qe(this.ordemCompraSearchFields,this.ordemCompraLookupDisplayFields,this.ordemCompraAdvancedDisplayFields,this.ordemCompraLookupSeparator,this.ordemCompraService,t,"filial.id eq '"+this.formGroup.get("filial").value.id+"' and pessoa.id eq '"+e.get("fornecedor").value.id+"'").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){r.ordemCompraLookupSuggestions=e.contents})},e.prototype.onOrdemCompraSearchRequest=function(e,t){var r=this;Ke(this.ordemCompraSearchFields,this.ordemCompraLookupDisplayFields,this.ordemCompraAdvancedDisplayFields,this.ordemCompraLookupSeparator,this.ordemCompraService,t,"filial.id eq '"+this.formGroup.get("filial").value.id+"' and pessoa.id eq '"+e.get("fornecedor").value.id+"'").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){r.ordemCompraSearchGridData=e.contents,r.ordemCompraSearchTotalRecords=e.totalElements})},e.prototype.addOrdemCompra=function(e){var t=this;this.dialogService.open(ht,w({},ze,{header:"Adicionar Ordem de Compra",data:{agenda:this.agenda,filial:this.formGroup.get("filial").value,fornecedor:e.get("fornecedor").value,ordens:e.get("ordens").value}})).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(a){return t.onOrdemCompraSaved(a,e)})},e.prototype.onProdutoLookupRequest=function(e){var t=this,r=this.formGroup.get("filial").value,o=this.agenda.tipoAgendamento;this.produtoService.listProdutos({pesquisa:e,empresaId:r?r.empresa.id:null,filialId:r?r.id:null,tipoAgendamentoId:o?o.id:null,situacao:"ATIVO",pagina:{limit:100,offset:0}}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.produtoLookupSuggestions=e.produtos.map(Ga.fromDto)})},e.prototype.onProdutoSearchRequest=function(e){var t=this,r=e.first,o=e.rows,i=e.multiSortMeta,s=e.filterData,l=r/o,d=i,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getProdutoSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,r,o=t.name,i=t.type,l=s[o];return i===n.FieldType.Integer?w({},e,((a={})[o]=(""+l).replace(/\D/,""),a)):w({},e,((r={})[o]=l,r))},{pagina:{limit:o,offset:l,listaOrdenacao:c?[w({},c)]:null}}),u=this.formGroup.get("filial").value,m=this.agenda.tipoAgendamento;this.produtoService.listProdutos(w({},p,{empresaId:u?u.empresa.id:null,filialId:u?u.id:null,situacao:"ATIVO",tipoAgendamentoId:m?m.id:null})).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.produtoSearchTotalRecords=e.qtdTotalRegistros,t.produtoSearchGridData=e.produtos.map(Ga.fromDto)})},e.prototype.onSafraLookupRequest=function(e){var t=this;Qe(this.safraSearchFields,this.safraLookupDisplayFields,this.safraAdvancedDisplayFields,this.safraLookupSeparator,this.safraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.safraLookupSuggestions=e.contents})},e.prototype.onSafraSearchRequest=function(e){var t=this;Ke(this.safraSearchFields,this.safraLookupDisplayFields,this.safraAdvancedDisplayFields,this.safraLookupSeparator,this.safraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.safraSearchGridData=e.contents,t.safraSearchTotalRecords=e.totalElements})},e.prototype.onTransportadoraLookupRequest=function(e){var t=this;Qe(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraLookupSuggestions=e.contents})},e.prototype.onTransportadoraSearchRequest=function(e){var t=this;Ke(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraSearchGridData=e.contents,t.transportadoraSearchTotalRecords=e.totalElements})},e.prototype.setTransportadora=function(e){var t=this;if(e){var r="pessoa.cpfCnpj eq '"+e.replace(/\./g,"").replace(/\//g,"").replace(/\-/g,"")+"'";this.transportadoraService.list({filterQuery:r,page:0,size:10}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;1===a.length&&(a[0].label=t.translate.instant(Ye(a[0],["codigo","pessoa.nome"]," - ",!0)),t.formGroup.get("transportadora").setValue(a[0]))})}},e.prototype.onSave=function(e){var t=this;return this.formGroup.get("agenda").setValue(this.agenda),this.formGroup.invalid?this.validateAllFormFields(this.formGroup):this.formGroup.get("fornecedores").length<=0?void(this.erroFornecedores=!0):(this.loading=!0,this.isNew()||!this.enableRevalidation?this.saveAndInit(e):(this.erpProcessData=this.erpProcessService.builderErpProcessDataValidaNotaNaOrdemCompra(this.erpProcessData,this.formGroup),this.erpProcessService.changeDataErp(this.erpProcessData),this.agendaService.checarRevalidacao(this.erpProcessData).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){a.requerRevalidacao?t.atualizaAgendaParaRejeitadoPorValidacao():t.saveAndInit(e)})))},e.prototype.atualizaAgendaParaRejeitadoPorValidacao=function(){var e=this;this.confirmationService.confirm({header:this.translate.instant("yms.patio.agenda_revalidacao_title"),message:this.translate.instant("yms.patio.agenda_revalidacao_message"),accept:function(){e.hasChangeService.hasChangeSave(e.agenda.id),e.agenda.status=He.REJEITADO_POR_VALIDACAO,e.agenda.motorista={id:e.erpProcessData.motoristaId},e.agenda.veiculo={id:e.erpProcessData.veiculoId},e.agendaService.atualizarAgenda(e.agenda).pipe(a.takeUntil(e.ngUnsubscribe),a.concatMap(function(t){return e.getSaveObservable()}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.successMessage(),e.router.navigate(["/chegada-veiculo"],{relativeTo:e.route})})},reject:function(){return e.loading=!1}})},e.prototype.saveAndInit=function(e){var t=this;this.getSaveObservable().pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){t.formGroup.get("id").setValue(a.id||null),t.successMessage(),t.hasChangeService.hasChangeSave(t.agenda.id),e&&t.saveAndInitButton&&t.saveAndInitButton.click()})},e.prototype.successMessage=function(){this.messageService.add({severity:"success",summary:this.translate.instant("saved_message_title"),detail:this.translate.instant("saved_message_content")})},e.prototype.isNew=function(){return!this.formGroup.value.id},e.prototype.addFornecedor=function(e){this.erroFornecedores=!1;var t=this.getFornecedorForm(e);return this.getFornecedores().push(t),t},e.prototype.removeFornecedor=function(e){var t=this;this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_fornecedor_header"),message:this.translate.instant("yms.erp.remove_fornecedor_message"),accept:function(){var a=t.getFornecedores().controls.indexOf(e);t.getFornecedores().removeAt(a)}})},e.prototype.getFornecedorForm=function(e){void 0===e&&(e={});var t=this.formBuilder.group({fornecedor:[e.fornecedor,C.Validators.required],origemMercadoria:[e.origemMercadoria],ordens:this.formBuilder.array([])});this.valueChanges(t,"fornecedor",this.onFornecedorChange);return this.checkValuesChanges(t,"fornecedor","origemMercadoria",this.origemMercadoriaService,function(e){return"pessoa.id eq '"+e.id+"'"},["codigo","endereco"],function(e){return dt.fromDto(e)},10,!1,!0),t},e.prototype.getFornecedores=function(){return this.formGroup.get("fornecedores")},e.prototype.getNotas=function(e){return e.get("notas")},e.prototype.addNota=function(e){var t=this;this.dialogService.open(yt,w({header:this.translate.instant("yms.erp.adicionar_nota")},ze,{data:{fornecedor:e.get("fornecedor").value,produto:this.formGroup.get("produto").value,filial:this.formGroup.get("filial").value,fornecedorNotasTokens:this.fornecedorNotasTokens,ordens:this.ordens}})).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(a){return t.onNotaSaved(a,e)})},e.prototype.removerNota=function(e,t,a){var r=this;this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_nota_header"),message:this.translate.instant("yms.erp.remove_nota_message"),accept:function(){var o=t.value.ordemCompra.id,i=r.getNotasFromOrdens(e,o).controls.indexOf(a);r.getNotasFromOrdens(e,o).removeAt(i);var n=a.value;r.fornecedorNotasTokens.push({id:n.chaveNotaFiscal,label:n.numeroNotaFiscal}),r.fornecedorNotas.push({chaveNotaFiscal:n.chaveNotaFiscal,serieNotaFiscal:n.serieNotaFiscal,serieLegalNotaFiscal:n.serieLegalNotaFiscal,numeroNotaFiscal:n.numeroNotaFiscal})}})},e.prototype.showButtons=function(){return!!this.agenda&&[He.AGENDADO,He.AGUARDANDO_CONFIRMACAO,He.AGUARDANDO_CONFIRMACAO_SOLICITANTE,He.REJEITADO_POR_VALIDACAO].includes(this.agenda.status)},e.prototype.disableAdicionarNota=function(){return null===this.ordemCompraSelecionado||this.ordemCompraSelecionado===undefined},e.prototype.removerOrdemCompra=function(e,t){var a=this;this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_ordem_compra_header"),message:this.translate.instant("yms.erp.remove_ordem_compra_message"),accept:function(){var r=a.getOrdensCompra(e),o=r.controls.indexOf(t);r.removeAt(o)}})},e.prototype.onOrdemCompraSaved=function(e,t){var a=this.getOrdemCompraForm({ordemCompra:e});this.getOrdensCompra(t).push(a),this.getFornecedorByOrdemCompra(e,t)},e.prototype.getFornecedorByOrdemCompra=function(e,t){this.pessoaService.list({size:1,page:0,filterQuery:"id eq '"+e.pessoa.id+"'"}).pipe(a.takeUntil(this.ngUnsubscribe),a.map(function(e){var t=e.contents;return(t||[]).length&&t[0]}),a.filter(function(e){return!!e})).subscribe(function(e){t.get("fornecedor").setValue(Ze.fromDto(e))})},e.prototype.getOrdensCompra=function(e){return this.ordens=e.get("ordens"),e.get("ordens")},e.prototype.getNotasFromOrdens=function(e,t){var a,r,o=null,i=e.controls.ordens.controls;try{for(var n=U(i),s=n.next();!s.done;s=n.next()){var l=s.value;l.controls.ordemCompra.value.id===t&&(o=l.controls.notas)}}catch(d){a={error:d}}finally{try{s&&!s.done&&(r=n["return"])&&r.call(n)}finally{if(a)throw a.error}}return o},e.prototype.addFornecedorNotasTokenEmOrdemCompra=function(e,t){if(null!==this.ordemCompraSelecionado){var a=this.fornecedorNotas.filter(function(e){return e.chaveNotaFiscal===t.id}),r=this.getNotasFromOrdens(e,this.ordemCompraSelecionado.id);null!==r&&null!==a[0]&&r.push(this.getNotaForm(a[0])),this.removeFornecedorNotasTokenDaOrdemCompra(t)}else this.mensagemOrdemCompraNaoSelecionado()},e.prototype.removeFornecedorNotasTokenDaOrdemCompra=function(e){this.fornecedorNotasTokens.splice(this.fornecedorNotasTokens.indexOf(e),1),this.fornecedorNotas=this.fornecedorNotas.filter(function(t){return t.chaveNotaFiscal!==e.id})},e.prototype.getOrdemCompraForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({ordemCompra:[e.ordemCompra,C.Validators.required],notas:this.formBuilder.array([])})},e.prototype.getNotaForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({chaveNotaFiscal:[e.chaveNotaFiscal],serieNotaFiscal:[e.serieNotaFiscal],serieLegalNotaFiscal:[e.serieLegalNotaFiscal],numeroNotaFiscal:[e.numeroNotaFiscal]})},e.prototype.mensagemOrdemCompraNaoSelecionado=function(){this.addMessage("error","Ordem de compra não selecionado","Nenhum ordem de compra foi selecionado!")},e.prototype.onNotaSaved=function(e,t){if(null!==this.ordemCompraSelecionado)if(e.addFornecedor){var a=this.formGroup.get("fornecedores").controls.find(function(t){return(t.value.fornecedor||{id:undefined}).id===e.fornecedor.id}),r=e.infoNota,o=this.getNotaForm({chaveNotaFiscal:r.chave,serieNotaFiscal:r.serie,serieLegalNotaFiscal:r.serieLegal,numeroNotaFiscal:r.numero});if(a)(n=this.getNotasFromOrdens(a,this.ordemCompraSelecionado.id)).push(o),this.disableFields(a,"fornecedor","origemMercadoria");else if(t.get("fornecedor").value){var i=this.addFornecedor({fornecedor:Ze.fromDto(e.fornecedor),origemMercadoria:dt.fromDto(e.origemMercadoria)});(n=this.getNotasFromOrdens(i,this.ordemCompraSelecionado.id)).push(o),this.disableFields(i,"fornecedor","origemMercadoria")}else{t.get("fornecedor").setValue(Ze.fromDto(e.fornecedor)),t.get("origemMercadoria").setValue(dt.fromDto(e.origemMercadoria)),(n=this.getNotasFromOrdens(t,this.ordemCompraSelecionado.id)).push(o),this.disableFields(t,"fornecedor","origemMercadoria")}}else{var n;null!==(n=this.getNotasFromOrdens(t,this.ordemCompraSelecionado.id))&&n.push(this.getNotaForm(e))}else this.mensagemOrdemCompraNaoSelecionado()},e.prototype.addMessage=function(e,t,a){this.messageService.add({severity:e,summary:this.translate.instant(t),detail:this.translate.instant(a)})},e.prototype.getSaveObservable=function(){var e=this.formGroup.getRawValue();e.empresa=e.filial.empresa;var t=nr.toDto(e);return this.isNew()&&!e.id?this.recebimentoOrdemCompraService.insert(t):this.recebimentoOrdemCompraService.update(this.formGroup.value.id,t)},e.prototype.getFormGroup=function(){return this.formBuilder.group({id:[undefined],filial:[{value:undefined,disabled:!1},C.Validators.required],fornecedores:this.formBuilder.array([]),produto:[{value:undefined,disabled:!0}],derivacao:[{value:undefined,disabled:!0}],transportadora:[undefined],safra:[undefined],agenda:[{value:undefined,disabled:!0},C.Validators.required]})},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var r=e.get(a);r instanceof C.FormControl?r.markAsDirty({onlySelf:!0}):r instanceof C.FormGroup?t.validateAllFormFields(r):r instanceof C.FormArray&&r.controls.forEach(function(e){return t.validateAllFormFields(e)})})},e.prototype.adicionarNovaNota=function(e){var t=(e.documentos||[]).length?e.documentos[0]:undefined;if(t){var a=Ze.fromDto(t.fornecedor),r=dt.fromDto(t.origemMercadoria);if(!this.getFornecedores().controls.find(function(e){return e.value.fornecedor.id===a.id}))return this.addFornecedor({fornecedor:a,origemMercadoria:r}),void this.addFornecedorNotasToken(t);this.addFornecedorNotasToken(t)}},e.prototype.addFornecedorNotasToken=function(e){this.fornecedorNotasTokens.push({id:this.chaveNotaFiscal,label:e.numero}),this.fornecedorNotas.push({chaveNotaFiscal:this.chaveNotaFiscal,serieNotaFiscal:e.serie,serieLegalNotaFiscal:e.serieLegal,numeroNotaFiscal:e.numero}),this.chaveNotaFiscal=undefined,this.loading=!1},e.prototype.removeNotaError=function(){this.erroChaveNota=!1},e.prototype.addNotaError=function(){this.erroChaveNota=!0},e.prototype.mensagemBuscandoNota=function(){this.messageService.add({severity:"info",summary:this.translate.instant("yms.erp.nota_search_summary"),detail:this.translate.instant("yms.erp.nota_search_detail"),life:5e3})},e.prototype.disableFields=function(e){for(var t=[],a=1;a<arguments.length;a++)t[a-1]=arguments[a];t.forEach(function(t){return e.get(t).disable()})},e.prototype.getDerivacaoSearchFields=function(){return[new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.derivacao_descricao")}),new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.derivacao_codigo")})]},e.prototype.getFilialSearchFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")})]},e.prototype.getFilialSearchGridFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")})]},e.prototype.getFornecedorSearchFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_codigo")}),new n.FormField({name:"cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_cpfCnpj")})]},e.prototype.getOrigemMercadoriaSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_endereco_codigo")}),new n.FormField({name:"numero",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_endereco_numero")}),new n.FormField({name:"endereco",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_endereco_endereco")})]},e.prototype.getProdutoSearchFields=function(){return[new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.produto_descricao")}),new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.produto_codigo")})]},e.prototype.getSafraSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.safra_codigo")}),new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.safra_descricao")})]},e.prototype.getSafraSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.safra_codigo")}),new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.safra_descricao")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.safra_empresa")})]},e.prototype.getTransportadoraSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_descricao")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getTransportadoraSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getOrdemCompraFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.ordem_compra_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")}),new n.FormField({name:"filial.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial")})]},e.prototype.getOrdemCompraGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.ordem_compra_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")}),new n.FormField({name:"filial.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_nome")})]},P([o.Input(),V("design:type",Ia)],e.prototype,"agenda",void 0),e=P([o.Component({selector:"recebimento-ordem-compra-form",template:'<p-confirmDialog [acceptLabel]="\'yes\' | translate" acceptIcon="" [rejectLabel]="\'no\' | translate" rejectIcon="">\n</p-confirmDialog>\n<div *sLoadingState="loading">\n <form [formGroup]="formGroup">\n <div class="ui-fluid ui-g">\n\n <div class="ui-g-12">\n <label for="chaveNotaFiscal">{{\'yms.erp.recebimento_chave_nota_fiscal\' | translate}}</label>\n <input pInputText type="text" [(ngModel)]="chaveNotaFiscal" [ngModelOptions]="{standalone: true}" (blur)="onBlurChaveNotaFiscal()">\n \x3c!-- <input [class.ng-invalid]="erroChaveNota" pInputText type="text" [(ngModel)]="chaveNotaFiscal" [ngModelOptions]="{standalone: true}" (blur)="onBlurChaveNotaFiscal()"> --\x3e\n \x3c!-- <span class="input-error" *ngIf="erroChaveNota">{{\'yms.erp.produto_nota_error_detail\' | translate}}</span> --\x3e\n </div>\n\n <div class="ui-md-6 ui-g-12 required">\n <label for="filial">{{\'yms.erp.recebimento_ordem_compra_filial\' | translate}}</label>\n <s-lookup dataKey="id" id="filial" name="filial" formControlName="filial"\n [searchFields]="filialSearchFields" [searchGridFields]="filialSearchGridFields"\n [searchGridData]="filialSearchGridData" [multiple]="false"\n [lookupSuggestions]="filialLookupSuggestions" (onLookupRequest)="onFilialLookupRequest($event)"\n (onSearchRequest)="onFilialSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="filialSearchTotalRecords"\n [searchTitle]="\'yms.erp.filial_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: filialSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'filial\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n\n <div class="ui-md-6 ui-g-12">\n <label for="transportadora">{{\'yms.erp.recebimento_ordem_compra_transportadora\' | translate}}</label>\n <s-lookup dataKey="id" id="transportadora" name="transportadora" formControlName="transportadora"\n [searchFields]="transportadoraSearchFields" [searchGridFields]="transportadoraSearchFields"\n [searchGridData]="transportadoraSearchGridData" [multiple]="false"\n [lookupSuggestions]="transportadoraLookupSuggestions"\n (onLookupRequest)="onTransportadoraLookupRequest($event)"\n (onSearchRequest)="onTransportadoraSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="transportadoraSearchTotalRecords"\n [searchTitle]="\'yms.erp.transportadora_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: transportadoraSearchTotalRecords}">\n </s-lookup>\n </div>\n\n <div class="ui-g-12" style="text-align: right;" *ngIf="totalEixosContratados || totalEixosComposicao">\n <label for="totalEixosContratados" float="right" style="display: inline;">\n {{totalEixosContratados}} {{\'yms.erp.total_eixos_contratados\' | translate}} /\n </label>\n <label for="totalEixosComposicao" float="right" style="display: inline;">\n {{totalEixosComposicao}} {{\'yms.erp.total_eixos_composicao\' | translate}}\n </label>\n </div>\n\n <div class="ui-md-12">\n <s-button *ngIf="showButtons() && !!formGroup.get(\'filial\').value && !createdByErp" styleClass="btn-erp-forms" iconClass="fas fa-plus" label="Adicionar fornecedor" priority="secondary" (onClick)="addFornecedor()"></s-button>\n <span style="display: block;" class="input-error" *ngIf="erroFornecedores">{{\'Selecione ao menos um fornecedor para continuar\' | translate}}</span>\n </div>\n\n <form class="ui-g-12" *ngFor="let fornecedorForm of getFornecedores().controls; let i = index;" [formGroup]="fornecedorForm">\n <p-panel [style]="{position: \'relative\'}" styleClass="form-group ui-g-12 ui-md-12" [toggleable]="true">\n\n <p-header>\n Fornecedor {{+i+1}}\n <s-button \n style="display: inline-block; position: absolute; right: 50px; top: 10px" \n *ngIf="showButtons() && !createdByErp"\n iconClass="fas fa-trash"\n label="Remover"\n priority="default"\n [auxiliary]="true"\n (onClick)="removeFornecedor(fornecedorForm)">\n </s-button>\n </p-header>\n \n <div class="ui-md-6 ui-g-12 required">\n <label for="fornecedor">{{\'yms.erp.recebimento_ordem_compra_fornecedor\' | translate}}</label>\n <s-lookup dataKey="id" id="fornecedor" name="fornecedor" formControlName="fornecedor"\n [searchFields]="fornecedorSearchFields" [searchGridFields]="fornecedorSearchFields"\n [searchGridData]="fornecedorSearchGridData" [multiple]="false"\n [lookupSuggestions]="fornecedorLookupSuggestions"\n (onLookupRequest)="onFornecedorLookupRequest($event)"\n (onSearchRequest)="onFornecedorSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="fornecedorSearchTotalRecords"\n [searchTitle]="\'yms.erp.fornecedor_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: { value: fornecedorSearchTotalRecords }">\n </s-lookup>\n <s-control-errors\n [control]="fornecedorForm.get(\'fornecedor\')"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }">\n </s-control-errors>\n </div>\n\n <div class="ui-md-6 ui-g-12">\n <label for="origem_mercadoria">{{\'yms.erp.recebimento_ordem_compra_mercadoria\' | translate}}</label>\n <s-lookup dataKey="id" id="origem_mercadoria" name="origem_mercadoria" formControlName="origemMercadoria" \n [searchFields]="origemMercadoriaSearchFields" [searchGridFields]="origemMercadoriaSearchFields"\n [searchGridData]="origemMercadoriaSearchGridData" [multiple]="false"\n [lookupSuggestions]="origemMercadoriaLookupSuggestions" lookupDisplayField="label"\n (onLookupRequest)="onOrigemMercadoriaLookupRequest(fornecedorForm, $event)"\n (onSearchRequest)="onOrigemMercadoriaSearchRequest(fornecedorForm, $event)" \n [searchTotalRecords]="origemMercadoriaSearchTotalRecords"\n [searchTitle]="\'yms.erp.origem_mercadoria_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: { value: origemMercadoriaSearchTotalRecords }">\n </s-lookup>\n </div>\n\n <div class="ui-g-12">\n <label for="fornecedorNotas">Notas a serem adicionadas</label>\n <s-token-list id="fornecedorNotas" [tokens]="fornecedorNotasTokens" (tokenSelected)="addFornecedorNotasTokenEmOrdemCompra(fornecedorForm, $event)" (tokenRemoved)="removeFornecedorNotasTokenDaOrdemCompra($event)" [removableTokens]="true"></s-token-list>\n </div>\n\n <div class="ui-g-12">\n <s-button label="Adicionar nota" *ngIf="showButtons()" styleClass="btn-erp-forms" priority="secondary" (onClick)="addNota(fornecedorForm)" [disabled]="disableAdicionarNota()"></s-button>\n <s-button label="Adicionar ordem de compra" *ngIf="showButtons() && !createdByErp" styleClass="btn-erp-forms" priority="secondary" (onClick)="addOrdemCompra(fornecedorForm)"></s-button>\n </div>\n\n <div class="ui-g-12">\n <h4>Ordens de Compra</h4>\n <p-table [value]="getOrdensCompra(fornecedorForm).controls" [(selection)]="ordemCompraSelecionado">\n <ng-template pTemplate="body" let-rowData>\n <tr [pSelectableRow]="rowData">\n <td style="width: 50px">\n <p-tableRadioButton [value]="rowData.get(\'ordemCompra\').value"></p-tableRadioButton>\n </td>\n <td>\n <p-accordion>\n <p-accordionTab>\n <p-header>\n Ordem {{rowData.get(\'ordemCompra\').value.codigo}}, Filial {{rowData.get(\'ordemCompra\').value.filial?.codigo}}\n\n <span *ngIf="showButtons() && !createdByErp" style="margin-left: 10px; float: right;" class="fas fa-trash" (click)="removerOrdemCompra(fornecedorForm, rowData)"></span>\n </p-header>\n\n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Notas</span>\n <span class="data">\n <p-accordion>\n <p-accordionTab *ngFor="let nota of getNotas(rowData).controls">\n <p-header>\n {{nota.get(\'chaveNotaFiscal\').value || (nota.get(\'serieNotaFiscal\').value + \' - \' + nota.get(\'numeroNotaFiscal\').value)}}\n\n <span *ngIf="showButtons()" style="margin-left: 10px; float: right;" class="fas fa-trash" (click)="removerNota(fornecedorForm, rowData, nota)"></span>\n </p-header>\n\n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Série nota fiscal</span>\n <span class="data">{{nota.value?.serieNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">Série legal nota fiscal</span>\n <span class="data">{{nota.value?.serieLegalNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">Número nota fiscal</span>\n <span class="data">{{nota.value?.numeroNotaFiscal}}</span>\n </div>\n </div>\n\n </p-accordionTab> \n </p-accordion>\n </span>\n </div>\n </div>\n </p-accordionTab>\n </p-accordion>\n </td>\n </tr>\n </ng-template>\n </p-table>\n </div>\n </p-panel>\n </form>\n </div>\n </form>\n\n <div style="margin: 5px 0 5px 0;">\n <s-button *ngIf="showButtons()" priority="primary" [label]="\'save\' | translate" (onClick)="onSave()"\n [disabled]="loading || disableButtonSave">\n </s-button>\n <s-button *ngIf="saveAndInitButton && showButtons()" priority="primary" [label]="\'save_and_init\' | translate"\n (onClick)="onSave(true)" [disabled]="loading || disableButtonSave">\n </s-button>\n </div>\n</div>',providers:[c.ConfirmationService],styles:[".required-h3{font-size:1.17rem;font-weight:700}.required-h3::after{content:'*';color:#c13018;font-weight:400;margin-left:5px;font-size:14px}.error-required-message{color:#c13018;margin-top:5px;font-size:12px}.separator{width:100%;margin:5px 0;height:1px;background-color:#ccc}.input-error{color:#c13018}.detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nota-error{color:#c13018}"]}),V("design:paramtypes",[C.FormBuilder,i.TranslateService,Gt,Kt,Xt,It,la,xe,ga,c.MessageService,F.ActivatedRoute,F.Router,Bt,na,sr,vt,c.ConfirmationService,c.DialogService,De,ta,aa,Ge,Zt])],e)}(),dr=function(){function e(e){this.recebimentoOrdemCompraService=e,this.loading=!0,this.unsubscribe$=new t.Subject}return e.prototype.ngAfterViewInit=function(){var e=this;this.recebimentoOrdemCompraService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",page:0,size:1}).pipe(a.takeUntil(this.unsubscribe$),a.switchMap(function(e){var a=e.contents;return a.length?t.of(a[0]):t.throwError("Recebimento Ordem de Compra não encontrado.")}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){return e.recebimentoOrdemCompra=nr.fromDto(t)})},P([o.Input(),V("design:type",Object)],e.prototype,"agenda",void 0),e=P([o.Component({selector:"recebimento-ordem-compra-info",template:'\n <div *sLoadingState="loading" style="padding: 20px;">\n <div class="detail-pane" *ngIf="agenda">\n\n <div class="detail-span">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_filial\' | translate}}</span>\n <span class="data">{{recebimentoOrdemCompra?.filial?.codigo}} - {{recebimentoOrdemCompra?.filial?.nome}}</span>\n </div>\n\n <div class="detail-span">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_produto\' | translate}}</span>\n <span class="data">{{recebimentoOrdemCompra?.produto?.descricao}}</span>\n </div>\n\n <div class="detail-span">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_derivacao\' | translate}}</span>\n <span class="data">{{recebimentoOrdemCompra?.derivacao?.descricao}}</span>\n </div>\n\n <div class="detail-span">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_transportadora\' | translate}}</span>\n <span class="data">{{recebimentoOrdemCompra?.transportadora?.placaVeiculo}}</span>\n </div>\n\n <div class="detail-span">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_safra\' | translate}}</span>\n <span class="data">{{recebimentoOrdemCompra?.safra?.descricao}}</span>\n </div>\n </div>\n <div *ngFor="let fornecedor of recebimentoOrdemCompra?.fornecedores">\n <div class="separator"></div>\n <h3>Fornecedor - {{fornecedor?.fornecedor?.nome}}</h3>\n <div class="detail-pane">\n <div class="detail-span" *ngFor="let ordemCompra of fornecedor.ordens">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_ordemcompra\' | translate}}</span>\n <span class="data">{{ ordemCompra.ordemCompra?.codigo }}</span>\n </div>\n </div>\n\n <div>\n <h4>Ordens de Compra</h4>\n <p-accordion>\n <p-accordionTab *ngFor="let ordemCompra of fornecedor.ordens">\n <p-header>\n Ordem de compra {{ ordemCompra?.ordemCompra?.numero }}, Filial {{ ordemCompra?.ordemCompra?.filial?.codigo }}\n </p-header>\n\n <div *ngFor="let nota of ordemCompra.notas">\n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Chave nota fiscal</span>\n <span class="data">{{ nota?.chaveNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Serie nota fiscal</span>\n <span class="data">{{ nota?.serieNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Serie legal nota fiscal</span>\n <span class="data">{{ nota?.serieLegalNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Número nota fiscal</span>\n <span class="data">{{ nota?.numeroNotaFiscal }}</span>\n </div>\n </div>\n <hr />\n </div>\n </p-accordionTab>\n </p-accordion>\n </div>\n </div>\n </div>\n ',styles:[".detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}"]}),V("design:paramtypes",[ga])],e)}(),cr=k,pr=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);return a.dataEmissao=a.dataEmissao&&cr(a.dataEmissao).toDate(),a.dataInicioVigencia=a.dataInicioVigencia&&cr(a.dataInicioVigencia).toDate(),a.dataFimVigencia=a.dataFimVigencia&&cr(a.dataFimVigencia).toDate(),a.createdDate=a.createdDate&&cr(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&cr(a.lastModifiedDate).toDate(),a.label="Número: "+a.numero+", Filial: "+a.filial.codigo,"Empresa"!==t&&a.empresa&&(a.empresa=Xe.fromDto(a.empresa,"ContratoCompra")),"Pessoa"!==t&&a.pessoa&&(a.pessoa=Ze.fromDto(a.pessoa,"ContratoCompra")),"Filial"!==t&&a.filial&&(a.filial=pt.fromDto(a.filial,"ContratoCompra")),"Safra"!==t&&a.safra&&(a.safra=or.fromDto(a.safra,"ContratoCompra")),"ContratoCompraItem"!==t&&a.itens&&(a.itens=Object.values(a.itens).map(function(e){return mr.fromDto(e,"ContratoCompra")})),a},e.toDto=function(e,t){var a=w({},e);return a.dataEmissao=a.dataEmissao&&cr(a.dataEmissao).format("YYYY-MM-DD"),a.dataInicioVigencia=a.dataInicioVigencia&&cr(a.dataInicioVigencia).format("YYYY-MM-DD"),a.dataFimVigencia=a.dataFimVigencia&&cr(a.dataFimVigencia).format("YYYY-MM-DD"),a.createdDate=a.createdDate&&cr(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&cr(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Xe.toDto(a.empresa,"ContratoCompra")),"Pessoa"!==t&&a.pessoa&&(a.pessoa=Ze.toDto(a.pessoa,"ContratoCompra")),"Filial"!==t&&a.filial&&(a.filial=pt.toDto(a.filial,"ContratoCompra")),"Safra"!==t&&a.safra&&(a.safra=or.toDto(a.safra,"ContratoCompra")),"ContratoCompraItem"!==t&&a.itens&&(a.itens=Object.values(a.itens).map(function(e){return mr.toDto(e,"ContratoCompra")}).filter(function(e){return Object.keys(e).length})),a},e}(),ur=k,mr=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);return a.sku=a.sku||{},a.dataCompetencia=a.dataCompetencia&&ur(a.dataCompetencia).toDate(),a.createdDate=a.createdDate&&ur(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&ur(a.lastModifiedDate).toDate(),a.label=a.sequencia+" - "+a.sku.descricao+" - "+a.sku.codigo,"ContratoCompra"!==t&&a.contrato&&(a.contrato=pr.fromDto(a.contrato,"ContratoCompraItem")),"Produto"!==t&&a.sku&&(a.sku=Ga.fromDto(a.sku,"ContratoCompraItem")),a},e.toDto=function(e,t){var a=w({},e);return a.dataCompetencia=a.dataCompetencia&&ur(a.dataCompetencia).format("YYYY-MM-DD"),a.createdDate=a.createdDate&&ur(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&ur(a.lastModifiedDate).format(),delete a.label,"ContratoCompra"!==t&&a.contrato&&(a.contrato=pr.toDto(a.contrato,"ContratoCompraItem")),"Produto"!==t&&a.sku&&(a.sku=Ga.toDto(a.sku,"ContratoCompraItem")),a},e}(),fr=k,hr=function(){function e(e,a,r,o,i,n){this.dialogRef=e,this.dialogConfig=a,this.contratoCompraService=r,this.contratoCompraItemService=o,this.translate=i,this.fb=n,this.contratoCompraLookupDisplayFields=["numero"],this.contratoCompraAdvancedDisplayFields=["id","numero","numeroAprovacao","situacaoAprovacao","dataEmissao","contratoPrioritario","dataInicioVigencia","dataFimVigencia"],this.contratoCompraLookupSeparator=" - ",this.contratoCompraItensLookupDisplayFields=["sequencia","sku.descricao"],this.contratoCompraItensAdvancedDisplayFields=["id","sequencia","sku.*","situacao","quantidadeContratada","quantidadeUtilizada","quantidadeEncerrada","dataCompetencia"],this.contratoCompraItensLookupSeparator=" - ",this.ngUnsubscribe=new t.Subject}return e.prototype.ngOnInit=function(){var e=this.dialogConfig.data;this.agenda=e.agenda,this.filial=e.filial,this.fornecedor=e.fornecedor,this.produto=e.produto,this.contratos=e.contratos.map(function(e){var t=e.contrato;return t?t.id:undefined}).filter(function(e){return!!e}),this.formGroup=this.getForm(),this.contratoCompraSearchFields=this.getContratoCompraFields(),this.contratoCompraSearchGridFields=this.getContratoCompraGridFields(),this.contratoCompraItensSearchFields=this.getContratoCompraItensFields(),this.contratoCompraItensSearchGridFields=this.getContratoCompraItensGridFields()},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete()},e.prototype.onContratoCompraLookupRequest=function(e){var t=this,a=this.contratoCompraLookupDisplayFields.map(function(e){return{field:e,order:"Asc"}})[0],r={numero:+e.replace(/\D/g,"")},o=this.filial;o&&o.empresa&&o.empresa.id&&(r.empresaId=o.empresa.id),this.contratoCompraService.listContratosCompra(w({},r,{pessoaId:(this.fornecedor||{id:undefined}).id,produtoId:(this.produto||{id:undefined}).id,filialId:(o||{id:undefined}).id,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,contratosSelecionados:this.contratos,pagina:{limit:30,offset:0,listaOrdenacao:[{campo:a.field,ordenacao:a.order}]}})).subscribe(function(e){t.contratoCompraLookupSuggestions=e.contents.map(pr.fromDto)})},e.prototype.onContratoCompraSearchRequest=function(e){var t=this,a=e.first,r=e.rows,o=e.multiSortMeta,i=e.filterData,n=a/r,s=this.getContratoCompraFields().filter(function(e){var t=e.name;return i[t]!=undefined&&""!=i[t]}).reduce(function(e,t){var a;return w({},e,((a={})[t.name]=i[t.name],a))},{}),l=this.filial;l&&l.empresa&&l.empresa.id&&(s.empresaId=l.empresa.id),s.dataEmissao=s.dataEmissao&&fr(s.dataEmissao).format("YYYY-MM-DD");var d=(o||[]).length?{field:o[0].field,order:1===o[0].order?"Asc":"Desc"}:{field:"numero",order:"Asc"};this.contratoCompraService.listContratosCompra(w({},s,{pessoaId:(this.fornecedor||{id:undefined}).id,produtoId:(this.produto||{id:undefined}).id,filialId:(l||{id:undefined}).id,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,contratosSelecionados:this.contratos,pagina:{limit:r,offset:n,listaOrdenacao:[{campo:d.field,ordenacao:d.order}]}})).subscribe(function(e){t.contratoCompraSearchGridData=e.contents.map(pr.fromDto),t.contratoCompraSearchTotalRecords=e.totalElements})},e.prototype.onContratoCompraItensLookupRequest=function(e){var t=this,r=this.contratoCompraItensLookupDisplayFields.map(function(e){return{field:e,order:1}}),o=this.filial.id,i={contratoId:this.formGroup.get("contrato").value.id,filialId:o,sequencia:isNaN(e)?null:e,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,pagina:this.getRecPagina(0,10,r)};this.contratoCompraItemService.pesquisarItensContratoCompra(i).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return w({},e,{contents:e.contents.map(function(e){return w({},e,{label:t.contratoCompraItensLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.contratoCompraItensLookupSeparator)})})})})).subscribe(function(e){t.contratoCompraItensLookupSuggestions=e.contents.map(mr.fromDto)})},e.prototype.onContratoCompraItensSearchRequest=function(e){var t=this,r=e.first,o=e.rows,i=e.multiSortMeta,n=e.filterData,s=i,l=this.filial.id,d={contratoId:this.formGroup.get("contrato").value.id,filialId:l,sequencia:n.sequencia,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,pagina:this.getRecPagina(r,o,s)};this.contratoCompraItemService.pesquisarItensContratoCompra(d).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return w({},e,{contents:e.contents.map(function(e){return w({},e,{label:t.contratoCompraItensLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.contratoCompraItensLookupSeparator)})})})})).subscribe(function(e){t.contratoCompraItensSearchGridData=e.contents.map(mr.fromDto),t.contratoCompraItensSearchTotalRecords=e.totalElements})},e.prototype.getProp=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},e.prototype.getRecPagina=function(e,t,a){return{offset:e/t,limit:t,listaOrdenacao:a&&a.length?a.map(function(e){return{campo:e.field,ordenacao:1===e.order?"Asc":"Desc"}}):[]}},e.prototype.addItemContrato=function(){this.getItensForm().push(this.getItemForm())},e.prototype.getItensForm=function(){return this.formGroup.get("itens")},e.prototype.save=function(){if(!this.formGroup.valid)return this.validateAllFormFields(this.formGroup);this.close({contrato:this.formGroup.value})},e.prototype.close=function(e){this.dialogRef.close(e)},e.prototype.getForm=function(){return this.fb.group({contrato:[undefined,C.Validators.required],itens:this.fb.array([])})},e.prototype.getItemForm=function(){return this.fb.group({item:[undefined,C.Validators.required],quantidade:[1]})},e.prototype.getContratoCompraFields=function(){return[new n.FormField({name:"filialContrato",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"numero",label:this.translate.instant("yms.erp.contrato_compra_numero"),type:n.FieldType.Integer})]},e.prototype.getContratoCompraGridFields=function(){return[new n.FormField({name:"numero",label:this.translate.instant("yms.erp.contrato_compra_numero"),type:n.FieldType.Integer}),new n.FormField({name:"filial.pessoa.nomeFantasia",label:this.translate.instant("yms.erp.contrato_compra_filial"),type:n.FieldType.Integer}),new n.FormField({name:"filial.pessoa.codigo",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"dataEmissao",label:this.translate.instant("yms.erp.contrato_compra_data_emissao"),type:n.FieldType.Date})]},e.prototype.getContratoCompraItensFields=function(){return[new n.FormField({name:"sequencia",label:this.translate.instant("yms.erp.contrato_compra_item_sequencia"),type:n.FieldType.Integer})]},e.prototype.getContratoCompraItensGridFields=function(){return[new n.FormField({name:"sequencia",label:this.translate.instant("yms.erp.contrato_compra_item_sequencia"),type:n.FieldType.Integer}),new n.FormField({name:"sku.descricao",label:this.translate.instant("yms.erp.produto"),type:n.FieldType.String})]},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var r=e.get(a);r instanceof C.FormControl?r.markAsDirty({onlySelf:!0}):r instanceof C.FormGroup?t.validateAllFormFields(r):r instanceof C.FormArray&&r.controls.forEach(function(e){return t.validateAllFormFields(e)})})},e=P([o.Component({template:'<form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-g-12 ui-md-6">\n <label for="contrato">Contrato</label>\n <s-lookup dataKey="id" name="contrato"\n formControlName="contrato" [searchFields]="contratoCompraSearchFields"\n [searchGridFields]="contratoCompraSearchGridFields"\n [searchGridData]="contratoCompraSearchGridData" [multiple]="false"\n [lookupSuggestions]="contratoCompraLookupSuggestions"\n (onLookupRequest)="onContratoCompraLookupRequest($event)"\n (onSearchRequest)="onContratoCompraSearchRequest($event)"\n lookupDisplayField="label" [searchTotalRecords]="contratoCompraSearchTotalRecords"\n [searchTitle]="\'yms.erp.recebimento_contrato_compra_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: contratoCompraSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="separator"></div>\n <div class="ui-g-12" *ngFor="let itemForm of getItensForm().controls">\n <form [formGroup]="itemForm">\n <div class="ui-g-6">\n <label>Contrato Item</label>\n <s-lookup dataKey="id" id="item" name="item" formControlName="item"\n [searchFields]="contratoCompraItensSearchFields"\n [searchGridFields]="contratoCompraItensSearchGridFields"\n [searchGridData]="contratoCompraItensSearchGridData" [multiple]="false"\n [lookupSuggestions]="contratoCompraItensLookupSuggestions"\n (onLookupRequest)="onContratoCompraItensLookupRequest($event)"\n (onSearchRequest)="onContratoCompraItensSearchRequest($event)"\n lookupDisplayField="label" [searchTotalRecords]="contratoCompraItensSearchTotalRecords"\n [searchTitle]="\'yms.erp.recebimento_contrato_compra_itens_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: contratoCompraItensSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="ui-g-6">\n <label>Quantidade</label>\n <input pInputText type="number" formControlName="quantidade">\n </div>\n </form>\n </div>\n <s-button label="Adicionar item" priority="secondary" (onClick)="addItemContrato()"></s-button>\n </div>\n\n <div style="margin-top: 10px;">\n <div class="separator"></div>\n <s-button style="float: right;" [label]="\'save\' | translate" priority="primary" (onClick)="save()"></s-button>\n <s-button style="float: right;" [label]="\'cancel\' | translate" priority="link" (onClick)="close()"></s-button>\n </div>\n</form>\n\n'}),V("design:paramtypes",[c.DynamicDialogRef,c.DynamicDialogConfig,kt,Ct,i.TranslateService,C.FormBuilder])],e)}(),gr=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);return a.label=Ye(a,["codigo","descricao"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Xe.fromDto(a.empresa,"Transgenia")),"Royalty"!==t&&a.royalty&&(a.royalty=Ea.fromDto(a.royalty,"Royalty")),a},e.toDto=function(e,t){var a=w({},e);return delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Xe.toDto(a.empresa,"Transgenia")),"Royalty"!==t&&a.royalty&&(a.roylty=Ea.toDto(a.royalty,"Transgenia")),a},e}(),vr=k,yr=function(){function e(){}return e.fromDto=function(e,t){var a=w({},e);a.createdDate=a.createdDate&&vr(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&vr(a.lastModifiedDate).toDate();return a.label=["id","fornecedor.id","fornecedor.codigo","fornecedor.nome","fornecedor.situacao","produto.id","produto.codigo","produto.comprado","produto.descricao","produto.produtoMisto","produto.situacao","produto.tipo","agenda.id","agenda.descricao","transportadora.id","transportadora.codigo","transportadora.placaVeiculo","transgenia.id","transgenia.codigo","transgenia.descricao","tipoNotaFiscal","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Filial"!==t&&a.filial&&(a.filial=pt.fromDto(a.filial,"Recebimento")),"Produto"!==t&&a.produto&&(a.produto=Ga.fromDto(a.produto,"Recebimento")),"Agenda"!==t&&a.agenda&&(a.agenda=Ia.fromDto(a.agenda,"Recebimento")),"PessoaEndereco"!==t&&a.origemMercadoria&&(a.origemMercadoria=dt.fromDto(a.origemMercadoria,"Recebimento")),"Derivacao"!==t&&a.derivacao&&(a.derivacao=qa.fromDto(a.derivacao,"Recebimento")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Pa.fromDto(a.transportadora,"Recebimento")),"Transgenia"!==t&&a.transgenia&&(a.transgenia=gr.fromDto(a.transgenia,"Transgenia")),a.fornecedores=a.fornecedores.map(function(e){return w({},e,{fornecedor:Ze.fromDto(e.fornecedor,"Recebimento"),origemMercadoria:dt.fromDto(e.origemMercadoria,"Recebimento"),contratos:e.contratos.map(function(e){return w({},e,{contrato:pr.fromDto(e.contrato),itens:e.itens.map(function(e){return w({},e,{item:mr.fromDto(e.item)})})})})})}),a},e.toDto=function(e,t){var a=w({},e);return a.createdDate=a.createdDate&&vr(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&vr(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.fornecedor&&(a.fornecedor=Ze.toDto(a.fornecedor,"Recebimento")),"Filial"!==t&&a.filial&&(a.filial=pt.toDto(a.filial,"Filial")),"Produto"!==t&&a.produto&&(a.produto=Ga.toDto(a.produto,"Recebimento")),"Agenda"!==t&&a.agenda&&(a.agenda=Ia.toDto(a.agenda,"Recebimento")),"PessoaEndereco"!==t&&a.origemMercadoria&&(a.origemMercadoria=dt.toDto(a.origemMercadoria,"Recebimento")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=Pa.toDto(a.transportadora,"Recebimento")),"Transgenia"!==t&&a.transgenia&&(a.transgenia=gr.toDto(a.transgenia,"Transgenia")),a.fornecedores=e.fornecedores.map(function(e){return w({},e,{fornecedor:Ze.toDto(e.fornecedor,"Recebimento"),origemMercadoria:dt.toDto(e.origemMercadoria,"Recebimento"),contratos:e.contratos.map(function(e){return w({},e,{contrato:pr.toDto(e.contrato),itens:e.itens.map(function(e){return w({},e,{item:mr.toDto(e.item)})})})})})}),a},e}();!function(e){e.EMPRESA_JURIDICA="EMPRESA_JURIDICA",e.PRODUTOR_RURAL="PRODUTOR_RURAL"}(Ua||(Ua={})),function(e){e.NAO_INFORMADO="NAO_INFORMADO",e.PARTICIPANTE_MONSANTO="PARTICIPANTE_MONSANTO",e.NAO_PARTICIPANTE_MONSANTO="NAO_PARTICIPANTE_MONSANTO"}(Ba||(Ba={}));var br=k,Fr=function(){function e(e,a,r,o,i,n,s,l,d,c,p,u,m,f,h,g,v,y,b,F,S,D,C,T,k,_){var I=this;this.recebimentoService=e,this.router=a,this.route=r,this.messageService=o,this.confirmationService=i,this.formBuilder=n,this.translate=s,this.hotkeysService=l,this.fieldCustomization=d,this.focusService=c,this.filialService=p,this.transportadoraService=u,this.pessoaEnderecoService=m,this.contratoCompraService=f,this.pessoaService=h,this.produtoService=g,this.derivacaoService=v,this.recebimentoChegadaOverride=y,this.notaValidatorService=b,this.transgeniaService=F,this.dialogService=S,this.agendaService=D,this.erpProcessService=C,this.erpFormConfigService=T,this.verificaNotaFiscal=k,this.hasChangeService=_,this.localeConfig={},this.currencyLocaleOptions={},this.permissions={},this.allPermissions={},this.visibleDialog=!1,this.quantidadeSelecionada=1,this.mainPanelCollapsed=!1,this.filialLookupDisplayFields=["codigo","nome","empresa.nome"],this.filialAdvancedDisplayFields=["id","codigo","nome","empresa.nome"],this.filialLookupSeparator=" - ",this.fornecedorLookupDisplayFields=["codigo","nome","cpfCnpj"],this.fornecedorAdvancedDisplayFields=["id","codigo","nome","situacao","cpfCnpj","tipoParticipante"],this.fornecedorLookupSeparator=" - ",this.origemMercadoriaLookupDisplayFields=["codigo","cep","endereco","empresa.descricao"],this.origemMercadoriaAdvancedDisplayFields=["id","codigo","cep","endereco","numero","complemento","cidade.*","bairro","situacao","empresa.descricao"],this.origemMercadoriaLookupSeparator=" - ",this.produtoLookupDisplayFields=["codigo","descricao","tipo"],this.produtoAdvancedDisplayFields=["id","codigo","comprado","descricao","produtoMisto","situacao","tipo"],this.produtoLookupSeparator=" - ",this.agendaLookupDisplayFields=["id","descricao"],this.agendaAdvancedDisplayFields=["id","descricao"],this.agendaLookupSeparator=" - ",this.derivacaoLookupDisplayFields=["codigo","descricao"],this.derivacaoAdvancedDisplayFields=["id","codigo","descricao"],this.derivacaoLookupSeparator=" - ",this.transportadoraLookupDisplayFields=["codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraAdvancedDisplayFields=["id","codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraLookupSeparator=" - ",this.transgeniaLookupDisplayFields=["codigo","descricao"],this.transgeniaAdvancedDisplayFields=["id","codigo","descricao"],this.transgeniaLookupSeparator=" - ",this.disableButtonSave=!1,this.disableOrdersButtons=!0,this.totalEixosContratados=0,this.totalEixosComposicao=0,this.tiposNota=[{label:this.translate.instant("yms.erp.tipo_nota_fiscal_empresa_juridica"),value:Ua.EMPRESA_JURIDICA},{label:this.translate.instant("yms.erp.tipo_nota_fiscal_produtor_rural"),value:Ua.PRODUTOR_RURAL}],this.erroChaveNota=!1,this.erroFornecedores=!1,this.notasTokens=[],this.fornecedorNotasTokens=[],this.fornecedorNotas=[],this.contratoSelecionado=null,this.ngUnsubscribe=new t.Subject,this.onChangeRevalidation=function(e){I.erpProcessData&&I.formGroup&&(I.erpProcessData=I.erpProcessService.builderErpProcessData(I.erpProcessData,I.formGroup),I.erpProcessService.changeData(I.erpProcessData))},this.getTipoTransgenia=function(){if(I.formGroup.get("fornecedores").length<=0)return Ba.NAO_INFORMADO;var e=I.formGroup.get("fornecedores").at(0).getRawValue().fornecedor;return e&&e.tipoParticipante||Ba.NAO_INFORMADO},this.onFilialValueChange=function(e){if(I.disableOrdersButtons=!e,!e&&I.isNew())return I.formGroup.get("produto").setValue(undefined),I.formGroup.get("produto").disable(),I.formGroup.get("transgenia").setValue(undefined),void I.formGroup.get("transgenia").disable();I.formGroup.get("produto").enable(),I.formGroup.get("transgenia").enable()}}return e.prototype.ngOnInit=function(){var e=this;this.formGroup=this.getFormGroup(),this.itemFormGroup=this.getItemForm(),this.formGroup.get("filial").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onFilialValueChange),this.formGroup.get("produto").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe),a.debounceTime(500),a.filter(function(t){var a=e.formGroup.get("derivacao").value;return(!a||a.produto.id!==t.id)&&(!!t||(e.formGroup.get("derivacao").setValue(undefined),e.formGroup.get("derivacao").disable(),!1))}),a.mergeMap(function(t){return e.derivacaoService.list({filterQuery:"produto.id eq '"+t.id+"' and situacao eq 'ATIVO'",page:0,size:1})})).subscribe(function(t){var a=t.contents;a.length?(e.formGroup.get("derivacao").setValue(a[0]),e.formGroup.get("derivacao").disable()):e.formGroup.get("derivacao").enable()}),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)}),this.route.params.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.agenda;"new"==a?e.buscarFilial():e.getRecebimento(a)}),this.formGroup.get("transportadora").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.formGroup.get("transgenia").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.formGroup.get("fornecedores").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.filialSearchFields=this.getFilialSearchFields(),this.filialSearchGridFields=this.getFilialSearchFields(),this.fornecedorSearchFields=this.getFornecedorSearchFields(),this.fornecedorSearchGridFields=this.getFornecedorSearchGridFields(),this.origemMercadoriaSearchFields=this.getOrigemMercadoriaFields(),this.origemMercadoriaSearchGridFields=this.getOrigemMercadoriaGridFields(),this.produtoSearchFields=this.getProdutoSearchFields(),this.produtoSearchGridFields=this.getProdutoSearchGridFields(),this.agendaSearchFields=this.getAgendaSearchFields(),this.agendaSearchGridFields=this.getAgendaSearchGridFields(),this.derivacaoSearchFields=this.getDerivacaoSearchFields(),this.derivacaoSearchGridFields=this.getDerivacaoSearchGridFields(),this.transportadoraSearchFields=this.getTransportadoraSearchFields(),this.transportadoraSearchGridFields=this.getTransportadoraSearchGridFields(),this.transgeniaSearchFields=this.getTransgeniaSearchFields(),this.transgeniaSearchGridFields=this.getTransgeniaSearchGridFields(),this.setHotkeys(),this.agenda&&this.agenda.externalTenant&&this.setTransportadora(this.agenda.externalTenant.cnpj),this.totalEixosComposicao=this.agenda&&this.agenda.veiculo&&this.agenda.veiculo.eixos||0;this.agenda&&!["AGUARDANDO_CONFIRMACAO_SOLICITANTE","AGENDADO","AGUARDANDO_CONFIRMACAO","EM_EXECUCAO","REJEITADO_POR_VALIDACAO"].includes(this.agenda.status)&&(this.formGroup.disable(),this.disableButtonSave=!0),this.erpProcessService.current.subscribe(function(t){return e.erpProcessData=t}),this.erpFormConfigService.current.subscribe(function(t){return e.enableRevalidation=t}),this.verificaSeTemAlteracao()},e.prototype.verificaSeTemAlteracao=function(){var e=this;this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.ngAfterViewInit=function(){var e=this,t=document.getElementsByTagName("input"),a=Array.from(t).find(function(e){return!e.disabled});a&&a.focus(),this.recebimentoChegadaOverride.initialize(),this.saveAndInitButton=document.getElementById("init"),this.createdByErpDisableForm(),this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete(),this.recebimentoChegadaOverride.remove()},e.prototype.createdByErpDisableForm=function(){this.disableOrdersButtons=this.agenda.createdByErp,this.agenda&&this.agenda.createdByErp&&(this.createdByErp=!0,this.formGroup.get("filial").disable(),this.formGroup.get("produto").disable(),this.formGroup.get("derivacao").disable(),this.disableFornecedores(),this.formGroup.get("transportadora").value&&this.formGroup.get("transportadora").disable())},e.prototype.disableFornecedores=function(){this.formGroup.get("fornecedores").controls.forEach(function(e){return e.get("fornecedor").disable()})},e.prototype.setHotkeys=function(){var e=this;this.hotkeysService.add(new L.Hotkey("alt+shift+x",function(){return e.permissions.excluir&&e.onDelete(),!1},["INPUT","SELECT","TEXTAREA"])),this.hotkeysService.add(new L.Hotkey("alt+shift+s",function(){return(e.isNew()||e.permissions.editar)&&e.onSave(),!1},["INPUT","SELECT","TEXTAREA"])),this.hotkeysService.add(new L.Hotkey("alt+shift+c",function(){return e.onCancel(),!1},["INPUT","SELECT","TEXTAREA"]))},e.prototype.onBlurChaveNotaFiscal=function(){var e=this;if(!this.verificaNotaFiscal.verificaSeNotaFiscalEstaDuplicada(this.chaveNotaFiscal,this.contratos,this.fornecedorNotasTokens)){this.removeNotaError();var t=this.chaveNotaFiscal;t&&(this.loading=!0,this.mensagemBuscandoNota(),this.notaValidatorService.pesquisarDocumentoValidaNotaEmUso({filialId:this.formGroup.get("filial").value&&this.formGroup.get("filial").value.id||null,chaveDocumento:t.trim()}).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return e.loading=!1})).subscribe(function(t){return e.adicionarNovaNota(t)}))}},e.prototype.isNew=function(){return!this.formGroup.value.id},e.prototype.updateSuggestions=function(e){e.fornecedor&&(e.fornecedor.label=this.getSuggestionValue(["id","codigo","nome","situacao"],"fornecedor",e,this.fornecedorLookupSeparator),e.fornecedor.label.trim()===this.fornecedorLookupSeparator.trim()&&delete e.fornecedor.label),e.produto&&(e.produto.label=this.getSuggestionValue(["id","codigo","comprado","descricao","produtoMisto","situacao","tipo"],"produto",e,this.produtoLookupSeparator),e.produto.label.trim()===this.produtoLookupSeparator.trim()&&delete e.produto.label),e.agenda&&(e.agenda.label=this.getSuggestionValue(["id","descricao"],"agenda",e,this.agendaLookupSeparator),e.agenda.label.trim()===this.agendaLookupSeparator.trim()&&delete e.agenda.label),e.derivacao&&(e.derivacao.label=this.getSuggestionValue(["id","codigo","descricao"],"derivacao",e,this.derivacaoLookupSeparator),e.derivacao.label.trim()===this.derivacaoLookupSeparator.trim()&&delete e.derivacao.label)},e.prototype.getSuggestionValue=function(e,t,a,r){var o=this;return e.map(function(e){return o.getProp(a,t+"."+e)}).reduce(function(e,t){return""+e+r+t})},e.prototype.onRouteDataChange=function(e){var t=e.localeConfig.number,a=t.currencySymbol,r=t.thousandsSeparator,o=t.decimalSeparator;if(this.localeConfig=e.localeConfig,this.currencyLocaleOptions={align:"left",prefix:a,thousands:r,decimal:o},this.permissions=e.allPermissions.recebimento,this.allPermissions=e.allPermissions,e.entity){this.permissions.editar||this.formGroup.disable();var i=yr.fromDto(e.entity);this.updateSuggestions(i),this.formGroup.patchValue(i)}else this.formGroup.patchValue(new yr)},e.prototype.onCancel=function(){this.goBack()},e.prototype.onSendFile=function(e,a){var r=[];return this.fieldCustomization.isEmpty(e)||r.push(this.fieldCustomization.deleteFiles(e)),this.fieldCustomization.isEmpty(a)||r.push(this.fieldCustomization.commitFiles(a)),this.fieldCustomization.isEmpty(r)?t.of({}):t.forkJoin(r)},e.prototype.onSave=function(e){var t=this;if(!(this.formGroup.get("fornecedores").length<=0))return this.formGroup.invalid?this.validateAllFormFields(this.formGroup):(this.loading=!0,this.isNew()||!this.enableRevalidation?this.saveAndInit(e):(this.erpProcessData=this.erpProcessService.builderErpProcessDataValidaNotaNoContrato(this.erpProcessData,this.formGroup),this.erpProcessService.changeDataErp(this.erpProcessData),this.agendaService.checarRevalidacao(this.erpProcessData).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){a.requerRevalidacao?t.atualizaAgendaParaRejeitadoPorValidacao():t.saveAndInit(e)})));this.erroFornecedores=!0},e.prototype.atualizaAgendaParaRejeitadoPorValidacao=function(){var e=this;this.confirmationService.confirm({header:this.translate.instant("yms.patio.agenda_revalidacao_title"),message:this.translate.instant("yms.patio.agenda_revalidacao_message"),accept:function(){e.hasChangeService.hasChangeSave(e.agenda.id),e.agenda.status=He.REJEITADO_POR_VALIDACAO,e.agenda.motorista={id:e.erpProcessData.motoristaId},e.agenda.veiculo={id:e.erpProcessData.veiculoId},e.agendaService.atualizarAgenda(e.agenda).pipe(a.takeUntil(e.ngUnsubscribe),a.concatMap(function(t){return e.getSaveObservable()}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.successMessage(),e.router.navigate(["/chegada-veiculo"],{relativeTo:e.route})})},reject:function(){return e.loading=!1}})},e.prototype.saveAndInit=function(e){var t=this;this.getSaveObservable().pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){t.formGroup.get("id").setValue(a.id||null),t.successMessage(),t.hasChangeService.hasChangeSave(t.agenda.id),e&&t.saveAndInitButton&&t.saveAndInitButton.click()})},e.prototype.successMessage=function(){this.messageService.add({severity:"success",summary:this.translate.instant("saved_message_title"),detail:this.translate.instant("saved_message_content")})},e.prototype.onDelete=function(){var e=this;this.confirmationService.confirm({message:this.translate.instant("yms.erp.delete_confirmation_message"),header:this.translate.instant("yms.erp.delete_confirmation_title"),accept:function(){return e.getDeleteObservable().pipe(a.takeUntil(e.ngUnsubscribe)).subscribe()}})},e.prototype.setTransportadora=function(e){var t=this;if(e){var r="pessoa.cpfCnpj eq '"+e.replace(".","").replace("/","").replace("-","")+"'";this.transportadoraService.list({filterQuery:r,page:0,size:10}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;if(1===a.length){var r=a[0].codigo?a[0].codigo.toString():"",o=a[0].descricao?a[0].descricao.toString():"";o.trim()||r.trim()?a[0].label=r+" - "+o:a[0].label=t.translate.instant("yms.erp.derivacao_sem_descricao"),t.formGroup.get("transportadora").setValue(a[0])}})}},e.prototype.getProp=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},e.prototype.getRecebimento=function(e){var t=this;this.loading=!0,this.recebimentoService.list({filterQuery:"agenda.id eq '"+e+"'",size:1,page:0}).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(e){var a=e.contents;if(a.length){t.totalEixosContratados=a[0].eixos||0,t.totalEixosComposicao=a[0].agenda&&a[0].agenda.veiculo&&a[0].agenda.veiculo.eixos||0;var r=yr.fromDto(a[0]);t.formGroup.enable(),t.formGroup.patchValue(r),r.fornecedores.forEach(function(e){var a=t.getFornecedorForm(e);t.getFornecedores().push(a),e.contratos.forEach(function(e){var r=t.getContratoForm(e);t.getContratos(a).push(r),e.itens.forEach(function(e){var a=t.getItemForm(e);t.getItensContrato(r).push(a)}),e.notas.forEach(function(e){var a=t.getNotaForm(e);t.getNotas(r).push(a)})})}),t.formCarregado=!0,t.createdByErpDisableForm()}else t.buscarFilial()})},e.prototype.onFilialLookupRequest=function(e){var t=this,r=this.getFilialSearchFields().filter(function(t){var a=t.type;return je(a,e)}).reduce(function(t,a){var r,o,i=a.name;return a.type===n.FieldType.Integer?w({},t,((r={})[i]=e.replace(/\D/,""),r)):w({},t,((o={})[i]=e,o))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:10,offset:0}});this.filialService.listFiliais(r).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.filialLookupSuggestions=e.filiais.map(pt.fromDto)})},e.prototype.onFilialSearchRequest=function(e){var t=this,r=e.first,o=e.rows,i=e.multiSortMeta,s=e.filterData,l=r/o,d=i,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getFilialSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,r,o=t.name,i=t.type,l=s[o];return i===n.FieldType.Integer?w({},e,((a={})[o]=(""+l).replace(/\D/,""),a)):w({},e,((r={})[o]=l,r))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:o,offset:l,listaOrdenacao:c?[w({},c)]:null}});this.filialService.listFiliais(p).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.filialSearchGridData=e.filiais.map(pt.fromDto),t.filialSearchTotalRecords=e.qtdTotalRegistros})},e.prototype.onFornecedorLookupRequest=function(e){var t=this,r=this.fornecedorLookupDisplayFields.map(function(e){return{field:e,order:1}}),o=this.getFornecedorSearchFields().filter(function(t){var a=t.type;return je(a,e)}).map(function(t){var a=t.name,r=t.type;return"number"==typeof e?a+" eq "+e:r==n.FieldType.Date?a+" eq '"+br(e).format("YYYY-MM-DD")+"'":r==n.FieldType.Time?a+" eq '"+br(e).format("HH:mm:ss")+"'":r==n.FieldType.DateTime?a+" eq '"+br(e).format()+"'":r==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or ");o="("+o+")"+(o?" and ":"")+"situacao eq 'ATIVO' and fornecedor eq true";var i=Pe(this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields);this.pessoaService.list({sort:r,filterQuery:o,displayFields:i}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return w({},e,{contents:e.contents.map(function(e){return w({},e,{label:t.fornecedorLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.fornecedorLookupSeparator)})})})})).subscribe(function(e){t.fornecedorLookupSuggestions=e.contents})},e.prototype.onFornecedorSearchRequest=function(e){var t=this,r=e.first,o=e.rows,i=e.multiSortMeta,s=e.filterData,l=r/o,d=i,c=this.getFornecedorSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,r=s[t];return"number"==typeof r?t+" eq "+r:a==n.FieldType.Date?t+" eq '"+br(r).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+br(r).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+br(r).format()+"'":a==n.FieldType.Enum?t+" eq '"+r+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+r.replace(/'/g,"\\'")+"'))":t+" eq '"+r+"'"}).join(" and ");c=c.concat((c?" and ":"")+"situacao eq 'ATIVO' and fornecedor eq true");var p=Pe(this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields);this.pessoaService.list({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return w({},e,{contents:e.contents.map(function(e){return w({},e,{label:t.fornecedorLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.fornecedorLookupSeparator)})})})})).subscribe(function(e){t.fornecedorSearchGridData=e.contents,t.fornecedorSearchTotalRecords=e.totalElements})},e.prototype.onOrigemMercadoriaLookupRequest=function(e,t){var r=this,o=(this.origemMercadoriaLookupDisplayFields.map(function(e){return{field:e,order:1}}),this.getOrigemMercadoriaFields().filter(function(t){var a=t.type;return je(a,e)}).map(function(t){var a=t.name,r=t.type;return"number"==typeof e?a+" eq "+e:r==n.FieldType.Date?a+" eq '"+br(e).format("YYYY-MM-DD")+"'":r==n.FieldType.Time?a+" eq '"+br(e).format("HH:mm:ss")+"'":r==n.FieldType.DateTime?a+" eq '"+br(e).format()+"'":r==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or "));o="("+o+")"+(o?" and ":"")+"situacao eq 'ATIVO' and pessoa.id eq '"+t.get("fornecedor").value.id+"'";var i=Pe(this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields);this.pessoaEnderecoService.list({filterQuery:o,displayFields:i}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return w({},e,{contents:e.contents.map(function(e){return w({},e,{label:r.origemMercadoriaLookupDisplayFields.map(function(t){return t.indexOf(".")>0?r.getProp(e,t):e[t]}).join(r.origemMercadoriaLookupSeparator)})})})})).subscribe(function(e){r.origemMercadoriaLookupSuggestions=e.contents})},e.prototype.onOrigemMercadoriaSearchRequest=function(e,t){var r=this,o=e.first,i=e.rows,s=e.multiSortMeta,l=e.filterData,d=o/i,c=s,p=this.getOrigemMercadoriaFields().filter(function(e){var t=e.name;return l[t]!=undefined&&""!=l[t]}).map(function(e){var t=e.name,a=e.type,r=l[t];return"number"==typeof r?t+" eq "+r:a==n.FieldType.Date?t+" eq '"+br(r).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+br(r).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+br(r).format()+"'":a==n.FieldType.Enum?t+" eq '"+r+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+r.replace(/'/g,"\\'")+"'))":t+" eq '"+r+"'"}).join(" and ");p=p.concat((p?" and ":"")+"situacao eq 'ATIVO' and pessoa.id eq '"+t.get("fornecedor").value.id+"'");var u=Pe(this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields);this.pessoaEnderecoService.list({page:d,sort:c,filterQuery:p,displayFields:u}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return w({},e,{contents:e.contents.map(function(e){return w({},e,{label:r.origemMercadoriaLookupDisplayFields.map(function(t){return t.indexOf(".")>0?r.getProp(e,t):e[t]}).join(r.origemMercadoriaLookupSeparator)})})})})).subscribe(function(e){r.origemMercadoriaSearchGridData=e.contents,r.origemMercadoriaSearchTotalRecords=e.totalElements})},e.prototype.getRecPagina=function(e,t,a){return{offset:e/t,limit:t,listaOrdenacao:a&&a.length?a.map(function(e){return{campo:e.field,ordenacao:1===e.order?"Asc":"Desc"}}):[]}},e.prototype.onProdutoLookupRequest=function(e){var t=this,r=this.formGroup.get("filial").value,o=this.agenda.tipoAgendamento;this.produtoService.listProdutosRecebimento({pesquisa:e,empresaId:r?r.empresa.id:null,filialId:r?r.id:null,tipoAgendamentoId:o?o.id:null}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.produtoLookupSuggestions=(e.produtos||[]).map(function(e){return Ga.fromDto(e)})})},e.prototype.onProdutoSearchRequest=function(e){var t=this,r=e.first,o=e.rows,i=e.multiSortMeta,s=e.filterData,l=r/o,d=i,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getProdutoSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,r,o=t.name,i=t.type,l=s[o];return i===n.FieldType.Integer?w({},e,((a={})[o]=(""+l).replace(/\D/,""),a)):w({},e,((r={})[o]=l,r))},{pagina:{limit:o,offset:l,listaOrdenacao:c?[w({},c)]:null}}),u=this.formGroup.get("filial").value,m=this.agenda.tipoAgendamento;this.produtoService.listProdutosRecebimento(w({},p,{empresaId:u?u.empresa.id:null,filialId:u?u.id:null,tipoAgendamentoId:m?m.id:null})).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.produtoSearchTotalRecords=e.qtdTotalRegistros,t.produtoSearchGridData=e.produtos.map(Ga.fromDto)})},e.prototype.onDerivacaoLookupRequest=function(e){var t=this,r=this.derivacaoLookupDisplayFields.map(function(e){return{field:e,order:1}}),o=this.getDerivacaoSearchFields().filter(function(t){var a=t.type;return je(a,e)}).map(function(t){var a=t.name,r=t.type;return"number"==typeof e?a+" eq "+e:r==n.FieldType.Date?a+" eq '"+br(e).format("YYYY-MM-DD")+"'":r==n.FieldType.Time?a+" eq '"+br(e).format("HH:mm:ss")+"'":r==n.FieldType.DateTime?a+" eq '"+br(e).format()+"'":r==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or "),i=Pe(this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields);this.derivacaoService.list({sort:r,filterQuery:o,displayFields:i}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return w({},e,{contents:e.contents.map(function(e){return w({},e,{label:t.derivacaoLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.derivacaoLookupSeparator)})})})})).subscribe(function(e){t.derivacaoLookupSuggestions=e.contents})},e.prototype.onDerivacaoSearchRequest=function(e){var t=this,r=e.first,o=e.rows,i=e.multiSortMeta,s=e.filterData,l=r/o,d=i,c=this.getDerivacaoSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,r=s[t];return"number"==typeof r?t+" eq "+r:a==n.FieldType.Date?t+" eq '"+br(r).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+br(r).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+br(r).format()+"'":a==n.FieldType.Enum?t+" eq '"+r+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+r.replace(/'/g,"\\'")+"'))":t+" eq '"+r+"'"}).join(" and "),p=Pe(this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields);this.derivacaoService.list({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return w({},e,{contents:e.contents.map(function(e){return w({},e,{label:t.derivacaoLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.derivacaoLookupSeparator)})})})})).subscribe(function(e){t.derivacaoSearchGridData=e.contents,t.derivacaoSearchTotalRecords=e.totalElements})},e.prototype.onTransportadoraLookupRequest=function(e){var t=this;Qe(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraLookupSuggestions=e.contents})},e.prototype.onTransportadoraSearchRequest=function(e){var t=this,r=e.first,o=e.rows,i=e.multiSortMeta,s=e.filterData,l=r/o,d=i,c=this.getTransportadoraSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,r=s[t];return"number"==typeof r?t+" eq "+r:a==n.FieldType.Date?t+" eq '"+br(r).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+br(r).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+br(r).format()+"'":a==n.FieldType.Enum?t+" eq '"+r+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+r.replace(/'/g,"\\'")+"'))":t+" eq '"+r+"'"}).join(" and "),p=Pe(this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields);this.transportadoraService.list({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return w({},e,{contents:e.contents.map(function(e){return w({},e,{label:t.transportadoraLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.transportadoraLookupSeparator)})})})})).subscribe(function(e){t.transportadoraSearchGridData=e.contents,t.transportadoraSearchTotalRecords=e.totalElements})},e.prototype.onTransgeniaLookupRequest=function(e){var t=this;Qe(this.getTransgeniaSearchFields(),this.transgeniaLookupDisplayFields,this.transgeniaAdvancedDisplayFields,this.transgeniaLookupSeparator,this.transgeniaService,e,"empresa.id eq '"+this.formGroup.get("filial").value.empresa.id+"' and tipoParticipante eq '"+this.getTipoTransgenia()+"'").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.transgeniaLookupSuggestions=e.contents})},e.prototype.onTransgeniaSearchRequest=function(e){var t=this,r=e.first,o=e.rows,i=e.multiSortMeta,s=e.filterData,l=r/o,d=i,c=this.getTransgeniaSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,r=s[t];return"number"==typeof r?t+" eq "+r:a==n.FieldType.Enum?t+" eq '"+r+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+r.replace(/'/g,"\\'")+"'))":t+" eq '"+r+"'"}).join(" and "),p=Pe(this.transgeniaLookupDisplayFields,this.transgeniaAdvancedDisplayFields);this.transgeniaService.list({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return w({},e,{contents:e.contents.map(function(e){return w({},e,{label:t.transgeniaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.transgeniaLookupSeparator)})})})})).subscribe(function(e){t.transgeniaSearchGridData=e.contents,t.transgeniaSearchTotalRecords=e.totalElements})},e.prototype.addFornecedor=function(e){void 0===e&&(e={}),this.erroFornecedores=!1;var t=this.getFornecedorForm(e);return this.configureFornecedor(t),this.getFornecedores().push(t),t},e.prototype.removeFornecedor=function(e){var t=this;this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_fornecedor_header"),message:this.translate.instant("yms.erp.remove_fornecedor_message"),accept:function(){var a=t.getFornecedores().controls.indexOf(e);t.getFornecedores().removeAt(a)}})},e.prototype.getFornecedores=function(){return this.formGroup.get("fornecedores")},e.prototype.addContrato=function(e){var t=this;this.dialogService.open(hr,w({},ze,{header:"Adicionar Contrato",data:{agenda:this.agenda,filial:this.formGroup.get("filial").value,produto:this.formGroup.get("produto").value,fornecedor:e.get("fornecedor").value,contratos:e.get("contratos").value}})).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(a){var r=a.contrato;return t.onContratoSaved(r,e)})},e.prototype.removerContrato=function(e,t){this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_contrato_header"),message:this.translate.instant("yms.erp.remove_contrato_message"),accept:function(){var a=e.get("contratos").controls.indexOf(t);e.get("contratos").removeAt(a)}})},e.prototype.getContratos=function(e){return this.contratos=e.get("contratos"),this.contratos},e.prototype.addNota=function(e){var t=this;this.dialogService.open(yt,w({header:this.translate.instant("yms.erp.adicionar_nota")},ze,{data:{fornecedor:e.get("fornecedor").value,produto:this.formGroup.get("produto").value,filial:this.formGroup.get("filial").value,fornecedorNotasTokens:this.fornecedorNotasTokens,contratos:this.contratos}})).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(a){return t.onNotaSaved(a,e)})},e.prototype.removerNota=function(e,t,a){var r=this;this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_nota_header"),message:this.translate.instant("yms.erp.remove_nota_message"),accept:function(){var o=t.value.contrato.id,i=r.getNotasFromContratos(e,o).controls.indexOf(a);r.getNotasFromContratos(e,o).removeAt(i);var n=a.value;r.fornecedorNotasTokens.push({id:n.chaveNotaFiscal,label:n.numeroNotaFiscal}),r.fornecedorNotas.push({chaveNotaFiscal:n.chaveNotaFiscal,serieNotaFiscal:n.serieNotaFiscal,serieLegalNotaFiscal:n.serieLegalNotaFiscal,numeroNotaFiscal:n.numeroNotaFiscal})}})},e.prototype.getNotas=function(e){return e.controls.notas},e.prototype.getItensContrato=function(e){return e.get("itens")},e.prototype.showButtons=function(){return!!this.agenda&&[He.AGENDADO,He.AGUARDANDO_CONFIRMACAO,He.AGUARDANDO_CONFIRMACAO_SOLICITANTE,He.REJEITADO_POR_VALIDACAO].includes(this.agenda.status)},e.prototype.disableAdicionarNota=function(){return null===this.contratoSelecionado},e.prototype.getNotaForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({chaveNotaFiscal:[e.chaveNotaFiscal],serieNotaFiscal:[e.serieNotaFiscal],serieLegalNotaFiscal:[e.serieLegalNotaFiscal],numeroNotaFiscal:[e.numeroNotaFiscal]})},e.prototype.getContratoForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({contrato:[e.contrato,C.Validators.required],itens:this.formBuilder.array([]),notas:this.formBuilder.array([])})},e.prototype.getItemForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({item:[e.item,C.Validators.required],quantidade:[e.quantidade]})},e.prototype.getFornecedorForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({fornecedor:[e.fornecedor,C.Validators.required],origemMercadoria:[e.origemMercadoria,C.Validators.compose([C.Validators.required])],tipoNotaFiscal:[e.tipoNotaFiscal||Ua.EMPRESA_JURIDICA,C.Validators.compose([])],contratos:this.formBuilder.array([])})},e.prototype.getFormGroup=function(){return this.formBuilder.group({id:[{value:undefined,disabled:!0},C.Validators.compose([])],filial:[undefined,C.Validators.required],produto:[{value:undefined,disabled:!0},C.Validators.compose([C.Validators.required])],derivacao:[{value:undefined,disabled:!0},C.Validators.compose([])],transportadora:[{value:undefined,disabled:!1},C.Validators.compose([])],agenda:[{value:this.agenda,disabled:!1},C.Validators.compose([C.Validators.required])],transgenia:[{value:undefined,disabled:!0},C.Validators.compose([])],fornecedores:this.formBuilder.array([]),createdBy:[{value:undefined,disabled:!0},C.Validators.compose([])],createdDate:[{value:undefined,disabled:!0},C.Validators.compose([])],lastModifiedBy:[{value:undefined,disabled:!0},C.Validators.compose([])],lastModifiedDate:[{value:undefined,disabled:!0},C.Validators.compose([])],custom:[]})},e.prototype.getFornecedorByContrato=function(e,t){this.pessoaService.list({size:1,page:0,filterQuery:"id eq '"+e.pessoa.id+"'"}).pipe(a.takeUntil(this.ngUnsubscribe),a.map(function(e){var t=e.contents;return(t||[]).length&&t[0]}),a.filter(function(e){return!!e})).subscribe(function(e){t.get("fornecedor").setValue(Ze.fromDto(e))})},e.prototype.getProdutoByContrato=function(e){var r=this;this.contratoCompraService.listItens(e.id,{size:1,page:0,displayFields:["sku.id"]}).pipe(a.takeUntil(this.ngUnsubscribe),a.mergeMap(function(e){var o=e.contents;return 1===o.length?r.produtoService.list({size:1,page:0,filterQuery:"id eq '"+o[0].sku.id+"'"}).pipe(a.takeUntil(r.ngUnsubscribe),a.map(function(e){var t=e.contents;return(t||[]).length&&t[0]})):t.empty()}),a.filter(function(e){return!!e})).subscribe(function(e){r.formGroup.get("produto").setValue(Ga.fromDto(e)),r.formGroup.get("produto").disable()})},e.prototype.onContratoSaved=function(e,t){var a=this;this.formGroup.get("produto").value||this.getProdutoByContrato(e.contrato),t.get("fornecedor").value||this.getFornecedorByContrato(e.contrato,t);var r=this.getContratoForm(e);(e.itens||[]).forEach(function(e){return r.get("itens").push(a.getItemForm(e))}),this.getContratos(t).push(r)},e.prototype.mensagemContratoNaoSelecionado=function(){this.addMessage("error","Contrato não selecionado","Nenhum contrato foi selecionado!")},e.prototype.onNotaSaved=function(e,t){var a=this;if(null!==this.contratoSelecionado)if(e.addFornecedor){var r=this.formGroup.get("fornecedores").controls.find(function(t){return(t.value.fornecedor||{id:undefined}).id===e.fornecedor.id}),o=this.validarCnpjFornecedor((t.value.fornecedor||{cpfCnpj:undefined}).cpfCnpj),i=e.infoNota,n=this.getNotaForm({chaveNotaFiscal:i.chave,serieNotaFiscal:i.serie,serieLegalNotaFiscal:i.serieLegal,numeroNotaFiscal:i.numero});if(r)(l=this.getNotasFromContratos(r,this.contratoSelecionado.id)).push(n);else if(t.get("fornecedor").value)if(o)this.confirmationService.confirm({header:"Fornecedor do mesmo grupo já cadastrado",message:"Um fornecedor do mesmo grupo parece já ter sido selecionado, deseja vincular a nota ao mesmo fornecedor?",accept:function(){a.getNotasFromContratos(o,a.contratoSelecionado.id).push(n)},reject:function(){var t=a.addFornecedor({fornecedor:Ze.fromDto(e.fornecedor),origemMercadoria:dt.fromDto(e.origemMercadoria)});a.getNotasFromContratos(t,a.contratoSelecionado.id).push(n)}});else{var s=this.addFornecedor({fornecedor:Ze.fromDto(e.fornecedor),origemMercadoria:dt.fromDto(e.origemMercadoria)});(l=this.getNotasFromContratos(s,this.contratoSelecionado.id)).push(n)}else{t.get("fornecedor").setValue(Ze.fromDto(e.fornecedor)),t.get("origemMercadoria").setValue(dt.fromDto(e.origemMercadoria)),(l=this.getNotasFromContratos(t,this.contratoSelecionado.id)).push(n)}}else{var l;null!==(l=this.getNotasFromContratos(t,this.contratoSelecionado.id))&&l.push(this.getNotaForm(e))}else this.mensagemContratoNaoSelecionado()},e.prototype.getNotasFromContratos=function(e,t){var a,r,o=null,i=e.controls.contratos.controls;try{for(var n=U(i),s=n.next();!s.done;s=n.next()){var l=s.value;l.controls.contrato.value.id===t&&(o=l.controls.notas)}}catch(d){a={error:d}}finally{try{s&&!s.done&&(r=n["return"])&&r.call(n)}finally{if(a)throw a.error}}return o},e.prototype.addFornecedorNotasTokenEmContrato=function(e,t){if(null!==this.contratoSelecionado){var a=this.fornecedorNotas.filter(function(e){return e.chaveNotaFiscal===t.id}),r=this.getNotasFromContratos(e,this.contratoSelecionado.id);null!==r&&null!==a[0]&&r.push(this.getNotaForm(a[0])),this.removeFornecedorNotasTokenDoContrato(t)}else this.mensagemContratoNaoSelecionado()},e.prototype.removeFornecedorNotasTokenDoContrato=function(e){this.fornecedorNotasTokens.splice(this.fornecedorNotasTokens.indexOf(e),1),this.fornecedorNotas=this.fornecedorNotas.filter(function(t){return t.chaveNotaFiscal!==e.id})},e.prototype.adicionarNovaNota=function(e){var t=this,a=(e.documentos||[]).length?e.documentos[0]:undefined;if(a){var r=a.itens[0]||{produto:undefined,derivacao:undefined},o=Ga.fromDto(r.produto);if(!this.formGroup.get("produto").value&&r.produto)this.formGroup.get("produto").setValue(o),this.formGroup.get("derivacao").setValue(qa.fromDto(r.derivacao));else if(r.produto&&!this.validateProduto(o))return void this.addNotaError();var i=Ze.fromDto(a.fornecedor),n=dt.fromDto(a.origemMercadoria),s=this.getFornecedores().controls.find(function(e){return e.value.fornecedor.id===i.id});this.validarCnpjFornecedor(i.cpfCnpj)?this.confirmationService.confirm({header:"Fornecedor do mesmo grupo já cadastrado",message:"Um fornecedor do mesmo grupo parece já ter sido selecionado, deseja vincular a nota ao mesmo fornecedor?",accept:function(){t.addFornecedorNotasToken(a)},reject:function(){s||t.addFornecedor({fornecedor:i,origemMercadoria:n}),t.addFornecedorNotasToken(a)}}):s||(this.addFornecedor({fornecedor:i,origemMercadoria:n}),this.addFornecedorNotasToken(a))}},e.prototype.addFornecedorNotasToken=function(e){this.fornecedorNotasTokens.push({id:this.chaveNotaFiscal,label:e.numero}),this.fornecedorNotas.push({chaveNotaFiscal:this.chaveNotaFiscal,serieNotaFiscal:e.serie,serieLegalNotaFiscal:e.serieLegal,numeroNotaFiscal:e.numero}),this.chaveNotaFiscal=undefined,this.loading=!1},e.prototype.removeNotaError=function(){this.erroChaveNota=!1},e.prototype.addNotaError=function(){this.erroChaveNota=!0},e.prototype.validateProduto=function(e){return this.formGroup.get("produto").value.id===e.id},e.prototype.getFilialSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.filial_nome"),type:n.FieldType.String})]},e.prototype.getFornecedorSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.pessoa_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.pessoa_nome"),type:n.FieldType.String}),new n.FormField({name:"cpfCnpj",label:this.translate.instant("yms.erp.pessoa_cpfCnpj"),type:n.FieldType.String})]},e.prototype.getFornecedorSearchGridFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.pessoa_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.pessoa_nome"),type:n.FieldType.String}),new n.FormField({name:"cpfCnpj",label:this.translate.instant("yms.erp.pessoa_cpfCnpj"),type:n.FieldType.String})]},e.prototype.getOrigemMercadoriaFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.pessoa_endereco_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"cep",label:this.translate.instant("yms.erp.pessoa_endereco_cep"),type:n.FieldType.String}),new n.FormField({name:"endereco",label:this.translate.instant("yms.erp.pessoa_endereco_endereco"),type:n.FieldType.String}),new n.FormField({name:"numero",label:this.translate.instant("yms.erp.pessoa_endereco_numero"),type:n.FieldType.String}),new n.FormField({name:"bairro",label:this.translate.instant("yms.erp.pessoa_endereco_bairro"),type:n.FieldType.String})]},e.prototype.getOrigemMercadoriaGridFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.pessoa_endereco_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"cep",label:this.translate.instant("yms.erp.pessoa_endereco_cep"),type:n.FieldType.String}),new n.FormField({name:"endereco",label:this.translate.instant("yms.erp.pessoa_endereco_endereco"),type:n.FieldType.String}),new n.FormField({name:"numero",label:this.translate.instant("yms.erp.pessoa_endereco_numero"),type:n.FieldType.String}),new n.FormField({name:"bairro",label:this.translate.instant("yms.erp.pessoa_endereco_bairro"),type:n.FieldType.String}),new n.FormField({name:"empresa.descricao",label:this.translate.instant("yms.erp.empresa"),type:n.FieldType.String})]},e.prototype.getProdutoSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.produto_codigo"),type:n.FieldType.String}),new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.produto_descricao"),type:n.FieldType.String})]},e.prototype.getProdutoSearchGridFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.produto_codigo"),type:n.FieldType.String}),new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.produto_descricao"),type:n.FieldType.String}),new n.FormField({name:"descricaoComplementar",label:this.translate.instant("yms.erp.produto_descricao_complementar"),type:n.FieldType.String})]},e.prototype.getAgendaSearchFields=function(){return[new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.agenda_descricao"),type:n.FieldType.String})]},e.prototype.getAgendaSearchGridFields=function(){return[new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.agenda_descricao"),type:n.FieldType.String})]},e.prototype.getDerivacaoSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.derivacao_codigo"),type:n.FieldType.String}),new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.derivacao_descricao"),type:n.FieldType.String})]},e.prototype.getDerivacaoSearchGridFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.derivacao_codigo"),type:n.FieldType.String}),new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.derivacao_descricao"),type:n.FieldType.String})]},e.prototype.getTransportadoraSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_descricao")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getTransportadoraSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getTransgeniaSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.transgenia_codigo")}),new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.transgenia_descricao")})]},e.prototype.getTransgeniaSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.transgenia_codigo")}),new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.transgenia_descricao")})]},e.prototype.goBack=function(){this.router.navigate(["../"],{relativeTo:this.route.parent})},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var r=e.get(a);r instanceof C.FormControl?r.markAsDirty({onlySelf:!0}):r instanceof C.FormGroup?t.validateAllFormFields(r):r instanceof C.FormArray&&r.controls.forEach(function(e){return t.validateAllFormFields(e)})}),this.focusService.focusFirstInvalidInput()},e.prototype.getSaveObservable=function(){var e=this.formGroup.getRawValue();e.agenda=this.agenda;var t,a=yr.toDto(e);if(this.isNew()&&!e.id)t=this.recebimentoService.insert(a);else{var r=e.id;t=this.recebimentoService.update(r,a)}return t},e.prototype.getDeleteObservable=function(){var e=this;return this.recebimentoService["delete"]("").pipe(a.tap(function(){e.addMessage("success","yms.erp.deleted_message_title","yms.erp.deleted_message_content"),e.goBack()}))},e.prototype.validateVisualization=function(){Ue(this.formGroup,this.allPermissions)||this.addMessage("error","yms.erp.cannot_visualize_form_summary","yms.erp.cannot_visualize_form_detail")},e.prototype.addMessage=function(e,t,a){this.messageService.add({severity:e,summary:this.translate.instant(t),detail:this.translate.instant(a)})},e.prototype.buscarFilial=function(){var e=this,t=this.agenda.planta||{cnpj:[]};1===t.cnpj.length?this.filialService.list({page:0,size:1,filterQuery:"pessoa.cpfCnpj eq '"+t.cnpj[0]+"'",displayFields:["*","empresa.nome"]}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;1===a.length&&e.formGroup.get("filial").setValue(pt.fromDto(a[0])),e.formCarregado=!0}):this.formCarregado=!0},e.prototype.configureFornecedor=function(e){var t=this;e.get("fornecedor").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe),a.debounceTime(500),a.tap(function(a){if(a)return t.ehPessoaJuridica(a)?(e.get("tipoNotaFiscal").setValue(Ua.EMPRESA_JURIDICA),void e.get("tipoNotaFiscal").enable()):(e.get("tipoNotaFiscal").setValue(Ua.PRODUTOR_RURAL),void e.get("tipoNotaFiscal").disable());e.get("tipoNotaFiscal").setValue(Ua.EMPRESA_JURIDICA),e.get("tipoNotaFiscal").disable()}),a.filter(function(e){return!!e||(t.formGroup.get("transgenia").setValue(null),t.formGroup.get("transgenia").disable(),!1)}),a.mergeMap(function(e){return t.pessoaEnderecoService.list({size:10,page:0,filterQuery:"situacao eq 'ATIVO' and pessoa.id eq '"+e.id+"'"}).pipe(a.takeUntil(t.ngUnsubscribe))})).subscribe(function(a){var r=a.contents;t.formGroup.get("transgenia").enable(),1===r.length?e.get("origemMercadoria").setValue(dt.fromDto(r[0])):(e.get("origemMercadoria").setValue(undefined),e.get("origemMercadoria").enable())})},e.prototype.ehPessoaJuridica=function(e){return(e.cpfCnpj||"").replace(/\D+/g,"").length>11},e.prototype.mensagemBuscandoNota=function(){this.messageService.add({severity:"info",summary:"Buscando dados da nota",detail:"Aguarde, buscando dados da nota",life:5e3})},e.prototype.validarCnpjFornecedor=function(e){return!!this.ehPessoaJuridica({cpfCnpj:e})&&this.formGroup.get("fornecedores").controls.find(function(t){return(t.value.fornecedor||{cpfCnpj:""}).cpfCnpj.substring(0,8)===e.substring(0,8)})},P([o.Input(),V("design:type",Ia)],e.prototype,"agenda",void 0),P([o.ViewChild("customTemplate"),V("design:type",o.TemplateRef)],e.prototype,"customTemplate",void 0),P([o.ViewChild("customFormFields"),V("design:type",o.TemplateRef)],e.prototype,"customFormFields",void 0),e=P([o.Component({selector:"recebimento-form",template:'<p-confirmDialog [acceptLabel]="\'yes\' | translate" acceptIcon="" [rejectLabel]="\'no\' | translate" rejectIcon=""></p-confirmDialog>\n<div *sLoadingState="loading">\n <form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-g-12 ui-md-6">\n <label for="chaveNotaFiscal">{{"yms.erp.recebimento_chave_nota_fiscal" | translate}}</label>\n <input [class.ng-invalid]="erroChaveNota" [(ngModel)]="chaveNotaFiscal" [ngModelOptions]="{ standalone: true }" type="text" id="chaveNotaFiscal" name="chaveNotaFiscal" pInputText autocomplete="off" (blur)="onBlurChaveNotaFiscal()"/>\n <span class="nota-error" *ngIf="erroChaveNota">{{\'yms.erp.produto_nota_error_detail\' | translate}}</span>\n </div>\n </div>\n <div class="ui-fluid">\n <div class="ui-g">\n <div [attr.data-hidden]="true" class="ui-g-12 ui-md-6">\n <label for="id">{{"yms.erp.recebimento_id" | translate}}</label>\n <input #idFormInput type="text" id="id" name="id" pInputText formControlName="id" autocomplete="off" />\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="filial">{{"yms.erp.filial" | translate}}</label>\n <s-lookup dataKey="id" id="filial" name="filial" formControlName="filial"\n [searchFields]="filialSearchFields" [searchGridFields]="filialSearchGridFields"\n [searchGridData]="filialSearchGridData" [multiple]="false"\n [lookupSuggestions]="filialLookupSuggestions"\n (onLookupRequest)="onFilialLookupRequest($event)"\n (onSearchRequest)="onFilialSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="filialSearchTotalRecords"\n [searchTitle]="\'yms.erp.filial_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: filialSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'filial\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="produto">{{"yms.erp.recebimento_produto" | translate}}</label>\n <s-lookup dataKey="id" id="produto" name="produto" formControlName="produto"\n [searchFields]="produtoSearchFields" [searchGridFields]="produtoSearchGridFields"\n [searchGridData]="produtoSearchGridData" [multiple]="false"\n [lookupSuggestions]="produtoLookupSuggestions"\n (onLookupRequest)="onProdutoLookupRequest($event)"\n (onSearchRequest)="onProdutoSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]=produtoSearchTotalRecords\n [searchTitle]="\'yms.erp.recebimento_produto_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: produtoSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'produto\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="derivacao">{{"yms.erp.recebimento_derivacao" | translate}}</label>\n <s-lookup dataKey="id" id="derivacao" name="derivacao" formControlName="derivacao"\n [searchFields]="derivacaoSearchFields" [searchGridFields]="derivacaoSearchGridFields"\n [searchGridData]="derivacaoSearchGridData" [multiple]="false"\n [lookupSuggestions]="derivacaoLookupSuggestions"\n (onLookupRequest)="onDerivacaoLookupRequest($event)"\n (onSearchRequest)="onDerivacaoSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]=derivacaoSearchTotalRecords\n [searchTitle]="\'yms.erp.recebimento_derivacao_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: derivacaoSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="transportadora">{{"yms.erp.recebimento_transportadora" | translate}}</label>\n <s-lookup dataKey="id" id="transportadora" name="transportadora" formControlName="transportadora"\n [searchFields]="transportadoraSearchFields" [searchGridFields]="transportadoraSearchGridFields"\n [searchGridData]="transportadoraSearchGridData" [multiple]="false"\n [lookupSuggestions]="transportadoraLookupSuggestions"\n (onLookupRequest)="onTransportadoraLookupRequest($event)"\n (onSearchRequest)="onTransportadoraSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="transportadoraSearchTotalRecords"\n [searchTitle]="\'yms.erp.transportadora_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: transportadoraSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="transgenia">{{"yms.erp.recebimento_transgenia" | translate}}</label>\n <s-lookup dataKey="id" id="transgenia" name="transgenia"\n formControlName="transgenia" [searchFields]="transgeniaSearchFields"\n [searchGridFields]="transgeniaSearchGridFields"\n [searchGridData]="transgeniaSearchGridData" [multiple]="false"\n [lookupSuggestions]="transgeniaLookupSuggestions"\n (onLookupRequest)="onTransgeniaLookupRequest($event)"\n (onSearchRequest)="onTransgeniaSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="transgeniaSearchTotalRecords"\n [searchTitle]="\'yms.erp.recebimento_transgenia_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: transgeniaSearchTotalRecords}">\n </s-lookup>\n </div>\n\n <div class="ui-md-12">\n <s-button styleClass="btn-erp-forms" *ngIf="showButtons() && !!formGroup.get(\'filial\').value && !createdByErp" iconClass="fas fa-plus" label="Adicionar fornecedor" priority="secondary" (onClick)="addFornecedor()"></s-button>\n <span style="display: block;" class="input-error" *ngIf="erroFornecedores">{{\'Selecione ao menos um fornecedor para continuar\' | translate}}</span>\n </div>\n\n <form class="ui-g-12" *ngFor="let fornecedorForm of getFornecedores().controls; let i = index;" [formGroup]="fornecedorForm">\n <p-panel [style]="{position: \'relative\'}" styleClass="form-group ui-g-12 ui-md-12" [toggleable]="true" >\n\n <p-header>\n Fornecedor {{+i+1}}\n <s-button \n style="display: inline-block; position: absolute; right: 50px; top: 10px" \n *ngIf="showButtons() && !createdByErp"\n iconClass="fas fa-trash"\n label="Remover"\n priority="default"\n [auxiliary]="true"\n (onClick)="removeFornecedor(fornecedorForm)"\n >\n </s-button>\n </p-header>\n <div class="ui-g-12 ui-md-6 required">\n <label for="fornecedor">{{"yms.erp.recebimento_fornecedor" | translate}}</label>\n <s-lookup dataKey="id" id="fornecedor" name="fornecedor" formControlName="fornecedor"\n [searchFields]="fornecedorSearchFields" [searchGridFields]="fornecedorSearchGridFields"\n [searchGridData]="fornecedorSearchGridData" [multiple]="false"\n [lookupSuggestions]="fornecedorLookupSuggestions"\n (onLookupRequest)="onFornecedorLookupRequest($event)"\n (onSearchRequest)="onFornecedorSearchRequest($event)" \n lookupDisplayField="label"\n [searchTotalRecords]=fornecedorSearchTotalRecords\n [searchTitle]="\'yms.erp.recebimento_fornecedor_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: fornecedorSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="fornecedorForm.get(\'fornecedor\')"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="origemMercadoria">{{"yms.erp.recebimento_origem_mercadoria" | translate}}</label>\n <s-lookup dataKey="id" id="origemMercadoria" name="origemMercadoria"\n formControlName="origemMercadoria" [searchFields]="origemMercadoriaSearchFields"\n [searchGridFields]="origemMercadoriaSearchGridFields"\n [searchGridData]="origemMercadoriaSearchGridData" [multiple]="false"\n [lookupSuggestions]="origemMercadoriaLookupSuggestions"\n (onLookupRequest)="onOrigemMercadoriaLookupRequest($event, fornecedorForm)"\n (onSearchRequest)="onOrigemMercadoriaSearchRequest($event, fornecedorForm)" lookupDisplayField="label"\n [searchTotalRecords]="origemMercadoriaSearchTotalRecords"\n [searchTitle]="\'yms.erp.recebimento_pessoa_endereco_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: origemMercadoriaSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="fornecedorForm.get(\'origemMercadoria\')"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n\n <div class="ui-g-12">\n <label for="fornecedorNotas">Notas a serem adicionadas</label>\n <s-token-list id="fornecedorNotas" [tokens]="fornecedorNotasTokens" (tokenSelected)="addFornecedorNotasTokenEmContrato(fornecedorForm, $event)" (tokenRemoved)="removeFornecedorNotasTokenDoContrato($event)" [removableTokens]="true"></s-token-list>\n </div>\n\n <div class="ui-g-12">\n <s-button label="Adicionar nota" *ngIf="showButtons()" styleClass="btn-erp-forms" priority="secondary" (onClick)="addNota(fornecedorForm)" [disabled]="disableAdicionarNota()"></s-button>\n <s-button label="Adicionar contrato" *ngIf="showButtons() && !createdByErp" styleClass="btn-erp-forms" priority="secondary" (onClick)="addContrato(fornecedorForm)"></s-button>\n </div>\n\n <div class="ui-g-12 ui-md-6">\n <label for="tipoNotaFiscal">{{"yms.erp.recebimento_tipo_nota_fiscal" | translate}}</label>\n <p-dropdown inputId="tipoNotaFiscal" name="tipoNotaFiscal" [options]="tiposNota" formControlName="tipoNotaFiscal">\n </p-dropdown>\n </div>\n\n <div class="ui-g-12">\n <h4>Contratos</h4>\n <p-table [value]="getContratos(fornecedorForm).controls" [(selection)]="contratoSelecionado">\n <ng-template pTemplate="body" let-rowData>\n <tr [pSelectableRow]="rowData">\n <td style="width: 50px">\n <p-tableRadioButton [value]="rowData.get(\'contrato\').value"></p-tableRadioButton>\n </td>\n <td>\n <p-accordion>\n <p-accordionTab>\n <p-header>\n Contrato {{rowData.get(\'contrato\').value.numero}}, Filial {{rowData.get(\'contrato\').value.filial?.codigo}}\n\n <span *ngIf="showButtons() && !createdByErp" style="margin-left: 10px; float: right;" class="fas fa-trash" (click)="removerContrato(fornecedorForm, rowData)"></span>\n </p-header>\n \n <div class="detail-pane" *ngFor="let item of getItensContrato(rowData).controls">\n <div class="detail-span">\n <span class="title">Sequência</span>\n <span class="data">{{item.value?.item.sequencia}}</span>\n </div>\n </div>\n \n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Notas</span>\n <span class="data">\n <p-accordion>\n <p-accordionTab *ngFor="let nota of getNotas(rowData).controls">\n <p-header>\n {{nota.get(\'chaveNotaFiscal\').value || (nota.get(\'serieNotaFiscal\').value + \' - \' + nota.get(\'numeroNotaFiscal\').value)}}\n\n <span *ngIf="showButtons()" style="margin-left: 10px; float: right;" class="fas fa-trash" (click)="removerNota(fornecedorForm, rowData, nota)"></span>\n </p-header>\n \n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Série nota fiscal</span>\n <span class="data">{{nota.value?.serieNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">Série legal nota fiscal</span>\n <span class="data">{{nota.value?.serieLegalNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">Número nota fiscal</span>\n <span class="data">{{nota.value?.numeroNotaFiscal}}</span>\n </div>\n </div>\n \n </p-accordionTab> \n </p-accordion>\n </span>\n </div>\n </div>\n </p-accordionTab>\n </p-accordion>\n </td>\n </tr>\n </ng-template>\n </p-table>\n </div>\n\n </p-panel>\n\n <div class="ui-g-12" style="text-align: right;" *ngIf="totalEixosContratados || totalEixosComposicao">\n <label for="totalEixosContratados" float="right" style="display: inline;">{{totalEixosContratados}} {{\'yms.erp.total_eixos_contratados\' | translate}} / </label>\n <label for="totalEixosComposicao" float="right" style="display: inline;">{{totalEixosComposicao}} {{\'yms.erp.total_eixos_composicao\' | translate}}</label>\n </div>\n </form>\n\n </div>\n </div>\n </form>\n\n <div style="margin: 5px 0 5px 0;">\n <s-button *ngIf="showButtons()" priority="primary" [label]="\'save\' | translate" (onClick)="onSave()" [disabled]="disableButtonSave"></s-button>\n <s-button *ngIf="saveAndInitButton && showButtons()" priority="primary" [label]="\'save_and_init\' | translate" (onClick)="onSave(true)" [disabled]="disableButtonSave"></s-button>\n </div>\n</div>',providers:[c.ConfirmationService],styles:[".required-h3{font-size:1.17rem;font-weight:700}.required-h3::after{content:'*';color:#c13018;font-weight:400;margin-left:5px;font-size:14px}.error-required-message{color:#c13018;margin-top:5px;font-size:12px}.separator{width:100%;margin:5px 0;height:1px;background-color:#ccc}.input-error{color:#c13018}.detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nota-error{color:#c13018}"]}),V("design:paramtypes",[Ce,F.Router,F.ActivatedRoute,T.MessageService,c.ConfirmationService,C.FormBuilder,i.TranslateService,L.HotkeysService,Oe,gt,Gt,la,Bt,kt,Kt,Xt,It,Te,vt,ya,c.DialogService,De,ta,aa,Ge,Zt])],e)}(),Sr=function(){function e(e){this.recebimentoService=e,this.loading=!0,this.unsubscribe$=new t.Subject}return e.prototype.ngAfterViewInit=function(){var e=this;this.recebimentoService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",page:0,size:1}).pipe(a.takeUntil(this.unsubscribe$),a.switchMap(function(e){var a=e.contents;return a.length?t.of(a[0]):t.throwError("Recebimento não encontrado.")}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.recebimento=yr.fromDto(t)})},P([o.Input(),V("design:type",Object)],e.prototype,"agenda",void 0),e=P([o.Component({selector:"recebimento-info",template:'\n <div *sLoadingState="loading" style="padding: 20px;">\n <div class="detail-pane" *ngIf="agenda">\n <div class="detail-span">\n <span class="title">\n {{ "yms.erp.recebimento_filial" | translate }}\n </span>\n <span class="data">\n {{ recebimento?.filial?.codigo }} - {{ recebimento?.filial?.nome }}\n </span>\n </div>\n <div class="detail-span">\n <span class="title">\n {{ "yms.erp.recebimento_produto" | translate }}\n </span>\n <span class="data">{{ recebimento?.produto?.descricao }}</span>\n </div>\n <div class="detail-span">\n <span class="title">\n {{ "yms.erp.recebimento_derivacao" | translate }}\n </span>\n <span class="data">{{ recebimento?.derivacao?.descricao }}</span>\n </div>\n </div>\n <div *ngFor="let fornecedor of recebimento?.fornecedores">\n <div class="separator"></div>\n <h3>Fornecedor - {{ fornecedor?.fornecedor?.nome }}</h3>\n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">\n {{ "yms.erp.recebimento_origem_mercadoria" | translate }}\n </span>\n <span class="data">\n {{ fornecedor?.origemMercadoria?.codigo }} - {{ fornecedor?.origemMercadoria?.cep }}\n </span>\n </div>\n </div>\n\n <div>\n <h4>Contratos</h4>\n <p-accordion>\n <p-accordionTab *ngFor="let contrato of fornecedor.contratos">\n <p-header>\n Contrato {{ contrato?.contrato?.numero }}, Filial {{ contrato?.contrato?.filial?.codigo }}\n </p-header>\n\n <div class="detail-pane" *ngFor="let item of contrato?.itens">\n <div class="detail-span">\n <span class="title">Sequência</span>\n <span class="data">{{ item?.item?.sequencia }}</span>\n </div>\n </div>\n\n <div *ngFor="let nota of contrato.notas">\n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Chave nota fiscal</span>\n <span class="data">{{ nota?.chaveNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Serie nota fiscal</span>\n <span class="data">{{ nota?.serieNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Serie legal nota fiscal</span>\n <span class="data">{{ nota?.serieLegalNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Número nota fiscal</span>\n <span class="data">{{ nota?.numeroNotaFiscal }}</span>\n </div>\n </div>\n <hr />\n </div>\n </p-accordionTab>\n </p-accordion>\n </div>\n </div>\n </div>\n ',styles:[".detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}"]}),V("design:paramtypes",[Ce])],e)}();function Dr(){return[{name:"json",func:O},{name:"xml",func:G}]}var Cr=function(){function e(e){this.dispatcher=e,this.dispatcher.dispatch(Ae).dispatch(Ne).dispatch(Wa)}return e=P([o.NgModule({declarations:[Ae,Fr,Ka,Ne,Ja,Sr,za,lr,dr,$a,hr,ht,tr,ar,Wa],entryComponents:[Ae,Ne,hr,ht,Wa],exports:[Ae,Ne],imports:[r.CommonModule,C.FormsModule,C.ReactiveFormsModule,i.TranslateModule,n.CustomFieldsModule,n.ControlErrorsModule,R.DialogModule,n.EmptyStateModule,n.DynamicFormModule,n.TokenListModule,E.PanelModule,I.AccordionModule,D.InputTextModule,A.DropdownModule,n.ButtonModule,n.LoadingStateModule,n.NumberInputModule,M.ConfirmDialogModule,n.LocaleModule,p.IntegrationModule,Ta,m.PermissionsModule,v.DynamicDialogModule,bt,I.AccordionModule,l.TableModule,y.TabViewModule,n.LoadingStateModule,_.HighlightModule.forRoot({languages:Dr}),L.HotkeyModule.forRoot()],providers:[Oe,gt,Te,_e,ka,sr,er,Ge]}),V("design:paramtypes",[p.IntegrationDispatcher])],e)}();e.AgendaModule=Ft,e.AgendaService=De,e.BalancaModule=te,e.BalancasService=X,e.CamerasModule=ne,e.CamerasService=ae,e.CancelasModule=J,e.CidadeModule=Dt,e.CidadeService=St,e.ContratoCompraItemModule=Tt,e.ContratoCompraItemService=Ct,e.ContratoCompraModule=_t,e.ContratoCompraService=kt,e.ControladorCancelaComponent=K,e.ControladorCancelaDescritor=Q,e.ControladorCancelasService=H,e.CoreModule=Ta,e.ERP_ENVIRONMENT=Se,e.ERP_SENIOR_HEADER=Me,e.EmpresaModule=At,e.EmpresaService=Rt,e.ErpFormConfigService=aa,e.ErpProcessData=ea,e.ErpProcessService=ta,e.ErpSeniorModule=Cr,e.EstadoModule=Lt,e.EstadoService=Et,e.ExpedicaoChegadaVeiculoOverride=_e,e.ExpedicaoModule=ua,e.ExpedicaoService=ke,e.FamiliaProdutoModule=Ot,e.FamiliaProdutoService=Nt,e.FieldCustomizationService=Oe,e.FilialModule=xt,e.FilialService=Gt,e.FormComponent=Ae,e.FormDescritor=Re,e.HasChangeService=Zt,e.InfoComponent=Ne,e.InfoDescritor=Le,e.IntegrationWebSocket=$,e.LogsModule=ue,e.LogsService=de,e.LprModule=le,e.LprService=se,e.PaisModule=wt,e.PaisService=qt,e.PedidoVendaItemModule=jt,e.PedidoVendaItemService=Pt,e.PedidoVendaModule=Ut,e.PedidoVendaService=Vt,e.PessoaEnderecoModule=zt,e.PessoaEnderecoService=Bt,e.PessoaFisicaModule=Yt,e.PessoaFisicaService=$t,e.PessoaJuridicaModule=Qt,e.PessoaJuridicaService=Ht,e.PessoaModule=Jt,e.PessoaService=Kt,e.PortariasComponent=he,e.PortariasDescritor=fe,e.PortariasModule=be,e.ProdutoModule=Wt,e.ProdutoService=Xt,e.RecebimentoChegadaVeiculoOverride=Te,e.RecebimentoContratoModule=ra,e.RecebimentoContratoService=Ce,e.RoyaltyModule=ia,e.RoyaltyService=oa,e.SafraModule=sa,e.SafraService=na,e.SnapshotComponent=ie,e.SnapshotDescritor=oe,e.TransportadoraModule=da,e.TransportadoraService=la,e.UnidadeMedidaModule=pa,e.UnidadeMedidaService=ca,e.VisualizarBalancaComponent=Z,e.VisualizarBalancaDescritor=W,e.highlightLanguages=Dr,e.ɵa=Y,e.ɵb=ee,e.ɵba=sr,e.ɵbb=dr,e.ɵbc=$a,e.ɵbd=hr,e.ɵbe=ht,e.ɵbf=tr,e.ɵbg=Fa,e.ɵbh=er,e.ɵbi=ar,e.ɵbj=Xa,e.ɵbk=Wa,e.ɵbl=Da,e.ɵbm=Mt,e.ɵbn=fa,e.ɵbo=ha,e.ɵbp=va,e.ɵbq=ba,e.ɵbr=Sa,e.ɵbs=Ca,e.ɵbt=bt,e.ɵbu=yt,e.ɵc=re,e.ɵd=ce,e.ɵe=pe,e.ɵf=me,e.ɵg=ye,e.ɵh=ge,e.ɵi=ve,e.ɵj=Fe,e.ɵk=Ie,e.ɵl=Fr,e.ɵm=gt,e.ɵn=It,e.ɵo=vt,e.ɵp=ya,e.ɵq=Ge,e.ɵr=Ka,e.ɵs=Ja,e.ɵt=Sr,e.ɵu=za,e.ɵv=ma,e.ɵw=ka,e.ɵx=lr,e.ɵy=xe,e.ɵz=ga,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("rxjs"),require("rxjs/operators"),require("@angular/common"),require("@angular/core"),require("@ngx-translate/core"),require("@seniorsistemas/angular-components"),require("primeng/message"),require("primeng/table"),require("@angular/common/http"),require("primeng/api"),require("@seniorsistemas/yms-routines"),require("@angular/animations"),require("@seniorsistemas/platform-components"),require("@stomp/ng2-stompjs"),require("sockjs-client"),require("ngx-cookie-service"),require("primeng/components/dynamicdialog/dynamicdialog"),require("primeng/primeng"),require("@seniorsistemas/yms-components"),require("@angular/router"),require("primeng/inputswitch"),require("primeng/inputtext"),require("@angular/forms"),require("moment"),require("primeng/components/common/messageservice"),require("primeng/shared"),require("primeng/button"),require("ngx-highlightjs"),require("primeng/accordion"),require("primeng/confirmdialog"),require("primeng/dialog"),require("primeng/dropdown"),require("primeng/panel"),require("angular2-hotkeys"),require("primeng/components/common/api"),require("highlight.js/lib/languages/json"),require("highlight.js/lib/languages/xml")):"function"==typeof define&&define.amd?define("@seniorsistemas/yms-integration",["exports","rxjs","rxjs/operators","@angular/common","@angular/core","@ngx-translate/core","@seniorsistemas/angular-components","primeng/message","primeng/table","@angular/common/http","primeng/api","@seniorsistemas/yms-routines","@angular/animations","@seniorsistemas/platform-components","@stomp/ng2-stompjs","sockjs-client","ngx-cookie-service","primeng/components/dynamicdialog/dynamicdialog","primeng/primeng","@seniorsistemas/yms-components","@angular/router","primeng/inputswitch","primeng/inputtext","@angular/forms","moment","primeng/components/common/messageservice","primeng/shared","primeng/button","ngx-highlightjs","primeng/accordion","primeng/confirmdialog","primeng/dialog","primeng/dropdown","primeng/panel","angular2-hotkeys","primeng/components/common/api","highlight.js/lib/languages/json","highlight.js/lib/languages/xml"],t):t(((e=e||self).seniorsistemas=e.seniorsistemas||{},e.seniorsistemas["yms-integration"]={}),e.rxjs,e.rxjs.operators,e.ng.common,e.ng.core,e.core$1,e.angularComponents,e.message,e.table,e.ng.common.http,e.api,e.ymsRoutines,e.ng.animations,e.platformComponents,e.ng2Stompjs,e.SockJS,e.ngxCookieService,e.dynamicdialog,e.primeng,e.ymsComponents,e.ng.router,e.inputswitch,e.inputtext,e.ng.forms,e._moment,e.messageservice,e.shared,e.button,e.ngxHighlightjs,e.accordion,e.confirmdialog,e.dialog,e.dropdown,e.panel,e.angular2Hotkeys,e.api$1,e.jsonx,e.xmlx)}(this,function(e,t,a,i,r,o,n,s,l,d,c,p,u,m,f,h,g,v,y,b,F,S,D,C,_,T,k,I,M,R,A,E,G,N,O,L,q,x){"use strict";q=q&&Object.prototype.hasOwnProperty.call(q,"default")?q["default"]:q,x=x&&Object.prototype.hasOwnProperty.call(x,"default")?x["default"]:x;var w=function(e,t){return(w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var a in t)t.hasOwnProperty(a)&&(e[a]=t[a])})(e,t)};function P(e,t){function a(){this.constructor=e}w(e,t),e.prototype=null===t?Object.create(t):(a.prototype=t.prototype,new a)}var j=function(){return(j=Object.assign||function(e){for(var t,a=1,i=arguments.length;a<i;a++)for(var r in t=arguments[a])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function V(e,t,a,i){var r,o=arguments.length,n=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,a):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,a,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(n=(o<3?r(n):o>3?r(t,a,n):r(t,a))||n);return o>3&&n&&Object.defineProperty(t,a,n),n}function U(e,t){return function(a,i){t(a,i,e)}}function B(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function z(e){var t="function"==typeof Symbol&&Symbol.iterator,a=t&&e[t],i=0;if(a)return a.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function $(e,t){var a="function"==typeof Symbol&&e[Symbol.iterator];if(!a)return e;var i,r,o=a.call(e),n=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)n.push(i.value)}catch(s){r={error:s}}finally{try{i&&!i.done&&(a=o["return"])&&a.call(o)}finally{if(r)throw r.error}}return n}function H(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat($(arguments[t]));return e}var Y=function(){function e(e,a,i){this._client=e;var r=JSON.parse(a.get("com.senior.token")),o=r.access_token,n=r.username.split("@")[1];this._subscriptionUrl="/topic/"+n+"/"+o+"/yms/"+i+"/",this._unsubscribe$=new t.Subject}return e.prototype.connect=function(e){var t=this;this._client.connectObservable.pipe(a.takeUntil(this._unsubscribe$)).subscribe(function(a){return e(t._subscriptionUrl,t._client,a)})},e.prototype.dispose=function(){this._unsubscribe$.next(),this._unsubscribe$.complete()},e}(),Q=function(){function e(e){this.messageService=e}return e.prototype.getListQueryParams=function(e){var t=e.page,a=void 0===t?0:t,i=e.size,r=void 0===i?10:i,o=e.sort,n=void 0===o?[]:o,s=e.filterQuery,l=void 0===s?"":s,c=e.displayFields,p=void 0===c?[]:c,u=new d.HttpParams;return u=(u=u.append("size",String(r))).append("offset",String(a)),n&&n.length&&(u=u.append("orderby",n.map(function(e){var t="";return 1===e.order?t=" asc":-1===e.order&&(t=" desc"),""+e.field+t}).join(", "))),l&&(u=u.append("filter",l)),p&&p.length&&(u=u.append("displayfields",p.join())),u},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var i=a.status?String(a.status):"Error",r=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:i,detail:r})}return t.throwError(a)})},e}(),K=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i.url="yms/integration/",i}return P(t,e),t.prototype.listGateByArea=function(e){var t=this.getListQueryParams({size:1e3,page:0,displayFields:["*"],filterQuery:"area.id eq '"+e+"'"});return this.http.get(this.url+"entities/gate",{params:t})},t.prototype.openGate=function(e){return this.http.post(this.url+"actions/openGate",{ip:e}).pipe(this.defaultCatch())},t.prototype.closeGate=function(e){return this.http.post(this.url+"actions/closeGate",{ip:e}).pipe(this.defaultCatch())},t.prototype.checkAccess=function(e){var t={includeFilters:!1,permissions:e};return this.http.post("platform/authorization/queries/checkAccess",t).pipe(this.defaultCatch())},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Q),J=function(){function e(){}return e=V([p.ControleCircuito({header:"Cancelas",name:"yms.integracao.devices"}),p.ControleOperacao({header:"Cancelas",name:"yms.integracao.devices"})],e)}(),X=function(e){function i(a,i){var r=e.call(this)||this;return r.service=a,r.translate=i,r.successState="default",r.permissionOpenGate=!1,r.permissionCloseGate=!1,r.uriGateDefault="res://senior.com.br/yms/devices/gate",r.unsubscribe$=new t.Subject,r.gates$=new t.Subject,r}return P(i,e),i.prototype.ngOnInit=function(){this.checkPermissionsGates()},i.prototype.checkPermissionsGates=function(){var e=this;this.service.listGateByArea(this.sequenciaCircuito.area.id).pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(t){var a=t.contents,i=e.buildResourceGateAndAction(a);i.length<=0||e.checkAcessPermissionGate(i,a)})},i.prototype.buildResourceGateAndAction=function(e){var t=[];return t.push({resource:this.uriGateDefault,action:"Close"}),t.push({resource:this.uriGateDefault,action:"Open"}),e.filter(function(e){e.resourceUri!==undefined&&(t.push({resource:e.resourceUri,action:"Close"}),t.push({resource:e.resourceUri,action:"Open"}))}),t},i.prototype.checkAcessPermissionGate=function(e,t){var i=this;this.service.checkAccess(e).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return i.loading=undefined})).subscribe(function(e){var a=e.permissions;i.gates$.next(i.buildGateWithActionsAndPermissions(a,t))})},i.prototype.buildGateWithActionsAndPermissions=function(e,t){var a=this,i=[];return t.filter(function(t){if(t.isActionButton=!1,t.actions=[],a.permissionCloseGate&&a.permissionOpenGate)return t.isActionButton=!0,void i.push(t);e.filter(function(e){t.isActionButton=!!t.isActionButton||a.checkDefaultGatePermission(e,t),t.resourceUri===e.resource&&(t.actions.push({action:e.action,authorized:e.authorized}),t.isActionButton=!!t.isActionButton||e.authorized)}),i.push(t)}),i},i.prototype.checkDefaultGatePermission=function(e,t){if(this.uriGateDefault===e.resource){if("Open"===e.action)return this.permissionOpenGate=e.authorized,e.authorized;if("Close"===e.action)return this.permissionCloseGate=e.authorized,e.authorized}return!1},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},i.prototype.model=function(e){var t=this,a=!1,i=!1;return this.permissionCloseGate&&this.permissionOpenGate||e.actions.filter(function(e){"Open"===e.action&&(a=e.authorized),"Close"===e.action&&(i=e.authorized)}),!0===this.permissionOpenGate&&(a=this.permissionOpenGate),!0===this.permissionCloseGate&&(i=this.permissionCloseGate),[{label:this.translate.instant("yms.integration.open_gate"),visible:a,command:function(){return t.openGate(e)}},{label:this.translate.instant("yms.integration.close_gate"),visible:i,command:function(){return t.closeGate(e)}}]},i.prototype.openGate=function(e){var t=this;this.loading=e.id,this.service.openGate(e.ip).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return t.loading=undefined})).subscribe(function(a){return t.successState=e.id})},i.prototype.closeGate=function(e){var t=this;this.loading=e.id,this.service.closeGate(e.ip).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return t.loading=undefined})).subscribe(function(a){return t.successState=e.id})},V([r.Input(),B("design:type",Object)],i.prototype,"sequenciaCircuito",void 0),i=V([r.Component({selector:"controlador-cancela-component",template:'<div>\n <p-table [value]="gates$ | async">\n <ng-template pTemplate="header">\n <tr>\n <th>{{\'yms.integration.gate_ip\' | translate}}</th>\n <th>{{\'yms.integration.gate_type\' | translate}}</th>\n <th></th>\n </tr>\n </ng-template>\n <ng-template pTemplate="body" let-rowData>\n <tr \n [@success]="successState === rowData.id ? successState : \'default\'" \n (@success.done)="successState = \'default\'"\n >\n <td>{{rowData.ip}}</td>\n <td>{{rowData.type | translate}}</td>\n <td>\n <div *ngIf="rowData.isActionButton">\n <span *sLoadingState="loading === rowData.id" >\n <s-button priority="default" [auxiliary]="true" label="Ações" [model]="model(rowData)" >\n </s-button>\n </span>\n </div>\n </td>\n </tr>\n </ng-template>\n </p-table>\n</div>',animations:[u.trigger("success",[u.state("*",u.style({backgroundColor:"#0C9348",opacity:.5})),u.state("default",u.style({backgroundColor:"#FFF",opacity:1})),u.transition("* => default",u.animate("1.2s ease-in")),u.transition("default => *",u.animate("0s"))])]}),B("design:paramtypes",[K,o.TranslateService])],i)}(J),W=function(){function e(e){this.dispatcher=e,this.dispatcher.dispatch(X)}return e=V([r.NgModule({imports:[i.CommonModule,l.TableModule,o.TranslateModule,s.MessageModule,n.ButtonModule,n.LoadingStateModule,m.PermissionsModule.forChild([{name:"gate",actions:["Open","Close"],uri:"res://senior.com.br/yms/devices/gate"}])],declarations:[X],entryComponents:[X],exports:[X],providers:[K]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),Z=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i.urlIntegration="yms/integration/",i.urlBalanca="yms/balanca/",i}return P(t,e),t.prototype.getWeightScaleByArea=function(e){var t={displayFields:["description","code"],page:0,size:1e3,filterQuery:"area.id eq '"+e+"'"};return this.http.get(this.urlIntegration+"entities/weightScale",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t.prototype.fallbackCall=function(e,t){return this.http.post(this.urlBalanca+"actions/manualWeight",{code:e,weight:t}).pipe(this.defaultCatch())},t.prototype.getStabilizedWeight=function(e){return this.http.post(this.urlBalanca+"queries/getStabilizedWeight",{code:e}).pipe(this.defaultCatch())},t.prototype.getWeightScaleByCode=function(e){var t={displayFields:["description","code"],page:0,size:10,filterQuery:"code eq '"+e+"'"};return this.http.get(this.urlIntegration+"entities/weightScale",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Q),ee=function(){function e(){}return e=V([p.ControleCircuito({header:"Balanças",name:"yms.integracao.devices"}),p.ControleOperacao({header:"Balanças",name:"yms.integracao.devices"})],e)}(),te=function(e){function i(a){var i=e.call(this)||this;return i.service=a,i.loading=!1,i.unsubscribe$=new t.Subject,i.weightScales$=new t.BehaviorSubject([]),i.weightScaleValues=new Map,i}return P(i,e),i.prototype.ngOnInit=function(){var e=this;this.sequenciaCircuito&&(this.loading=!0,this.service.getWeightScaleByArea(this.sequenciaCircuito.area.id).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loading=!1})).subscribe(function(t){var a=t.contents;e.weightScales$.next(a),a.forEach(function(t){e.weightScaleValues.set(t.id,0),e.service.getStabilizedWeight(t.code).subscribe(function(a){e.weightScaleValues.set(t.id,a.weight)})})}))},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},V([r.Input(),B("design:type",Object)],i.prototype,"sequenciaCircuito",void 0),i=V([r.Component({selector:"visualizar-balanca-component",template:'<div *sLoadingState="loading">\n <p-table [value]="weightScales$ | async">\n <ng-template pTemplate="header">\n <tr>\n <th>Código</th>\n <th>Descrição</th>\n <th>Peso</th>\n </tr>\n </ng-template>\n <ng-template let-rowData pTemplate="body">\n <tr>\n <td>{{rowData.code}}</td>\n <td>{{rowData.description}}</td>\n <td>{{weightScaleValues.get(rowData.id)}}</td>\n </tr>\n </ng-template>\n </p-table>\n</div>'}),B("design:paramtypes",[Z])],i)}(ee),ae=function(e){function t(){var t=e.call(this)||this,a=t.getCookieObject("com.senior.token").access_token,i=t.getCookie("com.senior.base.url")+"/websocket/subscription";return t.socketProvider=function(){return new h(i)},t.configureConfig(a),t}return P(t,e),t.prototype.getCookieObject=function(e){var t=this.getCookie(e);return t?JSON.parse(t):t},t.prototype.getCookie=function(e){try{for(var t=e+"=",a=decodeURIComponent(document.cookie).split(";"),i=0;i<a.length;i++){for(var r=a[i];" "==r.charAt(0);)r=r.substring(1);if(0==r.indexOf(t))return r.substring(t.length,r.length)}return null}catch(o){return null}},t.prototype.configureConfig=function(e){this.url=this.socketProvider,this.headers={"content-type":"application/json",Authorization:"Bearer "+e,"Access-Control-Allow-Origin":"*"},this.heartbeat_in=1e4,this.heartbeat_out=1e4,this.reconnect_delay=15e3,this.debug=!1},t}(f.StompConfig),ie=function(){function e(e){this.dispatcher=e,this.dispatcher.dispatch(te)}return e=V([r.NgModule({imports:[i.CommonModule,l.TableModule,s.MessageModule,n.LoadingStateModule],declarations:[te],entryComponents:[te],exports:[te],providers:[Z,g.CookieService,f.StompService,{provide:f.StompConfig,useClass:ae}]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),re=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.url="yms/integration/",i.patioUrl="yms/patio/",i}return P(t,e),t.prototype.getCamerasByArea=function(e){var t={page:0,size:1e3,filterQuery:"area.id eq '"+e+"'",displayFields:["id","description","ip"]};return this.http.get(this.url+"entities/camera",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t.prototype.takeSnapshot=function(e){return this.http.get(this.url+"queries/fetchSnapshot",{params:{ip:e.ip}}).pipe(this.defaultCatch())},t.prototype.saveSnapshotInCircuit=function(e){return this.http.post(this.patioUrl+"actions/adicionaImagemExecucaoCircuito",e).pipe(this.defaultCatch())},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Q),oe=function(){function e(e,a,i,r){this.dialogRef=e,this.dialogConfig=a,this.service=i,this.messageService=r,this.loading=!1,this.unsubscribe$=new t.Subject}return e.prototype.ngOnInit=function(){this.imageUrl=this.dialogConfig.data.url},e.prototype.save=function(){var e=this;this.loading=!0;var t=this.dialogConfig.data.execucaoCircuito,i=this.dialogConfig.data.cameraIp;this.service.saveSnapshotInCircuit({execucaoCircuitoId:t.id,alvoId:t.sequenciaCircuito.id,cameraIp:i,imagemUrl:this.imageUrl}).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loading=!1})).subscribe(function(){e.messageService.add({severity:"success",summary:"Salvo com sucesso!",detail:"Imagem salva com sucesso"}),e.dialogRef.close()})},e.prototype.close=function(e){this.dialogRef.close(e)},e=V([r.Component({selector:"view-image-component",template:'\n <s-loading-state [loading]="loading">\n <img [src]="imageUrl" width="100%">\n <br>\n </s-loading-state>\n\n <div style="position: absolute; bottom: 0; width: 670px; padding-top: 10px; border-top: 1px solid #ccc;" [style.pointer-events]="loading ? \'none\' : \'all\'">\n <s-button priority="primary" label="Salvar" (onClick)="save()"></s-button>\n <s-button priority="link" label="Cancelar" (onClick)="close()"></s-button>\n </div> \n '}),B("design:paramtypes",[c.DynamicDialogRef,c.DynamicDialogConfig,re,c.MessageService])],e)}(),ne=function(){function e(){}return e=V([p.ControleOperacao({header:"Câmeras",name:"yms.integracao.devices"}),p.ControleCircuito({header:"Câmeras",name:"yms.integracao.devices"})],e)}(),se=function(e){function i(a,i){var r=e.call(this)||this;return r.service=a,r.dialogService=i,r.loadingAll=!1,r.loading=[],r.unsubscribe$=new t.Subject,r.cameras$=new t.Subject,r}return P(i,e),i.prototype.ngOnInit=function(){var e=this;this.loadingAll=!0,this.service.getCamerasByArea(this.sequenciaCircuito.area.id).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loadingAll=!1})).subscribe(function(t){var a=t.contents;return e.cameras$.next(a)})},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},i.prototype.takeSnapshot=function(e){var t=this;this.loading.push(e.id),this.service.takeSnapshot(e).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){var a=t.loading.indexOf(e.id);t.loading.splice(a,1)})).subscribe(function(a){var i=a.url;t.dialogService.open(oe,{header:e.description,width:"700px",height:"600px",contentStyle:{height:"500px",overflow:"hidden"},data:{url:i,cameraIp:e.ip,execucaoCircuito:t.execucaoCircuito}})})},V([r.Input(),B("design:type",Object)],i.prototype,"sequenciaCircuito",void 0),V([r.Input(),B("design:type",Object)],i.prototype,"execucaoCircuito",void 0),i=V([r.Component({selector:"snapshot-component",template:'<div class="lista-cameras" *sLoadingState="loadingAll">\n <div class="camera" *ngFor="let camera of cameras$ | async">\n <span *sLoadingState="loading.includes(camera.id)">\n <div class="info">\n <div class="info-title">\n Descrição\n </div>\n <div class="info-data">\n {{camera.description}}\n </div>\n </div>\n\n <div class="info">\n <div class="info-title">\n IP\n </div>\n <div class="info-data">\n {{camera.ip}}\n </div>\n </div>\n\n <s-button priority="default" [auxiliary]="true" iconClass="fa fa-camera" (onClick)="takeSnapshot(camera)">\n </s-button>\n </span>\n </div>\n</div>',providers:[c.DialogService],styles:[".lista-cameras{display:flex;flex-direction:column}.lista-cameras .camera{width:100%;height:60px;border-bottom:1px solid #ccc;padding-left:20px}.lista-cameras .camera .info{width:40%;margin-top:5px;display:inline-block}.lista-cameras .camera .info .info-title{display:block;font-size:12px}.lista-cameras .camera .info .info-data{display:inline-block;font-size:16px;font-weight:800}"]}),B("design:paramtypes",[re,c.DialogService])],i)}(ne),le=function(){function e(e){this.dispatcher=e,this.dispatcher.dispatch(se)}return e=V([r.NgModule({imports:[i.CommonModule,n.ButtonModule,n.LoadingStateModule,v.DynamicDialogModule],declarations:[se,oe],entryComponents:[se,oe],exports:[se],providers:[re]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),de=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i.url="yms/integration/",i}return P(t,e),t.prototype.getLprByArea=function(e){var t={page:0,size:1e3,filterQuery:"area.id eq '"+e+"'",displayFields:["id","stream","description","area.*"]};return this.http.get(this.url+"entities/lprConfiguration",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t.prototype.fallbackCall=function(e,t){return this.http.post(this.url+"actions/lprEventPublish",{stream:e,licencePlate:t}).pipe(this.defaultCatch())},t.prototype.getLprByCode=function(e){var t={page:0,size:10,filterQuery:"stream eq '"+e+"'",displayFields:["id","stream","description","locked"]};return this.http.get(this.url+"entities/lprConfiguration",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Q),ce=function(){function e(){}return e=V([r.NgModule({providers:[de]})],e)}(),pe=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i.url="yms/integration/",i}return P(t,e),t.prototype.listLogByCircuit=function(e,t){return t.filterQuery="execucaoCircuitoId eq '"+e+"'",this.http.get(this.url+"entities/logCircuit",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Q),ue=function(){function e(){}return e=V([p.CircuitoFinalizado({header:"Logs com dispositivos",name:"yms.integracao.devices"})],e)}(),me=function(e){function i(a,i){var r=e.call(this)||this;return r.logsService=a,r.translate=i,r.unsubscribe$=new t.Subject,r}return P(i,e),i.prototype.ngOnInit=function(){this.columns=[{field:"username",header:this.translate.instant("yms.integration.usuario")},{field:"log",header:this.translate.instant("yms.integration.log")},{field:"createdDate",header:this.translate.instant("yms.integration.created_date")}]},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},i.prototype.onGridChange=function(e){var t=e.rows,a=e.first/t;this.updateGrid({size:t,page:a,sort:[{field:"createdDate",order:-1}]})},i.prototype.updateGrid=function(e){var t=this;this.loading=!0;var i=e.page,r=e.size,o=e.sort;this.logsService.listLogByCircuit(this.execucaoCircuito.id,{page:i,size:r,sort:o}).pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(e){var a=e.contents,i=e.totalElements;t.logsData=a,t.totalRecords=i})},V([r.Input(),B("design:type",Object)],i.prototype,"execucaoCircuito",void 0),i=V([r.Component({template:'<p-table [columns]="columns" [value]="logsData" [paginator]="true" [lazy]="true" [totalRecords]="totalRecords"\nrows="10" [rowsPerPageOptions]="[10, 20, 50, 100]" (onLazyLoad)="onGridChange($event)">\n <ng-template pTemplate="header" let-columns>\n <tr>\n <th *ngFor="let column of columns">{{ column.header }}</th>\n </tr>\n </ng-template>\n <ng-template pTemplate="body" let-rowData>\n <tr>\n <td>{{rowData.username}}</td>\n <td [pTooltip]="rowData.log">{{rowData.log}}</td>\n <td>{{rowData.createdDate | date: \'dd/MM/yyyy hh:mm:ss\'}}</td>\n </tr>\n </ng-template>\n</p-table>\n'}),B("design:paramtypes",[pe,o.TranslateService])],i)}(ue),fe=function(){function e(e){e.dispatch(me)}return e=V([r.NgModule({declarations:[me],entryComponents:[me],providers:[pe],imports:[i.CommonModule,l.TableModule,o.TranslateModule,y.TooltipModule,n.LoadingStateModule]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),he=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i}return P(t,e),t.prototype.agendas=function(e){return this.http.get("yms/patio/entities/agenda",{params:this.getListQueryParams(e)}).pipe(this.defaultCatch())},t.prototype.ultimaPlacaLida=function(e){return this.http.post("yms/integration/queries/getLastValidPlateByLpr",{stream:e}).pipe(this.defaultCatch())},t.prototype.getPortarias=function(e){return this.http.get("yms/integration/entities/lobby",{params:this.getListQueryParams({page:0,size:100,filterQuery:"planta.id eq '"+e+"'",displayFields:["description","entranceLpr.*","lprs.*","planta.*"]})}).pipe(this.defaultCatch())},t.prototype.executarEntrada=function(e,t){return this.http.post("yms/integration/actions/executeLobby",{lobbyId:e,plate:t}).pipe(this.defaultCatch())},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Q),ge=function(){function e(){}return e=V([p.ControleUnificado({header:"Periféricos",name:"yms.integracao.devices"})],e)}(),ve=function(e){function i(a,i){var r=e.call(this)||this;return r.selectPlantService=a,r.portariaService=i,r.unsubscribe$=new t.Subject,r}return P(i,e),i.prototype.ngOnInit=function(){var e=this,t=this.selectPlantService.getPlant();this.portariaService.getPortarias(t.id).pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(t){var a=t.contents;return e.portarias=a})},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},i=V([r.Component({selector:"portarias",template:'\n <h3>Portarias</h3>\n <div class="separator"></div>\n <div class="ui-g">\n <portaria-entrada *ngFor="let portaria of portarias" class="ui-md-4" [portaria]="portaria"></portaria-entrada>\n </div>\n '}),B("design:paramtypes",[b.SelectPlantService,he])],i)}(ge),ye=function(){function e(e,a,i,r){this.dialogRef=e,this.dialogConfig=a,this.portariaService=i,this.router=r,this.unsubscribe$=new t.Subject}return e.prototype.ngOnInit=function(){var e=this;this.veiculo=this.dialogConfig.data.veiculo,this.portaria=this.dialogConfig.data.portaria,this.loading=!0,this.portariaService.agendas({size:100,page:0,displayFields:["veiculo.primario.*","tipoAgendamento.*","descricao","externalTenant","dataEsperadaAgendamento"],filterQuery:"veiculo.primario.placa eq '"+this.veiculo+"' and status eq 'AGENDADO' and planta eq '"+this.portaria.planta.id+"'"}).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loading=!1})).subscribe(function(t){var a=t.contents;e.agendas=a,e.agendas.length?1===e.agendas.length&&(e.selected=e.agendas[0]):e.chegadaSimplificada()})},e.prototype.chegadaSimplificada=function(){this.router.navigate(["execucao-circuito/new"],{queryParams:{veiculo:this.veiculo,navigateTo:"processo-entrada"}}),this.dialogRef.close()},e.prototype.chegada=function(){this.selected&&(this.router.navigate(["execucao-circuito/"+this.selected.id]),this.dialogRef.close())},e.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},e.prototype.getColumns=function(){return[{field:"descricao",label:"Descrição"},{field:"dataEsperadaAgendamento",label:"Data"},{field:"tipoAgendamento",label:"Tipo de Agendamento"},{field:"externalTenant",label:"Parceiro"}]},e=V([r.Component({template:'\n <div style="width: 100%; height: calc(100% - 50px); overflow: auto;">\n <div *sLoadingState="loading">\n <p-table [value]="agendas" [columns]="getColumns()" selectionMode="single" [(selection)]="selected" dataKey="id">\n <ng-template pTemplate="header" let-columns>\n <tr>\n <th style="width: 50px;"></th>\n <th *ngFor="let column of columns">{{column.label}}</th>\n </tr>\n </ng-template>\n <ng-template pTemplate="body" let-rowData>\n <tr [pSelectableRow]="rowData">\n <td style="width: 50px;">\n <p-tableRadioButton [value]="rowData"></p-tableRadioButton>\n </td>\n <td>{{rowData[\'descricao\']}}</td>\n <td>{{rowData[\'dataEsperadaAgendamento\'] | date: \'dd/MM/yyyy HH:mm\'}}</td>\n <td>{{rowData[\'tipoAgendamento\']?.descricao}}</td>\n <td>{{rowData[\'externalTenant\']?.descricao}}</td>\n </tr>\n </ng-template>\n </p-table>\n </div>\n </div>\n <div style="position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: flex-end; height: 40px; align-items: center;">\n <s-button priority="primary" label="Registrar chegada" [disabled]="!selected" (onClick)="chegada()"></s-button>\n <s-button priority="primary" label="Registrar chegada simplificada" (onClick)="chegadaSimplificada()"></s-button>\n </div>\n '}),B("design:paramtypes",[c.DynamicDialogRef,c.DynamicDialogConfig,he,F.Router])],e)}(),be=function(){function e(e){this.dialogRef=e}return e.prototype["continue"]=function(){this.dialogRef.close({placa:this.placa})},e=V([r.Component({template:'\n <p>Não foi encontrada uma leitura de placa. Deseja informar a placa para realizar a entrada?</p>\n <div class="separator"></div>\n <input pInputText type="text" pattern="[A-Z0-9]{6,10}" maxlength="10" placeholder="Digite a placa" [(ngModel)]="placa" #placaInput>\n \n <div style="position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: flex-end; height: 40px; align-items: center;">\n <s-button priority="primary" label="Continuar" [disabled]="!placa || !placaInput.validity.valid" (onClick)="continue()"></s-button>\n </div>\n '}),B("design:paramtypes",[c.DynamicDialogRef])],e)}(),Fe=function(){function e(e,a,i,r){this.dialogService=e,this.portariaService=a,this.loading=!1,this.unsubscribe$=new t.Subject,this.websocket=new Y(i,r,"integration")}return e.prototype.ngOnInit=function(){var e=this;this.websocket.connect(function(t,i){i.subscribe(t+"wsLprLockUnlocked").pipe(a.map(function(e){return e.body}),a.map(function(e){return JSON.parse(e).data}),a.takeUntil(e.unsubscribe$)).subscribe(function(t){return e.portaria.lprs=e.portaria.lprs.map(function(e){return e.stream===t.stream?j({},e,{locked:t.locked}):e})})})},e.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},e.prototype.readPlaque=function(){var e=this;this.loading=!0,this.portariaService.ultimaPlacaLida(this.portaria.entranceLpr.stream).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loading=!1})).subscribe(function(t){var a=t.plate;if(!a)return e.placaNaoEncontrada();e.openAgendas(a)})},e.prototype.placaNaoEncontrada=function(){var e=this;this.dialogService.open(be,{header:"Placa não encontrada",style:{display:"flex","flex-direction":"column"},height:"80%",styleClass:"ui-g-12 ui-md-8",contentStyle:{"overflow-y":"auto",height:"100%","max-height":"100%",flex:1}}).onClose.pipe(a.filter(function(e){return!!e})).subscribe(function(t){return e.openAgendas(t.placa)})},e.prototype.openAgendas=function(e){var t=this;this.portariaService.executarEntrada(this.portaria.id,e).pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(){t.dialogService.open(ye,{header:"Agendamentos | "+e.toUpperCase(),style:{display:"flex","flex-direction":"column"},height:"80%",styleClass:"ui-g-12 ui-md-8",contentStyle:{"overflow-y":"auto",height:"100%","max-height":"100%",flex:1},data:{veiculo:e,portaria:t.portaria}})})},V([r.Input(),B("design:type",Object)],e.prototype,"portaria",void 0),e=V([r.Component({selector:"portaria-entrada",template:'\n <div class="card-entrada" *sLoadingState="loading">\n <div class="portaria-card">\n <h4>{{portaria?.description}}</h4>\n <s-button style="float: right" [auxiliary]="true" iconClass="fas fa-camera" priority="default" (onClick)="readPlaque()"></s-button>\n </div>\n <div class="portaria-card" *ngFor="let lpr of portaria.lprs">\n <h4>{{lpr.description || lpr.stream}}</h4>\n <p-inputSwitch styleClass="lprInputSwitch" [ngModel]="lpr.locked" [readonly]="true"></p-inputSwitch>\n </div>\n </div>\n ',providers:[c.DialogService],styles:[":host{display:block;padding:10px}.card-entrada{border-radius:20px;border:1px solid #ccc;padding:10px}.card-entrada .portaria-card{min-height:40px;display:flex;justify-content:space-between;align-items:center}"]}),B("design:paramtypes",[c.DialogService,he,f.StompService,g.CookieService])],e)}(),Se=function(){function e(e){e.dispatch(ve)}return e=V([r.NgModule({imports:[i.CommonModule,C.FormsModule,F.RouterModule,n.ButtonModule,l.TableModule,n.LoadingStateModule,S.InputSwitchModule,D.InputTextModule,v.DynamicDialogModule,d.HttpClientModule,b.SelectPlantModule,s.MessageModule],declarations:[ve,Fe,ye,be],entryComponents:[ve,ye,be],providers:[he,g.CookieService,f.StompService,{provide:f.StompConfig,useClass:ae}]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),De=[n.FieldType.Integer,n.FieldType.Double],Ce=/^\d+\b$/,_e=function(e,t){return e.concat(t.filter(function(t){return!e.includes(t)}))},Te=function(e,t){var a=ke(e,t),i=a.isValidValue;return!(a.typeExists&&!i)},ke=function(e,t){switch(e){case n.FieldType.Time:case n.FieldType.Date:case n.FieldType.DateTime:return{isValidValue:!1,typeExists:!0};case n.FieldType.Integer:case n.FieldType.Double:default:return{isValidValue:t.match(Ce),typeExists:De.includes(e)}}},Ie=function(e,t){return 0===Object.keys(e.controls).filter(function(a){var i=e.get(a).errors?e.get(a).errors.required:e.get(a).errors;return t[a]&&!t[a].visualizar&&i}).length},Me=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},Re={style:{display:"flex","flex-direction":"column"},height:"80%",styleClass:"ui-g-12 ui-md-4",contentStyle:{"overflow-y":"auto",height:"auto","max-height":"none","margin-bottom":"0",flex:1}},Ae=_;function Ee(e,t,a,i){void 0===e&&(e={}),void 0===t&&(t=[]);return t.map(function(t){return t.indexOf(".")>0?Me(e,t):e[t]}).join(a).split("-").reduce(function(e,t){return void 0===e&&(e=" "),void 0===t&&(t=" "),e.trim()&&t.trim()?e+" - "+t:e.trim()&&!t.trim()?""+e:!e.trim()&&t.trim()?""+t:void 0})||(i?"yms.erp.sem_descricao":" - ")}var Ge,Ne,Oe,Le=function(e,t,i,r,o,s,l){void 0===l&&(l="");var d=t.map(function(e){return{field:e,order:1}}),c=e.filter(function(e){var t=e.type;return Te(t,s)}).map(function(e){var t=e.name,a=e.type;return"number"==typeof s||a===n.FieldType.Integer?t+" eq "+s:a==n.FieldType.Date?t+" eq '"+Ae(s).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Ae(s).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Ae(s).format()+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+s.replace(/'/g,"\\'")+"'))":t+" eq '"+s+"'"}).join(" or ");l&&l.trim()&&(c=c?"("+c+") and "+l:l);var p=_e(t,i);return o.list({sort:d,filterQuery:c,displayFields:p}).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:Ee(e,t,r)})})})}))},qe=function(e,t,i,r,o,s,l){void 0===l&&(l="");var d=s.first,c=s.rows,p=s.multiSortMeta,u=s.filterData,m=d/c,f=p,h=e.filter(function(e){var t=e.name;return u[t]!=undefined&&""!=u[t]}).map(function(e){var t=e.name,a=e.type,i=u[t];return"number"==typeof i||a===n.FieldType.Integer?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Ae(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Ae(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Ae(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.Lookup?t+" eq '"+i.id+"'":a==n.FieldType.String&&-1!==t.indexOf(".")?"containing("+t+", '"+i.replace(/'/g,"\\'")+"')":a==n.FieldType.String&&-1===t.indexOf(".")?"containing(lower("+t+"),lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and ");h=l&&l.trim()?h.concat(h?" and ":"").concat(l):h;var g=_e(t,i);return o.list({page:m,sort:f,filterQuery:h,displayFields:g}).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:Ee(e,t,r)})})})}))},xe=_,we=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&xe(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&xe(a.lastModifiedDate).toDate();return a.label=Ee(a,["descricao"]," - "),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&xe(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&xe(a.lastModifiedDate).format(),delete a.label,a},e}(),Pe="Ronda",je=function(){function e(){}return e=V([p.ChegadaVeiculo({header:Pe,name:"yms.integracao.sam",icon:"fal fa-shield"})],e)}(),Ve=function(e){function i(a){var i=e.call(this)||this;return i.integrationCallback=a,i.save=[],i.header=Pe,i.loading=!1,i.unsubscribe$=new t.Subject,i._integrationCallback=a,i}return P(i,e),i.prototype.ngOnInit=function(){var e=this;this._integrationCallback.onAgendamentoSaved().pipe(a.takeUntil(this.unsubscribe$),a.mergeMap(function(a){e.save;return e.agenda=a,t.empty()})).subscribe()},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},V([r.Output(),B("design:type",we)],i.prototype,"agenda",void 0),V([r.Input(),B("design:type",Array)],i.prototype,"save",void 0),i=V([r.Component({template:'\n <div *ngIf="agenda">\n <scheduling [agenda]="agenda"></scheduling>\n </div>\n '}),B("design:paramtypes",[p.IntegrationEventsCallback])],i)}(je),Ue=function(){function e(){}return e.prototype.focusFirstInvalidInput=function(){var e=Array.from(document.getElementsByClassName("ng-invalid")).find(function(e){return"FORM"!==e.nodeName});if(e)if("P-CALENDAR"===e.nodeName){var t=e.getAttribute("ng-reflect-input-id"),a=document.getElementById(t);a&&a.focus()}else if("S-LOOKUP"===e.nodeName){var i=this.getNestedInput(e.firstElementChild);i&&i.focus()}else e.focus()},e.prototype.getNestedInput=function(e){return"INPUT"===e.nodeName?e:this.getNestedInput(e.firstElementChild)},e=V([r.Injectable()],e)}(),Be=function(){function e(e,t){this.http=e,this.messageService=t,this.http=e,this.messageService=t,this.defaultCatch=this.defaultCatch.bind(this)}return e.prototype.commitFiles=function(e){return this.http.post("platform/field_customization/actions/commitObject",{objects:e}).pipe(this.defaultCatch())},e.prototype.deleteFiles=function(e){return this.http.post("platform/field_customization/actions/deleteObjects",e).pipe(this.defaultCatch())},e.prototype.getFiles=function(e){var t=this,a=[];e.value.custom&&(a=e.value.custom.fieldCustomization||[],delete e.value.custom.fieldCustomization);var i=[],r={};return a.forEach(function(e){var a=e.domain,o=e.service,n=e.entity,s=e.toDelete,l=e.toInsert;if(!t.isEmpty(l)){var d=Object.keys(l).map(function(e){return{version:l[e].version,fileName:l[e].name,objectId:l[e].objectId}});t.isEmpty(d)||i.push.apply(i,H(d))}if(!t.isEmpty(s)){var c=[];Object.keys(s).forEach(function(e){var t=(s[e]||[]).map(function(t){return{field:e,objectId:t}});c.push.apply(c,H(t))}),r={domain:a,service:o,entityName:n,objects:c}}}),{filesToCommit:i,filesToDelete:r}},e.prototype.isEmpty=function(e){return Array.isArray(e)?0===e.length:0===Object.entries(e).length&&e.constructor===Object},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var i=a.status?String(a.status):"Error",r=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:i,detail:r})}return t.throwError(a)})},e=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,T.MessageService])],e)}(),ze=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i.domainService="yms_int/sam",i}return P(t,e),t.prototype.getVisited=function(e){return this.http.post("yms_int/sam/queries/getVisited",{id:e})},t.ngInjectableDef=r.defineInjectable({factory:function(){return new t(r.inject(d.HttpClient),r.inject(T.MessageService))},token:t,providedIn:"root"}),t=V([r.Injectable({providedIn:"root"}),B("design:paramtypes",[d.HttpClient,T.MessageService])],t)}(Q),$e=function(){return function(){}}(),He=function(){return function(){}}(),Ye=function(e){function i(a){var i=e.call(this)||this;return i.service=a,i.visited=new $e,i.ngUnsubscribe=new t.Subject,i.visitedService=a,i}return P(i,e),i.prototype.ngOnInit=function(){},i.prototype.ngAfterContentInit=function(){var e=this;this.agenda||console.error("agenda not found"),this.visitedService.getVisited(this.agenda.id).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){t&&(e.visited.name=t.name,e.visited.contactPhone=t.contactPhone)})},V([r.Input(),B("design:type",Object)],i.prototype,"agenda",void 0),i=V([r.Component({selector:"visited-info",template:'\n <div> \n <div class="info">\n <div class="info-title">\n Visitado:\n </div>\n <div class="info-data">\n {{ visited.name }} {{ visited.contactPhone }}\n </div>\n </div>\n </div>\n',styles:[".info{width:40%;margin-top:5px;display:inline-block}.info .info-title{display:block;font-size:12px}.info .info-data{display:inline-block;font-size:16px;font-weight:800}"]}),B("design:paramtypes",[ze])],i)}(He),Qe=function(){return function(){this.credentialCards=[]}}();!function(e){e.BARCODE_CARD="BARCODE_CARD",e.RFID_CARD="RFID_CARD",e.SMART_CARD="SMART_CARD"}(Ge||(Ge={})),function(e){e.CHECK_IN_PENDING="CHECK_IN_PENDING",e.CHECK_IN_REALIZED="CHECK_IN_REALIZED",e.VISITING="VISITING",e.CHECK_OUT_REALIZED="CHECK_OUT_REALIZED",e.CHECK_IN_NOT_REALIZED="CHECK_IN_NOT_REALIZED",e.CHECK_IN_EXPIRED="CHECK_IN_EXPIRED"}(Ne||(Ne={})),function(e){e.BARCODE_CARD="BARCODE_CARD",e.RFID_CARD="RFID_CARD",e.SMART_CARD="SMART_CARD"}(Oe||(Oe={}));var Ke,Je=_,Xe=function(){function e(e,a,i,r,o){this.fb=e,this.dialogRef=a,this.translate=i,this.route=r,this.dialogConfig=o,this.unsubscribe$=new t.Subject,this.technologies=[],this.localeConfig={}}return e.prototype.ngOnInit=function(){var e=this;this.formGroup=this.fb.group({tecnologiaCracha:[undefined,C.Validators.compose([C.Validators.required])],numero:[undefined,C.Validators.compose([C.Validators.required])],validadeCredencial:[undefined,C.Validators.compose([C.Validators.required])],hora:[undefined,C.Validators.compose([C.Validators.required])]}),this.route.data.pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(t){e.localeConfig=t.localeConfig}),this.tecnologiaCracha(Oe.BARCODE_CARD,Oe.RFID_CARD,Oe.SMART_CARD),this.formataDataEHoraDaCredencial()},e.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},e.prototype.gerar=function(){if(!this.formGroup.valid)return this.validateAllFormFields(this.formGroup);var e=this.getDataHora(),t=this.dialogConfig.data.visitante,a=this.gerarCredencial(t,e);this.close(a)},e.prototype.tecnologiaCracha=function(){for(var e,t,a=[],i=0;i<arguments.length;i++)a[i]=arguments[i];this.technologies=[];try{for(var r=z(a),o=r.next();!o.done;o=r.next()){var n=o.value;this.technologies.push({label:this.getTecnologiaCrachaTraduzida(n),value:n})}}catch(s){e={error:s}}finally{try{o&&!o.done&&(t=r["return"])&&t.call(r)}finally{if(e)throw e.error}}},e.prototype.getTecnologiaCrachaTraduzida=function(e){return e===Oe.BARCODE_CARD?this.translate.instant("yms.patio.cartao_credencial_codigo_barras"):e===Oe.RFID_CARD?this.translate.instant("yms.patio.cartao_credencial_rfid"):e===Oe.SMART_CARD?this.translate.instant("yms.patio.cartao_credencial_smart"):void 0},e.prototype.formataDataEHoraDaCredencial=function(){var e=Je().add(1,"hour");this.formGroup.get("validadeCredencial").disable(),this.definiValor("validadeCredencial",e.format("DD/MM/YYYY")),this.definiValor("hora",e.format("HH:mm"))},e.prototype.getDataHora=function(){var e=new Date,t=this.formGroup.get("hora").value,a=Je().date(t).add(1,"hour").hours(),i=Je().date(t).minutes();return e.setHours(a),e.setMinutes(i),e},e.prototype.gerarCredencial=function(e,t){return{visitor:e,cardTechnology:this.formGroup.get("tecnologiaCracha").value,cardNumber:this.formGroup.get("numero").value,endDate:t}},e.prototype.definiValor=function(e,t){return this.formGroup.get(e).setValue(t)},e.prototype.close=function(e){this.dialogRef.close(e)},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);if(i instanceof C.FormControl)i.markAsDirty({onlySelf:!0});else{if(!(i instanceof C.FormGroup))throw"Instance fot found";t.validateAllFormFields(i)}}),e.markAsDirty({onlySelf:!0})},e=V([r.Component({template:'<form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-g-12 required">\n <label for="tecnologiaCracha">{{\n "yms.patio.motorista_tecnologiaCracha" | translate\n }}</label>\n <p-dropdown\n inputId="tecnologiaCracha"\n name="tecnologiaCracha"\n [options]="this.technologies"\n formControlName="tecnologiaCracha"\n [autoWidth]="false"\n placeholder="{{\n \'yms.patio.visitante_credencial_tecnologia_cracha_place_holder\' | translate\n }}"\n ></p-dropdown>\n <s-control-errors\n [control]="formGroup.controls[\'tecnologiaCracha\']"\n [errorMessages]="{ required: \'error_required\' | translate }"\n ></s-control-errors>\n </div>\n <div class="ui-g-12 required">\n <label for="numero">{{ "yms.patio.visitante_credencial_numero" | translate }}</label>\n <input\n id="numero"\n type="text"\n name="numero"\n pInputText\n formControlName="numero"\n autocomplete="off"\n />\n <s-control-errors\n [control]="formGroup.controls[\'numero\']"\n [errorMessages]="{ required: \'error_required\' | translate }"\n ></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="validadeCredencial">{{\n "yms.patio.visitante_validade_credencial" | translate\n }}</label>\n <input\n id="validadeCredencial"\n type="text"\n name="validadeCredencial"\n pInputText\n formControlName="validadeCredencial"\n autocomplete="off"\n />\n <s-control-errors\n [control]="formGroup.controls[\'numero\']"\n [errorMessages]="{ required: \'error_required\' | translate }"\n ></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="hora">{{ "yms.patio.visitante_credecnial_hora" | translate }}</label>\n <p-calendar\n id="hora"\n name="hora"\n formControlName="hora"\n [locale]="localeConfig.calendar"\n inputId="hora"\n [showTime]="true"\n [hourFormat]="localeConfig.calendar.hourFormat"\n [timeOnly]="true"\n >\n </p-calendar>\n <s-control-errors\n [control]="formGroup.controls[\'numero\']"\n [errorMessages]="{ required: \'error_required\' | translate }"\n ></s-control-errors>\n </div>\n </div>\n\n <s-button\n [label]="\'yms.patio.visitante_button_cancelar\' | translate"\n (onClick)="close()"\n priority="link"\n ></s-button>\n <s-button\n [label]="\'yms.patio.visitante_button_gerar\' | translate"\n (onClick)="gerar()"\n ></s-button>\n</form>\n',providers:[c.ConfirmationService]}),B("design:paramtypes",[C.FormBuilder,c.DynamicDialogRef,o.TranslateService,F.ActivatedRoute,c.DynamicDialogConfig])],e)}(),We=function(){function e(e,a,i){this.dialogRef=a,this.dialogConfig=i,this.unsubscribe$=new t.Subject,this.ngUnsubscribe=new t.Subject,this.notSavedData=new r.EventEmitter,this.actualChanged=!1,this.isFormModified=!1,this.formGroup=e.group({name:[undefined,C.Validators.compose([C.Validators.required])],document:[undefined,C.Validators.compose([C.Validators.required])],contact:[undefined,C.Validators.compose([C.Validators.required])]})}return e.prototype.ngOnInit=function(){var e=this,i=this.dialogConfig.data;i!==undefined&&(this.id=i.id,this.formGroup.get("name").setValue(i.name),this.formGroup.get("document").setValue(i.document),this.formGroup.get("contact").setValue(i.contact),i.document!==undefined&&this.formGroup.get("document").disable()),this.notSavedData.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.actualChanged=t}),(new t.ReplaySubject).subscribe(function(t){return e.isFormModified=!t})},e.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},e.prototype.save=function(){if(!this.formGroup.valid)return this.validateAllFormFields(this.formGroup);var e=this.formGroup.getRawValue();e.id=this.id,this.close(e)},e.prototype.close=function(e){this.dialogRef.close(e)},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);if(i instanceof C.FormControl)i.markAsDirty({onlySelf:!0});else{if(!(i instanceof C.FormGroup))throw"Instance fot found";t.validateAllFormFields(i)}}),e.markAsDirty({onlySelf:!0})},V([r.Output(),B("design:type",r.EventEmitter)],e.prototype,"notSavedData",void 0),e=V([r.Component({template:'<form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-g-12 required">\n <label for="name">{{ "yms.visitante_nome" | translate }}</label>\n <input\n id="name"\n type="text"\n name="name"\n pInputText\n formControlName="name"\n dialog\n autocomplete="off"\n />\n <s-control-errors\n [control]="formGroup.controls[\'name\']"\n [errorMessages]="{ required: \'error_required\' | translate }"\n ></s-control-errors>\n </div>\n <div class="ui-g-12 required">\n <label for="document">{{ "yms.visitante_documento" | translate }}</label>\n <input\n id="document"\n type="text"\n name="document"\n pInputText\n formControlName="document"\n autocomplete="off"\n />\n <s-control-errors\n [control]="formGroup.controls[\'document\']"\n [errorMessages]="{ required: \'error_required\' | translate }"\n ></s-control-errors>\n </div>\n <div class="ui-g-12 required">\n <label for="contact">{{ "yms.visitante_contato" | translate }}</label>\n <input\n id="contact"\n type="text"\n name="contact"\n pInputText\n formControlName="contact"\n autocomplete="off"\n />\n <s-control-errors\n [control]="formGroup.controls[\'contact\']"\n [errorMessages]="{ required: \'error_required\' | translate }"\n ></s-control-errors>\n </div>\n </div>\n\n <s-button\n [label]="\'yms.patio.visitante_button_cancelar\' | translate"\n (onClick)="close()"\n priority="link"\n ></s-button>\n <s-button\n [label]="\'yms.patio.visitante_button_salvar\' | translate"\n (onClick)="save()"\n ></s-button>\n</form>\n',providers:[c.ConfirmationService]}),B("design:paramtypes",[C.FormBuilder,c.DynamicDialogRef,c.DynamicDialogConfig])],e)}(),Ze=function(){function e(e,a,i){this.translate=e,this.dialogService=a,this.integrationCallback=i,this.visitors=[],this.visitorsChange=new r.EventEmitter,this.hasChange=new r.EventEmitter,this.ngUnsubscribe=new t.Subject,this.unsubscribe$=new t.Subject,this._integrationCallback=i}return e.prototype.ngOnInit=function(){this.constroiCamposTabelaVistante(),this.visitanteTotalRecords=0},e.prototype.ngAfterContentInit=function(){var e=this;this.visitanteGridLoading=!1,this.adicionaVisitantesGrid(),this._integrationCallback.onAgendamentoMotoristaChanged().pipe(a.takeUntil(this.unsubscribe$),a.mergeMap(function(a){return e.atualizaMotorista(a),t.empty()})).subscribe()},e.prototype.atualizaMotorista=function(e){var t=this.visitanteGridData.find(function(e){return e.driver});t&&t.documentType===this.getDocumentType()&&t.document===e.cpf||(this.visitanteGridData.length>0?this.visitanteGridData[0]={name:e.nome,document:e.cpf,contact:this.getContatoMotorista(e),visitorSituation:Ne.CHECK_IN_PENDING,documentType:this.getDocumentType(),driver:!0}:this.visitanteGridData.push({name:e.nome,document:e.cpf,contact:this.getContatoMotorista(e),visitorSituation:Ne.CHECK_IN_PENDING,documentType:this.getDocumentType(),driver:!0}))},e.prototype.adicionaVisitantesGrid=function(){var e=this;if(this.visitors.length)this.visitanteGridData=[],this.adicionaMotoristaNoVisitanteGridData(),this.visitors.forEach(function(t){e.motorista.cpf!==t.visitor.document&&e.visitanteGridData.push({id:t.visitor.id,name:t.visitor.name,document:t.visitor.document,contact:t.visitor.contact,visitorSituation:e.getVisitorSituation(t.visitor.visitorSituation),documentType:e.getDocumentType(),driver:!0}),e.visitanteTotalRecords=e.visitors.length});else{this.visitanteGridData=[];var t=new Qe;t.visitor={name:this.motorista.nome,document:this.motorista.cpf,contact:this.getContatoMotorista(this.motorista),documentType:this.getDocumentType(),visitorSituation:Ne.CHECK_IN_PENDING,driver:!0},this.visitanteGridData.find(function(e){return t.visitor.document===e.document})===undefined&&(this.visitanteGridData.push(t.visitor),this.visitors.push(t),this.visitanteTotalRecords=1)}this.visitanteGridLoading=!1},e.prototype.isCredentialCardsEmpty=function(e){var t=this.visitors.find(function(t){return t.visitor.document===e.document});return t!==undefined&&t.credentialCards.filter(function(e){return 0!==Object.keys(e).length}).length>0},e.prototype.adicionaMotoristaNoVisitanteGridData=function(){var e=this,t=this.visitors.find(function(t){return e.motorista.cpf===t.visitor.document});t===undefined?this.visitanteGridData.push({name:this.motorista.nome,document:this.motorista.cpf,contact:this.getContatoMotorista(this.motorista),visitorSituation:Ne.CHECK_IN_PENDING,documentType:this.getDocumentType(),driver:!0}):this.visitanteGridData.push({id:t.visitor.id,name:t.visitor.name,document:t.visitor.document,contact:this.getContatoMotorista(this.motorista),visitorSituation:this.getVisitorSituation(t.visitor.visitorSituation),documentType:this.getDocumentType(),driver:!0})},e.prototype.criarOuAtualizarVisitante=function(e){var t=this;this.dialogService.open(We,j({header:this.translate.instant("yms.patio.motorista_adicionar_visitante")},Re,this.constroiVisitante(e))).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(e){return t.adicionaVisitanteParaSalvar(e)})},e.prototype.adicionaVisitanteParaSalvar=function(e){var t=this;if(this.visitanteGridData.forEach(function(a){a.document===e.document&&(a.contact=e.contact,a.name=e.name,t.visitorFound=!0)}),!this.visitorFound){this.visitanteGridLoading=!0,e.documentType=this.getDocumentType(),e.visitorSituation===undefined&&(e.visitorSituation=Ne.CHECK_IN_PENDING),this.addVisitanteNaTabela(e),this.visitanteTotalRecords++,this.visitanteGridLoading=!1;var a=new Qe;a.visitor={name:e.name,document:e.document,contact:e.contact,documentType:e.documentType,visitorSituation:e.visitorSituation,driver:!1},this.visitors.push(a),this.visitorsChange.emit(this.visitors),this.hasChange.emit(!0)}},e.prototype.model=function(e){var t=this,a=e.document===this.motorista.cpf,i=this.visitors.find(function(t){return t.visitor.document===e.document});return[{label:this.translate.instant("yms.patio.motorista_editar_visitante"),command:function(){return t.editarVisitante(e)},visible:!a},{label:this.translate.instant("yms.patio.delete"),command:function(){return t.deletarVisitante(e)},visible:!a},{label:this.translate.instant("yms.patio.motorista_visitante_entregar_credencial"),command:function(){return t.entregarCredencial(e)},visible:a||!a},{label:this.translate.instant("yms.patio.remover_credenciais"),command:function(){return t.deletarCredenciais(i)},visible:null!=i&&null!=i.credentialCards&&i.credentialCards.length>0}]},e.prototype.addVisitanteNaTabela=function(e){e.id!==undefined?this.visitanteGridData=this.visitanteGridData.map(function(t){return t.id===e.id?e:t}):this.visitanteGridData.push(e)},e.prototype.entregarCredencial=function(e){var t=this;this.dialogService.open(Xe,{header:this.translate.instant("yms.patio.motorista_visitante_credencial"),data:{visitante:e}}).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(e){return t.adicionaCredencialParaEntregar(e)})},e.prototype.adicionaCredencialParaEntregar=function(e){var t=this.visitors.find(function(t){return t.visitor.document===e.visitor.document});t===undefined?this.visitors.push({visitor:e.visitor,credentialCards:[this.createCredentialCard(e)]}):t.credentialCards.push(this.createCredentialCard(e)),this.hasChange.emit(!0)},e.prototype.editarVisitante=function(e){this.criarOuAtualizarVisitante(e)},e.prototype.deletarVisitante=function(e){var t=this;this.visitanteGridData.forEach(function(a,i){if(a.document===e.document){t.visitanteGridData.splice(i,1);var r=t.visitors.findIndex(function(e){return e.visitor.document===a.document});-1!==r&&(t.visitors.splice(r,1),t.hasChange.emit(!0))}})},e.prototype.deletarCredenciais=function(e){e.credentialCards.splice(0,e.credentialCards.length),this.hasChange.emit(!0)},e.prototype.getContatoMotorista=function(e){return e.telefone===undefined?"0":e.telefone},e.prototype.getCredentialCards=function(e){var t=this;return this.visitors.length<=0?[]:this.visitors.find(function(t){return t.visitor.document===e.document}).credentialCards.filter(function(e){return 0!==Object.keys(e).length}).map(function(e){return{cardTechnology:t.getTecnologiaCrachaTraduzida(e.cardTechnology),cardNumber:e.cardNumber,endDate:e.endDate}})},e.prototype.constroiVisitante=function(e){var t={data:{}};return e!==undefined&&null!==e&&(t={data:{id:e.id,name:e.name,document:e.document,contact:e.contact,visitorSituation:this.getVisitorSituation(e.visitorSituation),documentType:this.getDocumentType()}}),t},e.prototype.createCredentialCard=function(e){return{visitor:e.id,cardTechnology:e.cardTechnology,cardNumber:e.cardNumber,endDate:e.endDate}},e.prototype.getTecnologiaCrachaTraduzida=function(e){return e===Ge.BARCODE_CARD?this.translate.instant("yms.patio.cartao_credencial_codigo_barras"):e===Ge.RFID_CARD?this.translate.instant("yms.patio.cartao_credencial_rfid"):e===Ge.SMART_CARD?this.translate.instant("yms.patio.cartao_credencial_smart"):void 0},e.prototype.getVisitorSituation=function(e){return e===undefined?Ne.CHECK_IN_PENDING:e},e.prototype.constroiCamposTabelaVistante=function(){this.visitanteGridColumns=[{field:"name",header:this.translate.instant("yms.patio.motorista_visitante_nome")},{field:"document",header:this.translate.instant("yms.patio.motorista_visitante_documento")},{field:"contact",header:this.translate.instant("yms.patio.motorista_visitante_contato")}]},e.prototype.getDocumentType=function(){return"cpf"},V([r.Input(),B("design:type",Object)],e.prototype,"motorista",void 0),V([r.Input(),B("design:type",Array)],e.prototype,"visitors",void 0),V([r.Output(),B("design:type",Object)],e.prototype,"visitorsChange",void 0),V([r.Output(),B("design:type",Object)],e.prototype,"hasChange",void 0),e=V([r.Component({selector:"visitante-component",template:'<div style="margin-bottom: 15px">\n <div>\n <p-header>\n {{ "yms.patio.motorista_titulo_lista_visitante" | translate}}\n <button\n style="margin-left: 50px"\n type="button"\n pButton\n (click)="criarOuAtualizarVisitante(null)"\n label="{{ \'yms.patio.motorista_add_visitante\' | translate }}"\n >\n </button>\n </p-header>\n <div class="ui-g">\n <div class="ui-g-12">\n <p-table\n #visitanteTable\n [value]="visitanteGridData"\n [columns]="visitanteGridColumns"\n dataKey="id"\n [lazy]="true"\n [scrollable]="true"\n [resizableColumns]="true"\n sortMode="single"\n [paginator]="true"\n [totalRecords]="visitanteTotalRecords"\n rows="10"\n [rowsPerPageOptions]="[10, 20, 50, 100]"\n [loading]="visitanteGridLoading"\n >\n <ng-template pTemplate="colgroup" let-columns>\n <colgroup>\n <col *ngFor="let col of columns" [style.width]="col.width" />\n </colgroup>\n </ng-template>\n <ng-template pTemplate="header" let-columns>\n <tr>\n <th id="espaco-coluna-plus" style="width: 50px"></th>\n <th\n id=""\n *ngFor="let col of columns"\n [pSortableColumn]="col.field"\n pResizableColumn\n >\n <div class="senior-header">\n <span class="senior-header-title">{{ col.header }}</span>\n <p-sortIcon [field]="col.field"></p-sortIcon>\n </div>\n </th>\n <th id="" style="width: 15%"></th>\n </tr>\n </ng-template>\n <ng-template pTemplate="body" let-rowData let-columns let-expanded="expanded">\n <tr [pSelectableRow]="rowData">\n <td style="width: 50px">\n <a href="#" [pRowToggler]="rowData" style="color: #000">\n <em [ngClass]="expanded ? \'fa fa-minus\' : \'fa fa-plus\'"></em>\n </a>\n </td>\n <td>\n <span>{{ rowData["name"] }}</span>\n </td>\n <td>\n <span>{{ rowData["document"] }}</span>\n </td>\n <td>\n <span>{{ rowData["contact"] }}</span>\n </td>\n <td style="width: 15%">\n <s-button\n priority="default"\n label="{{ \'yms.patio.motorista_acao_visitante\' | translate }}"\n [model]="model(rowData)"\n >\n </s-button>\n </td>\n </tr>\n </ng-template>\n <ng-template pTemplate="rowexpansion" let-rowData let-columns="columns">\n <tr class="bg-white no-hover">\n <td [attr.colspan]="columns.length + 2">\n <div *ngIf="isCredentialCardsEmpty(rowData); else elseBlock">\n <div\n class="container flex-container"\n *ngFor="let credentialCard of getCredentialCards(rowData)"\n >\n <p-card\n header="{{ credentialCard.cardTechnology }}"\n [style]="{ width: \'300px\', margin: \'10px\' }"\n >\n <div>\n Número: <strong>{{ credentialCard.cardNumber }}</strong>\n </div>\n <div>\n Data de validade:\n <strong>{{ credentialCard.endDate | date : "dd/MM/yyyy hh:mm" }}</strong>\n </div>\n </p-card>\n </div>\n </div>\n <ng-template #elseBlock\n >Não há credenciais para salvar ou entregues</ng-template\n >\n </td>\n </tr>\n </ng-template>\n <ng-template pTemplate="paginatorright">\n <span\n [translate]="\'total_records\'"\n [translateParams]="{ value: visitanteTotalRecords }"\n ></span>\n </ng-template>\n </p-table>\n </div>\n </div>\n</div>\n</div>',styles:[".container{display:inline-flex}.flex-container{flex-wrap:wrap}"]}),B("design:paramtypes",[o.TranslateService,c.DialogService,p.IntegrationEventsCallback])],e)}(),et=function(){function e(e,t,a,i){this.http=e,this.messageService=t,this.entityUrl=a,this.actionsUrl=i,this.http=e,this.messageService=t,this.entityUrl=a,this.actionsUrl=i,this.defaultCatch=this.defaultCatch.bind(this)}return e.prototype.getListQueryParams=function(e){var t=e.page,a=void 0===t?0:t,i=e.size,r=void 0===i?10:i,o=e.sort,n=void 0===o?[]:o,s=e.filterQuery,l=void 0===s?"":s,c=e.displayFields,p=void 0===c?[]:c,u=new d.HttpParams;return u=(u=u.append("size",String(r))).append("offset",String(a)),n&&n.length&&(u=u.append("orderby",n.map(function(e){var t="";return 1===e.order?t=" asc":-1===e.order&&(t=" desc"),""+e.field+t}).join(", "))),l&&(u=u.append("filter",l)),p&&p.length&&(u=u.append("displayfields",p.join())),u},e.prototype.getBodyParams=function(e){var t=e.page,a=void 0===t?0:t,i=e.size,r=void 0===i?10:i,o=e.sort,n=void 0===o?[]:o,s=e.filterQuery,l=void 0===s?"":s,d=e.displayFields,c=void 0===d?[]:d,p={};return p.size=r,p.offset=a,n&&n.length&&(p.orderBy=n.map(function(e){var t="";return 1===e.order?t=" asc":-1===e.order&&(t=" desc"),""+e.field+t}).join(", ")),l&&(p.filter=l),c&&c.length&&(p.displayFields=c.join()),p},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var i=a.status?String(a.status):"Error",r=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:i,detail:r})}return t.throwError(a)})},e.prototype.getListBodyParams=function(e){var t=this.getBodyParams(e);return e.displayFields&&e.displayFields.length&&(t.displayFields=e.displayFields),t},e.prototype.list=function(e){return this.http.get(this.entityUrl,{params:this.getListQueryParams(e)}).pipe(this.defaultCatch())},e.prototype.get=function(e,t){return void 0===t&&(t=!0),this.http.get(this.entityUrl+"/"+e).pipe(t?this.defaultCatch():a.tap())},e.prototype.insert=function(e){return this.http.post(""+this.entityUrl,e).pipe(this.defaultCatch())},e.prototype.update=function(e,t,i){return void 0===i&&(i=!0),this.http.put(this.entityUrl+"/"+e,t).pipe(i?this.defaultCatch():a.tap())},e.prototype["delete"]=function(e){return this.http["delete"](this.entityUrl+"/"+e).pipe(this.defaultCatch())},e.prototype.listCustomFilter=function(e,t){return this.http.post(this.actionsUrl+"/"+t,this.getBodyParams(e)).pipe(this.defaultCatch())},e}(),tt=function(e){function t(t,a){var i=e.call(this,t,a,"yms_int/sam/entities/scheduling")||this;return i.http=t,i.messageService=a,i.domainService="yms_int/sam",i}return P(t,e),t.prototype.saveScheduling=function(e){return this.http.post(this.domainService+"/actions/saveScheduling",e).pipe(this.defaultCatch())},t.prototype.startScheduling=function(e){return this.http.post(this.domainService+"/actions/startScheduling",{id:e}).pipe(this.defaultCatch())},t.prototype.getSchedulingByYms=function(e){return this.http.post(this.domainService+"/queries/getSchedulingByYms",{id:e}).pipe(this.defaultCatch())},t.ngInjectableDef=r.defineInjectable({factory:function(){return new t(r.inject(d.HttpClient),r.inject(T.MessageService))},token:t,providedIn:"root"}),t=V([r.Injectable({providedIn:"root"}),B("design:paramtypes",[d.HttpClient,T.MessageService])],t)}(et),at=function(e,t){return e.concat(t.filter(function(t){return!e.includes(t)}))},it=[n.FieldType.Integer,n.FieldType.Double],rt=_,ot=function(){function e(e,a,i,r,o){void 0===r&&(r=""),this._lookupDisplayFields=[],this._advancedDisplayFields=[],this._params=[],this._url={},this._nameService={},this._useCustomSearch=!1,this._responseNamesData={},this._service=a,this._searchFields=e,this._searchGridFields=i||e,this._lookupSeparator=r,this.unsubscribe$=new t.Subject,this.verificaAtivo=o}return Object.defineProperty(e.prototype,"searchFields",{get:function(){return this._searchFields},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"searchGridFields",{get:function(){return this._searchGridFields},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"searchGridData",{get:function(){return this._searchGridData},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lookupSuggestions",{get:function(){return this._lookupSuggestions},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"searchTotalRecords",{get:function(){return this._searchTotalRecords},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lookupDisplayFields",{get:function(){return this._lookupDisplayFields},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"advancedDisplayFields",{get:function(){return this._advancedDisplayFields},enumerable:!0,configurable:!0}),e.prototype.setLookupDisplayFields=function(e){return this._lookupDisplayFields=e,this},e.prototype.setAdvancedDisplayFields=function(e){return this._advancedDisplayFields=e,this},e.prototype.setVariablesCustomSearch=function(e){return void 0===e&&(e={}),this._params=e.params,this._url=e.url,this._nameService=e.nameService,this._customService=e.service,this._responseNamesData=e.responseNamesData,this},e.prototype.lookupRequest=function(e,t){var i=this,r=this._lookupDisplayFields.map(function(e){return{field:e,order:1}}),o=this._searchFields.filter(function(t){return function(e,t){var a=it.includes(e),i=t.match(/^\d+\b$/);return!(a&&!i)}(t.type,e)}).map(function(t){var a=t.name,i=t.type;return"number"==typeof e?a+" eq "+e:i==n.FieldType.Date?a+" eq '"+rt(e).format("YYYY-MM-DD")+"'":i==n.FieldType.Time?a+" eq '"+rt(e).format("HH:mm:ss")+"'":i==n.FieldType.DateTime?a+" eq '"+rt(e).format()+"'":i==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or "),s=at(this._lookupDisplayFields,this._advancedDisplayFields),l=this.geradorFiltro(o,t);this._service.list({sort:r,filterQuery:l,displayFields:s}).pipe(a.takeUntil(this.unsubscribe$)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:i._lookupDisplayFields.map(function(t){return t.indexOf(".")>0?i.getProp(e,t):e[t]}).join(i._lookupSeparator)})})})})).subscribe(function(e){return i._lookupSuggestions=e.contents})},e.prototype.searchRequest=function(e,t){var i=this,r=e.first,o=e.rows,s=e.multiSortMeta,l=e.filterData,d=r/o,c=s,p=this._searchGridFields.filter(function(e){var t=e.name;return l[t]!=undefined&&""!=l[t]}).map(function(e){var t=e.name,a=e.type,i=l[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+rt(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+rt(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+rt(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":a==n.FieldType.Lookup?t+" eq '"+i.id+"'":t+" eq '"+i+"'"}).join(" and "),u=at(this._lookupDisplayFields,this._advancedDisplayFields),m=this.geradorFiltro(p,t);this._service.list({page:d,sort:c,filterQuery:m,displayFields:u}).pipe(a.takeUntil(this.unsubscribe$)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:i._lookupDisplayFields.map(function(t){return t.indexOf(".")>0?i.getProp(e,t):e[t]}).join(i._lookupSeparator)})})})})).subscribe(function(e){i._searchGridData=e.contents,i._searchTotalRecords=e.totalElements})},e.prototype.customLookupRequest=function(e){var t=this;this._params.descricao=e,this._customService[this._nameService](this._params,this._url).pipe(a.takeUntil(this.unsubscribe$)).pipe(a.map(function(e){return j({},e,{contents:e[t._responseNamesData.contents].map(function(e){return j({},e,{label:t._lookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t._lookupSeparator)})})})})).subscribe(function(e){return t._lookupSuggestions=e[t._responseNamesData.contents]})},e.prototype.customSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.sortField,n=e.sortOrder,s=e.filterData,l={plantaId:this._params.plantaId,page:i/r,size:r,sortField:o,sortOrder:n};Object.entries(s).filter(function(e){return!(!e[0]||!e[1])&&(l[e[0]]=e[1])}),this._customService[this._nameService](l,this._url).pipe(a.takeUntil(this.unsubscribe$)).pipe(a.map(function(e){return j({},e,{contents:e[t._responseNamesData.contents].map(function(e){return j({},e,{label:t._lookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t._lookupSeparator)})})})})).subscribe(function(e){t._searchGridData=e[t._responseNamesData.contents],t._searchTotalRecords=e[t._responseNamesData.totalElements]})},e.prototype.getProp=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},e.prototype.geradorFiltro=function(e,t){var a=e?"("+e+")":"";return this.verificaAtivo&&(a+=e?"and ativo eq true":"ativo eq true"),a.concat(""+(t?t(e):""))},e}(),nt=function(e){function t(t,a){var i=e.call(this,t,a,"sam/lobby/entities/lobby")||this;return i.http=t,i.messageService=a,i}return P(t,e),t.ngInjectableDef=r.defineInjectable({factory:function(){return new t(r.inject(d.HttpClient),r.inject(T.MessageService))},token:t,providedIn:"root"}),t=V([r.Injectable({providedIn:"root"}),B("design:paramtypes",[d.HttpClient,T.MessageService])],t)}(et),st=function(){return function(){}}(),lt=function(){return function(){}}();!function(e){e.PENDING="PENDING",e.IN_PROGRESS="IN_PROGRESS",e.FINISHED="FINISHED",e.NOT_OCCURRED="NOT_OCCURRED"}(Ke||(Ke={}));var dt,ct=function(){function e(e,a,i,o,n,s){this.fb=e,this.route=a,this.translate=i,this.messageService=o,this.lobbyService=n,this.schedulingService=s,this.notSavedData=new r.EventEmitter,this.schedulingVisitors=new st,this.isFormModified=!1,this.loading=!1,this.localeConfig={},this.ngUnsubscribe=new t.Subject}return e.prototype.ngOnInit=function(){var e=this;this.createForm(),this.portariaLookup=new ot(this.getLobbyFields(),this.lobbyService),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){e.localeConfig=t.localeConfig}),this.formGroup.valueChanges.subscribe(function(t){return e.isFormModified=!0})},e.prototype.ngAfterViewInit=function(){this.saveAndInitButton=document.getElementById("init")},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete()},e.prototype.ngOnChanges=function(){var e=this;this.agenda.id&&(this.loading=!0,this.schedulingService.getSchedulingByYms(this.agenda.id).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return e.loading=!1})).subscribe(function(t){if(t.scheduling){var a=t.scheduling;e.schedulingVisitors.scheduling=a,e.schedulingVisitors.visitors=t.visitors,e.formGroup.controls.motivoVisita.setValue(a.description),e.formGroup.controls.dataSaida.setValue(new Date(a.expectedEndDate)),e.formGroup.controls.horaSaida.setValue(new Date(a.expectedEndDate)),e.getLobby(a).subscribe(function(t){return e.formGroup.controls.portaria.setValue(t)})}else{var i=new Date;i.setHours((new Date).getHours()+1),e.schedulingVisitors.scheduling=new lt,e.schedulingVisitors.visitors=[],e.schedulingVisitors.scheduling.visitSituation=Ke.PENDING,e.schedulingVisitors.scheduling.description=e.agenda.descricao,e.schedulingVisitors.scheduling.expectedStartDate=new Date,e.schedulingVisitors.scheduling.expectedEndDate=i,e.formGroup.controls.motivoVisita.setValue(e.schedulingVisitors.scheduling.description),e.formGroup.controls.dataSaida.setValue(e.schedulingVisitors.scheduling.expectedStartDate),e.formGroup.controls.horaSaida.setValue(e.schedulingVisitors.scheduling.expectedEndDate)}}),this.patchActualValue())},e.prototype.getLobby=function(e){if(e.lobbyIdSAM)return this.lobbyService.get(e.lobbyIdSAM)},e.prototype.patchActualValue=function(){var e=this;setTimeout(function(){e.actualValue=e.formGroup.value,e.formGroup.patchValue(e.actualValue)},500)},e.prototype.canSave=function(){return!!(this.agenda&&this.agenda.id&&this.isFormModified)},e.prototype.onSave=function(e){var i=this;if(this.formGroup.invalid)this.validateAllFormFields(this.formGroup);else{this.isFormModified=!1;var r=this.schedulingVisitors.scheduling;r.idYMS=this.agenda.id,r.description=this.formGroup.controls.motivoVisita.value,r.expectedStartDate=new Date;var o=this.formGroup.controls.dataSaida.value,n=this.formGroup.controls.horaSaida.value;r.expectedEndDate=this.getDate(o,n);var s=this.formGroup.controls.portaria.value;s&&(r.lobbyIdSAM=s.id),this.loading=!0,this.schedulingService.saveScheduling(this.schedulingVisitors).pipe(a.takeUntil(this.ngUnsubscribe),a.mergeMap(function(a){return i.schedulingVisitors=a,e?i.schedulingService.startScheduling(i.schedulingVisitors.scheduling.idYMS):(i.loading=!1,t.NEVER)}),a.finalize(function(){return i.loading=!1})).subscribe(function(e){e&&i.saveAndInitButton&&i.saveAndInitButton.click(),i.loading=!1})}},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup&&t.validateAllFormFields(i)})},e.prototype.getDate=function(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes())},e.prototype.reset=function(){this.formGroup.patchValue(j({},this.actualValue))},e.prototype.createForm=function(){this.formGroup=this.fb.group({motivoVisita:[undefined,C.Validators.compose([C.Validators.required])],portaria:[undefined,C.Validators.compose([C.Validators.required])],dataSaida:[undefined,C.Validators.compose([C.Validators.required])],horaSaida:[undefined,C.Validators.compose([C.Validators.required])]})},e.prototype.getLobbyFields=function(){return[new n.FormField({name:"name",type:n.FieldType.String,label:this.translate.instant("yms.patio.sam_portaria_descricao")})]},V([r.Input(),B("design:type",Object)],e.prototype,"agenda",void 0),V([r.Output(),B("design:type",r.EventEmitter)],e.prototype,"notSavedData",void 0),e=V([r.Component({selector:"scheduling",template:'<visited-info [agenda]="agenda"> </visited-info>\r\n<form [formGroup]="formGroup" *sLoadingState="loading" novalidate>\r\n <div class="ui-fluid">\r\n <div class="ui-g">\r\n <div class="ui-g-12 ui-md-6 required">\r\n <label for="motivoVisita">{{ "yms.patio.sam_motivo_visita" | translate }}</label>\r\n <input\r\n type="text"\r\n id="motivoVisita"\r\n name="motivoVisita"\r\n pInputText\r\n formControlName="motivoVisita"\r\n autocomplete="off"\r\n />\r\n <s-control-errors\r\n [control]="formGroup.controls[\'motivoVisita\']"\r\n [errorMessages]="{ required: \'error_required\' | translate }"\r\n >\r\n </s-control-errors>\r\n </div>\r\n <div class="ui-g-12 ui-md-6 required">\r\n <label for="portaria">{{ "yms.patio.sam_portaria" | translate }}</label>\r\n <s-lookup\r\n dataKey="id"\r\n id="portaria"\r\n name="portaria"\r\n formControlName="portaria"\r\n lookupDisplayField="name"\r\n [multiple]="false"\r\n (onLookupRequest)="portariaLookup.lookupRequest($event)"\r\n (onSearchRequest)="portariaLookup.searchRequest($event)"\r\n [searchTitle]="\'yms.patio.sam_portaria\' | translate"\r\n [searchEmptyTitle]="\'nothing_found\' | translate"\r\n [searchFields]="portariaLookup.searchFields"\r\n [searchGridFields]="portariaLookup.searchGridFields"\r\n [searchGridData]="portariaLookup.searchGridData"\r\n [searchTotalRecords]="portariaLookup.searchTotalRecords"\r\n [searchTotalRecordsLabel]="\r\n \'total_records\' | translate : { value: portariaLookup.searchTotalRecords }\r\n ">\r\n </s-lookup>\r\n <s-control-errors \r\n [control]="formGroup.controls[\'portaria\']"\r\n [errorMessages]="{ required: \'error_required\' | translate }">\r\n </s-control-errors>\r\n </div>\r\n <div class="ui-g-6 ui-md-3 required">\r\n <label for="dataSaida">{{ "yms.patio.sam_data_saida" | translate }}</label>\r\n <p-calendar\r\n id="dataSaida"\r\n name="dataSaida"\r\n formControlName="dataSaida"\r\n inputId="dataSaida"\r\n [showIcon]="true"\r\n [locale]="localeConfig.calendar"\r\n [dateFormat]="localeConfig.calendar.dateFormat"\r\n >\r\n </p-calendar>\r\n <s-control-errors\r\n [control]="formGroup.controls[\'dataSaida\']"\r\n [errorMessages]="{ required: \'error_required\' | translate }"\r\n >\r\n </s-control-errors>\r\n </div>\r\n <div class="ui-g-6 ui-md-3 required">\r\n <label for="horaSaida">{{ "yms.patio.sam_hora_saida" | translate }}</label>\r\n <p-calendar\r\n id="horaSaida"\r\n name="horaSaida"\r\n formControlName="horaSaida"\r\n [locale]="localeConfig.calendar"\r\n inputId="horaSaida"\r\n [showTime]="true"\r\n [hourFormat]="localeConfig.calendar.hourFormat"\r\n [timeOnly]="true"\r\n >\r\n </p-calendar>\r\n <s-control-errors\r\n [control]="formGroup.controls[\'horaSaida\']"\r\n [errorMessages]="{ required: \'error_required\' | translate }"\r\n >\r\n </s-control-errors>\r\n </div>\r\n </div>\r\n </div>\r\n</form>\r\n<div class="separator"></div>\r\n<div *ngIf="schedulingVisitors.visitors">\r\n <visitante-component\r\n [motorista]="agenda.motorista"\r\n [(visitors)]="schedulingVisitors.visitors"\r\n (hasChange)="isFormModified = $event">\r\n </visitante-component>\r\n</div>\r\n<div class="separator"></div>\r\n<div style="margin-top: 10px">\r\n <s-button priority="primary" [label]="\'save\' | translate" (onClick)="onSave()"\r\n [disabled]="loading || !canSave()"></s-button>\r\n <s-button *ngIf="saveAndInitButton" priority="primary" [label]="\'save_and_init\' | translate" (onClick)="onSave(true)"\r\n [disabled]="loading"></s-button>\r\n \r\n</div>\r\n'}),B("design:paramtypes",[C.FormBuilder,F.ActivatedRoute,o.TranslateService,T.MessageService,nt,tt])],e)}(),pt=function(){function e(e){this.dispatcher=e,this._dispatcher=e,this._dispatcher.dispatch(Ve)}return e=V([r.NgModule({declarations:[Ve,Ye,ct,Ze,We,Xe],entryComponents:[Ve,Ye,ct,Ze,We,Xe],exports:[Ve,Ye,ct],imports:[p.IntegrationModule,i.CommonModule,o.TranslateModule,C.FormsModule,n.ButtonModule,y.SharedModule,y.CardModule,I.ButtonModule,C.ReactiveFormsModule,k.SharedModule,n.CustomFieldsModule,n.ControlErrorsModule,y.DialogModule,n.EmptyStateModule,n.DynamicFormModule,n.TokenListModule,y.PanelModule,y.InputTextModule,y.DropdownModule,n.ButtonModule,n.LoadingStateModule,n.NumberInputModule,y.ConfirmDialogModule,n.LocaleModule,m.PermissionsModule,v.DynamicDialogModule,l.TableModule,y.TabViewModule,y.CalendarModule],providers:[Be,Ue]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),ut=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i.domainService="yms_int/sam",i}return P(t,e),t.prototype.findVisitors=function(e){return this.http.post("yms_int/sam/queries/findVisitorsBySchedulingIdYMS",{agendaIdYMS:e})},t.ngInjectableDef=r.defineInjectable({factory:function(){return new t(r.inject(d.HttpClient),r.inject(T.MessageService))},token:t,providedIn:"root"}),t=V([r.Injectable({providedIn:"root"}),B("design:paramtypes",[d.HttpClient,T.MessageService])],t)}(Q),mt=function(e){function i(a){var i=e.call(this)||this;return i.service=a,i.ngUnsubscribe=new t.Subject,i.visitorService=a,i}return P(i,e),i.prototype.ngOnInit=function(){},i.prototype.ngAfterContentInit=function(){var e=this;this.visitorService.findVisitors(this.agenda.id).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){t.visitors.length&&(e.visitors=t.visitors)})},i.prototype.credentialResume=function(e){var t,a,i="";try{for(var r=z(e),o=r.next();!o.done;o=r.next()){var n=o.value;n.cardNumber?i+=n.cardNumber:i+=" - "}}catch(s){t={error:s}}finally{try{o&&!o.done&&(a=r["return"])&&a.call(r)}finally{if(t)throw t.error}}return i},V([r.Input(),B("design:type",Object)],i.prototype,"agenda",void 0),i=V([r.Component({selector:"visitor-list-component",template:'\n<div> \n <p-table [value]="visitors">\n <ng-template pTemplate="header">\n <tr>\n <th id="visitor_name">{{\'yms.patio.motorista_visitante_nome\' | translate}}</th>\n <th id="visitor_docuemnt">{{\'yms.patio.motorista_visitante_documento\' | translate}}</th> \n <th id="visitor_credential">{{\'yms.patio.motorista_visitante_credenciais\' | translate}}</th>\n <th id="visitor_contact">{{\'yms.patio.motorista_visitante_contato\' | translate}}</th>\n </tr>\n </ng-template>\n <ng-template let-rowData pTemplate="body">\n <tr>\n <td id="">{{rowData.visitor.name}}</td>\n <td id="">{{rowData.visitor.document}}</td>\n <td id="">{{credentialResume(rowData.credentialCards)}} </td>\n <td id="">{{rowData.visitor.contact}}</td>\n </tr>\n </ng-template>\n </p-table>\n</div>'}),B("design:paramtypes",[ut])],i)}(function(){function e(){}return e=V([p.ControleCircuito({header:"Ronda",name:"yms.integracao.sam"}),p.ControleOperacao({header:"Ronda",name:"yms.integracao.sam"})],e)}()),ft=function(){function e(e){this.dispatcher=e,this.dispatcher.dispatch(mt)}return e=V([r.NgModule({imports:[i.CommonModule,l.TableModule,s.MessageModule,o.TranslateModule,n.LoadingStateModule],declarations:[mt],entryComponents:[mt],exports:[mt],providers:[ut]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),ht=function(){function e(e,t,a,i){this.http=e,this.messageService=t,this.entityUrl=a,this.actionsUrl=i,this.http=e,this.messageService=t,this.entityUrl=a,this.actionsUrl=i,this.defaultCatch=this.defaultCatch.bind(this)}return e.prototype.getListQueryParams=function(e){var t=e.page,a=void 0===t?0:t,i=e.size,r=void 0===i?10:i,o=e.sort,n=void 0===o?[]:o,s=e.filterQuery,l=void 0===s?"":s,c=e.displayFields,p=void 0===c?[]:c,u=new d.HttpParams;return u=(u=u.append("size",String(r))).append("offset",String(a)),n&&n.length&&(u=u.append("orderby",n.map(function(e){var t="";return 1===e.order?t=" asc":-1===e.order&&(t=" desc"),""+e.field+t}).join(", "))),l&&(u=u.append("filter",l)),p&&p.length&&(u=u.append("displayfields",p.join())),u},e.prototype.getBodyParams=function(e){var t=e.page,a=void 0===t?0:t,i=e.size,r=void 0===i?10:i,o=e.sort,n=void 0===o?[]:o,s=e.filterQuery,l=void 0===s?"":s,d=e.displayFields,c=void 0===d?[]:d,p={};return p.size=r,p.offset=a,n&&n.length&&(p.orderBy=n.map(function(e){var t="";return 1===e.order?t=" asc":-1===e.order&&(t=" desc"),""+e.field+t}).join(", ")),l&&(p.filter=l),c&&c.length&&(p.displayfields=c.join()),p},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var i=a.status?String(a.status):"Error",r=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:i,detail:r})}return t.throwError(a)})},e.prototype.list=function(e){return this.http.get(this.entityUrl,{params:this.getListQueryParams(e)}).pipe(this.defaultCatch())},e.prototype.get=function(e){return this.http.get(this.entityUrl+"/"+e).pipe(this.defaultCatch())},e.prototype.insert=function(e){return this.http.post(""+this.entityUrl,e).pipe(this.defaultCatch())},e.prototype.update=function(e,t){return this.http.put(this.entityUrl+"/"+e,t).pipe(this.defaultCatch())},e.prototype["delete"]=function(e){return this.http["delete"](this.entityUrl+"/"+e).pipe(this.defaultCatch())},e.prototype.listCustomFilter=function(e,t){return this.http.post(this.actionsUrl+"/"+t,this.getBodyParams(e)).pipe(this.defaultCatch())},e}(),gt=new r.InjectionToken("integration_environment"),vt=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/agenda",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r._agendaUrl=i.project.domain+"/patio",r}return P(t,e),t.prototype.atualizarAgenda=function(e){return this.http.post(this._agendaUrl+"/actions/atualizarAgenda",{agenda:e}).pipe(this.defaultCatch())},t.prototype.retornaModelosValidacao=function(e){return this.http.post("yms/agenda/queries/retornaModelosDeValidacao",{tipoAgendamentoId:e}).pipe(this.defaultCatch())},t.prototype.checarRevalidacao=function(e){return this.http.post("yms/agenda/actions/checarRevalidacao",e).pipe(this.defaultCatch())},t.prototype.listExternalAgenda=function(e){return this.http.get("yms/agenda/entities/agenda",{params:this.getListQueryParams(e)}).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),yt=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/recebimentoContrato",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r._baseUrl=i.project.domain+"/"+i.project.service,r}return P(t,e),t.prototype.registrarChegadaVeiculoComRecebimento=function(e){return this.http.post(this._baseUrl+"/actions/registrarChegadaDeVeiculoComRecebimento",e).pipe(this.defaultCatch())},t.prototype.insertContratoRecebimento=function(e,t){return this.http.post(this.entityUrl+"/recebimento/"+e+"/contratos",t).pipe(this.defaultCatch())},t.prototype.insertContratoRecebimentoItem=function(e,t){return this.http.post(this.entityUrl+"/contratoRecebimento/"+e+"/itens",t).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),bt=function(){function e(e,t,a){this.override=e,this.agendaService=t,this.recebimentoService=a,this.RECEBIMENTO_KEY="ERP_SENIOR_RECEBIMENTO"}return e.prototype.initialize=function(){var e=this;this.override.addOverride(this.RECEBIMENTO_KEY,function(t){return e.functionToOverride(t)})},e.prototype.remove=function(){this.override.disposeOverride(this.RECEBIMENTO_KEY)},e.prototype.functionToOverride=function(e){var i=this;return this.agendaService.atualizarAgenda(e.agenda).pipe(a.mergeMap(function(t){return i.recebimentoService.list({filterQuery:"agenda.id eq '"+e.agenda.id+"'",page:0,size:1})}),a.map(function(e){var t=e.contents;return t.length?t[0]:null}),a.mergeMap(function(a){return a?i.recebimentoService.registrarChegadaVeiculoComRecebimento({recebimento:a,circuito:e.circuito.id,sequenciaInicial:e.sequencia.id,vagaInicial:(e.vaga||{}).id}):t.throwError("Os dados da guia ERP Senior não foram informados")}))},e=V([r.Injectable(),B("design:paramtypes",[p.ChegadaVeiculoOverride,vt,yt])],e)}(),Ft=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/expedicao",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r._baseUrl=i.project.domain+"/"+i.project.service,r}return P(t,e),t.prototype.registrarChegadaVeiculoComExpedicao=function(e){return this.http.post(this._baseUrl+"/actions/registrarChegadaDeVeiculoComExpedicao",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,c.MessageService,Object])],t)}(ht),St=function(){function e(e,t,a){this.override=e,this.agendaService=t,this.expedicaoService=a,this.EXPEDICAO_KEY="ERP_SENIOR_EXPEDICAO"}return e.prototype.initialize=function(){var e=this;this.override.addOverride(this.EXPEDICAO_KEY,function(t){return e.functionToOverride(t)})},e.prototype.remove=function(){this.override.disposeOverride(this.EXPEDICAO_KEY)},e.prototype.functionToOverride=function(e){var i=this;return this.agendaService.atualizarAgenda(e.agenda).pipe(a.mergeMap(function(t){return i.expedicaoService.list({filterQuery:"agenda.id eq '"+e.agenda.id+"'",page:0,size:1})}),a.map(function(e){var t=e.contents;return t.length?t[0]:null}),a.mergeMap(function(a){return a?i.expedicaoService.registrarChegadaVeiculoComExpedicao({expedicao:a,circuito:e.circuito.id,sequenciaInicial:e.sequencia.id,vagaInicial:(e.vaga||{}).id}):t.throwError("Não foi possível encontrar os dados de expedição")}))},e=V([r.Injectable(),B("design:paramtypes",[p.ChegadaVeiculoOverride,vt,Ft])],e)}(),Dt=function(){function e(e,t){this.http=e,this.messageService=t,this.baseUrl="yms/integration/"}return e.prototype.getProcessConfigurationErp=function(e){return this.http.get(this.baseUrl+"queries/getErpProcessConfigurationByTipoAgendamento",{params:{idTipoAgendamento:e}}).pipe(this.defaultCatch())},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var i=a.status?String(a.status):"Error",r=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:i,detail:r})}return t.throwError(a)})},e=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],e)}(),Ct="ERP Senior",_t=function(){function e(){}return e=V([p.Agendamento({header:Ct,name:"yms.integracao.erpagrox"}),p.ChegadaVeiculo({header:Ct,name:"yms.integracao.erpagrox",icon:"fal fa-book"})],e)}(),Tt=function(e){function i(a,i){var r=e.call(this)||this;return r.integrationCallback=a,r.integrationService=i,r.header=Ct,r.loading=!1,r.unsubscribe$=new t.Subject,r}return P(i,e),i.prototype.ngOnInit=function(){var e=this;this.integrationCallback.onAgendamentoSaved().pipe(a.takeUntil(this.unsubscribe$),a.mergeMap(function(i){return e.agenda=i,e.loading=!0,e.agenda?e.integrationService.getProcessConfigurationErp(e.agenda.tipoAgendamento.id).pipe(a.finalize(function(){return e.loading=!1})):t.empty()})).subscribe(function(t){return e.tipoProcessoErpAtual=t.id})},i.prototype.ngOnChanges=function(){},i.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},i=V([r.Component({template:'\n <div *ngIf="agenda">\n <div [ngSwitch]="tipoProcessoErpAtual">\n <recebimento-form *ngSwitchCase="\'RECEBIMENTO_CONTRATO\'" [agenda]="agenda"></recebimento-form>\n <expedicao-form *ngSwitchCase="\'EXPEDICAO\'" [agenda]="agenda"></expedicao-form>\n <devolucao-form *ngSwitchCase="\'DEVOLUCAO\'" [agenda]="agenda"></devolucao-form>\n <recebimento-ordem-compra-form *ngSwitchCase="\'RECEBIMENTO_ORDEM_COMPRA\'" [agenda]="agenda"></recebimento-ordem-compra-form>\n <processo-avulso-form *ngSwitchCase="\'PROCESSO_AVULSO\'" [agenda]="agenda"></processo-avulso-form>\n <div *ngSwitchDefault>\n <s-loading-state [loading]="loading">\n <h3 *ngIf="!loading" style="text-align: center;">\n ATENÇÃO, não existe Tipo de Processo configurado para esse tipo de agendamento.\n </h3>\n <h3 *ngIf="loading" style="text-align: center;"> Carregando configurações </h3>\n </s-loading-state>\n </div>\n </div>\n </div>\n '}),B("design:paramtypes",[p.IntegrationEventsCallback,Dt])],i)}(_t),kt="Informações fiscais",It=function(){function e(){}return e=V([p.ControleCircuito({header:kt,name:"yms.integracao.erpagrox"}),p.ControleOperacao({header:kt,name:"yms.integracao.erpagrox"}),p.CircuitoFinalizado({header:kt,name:"yms.integracao.erpagrox"})],e)}(),Mt=function(e){function i(a){var i=e.call(this)||this;return i.integrationService=a,i.ngUnsubscribe=new t.Subject,i}return P(i,e),i.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete()},i.prototype.ngOnInit=function(){var e=this;this.integrationService.getProcessConfigurationErp(this.agenda.tipoAgendamento.id).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.tipoProcessoErpAtual=t.id})},V([r.Input(),B("design:type",Object)],i.prototype,"agenda",void 0),i=V([r.Component({template:'\n <div *ngIf="agenda">\n <div [ngSwitch]="tipoProcessoErpAtual">\n <recebimento-info *ngSwitchCase="\'RECEBIMENTO_CONTRATO\'" [agenda]="agenda"></recebimento-info>\n <expedicao-info *ngSwitchCase="\'EXPEDICAO\'" [agenda]="agenda"></expedicao-info>\n <devolucao-info *ngSwitchCase="\'DEVOLUCAO\'" [agenda]="agenda"></devolucao-info> \n <recebimento-ordem-compra-info *ngSwitchCase="\'RECEBIMENTO_ORDEM_COMPRA\'" [agenda]="agenda"></recebimento-ordem-compra-info>\n <processo-avulso-info *ngSwitchCase="\'PROCESSO_AVULSO\'" [agenda]="agenda"></processo-avulso-info>\n </div>\n </div>\n '}),B("design:paramtypes",[Dt])],i)}(It),Rt=function(){function e(e,t){this.messageService=e,this.translate=t}return e.prototype.verificaSeNotaFiscalEstaDuplicada=function(e,t,a){if(""==e)return!1;var i=a.filter(function(t){return t.id==e});return void 0!==t&&i.length<=0&&(t=t.value).length>0&&(i=t.filter(function(t){return!(t.notas.length<=0)&&t.notas.filter(function(t){return t.chaveNotaFiscal==e}).length>0})),i.length>0&&(this.messageService.add({severity:"error",summary:this.translate.instant("yms.integration.titulo_nota_fical_ja_exite"),detail:this.translate.instant("yms.integration.conteudo_nota_fical_ja_exite")}),!0)},e.prototype.findDuplicateFornecedores=function(e){var t,a=e.documentos.map(function(e){return e.numero});return(t=a,t.filter(function(e,t){return a.indexOf(e)!==t})).length>0?e.documentos.map(function(e){return e.fornecedor.codigo}).join(" "):null},e=V([r.Injectable(),B("design:paramtypes",[T.MessageService,o.TranslateService])],e)}(),At=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/ordemCompra",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r.environment=i,r}return P(t,e),t.prototype.listOrdensCompra=function(e){return this.http.post(this.environment.project.domain+"/"+this.environment.project.service+"/queries/pesquisarOrdensCompra",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),Et=_,Gt=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&Et(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Et(a.lastModifiedDate).toDate();return a.label=Ee(a,["codigo","nome","fantasia"]," - "),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Et(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Et(a.lastModifiedDate).format(),delete a.label,a},e}(),Nt=_,Ot=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&Nt(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Nt(a.lastModifiedDate).toDate();return a.label=Ee(a,["codigo","nome","cpfCnpj"]," - "),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Nt(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Nt(a.lastModifiedDate).format(),delete a.label,a},e}(),Lt=_,qt=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&Lt(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Lt(a.lastModifiedDate).toDate();return a.label=["id","pessoa.codigo","pessoa.nome","pessoa.site","pessoa.situacao","pessoa.cliente","pessoa.fornecedor","pessoa.representante","cnpj","nomeFantasia","inscricaoEstadual","inscricaoMunicipal","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Pessoa"!==t&&a.pessoa&&(a.pessoa=Ot.fromDto(a.pessoa,"PessoaJuridica")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Lt(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Lt(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.pessoa&&(a.pessoa=Ot.toDto(a.pessoa,"PessoaJuridica")),a},e}(),xt=_,wt=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&xt(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&xt(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&xt(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&xt(a.lastModifiedDate).format(),delete a.label,a},e}(),Pt=_,jt=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&Pt(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Pt(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","abreviatura","pais.id","pais.codigo","pais.descricao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Pais"!==t&&a.pais&&(a.pais=wt.fromDto(a.pais,"Estado")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Pt(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Pt(a.lastModifiedDate).format(),delete a.label,"Pais"!==t&&a.pais&&(a.pais=wt.toDto(a.pais,"Estado")),a},e}(),Vt=_,Ut=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&Vt(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Vt(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","estado.id","estado.codigo","estado.descricao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Estado"!==t&&a.estado&&(a.estado=jt.fromDto(a.estado,"Cidade")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Vt(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Vt(a.lastModifiedDate).format(),delete a.label,"Estado"!==t&&a.estado&&(a.estado=jt.toDto(a.estado,"Cidade")),a},e}(),Bt=_,zt=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&Bt(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Bt(a.lastModifiedDate).toDate();return a.label=Ee(a,["codigo","endereco"]," - "),"Pessoa"!==t&&a.pessoa&&(a.pessoa=Ot.fromDto(a.pessoa,"PessoaEndereco")),"Cidade"!==t&&a.cidade&&(a.cidade=Ut.fromDto(a.cidade,"PessoaEndereco")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Bt(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Bt(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.pessoa&&(a.pessoa=Ot.toDto(a.pessoa,"PessoaEndereco")),"Cidade"!==t&&a.cidade&&(a.cidade=Ut.toDto(a.cidade,"PessoaEndereco")),a},e}(),$t=_,Ht=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&$t(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&$t(a.lastModifiedDate).toDate();return a.label=Ee(a,["codigo","nome","empresa.nome"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Gt.fromDto(a.empresa,"Filial")),"PessoaJuridica"!==t&&a.pessoaJuridica&&(a.pessoaJuridica=qt.fromDto(a.pessoaJuridica,"Filial")),"PessoaEndereco"!==t&&a.endereco&&(a.endereco=zt.fromDto(a.endereco,"Filial")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&$t(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&$t(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Gt.toDto(a.empresa,"Filial")),"PessoaJuridica"!==t&&a.pessoaJuridica&&(a.pessoaJuridica=qt.toDto(a.pessoaJuridica,"Filial")),"PessoaEndereco"!==t&&a.endereco&&(a.endereco=zt.toDto(a.endereco,"Filial")),a},e}(),Yt=_,Qt=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&Yt(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Yt(a.lastModifiedDate).toDate();return a.label=Ee(a,["codigo","descricao","tipo"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Gt.fromDto(a.empresa,"Produto")),"Filial"!==t&&a.filial&&(a.filial=Ht.fromDto(a.filial,"Produto")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Yt(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Yt(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Gt.toDto(a.empresa,"Produto")),"Filial"!==t&&a.filial&&(a.filial=Ht.toDto(a.filial,"Produto")),a},e}(),Kt=_,Jt=function(){function e(e,a,i,r,o,n){this.dialogRef=e,this.dialogConfig=a,this.ordemCompraService=i,this.translate=r,this.fb=o,this.route=n,this.ordemCompraLookupDisplayFields=["codigo","empresa.nome"],this.ordemCompraAdvancedDisplayFields=["id","codigo","empresa.nome","filial.nome","pessoa.nome"],this.ordemCompraLookupSeparator=" - ",this.permissions={},this.ngUnsubscribe=new t.Subject}return e.prototype.ngOnInit=function(){var e=this,t=this.dialogConfig.data;this.agenda=t.agenda,this.filial=t.filial,this.fornecedor=t.fornecedor,this.ordensCompra=t.ordens.map(function(e){var t=e.ordemCompra;return t?t.id:undefined}).filter(function(e){return!!e}),this.formGroup=this.getForm(),this.ordemCompraSearchFields=this.getOrdemCompraFields(),this.ordemCompraSearchGridFields=this.getOrdemCompraGridFields(),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)})},e.prototype.onRouteDataChange=function(e){this.permissions=e.allPermissions.agenda},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete()},e.prototype.onOrdemCompraLookupRequest=function(e){var t=this,a=this.ordemCompraLookupDisplayFields.map(function(e){return{field:e,order:"Asc"}})[0],i={numero:+e.replace(/\D/g,"")},r=this.filial;r&&r.empresa&&r.empresa.id&&(i.empresaId=r.empresa.id),this.ordemCompraService.listOrdensCompra(j({},i,{pessoaId:(this.fornecedor||{id:undefined}).id,filialId:(r||{id:undefined}).id,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,ordensCompraSelecionados:this.ordensCompra,pagina:{limit:30,offset:0,listaOrdenacao:[{campo:a.field,ordenacao:a.order}]}})).subscribe(function(e){t.ordemCompraLookupSuggestions=e.contents.map(Qt.fromDto)})},e.prototype.onOrdemCompraSearchRequest=function(e){var t=this,a=e.first,i=e.rows,r=e.multiSortMeta,o=e.filterData,n=a/i,s=this.getOrdemCompraFields().filter(function(e){var t=e.name;return o[t]!=undefined&&""!=o[t]}).reduce(function(e,t){var a;return j({},e,((a={})[t.name]=o[t.name],a))},{}),l=this.filial;l&&l.empresa&&l.empresa.id&&(s.empresaId=l.empresa.id),s.dataEmissao=s.dataEmissao&&Kt(s.dataEmissao).format("YYYY-MM-DD");var d=(r||[]).length?{field:r[0].field,order:1===r[0].order?"Asc":"Desc"}:{field:"numero",order:"Asc"};this.ordemCompraService.listOrdensCompra(j({},s,{pessoaId:(this.fornecedor||{id:undefined}).id,filialId:(l||{id:undefined}).id,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,ordensCompraSelecionados:this.ordensCompra,pagina:{limit:i,offset:n,listaOrdenacao:[{campo:d.field,ordenacao:d.order}]}})).subscribe(function(e){t.ordemCompraSearchGridData=e.contents.map(Qt.fromDto),t.ordemCompraSearchTotalRecords=e.totalElements})},e.prototype.getRecPagina=function(e,t,a){return{offset:e/t,limit:t,listaOrdenacao:a&&a.length?a.map(function(e){return{campo:e.field,ordenacao:1===e.order?"Asc":"Desc"}}):[]}},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup?t.validateAllFormFields(i):i instanceof C.FormArray&&i.controls.forEach(function(e){return t.validateAllFormFields(e)})})},e.prototype.save=function(){if(!this.formGroup.valid)return this.validateAllFormFields(this.formGroup);this.close(this.formGroup.get("ordemCompra").value)},e.prototype.close=function(e){this.dialogRef.close(e)},e.prototype.getForm=function(){return this.fb.group({ordemCompra:[undefined,C.Validators.required]})},e.prototype.getOrdemCompraFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.ordem_compra_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")}),new n.FormField({name:"filial.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial")})]},e.prototype.getOrdemCompraGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.ordem_compra_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")}),new n.FormField({name:"filial.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_nome")})]},e=V([r.Component({template:'<form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-g-12 ui-md-6">\n <label for="ordemCompra">Ordem Compra</label>\n <s-lookup dataKey="id" name="ordemCompra"\n formControlName="ordemCompra" [searchFields]="ordemCompraSearchFields"\n [searchGridFields]="ordemCompraSearchGridFields"\n [searchGridData]="ordemCompraSearchGridData" [multiple]="false"\n [lookupSuggestions]="ordemCompraLookupSuggestions"\n (onLookupRequest)="onOrdemCompraLookupRequest($event)"\n (onSearchRequest)="onOrdemCompraSearchRequest($event)"\n lookupDisplayField="label" [searchTotalRecords]="ordemCompraSearchTotalRecords"\n [searchTitle]="\'yms.erp.recebimento_ordem_compra_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: ordemCompraSearchTotalRecords}">\n </s-lookup>\n </div>\n </div>\n \n <div style="margin-top: 10px;">\n <div class="separator"></div>\n <s-button style="float: right;" [label]="\'save\' | translate" priority="primary" (onClick)="save()"\n [disabled]="!permissions.editar"></s-button>\n <s-button style="float: right;" [label]="\'cancel\' | translate" priority="link" (onClick)="close()"></s-button>\n </div>\n</form>'}),B("design:paramtypes",[c.DynamicDialogRef,c.DynamicDialogConfig,At,o.TranslateService,C.FormBuilder,F.ActivatedRoute])],e)}(),Xt=function(){function e(e,t,a){this.http=t,this.messageService=a,this.baseUrl=e.project.domain+"/"+e.project.service}return e.prototype.pesquisarDocumento=function(e){return this.http.post(this.baseUrl+"/queries/pesquisarDocumento",e).pipe(this.defaultCatch())},e.prototype.pesquisarDocumentoValidaNotaEmUso=function(e){return this.http.post(this.baseUrl+"/queries/pesquisarDocumentoValidaNotaEmUso",e).pipe(this.defaultCatch())},e.prototype.pesquisarDocumentoGenerico=function(e){return this.http.post("yms/integration/queries/pesquisarDocumentoGenerico",e).pipe(this.defaultCatch())},e.prototype.executarAuditoria=function(e){return this.http.post(this.baseUrl+"/actions/executarAuditoria",e).pipe(this.defaultCatch())},e.prototype.defaultCatch=function(){var e=this;return a.catchError(function(a){if(a){var i=a.status?String(a.status):"Error",r=a.error&&a.error.message||a.statusText||a.message||"Error";e.messageService.add({severity:"error",summary:i,detail:r})}return t.throwError(a)})},e=V([r.Injectable(),U(0,r.Inject(gt)),B("design:paramtypes",[Object,d.HttpClient,c.MessageService])],e)}(),Wt=function(){function e(e,a,i,r,o,n,s,l){var d=this;this.notaValidatorService=a,this.dialogConfig=i,this.confirmationService=r,this.dialogRef=o,this.verificaNotaFiscal=n,this.messageService=s,this.translate=l,this.loading=!1,this.botaoDesabilitado=!1,this.unsubscribe$=new t.Subject,this.validateNotaFiscal=function(e){if(e&&e.documentos[0]){var t=e.documentos[0];if(d.validaProdutoNaNotaFiscal(t.itens)){var a={chave:d.formGroup.get("chaveNotaFiscal").value,serie:t.serie,serieLegal:t.serieLegal,numero:t.numero};d.fornecedor?(t.fornecedor||{id:undefined}).id&&t.fornecedor.id!==d.fornecedor.id?d.confirmAndAddNovoFornecedor(a,t.fornecedor,t.origemMercadoria):(d.formGroup.get("serieNotaFiscal").setValue(t.serie),d.formGroup.get("serieLegalNotaFiscal").setValue(t.serieLegal),d.formGroup.get("numeroNotaFiscal").setValue(t.numero),d.desabilitaCamposNotaFiscal()):d.closeAndReturnNota(a,t.fornecedor,t.origemMercadoria)}}},this.camposPreenchidosValidation=function(e){var t=e.get("chaveNotaFiscal").value,a=e.get("serieNotaFiscal").value,i=e.get("numeroNotaFiscal").value;return t||a||i?null:{erroMultiplosCampos:!0}},this.formGroup=e.group({chaveNotaFiscal:[undefined],serieNotaFiscal:[undefined],serieLegalNotaFiscal:[undefined],numeroNotaFiscal:[undefined]},{validators:this.camposPreenchidosValidation})}return e.prototype.ngOnInit=function(){this.filialId=this.dialogConfig.data.filial.id,this.fornecedor=this.dialogConfig.data.fornecedor,this.produto=this.dialogConfig.data.produto,this.fornecedorNotasTokens=this.dialogConfig.data.fornecedorNotasTokens,this.contratos=this.dialogConfig.data.contratos},e.prototype.ngOnDestroy=function(){this.unsubscribe$.next(),this.unsubscribe$.complete()},e.prototype.save=function(){var e=this.formGroup.get("chaveNotaFiscal").value;if(!this.verificaNotaFiscal.verificaSeNotaFiscalEstaDuplicada(e,this.contratos,this.fornecedorNotasTokens)){if(e||this.removeErrorChaveNota(),!this.formGroup.valid)return this.validateAllFormFields(this.formGroup);this.habilitaCamposNotaFiscal(),this.close(this.formGroup.value)}},e.prototype.close=function(e){this.dialogRef.close(e)},e.prototype.onBlurNotaFiscal=function(){var e=this,t=this.formGroup.get("chaveNotaFiscal").value;this.verificaNotaFiscal.verificaSeNotaFiscalEstaDuplicada(t,this.contratos,this.fornecedorNotasTokens)?this.botaoDesabilitado=!0:(this.removeErrorChaveNota(),this.loading=!0,this.notaValidatorService.pesquisarDocumentoValidaNotaEmUso({chaveDocumento:(t||"").trim(),filialId:this.filialId}).pipe(a.takeUntil(this.unsubscribe$),a.finalize(function(){return e.loading=!1})).subscribe(this.validateNotaFiscal),this.botaoDesabilitado=!1)},e.prototype.validaProdutoNaNotaFiscal=function(e){if(null!=e&&e.length>0){var t=e[0].produto;if(t&&this.produto&&t.id!==this.produto.id)return this.addErrorIfProdutoIsDifferent(),!1}return!0},e.prototype.confirmAndAddNovoFornecedor=function(e,t,a){var i=this;this.confirmationService.confirm({header:"O fornecedor vinculado a nota não é o mesmo que o selecionado",message:"O fornecedor vinculado a nota não é o mesmo que o selecionado. Deseja adicionar um novo fornecedor ou cancelar a operação?",acceptLabel:"Adicionar um novo fornecedor",rejectLabel:"Cancelar operação",accept:function(){return i.closeAndReturnNota(e,t,a)},reject:function(){return i.formGroup.get("chaveNotaFiscal").setValue(undefined)}})},e.prototype.addErrorIfProdutoIsDifferent=function(){this.formGroup.get("chaveNotaFiscal").setErrors({errorChaveNota:!0})},e.prototype.removeErrorChaveNota=function(){this.formGroup.get("chaveNotaFiscal").setErrors(null)},e.prototype.closeAndReturnNota=function(e,t,a){this.dialogRef.close({addFornecedor:!0,infoNota:e,fornecedor:t,origemMercadoria:a})},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup&&t.validateAllFormFields(i)}),e.markAsDirty({onlySelf:!0})},e.prototype.habilitaCamposNotaFiscal=function(){this.formGroup.get("serieNotaFiscal").enable(),this.formGroup.get("serieLegalNotaFiscal").enable(),this.formGroup.get("numeroNotaFiscal").enable()},e.prototype.desabilitaCamposNotaFiscal=function(){this.formGroup.get("serieNotaFiscal").disable(),this.formGroup.get("serieLegalNotaFiscal").disable(),this.formGroup.get("numeroNotaFiscal").disable()},e=V([r.Component({template:'<form [formGroup]="formGroup">\n <div class="ui-g ui-fluid" *sLoadingState="loading">\n <div class="ui-g-12">\n <label for="chaveNotaFiscal">{{\'yms.erp.recebimento_chave_nota_fiscal\' | translate}}</label>\n <input pInputText type="text" formControlName="chaveNotaFiscal" (blur)="onBlurNotaFiscal()">\n <s-control-errors [control]="formGroup.controls.chaveNotaFiscal" [errorMessages]="{ errorChaveNota: \'yms.erp.produto_nota_error_detail\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12">\n <label for="serieNotaFiscal">{{\'yms.erp.recebimento_serie_nota_fiscal\' | translate}}</label>\n <input pInputText type="text" formControlName="serieNotaFiscal">\n </div>\n <div class="ui-g-12">\n <label for="serieLegalNotaFiscal">{{\'yms.erp.recebimento_serie_legal_nota_fiscal\' | translate}}</label>\n <input pInputText type="text" formControlName="serieLegalNotaFiscal">\n </div>\n <div class="ui-g-12">\n <label for="numeroNotaFiscal">{{\'yms.erp.recebimento_numero_nota_fiscal\' | translate}}</label>\n <input pInputText type="text" formControlName="numeroNotaFiscal">\n </div>\n </div>\n\n <s-control-errors [control]="formGroup" [errorMessages]="{ erroMultiplosCampos: \'yms.erp.nota_fiscal_no_value\' | translate }"></s-control-errors>\n\n <s-button label="Cancelar" (onClick)="close()" priority="link"></s-button>\n <s-button label="Salvar" [disabled]="botaoDesabilitado" (onClick)="save()"></s-button>\n</form>\n\n<p-confirmDialog appendTo="body"></p-confirmDialog>',providers:[c.ConfirmationService]}),B("design:paramtypes",[C.FormBuilder,Xt,c.DynamicDialogConfig,c.ConfirmationService,c.DynamicDialogRef,Rt,T.MessageService,o.TranslateService])],e)}(),Zt=function(){function e(){}return e=V([r.NgModule({imports:[i.CommonModule,C.ReactiveFormsModule,v.DynamicDialogModule,D.InputTextModule,n.ButtonModule,n.ControlErrorsModule,o.TranslateModule,n.LoadingStateModule,A.ConfirmDialogModule],declarations:[Wt],entryComponents:[Wt]})],e)}(),ea=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"agenda",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/agenda/entities/agenda"}])],providers:[vt],declarations:[],exports:[]})],e)}(),ta=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/cidade",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),aa=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"cidade",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/cidade"}])],providers:[ta],declarations:[],exports:[]})],e)}(),ia=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/contratoCompraItem",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r.environment=i,r}return P(t,e),t.prototype.pesquisarItensContratoCompra=function(e){return this.http.post(this.environment.project.domain+"/"+this.environment.project.service+"/queries/pesquisarItensContratoCompra",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),ra=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"contratoCompraItem",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/contratoCompraItem"}])],providers:[ia],declarations:[],exports:[]})],e)}(),oa=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/contratoCompra",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r.environment=i,r}return P(t,e),t.prototype.listContratosCompra=function(e){return this.http.post(this.environment.project.domain+"/"+this.environment.project.service+"/queries/pesquisarContratosCompra",e).pipe(this.defaultCatch())},t.prototype.getItens=function(e,t){return this.http.get(this.entityUrl+"/"+e+"/itens/"+t).pipe(this.defaultCatch())},t.prototype.updateItens=function(e,t,a){return this.http.put(this.entityUrl+"/"+e+"/itens/"+t,a).pipe(this.defaultCatch())},t.prototype.listItens=function(e,t){return this.http.get(this.entityUrl+"/"+e+"/itens",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t.prototype.insertItens=function(e,t){return this.http.post(this.entityUrl+"/"+e+"/itens",t).pipe(this.defaultCatch())},t.prototype.deleteItens=function(e,t){return this.http["delete"](this.entityUrl+"/"+e+"/itens/"+t).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),na=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"contratoCompra",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/contratoCompra"}])],providers:[oa],declarations:[],exports:[]})],e)}(),sa=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/derivacao",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),la=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"derivacao",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/derivacao"}])],providers:[sa],declarations:[],exports:[]})],e)}(),da=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/empresa",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),ca=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"empresa",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/empresa"}])],providers:[da],declarations:[],exports:[]})],e)}(),pa=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/estado",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),ua=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"estado",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/estado"}])],providers:[pa],declarations:[],exports:[]})],e)}(),ma=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/familiaProduto",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),fa=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"familiaProduto",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/familiaProduto"}])],providers:[ma],declarations:[],exports:[]})],e)}(),ha=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/filial",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r.baseUrl=i.project.domain+"/"+i.project.service+"/",r}return P(t,e),t.prototype.listFiliais=function(e){return this.http.post(this.baseUrl+"queries/pesquisarFiliais",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),ga=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"filial",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/filial"}])],providers:[ha],declarations:[],exports:[]})],e)}(),va=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/pais",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),ya=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"pais",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/pais"}])],providers:[va],declarations:[],exports:[]})],e)}(),ba=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/pedidoVendaItem",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r.queriesUrl=i.project.domain+"/"+i.project.service+"/queries",r}return P(t,e),t.prototype.pesquisarItensPedidoVenda=function(e){return this.http.post(this.queriesUrl+"/pesquisarItensPedidoVenda",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),Fa=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"pedidoVendaItem",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/pedidoVendaItem"}])],providers:[ba],declarations:[],exports:[]})],e)}(),Sa=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/pedidoVenda",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r.queriesUrl=i.project.domain+"/"+i.project.service+"/queries",r}return P(t,e),t.prototype.getItens=function(e,t){return this.http.get(this.entityUrl+"/"+e+"/itens/"+t).pipe(this.defaultCatch())},t.prototype.pesquisarPedidosVenda=function(e){return this.http.post(this.queriesUrl+"/pesquisarPedidosVenda",e).pipe(this.defaultCatch())},t.prototype.updateItens=function(e,t,a){return this.http.put(this.entityUrl+"/"+e+"/itens/"+t,a).pipe(this.defaultCatch())},t.prototype.listItens=function(e,t){return this.http.get(this.entityUrl+"/"+e+"/itens",{params:this.getListQueryParams(t)}).pipe(this.defaultCatch())},t.prototype.insertItens=function(e,t){return this.http.post(this.entityUrl+"/"+e+"/itens",t).pipe(this.defaultCatch())},t.prototype.deleteItens=function(e,t){return this.http["delete"](this.entityUrl+"/"+e+"/itens/"+t).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),Da=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"pedidoVenda",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/pedidoVenda"}])],providers:[Sa],declarations:[],exports:[]})],e)}(),Ca=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/pessoaEndereco",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),_a=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"pessoaEndereco",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/pessoaEndereco"}])],providers:[Ca],declarations:[],exports:[]})],e)}(),Ta=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/pessoaFisica",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),ka=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"pessoaFisica",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/pessoaFisica"}])],providers:[Ta],declarations:[],exports:[]})],e)}(),Ia=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/pessoaJuridica",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),Ma=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"pessoaJuridica",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/pessoaJuridica"}])],providers:[Ia],declarations:[],exports:[]})],e)}(),Ra=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/pessoa",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),Aa=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"pessoa",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/pessoa"}])],providers:[Ra],declarations:[],exports:[]})],e)}(),Ea=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/produto",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r.environment=i,r}return P(t,e),t.prototype.listProdutosRecebimento=function(e){return this.http.post(this.environment.project.domain+"/"+this.environment.project.service+"/queries/pesquisarProdutoRecebimento",e).pipe(this.defaultCatch())},t.prototype.listProdutos=function(e){return this.http.post(this.environment.project.domain+"/"+this.environment.project.service+"/queries/pesquisarProduto",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),Ga=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"produto",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/produto"}])],providers:[Ea],declarations:[],exports:[]})],e)}(),Na=function(){function e(){this.messageSource=new t.BehaviorSubject({id:null,change:!1}),this.current=this.messageSource.asObservable()}return e.prototype.hasChange=function(e){var t={id:e,change:!0};this.messageSource.next(t)},e.prototype.hasChangeSave=function(e){var t={id:e,change:!1};this.messageSource.next(t)},Object.defineProperty(e.prototype,"change",{get:function(){return this.messageSource.value},enumerable:!0,configurable:!0}),e=V([r.Injectable(),B("design:paramtypes",[])],e)}(),Oa=function(){return function(){}}(),La=function(){function e(){this.messageSource=new t.BehaviorSubject(undefined),this.current=this.messageSource.asObservable()}return e.prototype.changeData=function(e){return this.messageSource.next(e),e},e.prototype.getProcessData=function(){return this.messageSource.value},e.prototype.changeDataErp=function(e){var t=this.messageSource.value?this.messageSource.value:e;return t.filialId=e.filialId,t.chaveIntegracao=e.chaveIntegracao,t.produtoId=e.produtoId,t.transgeniaId=e.transgeniaId,t.transportadoraId=e.transportadoraId,this.changeData(t)},e.prototype.changeDataVeiculo=function(e,t){var a=this.messageSource.value?this.messageSource.value:new Oa;return a.veiculoId=e,a.eixos=t,this.changeData(a)},e.prototype.changeDataMotorista=function(e){var t=this.messageSource.value?this.messageSource.value:new Oa;return t.motoristaId=e,this.changeData(t)},e.prototype.changeDataAgenda=function(e,t,a,i){var r=this.messageSource.value?this.messageSource.value:new Oa;return r.agendaId=e,r.motoristaId=t,r.veiculoId=a,r.eixos=i,this.changeData(r)},e.prototype.builderErpProcessData=function(e,t){return e.chaveIntegracao=null!=t.get("chaveNotaFiscal")?t.get("chaveNotaFiscal").value:null,e.filialId=this.getFieldFormGroup(t,"filial"),e.produtoId=this.getFieldFormGroup(t,"produto"),e.transgeniaId=this.getFieldFormGroup(t,"transgenia"),e.transportadoraId=this.getFieldFormGroup(t,"transportadora"),e.fornecedores=this.listarIdsFornecedores(t.getRawValue().fornecedores),e},e.prototype.builderErpProcessDataValidaNotaNoContrato=function(e,t){return(e=this.builderErpProcessData(e,t)).recebimentoTemNota=this.verificaSeTemNotaNoContratoNoFornecedo(t.getRawValue().fornecedores),e},e.prototype.verificaSeTemNotaNoContratoNoFornecedo=function(e){var t=this,a=!1,i=[];null!=e&&e.filter(function(e){return null!=e.contratos&&e.contratos!=undefined}).forEach(function(e){return i.push(e.contratos)});var r=[];return null!=i&&i.filter(function(e){return null!=e&&e!=undefined}).forEach(function(e){return r.push(a=t.verificaSeContratosTemNota(e))}),a},e.prototype.verificaSeContratosTemNota=function(e){var t=!0;return e.filter(function(e){return null!=e&&e!=undefined}).forEach(function(e){return t=t&&e.notas.length>0}),t},e.prototype.builderErpProcessDataValidaNotaNaOrdemCompra=function(e,t){return(e=this.builderErpProcessData(e,t)).recebimentoTemNota=this.verificaSeTemNotaNaOrdemCompraDoFornecedo(t.getRawValue().fornecedores),e},e.prototype.verificaSeTemNotaNaOrdemCompraDoFornecedo=function(e){var t=this,a=!1,i=[];null!=e&&e.filter(function(e){return null!=e.ordens&&e.ordens!=undefined}).forEach(function(e){return i.push(e.ordens)});var r=[];return null!=i&&i.filter(function(e){return null!=e&&e!=undefined}).forEach(function(e){return r.push(a=t.verificaSeOrdemCompraTemNota(e))}),a},e.prototype.verificaSeOrdemCompraTemNota=function(e){var t=!0;return e.filter(function(e){return null!=e&&e!=undefined}).forEach(function(e){return t=t&&e.notas.length>0}),t},e.prototype.getFieldFormGroup=function(e,t){return null==e.get(t)||null==e.get(t).value?null:e.get(t).value.id},e.prototype.listarIdsFornecedores=function(e){var t=[];return null!=e&&e.filter(function(e){return null!=e.fornecedor&&e.fornecedor!=undefined}).forEach(function(e){return t.push(e.fornecedor)}),t.map(function(e){return e.id})},e=V([r.Injectable(),B("design:paramtypes",[])],e)}(),qa=function(){function e(){this.messageSource=new t.BehaviorSubject(!1),this.current=this.messageSource.asObservable()}return e.prototype.enableRevalidation=function(){this.messageSource.next(!0)},Object.defineProperty(e.prototype,"enable",{get:function(){return this.messageSource.value},enumerable:!0,configurable:!0}),e=V([r.Injectable(),B("design:paramtypes",[])],e)}(),xa=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"recebimentoContrato",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/recebimentoContrato"},{name:"agenda",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/agenda/entities/agenda"}])],providers:[yt,La,qa,Na],declarations:[],exports:[]})],e)}(),wa=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/royalty",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),Pa=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"royalty",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/royalty"}])],providers:[wa],declarations:[],exports:[]})],e)}(),ja=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/safra",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),Va=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"safra",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/safra"}])],providers:[ja],declarations:[],exports:[]})],e)}(),Ua=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/transportadora",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),Ba=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"transportadora",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/transportadora"}])],providers:[Ua],declarations:[],exports:[]})],e)}(),za=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/unidadeMedida",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),$a=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"unidadeMedida",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/unidadeMedida"}])],providers:[za],declarations:[],exports:[]})],e)}(),Ha=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"expedicao",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/expedicao"}])],providers:[Ft]})],e)}(),Ya=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/devolucao",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r._baseUrl=i.project.domain+"/"+i.project.service,r}return P(t,e),t.prototype.registrarChegadaVeiculoComDevolucao=function(e){return this.http.post(this._baseUrl+"/actions/registrarChegadaDeVeiculoComDevolucao",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),Qa=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"devolucao",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/devolucao"}])],providers:[Ya,La,qa],declarations:[],exports:[]})],e)}(),Ka=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"ordemCompra",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/ordem-compra"},{name:"agenda",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/agenda/entities/agenda"}])],providers:[At],declarations:[],exports:[]})],e)}(),Ja=function(){function e(e){this.translate=e}return e.prototype.buildForString=function(e,t){return this.build(e,t,n.FieldType.String)},e.prototype.buildForInteger=function(e,t){return this.build(e,t,n.FieldType.Integer)},e.prototype.build=function(e,t,a){return new n.FormField({label:this.translate.instant(t),name:e,type:a})},e=V([r.Injectable(),B("design:paramtypes",[o.TranslateService])],e)}(),Xa=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/recebimentoOrdemCompra",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r._baseUrl=i.project.domain+"/"+i.project.service,r}return P(t,e),t.prototype.registrarChegadaVeiculoRecebimentoOrdemCompra=function(e){return this.http.post(this._baseUrl+"/actions/registrarChegadaDeVeiculoComRecebimentoOrdemCompra",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),Wa=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"recebimentoOrdemCompra",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/recebimentoOrdemCompra"},{name:"agenda",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/agenda/entities/agenda"}])],providers:[Xa,La,qa,Ja],declarations:[],exports:[]})],e)}(),Za=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/transgenia",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,c.MessageService,Object])],t)}(ht),ei=function(){function e(){}return e=V([r.NgModule({providers:[Za]})],e)}(),ti=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/"+i.project.service+"/entities/processoAvulso",i.project.domain+"/"+i.project.service+"/actions")||this;return r.http=t,r.messageService=a,r}return P(t,e),t.prototype.registrarChegada=function(e){return this.http.post(this.actionsUrl+"/registrarChegadaDeVeiculoComProcessoAvulso",e).pipe(this.defaultCatch())},t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,c.MessageService,Object])],t)}(ht),ai=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"processoAvulso",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/processoAvulso"},{name:"agenda",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/agenda/entities/agenda"}])],providers:[ti,La,qa]})],e)}(),ii=function(e){function t(t,a,i){var r=e.call(this,t,a,i.project.domain+"/erp/entities/logIntegracao",i.project.domain+"/erp/actions")||this;return r.http=t,r.messageService=a,r.environment=i,r}return P(t,e),t=V([r.Injectable(),U(2,r.Inject(gt)),B("design:paramtypes",[d.HttpClient,T.MessageService,Object])],t)}(ht),ri=function(){function e(){}return e=V([r.NgModule({imports:[m.PermissionsModule.forChild([{name:"logIntegracao",actions:["Visualizar","Incluir","Editar","Excluir"],uri:"res://senior.com.br/yms/erp/entities/logIntegracao"}])],providers:[ii],declarations:[],exports:[]})],e)}(),oi=function(){function e(){}return e=V([r.NgModule({imports:[ca,Aa,ka,Ma,ya,ua,aa,_a,ga,Ba,Ga,$a,Pa,fa,Va,Da,Fa,na,ra,xa,ea,la,Ha,Qa,Ka,Wa,ei,m.PermissionsModule,ai,ri],providers:[Dt,Xt],exports:[]})],e)}(),ni=function(){function e(e,t,a){this.override=e,this.agendaService=t,this.devolucaoService=a,this.DEVOLUCAO_KEY="ERP_SENIOR_DEVOLUCAO"}return e.prototype.initialize=function(){var e=this;this.override.addOverride(this.DEVOLUCAO_KEY,function(t){return e.functionToOverride(t)})},e.prototype.remove=function(){this.override.disposeOverride(this.DEVOLUCAO_KEY)},e.prototype.functionToOverride=function(e){var i=this;return this.agendaService.atualizarAgenda(e.agenda).pipe(a.mergeMap(function(t){return i.devolucaoService.list({filterQuery:"agenda.id eq '"+e.agenda.id+"'",page:0,size:1})}),a.map(function(e){var t=e.contents;return t.length?t[0]:null}),a.mergeMap(function(a){return a?i.devolucaoService.registrarChegadaVeiculoComDevolucao({devolucao:a,circuito:e.circuito.id,sequenciaInicial:e.sequencia.id,vagaInicial:(e.vaga||{}).id}):t.throwError("Não foi possível encontrar os dados de devolução")}))},e=V([r.Injectable(),B("design:paramtypes",[p.ChegadaVeiculoOverride,vt,Ya])],e)}(),si=_,li=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&si(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&si(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","quantidadeDecimais","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&si(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&si(a.lastModifiedDate).format(),delete a.label,a},e}(),di=_,ci=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&di(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&di(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Empresa"!==t&&a.empresa&&(a.empresa=Gt.fromDto(a.empresa,"Royalty")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&di(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&di(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Gt.toDto(a.empresa,"Royalty")),a},e}(),pi=_,ui=function(){function e(){}return e.fromDto=function(e,t){if(e.id===undefined)return e;var a=j({},e);a.createdDate=a.codigo&&pi(a.createdDate).toDate(),a.createdDate=a.createdDate&&pi(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&pi(a.lastModifiedDate).toDate();return a.label=["id","codigo","descricao","situacao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Empresa"!==t&&a.empresa&&(a.empresa=Gt.fromDto(a.empresa,"FamiliaProduto")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&pi(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&pi(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Gt.toDto(a.empresa,"FamiliaProduto")),a},e}(),mi=_,fi=function(){function e(){this.produtoMisto=!1,this.comprado=!1}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&mi(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&mi(a.lastModifiedDate).toDate();return a.label=Ee(a,["codigo","descricao"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Gt.fromDto(a.empresa,"Produto")),"UnidadeMedida"!==t&&a.unidadeMedida&&(a.unidadeMedida=li.fromDto(a.unidadeMedida,"Produto")),"UnidadeMedida"!==t&&a.unidadeMedidaAgroG5&&(a.unidadeMedidaAgroG5=li.fromDto(a.unidadeMedidaAgroG5,"Produto")),"Royalty"!==t&&a.royalty&&(a.royalty=ci.fromDto(a.royalty,"Produto")),"FamiliaProduto"!==t&&a.familia&&(a.familia=ui.fromDto(a.familia,"Produto")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&mi(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&mi(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Gt.toDto(a.empresa,"Produto")),"UnidadeMedida"!==t&&a.unidadeMedida&&(a.unidadeMedida=li.toDto(a.unidadeMedida,"Produto")),"UnidadeMedida"!==t&&a.unidadeMedidaAgroG5&&(a.unidadeMedidaAgroG5=li.toDto(a.unidadeMedidaAgroG5,"Produto")),"Royalty"!==t&&a.royalty&&(a.royalty=ci.toDto(a.royalty,"Produto")),"FamiliaProduto"!==t&&a.familia&&(a.familia=ui.toDto(a.familia,"Produto")),a},e}(),hi=_,gi=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&hi(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&hi(a.lastModifiedDate).toDate();return a.label=Ee(a,["codigo","descricao"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Gt.fromDto(a.empresa,"Derivacao")),"Produto"!==t&&a.produto&&(a.produto=fi.fromDto(a.produto,"Derivacao")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&hi(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&hi(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Gt.toDto(a.empresa,"Derivacao")),"Produto"!==t&&a.produto&&(a.produto=fi.toDto(a.produto,"Derivacao")),a},e}(),vi=_,yi=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&vi(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&vi(a.lastModifiedDate).toDate();return a.label=Ee(a,["codigo","pessoa.nome","pessoa.cpfCnpj"]," - "),"Pessoa"!==t&&a.pessoa&&(a.pessoa=Ot.fromDto(a.pessoa,"Transportadora")),"PessoaEndereco"!==t&&a.endereco&&(a.endereco=zt.fromDto(a.endereco,"Transportadora")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&vi(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&vi(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.pessoa&&(a.pessoa=Ot.toDto(a.pessoa,"Transportadora")),"PessoaEndereco"!==t&&a.endereco&&(a.endereco=zt.toDto(a.endereco,"Transportadora")),a},e}(),bi=_,Fi=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&bi(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&bi(a.lastModifiedDate).toDate();return a.label=[""].map(function(e){return a[e]}).join(" - "),"Pessoa"!==t&&a.fornecedor&&(a.fornecedor=Ot.fromDto(a.fornecedor,"Devolucao")),"Filial"!==t&&a.filial&&(a.filial=Ht.fromDto(a.filial,"Devolucao")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=yi.fromDto(a.transportadora,"Devolucao")),"Produto"!==t&&a.produto&&(a.produto=fi.fromDto(a.produto,"Devolucao")),"Agenda"!==t&&a.agenda&&(a.agenda=we.fromDto(a.agenda,"Devolucao")),"PessoaEndereco"!==t&&a.origemMercadoria&&(a.origemMercadoria=zt.fromDto(a.origemMercadoria,"Recebimento")),"Derivacao"!==t&&a.derivacao&&(a.derivacao=gi.fromDto(a.derivacao,"Devolucao")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&bi(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&bi(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.fornecedor&&(a.fornecedor=Ot.toDto(a.fornecedor,"Devolucao")),"Filial"!==t&&a.filial&&(a.filial=Ht.toDto(a.filial,"Devolucao")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=yi.toDto(a.transportadora,"Devolucao")),"Produto"!==t&&a.produto&&(a.produto=fi.toDto(a.produto,"Devolucao")),"Agenda"!==t&&a.agenda&&(a.agenda=we.toDto(a.agenda,"Devolucao")),"PessoaEndereco"!==t&&a.origemMercadoria&&(a.origemMercadoria=zt.toDto(a.origemMercadoria,"Devolucao")),a},e}();!function(e){e.AGUARDANDO_CONFIRMACAO="AGUARDANDO_CONFIRMACAO_SOLICITANTE",e.AGENDADO="AGENDADO",e.AGUARDANDO_CONFIRMACAO_SOLICITANTE="AGUARDANDO_CONFIRMACAO",e.REJEITADO_POR_VALIDACAO="REJEITADO_POR_VALIDACAO",e.CANCELADO="CANCELADO"}(dt||(dt={}));var Si,Di,Ci=function(){function e(e,a,i,r,o,n,s,l,d,c,p,u,m,f,h,g,v,y){this.fb=e,this.router=a,this.translate=i,this.filialService=r,this.pessoaService=o,this.produtoService=n,this.derivacaoService=s,this.origemMercadoriaService=l,this.transportadoraService=d,this.devolucaoService=c,this.messageService=p,this.route=u,this.override=m,this.confirmationService=f,this.agendaService=h,this.erpProcessService=g,this.erpFormConfigService=v,this.hasChangeService=y,this.filialLookupDisplayFields=["codigo","nome","empresa.nome"],this.filialAdvancedDisplayFields=["id","codigo","nome","empresa.nome"],this.filialLookupSeparator=" - ",this.fornecedorLookupDisplayFields=["codigo","nome"],this.fornecedorAdvancedDisplayFields=["id","codigo","nome"],this.fornecedorLookupSeparator=" - ",this.produtoLookupDisplayFields=["codigo","descricao"],this.produtoAdvancedDisplayFields=["id","codigo","descricao"],this.produtoLookupSeparator=" - ",this.derivacaoLookupDisplayFields=["codigo","descricao"],this.derivacaoAdvancedDisplayFields=["id","codigo","descricao"],this.derivacaoLookupSeparator=" - ",this.origemMercadoriaLookupDisplayFields=["codigo","endereco"],this.origemMercadoriaAdvancedDisplayFields=["id","codigo","endereco","numero"],this.origemMercadoriaLookupSeparator=" - ",this.transportadoraLookupDisplayFields=["codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraAdvancedDisplayFields=["id","codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraLookupSeparator=" - ",this.disableButtonSave=!1,this.totalEixosContratados=0,this.totalEixosComposicao=0,this.permissions={},this.ngUnsubscribe=new t.Subject,this.formGroup=this.getFormGroup()}return e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete(),this.override.remove()},e.prototype.ngAfterViewInit=function(){var e=this;this.override.initialize(),this.saveAndInitButton=document.getElementById("init"),this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)});(this.agenda&&!["AGUARDANDO_CONFIRMACAO_SOLICITANTE","AGENDADO","AGUARDANDO_CONFIRMACAO","REJEITADO_POR_VALIDACAO"].includes(this.agenda.status)||!this.permissions.editar)&&(this.formGroup.disable(),this.disableButtonSave=!0),this.createdByErpDisableForm()},e.prototype.ngOnInit=function(){var e=this;this.filialSearchFields=this.getFilialSearchFields(),this.filialSearchGridFields=this.getFilialSearchGridFields(),this.fornecedorSearchFields=this.getFornecedorSearchFields(),this.produtoSearchFields=this.getProdutoSearchFields(),this.derivacaoSearchFields=this.getDerivacaoSearchFields(),this.origemMercadoriaSearchFields=this.getOrigemMercadoriaSearchFields(),this.transportadoraSearchFields=this.getTransportadoraSearchFields(),this.transportadoraSearchGridFields=this.getTransportadoraSearchGridFields(),this.route.params.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.agenda;"new"!=a&&e.getDevolucao(a)}),this.getEmpresaFilial(),this.filialValueChanges();this.checkValuesChanges("produto","derivacao",this.derivacaoService,function(e){return"produto.id eq '"+e.id+"' and situacao eq 'ATIVO'"},["codigo","descricao"],10,!0,!0);this.checkValuesChanges("fornecedor","origemMercadoria",this.origemMercadoriaService,function(e){return"pessoa.id eq '"+e.id+"'"},["codigo","endereco"],10,!1,!0),this.agenda&&this.agenda.externalTenant&&this.setTransportadora(this.agenda.externalTenant.cnpj),this.totalEixosComposicao=this.agenda&&this.agenda.veiculo&&this.agenda.veiculo.eixos||0,this.erpProcessService.current.subscribe(function(t){return e.erpProcessData=t}),this.erpFormConfigService.current.subscribe(function(t){return e.enableRevalidation=t}),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)})},e.prototype.onRouteDataChange=function(e){this.permissions=e.allPermissions.agenda},e.prototype.createdByErpDisableForm=function(){this.agenda&&this.agenda.createdByErp&&(this.formGroup.get("filial").disable(),this.formGroup.get("fornecedor").disable(),this.formGroup.get("produto").disable(),this.formGroup.get("derivacao").disable(),this.formGroup.get("origemMercadoria").disable(),this.formGroup.get("transportadora").disable(),this.formGroup.get("contratos").disable())},e.prototype.getEmpresaFilial=function(){var e=this,t=this.agenda.planta||{cnpj:[]};1===t.cnpj.length&&this.filialService.list({page:0,size:1,filterQuery:"pessoa.cpfCnpj eq '"+t.cnpj[0]+"'",displayFields:["*","empresa.nome"]}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;1===a.length&&e.formGroup.get("filial").setValue(Ht.fromDto(a[0]))})},e.prototype.filialValueChanges=function(){var e=this;this.formGroup.get("filial").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){if(t)return e.formGroup.get("produto").enable();e.formGroup.get("produto").setValue(undefined),e.formGroup.get("produto").disable()})},e.prototype.checkValuesChanges=function(e,t,i,r,o,n,s,l){var d=this;void 0===n&&(n=1),this.formGroup.get(e).valueChanges.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return s&&d.formGroup.get(t).setValidators(e?C.Validators.required:C.Validators.nullValidator),l&&d.formGroup.get(t).setValue(null),!!e||(d.formGroup.get(t).setValue(undefined),d.formGroup.get(t).disable(),!1)}),a.mergeMap(function(e){var t=r(e);return i.list({filterQuery:t,page:0,size:n})})).subscribe(function(e){var a=e.contents;if(a.length){if(1===a.length){var i=a[0][o[0]]?a[0][o[0]].toString():"",r=a[0][o[1]]?a[0][o[1]].toString():"";r.trim()||i.trim()?a[0].label=i+" - "+r:a[0].label=d.translate.instant("yms.erp.derivacao_sem_descricao"),d.formGroup.get(t).setValue(a[0])}a.length>1?d.formGroup.get(t).enable():d.formGroup.get(t).disable()}else d.formGroup.get(t).enable()})},e.prototype.getDevolucao=function(e){var t=this;this.devolucaoService.list({filterQuery:"agenda.id eq '"+e+"'",size:1,page:0}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;if(a.length){t.totalEixosContratados=a[0].eixos||0,t.totalEixosComposicao=a[0].agenda&&a[0].agenda.veiculo&&a[0].agenda.veiculo.eixos||0;var i=Fi.fromDto(a[0]);t.formGroup.enable(),t.formGroup.patchValue(i)}}),this.formCarregado=!0},e.prototype.onFilialLookupRequest=function(e){var t=this,i=this.getFilialSearchFields().filter(function(t){var a=t.type;return Te(a,e)}).reduce(function(t,a){var i,r,o=a.name;return a.type===n.FieldType.Integer?j({},t,((i={})[o]=e.replace(/\D/,""),i)):j({},t,((r={})[o]=e,r))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:10,offset:0}});this.filialService.listFiliais(i).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.filialLookupSuggestions=e.filiais.map(function(e){return Ht.fromDto(e)})})},e.prototype.onFilialSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getFilialSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}});this.filialService.listFiliais(p).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.filialSearchGridData=e.filiais.map(Ht.fromDto),t.filialSearchTotalRecords=e.qtdTotalRegistros})},e.prototype.onFornecedorLookupRequest=function(e){var t=this;Le(this.fornecedorSearchFields,this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields,this.fornecedorLookupSeparator,this.pessoaService,e," fornecedor eq true ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.fornecedorLookupSuggestions=e.contents})},e.prototype.onFornecedorSearchRequest=function(e){var t=this;qe(this.fornecedorSearchFields,this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields,this.fornecedorLookupSeparator,this.pessoaService,e," fornecedor eq true ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.fornecedorSearchGridData=e.contents,t.fornecedorSearchTotalRecords=e.totalElements})},e.prototype.onProdutoLookupRequest=function(e){var t=this,i=this.formGroup.get("filial").value,r=this.agenda.tipoAgendamento;this.produtoService.listProdutos({pesquisa:e,empresaId:i?i.empresa.id:null,filialId:i?i.id:null,tipoAgendamentoId:r?r.id:null,situacao:"ATIVO",pagina:{limit:100,offset:0}}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.produtoLookupSuggestions=e.produtos.map(fi.fromDto)})},e.prototype.onProdutoSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getProdutoSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}}),u=this.formGroup.get("filial").value,m=this.agenda.tipoAgendamento;this.produtoService.listProdutos(j({},p,{empresaId:u?u.empresa.id:null,filialId:u?u.id:null,situacao:"ATIVO",tipoAgendamentoId:m?m.id:null})).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.produtoSearchTotalRecords=e.qtdTotalRegistros,t.produtoSearchGridData=e.produtos.map(fi.fromDto)})},e.prototype.onDerivacaoLookupRequest=function(e){var t=this;Le(this.derivacaoSearchFields,this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields,this.derivacaoLookupSeparator,this.derivacaoService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.derivacaoLookupSuggestions=e.contents})},e.prototype.onDerivacaoSearchRequest=function(e){var t=this;qe(this.derivacaoSearchFields,this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields,this.derivacaoLookupSeparator,this.derivacaoService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.derivacaoSearchGridData=e.contents,t.derivacaoSearchTotalRecords=e.totalElements})},e.prototype.onOrigemMercadoriaLookupRequest=function(e){var t=this;Le(this.origemMercadoriaSearchFields,this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields,this.origemMercadoriaLookupSeparator,this.origemMercadoriaService,e," pessoa.id eq '"+this.formGroup.get("fornecedor").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.origemMercadoriaLookupSuggestions=e.contents})},e.prototype.onOrigemMercadoriaSearchRequest=function(e){var t=this;qe(this.origemMercadoriaSearchFields,this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields,this.origemMercadoriaLookupSeparator,this.origemMercadoriaService,e," pessoa.id eq '"+this.formGroup.get("fornecedor").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.origemMercadoriaSearchGridData=e.contents,t.origemMercadoriaSearchTotalRecords=e.totalElements})},e.prototype.onTransportadoraLookupRequest=function(e){var t=this;Le(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraLookupSuggestions=e.contents})},e.prototype.onTransportadoraSearchRequest=function(e){var t=this;qe(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraSearchGridData=e.contents,t.transportadoraSearchTotalRecords=e.totalElements})},e.prototype.setTransportadora=function(e){var t=this;if(e){var i="pessoa.cpfCnpj eq '"+e.replace(".","").replace("/","").replace("-","")+"'";this.transportadoraService.list({filterQuery:i,page:0,size:10}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;if(1===a.length){var i=a[0].codigo?a[0].codigo.toString():"",r=a[0].descricao?a[0].descricao.toString():"";r.trim()||i.trim()?a[0].label=i+" - "+r:a[0].label=t.translate.instant("yms.erp.derivacao_sem_descricao"),t.formGroup.get("transportadora").setValue(a[0])}})}},e.prototype.onSave=function(e){var t=this;return this.formGroup.get("agenda").setValue(this.agenda),this.formGroup.invalid&&this.validateAllFormFields(this.formGroup),this.loading=!0,this.isNew()||!this.enableRevalidation?this.saveAndInit(e):(this.erpProcessData=this.erpProcessService.builderErpProcessData(this.erpProcessData,this.formGroup),this.erpProcessService.changeDataErp(this.erpProcessData),this.agendaService.checarRevalidacao(this.erpProcessData).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){a.requerRevalidacao?t.atualizaAgendaParaRejeitadoPorValidacao():t.saveAndInit(e)}))},e.prototype.atualizaAgendaParaRejeitadoPorValidacao=function(){var e=this;this.confirmationService.confirm({header:this.translate.instant("yms.patio.agenda_revalidacao_title"),message:this.translate.instant("yms.patio.agenda_revalidacao_message"),accept:function(){e.hasChangeService.hasChangeSave(e.agenda.id),e.agenda.status=dt.REJEITADO_POR_VALIDACAO,e.agenda.motorista={id:e.erpProcessData.motoristaId},e.agenda.veiculo={id:e.erpProcessData.veiculoId},e.agendaService.atualizarAgenda(e.agenda).pipe(a.takeUntil(e.ngUnsubscribe),a.concatMap(function(t){return e.getSaveObservable()}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.successMessage(),e.router.navigate(["/chegada-veiculo"],{relativeTo:e.route})})},reject:function(){return e.loading=!1}})},e.prototype.saveAndInit=function(e){var t=this;this.getSaveObservable().pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){t.formGroup.get("id").setValue(a.id||null),t.successMessage(),e&&t.saveAndInitButton&&(t.hasChangeService.hasChangeSave(t.agenda.id),t.saveAndInitButton.click())})},e.prototype.successMessage=function(){this.messageService.add({severity:"success",summary:this.translate.instant("saved_message_title"),detail:this.translate.instant("saved_message_content")})},e.prototype.addMessage=function(e,t,a){this.messageService.add({severity:e,summary:this.translate.instant(t),detail:this.translate.instant(a)})},e.prototype.getSaveObservable=function(){var e=this.formGroup.getRawValue(),t=Fi.toDto(e);return this.isNew()&&!e.id?this.devolucaoService.insert(t):this.devolucaoService.update(this.formGroup.value.id,t)},e.prototype.isNew=function(){return!this.formGroup.value.id},e.prototype.getFormGroup=function(){return this.fb.group({id:[undefined],filial:[undefined,C.Validators.required],fornecedor:[undefined,C.Validators.required],produto:[{value:undefined,disabled:!0},C.Validators.required],derivacao:[{value:undefined,disabled:!0},C.Validators.required],origemMercadoria:[{value:undefined,disabled:!0},C.Validators.required],transportadora:[undefined],agenda:[undefined,C.Validators.required],chaveNotaFiscal:[undefined],numeroNotaFiscal:[undefined],serieNotaFiscal:[undefined],numeroNotaFiscalProdutor:[undefined],serieNotaFiscalProdutor:[undefined]})},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup&&t.validateAllFormFields(i)})},e.prototype.getFilialSearchFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")})]},e.prototype.getFilialSearchGridFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")})]},e.prototype.getFornecedorSearchFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_codigo")})]},e.prototype.getProdutoSearchFields=function(){return[new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.produto_descricao")}),new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.produto_codigo")})]},e.prototype.getDerivacaoSearchFields=function(){return[new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.derivacao_descricao")}),new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.derivacao_codigo")})]},e.prototype.getOrigemMercadoriaSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_endereco_codigo")}),new n.FormField({name:"numero",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_endereco_numero")}),new n.FormField({name:"endereco",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_endereco_endereco")})]},e.prototype.getTransportadoraSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_descricao")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getTransportadoraSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},V([r.Input(),B("design:type",we)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"devolucao-form",template:'<p-confirmDialog [acceptLabel]="\'yes\' | translate" acceptIcon="" [rejectLabel]="\'no\' | translate" rejectIcon=""></p-confirmDialog>\n<div *sLoadingState="loading">\n <form [formGroup]="formGroup">\n <div class="ui-fluid ui-g"> \n <div class="ui-md-6 ui-g-12 required">\n <label for="filial">{{\'yms.erp.devolucao_filial\' | translate}}</label>\n <s-lookup dataKey="id" id="filial" name="filial" formControlName="filial"\n [searchFields]="filialSearchFields" [searchGridFields]="filialSearchGridFields"\n [searchGridData]="filialSearchGridData" [multiple]="false"\n [lookupSuggestions]="filialLookupSuggestions"\n (onLookupRequest)="onFilialLookupRequest($event)"\n (onSearchRequest)="onFilialSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="filialSearchTotalRecords"\n [searchTitle]="\'yms.erp.filial_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: filialSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'filial\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n \n <div class="ui-md-6 ui-g-12 required">\n <label for="fornecedor">{{\'yms.erp.devolucao_fornecedor\' | translate}}</label>\n <s-lookup dataKey="id" id="fornecedor" name="fornecedor" formControlName="fornecedor"\n [searchFields]="fornecedorSearchFields" [searchGridFields]="fornecedorSearchFields"\n [searchGridData]="fornecedorSearchGridData" [multiple]="false"\n [lookupSuggestions]="fornecedorLookupSuggestions"\n (onLookupRequest)="onFornecedorLookupRequest($event)"\n (onSearchRequest)="onFornecedorSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="fornecedorSearchTotalRecords"\n [searchTitle]="\'yms.erp.fornecedor_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: fornecedorSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'fornecedor\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n \n <div class="ui-md-6 ui-g-12 required">\n <label for="produto">{{\'yms.erp.devolucao_produto\' | translate}}</label>\n <s-lookup dataKey="id" id="produto" name="produto" formControlName="produto"\n [searchFields]="produtoSearchFields" [searchGridFields]="produtoSearchFields"\n [searchGridData]="produtoSearchGridData" [multiple]="false"\n [lookupSuggestions]="produtoLookupSuggestions"\n (onLookupRequest)="onProdutoLookupRequest($event)"\n (onSearchRequest)="onProdutoSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="produtoSearchTotalRecords"\n [searchTitle]="\'yms.erp.produto_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: produtoSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'produto\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div> \n \n <div class="ui-md-6 ui-g-12" [ngClass]="{\'required\': formGroup.get(\'produto\').value}">\n <label for="derivacao">{{\'yms.erp.devolucao_derivacao\' | translate}}</label>\n <s-lookup dataKey="id" id="derivacao" name="derivacao" formControlName="derivacao"\n [searchFields]="derivacaoSearchFields" [searchGridFields]="derivacaoSearchFields"\n [searchGridData]="derivacaoSearchGridData" [multiple]="false"\n [lookupSuggestions]="derivacaoLookupSuggestions"\n (onLookupRequest)="onDerivacaoLookupRequest($event)"\n (onSearchRequest)="onDerivacaoSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="derivacaoSearchTotalRecords"\n [searchTitle]="\'yms.erp.derivacao_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: derivacaoSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'derivacao\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n \n <div class="ui-md-6 ui-g-12 required">\n <label for="origemMercadoria">{{\'yms.erp.devolucao_origem_mercadoria\' | translate}}</label>\n <s-lookup dataKey="id" id="origemMercadoria" name="origemMercadoria" formControlName="origemMercadoria"\n [searchFields]="origemMercadoriaSearchFields" [searchGridFields]="origemMercadoriaSearchFields"\n [searchGridData]="origemMercadoriaSearchGridData" [multiple]="false"\n [lookupSuggestions]="origemMercadoriaLookupSuggestions"\n (onLookupRequest)="onOrigemMercadoriaLookupRequest($event)"\n (onSearchRequest)="onOrigemMercadoriaSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="origemMercadoriaSearchTotalRecords"\n [searchTitle]="\'yms.erp.origem_mercadoria_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: origemMercadoriaSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'origemMercadoria\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n \n \n <div class="ui-md-6 ui-g-12">\n <label for="transportadora">{{\'yms.erp.devolucao_transportadora\' | translate}}</label>\n <s-lookup dataKey="id" id="transportadora" name="transportadora" formControlName="transportadora"\n [searchFields]="transportadoraSearchFields" [searchGridFields]="transportadoraSearchFields"\n [searchGridData]="transportadoraSearchGridData" [multiple]="false"\n [lookupSuggestions]="transportadoraLookupSuggestions"\n (onLookupRequest)="onTransportadoraLookupRequest($event)"\n (onSearchRequest)="onTransportadoraSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="transportadoraSearchTotalRecords"\n [searchTitle]="\'yms.erp.transportadora_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: transportadoraSearchTotalRecords}">\n </s-lookup>\n </div>\n \n <div class="ui-md-6 ui-g-12">\n <label for="chaveNotaFiscal">{{\'yms.erp.devolucao_chave_nota_fiscal\' | translate}}</label>\n <input type="text" id="chaveNotaFiscal" name="chaveNotaFiscal" pInputText formControlName="chaveNotaFiscal"> \n </div>\n \n <div class="ui-md-6 ui-g-12">\n <label for="numeroNotaFiscal">{{\'yms.erp.devolucao_numero_nota_fiscal\' | translate}}</label>\n <input type="text" id="numeroNotaFiscal" name="numeroNotaFiscal" pInputText formControlName="numeroNotaFiscal"> \n </div>\n \n <div class="ui-md-6 ui-g-12">\n <label for="serieNotaFiscal">{{\'yms.erp.devolucao_serie_nota_fiscal\' | translate}}</label>\n <input type="text" id="serieNotaFiscal" name="serieNotaFiscal" pInputText formControlName="serieNotaFiscal"> \n </div>\n \n <div class="ui-md-6 ui-g-12">\n <label for="numeroNotaFiscalProdutor">{{\'yms.erp.devolucao_numero_nota_fiscal_produtor\' | translate}}</label>\n <input type="text" id="numeroNotaFiscalProdutor" name="numeroNotaFiscalProdutor" pInputText formControlName="numeroNotaFiscalProdutor"> \n </div>\n \n <div class="ui-md-6 ui-g-12">\n <label for="serieNotaFiscalProdutor">{{\'yms.erp.devolucao_serie_nota_fiscal_produtor\' | translate}}</label>\n <input type="text" id="serieNotaFiscalProdutor" name="serieNotaFiscalProdutor" pInputText formControlName="serieNotaFiscalProdutor"> \n </div>\n <div class="ui-g-12" style="text-align: right;" *ngIf="totalEixosContratados || totalEixosComposicao">\n <label for="totalEixosContratados" float="right" style="display: inline;">{{totalEixosContratados}} {{\'yms.erp.total_eixos_contratados\' | translate}} / </label>\n <label for="totalEixosComposicao" float="right" style="display: inline;">{{totalEixosComposicao}} {{\'yms.erp.total_eixos_composicao\' | translate}}</label>\n </div>\n </div>\n </form>\n \n <div style="margin: 5px 0 5px 0;">\n <s-button priority="primary" [label]="\'save\' | translate" (onClick)="onSave()" [disabled]="loading || disableButtonSave"></s-button>\n <s-button *ngIf="saveAndInitButton" priority="primary" [label]="\'save_and_init\' | translate" (onClick)="onSave(true)" [disabled]="disableButtonSave"></s-button>\n </div>\n</div>\n'}),B("design:paramtypes",[C.FormBuilder,F.Router,o.TranslateService,ha,Ra,Ea,sa,Ca,Ua,Ya,c.MessageService,F.ActivatedRoute,ni,c.ConfirmationService,vt,La,qa,Na])],e)}(),_i=function(){function e(e){this.devolucaoService=e,this.loading=!0,this.unsubscribe$=new t.Subject}return e.prototype.ngAfterViewInit=function(){var e=this;this.devolucaoService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",page:0,size:1}).pipe(a.takeUntil(this.unsubscribe$),a.switchMap(function(e){var a=e.contents;return a.length?t.of(a[0]):t.throwError("Devolução não encontrado.")}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){return e.devolucao=Fi.fromDto(t)})},V([r.Input(),B("design:type",Object)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"devolucao-info",template:'\n <div *sLoadingState="loading" style="padding: 20px;">\n <div class="detail-pane" *ngIf="agenda">\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_fornecedor\' | translate}}</span>\n <span class="data">{{devolucao?.fornecedor?.nome}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_transportadora\' | translate}}</span>\n <span class="data">{{devolucao?.transportadora?.nome}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_produto\' | translate}}</span>\n <span class="data">{{devolucao?.produto?.descricao}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_derivacao\' | translate}}</span>\n <span class="data">{{devolucao?.derivacao?.descricao}}</span>\n </div>\n \n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_chave_nota_fiscal\' | translate}}</span>\n <span class="data">{{devolucao?.chaveNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_numero_nota_fiscal\' | translate}}</span>\n <span class="data">{{devolucao?.numeroNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_serie_nota_fiscal\' | translate}}</span>\n <span class="data">{{devolucao?.serieNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_numero_nota_fiscal_produtor\' | translate}}</span>\n <span class="data">{{devolucao?.numeroNotaFiscalProdutor}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_serie_nota_fiscal_produtor\' | translate}}</span>\n <span class="data">{{devolucao?.serieNotaFiscalProdutor}}</span>\n </div> \n <div class="detail-span">\n <span class="title">{{\'yms.erp.devolucao_origem_mercadoria\' | translate}}</span>\n <span class="data">{{devolucao?.origemMercadoria?.cep}} - {{devolucao?.origemMercadoria?.endereco}}</span>\n </div>\n </div>\n </div>\n ',styles:[".detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}"]}),B("design:paramtypes",[Ya])],e)}(),Ti=_,ki=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&Ti(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Ti(a.lastModifiedDate).toDate();return a.label=["id","clienteFaturamento.id","clienteFaturamento.codigo","clienteFaturamento.nome","clienteRemessa.id","clienteRemessa.codigo","clienteRemessa.nome","filial.id","filial.codigo","filial.nome","transportadora.id","transportadora.codigo","transportadora.placaVeiculo","pedidoVenda.id","agenda.id","agenda.descricao","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Pessoa"!==t&&a.clienteFaturamento&&(a.clienteFaturamento=Ot.fromDto(a.clienteFaturamento,"Recebimento")),"Pessoa"!==t&&a.clienteRemessa&&(a.clienteRemessa=Ot.fromDto(a.clienteRemessa,"Recebimento")),"Filial"!==t&&a.filial&&(a.filial=Ht.fromDto(a.filial,"Recebimento")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=yi.fromDto(a.transportadora,"Recebimento")),"Agenda"!==t&&a.agenda&&(a.agenda=we.fromDto(a.agenda,"Recebimento")),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Ti(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Ti(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.clienteFaturamento&&(a.clienteFaturamento=Ot.toDto(a.clienteFaturamento,"Recebimento")),"Pessoa"!==t&&a.clienteRemessa&&(a.clienteRemessa=Ot.toDto(a.clienteRemessa,"Recebimento")),"Filial"!==t&&a.filial&&(a.filial=Ht.toDto(a.filial,"Recebimento")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=yi.toDto(a.transportadora,"Recebimento")),"Agenda"!==t&&a.agenda&&(a.agenda=we.toDto(a.agenda,"Recebimento")),a},e}(),Ii=_,Mi=function(){function e(e,a,i,r,o,n,s,l,d,c,p,u,m,f,h,g,v,y,b,F){this.expedicaoService=e,this.router=a,this.route=i,this.messageService=r,this.formBuilder=o,this.translate=n,this.hotkeysService=s,this.fieldCustomization=l,this.focusService=d,this.pessoaService=c,this.filialService=p,this.transportadoraService=u,this.pedidoVendaService=m,this.pedidoVendaItemService=f,this.agendaService=h,this.override=g,this.confirmationService=v,this.erpProcessService=y,this.erpFormConfigService=b,this.hasChangeService=F,this.localeConfig={},this.currencyLocaleOptions={},this.permissions={},this.allPermissions={},this.mainPanelCollapsed=!1,this.visibleDialog=!1,this.formCarregado=!1,this.clienteFaturamentoLookupDisplayFields=["codigo","nome","cpfCnpj"],this.clienteFaturamentoAdvancedDisplayFields=["id","codigo","nome"],this.clienteFaturamentoLookupSeparator=" - ",this.clienteRemessaLookupDisplayFields=["codigo","nome","cpfCnpj"],this.clienteRemessaAdvancedDisplayFields=["id","codigo","nome"],this.clienteRemessaLookupSeparator=" - ",this.filialLookupDisplayFields=["codigo","nome"],this.filialAdvancedDisplayFields=["id","codigo","nome"],this.filialLookupSeparator=" - ",this.transportadoraLookupDisplayFields=["codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraAdvancedDisplayFields=["id","codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraLookupSeparator=" - ",this.pedidoVendaLookupDisplayFields=["numero","cliente"],this.pedidoVendaAdvancedDisplayFields=["id","numero","filial.nome","filial.codigo","pessoa.id","pessoa.codigo","pessoa.nome"],this.pedidoVendaLookupSeparator=" - ",this.pedidoVendaItemLookupDisplayFields=["sequencia","sku.descricao"],this.pedidoVendaItemAdvancedDisplayFields=["id","sequencia","sku.descricao"],this.pedidoVendaItemLookupSeparator=" - ",this.agendaLookupDisplayFields=["id","descricao"],this.agendaAdvancedDisplayFields=["id","descricao"],this.agendaLookupSeparator=" - ",this.disableButtonSave=!1,this.disableOrdersButtons=!0,this.totalEixosContratados=0,this.totalEixosComposicao=0,this.ordersValid=!0,this.ngUnsubscribe=new t.Subject,this.formGroup=this.getFormGroup(),this.pedidoVendaForm=this.getPedidoVendaForm(),this.itemFormGroup=this.getOrdemVendaItemForm()}return e.prototype.ngOnInit=function(){var e=this;this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)}),this.route.params.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.agenda;"new"!=a?e.getExpedicao(a):e.buscarFilial()}),this.clienteFaturamentoSearchFields=this.getClienteSearchFields(),this.clienteFaturamentoSearchGridFields=this.getClienteSearchGridFields(),this.clienteRemessaSearchFields=this.getClienteSearchFields(),this.clienteRemessaSearchGridFields=this.getClienteSearchGridFields(),this.filialSearchFields=this.getFilialSearchFields(),this.filialSearchGridFields=this.getFilialSearchGridFields(),this.transportadoraSearchFields=this.getTransportadoraSearchFields(),this.transportadoraSearchGridFields=this.getTransportadoraSearchGridFields(),this.pedidoVendaSearchFields=this.getPedidoVendaSearchFields(),this.pedidoVendaSearchGridFields=this.getPedidoVendaSearchGridFields(),this.pedidoVendaItemSearchFields=this.getPedidoVendaItemSearchFields(),this.pedidoVendaItemSearchGridFields=this.getPedidoVendaItemSearchGridFields(),this.agendaSearchFields=this.getAgendaSearchFields(),this.agendaSearchGridFields=this.getAgendaSearchGridFields(),this.setHotkeys(),this.agenda&&this.agenda.externalTenant&&this.setTransportadora(this.agenda.externalTenant.cnpj),this.totalEixosComposicao=this.agenda&&this.agenda.veiculo&&this.agenda.veiculo.eixos||0,this.setPedidosValueChanges(),this.erpProcessService.current.subscribe(function(t){return e.erpProcessData=t}),this.erpFormConfigService.current.subscribe(function(t){return e.enableRevalidation=t}),this.revalidacaoTransportadora(),this.verificaSeTemAlteracao()},e.prototype.verificaSeTemAlteracao=function(){var e=this;this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.revalidacaoTransportadora=function(){var e=this;this.formGroup.get("transportadora").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=e.formGroup.get("transportadora").value;e.erpProcessService&&a&&(e.erpProcessData.transportadoraId=a.id,e.erpProcessService.changeData(e.erpProcessData))})},e.prototype.abrirPedidoVenda=function(e){var t=document.getElementById("pedidoVenda").getElementsByTagName("button");t.length&&(this.pedidoVendaForm.patchValue({pedidoVenda:e}),t[0].click())},e.prototype.excluirPedidoVenda=function(e){this.formGroup.get("pedidos").removeAt(e)},e.prototype.abrirPedidoVendaItem=function(e,t){this.itemFormGroup.patchValue(t||{item:undefined,quantidade:1}),this.pedidoAtual=e,this.visibleDialog=!0},e.prototype.excluirPedidoVendaItem=function(e,t){var a=t.get("itens").value.findIndex(function(t){return t.item.id===e});a>=0&&t.get("itens").removeAt(a)},e.prototype.setPedidosValueChanges=function(){var e=this;this.formGroup.get("pedidos").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(){var t=e.formGroup.get("pedidos").length;e.ordersValid=t>0,e.formGroup.get("filial")[t>=1?"disable":"enable"]()})},e.prototype.selecionarPedidoVenda=function(e){if(this.formGroup.get("pedidos").value.find(function(t){return t.pedidoVenda.id===e.id}))return this.addMessage("warn",this.translate.instant("yms.erp.pedido_venda_search_already_selected_summary"),this.translate.instant("yms.erp.pedido_venda_search_already_selected_detail"));this.formGroup.get("pedidos").push(this.getOrdemVendaForm(e,!0)),e&&1===this.formGroup.get("pedidos").length&&!this.formGroup.get("clienteFaturamento").value&&this.buscarClienteAFaturar(e)},e.prototype.selecionarPedidoVendaItem=function(){var e=this.itemFormGroup.value,t=this.pedidoAtual.get("itens").value;if(t&&e&&e.item&&t.find(function(t){return t.item.id===e.item.id}))return this.addMessage("warn",this.translate.instant("yms.erp.item_pedido_venda_search_already_selected_summary"),this.translate.instant("yms.erp.item_pedido_venda_search_already_selected_detail"));var a=this.getOrdemVendaItemForm();a.patchValue(j({},this.itemFormGroup.value)),a.get("item").value!=undefined&&(this.pedidoAtual.get("itens").push(a),this.visibleDialog=!1)},e.prototype.selecionarPedidoVendaItemAutomaticamente=function(e,t){if(e&&1===e.length){var a=this.getOrdemVendaItemForm(),i=this.getPedidos().filter(function(e){return!(!e||!e.value.pedidoVenda)&&e.value.pedidoVenda.id===t.id});this.itemFormGroup.get("item").setValue(1===e.length?e[0]:{}),this.itemFormGroup.get("quantidade").setValue(1),a.patchValue(j({},this.itemFormGroup.value)),i[0].get("itens").push(a),this.visibleDialog=!1}},e.prototype.getPedidos=function(){return this.formGroup.get("pedidos").controls},e.prototype.buildTokens=function(e){return e.map(function(e){var t=e&&e.item?e.item:e,a=t.sku?t.sku:t.produto;return{id:t.id,label:"Produto: "+a.descricao+", Sequencia: "+t.sequencia}})},e.prototype.ngAfterViewInit=function(){var e=this,t=document.getElementsByTagName("input"),a=Array.from(t).find(function(e){return!e.disabled});a&&a.focus(),this.override.initialize(),this.saveAndInitButton=document.getElementById("init"),this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)});(this.agenda&&!["AGUARDANDO_CONFIRMACAO_SOLICITANTE","AGENDADO","AGUARDANDO_CONFIRMACAO","REJEITADO_POR_VALIDACAO"].includes(this.agenda.status)||!this.permissions.editar)&&(this.formGroup.disable(),this.disableButtonSave=!0),this.agenda&&this.agenda.createdByErp&&(this.formGroup.get("filial").disable(),this.formGroup.get("transportadora").disable(),this.formGroup.get("clienteRemessa").disable(),this.formGroup.get("clienteFaturamento").disable(),this.pedidoVendaForm.disable(),this.itemFormGroup.disable(),this.disableOrdersButtons=!0)},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete(),this.override.remove()},e.prototype.setHotkeys=function(){var e=this;this.hotkeysService.add(new O.Hotkey("alt+shift+s",function(){return(e.isNew()||e.permissions.editar)&&e.onSave(),!1},["INPUT","SELECT","TEXTAREA"])),this.hotkeysService.add(new O.Hotkey("alt+shift+c",function(){return e.onCancel(),!1},["INPUT","SELECT","TEXTAREA"]))},e.prototype.isNew=function(){return!this.formGroup.value.id},e.prototype.updateSuggestions=function(e){e.agenda&&(e.agenda.label=this.getSuggestionValue(["id","descricao"],"agenda",e,this.agendaLookupSeparator),e.agenda.label.trim()===this.agendaLookupSeparator.trim()&&delete e.agenda.label)},e.prototype.getSuggestionValue=function(e,t,a,i){var r=this;return e.map(function(e){return r.getProp(a,t+"."+e)}).reduce(function(e,t){return""+e+i+t})},e.prototype.onRouteDataChange=function(e){var t=e.localeConfig.number,a=t.currencySymbol,i=t.thousandsSeparator,r=t.decimalSeparator;if(this.localeConfig=e.localeConfig,this.currencyLocaleOptions={align:"left",prefix:a,thousands:i,decimal:r},this.permissions=e.allPermissions.expedicao,this.allPermissions=e.allPermissions,e.entity){this.permissions.editar||this.formGroup.disable();var o=ki.fromDto(e.entity);this.updateSuggestions(o),this.formGroup.patchValue(o)}else this.formGroup.patchValue(new ki)},e.prototype.onCancel=function(){this.goBack()},e.prototype.onSendFile=function(e,a){var i=[];return this.fieldCustomization.isEmpty(e)||i.push(this.fieldCustomization.deleteFiles(e)),this.fieldCustomization.isEmpty(a)||i.push(this.fieldCustomization.commitFiles(a)),this.fieldCustomization.isEmpty(i)?t.of({}):t.forkJoin(i)},e.prototype.setValuesPedidoBiodisel=function(){var e=this.formGroup.get("numeroPedidoCliente").value,t=this.formGroup.get("itemPedidoCliente").value,a=this.formGroup.get("pedidos").value;(a||[]).map(function(a){a&&a.itens&&a.itens.length&&(a.itens[0].numeroPedidoCliente=e,a.itens[0].itemPedidoCliente=t)}),this.formGroup.get("pedidos").patchValue(a)},e.prototype.getValuesPedidoBiodisel=function(){var e=this.formGroup.get("pedidos").value,t=this.formGroup.get("numeroPedidoCliente"),a=this.formGroup.get("itemPedidoCliente");(e||[]).map(function(e){if(!t.value||!a.value){var i=e&&e.itens&&e.itens.length?e.itens[0].pedido:null;i&&i.itens&&i.itens.length&&1===i.itens.length&&(t.patchValue(i.itens[0].numeroPedidoCliente),a.patchValue(i.itens[0].itemPedidoCliente))}})},e.prototype.onSave=function(e){var t=this;if(this.formGroup.get("agenda").setValue(this.agenda),this.ordersValid=this.formGroup.get("pedidos").length>0,this.formGroup.invalid||!this.ordersValid)return this.validateAllFormFields(this.formGroup);this.setValuesPedidoBiodisel();var i=this.fieldCustomization.getFiles(this.formGroup),r=i.filesToDelete,o=i.filesToCommit;return this.loading=!0,this.isNew()||!this.enableRevalidation?this.saveAndInit(r,o,e):(this.erpProcessData=this.erpProcessService.builderErpProcessData(this.erpProcessData,this.formGroup),this.erpProcessService.changeDataErp(this.erpProcessData),this.agendaService.checarRevalidacao(this.erpProcessData).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){a.requerRevalidacao?t.atualizaAgendaParaRejeitadoPorValidacao():t.saveAndInit(r,o,e)}))},e.prototype.atualizaAgendaParaRejeitadoPorValidacao=function(){var e=this;this.confirmationService.confirm({header:this.translate.instant("yms.patio.agenda_revalidacao_title"),message:this.translate.instant("yms.patio.agenda_revalidacao_message"),accept:function(){e.hasChangeService.hasChangeSave(e.agenda.id),e.agenda.status=dt.REJEITADO_POR_VALIDACAO,e.agenda.motorista={id:e.erpProcessData.motoristaId},e.agenda.veiculo={id:e.erpProcessData.veiculoId},e.agendaService.atualizarAgenda(e.agenda).pipe(a.takeUntil(e.ngUnsubscribe),a.concatMap(function(t){return e.getSaveObservable()}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.successMessage(),e.router.navigate(["/chegada-veiculo"],{relativeTo:e.route})})},reject:function(){return e.loading=!1}})},e.prototype.saveAndInit=function(e,t,a){var i=this;this.atualizaExpedicao(e,t,function(){i.hasChangeService.hasChangeSave(i.agenda.id),a&&i.saveAndInitButton&&(i.hasChangeService.hasChangeSave(i.agenda.id),i.saveAndInitButton.click())})},e.prototype.successMessage=function(){this.messageService.add({severity:"success",summary:this.translate.instant("saved_message_title"),detail:this.translate.instant("saved_message_content")})},e.prototype.atualizaExpedicao=function(e,i,r){var o=this;return this.getSaveObservable().pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return o.loading=!1})).subscribe(function(n){o.formGroup.get("id").setValue(n.id||null),o.onSendFile(e,i).pipe(a.takeUntil(o.ngUnsubscribe),a.catchError(function(e){return o.loading=!1,t.throwError(e)})).subscribe(function(){o.addMessage("success","saved_message_title","saved_message_content"),r()})})},e.prototype.setTransportadora=function(e){var t=this;if(e){var i="pessoa.cpfCnpj eq '"+e.replace(".","").replace("/","").replace("-","")+"'";this.transportadoraService.list({filterQuery:i,page:0,size:10}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;if(1===a.length){var i=a[0].codigo?a[0].codigo.toString():"",r=a[0].descricao?a[0].descricao.toString():"";r.trim()||i.trim()?a[0].label=i+" - "+r:a[0].label=t.translate.instant("yms.erp.derivacao_sem_descricao"),t.formGroup.get("transportadora").setValue(a[0])}})}},e.prototype.getProp=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},e.prototype.getExpedicao=function(e){var t=this;this.loading=!0,this.expedicaoService.list({filterQuery:"agenda.id eq '"+e+"'",size:1,page:0}).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(e){var a=e.contents;if(a.length){t.totalEixosContratados=a[0].eixos||0,t.totalEixosComposicao=a[0].agenda&&a[0].agenda.veiculo&&a[0].agenda.veiculo.eixos||0;var i=ki.fromDto(a[0]);t.formGroup.enable(),t.formGroup.patchValue(i),i.pedidos.forEach(function(e){var a=t.getOrdemVendaForm();a.patchValue(e),e.itens.forEach(function(e){var i=t.getOrdemVendaItemForm();i.patchValue(e),a.get("itens").push(i)}),t.formGroup.get("pedidos").push(a)}),t.getValuesPedidoBiodisel(),t.formCarregado=!0}else t.buscarFilial()})},e.prototype.onClienteFaturamentoLookupRequest=function(e){var t=this;Le(this.clienteFaturamentoSearchFields,this.clienteFaturamentoLookupDisplayFields,this.clienteFaturamentoAdvancedDisplayFields,this.clienteFaturamentoLookupSeparator,this.pessoaService,e,"cliente eq true").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.clienteFaturamentoLookupSuggestions=e.contents})},e.prototype.onClienteFaturamentoSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=this.getClienteSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,i=s[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Ii(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Ii(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Ii(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":a==n.FieldType.Lookup?t+" eq '"+i.id+"'":t+" eq '"+i+"'"}).join(" and ");c=c+(c?" and ":"")+"situacao eq ATIVO and cliente eq true";var p=_e(this.clienteFaturamentoLookupDisplayFields,this.clienteFaturamentoAdvancedDisplayFields);this.pessoaService.list({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.clienteFaturamentoLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.clienteFaturamentoLookupSeparator)})})})})).subscribe(function(e){t.clienteFaturamentoSearchGridData=e.contents,t.clienteFaturamentoSearchTotalRecords=e.totalElements})},e.prototype.onClienteRemessaLookupRequest=function(e){var t=this;Le(this.clienteRemessaSearchFields,this.clienteRemessaLookupDisplayFields,this.clienteRemessaAdvancedDisplayFields,this.clienteRemessaLookupSeparator,this.pessoaService,e,"cliente eq true").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.clienteRemessaLookupSuggestions=e.contents})},e.prototype.onClienteRemessaSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=this.getClienteSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,i=s[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Ii(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Ii(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Ii(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and ");c=c+(c?" and ":"")+"situacao eq ATIVO and cliente eq true";var p=_e(this.clienteRemessaLookupDisplayFields,this.clienteRemessaAdvancedDisplayFields);this.pessoaService.list({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.clienteRemessaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.clienteRemessaLookupSeparator)})})})})).subscribe(function(e){t.clienteRemessaSearchGridData=e.contents,t.clienteRemessaSearchTotalRecords=e.totalElements})},e.prototype.onFilialSelect=function(e){this.disableOrdersButtons=!e||this.agenda.createdByErp},e.prototype.onFilialLookupRequest=function(e){var t=this,i=this.getFilialSearchFields().filter(function(t){var a=t.type;return Te(a,e)}).reduce(function(t,a){var i,r,o=a.name;return a.type===n.FieldType.Integer?j({},t,((i={})[o]=e.replace(/\D/,""),i)):j({},t,((r={})[o]=e,r))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:10,offset:0}});this.filialService.listFiliais(i).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.filialLookupSuggestions=e.filiais.map(function(e){return Ht.fromDto(e)})})},e.prototype.onFilialSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getFilialSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}});this.filialService.listFiliais(p).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.filialSearchGridData=e.filiais.map(Ht.fromDto),t.filialSearchTotalRecords=e.qtdTotalRegistros})},e.prototype.onTransportadoraLookupRequest=function(e){var t=this;Le(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraLookupSuggestions=e.contents})},e.prototype.onTransportadoraSearchRequest=function(e){var t=this;qe(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraSearchGridData=e.contents,t.transportadoraSearchTotalRecords=e.totalElements})},e.prototype.onPedidoVendaLookupRequest=function(e){var t=this,i=this.pedidoVendaLookupDisplayFields.map(function(e){return{field:e,order:1}}),r=this.getPedidoVendaSearchFields().filter(function(t){var a=t.type;return Te(a,e)}).map(function(t){var a=t.name,i=t.type;return"number"==typeof e?a+" eq "+e:i==n.FieldType.Date?a+" eq '"+Ii(e).format("YYYY-MM-DD")+"'":i==n.FieldType.Time?a+" eq '"+Ii(e).format("HH:mm:ss")+"'":i==n.FieldType.DateTime?a+" eq '"+Ii(e).format()+"'":i==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or ");r=r+(r?" and ":"")+"situacaoPedido eq ABERTO_TOTAL or situacaoPedido eq ABERTO_PARCIAL";var o=this.formGroup.get("pedidos").value||[],s="";o.map(function(e){return!!(e&&e.pedidoVenda&&e.pedidoVenda.id)&&(s+=" and (id ne '"+e.pedidoVenda.id+"')")}),o.length&&s&&(r+=s);var l=_e(this.pedidoVendaLookupDisplayFields,this.pedidoVendaAdvancedDisplayFields);this.pedidoVendaService.list({sort:i,filterQuery:r,displayFields:l}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.pedidoVendaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.pedidoVendaLookupSeparator)})})})})).subscribe(function(e){t.pedidoVendaLookupSuggestions=e.contents})},e.prototype.getRecPagina=function(e,t,a){return{offset:e/t,limit:t,listaOrdenacao:a&&a.length?a.map(function(e){return{campo:e.field,ordenacao:1===e.order?"Asc":"Desc"}}):[]}},e.prototype.onPedidoVendaSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,n=e.filterData,s=o||[],l=this.formGroup.get("filial").value,d=this.formGroup.get("pedidos").value||[],c=[];d.map(function(e){return!!(e&&e.pedidoVenda&&e.pedidoVenda.id)&&c.push(e.pedidoVenda.id)});var p={pessoaId:n.cliente?n.cliente.id:null,filialId:l?l.id:null,tipoAgendamentoId:this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,filialPedido:n.filialPedido,pedidosSelecionados:c,numero:n.numero,pagina:this.getRecPagina(i,r,s)};this.pedidoVendaService.pesquisarPedidosVenda(p).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.pedidoVendaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.pedidoVendaLookupSeparator)})})})})).subscribe(function(e){t.pedidoVendaSearchGridData=e.contents,t.pedidoVendaSearchTotalRecords=e.totalElements})},e.prototype.onPedidoVendaItemLookupRequest=function(e){var t=this,i=this.pedidoVendaItemLookupDisplayFields.map(function(e){return{field:e,order:1}}),r=(this.formGroup.get("filial").value||{}).id,o={pedidoId:(this.pedidoAtual.get("pedidoVenda").value||{}).id,filialId:r,sequencia:isNaN(e)?null:e,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,pagina:this.getRecPagina(0,10,i)};this.pedidoVendaItemService.pesquisarItensPedidoVenda(o).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.pedidoVendaItemLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.pedidoVendaItemLookupSeparator)})})})})).subscribe(function(e){t.pedidoVendaItemLookupSuggestions=e.contents})},e.prototype.onPedidoVendaItemSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,n=e.filterData,s=o,l=(this.formGroup.get("filial").value||{}).id,d={pedidoId:(this.pedidoAtual.get("pedidoVenda").value||{}).id,filialId:l,sequencia:n.sequencia,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,pagina:this.getRecPagina(i,r,s)};this.pedidoVendaItemService.pesquisarItensPedidoVenda(d).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.pedidoVendaItemLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.pedidoVendaItemLookupSeparator)})})})})).subscribe(function(e){t.pedidoVendaItemSearchGridData=e.contents,t.pedidoVendaItemSearchTotalRecords=e.totalElements})},e.prototype.getAutomaticItensOrder=function(e){var t=this;if(e&&e.id){var i=this.pedidoVendaItemLookupDisplayFields.map(function(e){return{field:e,order:1}}),r=(this.formGroup.get("filial").value||{}).id,o={pedidoId:e.id,filialId:r,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,pagina:this.getRecPagina(0,10,i)};this.pedidoVendaItemService.pesquisarItensPedidoVenda(o).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.pedidoVendaItemLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.pedidoVendaItemLookupSeparator)})})})})).subscribe(function(a){t.selecionarPedidoVendaItemAutomaticamente(a.contents,e)})}},e.prototype.onAgendaLookupRequest=function(e){var t=this,i=this.agendaLookupDisplayFields.map(function(e){return{field:e,order:1}}),r=this.getAgendaSearchFields().filter(function(t){var a=t.type;return Te(a,e)}).map(function(t){var a=t.name,i=t.type;return"number"==typeof e?a+" eq "+e:i==n.FieldType.Date?a+" eq '"+Ii(e).format("YYYY-MM-DD")+"'":i==n.FieldType.Time?a+" eq '"+Ii(e).format("HH:mm:ss")+"'":i==n.FieldType.DateTime?a+" eq '"+Ii(e).format()+"'":i==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or "),o=_e(this.agendaLookupDisplayFields,this.agendaAdvancedDisplayFields);this.agendaService.listExternalAgenda({sort:i,filterQuery:r,displayFields:o}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.agendaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.agendaLookupSeparator)})})})})).subscribe(function(e){t.agendaLookupSuggestions=e.contents})},e.prototype.onAgendaSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=this.getAgendaSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,i=s[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Ii(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Ii(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Ii(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and "),p=_e(this.agendaLookupDisplayFields,this.agendaAdvancedDisplayFields);this.agendaService.listExternalAgenda({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.agendaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.agendaLookupSeparator)})})})})).subscribe(function(e){t.agendaSearchGridData=e.contents,t.agendaSearchTotalRecords=e.totalElements})},e.prototype.getFormGroup=function(){return this.formBuilder.group({id:[{value:undefined,disabled:!0},C.Validators.compose([])],clienteFaturamento:[{value:undefined,disabled:!1},C.Validators.compose([C.Validators.required])],clienteRemessa:[{value:undefined,disabled:!1}],filial:[{value:undefined,disabled:!1},C.Validators.compose([C.Validators.required])],transportadora:[{value:undefined,disabled:!1},C.Validators.compose([])],pedidos:this.formBuilder.array([]),agenda:[{value:undefined,disabled:!1},C.Validators.compose([C.Validators.required])],numeroAgendamentoCliente:[{value:undefined,disabled:!1},C.Validators.compose([])],numeroPedidoCliente:[{value:undefined,disabled:!1},C.Validators.compose([])],itemPedidoCliente:[{value:undefined,disabled:!1},C.Validators.compose([])],createdBy:[{value:undefined,disabled:!0},C.Validators.compose([])],createdDate:[{value:undefined,disabled:!0},C.Validators.compose([])],lastModifiedBy:[{value:undefined,disabled:!0},C.Validators.compose([])],lastModifiedDate:[{value:undefined,disabled:!0},C.Validators.compose([])]})},e.prototype.getClienteSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.pessoa_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.pessoa_nome"),type:n.FieldType.String}),new n.FormField({name:"cpfCnpj",label:this.translate.instant("yms.erp.pessoa_cpfCnpj"),type:n.FieldType.String})]},e.prototype.getClienteSearchGridFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.pessoa_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.pessoa_nome"),type:n.FieldType.String}),new n.FormField({name:"cpfCnpj",label:this.translate.instant("yms.erp.pessoa_cpfCnpj"),type:n.FieldType.String}),new n.FormField({name:"site",label:this.translate.instant("yms.erp.pessoa_site"),type:n.FieldType.String})]},e.prototype.getFilialSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.filial_nome"),type:n.FieldType.String})]},e.prototype.getFilialSearchGridFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.filial_nome"),type:n.FieldType.String})]},e.prototype.getTransportadoraSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_descricao")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getTransportadoraSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getPedidoVendaSearchFields=function(){var e=this,i=new t.Subject,r=new t.Subject;return[new n.FormField({name:"numero",label:this.translate.instant("yms.erp.pedido_venda_numero"),type:n.FieldType.Integer}),new n.FormField({name:"filialPedido",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"cliente",label:this.translate.instant("yms.erp.pessoa_cliente_label"),type:n.FieldType.Lookup,searchFields:this.getClienteSearchFields(),searchGridFields:this.getClienteSearchGridFields(),suggestionsObservable:i,searchObservable:r,emptyMessage:"Nenhuma sugestão encontrada",size:{sm:12,md:12,lg:12,xl:12},onLookupRequest:function(t){Le(e.clienteFaturamentoSearchFields,e.clienteFaturamentoLookupDisplayFields,e.clienteFaturamentoAdvancedDisplayFields,e.clienteFaturamentoLookupSeparator,e.pessoaService,t,"situacao eq ATIVO and cliente eq true").pipe(a.takeUntil(e.ngUnsubscribe)).subscribe(function(e){return i.next(e.contents)})},onSearchRequest:function(t){qe(e.clienteFaturamentoSearchFields,e.clienteFaturamentoLookupDisplayFields,e.clienteFaturamentoAdvancedDisplayFields,e.clienteFaturamentoLookupSeparator,e.pessoaService,t,"situacao eq ATIVO and cliente eq true").pipe(a.takeUntil(e.ngUnsubscribe)).subscribe(function(e){r.next({totalRecords:e.totalElements,gridData:e.contents})})},dataKey:"id",lookupDisplayField:"label",searchTitle:this.translate.instant("yms.erp.pessoa_cliente_label"),searchEmptyTitle:this.translate.instant("yms.erp.nothing_found"),filterLabel:this.translate.instant("yms.erp.filter"),filterTitle:this.translate.instant("yms.integration.filters"),clearLabel:this.translate.instant("yms.erp.clear"),cancelLabel:this.translate.instant("yms.erp.cancel"),selectLabel:this.translate.instant("yms.erp.select"),tooltip:this.translate.instant("yms.erp.pessoa_cliente_label")})]},e.prototype.getPedidoVendaSearchGridFields=function(){return[new n.FormField({name:"numero",label:this.translate.instant("yms.erp.pedido_venda_numero"),type:n.FieldType.Integer}),new n.FormField({name:"filial.nome",label:this.translate.instant("yms.erp.filial"),type:n.FieldType.String}),new n.FormField({name:"filial.codigo",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"pessoa.nome",label:this.translate.instant("yms.erp.pessoa_cliente_label"),type:n.FieldType.Integer}),new n.FormField({name:"pessoa.codigo",label:this.translate.instant("yms.erp.pessoa_cliente_codigo_label"),type:n.FieldType.Integer})]},e.prototype.getPedidoVendaItemSearchFields=function(){return[new n.FormField({name:"sequencia",label:this.translate.instant("yms.erp.pedido_venda_item_sequencia"),type:n.FieldType.Integer})]},e.prototype.getPedidoVendaItemSearchGridFields=function(){return H(this.getPedidoVendaItemSearchFields(),[new n.FormField({name:"sku.descricao",label:this.translate.instant("yms.erp.produto"),type:n.FieldType.String})])},e.prototype.getAgendaSearchFields=function(){return[new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.agenda_descricao"),type:n.FieldType.String})]},e.prototype.getAgendaSearchGridFields=function(){return[new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.agenda_descricao"),type:n.FieldType.String})]},e.prototype.getDerivacaoSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.derivacao_codigo"),type:n.FieldType.String}),new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.derivacao_descricao"),type:n.FieldType.String})]},e.prototype.getDerivacaoSearchGridFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.derivacao_codigo"),type:n.FieldType.String}),new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.derivacao_descricao"),type:n.FieldType.String})]},e.prototype.goBack=function(){this.router.navigate(["../"],{relativeTo:this.route.parent})},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup&&t.validateAllFormFields(i)}),this.focusService.focusFirstInvalidInput()},e.prototype.getSaveObservable=function(){var e,t=this.formGroup.getRawValue(),a=ki.toDto(t);if(this.isNew()&&!t.id)e=this.expedicaoService.insert(a);else{var i=t.id;e=this.expedicaoService.update(i,a)}return e},e.prototype.validateVisualization=function(){Ie(this.formGroup,this.allPermissions)||this.addMessage("error","yms.erp.cannot_visualize_form_summary","yms.erp.cannot_visualize_form_detail")},e.prototype.addMessage=function(e,t,a){this.messageService.add({severity:e,summary:this.translate.instant(t),detail:this.translate.instant(a)})},e.prototype.getPedidoVendaForm=function(){return this.formBuilder.group({pedidoVenda:[undefined]})},e.prototype.getOrdemVendaForm=function(e,t){return t&&this.getAutomaticItensOrder(e),this.formBuilder.group({id:[undefined],pedidoVenda:[e],itens:this.formBuilder.array([])})},e.prototype.getOrdemVendaItemForm=function(e){return this.formBuilder.group({id:[undefined],pedido:[undefined],item:[e],quantidade:[undefined],numeroPedidoCliente:[undefined],itemPedidoCliente:[undefined]})},e.prototype.buscarFilial=function(){var e=this,t=this.agenda.planta||{cnpj:[]};1===t.cnpj.length?(this.filialService.list({page:0,size:1,filterQuery:"pessoa.cpfCnpj eq '"+t.cnpj[0]+"'",displayFields:["*","empresa.nome"]}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;1===a.length&&(e.formGroup.get("filial").setValue(Ht.fromDto(a[0])),e.disableOrdersButtons=!1)}),this.formCarregado=!0):this.formCarregado=!0},e.prototype.buscarClienteAFaturar=function(e){var t=this;this.pessoaService.list({size:1,page:0,filterQuery:"id eq '"+e.pessoa.id+"'"}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;1===(a||[]).length&&t.formGroup.get("clienteFaturamento").setValue(Ot.fromDto(a[0]))})},V([r.Input(),B("design:type",we)],e.prototype,"agenda",void 0),V([r.Input(),B("design:type",Boolean)],e.prototype,"revalidacao",void 0),V([r.ViewChild("customTemplate"),B("design:type",r.TemplateRef)],e.prototype,"customTemplate",void 0),V([r.ViewChild("customFormFields"),B("design:type",r.TemplateRef)],e.prototype,"customFormFields",void 0),e=V([r.Component({selector:"expedicao-form",template:'<div *sLoadingState="loading">\n <form [formGroup]="formGroup">\n <div class="ui-g">\n <div class="ui-g-12 ui-md-12">\n <label class="required-h3">Pedidos:</label>\n <s-button label="Adicionar pedido" priority="default" (onClick)="abrirPedidoVenda()" [disabled]="disableButtonSave || disableOrdersButtons"></s-button>\n <div class="error-required-message" [hidden]="ordersValid">{{\'yms.erp.error_required\' | translate}}</div>\n <p-accordion>\n <p-accordionTab *ngFor="let pedido of getPedidos(); let i = index">\n <p-header>\n Pedido: {{ pedido.get(\'pedidoVenda\')?.value?.numero }}\n </p-header>\n \n <div style="margin: 10px 0; display: block;">\n <s-button label="Adicionar item do pedido" priority="default" size="small"\n (onClick)="abrirPedidoVendaItem(pedido)" [disabled]="disableButtonSave || disableOrdersButtons"></s-button>\n <s-button label="Excluir pedido" priority="default" size="small"\n (onClick)="excluirPedidoVenda(i)" [disabled]="disableButtonSave || disableOrdersButtons"></s-button>\n </div>\n \n <s-token-list [tokens]="buildTokens(pedido.get(\'itens\')?.value)" [removableTokens]="true"\n (tokenRemoved)="excluirPedidoVendaItem($event.id, pedido)">\n </s-token-list>\n </p-accordionTab>\n </p-accordion>\n <div style="display: inline-block;" class="separator"></div>\n </div>\n </div>\n <div class="ui-fluid">\n <div class="ui-g">\n <div [attr.data-hidden]="true" class="ui-g-12 ui-md-6">\n <label for="id">{{"yms.erp.recebimento_id" | translate}}</label>\n <input #idFormInput type="text" id="id" name="id" pInputText formControlName="id"\n autocomplete="off" />\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="filial">{{"yms.erp.expedicao_filial" | translate}}</label>\n <s-lookup dataKey="id" id="filial" name="filial" formControlName="filial"\n [searchFields]="filialSearchFields" [searchGridFields]="filialSearchGridFields"\n [searchGridData]="filialSearchGridData" [multiple]="false"\n [lookupSuggestions]="filialLookupSuggestions" (onLookupRequest)="onFilialLookupRequest($event)"\n (onSearchRequest)="onFilialSearchRequest($event)" lookupDisplayField="label"\n (onSelect)="onFilialSelect($event)"\n [searchTotalRecords]="filialSearchTotalRecords"\n [searchTitle]="\'yms.erp.filial_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: filialSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'filial\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="clienteFaturamento">{{"yms.erp.expedicao_cliente_faturamento" | translate}}</label>\n <s-lookup dataKey="id" id="clienteFaturamento" name="clienteFaturamento"\n formControlName="clienteFaturamento" [searchFields]="clienteFaturamentoSearchFields"\n [searchGridFields]="clienteFaturamentoSearchGridFields"\n [searchGridData]="clienteFaturamentoSearchGridData" [multiple]="false"\n [lookupSuggestions]="clienteFaturamentoLookupSuggestions"\n (onLookupRequest)="onClienteFaturamentoLookupRequest($event)"\n (onSearchRequest)="onClienteFaturamentoSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="clienteFaturamentoSearchTotalRecords"\n [searchTitle]="\'yms.erp.cliente_faturamento_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: clienteFaturamentoSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'clienteFaturamento\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="clienteRemessa">{{"yms.erp.expedicao_cliente_remessa" | translate}}</label>\n <s-lookup dataKey="id" id="clienteRemessa" name="clienteRemessa" formControlName="clienteRemessa"\n [searchFields]="clienteRemessaSearchFields" [searchGridFields]="clienteRemessaSearchGridFields"\n [searchGridData]="clienteRemessaSearchGridData" [multiple]="false"\n [lookupSuggestions]="clienteRemessaLookupSuggestions"\n (onLookupRequest)="onClienteRemessaLookupRequest($event)"\n (onSearchRequest)="onClienteRemessaSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="clienteRemessaSearchTotalRecords"\n [searchTitle]="\'yms.erp.cliente_remessa_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: clienteRemessaSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'clienteRemessa\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="transportadora">{{"yms.erp.expedicao_transportadora" | translate}}</label>\n <s-lookup dataKey="id" id="transportadora" name="transportadora" formControlName="transportadora"\n [searchFields]="transportadoraSearchFields" [searchGridFields]="transportadoraSearchGridFields"\n [searchGridData]="transportadoraSearchGridData" [multiple]="false"\n [lookupSuggestions]="transportadoraLookupSuggestions"\n (onLookupRequest)="onTransportadoraLookupRequest($event)"\n (onSearchRequest)="onTransportadoraSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="transportadoraSearchTotalRecords"\n [searchTitle]="\'yms.erp.transportadora_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: transportadoraSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="numeroAgendamentoCliente">Número agendamento do cliente</label>\n <input type="text" pInputText formControlName="numeroAgendamentoCliente" pattern="[0-9]+$">\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="numeroPedidoCliente">Número pedido do cliente</label>\n <input type="text" pInputText formControlName="numeroPedidoCliente" pattern="[0-9]+$">\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="itemPedidoCliente">Item pedido do cliente</label>\n <input type="text" pInputText formControlName="itemPedidoCliente" pattern="[0-9]+$">\n </div>\n <div class="ui-g-12" style="text-align: right;" *ngIf="totalEixosContratados || totalEixosComposicao">\n <label for="totalEixosContratados" float="right" style="display: inline;">{{totalEixosContratados}} {{\'yms.erp.total_eixos_contratados\' | translate}} / </label>\n <label for="totalEixosComposicao" float="right" style="display: inline;">{{totalEixosComposicao}} {{\'yms.erp.total_eixos_composicao\' | translate}}</label>\n </div>\n </div>\n </div>\n </form>\n\n <div style="margin: 5px 0 5px 0;">\n <s-button priority="primary" [label]="\'save\' | translate" (onClick)="onSave()" [disabled]="disableButtonSave"></s-button>\n <s-button *ngIf="saveAndInitButton" priority="primary" [label]="\'save_and_init\' | translate" (onClick)="onSave(true)" [disabled]="disableButtonSave"></s-button>\n </div>\n\n <form [formGroup]="pedidoVendaForm" [hidden]="true">\n <s-lookup dataKey="id" id="pedidoVenda" name="pedidoVenda" formControlName="pedidoVenda"\n [searchFields]="pedidoVendaSearchFields" [searchGridFields]="pedidoVendaSearchGridFields"\n [searchGridData]="pedidoVendaSearchGridData" [multiple]="false"\n [lookupSuggestions]="pedidoVendaLookupSuggestions" (onLookupRequest)="onPedidoVendaLookupRequest($event)"\n (onSearchRequest)="onPedidoVendaSearchRequest($event)" lookupDisplayField="label"\n (onSelect)="selecionarPedidoVenda($event)" [searchTotalRecords]="pedidoVendaSearchTotalRecords"\n [searchTitle]="\'yms.erp.pedido_venda_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate" [filterLabel]="\'yms.erp.filter\' | translate"\n [clearLabel]="\'yms.erp.clear\' | translate" [cancelLabel]="\'yms.erp.cancel\' | translate"\n [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: pedidoVendaSearchTotalRecords}">\n </s-lookup>\n </form>\n\n <p-dialog [(visible)]="visibleDialog" styleClass="s-lookup-modal" [modal]="true">\n <p-header>\n Adicionar item\n </p-header>\n\n <form [formGroup]="itemFormGroup">\n <div class="ui-fluid">\n <div class="ui-g">\n <div class="ui-g-12 ui-md-6">\n <label for="item">Item do pedido</label>\n <s-lookup dataKey="id" id="item" name="item" formControlName="item"\n [searchFields]="pedidoVendaItemSearchFields"\n [searchGridFields]="pedidoVendaItemSearchGridFields"\n [searchGridData]="pedidoVendaItemSearchGridData" [multiple]="false"\n [lookupSuggestions]="pedidoVendaItemLookupSuggestions"\n (onLookupRequest)="onPedidoVendaItemLookupRequest($event)"\n (onSearchRequest)="onPedidoVendaItemSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="pedidoVendaItemSearchTotalRecords"\n [searchTitle]="\'yms.erp.expedicao_pedido_venda_itens_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: pedidoVendaItemSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="quantidade">Quantidade</label>\n <input type="number" pInputText formControlName="quantidade">\n </div>\n </div>\n </div>\n </form>\n\n <p-footer>\n <s-button [label]="\'select\' | translate" (onClick)="selecionarPedidoVendaItem()"></s-button>\n </p-footer>\n </p-dialog>\n</div>',styles:[".required-h3{font-size:1.17rem;font-weight:700}.required-h3::after{content:'*';color:#c13018;font-weight:400;margin-left:5px;font-size:14px}.error-required-message{color:#c13018;margin-top:5px;font-size:12px}.separator{width:100%;margin:5px 0;height:1px;background-color:#ccc}.input-error{color:#c13018}.detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nota-error{color:#c13018}"]}),B("design:paramtypes",[Ft,F.Router,F.ActivatedRoute,T.MessageService,C.FormBuilder,o.TranslateService,O.HotkeysService,Be,Ue,Ra,ha,Ua,Sa,ba,vt,St,c.ConfirmationService,La,qa,Na])],e)}(),Ri=function(){function e(e){this.expedicaoService=e,this.loading=!0,this.unsubscribe$=new t.Subject}return e.prototype.ngAfterViewInit=function(){var e=this;this.expedicaoService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",page:0,size:1}).pipe(a.takeUntil(this.unsubscribe$),a.switchMap(function(e){var a=e.contents;return a.length?t.of(a[0]):t.throwError("Dados de expedição não encontrados")}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){return e.expedicao=ki.fromDto(t)})},V([r.Input(),B("design:type",Object)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"expedicao-info",template:'\n <div *sLoadingState="loading" style="padding: 20px">\n <div class="detail-pane" *ngIf="agenda && expedicao">\n <div class="detail-span">\n <span class="title">{{\'yms.erp.expedicao_filial\' | translate}}</span>\n <span class="data">{{expedicao.filial?.codigo}} - {{expedicao.filial?.nome}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.expedicao_cliente_faturamento\' | translate}}</span>\n <span class="data">{{expedicao.clienteFaturamento?.nome}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.expedicao_cliente_remessa\' | translate}}</span>\n <span class="data">{{expedicao.clienteRemessa?.nome}}</span>\n </div>\n <div class="detail-span">\n <span class="title">{{\'yms.erp.expedicao_transportadora\' | translate}}</span>\n <span class="data">{{expedicao.transportadora?.pessoa?.nomeFantasia}}</span>\n </div>\n </div>\n </div>\n ',styles:[".detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}"]}),B("design:paramtypes",[Ft])],e)}(),Ai=function(){function e(){}return e=V([p.CircuitoFinalizado({header:"Logs de integração YMS/ERP",name:"yms.integracao.erpagrox"})],e)}(),Ei=function(e){function i(a,i,r){var o=e.call(this)||this;return o.route=a,o.logIntegracaoService=i,o.translate=r,o.allPermissions={},o.permissions={},o.localeConfig={},o.currentListParams={page:0,size:10,sort:[],filterData:{}},o.serverError=!1,o.ngUnsubscribe=new t.Subject,o.xmlFormatter=require("xml-formatter")||function(e,t){return e},o}return P(i,e),i.prototype.ngOnInit=function(){var e=this;this.gridColumns=this.getGridColumns(),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)})},i.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete()},i.prototype.onRouteDataChange=function(e){this.allPermissions=e.allPermissions,this.permissions=e.allPermissions.logIntegracao,this.localeConfig=e.localeConfig},i.prototype.onSearch=function(){this.resetGrid()},i.prototype.onGridChange=function(e){var t=e.rows,a=e.first/t,i=e.multiSortMeta;return this.updateGrid({page:a,size:t,sort:i})},i.prototype.getProp=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},i.prototype.getGridColumns=function(){return[{field:"nome",header:this.translate.instant("yms.integration.log_integracao_nome")},{field:"entradaEm",header:this.translate.instant("yms.integration.log_integracao_entrada_em")},{field:"saidaEm",header:this.translate.instant("yms.integration.log_integracao_saida_em")}]},i.prototype.updateGrid=function(e){var t=this;void 0===e&&(e={}),this.showLoader=!0,this.currentListParams=j({},this.currentListParams,e);var i=this.currentListParams,r=i.page,o=i.size;this.logIntegracaoService.list({page:r,size:o,sort:[{field:"entradaEm",order:-1}],filterQuery:"agenda eq '"+this.agenda.id+"'",displayFields:["*"]}).pipe(a.takeUntil(this.ngUnsubscribe),a.catchError(function(e){throw t.serverError=!0,e}),a.finalize(function(){t.showLoader=!1})).subscribe(function(e){t.selection=[],t.gridData=e.contents,t.totalRecords=e.totalElements,t.serverError=!1})},i.prototype.getPayload=function(e){return"{"==e[0]?JSON.stringify(JSON.parse(e),null,2):"<"===e[0]?this.xmlFormatter(e):e},i.prototype.resetGrid=function(e){e&&(this.currentListParams=j({},this.currentListParams,e)),this.currentListParams=j({},this.currentListParams,{page:0,sort:[]}),this.table.reset()},i.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup&&t.validateAllFormFields(i)})},V([r.Input(),B("design:type",we)],i.prototype,"agenda",void 0),V([r.ViewChild("logIntegracaoTable"),B("design:type",l.Table)],i.prototype,"table",void 0),V([r.ViewChild("customTemplate"),B("design:type",r.TemplateRef)],i.prototype,"customTemplate",void 0),V([r.ViewChild("customFilterFields"),B("design:type",r.TemplateRef)],i.prototype,"customFilterFields",void 0),V([r.ViewChild("customGridColgroup"),B("design:type",r.TemplateRef)],i.prototype,"customGridColgroup",void 0),V([r.ViewChild("customGridHeader"),B("design:type",r.TemplateRef)],i.prototype,"customGridHeader",void 0),V([r.ViewChild("customGridBody"),B("design:type",r.TemplateRef)],i.prototype,"customGridBody",void 0),i=V([r.Component({template:'<div *sLoadingState="showLoader">\n <s-empty-state *ngIf="serverError" iconClass="fa fa-exclamation-triangle" title="{{\'yms.integration.error_server_title\' | translate}}"\n primaryActionLabel="{{\'yms.integration.error_server_try_again\' | translate}}" (primaryAction)="resetGrid()"\n description="{{\'yms.integration.error_server_description\' | translate}}"></s-empty-state>\n <s-empty-state *ngIf="gridData && !gridData.length" [title]="\'yms.integration.log_integracao_empty_state_title\' | translate"\n [description]="\'yms.integration.log_integracao_empty_state_description\' | translate"></s-empty-state>\n <div [attr.data-hidden]="!gridData?.length || serverError">\n <div class="ui-g">\n <div class="ui-g-12">\n <p-table #logIntegracaoTable [value]="gridData" [columns]="gridColumns" dataKey="id" [lazy]="true" [scrollable]="true"\n [resizableColumns]="true" [paginator]="true" [totalRecords]="totalRecords"\n rows="10" [rowsPerPageOptions]="[10, 20, 50, 100]" [(selection)]="selection" (onLazyLoad)="onGridChange($event)" >\n <ng-template pTemplate="colgroup" let-columns *ngIf="!customGridColgroup else customGridColgroup">\n <colgroup>\n <col *ngFor="let col of columns" [style.width]="col.width">\n \x3c!--{CA:GRID_COLGROUP_COLUMNS:START}--\x3e\n \x3c!--{CA:GRID_COLGROUP_COLUMNS:END}--\x3e\n </colgroup>\n </ng-template>\n <ng-template pTemplate="header" let-columns *ngIf="!customGridHeader else customGridHeader">\n <tr>\n <th style="width: 50px">\n \n </th>\n <th *ngFor="let col of columns; let i = index" [ngStyle]="i === 0 ? {\'width\': \'200px\'} : {\'width\': \'150px\'}" pResizableColumn>\n <div class="senior-header">\n <span class="senior-header-title">{{col.header}}</span>\n </div>\n </th>\n \x3c!--{CA:GRID_HEADER_COLUMNS:START}--\x3e\n \x3c!--{CA:GRID_HEADER_COLUMNS:END}--\x3e\n </tr>\n </ng-template>\n <ng-template pTemplate="body" let-rowData let-columns let-expanded="expanded" *ngIf="!customGridBody else customGridBody">\n <tr [pSelectableRow]="rowData">\n <td style="width: 50px;">\n <a href="#" [pRowToggler]="rowData">\n <i [ngClass]="expanded ? \'pi pi-chevron-down\' : \'pi pi-chevron-right\'"></i>\n </a>\n </td>\n <td (click)="selection = [rowData]" style="width: 200px">\n <span>{{getProp(rowData, \'nome\') || (\'yms.integration.list_grid_empty_field\' | translate)}}</span>\n </td>\n <td (click)="selection = [rowData]" style="width: 150px">\n <span>{{getProp(rowData, \'entradaEm\') | localizedDate | async}}</span>\n </td>\n <td (click)="selection = [rowData]" style="width: 150px">\n <span>{{getProp(rowData, \'saidaEm\') | localizedDate | async}}</span>\n </td>\n \x3c!--{CA:GRID_BODY_COLUMNS:START}--\x3e\n \x3c!--{CA:GRID_BODY_COLUMNS:END}--\x3e\n </tr>\n </ng-template>\n <ng-template pTemplate="rowexpansion" let-rowData>\n <td colspan="4">\n <p-tabView>\n <p-tabPanel header="Payload de entrada">\n <pre *ngIf="rowData.entrada">\n <code [highlight]="getPayload(rowData.entrada)" [languages]="[\'json\', \'xml\']">\n </code>\n </pre>\n <s-empty-state *ngIf="!rowData.entrada" [title]="\'Não há informação\' | translate"\n [description]="\'Não há informações a serem exibidas\' | translate">\n </s-empty-state>\n </p-tabPanel>\n <p-tabPanel header="Payload de saída">\n <pre *ngIf="rowData.saida">\n <code [highlight]="getPayload(rowData.saida)" [languages]="[\'json\', \'xml\']">\n </code>\n </pre>\n <s-empty-state *ngIf="!rowData.saida" [title]="\'Não há informação\' | translate"\n [description]="\'Não há informações a serem exibidas\' | translate">\n </s-empty-state>\n </p-tabPanel>\n <p-tabPanel header="Stack Trace">\n <pre *ngIf="rowData.stackTrace">\n <code [highlight]="getPayload(rowData.stackTrace)" [languages]="[\'json\', \'xml\']">\n </code>\n </pre>\n <s-empty-state *ngIf="!rowData.stackTrace" [title]="\'Não há informação\' | translate"\n [description]="\'Não há informações a serem exibidas\' | translate">\n </s-empty-state>\n </p-tabPanel>\n </p-tabView>\n <div class="separator"></div>\n </td>\n </ng-template>\n <ng-template pTemplate="paginatorright">\n <span [translate]="\'yms.integration.total_records\'" [translateParams]="{value: totalRecords}"></span>\n </ng-template>\n \x3c!--{CA:GRID_TEMPLATES:START}--\x3e\n \x3c!--{CA:GRID_TEMPLATES:END}--\x3e\n </p-table>\n </div>\n </div>\n </div>\n</div>\n\x3c!--{CA:FILE_CONTENTS:START}--\x3e\n\x3c!--{CA:FILE_CONTENTS:END}--\x3e',providers:[L.ConfirmationService],styles:[".required-h3{font-size:1.17rem;font-weight:700}.required-h3::after{content:'*';color:#c13018;font-weight:400;margin-left:5px;font-size:14px}.error-required-message{color:#c13018;margin-top:5px;font-size:12px}.separator{width:100%;margin:5px 0;height:1px;background-color:#ccc}.input-error{color:#c13018}.detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nota-error{color:#c13018}"]}),B("design:paramtypes",[F.ActivatedRoute,ii,o.TranslateService])],i)}(Ai),Gi=function(){function e(){}return e.fromDto=function(e){var t=j({},e);return t.filial=Ht.fromDto(t.filial),t},e.toDto=function(e){var t=j({},e);return t.filial=Ht.toDto(t.filial),t},e}(),Ni=function(){function e(e,t,a){this.override=e,this.agendaService=t,this.processoAvulsoService=a,this.AVULSO_KEY="ERP_SENIOR_PROCESSO_AVULSO"}return e.prototype.initialize=function(){var e=this;this.override.addOverride(this.AVULSO_KEY,function(t){return e.functionToOverride(t)})},e.prototype.remove=function(){this.override.disposeOverride(this.AVULSO_KEY)},e.prototype.functionToOverride=function(e){var i=this;return this.agendaService.atualizarAgenda(e.agenda).pipe(a.mergeMap(function(t){return i.processoAvulsoService.list({filterQuery:"agenda.id eq '"+e.agenda.id+"'",page:0,size:1})}),a.map(function(e){var t=e.contents;return t.length?t[0]:null}),a.mergeMap(function(a){return a?i.processoAvulsoService.registrarChegada({processoAvulso:a,circuito:e.circuito.id,sequenciaInicial:e.sequencia.id,vagaInicial:(e.vaga||{}).id}):t.throwError("Os dados da guia ERP Senior não foram informados")}))},e=V([r.Injectable(),B("design:paramtypes",[p.ChegadaVeiculoOverride,vt,ti])],e)}(),Oi=function(){function e(e,a,i,r,o,n,s,l,d,c,p,u,m){this.fb=e,this.router=a,this.route=i,this.filialService=r,this.processoAvulsoService=o,this.messageService=n,this.processoAvulsoOverride=s,this.translate=l,this.confirmationService=d,this.agendaService=c,this.erpProcessService=p,this.erpFormConfigService=u,this.hasChangeService=m,this.loading=!1,this.filialLookupDisplayFields=["codigo","nome","empresa.nome"],this.filialAdvancedDisplayFields=["id","codigo","nome","empresa.nome"],this.filialLookupSeparator=" - ",this.permissions={},this.formCarregado=!1,this.ngUnsubscribe=new t.Subject}return e.prototype.ngOnInit=function(){var e=this;this.formGroup=this.fb.group({id:[undefined],filial:[undefined,C.Validators.required],agenda:[undefined]}),this.filialSearchFields=this.getFilialSearchFields(),this.filialSearchGridFields=this.getFilialSearchGridFields(),this.getProcessoAvulso(),this.formGroup.get("filial").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=e.formGroup.get("filial").value;e.erpProcessService&&a&&(e.erpProcessData.filialId=a.id,e.erpProcessService.changeData(e.erpProcessData))}),this.processoAvulsoOverride.initialize(),this.erpProcessService.current.subscribe(function(t){return e.erpProcessData=t}),this.erpFormConfigService.current.subscribe(function(t){return e.enableRevalidation=t}),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)}),this.verificaSeTemAlteracao()},e.prototype.onRouteDataChange=function(e){this.permissions=e.allPermissions.agenda},e.prototype.verificaSeTemAlteracao=function(){var e=this;this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.ngAfterViewInit=function(){var e=this;this.saveAndInitButton=document.getElementById("init"),this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete(),this.processoAvulsoOverride.remove()},e.prototype.onSave=function(e){var t=this;return this.formGroup.invalid?this.validateAllFormFields(this.formGroup):(this.loading=!0,this.isNew()||!this.enableRevalidation?this.saveAndInit(e):(this.erpProcessData=this.erpProcessService.builderErpProcessData(this.erpProcessData,this.formGroup),this.erpProcessService.changeDataErp(this.erpProcessData),this.agendaService.checarRevalidacao(this.erpProcessData).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){a.requerRevalidacao?t.atualizaAgendaParaRejeitadoPorValidacao():t.saveAndInit(e)})))},e.prototype.atualizaAgendaParaRejeitadoPorValidacao=function(){var e=this;this.confirmationService.confirm({header:this.translate.instant("yms.patio.agenda_revalidacao_title"),message:this.translate.instant("yms.patio.agenda_revalidacao_message"),accept:function(){e.hasChangeService.hasChangeSave(e.agenda.id),e.agenda.status=dt.REJEITADO_POR_VALIDACAO,e.agenda.motorista={id:e.erpProcessData.motoristaId},e.agenda.veiculo={id:e.erpProcessData.veiculoId},e.agendaService.atualizarAgenda(e.agenda).pipe(a.takeUntil(e.ngUnsubscribe),a.concatMap(function(t){return e.getSaveObservable()}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.successMessage(),e.router.navigate(["/chegada-veiculo"],{relativeTo:e.route})})},reject:function(){return e.loading=!1}})},e.prototype.saveAndInit=function(e){var t=this;this.getSaveObservable().pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){t.formGroup.patchValue(j({},Gi.fromDto(a))),t.successMessage(),t.hasChangeService.hasChangeSave(t.agenda.id),e&&t.saveAndInitButton&&(t.hasChangeService.hasChangeSave(t.agenda.id),t.saveAndInitButton.click())})},e.prototype.successMessage=function(){this.messageService.add({severity:"success",summary:this.translate.instant("saved_message_title"),detail:this.translate.instant("saved_message_content")})},e.prototype.isNew=function(){return!this.formGroup.value.id},e.prototype.onFilialLookupRequest=function(e){var t=this,i=this.getFilialSearchFields().filter(function(t){var a=t.type;return Te(a,e)}).reduce(function(t,a){var i,r,o=a.name;return a.type===n.FieldType.Integer?j({},t,((i={})[o]=e.replace(/\D/,""),i)):j({},t,((r={})[o]=e,r))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:10,offset:0}});this.filialService.listFiliais(i).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.filialLookupSuggestions=e.filiais.map(function(e){return Ht.fromDto(e)})})},e.prototype.onFilialSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getFilialSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}});this.filialService.listFiliais(p).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.filialSearchGridData=e.filiais.map(Ht.fromDto),t.filialSearchTotalRecords=e.qtdTotalRegistros})},e.prototype.getSaveObservable=function(){var e=this.formGroup.value;e.agenda=this.agenda;var t=Gi.toDto(e);return e.id?this.processoAvulsoService.update(e.id,t):this.processoAvulsoService.insert(t)},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup?t.validateAllFormFields(i):i instanceof C.FormArray&&i.controls.forEach(function(e){return t.validateAllFormFields(e)})})},e.prototype.getProcessoAvulso=function(){var e=this;this.processoAvulsoService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",size:1,page:0}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;if(!a||a.length<=0)return e.buscarFilial();var i=a[0];e.formGroup.patchValue(j({},Gi.fromDto(i))),e.formCarregado=!0})},e.prototype.getFilialSearchFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")})]},e.prototype.getFilialSearchGridFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")})]},e.prototype.buscarFilial=function(){var e=this,t=this.agenda.planta||{cnpj:[]};1===t.cnpj.length&&this.filialService.list({page:0,size:1,filterQuery:"pessoa.cpfCnpj eq '"+t.cnpj[0]+"'",displayFields:["*","empresa.nome"]}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;1===a.length&&e.formGroup.get("filial").setValue(Ht.fromDto(a[0]))}),this.formCarregado=!0},V([r.Input(),B("design:type",we)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"processo-avulso-form",template:'<div *sLoadingState="loading">\n <form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-md-6 ui-g-12 required">\n <label for="filial">{{\'yms.erp.recebimento_ordem_compra_filial\' | translate}}</label>\n <s-lookup dataKey="id" id="filial" name="filial" formControlName="filial"\n [searchFields]="filialSearchFields" [searchGridFields]="filialSearchGridFields"\n [searchGridData]="filialSearchGridData" [multiple]="false"\n [lookupSuggestions]="filialLookupSuggestions" (onLookupRequest)="onFilialLookupRequest($event)"\n (onSearchRequest)="onFilialSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="filialSearchTotalRecords"\n [searchTitle]="\'yms.erp.filial_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: filialSearchTotalRecords}"\n [disabled]="!permissions.editar">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'filial\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n </div>\n </form>\n\n <div style="margin: 5px 0 5px 0;">\n <s-button priority="primary" [label]="\'save\' | translate" (onClick)="onSave()" \n [disabled]="loading || !permissions.editar"></s-button>\n <s-button *ngIf="saveAndInitButton" priority="primary" [label]="\'save_and_init\' | translate"\n (onClick)="onSave(true)" [disabled]="loading || !permissions.editar"></s-button>\n </div>\n</div>'}),B("design:paramtypes",[C.FormBuilder,F.Router,F.ActivatedRoute,ha,ti,c.MessageService,Ni,o.TranslateService,c.ConfirmationService,vt,La,qa,Na])],e)}(),Li=function(){function e(e){this.processoAvulsoService=e,this.loading=!1,this.unsubscribe$=new t.Subject}return e.prototype.ngAfterViewInit=function(){var e=this;this.processoAvulsoService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",page:0,size:1}).pipe(a.takeUntil(this.unsubscribe$)).subscribe(function(t){var a=t.contents;!a||a.length<=0||(e.processoAvulso=Gi.fromDto(a[0]))})},V([r.Input(),B("design:type",we)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"processo-avulso-info",template:'\n <div *sLoadingState="loading" style="padding: 20px;">\n <div class="detail-pane" *ngIf="agenda">\n <div class="detail-span">\n <span class="title">{{\'yms.erp.filial\' | translate}}</span>\n <span class="data">{{processoAvulso?.filial?.nome}} - {{processoAvulso?.filial?.codigo}}</span>\n </div>\n </div>\n </div>\n '}),B("design:paramtypes",[ti])],e)}(),qi=_,xi=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.competenciaInicial=a.competenciaInicial&&qi(a.competenciaInicial).toDate(),a.competenciaFinal=a.competenciaFinal&&qi(a.competenciaFinal).toDate(),a.createdDate=a.createdDate&&qi(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&qi(a.lastModifiedDate).toDate();return a.label=Ee(a,["codigo","descricao"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Gt.fromDto(a.empresa,"Safra")),a},e.toDto=function(e,t){var a=j({},e);return a.competenciaInicial=a.competenciaInicial&&qi(a.competenciaInicial).format("YYYY-MM-DD"),a.competenciaFinal=a.competenciaFinal&&qi(a.competenciaFinal).format("YYYY-MM-DD"),a.createdDate=a.createdDate&&qi(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&qi(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Gt.toDto(a.empresa,"Safra")),a},e}(),wi=_,Pi=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&wi(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&wi(a.lastModifiedDate).toDate();return a.label=[""].map(function(e){return a[e]}).join(" - "),"Agenda"!==t&&a.agenda&&(a.agenda=we.fromDto(a.agenda,"RecebimentoOrdemCompra")),"Empresa"!==t&&a.empresa&&(a.empresa=Gt.fromDto(a.empresa,"RecebimentoOrdemCompra")),"Filial"!==t&&a.filial&&(a.filial=Ht.fromDto(a.filial,"RecebimentoOrdemCompra")),"PessoaEndereco"!==t&&a.origemMercadoria&&(a.origemMercadoria=zt.fromDto(a.origemMercadoria,"RecebimentoOrdemCompra")),"Produto"!==t&&a.produto&&(a.produto=fi.fromDto(a.produto,"RecebimentoOrdemCompra")),"Derivacao"!==t&&a.derivacao&&(a.derivacao=gi.fromDto(a.derivacao,"RecebimentoOrdemCompra")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=yi.fromDto(a.transportadora,"RecebimentoOrdemCompra")),"Safra"!==t&&a.safra&&(a.safra=xi.fromDto(a.safra,"RecebimentoOrdemCompra")),"OrdemCompra"!==t&&a.ordemCompra&&(a.ordemCompra=Qt.fromDto(a.ordemCompra,"RecebimentoOrdemCompra")),a.fornecedores=a.fornecedores.map(function(e){return j({},e,{fornecedor:Ot.fromDto(e.fornecedor),origemMercadoria:zt.fromDto(e.origemMercadoria),ordens:e.ordens.map(Qt.fromDto)})}),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&wi(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&wi(a.lastModifiedDate).format(),delete a.label,"Agenda"!==t&&a.agenda&&(a.agenda=we.toDto(a.agenda,"RecebimentoOrdemCompra")),"Empresa"!==t&&a.empresa&&(a.empresa=Gt.toDto(a.empresa,"RecebimentoOrdemCompra")),"Filial"!==t&&a.filial&&(a.filial=Ht.toDto(a.filial,"RecebimentoOrdemCompra")),"Produto"!==t&&a.produto&&(a.produto=fi.toDto(a.produto,"RecebimentoOrdemCompra")),"Derivacao"!==t&&a.derivacao&&(a.derivacao=gi.toDto(a.derivacao,"RecebimentoOrdemCompra")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=yi.toDto(a.transportadora,"RecebimentoOrdemCompra")),"Safra"!==t&&a.safra&&(a.safra=xi.toDto(a.safra,"RecebimentoOrdemCompra")),"OrdemCompra"!==t&&a.ordemCompra&&(a.ordemCompra=Qt.toDto(a.ordemCompra,"RecebimentoOrdemCompra")),a},e}(),ji=function(){function e(e,t,a){this.override=e,this.agendaService=t,this.recebimentoOrdemCompraService=a,this.RECEBIMENTO_ORDEMCOMPRA_KEY="ERP_SENIOR_RECEBIMENTO_ORDEMCOMPRA_KEY"}return e.prototype.initialize=function(){var e=this;this.override.addOverride(this.RECEBIMENTO_ORDEMCOMPRA_KEY,function(t){return e.functionToOverride(t)})},e.prototype.remove=function(){this.override.disposeOverride(this.RECEBIMENTO_ORDEMCOMPRA_KEY)},e.prototype.functionToOverride=function(e){var i=this;return this.agendaService.atualizarAgenda(e.agenda).pipe(a.mergeMap(function(t){return i.recebimentoOrdemCompraService.list({filterQuery:"agenda.id eq '"+e.agenda.id+"'",page:0,size:1})}),a.map(function(e){var t=e.contents;return t.length?t[0]:null}),a.mergeMap(function(a){return a?i.recebimentoOrdemCompraService.registrarChegadaVeiculoRecebimentoOrdemCompra({recebimentoOrdemCompra:a,circuito:e.circuito.id,sequenciaInicial:e.sequencia.id,vagaInicial:(e.vaga||{}).id}):t.throwError("Não foi possível encontrar os dados de Recebimento de ordem de compra")}))},e=V([r.Injectable(),B("design:paramtypes",[p.ChegadaVeiculoOverride,vt,Xa])],e)}(),Vi=function(){function e(e,a,i,r,o,n,s,l,d,c,p,u,m,f,h,g,v,y,b,F,S,D,C){var _=this;this.formBuilder=e,this.translate=a,this.filialService=i,this.pessoaService=r,this.produtoService=o,this.derivacaoService=n,this.transportadoraService=s,this.ordemCompraService=l,this.recebimentoOrdemCompraService=d,this.messageService=c,this.route=p,this.router=u,this.origemMercadoriaService=m,this.safraService=f,this.override=h,this.notaValidatorService=g,this.confirmationService=v,this.dialogService=y,this.agendaService=b,this.erpProcessService=F,this.erpFormConfigService=S,this.verificaNotaFiscal=D,this.hasChangeService=C,this.derivacaoLookupDisplayFields=["codigo","descricao"],this.derivacaoAdvancedDisplayFields=["id","codigo","descricao"],this.derivacaoLookupSeparator=" - ",this.filialLookupDisplayFields=["codigo","nome","empresa.nome"],this.filialAdvancedDisplayFields=["id","codigo","nome","empresa.nome"],this.filialLookupSeparator=" - ",this.fornecedorLookupDisplayFields=["codigo","nome","cpfCnpj"],this.fornecedorAdvancedDisplayFields=["id","codigo","nome"],this.fornecedorLookupSeparator=" - ",this.ordemCompraLookupDisplayFields=["codigo","empresa.nome"],this.ordemCompraAdvancedDisplayFields=["id","codigo","empresa.nome","filial.nome","pessoa.nome"],this.ordemCompraLookupSeparator=" - ",this.origemMercadoriaLookupDisplayFields=["codigo","endereco"],this.origemMercadoriaAdvancedDisplayFields=["id","codigo","endereco","numero"],this.origemMercadoriaLookupSeparator=" - ",this.produtoLookupDisplayFields=["codigo","descricao"],this.produtoAdvancedDisplayFields=["id","codigo","descricao"],this.produtoLookupSeparator=" - ",this.safraLookupDisplayFields=["codigo","descricao"],this.safraAdvancedDisplayFields=["id","codigo","descricao"],this.safraLookupSeparator=" - ",this.transportadoraLookupDisplayFields=["codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraAdvancedDisplayFields=["id","codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraLookupSeparator=" - ",this.disableButtonSave=!1,this.totalEixosContratados=0,this.totalEixosComposicao=0,this.erroChaveNota=!1,this.erroFornecedores=!1,this.notasTokens=[],this.fornecedorNotasTokens=[],this.fornecedorNotas=[],this.formCarregado=!1,this.ordemCompraSelecionado=null,this.permissions={},this.ngUnsubscribe=new t.Subject,this.onFilialValueChange=function(e,t){_.changeFormGroupValue(e,"produto",t)},this.onFornecedorChange=function(e,t){_.changeFormGroupValue(e,"origemMercadoria",t),_.changeFormGroupValue(e,"ordens",t)},this.onChangeRevalidation=function(e){_.erpProcessData&&_.formGroup&&(_.erpProcessData=_.erpProcessService.builderErpProcessData(_.erpProcessData,_.formGroup),_.erpProcessService.changeData(_.erpProcessData))},this.formGroup=this.getFormGroup()}return e.prototype.ngOnInit=function(){var e=this;this.route.params.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.agenda;if("new"==a)return e.configureForm();e.getRecebimentoOrdemCompra(a)}),this.formGroup.get("filial").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.formGroup.get("fornecedores").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.formGroup.get("transportadora").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.derivacaoSearchFields=this.getDerivacaoSearchFields(),this.filialSearchFields=this.getFilialSearchFields(),this.filialSearchGridFields=this.getFilialSearchGridFields(),this.fornecedorSearchFields=this.getFornecedorSearchFields(),this.origemMercadoriaSearchFields=this.getOrigemMercadoriaSearchFields(),this.produtoSearchFields=this.getProdutoSearchFields(),this.safraSearchFields=this.getSafraSearchFields(),this.safraSearchGridFields=this.getSafraSearchGridFields(),this.transportadoraSearchFields=this.getTransportadoraSearchFields(),this.transportadoraSearchGridFields=this.getTransportadoraSearchGridFields(),this.ordemCompraSearchFields=this.getOrdemCompraFields(),this.ordemCompraSearchGridFields=this.getOrdemCompraGridFields(),this.agenda&&this.agenda.externalTenant&&this.setTransportadora(this.agenda.externalTenant.cnpj),this.getEmpresaFilial(),this.totalEixosComposicao=this.agenda&&this.agenda.veiculo&&this.agenda.veiculo.eixos||0;this.agenda&&!["AGUARDANDO_CONFIRMACAO_SOLICITANTE","AGENDADO","AGUARDANDO_CONFIRMACAO","REJEITADO_POR_VALIDACAO"].includes(this.agenda.status)&&(this.formGroup.disable(),this.disableButtonSave=!0),this.createdByErpDisableForm(),this.erpProcessService.current.subscribe(function(t){return e.erpProcessData=t}),this.erpFormConfigService.current.subscribe(function(t){return e.enableRevalidation=t}),this.verificaSeTemAlteracao(),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)})},e.prototype.onRouteDataChange=function(e){this.permissions=e.allPermissions.agenda},e.prototype.verificaSeTemAlteracao=function(){var e=this;this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.ngAfterViewInit=function(){this.override.initialize(),this.saveAndInitButton=document.getElementById("init")},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete(),this.override.remove()},e.prototype.createdByErpDisableForm=function(){this.agenda&&this.agenda.createdByErp&&(this.createdByErp=!0,this.formGroup.get("filial").disable(),this.formGroup.get("produto").disable(),this.formGroup.get("derivacao").disable(),this.formGroup.get("transportadora").value&&this.formGroup.get("transportadora").disable())},e.prototype.configureForm=function(){var e=this;this.valueChanges(this.formGroup,"filial",this.onFilialValueChange);this.checkValuesChanges(this.formGroup,"produto","derivacao",this.derivacaoService,function(e){return"produto.id eq '"+e.id+"' and situacao eq 'ATIVO'"},["codigo","descricao"],function(e){return gi.fromDto(e)},10,!0,!0),this.formGroup.get("fornecedores").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){t&&t.length>0?(e.formGroup.get("produto").disable(),e.formGroup.get("derivacao").disable()):(e.formGroup.get("produto").enable(),e.formGroup.get("derivacao").enable())}),this.createdByErpDisableForm(),this.formCarregado=!0},e.prototype.getEmpresaFilial=function(){var e=this,t=this.agenda.planta||{cnpj:[]};if(1===t.cnpj.length){var i="pessoa.cpfCnpj eq '"+t.cnpj[0]+"'";this.filialService.list({filterQuery:i,page:0,size:10}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;if(1===a.length){var i=a[0],r=a[0].empresa;i.label=i.codigo+" - "+i.nome,r.label=r.codigo+" - "+r.nome,e.formGroup.get("empresa").setValue(r),e.formGroup.get("filial").setValue(i),e.formGroup.get("filial").enable(),e.formGroup.get("produto").enable(),e.formGroup.get("ordemCompra").enable()}})}},e.prototype.checkValuesChanges=function(e,t,i,r,o,n,s,l,d,c){var p=this;void 0===l&&(l=1),e.get(t).valueChanges.pipe(a.takeUntil(this.ngUnsubscribe),a.debounceTime(500),a.filter(function(t){return d&&e.get(i).setValidators(t?C.Validators.required:C.Validators.nullValidator),c&&e.get(i).setValue(null),!!t||(e.get(i).setValue(null),e.get(i).disable(),!1)}),a.mergeMap(function(e){var t=o(e);return r.list({filterQuery:t,page:0,size:l})})).subscribe(function(t){var a=t.contents;if(!a||!a.length||a.length>1)return e.get(i).enable();1===a.length&&(a[0].label=p.translate.instant(Ee(a[0],n," - ",!0)),e.get(i).setValue(s(a[0]))),a.length>1?e.get(i).enable():e.get(i).disable()})},e.prototype.onBlurChaveNotaFiscal=function(){var e=this;if(!this.verificaNotaFiscal.verificaSeNotaFiscalEstaDuplicada(this.chaveNotaFiscal,this.ordens,this.fornecedorNotasTokens)){this.removeNotaError();var t=this.chaveNotaFiscal;t&&(this.loading=!0,this.mensagemBuscandoNota(),this.notaValidatorService.pesquisarDocumentoValidaNotaEmUso({filialId:this.formGroup.get("filial").value&&this.formGroup.get("filial").value.id||null,chaveDocumento:t.trim()||""}).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.addNovaNota(t)}))}},e.prototype.valueChanges=function(e,t,i){e.get(t).valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return i(t,e)})},e.prototype.changeFormGroupValue=function(e,t,a){if(!e)return a.get(t).setValue(undefined),void a.get(t).disable();a.get(t).enable()},e.prototype.getRecebimentoOrdemCompra=function(e){var t=this;this.loading=!0,this.recebimentoOrdemCompraService.list({filterQuery:"agenda.id eq '"+e+"'",size:1,page:0}).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(e){var a=e.contents;if(!a.length)return t.formCarregado=!0,t.configureForm();t.totalEixosContratados=a[0].eixos||0,t.totalEixosComposicao=a[0].agenda&&a[0].agenda.veiculo&&a[0].agenda.veiculo.eixos||0;var i=Pi.fromDto(a[0]);t.formGroup.enable(),t.formGroup.patchValue(i),i.fornecedores.forEach(function(e){var a=t.getFornecedorForm(e);t.getFornecedoresForm().push(a),e.ordens.forEach(function(e){var i=t.getOrdemCompraForm(e);t.getOrdensCompra(a).push(i),e.notas.forEach(function(e){var a=t.getNotaForm(e);t.getNotas(i).push(a)})})}),t.configureForm()})},e.prototype.onFilialLookupRequest=function(e){var t=this,i=this.getFilialSearchFields().filter(function(t){var a=t.type;return Te(a,e)}).reduce(function(t,a){var i,r,o=a.name;return a.type===n.FieldType.Integer?j({},t,((i={})[o]=e.replace(/\D/,""),i)):j({},t,((r={})[o]=e,r))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:10,offset:0}});this.filialService.listFiliais(i).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.filialLookupSuggestions=e.filiais.map(function(e){return Ht.fromDto(e)})})},e.prototype.onFilialSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getFilialSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}});this.filialService.listFiliais(p).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.filialSearchGridData=e.filiais.map(Ht.fromDto),t.filialSearchTotalRecords=e.qtdTotalRegistros})},e.prototype.onFornecedorLookupRequest=function(e){var t=this;Le(this.fornecedorSearchFields,this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields,this.fornecedorLookupSeparator,this.pessoaService,e," fornecedor eq true ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.fornecedorLookupSuggestions=e.contents})},e.prototype.onFornecedorSearchRequest=function(e){var t=this;qe(this.fornecedorSearchFields,this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields,this.fornecedorLookupSeparator,this.pessoaService,e," fornecedor eq true ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.fornecedorSearchGridData=e.contents,t.fornecedorSearchTotalRecords=e.totalElements})},e.prototype.onOrigemMercadoriaLookupRequest=function(e,t){var i=this;Le(this.origemMercadoriaSearchFields,this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields,this.origemMercadoriaLookupSeparator,this.origemMercadoriaService,t," pessoa.id eq '"+e.get("fornecedor").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){i.origemMercadoriaLookupSuggestions=e.contents})},e.prototype.onOrigemMercadoriaSearchRequest=function(e,t){var i=this;qe(this.origemMercadoriaSearchFields,this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields,this.origemMercadoriaLookupSeparator,this.origemMercadoriaService,t," pessoa.id eq '"+e.get("fornecedor").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){i.origemMercadoriaSearchGridData=e.contents,i.origemMercadoriaSearchTotalRecords=e.totalElements})},e.prototype.onDerivacaoLookupRequest=function(e){var t=this;Le(this.derivacaoSearchFields,this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields,this.derivacaoLookupSeparator,this.derivacaoService,e," produto.id eq '"+this.formGroup.get("produto").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.derivacaoLookupSuggestions=e.contents})},e.prototype.onDerivacaoSearchRequest=function(e){var t=this;qe(this.derivacaoSearchFields,this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields,this.derivacaoLookupSeparator,this.derivacaoService,e," produto.id eq '"+this.formGroup.get("produto").value.id+"' ").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.derivacaoSearchGridData=e.contents,t.derivacaoSearchTotalRecords=e.totalElements})},e.prototype.onOrdemCompraLookupRequest=function(e,t){var i=this;Le(this.ordemCompraSearchFields,this.ordemCompraLookupDisplayFields,this.ordemCompraAdvancedDisplayFields,this.ordemCompraLookupSeparator,this.ordemCompraService,t,"filial.id eq '"+this.formGroup.get("filial").value.id+"' and pessoa.id eq '"+e.get("fornecedor").value.id+"'").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){i.ordemCompraLookupSuggestions=e.contents})},e.prototype.onOrdemCompraSearchRequest=function(e,t){var i=this;qe(this.ordemCompraSearchFields,this.ordemCompraLookupDisplayFields,this.ordemCompraAdvancedDisplayFields,this.ordemCompraLookupSeparator,this.ordemCompraService,t,"filial.id eq '"+this.formGroup.get("filial").value.id+"' and pessoa.id eq '"+e.get("fornecedor").value.id+"'").pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){i.ordemCompraSearchGridData=e.contents,i.ordemCompraSearchTotalRecords=e.totalElements})},e.prototype.addOrdemCompra=function(e){var t=this;this.dialogService.open(Jt,j({},Re,{header:"Adicionar Ordem de Compra",data:{agenda:this.agenda,filial:this.formGroup.get("filial").value,fornecedor:e.get("fornecedor").value,ordens:e.get("ordens").value}})).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(a){return t.onOrdemCompraSaved(a,e)})},e.prototype.onProdutoLookupRequest=function(e){var t=this,i=this.formGroup.get("filial").value,r=this.agenda.tipoAgendamento;this.produtoService.listProdutos({pesquisa:e,empresaId:i?i.empresa.id:null,filialId:i?i.id:null,tipoAgendamentoId:r?r.id:null,situacao:"ATIVO",pagina:{limit:100,offset:0}}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.produtoLookupSuggestions=e.produtos.map(fi.fromDto)})},e.prototype.onProdutoSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getProdutoSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}}),u=this.formGroup.get("filial").value,m=this.agenda.tipoAgendamento;this.produtoService.listProdutos(j({},p,{empresaId:u?u.empresa.id:null,filialId:u?u.id:null,situacao:"ATIVO",tipoAgendamentoId:m?m.id:null})).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.produtoSearchTotalRecords=e.qtdTotalRegistros,t.produtoSearchGridData=e.produtos.map(fi.fromDto)})},e.prototype.onSafraLookupRequest=function(e){var t=this;Le(this.safraSearchFields,this.safraLookupDisplayFields,this.safraAdvancedDisplayFields,this.safraLookupSeparator,this.safraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.safraLookupSuggestions=e.contents})},e.prototype.onSafraSearchRequest=function(e){var t=this;qe(this.safraSearchFields,this.safraLookupDisplayFields,this.safraAdvancedDisplayFields,this.safraLookupSeparator,this.safraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.safraSearchGridData=e.contents,t.safraSearchTotalRecords=e.totalElements})},e.prototype.onTransportadoraLookupRequest=function(e){var t=this;Le(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraLookupSuggestions=e.contents})},e.prototype.onTransportadoraSearchRequest=function(e){var t=this;qe(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraSearchGridData=e.contents,t.transportadoraSearchTotalRecords=e.totalElements})},e.prototype.setTransportadora=function(e){var t=this;if(e){var i="pessoa.cpfCnpj eq '"+e.replace(/\./g,"").replace(/\//g,"").replace(/\-/g,"")+"'";this.transportadoraService.list({filterQuery:i,page:0,size:10}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;1===a.length&&(a[0].label=t.translate.instant(Ee(a[0],["codigo","pessoa.nome"]," - ",!0)),t.formGroup.get("transportadora").setValue(a[0]))})}},e.prototype.onSave=function(e){var t=this;return this.formGroup.get("agenda").setValue(this.agenda),this.formGroup.invalid?this.validateAllFormFields(this.formGroup):this.formGroup.get("fornecedores").length<=0?void(this.erroFornecedores=!0):(this.loading=!0,this.isNew()||!this.enableRevalidation?this.saveAndInit(e):(this.erpProcessData=this.erpProcessService.builderErpProcessDataValidaNotaNaOrdemCompra(this.erpProcessData,this.formGroup),this.erpProcessService.changeDataErp(this.erpProcessData),this.agendaService.checarRevalidacao(this.erpProcessData).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){a.requerRevalidacao?t.atualizaAgendaParaRejeitadoPorValidacao():t.saveAndInit(e)})))},e.prototype.atualizaAgendaParaRejeitadoPorValidacao=function(){var e=this;this.confirmationService.confirm({header:this.translate.instant("yms.patio.agenda_revalidacao_title"),message:this.translate.instant("yms.patio.agenda_revalidacao_message"),accept:function(){e.hasChangeService.hasChangeSave(e.agenda.id),e.agenda.status=dt.REJEITADO_POR_VALIDACAO,e.agenda.motorista={id:e.erpProcessData.motoristaId},e.agenda.veiculo={id:e.erpProcessData.veiculoId},e.agendaService.atualizarAgenda(e.agenda).pipe(a.takeUntil(e.ngUnsubscribe),a.concatMap(function(t){return e.getSaveObservable()}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.successMessage(),e.router.navigate(["/chegada-veiculo"],{relativeTo:e.route})})},reject:function(){return e.loading=!1}})},e.prototype.saveAndInit=function(e){var t=this;this.getSaveObservable().pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){t.formGroup.get("id").setValue(a.id||null),t.successMessage(),t.hasChangeService.hasChangeSave(t.agenda.id),e&&t.saveAndInitButton&&t.saveAndInitButton.click()})},e.prototype.successMessage=function(){this.messageService.add({severity:"success",summary:this.translate.instant("saved_message_title"),detail:this.translate.instant("saved_message_content")})},e.prototype.isNew=function(){return!this.formGroup.value.id},e.prototype.addFornecedor=function(e){this.erroFornecedores=!1;var t=this.getFornecedorForm(e);return this.getFornecedoresForm().push(t),t},e.prototype.removeFornecedor=function(e){var t=this;this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_fornecedor_header"),message:this.translate.instant("yms.erp.remove_fornecedor_message"),accept:function(){var a=t.getFornecedoresForm().controls.indexOf(e);t.getFornecedoresForm().removeAt(a)}})},e.prototype.getFornecedorForm=function(e){void 0===e&&(e={});var t=this.formBuilder.group({fornecedor:[e.fornecedor,C.Validators.required],origemMercadoria:[e.origemMercadoria],ordens:this.formBuilder.array([])});this.valueChanges(t,"fornecedor",this.onFornecedorChange);return this.checkValuesChanges(t,"fornecedor","origemMercadoria",this.origemMercadoriaService,function(e){return"pessoa.id eq '"+e.id+"'"},["codigo","endereco"],function(e){return zt.fromDto(e)},10,!1,!0),t},e.prototype.getFornecedoresForm=function(){return this.formGroup.get("fornecedores")},e.prototype.getNotas=function(e){return e.get("notas")},e.prototype.addNota=function(e){var t=this;this.dialogService.open(Wt,j({header:this.translate.instant("yms.erp.adicionar_nota")},Re,{data:{fornecedor:e.get("fornecedor").value,produto:this.formGroup.get("produto").value,filial:this.formGroup.get("filial").value,fornecedorNotasTokens:this.fornecedorNotasTokens,ordens:this.ordens}})).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(a){return t.onNotaSaved(a,e)})},e.prototype.removerNota=function(e,t,a){var i=this;this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_nota_header"),message:this.translate.instant("yms.erp.remove_nota_message"),accept:function(){var r=t.value.ordemCompra.id,o=i.getNotasFromOrdens(e,r).controls.indexOf(a);i.getNotasFromOrdens(e,r).removeAt(o);var n=a.value;i.fornecedorNotasTokens.push({id:n.chaveNotaFiscal,label:n.numeroNotaFiscal}),i.fornecedorNotas.push({chaveNotaFiscal:n.chaveNotaFiscal,serieNotaFiscal:n.serieNotaFiscal,serieLegalNotaFiscal:n.serieLegalNotaFiscal,numeroNotaFiscal:n.numeroNotaFiscal})}})},e.prototype.showButtons=function(){return!!this.agenda&&[dt.AGENDADO,dt.AGUARDANDO_CONFIRMACAO,dt.AGUARDANDO_CONFIRMACAO_SOLICITANTE,dt.REJEITADO_POR_VALIDACAO].includes(this.agenda.status)},e.prototype.disableAdicionarNota=function(){return null===this.ordemCompraSelecionado||this.ordemCompraSelecionado===undefined},e.prototype.removerOrdemCompra=function(e,t){var a=this;this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_ordem_compra_header"),message:this.translate.instant("yms.erp.remove_ordem_compra_message"),accept:function(){var i=a.getOrdensCompra(e),r=i.controls.indexOf(t);i.removeAt(r)}})},e.prototype.onOrdemCompraSaved=function(e,t){var a=this.getOrdemCompraForm({ordemCompra:e});this.getOrdensCompra(t).push(a),this.getFornecedorByOrdemCompra(e,t)},e.prototype.getFornecedorByOrdemCompra=function(e,t){this.pessoaService.list({size:1,page:0,filterQuery:"id eq '"+e.pessoa.id+"'"}).pipe(a.takeUntil(this.ngUnsubscribe),a.map(function(e){var t=e.contents;return(t||[]).length&&t[0]}),a.filter(function(e){return!!e})).subscribe(function(e){t.get("fornecedor").setValue(Ot.fromDto(e))})},e.prototype.getOrdensCompra=function(e){return this.ordens=e.get("ordens"),e.get("ordens")},e.prototype.getNotasFromOrdens=function(e,t){var a,i,r=null,o=e.controls.ordens.controls;try{for(var n=z(o),s=n.next();!s.done;s=n.next()){var l=s.value;l.controls.ordemCompra.value.id===t&&(r=l.controls.notas)}}catch(d){a={error:d}}finally{try{s&&!s.done&&(i=n["return"])&&i.call(n)}finally{if(a)throw a.error}}return r},e.prototype.addFornecedorNotasTokenEmOrdemCompra=function(e,t){if(null!==this.ordemCompraSelecionado){var a=this.fornecedorNotas.filter(function(e){return e.chaveNotaFiscal===t.id}),i=this.getNotasFromOrdens(e,this.ordemCompraSelecionado.id);null!==i&&null!==a[0]&&i.push(this.getNotaForm(a[0])),this.removeFornecedorNotasTokenDaOrdemCompra(t)}else this.mensagemOrdemCompraNaoSelecionado()},e.prototype.removeFornecedorNotasTokenDaOrdemCompra=function(e){this.fornecedorNotasTokens.splice(this.fornecedorNotasTokens.indexOf(e),1),this.fornecedorNotas=this.fornecedorNotas.filter(function(t){return t.chaveNotaFiscal!==e.id})},e.prototype.getOrdemCompraForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({ordemCompra:[e.ordemCompra,C.Validators.required],notas:this.formBuilder.array([])})},e.prototype.getNotaForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({chaveNotaFiscal:[e.chaveNotaFiscal],serieNotaFiscal:[e.serieNotaFiscal],serieLegalNotaFiscal:[e.serieLegalNotaFiscal],numeroNotaFiscal:[e.numeroNotaFiscal]})},e.prototype.mensagemOrdemCompraNaoSelecionado=function(){this.addMessage("error","Ordem de compra não selecionado","Nenhum ordem de compra foi selecionado!")},e.prototype.onNotaSaved=function(e,t){if(null!==this.ordemCompraSelecionado)if(e.addFornecedor){var a=this.formGroup.get("fornecedores").controls.find(function(t){return(t.value.fornecedor||{id:undefined}).id===e.fornecedor.id}),i=e.infoNota,r=this.getNotaForm({chaveNotaFiscal:i.chave,serieNotaFiscal:i.serie,serieLegalNotaFiscal:i.serieLegal,numeroNotaFiscal:i.numero});if(a)(n=this.getNotasFromOrdens(a,this.ordemCompraSelecionado.id)).push(r),this.disableFields(a,"fornecedor","origemMercadoria");else if(t.get("fornecedor").value){var o=this.addFornecedor({fornecedor:Ot.fromDto(e.fornecedor),origemMercadoria:zt.fromDto(e.origemMercadoria)});(n=this.getNotasFromOrdens(o,this.ordemCompraSelecionado.id)).push(r),this.disableFields(o,"fornecedor","origemMercadoria")}else{t.get("fornecedor").setValue(Ot.fromDto(e.fornecedor)),t.get("origemMercadoria").setValue(zt.fromDto(e.origemMercadoria)),(n=this.getNotasFromOrdens(t,this.ordemCompraSelecionado.id)).push(r),this.disableFields(t,"fornecedor","origemMercadoria")}}else{var n;null!==(n=this.getNotasFromOrdens(t,this.ordemCompraSelecionado.id))&&n.push(this.getNotaForm(e))}else this.mensagemOrdemCompraNaoSelecionado()},e.prototype.addMessage=function(e,t,a){this.messageService.add({severity:e,summary:this.translate.instant(t),detail:this.translate.instant(a)})},e.prototype.getSaveObservable=function(){var e=this.formGroup.getRawValue();e.empresa=e.filial.empresa;var t=Pi.toDto(e),a=t.fornecedores;return t.fornecedores.forEach(function(e){t.fornecedores.forEach(function(t){e.fornecedor.id===t.fornecedor.id&&e.origemMercadoria.id===t.origemMercadoria.id&&(a=a.splice(a.indexOf(t),1))})}),t.fornecedores=a,this.isNew()&&!e.id?this.recebimentoOrdemCompraService.insert(t):this.recebimentoOrdemCompraService.update(this.formGroup.value.id,t)},e.prototype.getFormGroup=function(){return this.formBuilder.group({id:[undefined],filial:[{value:undefined,disabled:!1},C.Validators.required],fornecedores:this.formBuilder.array([]),produto:[{value:undefined,disabled:!0}],derivacao:[{value:undefined,disabled:!0}],transportadora:[undefined],safra:[undefined],agenda:[{value:undefined,disabled:!0},C.Validators.required]})},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup?t.validateAllFormFields(i):i instanceof C.FormArray&&i.controls.forEach(function(e){return t.validateAllFormFields(e)})})},e.prototype.addNovaNota=function(e){var t=(e.documentos||[]).length?e.documentos[0]:undefined;if(t){var a=Ot.fromDto(t.fornecedor),i=zt.fromDto(t.origemMercadoria);if(!this.getFornecedoresForm().controls.find(function(e){return e.value.fornecedor.id===a.id}))return this.addFornecedor({fornecedor:a,origemMercadoria:i}),void this.addFornecedorNotasToken(t);this.addFornecedorNotasToken(t)}},e.prototype.addFornecedorNotasToken=function(e){this.fornecedorNotasTokens.push({id:this.chaveNotaFiscal,label:e.numero}),this.fornecedorNotas.push({chaveNotaFiscal:this.chaveNotaFiscal,serieNotaFiscal:e.serie,serieLegalNotaFiscal:e.serieLegal,numeroNotaFiscal:e.numero}),this.chaveNotaFiscal=undefined,this.loading=!1},e.prototype.removeNotaError=function(){this.erroChaveNota=!1},e.prototype.addNotaError=function(){this.erroChaveNota=!0},e.prototype.mensagemBuscandoNota=function(){this.messageService.add({severity:"info",summary:this.translate.instant("yms.erp.nota_search_summary"),detail:this.translate.instant("yms.erp.nota_search_detail"),life:5e3})},e.prototype.disableFields=function(e){for(var t=[],a=1;a<arguments.length;a++)t[a-1]=arguments[a];t.forEach(function(t){return e.get(t).disable()})},e.prototype.getDerivacaoSearchFields=function(){return[new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.derivacao_descricao")}),new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.derivacao_codigo")})]},e.prototype.getFilialSearchFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")})]},e.prototype.getFilialSearchGridFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.filial_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")})]},e.prototype.getFornecedorSearchFields=function(){return[new n.FormField({name:"nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_codigo")}),new n.FormField({name:"cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_cpfCnpj")})]},e.prototype.getOrigemMercadoriaSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_endereco_codigo")}),new n.FormField({name:"numero",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_endereco_numero")}),new n.FormField({name:"endereco",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_endereco_endereco")})]},e.prototype.getProdutoSearchFields=function(){return[new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.produto_descricao")}),new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.produto_codigo")})]},e.prototype.getSafraSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.safra_codigo")}),new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.safra_descricao")})]},e.prototype.getSafraSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.safra_codigo")}),new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.safra_descricao")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.safra_empresa")})]},e.prototype.getTransportadoraSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_descricao")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getTransportadoraSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getOrdemCompraFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.ordem_compra_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")}),new n.FormField({name:"filial.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial")})]},e.prototype.getOrdemCompraGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.ordem_compra_codigo")}),new n.FormField({name:"empresa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.empresa")}),new n.FormField({name:"filial.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.filial")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.pessoa_nome")})]},V([r.Input(),B("design:type",we)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"recebimento-ordem-compra-form",template:'<p-confirmDialog [acceptLabel]="\'yes\' | translate" acceptIcon="" [rejectLabel]="\'no\' | translate" rejectIcon="">\n</p-confirmDialog>\n<div *sLoadingState="loading">\n <form [formGroup]="formGroup">\n <div class="ui-fluid ui-g">\n\n <div class="ui-g-12">\n <label for="chaveNotaFiscal">{{\'yms.erp.recebimento_chave_nota_fiscal\' | translate}}</label>\n <input pInputText type="text" [(ngModel)]="chaveNotaFiscal" [ngModelOptions]="{standalone: true}" (blur)="onBlurChaveNotaFiscal()">\n \x3c!-- <input [class.ng-invalid]="erroChaveNota" pInputText type="text" [(ngModel)]="chaveNotaFiscal" [ngModelOptions]="{standalone: true}" (blur)="onBlurChaveNotaFiscal()"> --\x3e\n \x3c!-- <span class="input-error" *ngIf="erroChaveNota">{{\'yms.erp.produto_nota_error_detail\' | translate}}</span> --\x3e\n </div>\n\n <div class="ui-md-6 ui-g-12 required">\n <label for="filial">{{\'yms.erp.recebimento_ordem_compra_filial\' | translate}}</label>\n <s-lookup dataKey="id" id="filial" name="filial" formControlName="filial"\n [searchFields]="filialSearchFields" [searchGridFields]="filialSearchGridFields"\n [searchGridData]="filialSearchGridData" [multiple]="false"\n [lookupSuggestions]="filialLookupSuggestions" (onLookupRequest)="onFilialLookupRequest($event)"\n (onSearchRequest)="onFilialSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="filialSearchTotalRecords"\n [searchTitle]="\'yms.erp.filial_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: filialSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'filial\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n\n <div class="ui-md-6 ui-g-12">\n <label for="transportadora">{{\'yms.erp.recebimento_ordem_compra_transportadora\' | translate}}</label>\n <s-lookup dataKey="id" id="transportadora" name="transportadora" formControlName="transportadora"\n [searchFields]="transportadoraSearchFields" [searchGridFields]="transportadoraSearchFields"\n [searchGridData]="transportadoraSearchGridData" [multiple]="false"\n [lookupSuggestions]="transportadoraLookupSuggestions"\n (onLookupRequest)="onTransportadoraLookupRequest($event)"\n (onSearchRequest)="onTransportadoraSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="transportadoraSearchTotalRecords"\n [searchTitle]="\'yms.erp.transportadora_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: transportadoraSearchTotalRecords}">\n </s-lookup>\n </div>\n\n <div class="ui-g-12" style="text-align: right;" *ngIf="totalEixosContratados || totalEixosComposicao">\n <label for="totalEixosContratados" float="right" style="display: inline;">\n {{totalEixosContratados}} {{\'yms.erp.total_eixos_contratados\' | translate}} /\n </label>\n <label for="totalEixosComposicao" float="right" style="display: inline;">\n {{totalEixosComposicao}} {{\'yms.erp.total_eixos_composicao\' | translate}}\n </label>\n </div>\n\n <div class="ui-md-12">\n <s-button *ngIf="showButtons() && !!formGroup.get(\'filial\').value && !createdByErp" styleClass="btn-erp-forms" \n iconClass="fas fa-plus" label="Adicionar fornecedor" priority="secondary" \n (onClick)="addFornecedor()" [disabled]="disableButtonSave || !permissions.editar"></s-button>\n <span style="display: block;" class="input-error" *ngIf="erroFornecedores">{{\'Selecione ao menos um fornecedor para continuar\' | translate}}</span>\n </div>\n\n <form class="ui-g-12" *ngFor="let fornecedorForm of getFornecedoresForm().controls; let i = index;" [formGroup]="fornecedorForm">\n <p-panel [style]="{position: \'relative\'}" styleClass="form-group ui-g-12 ui-md-12" [toggleable]="true">\n\n <p-header>\n Fornecedor {{+i+1}}\n <s-button \n style="display: inline-block; position: absolute; right: 50px; top: 10px" \n *ngIf="showButtons() && !createdByErp"\n iconClass="fas fa-trash"\n label="Remover"\n priority="default"\n [auxiliary]="true"\n (onClick)="removeFornecedor(fornecedorForm)">\n </s-button>\n </p-header>\n \n <div class="ui-md-6 ui-g-12 required">\n <label for="fornecedor">{{\'yms.erp.recebimento_ordem_compra_fornecedor\' | translate}}</label>\n <s-lookup dataKey="id" id="fornecedor" name="fornecedor" formControlName="fornecedor"\n [searchFields]="fornecedorSearchFields" [searchGridFields]="fornecedorSearchFields"\n [searchGridData]="fornecedorSearchGridData" [multiple]="false"\n [lookupSuggestions]="fornecedorLookupSuggestions"\n (onLookupRequest)="onFornecedorLookupRequest($event)"\n (onSearchRequest)="onFornecedorSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="fornecedorSearchTotalRecords"\n [searchTitle]="\'yms.erp.fornecedor_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: { value: fornecedorSearchTotalRecords }">\n </s-lookup>\n <s-control-errors\n [control]="fornecedorForm.get(\'fornecedor\')"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }">\n </s-control-errors>\n </div>\n\n <div class="ui-md-6 ui-g-12">\n <label for="origem_mercadoria">{{\'yms.erp.recebimento_ordem_compra_mercadoria\' | translate}}</label>\n <s-lookup dataKey="id" id="origem_mercadoria" name="origem_mercadoria" formControlName="origemMercadoria" \n [searchFields]="origemMercadoriaSearchFields" [searchGridFields]="origemMercadoriaSearchFields"\n [searchGridData]="origemMercadoriaSearchGridData" [multiple]="false"\n [lookupSuggestions]="origemMercadoriaLookupSuggestions" lookupDisplayField="label"\n (onLookupRequest)="onOrigemMercadoriaLookupRequest(fornecedorForm, $event)"\n (onSearchRequest)="onOrigemMercadoriaSearchRequest(fornecedorForm, $event)" \n [searchTotalRecords]="origemMercadoriaSearchTotalRecords"\n [searchTitle]="\'yms.erp.origem_mercadoria_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: { value: origemMercadoriaSearchTotalRecords }">\n </s-lookup>\n </div>\n\n <div class="ui-g-12">\n <label for="fornecedorNotas">Notas a serem adicionadas</label>\n <s-token-list id="fornecedorNotas" [tokens]="fornecedorNotasTokens" (tokenSelected)="addFornecedorNotasTokenEmOrdemCompra(fornecedorForm, $event)" (tokenRemoved)="removeFornecedorNotasTokenDaOrdemCompra($event)" [removableTokens]="true"></s-token-list>\n </div>\n\n <div class="ui-g-12">\n <s-button label="Adicionar nota" *ngIf="showButtons()" styleClass="btn-erp-forms" priority="secondary" (onClick)="addNota(fornecedorForm)" [disabled]="disableAdicionarNota()"></s-button>\n <s-button label="Adicionar ordem de compra" *ngIf="showButtons() && !createdByErp" styleClass="btn-erp-forms" priority="secondary" (onClick)="addOrdemCompra(fornecedorForm)"></s-button>\n </div>\n\n <div class="ui-g-12">\n <h4>Ordens de Compra</h4>\n <p-table [value]="getOrdensCompra(fornecedorForm).controls" [(selection)]="ordemCompraSelecionado">\n <ng-template pTemplate="body" let-rowData>\n <tr [pSelectableRow]="rowData">\n <td style="width: 50px">\n <p-tableRadioButton [value]="rowData.get(\'ordemCompra\').value"></p-tableRadioButton>\n </td>\n <td>\n <p-accordion>\n <p-accordionTab>\n <p-header>\n Ordem {{rowData.get(\'ordemCompra\').value.codigo}}, Filial {{rowData.get(\'ordemCompra\').value.filial?.codigo}}\n\n <span *ngIf="showButtons() && !createdByErp" style="margin-left: 10px; float: right;" class="fas fa-trash" (click)="removerOrdemCompra(fornecedorForm, rowData)"></span>\n </p-header>\n\n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Notas</span>\n <span class="data">\n <p-accordion>\n <p-accordionTab *ngFor="let nota of getNotas(rowData).controls">\n <p-header>\n {{nota.get(\'chaveNotaFiscal\').value || (nota.get(\'serieNotaFiscal\').value + \' - \' + nota.get(\'numeroNotaFiscal\').value)}}\n\n <span *ngIf="showButtons()" style="margin-left: 10px; float: right;" class="fas fa-trash" (click)="removerNota(fornecedorForm, rowData, nota)"></span>\n </p-header>\n\n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Série nota fiscal</span>\n <span class="data">{{nota.value?.serieNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">Série legal nota fiscal</span>\n <span class="data">{{nota.value?.serieLegalNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">Número nota fiscal</span>\n <span class="data">{{nota.value?.numeroNotaFiscal}}</span>\n </div>\n </div>\n\n </p-accordionTab> \n </p-accordion>\n </span>\n </div>\n </div>\n </p-accordionTab>\n </p-accordion>\n </td>\n </tr>\n </ng-template>\n </p-table>\n </div>\n </p-panel>\n </form>\n </div>\n </form>\n\n <div style="margin: 5px 0 5px 0;">\n <s-button *ngIf="showButtons()" priority="primary" [label]="\'save\' | translate" (onClick)="onSave()"\n [disabled]="loading || disableButtonSave">\n </s-button>\n <s-button *ngIf="saveAndInitButton && showButtons()" priority="primary" [label]="\'save_and_init\' | translate"\n (onClick)="onSave(true)" [disabled]="loading || disableButtonSave">\n </s-button>\n </div>\n</div>',providers:[c.ConfirmationService],styles:[".required-h3{font-size:1.17rem;font-weight:700}.required-h3::after{content:'*';color:#c13018;font-weight:400;margin-left:5px;font-size:14px}.error-required-message{color:#c13018;margin-top:5px;font-size:12px}.separator{width:100%;margin:5px 0;height:1px;background-color:#ccc}.input-error{color:#c13018}.detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nota-error{color:#c13018}"]}),B("design:paramtypes",[C.FormBuilder,o.TranslateService,ha,Ra,Ea,sa,Ua,At,Xa,c.MessageService,F.ActivatedRoute,F.Router,Ca,ja,ji,Xt,c.ConfirmationService,c.DialogService,vt,La,qa,Rt,Na])],e)}(),Ui=function(){function e(e){this.recebimentoOrdemCompraService=e,this.loading=!0,this.unsubscribe$=new t.Subject}return e.prototype.ngAfterViewInit=function(){var e=this;this.recebimentoOrdemCompraService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",page:0,size:1}).pipe(a.takeUntil(this.unsubscribe$),a.switchMap(function(e){var a=e.contents;return a.length?t.of(a[0]):t.throwError("Recebimento Ordem de Compra não encontrado.")}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){return e.recebimentoOrdemCompra=Pi.fromDto(t)})},V([r.Input(),B("design:type",Object)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"recebimento-ordem-compra-info",template:'\n <div *sLoadingState="loading" style="padding: 20px;">\n <div class="detail-pane" *ngIf="agenda">\n\n <div class="detail-span">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_filial\' | translate}}</span>\n <span class="data">{{recebimentoOrdemCompra?.filial?.codigo}} - {{recebimentoOrdemCompra?.filial?.nome}}</span>\n </div>\n\n <div class="detail-span">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_produto\' | translate}}</span>\n <span class="data">{{recebimentoOrdemCompra?.produto?.descricao}}</span>\n </div>\n\n <div class="detail-span">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_derivacao\' | translate}}</span>\n <span class="data">{{recebimentoOrdemCompra?.derivacao?.descricao}}</span>\n </div>\n\n <div class="detail-span">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_transportadora\' | translate}}</span>\n <span class="data">{{recebimentoOrdemCompra?.transportadora?.placaVeiculo}}</span>\n </div>\n\n <div class="detail-span">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_safra\' | translate}}</span>\n <span class="data">{{recebimentoOrdemCompra?.safra?.descricao}}</span>\n </div>\n </div>\n <div *ngFor="let fornecedor of recebimentoOrdemCompra?.fornecedores">\n <div class="separator"></div>\n <h3>Fornecedor - {{fornecedor?.fornecedor?.nome}}</h3>\n <div class="detail-pane">\n <div class="detail-span" *ngFor="let ordemCompra of fornecedor.ordens">\n <span class="title">{{\'yms.erp.recebimento_ordem_compra_ordemcompra\' | translate}}</span>\n <span class="data">{{ ordemCompra.ordemCompra?.codigo }}</span>\n </div>\n </div>\n\n <div>\n <h4>Ordens de Compra</h4>\n <p-accordion>\n <p-accordionTab *ngFor="let ordemCompra of fornecedor.ordens">\n <p-header>\n Ordem de compra {{ ordemCompra?.ordemCompra?.numero }}, Filial {{ ordemCompra?.ordemCompra?.filial?.codigo }}\n </p-header>\n\n <div *ngFor="let nota of ordemCompra.notas">\n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Chave nota fiscal</span>\n <span class="data">{{ nota?.chaveNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Serie nota fiscal</span>\n <span class="data">{{ nota?.serieNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Serie legal nota fiscal</span>\n <span class="data">{{ nota?.serieLegalNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Número nota fiscal</span>\n <span class="data">{{ nota?.numeroNotaFiscal }}</span>\n </div>\n </div>\n <hr />\n </div>\n </p-accordionTab>\n </p-accordion>\n </div>\n </div>\n </div>\n ',styles:[".detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}"]}),B("design:paramtypes",[Xa])],e)}(),Bi=_,zi=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);return a.dataEmissao=a.dataEmissao&&Bi(a.dataEmissao).toDate(),a.dataInicioVigencia=a.dataInicioVigencia&&Bi(a.dataInicioVigencia).toDate(),a.dataFimVigencia=a.dataFimVigencia&&Bi(a.dataFimVigencia).toDate(),a.createdDate=a.createdDate&&Bi(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Bi(a.lastModifiedDate).toDate(),a.label="Número: "+a.numero+", Filial: "+a.filial.codigo,"Empresa"!==t&&a.empresa&&(a.empresa=Gt.fromDto(a.empresa,"ContratoCompra")),"Pessoa"!==t&&a.pessoa&&(a.pessoa=Ot.fromDto(a.pessoa,"ContratoCompra")),"Filial"!==t&&a.filial&&(a.filial=Ht.fromDto(a.filial,"ContratoCompra")),"Safra"!==t&&a.safra&&(a.safra=xi.fromDto(a.safra,"ContratoCompra")),"ContratoCompraItem"!==t&&a.itens&&(a.itens=Object.values(a.itens).map(function(e){return Hi.fromDto(e,"ContratoCompra")})),a},e.toDto=function(e,t){var a=j({},e);return a.dataEmissao=a.dataEmissao&&Bi(a.dataEmissao).format("YYYY-MM-DD"),a.dataInicioVigencia=a.dataInicioVigencia&&Bi(a.dataInicioVigencia).format("YYYY-MM-DD"),a.dataFimVigencia=a.dataFimVigencia&&Bi(a.dataFimVigencia).format("YYYY-MM-DD"),a.createdDate=a.createdDate&&Bi(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Bi(a.lastModifiedDate).format(),delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Gt.toDto(a.empresa,"ContratoCompra")),"Pessoa"!==t&&a.pessoa&&(a.pessoa=Ot.toDto(a.pessoa,"ContratoCompra")),"Filial"!==t&&a.filial&&(a.filial=Ht.toDto(a.filial,"ContratoCompra")),"Safra"!==t&&a.safra&&(a.safra=xi.toDto(a.safra,"ContratoCompra")),"ContratoCompraItem"!==t&&a.itens&&(a.itens=Object.values(a.itens).map(function(e){return Hi.toDto(e,"ContratoCompra")}).filter(function(e){return Object.keys(e).length})),a},e}(),$i=_,Hi=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);return a.sku=a.sku||{},a.dataCompetencia=a.dataCompetencia&&$i(a.dataCompetencia).toDate(),a.createdDate=a.createdDate&&$i(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&$i(a.lastModifiedDate).toDate(),a.label=a.sequencia+" - "+a.sku.descricao+" - "+a.sku.codigo,"ContratoCompra"!==t&&a.contrato&&(a.contrato=zi.fromDto(a.contrato,"ContratoCompraItem")),"Produto"!==t&&a.sku&&(a.sku=fi.fromDto(a.sku,"ContratoCompraItem")),a},e.toDto=function(e,t){var a=j({},e);return a.dataCompetencia=a.dataCompetencia&&$i(a.dataCompetencia).format("YYYY-MM-DD"),a.createdDate=a.createdDate&&$i(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&$i(a.lastModifiedDate).format(),delete a.label,"ContratoCompra"!==t&&a.contrato&&(a.contrato=zi.toDto(a.contrato,"ContratoCompraItem")),"Produto"!==t&&a.sku&&(a.sku=fi.toDto(a.sku,"ContratoCompraItem")),a},e}(),Yi=_,Qi=function(){function e(e,a,i,r,o,n,s){this.dialogRef=e,this.dialogConfig=a,this.contratoCompraService=i,this.contratoCompraItemService=r,this.translate=o,this.fb=n,this.route=s,this.contratoCompraLookupDisplayFields=["numero"],this.contratoCompraAdvancedDisplayFields=["id","numero","numeroAprovacao","situacaoAprovacao","dataEmissao","contratoPrioritario","dataInicioVigencia","dataFimVigencia"],this.contratoCompraLookupSeparator=" - ",this.contratoCompraItensLookupDisplayFields=["sequencia","sku.descricao"],this.contratoCompraItensAdvancedDisplayFields=["id","sequencia","sku.*","situacao","quantidadeContratada","quantidadeUtilizada","quantidadeEncerrada","dataCompetencia"],this.contratoCompraItensLookupSeparator=" - ",this.disableButtonSave=!1,this.permissions={},this.ngUnsubscribe=new t.Subject}return e.prototype.ngOnInit=function(){var e=this,t=this.dialogConfig.data;this.agenda=t.agenda,this.filial=t.filial,this.fornecedor=t.fornecedor,this.produto=t.produto,this.contratos=t.contratos.map(function(e){var t=e.contrato;return t?t.id:undefined}).filter(function(e){return!!e}),this.formGroup=this.getForm(),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)}),this.contratoCompraSearchFields=this.getContratoCompraFields(),this.contratoCompraSearchGridFields=this.getContratoCompraGridFields(),this.contratoCompraItensSearchFields=this.getContratoCompraItensFields(),this.contratoCompraItensSearchGridFields=this.getContratoCompraItensGridFields()},e.prototype.ngAfterViewInit=function(){(this.agenda&&!["AGUARDANDO_CONFIRMACAO_SOLICITANTE","AGENDADO","AGUARDANDO_CONFIRMACAO","REJEITADO_POR_VALIDACAO"].includes(this.agenda.status)||!this.permissions.editar)&&(this.formGroup.disable(),this.disableButtonSave=!0)},e.prototype.onRouteDataChange=function(e){this.permissions=e.allPermissions.agenda},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete()},e.prototype.onContratoCompraLookupRequest=function(e){var t=this,a=this.contratoCompraLookupDisplayFields.map(function(e){return{field:e,order:"Asc"}})[0],i={numero:+e.replace(/\D/g,"")},r=this.filial;r&&r.empresa&&r.empresa.id&&(i.empresaId=r.empresa.id),this.contratoCompraService.listContratosCompra(j({},i,{pessoaId:(this.fornecedor||{id:undefined}).id,produtoId:(this.produto||{id:undefined}).id,filialId:(r||{id:undefined}).id,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,contratosSelecionados:this.contratos,pagina:{limit:30,offset:0,listaOrdenacao:[{campo:a.field,ordenacao:a.order}]}})).subscribe(function(e){t.contratoCompraLookupSuggestions=e.contents.map(zi.fromDto)})},e.prototype.onContratoCompraSearchRequest=function(e){var t=this,a=e.first,i=e.rows,r=e.multiSortMeta,o=e.filterData,n=a/i,s=this.getContratoCompraFields().filter(function(e){var t=e.name;return o[t]!=undefined&&""!=o[t]}).reduce(function(e,t){var a;return j({},e,((a={})[t.name]=o[t.name],a))},{}),l=this.filial;l&&l.empresa&&l.empresa.id&&(s.empresaId=l.empresa.id),s.dataEmissao=s.dataEmissao&&Yi(s.dataEmissao).format("YYYY-MM-DD");var d=(r||[]).length?{field:r[0].field,order:1===r[0].order?"Asc":"Desc"}:{field:"numero",order:"Asc"};this.contratoCompraService.listContratosCompra(j({},s,{pessoaId:(this.fornecedor||{id:undefined}).id,produtoId:(this.produto||{id:undefined}).id,filialId:(l||{id:undefined}).id,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,contratosSelecionados:this.contratos,pagina:{limit:i,offset:n,listaOrdenacao:[{campo:d.field,ordenacao:d.order}]}})).subscribe(function(e){t.contratoCompraSearchGridData=e.contents.map(zi.fromDto),t.contratoCompraSearchTotalRecords=e.totalElements})},e.prototype.onContratoCompraItensLookupRequest=function(e){var t=this,i=this.contratoCompraItensLookupDisplayFields.map(function(e){return{field:e,order:1}}),r=this.filial.id,o={contratoId:this.formGroup.get("contrato").value.id,filialId:r,sequencia:isNaN(e)?null:e,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,pagina:this.getRecPagina(0,10,i)};this.contratoCompraItemService.pesquisarItensContratoCompra(o).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.contratoCompraItensLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.contratoCompraItensLookupSeparator)})})})})).subscribe(function(e){t.contratoCompraItensLookupSuggestions=e.contents.map(Hi.fromDto)})},e.prototype.onContratoCompraItensSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,n=e.filterData,s=o,l=this.filial.id,d={contratoId:this.formGroup.get("contrato").value.id,filialId:l,sequencia:n.sequencia,tipoAgendamentoId:this.agenda&&this.agenda.tipoAgendamento?this.agenda.tipoAgendamento.id:null,pagina:this.getRecPagina(i,r,s)};this.contratoCompraItemService.pesquisarItensContratoCompra(d).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.contratoCompraItensLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.contratoCompraItensLookupSeparator)})})})})).subscribe(function(e){t.contratoCompraItensSearchGridData=e.contents.map(Hi.fromDto),t.contratoCompraItensSearchTotalRecords=e.totalElements})},e.prototype.getProp=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},e.prototype.getRecPagina=function(e,t,a){return{offset:e/t,limit:t,listaOrdenacao:a&&a.length?a.map(function(e){return{campo:e.field,ordenacao:1===e.order?"Asc":"Desc"}}):[]}},e.prototype.addItemContrato=function(){this.getItensForm().push(this.getItemForm())},e.prototype.getItensForm=function(){return this.formGroup.get("itens")},e.prototype.save=function(){if(!this.formGroup.valid)return this.validateAllFormFields(this.formGroup);this.close({contrato:this.formGroup.value})},e.prototype.close=function(e){this.dialogRef.close(e)},e.prototype.getForm=function(){return this.fb.group({contrato:[undefined,C.Validators.required],itens:this.fb.array([])})},e.prototype.getItemForm=function(){return this.fb.group({item:[undefined,C.Validators.required],quantidade:[1]})},e.prototype.getContratoCompraFields=function(){return[new n.FormField({name:"filialContrato",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"numero",label:this.translate.instant("yms.erp.contrato_compra_numero"),type:n.FieldType.Integer})]},e.prototype.getContratoCompraGridFields=function(){return[new n.FormField({name:"numero",label:this.translate.instant("yms.erp.contrato_compra_numero"),type:n.FieldType.Integer}),new n.FormField({name:"filial.pessoa.nomeFantasia",label:this.translate.instant("yms.erp.contrato_compra_filial"),type:n.FieldType.Integer}),new n.FormField({name:"filial.pessoa.codigo",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"dataEmissao",label:this.translate.instant("yms.erp.contrato_compra_data_emissao"),type:n.FieldType.Date})]},e.prototype.getContratoCompraItensFields=function(){return[new n.FormField({name:"sequencia",label:this.translate.instant("yms.erp.contrato_compra_item_sequencia"),type:n.FieldType.Integer})]},e.prototype.getContratoCompraItensGridFields=function(){return[new n.FormField({name:"sequencia",label:this.translate.instant("yms.erp.contrato_compra_item_sequencia"),type:n.FieldType.Integer}),new n.FormField({name:"sku.descricao",label:this.translate.instant("yms.erp.produto"),type:n.FieldType.String})]},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup?t.validateAllFormFields(i):i instanceof C.FormArray&&i.controls.forEach(function(e){return t.validateAllFormFields(e)})})},e=V([r.Component({template:'<form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-g-12 ui-md-6">\n <label for="contrato">Contrato</label>\n <s-lookup dataKey="id" name="contrato"\n formControlName="contrato" [searchFields]="contratoCompraSearchFields"\n [searchGridFields]="contratoCompraSearchGridFields"\n [searchGridData]="contratoCompraSearchGridData" [multiple]="false"\n [lookupSuggestions]="contratoCompraLookupSuggestions"\n (onLookupRequest)="onContratoCompraLookupRequest($event)"\n (onSearchRequest)="onContratoCompraSearchRequest($event)"\n lookupDisplayField="label" [searchTotalRecords]="contratoCompraSearchTotalRecords"\n [searchTitle]="\'yms.erp.recebimento_contrato_compra_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: contratoCompraSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="separator"></div>\n <div class="ui-g-12" *ngFor="let itemForm of getItensForm().controls">\n <form [formGroup]="itemForm">\n <div class="ui-g-6">\n <label>Contrato Item</label>\n <s-lookup dataKey="id" id="item" name="item" formControlName="item"\n [searchFields]="contratoCompraItensSearchFields"\n [searchGridFields]="contratoCompraItensSearchGridFields"\n [searchGridData]="contratoCompraItensSearchGridData" [multiple]="false"\n [lookupSuggestions]="contratoCompraItensLookupSuggestions"\n (onLookupRequest)="onContratoCompraItensLookupRequest($event)"\n (onSearchRequest)="onContratoCompraItensSearchRequest($event)"\n lookupDisplayField="label" [searchTotalRecords]="contratoCompraItensSearchTotalRecords"\n [searchTitle]="\'yms.erp.recebimento_contrato_compra_itens_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: contratoCompraItensSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="ui-g-6">\n <label>Quantidade</label>\n <input pInputText type="number" formControlName="quantidade">\n </div>\n </form>\n </div>\n <s-button label="Adicionar item" priority="secondary" (onClick)="addItemContrato()"\n [disabled]="disableButtonSave"></s-button>\n </div>\n\n <div style="margin-top: 10px;">\n <div class="separator"></div>\n <s-button style="float: right;" [label]="\'save\' | translate" priority="primary" (onClick)="save()"\n [disabled]="disableButtonSave"></s-button>\n <s-button style="float: right;" [label]="\'cancel\' | translate" priority="link" (onClick)="close()"></s-button>\n </div>\n</form>\n\n'}),B("design:paramtypes",[c.DynamicDialogRef,c.DynamicDialogConfig,oa,ia,o.TranslateService,C.FormBuilder,F.ActivatedRoute])],e)}(),Ki=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);return a.label=Ee(a,["codigo","descricao"]," - "),"Empresa"!==t&&a.empresa&&(a.empresa=Gt.fromDto(a.empresa,"Transgenia")),"Royalty"!==t&&a.royalty&&(a.royalty=ci.fromDto(a.royalty,"Royalty")),a},e.toDto=function(e,t){var a=j({},e);return delete a.label,"Empresa"!==t&&a.empresa&&(a.empresa=Gt.toDto(a.empresa,"Transgenia")),"Royalty"!==t&&a.royalty&&(a.roylty=ci.toDto(a.royalty,"Transgenia")),a},e}(),Ji=_,Xi=function(){function e(){}return e.fromDto=function(e,t){var a=j({},e);a.createdDate=a.createdDate&&Ji(a.createdDate).toDate(),a.lastModifiedDate=a.lastModifiedDate&&Ji(a.lastModifiedDate).toDate();return a.label=["id","fornecedor.id","fornecedor.codigo","fornecedor.nome","fornecedor.situacao","produto.id","produto.codigo","produto.comprado","produto.descricao","produto.produtoMisto","produto.situacao","produto.tipo","agenda.id","agenda.descricao","transportadora.id","transportadora.codigo","transportadora.placaVeiculo","transgenia.id","transgenia.codigo","transgenia.descricao","tipoNotaFiscal","createdBy","createdDate","lastModifiedBy","lastModifiedDate"].map(function(e){return a[e]}).join(" - "),"Filial"!==t&&a.filial&&(a.filial=Ht.fromDto(a.filial,"Recebimento")),"Produto"!==t&&a.produto&&(a.produto=fi.fromDto(a.produto,"Recebimento")),"Agenda"!==t&&a.agenda&&(a.agenda=we.fromDto(a.agenda,"Recebimento")),"PessoaEndereco"!==t&&a.origemMercadoria&&(a.origemMercadoria=zt.fromDto(a.origemMercadoria,"Recebimento")),"Derivacao"!==t&&a.derivacao&&(a.derivacao=gi.fromDto(a.derivacao,"Recebimento")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=yi.fromDto(a.transportadora,"Recebimento")),"Transgenia"!==t&&a.transgenia&&(a.transgenia=Ki.fromDto(a.transgenia,"Transgenia")),a.fornecedores=a.fornecedores.map(function(e){return j({},e,{fornecedor:Ot.fromDto(e.fornecedor,"Recebimento"),origemMercadoria:zt.fromDto(e.origemMercadoria,"Recebimento"),contratos:e.contratos.map(function(e){return j({},e,{contrato:zi.fromDto(e.contrato),itens:e.itens.map(function(e){return j({},e,{item:Hi.fromDto(e.item)})})})})})}),a},e.toDto=function(e,t){var a=j({},e);return a.createdDate=a.createdDate&&Ji(a.createdDate).format(),a.lastModifiedDate=a.lastModifiedDate&&Ji(a.lastModifiedDate).format(),delete a.label,"Pessoa"!==t&&a.fornecedor&&(a.fornecedor=Ot.toDto(a.fornecedor,"Recebimento")),"Filial"!==t&&a.filial&&(a.filial=Ht.toDto(a.filial,"Filial")),"Produto"!==t&&a.produto&&(a.produto=fi.toDto(a.produto,"Recebimento")),"Agenda"!==t&&a.agenda&&(a.agenda=we.toDto(a.agenda,"Recebimento")),"PessoaEndereco"!==t&&a.origemMercadoria&&(a.origemMercadoria=zt.toDto(a.origemMercadoria,"Recebimento")),"Transportadora"!==t&&a.transportadora&&(a.transportadora=yi.toDto(a.transportadora,"Recebimento")),"Transgenia"!==t&&a.transgenia&&(a.transgenia=Ki.toDto(a.transgenia,"Transgenia")),a.fornecedores=e.fornecedores.map(function(e){return j({},e,{fornecedor:Ot.toDto(e.fornecedor,"Recebimento"),origemMercadoria:zt.toDto(e.origemMercadoria,"Recebimento"),contratos:e.contratos.map(function(e){return j({},e,{contrato:zi.toDto(e.contrato),itens:e.itens.map(function(e){return j({},e,{item:Hi.toDto(e.item)})})})})})}),a},e}();!function(e){e.EMPRESA_JURIDICA="EMPRESA_JURIDICA",e.PRODUTOR_RURAL="PRODUTOR_RURAL"}(Si||(Si={})),function(e){e.INATIVO="INATIVO",e.ATIVO="ATIVO"}(Di||(Di={}));var Wi=_,Zi=function(){function e(e,a,i,r,o,n,s,l,d,c,p,u,m,f,h,g,v,y,b,F,S,D,C,_,T,k,I){var M=this;this.recebimentoService=e,this.router=a,this.route=i,this.messageService=r,this.confirmationService=o,this.formBuilder=n,this.translate=s,this.hotkeysService=l,this.fieldCustomization=d,this.focusService=c,this.filialService=p,this.transportadoraService=u,this.pessoaEnderecoService=m,this.contratoCompraService=f,this.pessoaService=h,this.produtoService=g,this.derivacaoService=v,this.recebimentoChegadaOverride=y,this.notaValidatorService=b,this.transgeniaService=F,this.dialogService=S,this.agendaService=D,this.erpProcessService=C,this.erpFormConfigService=_,this.verificaNotaFiscal=T,this.hasChangeService=k,this.buildFormField=I,this.localeConfig={},this.currencyLocaleOptions={},this.permissions={},this.allPermissions={},this.visibleDialog=!1,this.quantidadeSelecionada=1,this.mainPanelCollapsed=!1,this.filialLookupDisplayFields=["codigo","nome","empresa.nome"],this.filialAdvancedDisplayFields=["id","codigo","nome","empresa.nome"],this.filialLookupSeparator=" - ",this.fornecedorLookupDisplayFields=["codigo","nome","cpfCnpj"],this.fornecedorAdvancedDisplayFields=["id","codigo","nome","situacao","cpfCnpj","tipoParticipante"],this.fornecedorLookupSeparator=" - ",this.origemMercadoriaLookupDisplayFields=["codigo","cep","endereco","empresa.descricao"],this.origemMercadoriaAdvancedDisplayFields=["id","codigo","cep","endereco","numero","complemento","cidade.*","bairro","situacao","empresa.descricao","cnpjCpf","inscricaoEstadual"],this.origemMercadoriaLookupSeparator=" - ",this.produtoLookupDisplayFields=["codigo","descricao","tipo"],this.produtoAdvancedDisplayFields=["id","codigo","comprado","descricao","produtoMisto","situacao","tipo"],this.produtoLookupSeparator=" - ",this.agendaLookupDisplayFields=["id","descricao"],this.agendaAdvancedDisplayFields=["id","descricao"],this.agendaLookupSeparator=" - ",this.derivacaoLookupDisplayFields=["codigo","descricao"],this.derivacaoAdvancedDisplayFields=["id","codigo","descricao"],this.derivacaoLookupSeparator=" - ",this.transportadoraLookupDisplayFields=["codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraAdvancedDisplayFields=["id","codigo","pessoa.nome","pessoa.cpfCnpj"],this.transportadoraLookupSeparator=" - ",this.transgeniaLookupDisplayFields=["codigo","descricao"],this.transgeniaAdvancedDisplayFields=["id","codigo","descricao","familia","tipoParticipante","situacao"],this.transgeniaLookupSeparator=" - ",this.disableButtonSave=!1,this.disableOrdersButtons=!0,this.totalEixosContratados=0,this.totalEixosComposicao=0,this.tiposNota=[{label:this.translate.instant("yms.erp.tipo_nota_fiscal_empresa_juridica"),value:Si.EMPRESA_JURIDICA},{label:this.translate.instant("yms.erp.tipo_nota_fiscal_produtor_rural"),value:Si.PRODUTOR_RURAL}],this.erroChaveNota=!1,this.erroFornecedores=!1,this.erroFornecedoresNotaDuplicada=null,this.notasTokens=[],this.fornecedorNotasTokens=[],this.fornecedorNotas=[],this.contratoSelecionado=null,this.ngUnsubscribe=new t.Subject,this.carregandoErpFilial=!0,this.carregandoErpRouteData=!0,this.carregandoErpRecebimento=!0,this.onChangeRevalidation=function(e){M.erpProcessData&&M.formGroup&&(M.erpProcessData=M.erpProcessService.builderErpProcessData(M.erpProcessData,M.formGroup),M.erpProcessService.changeData(M.erpProcessData))},this.onFilialValueChange=function(e){if(M.disableOrdersButtons=!e,!e&&M.isNew())return M.formGroup.get("produto").setValue(undefined),M.formGroup.get("produto").disable(),M.formGroup.get("transgenia").setValue(undefined),M.formGroup.get("transgenia").disable(),void(M.carregandoErpFilial=!1);M.formGroup.get("produto").enable(),M.formGroup.get("transgenia").enable(),M.carregandoErpFilial=!1}}return e.prototype.ngOnInit=function(){var e=this;this.formGroup=this.getFormGroup(),this.itemFormGroup=this.getItemForm(),this.formGroup.get("filial").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onFilialValueChange),this.formGroup.get("produto").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe),a.debounceTime(500),a.filter(function(t){var a=e.formGroup.get("derivacao").value;return(!a||a.produto.id!==t.id)&&(!!t||(e.formGroup.get("derivacao").setValue(undefined),e.formGroup.get("derivacao").disable(),!1))}),a.mergeMap(function(t){return e.derivacaoService.list({filterQuery:"produto.id eq '"+t.id+"' and situacao eq 'ATIVO'",page:0,size:1})})).subscribe(function(t){var a=t.contents;a.length?(e.formGroup.get("derivacao").setValue(a[0]),e.formGroup.get("derivacao").disable()):e.formGroup.get("derivacao").enable()}),this.route.data.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){return e.onRouteDataChange(t)}),this.route.params.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.agenda;"new"==a?e.buscarFilial():e.getRecebimento(a)}),this.formGroup.get("transportadora").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.formGroup.get("transgenia").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.formGroup.get("fornecedores").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(this.onChangeRevalidation),this.filialSearchFields=this.getFilialSearchFields(),this.filialSearchGridFields=this.getFilialSearchFields(),this.fornecedorSearchFields=this.getFornecedorSearchFields(),this.fornecedorSearchGridFields=this.getFornecedorSearchGridFields(),this.origemMercadoriaSearchFields=this.getOrigemMercadoriaFields(),this.origemMercadoriaSearchGridFields=this.getOrigemMercadoriaGridFields(),this.produtoSearchFields=this.getProdutoSearchFields(),this.produtoSearchGridFields=this.getProdutoSearchGridFields(),this.agendaSearchFields=this.getAgendaSearchFields(),this.agendaSearchGridFields=this.getAgendaSearchGridFields(),this.derivacaoSearchFields=this.getDerivacaoSearchFields(),this.derivacaoSearchGridFields=this.getDerivacaoSearchGridFields(),this.transportadoraSearchFields=this.getTransportadoraSearchFields(),this.transportadoraSearchGridFields=this.getTransportadoraSearchGridFields(),this.transgeniaSearchFields=this.getTransgeniaSearchFields(),this.transgeniaSearchGridFields=this.getTransgeniaSearchGridFields(),this.setHotkeys(),this.agenda&&this.agenda.externalTenant&&this.setTransportadora(this.agenda.externalTenant.cnpj),this.totalEixosComposicao=this.agenda&&this.agenda.veiculo&&this.agenda.veiculo.eixos||0;this.agenda&&!["AGUARDANDO_CONFIRMACAO_SOLICITANTE","AGENDADO","AGUARDANDO_CONFIRMACAO","REJEITADO_POR_VALIDACAO"].includes(this.agenda.status)&&(this.formGroup.disable(),this.disableButtonSave=!0),this.erpProcessService.current.subscribe(function(t){return e.erpProcessData=t}),this.erpFormConfigService.current.subscribe(function(t){return e.enableRevalidation=t}),this.verificaSeTemAlteracao(),this.formGroup.get("produto").valueChanges.subscribe(function(){e.validaTransgenia()}),this.formGroup.get("fornecedores").valueChanges.subscribe(function(){e.validaTransgenia()})},e.prototype.verificaSeTemAlteracao=function(){var e=this;this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.validaTransgenia=function(){if(!this.erpCarregado()){var e=this.formGroup.get("transgenia").value,t=this.formGroup.get("produto").value,a=this.getFamiliaProduto();t&&e&&(this.validaFamiliaProdutoCorrespondeFamiliaTrangenia(e,a)?this.validaFornecedorCorrespondeTipoPaticipanteDaTransgenia(e):this.mensagemTransgeniaInvalida())}},e.prototype.erpCarregado=function(){return!!this.carregandoErpFilial||(!!this.carregandoErpRouteData||!!this.carregandoErpRecebimento)},e.prototype.mensagemTransgeniaInvalida=function(){this.addMessage("error","yms.integration.mensagem_erro_titulo_informar_transgenia","yms.integration.mensagem_erro_conteuto_informar_transgenia"),this.formGroup.get("transgenia").setValue(undefined)},e.prototype.validaFamiliaProdutoCorrespondeFamiliaTrangenia=function(e,t){return null!==t&&e.familia===t},e.prototype.validaFornecedorCorrespondeTipoPaticipanteDaTransgenia=function(e){var t=this.getTipoTransgenia(),a=this.formGroup.get("fornecedores");if(a.length>0){var i=!0;if(a.controls.forEach(function(e){i=null===e.value.fornecedor}),i)return!0;if(null===t)return this.mensagemTransgeniaInvalida(),!1;if(t!==e.tipoParticipante)return this.mensagemTransgeniaInvalida(),!1;if(t===e.tipoParticipante)return!0}return!1},e.prototype.ngAfterViewInit=function(){var e=this,t=document.getElementsByTagName("input"),a=Array.from(t).find(function(e){return!e.disabled});a&&a.focus(),this.recebimentoChegadaOverride.initialize(),this.saveAndInitButton=document.getElementById("init"),this.createdByErpDisableForm(),this.formGroup.valueChanges.subscribe(function(){e.formCarregado&&e.hasChangeService.hasChange(e.agenda.id)})},e.prototype.ngOnDestroy=function(){this.ngUnsubscribe.next(),this.ngUnsubscribe.complete(),this.recebimentoChegadaOverride.remove()},e.prototype.createdByErpDisableForm=function(){this.disableOrdersButtons=this.agenda.createdByErp,this.isNew()&&(this.createdByErp=!1,this.formGroup.get("filial").enable(),this.formGroup.get("produto").enable(),this.formGroup.get("derivacao").enable(),this.formGroup.get("transportadora").enable(),this.formGroup.get("fornecedores").controls.forEach(function(e){return e.get("fornecedor").enable()})),this.agenda&&this.agenda.createdByErp&&(this.createdByErp=!0,this.formGroup.get("filial").disable(),this.formGroup.get("produto").disable(),this.formGroup.get("derivacao").disable(),this.disableFornecedores(),this.formGroup.get("transportadora").value&&this.formGroup.get("transportadora").disable())},e.prototype.disableFornecedores=function(){this.formGroup.get("fornecedores").controls.forEach(function(e){return e.get("fornecedor").disable()})},e.prototype.setHotkeys=function(){var e=this;this.hotkeysService.add(new O.Hotkey("alt+shift+x",function(){return e.permissions.excluir&&e.onDelete(),!1},["INPUT","SELECT","TEXTAREA"])),this.hotkeysService.add(new O.Hotkey("alt+shift+s",function(){return(e.isNew()||e.permissions.editar)&&e.onSave(),!1},["INPUT","SELECT","TEXTAREA"])),this.hotkeysService.add(new O.Hotkey("alt+shift+c",function(){return e.onCancel(),!1},["INPUT","SELECT","TEXTAREA"]))},e.prototype.onBlurChaveNotaFiscal=function(){var e=this;if(!this.verificaNotaFiscal.verificaSeNotaFiscalEstaDuplicada(this.chaveNotaFiscal,this.contratos,this.fornecedorNotasTokens)){this.removeNotaError();var t=this.chaveNotaFiscal;t&&(this.loading=!0,this.mensagemBuscandoNota(),this.notaValidatorService.pesquisarDocumentoValidaNotaEmUso({filialId:this.formGroup.get("filial").value&&this.formGroup.get("filial").value.id||null,chaveDocumento:t.trim()}).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return e.loading=!1})).subscribe(function(t){return e.addNovaNota(t)}))}},e.prototype.addNovaNota=function(e){var t=(e.documentos||[]).length?e.documentos[0]:undefined;if(t){var a=t.itens[0]||{produto:undefined,derivacao:undefined},i=fi.fromDto(a.produto);if(!this.formGroup.get("produto").value&&a.produto)this.formGroup.get("produto").setValue(i),this.formGroup.get("derivacao").setValue(gi.fromDto(a.derivacao));else if(a.produto&&!this.validateProduto(i))return void this.addNotaError();var r=Ot.fromDto(t.fornecedor),o=zt.fromDto(t.origemMercadoria),n=this.getFornecedoresForm().controls.find(function(e){return e.value.fornecedor.id===r.id});this.validarCnpjFornecedor(r.cpfCnpj)?(n||this.addFornecedor({fornecedor:r,origemMercadoria:o}),this.addFornecedorNotasToken(t)):n||(this.addFornecedor({fornecedor:r,origemMercadoria:o}),this.addFornecedorNotasToken(t)),this.validaRetornoPesquisaDocumentos(e)}},e.prototype.validaRetornoPesquisaDocumentos=function(e){var t=this.verificaNotaFiscal.findDuplicateFornecedores(e);null!==t&&(this.erroFornecedoresNotaDuplicada=this.translate.instant("yms.patio.duplicate_supplier")+t)},e.prototype.addFornecedorNotasToken=function(e){this.fornecedorNotasTokens.push({id:this.chaveNotaFiscal,label:e.numero}),this.fornecedorNotas.push({chaveNotaFiscal:this.chaveNotaFiscal,serieNotaFiscal:e.serie,serieLegalNotaFiscal:e.serieLegal,numeroNotaFiscal:e.numero}),this.chaveNotaFiscal=undefined,this.loading=!1},e.prototype.isNew=function(){return!this.formGroup.value.id},e.prototype.updateSuggestions=function(e){e.fornecedor&&(e.fornecedor.label=this.getSuggestionValue(["id","codigo","nome","situacao"],"fornecedor",e,this.fornecedorLookupSeparator),e.fornecedor.label.trim()===this.fornecedorLookupSeparator.trim()&&delete e.fornecedor.label),e.produto&&(e.produto.label=this.getSuggestionValue(["id","codigo","comprado","descricao","produtoMisto","situacao","tipo"],"produto",e,this.produtoLookupSeparator),e.produto.label.trim()===this.produtoLookupSeparator.trim()&&delete e.produto.label),e.agenda&&(e.agenda.label=this.getSuggestionValue(["id","descricao"],"agenda",e,this.agendaLookupSeparator),e.agenda.label.trim()===this.agendaLookupSeparator.trim()&&delete e.agenda.label),e.derivacao&&(e.derivacao.label=this.getSuggestionValue(["id","codigo","descricao"],"derivacao",e,this.derivacaoLookupSeparator),e.derivacao.label.trim()===this.derivacaoLookupSeparator.trim()&&delete e.derivacao.label)},e.prototype.getSuggestionValue=function(e,t,a,i){var r=this;return e.map(function(e){return r.getProp(a,t+"."+e)}).reduce(function(e,t){return""+e+i+t})},e.prototype.onRouteDataChange=function(e){var t=e.localeConfig.number,a=t.currencySymbol,i=t.thousandsSeparator,r=t.decimalSeparator;if(this.localeConfig=e.localeConfig,this.currencyLocaleOptions={align:"left",prefix:a,thousands:i,decimal:r},this.permissions=e.allPermissions.agenda,this.allPermissions=e.allPermissions,e.entity){this.permissions.editar||this.formGroup.disable();var o=Xi.fromDto(e.entity);this.updateSuggestions(o),this.formGroup.patchValue(o)}else this.formGroup.patchValue(new Xi);this.carregandoErpRouteData=!1},e.prototype.onCancel=function(){this.goBack()},e.prototype.onSendFile=function(e,a){var i=[];return this.fieldCustomization.isEmpty(e)||i.push(this.fieldCustomization.deleteFiles(e)),this.fieldCustomization.isEmpty(a)||i.push(this.fieldCustomization.commitFiles(a)),this.fieldCustomization.isEmpty(i)?t.of({}):t.forkJoin(i)},e.prototype.onSave=function(e){var t=this;if(!(this.formGroup.get("fornecedores").length<=0))return this.formGroup.invalid?this.validateAllFormFields(this.formGroup):(this.loading=!0,this.isNew()||!this.enableRevalidation?this.saveAndInit(e):(this.erpProcessData=this.erpProcessService.builderErpProcessDataValidaNotaNoContrato(this.erpProcessData,this.formGroup),this.erpProcessService.changeDataErp(this.erpProcessData),this.agendaService.checarRevalidacao(this.erpProcessData).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){a.requerRevalidacao?t.atualizaAgendaParaRejeitadoPorValidacao():t.saveAndInit(e)})));this.erroFornecedores=!0},e.prototype.atualizaAgendaParaRejeitadoPorValidacao=function(){var e=this;this.confirmationService.confirm({header:this.translate.instant("yms.patio.agenda_revalidacao_title"),message:this.translate.instant("yms.patio.agenda_revalidacao_message"),accept:function(){e.hasChangeService.hasChangeSave(e.agenda.id),e.agenda.status=dt.REJEITADO_POR_VALIDACAO,e.agenda.motorista={id:e.erpProcessData.motoristaId},e.agenda.veiculo={id:e.erpProcessData.veiculoId},e.agendaService.atualizarAgenda(e.agenda).pipe(a.takeUntil(e.ngUnsubscribe),a.concatMap(function(t){return e.getSaveObservable()}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.successMessage(),e.router.navigate(["/chegada-veiculo"],{relativeTo:e.route})})},reject:function(){return e.loading=!1}})},e.prototype.saveAndInit=function(e){var t=this;this.getSaveObservable().pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(a){t.formGroup.get("id").setValue(a.id||null),t.successMessage(),t.hasChangeService.hasChangeSave(t.agenda.id),e&&t.saveAndInitButton&&t.saveAndInitButton.click()})},e.prototype.successMessage=function(){this.messageService.add({severity:"success",summary:this.translate.instant("saved_message_title"),detail:this.translate.instant("saved_message_content")})},e.prototype.onDelete=function(){var e=this;this.confirmationService.confirm({message:this.translate.instant("yms.erp.delete_confirmation_message"),header:this.translate.instant("yms.erp.delete_confirmation_title"),accept:function(){return e.getDeleteObservable().pipe(a.takeUntil(e.ngUnsubscribe)).subscribe()}})},e.prototype.setTransportadora=function(e){var t=this;if(e){var i="pessoa.cpfCnpj eq '"+e.replace(".","").replace("/","").replace("-","")+"'";this.transportadoraService.list({filterQuery:i,page:0,size:10}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){var a=e.contents;if(1===a.length){var i=a[0].codigo?a[0].codigo.toString():"",r=a[0].descricao?a[0].descricao.toString():"";r.trim()||i.trim()?a[0].label=i+" - "+r:a[0].label=t.translate.instant("yms.erp.derivacao_sem_descricao"),t.formGroup.get("transportadora").setValue(a[0])}})}},e.prototype.getProp=function(e,t){return t.split(".").reduce(function(e,t){return e[t]===undefined?"":e[t]},e)},e.prototype.getRecebimento=function(e){var t=this;this.loading=!0,this.recebimentoService.list({filterQuery:"agenda.id eq '"+e+"'",size:1,page:0}).pipe(a.takeUntil(this.ngUnsubscribe),a.finalize(function(){return t.loading=!1})).subscribe(function(e){var a=e.contents;if(a.length){t.totalEixosContratados=a[0].eixos||0,t.totalEixosComposicao=a[0].agenda&&a[0].agenda.veiculo&&a[0].agenda.veiculo.eixos||0;var i=Xi.fromDto(a[0]);t.formGroup.enable(),t.formGroup.patchValue(i),i.fornecedores.forEach(function(e){var a=t.getFornecedorForm(e);t.getFornecedoresForm().push(a),e.contratos.forEach(function(e){var i=t.getContratoForm(e);t.getContratos(a).push(i),e.itens.forEach(function(e){var a=t.getItemForm(e);t.getItensContrato(i).push(a)}),e.notas.forEach(function(e){var a=t.getNotaForm(e);t.getNotas(i).push(a)})})}),t.createdByErpDisableForm(),t.formCarregado=!0,t.carregandoErpRecebimento=!1}else t.buscarFilial()})},e.prototype.onFilialLookupRequest=function(e){var t=this,i=this.getFilialSearchFields().filter(function(t){var a=t.type;return Te(a,e)}).reduce(function(t,a){var i,r,o=a.name;return a.type===n.FieldType.Integer?j({},t,((i={})[o]=e.replace(/\D/,""),i)):j({},t,((r={})[o]=e,r))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:10,offset:0}});this.filialService.listFiliais(i).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.filialLookupSuggestions=e.filiais.map(Ht.fromDto)})},e.prototype.onFilialSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getFilialSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{cnpjs:this.agenda.planta.cnpj,pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}});this.filialService.listFiliais(p).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.filialSearchGridData=e.filiais.map(Ht.fromDto),t.filialSearchTotalRecords=e.qtdTotalRegistros})},e.prototype.onFornecedorLookupRequest=function(e){var t=this,i=this.fornecedorLookupDisplayFields.map(function(e){return{field:e,order:1}}),r=this.getFornecedorSearchFields().filter(function(t){var a=t.type;return Te(a,e)}).map(function(t){var a=t.name,i=t.type;return"number"==typeof e?a+" eq "+e:i==n.FieldType.Date?a+" eq '"+Wi(e).format("YYYY-MM-DD")+"'":i==n.FieldType.Time?a+" eq '"+Wi(e).format("HH:mm:ss")+"'":i==n.FieldType.DateTime?a+" eq '"+Wi(e).format()+"'":i==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or ");r="("+r+")"+(r?" and ":"")+"situacao eq 'ATIVO' and fornecedor eq true";var o=_e(this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields);this.pessoaService.list({sort:i,filterQuery:r,displayFields:o}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.fornecedorLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.fornecedorLookupSeparator)})})})})).subscribe(function(e){t.fornecedorLookupSuggestions=e.contents})},e.prototype.onFornecedorSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=this.getFornecedorSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,i=s[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Wi(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Wi(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Wi(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and ");c=c.concat((c?" and ":"")+"situacao eq 'ATIVO' and fornecedor eq true");var p=_e(this.fornecedorLookupDisplayFields,this.fornecedorAdvancedDisplayFields);this.pessoaService.list({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.fornecedorLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.fornecedorLookupSeparator)})})})})).subscribe(function(e){t.fornecedorSearchGridData=e.contents,t.fornecedorSearchTotalRecords=e.totalElements})},e.prototype.montaQueryOrigemMercadoria=function(e){return"situacao eq 'ATIVO' and origem eq 'true' and pessoa.id eq '"+e+"'"},e.prototype.onOrigemMercadoriaLookupRequest=function(e,t){var i=this,r=(this.origemMercadoriaLookupDisplayFields.map(function(e){return{field:e,order:1}}),this.getOrigemMercadoriaFields().filter(function(t){var a=t.type;return Te(a,e)}).map(function(t){var a=t.name,i=t.type;return"number"==typeof e?a+" eq "+e:i==n.FieldType.Date?a+" eq '"+Wi(e).format("YYYY-MM-DD")+"'":i==n.FieldType.Time?a+" eq '"+Wi(e).format("HH:mm:ss")+"'":i==n.FieldType.DateTime?a+" eq '"+Wi(e).format()+"'":i==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or "));r="("+r+")"+(r?" and ":""),r+=this.montaQueryOrigemMercadoria(t.get("fornecedor").value.id);var o=_e(this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields);this.pessoaEnderecoService.list({filterQuery:r,displayFields:o}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:i.origemMercadoriaLookupDisplayFields.map(function(t){return t.indexOf(".")>0?i.getProp(e,t):e[t]}).join(i.origemMercadoriaLookupSeparator)})})})})).subscribe(function(e){i.origemMercadoriaLookupSuggestions=e.contents})},e.prototype.onOrigemMercadoriaSearchRequest=function(e,t){var i=this,r=e.first,o=e.rows,s=e.multiSortMeta,l=e.filterData,d=r/o,c=s,p=this.getOrigemMercadoriaFields().filter(function(e){var t=e.name;return l[t]!=undefined&&""!=l[t]}).map(function(e){var t=e.name,a=e.type,i=l[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Wi(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Wi(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Wi(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and ");p=p.concat(p?" and ":""),p+=this.montaQueryOrigemMercadoria(t.get("fornecedor").value.id);var u=_e(this.origemMercadoriaLookupDisplayFields,this.origemMercadoriaAdvancedDisplayFields);this.pessoaEnderecoService.list({page:d,sort:c,filterQuery:p,displayFields:u}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:i.origemMercadoriaLookupDisplayFields.map(function(t){return t.indexOf(".")>0?i.getProp(e,t):e[t]}).join(i.origemMercadoriaLookupSeparator)})})})})).subscribe(function(e){i.origemMercadoriaSearchGridData=e.contents,i.origemMercadoriaSearchTotalRecords=e.totalElements})},e.prototype.getRecPagina=function(e,t,a){return{offset:e/t,limit:t,listaOrdenacao:a&&a.length?a.map(function(e){return{campo:e.field,ordenacao:1===e.order?"Asc":"Desc"}}):[]}},e.prototype.onProdutoLookupRequest=function(e){var t=this,i=this.formGroup.get("filial").value,r=this.agenda.tipoAgendamento;this.produtoService.listProdutosRecebimento({pesquisa:e,empresaId:i?i.empresa.id:null,filialId:i?i.id:null,tipoAgendamentoId:r?r.id:null}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.produtoLookupSuggestions=(e.produtos||[]).map(function(e){return fi.fromDto(e)})})},e.prototype.onProdutoSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=!!(d||[]).length&&{campo:d[0].field,ordenacao:d[0].order>0?"Asc":"Desc"},p=this.getProdutoSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).reduce(function(e,t){var a,i,r=t.name,o=t.type,l=s[r];return o===n.FieldType.Integer?j({},e,((a={})[r]=(""+l).replace(/\D/,""),a)):j({},e,((i={})[r]=l,i))},{pagina:{limit:r,offset:l,listaOrdenacao:c?[j({},c)]:null}}),u=this.formGroup.get("filial").value,m=this.agenda.tipoAgendamento;this.produtoService.listProdutosRecebimento(j({},p,{empresaId:u?u.empresa.id:null,filialId:u?u.id:null,tipoAgendamentoId:m?m.id:null})).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.produtoSearchTotalRecords=e.qtdTotalRegistros,t.produtoSearchGridData=(e.produtos||[]).map(function(e){return fi.fromDto(e)})})},e.prototype.onDerivacaoLookupRequest=function(e){var t=this,i=this.derivacaoLookupDisplayFields.map(function(e){return{field:e,order:1}}),r=this.getDerivacaoSearchFields().filter(function(t){var a=t.type;return Te(a,e)}).map(function(t){var a=t.name,i=t.type;return"number"==typeof e?a+" eq "+e:i==n.FieldType.Date?a+" eq '"+Wi(e).format("YYYY-MM-DD")+"'":i==n.FieldType.Time?a+" eq '"+Wi(e).format("HH:mm:ss")+"'":i==n.FieldType.DateTime?a+" eq '"+Wi(e).format()+"'":i==n.FieldType.String?"containing(lower("+a+"), lower('"+e.replace(/'/g,"\\'")+"'))":a+" eq '"+e+"'"}).join(" or "),o=_e(this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields);this.derivacaoService.list({sort:i,filterQuery:r,displayFields:o}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.derivacaoLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.derivacaoLookupSeparator)})})})})).subscribe(function(e){t.derivacaoLookupSuggestions=e.contents})},e.prototype.onDerivacaoSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=this.getDerivacaoSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,i=s[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Wi(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Wi(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Wi(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and "),p=_e(this.derivacaoLookupDisplayFields,this.derivacaoAdvancedDisplayFields);this.derivacaoService.list({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.derivacaoLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.derivacaoLookupSeparator)})})})})).subscribe(function(e){t.derivacaoSearchGridData=e.contents,t.derivacaoSearchTotalRecords=e.totalElements})},e.prototype.onTransportadoraLookupRequest=function(e){var t=this;Le(this.transportadoraSearchFields,this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields,this.transportadoraLookupSeparator,this.transportadoraService,e).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){t.transportadoraLookupSuggestions=e.contents})},e.prototype.onTransportadoraSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=this.getTransportadoraSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,i=s[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Date?t+" eq '"+Wi(i).format("YYYY-MM-DD")+"'":a==n.FieldType.Time?t+" eq '"+Wi(i).format("HH:mm:ss")+"'":a==n.FieldType.DateTime?t+" eq '"+Wi(i).format()+"'":a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and "),p=_e(this.transportadoraLookupDisplayFields,this.transportadoraAdvancedDisplayFields);this.transportadoraService.list({page:l,sort:d,filterQuery:c,displayFields:p}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.transportadoraLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.transportadoraLookupSeparator)})})})})).subscribe(function(e){t.transportadoraSearchGridData=e.contents,t.transportadoraSearchTotalRecords=e.totalElements})},e.prototype.onTransgeniaLookupRequest=function(e){var t=this;Le(this.getTransgeniaSearchFields(),this.transgeniaLookupDisplayFields,this.transgeniaAdvancedDisplayFields,this.transgeniaLookupSeparator,this.transgeniaService,e,this.geraFiltroTransgenia()).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(e){return t.transgeniaLookupSuggestions=e.contents})},e.prototype.onTransgeniaSearchRequest=function(e){var t=this,i=e.first,r=e.rows,o=e.multiSortMeta,s=e.filterData,l=i/r,d=o,c=this.getTransgeniaSearchFields().filter(function(e){var t=e.name;return s[t]!=undefined&&""!=s[t]}).map(function(e){var t=e.name,a=e.type,i=s[t];return"number"==typeof i?t+" eq "+i:a==n.FieldType.Enum?t+" eq '"+i+"'":a==n.FieldType.String?"containing(lower("+t+"), lower('"+i.replace(/'/g,"\\'")+"'))":t+" eq '"+i+"'"}).join(" and "),p=this.geraFiltroTransgenia();p&&p.trim()&&(c=c?"("+c+") and "+p:p);var u=_e(this.transgeniaLookupDisplayFields,this.transgeniaAdvancedDisplayFields);this.transgeniaService.list({page:l,sort:d,filterQuery:c,displayFields:u}).pipe(a.takeUntil(this.ngUnsubscribe)).pipe(a.map(function(e){return j({},e,{contents:e.contents.map(function(e){return j({},e,{label:t.transgeniaLookupDisplayFields.map(function(a){return a.indexOf(".")>0?t.getProp(e,a):e[a]}).join(t.transgeniaLookupSeparator)})})})})).subscribe(function(e){t.transgeniaSearchGridData=e.contents,t.transgeniaSearchTotalRecords=e.totalElements})},e.prototype.addFornecedor=function(e){void 0===e&&(e={}),this.erroFornecedores=!1;var t=this.getFornecedorForm(e);return this.configureFornecedor(t),this.getFornecedoresForm().push(t),t},e.prototype.removeFornecedor=function(e){var t=this;this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_fornecedor_header"),message:this.translate.instant("yms.erp.remove_fornecedor_message"),accept:function(){var a=t.getFornecedoresForm().controls.indexOf(e);t.getFornecedoresForm().removeAt(a)}})},e.prototype.getFornecedoresForm=function(){return this.formGroup.get("fornecedores")},e.prototype.addContrato=function(e){var t=this;this.dialogService.open(Qi,j({},Re,{header:"Adicionar Contrato",data:{agenda:this.agenda,filial:this.formGroup.get("filial").value,produto:this.formGroup.get("produto").value,fornecedor:e.get("fornecedor").value,contratos:e.get("contratos").value}})).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(a){var i=a.contrato;return t.onContratoSaved(i,e)})},e.prototype.removerContrato=function(e,t){this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_contrato_header"),message:this.translate.instant("yms.erp.remove_contrato_message"),accept:function(){var a=e.get("contratos").controls.indexOf(t);e.get("contratos").removeAt(a)}})},e.prototype.getContratos=function(e){return this.contratos=e.get("contratos"),this.contratos},e.prototype.addNota=function(e){var t=this;this.dialogService.open(Wt,j({header:this.translate.instant("yms.erp.adicionar_nota")},Re,{data:{fornecedor:e.get("fornecedor").value,produto:this.formGroup.get("produto").value,filial:this.formGroup.get("filial").value,fornecedorNotasTokens:this.fornecedorNotasTokens,contratos:this.contratos}})).onClose.pipe(a.takeUntil(this.ngUnsubscribe),a.filter(function(e){return!!e})).subscribe(function(a){return t.onNotaSaved(a,e)})},e.prototype.removerNota=function(e,t,a){var i=this;this.confirmationService.confirm({header:this.translate.instant("yms.erp.remove_nota_header"),message:this.translate.instant("yms.erp.remove_nota_message"),accept:function(){var r=t.value.contrato.id,o=i.getNotasFromContratos(e,r).controls.indexOf(a);i.getNotasFromContratos(e,r).removeAt(o);var n=a.value;i.fornecedorNotasTokens.push({id:n.chaveNotaFiscal,label:n.numeroNotaFiscal}),i.fornecedorNotas.push({chaveNotaFiscal:n.chaveNotaFiscal,serieNotaFiscal:n.serieNotaFiscal,serieLegalNotaFiscal:n.serieLegalNotaFiscal,numeroNotaFiscal:n.numeroNotaFiscal})}})},e.prototype.getNotas=function(e){return e.controls.notas},e.prototype.getItensContrato=function(e){return e.get("itens")},e.prototype.showButtons=function(){return!!this.agenda&&(this.isNew()||[dt.AGENDADO,dt.AGUARDANDO_CONFIRMACAO,dt.AGUARDANDO_CONFIRMACAO_SOLICITANTE,dt.REJEITADO_POR_VALIDACAO].includes(this.agenda.status))},e.prototype.disableAdicionarNota=function(){return null===this.contratoSelecionado},e.prototype.getTipoTransgenia=function(){if(this.formGroup.get("fornecedores").length<=0)return null;var e=null;return Xi.toDto(this.formGroup.getRawValue()).fornecedores.forEach(function(t){null!=t.fornecedor&&null!=t.fornecedor.tipoParticipante&&(e=t.fornecedor.tipoParticipante)}),e},e.prototype.getFamiliaProduto=function(){var e=this.formGroup.get("produto").value;return e&&e.familia&&e.familia.codigo?e.familia.codigo:e&&e.familia?e.familia:null},e.prototype.geraFiltroTransgenia=function(){var e="empresa.id eq '"+this.formGroup.get("filial").value.empresa.id+"'";e+="and situacao eq '"+Di.ATIVO+"'";var t=this.getFamiliaProduto();t&&(e+=" and ",e+="familia eq '"+t+"'");var a=this.getTipoTransgenia();return a&&(e+=" and ",e+="tipoParticipante eq '"+a+"'"),e},e.prototype.getNotaForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({chaveNotaFiscal:[e.chaveNotaFiscal],serieNotaFiscal:[e.serieNotaFiscal],serieLegalNotaFiscal:[e.serieLegalNotaFiscal],numeroNotaFiscal:[e.numeroNotaFiscal]})},e.prototype.getContratoForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({contrato:[e.contrato,C.Validators.required],itens:this.formBuilder.array([]),notas:this.formBuilder.array([])})},e.prototype.getItemForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({item:[e.item,C.Validators.required],quantidade:[e.quantidade]})},e.prototype.getFornecedorForm=function(e){return void 0===e&&(e={}),this.formBuilder.group({fornecedor:[e.fornecedor,C.Validators.required],origemMercadoria:[e.origemMercadoria,C.Validators.compose([C.Validators.required])],tipoNotaFiscal:[e.tipoNotaFiscal||Si.EMPRESA_JURIDICA,C.Validators.compose([])],contratos:this.formBuilder.array([])})},e.prototype.getFormGroup=function(){return this.formBuilder.group({id:[{value:undefined,disabled:!0},C.Validators.compose([])],filial:[{value:undefined,disabled:!1},C.Validators.required],produto:[{value:undefined,disabled:!0},C.Validators.compose([C.Validators.required])],derivacao:[{value:undefined,disabled:!0},C.Validators.compose([])],transportadora:[{value:undefined,disabled:!1},C.Validators.compose([])],agenda:[{value:this.agenda,disabled:!1},C.Validators.compose([C.Validators.required])],transgenia:[{value:undefined,disabled:!0},C.Validators.compose([])],fornecedores:this.formBuilder.array([]),createdBy:[{value:undefined,disabled:!0},C.Validators.compose([])],createdDate:[{value:undefined,disabled:!0},C.Validators.compose([])],lastModifiedBy:[{value:undefined,disabled:!0},C.Validators.compose([])],lastModifiedDate:[{value:undefined,disabled:!0},C.Validators.compose([])],custom:[]})},e.prototype.getFornecedorByContrato=function(e,t){this.pessoaService.list({size:1,page:0,filterQuery:"id eq '"+e.pessoa.id+"'"}).pipe(a.takeUntil(this.ngUnsubscribe),a.map(function(e){var t=e.contents;return(t||[]).length&&t[0]}),a.filter(function(e){return!!e})).subscribe(function(e){t.get("fornecedor").setValue(Ot.fromDto(e))})},e.prototype.getProdutoByContrato=function(e){var i=this;this.contratoCompraService.listItens(e.id,{size:1,page:0,displayFields:["sku.id"]}).pipe(a.takeUntil(this.ngUnsubscribe),a.mergeMap(function(e){var r=e.contents;return 1===r.length?i.produtoService.list({size:1,page:0,filterQuery:"id eq '"+r[0].sku.id+"'"}).pipe(a.takeUntil(i.ngUnsubscribe),a.map(function(e){var t=e.contents;return(t||[]).length&&t[0]})):t.empty()}),a.filter(function(e){return!!e})).subscribe(function(e){i.formGroup.get("produto").setValue(fi.fromDto(e)),i.formGroup.get("produto").disable()})},e.prototype.onContratoSaved=function(e,t){var a=this;this.formGroup.get("produto").value||this.getProdutoByContrato(e.contrato),t.get("fornecedor").value||this.getFornecedorByContrato(e.contrato,t);var i=this.getContratoForm(e);(e.itens||[]).forEach(function(e){return i.get("itens").push(a.getItemForm(e))}),this.getContratos(t).push(i)},e.prototype.mensagemContratoNaoSelecionado=function(){this.addMessage("error","Contrato não selecionado","Nenhum contrato foi selecionado!")},e.prototype.onNotaSaved=function(e,t){if(null!==this.contratoSelecionado)if(e.addFornecedor){var a=this.formGroup.get("fornecedores").controls.find(function(t){return(t.value.fornecedor||{id:undefined}).id===e.fornecedor.id}),i=e.infoNota,r=this.getNotaForm({chaveNotaFiscal:i.chave,serieNotaFiscal:i.serie,serieLegalNotaFiscal:i.serieLegal,numeroNotaFiscal:i.numero});if(a)(n=this.getNotasFromContratos(a,this.contratoSelecionado.id)).push(r);else if(t.get("fornecedor").value){var o=this.addFornecedor({fornecedor:Ot.fromDto(e.fornecedor),origemMercadoria:zt.fromDto(e.origemMercadoria)});(n=this.getNotasFromContratos(o,this.contratoSelecionado.id)).push(r)}else{t.get("fornecedor").setValue(Ot.fromDto(e.fornecedor)),t.get("origemMercadoria").setValue(zt.fromDto(e.origemMercadoria)),(n=this.getNotasFromContratos(t,this.contratoSelecionado.id)).push(r)}}else{var n;null!==(n=this.getNotasFromContratos(t,this.contratoSelecionado.id))&&n.push(this.getNotaForm(e))}else this.mensagemContratoNaoSelecionado()},e.prototype.getNotasFromContratos=function(e,t){var a,i,r=null,o=e.controls.contratos.controls;try{for(var n=z(o),s=n.next();!s.done;s=n.next()){var l=s.value;l.controls.contrato.value.id===t&&(r=l.controls.notas)}}catch(d){a={error:d}}finally{try{s&&!s.done&&(i=n["return"])&&i.call(n)}finally{if(a)throw a.error}}return r},e.prototype.addFornecedorNotasTokenEmContrato=function(e,t){if(null!==this.contratoSelecionado){var a=this.fornecedorNotas.filter(function(e){return e.chaveNotaFiscal===t.id}),i=this.getNotasFromContratos(e,this.contratoSelecionado.id);null!==i&&null!==a[0]&&i.push(this.getNotaForm(a[0])),this.removeFornecedorNotasTokenDoContrato(t)}else this.mensagemContratoNaoSelecionado()},e.prototype.removeFornecedorNotasTokenDoContrato=function(e){this.fornecedorNotasTokens.splice(this.fornecedorNotasTokens.indexOf(e),1),this.fornecedorNotas=this.fornecedorNotas.filter(function(t){return t.chaveNotaFiscal!==e.id})},e.prototype.removeNotaError=function(){this.erroFornecedoresNotaDuplicada=null,this.erroChaveNota=!1},e.prototype.addNotaError=function(){this.erroChaveNota=!0},e.prototype.validateProduto=function(e){return this.formGroup.get("produto").value.id===e.id},e.prototype.getFilialSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.filial_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.filial_nome"),type:n.FieldType.String})]},e.prototype.getFornecedorSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.pessoa_codigo"),type:n.FieldType.Integer}),new n.FormField({name:"nome",label:this.translate.instant("yms.erp.pessoa_nome"),type:n.FieldType.String}),new n.FormField({name:"cpfCnpj",label:this.translate.instant("yms.erp.pessoa_cpfCnpj"),type:n.FieldType.String})]},e.prototype.getFornecedorSearchGridFields=function(){return this.getFornecedorSearchFields()},e.prototype.getOrigemMercadoriaFields=function(){return[this.buildFormField.buildForInteger("codigo","yms.erp.pessoa_endereco_codigo"),this.buildFormField.buildForString("cnpjCpf","yms.erp.pessoa_endereco_cnpj_cpf"),this.buildFormField.buildForString("inscricaoEstadual","yms.erp.pessoa_endereco_inscricao_estadual"),this.buildFormField.buildForString("cep","yms.erp.pessoa_endereco_cep"),this.buildFormField.buildForString("endereco","yms.erp.pessoa_endereco_endereco"),this.buildFormField.buildForString("numero","yms.erp.pessoa_endereco_numero"),this.buildFormField.buildForString("bairro","yms.erp.pessoa_endereco_bairro")]},e.prototype.getOrigemMercadoriaGridFields=function(){var e=this.getOrigemMercadoriaFields();return e.push(this.buildFormField.buildForString("empresa.descricao","yms.erp.empresa")),e},e.prototype.getProdutoSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.produto_codigo"),type:n.FieldType.String}),new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.produto_descricao"),type:n.FieldType.String})]},e.prototype.getProdutoSearchGridFields=function(){var e=this.getProdutoSearchFields();return e.push(new n.FormField({name:"descricaoComplementar",label:this.translate.instant("yms.erp.produto_descricao_complementar"),type:n.FieldType.String})),e},e.prototype.getAgendaSearchFields=function(){return[new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.agenda_descricao"),type:n.FieldType.String})]},e.prototype.getAgendaSearchGridFields=function(){return[new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.agenda_descricao"),type:n.FieldType.String})]},e.prototype.getDerivacaoSearchFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.derivacao_codigo"),type:n.FieldType.String}),new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.derivacao_descricao"),type:n.FieldType.String})]},e.prototype.getDerivacaoSearchGridFields=function(){return[new n.FormField({name:"codigo",label:this.translate.instant("yms.erp.derivacao_codigo"),type:n.FieldType.String}),new n.FormField({name:"descricao",label:this.translate.instant("yms.erp.derivacao_descricao"),type:n.FieldType.String})]},e.prototype.getTransportadoraSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_descricao")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getTransportadoraSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.transportadora_codigo")}),new n.FormField({name:"pessoa.nome",type:n.FieldType.Integer,label:this.translate.instant("yms.erp.pessoa_nome")}),new n.FormField({name:"pessoa.cpfCnpj",type:n.FieldType.String,label:this.translate.instant("yms.erp.transportadora_cnpj")})]},e.prototype.getTransgeniaSearchFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.transgenia_codigo")}),new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.transgenia_descricao")})]},e.prototype.getTransgeniaSearchGridFields=function(){return[new n.FormField({name:"codigo",type:n.FieldType.String,label:this.translate.instant("yms.erp.transgenia_codigo")}),new n.FormField({name:"descricao",type:n.FieldType.String,label:this.translate.instant("yms.erp.transgenia_descricao")})]},e.prototype.goBack=function(){this.router.navigate(["../"],{relativeTo:this.route.parent})},e.prototype.validateAllFormFields=function(e){var t=this;Object.keys(e.controls).forEach(function(a){var i=e.get(a);i instanceof C.FormControl?i.markAsDirty({onlySelf:!0}):i instanceof C.FormGroup?t.validateAllFormFields(i):i instanceof C.FormArray&&i.controls.forEach(function(e){return t.validateAllFormFields(e)})}),this.focusService.focusFirstInvalidInput()},e.prototype.getSaveObservable=function(){var e=this.formGroup.getRawValue();e.agenda=this.agenda;var t,a=Xi.toDto(e),i=a.fornecedores;if(a.fornecedores.forEach(function(e){a.fornecedores.forEach(function(t){e.fornecedor.id===t.fornecedor.id&&e.origemMercadoria.id===t.origemMercadoria.id&&(t.contratos.forEach(function(t){return e.contratos.push(t)}),i=i.splice(i.indexOf(t),1))})}),a.fornecedores=i,this.isNew()&&!e.id)t=this.recebimentoService.insert(a);else{var r=e.id;t=this.recebimentoService.update(r,a)}return t},e.prototype.getDeleteObservable=function(){var e=this;return this.recebimentoService["delete"]("").pipe(a.tap(function(){e.addMessage("success","yms.erp.deleted_message_title","yms.erp.deleted_message_content"),e.goBack()}))},e.prototype.validateVisualization=function(){Ie(this.formGroup,this.allPermissions)||this.addMessage("error","yms.erp.cannot_visualize_form_summary","yms.erp.cannot_visualize_form_detail")},e.prototype.addMessage=function(e,t,a){this.messageService.add({severity:e,summary:this.translate.instant(t),detail:this.translate.instant(a)})},e.prototype.buscarFilial=function(){var e=this,t=this.agenda.planta||{cnpj:[]};1===t.cnpj.length?this.filialService.list({page:0,size:1,filterQuery:"pessoa.cpfCnpj eq '"+t.cnpj[0]+"'",displayFields:["*","empresa.nome"]}).pipe(a.takeUntil(this.ngUnsubscribe)).subscribe(function(t){var a=t.contents;1===a.length&&e.formGroup.get("filial").setValue(Ht.fromDto(a[0])),e.formCarregado=!0}):this.formCarregado=!0},e.prototype.configureFornecedor=function(e){var t=this;e.get("fornecedor").valueChanges.pipe(a.takeUntil(this.ngUnsubscribe),a.debounceTime(500),a.tap(function(a){if(a)return t.ehPessoaJuridica(a)?(e.get("tipoNotaFiscal").setValue(Si.EMPRESA_JURIDICA),void e.get("tipoNotaFiscal").enable()):(e.get("tipoNotaFiscal").setValue(Si.PRODUTOR_RURAL),void e.get("tipoNotaFiscal").disable());e.get("tipoNotaFiscal").setValue(Si.EMPRESA_JURIDICA),e.get("tipoNotaFiscal").disable()}),a.filter(function(e){return!!e||(t.formGroup.get("transgenia").setValue(null),t.formGroup.get("transgenia").disable(),!1)}),a.mergeMap(function(e){return t.pessoaEnderecoService.list({size:10,page:0,filterQuery:"situacao eq 'ATIVO' and pessoa.id eq '"+e.id+"'"}).pipe(a.takeUntil(t.ngUnsubscribe))})).subscribe(function(a){var i=a.contents;t.formGroup.get("transgenia").enable(),1===i.length?e.get("origemMercadoria").setValue(zt.fromDto(i[0])):(e.get("origemMercadoria").setValue(undefined),e.get("origemMercadoria").enable())})},e.prototype.ehPessoaJuridica=function(e){return(e.cpfCnpj||"").replace(/\D+/g,"").length>11},e.prototype.mensagemBuscandoNota=function(){this.messageService.add({severity:"info",summary:"Buscando dados da nota",detail:"Aguarde, buscando dados da nota",life:5e3})},e.prototype.validarCnpjFornecedor=function(e){return!!this.ehPessoaJuridica({cpfCnpj:e})&&this.formGroup.get("fornecedores").controls.find(function(t){return(t.value.fornecedor||{cpfCnpj:""}).cpfCnpj.substring(0,8)===e.substring(0,8)})},V([r.Input(),B("design:type",we)],e.prototype,"agenda",void 0),V([r.ViewChild("customTemplate"),B("design:type",r.TemplateRef)],e.prototype,"customTemplate",void 0),V([r.ViewChild("customFormFields"),B("design:type",r.TemplateRef)],e.prototype,"customFormFields",void 0),e=V([r.Component({selector:"recebimento-form",template:'<p-confirmDialog [acceptLabel]="\'yes\' | translate" acceptIcon="" [rejectLabel]="\'no\' | translate" rejectIcon=""></p-confirmDialog>\n<div *sLoadingState="loading">\n <form [formGroup]="formGroup">\n <div class="ui-g ui-fluid">\n <div class="ui-g-12 ui-md-6">\n <label for="chaveNotaFiscal">{{"yms.erp.recebimento_chave_nota_fiscal" | translate}}</label>\n <input [class.ng-invalid]="erroChaveNota" [(ngModel)]="chaveNotaFiscal" [ngModelOptions]="{ standalone: true }" type="text" id="chaveNotaFiscal" name="chaveNotaFiscal" pInputText autocomplete="off" (blur)="onBlurChaveNotaFiscal()"/>\n <span class="nota-error" *ngIf="erroChaveNota">{{\'yms.erp.produto_nota_error_detail\' | translate}}</span>\n </div>\n </div>\n <div class="ui-fluid">\n <div class="ui-g">\n <div [attr.data-hidden]="true" class="ui-g-12 ui-md-6">\n <label for="id">{{"yms.erp.recebimento_id" | translate}}</label>\n <input #idFormInput type="text" id="id" name="id" pInputText formControlName="id" autocomplete="off" />\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="filial">{{"yms.erp.filial" | translate}}</label>\n <s-lookup dataKey="id" id="filial" name="filial" formControlName="filial"\n [searchFields]="filialSearchFields" [searchGridFields]="filialSearchGridFields"\n [searchGridData]="filialSearchGridData" [multiple]="false"\n [lookupSuggestions]="filialLookupSuggestions"\n (onLookupRequest)="onFilialLookupRequest($event)"\n (onSearchRequest)="onFilialSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="filialSearchTotalRecords"\n [searchTitle]="\'yms.erp.filial_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: filialSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'filial\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="produto">{{"yms.erp.recebimento_produto" | translate}}</label>\n <s-lookup dataKey="id" id="produto" name="produto" formControlName="produto"\n [searchFields]="produtoSearchFields" [searchGridFields]="produtoSearchGridFields"\n [searchGridData]="produtoSearchGridData" [multiple]="false"\n [lookupSuggestions]="produtoLookupSuggestions"\n (onLookupRequest)="onProdutoLookupRequest($event)"\n (onSearchRequest)="onProdutoSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]=produtoSearchTotalRecords\n [searchTitle]="\'yms.erp.recebimento_produto_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: produtoSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="formGroup.controls[\'produto\']"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="derivacao">{{"yms.erp.recebimento_derivacao" | translate}}</label>\n <s-lookup dataKey="id" id="derivacao" name="derivacao" formControlName="derivacao"\n [searchFields]="derivacaoSearchFields" [searchGridFields]="derivacaoSearchGridFields"\n [searchGridData]="derivacaoSearchGridData" [multiple]="false"\n [lookupSuggestions]="derivacaoLookupSuggestions"\n (onLookupRequest)="onDerivacaoLookupRequest($event)"\n (onSearchRequest)="onDerivacaoSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]=derivacaoSearchTotalRecords\n [searchTitle]="\'yms.erp.recebimento_derivacao_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: derivacaoSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="transportadora">{{"yms.erp.recebimento_transportadora" | translate}}</label>\n <s-lookup dataKey="id" id="transportadora" name="transportadora" formControlName="transportadora"\n [searchFields]="transportadoraSearchFields" [searchGridFields]="transportadoraSearchGridFields"\n [searchGridData]="transportadoraSearchGridData" [multiple]="false"\n [lookupSuggestions]="transportadoraLookupSuggestions"\n (onLookupRequest)="onTransportadoraLookupRequest($event)"\n (onSearchRequest)="onTransportadoraSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="transportadoraSearchTotalRecords"\n [searchTitle]="\'yms.erp.transportadora_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: transportadoraSearchTotalRecords}">\n </s-lookup>\n </div>\n <div class="ui-g-12 ui-md-6">\n <label for="transgenia">{{"yms.erp.recebimento_transgenia" | translate}}</label>\n <s-lookup dataKey="id" id="transgenia" name="transgenia"\n formControlName="transgenia" [searchFields]="transgeniaSearchFields"\n [searchGridFields]="transgeniaSearchGridFields"\n [searchGridData]="transgeniaSearchGridData" [multiple]="false"\n [lookupSuggestions]="transgeniaLookupSuggestions"\n (onLookupRequest)="onTransgeniaLookupRequest($event)"\n (onSearchRequest)="onTransgeniaSearchRequest($event)" lookupDisplayField="label"\n [searchTotalRecords]="transgeniaSearchTotalRecords"\n [searchTitle]="\'yms.erp.recebimento_transgenia_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: transgeniaSearchTotalRecords}">\n </s-lookup>\n </div>\n\n <div class="ui-md-12">\n <s-button styleClass="btn-erp-forms" *ngIf="showButtons() && !!formGroup.get(\'filial\').value && !createdByErp"\n iconClass="fas fa-plus" label="Adicionar fornecedor" priority="secondary" (onClick)="addFornecedor()"\n [disabled]="disableButtonSave || !permissions.editar"></s-button>\n <span style="display: block;" class="input-error" *ngIf="erroFornecedores">{{\'Selecione ao menos um fornecedor para continuar\' | translate}}</span>\n <span style="display: block;" class="input-error" *ngIf="erroFornecedoresNotaDuplicada">{{ erroFornecedoresNotaDuplicada }}</span>\n </div>\n\n <form class="ui-g-12" *ngFor="let fornecedorForm of getFornecedoresForm().controls; let i = index;" [formGroup]="fornecedorForm">\n <p-panel [style]="{position: \'relative\'}" styleClass="form-group ui-g-12 ui-md-12" [toggleable]="true" >\n\n <p-header>\n Fornecedor {{+i+1}}\n <s-button \n style="display: inline-block; position: absolute; right: 50px; top: 10px" \n *ngIf="showButtons() && !createdByErp"\n iconClass="fas fa-trash"\n label="Remover"\n priority="default"\n [auxiliary]="true"\n (onClick)="removeFornecedor(fornecedorForm)"\n >\n </s-button>\n </p-header>\n <div class="ui-g-12 ui-md-6 required">\n <label for="fornecedor">{{"yms.erp.recebimento_fornecedor" | translate}}</label>\n <s-lookup dataKey="id" id="fornecedor" name="fornecedor" formControlName="fornecedor"\n [searchFields]="fornecedorSearchFields" [searchGridFields]="fornecedorSearchGridFields"\n [searchGridData]="fornecedorSearchGridData" [multiple]="false"\n [lookupSuggestions]="fornecedorLookupSuggestions"\n (onLookupRequest)="onFornecedorLookupRequest($event)"\n (onSearchRequest)="onFornecedorSearchRequest($event)" \n lookupDisplayField="label"\n [searchTotalRecords]=fornecedorSearchTotalRecords\n [searchTitle]="\'yms.erp.recebimento_fornecedor_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: fornecedorSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="fornecedorForm.get(\'fornecedor\')"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n <div class="ui-g-12 ui-md-6 required">\n <label for="origemMercadoria">{{"yms.erp.recebimento_origem_mercadoria" | translate}}</label>\n <s-lookup dataKey="id" id="origemMercadoria" name="origemMercadoria"\n formControlName="origemMercadoria" [searchFields]="origemMercadoriaSearchFields"\n [searchGridFields]="origemMercadoriaSearchGridFields"\n [searchGridData]="origemMercadoriaSearchGridData" [multiple]="false"\n [lookupSuggestions]="origemMercadoriaLookupSuggestions"\n (onLookupRequest)="onOrigemMercadoriaLookupRequest($event, fornecedorForm)"\n (onSearchRequest)="onOrigemMercadoriaSearchRequest($event, fornecedorForm)" lookupDisplayField="label"\n [searchTotalRecords]="origemMercadoriaSearchTotalRecords"\n [searchTitle]="\'yms.erp.recebimento_pessoa_endereco_search_title\' | translate"\n [searchEmptyTitle]="\'yms.erp.nothing_found\' | translate"\n [filterLabel]="\'yms.erp.filter\' | translate" [clearLabel]="\'yms.erp.clear\' | translate"\n [cancelLabel]="\'yms.erp.cancel\' | translate" [selectLabel]="\'yms.erp.select\' | translate"\n [searchTotalRecordsLabel]="\'yms.erp.total_records\' | translate: {value: origemMercadoriaSearchTotalRecords}">\n </s-lookup>\n <s-control-errors [control]="fornecedorForm.get(\'origemMercadoria\')"\n [errorMessages]="{ required: \'yms.erp.error_required\' | translate }"></s-control-errors>\n </div>\n\n <div class="ui-g-12">\n <label for="fornecedorNotas">Notas a serem adicionadas</label>\n <s-token-list id="fornecedorNotas" [tokens]="fornecedorNotasTokens" (tokenSelected)="addFornecedorNotasTokenEmContrato(fornecedorForm, $event)" (tokenRemoved)="removeFornecedorNotasTokenDoContrato($event)" [removableTokens]="true"></s-token-list>\n </div>\n\n <div class="ui-g-12">\n <s-button label="Adicionar nota" *ngIf="showButtons()" styleClass="btn-erp-forms" priority="secondary" (onClick)="addNota(fornecedorForm)" [disabled]="disableAdicionarNota()"></s-button>\n <s-button label="Adicionar contrato" *ngIf="showButtons() && !createdByErp" styleClass="btn-erp-forms" priority="secondary" (onClick)="addContrato(fornecedorForm)"></s-button>\n </div>\n\n <div class="ui-g-12 ui-md-6">\n <label for="tipoNotaFiscal">{{"yms.erp.recebimento_tipo_nota_fiscal" | translate}}</label>\n <p-dropdown inputId="tipoNotaFiscal" name="tipoNotaFiscal" [options]="tiposNota" formControlName="tipoNotaFiscal">\n </p-dropdown>\n </div>\n\n <div class="ui-g-12">\n <h4>Contratos</h4>\n <p-table [value]="getContratos(fornecedorForm).controls" [(selection)]="contratoSelecionado">\n <ng-template pTemplate="body" let-rowData>\n <tr [pSelectableRow]="rowData">\n <td style="width: 50px">\n <p-tableRadioButton [value]="rowData.get(\'contrato\').value"></p-tableRadioButton>\n </td>\n <td>\n <p-accordion>\n <p-accordionTab>\n <p-header>\n Contrato {{rowData.get(\'contrato\').value.numero}}, Filial {{rowData.get(\'contrato\').value.filial?.codigo}}\n\n <span *ngIf="showButtons() && !createdByErp" style="margin-left: 10px; float: right;" class="fas fa-trash" (click)="removerContrato(fornecedorForm, rowData)"></span>\n </p-header>\n \n <div class="detail-pane" *ngFor="let item of getItensContrato(rowData).controls">\n <div class="detail-span">\n <span class="title">Sequência</span>\n <span class="data">{{item.value?.item.sequencia}}</span>\n </div>\n </div>\n \n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Notas</span>\n <span class="data">\n <p-accordion>\n <p-accordionTab *ngFor="let nota of getNotas(rowData).controls">\n <p-header>\n {{nota.get(\'chaveNotaFiscal\').value || (nota.get(\'serieNotaFiscal\').value + \' - \' + nota.get(\'numeroNotaFiscal\').value)}}\n\n <span *ngIf="showButtons()" style="margin-left: 10px; float: right;" class="fas fa-trash" (click)="removerNota(fornecedorForm, rowData, nota)"></span>\n </p-header>\n \n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Série nota fiscal</span>\n <span class="data">{{nota.value?.serieNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">Série legal nota fiscal</span>\n <span class="data">{{nota.value?.serieLegalNotaFiscal}}</span>\n </div>\n <div class="detail-span">\n <span class="title">Número nota fiscal</span>\n <span class="data">{{nota.value?.numeroNotaFiscal}}</span>\n </div>\n </div>\n \n </p-accordionTab> \n </p-accordion>\n </span>\n </div>\n </div>\n </p-accordionTab>\n </p-accordion>\n </td>\n </tr>\n </ng-template>\n </p-table>\n </div>\n\n </p-panel>\n\n <div class="ui-g-12" style="text-align: right;" *ngIf="totalEixosContratados || totalEixosComposicao">\n <label for="totalEixosContratados" float="right" style="display: inline;">{{totalEixosContratados}} {{\'yms.erp.total_eixos_contratados\' | translate}} / </label>\n <label for="totalEixosComposicao" float="right" style="display: inline;">{{totalEixosComposicao}} {{\'yms.erp.total_eixos_composicao\' | translate}}</label>\n </div>\n </form>\n\n </div>\n </div>\n </form>\n\n <div style="margin: 5px 0 5px 0;">\n <s-button *ngIf="showButtons()" priority="primary" [label]="\'save\' | translate" (onClick)="onSave()"\n [disabled]="disableButtonSave || !allPermissions.agenda.editar"></s-button>\n <s-button *ngIf="saveAndInitButton && showButtons()" priority="primary" [label]="\'save_and_init\' | translate"\n (onClick)="onSave(true)" [disabled]="disableButtonSave || !allPermissions.agenda.editar"></s-button>\n </div>\n</div>',providers:[c.ConfirmationService],styles:[".required-h3{font-size:1.17rem;font-weight:700}.required-h3::after{content:'*';color:#c13018;font-weight:400;margin-left:5px;font-size:14px}.error-required-message{color:#c13018;margin-top:5px;font-size:12px}.separator{width:100%;margin:5px 0;height:1px;background-color:#ccc}.input-error{color:#c13018}.detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nota-error{color:#c13018}"]}),B("design:paramtypes",[yt,F.Router,F.ActivatedRoute,T.MessageService,c.ConfirmationService,C.FormBuilder,o.TranslateService,O.HotkeysService,Be,Ue,ha,Ua,Ca,oa,Ra,Ea,sa,bt,Xt,Za,c.DialogService,vt,La,qa,Rt,Na,Ja])],e)}(),er=function(){function e(e){this.recebimentoService=e,this.loading=!0,this.unsubscribe$=new t.Subject}return e.prototype.ngAfterViewInit=function(){var e=this;this.recebimentoService.list({filterQuery:"agenda.id eq '"+this.agenda.id+"'",page:0,size:1}).pipe(a.takeUntil(this.unsubscribe$),a.switchMap(function(e){var a=e.contents;return a.length?t.of(a[0]):t.throwError("Recebimento não encontrado.")}),a.finalize(function(){return e.loading=!1})).subscribe(function(t){e.recebimento=Xi.fromDto(t)})},V([r.Input(),B("design:type",Object)],e.prototype,"agenda",void 0),e=V([r.Component({selector:"recebimento-info",template:'\n <div *sLoadingState="loading" style="padding: 20px;">\n <div class="detail-pane" *ngIf="agenda">\n <div class="detail-span">\n <span class="title">\n {{ "yms.erp.recebimento_filial" | translate }}\n </span>\n <span class="data">\n {{ recebimento?.filial?.codigo }} - {{ recebimento?.filial?.nome }}\n </span>\n </div>\n <div class="detail-span">\n <span class="title">\n {{ "yms.erp.recebimento_produto" | translate }}\n </span>\n <span class="data">{{ recebimento?.produto?.descricao }}</span>\n </div>\n <div class="detail-span">\n <span class="title">\n {{ "yms.erp.recebimento_derivacao" | translate }}\n </span>\n <span class="data">{{ recebimento?.derivacao?.descricao }}</span>\n </div>\n </div>\n <div *ngFor="let fornecedor of recebimento?.fornecedores">\n <div class="separator"></div>\n <h3>Fornecedor - {{ fornecedor?.fornecedor?.nome }}</h3>\n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">\n {{ "yms.erp.recebimento_origem_mercadoria" | translate }}\n </span>\n <span class="data">\n {{ fornecedor?.origemMercadoria?.codigo }} - {{ fornecedor?.origemMercadoria?.cep }}\n </span>\n </div>\n </div>\n\n <div>\n <h4>Contratos</h4>\n <p-accordion>\n <p-accordionTab *ngFor="let contrato of fornecedor.contratos">\n <p-header>\n Contrato {{ contrato?.contrato?.numero }}, Filial {{ contrato?.contrato?.filial?.codigo }}\n </p-header>\n\n <div class="detail-pane" *ngFor="let item of contrato?.itens">\n <div class="detail-span">\n <span class="title">Sequência</span>\n <span class="data">{{ item?.item?.sequencia }}</span>\n </div>\n </div>\n\n <div *ngFor="let nota of contrato.notas">\n <div class="detail-pane">\n <div class="detail-span">\n <span class="title">Chave nota fiscal</span>\n <span class="data">{{ nota?.chaveNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Serie nota fiscal</span>\n <span class="data">{{ nota?.serieNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Serie legal nota fiscal</span>\n <span class="data">{{ nota?.serieLegalNotaFiscal }}</span>\n </div>\n <div class="detail-span">\n <span class="title">Número nota fiscal</span>\n <span class="data">{{ nota?.numeroNotaFiscal }}</span>\n </div>\n </div>\n <hr />\n </div>\n </p-accordionTab>\n </p-accordion>\n </div>\n </div>\n </div>\n ',styles:[".detail-pane{display:flex;flex-wrap:wrap;justify-content:flex-start}.detail-pane .detail-span{width:50%;padding:10px 0;display:flex;flex-direction:column}.detail-pane .detail-span .title{font-size:14px;opacity:.7;margin-bottom:4px}.detail-pane .detail-span .data{font-size:16px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}"]}),B("design:paramtypes",[yt])],e)}();function tr(){return[{name:"json",func:q},{name:"xml",func:x}]}var ar=function(){function e(e){this.dispatcher=e,this.dispatcher.dispatch(Tt).dispatch(Mt).dispatch(Ei)}return e=V([r.NgModule({declarations:[Tt,Zi,Mi,Mt,Ri,er,Ci,Vi,Ui,_i,Qi,Jt,Oi,Li,Ei],entryComponents:[Tt,Mt,Qi,Jt,Ei],exports:[Tt,Mt],imports:[i.CommonModule,C.FormsModule,C.ReactiveFormsModule,o.TranslateModule,n.CustomFieldsModule,n.ControlErrorsModule,E.DialogModule,n.EmptyStateModule,n.DynamicFormModule,n.TokenListModule,N.PanelModule,R.AccordionModule,D.InputTextModule,G.DropdownModule,n.ButtonModule,n.LoadingStateModule,n.NumberInputModule,A.ConfirmDialogModule,n.LocaleModule,p.IntegrationModule,oi,m.PermissionsModule,v.DynamicDialogModule,Zt,R.AccordionModule,l.TableModule,y.TabViewModule,n.LoadingStateModule,M.HighlightModule.forRoot({languages:tr}),O.HotkeyModule.forRoot()],providers:[Be,Ue,bt,St,ni,ji,Ni,Rt]}),B("design:paramtypes",[p.IntegrationDispatcher])],e)}(),ir=function(e){function t(t,a){var i=e.call(this,a)||this;return i.http=t,i.messageService=a,i.url_dock="yms/dock/",i}return P(t,e),t.prototype.fallbackCall=function(e,t,a){return this.http.post(this.url_dock+"actions/setVagaInTransit",{plantId:e,vaga:t,plate:a}).pipe(this.defaultCatch())},t=V([r.Injectable(),B("design:paramtypes",[d.HttpClient,c.MessageService])],t)}(Q),rr=function(){function e(){}return e=V([r.NgModule({providers:[ir]})],e)}();e.AgendaModule=ea,e.AgendaService=vt,e.BalancaModule=ie,e.BalancasService=Z,e.CamerasModule=le,e.CamerasService=re,e.CancelasModule=W,e.CidadeModule=aa,e.CidadeService=ta,e.ContratoCompraItemModule=ra,e.ContratoCompraItemService=ia,e.ContratoCompraModule=na,e.ContratoCompraService=oa,e.ControladorCancelaComponent=X,e.ControladorCancelaDescritor=J,e.ControladorCancelasService=K,e.CoreModule=oi,e.DockModule=rr,e.DockService=ir,e.ERP_ENVIRONMENT=gt,e.ERP_SENIOR_HEADER=Ct,e.EmpresaModule=ca,e.EmpresaService=da,e.ErpFormConfigService=qa,e.ErpProcessData=Oa,e.ErpProcessService=La,e.ErpSeniorModule=ar,e.EstadoModule=ua,e.EstadoService=pa,e.ExpedicaoChegadaVeiculoOverride=St,e.ExpedicaoModule=Ha,e.ExpedicaoService=Ft,e.FamiliaProdutoModule=fa,e.FamiliaProdutoService=ma,e.FieldCustomizationService=Be,e.FilialModule=ga,e.FilialService=ha,e.FormComponent=Tt,e.FormDescritor=_t,e.FormSamComponent=Ve,e.FormSamDescritor=je,e.HasChangeService=Na,e.InfoComponent=Mt,e.InfoDescritor=It,e.IntegrationWebSocket=Y,e.LogsModule=fe,e.LogsService=pe,e.LprModule=ce,e.LprService=de,e.PaisModule=ya,e.PaisService=va,e.PedidoVendaItemModule=Fa,e.PedidoVendaItemService=ba,e.PedidoVendaModule=Da,e.PedidoVendaService=Sa,e.PessoaEnderecoModule=_a,e.PessoaEnderecoService=Ca,e.PessoaFisicaModule=ka,e.PessoaFisicaService=Ta,e.PessoaJuridicaModule=Ma,e.PessoaJuridicaService=Ia,e.PessoaModule=Aa,e.PessoaService=Ra,e.PortariasComponent=ve,e.PortariasDescritor=ge,e.PortariasModule=Se,e.ProdutoModule=Ga,e.ProdutoService=Ea,e.RecebimentoChegadaVeiculoOverride=bt,e.RecebimentoContratoModule=xa,e.RecebimentoContratoService=yt,e.RoyaltyModule=Pa,e.RoyaltyService=wa,e.SAM_SENIOR_HEADER=Pe,e.SafraModule=Va,e.SafraService=ja,e.SamSeniorModule=pt,e.SnapshotComponent=se,e.SnapshotDescritor=ne,e.TransportadoraModule=Ba,e.TransportadoraService=Ua,e.UnidadeMedidaModule=$a,e.UnidadeMedidaService=za,e.VisitorListComponent=mt,e.VisitorListModule=ft,e.VisitorListService=ut,e.VisualizarBalancaComponent=te,e.VisualizarBalancaDescritor=ee,e.highlightLanguages=tr,e.ɵa=Q,e.ɵb=ae,e.ɵba=Rt,e.ɵbb=Ja,e.ɵbc=Mi,e.ɵbd=Ri,e.ɵbe=er,e.ɵbf=Ci,e.ɵbg=Ya,e.ɵbh=ni,e.ɵbi=Vi,e.ɵbj=At,e.ɵbk=Xa,e.ɵbl=ji,e.ɵbm=Ui,e.ɵbn=_i,e.ɵbo=Qi,e.ɵbp=Jt,e.ɵbq=Oi,e.ɵbr=ti,e.ɵbs=Ni,e.ɵbt=Li,e.ɵbu=Ai,e.ɵbv=Ei,e.ɵbw=ii,e.ɵbx=la,e.ɵby=Qa,e.ɵbz=Ka,e.ɵc=oe,e.ɵca=Wa,e.ɵcb=ei,e.ɵcc=ai,e.ɵcd=ri,e.ɵce=Zt,e.ɵcf=Wt,e.ɵd=ue,e.ɵe=me,e.ɵf=he,e.ɵg=Fe,e.ɵh=ye,e.ɵi=be,e.ɵj=He,e.ɵk=Ye,e.ɵl=ze,e.ɵm=ct,e.ɵn=nt,e.ɵo=et,e.ɵp=tt,e.ɵq=Ze,e.ɵr=We,e.ɵs=Xe,e.ɵt=Ue,e.ɵu=ht,e.ɵv=Dt,e.ɵw=Zi,e.ɵx=sa,e.ɵy=Xt,e.ɵz=Za,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
2
2
|
//# sourceMappingURL=seniorsistemas-yms-integration.umd.min.js.map
|