Skip to content

Commit 02b4680

Browse files
author
david_webb6
committed
invoiceadd 32 bit
1 parent 4916fb9 commit 02b4680

17 files changed

+3283
-0
lines changed

qbdt/vb.NET/qbXML/CDN_InvoiceAdd.zip

53.2 KB
Binary file not shown.
Binary file not shown.
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
Option Strict Off
2+
Option Explicit On
3+
Module ArAccountInfo
4+
' ArAccountInfo.bas
5+
' This module is part of the Invoice sample program
6+
' for the QuickBooks SDK Version CA2.0.
7+
' Created September, 2002
8+
'
9+
' Copyright © 2021-2022 Intuit Inc. All rights reserved.
10+
' Use is subject to the terms specified at:
11+
' http://developer.intuit.com/legal/devsite_tos.html
12+
'
13+
'-------------------------------------------------------------
14+
15+
16+
'Public String variable that contains the currency associated to the accounts
17+
Public colArAccount As Collection
18+
Function GetArAccountList() As Object
19+
'The GetArAccountList function generates a request to QuickBooks and call the ParseArAccount procedure to parse the
20+
'ArAccount's list
21+
'On Error GoTo ErrHandler
22+
'Call OpenConnection to establish a QuickBooks connection and session
23+
If Not blnIsOpenConnection Then
24+
If Not OpenConnection Then
25+
Exit Function
26+
End If
27+
End If
28+
29+
30+
' We generate the request qbXML in order to get the ArAccount list and filtering to have just the account receivables.
31+
requestXML = "<?xml version=""1.0"" ?>" & "<?qbxml version=""2.0""?>" & "<QBXML><QBXMLMsgsRq onError=""continueOnError"">" & "<AccountQueryRq requestID=""1"">" & "<AccountType>AccountsReceivable</AccountType>" & "</AccountQueryRq>" & "</QBXMLMsgsRq></QBXML>"
32+
33+
34+
' PrintXMLToFile requestXML, "C:\request.xml" '*** remove comment character to produce a xml request file
35+
36+
' Send request to QuickBooks
37+
responseXML = qbXMLRP.ProcessRequest(ticket, requestXML)
38+
39+
'PrintXMLToFile responseXML, "C:\response.xml" '*** remove Comment character to produce a xml response file
40+
41+
'The ParseArAccount function parses the response coming from QuickBooks and populates the colArAccount collection
42+
ParseArAccount((responseXML))
43+
Exit Function
44+
ErrHandler:
45+
' In case something goes wrong along the way..
46+
MsgBox("Error sending request to QuickBooks: " & Err.Description)
47+
CloseConnection()
48+
End Function
49+
50+
Sub ParseArAccount(ByRef sXML As Object)
51+
'This function parse the response to the ArAccountQuery request
52+
'The parsed information is save in the public colArAccount collection
53+
54+
Dim objXmlDoc As New MSXML2.DOMDocument60
55+
Dim objRootElement As MSXML2.IXMLDOMElement ' root element of the XML document (QBXML Block)
56+
Dim objMsgsRsNode As MSXML2.IXMLDOMNode ' QBXMLMsgsRs grouping (opening tag of message)
57+
Dim objMessageNode As MSXML2.IXMLDOMNode ' Message node
58+
Dim objArAccountNode As MSXML2.IXMLDOMNode ' ArAccount node
59+
Dim objArAccountItem As MSXML2.IXMLDOMNode ' ArAccount node
60+
Dim objElementItem As MSXML2.IXMLDOMNode ' Element node
61+
62+
Dim strFullName As String
63+
Dim strArAccountArray(1) As String
64+
'strArAccountArray(0) is the name of the ArAccount
65+
'strArAccountArray(1) is the currencyref
66+
' Load XML Script
67+
objXmlDoc.async = False
68+
69+
If objXmlDoc.loadXML(sXML) = True And Len(objXmlDoc.xml) > 0 Then 'verify that there is some values in the documents
70+
71+
objRootElement = objXmlDoc.documentElement
72+
73+
For Each objMsgsRsNode In objRootElement.childNodes
74+
75+
If objMsgsRsNode.nodeName = "QBXMLMsgsRs" Then
76+
77+
For Each objMessageNode In objMsgsRsNode.childNodes
78+
79+
' If we find the Account list, let's parse it.
80+
If objMessageNode.nodeName = "AccountQueryRs" Then
81+
82+
For Each objArAccountNode In objMessageNode.childNodes
83+
strArAccountArray(0) = ""
84+
strArAccountArray(1) = ""
85+
86+
For Each objArAccountItem In objArAccountNode.childNodes
87+
'Transfer the ArAccount information into the collection
88+
If objArAccountItem.nodeName = "FullName" Then
89+
90+
strFullName = objArAccountItem.nodeTypedValue
91+
strArAccountArray(0) = strFullName
92+
ElseIf objArAccountItem.nodeName = "CurrencyRef" Then
93+
' Parses the CurrencyRef node
94+
For Each objElementItem In objArAccountItem.childNodes
95+
If objElementItem.nodeName = "ListID" Then
96+
'Insert the ListID into the colArAccount collection. One property of the a collection is to accept
97+
'a second parameter that is alphanumeric and will used as an identifier of the object. The name of the ArAccount is used as
98+
' the identifier
99+
100+
101+
strArAccountArray(1) = objElementItem.nodeTypedValue
102+
Exit For 'We have the list ID, go to the next element
103+
End If
104+
Next objElementItem
105+
End If
106+
Next objArAccountItem
107+
colArAccount.Add(strArAccountArray, strFullName)
108+
Next objArAccountNode
109+
110+
End If
111+
Next objMessageNode
112+
End If
113+
Next objMsgsRsNode
114+
End If
115+
End Sub
116+
End Module
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Imports System.Reflection
2+
Imports System.Runtime.CompilerServices
3+
Imports System.Runtime.InteropServices
4+
5+
' General Information about an assembly is controlled through the following
6+
' set of attributes. Change these attribute values to modify the information
7+
' associated with an assembly.
8+
9+
10+
' TODO: Review the values of the assembly attributes
11+
12+
13+
<Assembly: AssemblyTitle("")>
14+
<Assembly: AssemblyDescription("")>
15+
<Assembly: AssemblyCompany("Intuit")>
16+
<Assembly: AssemblyProduct("")>
17+
<Assembly: AssemblyCopyright("")>
18+
<Assembly: AssemblyTrademark("")>
19+
<Assembly: AssemblyCulture("")>
20+
21+
' Version information for an assembly consists of the following four values:
22+
23+
' Major version
24+
' Minor Version
25+
' Build Number
26+
' Revision
27+
28+
' You can specify all the values or you can default the Build and Revision Numbers
29+
' by using the '*' as shown below:
30+
31+
<Assembly: AssemblyVersion("1.0.*")>
32+
33+
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
Option Strict Off
2+
Option Explicit On
3+
Module CurrencyInfo
4+
' CurrencyInfo.bas
5+
' This module is part of the Invoice sample program
6+
' for the QuickBooks SDK Version CA2.0.
7+
' Created September, 2002
8+
'
9+
' Copyright © 2021-2022 Intuit Inc. All rights reserved.
10+
' Use is subject to the terms specified at:
11+
' http://developer.intuit.com/legal/devsite_tos.html
12+
'
13+
'-------------------------------------------------------------
14+
15+
Function GetCurExRate(ByRef strCurrencyID As String) As String
16+
'This function create a request to QuickBooks to return information on a single currency
17+
On Error GoTo ErrHandler
18+
19+
20+
'Call OpenConnection to establish a QuickBooks connection and session
21+
If Not blnIsOpenConnection Then
22+
If Not OpenConnection Then
23+
Exit Function
24+
End If
25+
End If
26+
27+
28+
' This request ask QuickBooks to return information on a certain currency
29+
requestXML = "<?xml version=""1.0"" ?>" & "<?qbxml version=""2.0""?>" & "<QBXML><QBXMLMsgsRq onError=""continueOnError"">" & "<CurrencyQueryRq requestID=""1"">" & "<ListID>" & strCurrencyID & "</ListID>" & "</CurrencyQueryRq>" & "</QBXMLMsgsRq></QBXML>"
30+
31+
' PrintXMLToFile requestXML, "C:\request.xml" '*** remove Comment character to produce a xml request file
32+
33+
' Send request to QuickBooks
34+
responseXML = qbXMLRP.ProcessRequest(ticket, requestXML)
35+
' PrintXMLToFile responseXML, "C:\response.xml" '*** remove Comment character to produce a xml response file
36+
37+
'Parse the response
38+
GetCurExRate = ParseCurrency(responseXML)
39+
40+
Exit Function
41+
42+
ErrHandler:
43+
' In case something goes wrong along the way..
44+
MsgBox("Error getting the currency rate from QuickBooks: " & Err.Description)
45+
CloseConnection()
46+
End Function
47+
48+
Function ParseCurrency(ByRef sXML As Object) As String
49+
'This function parse the response from QuickBooks in order to find the Exchange Rate
50+
Dim objXmlDoc As New MSXML2.DOMDocument60
51+
Dim objRootElement As MSXML2.IXMLDOMElement ' root element of the XML document (QBXML Block)
52+
Dim objMsgsRsNode As MSXML2.IXMLDOMNode ' QBXMLMsgsRs grouping (opening tag of message)
53+
Dim objMessageNode As MSXML2.IXMLDOMNode ' Message node
54+
Dim objCurrencyNode As MSXML2.IXMLDOMNode ' Currency node
55+
Dim objCurrencyItem As MSXML2.IXMLDOMNode ' CurrencyItem node
56+
57+
58+
' Load XML Script
59+
objXmlDoc.async = False
60+
61+
If objXmlDoc.loadXML(sXML) = True And Len(objXmlDoc.xml) > 0 Then 'verify that there is some values in the documents
62+
63+
objRootElement = objXmlDoc.documentElement
64+
65+
For Each objMsgsRsNode In objRootElement.childNodes
66+
67+
If objMsgsRsNode.nodeName = "QBXMLMsgsRs" Then
68+
69+
For Each objMessageNode In objMsgsRsNode.childNodes
70+
71+
' If we find the Currency, let's parse it.
72+
If objMessageNode.nodeName = "CurrencyQueryRs" Then
73+
74+
75+
For Each objCurrencyNode In objMessageNode.childNodes 'For each currency in the list(in this example, there is only one currency returned)
76+
77+
For Each objCurrencyItem In objCurrencyNode.childNodes
78+
If objCurrencyItem.nodeName = "ExchangeRate" Then
79+
80+
ParseCurrency = objCurrencyItem.nodeTypedValue 'Add the exchange rate to the collection
81+
Exit For
82+
End If
83+
Next objCurrencyItem
84+
Next objCurrencyNode
85+
86+
End If
87+
Next objMessageNode
88+
End If
89+
Next objMsgsRsNode
90+
End If
91+
92+
End Function
93+
End Module
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
Option Strict Off
2+
Option Explicit On
3+
Module CustomerInfo
4+
' CustomerInfo.bas
5+
' This module is part of the Invoice sample program
6+
' for the QuickBooks SDK Version 2.0.
7+
' Created September, 2002
8+
'
9+
' Copyright © 2021-2022 Intuit Inc. All rights reserved.
10+
' Use is subject to the terms specified at:
11+
' http://developer.intuit.com/legal/devsite_tos.html
12+
'
13+
'-------------------------------------------------------------
14+
15+
16+
'This public collection contain the Currency ListIDs and names associated to the Customer
17+
Public colCustomerCurrencyList As Collection
18+
Sub GetCustomerList()
19+
'The GetCustomerList function generates a request to QuickBooks and call the ParseCustomer function to parse the
20+
'Customer's list
21+
On Error GoTo ErrHandler
22+
'Call OpenConnection to establish a QuickBooks connection and session
23+
If Not blnIsOpenConnection Then
24+
If Not OpenConnection Then
25+
Exit Sub
26+
End If
27+
End If
28+
29+
30+
' We generate the request qbXML in order to get the customer list.
31+
requestXML = "<?xml version=""1.0"" ?>" & "<?qbxml version=""2.0""?>" & "<QBXML><QBXMLMsgsRq onError=""continueOnError"">" & "<CustomerQueryRq requestID=""1""/>" & "</QBXMLMsgsRq></QBXML>"
32+
33+
34+
' PrintXMLToFile requestXML, "C:\request.xml" '*** remove Comment character to produce a xml request file
35+
36+
' Send request to QuickBooks
37+
responseXML = qbXMLRP.ProcessRequest(ticket, requestXML)
38+
39+
'PrintXMLToFile responseXML, "C:\response.xml" '*** remove Comment character to produce a xml response file
40+
41+
'The ParseCustomer procedure parses the response coming from QuickBooks and returns the customers list inside the colCustomerCurrencyList collection
42+
ParseCustomer((responseXML))
43+
Exit Sub
44+
ErrHandler:
45+
' In case something goes wrong along the way..
46+
MsgBox("Error sending request to QuickBooks: " & Err.Description)
47+
CloseConnection()
48+
End Sub
49+
50+
Sub ParseCustomer(ByRef sXML As Object)
51+
'This function parse the response to the CustomerQuery request
52+
'Some info is store in a global variable and some are returned by the function
53+
Dim objXmlDoc As New MSXML2.DOMDocument60
54+
Dim objRootElement As MSXML2.IXMLDOMElement ' root element of the XML document (QBXML Block)
55+
Dim objMsgsRsNode As MSXML2.IXMLDOMNode ' QBXMLMsgsRs grouping (opening tag of message)
56+
Dim objMessageNode As MSXML2.IXMLDOMNode ' Message node
57+
Dim objCustomerNode As MSXML2.IXMLDOMNode ' Customer node
58+
Dim objCustomerItem As MSXML2.IXMLDOMNode ' Customer node
59+
Dim objElementItem As MSXML2.IXMLDOMNode ' Element node
60+
61+
Dim strFullName As String
62+
Dim strCustomerCurrencyArray(1) As String
63+
'strCustomerCurrencyArray(0) is the customer's name
64+
'strCustomerCurrencyArray(1) is the currency ref
65+
66+
' Load XML Script
67+
objXmlDoc.async = False
68+
69+
If objXmlDoc.loadXML(sXML) = True And Len(objXmlDoc.xml) > 0 Then 'verify that there is some values in the documents
70+
71+
objRootElement = objXmlDoc.documentElement
72+
73+
For Each objMsgsRsNode In objRootElement.childNodes
74+
75+
If objMsgsRsNode.nodeName = "QBXMLMsgsRs" Then
76+
77+
For Each objMessageNode In objMsgsRsNode.childNodes
78+
79+
' If we find the customer list, let's parse it.
80+
If objMessageNode.nodeName = "CustomerQueryRs" Then
81+
82+
For Each objCustomerNode In objMessageNode.childNodes ' Go through each customer nodes returned by the query
83+
strCustomerCurrencyArray(0) = ""
84+
strCustomerCurrencyArray(1) = ""
85+
86+
For Each objCustomerItem In objCustomerNode.childNodes
87+
'Transfer the customer information into the collection
88+
89+
If objCustomerItem.nodeName = "FullName" Then
90+
91+
strFullName = objCustomerItem.nodeTypedValue
92+
strCustomerCurrencyArray(0) = strFullName
93+
ElseIf objCustomerItem.nodeName = "CurrencyRef" Then
94+
' Parses the CurrencyRef node
95+
For Each objElementItem In objCustomerItem.childNodes
96+
If objElementItem.nodeName = "ListID" Then
97+
98+
strCustomerCurrencyArray(1) = objElementItem.nodeTypedValue
99+
Exit For
100+
End If
101+
Next objElementItem
102+
103+
End If
104+
Next objCustomerItem
105+
colCustomerCurrencyList.Add(strCustomerCurrencyArray, strFullName)
106+
Next objCustomerNode
107+
108+
End If
109+
Next objMessageNode
110+
End If
111+
Next objMsgsRsNode
112+
End If
113+
End Sub
114+
End Module

0 commit comments

Comments
 (0)