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 | 1x 4x 1x 4x 1x 4x 1x 2x 2x 2x 2x 2x 8x 8x 8x 2x 8x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import moment from 'moment-timezone'; import { models } from '../../../config/database'; import ResupplyDao from '../../database/dao/resupply'; import { mountWhereBasedFilter } from '../../helpers/reports/sequelize'; import resupplyPickingStatus from '../../helpers/status/resupplyStatus'; import { t } from '../../helpers/i18n'; import NumberFormatter from '../../helpers/number/format'; // Funcao criada para popular o array headers e rows enviados por parametro export async function generateData( columns, filters, headers = [], rows = [], opts = {} ) { const where = mountWhereBasedFilter(filters); const headersValue = columns.map((it) => it.value); const data = await ResupplyDao.findListResupply(where, { attributes: headersValue, include: [ { required: false, model: models.User, as: 'userResupply', attributes: ['id', 'login'], }, { required: true, model: models.Branch, as: 'branch', attributes: ['name'], }, ], ...opts, }); const headersValueRes = columns.map((it) => it.value); columns.forEach((it) => { headers.push(it.label); }); data.forEach((it) => { it.branchCode = `${it.branchCode} - ${it.branch.name}`; it.resupplyUser = it.userResupply.login; it.status = resupplyPickingStatus.resupplyPickingStatus(it.status); const row = []; for (let index = 0; index < headersValueRes.length; index += 1) { const column = headersValueRes[index]; row.push(column.split('.').reduce((o, i) => o[i] || '', it)); if (column === 'createdAt') { row[index] = moment(row[index]).format('L LTS'); } Iif ( (column === 'suggestedQuantity' || column === 'quantityResupplied' || column === 'balanceOnResupply') && row[index] !== null ) { row[index] = NumberFormatter.format(row[index], 4); } } rows.push(row); }); } export async function generateSheetHeader(headers, appLanguage) { headers.push({ header: t('BEE145' /* Filial */, undefined, appLanguage) }); headers.push({ header: t('BEE182' /* Depósito */, undefined, appLanguage) }); headers.push({ header: t('BEE2726' /* Endereço de Origem */, undefined, appLanguage), }); headers.push({ header: t('BEE2715' /* Endereço de Picking */, undefined, appLanguage), }); headers.push({ header: t('BEE378' /* Código do Produto */, undefined, appLanguage), }); headers.push({ header: t('BEE758' /* Descrição do Produto */, undefined, appLanguage), }); headers.push({ header: t( 'BEE2669' /* Critério do Ressuprimento */, undefined, appLanguage ), }); headers.push({ header: t('BEE2662' /* Capacidade Máxima (UN) */, undefined, appLanguage), }); headers.push({ header: t( 'BEE2663' /* Ponto de Ressuprimento (UN) */, undefined, appLanguage ), }); headers.push({ header: t('BEE2652' /* Saldo no picking */, undefined, appLanguage), }); headers.push({ header: t('BEE2649' /* Quantidade Sugerida */, undefined, appLanguage), }); headers.push({ header: t('BEE2727' /* Quantidade Pendente */, undefined, appLanguage), }); headers.push({ header: t('BEE2724' /* Ressuprimento gerado? */, undefined, appLanguage), }); headers.push({ header: t('BEE277' /* Descrição */, undefined, appLanguage) }); return headers; } export default { generateData, generateSheetHeader, }; |