@senior-agronegocio/angular-components 0.0.9883 → 0.0.9885

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 (31) hide show
  1. package/bundles/senior-agronegocio-angular-components.umd.js +124 -66
  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/modal-invoice-pj/for-fixation/modal-invoice-pj-for-fixation.component.d.ts +6 -5
  6. package/components/modal-invoice-pj/modal-shared-imports.d.ts +4 -7
  7. package/components/modal-invoice-pj/services/agro-invoice/interfaces.d.ts +2 -1
  8. package/components/modal-invoice-pj/services/producer-invoice-fixation/producer-invoice-dto.d.ts +15 -0
  9. package/components/modal-invoice-pj/services/producer-invoice-fixation/producer-invoice.service.d.ts +18 -0
  10. package/esm2015/components/event-control-board/event-control-board.component.js +2 -1
  11. package/esm2015/components/modal-invoice-pj/for-fixation/modal-invoice-pj-for-fixation.component.js +43 -25
  12. package/esm2015/components/modal-invoice-pj/modal-invoice-pj-base.class.js +9 -4
  13. package/esm2015/components/modal-invoice-pj/services/agro-invoice/interfaces.js +1 -1
  14. package/esm2015/components/modal-invoice-pj/services/producer-invoice-fixation/producer-invoice-dto.js +1 -0
  15. package/esm2015/components/modal-invoice-pj/services/producer-invoice-fixation/producer-invoice.service.js +63 -0
  16. package/esm2015/services/i18n/pt-BR.js +2 -2
  17. package/esm2015/services/producer-invoice/producer-invoice.service.js +4 -37
  18. package/esm5/components/event-control-board/event-control-board.component.js +2 -1
  19. package/esm5/components/modal-invoice-pj/for-fixation/modal-invoice-pj-for-fixation.component.js +52 -28
  20. package/esm5/components/modal-invoice-pj/modal-invoice-pj-base.class.js +15 -4
  21. package/esm5/components/modal-invoice-pj/services/agro-invoice/interfaces.js +1 -1
  22. package/esm5/components/modal-invoice-pj/services/producer-invoice-fixation/producer-invoice-dto.js +1 -0
  23. package/esm5/components/modal-invoice-pj/services/producer-invoice-fixation/producer-invoice.service.js +71 -0
  24. package/esm5/services/i18n/pt-BR.js +2 -2
  25. package/esm5/services/producer-invoice/producer-invoice.service.js +4 -42
  26. package/fesm2015/senior-agronegocio-angular-components.js +101 -58
  27. package/fesm2015/senior-agronegocio-angular-components.js.map +1 -1
  28. package/fesm5/senior-agronegocio-angular-components.js +124 -66
  29. package/fesm5/senior-agronegocio-angular-components.js.map +1 -1
  30. package/package.json +1 -1
  31. package/services/producer-invoice/producer-invoice.service.d.ts +1 -4
@@ -991,7 +991,7 @@
991
991
  "agro.angular_components.ORIGINATION_CREATE_EFFECTIVE_BALANCE": "Emissão de saldo efetivo",
992
992
  "agro.angular_components.PRODUCER_NET_VALUE_EFFECTIVE_BALANCE_CONFIRMATION": "Confirmação de saldo efetivo",
993
993
  "agro.angular_components.CLOSE_INVOICE_FIXATION": "Fechamento de NF",
994
- "agro.angular_components.INVOICE_CLOSE_INVOICE": "Solicitação de cancelamento da NF",
994
+ "agro.angular_components.INVOICE_CLOSE_INVOICE": "Fechamento de NF",
995
995
  "agro.angular_components.ORIGINATION_CREATE_EFFECTIVE_CONFIRMATION": "Confirmação efetiva",
996
996
  "agro.angular_components.ORIGINATION_CREATE_PROVISIONAL_BALANCE": "Saldo provisório",
997
997
  "agro.angular_components.CLOSE_INVOICE_TRANSFER": "Fechamento de NF",
