|
|
@@ -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) {
|