public AccountingXml (final @Nonnull Accounting accounting) { customersXml = accounting.getCustomerRegistry().findCustomers().stream().map(customer -> new CustomerXml(customer)) .collect(toList()); projectsXml = accounting.getProjectRegistry().findProjects().stream().map(project -> new ProjectXml(project)) .collect(toList()); invoicesxml = accounting.getInvoiceRegistry().findInvoices().stream().map(invoice -> new InvoiceXml(invoice)) .collect(toList()); }
public void fill (final @Nonnull Accounting accounting) { final CustomerRegistry customerRegistry = accounting.getCustomerRegistry(); final ProjectRegistry projectRegistry = accounting.getProjectRegistry(); final InvoiceRegistry invoiceRegistry = accounting.getInvoiceRegistry(); customersXml.forEach(customer -> customerRegistry.addCustomer().with(customer.toBuilder()).create()); projectsXml.forEach(project -> projectRegistry.addProject().with(project.toBuilder(accounting)).create()); invoicesxml.forEach(invoice -> invoiceRegistry.addInvoice().with(invoice.toBuilder(accounting)).create()); } }
/******************************************************************************************************************* * * Reacts to the notification that an {@link Accounting} has been opened by populating the presentation with * the customers. * * @param event the notification event * ******************************************************************************************************************/ @VisibleForTesting void onAccountingOpenedEvent (final @Nonnull @ListensTo AccountingOpenedEvent event) { log.info("onAccountingOpenedEvent({})", event); presentation.populate(event.getAccounting().getCustomerRegistry().findCustomers().stream() .map(customer -> (CustomerSpi)customer) .sorted(comparing(CustomerSpi::getName)) .map(customer -> createPresentationModelFor(customer)) .collect(toCompositePresentationModel())); }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override public void importCustomers() throws IOException { log.debug("importCustomers()"); final NativeAddressBook addressBook = NativeAddressBook.instance(); IBizUtils.loadConfiguration(path.resolve("clients")).getStream("clients").forEach(customerConfig -> { final String firstName = trim(customerConfig.getString("firstName")); final String clientCompany = customerConfig.getString("clientCompany"); final Contact contact = getContact(addressBook, firstName, clientCompany); customerRegistry.addCustomer().withId(customerConfig.getId("addressBookId")) .withName(firstName) .withBillingAddress(getAddress(contact)) .withVatNumber(getVatNumber(contact)) .create(); }); }
@Nonnull public Project.Builder toBuilder (final @Nonnull Accounting accounting) { try { final Customer customer = accounting.getCustomerRegistry().findCustomers().withId(customerXml.getId()).result(); return new Project.Builder().withId(id) .withCustomer(customer) .withName(name) .withNumber(number) .withDescription(description) .withNotes(notes) .withStatus(status) .withHourlyRate(hourlyRate) .withBudget(budget) .withStartDate(startDate) .withEndDate(endDate) .withEvents(JobEventXml.toJobEvents(jobEventsXml)); } catch (NotFoundException e) { throw new RuntimeException(e); } } }
customerRegistry.addCustomer() .withId(new Id("" + nextId++)) .withName("ACME Consulting") .create(); final Customer acmeFinancing = customerRegistry.addCustomer() .withId(new Id("" + nextId++)) .withName("ACME Financing")
public void dumpAll() throws IOException { dumpCustomers(accounting.getCustomerRegistry().findCustomers()); dumpProjects(accounting.getProjectRegistry().findProjects()); dumpInvoices(accounting.getInvoiceRegistry().findInvoices()); }
final Customer customer = customerRegistry.findCustomers().withId(customerId).result(); final IBizProjectStatus status = IBizProjectStatus.values()[projectConfig.getInt("projectStatus")];