bug#10822
dev:thiago qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@81498 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
20a7ed461d
commit
f46e67b9d1
|
@ -0,0 +1,7 @@
|
||||||
|
package com.rjconsultores.ventaboletos.dao;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.IntegracaoTotvs;
|
||||||
|
|
||||||
|
public interface IntegracaoTotvsDAO extends GenericDAO<IntegracaoTotvs, Integer> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.rjconsultores.ventaboletos.dao;
|
||||||
|
|
||||||
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.dao.hibernate.GenericHibernateDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.IntegracaoTotvs;
|
||||||
|
|
||||||
|
@Repository("IntgeracaoTotvsDAO")
|
||||||
|
public class IntgeracaoTotvsHibernateDAO extends GenericHibernateDAO<IntegracaoTotvs, Integer>
|
||||||
|
implements IntegracaoTotvsDAO {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public IntgeracaoTotvsHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
|
setSessionFactory(factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -271,14 +271,14 @@ public class Caja implements java.io.Serializable {
|
||||||
private String ccf;
|
private String ccf;
|
||||||
|
|
||||||
@Temporal(TemporalType.DATE)
|
@Temporal(TemporalType.DATE)
|
||||||
@Column(name = "FECHORVENTA_H", length = 7)
|
@Column(name = "FECHORVENTA_H")
|
||||||
private Date fechorventaH;
|
private Date fechorventaH;
|
||||||
|
|
||||||
@Column(name = "SERIEIMPFISCALORIGINAL", length = 6)
|
@Column(name = "SERIEIMPFISCALORIGINAL", length = 6)
|
||||||
private String serieimpfiscaloriginal;
|
private String serieimpfiscaloriginal;
|
||||||
|
|
||||||
@Column(name = "INDINTEGRADOAG", nullable = false, precision = 1, scale = 0)
|
@Column(name = "INDINTEGRADOAG", precision = 1, scale = 0)
|
||||||
private boolean indintegradoag;
|
private Boolean indintegradoag;
|
||||||
|
|
||||||
@Column(name = "TRANSACAO_ID", precision = 15, scale = 0)
|
@Column(name = "TRANSACAO_ID", precision = 15, scale = 0)
|
||||||
private Long transacaoId;
|
private Long transacaoId;
|
||||||
|
@ -313,6 +313,12 @@ public class Caja implements java.io.Serializable {
|
||||||
@OneToMany(mappedBy = "caja")
|
@OneToMany(mappedBy = "caja")
|
||||||
private List<CajaFormaPago> cajaFormaPago;
|
private List<CajaFormaPago> cajaFormaPago;
|
||||||
|
|
||||||
|
@Column(name = "INTEGRADOTOTVS", precision = 1, scale = 0)
|
||||||
|
private Integer integradoTotvs;
|
||||||
|
|
||||||
|
@Column(name = "ERRO", precision = 1, scale = 0)
|
||||||
|
private String erro;
|
||||||
|
|
||||||
public Caja() {
|
public Caja() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,7 +346,7 @@ public class Caja implements java.io.Serializable {
|
||||||
Integer levanteId, Integer rutaId, String serieimpfiscal, Date fecintegracion, Integer ptovtaventaId,
|
Integer levanteId, Integer rutaId, String serieimpfiscal, Date fecintegracion, Integer ptovtaventaId,
|
||||||
Boolean indremotoinverso, Date fecnacimiento, String dispositivoembarcada, Long numerobilheteembarcada,
|
Boolean indremotoinverso, Date fecnacimiento, String dispositivoembarcada, Long numerobilheteembarcada,
|
||||||
String numasientovinculado, String ccf, Date fechorventaH, String serieimpfiscaloriginal,
|
String numasientovinculado, String ccf, Date fechorventaH, String serieimpfiscaloriginal,
|
||||||
boolean indintegradoag, Long transacaoId, Long transacaooriginalId, String descnumdoc, String descnumdoc2,
|
Boolean indintegradoag, Long transacaoId, Long transacaooriginalId, String descnumdoc, String descnumdoc2,
|
||||||
String desctipodoc, String desctipodoc2, String desctelefono, Long aidfId, String nacionalidad,
|
String desctipodoc, String desctipodoc2, String desctelefono, Long aidfId, String nacionalidad,
|
||||||
String sexo) {
|
String sexo) {
|
||||||
this.cajaId = cajaId;
|
this.cajaId = cajaId;
|
||||||
|
@ -1103,11 +1109,11 @@ public class Caja implements java.io.Serializable {
|
||||||
this.serieimpfiscaloriginal = serieimpfiscaloriginal;
|
this.serieimpfiscaloriginal = serieimpfiscaloriginal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIndintegradoag() {
|
public Boolean isIndintegradoag() {
|
||||||
return this.indintegradoag;
|
return this.indintegradoag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIndintegradoag(boolean indintegradoag) {
|
public void setIndintegradoag(Boolean indintegradoag) {
|
||||||
this.indintegradoag = indintegradoag;
|
this.indintegradoag = indintegradoag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1199,4 +1205,20 @@ public class Caja implements java.io.Serializable {
|
||||||
this.cajaFormaPago = cajaFormaPago;
|
this.cajaFormaPago = cajaFormaPago;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getIntegradoTotvs() {
|
||||||
|
return integradoTotvs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIntegradoTotvs(Integer integradoTotvs) {
|
||||||
|
this.integradoTotvs = integradoTotvs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getErro() {
|
||||||
|
return erro;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErro(String erro) {
|
||||||
|
this.erro = erro;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,134 @@
|
||||||
package com.rjconsultores.ventaboletos.entidad;
|
package com.rjconsultores.ventaboletos.entidad;
|
||||||
|
|
||||||
public class IntegracaoTotvs {
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.persistence.Basic;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.SequenceGenerator;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@SequenceGenerator(name = "INTEGRACAOTOTVS_SEQ", sequenceName = "INTEGRACAOTOTVS_SEQ", allocationSize = 1)
|
||||||
|
@Table(name = "INTEGRACAO_TOTVS")
|
||||||
|
public class IntegracaoTotvs implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
@Id
|
||||||
|
@Basic(optional = false)
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO, generator = "INTEGRACAOTOTVS_SEQ")
|
||||||
|
@Column(name = "INTEGRACAOTOTVS_ID")
|
||||||
|
private Integer integracaoTotvsId;
|
||||||
|
@Column(name = "DESC_INTEGRACAO")
|
||||||
|
private String descIntegracao;
|
||||||
|
@Column(name = "ESQUEMACORRIDA_ID")
|
||||||
|
private Integer esquemaCorridaId;
|
||||||
|
@Column(name = "FECFIN")
|
||||||
|
private Date fecFin;
|
||||||
|
@Column(name = "FECINI")
|
||||||
|
private Date fecInicio;
|
||||||
|
@Column(name = "FECMODIF")
|
||||||
|
private Date fecmodif;
|
||||||
|
@Column(name = "PUNTOVENTA_ID")
|
||||||
|
private Integer puntoVentaId;
|
||||||
|
@Column(name = "EMPRESA_ID")
|
||||||
|
private Integer empresaId;
|
||||||
|
@Column(name = "USUARIO_ID")
|
||||||
|
private Integer usuarioId;
|
||||||
|
@Column(name = "QTDEREGISTROSATUALIZADOS")
|
||||||
|
private Integer qtdadeResgistrosAtualizados;
|
||||||
|
|
||||||
|
@Column(name = "ACTIVO")
|
||||||
|
private Boolean activo;
|
||||||
|
|
||||||
|
public Integer getIntegracaoTotvsId() {
|
||||||
|
return integracaoTotvsId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIntegracaoTotvsId(Integer integracaoTotvsId) {
|
||||||
|
this.integracaoTotvsId = integracaoTotvsId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescIntegracao() {
|
||||||
|
return descIntegracao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescIntegracao(String descIntegracao) {
|
||||||
|
this.descIntegracao = descIntegracao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getEsquemaCorridaId() {
|
||||||
|
return esquemaCorridaId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEsquemaCorridaId(Integer esquemaCorridaId) {
|
||||||
|
this.esquemaCorridaId = esquemaCorridaId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getFecFin() {
|
||||||
|
return fecFin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFecFin(Date fecFin) {
|
||||||
|
this.fecFin = fecFin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getFecInicio() {
|
||||||
|
return fecInicio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFecInicio(Date fecInicio) {
|
||||||
|
this.fecInicio = fecInicio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getFecmodif() {
|
||||||
|
return fecmodif;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFecmodif(Date fecmodif) {
|
||||||
|
this.fecmodif = fecmodif;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPuntoVentaId() {
|
||||||
|
return puntoVentaId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPuntoVentaId(Integer puntoVentaId) {
|
||||||
|
this.puntoVentaId = puntoVentaId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getUsuarioId() {
|
||||||
|
return usuarioId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsuarioId(Integer usuarioId) {
|
||||||
|
this.usuarioId = usuarioId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getActivo() {
|
||||||
|
return activo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivo(Boolean activo) {
|
||||||
|
this.activo = activo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getQtdadeResgistrosAtualizados() {
|
||||||
|
return qtdadeResgistrosAtualizados;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQtdadeResgistrosAtualizados(Integer qtdadeResgistrosAtualizados) {
|
||||||
|
this.qtdadeResgistrosAtualizados = qtdadeResgistrosAtualizados;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getEmpresaId() {
|
||||||
|
return empresaId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmpresaId(Integer empresaId) {
|
||||||
|
this.empresaId = empresaId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Usuario;
|
||||||
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||||
|
|
||||||
public interface IntegracaoTotvsService {
|
public interface IntegracaoTotvsService {
|
||||||
|
@ -16,4 +17,6 @@ public interface IntegracaoTotvsService {
|
||||||
|
|
||||||
public List<PuntoVenta> buscaPuntoVentaEmpresa(Empresa empresa) throws Exception;
|
public List<PuntoVenta> buscaPuntoVentaEmpresa(Empresa empresa) throws Exception;
|
||||||
|
|
||||||
|
public Integer solicitaReIntegracaoBilhete(Empresa empresa, Date dataInicial, Date dataFinal, PuntoVenta puntoVenta, Usuario usuario) throws BusinessException;
|
||||||
|
|
||||||
}
|
}
|
|
@ -11,7 +11,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
|
@ -5,21 +5,27 @@ import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.dao.CajaDAO;
|
import com.rjconsultores.ventaboletos.dao.CajaDAO;
|
||||||
import com.rjconsultores.ventaboletos.dao.CorridaDAO;
|
import com.rjconsultores.ventaboletos.dao.CorridaDAO;
|
||||||
import com.rjconsultores.ventaboletos.dao.EsquemaCorridaDAO;
|
import com.rjconsultores.ventaboletos.dao.EsquemaCorridaDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.dao.IntegracaoTotvsDAO;
|
||||||
import com.rjconsultores.ventaboletos.dao.MarcaDAO;
|
import com.rjconsultores.ventaboletos.dao.MarcaDAO;
|
||||||
import com.rjconsultores.ventaboletos.dao.PuntoVentaDAO;
|
import com.rjconsultores.ventaboletos.dao.PuntoVentaDAO;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.IntegracaoTotvs;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Marca;
|
import com.rjconsultores.ventaboletos.entidad.Marca;
|
||||||
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Usuario;
|
||||||
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||||
import com.rjconsultores.ventaboletos.service.IntegracaoTotvsService;
|
import com.rjconsultores.ventaboletos.service.IntegracaoTotvsService;
|
||||||
|
|
||||||
@Service("integracaoTotvsService")
|
@Service("integracaoTotvsService")
|
||||||
public class IntegracaoTotvsServiceImpl implements IntegracaoTotvsService {
|
public class IntegracaoTotvsServiceImpl implements IntegracaoTotvsService {
|
||||||
|
|
||||||
|
private static final String BILHETE = "BILHETE";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
CajaDAO cajaDao;
|
CajaDAO cajaDao;
|
||||||
|
|
||||||
|
@ -35,6 +41,9 @@ public class IntegracaoTotvsServiceImpl implements IntegracaoTotvsService {
|
||||||
@Autowired
|
@Autowired
|
||||||
EsquemaCorridaDAO esquemaCorridaDao;
|
EsquemaCorridaDAO esquemaCorridaDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
IntegracaoTotvsDAO integracaoTotvsDAO;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer atualizaStstausBilhetesIntegrar(Empresa empresa, Date dataInicial, Date dataFinal, PuntoVenta puntoVenta) throws BusinessException {
|
public Integer atualizaStstausBilhetesIntegrar(Empresa empresa, Date dataInicial, Date dataFinal, PuntoVenta puntoVenta) throws BusinessException {
|
||||||
Marca marca = null;
|
Marca marca = null;
|
||||||
|
@ -50,6 +59,26 @@ public class IntegracaoTotvsServiceImpl implements IntegracaoTotvsService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public Integer solicitaReIntegracaoBilhete(Empresa empresa, Date dataInicial, Date dataFinal, PuntoVenta puntoVenta, Usuario usuario) throws BusinessException {
|
||||||
|
Integer retorno = atualizaStstausBilhetesIntegrar(empresa, dataInicial, dataFinal, puntoVenta);
|
||||||
|
if (retorno.intValue() > 0) {
|
||||||
|
IntegracaoTotvs integracaoTotvs = new IntegracaoTotvs();
|
||||||
|
integracaoTotvs.setDescIntegracao(BILHETE);
|
||||||
|
integracaoTotvs.setFecInicio(dataInicial);
|
||||||
|
integracaoTotvs.setFecFin(dataFinal);
|
||||||
|
integracaoTotvs.setFecmodif(new Date());
|
||||||
|
integracaoTotvs.setPuntoVentaId(puntoVenta.getPuntoventaId());
|
||||||
|
integracaoTotvs.setEmpresaId(empresa.getEmpresaId());
|
||||||
|
integracaoTotvs.setUsuarioId(usuario.getUsuarioId());
|
||||||
|
integracaoTotvs.setActivo(Boolean.TRUE);
|
||||||
|
integracaoTotvs.setQtdadeResgistrosAtualizados(retorno);
|
||||||
|
integracaoTotvsDAO.suscribir(integracaoTotvs);
|
||||||
|
}
|
||||||
|
return retorno;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer atualizaStstausServicosIntegrar(Empresa empresa, Integer numServico) throws BusinessException {
|
public Integer atualizaStstausServicosIntegrar(Empresa empresa, Integer numServico) throws BusinessException {
|
||||||
Marca marca = null;
|
Marca marca = null;
|
||||||
|
|
|
@ -251,6 +251,14 @@ public final class DateUtil {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getStringDateHour(java.util.Date d) {
|
||||||
|
if (d != null) {
|
||||||
|
DateFormat df = new SimpleDateFormat(ddMMaaHHmm);
|
||||||
|
return df.format(d);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getStringDate(java.util.Date d) {
|
public static String getStringDate(java.util.Date d) {
|
||||||
return getStringDate(d, "dd/MM/yyyy");
|
return getStringDate(d, "dd/MM/yyyy");
|
||||||
}
|
}
|
||||||
|
@ -596,10 +604,10 @@ public final class DateUtil {
|
||||||
*/
|
*/
|
||||||
public static Set<Integer> carregarDiasCompetencia(String competencia, Date dataMovimento) {
|
public static Set<Integer> carregarDiasCompetencia(String competencia, Date dataMovimento) {
|
||||||
Set<Integer> diasCompetencia = new TreeSet<Integer>();
|
Set<Integer> diasCompetencia = new TreeSet<Integer>();
|
||||||
if(competencia== null && dataMovimento!=null){
|
if (competencia == null && dataMovimento != null) {
|
||||||
Integer diaInteger = new Integer (getStringDate(dataMovimento).split("/")[0]);
|
Integer diaInteger = new Integer(getStringDate(dataMovimento).split("/")[0]);
|
||||||
diasCompetencia.add(diaInteger);
|
diasCompetencia.add(diaInteger);
|
||||||
}else{
|
} else {
|
||||||
String[] vetCompetencia = competencia.split("/");
|
String[] vetCompetencia = competencia.split("/");
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.set(Calendar.MONTH, Integer.valueOf(vetCompetencia[0]) - 1);
|
cal.set(Calendar.MONTH, Integer.valueOf(vetCompetencia[0]) - 1);
|
||||||
|
@ -660,6 +668,7 @@ public final class DateUtil {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Date getYesterdayDate() {
|
public static Date getYesterdayDate() {
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.add(Calendar.DATE, -1);
|
calendar.add(Calendar.DATE, -1);
|
||||||
|
@ -668,6 +677,7 @@ public final class DateUtil {
|
||||||
Date yesterday = calendar.getTime();
|
Date yesterday = calendar.getTime();
|
||||||
return yesterday;
|
return yesterday;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getYesterdayDateString() {
|
public static String getYesterdayDateString() {
|
||||||
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
|
|
|
@ -38,34 +38,34 @@ public class MoneyHelper {
|
||||||
return arredondar(aValor);
|
return arredondar(aValor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BigDecimal somar(BigDecimal ... aAmount) {
|
public static BigDecimal somar(BigDecimal... aAmount) {
|
||||||
BigDecimal total = BigDecimal.ZERO;
|
BigDecimal total = BigDecimal.ZERO;
|
||||||
for(BigDecimal value : aAmount){
|
for (BigDecimal value : aAmount) {
|
||||||
BigDecimal fAmountOne = value == null ? BigDecimal.ZERO:arredondar(value);
|
BigDecimal fAmountOne = value == null ? BigDecimal.ZERO : arredondar(value);
|
||||||
total = total.add(fAmountOne);
|
total = total.add(fAmountOne);
|
||||||
}
|
}
|
||||||
return total.setScale(DECIMALS, ROUNDING_MODE);
|
return total.setScale(DECIMALS, ROUNDING_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BigDecimal somar(int customScale, BigDecimal ... aAmount) {
|
public static BigDecimal somar(int customScale, BigDecimal... aAmount) {
|
||||||
BigDecimal total = BigDecimal.ZERO;
|
BigDecimal total = BigDecimal.ZERO;
|
||||||
for(BigDecimal value : aAmount){
|
for (BigDecimal value : aAmount) {
|
||||||
BigDecimal fAmountOne = value == null ? BigDecimal.ZERO:arredondar(value, customScale);
|
BigDecimal fAmountOne = value == null ? BigDecimal.ZERO : arredondar(value, customScale);
|
||||||
total = total.add(fAmountOne);
|
total = total.add(fAmountOne);
|
||||||
}
|
}
|
||||||
return total.setScale(DECIMALS, ROUNDING_MODE);
|
return total.setScale(DECIMALS, ROUNDING_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BigDecimal somar(BigDecimal aAmountOne, BigDecimal aAmountTwo) {
|
public static BigDecimal somar(BigDecimal aAmountOne, BigDecimal aAmountTwo) {
|
||||||
BigDecimal fAmountOne = aAmountOne == null ? BigDecimal.ZERO:arredondar(aAmountOne);
|
BigDecimal fAmountOne = aAmountOne == null ? BigDecimal.ZERO : arredondar(aAmountOne);
|
||||||
BigDecimal fAmountTwo =aAmountTwo == null ? BigDecimal.ZERO: arredondar(aAmountTwo);
|
BigDecimal fAmountTwo = aAmountTwo == null ? BigDecimal.ZERO : arredondar(aAmountTwo);
|
||||||
|
|
||||||
return fAmountOne.add(fAmountTwo).setScale(DECIMALS, ROUNDING_MODE);
|
return fAmountOne.add(fAmountTwo).setScale(DECIMALS, ROUNDING_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BigDecimal somar(BigDecimal aAmountOne, BigDecimal aAmountTwo, int customScale) {
|
public static BigDecimal somar(BigDecimal aAmountOne, BigDecimal aAmountTwo, int customScale) {
|
||||||
BigDecimal fAmountOne = aAmountOne == null ? BigDecimal.ZERO:arredondar(aAmountOne, customScale);
|
BigDecimal fAmountOne = aAmountOne == null ? BigDecimal.ZERO : arredondar(aAmountOne, customScale);
|
||||||
BigDecimal fAmountTwo =aAmountTwo == null ? BigDecimal.ZERO: arredondar(aAmountTwo, customScale);
|
BigDecimal fAmountTwo = aAmountTwo == null ? BigDecimal.ZERO : arredondar(aAmountTwo, customScale);
|
||||||
|
|
||||||
return fAmountOne.add(fAmountTwo).setScale(DECIMALS, ROUNDING_MODE);
|
return fAmountOne.add(fAmountTwo).setScale(DECIMALS, ROUNDING_MODE);
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ public class MoneyHelper {
|
||||||
BigDecimal diferenca = getDiferenca(aAmountOne, aAmountTwo);
|
BigDecimal diferenca = getDiferenca(aAmountOne, aAmountTwo);
|
||||||
BigDecimal fractionalChange = BigDecimal.ZERO;
|
BigDecimal fractionalChange = BigDecimal.ZERO;
|
||||||
|
|
||||||
if ( diferenca!=null && ( diferenca.compareTo(BigDecimal.ZERO) != 0) && (aAmountOne.compareTo(BigDecimal.ZERO) != 0) ){
|
if (diferenca != null && (diferenca.compareTo(BigDecimal.ZERO) != 0) && (aAmountOne.compareTo(BigDecimal.ZERO) != 0)) {
|
||||||
fractionalChange = diferenca.divide(aAmountOne, new MathContext(MATH_CONTEXT));
|
fractionalChange = diferenca.divide(aAmountOne, new MathContext(MATH_CONTEXT));
|
||||||
}
|
}
|
||||||
return arredondar(fractionalChange.multiply(HUNDRED)).abs();
|
return arredondar(fractionalChange.multiply(HUNDRED)).abs();
|
||||||
|
@ -188,7 +188,7 @@ public class MoneyHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BigDecimal getPercentualValor(BigDecimal valorTotal, BigDecimal valorPercentual) {
|
public static BigDecimal getPercentualValor(BigDecimal valorTotal, BigDecimal valorPercentual) {
|
||||||
if(valorTotal != null && valorPercentual != null) {
|
if (valorTotal != null && valorPercentual != null) {
|
||||||
return dividir(dividir(multiplicar(valorTotal, valorPercentual), HUNDRED), HUNDRED);
|
return dividir(dividir(multiplicar(valorTotal, valorPercentual), HUNDRED), HUNDRED);
|
||||||
}
|
}
|
||||||
return BigDecimal.ZERO;
|
return BigDecimal.ZERO;
|
||||||
|
@ -196,12 +196,13 @@ public class MoneyHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converte uma string no formato de moeda em um {@link BigDecimal}
|
* Converte uma string no formato de moeda em um {@link BigDecimal}
|
||||||
|
*
|
||||||
* @param valor
|
* @param valor
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static BigDecimal getValor(String valor) {
|
public static BigDecimal getValor(String valor) {
|
||||||
try {
|
try {
|
||||||
if(StringUtils.isNotBlank(valor)) {
|
if (StringUtils.isNotBlank(valor)) {
|
||||||
NumberFormat nf = DecimalFormat.getCurrencyInstance(Locale.getDefault());
|
NumberFormat nf = DecimalFormat.getCurrencyInstance(Locale.getDefault());
|
||||||
nf.setMinimumFractionDigits(DECIMALS);
|
nf.setMinimumFractionDigits(DECIMALS);
|
||||||
nf.setMaximumFractionDigits(DECIMALS);
|
nf.setMaximumFractionDigits(DECIMALS);
|
||||||
|
@ -213,6 +214,11 @@ public class MoneyHelper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getValor(BigDecimal valor) {
|
||||||
|
NumberFormat nf = NumberFormat.getInstance(Locale.getDefault());
|
||||||
|
return nf.format(valor);
|
||||||
|
}
|
||||||
|
|
||||||
public static BigDecimal arredondar(BigDecimal aNumber, int customScale) {
|
public static BigDecimal arredondar(BigDecimal aNumber, int customScale) {
|
||||||
return aNumber.setScale(customScale, ROUNDING_MODE);
|
return aNumber.setScale(customScale, ROUNDING_MODE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue