Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | 5x 5x 5x 5x 5x 3x 3x 5x 75x 5x 5x 5x 75x 5x 75x 5x 6x 6x 6x 6x 6x 90x 90x 90x 12x 90x 6x 90x 6x 90x 6x 90x 36x 90x 6x 90x 6x | import moment from 'moment-timezone'; import I18n from '../../helpers/i18n'; import inboundOrderDao from '../../database/dao/inboundOrder'; import { models } from '../../../config/database'; import { mountWhereBasedFilter } from '../../helpers/reports/sequelize'; import InboundOrderStatus from '../../database/enumerators/inboundOrder'; import NumberFormatter from '../../helpers/number/format'; function remove(headersValue, value) { const index = headersValue.indexOf(value); Eif (index !== -1) { headersValue.splice(index, 1); } } export default async function generateData( columns, filters, headers = [], rows = [], opts = {}, appLanguage = 'ptBr' ) { let whereProd = {}; if (filters.productCode) { whereProd = mountWhereBasedFilter({ productCode: filters.productCode }); delete filters.productCode; } const where = mountWhereBasedFilter(filters); let headersValue = columns.map((it) => it.value); remove(headersValue, 'qtdProdutos'); const dados = await inboundOrderDao.findInboundOrders(where, { attributes: headersValue, include: [ { required: false, model: models.Supplier, as: 'supplier', }, { required: false, model: models.Branch, as: 'branch', attributes: ['code', 'name'], }, { required: false, model: models.Carrier, as: 'carrier', attributes: ['code', 'name'], }, { separate: true, required: false, model: models.InboundOrderProduct, as: 'products', attributes: ['productCode', 'supplierProductCode'], include: [ { required: true, model: models.Product, as: 'product', attributes: ['id', 'name'], where: whereProd, }, ], }, { required: false, model: models.User, as: 'userCreated', attributes: ['login'], }, { required: false, model: models.User, as: 'userUpdated', attributes: ['login'], }, ], ...opts, }); headersValue = null; headersValue = columns.map((it) => it.value); columns.forEach((it) => { headers.push(it.label); }); dados.forEach((it) => { it.userCreated && it.userCreated.dataValues && it.userCreated.dataValues.login ? (it.createdUser = it.userCreated.dataValues.login) : (it.createdUser = ''); it.userUpdated && it.userUpdated.dataValues && it.userUpdated.dataValues.login ? (it.updatedUser = it.userUpdated.dataValues.login) : (it.updatedUser = ''); it.qtdProdutos = it.products ? it.products.length : ''; const row = []; for (let index = 0; index < headersValue.length; index++) { const column = headersValue[index]; row.push(it[column]); if ( (column === 'createdAt' || column === 'updatedAt' || column === 'deliveryDate') && row[index] !== null ) { row[index] = moment(row[index]).isValid() ? moment(row[index]).format('L LTS') : ''; } if (column === 'branchCode') row[index] = it.branch ? `${it.branch.code} - ${it.branch.name}` : row[index]; if (column === 'supplierCode') row[index] = it.supplier ? `${it.supplier.code} - ${it.supplier.name}` : row[index]; if (column === 'carrierCode') row[index] = it.carrier ? `${it.carrier.code} - ${it.carrier.name}` : row[index]; if ( column === 'checkedPlate' || column === 'checkedOrder' || column === 'stored' || column === 'blocked' || column === 'canceled' || column === 'divergence' ) { row[index] = row[index] ? I18n.t('BEE172' /* Sim */, undefined, appLanguage) : I18n.t('BEE173' /* Não */, undefined, appLanguage); } if (column === 'status') row[index] = it.status ? InboundOrderStatus.getStatusValues(it.status, appLanguage) : ''; Iif (column === 'expectedVolumes' && row[index] !== null) { row[index] = NumberFormatter.format(row[index], 3); } } rows.push(row); }); } |