@seniorsistemas/yms-integration 1.4.3 → 1.5.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.
Files changed (62) hide show
  1. package/bundles/seniorsistemas-yms-integration.umd.js +229 -164
  2. package/bundles/seniorsistemas-yms-integration.umd.js.map +1 -1
  3. package/bundles/seniorsistemas-yms-integration.umd.min.js +1 -1
  4. package/bundles/seniorsistemas-yms-integration.umd.min.js.map +1 -1
  5. package/esm2015/index.js +3 -1
  6. package/esm2015/src/erp-senior/core/entities/agenda/agenda-dto.js +1 -5
  7. package/esm2015/src/erp-senior/core/entities/agenda/agenda.js +1 -5
  8. package/esm2015/src/erp-senior/core/entities/agenda/agenda.service.js +4 -1
  9. package/esm2015/src/erp-senior/core/entities/devolucao/devolucao.module.js +3 -1
  10. package/esm2015/src/erp-senior/core/entities/motorista/motorista.js +1 -0
  11. package/esm2015/src/erp-senior/core/entities/processo-avulso/processo-avulso.module.js +3 -2
  12. package/esm2015/src/erp-senior/core/entities/recebimento-contrato/recebimento.js +1 -7
  13. package/esm2015/src/erp-senior/core/entities/recebimento-contrato/recebimento.module.js +3 -1
  14. package/esm2015/src/erp-senior/core/entities/recebimento-ordem-compra/recebimento-ordem-compra.module.js +3 -1
  15. package/esm2015/src/erp-senior/core/erp-process-data/erp-process-data.js +3 -0
  16. package/esm2015/src/erp-senior/core/erp-process-data/erp-process-service.js +74 -0
  17. package/esm2015/src/erp-senior/core/veiculo/veiculo.js +1 -0
  18. package/esm2015/src/erp-senior/devolucao/form/devolucao-form.component.js +21 -25
  19. package/esm2015/src/erp-senior/expedicao/form/expedicao-form.component.js +32 -25
  20. package/esm2015/src/erp-senior/processo-avulso/form/processo-avulso-form.component.js +29 -25
  21. package/esm2015/src/erp-senior/recebimento/form/recebimento-form.component.js +40 -26
  22. package/esm2015/src/erp-senior/recebimento-ordem-compra/form/recebimento-ordem-compra-form.component.js +36 -25
  23. package/esm5/index.js +3 -1
  24. package/esm5/src/erp-senior/core/entities/agenda/agenda-dto.js +1 -5
  25. package/esm5/src/erp-senior/core/entities/agenda/agenda.js +1 -5
  26. package/esm5/src/erp-senior/core/entities/agenda/agenda.service.js +4 -1
  27. package/esm5/src/erp-senior/core/entities/devolucao/devolucao.module.js +3 -1
  28. package/esm5/src/erp-senior/core/entities/motorista/motorista.js +1 -0
  29. package/esm5/src/erp-senior/core/entities/processo-avulso/processo-avulso.module.js +3 -2
  30. package/esm5/src/erp-senior/core/entities/recebimento-contrato/recebimento.js +1 -7
  31. package/esm5/src/erp-senior/core/entities/recebimento-contrato/recebimento.module.js +3 -1
  32. package/esm5/src/erp-senior/core/entities/recebimento-ordem-compra/recebimento-ordem-compra.module.js +3 -1
  33. package/esm5/src/erp-senior/core/erp-process-data/erp-process-data.js +7 -0
  34. package/esm5/src/erp-senior/core/erp-process-data/erp-process-service.js +75 -0
  35. package/esm5/src/erp-senior/core/veiculo/veiculo.js +1 -0
  36. package/esm5/src/erp-senior/devolucao/form/devolucao-form.component.js +21 -25
  37. package/esm5/src/erp-senior/expedicao/form/expedicao-form.component.js +33 -25
  38. package/esm5/src/erp-senior/processo-avulso/form/processo-avulso-form.component.js +29 -25
  39. package/esm5/src/erp-senior/recebimento/form/recebimento-form.component.js +40 -26
  40. package/esm5/src/erp-senior/recebimento-ordem-compra/form/recebimento-ordem-compra-form.component.js +36 -25
  41. package/fesm2015/seniorsistemas-yms-integration.js +224 -164
  42. package/fesm2015/seniorsistemas-yms-integration.js.map +1 -1
  43. package/fesm5/seniorsistemas-yms-integration.js +229 -166
  44. package/fesm5/seniorsistemas-yms-integration.js.map +1 -1
  45. package/index.d.ts +2 -0
  46. package/package.json +1 -1
  47. package/seniorsistemas-yms-integration.metadata.json +1 -1
  48. package/src/erp-senior/core/entities/agenda/agenda-dto.d.ts +2 -0
  49. package/src/erp-senior/core/entities/agenda/agenda.d.ts +4 -1
  50. package/src/erp-senior/core/entities/agenda/agenda.service.d.ts +2 -0
  51. package/src/erp-senior/core/entities/motorista/motorista.d.ts +3 -0
  52. package/src/erp-senior/core/erp-process-data/erp-process-data.d.ts +12 -0
  53. package/src/erp-senior/core/erp-process-data/erp-process-service.d.ts +16 -0
  54. package/src/erp-senior/core/veiculo/veiculo.d.ts +4 -0
  55. package/src/erp-senior/devolucao/form/devolucao-form.component.d.ts +5 -5
  56. package/src/erp-senior/expedicao/form/expedicao-form.component.d.ts +6 -5
  57. package/src/erp-senior/processo-avulso/form/processo-avulso-form.component.d.ts +5 -5
  58. package/src/erp-senior/recebimento/form/recebimento-form.component.d.ts +6 -4
  59. package/src/erp-senior/recebimento-ordem-compra/form/recebimento-ordem-compra-form.component.d.ts +5 -4
  60. package/esm2015/src/utils/form-intact-checker.js +0 -40
  61. package/esm5/src/utils/form-intact-checker.js +0 -43
  62. package/src/utils/form-intact-checker.d.ts +0 -10
