Skip to content

Package: DefaultIBizCustomerImporter

DefaultIBizCustomerImporter

nameinstructionbranchcomplexitylinemethod
importCustomers()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
trim(String)
M: 7 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

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.importer.ibiz.impl;
27:
28: import javax.annotation.CheckForNull;
29: import javax.annotation.Nonnull;
30: import java.io.IOException;
31: import java.nio.file.Path;
32: import it.tidalwave.accounting.importer.ibiz.spi.IBizCustomerImporter;
33: import it.tidalwave.accounting.model.CustomerRegistry;
34: import lombok.RequiredArgsConstructor;
35: import lombok.extern.slf4j.Slf4j;
36:
37: /***************************************************************************************************************************************************************
38: *
39: * @author Fabrizio Giudici
40: *
41: **************************************************************************************************************************************************************/
42: @RequiredArgsConstructor @Slf4j
43: public class DefaultIBizCustomerImporter implements IBizCustomerImporter
44: {
45: @Nonnull
46: private final CustomerRegistry customerRegistry;
47:
48: @Nonnull
49: private final Path path;
50:
51: /***********************************************************************************************************************************************************
52: * {@inheritDoc}
53: **********************************************************************************************************************************************************/
54: @Override
55: public void importCustomers()
56: throws IOException
57: {
58: log.debug("importCustomers()");
59: /* final NativeAddressBook addressBook = NativeAddressBook.instance();
60: IBizUtils.loadConfiguration(path.resolve("clients")).getStream("clients").forEach(customerConfig ->
61: {
62: final String firstName = trim(customerConfig.getString("firstName"));
63: final String clientCompany = customerConfig.getString("clientCompany");
64: final Contact contact = getContact(addressBook, firstName, clientCompany);
65:
66: customerRegistry.addCustomer().withId(customerConfig.getId("addressBookId"))
67: .withName(firstName)
68: .withBillingAddress(getAddress(contact))
69: .withVatNumber(getVatNumber(contact))
70: .create();
71: });*/
72: }
73:
74: // @Nonnull
75: // private String getVatNumber (final @Nonnull Contact contact)
76: // {
77: // final MultiValue<String> phone = contact.getPhone();
78: // final MultiValue<String> email = contact.getEmail();
79: // String vat = "";
80: //
81: // if (email != null)
82: // {
83: // vat = email.getFirstHomeValue(); // VAT is also there in my address book...
84: // }
85: //
86: // if (((vat == null) || vat.equals("")) && (phone != null))
87: // {
88: // vat = phone.getFirstHomeValue(); // VAT is also there in my address book...
89: // }
90: //
91: // return vat;
92: // }
93:
94: // @Nonnull
95: // private Address getAddress (final @Nonnull Contact contact)
96: // {
97: // Address.Builder addressBuilder = Address.builder();
98: //
99: // if (contact.getAddress() != null)
100: // {
101: // final corny.addressbook.data.Address addr = contact.getAddress().getFirstHomeValue();
102: // addressBuilder = addressBuilder.withCity(addr.getCity())
103: // .withState(addr.getCountry())
104: // .withStreet(addr.getStreet())
105: // .withZip("" + addr.getZip());
106: // }
107: //
108: // return addressBuilder.create();
109: // }
110:
111: /***********************************************************************************************************************************************************
112: *
113: **********************************************************************************************************************************************************/
114: // @Nonnull
115: // private Contact getContact (final @Nonnull NativeAddressBook addressBook,
116: // final @Nonnull String firstName,
117: // final @Nonnull String clientCompany)
118: // {
119: // List<Contact> contacts = addressBook.getContactsWithFirstName(firstName);
120: //
121: // if (contacts.isEmpty())
122: // {
123: // contacts = addressBook.getContactsWithSomeAttribute(clientCompany);
124: // }
125: //
126: // return contacts.get(0);
127: // }
128:
129: @Nonnull
130: private static String trim (@CheckForNull final String string)
131: {
132:• return (string == null) ? "" : string.trim();
133: }
134: }