Commit 45ed677c by Tuomas Riihimäki

Formatointia.

1 parent 1a9af8bc
......@@ -209,11 +209,9 @@ public class BillBean implements BillBeanLocal {
Product creditproduct = productBean.findCreditProduct();
EventUser user = bill.getUser();
AccountEvent ac = productBean.createAccountEvent(creditproduct,
bill.totalPrice(), user);
AccountEvent ac = productBean.createAccountEvent(creditproduct, bill.totalPrice(), user);
logger.info("Created creditentry. {}, userproducts {}", ac, user
.getAccountEvents().size());
logger.info("Created creditentry. {}, userproducts {}", ac, user.getAccountEvents().size());
ac.setDelivered(when);
ac.setEventTime(when);
......@@ -224,27 +222,20 @@ public class BillBean implements BillBeanLocal {
bill.setPaidDate(when.getTime());
// bill = billFacade.merge(bill);
boolean checked = false;
for (BillLine bl : bill.getBillLines()) {
Product prod = bl.getLineProduct();
if (prod != null
&& prod.getProductFlags().contains(
ProductFlag.PREPAID_INSTANT_CREATE)) {
logger.debug("Creating Bill prepaidInstant product {}, {}",
prod.getName(), bl.getQuantity());
if (prod.getProductFlags().contains(
ProductFlag.RESERVE_PLACE_WHEN_BOUGHT)
|| prod.getProductFlags().contains(
ProductFlag.CREATE_NEW_PLACE_WHEN_BOUGHT)) {
placebean.lockPlaceProduct(bill.getUser(), prod,
bl.getQuantity());
if (prod != null && prod.getProductFlags().contains(ProductFlag.PREPAID_INSTANT_CREATE)) {
logger.debug("Creating Bill prepaidInstant product {}, {}", prod.getName(), bl.getQuantity());
if (prod.getProductFlags().contains(ProductFlag.RESERVE_PLACE_WHEN_BOUGHT)
|| prod.getProductFlags().contains(ProductFlag.CREATE_NEW_PLACE_WHEN_BOUGHT)) {
placebean.lockPlaceProduct(bill.getUser(), prod, bl.getQuantity());
}
AccountEvent ac2 = productPBean.createAccountEvent(prod,
bl.getQuantity(), user, bill.getSentDate(), bl.getFoodwave());
logger.info("Created ac from product. {}, userproducts {}",
ac2, user.getAccountEvents().size());
AccountEvent ac2 = productPBean.createAccountEvent(prod, bl.getQuantity(), user, bill.getSentDate(), bl.getFoodwave());
logger.info("Created ac from product. {}, userproducts {}", ac2, user.getAccountEvents().size());
ac2.setSeller(permbean.getCurrentUser());
......@@ -253,9 +244,7 @@ public class BillBean implements BillBeanLocal {
}
MailMessage msg = new MailMessage();
msg.setSubject(I18n.get("bill.billMarkedPaidMail.subject"));
msg.setMessage(I18n.get("bill.billMarkedPaidMail.message", (bill
.getBillNumber() == null) ? "----" : bill.getBillNumber()
.toString()));
msg.setMessage(I18n.get("bill.billMarkedPaidMail.message", (bill.getBillNumber() == null) ? "----" : bill.getBillNumber().toString()));
msg.setTo(bill.getUser().getUser());
utilbean.sendMail(msg);
eventUserFacade.flush();
......@@ -265,13 +254,9 @@ public class BillBean implements BillBeanLocal {
@Override
@RolesAllowed({ BillPermission.S_CREATE_BILL, BillPermission.S_WRITE_ALL })
public void createBill(Bill bill) {
if (!permbean.isCurrentUser(bill.getUser())
&& !permbean.hasPermission(BillPermission.WRITE_ALL)) {
loggingBean.logMessage(SecurityLogType.permissionDenied,
permbean.getCurrentUser(),
"Not enought rights to create bill for user ");
throw new EJBAccessException(
"Could not create bill for another user");
if (!permbean.isCurrentUser(bill.getUser()) && !permbean.hasPermission(BillPermission.WRITE_ALL)) {
loggingBean.logMessage(SecurityLogType.permissionDenied, permbean.getCurrentUser(), "Not enought rights to create bill for user ");
throw new EJBAccessException("Could not create bill for another user");
}
billFacade.create(bill);
generateBillNumber(bill);
......@@ -285,13 +270,9 @@ public class BillBean implements BillBeanLocal {
@Override
@RolesAllowed({ BillPermission.S_VIEW_OWN, BillPermission.S_READ_ALL })
public List<Bill> find(EventUser user) {
if (!permbean.isCurrentUser(user)
&& !permbean.hasPermission(BillPermission.READ_ALL)) {
loggingBean.logMessage(SecurityLogType.permissionDenied,
permbean.getCurrentUser(),
"Not enought rights to get bill list for user ");
throw new EJBAccessException(
"Could not list bills for another user");
if (!permbean.isCurrentUser(user) && !permbean.hasPermission(BillPermission.READ_ALL)) {
loggingBean.logMessage(SecurityLogType.permissionDenied, permbean.getCurrentUser(), "Not enought rights to get bill list for user ");
throw new EJBAccessException("Could not list bills for another user");
}
return billFacade.find(user);
}
......
......@@ -78,15 +78,14 @@ public class ProductPBean {
unitPrice = unitPrice.multiply(d.getPercentage());
}
AccountEvent ret = new AccountEvent(user, product, unitPrice, quantity,
Calendar.getInstance());
AccountEvent ret = new AccountEvent(user, product, unitPrice, quantity, Calendar.getInstance());
ret.setDelivered(Calendar.getInstance());
ret.setSeller(permbean.getCurrentUser());
if (foodwave != null) {
ret.setFoodWave(foodwave);
if(foodwave.getAccountEvents() == null) {
if (foodwave.getAccountEvents() == null) {
foodwave.setAccountEvents(new ArrayList<AccountEvent>());
}
foodwave.getAccountEvents().add(ret);
......
......@@ -7,6 +7,7 @@ import javax.faces.bean.RequestScoped;
import javax.inject.Named;
import fi.insomnia.bortal.beans.ActionLogBeanLocal;
import fi.insomnia.bortal.enums.apps.ContentPermission;
import fi.insomnia.bortal.model.ActionLogMessage;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
......@@ -29,6 +30,9 @@ public class ActionLogMessageView extends GenericCDIView {
}
public List<ActionLogMessage> getMessages() {
if (super.hasPermission(ContentPermission.MANAGE_ACTIONLOG)) {
return actionLogBean.getAllActionLogEvents();
}
return null;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!