Oscar José Nuñez Chávez 5 éve
szülő
commit
637e427f4b

+ 3 - 2
src/app/components/incomes/incomes.component.html

@@ -50,8 +50,9 @@
                   name="instrumento"
                   (change)="filter_by_income_status($event)"
                 >
-                  <option value="1">Activos</option>
-                  <option value="0">Todos</option>
+                  <option value="1">Proyecciones para hoy</option>
+                  <option value="2">Proyecciones activas no canceladas</option>
+                  <option value="0">Todas</option>
                 </select>
               </div>
             </div>

+ 21 - 16
src/app/components/incomes/incomes.component.ts

@@ -171,22 +171,27 @@ export class IncomesComponent implements OnInit {
 
     let active = event.target.value;
 
-    this.incomesService.getProjectionsIncomeList(active, "0").subscribe(
-      ans => {
-        this.listProposals = ans["result"];
-        this.dataSource.data = this.listProposals;
-        this.dataSource.paginator = this.paginator;
-        this.dataSource.sort = this.sort;
-        Swal.close();
-      },
-      err => {
-        Swal.fire({
-          icon: "error",
-          title: "Error en el servidor",
-          text: err.message
-        });
-      }
-    );
+    let active_income = active == 1 || active == 2 ? "1" : "0";
+    let current_date = active == 1 ? "1" : "0";
+
+    this.incomesService
+      .getProjectionsIncomeList(active_income, current_date)
+      .subscribe(
+        ans => {
+          this.listProposals = ans["result"];
+          this.dataSource.data = this.listProposals;
+          this.dataSource.paginator = this.paginator;
+          this.dataSource.sort = this.sort;
+          Swal.close();
+        },
+        err => {
+          Swal.fire({
+            icon: "error",
+            title: "Error en el servidor",
+            text: err.message
+          });
+        }
+      );
   }
 
   applyFilter(event: Event) {

+ 3 - 1
src/app/components/instruments/bonos/bonos.component.ts

@@ -385,8 +385,9 @@ export class BONO implements InstrumentComponent {
     // Get calculations, always
     if (
       this.instrument_work != undefined &&
-      this.instrument_work.proyecciones != ""
+      this.instrument_work.proyecciones == ""
     ) {
+      console.log("get calcs");
       this.getCalculations(this.investmentProposalForm, false);
     }
   }
@@ -554,6 +555,7 @@ export class BONO implements InstrumentComponent {
           this.proyecciones = ans["result"]["proyecciones"];
 
           this.dataSource.data = this.proyecciones;
+          this.dataSource2.data = this.proyecciones;
           this.dataSource.paginator = this.paginator;
           this.dataSource.sort = this.sort;
 

+ 3 - 1
src/app/components/instruments/certificados/certificados.component.ts

@@ -385,7 +385,7 @@ export class CINV implements InstrumentComponent {
     // Get calculations, always
     if (
       this.instrument_work != undefined &&
-      this.instrument_work.proyecciones != ""
+      this.instrument_work.proyecciones == ""
     ) {
       this.getCalculations(this.investmentProposalForm, false);
     }
@@ -554,6 +554,8 @@ export class CINV implements InstrumentComponent {
           this.proyecciones = ans["result"]["proyecciones"];
 
           this.dataSource.data = this.proyecciones;
+          this.dataSource2.data = this.proyecciones;
+
           this.dataSource.paginator = this.paginator;
           this.dataSource.sort = this.sort;
 

+ 3 - 1
src/app/components/instruments/eurobonos/eurobonos.component.ts

@@ -385,7 +385,7 @@ export class EURB implements InstrumentComponent {
     // Get calculations, always
     if (
       this.instrument_work != undefined &&
-      this.instrument_work.proyecciones != ""
+      this.instrument_work.proyecciones == ""
     ) {
       this.getCalculations(this.investmentProposalForm, false);
     }
@@ -554,6 +554,8 @@ export class EURB implements InstrumentComponent {
           this.proyecciones = ans["result"]["proyecciones"];
 
           this.dataSource.data = this.proyecciones;
+          this.dataSource2.data = this.proyecciones;
+
           this.dataSource.paginator = this.paginator;
           this.dataSource.sort = this.sort;
 

+ 3 - 1
src/app/components/instruments/titulos/titulos.component.ts

@@ -407,7 +407,7 @@ export class TIT implements InstrumentComponent {
     // Get calculations, always
     if (
       this.instrument_work != undefined &&
-      this.instrument_work.proyecciones != ""
+      this.instrument_work.proyecciones == ""
     ) {
       this.getCalculations(this.investmentProposalForm, false);
     }
@@ -606,6 +606,8 @@ export class TIT implements InstrumentComponent {
           this.proyecciones = ans["result"]["proyecciones"];
 
           this.dataSource.data = this.proyecciones;
+          this.dataSource2.data = this.proyecciones;
+
           this.dataSource.paginator = this.paginator;
           this.dataSource.sort = this.sort;
 

+ 3 - 3
src/app/components/investment-proposals/approve/approve.component.ts

@@ -379,7 +379,7 @@ export class InvestmentProposalApproveComponent implements OnInit {
           Swal.fire({
             title: `<h3>Aprobación de propuesta de inversión</h3>`,
             icon: "info",
-            html: `${this.generated_inputs_next}`,
+            html: `<div>Notificar a:</div>${this.generated_inputs_next}`,
             confirmButtonText: "Aprobar propuesta",
             showCancelButton: true,
             cancelButtonText: "Cancelar",
@@ -454,7 +454,7 @@ export class InvestmentProposalApproveComponent implements OnInit {
         preConfirm: comentario => {
           this.reviewProposal = {
             id_inversion: this.investmentProposalID,
-            step: "next",
+            step: "previous",
             comentario: comentario
           };
         },
@@ -464,7 +464,7 @@ export class InvestmentProposalApproveComponent implements OnInit {
           Swal.fire({
             title: `<h3>Aprobación de propuesta de inversión</h3>`,
             icon: "info",
-            html: `${this.generated_inputs_previous}`,
+            html: `<div>Notificar a:</div>${this.generated_inputs_previous}`,
             confirmButtonText: "Rechazar propuesta",
             showCancelButton: true,
             confirmButtonColor: "#C82333",

+ 1 - 2
src/app/components/investment-proposals/investment-proposals.component.ts

@@ -251,7 +251,7 @@ export class InvestmentProposalsComponent implements OnInit {
       .getAvailableUsers(investmentProposalID)
       .subscribe(res => {
         this.userList = res["usuarios_next"];
-        this.test = "";
+        this.test = "<div>Notificar a:</div>";
 
         if (this.userList.length > 0) {
           for (let i = 0; i < this.userList.length; i++) {
@@ -432,7 +432,6 @@ export class InvestmentProposalsComponent implements OnInit {
   }
 
   userType(userRole: any, requiredRole: any) {
-    console.log(userRole);
     if (userRole.length == 0) {
       return true;
     }

+ 3 - 3
src/app/components/investment-proposals/payment-approval/payment-approval.component.ts

@@ -406,7 +406,7 @@ export class PaymentApprovalComponent implements OnInit {
           Swal.fire({
             title: `<h3>Revisión del pago de inversión</h3>`,
             icon: "info",
-            html: `${this.generated_inputs_next}`,
+            html: `<div>Notificar a:</div>${this.generated_inputs_next}`,
             confirmButtonText: "Aprobar propuesta",
             showCancelButton: true,
             cancelButtonText: "Cancelar",
@@ -481,7 +481,7 @@ export class PaymentApprovalComponent implements OnInit {
         preConfirm: comentario => {
           this.reviewProposal = {
             id_inversion: this.investmentProposalID,
-            step: "next",
+            step: "previous",
             comentario: comentario
           };
         },
@@ -491,7 +491,7 @@ export class PaymentApprovalComponent implements OnInit {
           Swal.fire({
             title: `<h3>Revisión propuesta de inversión</h3>`,
             icon: "info",
-            html: `${this.generated_inputs_previous}`,
+            html: `<div>Notificar a:</div>${this.generated_inputs_previous}`,
             confirmButtonText: "Rechazar propuesta",
             showCancelButton: true,
             confirmButtonColor: "#C82333",

+ 1 - 6
src/app/components/investment-proposals/payment-info/payment-info.component.html

@@ -160,16 +160,11 @@
                     <select
                       class="custom-select"
                       formControlName="cuenta_bancaria_destino"
-                      [ngClass]="{
-                        'is-invalid':
-                          submitted && f.cuenta_bancaria_destino.errors
-                      }"
                     >
                       <option
-                        *ngFor="let item of accounts"
+                        *ngFor="let item of accounts_destination"
                         [value]="item.id_cuenta_bancaria_destino"
                       >
-                        {{ nameBankAccounts(item.id_banco) }} -
                         {{ item.nombre }}</option
                       >
                     </select>

+ 15 - 9
src/app/components/investment-proposals/payment-info/payment-info.component.ts

@@ -77,6 +77,7 @@ export class PaymentInfoComponent implements OnInit {
   investmentService: any;
   payment_check: boolean;
   payment_transfer: boolean;
+  accounts_destination: any;
 
   constructor(
     private router: Router,
@@ -158,6 +159,12 @@ export class PaymentInfoComponent implements OnInit {
       //this.payment_types = res;
     });
 
+    this.catalogService
+      .getCatalogInfo("cuentas-bancaria-destino")
+      .subscribe(res => {
+        this.accounts_destination = res;
+      });
+
     this.investmentProposalForm = this.formBuilder.group({
       monto: [
         this.inversionAmount,
@@ -233,7 +240,7 @@ export class PaymentInfoComponent implements OnInit {
           Swal.fire({
             title: `<h3>Enviar información de pago</h3>`,
             icon: "info",
-            html: `${this.generated_inputs_next}`,
+            html: `<div>Notificar a:</div>${this.generated_inputs_next}`,
             confirmButtonText: "Enviar información",
             showCancelButton: true,
             cancelButtonText: "Cancelar",
@@ -255,24 +262,23 @@ export class PaymentInfoComponent implements OnInit {
               this.reviewProposal["notificar"] = array.toString();
               this.paymentObject = {
                 monto: this.investmentProposalForm.value.monto,
-                id_tipo_pago: this.investmentProposalForm.value.tipo_pago,
-                id_cuenta_bancaria: this.investmentProposalForm.value
+                id_tipo_pago: +this.investmentProposalForm.value.tipo_pago,
+                id_cuenta_bancaria: +this.investmentProposalForm.value
                   .cuenta_bancaria,
 
                 //fecha_pago: this.investmentProposalForm.value.fecha_pago.singleDate.formatted,
                 fecha_vencimiento: this.investmentProposalForm.value
                   .fecha_vencimiento.singleDate.formatted,
-                id_inversion: this.investmentProposalID
+                id_inversion: +this.investmentProposalID
               };
 
-              if (this.investmentProposalForm.value.tipo_pago == 2) {
+              if (+this.investmentProposalForm.value.tipo_pago == 2) {
                 this.paymentObject[
                   "emitir_nombre"
                 ] = this.investmentProposalForm.value.emitir_nombre;
-              } else if (this.investmentProposalForm.value.tipo_pago == 3) {
-                this.paymentObject[
-                  "id_cuenta_bancaria_destino"
-                ] = this.investmentProposalForm.value.cuenta_bancaria_destino;
+              } else if (+this.investmentProposalForm.value.tipo_pago == 3) {
+                this.paymentObject["id_cuenta_bancaria_destino"] = +this
+                  .investmentProposalForm.value.cuenta_bancaria_destino;
               }
 
               this.investmentsService

+ 1 - 1
src/app/components/investment-proposals/payment-requirement/payment-requirement.component.ts

@@ -184,7 +184,7 @@ export class PaymentRequirementComponent implements OnInit {
         title: `<h3>Enviar información de pago</h3>`,
         icon: "info",
 
-        html: `${this.generated_inputs_next}`,
+        html: `<div>Notificar a:</div>${this.generated_inputs_next}`,
         confirmButtonText: "Enviar requisición",
         showCancelButton: true,
         cancelButtonText: "Cancelar",

+ 2 - 2
src/app/components/investment-proposals/result/result.component.ts

@@ -311,7 +311,7 @@ export class ResultComponent implements OnInit {
       .getAvailableUsers(this.investmentProposalID)
       .subscribe(res => {
         this.userList = res["usuarios_next"];
-        this.test = "";
+        this.test = "<div>Notificar a:</div>";
 
         if (this.userList.length > 0) {
           for (let i = 0; i < this.userList.length; i++) {
@@ -454,7 +454,7 @@ export class ResultComponent implements OnInit {
       .getAvailableUsers(this.investmentProposalID)
       .subscribe(res => {
         this.userList = res["usuarios_next"];
-        this.test = "";
+        this.test = "<div>Notificar a:</div>";
 
         if (this.userList.length > 0) {
           for (let i = 0; i < this.userList.length; i++) {

+ 3 - 3
src/app/components/investment-proposals/review/review.component.ts

@@ -381,7 +381,7 @@ export class InvestmentProposalReviewComponent implements OnInit {
           Swal.fire({
             title: `<h3>Revisión propuesta de inversión</h3>`,
             icon: "info",
-            html: `${this.generated_inputs_next}`,
+            html: `<div>Notificar a:</div>${this.generated_inputs_next}`,
             confirmButtonText: "Aprobar propuesta",
             showCancelButton: true,
             cancelButtonText: "Cancelar",
@@ -456,7 +456,7 @@ export class InvestmentProposalReviewComponent implements OnInit {
         preConfirm: comentario => {
           this.reviewProposal = {
             id_inversion: this.investmentProposalID,
-            step: "next",
+            step: "previous",
             comentario: comentario
           };
         },
@@ -466,7 +466,7 @@ export class InvestmentProposalReviewComponent implements OnInit {
           Swal.fire({
             title: `<h3>Revisión propuesta de inversión</h3>`,
             icon: "info",
-            html: `${this.generated_inputs_previous}`,
+            html: `<div>Notificar a:</div>${this.generated_inputs_previous}`,
             confirmButtonText: "Rechazar propuesta",
             showCancelButton: true,
             confirmButtonColor: "#C82333",

+ 60 - 0
src/app/components/investments/costs/vcn/vcn.costs.component.ts

@@ -243,6 +243,66 @@ 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"]["id_inversion_instrumento"][
+                        "instrumento"
+                      ]["proyecciones"];
+
+                    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
+                });
+              }
+            );
+        },
+        err => {
+          Swal.fire({
+            icon: "error",
+            title: "Error al guardar",
+            text: err.message
+          });
+        }
+      );
+  }
+
+  saveProjection() {
+    let objProjection = { proyecciones: this.form.value };
+    Swal.fire({
+      allowOutsideClick: false,
+      icon: "info",
+      text: "Espere por favor..."
+    });
+    Swal.showLoading();
+
+    this.instrumentService
+      .projectionModification(this.investmentProposalID, this.form.value)
       .subscribe(
         resp => {
           this.investmentsService

+ 14 - 1
src/app/services/instrument-calculations.service.ts

@@ -272,7 +272,20 @@ export class InstrumentCalculations {
 
   projectionCalc(id: string, proyecciones: any): Observable<boolean> {
     return this.http
-      .put<any>(`${environment.productionApiUrl}/autocomplete/${id}`, {
+      .post<any>(`${environment.productionApiUrl}/autocomplete/${id}`, {
+        proyecciones
+      })
+      .pipe(
+        map(response => {
+          return response;
+        }),
+        catchError(this.errorHandl)
+      );
+  }
+
+  projectionModification(id: string, proyecciones: any): Observable<boolean> {
+    return this.http
+      .put<any>(`${environment.productionApiUrl}/proyecciones/${id}`, {
         proyecciones
       })
       .pipe(