@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
@@ -3316,8 +3316,8 @@
3316
3316
  DocumentService.prototype.getSystemIntegration = function () {
3317
3317
  return this.http.get('yms_int/wms/queries/getSystemIntegration');
3318
3318
  };
3319
- DocumentService.prototype.getPlanta = function (plantaId) {
3320
- return this.http.get('yms/patio/entities/planta/' + plantaId);
3319
+ DocumentService.prototype.getYard = function (yardId) {
3320
+ return this.http.get('yms/patio/entities/planta/' + yardId);
3321
3321
  };
3322
3322
  DocumentService = __decorate([
3323
3323
  core.Injectable(),
@@ -3371,13 +3371,14 @@
3371
3371
  }
3372
3372
 
3373
3373
  var DocumentGridComponent = /** @class */ (function () {
3374
- function DocumentGridComponent(translate, documentService, confirmationService, integrationService, agendaService, utils) {
3374
+ function DocumentGridComponent(translate, documentService, confirmationService, integrationService, agendaService, utils, wmsService) {
3375
3375
  this.translate = translate;
3376
3376
  this.documentService = documentService;
3377
3377
  this.confirmationService = confirmationService;
3378
3378
  this.integrationService = integrationService;
3379
3379
  this.agendaService = agendaService;
3380
3380
  this.utils = utils;
3381
+ this.wmsService = wmsService;
3381
3382
  this.viewDocument = new core.EventEmitter();
3382
3383
  this.gridData = [];
3383
3384
  this.enableButtonIsClienteExterno = true;
@@ -3395,9 +3396,43 @@
3395
3396
  }
3396
3397
  };
3397
3398
  DocumentGridComponent.prototype.ngOnInit = function () {
3399
+ var _this = this;
3398
3400
  this.verifyClienteExterno();
3399
3401
  this.getProcessTypeByScheduling();
3400
3402
  this.listDocuments(false);
3403
+ this.wmsService.getSystemIntegration()
3404
+ .subscribe(function (_a) {
3405
+ var system = _a.system;
3406
+ _this.wmsSystem = system;
3407
+ if (_this.isWmsSeniorConnect()) {
3408
+ _this.getYard();
3409
+ _this.getSchedule();
3410
+ }
3411
+ });
3412
+ };
3413
+ DocumentGridComponent.prototype.getYard = function () {
3414
+ var _this = this;
3415
+ this.documentService.getYard(this.agenda.planta.id)
3416
+ .pipe(operators.catchError(function (err) {
3417
+ return rxjs.throwError(err);
3418
+ }))
3419
+ .subscribe(function (content) {
3420
+ _this.yard = content;
3421
+ });
3422
+ };
3423
+ DocumentGridComponent.prototype.getSchedule = function () {
3424
+ var _this = this;
3425
+ if (this.agenda.externalTenant && this.agenda.externalTenant.cnpj) {
3426
+ this.schedule = this.agenda;
3427
+ return;
3428
+ }
3429
+ this.agendaService.get(this.agenda.id)
3430
+ .pipe(operators.catchError(function (err) {
3431
+ return rxjs.throwError(err);
3432
+ }))
3433
+ .subscribe(function (content) {
3434
+ _this.schedule = content;
3435
+ });
3401
3436
  };
3402
3437
  DocumentGridComponent.prototype.verifyClienteExterno = function () {
3403
3438
  var _this = this;
@@ -3537,7 +3572,7 @@
3537
3572
  accept: function () {
3538
3573
  _this.removeDocumentIfIdUndfined();
3539
3574
  if (_this.selection.length < 1) {
3540
- return rxjs.empty();
3575
+ return null;
3541
3576
  }
3542
3577
  return rxjs.forkJoin(_this.selection.map(function (document) { return _this.documentService.delete(document.id); }))
3543
3578
  .pipe(operators.takeUntil(_this.ngUnsubscribe))
@@ -3659,6 +3694,30 @@
3659
3694
  DocumentGridComponent.prototype.sucessMessage = function () {
3660
3695
  return this.utils.message("success", this.summary, "saved_message_content");
3661
3696
  };
3697
+ DocumentGridComponent.prototype.validateDocument = function (document) {
3698
+ if (this.isWmsSeniorConnect()) {
3699
+ if (!this.yard.codigo) {
3700
+ this.buildMessage("yms.int.yard_code_not_found_warning_description");
3701
+ return false;
3702
+ }
3703
+ if (document.logistcUnitDocument !== this.yard.codigo) {
3704
+ this.buildMessage("yms.int.document_yard_mismatch_agenda_warning_description");
3705
+ return false;
3706
+ }
3707
+ if (!this.schedule.externalTenant) {
3708
+ this.buildMessage("yms.int.partner_not_informed_agenda_warning_description");
3709
+ return false;
3710
+ }
3711
+ if (document.partnerDocument !== this.schedule.externalTenant.cnpj) {
3712
+ this.buildMessage("yms.int.partner_differs_from_agenda_warning_description");
3713
+ return false;
3714
+ }
3715
+ }
3716
+ return true;
3717
+ };
3718
+ DocumentGridComponent.prototype.buildMessage = function (description) {
3719
+ this.utils.message("warn", "yms.int.documento_invalido_warning_header", description);
3720
+ };
3662
3721
  __decorate([
3663
3722
  core.Input(),
3664
3723
  __metadata("design:type", Object)
@@ -3714,7 +3773,8 @@
3714
3773
  api.ConfirmationService,
3715
3774
  IntegrationService,
3716
3775
  AgendaService,
3717
- UtilsMessageService])
3776
+ UtilsMessageService,
3777
+ FormWmsService])
3718
3778
  ], DocumentGridComponent);
3719
3779
  return DocumentGridComponent;
3720
3780
  }());
