Procházet zdrojové kódy

format pper y pemp

ahernandez před 5 roky
rodič
revize
89de3d5147

+ 12 - 12
src/app/components/instruments/pemp/pemp.component.html

@@ -316,7 +316,7 @@
                 {{
                   row.tasa_porcentaje == "" || row.tasa_porcentaje == undefined
                     ? "0"
-                    : row.tasa_porcentaje
+                    : row.tasa_porcentaje | number: "1.2-4"
                 }}%
               </td>
               <td mat-footer-cell *matFooterCellDef>
@@ -333,7 +333,7 @@
                 ${{
                   row.ingreso_bruto == "" || row.ingreso_bruto == undefined
                     ? "0"
-                    : row.ingreso_bruto
+                    : row.ingreso_bruto | number: "1.2-4"
                 }}
               </td>
               <td mat-footer-cell *matFooterCellDef>
@@ -349,7 +349,7 @@
                 ${{
                   row.ingreso_neto == "" || row.ingreso_neto == undefined
                     ? "0"
-                    : row.ingreso_neto
+                    : row.ingreso_neto | number: "1.2-4"
                 }}
               </td>
               <td mat-footer-cell *matFooterCellDef>
@@ -362,7 +362,7 @@
             <ng-container matColumnDef="iva">
               <th mat-header-cell *matHeaderCellDef>IVA</th>
               <td mat-cell *matCellDef="let row">
-                ${{ row.iva == "" || row.iva == undefined ? "0" : row.iva }}
+                ${{ row.iva == "" || row.iva == undefined ? "0" : row.iva | number: "1.2-4"}}
               </td>
               <td mat-footer-cell *matFooterCellDef>
                 ${{ consolidado_proyeccion.total_iva | number: "1.2-4" }}
@@ -393,7 +393,7 @@
                 ${{
                   row.monto_recibir == "" || row.monto_recibir == undefined
                     ? "0"
-                    : row.monto_recibir
+                    : row.monto_recibir | number: "1.2-4"
                 }}
               </td>
               <td mat-footer-cell *matFooterCellDef>
@@ -410,7 +410,7 @@
                   row.capital_restante == "" ||
                   row.capital_restante == undefined
                     ? "0"
-                    : row.capital_restante
+                    : row.capital_restante | number: "1.2-4"
                 }}
               </td>
               <td mat-footer-cell *matFooterCellDef>
@@ -557,7 +557,7 @@
                 {{
                   row.tasa_porcentaje == "" || row.tasa_porcentaje == undefined
                     ? "0"
-                    : row.tasa_porcentaje
+                    : row.tasa_porcentaje | number: "1.2-4"
                 }}%
               </td>
               <td mat-footer-cell *matFooterCellDef></td>
@@ -569,7 +569,7 @@
                 ${{
                   row.ingreso_bruto == "" || row.ingreso_bruto == undefined
                     ? "0"
-                    : row.ingreso_bruto
+                    : row.ingreso_bruto | number: "1.2-4"
                 }}
               </td>
               <td mat-footer-cell *matFooterCellDef>
@@ -585,7 +585,7 @@
                 ${{
                   row.ingreso_neto == "" || row.ingreso_neto == undefined
                     ? "0"
-                    : row.ingreso_neto
+                    : row.ingreso_neto | number: "1.2-4"
                 }}
               </td>
               <td mat-footer-cell *matFooterCellDef>
@@ -598,7 +598,7 @@
             <ng-container matColumnDef="iva">
               <th mat-header-cell *matHeaderCellDef>IVA</th>
               <td mat-cell *matCellDef="let row">
-                ${{ row.iva == "" || row.iva == undefined ? "0" : row.iva }}
+                ${{ row.iva == "" || row.iva == undefined ? "0" : row.iva | number: "1.2-4"}}
               </td>
               <td mat-footer-cell *matFooterCellDef>
                 ${{ consolidado_proyeccion.total_iva | number: "1.2-4" }}
@@ -629,7 +629,7 @@
                 ${{
                   row.monto_recibir == "" || row.monto_recibir == undefined
                     ? "0"
-                    : row.monto_recibir
+                    : row.monto_recibir | number: "1.2-4"
                 }}
               </td>
               <td mat-footer-cell *matFooterCellDef>
@@ -646,7 +646,7 @@
                   row.capital_restante == "" ||
                   row.capital_restante == undefined
                     ? "0"
-                    : row.capital_restante
+                    : row.capital_restante | number: "1.2-4"
                 }}
               </td>
               <td mat-footer-cell *matFooterCellDef>

+ 13 - 4
src/app/components/investments/costs/pemp/pemp.costs.component.html

