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

+ 38 - 217
src/app/components/incomes/general-form/general-form.component.html

@@ -26,193 +26,54 @@
           <div class="card borderless card-wrapper">
             <div class="wrapper-costs">
               <h4 class="card-title">
-                Información de la proyección para la fecha: {{ payment_date }}
+                Información de la proyección para la fecha: {{ projectionDate }}
               </h4>
-              <div class="align-container">
-                <div class="income-summary" *ngIf="projection_exists">
-                  <div class="row">
-                    <div class="col-lg-3 col-md-4 col-sm-6">
-                      <h4>Codigo de la inversión:</h4>
-                      <div class="field">
-                        {{ projection.codigo_inversion }}
-                      </div>
-                    </div>
-
-                    <div class="col-lg-3 col-md-4 col-sm-6">
-                      <h4>Nombre de la inversión:</h4>
-                      <div class="field">
-                        {{ projection.nombre_inversion }}
-                      </div>
-                    </div>
-
-                    <div class="col-lg-3 col-md-4 col-sm-6">
-                      <h4>Empresa:</h4>
-                      <div class="field">
-                        {{ projection.empresa }}
-                      </div>
+              <div class="income-summary" *ngIf="projection_exists">
+                <div class="row">
+                  <div class="col-lg-3 col-md-4 col-sm-6">
+                    <h4>Codigo de la inversión:</h4>
+                    <div class="field">
+                      {{ projectionRes.codigo_inversion }}
                     </div>
+                  </div>
 
-                    <div class="col-lg-3 col-md-4 col-sm-6">
-                      <h4>Tipo instrumento:</h4>
-                      <div class="field">
-                        {{ projection.tipo_instrumento }}
-                      </div>
+                  <div class="col-lg-3 col-md-4 col-sm-6">
+                    <h4>Empresa:</h4>
+                    <div class="field">
+                      {{ projectionRes.empresa }}
                     </div>
+                  </div>
 
-                    <div class="col-lg-3 col-md-4 col-sm-6">
-                      <h4>Capital:</h4>
-                      <div class="field">
-                        $USD {{ projection.capital | number: "1.2-4" }}
-                      </div>
-                    </div>
-                    <div class="col-lg-3 col-md-4 col-sm-6">
-                      <h4>Ingreso bruto:</h4>
-                      <div class="field">
-                        $USD {{ projection.ingreso_bruto | number: "1.2-4" }}
-                      </div>
-                    </div>
-                    <div class="col-lg-3 col-md-4 col-sm-6">
-                      <h4>Renta:</h4>
-                      <div class="field">
-                        $USD {{ projection.renta | number: "1.2-4" }}
-                      </div>
-                    </div>
-                    <div class="col-lg-3 col-md-4 col-sm-6">
-                      <h4>Ingreso neto:</h4>
-                      <div class="field">
-                        $USD {{ projection.ingreso_neto | number: "1.2-4" }}
-                      </div>
+                  <div class="col-lg-3 col-md-4 col-sm-6">
+                    <h4>Tipo instrumento:</h4>
+                    <div class="field">
+                      {{ projectionRes.tipo_instrumento }}
                     </div>
+                  </div>
 
-                    <div class="col-lg-3 col-md-4 col-sm-6">
-                      <h4>Capital faltante:</h4>
-                      <div class="field">
-                        $USD
-                        {{ projection.capital_faltante | number: "1.2-4" }}
-                      </div>
-                    </div>
-                    <div class="col-lg-3 col-md-4 col-sm-6">
-                      <h4>Ingreso bruto:</h4>
-                      <div class="field">
-                        $USD
-                        {{
-                          projection.ingreso_bruto_faltante | number: "1.2-4"
-                        }}
-                      </div>
+                  <div class="col-lg-3 col-md-4 col-sm-6">
+                    <h4>Capital:</h4>
+                    <div class="field">
+                      $USD {{ projectionRes.capital | number: "1.2-4" }}
                     </div>
-                    <div class="col-lg-3 col-md-4 col-sm-6">
-                      <h4>Renta:</h4>
-                      <div class="field">
-                        $USD {{ projection.renta_faltante | number: "1.2-4" }}
-                      </div>
+                  </div>
+                  <div class="col-lg-3 col-md-4 col-sm-6">
+                    <h4>Ingreso bruto:</h4>
+                    <div class="field">
+                      $USD {{ projectionRes.ingreso_bruto | number: "1.2-4" }}
                     </div>
