Przeglądaj źródła

Guardado para proyecciones de cetes y dap, avance formulario de requisicion de pago, correccion para bug que impide navegar entre los pasos formularios de la propuesta de inversion en modo de produccion

Oscar José Nuñez Chávez 5 lat temu
rodzic
commit
18eb6152a3
18 zmienionych plików z 163 dodań i 81 usunięć
  1. 4 32
      src/app/components/instruments/cete/cete.component.html
  2. 3 0
      src/app/components/instruments/dap/dap.component.html
  3. 3 0
      src/app/components/instruments/lete/lete.component.html
  4. 3 0
      src/app/components/instruments/pbur/pbur.component.html
  5. 3 0
      src/app/components/instruments/vcn/vcn.component.html
  6. 2 0
      src/app/components/investment-proposals/complement-info/complement-info.component.html
  7. 1 0
      src/app/components/investment-proposals/general-info/general-info.component.html
  8. 21 3
      src/app/components/investment-proposals/investment-proposals.component.html
  9. 11 0
      src/app/components/investment-proposals/investment-proposals.component.ts
  10. 4 1
      src/app/components/investment-proposals/payment-info/payment-info.component.html
  11. 50 18
      src/app/components/investment-proposals/payment-requirement/payment-requirement.component.html
  12. 6 0
      src/app/components/investment-proposals/payment-requirement/payment-requirement.component.scss
  13. 29 23
      src/app/components/investment-proposals/payment-requirement/payment-requirement.component.ts
  14. 2 0
      src/app/components/investment-proposals/proposal-detail/proposal-detail.component.ts
  15. 4 0
      src/app/components/investment-proposals/result/result.component.html
  16. 6 1
      src/app/components/investment-proposals/result/result.component.ts
  17. 10 2
      src/app/components/investment-proposals/review/review.component.html
  18. 1 1
      src/app/components/investment-proposals/review/review.component.ts

+ 4 - 32
src/app/components/instruments/cete/cete.component.html

@@ -156,41 +156,13 @@
         </div>
       </div>
 
-      <!-- Plazo -->
-      <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-percent" aria-hidden="true"></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 *ngIf="f.plazo.errors.pattern">
-                Debe ingresar una cifra válida
-              </div>
-            </div>
-          </div>
-        </div>
-      </div>
-
       <!-- Otros Costos -->
       <div class="col-lg-6 col-sm-12 pr-xl-3">
         <div class="form-group">
           <label for="otros_costos">Otros costos: </label>
           <div class="input-box-container">
             <p>
-              <i class="fas fa-percent" aria-hidden="true"></i>
+              <i class="fas fa-dollar-sign"></i>
             </p>
             <input
               type="text"
@@ -360,6 +332,7 @@
         <div class="form-group text-right">
           <br />
           <button
+            type="button"
             class="btn btn-success center-component"
             (click)="getCalculations(investmentProposalForm, false)"
           >
@@ -482,21 +455,20 @@
     <br />
     <div class="form-group text-center space-20">
       <button
+        type="button"
         class="btn btn-default center-component margin-right"
         (click)="goToPrevious()"
       >
         Anterior
       </button>
       <button
+        type="submit"
         class="btn btn-primary center-component margin-right"
         (click)="goToNext(investmentProposalForm)"
       >
         Siguiente
       </button>
     </div>
-
-    <!-- [disabled]="!investmentProposalForm.valid"
-                      <div *ngIf="error" class="alert alert-danger mt-3 mb-0">{{error}}</div>-->
   </form>
 </div>
 

+ 3 - 0
src/app/components/instruments/dap/dap.component.html

@@ -198,6 +198,7 @@
         <div class="form-group text-right">
           <br />
           <button
+            type="button"
             class="btn btn-success center-component"
             (click)="getCalculations(investmentProposalForm, false)"
           >
@@ -334,12 +335,14 @@
     <br />
     <div class="form-group text-center space-20">
       <button
+        type="button"
         class="btn btn-default center-component margin-right"
         (click)="goToPrevious()"
       >
         Anterior
       </button>
       <button
+        type="submit"
         class="btn btn-primary center-component margin-right"
         (click)="goToNext(investmentProposalForm)"
       >

+ 3 - 0
src/app/components/instruments/lete/lete.component.html

@@ -254,6 +254,7 @@
         <div class="form-group text-right">
           <br />
           <button
+            type="button"
             class="btn btn-success center-component"
             (click)="getCalculations(investmentProposalForm, false)"
           >
@@ -314,12 +315,14 @@
     <br />
     <div class="form-group text-center space-20">
       <button
+        type="button"
         class="btn btn-default center-component margin-right"
         (click)="goToPrevious()"
       >
         Anterior
       </button>
       <button
