-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathCustomerHelper.java
99 lines (78 loc) · 3.12 KB
/
CustomerHelper.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package com.intuit.developer.sampleapp.crud.helper;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.List;
import org.apache.commons.lang.RandomStringUtils;
import com.intuit.developer.sampleapp.crud.helper.Address;
import com.intuit.developer.sampleapp.crud.helper.Email;
import com.intuit.developer.sampleapp.crud.helper.Job;
import com.intuit.developer.sampleapp.crud.helper.Telephone;
import com.intuit.ipp.data.Customer;
import com.intuit.ipp.data.ReferenceType;
import com.intuit.ipp.exception.FMSException;
import com.intuit.ipp.services.DataService;
import com.intuit.ipp.util.DateUtils;
/**
* @author dderose
*
*/
public final class CustomerHelper {
private CustomerHelper() {
}
public static Customer getCustomer(DataService service) throws FMSException, ParseException {
List<Customer> customers = (List<Customer>) service.findAll(new Customer());
if (!customers.isEmpty()) {
return customers.get(0);
}
return createCustomer(service);
}
private static Customer createCustomer(DataService service) throws FMSException, ParseException {
return service.add(getCustomerWithAllFields());
}
public static ReferenceType getCustomerRef(Customer customer) {
ReferenceType customerRef = new ReferenceType();
customerRef.setName(customer.getDisplayName());
customerRef.setValue(customer.getId());
return customerRef;
}
public static Customer getCustomerWithMandatoryFields() throws FMSException {
Customer customer = new Customer();
// Mandatory Fields
customer.setDisplayName(RandomStringUtils.randomAlphanumeric(6));
return customer;
}
public static Customer getCustomerWithAllFields() throws FMSException, ParseException {
Customer customer = new Customer();
// Mandatory Fields
customer.setDisplayName(RandomStringUtils.randomAlphanumeric(6));
customer.setTitle(RandomStringUtils.randomAlphanumeric(3));
customer.setGivenName(RandomStringUtils.randomAlphanumeric(6));
customer.setMiddleName(RandomStringUtils.randomAlphanumeric(6));
customer.setFamilyName(RandomStringUtils.randomAlphanumeric(6));
// Optional Fields
customer.setOrganization(false);
customer.setSuffix("Sr.");
customer.setCompanyName("ABC Corporations");
customer.setPrintOnCheckName("Print name");
customer.setActive(true);
customer.setPrimaryPhone(Telephone.getPrimaryPhone());
customer.setAlternatePhone(Telephone.getAlternatePhone());
customer.setMobile(Telephone.getMobilePhone());
customer.setFax(Telephone.getFax());
customer.setPrimaryEmailAddr(Email.getEmailAddress());
customer.setContactName("Contact Name");
customer.setAltContactName("Alternate Name");
customer.setNotes("Testing Notes");
customer.setBalance(new BigDecimal("0"));
customer.setOpenBalanceDate(DateUtils.getCurrentDateTime());
customer.setBalanceWithJobs(new BigDecimal("5055.5"));
customer.setCreditLimit(new BigDecimal("200000"));
customer.setAcctNum("Test020102");
customer.setResaleNum("40");
customer.setJob(false);
customer.setJobInfo(Job.getJobInfo());
customer.setBillAddr(Address.getPhysicalAddress());
customer.setShipAddr(Address.getPhysicalAddress());
return customer;
}
}