Question

I'm referring to version v3 (2.2.1) of the SDK. I'm trying to figure out what I need to do to create an invoice. My issue is not any errors or connection issues, it's just that the docs seem to be poor and there's no examples. So what I have is:

BatchOperation batch= new BatchOperation();
Invoice invoice = new Invoice();
invoice.set...
...
batch.addEntity(invoice, OperationEnum.CREATE, "bID");

The problem is that I just don't understand how the many setter methods for the Invoice entity would correspond to a general invoice e.g. the ID, customer identifer etc.

If anyone has done this before could you give me an example of the kinds of setters that I might want to use for a generic invoice. My main problem here is that the explanations for all the Invoice setters (and getters) in the JavaDoc are like:

setAllowIPNPayment(Boolean value) 
       Sets the value of the allowIPNPayment property.

...and they're all like that e.g. Sets the value of the [X] property.

Was it helpful?

Solution

PFB one sample payload.

Request

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Invoice xmlns="http://schema.intuit.com/finance/v3">
        <Line>
            <Amount>15</Amount>
            <DetailType>SalesItemLineDetail</DetailType>
            <SalesItemLineDetail>
                <ItemRef name="Hours">2</ItemRef>
            </SalesItemLineDetail>
        </Line>
        <CustomerRef name="Hours">2</CustomerRef>
    </Invoice>

Response

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2014-04-30T07:35:49.705-07:00">
    <Invoice domain="QBO" sparse="false">
        <Id>16</Id>
        <SyncToken>0</SyncToken>
        <MetaData>
            <CreateTime>2014-04-30T07:35:49-07:00</CreateTime>
            <LastUpdatedTime>2014-04-30T07:35:49-07:00</LastUpdatedTime>
        </MetaData>
        <DocNumber>1003</DocNumber>
        <TxnDate>2014-04-30</TxnDate>
        <CurrencyRef name="Australian Dollar">AUD</CurrencyRef>
        <Line>
            <Id>1</Id>
            <LineNum>1</LineNum>
            <Amount>15.00</Amount>
            <DetailType>SalesItemLineDetail</DetailType>
            <SalesItemLineDetail>
                <ItemRef name="Hours">2</ItemRef>
            </SalesItemLineDetail>
        </Line>
        <Line>
            <Amount>15.00</Amount>
            <DetailType>SubTotalLineDetail</DetailType>
            <SubTotalLineDetail/>
        </Line>
        <CustomerRef name="abc">2</CustomerRef>
        <DueDate>2014-05-30</DueDate>
        <GlobalTaxCalculation>NotApplicable</GlobalTaxCalculation>
        <TotalAmt>15.00</TotalAmt>
        <PrintStatus>NeedToPrint</PrintStatus>
        <EmailStatus>NotSet</EmailStatus>
        <Balance>15.00</Balance>
        <Deposit>0</Deposit>
        <AllowIPNPayment>false</AllowIPNPayment>
        <AllowOnlinePayment>false</AllowOnlinePayment>
        <AllowOnlineCreditCardPayment>false</AllowOnlineCreditCardPayment>
        <AllowOnlineACHPayment>false</AllowOnlineACHPayment>
    </Invoice>
</IntuitResponse>

You can use the above setter using java sdk. It will create a valid Invoice. Please use IDs of valid referenced objects (Item and Customer)

Doc Ref - https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/030_entity_services_reference/invoice

Update

void createInvoice() {
    try {

        Invoice invoice = new Invoice();
        ReferenceType customerReferenceType = new ReferenceType();
        customerReferenceType.setName("abc");
        customerReferenceType.setValue("2");
        invoice.setCustomerRef(customerReferenceType);
        Line line = new Line();
        line.setAmount(new BigDecimal(15));
        line.setDetailType(LineDetailTypeEnum.SALES_ITEM_LINE_DETAIL);

        SalesItemLineDetail salesItemLineDetail = new SalesItemLineDetail();
        ReferenceType referenceType = customerReferenceType;
        referenceType.setName("Hours");
        referenceType.setValue("2");
        salesItemLineDetail.setItemRef(referenceType);
        line.setSalesItemLineDetail(salesItemLineDetail);

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

        this.service.add(invoice);
    } catch (FMSException e) {
        e.printStackTrace();
    } 

Thanks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top