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 | 3x 3x 1x 2x 2x 1x 3x 3x 1x 2x 2x 1x 2x 2x 1x 3x 3x 2x 2x 1x 3x 3x 2x 2x 1x 1x 3x 3x 1x 2x 1x 3x 3x 1x 2x 1x 2x 2x 2x 2x 1x | import APIError from '../helpers/error'; import { t } from '../helpers/i18n'; import DockInformation from '../source/docks/information'; import BranchInformation from '../source/branches/information'; import WarehouseInformation from '../source/warehouses/information'; import DockControlInformation from '../source/dockControl/information'; async function validDockId(req) { const dockId = req.body.dockId || req.query.dockId; if (!dockId) { throw new APIError('INVALID_ID', t('BEE3421' /* ID inválido */)); } else { const existDock = await DockInformation.getDock( { id: dockId, }, { userBranches: req.userBranches } ); if (!existDock) { throw new APIError( 'NOT_EXIST_DOCK_ID', t('BEE1194', { 0: dockId } /* Doca %{0} não localizada */) ); } } } async function validCode(req) { const code = req.body.code || req.query.code; if (!code) { throw new APIError('INVALID_DOCK_CODE'); } else { const existDock = await DockInformation.getDock({ code, }); if (existDock) { throw new APIError( 'EXIST_DOCK_CODE', t('BEE1192', { 0: code } /* Código %{0} não cadastrado */) ); } } } function validDockName(req) { const name = req.body.name || req.query.name; if (!name) { throw new APIError('INVALID_DOCK_NAME'); } } async function validBranch(req) { const branch = req.body.branchCode || req.query.branchCode; if (branch) { const existBranch = await BranchInformation.getBranch( { code: branch, }, { userBranches: req.userBranches } ); if (!existBranch) throw new APIError( '', t('BEE1160', { 0: branch } /* Filial %{0} inválida ! */) ); } } async function validWarehouse(req) { const warehouse = req.body.warehouseCode || req.query.warehouseCode; if (warehouse) { const existWarehouse = await WarehouseInformation.getWarehouse( { code: warehouse, }, { userBranches: req.userBranches } ); if (!existWarehouse) throw new APIError( '', t('BEE1195', { 0: warehouse } /* Armazém %{0} inválido ! */) ); } else { throw new APIError('', t('BEE3331' /* O armazém deve ser informado. */)); } } function validDockType(req) { const dockType = req.body.dockType || req.query.dockType; if (!dockType) { throw new APIError( '', t('BEE1196' /* Tipo de doca deve ser informado ! */) ); } else if (dockType > 3) { throw new APIError( '', t('BEE1197', { 0: dockType } /* Tipo de doca %{0} inválido ! */) ); } } function validStatus(req) { const status = req.body.status || req.query.status; if (!status) { throw new APIError('', t('BEE1198' /* Status deve ser informado ! */)); } else if (status > 3) { throw new APIError( '', t('BEE1199', { 0: status } /* Status %{0} inválido ! */) ); } } async function validDeleteHasAssociatedDockControl(req) { const dockId = req.body.dockId || req.query.dockId; const dockData = await DockInformation.getDock({ id: dockId, }); const dockControl = await DockControlInformation.getDockControl({ dockCode: dockData.code, }); if (dockControl) { throw new APIError( '', t( 'BEE4257' /* Não é possível excluir esta doca, pois ela já foi utilizada no Monitor de Controle de Docas */ ) ); } } export default { validDockId, validCode, validDockName, validBranch, validWarehouse, validDockType, validStatus, validDeleteHasAssociatedDockControl, }; |