@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
@@ -3093,51 +3093,6 @@ var FormWmsComponent = /** @class */ (function (_super) {
3093
3093
  return FormWmsComponent;
3094
3094
  }(FormWmsDescritor));
3095
3095
 
3096
- var IntegrationService = /** @class */ (function () {
3097
- function IntegrationService(httpClient) {
3098
- this.httpClient = httpClient;
3099
- }
3100
- IntegrationService.prototype.getProcessTypeByScheduling = function (idSchedulingType) {
3101
- return this.httpClient.post('yms/integration/queries/getProcessTypeByScheduling', { idSchedulingType: idSchedulingType });
3102
- };
3103
- IntegrationService.ngInjectableDef = defineInjectable({ factory: function IntegrationService_Factory() { return new IntegrationService(inject(HttpClient)); }, token: IntegrationService, providedIn: "root" });
3104
- IntegrationService = __decorate([
3105
- Injectable({ providedIn: 'root' }),
3106
- __metadata("design:paramtypes", [HttpClient])
3107
- ], IntegrationService);
3108
- return IntegrationService;
3109
- }());
3110
- var ProcessType;
3111
- (function (ProcessType) {
3112
- ProcessType["RECEBIMENTO_CONTRATO"] = "RECEBIMENTO_CONTRATO";
3113
- ProcessType["RECEBIMENTO_ORDEM_COMPRA"] = "RECEBIMENTO_ORDEM_COMPRA";
3114
- ProcessType["EXPEDICAO"] = "EXPEDICAO";
3115
- ProcessType["DEVOLUCAO"] = "DEVOLUCAO";
3116
- ProcessType["PROCESSO_AVULSO"] = "PROCESSO_AVULSO";
3117
- ProcessType["RECEBIMENTO_WMS"] = "RECEBIMENTO_WMS";
3118
- })(ProcessType || (ProcessType = {}));
3119
-
3120
- var DocumentService = /** @class */ (function (_super) {
3121
- __extends(DocumentService, _super);
3122
- function DocumentService(http, messageService) {
3123
- var _this = _super.call(this, http, messageService, 'yms_int/wms/entities/document', '') || this;
3124
- _this.http = http;
3125
- _this.messageService = messageService;
3126
- return _this;
3127
- }
3128
- DocumentService.prototype.findDocuments = function (input) {
3129
- return this.http.post('yms_int/wms/queries/findDocuments', input);
3130
- };
3131
- DocumentService.prototype.getSystemIntegration = function () {
3132
- return this.http.get('yms_int/wms/queries/getSystemIntegration');
3133
- };
3134
- DocumentService = __decorate([
3135
- Injectable(),
3136
- __metadata("design:paramtypes", [HttpClient, MessageService])
3137
- ], DocumentService);
3138
- return DocumentService;
3139
- }(EntityService));
3140
-
3141
3096
  var EntityService$1 = /** @class */ (function () {
3142
3097
  function EntityService(http, messageService, entityUrl, actionsUrl) {
3143
3098
  this.http = http;
@@ -3260,6 +3215,51 @@ var AgendaService = /** @class */ (function (_super) {
3260
3215
  return AgendaService;
3261
3216
  }(EntityService$2));
3262
3217
 
3218
+ var DocumentService = /** @class */ (function (_super) {
3219
+ __extends(DocumentService, _super);
3220
+ function DocumentService(http, messageService) {
3221
+ var _this = _super.call(this, http, messageService, 'yms_int/wms/entities/document', '') || this;
3222
+ _this.http = http;
3223
+ _this.messageService = messageService;
3224
+ return _this;
3225
+ }
3226
+ DocumentService.prototype.findDocuments = function (input) {
3227
+ return this.http.post('yms_int/wms/queries/findDocuments', input);
3228
+ };
3229
+ DocumentService.prototype.getSystemIntegration = function () {
3230
+ return this.http.get('yms_int/wms/queries/getSystemIntegration');
3231
+ };
3232
+ DocumentService = __decorate([
3233
+ Injectable(),
3234
+ __metadata("design:paramtypes", [HttpClient, MessageService])
3235
+ ], DocumentService);
3236
+ return DocumentService;
3237
+ }(EntityService));
3238
+
3239
+ var IntegrationService = /** @class */ (function () {
3240
+ function IntegrationService(httpClient) {
3241
+ this.httpClient = httpClient;
3242
+ }
3243
+ IntegrationService.prototype.getProcessTypeByScheduling = function (idSchedulingType) {
3244
+ return this.httpClient.post('yms/integration/queries/getProcessTypeByScheduling', { idSchedulingType: idSchedulingType });
3245
+ };
3246
+ IntegrationService.ngInjectableDef = defineInjectable({ factory: function IntegrationService_Factory() { return new IntegrationService(inject(HttpClient)); }, token: IntegrationService, providedIn: "root" });
3247
+ IntegrationService = __decorate([
3248
+ Injectable({ providedIn: 'root' }),
3249
+ __metadata("design:paramtypes", [HttpClient])
3250
+ ], IntegrationService);
3251
+ return IntegrationService;
3252
+ }());
3253
+ var ProcessType;
3254
+ (function (ProcessType) {
3255
+ ProcessType["RECEBIMENTO_CONTRATO"] = "RECEBIMENTO_CONTRATO";
3256
+ ProcessType["RECEBIMENTO_ORDEM_COMPRA"] = "RECEBIMENTO_ORDEM_COMPRA";
3257
+ ProcessType["EXPEDICAO"] = "EXPEDICAO";
3258
+ ProcessType["DEVOLUCAO"] = "DEVOLUCAO";
3259
+ ProcessType["PROCESSO_AVULSO"] = "PROCESSO_AVULSO";
3260
+ ProcessType["RECEBIMENTO_WMS"] = "RECEBIMENTO_WMS";
3261
+ })(ProcessType || (ProcessType = {}));
3262
+
3263
3263
  var DocumentGridComponent = /** @class */ (function () {
3264
3264
  function DocumentGridComponent(translate, documentService, messageService, confirmationService, integrationService, agendaService) {
3265
3265
  this.translate = translate;
@@ -3277,7 +3277,7 @@ var DocumentGridComponent = /** @class */ (function () {
3277
3277
  DocumentGridComponent.prototype.ngOnInit = function () {
3278
3278
  this.verifyClienteExterno();
3279
3279
  this.getProcessTypeByScheduling();
3280
- this.listDocuments();
3280
+ this.listDocuments(false);
3281
3281
  };
3282
3282
  DocumentGridComponent.prototype.ngAfterContentChecked = function () {
3283
3283
  this.gridColumns = this.getGridColumns();
@@ -3296,8 +3296,17 @@ var DocumentGridComponent = /** @class */ (function () {
3296
3296
  .subscribe(function (result) { return _this.processType = result.processType; });
3297
3297
  };
3298
3298
  DocumentGridComponent.prototype.onChangeDocument = function (document) {
3299
+ var duplicateDocument = this.gridData.find(function (gridData) { return gridData.key === document.key; });
3300
+ if (duplicateDocument) {
3301
+ this.message("error", "yms.int.wms_error_register_document_message_title", "yms.int.wms_error_register_document_message_description");
3302
+ this.selection[0] = document;
3303
+ this.visibleDocumentRegister = true;
3304
+ return;
3305
+ }
3299
3306
  this.gridData.push(document);
3300
3307
  this.disabled = false;
3308
+ this.message("success", "yms.int.wms_saved_document_message_title", "yms.int.wms_success_message_description");
3309
+ this.visibleDocumentRegister = false;
3301
3310
  };
3302
3311
  DocumentGridComponent.prototype.cantEditStatus = function () {
3303
3312
  var cantEditStatus = [
@@ -3358,9 +3367,10 @@ var DocumentGridComponent = /** @class */ (function () {
3358
3367
  }
3359
3368
  data.key = _this.updateKeyByWms(data);
3360
3369
  _this.documentService.insert(data).subscribe(function () {
3361
- _this.message("success", "saved_message_title", "saved_message_content");
3370
+ _this.message("success", "yms.int.wms_saved_document_message_title", "saved_message_content");
3362
3371
  });
3363
3372
  _this.disabled = true;
3373
+ _this.listDocuments(false);
3364
3374
  }
3365
3375
  });
3366
3376
  }
@@ -3392,8 +3402,7 @@ var DocumentGridComponent = /** @class */ (function () {
3392
3402
  summary: _this.translate.instant("deleted_message_title"),
3393
3403
  detail: _this.translate.instant("deleted_message_content"),
3394
3404
  });
3395
- _this.gridData = [];
3396
- _this.listDocuments();
3405
+ _this.listDocuments(true);
3397
3406
  });
3398
3407
  }
3399
3408
  });
@@ -3402,26 +3411,29 @@ var DocumentGridComponent = /** @class */ (function () {
3402
3411
  var _this = this;
3403
3412
  this.selection.forEach(function (value, index) {
3404
3413
  if (!value.id) {
3405
- _this.gridData.splice(index, 1);
3414
+ var indexGridData = _this.gridData.findIndex(function (document) { return document.key === value.key; });
3415
+ _this.gridData.splice(indexGridData, 1);
3406
3416
  _this.selection.splice(index, 1);
3407
3417
  }
3408
3418
  });
3409
3419
  };
3410
- DocumentGridComponent.prototype.listDocuments = function () {
3420
+ DocumentGridComponent.prototype.listDocuments = function (isDelete) {
3411
3421
  var _this = this;
3412
3422
  this.documentService.list({
3413
3423
  filterQuery: "schedulingId eq '" + this.agenda.id + "'"
3414
3424
  })
3415
3425
  .subscribe(function (contents) {
3416
- _this.gridData = [];
3426
+ var _a;
3427
+ _this.gridData = isDelete ? _this.gridData.filter(function (item) { return !item.id; }) : [];
3417
3428
  if (contents.totalElements > 0) {
3418
- _this.gridData = contents.contents;
3429
+ (_a = _this.gridData).push.apply(_a, __spread(contents.contents));
3419
3430
  _this.documentTotalRecords = contents.totalElements;
3420
3431
  }
3421
3432
  else {
3422
3433
  _this.documentTotalRecords = _this.gridData.length;
3423
3434
  }
3424
- _this.disabled = true;
3435
+ var hasElementWithoutId = _this.gridData.some(function (item) { return !item.id; });
3436
+ _this.disabled = !hasElementWithoutId;
3425
3437
  _this.loading = false;
3426
3438
  });
3427
3439
  };
@@ -3516,7 +3528,7 @@ var DocumentGridComponent = /** @class */ (function () {
3516
3528
  DocumentGridComponent = __decorate([
3517
3529
  Component({
3518
3530
  selector: 'document-grid',
3519
- 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>",
3531
+ 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>",
3520
3532
  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}"]
3521
3533
  }),
3522
3534
  __metadata("design:paramtypes", [TranslateService,
@@ -3599,7 +3611,6 @@ var RegisterDocumentComponent = /** @class */ (function () {
3599
3611
  };
3600
3612
  RegisterDocumentComponent.prototype.close = function () {
3601
3613
  this.visibleChange.emit(false);
3602
- this.formGroup.reset();
3603
3614
  };
3604
3615
  RegisterDocumentComponent.prototype.setValuesFormGroup = function (document) {
3605
3616
  this.formGroup.get('key').setValue(document.key);
@@ -3638,24 +3649,16 @@ var RegisterDocumentComponent = /** @class */ (function () {
3638
3649
  if (this.agenda.id !== undefined) {
3639
3650
  value.schedulingId = this.agenda.id;
3640
3651
  }
3641
- if (value.key === undefined) {
3652
+ if (value.key === undefined || value.key === null) {
3642
3653
  value.key = value.invoiceKey;
3643
3654
  if (this.isWmsWis()) {
3644
3655
  value.key = value.invoiceNumber + ":" + value.invoiceSerialNumber + ":" + value.partnerDocument;
3645
3656
  }
3646
3657
  }
3658
+ this.formGroup.reset();
3647
3659
  this.document.emit(Document.fromDto(value));
3648
- this.successMessage();
3649
- this.visibleChange.emit(false);
3650
3660
  }
3651
3661
  };
3652
- RegisterDocumentComponent.prototype.successMessage = function () {
3653
- this.messageService.add({
3654
- severity: "success",
3655
- summary: this.translateService.instant("yms.saved_message_title"),
3656
- detail: this.translateService.instant("yms.int.wms_success_message_description"),
3657
- });
3658
- };
3659
3662
  RegisterDocumentComponent.prototype.isWmsWis = function () {
3660
3663
  return this.wmsSystem === WmsSystem.WIS;
3661
3664
  };
@@ -3736,6 +3739,7 @@ var InsertKeyComponent = /** @class */ (function () {
3736
3739
  this.document = new EventEmitter();
3737
3740
  this.visible = new EventEmitter();
3738
3741
  this.visibleChange = new EventEmitter();
3742
+ this.isLoading = false;
3739
3743
  }
3740
3744
  InsertKeyComponent.prototype.ngOnInit = function () {
3741
3745
  this.formGroup = this.formBuilder.group({
@@ -3753,11 +3757,11 @@ var InsertKeyComponent = /** @class */ (function () {
3753
3757
  return this.wmsSystem === WmsSystem.SENIOR_CONNECT;
3754
3758
  };
3755
3759
  InsertKeyComponent.prototype.add = function () {
3756
- this.visibleChange.emit(false);
3757
3760
  this.searchKey();
3758
3761
  };
3759
3762
  InsertKeyComponent.prototype.searchKey = function () {
3760
3763
  var _this = this;
3764
+ this.isLoading = true;
3761
3765
  var key = {
3762
3766
  documentKeys: [this.formGroup.get('key').value],
3763
3767
  invoices: [{
@@ -3769,8 +3773,25 @@ var InsertKeyComponent = /** @class */ (function () {
3769
3773
  size: 0,
3770
3774
  offset: 0
3771
3775
  };
3772
- this.documentService.findDocuments(key).subscribe(function (content) {
3773
- if (content.totalElements < 1) {
3776
+ this.documentService.findDocuments(key)
3777
+ .pipe(catchError(function (err) {
3778
+ if (err.error && err.error.message.includes("404")) {
3779
+ _this.message("error", "yms.int.wms_error_search_document_message_header", "yms.int.wms_error_search_document_not_found_message_content");
3780
+ }
3781
+ else {
3782
+ _this.messageService.add({
3783
+ severity: "error",
3784
+ summary: _this.translate.instant("yms.int.wms_error_search_document_message_header"),
3785
+ detail: _this.translate.instant("yms.int.wms_error_unknown_search_document_message_content") + err.error.message,
3786
+ });
3787
+ }
3788
+ return throwError(err);
3789
+ }), finalize(function () {
3790
+ _this.isLoading = false;
3791
+ }))
3792
+ .subscribe(function (content) {
3793
+ _this.visibleChange.emit(false);
3794
+ if (!content || content.totalElements < 1) {
3774
3795
  _this.message("warn", "yms.int.wms_insert_key_warning_message_header", "yms.int.wms_insert_key_warning_message_description");
3775
3796
  return;
3776
3797
  }
@@ -3789,6 +3810,9 @@ var InsertKeyComponent = /** @class */ (function () {
3789
3810
  InsertKeyComponent.prototype.cancel = function () {
3790
3811
  this.visibleChange.emit(false);
3791
3812
  };
3813
+ InsertKeyComponent.prototype.onDialogShow = function () {
3814
+ this.formGroup.reset();
3815
+ };
3792
3816
  __decorate([
3793
3817
  Output(),
3794
3818
  __metadata("design:type", EventEmitter)
@@ -3808,7 +3832,7 @@ var InsertKeyComponent = /** @class */ (function () {
3808
3832
  InsertKeyComponent = __decorate([
3809
3833
  Component({
3810
3834
  selector: "insert-key",
3811
- 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>",
3835
+ 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",
3812
3836
  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}"]
3813
3837
  }),
3814
3838
  __metadata("design:paramtypes", [FormBuilder,
@@ -3830,7 +3854,8 @@ var InsertKeyModule = /** @class */ (function () {
3830
3854
  ButtonModule,
3831
3855
  TranslateModule,
3832
3856
  DialogModule,
3833
- InputTextModule$1
3857
+ InputTextModule$1,
3858
+ LoadingStateModule
3834
3859
  ],
3835
3860
  exports: [InsertKeyComponent],
3836
3861
  declarations: [InsertKeyComponent]
@@ -4994,19 +5019,23 @@ var NotaValidatorService = /** @class */ (function () {
4994
5019
  }());
4995
5020
 
4996
5021
  var NotaFormComponent = /** @class */ (function () {
4997
- function NotaFormComponent(fb, notaValidatorService, dialogConfig, confirmationService, dialogRef, verificaNotaFiscal, messageService, translate) {
5022
+ function NotaFormComponent(fb, notaValidatorService, dialogConfig, confirmationService, dialogRef, verificaNotaFiscal) {
4998
5023
  var _this = this;
4999
5024
  this.notaValidatorService = notaValidatorService;
5000
5025
  this.dialogConfig = dialogConfig;
5001
5026
  this.confirmationService = confirmationService;
5002
5027
  this.dialogRef = dialogRef;
5003
5028
  this.verificaNotaFiscal = verificaNotaFiscal;
5004
- this.messageService = messageService;
5005
- this.translate = translate;
5006
5029
  this.loading = false;
5007
5030
  this.botaoDesabilitado = false;
5031
+ this.disabled = true;
5008
5032
  this.unsubscribe$ = new Subject();
5009
5033
  this.validateNotaFiscal = function (response) {
5034
+ var chaveNotaFiscal = _this.formGroup.get("chaveNotaFiscal").value;
5035
+ if (chaveNotaFiscal.length === 0) {
5036
+ return;
5037
+ }
5038
+ _this.disabled = false;
5010
5039
  if (!response || !response.documentos[0]) {
5011
5040
  return;
5012
5041
  }
@@ -5040,10 +5069,10 @@ var NotaFormComponent = /** @class */ (function () {
5040
5069
  return !!chave || !!serie || !!numero ? null : { erroMultiplosCampos: true };
5041
5070
  };
5042
5071
  this.formGroup = fb.group({
5043
- chaveNotaFiscal: [undefined],
5044
- serieNotaFiscal: [undefined],
5045
- serieLegalNotaFiscal: [undefined],
5046
- numeroNotaFiscal: [undefined],
5072
+ chaveNotaFiscal: [undefined, Validators.required],
5073
+ serieNotaFiscal: [undefined, Validators.required],
5074
+ serieLegalNotaFiscal: [undefined, Validators.required],
5075
+ numeroNotaFiscal: [undefined, Validators.required],
5047
5076
  }, { validators: this.camposPreenchidosValidation });
5048
5077
  }
5049
5078
  NotaFormComponent.prototype.ngOnInit = function () {
@@ -5087,7 +5116,10 @@ var NotaFormComponent = /** @class */ (function () {
5087
5116
  chaveDocumento: (chaveNotaFiscal || "").replace(/\s/g, ""),
5088
5117
  filialId: this.filialId
5089
5118
  })
5090
- .pipe(takeUntil(this.unsubscribe$), finalize(function () { return _this.loading = false; }))
5119
+ .pipe(takeUntil(this.unsubscribe$), catchError(function () {
5120
+ _this.disabled = false;
5121
+ return of(null);
5122
+ }), finalize(function () { return _this.loading = false; }))
5091
5123
  .subscribe(this.validateNotaFiscal);
5092
5124
  this.botaoDesabilitado = false;
5093
5125
  };
@@ -5146,7 +5178,7 @@ var NotaFormComponent = /** @class */ (function () {
5146
5178
  };
5147
5179
  NotaFormComponent = __decorate([
5148
5180
  Component({
5149
- 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>",
5181
+ 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>",
5150
5182
  providers: [ConfirmationService]
5151
5183
  }),
5152
5184
  __metadata("design:paramtypes", [FormBuilder,
@@ -5154,9 +5186,7 @@ var NotaFormComponent = /** @class */ (function () {
5154
5186
  DynamicDialogConfig,
5155
5187
  ConfirmationService,
5156
5188
  DynamicDialogRef,
5157
- VerificaNotafiscal,
5158
- MessageService$1,
5159
- TranslateService])
5189
+ VerificaNotafiscal])
5160
5190
  ], NotaFormComponent);
5161
5191
  return NotaFormComponent;
5162
5192
  }());