Skip to content

Package: AccountingXml

AccountingXml

nameinstructionbranchcomplexitylinemethod
AccountingXml(Accounting)
M: 0 C: 45
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
fill(Accounting)
M: 0 C: 27
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
lambda$fill$0(CustomerRegistry, CustomerXml)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
lambda$fill$1(ProjectRegistry, Accounting, ProjectXml)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
lambda$fill$2(InvoiceRegistry, Accounting, InvoiceXml)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * *************************************************************************************************************************************************************
3: *
4: * blueHour: open source accounting
5: * http://tidalwave.it/projects/bluehour
6: *
7: * Copyright (C) 2013 - 2024 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *************************************************************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
12: * You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
17: * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
18: *
19: * *************************************************************************************************************************************************************
20: *
21: * git clone https://bitbucket.org/tidalwave/bluehour-src
22: * git clone https://github.com/tidalwave-it/bluehour-src
23: *
24: * *************************************************************************************************************************************************************
25: */
26: package it.tidalwave.accounting.exporter.xml.impl.xml;
27:
28: import javax.annotation.Nonnull;
29: import java.util.List;
30: import javax.xml.bind.annotation.XmlAccessorOrder;
31: import javax.xml.bind.annotation.XmlAccessorType;
32: import javax.xml.bind.annotation.XmlElement;
33: import javax.xml.bind.annotation.XmlElementWrapper;
34: import javax.xml.bind.annotation.XmlRootElement;
35: import it.tidalwave.accounting.model.Accounting;
36: import lombok.NoArgsConstructor;
37: import static javax.xml.bind.annotation.XmlAccessOrder.ALPHABETICAL;
38: import static javax.xml.bind.annotation.XmlAccessType.FIELD;
39: import static java.util.Comparator.*;
40: import static java.util.stream.Collectors.*;
41:
42: /***************************************************************************************************************************************************************
43: *
44: * @author Fabrizio Giudici
45: *
46: **************************************************************************************************************************************************************/
47: //@Mutable
48: @NoArgsConstructor
49: @XmlRootElement(name = "accounting") @XmlAccessorType(FIELD) @XmlAccessorOrder(ALPHABETICAL)
50: public class AccountingXml
51: {
52: @XmlElementWrapper(name = "customers")
53: @XmlElement(name = "customer")
54: private List<CustomerXml> customersXml;
55:
56: @XmlElementWrapper(name = "projects")
57: @XmlElement(name = "project")
58: private List<ProjectXml> projectsXml;
59:
60: @XmlElementWrapper(name = "invoices")
61: @XmlElement(name = "invoice")
62: private List<InvoiceXml> invoicesxml;
63:
64: public AccountingXml (@Nonnull final Accounting accounting)
65: {
66: customersXml = accounting.getCustomerRegistry().findCustomers().stream().map(CustomerXml::new)
67: .sorted(comparing(CustomerXml::getId)).collect(toList());
68: projectsXml = accounting.getProjectRegistry().findProjects().stream().map(ProjectXml::new)
69: .sorted(comparing(ProjectXml::getId)).collect(toList());
70: invoicesxml = accounting.getInvoiceRegistry().findInvoices().stream().map(InvoiceXml::new)
71: .sorted(comparing(InvoiceXml::getId)).collect(toList());
72: }
73:
74: public void fill (@Nonnull final Accounting accounting)
75: {
76: final var customerRegistry = accounting.getCustomerRegistry();
77: final var projectRegistry = accounting.getProjectRegistry();
78: final var invoiceRegistry = accounting.getInvoiceRegistry();
79: customersXml.forEach(customer -> customerRegistry.addCustomer().with(customer.toBuilder()).create());
80: projectsXml.forEach(project -> projectRegistry.addProject().with(project.toBuilder(accounting)).create());
81: invoicesxml.forEach(invoice -> invoiceRegistry.addInvoice().with(invoice.toBuilder(accounting)).create());
82: }
83: }