@senior-gestao-empresarial/erpx-components 4.8.0 → 4.9.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.
@@ -33362,6 +33362,16 @@
33362
33362
  this.messageService = messageService;
33363
33363
  this.readOnly = false;
33364
33364
  this.showSugestaoButton = true;
33365
+ /**
33366
+ * Controla se o rateio deve ser carregado automaticamente via API quando
33367
+ * idMovimento está presente (modo conectado). Default: true.
33368
+ *
33369
+ * Defina como false para restaurar um rateio que o usuário já distribuiu e que
33370
+ * ainda não foi persistido no backend de rateio: o componente popula a grid a
33371
+ * partir de initialContext/initialRateios e mantém o botão Salvar e a gravação
33372
+ * vinculada ao movimento.
33373
+ */
33374
+ this.loadFromApi = true;
33365
33375
  /**
33366
33376
  * Critério de rateio padrão usado pela API de sugestão.
33367
33377
  * Default: 'V3' (Despesas — Conta X C. Custos).
@@ -33461,13 +33471,13 @@
33461
33471
  });
33462
33472
  ErpRateioEditorComponent.prototype.ngOnChanges = function (changes) {
33463
33473
  var movimentoChanged = changes.idMovimento || changes.tipoMovimento;
33464
- if (movimentoChanged && this.idMovimento && this.tipoMovimento) {
33465
- // Modo conectado: carrega via API
33474
+ if (movimentoChanged && this.idMovimento && this.tipoMovimento && this.loadFromApi) {
33475
+ // Modo conectado com carga via API
33466
33476
  this.carregarRateio();
33467
33477
  }
33468
- else if (this.isStandalone && (changes.initialContext || changes.initialRateios || movimentoChanged)) {
33469
- // Modo standalone: usa inputs diretos (mesmo que vazios)
33470
- this.inicializarStandalone();
33478
+ else if (this.isInputDriven && (changes.initialContext || changes.initialRateios || changes.loadFromApi || movimentoChanged)) {
33479
+ // Alimentado por inputs: modo standalone OU conectado sem carga via API
33480
+ this.inicializarPorInputs();
33471
33481
  }
33472
33482
  };
33473
33483
  Object.defineProperty(ErpRateioEditorComponent.prototype, "rateios", {
@@ -33486,10 +33496,21 @@
33486
33496
  enumerable: true,
33487
33497
  configurable: true
33488
33498
  });
33499
+ Object.defineProperty(ErpRateioEditorComponent.prototype, "isInputDriven", {
33500
+ /**
33501
+ * Indica se o componente é alimentado por inputs em vez da API:
33502
+ * modo standalone (sem idMovimento) OU modo conectado com loadFromApi = false.
33503
+ */
33504
+ get: function () {
33505
+ return this.isStandalone || !this.loadFromApi;
33506
+ },
33507
+ enumerable: true,
33508
+ configurable: true
33509
+ });
33489
33510
  Object.defineProperty(ErpRateioEditorComponent.prototype, "isReady", {
33490
- /** Indica se o componente está pronto para exibir UI (modo conectado carregou OU modo standalone inicializado). */
33511
+ /** Indica se o componente está pronto para exibir UI (carregou via API OU foi inicializado por inputs). */
33491
33512
  get: function () {
33492
- return !!this.loadedContext || this.isStandalone;
33513
+ return !!this.loadedContext || this.isInputDriven;
33493
33514
  },
33494
33515
  enumerable: true,
33495
33516
  configurable: true
@@ -33501,10 +33522,21 @@
33501
33522
  // === AÇÕES PÚBLICAS ===
33502
33523
  ErpRateioEditorComponent.prototype.onSalvar = function () {
33503
33524
  var _this = this;
33525
+ var _a;
33504
33526
  if (this.effectiveReadOnly) {
33505
33527
  return;
33506
33528
  }
33507
33529
  var ctx = this.loadedContext;
33530
+ if (!((_a = ctx === null || ctx === void 0 ? void 0 : ctx.e070fil) === null || _a === void 0 ? void 0 : _a.id) || !(ctx === null || ctx === void 0 ? void 0 : ctx.criRat)) {
33531
+ var message = this.translate.instant('erpx.rateio_editor.erro_contexto_incompleto');
33532
+ this.messageService.add({
33533
+ severity: 'error',
33534
+ summary: this.translate.instant('erpx.rateio_editor.erro_titulo'),
33535
+ detail: message
33536
+ });
33537
+ this.error.emit({ operacao: 'save', message: message });
33538
+ return;
33539
+ }
33508
33540
  var input = {
33509
33541
  idMovimento: this.idMovimento,
33510
33542
  tipoMovimento: this.tipoMovimento,
@@ -33526,13 +33558,14 @@
33526
33558
  });
33527
33559
  _this.save.emit({ idMovimento: _this.idMovimento, tipoMovimento: _this.tipoMovimento, rateios: _this.contasDataSource });
33528
33560
  }, function (err) {
33529
- var _a, _b;
33561
+ var _a;
33562
+ var detail = ((_a = err === null || err === void 0 ? void 0 : err.error) === null || _a === void 0 ? void 0 : _a.message) || (err === null || err === void 0 ? void 0 : err.message) || _this.translate.instant('erpx.rateio_editor.erro_salvar');
33530
33563
  _this.messageService.add({
33531
33564
  severity: 'error',
33532
- summary: _this.translate.instant('erpx.rateio_editor.erro_titulo') || 'Erro',
33533
- detail: ((_a = err === null || err === void 0 ? void 0 : err.error) === null || _a === void 0 ? void 0 : _a.message) || (err === null || err === void 0 ? void 0 : err.message) || 'Erro ao salvar rateio'
33565
+ summary: _this.translate.instant('erpx.rateio_editor.erro_titulo'),
33566
+ detail: detail
33534
33567
  });
33535
- _this.error.emit({ operacao: 'save', message: ((_b = err === null || err === void 0 ? void 0 : err.error) === null || _b === void 0 ? void 0 : _b.message) || (err === null || err === void 0 ? void 0 : err.message) || 'Erro ao salvar rateio', originalError: err });
33568
+ _this.error.emit({ operacao: 'save', message: detail, originalError: err });
33536
33569
  });