-                    <div class="col-lg-3 col-md-4 col-sm-6">
-                      <h4>Ingreso neto:</h4>
-                      <div class="field">
-                        $USD
-                        {{ projection.ingreso_neto_faltante | number: "1.2-4" }}
-                      </div>
+                  </div>
+                  <div class="col-lg-3 col-md-4 col-sm-6">
+                    <h4>Renta:</h4>
+                    <div class="field">
+                      $USD {{ projectionRes.renta | number: "1.2-4" }}
                     </div>
                   </div>
-                </div>
-              </div>
-              <br />
-              <br />
-              <div *ngIf="incomes_exists">
-                <h4 class="card-title">
-                  Listado de ingresos parciales para proyección
-                </h4>
-                <div class="align-container">
-                  <div class="instrument-calcs-summary">
-                    <table
-                      mat-table
-                      [dataSource]="dataSource"
-                      class="example-table"
-                    >
-                      <ng-container matColumnDef="fecha_proyeccion_ingreso">
-                        <th mat-header-cell *matHeaderCellDef>
-                          Fecha de proyección
-                        </th>
-                        <td mat-cell *matCellDef="let row">
-                          {{
-                            row.fecha_proyeccion_ingreso == "" ||
-                            row.fecha_proyeccion_ingreso == undefined
-                              ? "-"
-                              : row.fecha_proyeccion_ingreso
-                          }}
-                        </td>
-                      </ng-container>
-                      <ng-container matColumnDef="fecha_ingreso">
-                        <th mat-header-cell *matHeaderCellDef>
-                          Fecha de ingreso
-                        </th>
-                        <td mat-cell *matCellDef="let row">
-                          {{
-                            row.fecha_ingreso == "" ||
-                            row.fecha_ingreso == undefined
-                              ? "-"
-                              : row.fecha_ingreso
-                          }}
-                        </td>
-                      </ng-container>
-                      <ng-container matColumnDef="fecha_conciliacion">
-                        <th mat-header-cell *matHeaderCellDef>
-                          Fecha conciliación
-                        </th>
-                        <td mat-cell *matCellDef="let row">
-                          {{
-                            row.fecha_conciliacion == "" ||
-                            row.fecha_conciliacion == undefined
-                              ? "-"
-                              : row.fecha_conciliacion
-                          }}
-                        </td>
-                      </ng-container>
-                      <ng-container matColumnDef="capital">
-                        <th mat-header-cell *matHeaderCellDef>Ingreso neto</th>
-                        <td mat-cell *matCellDef="let row">
-                          $USD
-                          {{
-                            row.capital == "" || row.capital == undefined
-                              ? "-"
-                              : (row.ingreso_neto | number: "1.2-4")
-                          }}
-                        </td>
-                      </ng-container>
-                      <ng-container matColumnDef="ingreso_bruto">
-                        <th mat-header-cell *matHeaderCellDef>Ingreso bruto</th>
-                        <td mat-cell *matCellDef="let row">
-                          $USD
-                          {{
-                            row.ingreso_bruto == "" ||
-                            row.ingreso_bruto == undefined
-                              ? "-"
-                              : (row.ingreso_bruto | number: "1.2-4")
-                          }}
-                        </td>
-                      </ng-container>
-                      <ng-container matColumnDef="renta">
-                        <th mat-header-cell *matHeaderCellDef>Renta</th>
-                        <td mat-cell *matCellDef="let row">
-                          {{
-                            row.renta == "" || row.renta == undefined
-                              ? "-"
-                              : (row.renta | number: "1.2-4")
-                          }}%
-                        </td>
-                      </ng-container>
-
-                      <tr
-                        mat-header-row
-                        *matHeaderRowDef="displayedColumns"
-                      ></tr>
-                      <tr
-                        mat-row
-                        *matRowDef="let row; columns: displayedColumns"
-                      ></tr>
-                    </table>
-
-                    <br />
+                  <div class="col-lg-3 col-md-4 col-sm-6">
+                    <h4>Ingreso neto:</h4>
+                    <div class="field">
+                      $USD {{ projectionRes.ingreso_neto | number: "1.2-4" }}
+                    </div>
                   </div>
                 </div>
               </div>
@@ -444,45 +305,6 @@
                       </div>
                     </div>
 
