diff --git a/app/resources/views/contabilidad/movimientos.blade.php b/app/resources/views/contabilidad/movimientos.blade.php
index 2d204f1..b0c30c2 100644
--- a/app/resources/views/contabilidad/movimientos.blade.php
+++ b/app/resources/views/contabilidad/movimientos.blade.php
@@ -64,7 +64,11 @@
Valor |
Glosa |
Centro de Costo |
+ Categoría |
Detalle |
+ RUT |
+ Nombre |
+ Identificador |
Editar |
diff --git a/app/resources/views/contabilidad/movimientos/scripts/movimientos_table.blade.php b/app/resources/views/contabilidad/movimientos/scripts/movimientos_table.blade.php
index 56af7ee..48fedb8 100644
--- a/app/resources/views/contabilidad/movimientos/scripts/movimientos_table.blade.php
+++ b/app/resources/views/contabilidad/movimientos/scripts/movimientos_table.blade.php
@@ -18,23 +18,23 @@
}
this.columns = [
- {title: 'Sigla', defs: {width: 'short', type: 'string'}, searchable: true, export: true}, //0
- {title: 'Banco', defs: {width: 'long', type: 'string'}, searchable: true, export: true},
- {title: 'Cuenta', defs: {width: 'short', type: 'string'}, searchable: true, export: true},
- {title: 'Fecha', defs: {width: 'long', type: 'string'}, searchable: true, export: true},
- {title: 'ISO Fecha', defs: {visible: false}},
- {title: 'Mes', defs: {width: 'short', type: 'string'}, searchable: true}, //5
- {title: 'Año', defs: {width: 'long', type: 'string'}, searchable: true},
- {title: 'Valor', defs: {className: 'dt-right', width: 'long', type: 'num'}, export: true},
- {title: 'ISO Valor', defs: {visible: false, type: 'num'}},
- {title: 'Glosa', defs: {width: 'short', type: 'string'}, export: true},
- {title: 'Centro de Costo', defs: {width: 'short', type: 'string'}, searchable: true, export: true}, //10
- {title: 'Categoria', defs: {width: 'short', type: 'string'}},
- {title: 'Detalle', defs: {width: 'long', type: 'string'}, export: true},
- {title: 'RUT', defs: {width: 'short', type: 'string'}, export: true},
- {title: 'Nombre', defs: {width: 'short', type: 'string'}, export: true},
- {title: 'Identificador', defs: {width: 'short', type: 'string'}, export: true}, //15
- {title: 'Editar', defs: {width: 'short', type: 'string'}},
+ {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'}, process: movimiento => movimiento.cuenta.banco.nombre, args: ['movimiento'], 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'}, 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}, process: fecha => [fecha.getFullYear(), fecha.getMonth() + 1, fecha.getDate()].join('-'), args: ['fecha']},
+ {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'}, process: fecha => fecha.getFullYear(), args: ['fecha'], searchable: 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'}, args: ['valor']},
+ {title: 'Glosa', defs: {width: 'short', type: 'string'}, process: movimiento => movimiento.glosa, args: ['movimiento'], export: true},
+ {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: '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'}, process: movimiento => (movimiento.detalles) ? movimiento.detalles.detalle : '', args: ['movimiento'], 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'}, args: ['nombre'], searchable: true, export: true},
+ {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'}, args: ['buttonsHTML']},
]
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
@@ -134,12 +134,14 @@
exportOptions: {
columns: exportColumns,
format: {
- body: (data, row, column, node) => {
- if (column === this.columns.map(({title}) => title).indexOf('Fecha')) {
- return data.split('-').reverse().join('-')
+ body: (data, row, columnIdx, node) => {
+ const formats = this.columns.filter(columnDef => columnDef.format)
+ 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')) {
- return data.replace(/\./g, '')
+ if (typeof data === 'string' && data.includes('(.*)<\/span>/, '$2')
}
return data
}
@@ -214,25 +216,28 @@
}
}
- const data = {
- Sigla: movimiento.cuenta.inmobiliaria.sigla,
- Banco: movimiento.cuenta.banco.nombre,
- Cuenta: movimiento.cuenta.cuenta,
- Fecha: this.props.formatters.date.format(fecha),
- 'ISO Fecha': [fecha.getFullYear(), fecha.getMonth() + 1, fecha.getDate()].join('-'),
- 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 params = {
+ movimiento,
+ fecha,
+ valor,
+ nombre,
+ 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 = []
this.columns.forEach(column => {
values.push(data[column.title])