@seniorsistemas/yms-integration 1.39.0 → 1.40.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 (22) hide show
  1. package/bundles/seniorsistemas-yms-integration.umd.js +78 -54
  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/wms/components/document-grid/document-grid.component.js +63 -6
  6. package/esm2015/src/wms/components/document-grid/insert-key/insert-key.component.js +8 -22
  7. package/esm2015/src/wms/components/document-grid/register-document/register-document.component.js +9 -31
  8. package/esm2015/src/wms/entities/document/document.service.js +3 -3
  9. package/esm5/src/wms/components/document-grid/document-grid.component.js +67 -6
  10. package/esm5/src/wms/components/document-grid/insert-key/insert-key.component.js +8 -23
  11. package/esm5/src/wms/components/document-grid/register-document/register-document.component.js +9 -32
  12. package/esm5/src/wms/entities/document/document.service.js +3 -3
  13. package/fesm2015/seniorsistemas-yms-integration.js +74 -52
  14. package/fesm2015/seniorsistemas-yms-integration.js.map +1 -1
  15. package/fesm5/seniorsistemas-yms-integration.js +78 -54
  16. package/fesm5/seniorsistemas-yms-integration.js.map +1 -1
  17. package/package.json +1 -1
  18. package/seniorsistemas-yms-integration.metadata.json +1 -1
  19. package/src/wms/components/document-grid/document-grid.component.d.ts +9 -1
  20. package/src/wms/components/document-grid/insert-key/insert-key.component.d.ts +3 -3
  21. package/src/wms/components/document-grid/register-document/register-document.component.d.ts +3 -7
  22. package/src/wms/entities/document/document.service.d.ts +1 -1