@@ -197,6 +197,7 @@
                               <input
                                 type="text"
                                 formControlName="ingreso_bruto"
+                                [value]="group.get('ingreso_bruto').value | number: '1.2-4'"
                                 class="form-control"
                                 readonly
                               />
@@ -216,6 +217,7 @@
                               <input
                                 type="text"
                                 formControlName="ingreso_neto"
+                                [value]="group.get('ingreso_neto').value | number: '1.2-4'"
                                 class="form-control"
                                 readonly
                               />
@@ -233,8 +235,10 @@
                                 <i class="fas fa-percent"></i>
                               </p>
                               <input
-                                type="number"
+                                type="text"
                                 formControlName="tasa_porcentaje"
+                                [value]="group.get('tasa_porcentaje').value | numberPipe" 
+                                (input)="inputValidator($event)"
                                 class="form-control"
                               />
                             </div>
@@ -253,8 +257,10 @@
                                 <i class="fas fa-dollar-sign"></i>
                               </p>
                               <input
-                                type="number"
+                                type="text"
                                 formControlName="amortizacion_capital"
+                                [value]="group.get('amortizacion_capital').value | numberPipe" 
+                                (input)="inputValidator($event)"
                                 class="form-control"
                               />
                             </div>
@@ -271,8 +277,9 @@
                                 <i class="fas fa-dollar-sign"></i>
                               </p>
                               <input
-                                type="number"
+                                type="text"
                                 formControlName="monto_recibir"
+                                [value]="group.get('monto_recibir').value | number: '1.2-4'"
                                 class="form-control"
                                 readonly
                               />
@@ -293,6 +300,7 @@
                               <input
                                 type="text"
                                 formControlName="iva"
+                                [value]="group.get('iva').value | number: '1.2-4'"
                                 class="form-control"
                                 readonly
                               />
@@ -312,8 +320,9 @@
                                 <i class="fas fa-dollar-sign"></i>
                               </p>
                               <input
-                                type="number"
+                                type="text"
                                 formControlName="capital_restante"
+                                [value]="group.get('capital_restante').value | number: '1.2-4'"
                                 class="form-control"
                                 readonly
                               />

+ 36 - 2
src/app/components/investments/costs/pemp/pemp.costs.component.ts

@@ -132,9 +132,43 @@ export class PEMPCostsComponent implements OnInit {
       Swal.close();
     }, 1200);
   }
