use of site.controller.invoice.InvoiceData in project jprime by bgjug.
the class TicketsController method register.
/**
* User submitted the form.
*/
@Transactional
@RequestMapping(value = "/tickets/epay", method = RequestMethod.POST)
public String register(Model model, @Valid final Registrant registrant, BindingResult bindingResult, HttpServletRequest request) throws Exception {
boolean invalidCaptcha = false;
if (registrant.getCaptcha() == null || !registrant.getCaptcha().equals(request.getSession().getAttribute(CaptchaController.SESSION_PARAM_CAPTCHA_IMAGE))) {
bindingResult.rejectValue("captcha", "invalid");
invalidCaptcha = true;
}
if (bindingResult.hasErrors() || invalidCaptcha) {
return TICKETS_REGISTER_JSP;
}
// check empty users, server side validation
List<Visitor> toBeRemoved = registrant.getVisitors().stream().filter(v -> v.getEmail() == null || v.getEmail().isEmpty() || v.getName() == null || v.getName().isEmpty()).collect(Collectors.toList());
registrant.getVisitors().removeAll(toBeRemoved);
registrant.getVisitors().forEach(visitor -> visitor.setStatus(VisitorStatus.REQUESTING));
if (!registrant.isCompany()) {
handlePersonalRegistrant(registrant);
}
registrant.setPaymentType(Registrant.PaymentType.BANK_TRANSFER);
Registrant savedRegistrant = registrantFacade.save(registrant);
model.addAttribute("tags", userFacade.findAllTags());
InvoiceData invoiceData = buildInvoiceData(savedRegistrant);
byte[] pdf = invoiceExporter.exportInvoice(invoiceData, registrant.isCompany());
sendPDF(savedRegistrant, generatePdfFilename(registrant, invoiceData.getSinglePriceWithVAT()), pdf);
return result("ok", model);
}
use of site.controller.invoice.InvoiceData in project jprime by bgjug.
the class AdminInvoiceController method invoiceDataForm.
@RequestMapping(value = "/{itemId}", method = RequestMethod.GET)
public String invoiceDataForm(@PathVariable("itemId") Long itemId, Model model) {
InvoiceData invoiceData = InvoiceData.fromRegistrant(registrantFacade.findById(itemId));
model.addAttribute("invoiceData", invoiceData);
return INVOICE_DATA_JSP;
}
use of site.controller.invoice.InvoiceData in project jprime by bgjug.
the class TicketsController method buildInvoiceData.
private InvoiceData buildInvoiceData(Registrant registrant) {
InvoiceData invoiceData = InvoiceData.fromRegistrant(registrant);
if (registrant.getPaymentType().equals(Registrant.PaymentType.BANK_TRANSFER)) {
// currently hardcoded
invoiceData.setInvoiceType(InvoiceData.PROFORMA_BG);
invoiceData.setInvoiceNumber(String.valueOf(registrant.getProformaInvoiceNumber()));
} else {
// currently hardcoded
invoiceData.setInvoiceType(InvoiceData.ORIGINAL_BG);
invoiceData.setInvoiceNumber(String.valueOf(registrant.getRealInvoiceNumber()));
}
return invoiceData;
}
Aggregations