示例#1
0
  @Override
  protected ActionForward handleSubmit(final ActionContext context) throws Exception {
    final SendInvoiceForm form = context.getForm();
    final boolean fromProfile = !form.isToSystem() && !form.isSelectMember();

    try {
      final Invoice invoice = invoiceService.send(resolveInvoice(context));
      context.sendMessage("invoice.sent");
      ActionForward forward = null;
      final Map<String, Object> params = new HashMap<String, Object>();
      if (fromProfile) {
        forward = context.findForward("profile");
        params.put("memberId", invoice.getToMember().getId());
      } else {
        forward = context.findForward("newInvoice");
      }
      final Member fromMember = invoice.getFromMember();
      if (fromMember != null && !fromMember.equals(context.getMember())) {
        // From another member
        params.put("from", form.getFrom());
      } else if (fromProfile) {
        params.put("to", form.getTo());
      }
      if (form.isToSystem()) {
        params.put("toSystem", true);
      } else if (form.isSelectMember()) {
        params.put("selectMember", true);
      }
      return ActionHelper.redirectWithParams(context.getRequest(), forward, params);
    } catch (final SendingInvoiceWithMultipleTransferTypesWithCustomFields e) {
      return context.sendError("invoice.error.sendingWithMultipleTransferTypesWithCustomFields");
    }
  }
示例#2
0
 private Invoice resolveInvoice(final ActionContext context) {
   final SendInvoiceForm form = context.getForm();
   final Invoice invoice = getDataBinder().readFromString(form);
   if ((context.isMember() && invoice.getFromMember() == null) || context.isOperator()) {
     invoice.setFrom(context.getAccountOwner());
   }
   return invoice;
 }