Oscar José Nuñez Chávez 5 lat temu
rodzic
commit
58a5c72420

+ 70 - 2
src/app/components/incomes/general-form/general-form.component.html

@@ -321,6 +321,70 @@
                         </div>
                       </div>
                     </div>
+                  </div>
+                  <br />
+                  <div class="row">
+                    <div class="col-12">
+                      <div class="custom-control custom-switch">
+                        <input
+                          type="checkbox"
+                          class="custom-control-input"
+                          id="customSwitch1"
+                          (click)="toggle()"
+                        />
+                        <label class="custom-control-label" for="customSwitch1"
+                          >Ingreso parcial</label
+                        >
+                      </div>
+                    </div>
+                    <div class="col-lg-6 col-sm-12 pr-xl-3" *ngIf="partial">
+                      <div class="form-group">
+                        <label for="fecha_inicio">Fecha inicio: </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_inicio"
+                              (click)="dp0.toggleCalendar()"
+                              [options]="myDpOptions"
+                              #dp0="angular-mydatepicker"
+                            />
+                          </div>
+                        </div>
+                      </div>
+                    </div>
+                    <div class="col-lg-6 col-sm-12 pr-xl-3" *ngIf="partial">
+                      <div class="form-group">
+                        <label for="fecha_vencimiento"
+                          >Fecha vencimiento:
+                        </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_vencimiento"
+                              (click)="dp0.toggleCalendar()"
+                              [options]="myDpOptions"
+                              #dp0="angular-mydatepicker"
+                            />
+                          </div>
+                        </div>
+                      </div>
+                    </div>
+                  </div>
+                  <div class="row">
                     <div class="col-lg-6 col-sm-12 pr-xl-3">
                       <div class="form-group">
                         <label for="payment_types">Tipo pago: </label>
@@ -383,7 +447,9 @@
                     <!-- Fecha vencimiento -->
                     <div class="col-lg-6 col-sm-12 pr-xl-3">
                       <div class="form-group">
-                        <label for="fecha_vencimiento">Fecha ingreso: </label>
+                        <label for="fecha_proyeccion_pago"
+                          >Fecha proyeccion pago:
+                        </label>
 
                         <div class="input-box-container">
                           <div>
@@ -394,7 +460,7 @@
                               class="input-box form-control"
                               placeholder="Seleccione una fecha"
                               angular-mydatepicker
-                              formControlName="fecha_ingreso"
+                              formControlName="fecha_proyeccion_pago"
                               (click)="dp2.toggleCalendar()"
                               [options]="myDpOptions"
                               #dp2="angular-mydatepicker"
@@ -442,6 +508,7 @@
                       <button
                         class="btn btn-primary center-component float-left"
                         type="button"
+                        [disabled]="true"
                         (click)="conciliateIncome()"
                       >
                         Conciliar ingreso
@@ -449,6 +516,7 @@
                       <button
                         class="btn btn-success center-component float-right"
                         type="submit"
+                        [disabled]="true"
                         (click)="submitIncome(investmentProposalForm)"
                       >
                         Guardar información de ingreso

+ 113 - 33
src/app/components/incomes/general-form/general-form.component.ts