@@ -1276,6 +1276,9 @@
1276
1276
  AgendaService.prototype.retornaModelosValidacao = function (tipoAgendamentoId) {
1277
1277
  return this.http.post("yms/agenda/queries/retornaModelosDeValidacao", { tipoAgendamentoId: tipoAgendamentoId }).pipe(this.defaultCatch());
1278
1278
  };
1279
+ AgendaService.prototype.checarRevalidacao = function (erpProcessData) {
1280
+ return this.http.post("yms/agenda/actions/checarRevalidacao", erpProcessData).pipe(this.defaultCatch());
1281
+ };
1279
1282
  AgendaService.prototype.listExternalAgenda = function (listParams) {
1280
1283
  return this.http
1281
1284
  .get("yms/agenda/entities/agenda", {
@@ -3610,6 +3613,82 @@
3610
3613
  /*{CA:FILE_CONTENTS:START}*/
3611
3614
  /*{CA:FILE_CONTENTS:END}*/
3612
3615
 
3616
+ var ErpProcessData = /** @class */ (function () {
3617
+ function ErpProcessData() {
3618
+ }
3619
+ return ErpProcessData;
3620
+ }());
3621
+
3622
+ var ErpProcessService = /** @class */ (function () {
3623
+ function ErpProcessService() {
3624
+ this.messageSource = new rxjs.BehaviorSubject(undefined);
3625
+ this.current = this.messageSource.asObservable();
3626
+ }
3627
+ ErpProcessService.prototype.changeData = function (message) {
3628
+ this.messageSource.next(message);
3629
+ return message;
3630
+ };
3631
+ ErpProcessService.prototype.getProcessData = function () {
3632
+ return this.messageSource.value;
3633
+ };
3634
+ ErpProcessService.prototype.changeDataErp = function (newMessage) {
3635
+ var message = this.messageSource.value ? this.messageSource.value : newMessage;
3636
+ message.filialId = newMessage.filialId;
3637
+ message.chaveIntegracao = newMessage.chaveIntegracao;
3638
+ message.produtoId = newMessage.produtoId;
3639
+ message.transgeniaId = newMessage.transgeniaId;
3640
+ message.transportadoraId = newMessage.transportadoraId;
3641
+ return this.changeData(message);
3642
+ };
3643
+ ErpProcessService.prototype.changeDataVeiculo = function (veiculoId, eixos) {
3644
+ var message = this.messageSource.value ? this.messageSource.value : new ErpProcessData();
3645
+ message.veiculoId = veiculoId;
3646
+ message.eixos = eixos;
3647
+ return this.changeData(message);
3648
+ };
3649
+ ErpProcessService.prototype.changeDataMotorista = function (motoristaId) {
3650
+ var message = this.messageSource.value ? this.messageSource.value : new ErpProcessData();
3651
+ message.motoristaId = motoristaId;
3652
+ return this.changeData(message);
3653
+ };
3654
+ ErpProcessService.prototype.changeDataAgenda = function (agendaId, motoristaId, veiculoId, eixos) {
3655
+ var message = this.messageSource.value ? this.messageSource.value : new ErpProcessData();
3656
+ message.agendaId = agendaId;
3657
+ message.motoristaId = motoristaId;
3658
+ message.veiculoId = veiculoId;
3659
+ message.eixos = eixos;
3660
+ return this.changeData(message);
3661
+ };
3662
+ ErpProcessService.prototype.builderErpProcessData = function (erpProcessData, formGroup) {
3663
+ erpProcessData.chaveIntegracao = formGroup.get("chaveNotaFiscal") != null ? formGroup.get("chaveNotaFiscal").value : null;
3664
+ erpProcessData.filialId = this.getFieldFormGroup(formGroup, 'filial');
3665
+ erpProcessData.produtoId = this.getFieldFormGroup(formGroup, 'produto');
3666
+ erpProcessData.transgeniaId = this.getFieldFormGroup(formGroup, 'transgenia');
3667
+ erpProcessData.transportadoraId = this.getFieldFormGroup(formGroup, 'transportadora');
3668
+ erpProcessData.fornecedores = this.listarIdsFornecedores(formGroup);
3669
+ return erpProcessData;
3670
+ };
3671
+ ErpProcessService.prototype.getFieldFormGroup = function (formGroup, fieldName) {
3672
+ if (formGroup.get(fieldName) == null || formGroup.get(fieldName).value == null) {
3673
+ return null;
3674
+ }
3675
+ return formGroup.get(fieldName).value.id;
3676
+ };
3677
+ ErpProcessService.prototype.listarIdsFornecedores = function (formGroup) {
3678
+ var listaFornecedores = [];
3679
+ var fornecedores = formGroup.get("fornecedores") != null ? formGroup.get("fornecedores").value : null;
3680
+ if (fornecedores != null) {
3681
+ fornecedores.forEach(function (element) { return listaFornecedores.push(element.fornecedor); });
3682
+ }
3683
+ return listaFornecedores.map(function (val) { return val.id; });
3684
+ };
3685
+ ErpProcessService = __decorate([
3686
+ core.Injectable(),
3687
+ __metadata("design:paramtypes", [])
3688
+ ], ErpProcessService);
3689
+ return ErpProcessService;
3690
+ }());
3691
+
3613
3692
  /*{CA:PROJECT_IMPORTS:START}*/
3614
3693
  /*{CA:PROJECT_IMPORTS:END}*/
3615
3694
  var RecebimentoContratoModule = /** @class */ (function () {
@@ -3628,6 +3707,7 @@
3628
3707
  ],
3629
3708
  providers: [
3630
3709
  RecebimentoContratoService,
3710
+ ErpProcessService,
3631
3711
  ],
3632
3712
  declarations: [
3633
3713
  /*{CA:MODULE_DECLARATIONS:START}*/
@@ -3943,6 +4023,7 @@
3943
4023
  ],
3944
4024
  providers: [
3945
4025
  DevolucaoService,
4026
+ ErpProcessService,
3946
4027
  ],
3947
4028
  declarations: [
3948
4029
  /*{CA:MODULE_DECLARATIONS:START}*/
@@ -4036,6 +4117,7 @@
4036
4117
  ],
4037
4118
  providers: [
4038
4119
  RecebimentoOrdemCompraService,
4120
+ ErpProcessService,
4039
4121
  ],
4040
4122
  declarations: [
4041
4123
  /*{CA:MODULE_DECLARATIONS:START}*/
@@ -4116,7 +4198,7 @@
4116
4198
  },
4117
4199
  ]),
4118
4200
  ],
4119
- providers: [ProcessoAvulsoService]
4201
+ providers: [ProcessoAvulsoService, ErpProcessService]
4120
4202
  })