+        type="submit"
         class="btn btn-primary center-component margin-right"
         (click)="goToNext(investmentProposalForm)"
       >

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

@@ -344,6 +344,7 @@
         <div class="form-group text-right">
           <br />
           <button
+            type="button"
             class="btn btn-success center-component"
             (click)="getCalculations(investmentProposalForm, false)"
           >
@@ -416,12 +417,14 @@
     <br />
     <div class="form-group text-center space-20">
       <button
+        type="button"
         class="btn btn-default center-component margin-right"
         (click)="goToPrevious()"
       >
         Anterior
       </button>
       <button
+        type="submit"
         class="btn btn-primary center-component margin-right"
         (click)="goToNext(investmentProposalForm)"
       >

+ 3 - 0
src/app/components/instruments/vcn/vcn.component.html

@@ -344,6 +344,7 @@
         <div class="form-group text-right">
           <br />
           <button
+            type="button"
             class="btn btn-success center-component"
             (click)="getCalculations(investmentProposalForm, false)"
           >
@@ -418,12 +419,14 @@
     <br />
     <div class="form-group text-center space-20">
       <button
+        type="button"
         class="btn btn-default center-component margin-right"
         (click)="goToPrevious()"
       >
         Anterior
       </button>
       <button
+        type="submit"
         class="btn btn-primary center-component margin-right"
         (click)="goToNext(investmentProposalForm)"
       >

+ 2 - 0
src/app/components/investment-proposals/complement-info/complement-info.component.html

@@ -383,12 +383,14 @@
                   <br />
                   <div class="form-group text-center space-20">
                     <button
+                      type="button"
                       class="btn btn-default center-component margin-right"
                       (click)="goToPrevious()"
                     >
                       Anterior
                     </button>
                     <button
+                      type="submit"
                       class="btn btn-primary center-component margin-right"
                       (click)="goToNext(investmentProposalForm)"
                     >

+ 1 - 0
src/app/components/investment-proposals/general-info/general-info.component.html

@@ -349,6 +349,7 @@
                   <br />
                   <div class="form-group text-center space-20">
                     <button
+                      type="submit"
                       class="btn btn-primary center-component margin-right"
                       (click)="goToNext(investmentProposalForm)"
                     >

+ 21 - 3
src/app/components/investment-proposals/investment-proposals.component.html

@@ -98,7 +98,7 @@
                     <div class="action-buttons">
                       <a
                         title="Detalle propuesta"
-                        class="btn btn-success btn-custom-small"
+                        class="btn btn-primary btn-custom-small"
                         (click)="view_investment_proposal(row.id_inversion)"
                       >
                         <i class="fas fa-info"></i>
@@ -142,7 +142,10 @@
                         <i class="fas fa-spell-check"></i>
                       </a>
                       <a
-                        title="Informacion de pago"
+                        *ngIf="
+                          can_write_payment_info(row.id_estado_inversion.codigo)
+                        "
+                        title="Información de pago"
                         class="btn btn-warning btn-custom-small"
                         [routerLink]="[
                           '/investment-proposal',
@@ -152,6 +155,21 @@
                       >
                         <i class="fas fa-money-check-alt"></i>
                       </a>
+                      <a
+                        *ngIf="
+                          can_write_payment_info(row.id_estado_inversion.codigo)
+                        "
+                        title="Requisición de pago"
+                        class="btn btn-success btn-custom-small"
+                        [routerLink]="[
+                          '/investment-proposal',
+                          row.id_inversion,
+                          'payment'
+                        ]"
+                      >
+                        <i class="fas fa-money-bill-wave"></i>
+                      </a>
+                      <!--
                       <a
                         title="Historico"
                         class="btn btn-link btn-custom-small"
@@ -162,7 +180,7 @@
                         ]"
                       >
                         <i class="fas fa-history"></i>
-                      </a>
+                      </a>-->
                     </div>
                   </td>
                 </ng-container>

+ 11 - 0
src/app/components/investment-proposals/investment-proposals.component.ts

@@ -124,6 +124,7 @@ export class InvestmentProposalsComponent implements OnInit {
       icon: "info",
       text: "Espere por favor..."
     });
+    Swal.showLoading();
     setTimeout(() => {
       this.router.navigate([`/investment-proposal/${id}`]);
     }, 1000);
@@ -179,6 +180,15 @@ export class InvestmentProposalsComponent implements OnInit {
     }
   }
 
