RTF
RTF

Reputation: 6494

QuickBooks Online Java SDK invoice creation always for the same customer

I'm referring to version v3 of the API using the Java SDK (v2.2.1). I'm using a trial account for testing, and I have 6 customers stored. The first customer I created has display name 'Abe Lincoln'. Whenever I try to create invoices for a customer using their associated customer ID (retrieved from the API by querying the display name), the invoices are created successfully but every one of them is associated with the customer 'Abe Lincoln' !!

Here's the invoice creation code. I ran it with hardcoded values just to be sure:

Invoice invoice = new Invoice();
invoice.setDocNumber("DocNum");

ReferenceType customerRef = new ReferenceType();
customerRef.setValue("4");  // display name = 'Joe Bloggs'
invoice.setCustomerRef(customerRef);

Line line = new Line();
line.setAmount( new BigDecimal(50) );
line.setDetailType(LineDetailTypeEnum.SALES_ITEM_LINE_DETAIL);

SalesItemLineDetail salesItemLineDetail = new SalesItemLineDetail();
ReferenceType itemRef = customerRef;

itemRef.setName("ProductName");
itemRef.setValue("1");
salesItemLineDetail.setItemRef(itemRef);
line.setSalesItemLineDetail(salesItemLineDetail);

List<Line> linesList = new ArrayList<Line>();
linesList.add(line);
invoice.setLine(linesList);

invoice.setPrivateNote("PrivateNote");
batch.addEntity(invoice, OperationEnum.CREATE, idx + "");

...and after running this, an invoice is created in my account for the customer 'Abe Lincoln'. The display name for the customer with id "4" is actually 'Joe Bloggs'. I've tried it with the values 2 through to 6 (which are all valid for other customers) but no matter what the result is the same. Can anyone suggest what's happening here?

Upvotes: 1

Views: 879

Answers (2)

Anirban Basak
Anirban Basak

Reputation: 193

you are overwriting value with 1 at later part.

ReferenceType itemRef = customerRef;

itemRef.setName("ProductName");
itemRef.setValue("1");

create a new ReferenceType object here...

ReferenceType itemRef = new ReferenceType();`

Upvotes: 2

Manas Mukherjee
Manas Mukherjee

Reputation: 5340

You can configure the java devkit to debug mode as mentioned in the following docs. https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0201_ipp_java_devkit_3.0/0006_logging#SDK_Logs

You can easily debug the issue by capturing and investigating the raw request/response XMLs.

Othewise, you can apiExplorer tool to query customer entity(for 'Abe Lincoln' and 'Joe Bloggs'). Please see if you have consistent DisplayName(as there are multiple name related attributes) and Id.

https://developer.intuit.com/apiexplorer?apiname=V3QBO#Customer

Thanks

Upvotes: 1

Related Questions