4121
4203
  ], ProcessoAvulsoModule);
4122
4204
  return ProcessoAvulsoModule;
@@ -4278,8 +4360,6 @@
4278
4360
  var Agenda = /** @class */ (function () {
4279
4361
  function Agenda() {
4280
4362
  }
4281
- /*{CA:CLASS_ATTRIBUTES:START}*/
4282
- /*{CA:CLASS_ATTRIBUTES:END}*/
4283
4363
  Agenda.fromDto = function (agendaDto, originEntity) {
4284
4364
  var model = __assign({}, agendaDto);
4285
4365
  model.createdDate = model.createdDate && moment$b(model.createdDate).toDate();
@@ -4298,8 +4378,6 @@
4298
4378
  };
4299
4379
  return Agenda;
4300
4380
  }());
4301
- /*{CA:FILE_CONTENTS:START}*/
4302
- /*{CA:FILE_CONTENTS:END}*/
4303
4381
 
4304
4382
  var moment$c = _moment;
4305
4383
  /*{CA:PROJECT_IMPORTS:START}*/
@@ -4603,50 +4681,8 @@
4603
4681
  StatusAgenda["CANCELADO"] = "CANCELADO";
4604
4682
  })(StatusAgenda || (StatusAgenda = {}));
4605
4683
 
4606
- var FormIntactChecker = /** @class */ (function () {
4607
- function FormIntactChecker(_form, _replaySubject) {
4608
- var _this = this;
4609
- this._form = _form;
4610
- this._replaySubject = _replaySubject;
4611
- this._form.statusChanges.subscribe(function (change) {
4612
- if (!_this._form.dirty) {
4613
- _this._originalValue = JSON.stringify(_this._form.value);
4614
- }
4615
- });
4616
- this._form.valueChanges.subscribe(function (changedValue) {
4617
- var current_value = JSON.stringify(_this._form.value);
4618
- if (_this._originalValue != current_value) {
4619
- if (_this._replaySubject && (_this._lastNotify == null || _this._lastNotify)) {
4620
- _this._replaySubject.next(false);
4621
- _this._lastNotify = false;
4622
- }
4623
- }
4624
- else {
4625
- if (_this._replaySubject) {
4626
- _this._replaySubject.next(true);
4627
- }
4628
- else {
4629
- _this._form.markAsPristine();
4630
- }
4631
- _this._lastNotify = true;
4632
- }
4633
- });
4634
- }
4635
- FormIntactChecker.prototype.markIntact = function () {
4636
- this._originalValue = JSON.stringify(this._form.value);
4637
- if (this._replaySubject) {
4638
- this._replaySubject.next(true);
4639
- }
4640
- else {
4641
- this._form.markAsPristine();
4642
- }
4643
- this._lastNotify = true;
4644
- };
4645
- return FormIntactChecker;
4646
- }());
4647
-
4648
4684
  var DevolucaoFormComponent = /** @class */ (function () {
4649
- function DevolucaoFormComponent(fb, router, translate, filialService, pessoaService, produtoService, derivacaoService, origemMercadoriaService, transportadoraService, devolucaoService, messageService, route, override, confirmationService, agendaService) {
4685
+ function DevolucaoFormComponent(fb, router, translate, filialService, pessoaService, produtoService, derivacaoService, origemMercadoriaService, transportadoraService, devolucaoService, messageService, route, override, confirmationService, agendaService, erpProcessService) {
4650
4686
  this.fb = fb;
4651
4687
  this.router = router;
4652
4688
  this.translate = translate;
@@ -4662,6 +4698,7 @@
4662
4698
  this.override = override;
4663
4699
  this.confirmationService = confirmationService;
4664
4700
  this.agendaService = agendaService;
4701
+ this.erpProcessService = erpProcessService;
4665
4702
  this.filialLookupDisplayFields = ["codigo", "nome", "empresa.nome"];
4666
4703
  this.filialAdvancedDisplayFields = ["id", "codigo", "nome", "empresa.nome"];
4667
4704
  this.filialLookupSeparator = " - ";
@@ -4684,7 +4721,6 @@
4684
4721
  this.totalEixosContratados = 0;
4685
4722
  this.totalEixosComposicao = 0;
4686
4723
  this.ngUnsubscribe = new rxjs.Subject();
4687
- this.isFormModified = false;
4688
4724
  this.formGroup = this.getFormGroup();
4689
4725
  }
4690
4726
  DevolucaoFormComponent.prototype.ngOnDestroy = function () {
@@ -4728,9 +4764,7 @@
4728
4764
  this.disableButtonSave = true;
4729
4765
  }
4730
4766
  this.createdByErpDisableForm();
4731
- var rs = new rxjs.ReplaySubject();
4732
- rs.subscribe(function (isIntact) { return (_this.isFormModified = !isIntact); });
4733
- this.formIntactChecker = new FormIntactChecker(this.formGroup, rs);
4767
+ this.erpProcessService.current.subscribe(function (message) { return _this.erpProcessData = message; });
4734
4768
  };
4735
4769
  DevolucaoFormComponent.prototype.createdByErpDisableForm = function () {
4736
4770
  if (this.agenda && this.agenda.createdByErp) {
@@ -5042,22 +5076,19 @@
5042
5076
  if (this.isNew()) {
5043
5077
  return this.saveAndInit(start);
5044
5078
  }
5045
- if (this.isFormModified) {
5046
- this.agendaService
5047
- .retornaModelosValidacao(this.agenda.tipoAgendamento.id)
5048
- .pipe(operators.takeUntil(this.ngUnsubscribe))
5049
- .subscribe(function (response) {
5050
- if (response.tiposModeloValidacao.length > 0) {
5051
- _this.atualizaAgendaParaRejeitadoPorValidacao();
5052
- }
5053
- else {
5054
- _this.saveAndInit(start);
5055
- }
5056
- });
5057
- }
5058
- else {
5059
- this.saveAndInit(start);
5060
- }
5079
+ this.erpProcessData = this.erpProcessService.builderErpProcessData(this.erpProcessData, this.formGroup);
5080
+ this.erpProcessService.changeDataErp(this.erpProcessData);
5081
+ return this.agendaService
5082
+ .checarRevalidacao(this.erpProcessData)
5083
+ .pipe(operators.takeUntil(this.ngUnsubscribe), operators.finalize(function () { return _this.loading = false; }))
5084
+ .subscribe(function (response) {
5085
+ if (response.requerRevalidacao) {
5086
+ _this.atualizaAgendaParaRejeitadoPorValidacao();
5087
+ }
5088
+ else {
5089
+ _this.saveAndInit(start);
5090
+ }
5091
+ });
5061
5092
  };
5062
5093
  DevolucaoFormComponent.prototype.atualizaAgendaParaRejeitadoPorValidacao = function () {
5063
5094
  var _this = this;
@@ -5298,7 +5329,8 @@
5298
5329
  router.ActivatedRoute,
5299
5330
  DevolucaoChegadaVeiculoOverride,
5300
5331
  api.ConfirmationService,
5301
- AgendaService])
5332
+ AgendaService,
5333
+ ErpProcessService])
5302
5334
  ], DevolucaoFormComponent);