@@ -108,6 +108,11 @@ export class GeneralIncomeFormComponent implements OnInit {
   incomeObject: any;
   incomes: any;
   incomes_exists: boolean;
+  idInversion: any;
+  idInstrumentIncome: any;
+  projectionDate: any;
+  projectionRes: any;
+  partial: boolean;
 
   constructor(
     private catalogService: CatalogsService,
@@ -123,9 +128,6 @@ export class GeneralIncomeFormComponent implements OnInit {
       this.authService.getJwtToken()
     );
     this.userRole = decodedToken.groups;
-    //    console.log("User role");
-    //  console.log(this.userRole);
-    //console.log(this.userRole.length == 0);
 
     Swal.fire({
       allowOutsideClick: false,
@@ -143,36 +145,51 @@ export class GeneralIncomeFormComponent implements OnInit {
 
   ngOnInit() {
     Swal.close();
+    this.partial = false;
     const formDataObj = {};
 
-    this.route.params.subscribe(params => {
-      this.instrumentCode = params["instrument"];
-      this.projectionID = params["id"];
+    this.route.queryParams.subscribe(params => {
+      // ALT
+      this.idInversion = params["id_inversion"];
+      this.idInstrumentIncome = params["id_proyeccion_ingreso_instrumento"];
+      this.projectionDate = params["fecha_proyeccion_pago"];
+
+      console.log(params);
     });
 
-    if (this.projectionID != undefined) {
-      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.payment_date = res["result"]["proyeccion"]["fecha_pago"];
-          },
-          err => {
-            Swal.fire({
-              icon: "error",
-              title: "Error en el servidor",
-              text: err.message
-            });
+    this.incomesService
+      .getProjection(
+        this.idInversion,
+        this.idInstrumentIncome,
+        this.projectionDate
+      )
+      .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.payment_date = res["result"]["proyeccion"]["fecha_pago"];
+        },
+        err => {
+          Swal.fire({
+            icon: "error",
+            title: "Error en el servidor",
+            text: err.message
+          });
+        }
+      );
 
     this.catalogService.getPaymentTypes().subscribe(res => {
       this.payment_types = res;
@@ -219,7 +236,11 @@ export class GeneralIncomeFormComponent implements OnInit {
       ],
       tipo_pago: ["", Validators.required],
       cuenta_bancaria: ["", Validators.required],
-      fecha_ingreso: ["", Validators.required]
+      //fecha_ingreso: ["", Validators.required],
+      comentario: [""],
+      fecha_proyeccion_pago: [""],
+      fecha_inicio: [""],
+      fecha_vencimiento: [""]
     });
   }
 
@@ -227,21 +248,32 @@ export class GeneralIncomeFormComponent implements OnInit {
     return this.investmentProposalForm.controls;
   }
 
+  toggle = () => {
+    if (this.partial == false) {
+      this.partial = true;
+    } else {
+      this.partial = false;
+    }
+  };
+
   submitIncome(form: any) {
     this.submitted = true;
-    console.log(form);
     if (!form.valid) {
       return false;
     }
 
     this.incomeObject = {
-      tipo_intrumento: this.projection.codigo_intrumento,
-      id_proyeccion_ingreso: this.projection.proyeccion_ingreso,
+      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,
+      //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,
@@ -250,6 +282,54 @@ export class GeneralIncomeFormComponent implements OnInit {
       id_tipo_pago: this.form.value.id_tipo_pago
     };
 
+    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;
+    }
+
+    /*
+    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"
+
+    */
     this.incomesService.createIncome(this.incomeObject).subscribe(
       success => {
         if (success) {

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

@@ -149,8 +149,9 @@
                         class="btn btn-success btn-custom-small"
                         (click)="
                           go_to_instrument_url(
-                            row.proyeccion_ingreso,
-                            row.codigo_instrumento
+                            row.id_inversion,
+                            row.id_proyeccion_ingreso_instrumento,
+                            row.fecha_proyeccion_pago
                           )
                         "
                       >

+ 8 - 2
src/app/components/incomes/incomes.component.ts

@@ -209,7 +209,7 @@ export class IncomesComponent implements OnInit {
     return true;
   }
 
-  go_to_instrument_url(id: string, code: string) {
+  go_to_instrument_url(id: string, id_proyeccion: string, fecha: string) {
     Swal.fire({
       allowOutsideClick: false,
       icon: "info",
@@ -218,7 +218,13 @@ export class IncomesComponent implements OnInit {
     Swal.showLoading();
 
     setTimeout(() => {
-      this.router.navigate([`/investment-income/${code}/${id}`]);
+      this.router.navigate([`/investment-income`], {
+        queryParams: {
+          id_inversion: id,
+          id_proyeccion_ingreso_instrumento: id_proyeccion,
+          fecha_proyeccion_pago: fecha
+        }
+      });
     }, 1000);
   }
 }

+ 1 - 1
src/app/layouts/admin/admin.routing.ts

@@ -217,7 +217,7 @@ export const AdminLayoutRoutes: Routes = [
     component: IncomesComponent
   },
   {
-    path: "investment-income/:instrument/:id",
+    path: "investment-income",
     component: GeneralIncomeFormComponent
   } /*
   {