Commit b556ad01 by Tuomas Riihimäki

Minor fixes for credit transfer and possibility to skip user

1 parent 79b27989
...@@ -829,8 +829,8 @@ public class UserBean implements UserBeanLocal { ...@@ -829,8 +829,8 @@ public class UserBean implements UserBeanLocal {
final Product dstCredprod = productbean.findCreditProduct(); final Product dstCredprod = productbean.findCreditProduct();
final Product srcCredprod = productFacade.findProductsByPrice(BigDecimal.ONE.negate(), source).get(0); final Product srcCredprod = productFacade.findProductsByPrice(BigDecimal.ONE.negate(), source).get(0);
if (!srcCredprod.getPrice().equals(dstCredprod.getPrice())) { if (srcCredprod.getPrice().compareTo(dstCredprod.getPrice()) != 0) {
throw new RuntimeException("Credit prices do not match!"); throw new RuntimeException("Credit prices do not match! src " + srcCredprod.getPrice() + " dst " + dstCredprod.getPrice());
} }
final BigDecimal creditPrice = srcCredprod.getPrice().negate(); final BigDecimal creditPrice = srcCredprod.getPrice().negate();
......
...@@ -42,6 +42,9 @@ ...@@ -42,6 +42,9 @@
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" /> <f:convertNumber minFractionDigits="2" maxFractionDigits="2" />
</h:outputText> </h:outputText>
</p:column> </p:column>
<p:column headerText="Skip">
<h:selectBooleanCheckbox value="#{wrap.skip}" />
</p:column>
</p:dataTable> </p:dataTable>
</h:form> </h:form>
......
...@@ -8,6 +8,9 @@ import javax.ejb.EJB; ...@@ -8,6 +8,9 @@ import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped; import javax.enterprise.context.ConversationScoped;
import javax.inject.Named; import javax.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.EventBeanLocal; import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal; import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.enums.apps.EventPermission; import fi.codecrew.moya.enums.apps.EventPermission;
...@@ -31,6 +34,7 @@ public class CreditTransferView extends GenericCDIView { ...@@ -31,6 +34,7 @@ public class CreditTransferView extends GenericCDIView {
private LanEvent sourceEvent; private LanEvent sourceEvent;
private BigDecimal totalCredits; private BigDecimal totalCredits;
private BigDecimal totalTransferred; private BigDecimal totalTransferred;
private static final Logger logger = LoggerFactory.getLogger(CreditTransferView.class);
public void init(List<EventUser> users) { public void init(List<EventUser> users) {
...@@ -64,7 +68,12 @@ public class CreditTransferView extends GenericCDIView { ...@@ -64,7 +68,12 @@ public class CreditTransferView extends GenericCDIView {
public String commitTransfer() { public String commitTransfer() {
List<User> transfer = new ArrayList<User>(); List<User> transfer = new ArrayList<User>();
for (EventUserWrapper u : users) { for (EventUserWrapper u : users) {
if (!u.isSkip())
{
transfer.add(u.getUser().getUser()); transfer.add(u.getUser().getUser());
} else {
logger.warn("Skipping transferuser {}: '{}'", u.getUser(), u.getUser().getWholeName());
}
} }
totalTransferred = userbean.transferAccountSaldoFromPreviousEvent(transfer, sourceEvent); totalTransferred = userbean.transferAccountSaldoFromPreviousEvent(transfer, sourceEvent);
...@@ -120,6 +129,7 @@ public class CreditTransferView extends GenericCDIView { ...@@ -120,6 +129,7 @@ public class CreditTransferView extends GenericCDIView {
private final EventUser user; private final EventUser user;
private BigDecimal credits = BigDecimal.ZERO; private BigDecimal credits = BigDecimal.ZERO;
private EventUser sourceEventuser; private EventUser sourceEventuser;
private boolean skip = false;
private EventUserWrapper(EventUser u) { private EventUserWrapper(EventUser u) {
super(); super();
...@@ -136,6 +146,9 @@ public class CreditTransferView extends GenericCDIView { ...@@ -136,6 +146,9 @@ public class CreditTransferView extends GenericCDIView {
public void setCredits(BigDecimal credits) { public void setCredits(BigDecimal credits) {
this.credits = credits; this.credits = credits;
if (BigDecimal.ZERO.compareTo(credits) < 0) {
skip = true;
}
} }
public EventUser getSourceEventuser() { public EventUser getSourceEventuser() {
...@@ -145,5 +158,13 @@ public class CreditTransferView extends GenericCDIView { ...@@ -145,5 +158,13 @@ public class CreditTransferView extends GenericCDIView {
public void setSourceEventuser(EventUser sourceEventuser) { public void setSourceEventuser(EventUser sourceEventuser) {
this.sourceEventuser = sourceEventuser; this.sourceEventuser = sourceEventuser;
} }
public boolean isSkip() {
return skip;
}
public void setSkip(boolean skip) {
this.skip = skip;
}
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!