@Override public BusinessValidateVO execute(InvoiceEntity invoice) { BusinessValidateVO validation = new BusinessValidateVO(MapTypeEnum.POLICIA_FEDERAL); for (InvoiceProductEntity product : invoice.getListInvoiceProducts()) { // Verifica se a Produto deve realmente ter Licença na Federal List<ProductOfficialTypeEntity> listTypes = productOfficialTypeDAO.findByNameNcm( MapTypeEnum.POLICIA_FEDERAL.getType(), product.getProduct().getProductOfficial().getCodNcm()); if (listTypes.isEmpty()) { continue; } LicensePFEntity license = licensePFDAO.findByCompanyExpirationDate( invoice.getCompany().getIdCompany(), invoice.getDateCreate()); ProductOfficialEntity products = licensePFDAO.findByProductOfficial( license.getIdLicense(), product.getProduct().getProductOfficial().getCodNcm()); if (products == null) { validation.setValid(false); validation.setMsg(product.getProduct().getName() + msgErro); break; } } return validation; }
public static List<InvoiceProductEntity> get() { List<InvoiceProductEntity> listProductMoves = new ArrayList<InvoiceProductEntity>(); InvoiceProductEntity invoiceProduct = new InvoiceProductEntity(); invoiceProduct.setInvoice(new InvoiceEntity()); invoiceProduct.getInvoice().setCompany(new CompanyEntity()); invoiceProduct.getInvoice().getCompany().setCnpj("111223444"); invoiceProduct.getInvoice().setDateCreate(Calendar.getInstance()); invoiceProduct.getInvoice().setCodCfop("1.8888"); invoiceProduct.setProduct(new ProductEntity()); invoiceProduct.getProduct().setQtdConcentration(new BigDecimal("90")); invoiceProduct.setQtdProduct(50d); invoiceProduct.setTypeQtdProduct("Kg"); invoiceProduct.getInvoice().setNumInvoice("123455"); invoiceProduct.getInvoice().setProvider(new ProviderEntity()); invoiceProduct.getInvoice().getProvider().setCnpj("99999999999"); invoiceProduct.getInvoice().setProviderCarrier(new ProviderEntity()); invoiceProduct.getInvoice().getProviderCarrier().setCnpj("8888888"); invoiceProduct.getProduct().setProductOfficial(new ProductOfficialEntity()); invoiceProduct.getProduct().getProductOfficial().setCodNcm("123.123.123"); invoiceProduct.getProduct().getProductOfficial().setName("Produto de Teste 123"); invoiceProduct.getInvoice().setImportName("nome importadora"); invoiceProduct.getInvoice().setCountry(new CountryEntity()); invoiceProduct.getInvoice().getCountry().setName("Argentina"); invoiceProduct.getInvoice().setCharterType(new CharterTypeEntity()); invoiceProduct.getInvoice().getCharterType().setRangeCfopInit(3); listProductMoves.add(invoiceProduct); return listProductMoves; }