@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
@@ -711,7 +711,7 @@ const ptBR = {
711
711
  "agro.angular_components.ORIGINATION_CREATE_EFFECTIVE_BALANCE": "Emissão de saldo efetivo",
712
712
  "agro.angular_components.PRODUCER_NET_VALUE_EFFECTIVE_BALANCE_CONFIRMATION": "Confirmação de saldo efetivo",
713
713
  "agro.angular_components.CLOSE_INVOICE_FIXATION": "Fechamento de NF",
714
- "agro.angular_components.INVOICE_CLOSE_INVOICE": "Solicitação de cancelamento da NF",
714
+ "agro.angular_components.INVOICE_CLOSE_INVOICE": "Fechamento de NF",
715
715
  "agro.angular_components.ORIGINATION_CREATE_EFFECTIVE_CONFIRMATION": "Confirmação efetiva",
716
716
  "agro.angular_components.ORIGINATION_CREATE_PROVISIONAL_BALANCE": "Saldo provisório",
717
717
  "agro.angular_components.CLOSE_INVOICE_TRANSFER": "Fechamento de NF",
@@ -5304,38 +5304,6 @@ let ProducerInvoiceService = class ProducerInvoiceService extends AgroEntityServ
5304
5304
  this.messageService = messageService;
5305
5305
  this.translate = translate;
5306
5306
  }
5307
- getTotalLinkedInInvoices(invoiceId, fixationId) {
5308
- return __awaiter(this, void 0, void 0, function* () {
5309
- const filter = `fixationItem.fixation.id eq '${fixationId}' ` + `and invoiceId in ('${invoiceId.join("','")}') `;
5310
- return new Promise((resolve, reject) => {
5311
- this.list({
5312
- filterQuery: filter,
5313
- size: AGRO_NUMBERS.ONE_HUNDRED,
5314
- }).subscribe({
5315
- next: (data) => {
5316
- const invoiceList = data.contents;
5317
- const producerInvoice = new Map();
5318
- if (invoiceList.length) {
5319
- invoiceList.forEach((invoice) => {
5320
- var _a;
5321
- producerInvoice.set(invoice.invoiceId, ((_a = producerInvoice.get(invoice.invoiceId)) !== null && _a !== void 0 ? _a : 0) + invoice.linkedValue);
5322
- });
5323
- }
5324
- resolve(Array.from(producerInvoice.entries()).map(([key, value]) => {
5325
- return {
5326
- invoiceId: key,
5327
- totalLinked: value,
5328
- };
5329
- }));
5330
- },
5331
- error: (err) => reject(new Error(typeof err === 'string' ? err : JSON.stringify(err))),
5332
- });
5333
- });
5334
- });
5335
- }
5336
- deleteAllProducerInvoice(fixationId) {
5337
- return this.http.post(`${this.actionsUrl}/deleteAllProducerInvoice`, { fixationId }).pipe(this.defaultCatch());
5338
- }
5339
5307
  };