5303
5335
  return DevolucaoFormComponent;
5304
5336
  }());
@@ -5411,7 +5443,7 @@
5411
5443
 
5412
5444
  var moment$k = _moment;
5413
5445
  var ExpedicaoFormComponent = /** @class */ (function () {
5414
- function ExpedicaoFormComponent(expedicaoService, router, route, messageService, formBuilder, translate, hotkeysService, fieldCustomization, focusService, pessoaService, filialService, transportadoraService, pedidoVendaService, pedidoVendaItemService, agendaService, override, confirmationService) {
5446
+ function ExpedicaoFormComponent(expedicaoService, router, route, messageService, formBuilder, translate, hotkeysService, fieldCustomization, focusService, pessoaService, filialService, transportadoraService, pedidoVendaService, pedidoVendaItemService, agendaService, override, confirmationService, erpProcessService) {
5415
5447
  this.expedicaoService = expedicaoService;
5416
5448
  this.router = router;
5417
5449
  this.route = route;
@@ -5429,6 +5461,7 @@
5429
5461
  this.agendaService = agendaService;
5430
5462
  this.override = override;
5431
5463
  this.confirmationService = confirmationService;
5464
+ this.erpProcessService = erpProcessService;
5432
5465
  this.localeConfig = {};
5433
5466
  this.currencyLocaleOptions = {};
5434
5467
  this.permissions = {};
@@ -5483,7 +5516,6 @@
5483
5516
  this.totalEixosComposicao = 0;
5484
5517
  this.ordersValid = true;
5485
5518
  this.ngUnsubscribe = new rxjs.Subject();
5486
- this.isFormModified = false;
5487
5519
  this.formGroup = this.getFormGroup();
5488
5520
  this.pedidoVendaForm = this.getPedidoVendaForm();
5489
5521
  this.itemFormGroup = this.getOrdemVendaItemForm();
@@ -5544,9 +5576,19 @@
5544
5576
  this.disableOrdersButtons = true;
5545
5577
  }
5546
5578
  this.setPedidosValueChanges();
5547
- var rs = new rxjs.ReplaySubject();
5548
- rs.subscribe(function (isIntact) { return (_this.isFormModified = !isIntact); });
5549
- this.formIntactChecker = new FormIntactChecker(this.formGroup, rs);
5579
+ this.erpProcessService.current.subscribe(function (message) { return _this.erpProcessData = message; });
5580
+ this.revalidacaoTransportadora();
5581
+ };
5582
+ ExpedicaoFormComponent.prototype.revalidacaoTransportadora = function () {
5583
+ var _this = this;
5584
+ this.formGroup.get("transportadora").valueChanges.pipe(operators.takeUntil(this.ngUnsubscribe)).subscribe(function (_) {
5585
+ var transp = _this.formGroup.get("transportadora").value;
5586
+ if (_this.erpProcessService && transp) {
5587
+ _this.erpProcessData.transportadoraId = transp.id;
5588
+ _this.erpProcessService.changeData(_this.erpProcessData);
5589
+ }
5590
+ return;
5591
+ });
5550
5592
  };
5551
5593
  ExpedicaoFormComponent.prototype.abrirPedidoVenda = function (pedidoVenda) {
5552
5594
  var buttons = document
@@ -5770,22 +5812,19 @@
5770
5812
  if (this.isNew()) {
5771
5813
  return this.saveAndInit(filesToDelete, filesToCommit, start);
5772
5814
  }
5773
- if (this.isFormModified) {
5774
- this.agendaService
5775
- .retornaModelosValidacao(this.agenda.tipoAgendamento.id)
5776
- .pipe(operators.takeUntil(this.ngUnsubscribe))
5777
- .subscribe(function (response) {
5778
- if (response.tiposModeloValidacao.length > 0) {
5779
- _this.atualizaAgendaParaRejeitadoPorValidacao();
5780
- }
5781
- else {
5782
- _this.saveAndInit(filesToDelete, filesToCommit, start);
5783
- }
5784
- });
5785
- }
5786
- else {
5787
- this.saveAndInit(filesToDelete, filesToCommit, start);
5788
- }
5815
+ this.erpProcessData = this.erpProcessService.builderErpProcessData(this.erpProcessData, this.formGroup);
5816
+ this.erpProcessService.changeDataErp(this.erpProcessData);
5817
+ return this.agendaService
5818
+ .checarRevalidacao(this.erpProcessData)
5819
+ .pipe(operators.takeUntil(this.ngUnsubscribe), operators.finalize(function () { return _this.loading = false; }))
5820
+ .subscribe(function (response) {
5821
+ if (response.requerRevalidacao) {
5822
+ _this.atualizaAgendaParaRejeitadoPorValidacao();
5823
+ }
5824
+ else {
5825
+ _this.saveAndInit(filesToDelete, filesToCommit, start);
5826
+ }
5827
+ });
5789
5828
  };
5790
5829
  ExpedicaoFormComponent.prototype.atualizaAgendaParaRejeitadoPorValidacao = function () {
5791
5830
  var _this = this;
@@ -6847,7 +6886,8 @@
6847
6886
  PedidoVendaItemService,
6848
6887
  AgendaService,
6849
6888
  ExpedicaoChegadaVeiculoOverride,
6850
- api.ConfirmationService])
6889
+ api.ConfirmationService,
6890
+ ErpProcessService])
6851
6891
  ], ExpedicaoFormComponent);
