|
@@ -113,6 +113,9 @@ export class GeneralIncomeFormComponent implements OnInit {
|
|
|
projectionDate: any;
|
|
projectionDate: any;
|
|
|
projectionRes: any;
|
|
projectionRes: any;
|
|
|
partial: boolean;
|
|
partial: boolean;
|
|
|
|
|
+ idProjection: any;
|
|
|
|
|
+ cantConciliate: boolean = true;
|
|
|
|
|
+ conciliateObject: any;
|
|
|
|
|
|
|
|
constructor(
|
|
constructor(
|
|
|
private catalogService: CatalogsService,
|
|
private catalogService: CatalogsService,
|
|
@@ -144,8 +147,8 @@ export class GeneralIncomeFormComponent implements OnInit {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
ngOnInit() {
|
|
|
- Swal.close();
|
|
|
|
|
this.partial = false;
|
|
this.partial = false;
|
|
|
|
|
+
|
|
|
const formDataObj = {};
|
|
const formDataObj = {};
|
|
|
|
|
|
|
|
this.route.queryParams.subscribe(params => {
|
|
this.route.queryParams.subscribe(params => {
|
|
@@ -153,7 +156,8 @@ export class GeneralIncomeFormComponent implements OnInit {
|
|
|
this.idInversion = params["id_inversion"];
|
|
this.idInversion = params["id_inversion"];
|
|
|
this.idInstrumentIncome = params["id_proyeccion_ingreso_instrumento"];
|
|
this.idInstrumentIncome = params["id_proyeccion_ingreso_instrumento"];
|
|
|
this.projectionDate = params["fecha_proyeccion_pago"];
|
|
this.projectionDate = params["fecha_proyeccion_pago"];
|
|
|
-
|
|
|
|
|
|
|
+ this.idProjection = params["id_proyeccion_ingreso"];
|
|
|
|
|
+ console.log("paarrams");
|
|
|
console.log(params);
|
|
console.log(params);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -161,26 +165,32 @@ export class GeneralIncomeFormComponent implements OnInit {
|
|
|
.getProjection(
|
|
.getProjection(
|
|
|
this.idInversion,
|
|
this.idInversion,
|
|
|
this.idInstrumentIncome,
|
|
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(
|
|
.subscribe(
|
|
|
res => {
|
|
res => {
|
|
|
- this.projection = res["result"]["proyeccion"];
|
|
|
|
|
this.projection_exists = true;
|
|
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 => {
|
|
err => {
|
|
|
Swal.fire({
|
|
Swal.fire({
|
|
@@ -238,7 +248,6 @@ export class GeneralIncomeFormComponent implements OnInit {
|
|
|
cuenta_bancaria: ["", Validators.required],
|
|
cuenta_bancaria: ["", Validators.required],
|
|
|
//fecha_ingreso: ["", Validators.required],
|
|
//fecha_ingreso: ["", Validators.required],
|
|
|
comentario: [""],
|
|
comentario: [""],
|
|
|
- fecha_proyeccion_pago: [""],
|
|
|
|
|
fecha_inicio: [""],
|
|
fecha_inicio: [""],
|
|
|
fecha_vencimiento: [""]
|
|
fecha_vencimiento: [""]
|
|
|
});
|
|
});
|
|
@@ -258,78 +267,45 @@ export class GeneralIncomeFormComponent implements OnInit {
|
|
|
|
|
|
|
|
submitIncome(form: any) {
|
|
submitIncome(form: any) {
|
|
|
this.submitted = true;
|
|
this.submitted = true;
|
|
|
|
|
+ console.log(form);
|
|
|
|
|
+ console.log(this.idProjection);
|
|
|
if (!form.valid) {
|
|
if (!form.valid) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
this.incomeObject = {
|
|
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) {
|
|
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(
|
|
this.incomesService.createIncome(this.incomeObject).subscribe(
|
|
|
success => {
|
|
success => {
|
|
|
if (success) {
|
|
if (success) {
|
|
@@ -341,7 +317,7 @@ export class GeneralIncomeFormComponent implements OnInit {
|
|
|
confirmButtonText: "El ingreso ha sido guardado"
|
|
confirmButtonText: "El ingreso ha sido guardado"
|
|
|
}).then(result => {
|
|
}).then(result => {
|
|
|
Swal.close();
|
|
Swal.close();
|
|
|
- window.location.href = "#/investment-incomes";
|
|
|
|
|
|
|
+ this.cantConciliate = false;
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
@@ -356,23 +332,16 @@ export class GeneralIncomeFormComponent implements OnInit {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
conciliateIncome() {
|
|
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 => {
|
|
success => {
|
|
|
if (success) {
|
|
if (success) {
|
|
|
Swal.fire({
|
|
Swal.fire({
|