-
+  clearProyeccion(proyecciones,nombres,tipoDato){
+    let clearPro = []  
+ 
+     proyecciones.forEach(createNewProyeccion); 
+   
+    function createNewProyeccion(arrFila, index) {
+     nombres.forEach(loopNombres);
+    
+     function loopNombres(nombre, index) {
+ 
+       arrFila[nombre] = parseFloat(arrFila[nombre].toString().replace(",",""))        
+       } 
+       clearPro.push(arrFila)
+       
+     } 
+ 
+   return clearPro;
+   }
+ 
+   public inputValidator(event: any) {
+     //console.log(event.target.value);
+     const pattern = /^[0-9]*$/;   
+     //let inputChar = String.fromCharCode(event.charCode)
+     
+     if (!pattern.test(event.target.value)) {
+ 
+       event.target.value = event.target.value.replace(/[^\d,.]+/g, '');
+       // invalid character, prevent input
+ 
+     }
+     
+   }
   recalculateProjectionChanges() {
-    let objProjection = { proyecciones: this.form.value };
+    let nombresProyecciones = ["tasa_porcentaje",
+                              "amortizacion_capital"]
+    let clearPro = this.clearProyeccion(this.form.value,nombresProyecciones,"decimal")
+    let objProjection = { proyecciones: clearPro };
     Swal.fire({
       allowOutsideClick: false,
       icon: "info",

+ 25 - 6
src/app/components/investments/costs/pper/pper.costs.component.html

@@ -195,9 +195,11 @@
                                 <i class="fas fa-percent"></i>
                               </p>
                               <input
-                                type="number"
+                                type="text"
                                 formControlName="tasa_porcentaje"
+                                [value]="group.get('tasa_porcentaje').value | numberPipe" 
                                 class="form-control"
+                                (input)="inputValidator($event)"
                               />
                             </div>
                           </div>
@@ -216,6 +218,7 @@
                               <input
                                 type="text"
                                 formControlName="saldo_inicial"
+                                [value]="group.get('saldo_inicial').value | number: '1.2-4'"
                                 class="form-control"
                                 readonly
                               />
@@ -236,6 +239,7 @@
                               <input
                                 type="text"
                                 formControlName="pago_cuota"
+                                [value]="group.get('pago_cuota').value | number: '1.2-4'"
                                 class="form-control"
                                 readonly
                               />
@@ -256,6 +260,7 @@
                               <input
                                 type="text"
                                 formControlName="ingreso_bruto"
+                                [value]="group.get('ingreso_bruto').value | number: '1.2-4'"
                                 class="form-control"
                                 readonly
                               />
@@ -274,8 +279,9 @@
                                 <i class="fas fa-percent"></i>
                               </p>
                               <input
-                                type="number"
+                                type="text"
                                 formControlName="iva_interes"
+                                [value]="group.get('iva_interes').value | number: '1.2-4'"
                                 class="form-control"
                                 readonly
                               />
@@ -296,6 +302,7 @@
                               <input
                                 type="text"
                                 formControlName="ingreso_neto"
+                                [value]="group.get('ingreso_neto').value | number: '1.2-4'"
                                 class="form-control"
                                 readonly
                               />
@@ -316,6 +323,7 @@
                               <input
                                 type="text"
                                 formControlName="abono_capital"
+                                [value]="group.get('abono_capital').value | number: '1.2-4'"
                                 class="form-control"
                                 readonly
                               />
@@ -338,6 +346,7 @@
                               <input
                                 type="text"
                                 formControlName="capital_restante"
+                                [value]="group.get('capital_restante').value | number: '1.2-4'"
                                 class="form-control"
                                 readonly
                               />
@@ -360,8 +369,11 @@
                               <input
                                 type="text"
                                 formControlName="pago_seguro_dano"
+                                [value]="group.get('pago_seguro_dano').value | numberPipe" 
                                 class="form-control"
-                                readonly
+                                (input)="inputValidator($event)"
+                                class="form-control"
+                                
                               />
                             </div>
                           </div>
@@ -381,8 +393,11 @@
                               <input
                                 type="text"
                                 formControlName="pago_seguro_vivienda"
+                                [value]="group.get('pago_seguro_vivienda').value | numberPipe" 
                                 class="form-control"
-                                readonly
+                                (input)="inputValidator($event)"
+                                class="form-control"
+                                
                               />
                             </div>
                           </div>
@@ -401,6 +416,7 @@
                               <input
                                 type="text"
                                 formControlName="total_cuota"
+                                [value]="group.get('total_cuota').value | number: '1.2-4'"
                                 class="form-control"
                                 readonly
                               />
@@ -421,9 +437,11 @@
                                 <i class="fas fa-dollar-sign"></i>
                               </p>
                               <input
-                                type="number"
+                                type="text"
                                 formControlName="amortizacion_capital"
+                                [value]="group.get('amortizacion_capital').value | numberPipe" 
                                 class="form-control"
+                                (input)="inputValidator($event)"
                               />
                             </div>
                           </div>
@@ -439,8 +457,9 @@
                                 <i class="fas fa-dollar-sign"></i>
                               </p>
                               <input
-                                type="number"
+                                type="text"
                                 formControlName="total_recibir"
+                                [value]="group.get('total_recibir').value | number: '1.2-4'"
                                 class="form-control"
                                 readonly
                               />

+ 38 - 2
src/app/components/investments/costs/pper/pper.costs.component.ts

@@ -132,9 +132,45 @@ export class PPERCostsComponent implements OnInit {
       Swal.close();
     }, 1200);
   }
-
+  clearProyeccion(proyecciones,nombres,tipoDato){
+    let clearPro = []  
+ 
+     proyecciones.forEach(createNewProyeccion); 
+   
+    function createNewProyeccion(arrFila, index) {
+     nombres.forEach(loopNombres);
+    
+     function loopNombres(nombre, index) {
+ 
+       arrFila[nombre] = parseFloat(arrFila[nombre].toString().replace(",",""))        
+       } 
+       clearPro.push(arrFila)
+       
+     } 
+ 
+   return clearPro;
+   }
+ 
+   public inputValidator(event: any) {
+     //console.log(event.target.value);
+     const pattern = /^[0-9]*$/;   
+     //let inputChar = String.fromCharCode(event.charCode)
+     
+     if (!pattern.test(event.target.value)) {
+ 
+       event.target.value = event.target.value.replace(/[^\d,.]+/g, '');
+       // invalid character, prevent input
+ 
+     }
+     
+   }
   recalculateProjectionChanges() {
-    let objProjection = { proyecciones: this.form.value };
+    let nombresProyecciones = ["tasa_porcentaje",
+                                "amortizacion_capital",
+                                 "pago_seguro_dano",
+                                 "pago_seguro_vivienda"]
+    let clearPro = this.clearProyeccion(this.form.value,nombresProyecciones,"decimal")
+    let objProjection = { proyecciones: clearPro };
     Swal.fire({
       allowOutsideClick: false,
       icon: "info",