6852
6892
  return ExpedicaoFormComponent;
6853
6893
  }());
@@ -7130,7 +7170,7 @@
7130
7170
  }());
7131
7171
 
7132
7172
  var ProcessoAvulsoFormComponent = /** @class */ (function () {
7133
- function ProcessoAvulsoFormComponent(fb, router, route, filialService, processoAvulsoService, messageService, processoAvulsoOverride, translate, confirmationService, agendaService) {
7173
+ function ProcessoAvulsoFormComponent(fb, router, route, filialService, processoAvulsoService, messageService, processoAvulsoOverride, translate, confirmationService, agendaService, erpProcessService) {
7134
7174
  this.fb = fb;
7135
7175
  this.router = router;
7136
7176
  this.route = route;
@@ -7141,12 +7181,12 @@
7141
7181
  this.translate = translate;
7142
7182
  this.confirmationService = confirmationService;
7143
7183
  this.agendaService = agendaService;
7184
+ this.erpProcessService = erpProcessService;
7144
7185
  this.loading = false;
7145
7186
  this.filialLookupDisplayFields = ["codigo", "nome", "empresa.nome"];
7146
7187
  this.filialAdvancedDisplayFields = ["id", "codigo", "nome", "empresa.nome"];
7147
7188
  this.filialLookupSeparator = " - ";
7148
7189
  this.ngUnsubscribe = new rxjs.Subject();
7149
- this.isFormModified = false;
7150
7190
  }
7151
7191
  ProcessoAvulsoFormComponent.prototype.ngOnInit = function () {
7152
7192
  var _this = this;
@@ -7158,10 +7198,16 @@
7158
7198
  this.filialSearchFields = this.getFilialSearchFields();
7159
7199
  this.filialSearchGridFields = this.getFilialSearchGridFields();
7160
7200
  this.getProcessoAvulso();
7201
+ this.formGroup.get("filial").valueChanges.pipe(operators.takeUntil(this.ngUnsubscribe)).subscribe(function (_) {
7202
+ var fil = _this.formGroup.get("filial").value;
7203
+ if (_this.erpProcessService && fil) {
7204
+ _this.erpProcessData.filialId = fil.id;
7205
+ _this.erpProcessService.changeData(_this.erpProcessData);
7206
+ }
7207
+ return;
7208
+ });
7161
7209
  this.processoAvulsoOverride.initialize();
7162
- var rs = new rxjs.ReplaySubject();
7163
- rs.subscribe(function (isIntact) { return (_this.isFormModified = !isIntact); });
7164
- this.formIntactChecker = new FormIntactChecker(this.formGroup, rs);
7210
+ this.erpProcessService.current.subscribe(function (message) { return _this.erpProcessData = message; });
7165
7211
  };
7166
7212
  ProcessoAvulsoFormComponent.prototype.ngAfterViewInit = function () {
7167
7213
  this.saveAndInitButton = document.getElementById('init');
@@ -7180,22 +7226,19 @@
7180
7226
  if (this.isNew()) {
7181
7227
  return this.saveAndInit(start);
7182
7228
  }
7183
- if (this.isFormModified) {
7184
- this.agendaService
7185
- .retornaModelosValidacao(this.agenda.tipoAgendamento.id)
7186
- .pipe(operators.takeUntil(this.ngUnsubscribe), operators.finalize(function () { return _this.loading = false; }))
7187
- .subscribe(function (response) {
7188
- if (response.tiposModeloValidacao.length > 0) {
7189
- _this.atualizaAgendaParaRejeitadoPorValidacao();
7190
- }
7191
- else {
7192
- _this.saveAndInit(start);
7193
- }
7194
- });
7195
- }
7196
- else {
7197
- this.saveAndInit(start);
7198
- }
7229
+ this.erpProcessData = this.erpProcessService.builderErpProcessData(this.erpProcessData, this.formGroup);
7230
+ this.erpProcessService.changeDataErp(this.erpProcessData);
7231
+ return this.agendaService
7232
+ .checarRevalidacao(this.erpProcessData)
7233
+ .pipe(operators.takeUntil(this.ngUnsubscribe), operators.finalize(function () { return _this.loading = false; }))
7234
+ .subscribe(function (response) {
7235
+ if (response.requerRevalidacao) {
7236
+ _this.atualizaAgendaParaRejeitadoPorValidacao();
7237
+ }
7238
+ else {
7239
+ _this.saveAndInit(start);
7240
+ }
7241
+ });
7199
7242
  };
7200
7243
  ProcessoAvulsoFormComponent.prototype.atualizaAgendaParaRejeitadoPorValidacao = function () {
7201
7244
  var _this = this;
@@ -7401,7 +7444,8 @@
7401
7444
  ProcessoAvulsoChegadaVeiculoOverride,
7402
7445
  core$1.TranslateService,
7403
7446
  api.ConfirmationService,
7404
- AgendaService])
7447
+ AgendaService,
7448
+ ErpProcessService])
7405
7449
  ], ProcessoAvulsoFormComponent);
