Search in sources :

Example 6 with Registrant

use of site.model.Registrant in project jprime by bgjug.

the class AdminInvoiceController method sendInvoice.

@Transactional
@RequestMapping(value = "/send", method = RequestMethod.POST)
public String sendInvoice(@Valid final InvoiceData invoiceData, BindingResult bindingResult) {
    if (bindingResult.hasErrors()) {
        return INVOICE_DATA_JSP;
    }
    Registrant registrant = registrantFacade.findById(invoiceData.getRegistrantId());
    registrantFacade.setRegistrantPaid(registrant);
    invoiceData.setInvoiceType(InvoiceData.ORIGINAL_BG);
    if (invoiceData.getInvoiceNumber().equals("0")) {
        registrantFacade.generateInvoiceNumber(registrant);
    }
    invoiceData.setInvoiceNumber(String.valueOf(registrant.getRealInvoiceNumber()));
    try {
        byte[] invoice = invoiceExporter.exportInvoice(invoiceData, registrant.isCompany());
        mailFacade.sendInvoice(registrant.getEmail(), "jPrime.io original invoice", "Please find attached the invoice for the conference passes that you purchased.", invoice, TicketsController.generatePdfFilename(registrant, invoiceData.getSinglePriceWithVAT()));
        mailFacade.sendInvoice("conference@jprime.io", "jPrime.io invoice", "The attached invoice was sent to " + registrant.getEmail(), invoice, TicketsController.generatePdfFilename(registrant, invoiceData.getSinglePriceWithVAT()));
    } catch (Exception e) {
        e.printStackTrace();
    }
    return "redirect:/admin/registrant/view";
}
Also used : Registrant(site.model.Registrant) Transactional(javax.transaction.Transactional) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with Registrant

use of site.model.Registrant in project jprime by bgjug.

the class AdminRegistrantController method getNewRegistrantForm.

@RequestMapping(value = "/add", method = RequestMethod.GET)
public String getNewRegistrantForm(Model model) {
    model.addAttribute("registrant", new Registrant());
    model.addAttribute("paymentTypes", Registrant.PaymentType.values());
    model.addAttribute("branches", Branch.values());
    return REGISTRANT_EDIT_JSP;
}
Also used : Registrant(site.model.Registrant) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with Registrant

use of site.model.Registrant in project jprime by bgjug.

the class TicketsEpayRegisterControllerTest method postNonCompanyRegistrantShouldSaveVisitorDataAsRegistrant.

@Test
@Ignore("ignored since adding captcha, has to be updated")
public void postNonCompanyRegistrantShouldSaveVisitorDataAsRegistrant() throws Exception {
    mockMvc.perform(post("/tickets/epay").param("visitors[0].name", "John Doe").param("visitors[0].email", "john@example.com").param("visitors[0].company", "Example").param("company", "false")).andExpect(status().isOk()).andExpect(view().name(TICKETS_RESULT_JSP));
    List<Registrant> allRegistrants = (List<Registrant>) registrantRepository.findAll();
    assertThat(allRegistrants.size(), is(1));
    Registrant registrant = allRegistrants.get(0);
    assertThat("John Doe", is(registrant.getName()));
    assertThat("john@example.com", is(registrant.getEmail()));
    assertThat(false, is(registrant.isCompany()));
    assertThat(1, is(registrant.getVisitors().size()));
    assertThat("John Doe", is(registrant.getVisitors().get(0).getName()));
    assertThat("john@example.com", is(registrant.getVisitors().get(0).getEmail()));
    assertThat("Example", is(registrant.getVisitors().get(0).getCompany()));
}
Also used : Registrant(site.model.Registrant) List(java.util.List) Ignore(org.junit.Ignore) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with Registrant

use of site.model.Registrant in project jprime by bgjug.

the class TicketsEpayRegisterControllerTest method postCompanyRegistrantShouldSaveInvoiceData.

@Test
@Ignore("ignored since adding captcha, has to be updated")
public void postCompanyRegistrantShouldSaveInvoiceData() throws Exception {
    mockMvc.perform(post("/tickets/epay").param("visitors[0].name", "John Doe").param("visitors[0].email", "john@example.com").param("visitors[0].company", "Example").param("company", "true").param("name", "Adams Family").param("address", "0001 Cemetery Lane").param("eik", "666").param("vatNumber", "666").param("mol", "Gomez Adams").param("email", "gomez@adams.com")).andExpect(status().isOk()).andExpect(view().name(TICKETS_RESULT_JSP));
    List<Registrant> allRegistrants = (List<Registrant>) registrantRepository.findAll();
    assertThat(allRegistrants.size(), is(1));
    Registrant registrant = allRegistrants.get(0);
    assertThat("Adams Family", is(registrant.getName()));
    assertThat("gomez@adams.com", is(registrant.getEmail()));
    assertThat("Adams Family", is(registrant.getName()));
    assertThat("0001 Cemetery Lane", is(registrant.getAddress()));
    assertThat("BG666", is(registrant.getVatNumber()));
    assertThat("666", is(registrant.getEik()));
    assertThat("Gomez Adams", is(registrant.getMol()));
    assertThat(true, is(registrant.isCompany()));
    assertThat(1, is(registrant.getVisitors().size()));
    assertThat("John Doe", is(registrant.getVisitors().get(0).getName()));
    assertThat("john@example.com", is(registrant.getVisitors().get(0).getEmail()));
    assertThat("Example", is(registrant.getVisitors().get(0).getCompany()));
    assertThat(VisitorStatus.REQUESTING, is(registrant.getVisitors().get(0).getStatus()));
}
Also used : Registrant(site.model.Registrant) List(java.util.List) Ignore(org.junit.Ignore) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Registrant (site.model.Registrant)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 List (java.util.List)4 Ignore (org.junit.Ignore)3 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Transactional (javax.transaction.Transactional)2 Visitor (site.model.Visitor)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Calendar (java.util.Calendar)1 Collectors (java.util.stream.Collectors)1 MessagingException (javax.mail.MessagingException)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 Valid (javax.validation.Valid)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Qualifier (org.springframework.beans.factory.annotation.Qualifier)1 Controller (org.springframework.stereotype.Controller)1 Model (org.springframework.ui.Model)1