@@ -5778,43 +5778,6 @@
5778
5778
  _this.translate = translate;
5779
5779
  return _this;
5780
5780
  }
5781
- ProducerInvoiceService.prototype.getTotalLinkedInInvoices = function (invoiceId, fixationId) {
5782
- return __awaiter(this, void 0, void 0, function () {
5783
- var filter;
5784
- var _this = this;
5785
- return __generator(this, function (_a) {
5786
- filter = "fixationItem.fixation.id eq '" + fixationId + "' " + ("and invoiceId in ('" + invoiceId.join("','") + "') ");
5787
- return [2 /*return*/, new Promise(function (resolve, reject) {
5788
- _this.list({
5789
- filterQuery: filter,
5790
- size: exports.AGRO_NUMBERS.ONE_HUNDRED,
5791
- }).subscribe({
5792
- next: function (data) {
5793
- var invoiceList = data.contents;
5794
- var producerInvoice = new Map();
5795
- if (invoiceList.length) {
5796
- invoiceList.forEach(function (invoice) {
5797
- var _a;
5798
- producerInvoice.set(invoice.invoiceId, ((_a = producerInvoice.get(invoice.invoiceId)) !== null && _a !== void 0 ? _a : 0) + invoice.linkedValue);
5799
- });
5800
- }
5801
- resolve(Array.from(producerInvoice.entries()).map(function (_a) {
5802
- var _b = __read(_a, 2), key = _b[0], value = _b[1];
5803
- return {
5804
- invoiceId: key,
5805
- totalLinked: value,
5806
- };
5807
- }));
5808
- },
5809
- error: function (err) { return reject(new Error(typeof err === 'string' ? err : JSON.stringify(err))); },
5810
- });
5811
- })];
5812
- });
5813
- });
5814
- };
5815
- ProducerInvoiceService.prototype.deleteAllProducerInvoice = function (fixationId) {
5816
- return this.http.post(this.actionsUrl + "/deleteAllProducerInvoice", { fixationId: fixationId }).pipe(this.defaultCatch());
5817
- };
5818
5781
  ProducerInvoiceService.ctorParameters = function () { return [
5819
5782
  { type: http.HttpClient },
5820
5783
  { type: api.MessageService },
@@ -6603,6 +6566,7 @@
6603
6566
  EventControlBoardComponent.prototype.getEventLabel = function (detail) {
6604
6567
  var _a;
6605
6568
  var eventLabel = (_a = this.eventItem.find(function (e) { return e.value === detail.eventOperation; })) === null || _a === void 0 ? void 0 : _a.label;
6569
+ console.log('Getting label for event operation:', eventLabel);
6606
6570
  if (eventLabel) {
6607
6571
  return this.translate.instant(eventLabel);
6608
6572
  }
@@ -7779,6 +7743,7 @@
7779
7743
  this.gridLoading = true;
7780
7744
  this.dontHaveAnyInvoice = false;
7781
7745
  this.updateCurrentParams(event);
7746
+ var numberSearchValue = searchValue ? AgroNumberUtils.getNearInteger(searchValue) : null;
7782
7747
  var filterBody = {
7783
7748
  filter: {
7784
7749
  companyId: companyId,
@@ -7787,6 +7752,7 @@
7787
7752
  ruralEstateIds: [ruralEstateId],
7788
7753
  multiProducts: false,
7789
7754
  productId: this.options.productId,
7755
+ number: numberSearchValue,
7790
7756
  },
7791
7757
  pageRequest: {
7792
7758
  offset: this.currentParams.page,
@@ -7798,11 +7764,20 @@
7798
7764
  },
7799
7765
  };
7800
7766
  if (searchValue) {
7801
- searchValue = AgroNumberUtils.getNearInteger(searchValue).toString();
7767
+ searchValue = numberSearchValue.toString();
7802
7768
  }
7803
7769
  this.invoiceService
7804
7770
  .invoiceLookupFilter(filterBody)
7805
- .pipe(operators.takeUntil(this.ngUnsubscribe), operators.finalize(function () {
7771
+ .pipe(operators.takeUntil(this.ngUnsubscribe), operators.switchMap(function (result) { return __awaiter(_this, void 0, void 0, function () {
7772
+ return __generator(this, function (_a) {
7773
+ switch (_a.label) {
7774
+ case 0: return [4 /*yield*/, this.adaptResult(result)];
7775
+ case 1:
7776
+ _a.sent();
7777
+ return [2 /*return*/, result];
7778
+ }
7779
+ });
7780
+ }); }), operators.finalize(function () {
7806
7781
  _this.gridLoading = false;
7807
7782
  }))
7808
7783
  .subscribe(function (result) {
@@ -8035,6 +8010,66 @@
8035
8010
  return ModalInvoicePjForTransferModule;
8036
8011
  }());
8037
8012
 
8013
+ var ProducerInvoiceService$1 = /** @class */ (function (_super) {
8014
+ __extends(ProducerInvoiceService, _super);
8015
+ function ProducerInvoiceService(http, messageService, translate) {
8016
+ var _this = _super.call(this, http, messageService, "agro/fixation/entities/producerInvoice", "agro/fixation/actions", "agro/fixation/queries", translate) || this;
8017
+ _this.http = http;
8018
+ _this.messageService = messageService;
8019
+ _this.translate = translate;
8020
+ return _this;
8021
+ }
8022
+ ProducerInvoiceService.prototype.getTotalLinkedInInvoices = function (invoiceId, fixationId) {
8023
+ return __awaiter(this, void 0, void 0, function () {
8024
+ var filter;
8025
+ var _this = this;
8026
+ return __generator(this, function (_a) {
8027
+ filter = "fixationItem.fixation.id eq '" + fixationId + "' " + ("and externalInvoiceId in ('" + invoiceId.join("','") + "') ");
8028
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8029
+ _this.list({
8030
+ filterQuery: filter,
8031
+ size: 100
8032
+ }).subscribe({
8033
+ next: function (data) {
8034
+ var invoiceList = data.contents;
8035
+ var producerInvoice = new Map();
8036
+ if (invoiceList.length) {
8037
+ invoiceList.forEach(function (invoice) {
8038
+ var _a;
8039
+ producerInvoice.set(invoice.invoiceId, ((_a = producerInvoice.get(invoice.invoiceId)) !== null && _a !== void 0 ? _a : 0) + invoice.linkedValue);
8040
+ });
8041
+ }
8042
+ resolve(Array.from(producerInvoice.entries()).map(function (_a) {
8043
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
8044
+ return {
8045
+ invoiceId: key,
8046
+ totalLinked: value
8047
+ };
8048
+ }));
8049
+ },
8050
+ error: function (err) { return reject(err instanceof Error ? err : new Error(String(err))); }
8051
+ });
8052
+ })];
8053
+ });
8054
+ });
8055
+ };
8056
+ ProducerInvoiceService.prototype.deleteAllProducerInvoice = function (fixationId) {
8057
+ return this.http.post(this.actionsUrl + "/deleteAllProducerInvoice", { fixationId: fixationId }).pipe(this.defaultCatch());
8058
+ };
8059
+ ProducerInvoiceService.ctorParameters = function () { return [
8060
+ { type: http.HttpClient },
8061
+ { type: api.MessageService },
8062
+ { type: LibTranslationService }
8063
+ ]; };
8064
+ ProducerInvoiceService.ɵprov = core["ɵɵdefineInjectable"]({ factory: function ProducerInvoiceService_Factory() { return new ProducerInvoiceService(core["ɵɵinject"](http.HttpClient), core["ɵɵinject"](api.MessageService), core["ɵɵinject"](LibTranslationService)); }, token: ProducerInvoiceService, providedIn: "root" });
8065
+ ProducerInvoiceService = __decorate([
8066
+ core.Injectable({
8067
+ providedIn: 'root'
8068
+ })
8069
+ ], ProducerInvoiceService);
8070
+ return ProducerInvoiceService;
8071
+ }(AgroEntityService));
8072
+
8038
8073
  var ModalInvoicePjForFixationComponent = /** @class */ (function (_super) {
8039
8074
  __extends(ModalInvoicePjForFixationComponent, _super);
8040
8075
  function ModalInvoicePjForFixationComponent(translationService, invoiceService, localeService, kilogramPipe, currencyPipe, producerInvoiceService, messageService, datePipe) {
@@ -8048,12 +8083,17 @@
8048
8083
  _this.messageService = messageService;
8049
8084
  _this.datePipe = datePipe;
8050
8085
  _this.whenSelectInvoices = new core.EventEmitter();
8086
+ common.registerLocaleData(localePt);
8051
8087
  return _this;
8052
8088
  }
8053
8089
  ModalInvoicePjForFixationComponent.prototype.ngOnInit = function () {
8054
8090
  var _this = this;
8055
8091
  this.defineGridColumns();
8056
- 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'); } });
8092
+ 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) {
8093
+ return _this.currencyPipe.transform(_this.getTotalValue(row) || 0, 'BRL', 'symbol', undefined, 'pt-BR');
8094
+ }, linkedValue: function (row) {
8095
+ return _this.currencyPipe.transform((row === null || row === void 0 ? void 0 : row.linkedValue) || 0, 'BRL', 'symbol', undefined, 'pt-BR');
8096
+ } });
8057
8097
  _super.prototype.ngOnInit.call(this);
8058
8098
  };
8059
8099
  ModalInvoicePjForFixationComponent.prototype.defineGridColumns = function () {
@@ -8075,7 +8115,7 @@
8075
8115
  };
8076
8116
  ModalInvoicePjForFixationComponent.prototype.beforeAdd = function (selectedInvoices) {
8077
8117
  if (selectedInvoices === null || selectedInvoices === void 0 ? void 0 : selectedInvoices.length) {
8078
- this.linkSelectedInvoicesInFixationItem();
8118
+ this.linkSelectedInvoicesInFixationItem(selectedInvoices);
8079
8119
  }
8080
8120
  return rxjs.of(rxjs.EMPTY).toPromise();
8081
8121
  };
@@ -8090,20 +8130,20 @@
8090
8130
  }
8091
8131
  _super.prototype.open.call(this);
8092
8132
  };