-                    <!-- Fecha vencimiento -->
-                    <div class="col-lg-6 col-sm-12 pr-xl-3">
-                      <div class="form-group">
-                        <label for="fecha_proyeccion_pago"
-                          >Fecha proyeccion pago:
-                        </label>
-
-                        <div class="input-box-container">
-                          <div>
-                            <p>
-                              <i class="far fa-calendar" aria-hidden="true"></i>
-                            </p>
-                            <input
-                              class="input-box form-control"
-                              placeholder="Seleccione una fecha"
-                              angular-mydatepicker
-                              formControlName="fecha_proyeccion_pago"
-                              (click)="dp2.toggleCalendar()"
-                              [options]="myDpOptions"
-                              #dp2="angular-mydatepicker"
-                              [ngClass]="{
-                                'is-invalid':
-                                  submitted && f.fecha_ingreso.errors
-                              }"
-                            />
-                          </div>
-                        </div>
-
-                        <div
-                          *ngIf="submitted && f.fecha_vencimiento.errors"
-                          class="invalid-feedback"
-                        >
-                          <div *ngIf="f.fecha_vencimiento.errors.required">
-                            Campo requerido
-                          </div>
-                        </div>
-                      </div>
-                    </div>
-
                     <div class="col-lg-6 col-sm-12 pr-xl-3">
                       <div class="form-group">
                         <label for="comentario">Comentarios: </label>
@@ -508,7 +330,7 @@
                       <button
                         class="btn btn-primary center-component float-left"
                         type="button"
-                        [disabled]="true"
+                        [disabled]="cantConciliate"
                         (click)="conciliateIncome()"
                       >
                         Conciliar ingreso
@@ -516,7 +338,6 @@
                       <button
                         class="btn btn-success center-component float-right"
                         type="submit"
-                        [disabled]="true"
                         (click)="submitIncome(investmentProposalForm)"
                       >
                         Guardar información de ingreso

+ 65 - 96
src/app/components/incomes/general-form/general-form.component.ts

