@seniorsistemas/yms-integration 1.30.1 → 1.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/bundles/seniorsistemas-yms-integration.umd.js +113 -83
  2. package/bundles/seniorsistemas-yms-integration.umd.js.map +1 -1
  3. package/bundles/seniorsistemas-yms-integration.umd.min.js +1 -1
  4. package/bundles/seniorsistemas-yms-integration.umd.min.js.map +1 -1
  5. package/esm2015/src/erp-senior/components/nota-form/nota-form.component.js +21 -18
  6. package/esm2015/src/wms/components/document-grid/document-grid.component.js +26 -16
  7. package/esm2015/src/wms/components/document-grid/insert-key/insert-key.component.js +30 -7
  8. package/esm2015/src/wms/components/document-grid/insert-key/insert-key.module.js +6 -5
  9. package/esm2015/src/wms/components/document-grid/register-document/register-document.component.js +5 -14
  10. package/esm5/src/erp-senior/components/nota-form/nota-form.component.js +21 -18
  11. package/esm5/src/wms/components/document-grid/document-grid.component.js +27 -16
  12. package/esm5/src/wms/components/document-grid/insert-key/insert-key.component.js +30 -7
  13. package/esm5/src/wms/components/document-grid/insert-key/insert-key.module.js +6 -5
  14. package/esm5/src/wms/components/document-grid/register-document/register-document.component.js +5 -14
  15. package/fesm2015/seniorsistemas-yms-integration.js +108 -79
  16. package/fesm2015/seniorsistemas-yms-integration.js.map +1 -1
  17. package/fesm5/seniorsistemas-yms-integration.js +113 -83
  18. package/fesm5/seniorsistemas-yms-integration.js.map +1 -1
  19. package/package.json +1 -1
  20. package/seniorsistemas-yms-integration.metadata.json +1 -1
  21. package/src/erp-senior/components/nota-form/nota-form.component.d.ts +3 -6
  22. package/src/wms/components/document-grid/document-grid.component.d.ts +5 -5
  23. package/src/wms/components/document-grid/insert-key/insert-key.component.d.ts +4 -2
  24. package/src/wms/components/document-grid/register-document/register-document.component.d.ts +2 -3
@@ -2886,47 +2886,6 @@ FormWmsComponent = __decorate([
2886
2886
  __metadata("design:paramtypes", [IntegrationEventsCallback, FormWmsService])
2887
2887
  ], FormWmsComponent);
2888
2888
 
