Browse Source

Merge branch 'features-o' of onunez/frontend-inversiones into development

Oscar José Nuñez Chávez 5 years ago
parent
commit
a72b34419b

+ 17 - 11
src/app/components/incomes/general-form/general-form.component.html

@@ -112,7 +112,10 @@
                               type="text"
                               formControlName="capital"
                               class="form-control"
-                              [value]="investmentProposalForm.get('capital').value | numberPipe" 
+                              [value]="
+                                investmentProposalForm.get('capital').value
+                                  | numberPipe
+                              "
                               (input)="inputValidator($event)"
                               [ngClass]="{
                                 'is-invalid': submitted && f.capital.errors
@@ -144,7 +147,10 @@
                             <input
                               type="text"
                               formControlName="ingreso_bruto"
-                              [value]="investmentProposalForm.get('ingreso_bruto').value | numberPipe" 
+                              [value]="
+                                investmentProposalForm.get('ingreso_bruto')
+                                  .value | numberPipe
+                              "
                               (input)="inputValidator($event)"
                               class="form-control"
                               [ngClass]="{
@@ -178,7 +184,10 @@
                             <input
                               type="text"
                               formControlName="ingreso_neto"
-                              [value]="investmentProposalForm.get('ingreso_neto').value | numberPipe" 
+                              [value]="
+                                investmentProposalForm.get('ingreso_neto')
+                                  .value | numberPipe
+                              "
                               (input)="inputValidator($event)"
                               class="form-control"
                               [ngClass]="{
@@ -299,27 +308,24 @@
                           </div>
                         </div>
                       </div>
-
                       <div class="col-lg-6 col-sm-12 pr-xl-3">
                         <div class="form-group">
-                          <label for="cuenta_bancaria">Cuenta bancaria: </label>
+                          <label for="cuenta_bancaria"
+                            >Cuenta bancaria destino:
+                          </label>
 
                           <select
                             class="custom-select"
                             formControlName="cuenta_bancaria"
-                            [ngClass]="{
-                              'is-invalid':
-                                submitted && f.cuenta_bancaria.errors
-                            }"
                           >
                             <option
-                              *ngFor="let item of accounts"
+                              *ngFor="let item of accounts_destination"
                               [value]="item.id_cuenta_bancaria"
                             >
-                              {{ nameBankAccounts(item.id_banco) }} -
                               {{ item.nombre }}</option
                             >
                           </select>
+
                           <div
                             *ngIf="submitted && f.cuenta_bancaria.errors"
                             class="invalid-feedback"

+ 14 - 13
src/app/components/incomes/general-form/general-form.component.ts