7406
7450
  return ProcessoAvulsoFormComponent;
7407
7451
  }());
@@ -7594,7 +7638,7 @@
7594
7638
  }());
7595
7639
 
7596
7640
  var RecebimentoOrdemCompraFormComponent = /** @class */ (function () {
7597
- function RecebimentoOrdemCompraFormComponent(formBuilder, translate, filialService, pessoaService, produtoService, derivacaoService, transportadoraService, ordemCompraService, recebimentoOrdemCompraService, messageService, route, router, origemMercadoriaService, safraService, override, notaValidatorService, confirmationService, dialogService, agendaService) {
7641
+ function RecebimentoOrdemCompraFormComponent(formBuilder, translate, filialService, pessoaService, produtoService, derivacaoService, transportadoraService, ordemCompraService, recebimentoOrdemCompraService, messageService, route, router, origemMercadoriaService, safraService, override, notaValidatorService, confirmationService, dialogService, agendaService, erpProcessService) {
7598
7642
  var _this = this;
7599
7643
  this.formBuilder = formBuilder;
7600
7644
  this.translate = translate;
@@ -7615,6 +7659,7 @@
7615
7659
  this.confirmationService = confirmationService;
7616
7660
  this.dialogService = dialogService;
7617
7661
  this.agendaService = agendaService;
7662
+ this.erpProcessService = erpProcessService;
7618
7663
  this.derivacaoLookupDisplayFields = ["codigo", "descricao"];
7619
7664
  this.derivacaoAdvancedDisplayFields = ["id", "codigo", "descricao"];
7620
7665
  this.derivacaoLookupSeparator = " - ";
@@ -7649,7 +7694,6 @@
7649
7694
  this.fornecedorNotas = [];
7650
7695
  this.ordemCompraSelecionado = null;
7651
7696
  this.ngUnsubscribe = new rxjs.Subject();
7652
- this.isFormModified = false;
7653
7697
  /**PRODUTO DEPENDE DE FILIAL. ORDEM COMPRA DEPENDE DE FILIAL */
7654
7698
  this.onFilialValueChange = function (filial, formGroup) {
7655
7699
  _this.changeFormGroupValue(filial, "produto", formGroup);
@@ -7658,6 +7702,13 @@
7658
7702
  _this.changeFormGroupValue(fornecedor, "origemMercadoria", formGroup);
7659
7703
  _this.changeFormGroupValue(fornecedor, "ordens", formGroup);
7660
7704
  };
7705
+ this.onChangeRevalidation = function (_) {
7706
+ if (_this.erpProcessData && _this.formGroup) {
7707
+ _this.erpProcessData = _this.erpProcessService.builderErpProcessData(_this.erpProcessData, _this.formGroup);
7708
+ _this.erpProcessService.changeData(_this.erpProcessData);
7709
+ }
7710
+ return;
7711
+ };
7661
7712
  this.formGroup = this.getFormGroup();
7662
7713
  }
7663
7714
  RecebimentoOrdemCompraFormComponent.prototype.ngOnInit = function () {
@@ -7669,6 +7720,14 @@
7669
7720
  }
7670
7721
  _this.getRecebimentoOrdemCompra(agenda);
7671
7722
  });
7723
+ this.formGroup
7724
+ .get('filial')
7725
+ .valueChanges.pipe(operators.takeUntil(this.ngUnsubscribe))
7726
+ .subscribe(this.onChangeRevalidation);
7727
+ this.formGroup
7728
+ .get('transportadora')
7729
+ .valueChanges.pipe(operators.takeUntil(this.ngUnsubscribe))
7730
+ .subscribe(this.onChangeRevalidation);
7672
7731
  this.derivacaoSearchFields = this.getDerivacaoSearchFields();
7673
7732
  this.filialSearchFields = this.getFilialSearchFields();
7674
7733
  this.filialSearchGridFields = this.getFilialSearchGridFields();
@@ -7698,9 +7757,7 @@
7698
7757
  this.disableButtonSave = true;
7699
7758
  }