5340
5308
  ProducerInvoiceService.ctorParameters = () => [
5341
5309
  { type: HttpClient },
@@ -6061,6 +6029,7 @@ let EventControlBoardComponent = class EventControlBoardComponent {
6061
6029
  getEventLabel(detail) {
6062
6030
  var _a;
6063
6031
  const eventLabel = (_a = this.eventItem.find((e) => e.value === detail.eventOperation)) === null || _a === void 0 ? void 0 : _a.label;
6032
+ console.log('Getting label for event operation:', eventLabel);
6064
6033
  if (eventLabel) {
6065
6034
  return this.translate.instant(eventLabel);
6066
6035
  }
@@ -7122,6 +7091,7 @@ let ModalInvoicePjBase = class ModalInvoicePjBase {
7122
7091
  this.gridLoading = true;
7123
7092
  this.dontHaveAnyInvoice = false;
7124
7093
  this.updateCurrentParams(event);
7094
+ const numberSearchValue = searchValue ? AgroNumberUtils.getNearInteger(searchValue) : null;
7125
7095
  const filterBody = {
7126
7096
  filter: {
7127
7097
  companyId,
@@ -7130,6 +7100,7 @@ let ModalInvoicePjBase = class ModalInvoicePjBase {
7130
7100
  ruralEstateIds: [ruralEstateId],
7131
7101
  multiProducts: false,
7132
7102
  productId: this.options.productId,
7103
+ number: numberSearchValue,
7133
7104
  },
7134
7105
  pageRequest: {
7135
7106
  offset: this.currentParams.page,
@@ -7141,11 +7112,14 @@ let ModalInvoicePjBase = class ModalInvoicePjBase {
7141
7112
  },
7142
7113
  };
7143
7114
  if (searchValue) {
7144
- searchValue = AgroNumberUtils.getNearInteger(searchValue).toString();
7115
+ searchValue = numberSearchValue.toString();
7145
7116
  }
7146
7117
  this.invoiceService
7147
7118
  .invoiceLookupFilter(filterBody)
7148
- .pipe(takeUntil(this.ngUnsubscribe), finalize(() => {
7119
+ .pipe(takeUntil(this.ngUnsubscribe), switchMap((result) => __awaiter(this, void 0, void 0, function* () {
7120
+ yield this.adaptResult(result);
7121
+ return result;
7122
+ })), finalize(() => {
7149
7123
  this.gridLoading = false;
7150
7124
  }))
7151
7125
  .subscribe((result) => {
@@ -7349,6 +7323,58 @@ ModalInvoicePjForTransferModule = __decorate([
7349
7323
  })
7350
7324
  ], ModalInvoicePjForTransferModule);
7351
7325
 
7326
+ let ProducerInvoiceService$1 = class ProducerInvoiceService extends AgroEntityService {
7327
+ constructor(http, messageService, translate) {
7328
+ super(http, messageService, `agro/fixation/entities/producerInvoice`, `agro/fixation/actions`, `agro/fixation/queries`, translate);
7329
+ this.http = http;
7330
+ this.messageService = messageService;
7331
+ this.translate = translate;
7332
+ }
7333
+ getTotalLinkedInInvoices(invoiceId, fixationId) {
7334
+ return __awaiter(this, void 0, void 0, function* () {
7335
+ const filter = `fixationItem.fixation.id eq '${fixationId}' ` + `and externalInvoiceId in ('${invoiceId.join("','")}') `;
7336
+ return new Promise((resolve, reject) => {
7337
+ this.list({
7338
+ filterQuery: filter,
7339
+ size: 100
7340
+ }).subscribe({
7341
+ next: (data) => {
7342
+ const invoiceList = data.contents;
7343
+ const producerInvoice = new Map();
7344
+ if (invoiceList.length) {
7345
+ invoiceList.forEach((invoice) => {
7346
+ var _a;
7347
+ producerInvoice.set(invoice.invoiceId, ((_a = producerInvoice.get(invoice.invoiceId)) !== null && _a !== void 0 ? _a : 0) + invoice.linkedValue);
7348
+ });
7349
+ }
7350
+ resolve(Array.from(producerInvoice.entries()).map(([key, value]) => {
7351
+ return {
7352
+ invoiceId: key,
7353
+ totalLinked: value
7354
+ };
7355
+ }));
7356
+ },
7357
+ error: (err) => reject(err instanceof Error ? err : new Error(String(err)))
7358
+ });
7359
+ });
7360
+ });
7361
+ }
7362
+ deleteAllProducerInvoice(fixationId) {
7363
+ return this.http.post(`${this.actionsUrl}/deleteAllProducerInvoice`, { fixationId }).pipe(this.defaultCatch());
7364
+ }
7365
+ };
7366
+ ProducerInvoiceService$1.ctorParameters = () => [
7367
+ { type: HttpClient },
7368
+ { type: MessageService },
7369
+ { type: LibTranslationService }
7370
+ ];
7371
+ ProducerInvoiceService$1.ɵprov = ɵɵdefineInjectable({ factory: function ProducerInvoiceService_Factory() { return new ProducerInvoiceService$1(ɵɵinject(HttpClient), ɵɵinject(MessageService), ɵɵinject(LibTranslationService)); }, token: ProducerInvoiceService$1, providedIn: "root" });
7372
+ ProducerInvoiceService$1 = __decorate([
7373
+ Injectable({
7374
+ providedIn: 'root'
7375
+ })
7376
+ ], ProducerInvoiceService$1);
7377
+
7352
7378
  let ModalInvoicePjForFixationComponent = class ModalInvoicePjForFixationComponent extends ModalInvoicePjBase {
7353
7379
  constructor(translationService, invoiceService, localeService, kilogramPipe, currencyPipe, producerInvoiceService, messageService, datePipe) {
7354
7380
  super(translationService, invoiceService, localeService, kilogramPipe, messageService, datePipe);
@@ -7361,10 +7387,11 @@ let ModalInvoicePjForFixationComponent = class ModalInvoicePjForFixationComponen
7361
7387
  this.messageService = messageService;
7362
7388
  this.datePipe = datePipe;
7363
7389
  this.whenSelectInvoices = new EventEmitter();
7390
+ registerLocaleData(localePt);
7364
7391
  }
7365
7392
  ngOnInit() {
7366
7393
  this.defineGridColumns();
7367
- this.gridFieldValuesMap = Object.assign(Object.assign({}, this.gridFieldValuesMap), { series: (row) => (row === null || row === void 0 ? void 0 : row.seriesLegal) || (row === null || row === void 0 ? void 0 : row.series) || row.series, totalValue: (row) => this.currencyPipe.transform((row === null || row === void 0 ? void 0 : row.netTotalValue) || 0, 'BRL') });
7394
+ this.gridFieldValuesMap = Object.assign(Object.assign({}, this.gridFieldValuesMap), { series: (row) => (row === null || row === void 0 ? void 0 : row.seriesLegal) || (row === null || row === void 0 ? void 0 : row.series) || row.series, totalValue: (row) => this.currencyPipe.transform(this.getTotalValue(row) || 0, 'BRL', 'symbol', undefined, 'pt-BR'), linkedValue: (row) => this.currencyPipe.transform((row === null || row === void 0 ? void 0 : row.linkedValue) || 0, 'BRL', 'symbol', undefined, 'pt-BR') });
7368
7395
  super.ngOnInit();
7369
7396
  }
7370
7397
  defineGridColumns() {
@@ -7386,7 +7413,7 @@ let ModalInvoicePjForFixationComponent = class ModalInvoicePjForFixationComponen
7386
7413
  }
7387
7414
  beforeAdd(selectedInvoices) {
7388
7415
  if (selectedInvoices === null || selectedInvoices === void 0 ? void 0 : selectedInvoices.length) {
7389
- this.linkSelectedInvoicesInFixationItem();
7416
+ this.linkSelectedInvoicesInFixationItem(selectedInvoices);
7390
7417
  }
7391
7418
  return of(EMPTY).toPromise();
7392
7419
  }
@@ -7401,14 +7428,14 @@ let ModalInvoicePjForFixationComponent = class ModalInvoicePjForFixationComponen
7401
7428
  }
7402
7429
  super.open();
7403
7430
  }
7404
- linkSelectedInvoicesInFixationItem() {
7431
+ linkSelectedInvoicesInFixationItem(selectedInvoices) {
7405
7432
  return __awaiter(this, void 0, void 0, function* () {
7406
- if (!(yield this.isValidAndSetLinkedValueInInvoices())) {
7433
+ if (!(yield this.isValidAndSetLinkedValueInInvoices(selectedInvoices))) {
7407
7434
  this.gridLoading = false;
7408
7435
  return;
7409
7436
  }
7410
7437
  const entities = []
7411
- .concat(...this.selected.map((invoice) => {
7438
+ .concat(...selectedInvoices.map((invoice) => {
7412
7439
  return this.options.fixationItems.map((fixationItem) => {
7413
7440
  const requiredValue = (fixationItem.requiredValue || 0) - (fixationItem.totalValueInvoices || 0);
7414
7441
  if (invoice.remainingValue <= 0 || requiredValue <= 0) {
@@ -7419,11 +7446,11 @@ let ModalInvoicePjForFixationComponent = class ModalInvoicePjForFixationComponen
7419
7446
  const body = {
7420
7447
  series: invoice === null || invoice === void 0 ? void 0 : invoice.series,
7421
7448
  number: String(invoice === null || invoice === void 0 ? void 0 : invoice.number),
7422
- invoiceId: invoice === null || invoice === void 0 ? void 0 : invoice.id,
7449
+ externalInvoiceId: invoice === null || invoice === void 0 ? void 0 : invoice.externalInvoiceId,
7423
7450
  linkedValue: valueToBeLinked,
7424
- totalValue: invoice === null || invoice === void 0 ? void 0 : invoice.totalValue,
7451
+ totalValue: this.getTotalValue(invoice),
7425
7452
  issuanceDate: invoice === null || invoice === void 0 ? void 0 : invoice.issuanceDate,
7426
- fixationItem,
7453
+ fixationItem: { id: fixationItem === null || fixationItem === void 0 ? void 0 : fixationItem.id },
7427
7454
  };
7428
7455
  fixationItem.totalValueInvoices = (fixationItem.totalValueInvoices || 0) + valueToBeLinked;
7429
7456
  return body;
@@ -7447,13 +7474,19 @@ let ModalInvoicePjForFixationComponent = class ModalInvoicePjForFixationComponen
7447
7474
  });
7448
7475
  });
7449
7476
  }
7450
- isValidAndSetLinkedValueInInvoices() {
7477
+ isValidAndSetLinkedValueInInvoices(selectedInvoices) {
7451
7478
  return __awaiter(this, void 0, void 0, function* () {
7452
- const valorLinked = yield this.producerInvoiceService.getTotalLinkedInInvoices(this.selected.map((invoice) => invoice.id), this.options.fixationId);
7479
+ const valorLinked = yield this.producerInvoiceService.getTotalLinkedInInvoices(selectedInvoices.map((invoice) => invoice.externalInvoiceId), this.options.fixationId);
7480
+ selectedInvoices.forEach((invoice) => {
7481
+ if (!invoice.totalValue) {
7482
+ invoice.totalValue = this.getTotalValue(invoice);
7483
+ }
7484
+ });
7453
7485
  let isValid = true;
7454
- this.selected.forEach((invoice) => {
7486
+ selectedInvoices.forEach((invoice) => {
7455
7487
  var _a;
7456
- invoice.linkedValue = ((_a = valorLinked.find((linked) => linked.invoiceId === invoice.id)) === null || _a === void 0 ? void 0 : _a.totalLinked) || 0;
7488
+ invoice.linkedValue =
7489
+ ((_a = valorLinked.find((linked) => linked.externalInvoiceId === invoice.externalInvoiceId)) === null || _a === void 0 ? void 0 : _a.totalLinked) || 0;
7457
7490
  if (invoice.linkedValue >= invoice.totalValue) {
7458
7491
  this.messageService.add({
7459
7492
  severity: 'warn',
@@ -7468,24 +7501,25 @@ let ModalInvoicePjForFixationComponent = class ModalInvoicePjForFixationComponen
7468
7501
  });
7469
7502
  }
7470
7503
  adaptResult(result) {
7504
+ var _a;
7471
7505
  return __awaiter(this, void 0, void 0, function* () {
7472
- return Promise.resolve(result);
7506
+ return yield this.updateLinkedValueInGrid(((_a = result === null || result === void 0 ? void 0 : result.result) === null || _a === void 0 ? void 0 : _a.invoices) || []);
7473
7507
  });
7474
7508
  }
7475
7509
  cancel() {
7476
7510
  this.options.fixationItems = [];
7477
7511
  return super.cancel();
7478
7512
  }
7479
- updateLinkedValueInGrid(rows) {
7513
+ updateLinkedValueInGrid(result) {
7480
7514
  return __awaiter(this, void 0, void 0, function* () {
7481
- const invoiceId = this.gridData.map((invoice) => invoice.id);
7515
+ const externalInvoiceId = result.map((invoice) => invoice.externalInvoiceId);
7482
7516
  let filter = `fixationItem.fixation.id eq '${this.options.fixationId}'`;
7483
- if (invoiceId && invoiceId.length > 0) {
7484
- filter += `and invoiceId in ('${invoiceId.join("','")}') `;
7517
+ if (externalInvoiceId && externalInvoiceId.length > 0) {
7518
+ filter += `and externalInvoiceId in ('${externalInvoiceId.join("','")}') `;
7485
7519
  }
7486
7520
  const listParams = {
7487
7521
  page: 0,
7488
- size: rows,
7522
+ size: result.length,
7489
7523
  filterQuery: filter,
7490
7524
  };
7491
7525
  yield this.producerInvoiceService
@@ -7494,14 +7528,23 @@ let ModalInvoicePjForFixationComponent = class ModalInvoicePjForFixationComponen
7494
7528
  .toPromise()
7495
7529
  .then((producerInvoices) => {
7496
7530
  producerInvoices === null || producerInvoices === void 0 ? void 0 : producerInvoices.contents.forEach((invoice) => {
7497
- const gridInvoice = this.gridData.find((item) => item.id === invoice.invoiceId);
7498
- if (gridInvoice) {
7499
- gridInvoice.linkedValue = invoice.linkedValue;
7500
- }
7531
+ var _a;
7532
+ (_a = result
7533
+ .filter((item) => item.externalInvoiceId === invoice.externalInvoiceId)) === null || _a === void 0 ? void 0 : _a.forEach((linkedInvoice) => {
7534
+ linkedInvoice.linkedValue = invoice.linkedValue;
7535
+ });
7501
7536
  });
7502
7537
  });
7503
7538
  });
7504
7539
  }
7540
+ getTotalValue(row) {
7541
+ const netTotalValue = row === null || row === void 0 ? void 0 : row.netTotalValue;
7542
+ if (netTotalValue) {
7543
+ return netTotalValue;
7544
+ }
7545
+ const items = (row === null || row === void 0 ? void 0 : row.items) || [];
7546
+ return items.reduce((total, item) => total + (item.unitPrice || 0) * (item.quantity || 0), 0);
7547
+ }
7505
7548
  };
7506
7549
  ModalInvoicePjForFixationComponent.ctorParameters = () => [
7507
7550
  { type: LibTranslationService },
@@ -7509,7 +7552,7 @@ ModalInvoicePjForFixationComponent.ctorParameters = () => [
7509
7552
  { type: LocaleService },
7510
7553
  { type: KilogramPipe },
7511
7554
  { type: CurrencyPipe },
7512
- { type: ProducerInvoiceService },
7555
+ { type: ProducerInvoiceService$1 },
7513
7556
  { type: MessageService$1 },
7514
7557
  { type: DatePipe }
7515
7558
  ];