Преглед на файлове

Merge branch 'features-o' of onunez/frontend-inversiones into development

Oscar José Nuñez Chávez преди 5 години
родител
ревизия
e38f8a2a9a

+ 24 - 0
src/app/components/instruments/pbur/pbur.component.html

@@ -49,6 +49,30 @@
           </div>
         </div>
       </div>
+
+      <div class="col-lg-6 col-sm-12 pr-xl-3">
+        <div class="form-group">
+          <label for="plazo">Plazo: </label>
+          <div class="input-box-container">
+            <p>
+              <i class="fas fa-dollar-sign"></i>
+            </p>
+            <input
+              type="text"
+              formControlName="plazo"
+              class="form-control"
+              [ngClass]="{
+                'is-invalid': submitted && f.plazo.errors
+              }"
+            />
+            <div *ngIf="submitted && f.plazo.errors" class="invalid-feedback">
+              <div *ngIf="f.plazo.errors.required">
+                Campo requerido
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
       <div class="col-lg-6 col-sm-12 pr-xl-3">
         <div class="form-group">
           <label for="renta_porcentaje">Porcentaje renta: </label>

+ 23 - 64
src/app/components/investments/costs/pbur/pbur.costs.component.ts

@@ -242,40 +242,18 @@ export class PBURCostsComponent implements OnInit {
     this.instrumentService
       .projectionCalc(this.investmentProposalID, this.form.value)
       .subscribe(
-        resp => {
-          this.investmentsService
-            .updateInstrumentProjection(
-              this.investmentProposalID,
-              objProjection
-            )
-            .subscribe(
-              success => {
-                if (success) {
-                  Swal.fire({
-                    allowOutsideClick: false,
-                    icon: "success",
-                    showCancelButton: false,
-                    title: "Exito",
-                    confirmButtonText: "La información ha sido actualizada"
-                  }).then(result => {
-                    this.proyecciones = result["result"];
-
-                    this.form = new FormArray(
-                      this.buildForm(this.proyecciones)
-                    );
-                    Swal.close();
-                    //window.location.reload();
-                  });
-                }
-              },
-              err => {
-                Swal.fire({
-                  icon: "error",
-                  title: "Error al guardar",
-                  text: err.message
-                });
-              }
-            );
+        result => {
+          Swal.fire({
+            allowOutsideClick: false,
+            icon: "success",
+            showCancelButton: false,
+            title: "Exito"
+          });
+          this.proyecciones = result["result"]["proyecciones"];
+          this.form.clear();
+          this.form = new FormArray(this.buildForm(this.proyecciones));
+          Swal.close();
+          //window.location.reload();
         },
         err => {
           Swal.fire({
@@ -297,37 +275,19 @@ export class PBURCostsComponent implements OnInit {
     Swal.showLoading();
 
     this.instrumentService
-      .projectionModification(this.investmentProposalID, this.form.value)
+      .projectionModification(this.investmentProposalID, objProjection)
       .subscribe(
         resp => {
-          this.investmentsService
-            .updateInstrumentProjection(
-              this.investmentProposalID,
-              objProjection
-            )
-            .subscribe(
-              success => {
-                if (success) {
-                  Swal.fire({
-                    allowOutsideClick: false,
-                    icon: "success",
-                    showCancelButton: false,
-                    title: "Exito",
-                    confirmButtonText: "La información ha sido actualizada"
-                  }).then(result => {
-                    Swal.close();
-                    //window.location.reload();
-                  });
-                }
-              },
-              err => {
-                Swal.fire({
-                  icon: "error",
-                  title: "Error al guardar",
-                  text: err.message
-                });
-              }
-            );
+          Swal.fire({
+            allowOutsideClick: false,
+            icon: "success",
+            showCancelButton: false,
+            title: "Exito",
+            confirmButtonText: "La información ha sido actualizada"
+          }).then(result => {
+            Swal.close();
+            //window.location.reload();
+          });
         },
         err => {
           Swal.fire({
@@ -338,7 +298,6 @@ export class PBURCostsComponent implements OnInit {
         }
       );
   }
-
   buildForm(items: any[]): FormGroup[] {
     return items.map(x => this.buildItem(x));
   }

+ 23 - 63
src/app/components/investments/costs/vcn/vcn.costs.component.ts

@@ -242,40 +242,18 @@ export class VCNCostsComponent implements OnInit {
     this.instrumentService
       .projectionCalc(this.investmentProposalID, this.form.value)
       .subscribe(
-        resp => {
-          this.investmentsService
-            .updateInstrumentProjection(
-              this.investmentProposalID,
-              objProjection
-            )
-            .subscribe(
-              success => {
-                if (success) {
-                  Swal.fire({
-                    allowOutsideClick: false,
-                    icon: "success",
-                    showCancelButton: false,
-                    title: "Exito",
-                    confirmButtonText: "La información ha sido actualizada"
-                  }).then(result => {
-                    this.proyecciones = result["result"];
-
-                    this.form = new FormArray(
-                      this.buildForm(this.proyecciones)
-                    );
-                    Swal.close();
-                    //window.location.reload();
-                  });
-                }
-              },
-              err => {
-                Swal.fire({
-                  icon: "error",
-                  title: "Error al guardar",
-                  text: err.message
-                });
-              }
-            );
+        result => {
+          Swal.fire({
+            allowOutsideClick: false,
+            icon: "success",
+            showCancelButton: false,
+            title: "Exito"
+          });
+          this.proyecciones = result["result"]["proyecciones"];
+          this.form.clear();
+          this.form = new FormArray(this.buildForm(this.proyecciones));
+          Swal.close();
+          //window.location.reload();
         },
         err => {
           Swal.fire({
@@ -297,37 +275,19 @@ export class VCNCostsComponent implements OnInit {
     Swal.showLoading();
 
     this.instrumentService
-      .projectionModification(this.investmentProposalID, this.form.value)
+      .projectionModification(this.investmentProposalID, objProjection)
       .subscribe(
         resp => {
-          this.investmentsService
-            .updateInstrumentProjection(
-              this.investmentProposalID,
-              objProjection
-            )
-            .subscribe(
-              success => {
-                if (success) {
-                  Swal.fire({
-                    allowOutsideClick: false,
-                    icon: "success",
-                    showCancelButton: false,
-                    title: "Exito",
-                    confirmButtonText: "La información ha sido actualizada"
-                  }).then(result => {
-                    Swal.close();
-                    //window.location.reload();
-                  });
-                }
-              },
-              err => {
-                Swal.fire({
-                  icon: "error",
-                  title: "Error al guardar",
-                  text: err.message
-                });
-              }
-            );
+          Swal.fire({
+            allowOutsideClick: false,
+            icon: "success",
+            showCancelButton: false,
+            title: "Exito",
+            confirmButtonText: "La información ha sido actualizada"
+          }).then(result => {
+            Swal.close();
+            //window.location.reload();
+          });
         },
         err => {
           Swal.fire({

+ 3 - 2
src/app/services/instrument-calculations.service.ts

@@ -285,9 +285,10 @@ export class InstrumentCalculations {
 
   projectionModification(id: string, proyecciones: any): Observable<boolean> {
     return this.http
-      .post<any>(`${environment.productionApiUrl}/proyecciones/${id}`, {
+      .put<any>(
+        `${environment.productionApiUrl}/proyeccion/${id}`,
         proyecciones
-      })
+      )
       .pipe(
         map(response => {
           return response;