@@ -3762,11 +3822,10 @@
3762
3822
  }());
3763
3823
 
3764
3824
  var RegisterDocumentComponent = /** @class */ (function () {
3765
- function RegisterDocumentComponent(fb, translate, utils, documentService) {
3825
+ function RegisterDocumentComponent(fb, translate, documentGridComponent) {
3766
3826
  this.fb = fb;
3767
3827
  this.translate = translate;
3768
- this.utils = utils;
3769
- this.documentService = documentService;
3828
+ this.documentGridComponent = documentGridComponent;
3770
3829
  this.document = new core.EventEmitter();
3771
3830
  this.visible = new core.EventEmitter();
3772
3831
  this.visibleChange = new core.EventEmitter();
@@ -3774,23 +3833,12 @@
3774
3833
  this.invoiceCondition = getInvoiceConditions(this.translate);
3775
3834
  }
3776
3835
  RegisterDocumentComponent.prototype.ngOnInit = function () {
3777
- this.getYard();
3778
3836
  this.getFormGroup();
3779
3837
  this.watchFormChanges();
3780
3838
  };
3781
3839
  RegisterDocumentComponent.prototype.ngOnChanges = function () {
3782
3840
  this.visibilityConfig();
3783
3841
  };
3784
- RegisterDocumentComponent.prototype.getYard = function () {
3785
- var _this = this;
3786
- this.documentService.getPlanta(this.agenda.planta.id)
3787
- .pipe(operators.catchError(function (err) {
3788
- return rxjs.throwError(err);
3789
- }))
3790
- .subscribe(function (content) {
3791
- _this.planta = content;
3792
- });
3793
- };
3794
3842
  RegisterDocumentComponent.prototype.visibilityConfig = function () {
3795
3843
  if (!this.edit && this.visible) {
3796
3844
  this.formGroup.disable();
@@ -3841,18 +3889,11 @@
3841
3889
  });
3842
3890
  };
3843
3891
  RegisterDocumentComponent.prototype.save = function () {
3844
- if (this.isWmsSeniorConnect()) {
3845
- if (!this.planta.codigo) {
3846
- this.utils.message("warn", "yms.int.yard_code_not_found_warning_header", "yms.int.yard_code_not_found_warning_description");
3847
- return;
3848
- }
3849
- var logistcUnitDocument = this.formGroup.get("logistcUnitDocument").value;
3850
- if (logistcUnitDocument !== this.planta.codigo) {
3851
- this.utils.message("warn", "yms.int.document_yard_mismatch_agenda_warning_header", "yms.int.document_yard_mismatch_agenda_warning_description");
3852
- return;
3853
- }
3892
+ var document = Document.fromDto(this.formGroup.getRawValue());
3893
+ if (!this.documentGridComponent.validateDocument(document)) {
3894
+ return;
3854
3895
  }
3855
- this.document.emit(Document.fromDto(this.formGroup.getRawValue()));
3896
+ this.document.emit(document);
3856
3897
  this.formGroup.reset();
3857
3898
  };
3858
3899
  RegisterDocumentComponent.prototype.isWmsWis = function () {
@@ -3910,8 +3951,7 @@
3910
3951
  }),
3911
3952
  __metadata("design:paramtypes", [forms.FormBuilder,
3912
3953
  core$1.TranslateService,
3913
- UtilsMessageService,
3914
- DocumentService])
3954
+ DocumentGridComponent])
3915
3955
  ], RegisterDocumentComponent);