2889
- let IntegrationService = class IntegrationService {
2890
- constructor(httpClient) {
2891
- this.httpClient = httpClient;
2892
- }
2893
- getProcessTypeByScheduling(idSchedulingType) {
2894
- return this.httpClient.post('yms/integration/queries/getProcessTypeByScheduling', { idSchedulingType });
2895
- }
2896
- };
2897
- IntegrationService.ngInjectableDef = defineInjectable({ factory: function IntegrationService_Factory() { return new IntegrationService(inject(HttpClient)); }, token: IntegrationService, providedIn: "root" });
2898
- IntegrationService = __decorate([
2899
- Injectable({ providedIn: 'root' }),
2900
- __metadata("design:paramtypes", [HttpClient])
2901
- ], IntegrationService);
2902
- var ProcessType;
2903
- (function (ProcessType) {
2904
- ProcessType["RECEBIMENTO_CONTRATO"] = "RECEBIMENTO_CONTRATO";
2905
- ProcessType["RECEBIMENTO_ORDEM_COMPRA"] = "RECEBIMENTO_ORDEM_COMPRA";
2906
- ProcessType["EXPEDICAO"] = "EXPEDICAO";
2907
- ProcessType["DEVOLUCAO"] = "DEVOLUCAO";
2908
- ProcessType["PROCESSO_AVULSO"] = "PROCESSO_AVULSO";
2909
- ProcessType["RECEBIMENTO_WMS"] = "RECEBIMENTO_WMS";
2910
- })(ProcessType || (ProcessType = {}));
2911
-
2912
- let DocumentService = class DocumentService extends EntityService {
2913
- constructor(http, messageService) {
2914
- super(http, messageService, 'yms_int/wms/entities/document', '');
2915
- this.http = http;
2916
- this.messageService = messageService;
2917
- }
2918
- findDocuments(input) {
2919
- return this.http.post('yms_int/wms/queries/findDocuments', input);
2920
- }
2921
- getSystemIntegration() {
2922
- return this.http.get('yms_int/wms/queries/getSystemIntegration');
2923
- }
2924
- };
2925
- DocumentService = __decorate([
2926
- Injectable(),
2927
- __metadata("design:paramtypes", [HttpClient, MessageService])
2928
- ], DocumentService);
2929
-
2930
2889
  class EntityService$1 {
2931
2890
  constructor(http, messageService, entityUrl, actionsUrl) {
2932
2891
  this.http = http;
@@ -3039,6 +2998,47 @@ AgendaService = __decorate([
3039
2998
  __metadata("design:paramtypes", [HttpClient, MessageService$1])
3040
2999
  ], AgendaService);
3041
3000
 
3001
+ let DocumentService = class DocumentService extends EntityService {
3002
+ constructor(http, messageService) {
3003
+ super(http, messageService, 'yms_int/wms/entities/document', '');
3004
+ this.http = http;
3005
+ this.messageService = messageService;
3006
+ }
3007
+ findDocuments(input) {
3008
+ return this.http.post('yms_int/wms/queries/findDocuments', input);
3009
+ }
3010
+ getSystemIntegration() {
3011
+ return this.http.get('yms_int/wms/queries/getSystemIntegration');
3012
+ }
3013
+ };
3014
+ DocumentService = __decorate([
3015
+ Injectable(),
3016
+ __metadata("design:paramtypes", [HttpClient, MessageService])
3017
+ ], DocumentService);
3018
+
3019
+ let IntegrationService = class IntegrationService {
3020
+ constructor(httpClient) {
3021
+ this.httpClient = httpClient;
3022
+ }
3023
+ getProcessTypeByScheduling(idSchedulingType) {
3024
+ return this.httpClient.post('yms/integration/queries/getProcessTypeByScheduling', { idSchedulingType });
3025
+ }
3026
+ };
3027
+ IntegrationService.ngInjectableDef = defineInjectable({ factory: function IntegrationService_Factory() { return new IntegrationService(inject(HttpClient)); }, token: IntegrationService, providedIn: "root" });
3028
+ IntegrationService = __decorate([
3029
+ Injectable({ providedIn: 'root' }),
3030
+ __metadata("design:paramtypes", [HttpClient])
3031
+ ], IntegrationService);
3032
+ var ProcessType;
3033
+ (function (ProcessType) {
3034
+ ProcessType["RECEBIMENTO_CONTRATO"] = "RECEBIMENTO_CONTRATO";
3035
+ ProcessType["RECEBIMENTO_ORDEM_COMPRA"] = "RECEBIMENTO_ORDEM_COMPRA";
3036
+ ProcessType["EXPEDICAO"] = "EXPEDICAO";
3037
+ ProcessType["DEVOLUCAO"] = "DEVOLUCAO";
3038
+ ProcessType["PROCESSO_AVULSO"] = "PROCESSO_AVULSO";
3039
+ ProcessType["RECEBIMENTO_WMS"] = "RECEBIMENTO_WMS";
3040
+ })(ProcessType || (ProcessType = {}));
3041
+
3042
3042
  let DocumentGridComponent = class DocumentGridComponent {
3043
3043
  constructor(translate, documentService, messageService, confirmationService, integrationService, agendaService) {
3044
3044
  this.translate = translate;
@@ -3056,7 +3056,7 @@ let DocumentGridComponent = class DocumentGridComponent {
3056
3056
  ngOnInit() {
3057
3057
  this.verifyClienteExterno();
3058
3058
  this.getProcessTypeByScheduling();
3059
- this.listDocuments();
3059
+ this.listDocuments(false);
3060
3060
  }
3061
3061
  ngAfterContentChecked() {
3062
3062
  this.gridColumns = this.getGridColumns();
@@ -3073,8 +3073,17 @@ let DocumentGridComponent = class DocumentGridComponent {
3073
3073
  .subscribe((result) => this.processType = result.processType);
3074
3074
  }
3075
3075
  onChangeDocument(document) {
3076
+ const duplicateDocument = this.gridData.find(gridData => gridData.key === document.key);
3077
+ if (duplicateDocument) {
3078
+ this.message("error", "yms.int.wms_error_register_document_message_title", "yms.int.wms_error_register_document_message_description");
3079
+ this.selection[0] = document;
3080
+ this.visibleDocumentRegister = true;
3081
+ return;
3082
+ }
3076
3083
  this.gridData.push(document);
3077
3084
  this.disabled = false;
3085
+ this.message("success", "yms.int.wms_saved_document_message_title", "yms.int.wms_success_message_description");
3086
+ this.visibleDocumentRegister = false;
3078
3087
  }
3079
3088
  cantEditStatus() {
3080
3089
  const cantEditStatus = [
@@ -3133,9 +3142,10 @@ let DocumentGridComponent = class DocumentGridComponent {
3133
3142
  }
3134
3143
  data.key = this.updateKeyByWms(data);
3135
3144
  this.documentService.insert(data).subscribe(() => {
3136
- this.message("success", "saved_message_title", "saved_message_content");
3145
+ this.message("success", "yms.int.wms_saved_document_message_title", "saved_message_content");
3137
3146
  });
3138
3147
  this.disabled = true;
3148
+ this.listDocuments(false);
3139
3149
  }
3140
3150
  });
3141
3151
  }
@@ -3166,8 +3176,7 @@ let DocumentGridComponent = class DocumentGridComponent {
3166
3176
  summary: this.translate.instant("deleted_message_title"),
3167
3177
  detail: this.translate.instant("deleted_message_content"),
3168
3178
  });
3169
- this.gridData = [];
3170
- this.listDocuments();
3179
+ this.listDocuments(true);
3171
3180
  });
3172
3181
  }
3173
3182
  });
