@senior-agronegocio/angular-components 0.0.9884 → 0.0.9886

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 (51) hide show
  1. package/bundles/senior-agronegocio-angular-components.umd.js +182 -130
  2. package/bundles/senior-agronegocio-angular-components.umd.js.map +1 -1
  3. package/bundles/senior-agronegocio-angular-components.umd.min.js +2 -2
  4. package/bundles/senior-agronegocio-angular-components.umd.min.js.map +1 -1
  5. package/components/event-control-board/common/event-control-constants.d.ts +2 -8
  6. package/components/event-control-board/event-control-board.component.d.ts +3 -0
  7. package/components/event-control-board/service/rural-estate/rural-estate.d.ts +0 -2
  8. package/components/modal-invoice-pj/for-fixation/modal-invoice-pj-for-fixation.component.d.ts +6 -5
  9. package/components/modal-invoice-pj/services/agro-invoice/interfaces.d.ts +2 -1
  10. package/components/modal-invoice-pj/services/producer-invoice-fixation/producer-invoice-dto.d.ts +15 -0
  11. package/components/modal-invoice-pj/services/producer-invoice-fixation/producer-invoice.service.d.ts +18 -0
  12. package/esm2015/components/event-control-board/common/event-control-constants.js +1 -7
  13. package/esm2015/components/event-control-board/event-control-board.component.js +49 -46
  14. package/esm2015/components/event-control-board/service/rural-estate/rural-estate.js +1 -10
  15. package/esm2015/components/modal-invoice-pj/for-fixation/modal-invoice-pj-for-fixation.component.js +44 -26
  16. package/esm2015/components/modal-invoice-pj/for-origination/modal-invoice-pj-for-origination.component.js +2 -2
  17. package/esm2015/components/modal-invoice-pj/for-transfer/modal-invoice-pj-for-transfer.component.js +2 -2
  18. package/esm2015/components/modal-invoice-pj/modal-invoice-pj-base.class.js +10 -5
  19. package/esm2015/components/modal-invoice-pj/services/agro-invoice/interfaces.js +1 -1
  20. package/esm2015/components/modal-invoice-pj/services/producer-invoice-fixation/producer-invoice-dto.js +1 -0
  21. package/esm2015/components/modal-invoice-pj/services/producer-invoice-fixation/producer-invoice.service.js +63 -0
  22. package/esm2015/services/i18n/en-US.js +2 -1
  23. package/esm2015/services/i18n/es-CO.js +2 -1
  24. package/esm2015/services/i18n/pt-BR.js +6 -4
  25. package/esm2015/services/producer-invoice/producer-invoice.service.js +4 -37
  26. package/esm5/components/event-control-board/common/event-control-constants.js +1 -7
  27. package/esm5/components/event-control-board/event-control-board.component.js +50 -47
  28. package/esm5/components/event-control-board/service/rural-estate/rural-estate.js +1 -10
  29. package/esm5/components/modal-invoice-pj/for-fixation/modal-invoice-pj-for-fixation.component.js +53 -29
  30. package/esm5/components/modal-invoice-pj/for-origination/modal-invoice-pj-for-origination.component.js +2 -2
  31. package/esm5/components/modal-invoice-pj/for-transfer/modal-invoice-pj-for-transfer.component.js +2 -2
  32. package/esm5/components/modal-invoice-pj/modal-invoice-pj-base.class.js +16 -5
  33. package/esm5/components/modal-invoice-pj/services/agro-invoice/interfaces.js +1 -1
  34. package/esm5/components/modal-invoice-pj/services/producer-invoice-fixation/producer-invoice-dto.js +1 -0
  35. package/esm5/components/modal-invoice-pj/services/producer-invoice-fixation/producer-invoice.service.js +71 -0
  36. package/esm5/services/i18n/en-US.js +2 -1
  37. package/esm5/services/i18n/es-CO.js +2 -1
  38. package/esm5/services/i18n/pt-BR.js +6 -4
  39. package/esm5/services/producer-invoice/producer-invoice.service.js +4 -42
  40. package/fesm2015/senior-agronegocio-angular-components.js +158 -121
  41. package/fesm2015/senior-agronegocio-angular-components.js.map +1 -1
  42. package/fesm5/senior-agronegocio-angular-components.js +182 -130
  43. package/fesm5/senior-agronegocio-angular-components.js.map +1 -1
  44. package/package.json +1 -1
  45. package/services/i18n/en-US.d.ts +1 -0
  46. package/services/i18n/es-CO.d.ts +1 -0
  47. package/services/i18n/pt-BR.d.ts +1 -0
  48. package/services/producer-invoice/producer-invoice.service.d.ts +1 -4
  49. package/components/event-control-board/common/input-fields.d.ts +0 -5
  50. package/esm2015/components/event-control-board/common/input-fields.js +0 -7
  51. package/esm5/components/event-control-board/common/input-fields.js +0 -7
@@ -574,6 +574,7 @@ var WebsocketModule = /** @class */ (function () {
574
574
  return WebsocketModule;
575
575
  }());
576
576
 