7700
7759
  this.createdByErpDisableForm();
7701
- var rs = new rxjs.ReplaySubject();
7702
- rs.subscribe(function (isIntact) { return (_this.isFormModified = !isIntact); });
7703
- this.formIntactChecker = new FormIntactChecker(this.formGroup, rs);
7760
+ this.erpProcessService.current.subscribe(function (message) { return _this.erpProcessData = message; });
7704
7761
  };
7705
7762
  RecebimentoOrdemCompraFormComponent.prototype.ngAfterViewInit = function () {
7706
7763
  this.override.initialize();
@@ -8111,22 +8168,19 @@
8111
8168
  if (this.isNew()) {
8112
8169
  return this.saveAndInit(start);
8113
8170
  }
8114
- if (this.isFormModified) {
8115
- return this.agendaService
8116
- .retornaModelosValidacao(this.agenda.tipoAgendamento.id)
8117
- .pipe(operators.takeUntil(this.ngUnsubscribe), operators.finalize(function () { return _this.loading = false; }))
8118
- .subscribe(function (response) {
8119
- if (response.tiposModeloValidacao.length > 0) {
8120
- _this.atualizaAgendaParaRejeitadoPorValidacao();
8121
- }
8122
- else {
8123
- _this.saveAndInit(start);
8124
- }
8125
- });
8126
- }
8127
- else {
8128
- return this.saveAndInit(start);
8129
- }
8171
+ this.erpProcessData = this.erpProcessService.builderErpProcessData(this.erpProcessData, this.formGroup);
8172
+ this.erpProcessService.changeDataErp(this.erpProcessData);
8173
+ return this.agendaService
8174
+ .checarRevalidacao(this.erpProcessData)
8175
+ .pipe(operators.takeUntil(this.ngUnsubscribe), operators.finalize(function () { return _this.loading = false; }))
8176
+ .subscribe(function (response) {
8177
+ if (response.requerRevalidacao) {
8178
+ _this.atualizaAgendaParaRejeitadoPorValidacao();
8179
+ }
8180
+ else {
8181
+ _this.saveAndInit(start);
8182
+ }
8183
+ });
8130
8184
  };
8131
8185
  RecebimentoOrdemCompraFormComponent.prototype.atualizaAgendaParaRejeitadoPorValidacao = function () {
8132
8186
  var _this = this;
@@ -8698,7 +8752,8 @@
8698
8752
  NotaValidatorService,
8699
8753
  api.ConfirmationService,
8700
8754
  api.DialogService,
8701
- AgendaService])
8755
+ AgendaService,
8756
+ ErpProcessService])
8702
8757
  ], RecebimentoOrdemCompraFormComponent);
8703
8758
  return RecebimentoOrdemCompraFormComponent;
8704
8759
  }());
@@ -9142,13 +9197,9 @@
9142
9197
  }());
9143
9198
 
9144
9199
  var moment$q = _moment;
9145
- /*{CA:PROJECT_IMPORTS:START}*/
9146
- /*{CA:PROJECT_IMPORTS:END}*/
9147
9200
  var RecebimentoContrato = /** @class */ (function () {
9148
9201
  function RecebimentoContrato() {
9149
9202
  }
9150
- /*{CA:CLASS_ATTRIBUTES:START}*/
9151
- /*{CA:CLASS_ATTRIBUTES:END}*/
9152
9203
  RecebimentoContrato.fromDto = function (recebimentoDto, originEntity) {
9153
9204
  var model = __assign({}, recebimentoDto);
9154
9205
  model.createdDate = model.createdDate && moment$q(model.createdDate).toDate();
@@ -9223,8 +9274,6 @@
9223
9274
  };
9224
9275
  return RecebimentoContrato;
9225
9276
  }());
9226
- /*{CA:FILE_CONTENTS:START}*/
9227
- /*{CA:FILE_CONTENTS:END}*/
9228
9277
 
9229
9278
  var TipoNotaFiscal;