@@ -3175,25 +3184,27 @@ let DocumentGridComponent = class DocumentGridComponent {
3175
3184
  removeDocumentIfIdUndfined() {
3176
3185
  this.selection.forEach((value, index) => {
3177
3186
  if (!value.id) {
3178
- this.gridData.splice(index, 1);
3187
+ const indexGridData = this.gridData.findIndex(document => document.key === value.key);
3188
+ this.gridData.splice(indexGridData, 1);
3179
3189
  this.selection.splice(index, 1);
3180
3190
  }
3181
3191
  });
3182
3192
  }
3183
- listDocuments() {
3193
+ listDocuments(isDelete) {
3184
3194
  this.documentService.list({
3185
3195
  filterQuery: `schedulingId eq '${this.agenda.id}'`
3186
3196
  })
3187
3197
  .subscribe((contents) => {
3188
- this.gridData = [];
3198
+ this.gridData = isDelete ? this.gridData.filter(item => !item.id) : [];
3189
3199
  if (contents.totalElements > 0) {
3190
- this.gridData = contents.contents;
3200
+ this.gridData.push(...contents.contents);
3191
3201
  this.documentTotalRecords = contents.totalElements;
3192
3202
  }
3193
3203
  else {
3194
3204
  this.documentTotalRecords = this.gridData.length;
3195
3205
  }
3196
- this.disabled = true;
3206
+ const hasElementWithoutId = this.gridData.some(item => !item.id);
3207
+ this.disabled = !hasElementWithoutId;
3197
3208
  this.loading = false;
3198
3209
  });
3199
3210
  }
@@ -3290,7 +3301,7 @@ __decorate([
3290
3301
  DocumentGridComponent = __decorate([
3291
3302
  Component({
3292
3303
  selector: 'document-grid',
3293
- template: "<div *ngIf=\"this.processType === 'RECEBIMENTO_WMS'; else processNotConfigured\">\n <p-panel>\n <p-header>\n <div class=\"buttons\">\n <div>\n <s-button\n label=\"{{'yms.int.wms_add_document' | translate}}\"\n priority=\"primary\"\n [model]=\"getActions()\"\n [auxiliary]=\"false\"\n [disabled]=\"!enableButtonIsClienteExterno\">\n </s-button>\n <s-button\n label=\"{{'yms.wms_view_button' | translate}}\"\n priority=\"secondary\"\n [auxiliary]=\"false\"\n [disabled]=\"!selection || selection.length !== 1\"\n (onClick)=\"view()\">\n </s-button>\n <s-button\n label=\"{{'yms.wms_delete_button' | translate}}\"\n priority=\"secondary\"\n [disabled]=\"!selection || !selection.length || !enableButtonIsClienteExterno\"\n (click)=\"onDelete()\">\n </s-button>\n </div>\n <s-button\n id=\"refresh-button\"\n priority=\"default\"\n iconClass=\"fa fa-refresh\"\n (onClick)=\"listDocuments()\"\n >\n </s-button>\n </div>\n </p-header>\n <div class=\"ui-g\">\n <div class=\"ui-g-12\" *ngIf=\"gridData && gridData.length; else emptyList\">\n <p-table #documentTable [value]=\"gridData\"\n [columns]=\"gridColumns\" dataKey=\"id\" [lazy]=\"true\" [scrollable]=\"true\" [resizableColumns]=\"true\"\n sortMode=\"multiple\" [paginator]=\"true\" [totalRecords]=\"documentTotalRecords\" rows=\"10\"\n [rowsPerPageOptions]=\"[10, 20, 50, 100]\" [(selection)]=\"selection\"\n [loading]=\"loading\">\n <ng-template pTemplate=\"colgroup\" let-columns>\n <colgroup>\n <col *ngFor=\"let col of columns\" [style.width]=\"col.width\"/>\n </colgroup>\n </ng-template>\n <ng-template pTemplate=\"header\" let-columns>\n <tr>\n <th id=\"checkbox\" class=\"table-checkbox\">\n <p-tableHeaderCheckbox></p-tableHeaderCheckbox>\n </th>\n <th id=\"col\" *ngFor=\"let col of columns\" [pSortableColumn]=\"col.field\" pResizableColumn>\n <div class=\"senior-header\">\n <span class=\"senior-header-title\">{{ col.header }}</span>\n <p-sortIcon [field]=\"col.field\"></p-sortIcon>\n </div>\n </th>\n </tr>\n </ng-template>\n <ng-template pTemplate=\"body\" let-rowData let-columns let-expanded=\"expanded\">\n <tr [pSelectableRow]=\"rowData\">\n <td class=\"table-checkbox\">\n <p-tableCheckbox [value]=\"rowData\"></p-tableCheckbox>\n </td>\n <td *ngFor=\"let column of getGridColumns()\" (click)=\"selection = [rowData]\">\n <span>{{ rowData[ column.field ] }}</span>\n </td>\n </tr>\n </ng-template>\n <ng-template pTemplate=\"paginatorright\">\n <span [translate]=\"'total_records'\" [translateParams]=\"{ value: documentTotalRecords }\"></span>\n </ng-template>\n </p-table> \n </div>\n </div>\n <register-document\n [wmsSystem]=\"wmsSystem\"\n [edit]=\"edit\"\n [viewDocument]=\"selection\"\n (document)=\"onChangeDocument($event)\"\n [(visible)]=\"visibleDocumentRegister\"\n [agenda]=\"agenda\">\n </register-document> \n <insert-key [wmsSystem]=\"wmsSystem\" \n (document)=\"onChangeDocument($event)\" [(visible)]=\"visibleInvoiceKey\"></insert-key>\n </p-panel>\n</div>\n <div class=\"button-save\">\n <s-button \n priority=\"primary\" [label]=\"'save' | translate\"\n [disabled]=\"disabled || !this.gridData || !enableButtonIsClienteExterno\"\n (click)=\"save()\">\n </s-button>\n </div>\n <register-document\n [wmsSystem]=\"wmsSystem\"\n [edit]=\"edit\"\n [viewDocument]=\"selection\"\n (document)=\"onChangeDocument($event)\"\n [(visible)]=\"visibleDocumentRegister\"\n [agenda]=\"agenda\">\n </register-document> \n <insert-key [wmsSystem]=\"wmsSystem\" \n (document)=\"onChangeDocument($event)\" [(visible)]=\"visibleInvoiceKey\"></insert-key>\n\n<ng-template #emptyList>\n <div class=\"center\">\n <s-empty-state\n iconClass=\"fa fa-exclamation-triangle\" [title]=\"'detail_empty_state_title' | translate\"\n [description]=\"'detail_empty_state_description' | translate\">\n </s-empty-state>\n </div>\n</ng-template>\n\n<ng-template #processNotConfigured>\n <div class=\"center\">\n <s-empty-state\n iconClass=\"fa fa-exclamation-triangle\"\n [title]=\"'yms.int.wms_there_no_process_type_configured_for_this_type_scheduling' | translate\"\n >\n </s-empty-state>\n </div>\n</ng-template>",
3304
+ template: "<div *ngIf=\"this.processType === 'RECEBIMENTO_WMS'; else processNotConfigured\">\n <p-panel>\n <p-header>\n <div class=\"buttons\">\n <div>\n <s-button\n label=\"{{'yms.int.wms_add_document' | translate}}\"\n priority=\"primary\"\n [model]=\"getActions()\"\n [auxiliary]=\"false\"\n [disabled]=\"!enableButtonIsClienteExterno\">\n </s-button>\n <s-button\n label=\"{{'yms.wms_view_button' | translate}}\"\n priority=\"secondary\"\n [auxiliary]=\"false\"\n [disabled]=\"!selection || selection.length !== 1\"\n (onClick)=\"view()\">\n </s-button>\n <s-button\n label=\"{{'yms.wms_delete_button' | translate}}\"\n priority=\"secondary\"\n [disabled]=\"!selection || !selection.length || !enableButtonIsClienteExterno\"\n (click)=\"onDelete()\">\n </s-button>\n </div>\n <s-button\n id=\"refresh-button\"\n priority=\"default\"\n iconClass=\"fa fa-refresh\"\n (onClick)=\"listDocuments(false)\"\n >\n </s-button>\n </div>\n </p-header>\n <div class=\"ui-g\">\n <div class=\"ui-g-12\" *ngIf=\"gridData && gridData.length; else emptyList\">\n <p-table #documentTable [value]=\"gridData\"\n [columns]=\"gridColumns\" dataKey=\"key\" [lazy]=\"true\" [scrollable]=\"true\" [resizableColumns]=\"true\"\n sortMode=\"multiple\" [paginator]=\"true\" [totalRecords]=\"documentTotalRecords\" rows=\"10\"\n [rowsPerPageOptions]=\"[10, 20, 50, 100]\" [(selection)]=\"selection\"\n [loading]=\"loading\">\n <ng-template pTemplate=\"colgroup\" let-columns>\n <colgroup>\n <col *ngFor=\"let col of columns\" [style.width]=\"col.width\"/>\n </colgroup>\n </ng-template>\n <ng-template pTemplate=\"header\" let-columns>\n <tr>\n <th id=\"checkbox\" class=\"table-checkbox\">\n <p-tableHeaderCheckbox></p-tableHeaderCheckbox>\n </th>\n <th id=\"col\" *ngFor=\"let col of columns\" [pSortableColumn]=\"col.field\" pResizableColumn>\n <div class=\"senior-header\">\n <span class=\"senior-header-title\">{{ col.header }}</span>\n <p-sortIcon [field]=\"col.field\"></p-sortIcon>\n </div>\n </th>\n </tr>\n </ng-template>\n <ng-template pTemplate=\"body\" let-rowData let-columns let-expanded=\"expanded\">\n <tr [pSelectableRow]=\"rowData\">\n <td class=\"table-checkbox\">\n <p-tableCheckbox [value]=\"rowData\"></p-tableCheckbox>\n </td>\n <td *ngFor=\"let column of getGridColumns()\" (click)=\"selection = [rowData]\">\n <span>{{ rowData[ column.field ] }}</span>\n </td>\n </tr>\n </ng-template>\n <ng-template pTemplate=\"paginatorright\">\n <span [translate]=\"'total_records'\" [translateParams]=\"{ value: documentTotalRecords }\"></span>\n </ng-template>\n </p-table> \n </div>\n </div>\n <register-document\n [wmsSystem]=\"wmsSystem\"\n [edit]=\"edit\"\n [viewDocument]=\"selection\"\n (document)=\"onChangeDocument($event)\"\n [(visible)]=\"visibleDocumentRegister\"\n [agenda]=\"agenda\">\n </register-document> \n <insert-key [wmsSystem]=\"wmsSystem\" \n (document)=\"onChangeDocument($event)\" [(visible)]=\"visibleInvoiceKey\"></insert-key>\n </p-panel>\n</div>\n <div class=\"button-save\">\n <s-button \n priority=\"primary\" [label]=\"'save' | translate\"\n [disabled]=\"disabled || !this.gridData || !enableButtonIsClienteExterno\"\n (click)=\"save()\">\n </s-button>\n </div>\n <register-document\n [wmsSystem]=\"wmsSystem\"\n [edit]=\"edit\"\n [viewDocument]=\"selection\"\n (document)=\"onChangeDocument($event)\"\n [(visible)]=\"visibleDocumentRegister\"\n [agenda]=\"agenda\">\n </register-document> \n <insert-key [wmsSystem]=\"wmsSystem\" \n (document)=\"onChangeDocument($event)\" [(visible)]=\"visibleInvoiceKey\"></insert-key>\n\n<ng-template #emptyList>\n <div class=\"center\">\n <s-empty-state\n iconClass=\"fa fa-exclamation-triangle\" [title]=\"'detail_empty_state_title' | translate\"\n [description]=\"'detail_empty_state_description' | translate\">\n </s-empty-state>\n </div>\n</ng-template>\n\n<ng-template #processNotConfigured>\n <div class=\"center\">\n <s-empty-state\n iconClass=\"fa fa-exclamation-triangle\"\n [title]=\"'yms.int.wms_there_no_process_type_configured_for_this_type_scheduling' | translate\"\n >\n </s-empty-state>\n </div>\n</ng-template>",
3294
3305
  styles: [".buttons{display:flex;justify-content:space-between}.center{flex-direction:column;text-align:center}.ui-g{display:block}.button-save{margin:5px 0}#refresh-button{color:#fff}.table-checkbox{width:50px}"]
3295
3306
  }),
3296
3307
  __metadata("design:paramtypes", [TranslateService,
@@ -3368,7 +3379,6 @@ let RegisterDocumentComponent = class RegisterDocumentComponent {
3368
3379
  }
3369
3380
  close() {
3370
3381
  this.visibleChange.emit(false);
3371
- this.formGroup.reset();
3372
3382
  }
3373
3383
  setValuesFormGroup(document) {
3374
3384
  this.formGroup.get('key').setValue(document.key);
@@ -3407,24 +3417,16 @@ let RegisterDocumentComponent = class RegisterDocumentComponent {
3407
3417
  if (this.agenda.id !== undefined) {
3408
3418
  value.schedulingId = this.agenda.id;
3409
3419
  }
3410
- if (value.key === undefined) {
3420
+ if (value.key === undefined || value.key === null) {
3411
3421
  value.key = value.invoiceKey;
3412
3422
  if (this.isWmsWis()) {
3413
3423
  value.key = `${value.invoiceNumber}:${value.invoiceSerialNumber}:${value.partnerDocument}`;
3414
3424
  }
3415
3425
  }
3426
+ this.formGroup.reset();
3416
3427
  this.document.emit(Document.fromDto(value));
3417
- this.successMessage();
3418
- this.visibleChange.emit(false);
3419
3428
  }
3420
3429
  }
3421
- successMessage() {
3422
- this.messageService.add({
3423
- severity: "success",
3424
- summary: this.translateService.instant("yms.saved_message_title"),
3425
- detail: this.translateService.instant("yms.int.wms_success_message_description"),
3426
- });
3427
- }
3428
3430
  isWmsWis() {
3429
3431
  return this.wmsSystem === WmsSystem.WIS;
3430
3432
  }
@@ -3501,6 +3503,7 @@ let InsertKeyComponent = class InsertKeyComponent {
3501
3503
  this.document = new EventEmitter();
3502
3504
  this.visible = new EventEmitter();
3503
3505
  this.visibleChange = new EventEmitter();
3506
+ this.isLoading = false;
3504
3507
  }
3505
3508
  ngOnInit() {
3506
3509
  this.formGroup = this.formBuilder.group({
@@ -3518,10 +3521,10 @@ let InsertKeyComponent = class InsertKeyComponent {
3518
3521
  return this.wmsSystem === WmsSystem.SENIOR_CONNECT;
3519
3522
  }
3520
3523
  add() {
3521
- this.visibleChange.emit(false);
3522
3524
  this.searchKey();
3523
3525
  }
3524
3526
  searchKey() {
3527
+ this.isLoading = true;
3525
3528
  const key = {
3526
3529
  documentKeys: [this.formGroup.get('key').value],
3527
3530
  invoices: [{
@@ -3533,8 +3536,25 @@ let InsertKeyComponent = class InsertKeyComponent {
3533
3536
  size: 0,
3534
3537
  offset: 0
3535
3538
  };
3536
- this.documentService.findDocuments(key).subscribe((content) => {
3537
- if (content.totalElements < 1) {
3539
+ this.documentService.findDocuments(key)
3540
+ .pipe(catchError(err => {
3541
+ if (err.error && err.error.message.includes("404")) {
3542
+ this.message("error", "yms.int.wms_error_search_document_message_header", "yms.int.wms_error_search_document_not_found_message_content");
3543
+ }
3544
+ else {
3545
+ this.messageService.add({
3546
+ severity: "error",
3547
+ summary: this.translate.instant("yms.int.wms_error_search_document_message_header"),
3548
+ detail: this.translate.instant("yms.int.wms_error_unknown_search_document_message_content") + err.error.message,
3549
+ });
3550
+ }
3551
+ return throwError(err);
3552
+ }), finalize(() => {
3553
+ this.isLoading = false;
3554
+ }))
3555
+ .subscribe((content) => {
3556
+ this.visibleChange.emit(false);
3557
+ if (!content || content.totalElements < 1) {
3538
3558
  this.message("warn", "yms.int.wms_insert_key_warning_message_header", "yms.int.wms_insert_key_warning_message_description");
3539
3559
  return;
3540
3560
  }
@@ -3553,6 +3573,9 @@ let InsertKeyComponent = class InsertKeyComponent {
3553
3573
  cancel() {
3554
3574
  this.visibleChange.emit(false);
3555
3575
  }
3576
+ onDialogShow() {
3577
+ this.formGroup.reset();
3578
+ }
3556
3579
  };
3557
3580
  __decorate([
3558
3581
  Output(),
@@ -3573,7 +3596,7 @@ __decorate([
3573
3596
  InsertKeyComponent = __decorate([
3574
3597
  Component({
3575
3598
  selector: "insert-key",
3576
- template: "<form [formGroup]=\"formGroup\">\n <p-dialog [(visible)]=\"visible\" [modal]=\"true\" [draggable]=\"false\" (visibleChange)=\"cancel()\">\n <p-header>{{'yms.int.wms_search_document' | translate}} {{ wmsSystem }}</p-header>\n <div class=\"flex py-2 justify-content-center spacing-bottom\" \n *ngIf=\"!isWmsSeniorConnect() && !isWmsWis()\">\n <label for=\"key\">{{'yms.int.wms_insert_key_label' | translate}}</label>\n <input id=\"key\" class=\"size-input\" pInputText type=\"text\" formControlName=\"key\">\n </div>\n <div class=\"flex py-2 justify-content-center spacing-bottom\" *ngIf=\"isWmsSeniorConnect()\">\n <label for=\"purchaseOrder\">{{'yms.int.wms_purchaseOrder' | translate}} </label>\n <input id=\"purchaseOrder\" class=\"size-input\" pInputText type=\"text\" formControlName=\"purchaseOrder\">\n </div>\n <div class=\"flex py-2 justify-content-center spacing-bottom\" *ngIf=\"isWmsWis()\">\n <label for=\"invoiceNumber\">{{'yms.int.wms_invoice_number' | translate}}</label>\n <input id=\"invoiceNumber\" class=\"size-input\" pInputText type=\"text\" formControlName=\"invoiceNumber\">\n </div>\n <div class=\"flex py-2 justify-content-center spacing-bottom\" *ngIf=\"isWmsWis()\">\n <label for=\"invoiceSerie\">{{'yms.int.wms_invoice_serie' | translate}}</label>\n <input id=\"invoiceSerie\" class=\"size-input\" pInputText type=\"text\" formControlName=\"invoiceSerie\">\n </div>\n <div class=\"flex py-2 justify-content-center spacing-bottom\" *ngIf=\"isWmsWis()\">\n <label for=\"partnerDocument\">{{'yms.int.wms_partner_document' | translate}}</label>\n <input id=\"partnerDocument\" class=\"size-input\" pInputText type=\"text\" formControlName=\"partnerDocument\">\n </div>\n <div class=\"separator\"></div>\n <div class=\"spacing-top\">\n <s-button pButton label=\"{{'yms.int.wms_search' | translate}}\" (click)=\"add()\"></s-button>\n <s-button\n type=\"button\"\n class=\"ui-button-link\"\n pButton label=\"{{'cancel' | translate}}\"\n (click)=\"cancel()\">\n </s-button>\n </div>\n </p-dialog>\n</form>",
3599
+ template: "<form [formGroup]=\"formGroup\">\n <p-dialog [(visible)]=\"visible\" [modal]=\"true\" \n [draggable]=\"false\" (visibleChange)=\"cancel()\" (onShow)=\"onDialogShow()\">\n <p-header>{{'yms.int.wms_search_document' | translate}} {{ wmsSystem }}</p-header>\n <s-loading-state [loading]=\"isLoading\">\n <div class=\"flex py-2 justify-content-center spacing-bottom\" \n *ngIf=\"!isWmsSeniorConnect() && !isWmsWis()\">\n <label for=\"key\">{{'yms.int.wms_insert_key_label' | translate}}</label>\n <input id=\"key\" class=\"size-input\" pInputText type=\"text\" formControlName=\"key\">\n </div>\n <div class=\"flex py-2 justify-content-center spacing-bottom\" *ngIf=\"isWmsSeniorConnect()\">\n <label for=\"purchaseOrder\">{{'yms.int.wms_purchaseOrder' | translate}} </label>\n <input id=\"purchaseOrder\" class=\"size-input\" pInputText type=\"text\" formControlName=\"purchaseOrder\">\n </div>\n <div class=\"flex py-2 justify-content-center spacing-bottom\" *ngIf=\"isWmsWis()\">\n <label for=\"invoiceNumber\">{{'yms.int.wms_invoice_number' | translate}}</label>\n <input id=\"invoiceNumber\" class=\"size-input\" pInputText type=\"text\" formControlName=\"invoiceNumber\">\n </div>\n <div class=\"flex py-2 justify-content-center spacing-bottom\" *ngIf=\"isWmsWis()\">\n <label for=\"invoiceSerie\">{{'yms.int.wms_invoice_serie' | translate}}</label>\n <input id=\"invoiceSerie\" class=\"size-input\" pInputText type=\"text\" formControlName=\"invoiceSerie\">\n </div>\n <div class=\"flex py-2 justify-content-center spacing-bottom\" *ngIf=\"isWmsWis()\">\n <label for=\"partnerDocument\">{{'yms.int.wms_partner_document' | translate}}</label>\n <input id=\"partnerDocument\" class=\"size-input\" pInputText type=\"text\" formControlName=\"partnerDocument\">\n </div>\n <div class=\"separator\"></div>\n <div class=\"spacing-top\">\n <s-button pButton label=\"{{'yms.int.wms_search' | translate}}\" (click)=\"add()\"></s-button>\n <s-button\n type=\"button\"\n class=\"ui-button-link\"\n pButton label=\"{{'cancel' | translate}}\"\n (click)=\"cancel()\">\n </s-button>\n </div>\n </s-loading-state>\n </p-dialog>\n\n</form>\n",
3577
3600
  styles: [".spacing-top{margin-top:10px}.spacing-bottom{margin-bottom:10px}.separator{width:100%;margin:5px 0;height:1px;background-color:#ccc}.size-input{width:480px}"]
3578
3601
  }),
3579
3602
  __metadata("design:paramtypes", [FormBuilder,
@@ -3592,7 +3615,8 @@ InsertKeyModule = __decorate([
3592
3615
  ButtonModule,
3593
3616
  TranslateModule,
3594
3617
  DialogModule,
3595
- InputTextModule$1
3618
+ InputTextModule$1,
3619
+ LoadingStateModule
3596
3620
  ],
3597
3621
  exports: [InsertKeyComponent],
3598
3622
  declarations: [InsertKeyComponent]
@@ -4690,18 +4714,22 @@ NotaValidatorService = __decorate([
4690
4714
  ], NotaValidatorService);
4691
4715
 
4692
4716
  let NotaFormComponent = class NotaFormComponent {
4693
- constructor(fb, notaValidatorService, dialogConfig, confirmationService, dialogRef, verificaNotaFiscal, messageService, translate) {
4717
+ constructor(fb, notaValidatorService, dialogConfig, confirmationService, dialogRef, verificaNotaFiscal) {
4694
4718
  this.notaValidatorService = notaValidatorService;
4695
4719
  this.dialogConfig = dialogConfig;
4696
4720
  this.confirmationService = confirmationService;
4697
4721
  this.dialogRef = dialogRef;
4698
4722
  this.verificaNotaFiscal = verificaNotaFiscal;
4699
- this.messageService = messageService;
4700
- this.translate = translate;
4701
4723
  this.loading = false;
4702
4724
  this.botaoDesabilitado = false;
4725
+ this.disabled = true;
4703
4726
  this.unsubscribe$ = new Subject();
4704
4727
  this.validateNotaFiscal = (response) => {
4728
+ const chaveNotaFiscal = this.formGroup.get("chaveNotaFiscal").value;
4729
+ if (chaveNotaFiscal.length === 0) {
4730
+ return;
4731
+ }
4732
+ this.disabled = false;
4705
4733
  if (!response || !response.documentos[0]) {
4706
4734
  return;
4707
4735
  }
@@ -4735,10 +4763,10 @@ let NotaFormComponent = class NotaFormComponent {
4735
4763
  return !!chave || !!serie || !!numero ? null : { erroMultiplosCampos: true };
4736
4764
  };
4737
4765
  this.formGroup = fb.group({
4738
- chaveNotaFiscal: [undefined],
4739
- serieNotaFiscal: [undefined],
4740
- serieLegalNotaFiscal: [undefined],
4741
- numeroNotaFiscal: [undefined],
4766
+ chaveNotaFiscal: [undefined, Validators.required],
4767
+ serieNotaFiscal: [undefined, Validators.required],
4768
+ serieLegalNotaFiscal: [undefined, Validators.required],
4769
+ numeroNotaFiscal: [undefined, Validators.required],
4742
4770
  }, { validators: this.camposPreenchidosValidation });
4743
4771
  }
4744
4772
  ngOnInit() {
@@ -4781,7 +4809,10 @@ let NotaFormComponent = class NotaFormComponent {
4781
4809
  chaveDocumento: (chaveNotaFiscal || "").replace(/\s/g, ""),
4782
4810
  filialId: this.filialId
4783
4811
  })
4784
- .pipe(takeUntil(this.unsubscribe$), finalize(() => this.loading = false))
4812
+ .pipe(takeUntil(this.unsubscribe$), catchError(() => {
4813
+ this.disabled = false;
4814
+ return of(null);
4815
+ }), finalize(() => this.loading = false))
4785
4816
  .subscribe(this.validateNotaFiscal);
4786
4817
  this.botaoDesabilitado = false;
4787
4818
  }
@@ -4839,7 +4870,7 @@ let NotaFormComponent = class NotaFormComponent {
4839
4870
  };
4840
4871
  NotaFormComponent = __decorate([
4841
4872
  Component({
4842
- template: "<form [formGroup]=\"formGroup\">\n <div class=\"ui-g ui-fluid\" *sLoadingState=\"loading\">\n <div class=\"ui-g-12\">\n <label for=\"chaveNotaFiscal\">{{'yms.erp.recebimento_chave_nota_fiscal' | translate}}</label>\n <input\n id=\"chaveNotaFiscal\"\n trim\n pInputText\n type=\"text\"\n formControlName=\"chaveNotaFiscal\"\n (blur)=\"onBlurNotaFiscal()\"\n >\n <s-control-errors [control]=\"formGroup.controls.chaveNotaFiscal\" [errorMessages]=\"{ errorChaveNota: 'yms.erp.produto_nota_error_detail' | translate }\"></s-control-errors>\n </div>\n <div class=\"ui-g-12\">\n <label for=\"serieNotaFiscal\">{{'yms.erp.recebimento_serie_nota_fiscal' | translate}}</label>\n <input pInputText type=\"text\" formControlName=\"serieNotaFiscal\">\n </div>\n <div class=\"ui-g-12\">\n <label for=\"serieLegalNotaFiscal\">{{'yms.erp.recebimento_serie_legal_nota_fiscal' | translate}}</label>\n <input pInputText type=\"text\" formControlName=\"serieLegalNotaFiscal\">\n </div>\n <div class=\"ui-g-12\">\n <label for=\"numeroNotaFiscal\">{{'yms.erp.recebimento_numero_nota_fiscal' | translate}}</label>\n <input pInputText type=\"text\" formControlName=\"numeroNotaFiscal\">\n </div>\n </div>\n\n <s-control-errors [control]=\"formGroup\" [errorMessages]=\"{ erroMultiplosCampos: 'yms.erp.nota_fiscal_no_value' | translate }\"></s-control-errors>\n\n <s-button label=\"Cancelar\" (onClick)=\"close()\" priority=\"link\"></s-button>\n <s-button label=\"Salvar\" [disabled]=\"botaoDesabilitado\" (onClick)=\"save()\"></s-button>\n</form>\n\n<p-confirmDialog appendTo=\"body\"></p-confirmDialog>",
4873
+ template: "<form [formGroup]=\"formGroup\">\n <div class=\"ui-g ui-fluid\" *sLoadingState=\"loading\">\n <div class=\"ui-g-12 required\">\n <label for=\"chaveNotaFiscal\">{{'yms.erp.recebimento_chave_nota_fiscal' | translate}}</label>\n <input\n id=\"chaveNotaFiscal\"\n trim\n pInputText\n type=\"text\"\n formControlName=\"chaveNotaFiscal\"\n (blur)=\"onBlurNotaFiscal()\"\n >\n <s-control-errors\n [control]=\"formGroup.controls.chaveNotaFiscal\"\n [errorMessages]=\"{ errorChaveNota: 'yms.erp.produto_nota_error_detail' | translate }\">\n </s-control-errors>\n </div>\n <div class=\"ui-g-12 required\" [attr.data-hidden]=\"disabled\">\n <label for=\"serieNotaFiscal\">{{'yms.erp.recebimento_serie_nota_fiscal' | translate}}</label>\n <input pInputText type=\"text\" formControlName=\"serieNotaFiscal\">\n <s-control-errors\n [control]=\"formGroup.controls['serieNotaFiscal']\"\n [errorMessages]=\"{ required: 'yms.erp.error_required' | translate }\">\n </s-control-errors>\n </div>\n <div class=\"ui-g-12 required\" [attr.data-hidden]=\"disabled\">\n <label for=\"serieLegalNotaFiscal\">{{'yms.erp.recebimento_serie_legal_nota_fiscal' | translate}}</label>\n <input pInputText type=\"text\" formControlName=\"serieLegalNotaFiscal\">\n <s-control-errors\n [control]=\"formGroup.controls['serieLegalNotaFiscal']\"\n [errorMessages]=\"{ required: 'yms.erp.error_required' | translate }\">\n </s-control-errors>\n </div>\n <div class=\"ui-g-12 required\" [attr.data-hidden]=\"disabled\">\n <label for=\"numeroNotaFiscal\">{{'yms.erp.recebimento_numero_nota_fiscal' | translate}}</label>\n <input pInputText type=\"text\" formControlName=\"numeroNotaFiscal\">\n <s-control-errors\n [control]=\"formGroup.controls['numeroNotaFiscal']\"\n [errorMessages]=\"{ required: 'yms.erp.error_required' | translate }\">\n </s-control-errors>\n </div>\n </div>\n\n <s-control-errors [control]=\"formGroup\" [errorMessages]=\"{ erroMultiplosCampos: 'yms.erp.nota_fiscal_no_value' | translate }\"></s-control-errors>\n\n <s-button label=\"Cancelar\" (onClick)=\"close()\" priority=\"link\"></s-button>\n <s-button label=\"Salvar\" [disabled]=\"botaoDesabilitado || disabled\" (onClick)=\"save()\"></s-button>\n</form>\n\n<p-confirmDialog appendTo=\"body\"></p-confirmDialog>",
4843
4874
  providers: [ConfirmationService]
4844
4875
  }),
4845
4876
  __metadata("design:paramtypes", [FormBuilder,
@@ -4847,9 +4878,7 @@ NotaFormComponent = __decorate([
4847
4878
  DynamicDialogConfig,
4848
4879
  ConfirmationService,
4849
4880
  DynamicDialogRef,
4850
- VerificaNotafiscal,
4851
- MessageService$1,
4852
- TranslateService])
4881
+ VerificaNotafiscal])
4853
4882
  ], NotaFormComponent);
4854
4883
 
4855
4884
  let TrimDirective = class TrimDirective {