@@ -118,6 +118,8 @@ export class GeneralIncomeFormComponent implements OnInit {
   conciliateObject: any;
   has_conciliate: boolean;
   showIncomeForm: boolean = false;
+  accounts_origin: any;
+  accounts_destination: any;
 
   constructor(
     private catalogService: CatalogsService,
@@ -142,12 +144,6 @@ export class GeneralIncomeFormComponent implements OnInit {
     Swal.showLoading();
   }
 
-  nameBankAccounts(id: string) {
-    let bank;
-    bank = this.banks.find(e => e.id_banco == id);
-    return bank.nombre;
-  }
-
   ngOnInit() {
     this.partial = false;
 
@@ -161,6 +157,18 @@ export class GeneralIncomeFormComponent implements OnInit {
       this.idProjection = params["id_proyeccion_ingreso"];
     });
 
+    this.catalogService
+      .getBankAccounts("origen", this.idInversion)
+      .subscribe(res => {
+        this.accounts_origin = res["result"];
+      });
+
+    this.catalogService
+      .getBankAccounts("destino", this.idInversion)
+      .subscribe(res => {
+        this.accounts_destination = res["result"];
+      });
+
     this.incomesService
       .getProjection(
         this.idInversion,
@@ -214,13 +222,6 @@ export class GeneralIncomeFormComponent implements OnInit {
     this.catalogService.getCountries().subscribe(res => {
       this.funds = res;
     });
-    this.catalogService.getCatalogInfo("bancos").subscribe(res => {
-      this.banks = res;
-      this.catalogService.getCatalogInfo("cuentas-bancarias").subscribe(res => {
-        this.accounts = res;
-      });
-      //this.payment_types = res;
-    });
 
     this.investmentProposalForm = this.formBuilder.group({
       capital: [

+ 78 - 44
src/app/components/instruments/titulos/titulos.component.ts

@@ -503,15 +503,6 @@ export class TIT implements InstrumentComponent {
           comision_bolsa_porcentaje_compra: this.f
             .comision_bolsa_porcentaje_compra.value,
 
-          valor_nominal_venta: +this.f.valor_nominal_venta.value,
-          precio_venta: +this.f.precio_venta.value,
-          precio_vencimiento_venta: +this.f.precio_vencimiento_venta.value,
-          cupon_porcentaje_venta: +this.f.cupon_porcentaje_venta.value,
-          comision_casa_porcentaje_venta: this.f.comision_casa_porcentaje_venta
-            .value,
-          comision_bolsa_porcentaje_venta: this.f
-            .comision_bolsa_porcentaje_venta.value,
-
           fecha_vencimiento_compra:
             this.f.fecha_vencimiento_compra.value == ""
               ? ""
@@ -525,6 +516,14 @@ export class TIT implements InstrumentComponent {
               ? ""
               : this.f.fecha_liquidacion_compra.value.singleDate.formatted,
 
+          valor_nominal_venta: +this.f.valor_nominal_venta.value,
+          precio_venta: +this.f.precio_venta.value,
+          precio_vencimiento_venta: +this.f.precio_vencimiento_venta.value,
+          cupon_porcentaje_venta: +this.f.cupon_porcentaje_venta.value,
+          comision_casa_porcentaje_venta: this.f.comision_casa_porcentaje_venta
+            .value,
+          comision_bolsa_porcentaje_venta: this.f
+            .comision_bolsa_porcentaje_venta.value,
           fecha_vencimiento_venta:
             this.f.fecha_vencimiento_venta.value == ""
               ? ""
@@ -688,24 +687,6 @@ export class TIT implements InstrumentComponent {
             fecha_liquidacion_compra: this.f.fecha_liquidacion_compra.value
               .singleDate.formatted,
 
-            valor_nominal_venta: this.investmentProposalForm.value
-              .valor_nominal_venta,
-            precio_venta: this.investmentProposalForm.value.precio_venta,
-            precio_vencimiento_venta: this.investmentProposalForm.value
-              .precio_vencimiento_venta,
-            cupon_porcentaje_venta: this.investmentProposalForm.value
-              .cupon_porcentaje_venta,
-            comision_casa_porcentaje_venta: this.investmentProposalForm.value
-              .comision_casa_porcentaje_venta,
-            comision_bolsa_porcentaje_venta: this.investmentProposalForm.value
-              .comision_bolsa_porcentaje_venta,
-            fecha_vencimiento_venta: this.f.fecha_vencimiento_venta.value
-              .singleDate.formatted,
-            fecha_ultima_cupon_venta: this.f.fecha_ultima_cupon_venta.value
-              .singleDate.formatted,
-            fecha_liquidacion_venta: this.f.fecha_liquidacion_venta.value
-              .singleDate.formatted,
-            fecha_emision: this.f.fecha_emision.value.singleDate.formatted,
             // Instrumento de compra
 
             comision_casa_compra: this.comision_casa_compra,
@@ -724,24 +705,7 @@ export class TIT implements InstrumentComponent {
             valor_transado_compra: this.valor_transado_compra,
             monto_pagar: this.monto_pagar,
             fecha_inicio_vigencia: this.fecha_inicio_vigencia,
-            // Instrumento de venta
 
-            comision_casa_venta: this.comision_casa_venta,
-            comision_bolsa_venta: this.comision_bolsa_venta,
-
-            fecha_siguiente_cupon_venta: this.fecha_siguiente_cupon_venta,
-            dias_vencimiento_venta: this.dias_vencimiento_venta,
-            dias_acumulados_venta: this.dias_acumulados_venta,
-            ytm_vencimiento_porcentaje_venta: this
-              .ytm_vencimiento_porcentaje_venta,
-            ytm_vencimiento_comision_porcentaje_venta: this
-              .ytm_vencimiento_comision_porcentaje_venta,
-
-            interes_acumulado_venta: this.interes_acumulado_venta,
-            interes_acumulado_porcentaje_venta: this
-              .interes_acumulado_porcentaje_venta,
-            precio_sucio_porcentaje_venta: this.precio_sucio_porcentaje_venta,
-            valor_transado_venta: this.valor_transado_venta,
             // Resultado de la operacion
             /*
             monto_recibir: this.monto_recibir,
@@ -763,6 +727,76 @@ export class TIT implements InstrumentComponent {
             proyecciones: this.proyecciones
           };
 
+          if (this.tipoEjecucion == 1) {
+            this.titulosObject[
+              "valor_nominal_venta"
+            ] = this.investmentProposalForm.value.valor_nominal_venta;
+            this.titulosObject[
+              "precio_venta"
+            ] = this.investmentProposalForm.value.precio_venta;
+            this.titulosObject[
+              "precio_vencimiento_venta"
+            ] = this.investmentProposalForm.value.precio_vencimiento_venta;
+            this.titulosObject[
+              "cupon_porcentaje_venta"
+            ] = this.investmentProposalForm.value.cupon_porcentaje_venta;
+            this.titulosObject[
+              "comision_casa_porcentaje_venta"
+            ] = this.investmentProposalForm.value.comision_casa_porcentaje_venta;
+            this.titulosObject[
+              "comision_bolsa_porcentaje_venta"
+            ] = this.investmentProposalForm.value.comision_bolsa_porcentaje_venta;
+            this.titulosObject[
+              "fecha_vencimiento_venta"
+            ] = this.f.fecha_vencimiento_venta.value.singleDate.formatted;
+            this.titulosObject[
+              "fecha_ultima_cupon_venta"
+            ] = this.f.fecha_ultima_cupon_venta.value.singleDate.formatted;
+            this.titulosObject[
+              "fecha_liquidacion_venta"
+            ] = this.f.fecha_liquidacion_venta.value.singleDate.formatted;
+            this.titulosObject[
+              "fecha_emision"
+            ] = this.f.fecha_emision.value.singleDate.formatted;
+            // Instrumento de venta
+
+            this.titulosObject[
+              "comision_casa_venta"
+            ] = this.comision_casa_venta;
+            this.titulosObject[
+              "comision_bolsa_venta"
+            ] = this.comision_bolsa_venta;
+
+            this.titulosObject[
+              "fecha_siguiente_cupon_venta"
+            ] = this.fecha_siguiente_cupon_venta;
+            this.titulosObject[
+              "dias_vencimiento_venta"
+            ] = this.dias_vencimiento_venta;
+            this.titulosObject[
+              "dias_acumulados_venta"
+            ] = this.dias_acumulados_venta;
+            this.titulosObject[
+              "ytm_vencimiento_porcentaje_venta"
+            ] = this.ytm_vencimiento_porcentaje_venta;
+            this.titulosObject[
+              "ytm_vencimiento_comision_porcentaje_venta"
+            ] = this.ytm_vencimiento_comision_porcentaje_venta;
+
+            this.titulosObject[
+              "interes_acumulado_venta"
+            ] = this.interes_acumulado_venta;
+            this.titulosObject[
+              "interes_acumulado_porcentaje_venta"
+            ] = this.interes_acumulado_porcentaje_venta;
+            this.titulosObject[
+              "precio_sucio_porcentaje_venta"
+            ] = this.precio_sucio_porcentaje_venta;
+            this.titulosObject[
+              "valor_transado_venta"
+            ] = this.valor_transado_venta;
+          }
+
           this.formDataService.setWork(this.titulosObject);
           Swal.close();
           if (saveForm == true) {