33537
33570
  };
33538
33571
  ErpRateioEditorComponent.prototype.onSugerir = function () {
@@ -33575,7 +33608,7 @@
33575
33608
  }
33576
33609
  _this.popularComRateios(rateio);
33577
33610
  _this.emitChange();
33578
- }, function (err) { var _a; return _this.error.emit({ operacao: 'suggest', message: ((_a = err === null || err === void 0 ? void 0 : err.error) === null || _a === void 0 ? void 0 : _a.message) || (err === null || err === void 0 ? void 0 : err.message) || 'Erro ao sugerir rateio', originalError: err }); });
33611
+ }, function (err) { var _a; return _this.error.emit({ operacao: 'suggest', message: ((_a = err === null || err === void 0 ? void 0 : err.error) === null || _a === void 0 ? void 0 : _a.message) || (err === null || err === void 0 ? void 0 : err.message) || _this.translate.instant('erpx.rateio_editor.erro_sugerir'), originalError: err }); });
33579
33612
  };
33580
33613
  // === MODAL CONTA FINANCEIRA ===
33581
33614
  ErpRateioEditorComponent.prototype.openContaDialog = function (editIndex) {
@@ -33748,8 +33781,8 @@
33748
33781
  return this.contasDataSource.indexOf(rowData);
33749
33782
  };
33750
33783
  // === PRIVADOS ===
33751
- /** Inicializa o componente em modo standalone (sem chamada à API). */
33752
- ErpRateioEditorComponent.prototype.inicializarStandalone = function () {
33784
+ /** Inicializa o componente a partir dos inputs (sem chamada à API de carga). */
33785
+ ErpRateioEditorComponent.prototype.inicializarPorInputs = function () {
33753
33786
  var _a, _b, _c;
33754
33787
  this.loadedContext = (this.initialContext || {});
33755
33788
  this.popularComRateios(this.initialRateios || []);
@@ -33771,7 +33804,7 @@
33771
33804
  _this.empresaId = output.e070fil.e070emp.id;
33772
33805
  }
33773
33806
  _this.gridColumns = _this.getGridColumns();
33774
- }, function (err) { var _a; return _this.error.emit({ operacao: 'load', message: ((_a = err === null || err === void 0 ? void 0 : err.error) === null || _a === void 0 ? void 0 : _a.message) || (err === null || err === void 0 ? void 0 : err.message) || 'Erro ao carregar rateio', originalError: err }); });
33807
+ }, function (err) { var _a; return _this.error.emit({ operacao: 'load', message: ((_a = err === null || err === void 0 ? void 0 : err.error) === null || _a === void 0 ? void 0 : _a.message) || (err === null || err === void 0 ? void 0 : err.message) || _this.translate.instant('erpx.rateio_editor.erro_carregar'), originalError: err }); });
33775
33808
  };
33776
33809
  ErpRateioEditorComponent.prototype.popularComRateios = function (rateios) {
33777
33810
  this.contasDataSource = __spread(rateios);
@@ -33922,6 +33955,9 @@
33922
33955
  __decorate([
33923
33956
  core.Input()
33924
33957
  ], ErpRateioEditorComponent.prototype, "initialRateios", void 0);
33958
+ __decorate([
33959
+ core.Input()
33960
+ ], ErpRateioEditorComponent.prototype, "loadFromApi", void 0);
33925
33961
  __decorate([
33926
33962
  core.Input()
33927
33963
  ], ErpRateioEditorComponent.prototype, "empresaId", void 0);
@@ -34076,7 +34112,12 @@
34076
34112
  "erpx.rateio_editor.error_soma_valor_invalida": "A soma dos valores deve ser igual ao valor base",
34077
34113
  "erpx.rateio_editor.sem_parametrizacao": "Não há parametrização de rateio cadastrada para este movimento",
34078
34114
  "erpx.rateio_editor.salvo_com_sucesso_titulo": "Rateio salvo",
34079
- "erpx.rateio_editor.salvo_com_sucesso_detalhe": "A distribuição foi gravada com sucesso"
34115
+ "erpx.rateio_editor.salvo_com_sucesso_detalhe": "A distribuição foi gravada com sucesso",
34116
+ "erpx.rateio_editor.erro_titulo": "Erro",
34117
+ "erpx.rateio_editor.erro_salvar": "Erro ao salvar rateio",
34118
+ "erpx.rateio_editor.erro_contexto_incompleto": "Não foi possível salvar: o contexto do rateio (filial e critério) não foi informado.",
34119
+ "erpx.rateio_editor.erro_sugerir": "Erro ao sugerir rateio",
34120
+ "erpx.rateio_editor.erro_carregar": "Erro ao carregar rateio"
34080
34121
  };
34081
34122
 
34082
34123
  exports.BreadcrumbComponent = BreadcrumbComponent;