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 | 2x 2x 1x 1x 5x 5x 1x 4x 4x 1x 3x 1x 2x 1x 1x 4x 2x 4x 4x 4x 2x 4x 4x 4x 2x 2x 9x 9x 8x 8x 2x 6x 2x 4x 1x 3x 1x 2x 1x 1x 2x 2x 2x 2x 1x | import APIError from '../helpers/error'; import { t } from '../helpers/i18n'; import BranchInformation from '../source/branches/information'; import OutboundOrderInformation from '../source/outboundOrders/information'; import OutboundOrderProductInformation from '../source/outboundOrderProducts/information'; import SerialGroupInformation from '../source/serialGroup/information'; import TypeOrderInformation from '../source/typeOrders/information'; import OutboundProductAllocationInformation from '../source/outboundOrderProductAllocations/information'; async function validBranchCustomerCode(req) { const branch = await BranchInformation.getBranch({ code: req.userMainBranch, }); if (branch && !branch.factoryDeposit) { throw new APIError( '', t('BEE2927' /* Depósito não localizado na Filial */) ); } else { req.factoryDeposit = branch.factoryDeposit; } } async function validSerialGroup(req) { const { serialGroupCode } = req.body; if (!serialGroupCode) { throw new APIError('', t('BEE2857' /* Etiqueta não encontrada. */)); } else { const result = await SerialGroupInformation.getSerialGroup({ code: serialGroupCode, }); if (!result) { throw new APIError('', t('BEE2857' /* Etiqueta não encontrada. */)); } else if (result.depositCode !== req.factoryDeposit) { throw new APIError('', t('BEE2928' /* Depósito diferente da filial */)); } else if (result.status === 1) { throw new APIError( '', t( 'BEE3087', { 0: serialGroupCode, } /* A etiqueta %{0} ainda não foi aprovada pela qualidade! */ ) ); } else { req.serialGroupInformation = result; } } } function validExistOrderNumber(req) { if (req.serialGroupInformation.orderNumber) { throw new APIError( '', t('BEE2864' /* A Etiqueta Agrupadora já está associada a um documento. */) ); } } async function validOrderType(req) { const { orderType } = req.body; const typeOrderExists = await TypeOrderInformation.findTypeOrders({ type: orderType, usesIndustryProcess: true, }); if (!typeOrderExists) { throw new APIError('', t('BEE3000' /* Tipo de documento não encontrado */)); } } async function validProductAllocation(req) { const { outboundOrderId } = req.body; const productAllocation = await OutboundProductAllocationInformation.getOutboundOrderProductAllocations( { outboundOrderId, } ); if (productAllocation.length > 0) { req.productAllocation = productAllocation; } else { throw new APIError('', t('BEE3001' /* Produto não alocado */)); } } async function validOutboundOrder(req) { const { outboundOrderId } = req.body; if (outboundOrderId) { const outboundOrders = await OutboundOrderInformation.getOutboundOrder({ id: outboundOrderId, }); if (!outboundOrders) { throw new APIError('', t('BEE1915' /* Documento não localizada */)); } else if (outboundOrders.status === 10) { throw new APIError( '', t('BEE2868' /* Este documento já foi finalizado. */) ); } else if (outboundOrders.status === 12) { throw new APIError('', t('BEE2869' /* Este documento foi cancelado. */)); } else if (![4, 10].includes(outboundOrders.status)) { throw new APIError('', t('BEE2938' /* Documento com status inválido */)); } else if (outboundOrders.depositCode !== req.factoryDeposit) { throw new APIError( '', t('BEE2935' /* Depósito do Documento diferente da filial */) ); } } else { throw new APIError( '', t('BEE3101' /* Documento de Saída deve ser informado! */) ); } } async function validStatusProduct(req) { const { outboundOrderProductId } = req.body; const existProduct = await OutboundOrderProductInformation.getListOutboundOrderProducts({ id: outboundOrderProductId, }); const serial = existProduct[0]; if (serial.status === 9) { throw new APIError( '', t( 'BEE2940', { 0: serial.serialGroup.code } /* A etiqueta %{0} está cancelada. */ ) ); } } export default { validBranchCustomerCode, validSerialGroup, validOutboundOrder, validExistOrderNumber, validStatusProduct, validOrderType, validProductAllocation, }; |