577
+ var INVOICE_CLOSING = "Fechamento de NF";
577
578
  var ptBR = {
578
579
  "agro.angular_components.table_empty_description": "Altere os filtros acima para gerar outros resultados de busca",
579
580
  "agro.angular_components.nothing_found": "Nenhum registro encontrado",
@@ -597,6 +598,7 @@ var ptBR = {
597
598
  "agro.angular_components.change_request_event_summary": "Alteração de \nPesagem",
598
599
  "agro.angular_components.ticket_maintenance_header": "Manutenção de ticket",
599
600
  "agro.angular_components.invoice_creating_event": "Emissão de NF",
601
+ "agro.angular_components.invoice_close_event": INVOICE_CLOSING,
600
602
  "agro.angular_components.balance_entry_control_event": "Entrada/saída balança",
601
603
  "agro.angular_components.event_origin_label": "Origem do evento",
602
604
  "agro.angular_components.event_details_header": "Detalhes do Evento",
@@ -814,11 +816,11 @@ var ptBR = {
814
816
  "agro.angular_components.ORIGINATION_CREATE_INVOICE": "Emissão de NF",
815
817
  "agro.angular_components.ORIGINATION_CREATE_EFFECTIVE_BALANCE": "Emissão de saldo efetivo",
816
818
  "agro.angular_components.PRODUCER_NET_VALUE_EFFECTIVE_BALANCE_CONFIRMATION": "Confirmação de saldo efetivo",
817
- "agro.angular_components.CLOSE_INVOICE_FIXATION": "Fechamento de NF",
818
- "agro.angular_components.INVOICE_CLOSE_INVOICE": "Fechamento de NF",
819
+ "agro.angular_components.CLOSE_INVOICE_FIXATION": INVOICE_CLOSING,
820
+ "agro.angular_components.INVOICE_CLOSE_INVOICE": INVOICE_CLOSING,
819
821
  "agro.angular_components.ORIGINATION_CREATE_EFFECTIVE_CONFIRMATION": "Confirmação efetiva",
820
822
  "agro.angular_components.ORIGINATION_CREATE_PROVISIONAL_BALANCE": "Saldo provisório",
821
- "agro.angular_components.CLOSE_INVOICE_TRANSFER": "Fechamento de NF",
823
+ "agro.angular_components.CLOSE_INVOICE_TRANSFER": INVOICE_CLOSING,
822
824
  "agro.angular_components.REOPEN_INVOICE_TRANSFER": "Reabertura da NF",
823
825
  "agro.angular_components.TRANSFER_CREATE_FINANCIAL_TITLE": "Criação de título financeiro",
824
826
  "agro.angular_components.TRANSFER_CANCEL_FINANCIAL_TITLE": "Cancelamento de título financeiro",
@@ -918,6 +920,7 @@ var enUS = {
918
920
  "agro.angular_components.change_request_event_summary": "Weight Change",
919
921
  "agro.angular_components.ticket_maintenance_header": "Ticket Maintenance",
920
922
  "agro.angular_components.invoice_creating_event": "Invoice Issuance",
923
+ "agro.angular_components.invoice_close_event": "Invoice Closing",
921
924
  "agro.angular_components.balance_entry_control_event": "Balance Entry/Exit",
922
925
  "agro.angular_components.event_origin_label": "Event origin",
923
926
  "agro.angular_components.event_details_header": "Event Details",
@@ -1239,6 +1242,7 @@ var esCO = {
1239
1242
  "agro.angular_components.change_request_event_summary": "Cambio de \nPesaje",
1240
1243
  "agro.angular_components.ticket_maintenance_header": "Mantenimiento de ticket",
1241
1244
  "agro.angular_components.invoice_creating_event": "Emisión de Factura",
1245
+ "agro.angular_components.invoice_close_event": "Cierre de Factura",
1242
1246
  "agro.angular_components.balance_entry_control_event": "Entrada/salida balanza",
1243
1247
  "agro.angular_components.event_origin_label": "Origen del evento",
1244
1248
  "agro.angular_components.event_details_header": "Detalles del Evento",
@@ -5602,43 +5606,6 @@ var ProducerInvoiceService = /** @class */ (function (_super) {
5602
5606
  _this.translate = translate;
5603
5607
  return _this;
5604
5608
  }
5605
- ProducerInvoiceService.prototype.getTotalLinkedInInvoices = function (invoiceId, fixationId) {
5606
- return __awaiter(this, void 0, void 0, function () {
5607
- var filter;
5608
- var _this = this;
5609
- return __generator(this, function (_a) {
5610
- filter = "fixationItem.fixation.id eq '" + fixationId + "' " + ("and invoiceId in ('" + invoiceId.join("','") + "') ");
5611
- return [2 /*return*/, new Promise(function (resolve, reject) {
5612
- _this.list({
5613
- filterQuery: filter,
5614
- size: AGRO_NUMBERS.ONE_HUNDRED,
5615
- }).subscribe({
5616
- next: function (data) {
5617
- var invoiceList = data.contents;
5618
- var producerInvoice = new Map();
5619
- if (invoiceList.length) {
5620
- invoiceList.forEach(function (invoice) {
5621
- var _a;
5622
- producerInvoice.set(invoice.invoiceId, ((_a = producerInvoice.get(invoice.invoiceId)) !== null && _a !== void 0 ? _a : 0) + invoice.linkedValue);
5623
- });
5624
- }
5625
- resolve(Array.from(producerInvoice.entries()).map(function (_a) {
5626
- var _b = __read(_a, 2), key = _b[0], value = _b[1];
5627
- return {
5628
- invoiceId: key,
5629
- totalLinked: value,
5630
- };
5631
- }));
5632
- },
5633
- error: function (err) { return reject(new Error(typeof err === 'string' ? err : JSON.stringify(err))); },
5634
- });
5635
- })];
5636
- });
5637
- });
5638
- };
5639
- ProducerInvoiceService.prototype.deleteAllProducerInvoice = function (fixationId) {
5640
- return this.http.post(this.actionsUrl + "/deleteAllProducerInvoice", { fixationId: fixationId }).pipe(this.defaultCatch());
5641
- };
5642
5609
  ProducerInvoiceService.ctorParameters = function () { return [
5643
5610
  { type: HttpClient },
5644
5611
  { type: MessageService },
@@ -5826,13 +5793,6 @@ var EventOperation;
5826
5793
  EventOperation["ORIGINATION_CREATE_STOCK_MOVEMENT"] = "ORIGINATION_CREATE_STOCK_MOVEMENT";
5827
5794
  })(EventOperation || (EventOperation = {}));
5828
5795
 
5829
- var InputFields;
5830
- (function (InputFields) {
5831
- InputFields["AGRO_INVOICE_TYPE"] = "agroInvoiceType";
5832
- InputFields["INVOICE_TYPE"] = "invoiceType";
5833
- InputFields["INVOICE_NUMBER"] = "number";
5834
- })(InputFields || (InputFields = {}));
5835
-
5836
5796
  var eventItem = [
5837
5797
  { label: "agro.angular_components.ticket_event", value: EventOperation.TICKET },
5838
5798
  { label: "agro.angular_components.provisional_event", value: EventOperation.PROVISIONAL },
@@ -5854,11 +5814,6 @@ var eventItem = [
5854
5814
  label: "agro.angular_components." + EventOperation.INVOICE_CLOSE_INVOICE,
5855
5815
  value: EventOperation.INVOICE_CLOSE_INVOICE,
5856
5816
  },
5857
- {
5858
- label: "agro.angular_components." + EventOperation.INVOICE_CLOSE_INVOICE,
5859
- value: EventOperation.INVOICE_CLOSE_INVOICE,
5860
- subLabelField: InputFields.AGRO_INVOICE_TYPE,
5861
- },
5862
5817
  { label: "agro.angular_components." + EventOperation.REPROCESS_INVOICE, value: EventOperation.REPROCESS_INVOICE },
5863
5818
  { label: "agro.angular_components." + EventOperation.EFFECTIVE_CONFIRMATION, value: EventOperation.EFFECTIVE_CONFIRMATION },
5864
5819
  { label: "agro.angular_components." + EventOperation.CHANGE_REQUEST, value: EventOperation.CHANGE_REQUEST },
@@ -6471,7 +6426,7 @@ var EventControlBoardComponent = /** @class */ (function () {
6471
6426
  if (prescriptionOperations.includes(eventOperation)) {
6472
6427
  formattedSubtitle = this.translate.instant('agro.angular_components.new_prescription_page', { count: subTitle });
6473
6428
  }
6474
- return formattedSubtitle;
6429
+ return formattedSubtitle !== null && formattedSubtitle !== void 0 ? formattedSubtitle : null;
6475
6430
  };
6476
6431
  EventControlBoardComponent.prototype.onGridChange = function (event) {
6477
6432
  var size = event === null || event === void 0 ? void 0 : event.rows;
@@ -6534,57 +6489,60 @@ var EventControlBoardComponent = /** @class */ (function () {
6534
6489
  return producerBalanceEntryControlId ? producerBalanceEntryControlId : null;
6535
6490
  };
6536
6491
  EventControlBoardComponent.prototype.stepSelected = function (event) {
6537
- var _this = this;
6538
6492
  this.selectedStep = event.step;
6539
6493
  this.applySidebarTitle("");
6540
- switch (this.selectedStep.eventType) {
6541
- case EventOrigin.BALANCE_ENTRY_CONTROL:
6542
- case EventOrigin.TICKET:
6543
- case EventOrigin.INVOICE:
6544
- case EventOrigin.CREATE_INVOICE:
6545
- this.sidebarLoading = true;
6546
- {
6547
- var param = JSON.parse(this.selectedStep.item.input);
6548
- var producerInvoiceId = this.getProducerInvoiceIdFromParams(param);
6549
- var filterQuery = "";
6550
- if (!producerInvoiceId) {
6551
- var producerBalanceEntryControlId = this.getProducerBalanceEntryControlIdFromParams(param);
6552
- if (!producerBalanceEntryControlId) {
6553
- this.sidebarLoading = false;
6554
- return;
6555
- }
6556
- filterQuery = "producerBalanceEntryControl.id eq '" + producerBalanceEntryControlId + "'";
6557
- }
6558
- else {
6559
- filterQuery = "id eq '" + producerInvoiceId + "'";
6560
- }
6561
- this.producerInvoiceService
6562
- .list({
6563
- displayFields: ["*", "producerBalanceEntryControl.*", "producerBalanceEntryControl.producer.*"],
6564
- filterQuery: filterQuery,
6565
- page: 0,
6566
- size: 1,
6567
- })
6568
- .pipe(takeUntil(this.ngUnsubscribe))
6569
- .subscribe(function (result) {
6570
- _this.producerInvoice = result === null || result === void 0 ? void 0 : result.contents[0];
6571
- _this.producerInvoice;
6572
- _this.sidebarLoading = false;
6573
- _this.applySidebarTitle(_this.getProducerInvoiceNumberAndSerie());
6574
- }, function () {
6575
- _this.sidebarLoading = false;
6576
- });
6577
- }
6578
- break;
6579
- case EventOrigin.FIXATION:
6580
- case EventOrigin.CANCEL_FIXATION:
6581
- case EventOrigin.CHANGE_REQUEST:
6582
- case EventOrigin.TRANSFER:
6583
- break;
6494
+ if (this.shouldLoadProducerInvoice(this.selectedStep.eventType)) {
6495
+ this.loadSelectedStepProducerInvoice();
6584
6496
  }
6585
6497
  this.showReprocessButton = event.step.state === StepState$1.Warning;
6586
6498
  this.showSidebar = true;
6587
6499
  };
6500
+ EventControlBoardComponent.prototype.shouldLoadProducerInvoice = function (eventType) {
6501
+ return [
6502
+ EventOrigin.BALANCE_ENTRY_CONTROL,
6503
+ EventOrigin.TICKET,
6504
+ EventOrigin.INVOICE,
6505
+ EventOrigin.CREATE_INVOICE,
6506
+ EventOrigin.CLOSE_INVOICE,
6507
+ ].includes(eventType);
6508
+ };
6509
+ EventControlBoardComponent.prototype.loadSelectedStepProducerInvoice = function () {
6510
+ var _this = this;
6511
+ this.sidebarLoading = true;
6512
+ var param = JSON.parse(this.selectedStep.item.input);
6513
+ var filterQuery = this.getProducerInvoiceFilterQuery(param);
6514
+ if (!filterQuery) {
6515
+ this.sidebarLoading = false;
6516
+ return;
6517
+ }
6518
+ this.producerInvoiceService
6519
+ .list({
6520
+ displayFields: ["*", "producerBalanceEntryControl.*", "producerBalanceEntryControl.producer.*"],
6521
+ filterQuery: filterQuery,
6522
+ page: 0,
6523
+ size: 1,
6524
+ })
6525
+ .pipe(takeUntil(this.ngUnsubscribe))
6526
+ .subscribe(function (result) {
6527
+ _this.producerInvoice = result === null || result === void 0 ? void 0 : result.contents[0];
6528
+ _this.producerInvoice;
6529
+ _this.sidebarLoading = false;
6530
+ _this.applySidebarTitle(_this.getProducerInvoiceNumberAndSerie());
6531
+ }, function () {
6532
+ _this.sidebarLoading = false;
6533
+ });
6534
+ };
6535
+ EventControlBoardComponent.prototype.getProducerInvoiceFilterQuery = function (param) {
6536
+ var producerInvoiceId = this.getProducerInvoiceIdFromParams(param);
6537
+ if (producerInvoiceId) {
6538
+ return "id eq '" + producerInvoiceId + "'";
6539
+ }
6540
+ var producerBalanceEntryControlId = this.getProducerBalanceEntryControlIdFromParams(param);
6541
+ if (!producerBalanceEntryControlId) {
6542
+ return null;
6543
+ }
6544
+ return "producerBalanceEntryControl.id eq '" + producerBalanceEntryControlId + "'";
6545
+ };
6588
6546
  EventControlBoardComponent.prototype.applySidebarTitle = function (title) {
6589
6547
  this.sidebarTitle = this.translate.instant("agro.angular_components.event_sidebar_title", { eventNumber: title });
6590
6548
  };
@@ -7604,6 +7562,7 @@ var ModalInvoicePjBase = /** @class */ (function () {
7604
7562
  this.gridLoading = true;
7605
7563
  this.dontHaveAnyInvoice = false;
7606
7564
  this.updateCurrentParams(event);
7565
+ var numberSearchValue = searchValue ? AgroNumberUtils.getNearInteger(searchValue) : null;
7607
7566
  var filterBody = {
7608
7567
  filter: {
7609
7568
  companyId: companyId,
@@ -7612,6 +7571,7 @@ var ModalInvoicePjBase = /** @class */ (function () {
7612
7571
  ruralEstateIds: [ruralEstateId],
7613
7572
  multiProducts: false,
7614
7573
  productId: this.options.productId,
7574
+ number: numberSearchValue,
7615
7575
  },
7616
7576
  pageRequest: {
7617
7577
  offset: this.currentParams.page,
@@ -7623,16 +7583,25 @@ var ModalInvoicePjBase = /** @class */ (function () {
7623
7583
  },
7624
7584
  };
7625
7585
  if (searchValue) {
7626
- searchValue = AgroNumberUtils.getNearInteger(searchValue).toString();
7586
+ searchValue = numberSearchValue.toString();
7627
7587
  }
7628
7588
  this.invoiceService
7629
7589
  .invoiceLookupFilter(filterBody)
7630
- .pipe(takeUntil(this.ngUnsubscribe), finalize(function () {
7590
+ .pipe(takeUntil(this.ngUnsubscribe), switchMap(function (result) { return __awaiter(_this, void 0, void 0, function () {
7591
+ return __generator(this, function (_a) {
7592
+ switch (_a.label) {
7593
+ case 0: return [4 /*yield*/, this.adaptResult(result)];
7594
+ case 1:
7595
+ _a.sent();
7596
+ return [2 /*return*/, result];
7597
+ }
7598
+ });
7599
+ }); }), finalize(function () {
7631
7600
  _this.gridLoading = false;
7632
7601
  }))
7633
7602
  .subscribe(function (result) {
7634
7603
  var _a;
7635
- _this.gridData = ((_a = result === null || result === void 0 ? void 0 : result.result) === null || _a === void 0 ? void 0 : _a.invoices) || [];
7604
+ _this.gridData = (((_a = result === null || result === void 0 ? void 0 : result.result) === null || _a === void 0 ? void 0 : _a.invoices) || []).map(function (invoice) { return (__assign(__assign({}, invoice), { _uniqueId: invoice.externalInvoiceId || invoice.invoiceId })); });
7636
7605
  if (_this.gridData.length === 0 && !searchValue) {
7637
7606
  _this.dontHaveAnyInvoice = true;
7638
7607
  }
@@ -7772,7 +7741,7 @@ var ModalInvoicePjForOriginationComponent = /** @class */ (function (_super) {
7772
7741
  ModalInvoicePjForOriginationComponent = __decorate([
7773
7742
  Component({
7774
7743
  selector: 's-modal-invoice-pj-for-origination',
7775
- template: "<p-dialog\r\n header=\"{{ 'agro.angular_components.panel_title_external_invoice_add_external_invoice' | libTranslate }}\"\r\n [(visible)]=\"visible\"\r\n [modal]=\"true\"\r\n class=\"add-invoice-modal\"\r\n [closeOnEscape]=\"false\"\r\n (onHide)=\"cancelPooling()\"\r\n [dismissableMask]=\"false\"\r\n>\r\n <ng-container *ngIf=\"!dontHaveAnyInvoice\">\r\n <div class=\"ui-g\">\r\n <label for=\"invoiceSearchInput\">{{ 'agro.angular_components.number' | libTranslate }}</label>\r\n <input\r\n type=\"text\"\r\n id=\"invoiceSearchInput\"\r\n pInputText\r\n [formControl]=\"searchValue\"\r\n [placeholder]=\"'' | libTranslate\"\r\n [required]=\"false\"\r\n />\r\n <div class=\"ui-g-12\">\r\n <p-table\r\n [(selection)]=\"selected\"\r\n [value]=\"gridData\"\r\n [columns]=\"gridColumns\"\r\n [scrollable]=\"true\"\r\n dataKey=\"externalInvoiceId\"\r\n [rows]=\"10\"\r\n [paginator]=\"true\"\r\n [lazyLoadOnInit]=\"false\"\r\n [totalRecords]=\"gridTotalRecords\"\r\n [lazy]=\"true\"\r\n (onLazyLoad)=\"updateGridData($event)\"\r\n [resizableColumns]=\"true\"\r\n *sLoadingState=\"gridLoading\"\r\n sortMode=\"multiple\"\r\n [selectionMode]=\"'multiple'\"\r\n >\r\n <ng-template pTemplate=\"header\" let-columns>\r\n <tr>\r\n <th class=\"checkbox\" scope=\"col\">\r\n <p-tableHeaderCheckbox></p-tableHeaderCheckbox>\r\n </th>\r\n <ng-container *ngFor=\"let col of columns\">\r\n <th\r\n *ngIf=\"col.sortable === undefined || col.sortable\"\r\n [pSortableColumn]=\"col.field\"\r\n scope=\"col\"\r\n >\r\n {{ col.header }}\r\n <p-sortIcon [field]=\"col.field\"></p-sortIcon>\r\n </th>\r\n <th *ngIf=\"col.sortable === false || col.sortable === null\" scope=\"col\">\r\n {{ col.header }}\r\n </th>\r\n </ng-container>\r\n </tr>\r\n </ng-template>\r\n\r\n <ng-template pTemplate=\"body\" let-rowData let-columns=\"columns\" let-rowIndex=\"rowIndex\">\r\n <tr>\r\n <td class=\"checkbox\" tabindex=\"0\">\r\n <p-tableCheckbox [value]=\"rowData\"></p-tableCheckbox>\r\n </td>\r\n <td\r\n [pSelectableRow]=\"rowData\"\r\n [pSelectableRowIndex]=\"rowIndex\"\r\n *ngFor=\"let col of columns\"\r\n class=\"column\"\r\n tabindex=\"0\"\r\n >\r\n <ng-container>\r\n {{ gridFieldValuesMap[col.field] ? gridFieldValuesMap[col.field](rowData) :\r\n rowData[col.field] }}\r\n </ng-container>\r\n </td>\r\n </tr>\r\n </ng-template>\r\n\r\n <ng-template pTemplate=\"paginatorright\">\r\n <span>{{ gridTotalRecords }} registros encontrados</span>\r\n </ng-template>\r\n </p-table>\r\n </div>\r\n </div>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"dontHaveAnyInvoice\">\r\n <s-empty-state\r\n iconClass=\"fa fa-exclamation-triangle\"\r\n title=\"{{ 'agro.angular_components.add_pj_invoice_modal_no_invoices_found' | libTranslate }}\"\r\n primaryActionLabel=\"{{ 'agro.angular_components.error_server_try_again' | libTranslate }}\"\r\n (primaryAction)=\"tryToSearchAgain()\"\r\n description=\"{{ 'agro.angular_components.no_register_found_for_external_invoices_summary' | libTranslate }}\"\r\n >\r\n </s-empty-state>\r\n </ng-container>\r\n\r\n <p-footer class=\"footer\" *ngIf=\"!dontHaveAnyInvoice\">\r\n <s-button\r\n [priority]=\"buttonPriority.Primary\"\r\n label=\"{{ 'agro.angular_components.panel_title_external_invoice_add_external_invoice' | libTranslate }}\"\r\n [disabled]=\"!selected?.length\"\r\n (click)=\"add()\"\r\n (keydown.enter)=\"add()\"\r\n ></s-button>\r\n <s-button\r\n [priority]=\"buttonPriority.Link\"\r\n label=\"{{ 'agro.angular_components.cancel' | libTranslate }}\"\r\n (click)=\"cancel()\"\r\n (keydown.enter)=\"cancel()\"\r\n ></s-button>\r\n </p-footer>\r\n</p-dialog>\r\n",
7744
+ template: "<p-dialog\r\n header=\"{{ 'agro.angular_components.panel_title_external_invoice_add_external_invoice' | libTranslate }}\"\r\n [(visible)]=\"visible\"\r\n [modal]=\"true\"\r\n class=\"add-invoice-modal\"\r\n [closeOnEscape]=\"false\"\r\n (onHide)=\"cancelPooling()\"\r\n [dismissableMask]=\"false\"\r\n>\r\n <ng-container *ngIf=\"!dontHaveAnyInvoice\">\r\n <div class=\"ui-g\">\r\n <label for=\"invoiceSearchInput\">{{ 'agro.angular_components.number' | libTranslate }}</label>\r\n <input\r\n type=\"text\"\r\n id=\"invoiceSearchInput\"\r\n pInputText\r\n [formControl]=\"searchValue\"\r\n [placeholder]=\"'' | libTranslate\"\r\n [required]=\"false\"\r\n />\r\n <div class=\"ui-g-12\">\r\n <p-table\r\n [(selection)]=\"selected\"\r\n [value]=\"gridData\"\r\n [columns]=\"gridColumns\"\r\n [scrollable]=\"true\"\r\n dataKey=\"_uniqueId\"\r\n [rows]=\"10\"\r\n [paginator]=\"true\"\r\n [lazyLoadOnInit]=\"false\"\r\n [totalRecords]=\"gridTotalRecords\"\r\n [lazy]=\"true\"\r\n (onLazyLoad)=\"updateGridData($event)\"\r\n [resizableColumns]=\"true\"\r\n *sLoadingState=\"gridLoading\"\r\n sortMode=\"multiple\"\r\n [selectionMode]=\"'multiple'\"\r\n >\r\n <ng-template pTemplate=\"header\" let-columns>\r\n <tr>\r\n <th class=\"checkbox\" scope=\"col\">\r\n <p-tableHeaderCheckbox></p-tableHeaderCheckbox>\r\n </th>\r\n <ng-container *ngFor=\"let col of columns\">\r\n <th\r\n *ngIf=\"col.sortable === undefined || col.sortable\"\r\n [pSortableColumn]=\"col.field\"\r\n scope=\"col\"\r\n >\r\n {{ col.header }}\r\n <p-sortIcon [field]=\"col.field\"></p-sortIcon>\r\n </th>\r\n <th *ngIf=\"col.sortable === false || col.sortable === null\" scope=\"col\">\r\n {{ col.header }}\r\n </th>\r\n </ng-container>\r\n </tr>\r\n </ng-template>\r\n\r\n <ng-template pTemplate=\"body\" let-rowData let-columns=\"columns\" let-rowIndex=\"rowIndex\">\r\n <tr>\r\n <td class=\"checkbox\" tabindex=\"0\">\r\n <p-tableCheckbox [value]=\"rowData\"></p-tableCheckbox>\r\n </td>\r\n <td\r\n [pSelectableRow]=\"rowData\"\r\n [pSelectableRowIndex]=\"rowIndex\"\r\n *ngFor=\"let col of columns\"\r\n class=\"column\"\r\n tabindex=\"0\"\r\n >\r\n <ng-container>\r\n {{ gridFieldValuesMap[col.field] ? gridFieldValuesMap[col.field](rowData) :\r\n rowData[col.field] }}\r\n </ng-container>\r\n </td>\r\n </tr>\r\n </ng-template>\r\n\r\n <ng-template pTemplate=\"paginatorright\">\r\n <span>{{ gridTotalRecords }} registros encontrados</span>\r\n </ng-template>\r\n </p-table>\r\n </div>\r\n </div>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"dontHaveAnyInvoice\">\r\n <s-empty-state\r\n iconClass=\"fa fa-exclamation-triangle\"\r\n title=\"{{ 'agro.angular_components.add_pj_invoice_modal_no_invoices_found' | libTranslate }}\"\r\n primaryActionLabel=\"{{ 'agro.angular_components.error_server_try_again' | libTranslate }}\"\r\n (primaryAction)=\"tryToSearchAgain()\"\r\n description=\"{{ 'agro.angular_components.no_register_found_for_external_invoices_summary' | libTranslate }}\"\r\n >\r\n </s-empty-state>\r\n </ng-container>\r\n\r\n <p-footer class=\"footer\" *ngIf=\"!dontHaveAnyInvoice\">\r\n <s-button\r\n [priority]=\"buttonPriority.Primary\"\r\n label=\"{{ 'agro.angular_components.panel_title_external_invoice_add_external_invoice' | libTranslate }}\"\r\n [disabled]=\"!selected?.length\"\r\n (click)=\"add()\"\r\n (keydown.enter)=\"add()\"\r\n ></s-button>\r\n <s-button\r\n [priority]=\"buttonPriority.Link\"\r\n label=\"{{ 'agro.angular_components.cancel' | libTranslate }}\"\r\n (click)=\"cancel()\"\r\n (keydown.enter)=\"cancel()\"\r\n ></s-button>\r\n </p-footer>\r\n</p-dialog>\r\n",
7776
7745
  styles: [".footer{width:100%;display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center}.add-invoice-modal{width:480px;max-width:480px}.add-invoice-modal input[type=text]{width:100%}.add-invoice-modal .ui-dialog{width:480px!important}.add-invoice-modal .ui-dialog .ui-dialog-content{min-height:175px}td.checkbox,th.checkbox{width:50px}td.column,th.column{min-width:150px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}"]
7777
7746
  })
7778
7747
  ], ModalInvoicePjForOriginationComponent);
@@ -7839,7 +7808,7 @@ var ModalInvoicePjForTransferComponent = /** @class */ (function (_super) {
7839
7808
  ModalInvoicePjForTransferComponent = __decorate([
7840
7809
  Component({
7841
7810
  selector: 's-modal-invoice-pj-for-transfer',
7842
- template: "<p-dialog\r\n header=\"{{ 'agro.angular_components.panel_title_external_invoice_add_external_invoice' | libTranslate }}\"\r\n [(visible)]=\"visible\"\r\n [modal]=\"true\"\r\n class=\"add-invoice-modal\"\r\n [closeOnEscape]=\"false\"\r\n (onHide)=\"cancelPooling()\"\r\n [dismissableMask]=\"false\"\r\n>\r\n <ng-container *ngIf=\"!dontHaveAnyInvoice\">\r\n <div class=\"ui-g\">\r\n <label for=\"invoiceSearchInput\">{{ 'agro.angular_components.number' | libTranslate }}</label>\r\n <input\r\n type=\"text\"\r\n id=\"invoiceSearchInput\"\r\n pInputText\r\n [formControl]=\"searchValue\"\r\n [placeholder]=\"'' | libTranslate\"\r\n [required]=\"false\"\r\n />\r\n <div class=\"ui-g-12\">\r\n <p-table\r\n [(selection)]=\"selected\"\r\n [value]=\"gridData\"\r\n [columns]=\"gridColumns\"\r\n [scrollable]=\"true\"\r\n dataKey=\"externalInvoiceId\"\r\n [rows]=\"10\"\r\n [paginator]=\"true\"\r\n [lazyLoadOnInit]=\"false\"\r\n [totalRecords]=\"gridTotalRecords\"\r\n [lazy]=\"true\"\r\n (onLazyLoad)=\"updateGridData($event)\"\r\n [resizableColumns]=\"true\"\r\n *sLoadingState=\"gridLoading\"\r\n sortMode=\"multiple\"\r\n [selectionMode]=\"'multiple'\"\r\n >\r\n <ng-template pTemplate=\"header\" let-columns>\r\n <tr>\r\n <th class=\"checkbox\" scope=\"col\">\r\n <p-tableHeaderCheckbox></p-tableHeaderCheckbox>\r\n </th>\r\n <ng-container *ngFor=\"let col of columns\">\r\n <th\r\n *ngIf=\"col.sortable === undefined || col.sortable\"\r\n [pSortableColumn]=\"col.field\"\r\n scope=\"col\"\r\n >\r\n {{ col.header }}\r\n <p-sortIcon [field]=\"col.field\"></p-sortIcon>\r\n </th>\r\n <th *ngIf=\"col.sortable === false || col.sortable === null\" scope=\"col\">\r\n {{ col.header }}\r\n </th>\r\n </ng-container>\r\n </tr>\r\n </ng-template>\r\n\r\n <ng-template pTemplate=\"body\" let-rowData let-columns=\"columns\" let-rowIndex=\"rowIndex\">\r\n <tr>\r\n <td class=\"checkbox\" tabindex=\"0\">\r\n <p-tableCheckbox [value]=\"rowData\"></p-tableCheckbox>\r\n </td>\r\n <td\r\n [pSelectableRow]=\"rowData\"\r\n [pSelectableRowIndex]=\"rowIndex\"\r\n *ngFor=\"let col of columns\"\r\n class=\"column\"\r\n tabindex=\"0\"\r\n >\r\n <ng-container>\r\n {{ gridFieldValuesMap[col.field] ? gridFieldValuesMap[col.field](rowData) :\r\n rowData[col.field] }}\r\n </ng-container>\r\n </td>\r\n </tr>\r\n </ng-template>\r\n\r\n <ng-template pTemplate=\"paginatorright\">\r\n <span>{{ gridTotalRecords }} registros encontrados</span>\r\n </ng-template>\r\n </p-table>\r\n </div>\r\n </div>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"dontHaveAnyInvoice\">\r\n <s-empty-state\r\n iconClass=\"fa fa-exclamation-triangle\"\r\n title=\"{{ 'agro.angular_components.add_pj_invoice_modal_no_invoices_found' | libTranslate }}\"\r\n primaryActionLabel=\"{{ 'agro.angular_components.error_server_try_again' | libTranslate }}\"\r\n (primaryAction)=\"tryToSearchAgain()\"\r\n description=\"{{ 'agro.angular_components.no_register_found_for_external_invoices_summary' | libTranslate }}\"\r\n >\r\n </s-empty-state>\r\n </ng-container>\r\n\r\n <p-footer class=\"footer\" *ngIf=\"!dontHaveAnyInvoice\">\r\n <s-button\r\n [priority]=\"buttonPriority.Primary\"\r\n label=\"{{ 'agro.angular_components.panel_title_external_invoice_add_external_invoice' | libTranslate }}\"\r\n [disabled]=\"!selected?.length\"\r\n (click)=\"add()\"\r\n (keydown.enter)=\"add()\"\r\n ></s-button>\r\n <s-button\r\n [priority]=\"buttonPriority.Link\"\r\n label=\"{{ 'agro.angular_components.cancel' | libTranslate }}\"\r\n (click)=\"cancel()\"\r\n (keydown.enter)=\"cancel()\"\r\n ></s-button>\r\n </p-footer>\r\n</p-dialog>\r\n",
7811
+ template: "<p-dialog\r\n header=\"{{ 'agro.angular_components.panel_title_external_invoice_add_external_invoice' | libTranslate }}\"\r\n [(visible)]=\"visible\"\r\n [modal]=\"true\"\r\n class=\"add-invoice-modal\"\r\n [closeOnEscape]=\"false\"\r\n (onHide)=\"cancelPooling()\"\r\n [dismissableMask]=\"false\"\r\n>\r\n <ng-container *ngIf=\"!dontHaveAnyInvoice\">\r\n <div class=\"ui-g\">\r\n <label for=\"invoiceSearchInput\">{{ 'agro.angular_components.number' | libTranslate }}</label>\r\n <input\r\n type=\"text\"\r\n id=\"invoiceSearchInput\"\r\n pInputText\r\n [formControl]=\"searchValue\"\r\n [placeholder]=\"'' | libTranslate\"\r\n [required]=\"false\"\r\n />\r\n <div class=\"ui-g-12\">\r\n <p-table\r\n [(selection)]=\"selected\"\r\n [value]=\"gridData\"\r\n [columns]=\"gridColumns\"\r\n [scrollable]=\"true\"\r\n dataKey=\"_uniqueId\"\r\n [rows]=\"10\"\r\n [paginator]=\"true\"\r\n [lazyLoadOnInit]=\"false\"\r\n [totalRecords]=\"gridTotalRecords\"\r\n [lazy]=\"true\"\r\n (onLazyLoad)=\"updateGridData($event)\"\r\n [resizableColumns]=\"true\"\r\n *sLoadingState=\"gridLoading\"\r\n sortMode=\"multiple\"\r\n [selectionMode]=\"'multiple'\"\r\n >\r\n <ng-template pTemplate=\"header\" let-columns>\r\n <tr>\r\n <th class=\"checkbox\" scope=\"col\">\r\n <p-tableHeaderCheckbox></p-tableHeaderCheckbox>\r\n </th>\r\n <ng-container *ngFor=\"let col of columns\">\r\n <th\r\n *ngIf=\"col.sortable === undefined || col.sortable\"\r\n [pSortableColumn]=\"col.field\"\r\n scope=\"col\"\r\n >\r\n {{ col.header }}\r\n <p-sortIcon [field]=\"col.field\"></p-sortIcon>\r\n </th>\r\n <th *ngIf=\"col.sortable === false || col.sortable === null\" scope=\"col\">\r\n {{ col.header }}\r\n </th>\r\n </ng-container>\r\n </tr>\r\n </ng-template>\r\n\r\n <ng-template pTemplate=\"body\" let-rowData let-columns=\"columns\" let-rowIndex=\"rowIndex\">\r\n <tr>\r\n <td class=\"checkbox\" tabindex=\"0\">\r\n <p-tableCheckbox [value]=\"rowData\"></p-tableCheckbox>\r\n </td>\r\n <td\r\n [pSelectableRow]=\"rowData\"\r\n [pSelectableRowIndex]=\"rowIndex\"\r\n *ngFor=\"let col of columns\"\r\n class=\"column\"\r\n tabindex=\"0\"\r\n >\r\n <ng-container>\r\n {{ gridFieldValuesMap[col.field] ? gridFieldValuesMap[col.field](rowData) :\r\n rowData[col.field] }}\r\n </ng-container>\r\n </td>\r\n </tr>\r\n </ng-template>\r\n\r\n <ng-template pTemplate=\"paginatorright\">\r\n <span>{{ gridTotalRecords }} registros encontrados</span>\r\n </ng-template>\r\n </p-table>\r\n </div>\r\n </div>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"dontHaveAnyInvoice\">\r\n <s-empty-state\r\n iconClass=\"fa fa-exclamation-triangle\"\r\n title=\"{{ 'agro.angular_components.add_pj_invoice_modal_no_invoices_found' | libTranslate }}\"\r\n primaryActionLabel=\"{{ 'agro.angular_components.error_server_try_again' | libTranslate }}\"\r\n (primaryAction)=\"tryToSearchAgain()\"\r\n description=\"{{ 'agro.angular_components.no_register_found_for_external_invoices_summary' | libTranslate }}\"\r\n >\r\n </s-empty-state>\r\n </ng-container>\r\n\r\n <p-footer class=\"footer\" *ngIf=\"!dontHaveAnyInvoice\">\r\n <s-button\r\n [priority]=\"buttonPriority.Primary\"\r\n label=\"{{ 'agro.angular_components.panel_title_external_invoice_add_external_invoice' | libTranslate }}\"\r\n [disabled]=\"!selected?.length\"\r\n (click)=\"add()\"\r\n (keydown.enter)=\"add()\"\r\n ></s-button>\r\n <s-button\r\n [priority]=\"buttonPriority.Link\"\r\n label=\"{{ 'agro.angular_components.cancel' | libTranslate }}\"\r\n (click)=\"cancel()\"\r\n (keydown.enter)=\"cancel()\"\r\n ></s-button>\r\n </p-footer>\r\n</p-dialog>\r\n",
7843
7812
  styles: [".footer{width:100%;display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center}.add-invoice-modal{width:480px;max-width:480px}.add-invoice-modal input[type=text]{width:100%}.add-invoice-modal .ui-dialog{width:480px!important}.add-invoice-modal .ui-dialog .ui-dialog-content{min-height:175px}td.checkbox,th.checkbox{width:50px}td.column,th.column{min-width:150px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}"]
7844
7813
  })
7845
7814
  ], ModalInvoicePjForTransferComponent);
@@ -7860,6 +7829,66 @@ var ModalInvoicePjForTransferModule = /** @class */ (function () {
7860
7829
  return ModalInvoicePjForTransferModule;
7861
7830
  }());
7862
7831
 
7832
+ var ProducerInvoiceService$1 = /** @class */ (function (_super) {
7833
+ __extends(ProducerInvoiceService, _super);
7834
+ function ProducerInvoiceService(http, messageService, translate) {
7835
+ var _this = _super.call(this, http, messageService, "agro/fixation/entities/producerInvoice", "agro/fixation/actions", "agro/fixation/queries", translate) || this;
7836
+ _this.http = http;
7837
+ _this.messageService = messageService;
7838
+ _this.translate = translate;
7839
+ return _this;
7840
+ }
7841
+ ProducerInvoiceService.prototype.getTotalLinkedInInvoices = function (invoiceId, fixationId) {
7842
+ return __awaiter(this, void 0, void 0, function () {
7843
+ var filter;
7844
+ var _this = this;
7845
+ return __generator(this, function (_a) {
7846
+ filter = "fixationItem.fixation.id eq '" + fixationId + "' " + ("and externalInvoiceId in ('" + invoiceId.join("','") + "') ");
7847
+ return [2 /*return*/, new Promise(function (resolve, reject) {
7848
+ _this.list({
7849
+ filterQuery: filter,
7850
+ size: 100
7851
+ }).subscribe({
7852
+ next: function (data) {
7853
+ var invoiceList = data.contents;
7854
+ var producerInvoice = new Map();
7855
+ if (invoiceList.length) {
7856
+ invoiceList.forEach(function (invoice) {
7857
+ var _a;
7858
+ producerInvoice.set(invoice.invoiceId, ((_a = producerInvoice.get(invoice.invoiceId)) !== null && _a !== void 0 ? _a : 0) + invoice.linkedValue);
7859
+ });
7860
+ }
7861
+ resolve(Array.from(producerInvoice.entries()).map(function (_a) {
7862
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
7863
+ return {
7864
+ invoiceId: key,
7865
+ totalLinked: value
7866
+ };
7867
+ }));
7868
+ },
7869
+ error: function (err) { return reject(err instanceof Error ? err : new Error(String(err))); }
7870
+ });
7871
+ })];
7872
+ });
7873
+ });
7874
+ };
7875
+ ProducerInvoiceService.prototype.deleteAllProducerInvoice = function (fixationId) {
7876
+ return this.http.post(this.actionsUrl + "/deleteAllProducerInvoice", { fixationId: fixationId }).pipe(this.defaultCatch());
7877
+ };
7878
+ ProducerInvoiceService.ctorParameters = function () { return [
7879
+ { type: HttpClient },
7880
+ { type: MessageService },
7881
+ { type: LibTranslationService }
7882
+ ]; };
7883
+ ProducerInvoiceService.ɵprov = ɵɵdefineInjectable({ factory: function ProducerInvoiceService_Factory() { return new ProducerInvoiceService(ɵɵinject(HttpClient), ɵɵinject(MessageService), ɵɵinject(LibTranslationService)); }, token: ProducerInvoiceService, providedIn: "root" });
7884
+ ProducerInvoiceService = __decorate([
7885
+ Injectable({
7886
+ providedIn: 'root'
7887
+ })
7888
+ ], ProducerInvoiceService);
7889
+ return ProducerInvoiceService;
7890
+ }(AgroEntityService));
7891
+
7863
7892
  var ModalInvoicePjForFixationComponent = /** @class */ (function (_super) {
7864
7893
  __extends(ModalInvoicePjForFixationComponent, _super);
7865
7894
  function ModalInvoicePjForFixationComponent(translationService, invoiceService, localeService, kilogramPipe, currencyPipe, producerInvoiceService, messageService, datePipe) {
@@ -7873,12 +7902,17 @@ var ModalInvoicePjForFixationComponent = /** @class */ (function (_super) {
7873
7902
  _this.messageService = messageService;
7874
7903
  _this.datePipe = datePipe;
7875
7904
  _this.whenSelectInvoices = new EventEmitter();
7905
+ registerLocaleData(localePt);
7876
7906
  return _this;
7877
7907
  }
7878
7908
  ModalInvoicePjForFixationComponent.prototype.ngOnInit = function () {
7879
7909
  var _this = this;
7880
7910
  this.defineGridColumns();
7881
- this.gridFieldValuesMap = __assign(__assign({}, this.gridFieldValuesMap), { series: function (row) { return (row === null || row === void 0 ? void 0 : row.seriesLegal) || (row === null || row === void 0 ? void 0 : row.series) || row.series; }, totalValue: function (row) { return _this.currencyPipe.transform((row === null || row === void 0 ? void 0 : row.netTotalValue) || 0, 'BRL'); } });
7911
+ this.gridFieldValuesMap = __assign(__assign({}, this.gridFieldValuesMap), { series: function (row) { return (row === null || row === void 0 ? void 0 : row.seriesLegal) || (row === null || row === void 0 ? void 0 : row.series) || row.series; }, totalValue: function (row) {
7912
+ return _this.currencyPipe.transform(_this.getTotalValue(row) || 0, 'BRL', 'symbol', undefined, 'pt-BR');
7913
+ }, linkedValue: function (row) {
7914
+ return _this.currencyPipe.transform((row === null || row === void 0 ? void 0 : row.linkedValue) || 0, 'BRL', 'symbol', undefined, 'pt-BR');
7915
+ } });
7882
7916
  _super.prototype.ngOnInit.call(this);
7883
7917
  };
7884
7918
  ModalInvoicePjForFixationComponent.prototype.defineGridColumns = function () {
@@ -7900,7 +7934,7 @@ var ModalInvoicePjForFixationComponent = /** @class */ (function (_super) {
7900
7934
  };
7901
7935
  ModalInvoicePjForFixationComponent.prototype.beforeAdd = function (selectedInvoices) {
7902
7936
  if (selectedInvoices === null || selectedInvoices === void 0 ? void 0 : selectedInvoices.length) {
7903
- this.linkSelectedInvoicesInFixationItem();
7937
+ this.linkSelectedInvoicesInFixationItem(selectedInvoices);
7904
7938
  }
7905
7939
  return of(EMPTY).toPromise();
7906
7940
  };
@@ -7915,20 +7949,20 @@ var ModalInvoicePjForFixationComponent = /** @class */ (function (_super) {
7915
7949
  }
7916
7950
  _super.prototype.open.call(this);
7917
7951
  };
7918
- ModalInvoicePjForFixationComponent.prototype.linkSelectedInvoicesInFixationItem = function () {
7952
+ ModalInvoicePjForFixationComponent.prototype.linkSelectedInvoicesInFixationItem = function (selectedInvoices) {
7919
7953
  return __awaiter(this, void 0, void 0, function () {
7920
7954
  var entities;
7921
7955
  var _this = this;
7922
7956
  return __generator(this, function (_a) {
7923
7957
  switch (_a.label) {
7924
- case 0: return [4 /*yield*/, this.isValidAndSetLinkedValueInInvoices()];
7958
+ case 0: return [4 /*yield*/, this.isValidAndSetLinkedValueInInvoices(selectedInvoices)];
7925
7959
  case 1:
7926
7960
  if (!(_a.sent())) {
7927
7961
  this.gridLoading = false;
7928
7962
  return [2 /*return*/];
7929
7963
  }
7930
7964
  entities = []
7931
- .concat.apply([], __spread(this.selected.map(function (invoice) {
7965
+ .concat.apply([], __spread(selectedInvoices.map(function (invoice) {
7932
7966
  return _this.options.fixationItems.map(function (fixationItem) {
7933
7967
  var requiredValue = (fixationItem.requiredValue || 0) - (fixationItem.totalValueInvoices || 0);
7934
7968
  if (invoice.remainingValue <= 0 || requiredValue <= 0) {
@@ -7939,11 +7973,11 @@ var ModalInvoicePjForFixationComponent = /** @class */ (function (_super) {
7939
7973
  var body = {
7940
7974
  series: invoice === null || invoice === void 0 ? void 0 : invoice.series,
7941
7975
  number: String(invoice === null || invoice === void 0 ? void 0 : invoice.number),
7942
- invoiceId: invoice === null || invoice === void 0 ? void 0 : invoice.id,
7976
+ externalInvoiceId: invoice === null || invoice === void 0 ? void 0 : invoice.externalInvoiceId,
7943
7977
  linkedValue: valueToBeLinked,
7944
- totalValue: invoice === null || invoice === void 0 ? void 0 : invoice.totalValue,
7978
+ totalValue: _this.getTotalValue(invoice),
7945
7979
  issuanceDate: invoice === null || invoice === void 0 ? void 0 : invoice.issuanceDate,
7946
- fixationItem: fixationItem,
7980
+ fixationItem: { id: fixationItem === null || fixationItem === void 0 ? void 0 : fixationItem.id },
7947
7981
  };
7948
7982
  fixationItem.totalValueInvoices = (fixationItem.totalValueInvoices || 0) + valueToBeLinked;
7949
7983
  return body;
@@ -7969,19 +8003,25 @@ var ModalInvoicePjForFixationComponent = /** @class */ (function (_super) {
7969
8003
  });
7970
8004
  });
7971
8005
  };
7972
- ModalInvoicePjForFixationComponent.prototype.isValidAndSetLinkedValueInInvoices = function () {
8006
+ ModalInvoicePjForFixationComponent.prototype.isValidAndSetLinkedValueInInvoices = function (selectedInvoices) {
7973
8007
  return __awaiter(this, void 0, void 0, function () {
7974
8008
  var valorLinked, isValid;
7975
8009
  var _this = this;
7976
8010
  return __generator(this, function (_a) {
7977
8011
  switch (_a.label) {
7978
- case 0: return [4 /*yield*/, this.producerInvoiceService.getTotalLinkedInInvoices(this.selected.map(function (invoice) { return invoice.id; }), this.options.fixationId)];
8012
+ case 0: return [4 /*yield*/, this.producerInvoiceService.getTotalLinkedInInvoices(selectedInvoices.map(function (invoice) { return invoice.externalInvoiceId; }), this.options.fixationId)];
7979
8013
  case 1:
7980
8014
  valorLinked = _a.sent();
8015
+ selectedInvoices.forEach(function (invoice) {
8016
+ if (!invoice.totalValue) {
8017
+ invoice.totalValue = _this.getTotalValue(invoice);
8018
+ }
8019
+ });
7981
8020
  isValid = true;
7982
- this.selected.forEach(function (invoice) {
8021
+ selectedInvoices.forEach(function (invoice) {
7983
8022
  var _a;
7984
- invoice.linkedValue = ((_a = valorLinked.find(function (linked) { return linked.invoiceId === invoice.id; })) === null || _a === void 0 ? void 0 : _a.totalLinked) || 0;
8023
+ invoice.linkedValue =
8024
+ ((_a = valorLinked.find(function (linked) { return linked.externalInvoiceId === invoice.externalInvoiceId; })) === null || _a === void 0 ? void 0 : _a.totalLinked) || 0;
7985
8025
  if (invoice.linkedValue >= invoice.totalValue) {
7986
8026
  _this.messageService.add({
7987
8027
  severity: 'warn',
@@ -7998,9 +8038,13 @@ var ModalInvoicePjForFixationComponent = /** @class */ (function (_super) {
7998
8038
  });
7999
8039
  };
8000
8040
  ModalInvoicePjForFixationComponent.prototype.adaptResult = function (result) {
8041
+ var _a;
8001
8042
  return __awaiter(this, void 0, void 0, function () {
8002
- return __generator(this, function (_a) {
8003
- return [2 /*return*/, Promise.resolve(result)];
8043
+ return __generator(this, function (_b) {
8044
+ switch (_b.label) {
8045
+ case 0: return [4 /*yield*/, this.updateLinkedValueInGrid(((_a = result === null || result === void 0 ? void 0 : result.result) === null || _a === void 0 ? void 0 : _a.invoices) || [])];
8046
+ case 1: return [2 /*return*/, _b.sent()];
8047
+ }
8004
8048
  });
8005
8049
  });
8006
8050
  };
@@ -8008,21 +8052,20 @@ var ModalInvoicePjForFixationComponent = /** @class */ (function (_super) {
8008
8052
  this.options.fixationItems = [];
8009
8053
  return _super.prototype.cancel.call(this);
8010
8054
  };
8011
- ModalInvoicePjForFixationComponent.prototype.updateLinkedValueInGrid = function (rows) {
8055
+ ModalInvoicePjForFixationComponent.prototype.updateLinkedValueInGrid = function (result) {
8012
8056
  return __awaiter(this, void 0, void 0, function () {
8013
- var invoiceId, filter, listParams;
8014
- var _this = this;
8057
+ var externalInvoiceId, filter, listParams;
8015
8058
  return __generator(this, function (_a) {
8016
8059
  switch (_a.label) {
8017
8060
  case 0:
8018
- invoiceId = this.gridData.map(function (invoice) { return invoice.id; });
8061
+ externalInvoiceId = result.map(function (invoice) { return invoice.externalInvoiceId; });
8019
8062
  filter = "fixationItem.fixation.id eq '" + this.options.fixationId + "'";
8020
- if (invoiceId && invoiceId.length > 0) {
8021
- filter += "and invoiceId in ('" + invoiceId.join("','") + "') ";
8063
+ if (externalInvoiceId && externalInvoiceId.length > 0) {
8064
+ filter += "and externalInvoiceId in ('" + externalInvoiceId.join("','") + "') ";
8022
8065
  }
8023
8066
  listParams = {
8024
8067
  page: 0,
8025
- size: rows,
8068
+ size: result.length,
8026
8069
  filterQuery: filter,
8027
8070
  };
8028
8071
  return [4 /*yield*/, this.producerInvoiceService
@@ -8031,10 +8074,11 @@ var ModalInvoicePjForFixationComponent = /** @class */ (function (_super) {
8031
8074
  .toPromise()
8032
8075
  .then(function (producerInvoices) {
8033
8076
  producerInvoices === null || producerInvoices === void 0 ? void 0 : producerInvoices.contents.forEach(function (invoice) {
8034
- var gridInvoice = _this.gridData.find(function (item) { return item.id === invoice.invoiceId; });
8035
- if (gridInvoice) {
8036
- gridInvoice.linkedValue = invoice.linkedValue;
8037
- }
8077
+ var _a;
8078
+ (_a = result
8079
+ .filter(function (item) { return item.externalInvoiceId === invoice.externalInvoiceId; })) === null || _a === void 0 ? void 0 : _a.forEach(function (linkedInvoice) {
8080
+ linkedInvoice.linkedValue = invoice.linkedValue;
8081
+ });
8038
8082
  });
8039
8083
  })];
8040
8084
  case 1:
@@ -8044,13 +8088,21 @@ var ModalInvoicePjForFixationComponent = /** @class */ (function (_super) {
8044
8088
  });
8045
8089
  });
8046
8090
  };
8091
+ ModalInvoicePjForFixationComponent.prototype.getTotalValue = function (row) {
8092
+ var netTotalValue = row === null || row === void 0 ? void 0 : row.netTotalValue;
8093
+ if (netTotalValue) {
8094
+ return netTotalValue;
8095
+ }
8096
+ var items = (row === null || row === void 0 ? void 0 : row.items) || [];
8097
+ return items.reduce(function (total, item) { return total + (item.unitPrice || 0) * (item.quantity || 0); }, 0);
8098
+ };
8047
8099
  ModalInvoicePjForFixationComponent.ctorParameters = function () { return [
8048
8100
  { type: LibTranslationService },
8049
8101
  { type: AgroInvoiceService },
8050
8102
  { type: LocaleService },
8051
8103
  { type: KilogramPipe },
8052
8104
  { type: CurrencyPipe },
8053
- { type: ProducerInvoiceService },
8105
+ { type: ProducerInvoiceService$1 },
8054
8106
  { type: MessageService$1 },
8055
8107
  { type: DatePipe }
8056
8108
  ]; };
@@ -8063,7 +8115,7 @@ var ModalInvoicePjForFixationComponent = /** @class */ (function (_super) {
8063
8115
  ModalInvoicePjForFixationComponent = __decorate([
8064
8116
  Component({
8065
8117
  selector: 's-modal-invoice-pj-for-fixation',
8066
- template: "<p-dialog\r\n header=\"{{ 'agro.angular_components.panel_title_external_invoice_add_external_invoice' | libTranslate }}\"\r\n [(visible)]=\"visible\"\r\n [modal]=\"true\"\r\n class=\"add-invoice-modal\"\r\n [closeOnEscape]=\"false\"\r\n (onHide)=\"cancelPooling()\"\r\n [dismissableMask]=\"false\"\r\n>\r\n <ng-container *ngIf=\"!dontHaveAnyInvoice\">\r\n <div class=\"ui-g\">\r\n <label for=\"invoiceSearchInput\">{{ 'agro.angular_components.number' | libTranslate }}</label>\r\n <input\r\n type=\"text\"\r\n id=\"invoiceSearchInput\"\r\n pInputText\r\n [formControl]=\"searchValue\"\r\n [placeholder]=\"'' | libTranslate\"\r\n [required]=\"false\"\r\n />\r\n <div class=\"ui-g-12\">\r\n <p-table\r\n [(selection)]=\"selected\"\r\n [value]=\"gridData\"\r\n [columns]=\"gridColumns\"\r\n [scrollable]=\"true\"\r\n dataKey=\"externalInvoiceId\"\r\n [rows]=\"10\"\r\n [paginator]=\"true\"\r\n [lazyLoadOnInit]=\"false\"\r\n [totalRecords]=\"gridTotalRecords\"\r\n [lazy]=\"true\"\r\n (onLazyLoad)=\"updateGridData($event)\"\r\n [resizableColumns]=\"true\"\r\n *sLoadingState=\"gridLoading\"\r\n sortMode=\"multiple\"\r\n [selectionMode]=\"'multiple'\"\r\n >\r\n <ng-template pTemplate=\"header\" let-columns>\r\n <tr>\r\n <th class=\"checkbox\" scope=\"col\">\r\n <p-tableHeaderCheckbox></p-tableHeaderCheckbox>\r\n </th>\r\n <ng-container *ngFor=\"let col of columns\">\r\n <th\r\n *ngIf=\"col.sortable === undefined || col.sortable\"\r\n [pSortableColumn]=\"col.field\"\r\n scope=\"col\"\r\n >\r\n {{ col.header }}\r\n <p-sortIcon [field]=\"col.field\"></p-sortIcon>\r\n </th>\r\n <th *ngIf=\"col.sortable === false || col.sortable === null\" scope=\"col\">\r\n {{ col.header }}\r\n </th>\r\n </ng-container>\r\n </tr>\r\n </ng-template>\r\n\r\n <ng-template pTemplate=\"body\" let-rowData let-columns=\"columns\" let-rowIndex=\"rowIndex\">\r\n <tr>\r\n <td class=\"checkbox\" tabindex=\"0\">\r\n <p-tableCheckbox [value]=\"rowData\"></p-tableCheckbox>\r\n </td>\r\n <td\r\n [pSelectableRow]=\"rowData\"\r\n [pSelectableRowIndex]=\"rowIndex\"\r\n *ngFor=\"let col of columns\"\r\n class=\"column\"\r\n tabindex=\"0\"\r\n >\r\n <ng-container>\r\n {{ gridFieldValuesMap[col.field] ? gridFieldValuesMap[col.field](rowData) :\r\n rowData[col.field] }}\r\n </ng-container>\r\n </td>\r\n </tr>\r\n </ng-template>\r\n\r\n <ng-template pTemplate=\"paginatorright\">\r\n <span>{{ gridTotalRecords }} registros encontrados</span>\r\n </ng-template>\r\n </p-table>\r\n </div>\r\n </div>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"dontHaveAnyInvoice\">\r\n <s-empty-state\r\n iconClass=\"fa fa-exclamation-triangle\"\r\n title=\"{{ 'agro.angular_components.add_pj_invoice_modal_no_invoices_found' | libTranslate }}\"\r\n primaryActionLabel=\"{{ 'agro.angular_components.error_server_try_again' | libTranslate }}\"\r\n (primaryAction)=\"tryToSearchAgain()\"\r\n description=\"{{ 'agro.angular_components.no_register_found_for_external_invoices_summary' | libTranslate }}\"\r\n >\r\n </s-empty-state>\r\n </ng-container>\r\n\r\n <p-footer class=\"footer\" *ngIf=\"!dontHaveAnyInvoice\">\r\n <s-button\r\n [priority]=\"buttonPriority.Primary\"\r\n label=\"{{ 'agro.angular_components.panel_title_external_invoice_add_external_invoice' | libTranslate }}\"\r\n [disabled]=\"!selected?.length\"\r\n (click)=\"add()\"\r\n (keydown.enter)=\"add()\"\r\n ></s-button>\r\n <s-button\r\n [priority]=\"buttonPriority.Link\"\r\n label=\"{{ 'agro.angular_components.cancel' | libTranslate }}\"\r\n (click)=\"cancel()\"\r\n (keydown.enter)=\"cancel()\"\r\n ></s-button>\r\n </p-footer>\r\n</p-dialog>\r\n",
8118
+ template: "<p-dialog\r\n header=\"{{ 'agro.angular_components.panel_title_external_invoice_add_external_invoice' | libTranslate }}\"\r\n [(visible)]=\"visible\"\r\n [modal]=\"true\"\r\n class=\"add-invoice-modal\"\r\n [closeOnEscape]=\"false\"\r\n (onHide)=\"cancelPooling()\"\r\n [dismissableMask]=\"false\"\r\n>\r\n <ng-container *ngIf=\"!dontHaveAnyInvoice\">\r\n <div class=\"ui-g\">\r\n <label for=\"invoiceSearchInput\">{{ 'agro.angular_components.number' | libTranslate }}</label>\r\n <input\r\n type=\"text\"\r\n id=\"invoiceSearchInput\"\r\n pInputText\r\n [formControl]=\"searchValue\"\r\n [placeholder]=\"'' | libTranslate\"\r\n [required]=\"false\"\r\n />\r\n <div class=\"ui-g-12\">\r\n <p-table\r\n [(selection)]=\"selected\"\r\n [value]=\"gridData\"\r\n [columns]=\"gridColumns\"\r\n [scrollable]=\"true\"\r\n dataKey=\"_uniqueId\"\r\n [rows]=\"10\"\r\n [paginator]=\"true\"\r\n [lazyLoadOnInit]=\"false\"\r\n [totalRecords]=\"gridTotalRecords\"\r\n [lazy]=\"true\"\r\n (onLazyLoad)=\"updateGridData($event)\"\r\n [resizableColumns]=\"true\"\r\n *sLoadingState=\"gridLoading\"\r\n sortMode=\"multiple\"\r\n [selectionMode]=\"'multiple'\"\r\n >\r\n <ng-template pTemplate=\"header\" let-columns>\r\n <tr>\r\n <th class=\"checkbox\" scope=\"col\">\r\n <p-tableHeaderCheckbox></p-tableHeaderCheckbox>\r\n </th>\r\n <ng-container *ngFor=\"let col of columns\">\r\n <th\r\n *ngIf=\"col.sortable === undefined || col.sortable\"\r\n [pSortableColumn]=\"col.field\"\r\n scope=\"col\"\r\n >\r\n {{ col.header }}\r\n <p-sortIcon [field]=\"col.field\"></p-sortIcon>\r\n </th>\r\n <th *ngIf=\"col.sortable === false || col.sortable === null\" scope=\"col\">\r\n {{ col.header }}\r\n </th>\r\n </ng-container>\r\n </tr>\r\n </ng-template>\r\n\r\n <ng-template pTemplate=\"body\" let-rowData let-columns=\"columns\" let-rowIndex=\"rowIndex\">\r\n <tr>\r\n <td class=\"checkbox\" tabindex=\"0\">\r\n <p-tableCheckbox [value]=\"rowData\"></p-tableCheckbox>\r\n </td>\r\n <td\r\n [pSelectableRow]=\"rowData\"\r\n [pSelectableRowIndex]=\"rowIndex\"\r\n *ngFor=\"let col of columns\"\r\n class=\"column\"\r\n tabindex=\"0\"\r\n >\r\n <ng-container>\r\n {{ gridFieldValuesMap[col.field] ? gridFieldValuesMap[col.field](rowData) :\r\n rowData[col.field] }}\r\n </ng-container>\r\n </td>\r\n </tr>\r\n </ng-template>\r\n\r\n <ng-template pTemplate=\"paginatorright\">\r\n <span>{{ gridTotalRecords }} registros encontrados</span>\r\n </ng-template>\r\n </p-table>\r\n </div>\r\n </div>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"dontHaveAnyInvoice\">\r\n <s-empty-state\r\n iconClass=\"fa fa-exclamation-triangle\"\r\n title=\"{{ 'agro.angular_components.add_pj_invoice_modal_no_invoices_found' | libTranslate }}\"\r\n primaryActionLabel=\"{{ 'agro.angular_components.error_server_try_again' | libTranslate }}\"\r\n (primaryAction)=\"tryToSearchAgain()\"\r\n description=\"{{ 'agro.angular_components.no_register_found_for_external_invoices_summary' | libTranslate }}\"\r\n >\r\n </s-empty-state>\r\n </ng-container>\r\n\r\n <p-footer class=\"footer\" *ngIf=\"!dontHaveAnyInvoice\">\r\n <s-button\r\n [priority]=\"buttonPriority.Primary\"\r\n label=\"{{ 'agro.angular_components.panel_title_external_invoice_add_external_invoice' | libTranslate }}\"\r\n [disabled]=\"!selected?.length\"\r\n (click)=\"add()\"\r\n (keydown.enter)=\"add()\"\r\n ></s-button>\r\n <s-button\r\n [priority]=\"buttonPriority.Link\"\r\n label=\"{{ 'agro.angular_components.cancel' | libTranslate }}\"\r\n (click)=\"cancel()\"\r\n (keydown.enter)=\"cancel()\"\r\n ></s-button>\r\n </p-footer>\r\n</p-dialog>\r\n",
8067
8119
  styles: [".footer{width:100%;display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center}.add-invoice-modal{width:480px;max-width:480px}.add-invoice-modal input[type=text]{width:100%}.add-invoice-modal .ui-dialog{width:480px!important}.add-invoice-modal .ui-dialog .ui-dialog-content{min-height:175px}td.checkbox,th.checkbox{width:50px}td.column,th.column{min-width:150px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}"]
8068
8120
  })
8069
8121
  ], ModalInvoicePjForFixationComponent);