FIX: En movimientos ahora se muestran las categorias y otros detalles faltantes.
This commit is contained in:
@ -64,7 +64,11 @@
|
|||||||
<th>Valor</th>
|
<th>Valor</th>
|
||||||
<th>Glosa</th>
|
<th>Glosa</th>
|
||||||
<th>Centro de Costo</th>
|
<th>Centro de Costo</th>
|
||||||
|
<th>Categoría</th>
|
||||||
<th>Detalle</th>
|
<th>Detalle</th>
|
||||||
|
<th>RUT</th>
|
||||||
|
<th>Nombre</th>
|
||||||
|
<th>Identificador</th>
|
||||||
<th>Editar</th>
|
<th>Editar</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -18,23 +18,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.columns = [
|
this.columns = [
|
||||||
{title: 'Sigla', defs: {width: 'short', type: 'string'}, searchable: true, export: true}, //0
|
{title: 'Sigla', defs: {width: 'short', type: 'string'}, process: movimiento => movimiento.cuenta.inmobiliaria.sigla, args: ['movimiento'], searchable: true, export: true}, //0
|
||||||
{title: 'Banco', defs: {width: 'long', type: 'string'}, searchable: true, export: true},
|
{title: 'Banco', defs: {width: 'long', type: 'string'}, process: movimiento => movimiento.cuenta.banco.nombre, args: ['movimiento'], searchable: true, export: true},
|
||||||
{title: 'Cuenta', defs: {width: 'short', type: 'string'}, searchable: true, export: true},
|
{title: 'Cuenta', defs: {width: 'short', type: 'string'}, process: movimiento => movimiento.cuenta.cuenta, args: ['movimiento'], searchable: true, export: true},
|
||||||
{title: 'Fecha', defs: {width: 'long', type: 'string'}, searchable: true, export: true},
|
{title: 'Fecha', defs: {width: 'long', type: 'string'}, process: fecha => this.props.formatters.date.format(fecha), args: ['fecha'], searchable: true, export: true, format: (value) => value.split('-').reverse().join('-')},
|
||||||
{title: 'ISO Fecha', defs: {visible: false}},
|
{title: 'ISO Fecha', defs: {visible: false}, process: fecha => [fecha.getFullYear(), fecha.getMonth() + 1, fecha.getDate()].join('-'), args: ['fecha']},
|
||||||
{title: 'Mes', defs: {width: 'short', type: 'string'}, searchable: true}, //5
|
{title: 'Mes', defs: {width: 'short', type: 'string'}, process: fecha => fecha.getMonth() + 1, args: ['fecha'], searchable: true}, //5
|
||||||
{title: 'Año', defs: {width: 'long', type: 'string'}, searchable: true},
|
{title: 'Año', defs: {width: 'long', type: 'string'}, process: fecha => fecha.getFullYear(), args: ['fecha'], searchable: true},
|
||||||
{title: 'Valor', defs: {className: 'dt-right', width: 'long', type: 'num'}, export: true},
|
{title: 'Valor', defs: {className: 'dt-right', width: 'long', type: 'num'}, process: valor => this.props.formatters.number.format(valor), args: ['valor'], export: true, format: (value) => value.replace(/\./g, '')},
|
||||||
{title: 'ISO Valor', defs: {visible: false, type: 'num'}},
|
{title: 'ISO Valor', defs: {visible: false, type: 'num'}, args: ['valor']},
|
||||||
{title: 'Glosa', defs: {width: 'short', type: 'string'}, export: true},
|
{title: 'Glosa', defs: {width: 'short', type: 'string'}, process: movimiento => movimiento.glosa, args: ['movimiento'], export: true},
|
||||||
{title: 'Centro de Costo', defs: {width: 'short', type: 'string'}, searchable: true, export: true}, //10
|
{title: 'Centro de Costo', defs: {width: 'short', type: 'string'}, process: movimiento => (movimiento.detalles && movimiento.detalles.centro_costo) ? movimiento.detalles.centro_costo.id : '', args: ['movimiento'], searchable: true, export: true}, //10
|
||||||
{title: 'Categoria', defs: {width: 'short', type: 'string'}},
|
{title: 'Categoría', defs: {width: 'short', type: 'string'}, process: movimiento => (movimiento.detalles) ? movimiento.detalles.categoria : '', args: ['movimiento'], searchable: true, export: true},
|
||||||
{title: 'Detalle', defs: {width: 'long', type: 'string'}, export: true},
|
{title: 'Detalle', defs: {width: 'long', type: 'string'}, process: movimiento => (movimiento.detalles) ? movimiento.detalles.detalle : '', args: ['movimiento'], export: true},
|
||||||
{title: 'RUT', defs: {width: 'short', type: 'string'}, export: true},
|
{title: 'RUT', defs: {width: 'short', type: 'string'}, process: movimiento => (movimiento.detalles && movimiento.detalles.digito) ? `${this.props.formatters.number.format(movimiento.detalles.rut)}-${movimiento.detalles.digito}` : '', args: ['movimiento'], searchable: true, export: true},
|
||||||
{title: 'Nombre', defs: {width: 'short', type: 'string'}, export: true},
|
{title: 'Nombre', defs: {width: 'short', type: 'string'}, args: ['nombre'], searchable: true, export: true},
|
||||||
{title: 'Identificador', defs: {width: 'short', type: 'string'}, export: true}, //15
|
{title: 'Identificador', defs: {width: 'short', type: 'string'}, process: movimiento => (movimiento.detalles) ? movimiento.detalles.identificador : '', args: ['movimiento'], export: true}, //15
|
||||||
{title: 'Editar', defs: {width: 'short', type: 'string'}},
|
{title: 'Editar', defs: {width: 'short', type: 'string'}, args: ['buttonsHTML']},
|
||||||
]
|
]
|
||||||
const N = this.columns.filter(column => typeof column.defs.visible === 'undefined' || column.defs.visible).length
|
const N = this.columns.filter(column => typeof column.defs.visible === 'undefined' || column.defs.visible).length
|
||||||
const nShort = this.columns.filter(column => column.defs.width === 'short').length
|
const nShort = this.columns.filter(column => column.defs.width === 'short').length
|
||||||
@ -134,12 +134,14 @@
|
|||||||
exportOptions: {
|
exportOptions: {
|
||||||
columns: exportColumns,
|
columns: exportColumns,
|
||||||
format: {
|
format: {
|
||||||
body: (data, row, column, node) => {
|
body: (data, row, columnIdx, node) => {
|
||||||
if (column === this.columns.map(({title}) => title).indexOf('Fecha')) {
|
const formats = this.columns.filter(columnDef => columnDef.format)
|
||||||
return data.split('-').reverse().join('-')
|
const match = formats.map(({title}) => title).indexOf(this.columns[columnIdx].title)
|
||||||
|
if (match > -1) {
|
||||||
|
return formats[match].format(data)
|
||||||
}
|
}
|
||||||
if (column === this.columns.map(({title}) => title).indexOf('Valor')) {
|
if (typeof data === 'string' && data.includes('<span data-tooltip')) {
|
||||||
return data.replace(/\./g, '')
|
return data.replace(/<span data-tooltip="(.*)">(.*)<\/span>/, '$2')
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
@ -214,25 +216,28 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = {
|
const params = {
|
||||||
Sigla: movimiento.cuenta.inmobiliaria.sigla,
|
movimiento,
|
||||||
Banco: movimiento.cuenta.banco.nombre,
|
fecha,
|
||||||
Cuenta: movimiento.cuenta.cuenta,
|
valor,
|
||||||
Fecha: this.props.formatters.date.format(fecha),
|
nombre,
|
||||||
'ISO Fecha': [fecha.getFullYear(), fecha.getMonth() + 1, fecha.getDate()].join('-'),
|
buttonsHTML,
|
||||||
Mes: fecha.getMonth() + 1,
|
|
||||||
'Año': fecha.getFullYear(),
|
|
||||||
Valor: this.props.formatters.number.format(valor),
|
|
||||||
'ISO Valor': valor,
|
|
||||||
Glosa: movimiento.glosa,
|
|
||||||
'Centro de Costo': (movimiento.detalles && movimiento.detalles.centro_costo) ? movimiento.detalles.centro_costo.id : '',
|
|
||||||
Categoria: (movimiento.detalles) ? movimiento.detalles.categoria : '',
|
|
||||||
Detalle: (movimiento.detalles) ? movimiento.detalles.detalle : '',
|
|
||||||
RUT: (movimiento.detalles && movimiento.detalles.digito) ? `${this.props.formatters.number.format(movimiento.detalles.rut)}-${movimiento.detalles.digito}` : '',
|
|
||||||
Nombre: nombre,
|
|
||||||
Identificador: (movimiento.detalles) ? movimiento.detalles.identificador : '',
|
|
||||||
Editar: buttonsHTML,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const data = {}
|
||||||
|
this.columns.forEach(column => {
|
||||||
|
if (column.process) {
|
||||||
|
const args = Object.entries(params).filter(([param, value]) => column.args.includes(param)).map(arr => arr[1])
|
||||||
|
data[column.title] = column.process(...args)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (column.args) {
|
||||||
|
data[column.title] = Object.entries(params).filter(([param, value]) => column.args.includes(param)).map(arr => arr[1])[0]
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data[column.title] = params[column.title.toLowerCase()]
|
||||||
|
})
|
||||||
|
|
||||||
const values = []
|
const values = []
|
||||||
this.columns.forEach(column => {
|
this.columns.forEach(column => {
|
||||||
values.push(data[column.title])
|
values.push(data[column.title])
|
||||||
|
Reference in New Issue
Block a user