3916
3956
  return RegisterDocumentComponent;
3917
3957
  }());
@@ -3958,13 +3998,14 @@
3958
3998
  }(EntityService));
3959
3999
 
3960
4000
  var InsertKeyComponent = /** @class */ (function () {
3961
- function InsertKeyComponent(formBuilder, documentService, utils, confirmationService, translate, externalTenantService) {
4001
+ function InsertKeyComponent(formBuilder, documentService, utils, confirmationService, translate, externalTenantService, documentGridComponent) {
3962
4002
  this.formBuilder = formBuilder;
3963
4003
  this.documentService = documentService;
3964
4004
  this.utils = utils;
3965
4005
  this.confirmationService = confirmationService;
3966
4006
  this.translate = translate;
3967
4007
  this.externalTenantService = externalTenantService;
4008
+ this.documentGridComponent = documentGridComponent;
3968
4009
  this.visible = new core.EventEmitter();
3969
4010
  this.document = new core.EventEmitter();
3970
4011
  this.visibleChange = new core.EventEmitter();
@@ -3974,7 +4015,6 @@
3974
4015
  }
3975
4016
  InsertKeyComponent.prototype.ngOnInit = function () {
3976
4017
  var _this = this;
3977
- this.getYard();
3978
4018
  this.formGroup = this.formBuilder.group({
3979
4019
  key: [undefined],
3980
4020
  purchaseOrder: [undefined],
@@ -3986,16 +4026,6 @@
3986
4026
  _this.validateKeyDetails(nf);
3987
4027
  });
3988
4028
  };
3989
- InsertKeyComponent.prototype.getYard = function () {
3990
- var _this = this;
3991
- this.documentService.getPlanta(this.agenda.planta.id)
3992
- .pipe(operators.catchError(function (err) {
3993
- return rxjs.throwError(err);
3994
- }))
3995
- .subscribe(function (content) {
3996
- _this.planta = content;
3997
- });
3998
- };
3999
4029
  InsertKeyComponent.prototype.isWmsWis = function () {
4000
4030
  return this.wmsSystem === WmsSystem.WIS;
4001
4031
  };
@@ -4039,15 +4069,8 @@
4039
4069
  return;
4040
4070
  }
4041
4071
  var document = content.contents[0];
4042
- if (_this.isWmsSeniorConnect()) {
4043
- if (!_this.planta.codigo) {
4044
- _this.utils.message("warn", "yms.int.yard_code_not_found_warning_header", "yms.int.yard_code_not_found_warning_description");
4045
- return;
4046
- }
4047
- if (document.logistcUnitDocument !== _this.planta.codigo) {
4048
- _this.utils.message("warn", "yms.int.document_yard_mismatch_agenda_warning_header", "yms.int.document_yard_mismatch_agenda_warning_description");
4049
- return;
4050
- }
4072
+ if (!_this.documentGridComponent.validateDocument(document)) {
4073
+ return;
4051
4074
  }
4052
4075
  document.invoiceKey = _this.formGroup.get('key').value;
4053
4076
  document.invoiceCondition = InvoiceCondition.AUTHORIZED;
@@ -4169,7 +4192,8 @@
4169
4192
  UtilsMessageService,
4170
4193
  api.ConfirmationService,
4171
4194
  core$1.TranslateService,
4172
- ExternalTenantService])
4195
+ ExternalTenantService,
4196
+ DocumentGridComponent])
4173
4197
  ], InsertKeyComponent);
4174
4198
  return InsertKeyComponent;
4175
4199
  }());