@@ -113,6 +113,9 @@ export class GeneralIncomeFormComponent implements OnInit {
   projectionDate: any;
   projectionRes: any;
   partial: boolean;
+  idProjection: any;
+  cantConciliate: boolean = true;
+  conciliateObject: any;
 
   constructor(
     private catalogService: CatalogsService,
@@ -144,8 +147,8 @@ export class GeneralIncomeFormComponent implements OnInit {
   }
 
   ngOnInit() {
-    Swal.close();
     this.partial = false;
+
     const formDataObj = {};
 
     this.route.queryParams.subscribe(params => {
@@ -153,7 +156,8 @@ export class GeneralIncomeFormComponent implements OnInit {
       this.idInversion = params["id_inversion"];
       this.idInstrumentIncome = params["id_proyeccion_ingreso_instrumento"];
       this.projectionDate = params["fecha_proyeccion_pago"];
-
+      this.idProjection = params["id_proyeccion_ingreso"];
+      console.log("paarrams");
       console.log(params);
     });
 
@@ -161,26 +165,32 @@ export class GeneralIncomeFormComponent implements OnInit {
       .getProjection(
         this.idInversion,
         this.idInstrumentIncome,
-        this.projectionDate
+        this.projectionDate,
+        this.idProjection
       )
-      .subscribe(res => {
-        this.projectionRes = res;
-        console.log("proyeccion");
-        console.log(this.projectionRes);
-      });
-
-    this.incomesService
-      .getProjectionIncome(this.instrumentCode, this.projectionID)
       .subscribe(
         res => {
-          this.projection = res["result"]["proyeccion"];
           this.projection_exists = true;
-          this.incomes = res["result"]["ingresos"];
-          if (this.incomes.length) {
-            this.incomes_exists = true;
-            this.dataSource.data = this.incomes;
+          this.projectionRes = res["result"][0];
+
+          if (this.projectionRes.estado == "NO CONCILIADO") {
+            this.cantConciliate = false;
           }
-          this.payment_date = res["result"]["proyeccion"]["fecha_pago"];
+
+          console.log("proyeccion");
+          console.log(this.projectionRes);
+          this.investmentProposalForm.setValue({
+            capital: this.projectionRes.capital,
+            ingreso_bruto: this.projectionRes.ingreso_bruto,
+            renta: this.projectionRes.renta,
+            ingreso_neto: this.projectionRes.ingreso_neto,
+            tipo_pago: "",
+            cuenta_bancaria: "",
+            comentario: "",
+            fecha_inicio: "",
+            fecha_vencimiento: ""
+          });
+          Swal.close();
         },
         err => {
           Swal.fire({
@@ -238,7 +248,6 @@ export class GeneralIncomeFormComponent implements OnInit {
       cuenta_bancaria: ["", Validators.required],
       //fecha_ingreso: ["", Validators.required],
       comentario: [""],
-      fecha_proyeccion_pago: [""],
       fecha_inicio: [""],
       fecha_vencimiento: [""]
     });
@@ -258,78 +267,45 @@ export class GeneralIncomeFormComponent implements OnInit {
 
   submitIncome(form: any) {
     this.submitted = true;
+    console.log(form);
+    console.log(this.idProjection);
     if (!form.valid) {
       return false;
     }
 
     this.incomeObject = {
-      id_inversion_instrumento: this.idInversion,
-      id_proyeccion_ingreso_instrumento: this.projection.proyeccion_ingreso, // Revisar
-      id_proyeccion_ingreso: 1, // Obtener desde endpoint si es que hay
-      fecha_proyeccion_pago: "?",
-
-      //tipo_intrumento: this.projection.codigo_intrumento,
-      posicion_ingreso: this.projection.posicion,
-      id_inversion: this.projection.id_inversion,
-      fecha_pago: this.projection.fecha_pago,
-
-      //fecha_ingreso: this.form.value.fecha_ingreso.singleDate.formatted,
-      capital: this.form.value.capital,
-      ingreso_bruto: this.form.value.ingreso_bruto,
-      renta: this.form.value.renta,
-      ingreso_neto: this.form.value.ingreso_neto,
-      id_cuenta_bancaria: this.form.value.id_cuenta_bancaria,
-      id_tipo_pago: this.form.value.id_tipo_pago
+      id_inversion_instrumento: this.projectionRes.id_inversion_instrumento,
+      id_proyeccion_ingreso_instrumento: this.idInstrumentIncome,
+      fecha_proyeccion_pago: this.projectionDate,
+
+      capital: form.value.capital,
+      ingreso_bruto: form.value.ingreso_bruto,
+      renta: form.value.renta,
+      ingreso_neto: form.value.ingreso_neto,
+      id_cuenta_bancaria: form.value.cuenta_bancaria,
+      id_tipo_pago: form.value.tipo_pago,
+      comentario: form.value.comentario
     };
+    console.log("test");
+
+    if (this.idProjection != undefined) {
+      this.incomeObject["id_proyeccion_ingreso"] = this.idProjection;
+    }
 
     if (this.partial == true) {
-      this.incomeObject[
-        "fecha_inicio"
-      ] = this.form.value.fecha_inicio.singleDate.formatted;
-      this.incomeObject[
-        "fecha_vencimiento"
-      ] = this.form.value.fecha_vencimiento.singleDate.formatted;
+      this.incomeObject["fecha_inicio"] =
+        form.value.fecha_inicio.singleDate.formatted;
+      this.incomeObject["fecha_vencimiento"] =
+        form.value.fecha_vencimiento.singleDate.formatted;
     }
 
-    /*
-    submit income
-    "id_cuenta_bancaria": 5,
-    "id_tipo_pago": 2,
-    "ingreso_bruto": 1250.0,
-    "capital": 0,
-    "renta": 125.0,
-    "ingreso_neto": 1125.0,
-    "comentario": "DAP COMPLETO"
-    
-    "id_inversion_instrumento": 246,
-    "id_proyeccion_ingreso_instrumento": 17,
-    "id_proyeccion_ingreso": 1,
-    "fecha_proyeccion_pago": "28/04/2013",
-    "fecha_inicio": "10/10/2018",
-    "fecha_vencimiento": "10/10/2019",
-
-    GET proyeccion instrumento
-    "id_inversion": 42,
-    "id_inversion_instrumento": 66,
-    "codigo_inversion": "INVLETE00001",
-    "nombre_inversion": "TEST1",
-    "empresa": "Angelica de Chávez",
-    "codigo_empresa": "MADC",
-    "id_estado": null,
-    "estado": null,
-    "estado_inversion": "Finalizada",
-    "tipo_ingreso": "INGRESO_NATURAL",
-    "tipo_instrumento": "Letes",
-    "codigo_instrumento": "LETE",
-    "id_proyeccion_ingreso": null,
-    "id_proyeccion_ingreso_instrumento": 28,
-    "capital": 0.0,
-    "ingreso_bruto": 0.0,
-    "renta": 0.0,
-    "ingreso_neto": 0.0,
-    "fecha_proyeccion_pago": "05/03/2020"
-
-    */
+    Swal.fire({
+      allowOutsideClick: false,
+      icon: "info",
+      text: "Espere por favor..."
+    });
+    Swal.showLoading();
+
     this.incomesService.createIncome(this.incomeObject).subscribe(
       success => {
         if (success) {
@@ -341,7 +317,7 @@ export class GeneralIncomeFormComponent implements OnInit {
             confirmButtonText: "El ingreso ha sido guardado"
           }).then(result => {
             Swal.close();
-            window.location.href = "#/investment-incomes";
+            this.cantConciliate = false;
           });
         }
       },
@@ -356,23 +332,16 @@ export class GeneralIncomeFormComponent implements OnInit {
   }
 
   conciliateIncome() {
-    this.incomeObject = {
-      tipo_intrumento: this.projection.codigo_intrumento,
-      id_proyeccion_ingreso: this.projection.proyeccion_ingreso,
-      posicion_ingreso: this.projection.posicion,
-      id_inversion: this.projection.id_inversion,
-      fecha_pago: this.projection.fecha_pago,
-
-      fecha_ingreso: this.form.value.fecha_ingreso.singleDate.formatted,
-      capital: this.form.value.capital,
-      ingreso_bruto: this.form.value.ingreso_bruto,
-      renta: this.form.value.renta,
-      ingreso_neto: this.form.value.ingreso_neto,
-      id_cuenta_bancaria: this.form.value.id_cuenta_bancaria,
-      id_tipo_pago: this.form.value.id_tipo_pago
+    this.conciliateObject = {
+      id_inversion_instrumento: this.projectionRes.id_inversion_instrumento,
+      id_proyeccion_ingreso_instrumento: this.idInstrumentIncome,
+      fecha_proyeccion_pago: this.projectionDate
     };
+    if (this.idProjection != undefined) {
+      this.conciliateObject["id_proyeccion_ingreso"] = this.idProjection;
+    }
 
-    this.incomesService.createIncome(this.incomeObject).subscribe(
+    this.incomesService.conciliateIncome(this.conciliateObject).subscribe(
       success => {
         if (success) {
           Swal.fire({

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

@@ -151,7 +151,8 @@
                           go_to_instrument_url(
                             row.id_inversion,
                             row.id_proyeccion_ingreso_instrumento,
-                            row.fecha_proyeccion_pago
+                            row.fecha_proyeccion_pago,
+                            row.id_proyeccion_ingreso
                           )
                         "
                       >

+ 9 - 3
src/app/components/incomes/incomes.component.ts

@@ -209,7 +209,12 @@ export class IncomesComponent implements OnInit {
     return true;
   }
 
-  go_to_instrument_url(id: string, id_proyeccion: string, fecha: string) {
+  go_to_instrument_url(
+    id: string,
+    id_proyeccion_instrumento: string,
+    fecha: string,
+    id_proyeccion?: string
+  ) {
     Swal.fire({
       allowOutsideClick: false,
       icon: "info",
@@ -221,8 +226,9 @@ export class IncomesComponent implements OnInit {
       this.router.navigate([`/investment-income`], {
         queryParams: {
           id_inversion: id,
-          id_proyeccion_ingreso_instrumento: id_proyeccion,
-          fecha_proyeccion_pago: fecha
+          id_proyeccion_ingreso_instrumento: id_proyeccion_instrumento,
+          fecha_proyeccion_pago: fecha,
+          id_proyeccion_ingreso: id_proyeccion
         }
       });
     }, 1000);

+ 10 - 5
src/app/services/incomes.service.ts

@@ -62,12 +62,17 @@ export class IncomesService {
   getProjection(
     id_inversion: string,
     id_proyeccion_ingreso_instrumento: string,
-    fecha_proyeccion_pago: string
+    fecha_proyeccion_pago: string,
+    id_proyeccion_instrumento?: string
   ): Observable<boolean> {
+    let url;
+    if (id_proyeccion_instrumento != undefined) {
+      url = `?id_inversion=${id_inversion}&id_proyeccion_ingreso_instrumento=${id_proyeccion_ingreso_instrumento}&fecha_proyeccion_pago=${fecha_proyeccion_pago}&id_proyeccion_ingreso=${id_proyeccion_instrumento}`;
+    } else {
+      url = `?id_inversion=${id_inversion}&id_proyeccion_ingreso_instrumento=${id_proyeccion_ingreso_instrumento}&fecha_proyeccion_pago=${fecha_proyeccion_pago}`;
+    }
     return this.http
-      .get<any>(
-        `${environment.productionApiUrl}/proyeccion?id_inversion=${id_inversion}&id_proyeccion_ingreso_instrumento=${id_proyeccion_ingreso_instrumento}&fecha_proyeccion_pago=${fecha_proyeccion_pago}`
-      )
+      .get<any>(`${environment.productionApiUrl}/proyeccion${url}`)
       .pipe(
         map(response => {
           return response;
@@ -102,7 +107,7 @@ export class IncomesService {
 
   conciliateIncome(income: Object): Observable<boolean> {
     return this.http
-      .post<any>(`${environment.productionApiUrl}/ingreso`, income)
+      .post<any>(`${environment.productionApiUrl}/conciliacion`, income)
       .pipe(
         map(response => {
           return response;