Search in sources :

Example 96 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus in project sic by belluccifranco.

the class FacturaController method calcularIvaVenta.

@GetMapping("/facturas/total-iva-venta/criteria")
@ResponseStatus(HttpStatus.OK)
public double calcularIvaVenta(@RequestParam Long idEmpresa, @RequestParam(required = false) Long desde, @RequestParam(required = false) Long hasta, @RequestParam(required = false) Long idCliente, @RequestParam(required = false) Integer nroSerie, @RequestParam(required = false) Integer nroFactura, @RequestParam(required = false) Long idViajante, @RequestParam(required = false) TipoDeComprobante tipoDeComprobante, @RequestParam(required = false) Long idUsuario, @RequestParam(required = false) Long nroPedido, @RequestParam(required = false) Boolean soloImpagas, @RequestParam(required = false) Boolean soloPagas) {
    Calendar fechaDesde = Calendar.getInstance();
    Calendar fechaHasta = Calendar.getInstance();
    if ((desde != null) && (hasta != null)) {
        fechaDesde.setTimeInMillis(desde);
        fechaHasta.setTimeInMillis(hasta);
    }
    if ((soloImpagas != null) && (soloPagas != null)) {
        if ((soloImpagas == true) && (soloPagas == true)) {
            soloImpagas = false;
            soloPagas = false;
        }
    }
    Cliente cliente = new Cliente();
    if (idCliente != null) {
        cliente = clienteService.getClientePorId(idCliente);
    }
    Usuario usuario = new Usuario();
    if (idUsuario != null) {
        usuario = usuarioService.getUsuarioPorId(idUsuario);
    }
    Usuario viajante = new Usuario();
    if (idViajante != null) {
        viajante = usuarioService.getUsuarioPorId(idViajante);
    }
    BusquedaFacturaVentaCriteria criteria = BusquedaFacturaVentaCriteria.builder().empresa(empresaService.getEmpresaPorId(idEmpresa)).buscaPorFecha((desde != null) && (hasta != null)).fechaDesde(fechaDesde.getTime()).fechaHasta(fechaHasta.getTime()).buscaCliente(idCliente != null).cliente(cliente).buscaUsuario(idUsuario != null).usuario(usuario).buscaViajante(idViajante != null).viajante(viajante).buscaPorNumeroFactura((nroSerie != null) && (nroFactura != null)).numSerie((nroSerie != null) ? nroSerie : 0).numFactura((nroFactura != null) ? nroFactura : 0).buscarPorPedido(nroPedido != null).nroPedido((nroPedido != null) ? nroPedido : 0).buscaPorTipoComprobante(tipoDeComprobante != null).tipoComprobante((tipoDeComprobante != null) ? tipoDeComprobante : null).buscaSoloImpagas(soloImpagas).buscaSoloPagadas(soloPagas).cantRegistros(0).build();
    return facturaService.calcularIvaVenta(criteria);
}
Also used : BusquedaFacturaVentaCriteria(sic.modelo.BusquedaFacturaVentaCriteria) Usuario(sic.modelo.Usuario) Calendar(java.util.Calendar) Cliente(sic.modelo.Cliente) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 97 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus in project sic by belluccifranco.

the class FacturaController method buscarFacturaCompra.

@GetMapping("/facturas/compra/busqueda/criteria")
@ResponseStatus(HttpStatus.OK)
public List<FacturaCompra> buscarFacturaCompra(@RequestParam Long idEmpresa, @RequestParam(required = false) Long desde, @RequestParam(required = false) Long hasta, @RequestParam(required = false) Long idProveedor, @RequestParam(required = false) Integer nroSerie, @RequestParam(required = false) Integer nroFactura, @RequestParam(required = false) Boolean soloImpagas, @RequestParam(required = false) Boolean soloPagas) {
    Calendar fechaDesde = Calendar.getInstance();
    Calendar fechaHasta = Calendar.getInstance();
    if ((desde != null) && (hasta != null)) {
        fechaDesde.setTimeInMillis(desde);
        fechaHasta.setTimeInMillis(hasta);
    }
    if (soloImpagas == null) {
        soloImpagas = false;
    }
    if (soloPagas == null) {
        soloPagas = false;
    }
    Proveedor proveedor = null;
    if (idProveedor != null) {
        proveedor = proveedorService.getProveedorPorId(idProveedor);
    }
    BusquedaFacturaCompraCriteria criteria = BusquedaFacturaCompraCriteria.builder().empresa(empresaService.getEmpresaPorId(idEmpresa)).buscaPorFecha((desde != null) && (hasta != null)).fechaDesde(fechaDesde.getTime()).fechaHasta(fechaHasta.getTime()).buscaPorProveedor(idProveedor != null).proveedor(proveedor).buscaPorNumeroFactura((nroSerie != null) && (nroFactura != null)).numSerie((nroSerie != null) ? nroSerie : 0).numFactura((nroFactura != null) ? nroFactura : 0).buscarSoloInpagas(soloImpagas).buscaSoloPagadas(soloPagas).cantRegistros(0).build();
    return facturaService.buscarFacturaCompra(criteria);
}
Also used : BusquedaFacturaCompraCriteria(sic.modelo.BusquedaFacturaCompraCriteria) Calendar(java.util.Calendar) Proveedor(sic.modelo.Proveedor) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 98 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus in project sic by belluccifranco.

the class TransportistaController method buscarTransportista.

@GetMapping("/transportistas/busqueda/criteria")
@ResponseStatus(HttpStatus.OK)
public List<Transportista> buscarTransportista(@RequestParam(value = "idEmpresa") long idEmpresa, @RequestParam(value = "nombre", required = false) String nombre, @RequestParam(value = "idPais", required = false) Long idPais, @RequestParam(value = "idProvincia", required = false) Long idProvincia, @RequestParam(value = "idLocalidad", required = false) Long idLocalidad) {
    Pais pais = null;
    if (idPais != null) {
        pais = paisService.getPaisPorId(idPais);
    }
    Provincia provincia = null;
    if (idProvincia != null) {
        provincia = provinciaService.getProvinciaPorId(idProvincia);
    }
    Localidad localidad = null;
    if (idLocalidad != null) {
        localidad = localidadService.getLocalidadPorId(idLocalidad);
    }
    BusquedaTransportistaCriteria criteria = new BusquedaTransportistaCriteria((nombre != null), nombre, (idPais != null), pais, (idProvincia != null), provincia, (idLocalidad != null), localidad, empresaService.getEmpresaPorId(idEmpresa));
    return transportistaService.buscarTransportistas(criteria);
}
Also used : Localidad(sic.modelo.Localidad) Pais(sic.modelo.Pais) Provincia(sic.modelo.Provincia) BusquedaTransportistaCriteria(sic.modelo.BusquedaTransportistaCriteria) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 99 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus in project dhis2-core by dhis2.

the class AppController method installApp.

@RequestMapping(method = RequestMethod.POST)
@PreAuthorize("hasRole('ALL') or hasRole('M_dhis-web-app-management')")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void installApp(@RequestParam("file") MultipartFile file) throws IOException, WebMessageException {
    File tempFile = File.createTempFile("IMPORT_", "_ZIP");
    file.transferTo(tempFile);
    AppStatus status = appManager.installApp(tempFile, file.getOriginalFilename());
    if (!status.ok()) {
        String message = i18nManager.getI18n().getString(status.getMessage());
        throw new WebMessageException(WebMessageUtils.conflict(message));
    }
}
Also used : AppStatus(org.hisp.dhis.appmanager.AppStatus) WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 100 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus in project dhis2-core by dhis2.

the class UserRoleController method addUserToRole.

@RequestMapping(value = "/{id}/users/{userId}", method = { RequestMethod.POST, RequestMethod.PUT })
@ResponseStatus(HttpStatus.NO_CONTENT)
public void addUserToRole(@PathVariable(value = "id") String pvId, @PathVariable("userId") String pvUserId, HttpServletResponse response) throws WebMessageException {
    UserAuthorityGroup userAuthorityGroup = userService.getUserAuthorityGroup(pvId);
    if (userAuthorityGroup == null) {
        throw new WebMessageException(WebMessageUtils.notFound("UserRole does not exist: " + pvId));
    }
    User user = userService.getUser(pvUserId);
    if (user == null) {
        throw new WebMessageException(WebMessageUtils.notFound("User does not exist: " + pvId));
    }
    if (!aclService.canUpdate(currentUserService.getCurrentUser(), userAuthorityGroup)) {
        throw new UpdateAccessDeniedException("You don't have the proper permissions to update this object.");
    }
    if (!user.getUserCredentials().getUserAuthorityGroups().contains(userAuthorityGroup)) {
        user.getUserCredentials().getUserAuthorityGroups().add(userAuthorityGroup);
        userService.updateUserCredentials(user.getUserCredentials());
    }
}
Also used : User(org.hisp.dhis.user.User) UserAuthorityGroup(org.hisp.dhis.user.UserAuthorityGroup) WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) UpdateAccessDeniedException(org.hisp.dhis.hibernate.exception.UpdateAccessDeniedException) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)149 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)118 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)36 ApiOperation (io.swagger.annotations.ApiOperation)31 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)26 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)19 GetMapping (org.springframework.web.bind.annotation.GetMapping)18 ApiResponses (io.swagger.annotations.ApiResponses)14 User (org.hisp.dhis.user.User)14 Transactional (org.springframework.transaction.annotation.Transactional)14 Date (java.util.Date)13 Configuration (org.hisp.dhis.configuration.Configuration)12 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)12 Period (org.hisp.dhis.period.Period)11 ArrayList (java.util.ArrayList)10 QualifiedName (com.netflix.metacat.common.QualifiedName)9 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)9 ApiImplicitParam (io.swagger.annotations.ApiImplicitParam)9 Calendar (java.util.Calendar)9 Task (org.flowable.engine.task.Task)8