Commit 9497091c by Tuukka Kivilahti

finalizing

1 parent 6dda4622
......@@ -112,7 +112,7 @@ public class BillPBean {
logger.debug("Creating Bill prepaidInstant product {}, {}", prod.getName(), bl.getQuantity());
AccountEvent ac2 = productPBean.createAccountEvent(prod, null,bl.getQuantity(), user, bill.getSentDate(), bl.getFoodwave());
AccountEvent ac2 = productPBean.createAccountEvent(prod, null,bl.getQuantity(), user, bill.getSentDate(), bl.getName() ,bl.getFoodwave());
logger.info("Created ac from product. {}, userproducts {}", ac2, user.getAccountEvents().size());
ac2.setSeller(permbean.getCurrentUser());
......
......@@ -22,10 +22,7 @@ import java.security.Principal;
import javax.annotation.Resource;
import javax.annotation.security.DeclareRoles;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.SessionContext;
import javax.ejb.Stateless;
import javax.ejb.*;
import javax.resource.spi.IllegalStateException;
import fi.codecrew.moya.enums.apps.*;
......
......@@ -474,7 +474,7 @@ public class ProductBean implements ProductBeanLocal {
public AccountEvent createAccountEvent(Product product, BigDecimal overriddenUnitPrice, BigDecimal quantity, EventUser user) {
user = eventUserFacade.reload(user);
AccountEvent ret = productPBean.createAccountEvent(product, overriddenUnitPrice, quantity, user, new Date(), null);
AccountEvent ret = productPBean.createAccountEvent(product, overriddenUnitPrice, quantity, user, new Date(), null, null);
cardTemplateBean.checkPrintedCard(user);
return ret;
}
......@@ -562,7 +562,10 @@ public class ProductBean implements ProductBeanLocal {
continue;
}
// TODO: pizzas also removed
// foods are handled from different view, remove them from here
if(ae.getProduct().getFoodWaveTemplates() != null && !ae.getProduct().getFoodWaveTemplates().isEmpty()) {
continue;
}
retlist.add(ae);
}
......
......@@ -75,8 +75,11 @@ public class ProductPBean {
}
public AccountEvent createAccountEvent(Product product, BigDecimal quantity, EventUser user, Date date) {
return this.createAccountEvent(product, null, quantity, user, date, null, null);
}
return this.createAccountEvent(product, null, quantity, user, date, null);
public AccountEvent createAccountEvent(Product product, BigDecimal quantity, EventUser user, Date date, String description) {
return this.createAccountEvent(product, null, quantity, user, date, description, null);
}
/**
......@@ -95,7 +98,7 @@ public class ProductPBean {
* AccountEvent creation time
* @return The created AccountEvent entity
*/
public AccountEvent createAccountEvent(Product product, BigDecimal overriddenUnitPrice, BigDecimal quantity, EventUser user, Date date, FoodWave foodwave) {
public AccountEvent createAccountEvent(Product product, BigDecimal overriddenUnitPrice, BigDecimal quantity, EventUser user, Date date, String description, FoodWave foodwave) {
if (!accounteventfacade.isAttached(product)) {
product = productFacade.reload(product);
......@@ -125,6 +128,18 @@ public class ProductPBean {
AccountEvent ret = new AccountEvent(user, product, unitPrice, quantity, Calendar.getInstance());
// If product name is edited, move it into the description
if(description != null && !description.isEmpty() && !product.getName().equals(description)) {
String aeDescription = description;
// Remove product name from option descriptions
aeDescription = aeDescription.replaceFirst("^" + product.getName() + ",?", "").trim();
ret.setDescription(aeDescription);
}
// ret.setDelivered(Calendar.getInstance());
ret.setSeller(permbean.getCurrentUser());
......
......@@ -186,7 +186,7 @@ public class ReaderBean implements ReaderBeanLocal {
if (reader.isAutoproduct()) {
EventUser eu = userbean.getEventUser(card.getUser().getUser(), false);
if (eu != null) {
AccountEvent createAc = productPBean.createAccountEvent(reader.getAutomaticProduct(), reader.getAutomaticProductCount(), eu, new Date());
AccountEvent createAc = productPBean.createAccountEvent(reader.getAutomaticProduct(), reader.getAutomaticProductCount(), eu, new Date(), "Created automatically");
readerfacade.flush();
logger.info("Creating new accountevent from autoproduct {}", createAc);
event.setNotes("Created automatic account event from reader. " + createAc);
......
......@@ -57,9 +57,19 @@
</p:dataTable>
</p:fieldset>
<br /><br /><br />
<br /><br />
<br />
<p:commandButton value="#{i18n['incomingflow.markEverythingGiven']}" update="membershipForm accounteventlistform" disabled="#{cardlessIncomingView.allGiven}" actionListener="#{cardlessIncomingView.giveEverything}" />
<br /><br /><br />
<br />
<p:fragment id="ungivenFragment" >
<span style="color: red; font-size: larger; font-weight: bolder;">
<h:outputText rendered="#{cardlessIncomingView.ungivenAccountevents}" value="#{i18n['incomingflow.ungivenProducts']}" />
</span>
</p:fragment>
<br />
<br />
<h:outputText rendered="#{empty cardlessIncomingView.groupMemberships}" value="#{i18n['placegroupview.noMemberships']}" />
<p:fieldset id="groupMembershipList" rendered="#{!empty cardlessIncomingView.groupMemberships}" legend="#{i18n['incomingflow.groupmemberships']}" toggleable="true" collapsed="#{fieldsetView.isCollapsed(component.id)}">
<p:ajax event="toggle" listener="#{fieldsetView.handleToggle}" />
......@@ -124,8 +134,8 @@
<h:outputText value="#{prod.description}" />
</p:column>
<p:column>
<p:commandButton update=":accounteventlistform" rendered="#{empty prod.delivered}" actionListener="#{cardlessIncomingView.giveAccountEvent}" value="#{i18n['incomingflow.giveAccountEvent']}" />
<p:commandButton update=":accounteventlistform" rendered="#{!empty prod.delivered}" actionListener="#{cardlessIncomingView.ungiveAccountEvent}" value="#{i18n['incomingflow.ungiveAccountEvent']}" />
<p:commandButton update=":accounteventlistform :membershipForm:ungivenFragment" rendered="#{empty prod.delivered}" actionListener="#{cardlessIncomingView.giveAccountEvent}" value="#{i18n['incomingflow.giveAccountEvent']}" />
<p:commandButton update=":accounteventlistform :membershipForm:ungivenFragment" rendered="#{!empty prod.delivered}" actionListener="#{cardlessIncomingView.ungiveAccountEvent}" value="#{i18n['incomingflow.ungiveAccountEvent']}" />
</p:column>
</p:dataTable>
......
......@@ -179,12 +179,6 @@ public class CardlessIncomingView extends GenericCDIView {
}
}
for(AccountEvent ae : productBean.getDeliverableAccountEvents(userview.getSelectedUser())) {
if(!ae.isEventDelivered()) {
productBean.markDelivered(ae,Calendar.getInstance());
}
}
addFaceMessage("incomingflow.allGiven",count);
memberlist = null;
......@@ -192,6 +186,27 @@ public class CardlessIncomingView extends GenericCDIView {
}
public boolean isAllGiven() {
List<GroupMembership> memberships = ticketBean.findMembershipPrintlistForUser(userview.getSelectedUser());
for(GroupMembership gm : memberships) {
if(gm.getEnteredEvent() != null) {
return false;
}
}
return true;
}
public boolean isUngivenAccountevents() {
List<AccountEvent> accountEvents = productBean.getDeliverableAccountEvents(userview.getSelectedUser());
for(AccountEvent ae : accountEvents) {
if(!ae.isEventDelivered()) {
return true;
}
}
return false;
}
......
......@@ -302,7 +302,7 @@ public class ProductShopItem implements Serializable {
if(option == null)
continue;
if(retString.length() == 0) {
if(retString.length() > 0) {
retString.append(", ");
}
retString.append(option.getName());
......
......@@ -384,7 +384,7 @@ incomingflow.giveplace = Mark given
incomingflow.groupmemberships = Computer places and tickets
incomingflow.invalidbarcode.message = Nothing found with the barcode, you can now add it to the user
incomingflow.invalidbarcode.title = Invalid code
incomingflow.markEverythingGiven = Give all ungiven items
incomingflow.markEverythingGiven=Give all ungiven tickets
incomingflow.multisearch = Multisearch
incomingflow.placesummary = Place summary
incomingflow.printedCard = Card
......@@ -1619,3 +1619,4 @@ incomingflow.giveAccountEvent=Mark given
incomingflow.ungiveAccountEvent=Mark not given
incomingflow.deliverableProducts=Products to deliver
placegroupview.accountEventDescription=Description
incomingflow.ungivenProducts=User has ungiven deliverable products
......@@ -597,7 +597,7 @@ incomingflow.giveplace = Mark given
incomingflow.groupmemberships = Computer places and tickets
incomingflow.invalidbarcode.message = Nothing found with the barcode, you can now add it to the user
incomingflow.invalidbarcode.title = Invalid code
incomingflow.markEverythingGiven = Give all ungiven items
incomingflow.markEverythingGiven=Give all ungiven tickets
incomingflow.multisearch = Multisearch
incomingflow.placesummary = Place summary
incomingflow.printedCard = Card
......@@ -1900,3 +1900,4 @@ incomingflow.giveAccountEvent=Mark given
incomingflow.ungiveAccountEvent=Mark not given
incomingflow.deliverableProducts=Products to deliver
placegroupview.accountEventDescription=Description
incomingflow.ungivenProducts=User has ungiven deliverable products
......@@ -598,7 +598,7 @@ incomingflow.giveplace = Merkitse annetuksi
incomingflow.groupmemberships = Konepaikat sek\u00E4 liput
incomingflow.invalidbarcode.message = Piipatulla koodilla ei l\u00F6ytynyt mit\u00E4\u00E4n, voit lis\u00E4t\u00E4 koodin k\u00E4ytt\u00E4j\u00E4\u00E4n
incomingflow.invalidbarcode.title = Virheellinen koodi
incomingflow.markEverythingGiven = Anna kaikki antamattomat tuotteet
incomingflow.markEverythingGiven=Anna kaikki antamattomat liput
incomingflow.multisearch = Monihaku
incomingflow.placesummary = Paikkayhteenveto
incomingflow.printedCard = Kortti
......@@ -1887,3 +1887,4 @@ incomingflow.giveAccountEvent=Merkitse annetuksi
incomingflow.ungiveAccountEvent=Ei olekkaan annettu
incomingflow.deliverableProducts=Toimitettavat tuotteet
placegroupview.accountEventDescription=Kuvaus
incomingflow.ungivenProducts=K\u00E4ytt\u00E4j\u00E4ll\u00E4 on toimittamattomia tuotteita
......@@ -78,6 +78,11 @@
<repositories>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>https://repository.primefaces.org</url>
</repository>
<repository>
<id>iudex</id>
<url>http://iudex.fi/maven/</url>
</repository>
......@@ -86,11 +91,8 @@
<name>jvnet-nexus-releases</name>
<url>https://maven.java.net/content/repositories/releases/</url>
</repository>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
</repository>
<!--
-->
<repository>
<id>apache.snapshots</id>
<url>http://repository.apache.org/snapshots/</url>
......@@ -99,5 +101,7 @@
<id>clojars.org</id>
<url>http://clojars.org/repo</url>
</repository>
</repositories>
</project>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!