+  can_write_payment_info(status: string) {
+    if (status == "REVIS" && (this.userRole.length == 0 || this.userRole)) {
+      // TO DO ver que el codigo de los tipos de usuario
+      return true;
+    } else {
+      return false;
+    }
+  }
+
   sendToReview(investmentProposalID: number, investmentCode: string) {
     (async () => {
       const { value: comentario } = await Swal.fire({
@@ -215,6 +225,7 @@ export class InvestmentProposalsComponent implements OnInit {
                   confirmButtonText: "La propuesta ha sido enviada a revisión"
                 }).then(result => {
                   Swal.close();
+                  window.location.reload();
                 });
               }
             },

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

@@ -201,7 +201,10 @@
                 <div class="col-lg-12 col-sm-12 pr-xl-12">
                   <div class="form-group text-right">
                     <br />
-                    <button class="btn btn-primary center-component">
+                    <button
+                      class="btn btn-primary center-component"
+                      type="submit"
+                    >
                       Enviar información de pago
                     </button>
                   </div>

+ 50 - 18
src/app/components/investment-proposals/payment-requirement/payment-requirement.component.html

@@ -15,7 +15,7 @@
                   Propuestas de inversión
                 </a>
               </li>
-              <li class="breadcrumb-item">Revisar</li>
+              <li class="breadcrumb-item">Requisición</li>
             </ol>
           </nav>
         </div>
@@ -30,28 +30,60 @@
           <div class="card borderless">
             <div class="card-header card-header-icon card-header-rose">
               <h4 class="card-title">
-                Resumen de la propuesta
+                Requisición
               </h4>
             </div>
             <div class="card-body">
               <div class="align-container">
-                <form [formGroup]="form" (ngSubmit)="submitForm()">
-                  <div class="form-group">
-                    asdasd
-                    <input type="file" (change)="uploadFile($event)" />
-                  </div>
+                <form>
+                  <div class="row">
+                    <div class="col-lg-6 col-sm-12 pr-xl-6">
+                      <div class="form-group">
+                        <label for="comentario">Comentario: </label>
 
-                  <div class="form-group input-group-lg">
-                    <input
-                      class="form-control"
-                      placeholder="Name"
-                      formControlName="name"
-                    />
-                  </div>
-                  <div class="review-buttons">
-                    <button class="btn btn-success">
-                      Guardar requisición de pago
-                    </button>
+                        <textarea
+                          rows="2"
+                          class="form-control"
+                          name="comentario"
+                        ></textarea>
+                      </div>
+                    </div>
+
+                    <div class="col-lg-6 col-sm-12 pr-xl-6">
+                      <div class="form-group">
+                        <label for="justificacion">Archivo: </label>
+
+                        <input
+                          type="file"
+                          name="evidencia"
+                          (change)="fileProgress($event)"
+                        />
+                      </div>
+                      <br />
+                      <div *ngIf="fileUploadProgress">
+                        Progreso: {{ fileUploadProgress }}
+                      </div>
+                      <div class="image-preview mb-3" *ngIf="previewUrl">
+                        <img [src]="previewUrl" height="300" />
+                      </div>
+
+                      <div class="mb-3" *ngIf="uploadedFilePath">
+                        {{ uploadedFilePath }}
+                      </div>
+                    </div>
+
+                    <br />
+                    <div class="col-lg-6 col-sm-12 pr-xl-6">
+                      <div class="form-group">
+                        <button
+                          class="btn btn-primary"
+                          (click)="onSubmit()"
+                          type="submit"
+                        >
+                          Enviar requisición de pago
+                        </button>
+                      </div>
+                    </div>
                   </div>
                 </form>
               </div>

+ 6 - 0
src/app/components/investment-proposals/payment-requirement/payment-requirement.component.scss

@@ -19,3 +19,9 @@
 .drop-file-over {
   background: #333;
 }
+
+.form-group input[type="file"] {
+  opacity: 1;
+  z-index: 1;
+  position: relative;
+}

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

@@ -2,7 +2,7 @@ import { Component, OnInit } from "@angular/core";
 import { FileUploader, FileLikeObject } from "ng2-file-upload";
 import { concat } from "rxjs";
 import { FormBuilder, FormGroup } from "@angular/forms";
-import { HttpClient } from "@angular/common/http";
+import { HttpClient, HttpEventType } from "@angular/common/http";
 
 @Component({
   selector: "app-payment-requirement",
@@ -13,34 +13,40 @@ export class PaymentRequirementComponent implements OnInit {
   title: string = "Formulario de requisición de pago";
 
   form: FormGroup;
-  public uploader: FileUploader = new FileUploader({});
-  public hasBaseDropZoneOver: boolean = false;
+  fileData: File = null;
+  previewUrl: any = null;
+  fileUploadProgress: string = null;
+  uploadedFilePath: string = null;
+  constructor(private http: HttpClient) {}
 
   ngOnInit() {}
 
-  constructor(public fb: FormBuilder, private http: HttpClient) {
-    this.form = this.fb.group({
-      name: [""],
-      avatar: [null]
-    });
+  fileProgress(fileInput: any) {
+    this.fileData = <File>fileInput.target.files[0];
+    this.preview();
   }
 
-  uploadFile(event) {
-    const file = (event.target as HTMLInputElement).files[0];
-    this.form.patchValue({
-      avatar: file
-    });
-    this.form.get("avatar").updateValueAndValidity();
-  }
+  preview() {
+    // Show preview
+    var mimeType = this.fileData.type;
+    if (mimeType.match(/image\/*/) == null) {
+      return;
+    }
 
-  submitForm() {
-    var formData: any = new FormData();
-    formData.append("name", this.form.get("name").value);
-    formData.append("avatar", this.form.get("avatar").value);
+    var reader = new FileReader();
+    reader.readAsDataURL(this.fileData);
+    reader.onload = _event => {
+      this.previewUrl = reader.result;
+    };
+  }
 
-    this.http.post("http://localhost:4000/api/create-user", formData).subscribe(
-      response => console.log(response),
-      error => console.log(error)
-    );
+  onSubmit() {
+    const formData = new FormData();
+    formData.append("file", this.fileData);
+    this.http.post("url/to/your/api", formData).subscribe(res => {
+      console.log(res);
+      //this.uploadedFilePath = res.data.filePath;
+      alert("SUCCESS !!");
+    });
   }
 }

+ 2 - 0
src/app/components/investment-proposals/proposal-detail/proposal-detail.component.ts

@@ -77,6 +77,7 @@ export class InvestmentProposalDetailComponent implements OnInit {
 
   ngOnInit() {
     //this.formDataService
+
     this.ads = this.loadInstrumentsService.getInstruments();
     this.route.params.subscribe(params => {
       this.investmentProposalID = params["id"];
@@ -305,6 +306,7 @@ export class InvestmentProposalDetailComponent implements OnInit {
     } else {
       this.investmentExists = false;
     }
+    Swal.close();
   }
 
   loadComponent() {

+ 4 - 0
src/app/components/investment-proposals/result/result.component.html

@@ -187,6 +187,7 @@
                     class="btn btn-success center-component"
                     [disabled]="!isFormValid"
                     (click)="submit()"
+                    type="button"
                   >
                     Guardar propuesta
                   </button>
@@ -202,18 +203,21 @@
 
                   <button
                     class="btn btn-primary center-component float-right"
+                    type="button"
                     (click)="sendToReview()"
                   >
                     Enviar a revision
                   </button>
                   <button
                     class="btn btn-success center-component margin-right float-right"
+                    type="button"
                     (click)="update_proposal()"
                   >
                     Guardar propuesta
                   </button>
                   <button
                     class="btn btn-default center-component margin-right float-right"
+                    type="button"
                     (click)="goToPrevious()"
                   >
                     Anterior

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

@@ -214,7 +214,8 @@ export class ResultComponent implements OnInit {
     this.final = {};
 
     Object.assign(this.final, this.general, this.instrument, this.complement);
-
+    console.log("info instrument");
+    console.log(this.instrument);
     this.inversion = {
       codigo_instrumento: this.general.instrumentos,
       info_inversion: {
@@ -246,7 +247,9 @@ export class ResultComponent implements OnInit {
       (this.instrument["proyecciones"] != undefined ||
         this.instrument["proyecciones"] != "")
     ) {
+      console.log("is an required object");
       this.inversion["proyecciones"] = this.instrument["proyecciones"];
+      console.log(this.inversion);
     }
   }
 
@@ -352,6 +355,8 @@ export class ResultComponent implements OnInit {
 
   // Actualizar la propuesta de inversion si se han realizado cambios
   update_proposal() {
+    console.log("update inversion");
+    console.log(this.inversion);
     this.investmentService
       .updateProposalInvestment(this.investmentProposalID, this.inversion)
       .subscribe(

+ 10 - 2
src/app/components/investment-proposals/review/review.component.html

@@ -163,11 +163,19 @@
                   </li>
                 </ul>
                 <div class="review-buttons">
-                  <button class="btn btn-danger " (click)="dismiss_proposal()">
+                  <button
+                    class="btn btn-danger "
+                    (click)="dismiss_proposal()"
+                    type="button"
+                  >
                     Rechazar propuesta
                   </button>
 
-                  <button class="btn btn-success " (click)="approve_proposal()">
+                  <button
+                    class="btn btn-success "
+                    (click)="approve_proposal()"
+                    type="button"
+                  >
                     Aprobar propuesta
                   </button>
                 </div>

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

@@ -394,7 +394,7 @@ export class InvestmentProposalReviewComponent implements OnInit {
       if (comentario) {
         this.reviewProposal = {
           id_inversion: this.investmentProposalID,
-          step: "next",
+          step: "previous",
           comentario: comentario
         };