qbxml 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +11 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +95 -0
  5. data/Rakefile +1 -0
  6. data/TODO.md +3 -0
  7. data/lib/qbxml.rb +12 -0
  8. data/lib/qbxml/hash.rb +148 -0
  9. data/lib/qbxml/qbxml.rb +102 -0
  10. data/lib/qbxml/types.rb +39 -0
  11. data/lib/qbxml/version.rb +3 -0
  12. data/qbxml.gemspec +23 -0
  13. data/schema/qbposxmlops30.xml +8343 -0
  14. data/schema/qbxmlops70.xml +26714 -0
  15. data/spec/backwards_compatibility.rb +26 -0
  16. data/spec/spec_helper.rb +25 -0
  17. data/spec/support/requests/account_query_rq.xml +8 -0
  18. data/spec/support/requests/customer_add_rq.xml +28 -0
  19. data/spec/support/requests/customer_query_iterator_rq.xml +11 -0
  20. data/spec/support/requests/customer_query_rq.xml +9 -0
  21. data/spec/support/requests/estimate_add_rq.xml +45 -0
  22. data/spec/support/requests/invoice_add_rq.xml +40 -0
  23. data/spec/support/requests/item_inventory_add_rq.xml +22 -0
  24. data/spec/support/requests/purchase_order_query_rq.xml +14 -0
  25. data/spec/support/requests/receive_payment_add_rq.xml +35 -0
  26. data/spec/support/requests/receive_payment_query_rq.xml +9 -0
  27. data/spec/support/requests/sales_receipt_add_rq.xml +49 -0
  28. data/spec/support/responses/account_query_rs.xml +42 -0
  29. data/spec/support/responses/customer_add_rs.xml +37 -0
  30. data/spec/support/responses/customer_query_rs.xml +49 -0
  31. data/spec/support/responses/customer_query_terator_rs.xml +34 -0
  32. data/spec/support/responses/item_inventory_add_rs.xml +40 -0
  33. data/spec/support/responses/purchase_order_query_rs.xml +84 -0
  34. data/spec/support/responses/receive_payment_query_rs.xml +51 -0
  35. data/spec/support/responses/sales_receipt_add_rs.xml +89 -0
  36. metadata +150 -0
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+ require 'quickbooks'
3
+
4
+ describe Qbxml do
5
+ context 'backwards compatibility with the quickbooks_api gem' do
6
+
7
+ let(:qb_old) { Quickbooks::API[:qb] }
8
+ let(:qb_new) { Qbxml.new(:qb) }
9
+
10
+ it 'should produce the same results when parsing qbxml/hash data' do
11
+ (requests + responses).each do |data|
12
+ old_parse = qb_old.qbxml_to_hash(data, true)
13
+
14
+ new_parse1 = qb_new.from_qbxml(data)
15
+ new_parse1.should == { 'qbxml' => old_parse }
16
+
17
+ # XML is a pain to compare so we can compare the parsed hash resulting
18
+ # from the generated XML instead.
19
+ #
20
+ new_parse2 = qb_new.from_qbxml(qb_new.to_qbxml(new_parse1))
21
+ new_parse2.should == { 'qbxml' => old_parse }
22
+ end
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,25 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ require 'rubygems'
5
+ require 'bundler/setup'
6
+ Bundler.require :default
7
+
8
+ require 'qbxml'
9
+ RSpec.configure do |config|
10
+ config.treat_symbols_as_metadata_keys_with_true_values = true
11
+ config.filter_run :focus => true
12
+ config.run_all_when_everything_filtered = true
13
+ end
14
+
15
+ SUPPORT_DIR = "#{File.dirname(__FILE__)}/support" unless defined? SUPPORT_DIR
16
+ REQUEST_DIR = "#{SUPPORT_DIR}/requests" unless defined? REQUEST_DIR
17
+ RESPONSE_DIR = "#{SUPPORT_DIR}/responses" unless defined? RESPONSE_DIR
18
+
19
+ def requests
20
+ Dir["#{REQUEST_DIR}/*.xml"].map { |f| File.read(f) }
21
+ end
22
+
23
+ def responses
24
+ Dir["#{RESPONSE_DIR}/*.xml"].map { |f| File.read(f) }
25
+ end
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <?qbxml version="2.0"?>
3
+ <QBXML>
4
+ <QBXMLMsgsRq onError="stopOnError">
5
+ <AccountQueryRq requestID="16">
6
+ </AccountQueryRq>
7
+ </QBXMLMsgsRq>
8
+ </QBXML>
@@ -0,0 +1,28 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <?qbxml version="2.0"?>
3
+ <QBXML>
4
+ <QBXMLMsgsRq onError="stopOnError">
5
+ <CustomerAddRq requestID="15">
6
+ <CustomerAdd>
7
+ <Name>20706 - Eastern XYZ University</Name>
8
+ <CompanyName>Eastern XYZ University</CompanyName>
9
+ <FirstName>Keith</FirstName>
10
+ <LastName>Palmer</LastName>
11
+ <BillAddress>
12
+ <Addr1>Eastern XYZ University</Addr1>
13
+ <Addr2>College of Engineering</Addr2>
14
+ <Addr3>123 XYZ Road</Addr3>
15
+ <City>Storrs-Mansfield</City>
16
+ <State>CT</State>
17
+ <PostalCode>06268</PostalCode>
18
+ <Country>United States</Country>
19
+ </BillAddress>
20
+ <Phone>860-634-1602</Phone>
21
+ <AltPhone>860-429-0021</AltPhone>
22
+ <Fax>860-429-5183</Fax>
23
+ <Email>keith@consolibyte.com</Email>
24
+ <Contact>Keith Palmer</Contact>
25
+ </CustomerAdd>
26
+ </CustomerAddRq>
27
+ </QBXMLMsgsRq>
28
+ </QBXML>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <?qbxml version="5.0"?>
3
+ <QBXML>
4
+ <QBXMLMsgsRq onError="continueOnError">
5
+ <CustomerQueryRq requestID="1" iterator="Start">
6
+ <MaxReturned>5</MaxReturned>
7
+ <FromModifiedDate>1984-01-29T22:03:19</FromModifiedDate>
8
+ <OwnerID>0</OwnerID>
9
+ </CustomerQueryRq>
10
+ </QBXMLMsgsRq>
11
+ </QBXML>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <?qbxml version="5.0"?>
3
+ <QBXML>
4
+ <QBXMLMsgsRq onError="stopOnError">
5
+ <CustomerQueryRq requestID="Q3VzdG9tZXJRdWVyeXwyODk2">
6
+ <FullName>Keith Palmer</FullName>
7
+ </CustomerQueryRq>
8
+ </QBXMLMsgsRq>
9
+ </QBXML>
@@ -0,0 +1,45 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <?qbxml version="6.0"?>
3
+ <QBXML>
4
+ <QBXMLMsgsRq onError="stopOnError">
5
+ <EstimateAddRq requestID="2">
6
+ <EstimateAdd>
7
+
8
+ <CustomerRef>
9
+ <FullName>Keith's Company</FullName>
10
+ </CustomerRef>
11
+
12
+ <TxnDate>2007-12-14</TxnDate>
13
+ <RefNumber>9668</RefNumber>
14
+
15
+ <BillAddress>
16
+ <Addr1>56 Cowles Road</Addr1>
17
+ <City>Willington</City>
18
+ <State>CT</State>
19
+ <PostalCode>06279</PostalCode>
20
+ <Country>United States</Country>
21
+ </BillAddress>
22
+
23
+ <EstimateLineAdd>
24
+ <ItemRef>
25
+ <FullName>Item Name 1</FullName>
26
+ </ItemRef>
27
+ <Desc>Item 1 Description Goes Here</Desc>
28
+ <Quantity>1</Quantity>
29
+ <Rate>295</Rate>
30
+ </EstimateLineAdd>
31
+
32
+ <EstimateLineAdd>
33
+ <ItemRef>
34
+ <FullName>Item Name 2</FullName>
35
+ </ItemRef>
36
+ <Desc>Item 2 Description Goes Here</Desc>
37
+ <Quantity>3</Quantity>
38
+ <Rate>25</Rate>
39
+ </EstimateLineAdd>
40
+
41
+ </EstimateAdd>
42
+ </EstimateAddRq>
43
+ </QBXMLMsgsRq>
44
+ </QBXML>
45
+
@@ -0,0 +1,40 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <?qbxml version="2.0"?>
3
+ <QBXML>
4
+ <QBXMLMsgsRq onError="stopOnError">
5
+ <InvoiceAddRq requestID="2">
6
+ <InvoiceAdd>
7
+ <CustomerRef>
8
+ <ListID>F560000-1197683156</ListID>
9
+ </CustomerRef>
10
+ <TxnDate>2007-12-14</TxnDate>
11
+ <RefNumber>9668</RefNumber>
12
+ <BillAddress>
13
+ <Addr1>56 Cowles Road</Addr1>
14
+ <City>Willington</City>
15
+ <State>CT</State>
16
+ <PostalCode>06279</PostalCode>
17
+ <Country>United States</Country>
18
+ </BillAddress>
19
+ <PONumber/>
20
+ <Memo/>
21
+ <InvoiceLineAdd>
22
+ <ItemRef>
23
+ <FullName>Downloaded Invoice</FullName>
24
+ </ItemRef>
25
+ <Desc>Item 1 Description Goes Here</Desc>
26
+ <Quantity>1</Quantity>
27
+ <Rate>295</Rate>
28
+ </InvoiceLineAdd>
29
+ <InvoiceLineAdd>
30
+ <ItemRef>
31
+ <FullName>Downloaded Invoice</FullName>
32
+ </ItemRef>
33
+ <Desc>Item 2 Description Goes Here</Desc>
34
+ <Quantity>3</Quantity>
35
+ <Rate>25</Rate>
36
+ </InvoiceLineAdd>
37
+ </InvoiceAdd>
38
+ </InvoiceAddRq>
39
+ </QBXMLMsgsRq>
40
+ </QBXML>
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <?qbxml version="7.0"?>
3
+ <QBXML>
4
+ <QBXMLMsgsRq onError="stopOnError">
5
+ <ItemInventoryAddRq requestID="SXRlbUludmVudG9yeUFkZHwxNTA=" >
6
+ <ItemInventoryAdd>
7
+ <Name>product name here</Name>
8
+ <SalesDesc>your sales description here</SalesDesc>
9
+ <SalesPrice>85.00</SalesPrice>
10
+ <IncomeAccountRef>
11
+ <FullName>Sales</FullName>
12
+ </IncomeAccountRef>
13
+ <COGSAccountRef>
14
+ <FullName>Cost of Goods Sold</FullName>
15
+ </COGSAccountRef>
16
+ <AssetAccountRef>
17
+ <FullName>Inventory Asset</FullName>
18
+ </AssetAccountRef>
19
+ </ItemInventoryAdd>
20
+ </ItemInventoryAddRq>
21
+ </QBXMLMsgsRq>
22
+ </QBXML>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <?qbxml version="8.0"?>
3
+ <QBXML>
4
+ <QBXMLMsgsRq onError="stopOnError">
5
+ <PurchaseOrderQueryRq requestID="UHVyY2hhc2VPcmRlckltcG9ydHwx" iterator="Start" >
6
+ <MaxReturned>10</MaxReturned>
7
+ <!--<ModifiedDateRangeFilter>
8
+ <FromModifiedDate>2010-09-27T22:20:09</FromModifiedDate>
9
+ </ModifiedDateRangeFilter>-->
10
+ <IncludeLineItems>true</IncludeLineItems>
11
+ <OwnerID>0</OwnerID>
12
+ </PurchaseOrderQueryRq>
13
+ </QBXMLMsgsRq>
14
+ </QBXML>
@@ -0,0 +1,35 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <?qbxml version="2.1"?>
3
+ <QBXML>
4
+ <QBXMLMsgsRq onError="stopOnError">
5
+ <ReceivePaymentAddRq>
6
+ <ReceivePaymentAdd>
7
+ <CustomerRef>
8
+ <ListID>F230000-1196864585</ListID>
9
+ <!--<FullName>Keith Palmer</FullName>--> <!-- You can specify either ListID or FullName -->
10
+ </CustomerRef>
11
+ <!--<ARAccountRef>
12
+ <ListID></ListID>
13
+ <FullName></FullName>
14
+ </ARAccountRef>-->
15
+ <TxnDate>2007-12-14</TxnDate>
16
+ <RefNumber>00612361</RefNumber>
17
+ <TotalAmount>195.00</TotalAmount>
18
+ <PaymentMethodRef>
19
+ <FullName>Check</FullName>
20
+ </PaymentMethodRef>
21
+ <Memo>Inv. #9460</Memo>
22
+ <!--<DepositToAccountRef>
23
+ <ListID></ListID>
24
+ <FullName></FullName>
25
+ </DepositToAccountRef>-->
26
+ <AppliedToTxnAdd>
27
+ <TxnID>12006-1196864828</TxnID>
28
+ <PaymentAmount>195.00</PaymentAmount>
29
+ </AppliedToTxnAdd>
30
+ <!-- If you don't want to apply payments manually to a particular transaction, use <IsAutoApply>true</IsAutoApply> -->
31
+ <!-- instead of the <AppliedToTxn> node. QuickBooks will make it's best guess how to apply the payment. -->
32
+ </ReceivePaymentAdd>
33
+ </ReceivePaymentAddRq>
34
+ </QBXMLMsgsRq>
35
+ </QBXML>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <?qbxml version="8.0"?>
3
+ <QBXML>
4
+ <QBXMLMsgsRq onError="stopOnError">
5
+ <ReceivePaymentQueryRq requestID="UmVjZWl2ZVBheW1lbnRRdWVyeXwyNDg0LTEyNjM0OTkyMzE=">
6
+ <TxnID>2484-1263499231</TxnID>
7
+ </ReceivePaymentQueryRq>
8
+ </QBXMLMsgsRq>
9
+ </QBXML>
@@ -0,0 +1,49 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <?qbxml version="7.0"?>
3
+ <QBXML>
4
+ <QBXMLMsgsRq onError="stopOnError">
5
+ <SalesReceiptAddRq requestID="U2FsZXNSZWNlaXB0QWRkfDE2NDY2" >
6
+ <SalesReceiptAdd>
7
+ <CustomerRef>
8
+ <ListID>80003579-1231522938</ListID>
9
+ </CustomerRef>
10
+ <TxnDate>2009-01-09</TxnDate>
11
+ <RefNumber>16466</RefNumber>
12
+ <BillAddress>
13
+ <Addr1>Tom Test</Addr1>
14
+ <Addr3>123 Test St</Addr3>
15
+ <City>Concord</City>
16
+ <State>Massachusetts</State>
17
+ <PostalCode>01742</PostalCode>
18
+ <Country>United States</Country>
19
+ </BillAddress>
20
+ <ShipAddress>
21
+ </ShipAddress>
22
+ <IsPending>true</IsPending>
23
+ <IsToBePrinted>true</IsToBePrinted>
24
+ <IsToBeEmailed>false</IsToBeEmailed>
25
+ <SalesReceiptLineAdd>
26
+ <ItemRef>
27
+ <ListID>200001-1143815300</ListID>
28
+ </ItemRef>
29
+ <Desc>$150.00 gift certificate</Desc>
30
+ <Quantity>1</Quantity>
31
+ <Rate>150.00</Rate>
32
+ <SalesTaxCodeRef>
33
+ <FullName>NON</FullName>
34
+ </SalesTaxCodeRef>
35
+ </SalesReceiptLineAdd>
36
+ <SalesReceiptLineAdd>
37
+ <ItemRef>
38
+ <ListID>80000857-1231503074</ListID>
39
+ </ItemRef>
40
+ <Desc>Handling Charge</Desc>
41
+ <Amount>0.00</Amount>
42
+ <SalesTaxCodeRef>
43
+ <FullName>NON</FullName>
44
+ </SalesTaxCodeRef>
45
+ </SalesReceiptLineAdd>
46
+ </SalesReceiptAdd>
47
+ </SalesReceiptAddRq>
48
+ </QBXMLMsgsRq>
49
+ </QBXML>
@@ -0,0 +1,42 @@
1
+ <?xml version="1.0" ?>
2
+ <QBXML>
3
+ <QBXMLMsgsRs>
4
+ <AccountQueryRs requestID="52" statusCode="0" statusSeverity="Info" statusMessage="Status OK">
5
+ <AccountRet>
6
+ <ListID>80000020-1209525941</ListID>
7
+ <TimeCreated>2008-04-29T23:25:41-05:00</TimeCreated>
8
+ <TimeModified>2008-04-29T23:25:41-05:00</TimeModified>
9
+ <EditSequence>1209525941</EditSequence>
10
+ <Name>Checking</Name>
11
+ <FullName>Checking</FullName>
12
+ <IsActive>true</IsActive>
13
+ <Sublevel>0</Sublevel>
14
+ <AccountType>Bank</AccountType>
15
+ <Balance>-197.02</Balance>
16
+ <TotalBalance>-197.02</TotalBalance>
17
+ <TaxLineInfoRet>
18
+ <TaxLineID>1864</TaxLineID>
19
+ <TaxLineName>B/S-Assets: Cash</TaxLineName>
20
+ </TaxLineInfoRet>
21
+ <CashFlowClassification>NotApplicable</CashFlowClassification>
22
+ </AccountRet>
23
+ <AccountRet>
24
+ <ListID>8000001E-1203476531</ListID>
25
+ <TimeCreated>2008-02-19T22:02:11-05:00</TimeCreated>
26
+ <TimeModified>2008-02-19T22:02:11-05:00</TimeModified>
27
+ <EditSequence>1203476531</EditSequence>
28
+ <Name>Accounts Receivable UPDATED</Name>
29
+ <FullName>Accounts Receivable UPDATED</FullName>
30
+ <IsActive>true</IsActive>
31
+ <Sublevel>0</Sublevel>
32
+ <AccountType>AccountsReceivable</AccountType>
33
+ <SpecialAccountType>AccountsReceivable</SpecialAccountType>
34
+ <AccountNumber>11000</AccountNumber>
35
+ <Desc>Unpaid or unapplied customer </Desc>
36
+ <Balance>951.65</Balance>
37
+ <TotalBalance>951.65</TotalBalance>
38
+ <CashFlowClassification>Operating</CashFlowClassification>
39
+ </AccountRet>
40
+ </AccountQueryRs>
41
+ </QBXMLMsgsRs>
42
+ </QBXML>
@@ -0,0 +1,37 @@
1
+ <?xml version="1.0" ?>
2
+ <QBXML>
3
+ <QBXMLMsgsRs>
4
+ <CustomerAddRs requestID="15" statusCode="0" statusSeverity="Info" statusMessage="Status OK">
5
+ <CustomerRet>
6
+ <ListID>F540000-1197683154</ListID>
7
+ <TimeCreated>2007-12-14T20:45:54-05:00</TimeCreated>
8
+ <TimeModified>2007-12-14T20:45:54-05:00</TimeModified>
9
+ <EditSequence>1197683154</EditSequence>
10
+ <Name>20706 - Eastern XYZ University</Name>
11
+ <FullName>20706 - Eastern XYZ University</FullName>
12
+ <IsActive>true</IsActive>
13
+ <Sublevel>0</Sublevel>
14
+ <CompanyName>Eastern XYZ University</CompanyName>
15
+ <FirstName>Keith</FirstName>
16
+ <LastName>Palmer</LastName>
17
+ <BillAddress>
18
+ <Addr1>Eastern XYZ University</Addr1>
19
+ <Addr2>College of Engineering</Addr2>
20
+ <Addr3>123 XYZ Road</Addr3>
21
+ <City>Storrs-Mansfield</City>
22
+ <State>CT</State>
23
+ <PostalCode>88130</PostalCode>
24
+ <Country>USA</Country>
25
+ </BillAddress>
26
+ <Phone>860-634-1602</Phone>
27
+ <AltPhone>860-429-0021</AltPhone>
28
+ <Fax>860-429-5183</Fax>
29
+ <Email>keith@consolibyte.com</Email>
30
+ <Contact>Keith Palmer</Contact>
31
+ <Balance>0.00</Balance>
32
+ <TotalBalance>0.00</TotalBalance>
33
+ <JobStatus>None</JobStatus>
34
+ </CustomerRet>
35
+ </CustomerAddRs>
36
+ </QBXMLMsgsRs>
37
+ </QBXML>
@@ -0,0 +1,49 @@
1
+ <?xml version="1.0" ?>
2
+ <QBXML>
3
+ <QBXMLMsgsRs>
4
+ <CustomerQueryRs requestID="Q3VzdG9tZXJRdWVyeXwyODk2" statusCode="0" statusSeverity="Info" statusMessage="Status OK">
5
+ <CustomerRet>
6
+ <ListID>10006-1211236622</ListID>
7
+ <TimeCreated>2008-05-19T18:37:02-05:00</TimeCreated>
8
+ <TimeModified>2008-06-10T23:35:56-05:00</TimeModified>
9
+ <EditSequence>1213155356</EditSequence>
10
+ <Name>Keith Palmer</Name>
11
+ <FullName>Keith Palmer</FullName>
12
+ <IsActive>true</IsActive>
13
+ <Sublevel>0</Sublevel>
14
+ <FirstName>Keith</FirstName>
15
+ <LastName>Palmer</LastName>
16
+ <BillAddress>
17
+ <Addr1>134 Stonemill Road</Addr1>
18
+ <Addr2>Suite D</Addr2>
19
+ <City>Storrs</City>
20
+ <State>CT</State>
21
+ <PostalCode>06268</PostalCode>
22
+ <Country>USA</Country>
23
+ </BillAddress>
24
+ <ShipAddress>
25
+ <Addr1>134 Stonemill Road</Addr1>
26
+ <Addr2>Suite D</Addr2>
27
+ <City>Storrs</City>
28
+ <State>CT</State>
29
+ <PostalCode>06268</PostalCode>
30
+ <Country>USA</Country>
31
+ </ShipAddress>
32
+ <Phone>(860) 634-1602</Phone>
33
+ <Fax>(860) 429-5182</Fax>
34
+ <Email>keith@uglyslug.com</Email>
35
+ <Balance>250.00</Balance>
36
+ <TotalBalance>250.00</TotalBalance>
37
+ <SalesTaxCodeRef>
38
+ <ListID>20000-1211065841</ListID>
39
+ <FullName>Non</FullName>
40
+ </SalesTaxCodeRef>
41
+ <ItemSalesTaxRef>
42
+ <ListID>10000-1211066051</ListID>
43
+ <FullName>Out of State</FullName>
44
+ </ItemSalesTaxRef>
45
+ <JobStatus>None</JobStatus>
46
+ </CustomerRet>
47
+ </CustomerQueryRs>
48
+ </QBXMLMsgsRs>
49
+ </QBXML>