8093
- ModalInvoicePjForFixationComponent.prototype.linkSelectedInvoicesInFixationItem = function () {
8133
+ ModalInvoicePjForFixationComponent.prototype.linkSelectedInvoicesInFixationItem = function (selectedInvoices) {
8094
8134
  return __awaiter(this, void 0, void 0, function () {
8095
8135
  var entities;
8096
8136
  var _this = this;
8097
8137
  return __generator(this, function (_a) {
8098
8138
  switch (_a.label) {
8099
- case 0: return [4 /*yield*/, this.isValidAndSetLinkedValueInInvoices()];
8139
+ case 0: return [4 /*yield*/, this.isValidAndSetLinkedValueInInvoices(selectedInvoices)];
8100
8140
  case 1:
8101
8141
  if (!(_a.sent())) {
8102
8142
  this.gridLoading = false;
8103
8143
  return [2 /*return*/];
8104
8144
  }
8105
8145
  entities = []
8106
- .concat.apply([], __spread(this.selected.map(function (invoice) {
8146
+ .concat.apply([], __spread(selectedInvoices.map(function (invoice) {
8107
8147
  return _this.options.fixationItems.map(function (fixationItem) {
8108
8148
  var requiredValue = (fixationItem.requiredValue || 0) - (fixationItem.totalValueInvoices || 0);
8109
8149
  if (invoice.remainingValue <= 0 || requiredValue <= 0) {
@@ -8114,11 +8154,11 @@
8114
8154
  var body = {
8115
8155
  series: invoice === null || invoice === void 0 ? void 0 : invoice.series,
8116
8156
  number: String(invoice === null || invoice === void 0 ? void 0 : invoice.number),
8117
- invoiceId: invoice === null || invoice === void 0 ? void 0 : invoice.id,
8157
+ externalInvoiceId: invoice === null || invoice === void 0 ? void 0 : invoice.externalInvoiceId,
8118
8158
  linkedValue: valueToBeLinked,
8119
- totalValue: invoice === null || invoice === void 0 ? void 0 : invoice.totalValue,
8159
+ totalValue: _this.getTotalValue(invoice),
8120
8160
  issuanceDate: invoice === null || invoice === void 0 ? void 0 : invoice.issuanceDate,
8121
- fixationItem: fixationItem,
8161
+ fixationItem: { id: fixationItem === null || fixationItem === void 0 ? void 0 : fixationItem.id },
8122
8162
  };
8123
8163
  fixationItem.totalValueInvoices = (fixationItem.totalValueInvoices || 0) + valueToBeLinked;
8124
8164
  return body;
@@ -8144,19 +8184,25 @@
8144
8184
  });
8145
8185
  });
8146
8186
  };
8147
- ModalInvoicePjForFixationComponent.prototype.isValidAndSetLinkedValueInInvoices = function () {
8187
+ ModalInvoicePjForFixationComponent.prototype.isValidAndSetLinkedValueInInvoices = function (selectedInvoices) {
8148
8188
  return __awaiter(this, void 0, void 0, function () {
8149
8189
  var valorLinked, isValid;
8150
8190
  var _this = this;
8151
8191
  return __generator(this, function (_a) {
8152
8192
  switch (_a.label) {
8153
- case 0: return [4 /*yield*/, this.producerInvoiceService.getTotalLinkedInInvoices(this.selected.map(function (invoice) { return invoice.id; }), this.options.fixationId)];
8193
+ case 0: return [4 /*yield*/, this.producerInvoiceService.getTotalLinkedInInvoices(selectedInvoices.map(function (invoice) { return invoice.externalInvoiceId; }), this.options.fixationId)];
8154
8194
  case 1:
8155
8195
  valorLinked = _a.sent();
8196
+ selectedInvoices.forEach(function (invoice) {
8197
+ if (!invoice.totalValue) {
8198
+ invoice.totalValue = _this.getTotalValue(invoice);
8199
+ }
8200
+ });
8156
8201
  isValid = true;
8157
- this.selected.forEach(function (invoice) {
8202
+ selectedInvoices.forEach(function (invoice) {
8158
8203
  var _a;
8159
- invoice.linkedValue = ((_a = valorLinked.find(function (linked) { return linked.invoiceId === invoice.id; })) === null || _a === void 0 ? void 0 : _a.totalLinked) || 0;
8204
+ invoice.linkedValue =
8205
+ ((_a = valorLinked.find(function (linked) { return linked.externalInvoiceId === invoice.externalInvoiceId; })) === null || _a === void 0 ? void 0 : _a.totalLinked) || 0;
8160
8206
  if (invoice.linkedValue >= invoice.totalValue) {
8161
8207
  _this.messageService.add({
8162
8208
  severity: 'warn',
@@ -8173,9 +8219,13 @@
8173
8219
  });
8174
8220
  };
8175
8221
  ModalInvoicePjForFixationComponent.prototype.adaptResult = function (result) {
8222
+ var _a;
8176
8223
  return __awaiter(this, void 0, void 0, function () {
8177
- return __generator(this, function (_a) {
8178
- return [2 /*return*/, Promise.resolve(result)];
8224
+ return __generator(this, function (_b) {
8225
+ switch (_b.label) {
8226
+ 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) || [])];
8227
+ case 1: return [2 /*return*/, _b.sent()];
8228
+ }
8179
8229
  });
8180
8230
  });
8181
8231
  };
@@ -8183,21 +8233,20 @@
8183
8233
  this.options.fixationItems = [];
8184
8234
  return _super.prototype.cancel.call(this);
8185
8235
  };
8186
- ModalInvoicePjForFixationComponent.prototype.updateLinkedValueInGrid = function (rows) {
8236
+ ModalInvoicePjForFixationComponent.prototype.updateLinkedValueInGrid = function (result) {
8187
8237
  return __awaiter(this, void 0, void 0, function () {
8188
- var invoiceId, filter, listParams;
8189
- var _this = this;
8238
+ var externalInvoiceId, filter, listParams;
8190
8239
  return __generator(this, function (_a) {
8191
8240
  switch (_a.label) {
8192
8241
  case 0:
8193
- invoiceId = this.gridData.map(function (invoice) { return invoice.id; });
8242
+ externalInvoiceId = result.map(function (invoice) { return invoice.externalInvoiceId; });
8194
8243
  filter = "fixationItem.fixation.id eq '" + this.options.fixationId + "'";
8195
- if (invoiceId && invoiceId.length > 0) {
8196
- filter += "and invoiceId in ('" + invoiceId.join("','") + "') ";
8244
+ if (externalInvoiceId && externalInvoiceId.length > 0) {
8245
+ filter += "and externalInvoiceId in ('" + externalInvoiceId.join("','") + "') ";
8197
8246
  }
8198
8247
  listParams = {
8199
8248
  page: 0,
8200
- size: rows,
8249
+ size: result.length,
8201
8250
  filterQuery: filter,
8202
8251
  };
8203
8252
  return [4 /*yield*/, this.producerInvoiceService
@@ -8206,10 +8255,11 @@
8206
8255
  .toPromise()
8207
8256
  .then(function (producerInvoices) {
8208
8257
  producerInvoices === null || producerInvoices === void 0 ? void 0 : producerInvoices.contents.forEach(function (invoice) {
8209
- var gridInvoice = _this.gridData.find(function (item) { return item.id === invoice.invoiceId; });
8210
- if (gridInvoice) {
8211
- gridInvoice.linkedValue = invoice.linkedValue;
8212
- }
8258
+ var _a;
8259
+ (_a = result
8260
+ .filter(function (item) { return item.externalInvoiceId === invoice.externalInvoiceId; })) === null || _a === void 0 ? void 0 : _a.forEach(function (linkedInvoice) {
8261
+ linkedInvoice.linkedValue = invoice.linkedValue;
8262
+ });
8213
8263
  });
8214
8264
  })];
8215
8265
  case 1:
@@ -8219,13 +8269,21 @@
8219
8269
  });
8220
8270
  });
8221
8271
  };
8272
+ ModalInvoicePjForFixationComponent.prototype.getTotalValue = function (row) {
8273
+ var netTotalValue = row === null || row === void 0 ? void 0 : row.netTotalValue;
8274
+ if (netTotalValue) {
8275
+ return netTotalValue;
8276
+ }
8277
+ var items = (row === null || row === void 0 ? void 0 : row.items) || [];
8278
+ return items.reduce(function (total, item) { return total + (item.unitPrice || 0) * (item.quantity || 0); }, 0);
8279
+ };
8222
8280
  ModalInvoicePjForFixationComponent.ctorParameters = function () { return [
8223
8281
  { type: LibTranslationService },
8224
8282
  { type: AgroInvoiceService },
8225
8283
  { type: angularComponents.LocaleService },
8226
8284
  { type: KilogramPipe },
8227
8285
  { type: common.CurrencyPipe },
8228
- { type: ProducerInvoiceService },
8286
+ { type: ProducerInvoiceService$1 },
8229
8287
  { type: primeng.MessageService },
8230
8288
  { type: common.DatePipe }
8231
8289
  ]; };