@seniorsistemas/yms-integration 1.39.0 → 1.40.0-c5bb9262-143e-4c54-86ef-c7f4a8489d6b

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 (29) hide show
  1. package/bundles/seniorsistemas-yms-integration.umd.js +81 -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/components/document-list/document-list.component.js +2 -1
  9. package/esm2015/src/wms/components/utils/invoice-conditions.js +2 -1
  10. package/esm2015/src/wms/entities/document/document.service.js +3 -3
  11. package/esm2015/src/wms/entities/invoice-condition/invoice-condition.js +2 -1
  12. package/esm5/src/wms/components/document-grid/document-grid.component.js +67 -6
  13. package/esm5/src/wms/components/document-grid/insert-key/insert-key.component.js +8 -23
  14. package/esm5/src/wms/components/document-grid/register-document/register-document.component.js +9 -32
  15. package/esm5/src/wms/components/document-list/document-list.component.js +2 -1
  16. package/esm5/src/wms/components/utils/invoice-conditions.js +2 -1
  17. package/esm5/src/wms/entities/document/document.service.js +3 -3
  18. package/esm5/src/wms/entities/invoice-condition/invoice-condition.js +2 -1
  19. package/fesm2015/seniorsistemas-yms-integration.js +77 -52
  20. package/fesm2015/seniorsistemas-yms-integration.js.map +1 -1
  21. package/fesm5/seniorsistemas-yms-integration.js +81 -54
  22. package/fesm5/seniorsistemas-yms-integration.js.map +1 -1
  23. package/package.json +1 -1
  24. package/seniorsistemas-yms-integration.metadata.json +1 -1
  25. package/src/wms/components/document-grid/document-grid.component.d.ts +9 -1
  26. package/src/wms/components/document-grid/insert-key/insert-key.component.d.ts +3 -3
  27. package/src/wms/components/document-grid/register-document/register-document.component.d.ts +3 -7
  28. package/src/wms/entities/document/document.service.d.ts +1 -1
  29. package/src/wms/entities/invoice-condition/invoice-condition.d.ts +2 -1