9230
9279
  (function (TipoNotaFiscal) {
@@ -9241,7 +9290,7 @@
9241
9290
 
9242
9291
  var moment$r = _moment;
9243
9292
  var RecebimentoFormComponent = /** @class */ (function () {
9244
- function RecebimentoFormComponent(recebimentoService, router, route, messageService, confirmationService, formBuilder, translate, hotkeysService, fieldCustomization, focusService, filialService, transportadoraService, pessoaEnderecoService, contratoCompraService, pessoaService, produtoService, derivacaoService, recebimentoChegadaOverride, notaValidatorService, transgeniaService, dialogService, agendaService) {
9293
+ function RecebimentoFormComponent(recebimentoService, router, route, messageService, confirmationService, formBuilder, translate, hotkeysService, fieldCustomization, focusService, filialService, transportadoraService, pessoaEnderecoService, contratoCompraService, pessoaService, produtoService, derivacaoService, recebimentoChegadaOverride, notaValidatorService, transgeniaService, dialogService, agendaService, erpProcessService) {
9245
9294
  var _this = this;
9246
9295
  this.recebimentoService = recebimentoService;
9247
9296
  this.router = router;
@@ -9265,6 +9314,7 @@
9265
9314
  this.transgeniaService = transgeniaService;
9266
9315
  this.dialogService = dialogService;
9267
9316
  this.agendaService = agendaService;
9317
+ this.erpProcessService = erpProcessService;
9268
9318
  this.localeConfig = {};
9269
9319
  this.currencyLocaleOptions = {};
9270
9320
  this.permissions = {};
@@ -9311,7 +9361,13 @@
9311
9361
  this.fornecedorNotas = [];
9312
9362
  this.contratoSelecionado = null;
9313
9363
  this.ngUnsubscribe = new rxjs.Subject();
9314
- this.isFormModified = false;
9364
+ this.onChangeRevalidation = function (_) {
9365
+ if (_this.erpProcessData && _this.formGroup) {
9366
+ _this.erpProcessData = _this.erpProcessService.builderErpProcessData(_this.erpProcessData, _this.formGroup);
9367
+ _this.erpProcessService.changeData(_this.erpProcessData);
9368
+ }
9369
+ return;
9370
+ };
9315
9371
  this.getTipoTransgenia = function () {
9316
9372
  if (_this.formGroup.get("fornecedores").length <= 0) {
9317
9373
  return TipoParticipanteTransgenia.NAO_INFORMADO;
@@ -9376,6 +9432,18 @@
9376
9432
  _this.getRecebimento(agenda);
9377
9433
  }
9378
9434
  });
9435
+ this.formGroup
9436
+ .get('transportadora')
9437
+ .valueChanges.pipe(operators.takeUntil(this.ngUnsubscribe))
9438
+ .subscribe(this.onChangeRevalidation);
9439
+ this.formGroup
9440
+ .get('transgenia')
9441
+ .valueChanges.pipe(operators.takeUntil(this.ngUnsubscribe))
9442
+ .subscribe(this.onChangeRevalidation);
9443
+ this.formGroup
9444
+ .get('fornecedores')
9445
+ .valueChanges.pipe(operators.takeUntil(this.ngUnsubscribe))
9446
+ .subscribe(this.onChangeRevalidation);
9379
9447
  this.filialSearchFields = this.getFilialSearchFields();
9380
9448
  this.filialSearchGridFields = this.getFilialSearchFields();
9381
9449
  this.fornecedorSearchFields = this.getFornecedorSearchFields();
@@ -9409,9 +9477,7 @@
9409
9477
  this.disableButtonSave = true;
9410
9478
  }
9411
9479
  this.createdByErpDisableForm();
9412
- var rs = new rxjs.ReplaySubject();
9413
- rs.subscribe(function (isIntact) { return (_this.isFormModified = !isIntact); });
9414
- this.formIntactChecker = new FormIntactChecker(this.formGroup, rs);
9480
+ this.erpProcessService.current.subscribe(function (message) { return _this.erpProcessData = message; });
9415
9481
  };
9416
9482
  RecebimentoFormComponent.prototype.ngAfterViewInit = function () {
9417
9483
  var inputList = document.getElementsByTagName("input");
@@ -9552,7 +9618,6 @@
9552
9618
  };
9553
9619
  RecebimentoFormComponent.prototype.onSave = function (start) {
9554
9620
  var _this = this;
9555
- this.formGroup.get("agenda").setValue(this.agenda);
9556
9621
  if (this.formGroup.get("fornecedores").length <= 0) {
9557
9622
  this.erroFornecedores = true;
9558
9623
  return;
@@ -9564,22 +9629,19 @@
9564
9629
  if (this.isNew()) {
9565
9630
  return this.saveAndInit(start);
9566
9631
  }
9567
- if (this.isFormModified) {
9568
- return this.agendaService
9569
- .retornaModelosValidacao(this.agenda.tipoAgendamento.id)
9570
- .pipe(operators.takeUntil(this.ngUnsubscribe), operators.finalize(function () { return _this.loading = false; }))
9571
- .subscribe(function (response) {
9572
- if (response.tiposModeloValidacao.length > 0) {
9573
- return _this.atualizaAgendaParaRejeitadoPorValidacao();
9574
- }
9575
- else {
9576
- return _this.saveAndInit(start);
9577
- }
9578
- });
9579
- }
9580
- else {
9581
- return this.saveAndInit(start);
9582
- }
9632
+ this.erpProcessData = this.erpProcessService.builderErpProcessData(this.erpProcessData, this.formGroup);
9633
+ this.erpProcessService.changeDataErp(this.erpProcessData);
9634
+ return this.agendaService
9635
+ .checarRevalidacao(this.erpProcessData)
9636
+ .pipe(operators.takeUntil(this.ngUnsubscribe), operators.finalize(function () { return _this.loading = false; }))
9637
+ .subscribe(function (response) {
9638
+ if (response.requerRevalidacao) {
9639
+ _this.atualizaAgendaParaRejeitadoPorValidacao();
9640
+ }
9641
+ else {
9642
+ _this.saveAndInit(start);
9643
+ }
9644
+ });
9583
9645
  };
9584
9646
  RecebimentoFormComponent.prototype.atualizaAgendaParaRejeitadoPorValidacao = function () {
9585
9647
  var _this = this;
@@ -10914,7 +10976,8 @@
10914
10976
  NotaValidatorService,
10915
10977
  TransgeniaService,
10916
10978
  api.DialogService,
10917
- AgendaService])
10979
+ AgendaService,
10980
+ ErpProcessService])
10918
10981
  ], RecebimentoFormComponent);
10919
10982
  return RecebimentoFormComponent;
10920
10983
  }());
@@ -11056,6 +11119,8 @@
11056
11119
  exports.ERP_SENIOR_HEADER = ERP_SENIOR_HEADER;
11057
11120
  exports.EmpresaModule = EmpresaModule;
11058
11121
  exports.EmpresaService = EmpresaService;
11122
+ exports.ErpProcessData = ErpProcessData;
11123
+ exports.ErpProcessService = ErpProcessService;
11059
11124
  exports.ErpSeniorModule = ErpSeniorModule;
11060
11125
  exports.EstadoModule = EstadoModule;
11061
11126
  exports.EstadoService = EstadoService;