@@ -3257,8 +3257,8 @@ var DocumentService = /** @class */ (function (_super) {
3257
3257
  DocumentService.prototype.getSystemIntegration = function () {
3258
3258
  return this.http.get('yms_int/wms/queries/getSystemIntegration');
3259
3259
  };
3260
- DocumentService.prototype.getPlanta = function (plantaId) {
3261
- return this.http.get('yms/patio/entities/planta/' + plantaId);
3260
+ DocumentService.prototype.getYard = function (yardId) {
3261
+ return this.http.get('yms/patio/entities/planta/' + yardId);
3262
3262
  };
3263
3263
  DocumentService = __decorate([
3264
3264
  Injectable(),
@@ -3312,13 +3312,14 @@ function getInvoiceConditions(translate) {
3312
3312
  }
3313
3313
 
3314
3314
  var DocumentGridComponent = /** @class */ (function () {
3315
- function DocumentGridComponent(translate, documentService, confirmationService, integrationService, agendaService, utils) {
3315
+ function DocumentGridComponent(translate, documentService, confirmationService, integrationService, agendaService, utils, wmsService) {
3316
3316
  this.translate = translate;
3317
3317
  this.documentService = documentService;
3318
3318
  this.confirmationService = confirmationService;
3319
3319
  this.integrationService = integrationService;
3320
3320
  this.agendaService = agendaService;
3321
3321
  this.utils = utils;
3322
+ this.wmsService = wmsService;
3322
3323
  this.viewDocument = new EventEmitter();
3323
3324
  this.gridData = [];
3324
3325
  this.enableButtonIsClienteExterno = true;
@@ -3336,9 +3337,43 @@ var DocumentGridComponent = /** @class */ (function () {
3336
3337
  }
3337
3338
  };
3338
3339
  DocumentGridComponent.prototype.ngOnInit = function () {
3340
+ var _this = this;
3339
3341
  this.verifyClienteExterno();
3340
3342
  this.getProcessTypeByScheduling();
3341
3343
  this.listDocuments(false);
3344
+ this.wmsService.getSystemIntegration()
3345
+ .subscribe(function (_a) {
3346
+ var system = _a.system;
3347
+ _this.wmsSystem = system;
3348
+ if (_this.isWmsSeniorConnect()) {
3349
+ _this.getYard();
3350
+ _this.getSchedule();
3351
+ }
3352
+ });
3353
+ };
3354
+ DocumentGridComponent.prototype.getYard = function () {
3355
+ var _this = this;
3356
+ this.documentService.getYard(this.agenda.planta.id)
3357
+ .pipe(catchError(function (err) {
3358
+ return throwError(err);
3359
+ }))
3360
+ .subscribe(function (content) {
3361
+ _this.yard = content;
3362
+ });
3363
+ };
3364
+ DocumentGridComponent.prototype.getSchedule = function () {
3365
+ var _this = this;
3366
+ if (this.agenda.externalTenant && this.agenda.externalTenant.cnpj) {
3367
+ this.schedule = this.agenda;
3368
+ return;
3369
+ }
3370
+ this.agendaService.get(this.agenda.id)
3371
+ .pipe(catchError(function (err) {
3372
+ return throwError(err);
3373
+ }))
3374
+ .subscribe(function (content) {
3375
+ _this.schedule = content;
3376
+ });
3342
3377
  };
3343
3378
  DocumentGridComponent.prototype.verifyClienteExterno = function () {
3344
3379
  var _this = this;
@@ -3478,7 +3513,7 @@ var DocumentGridComponent = /** @class */ (function () {
3478
3513
  accept: function () {
3479
3514
  _this.removeDocumentIfIdUndfined();
3480
3515
  if (_this.selection.length < 1) {
3481
- return empty();
3516
+ return null;
3482
3517
  }
3483
3518
  return forkJoin(_this.selection.map(function (document) { return _this.documentService.delete(document.id); }))
3484
3519
  .pipe(takeUntil(_this.ngUnsubscribe))
@@ -3600,6 +3635,30 @@ var DocumentGridComponent = /** @class */ (function () {
3600
3635
  DocumentGridComponent.prototype.sucessMessage = function () {
3601
3636
  return this.utils.message("success", this.summary, "saved_message_content");
3602
3637
  };
3638
+ DocumentGridComponent.prototype.validateDocument = function (document) {
3639
+ if (this.isWmsSeniorConnect()) {
3640
+ if (!this.yard.codigo) {
3641
+ this.buildMessage("yms.int.yard_code_not_found_warning_description");
3642
+ return false;
3643
+ }
3644
+ if (document.logistcUnitDocument !== this.yard.codigo) {
3645
+ this.buildMessage("yms.int.document_yard_mismatch_agenda_warning_description");
3646
+ return false;
3647
+ }
3648
+ if (!this.schedule.externalTenant) {
3649
+ this.buildMessage("yms.int.partner_not_informed_agenda_warning_description");
3650
+ return false;
3651
+ }
3652
+ if (document.partnerDocument !== this.schedule.externalTenant.cnpj) {
3653
+ this.buildMessage("yms.int.partner_differs_from_agenda_warning_description");
3654
+ return false;
3655
+ }
3656
+ }
3657
+ return true;
3658
+ };
3659
+ DocumentGridComponent.prototype.buildMessage = function (description) {
3660
+ this.utils.message("warn", "yms.int.documento_invalido_warning_header", description);
3661
+ };
3603
3662
  __decorate([
3604
3663
  Input(),
3605
3664
  __metadata("design:type", Object)
@@ -3655,7 +3714,8 @@ var DocumentGridComponent = /** @class */ (function () {
3655
3714
  ConfirmationService,
3656
3715
  IntegrationService,
3657
3716
  AgendaService,
3658
- UtilsMessageService])
3717
+ UtilsMessageService,
3718
+ FormWmsService])
3659
3719
  ], DocumentGridComponent);
3660
3720
  return DocumentGridComponent;
3661
3721
  }());
@@ -3703,11 +3763,10 @@ var Document = /** @class */ (function () {
3703
3763
  }());
3704
3764
 
3705
3765
  var RegisterDocumentComponent = /** @class */ (function () {
3706
- function RegisterDocumentComponent(fb, translate, utils, documentService) {
3766
+ function RegisterDocumentComponent(fb, translate, documentGridComponent) {
3707
3767
  this.fb = fb;
3708
3768
  this.translate = translate;
3709
- this.utils = utils;
3710
- this.documentService = documentService;
3769
+ this.documentGridComponent = documentGridComponent;
3711
3770
  this.document = new EventEmitter();
3712
3771
  this.visible = new EventEmitter();
3713
3772
  this.visibleChange = new EventEmitter();
@@ -3715,23 +3774,12 @@ var RegisterDocumentComponent = /** @class */ (function () {
3715
3774
  this.invoiceCondition = getInvoiceConditions(this.translate);
3716
3775
  }
3717
3776
  RegisterDocumentComponent.prototype.ngOnInit = function () {
3718
- this.getYard();
3719
3777
  this.getFormGroup();
3720
3778
  this.watchFormChanges();
3721
3779
  };
3722
3780
  RegisterDocumentComponent.prototype.ngOnChanges = function () {
3723
3781
  this.visibilityConfig();
3724
3782
  };
3725
- RegisterDocumentComponent.prototype.getYard = function () {
3726
- var _this = this;
3727
- this.documentService.getPlanta(this.agenda.planta.id)
3728
- .pipe(catchError(function (err) {
3729
- return throwError(err);
3730
- }))
3731
- .subscribe(function (content) {
3732
- _this.planta = content;
3733
- });
3734
- };
3735
3783
  RegisterDocumentComponent.prototype.visibilityConfig = function () {
3736
3784
  if (!this.edit && this.visible) {
3737
3785
  this.formGroup.disable();
@@ -3782,18 +3830,11 @@ var RegisterDocumentComponent = /** @class */ (function () {
3782
3830
  });
3783
3831
  };
3784
3832
  RegisterDocumentComponent.prototype.save = function () {
3785
- if (this.isWmsSeniorConnect()) {
3786
- if (!this.planta.codigo) {
3787
- this.utils.message("warn", "yms.int.yard_code_not_found_warning_header", "yms.int.yard_code_not_found_warning_description");
3788
- return;
3789
- }
3790
- var logistcUnitDocument = this.formGroup.get("logistcUnitDocument").value;
3791
- if (logistcUnitDocument !== this.planta.codigo) {
3792
- this.utils.message("warn", "yms.int.document_yard_mismatch_agenda_warning_header", "yms.int.document_yard_mismatch_agenda_warning_description");
3793
- return;
3794
- }
3833
+ var document = Document.fromDto(this.formGroup.getRawValue());
3834
+ if (!this.documentGridComponent.validateDocument(document)) {
3835
+ return;
3795
3836
  }
3796
- this.document.emit(Document.fromDto(this.formGroup.getRawValue()));
3837
+ this.document.emit(document);
3797
3838
  this.formGroup.reset();
3798
3839
  };
3799
3840
  RegisterDocumentComponent.prototype.isWmsWis = function () {
@@ -3851,8 +3892,7 @@ var RegisterDocumentComponent = /** @class */ (function () {
3851
3892
  }),
3852
3893
  __metadata("design:paramtypes", [FormBuilder,
3853
3894
  TranslateService,
3854
- UtilsMessageService,
3855
- DocumentService])
3895
+ DocumentGridComponent])
3856
3896
  ], RegisterDocumentComponent);
3857
3897
  return RegisterDocumentComponent;
3858
3898
  }());
@@ -3899,13 +3939,14 @@ var ExternalTenantService = /** @class */ (function (_super) {
3899
3939
  }(EntityService));
3900
3940
 
3901
3941
  var InsertKeyComponent = /** @class */ (function () {
3902
- function InsertKeyComponent(formBuilder, documentService, utils, confirmationService, translate, externalTenantService) {
3942
+ function InsertKeyComponent(formBuilder, documentService, utils, confirmationService, translate, externalTenantService, documentGridComponent) {
3903
3943
  this.formBuilder = formBuilder;
3904
3944
  this.documentService = documentService;
3905
3945
  this.utils = utils;
3906
3946
  this.confirmationService = confirmationService;
3907
3947
  this.translate = translate;
3908
3948
  this.externalTenantService = externalTenantService;
3949
+ this.documentGridComponent = documentGridComponent;
3909
3950
  this.visible = new EventEmitter();
3910
3951
  this.document = new EventEmitter();
3911
3952
  this.visibleChange = new EventEmitter();
@@ -3915,7 +3956,6 @@ var InsertKeyComponent = /** @class */ (function () {
3915
3956
  }
3916
3957
  InsertKeyComponent.prototype.ngOnInit = function () {
3917
3958
  var _this = this;
3918
- this.getYard();
3919
3959
  this.formGroup = this.formBuilder.group({
3920
3960
  key: [undefined],
3921
3961
  purchaseOrder: [undefined],
@@ -3927,16 +3967,6 @@ var InsertKeyComponent = /** @class */ (function () {
3927
3967
  _this.validateKeyDetails(nf);
3928
3968
  });
3929
3969
  };
3930
- InsertKeyComponent.prototype.getYard = function () {
3931
- var _this = this;
3932
- this.documentService.getPlanta(this.agenda.planta.id)
3933
- .pipe(catchError(function (err) {
3934
- return throwError(err);
3935
- }))
3936
- .subscribe(function (content) {
3937
- _this.planta = content;
3938
- });
3939
- };
3940
3970
  InsertKeyComponent.prototype.isWmsWis = function () {
3941
3971
  return this.wmsSystem === WmsSystem.WIS;
3942
3972
  };
@@ -3980,15 +4010,8 @@ var InsertKeyComponent = /** @class */ (function () {
3980
4010
  return;
3981
4011
  }
3982
4012
  var document = content.contents[0];
3983
- if (_this.isWmsSeniorConnect()) {
3984
- if (!_this.planta.codigo) {
3985
- _this.utils.message("warn", "yms.int.yard_code_not_found_warning_header", "yms.int.yard_code_not_found_warning_description");
3986
- return;
3987
- }
3988
- if (document.logistcUnitDocument !== _this.planta.codigo) {
3989
- _this.utils.message("warn", "yms.int.document_yard_mismatch_agenda_warning_header", "yms.int.document_yard_mismatch_agenda_warning_description");
3990
- return;
3991
- }
4013
+ if (!_this.documentGridComponent.validateDocument(document)) {
4014
+ return;
3992
4015
  }
3993
4016
  document.invoiceKey = _this.formGroup.get('key').value;
3994
4017
  document.invoiceCondition = InvoiceCondition.AUTHORIZED;
@@ -4110,7 +4133,8 @@ var InsertKeyComponent = /** @class */ (function () {
4110
4133
  UtilsMessageService,
4111
4134
  ConfirmationService,
4112
4135
  TranslateService,
4113
- ExternalTenantService])
4136
+ ExternalTenantService,
4137
+ DocumentGridComponent])
4114
4138
  ], InsertKeyComponent);
4115
4139
  return InsertKeyComponent;
4116
4140
  }());