@@ -3037,8 +3037,8 @@ let DocumentService = class DocumentService extends EntityService {
3037
3037
  getSystemIntegration() {
3038
3038
  return this.http.get('yms_int/wms/queries/getSystemIntegration');
3039
3039
  }
3040
- getPlanta(plantaId) {
3041
- return this.http.get('yms/patio/entities/planta/' + plantaId);
3040
+ getYard(yardId) {
3041
+ return this.http.get('yms/patio/entities/planta/' + yardId);
3042
3042
  }
3043
3043
  };
3044
3044
  DocumentService = __decorate([
@@ -3076,6 +3076,7 @@ var InvoiceCondition;
3076
3076
  InvoiceCondition["MANUAL_AUTHORIZED"] = "MANUAL_AUTHORIZED";
3077
3077
  InvoiceCondition["DEVOLUTION"] = "DEVOLUTION";
3078
3078
  InvoiceCondition["REJECTED"] = "REJECTED";
3079
+ InvoiceCondition["DIVERGENCE"] = "DIVERGENCE";
3079
3080
  })(InvoiceCondition || (InvoiceCondition = {}));
3080
3081
 
3081
3082
  function getInvoiceConditions(translate) {
@@ -3086,17 +3087,19 @@ function getInvoiceConditions(translate) {
3086
3087
  { label: translate.instant("yms.int.wms_grid_document_invoice_condition_partial_authorized"), value: InvoiceCondition.PARTIAL_AUTHORIZED },
3087
3088
  { label: translate.instant("yms.int.wms_grid_document_invoice_condition_devolution"), value: InvoiceCondition.DEVOLUTION },
3088
3089
  { label: translate.instant("yms.int.wms_grid_document_invoice_condition_rejected"), value: InvoiceCondition.REJECTED },
3090
+ { label: translate.instant("yms.int.wms_grid_document_invoice_condition_divergence"), value: InvoiceCondition.DIVERGENCE },
3089
3091
  ];
3090
3092
  }
3091
3093
 
3092
3094
  let DocumentGridComponent = class DocumentGridComponent {
3093
- constructor(translate, documentService, confirmationService, integrationService, agendaService, utils) {
3095
+ constructor(translate, documentService, confirmationService, integrationService, agendaService, utils, wmsService) {
3094
3096
  this.translate = translate;
3095
3097
  this.documentService = documentService;
3096
3098
  this.confirmationService = confirmationService;
3097
3099
  this.integrationService = integrationService;
3098
3100
  this.agendaService = agendaService;
3099
3101
  this.utils = utils;
3102
+ this.wmsService = wmsService;
3100
3103
  this.viewDocument = new EventEmitter();
3101
3104
  this.gridData = [];
3102
3105
  this.enableButtonIsClienteExterno = true;
@@ -3117,6 +3120,36 @@ let DocumentGridComponent = class DocumentGridComponent {
3117
3120
  this.verifyClienteExterno();
3118
3121
  this.getProcessTypeByScheduling();
3119
3122
  this.listDocuments(false);
3123
+ this.wmsService.getSystemIntegration()
3124
+ .subscribe(({ system }) => {
3125
+ this.wmsSystem = system;
3126
+ if (this.isWmsSeniorConnect()) {
3127
+ this.getYard();
3128
+ this.getSchedule();
3129
+ }
3130
+ });
3131
+ }
3132
+ getYard() {
3133
+ this.documentService.getYard(this.agenda.planta.id)
3134
+ .pipe(catchError(err => {
3135
+ return throwError(err);
3136
+ }))
3137
+ .subscribe((content) => {
3138
+ this.yard = content;
3139
+ });
3140
+ }
3141
+ getSchedule() {
3142
+ if (this.agenda.externalTenant && this.agenda.externalTenant.cnpj) {
3143
+ this.schedule = this.agenda;
3144
+ return;
3145
+ }
3146
+ this.agendaService.get(this.agenda.id)
3147
+ .pipe(catchError(err => {
3148
+ return throwError(err);
3149
+ }))
3150
+ .subscribe((content) => {
3151
+ this.schedule = content;
3152
+ });
3120
3153
  }
3121
3154
  verifyClienteExterno() {
3122
3155
  this.agendaService.isClienteExterno()
@@ -3251,7 +3284,7 @@ let DocumentGridComponent = class DocumentGridComponent {
3251
3284
  accept: () => {
3252
3285
  this.removeDocumentIfIdUndfined();
3253
3286
  if (this.selection.length < 1) {
3254
- return empty();
3287
+ return null;
3255
3288
  }
3256
3289
  return forkJoin(this.selection.map(document => this.documentService.delete(document.id)))
3257
3290
  .pipe(takeUntil(this.ngUnsubscribe))
@@ -3376,6 +3409,30 @@ let DocumentGridComponent = class DocumentGridComponent {
3376
3409
  sucessMessage() {
3377
3410
  return this.utils.message("success", this.summary, "saved_message_content");
3378
3411
  }
3412
+ validateDocument(document) {
3413
+ if (this.isWmsSeniorConnect()) {
3414
+ if (!this.yard.codigo) {
3415
+ this.buildMessage("yms.int.yard_code_not_found_warning_description");
3416
+ return false;
3417
+ }
3418
+ if (document.logistcUnitDocument !== this.yard.codigo) {
3419
+ this.buildMessage("yms.int.document_yard_mismatch_agenda_warning_description");
3420
+ return false;
3421
+ }
3422
+ if (!this.schedule.externalTenant) {
3423
+ this.buildMessage("yms.int.partner_not_informed_agenda_warning_description");
3424
+ return false;
3425
+ }
3426
+ if (document.partnerDocument !== this.schedule.externalTenant.cnpj) {
3427
+ this.buildMessage("yms.int.partner_differs_from_agenda_warning_description");
3428
+ return false;
3429
+ }
3430
+ }
3431
+ return true;
3432
+ }
3433
+ buildMessage(description) {
3434
+ this.utils.message("warn", "yms.int.documento_invalido_warning_header", description);
3435
+ }
3379
3436
  };
3380
3437
  __decorate([
3381
3438
  Input(),
@@ -3432,7 +3489,8 @@ DocumentGridComponent = __decorate([
3432
3489
  ConfirmationService,
3433
3490
  IntegrationService,
3434
3491
  AgendaService,
3435
- UtilsMessageService])
3492
+ UtilsMessageService,
3493
+ FormWmsService])
3436
3494
  ], DocumentGridComponent);
3437
3495
 
3438
3496
  const moment$4 = _moment;
@@ -3475,11 +3533,10 @@ class Document {
3475
3533
  }
3476
3534
 
3477
3535
  let RegisterDocumentComponent = class RegisterDocumentComponent {
3478
- constructor(fb, translate, utils, documentService) {
3536
+ constructor(fb, translate, documentGridComponent) {
3479
3537
  this.fb = fb;
3480
3538
  this.translate = translate;
3481
- this.utils = utils;
3482
- this.documentService = documentService;
3539
+ this.documentGridComponent = documentGridComponent;
3483
3540
  this.document = new EventEmitter();
3484
3541
  this.visible = new EventEmitter();
3485
3542
  this.visibleChange = new EventEmitter();
@@ -3487,22 +3544,12 @@ let RegisterDocumentComponent = class RegisterDocumentComponent {
3487
3544
  this.invoiceCondition = getInvoiceConditions(this.translate);
3488
3545
  }
3489
3546
  ngOnInit() {
3490
- this.getYard();
3491
3547
  this.getFormGroup();
3492
3548
  this.watchFormChanges();
3493
3549
  }
3494
3550
  ngOnChanges() {
3495
3551
  this.visibilityConfig();
3496
3552
  }
3497
- getYard() {
3498
- this.documentService.getPlanta(this.agenda.planta.id)
3499
- .pipe(catchError(err => {
3500
- return throwError(err);
3501
- }))
3502
- .subscribe((content) => {
3503
- this.planta = content;
3504
- });
3505
- }
3506
3553
  visibilityConfig() {
3507
3554
  if (!this.edit && this.visible) {
3508
3555
  this.formGroup.disable();
@@ -3553,18 +3600,11 @@ let RegisterDocumentComponent = class RegisterDocumentComponent {
3553
3600
  });
3554
3601
  }
3555
3602
  save() {
3556
- if (this.isWmsSeniorConnect()) {
3557
- if (!this.planta.codigo) {
3558
- this.utils.message("warn", "yms.int.yard_code_not_found_warning_header", "yms.int.yard_code_not_found_warning_description");
3559
- return;
3560
- }
3561
- const logistcUnitDocument = this.formGroup.get("logistcUnitDocument").value;
3562
- if (logistcUnitDocument !== this.planta.codigo) {
3563
- this.utils.message("warn", "yms.int.document_yard_mismatch_agenda_warning_header", "yms.int.document_yard_mismatch_agenda_warning_description");
3564
- return;
3565
- }
3603
+ const document = Document.fromDto(this.formGroup.getRawValue());
3604
+ if (!this.documentGridComponent.validateDocument(document)) {
3605
+ return;
3566
3606
  }
3567
- this.document.emit(Document.fromDto(this.formGroup.getRawValue()));
3607
+ this.document.emit(document);
3568
3608
  this.formGroup.reset();
3569
3609
  }
3570
3610
  isWmsWis() {
@@ -3622,8 +3662,7 @@ RegisterDocumentComponent = __decorate([
3622
3662
  }),
3623
3663
  __metadata("design:paramtypes", [FormBuilder,
3624
3664
  TranslateService,
3625
- UtilsMessageService,
3626
- DocumentService])
3665
+ DocumentGridComponent])
3627
3666
  ], RegisterDocumentComponent);
3628
3667
 
3629
3668
  let RegisterDocumentModule = class RegisterDocumentModule {
@@ -3662,13 +3701,14 @@ ExternalTenantService = __decorate([
3662
3701
  ], ExternalTenantService);
3663
3702
 
3664
3703
  let InsertKeyComponent = class InsertKeyComponent {
3665
- constructor(formBuilder, documentService, utils, confirmationService, translate, externalTenantService) {
3704
+ constructor(formBuilder, documentService, utils, confirmationService, translate, externalTenantService, documentGridComponent) {
3666
3705
  this.formBuilder = formBuilder;
3667
3706
  this.documentService = documentService;
3668
3707
  this.utils = utils;
3669
3708
  this.confirmationService = confirmationService;
3670
3709
  this.translate = translate;
3671
3710
  this.externalTenantService = externalTenantService;
3711
+ this.documentGridComponent = documentGridComponent;
3672
3712
  this.visible = new EventEmitter();
3673
3713
  this.document = new EventEmitter();
3674
3714
  this.visibleChange = new EventEmitter();
@@ -3677,7 +3717,6 @@ let InsertKeyComponent = class InsertKeyComponent {
3677
3717
  this.ngUnsubscribe = new Subject();
3678
3718
  }
3679
3719
  ngOnInit() {
3680
- this.getYard();
3681
3720
  this.formGroup = this.formBuilder.group({
3682
3721
  key: [undefined],
3683
3722
  purchaseOrder: [undefined],
@@ -3689,15 +3728,6 @@ let InsertKeyComponent = class InsertKeyComponent {
3689
3728
  this.validateKeyDetails(nf);
3690
3729
  });
3691
3730
  }
3692
- getYard() {
3693
- this.documentService.getPlanta(this.agenda.planta.id)
3694
- .pipe(catchError(err => {
3695
- return throwError(err);
3696
- }))
3697
- .subscribe((content) => {
3698
- this.planta = content;
3699
- });
3700
- }
3701
3731
  isWmsWis() {
3702
3732
  return this.wmsSystem === WmsSystem.WIS;
3703
3733
  }
@@ -3740,15 +3770,8 @@ let InsertKeyComponent = class InsertKeyComponent {
3740
3770
  return;
3741
3771
  }
3742
3772
  const document = content.contents[0];
3743
- if (this.isWmsSeniorConnect()) {
3744
- if (!this.planta.codigo) {
3745
- this.utils.message("warn", "yms.int.yard_code_not_found_warning_header", "yms.int.yard_code_not_found_warning_description");
3746
- return;
3747
- }
3748
- if (document.logistcUnitDocument !== this.planta.codigo) {
3749
- this.utils.message("warn", "yms.int.document_yard_mismatch_agenda_warning_header", "yms.int.document_yard_mismatch_agenda_warning_description");
3750
- return;
3751
- }
3773
+ if (!this.documentGridComponent.validateDocument(document)) {
3774
+ return;
3752
3775
  }
3753
3776
  document.invoiceKey = this.formGroup.get('key').value;
3754
3777
  document.invoiceCondition = InvoiceCondition.AUTHORIZED;
@@ -3869,7 +3892,8 @@ InsertKeyComponent = __decorate([
3869
3892
  UtilsMessageService,
3870
3893
  ConfirmationService,
3871
3894
  TranslateService,
3872
- ExternalTenantService])
3895
+ ExternalTenantService,
3896
+ DocumentGridComponent])
3873
3897
  ], InsertKeyComponent);
3874
3898
 
3875
3899
  let InsertKeyModule = class InsertKeyModule {
@@ -3996,6 +4020,7 @@ let DocumentListComponent = class DocumentListComponent extends DocumentListDesc
3996
4020
  { label: this.translate.instant("yms.int.wms_grid_document_invoice_condition_partial_authorized"), value: InvoiceCondition.PARTIAL_AUTHORIZED },
3997
4021
  { label: this.translate.instant("yms.int.wms_grid_document_invoice_condition_devolution"), value: InvoiceCondition.DEVOLUTION },
3998
4022
  { label: this.translate.instant("yms.int.wms_grid_document_invoice_condition_rejected"), value: InvoiceCondition.REJECTED },
4023
+ { label: this.translate.instant("yms.int.wms_grid_document_invoice_condition_divergence"), value: InvoiceCondition.DIVERGENCE },
3999
4024
  ];
4000
4025
  this.isAuthorized = (condition) => (condition === InvoiceCondition.AUTHORIZED);
4001
4026
  }