Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
KGOrders
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cam Hayes
KGOrders
Commits
ac7b38b2
Commit
ac7b38b2
authored
Aug 05, 2025
by
Cameron Hayes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made all the changes discussed to the qbAPI except for fixed columns
parent
43b62c06
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
18 deletions
+72
-18
qbAPI.dfm
kgOrdersServer/Source/qbAPI.dfm
+4
-2
qbAPI.pas
kgOrdersServer/Source/qbAPI.pas
+68
-16
No files found.
kgOrdersServer/Source/qbAPI.dfm
View file @
ac7b38b2
...
@@ -263,7 +263,7 @@ object fQB: TfQB
...
@@ -263,7 +263,7 @@ object fQB: TfQB
OnClick = Button5Click
OnClick = Button5Click
end
end
object Button6: TButton
object Button6: TButton
Left = 5
38
Left = 5
42
Top = 5
Top = 5
Width = 108
Width = 108
Height = 25
Height = 25
...
@@ -529,7 +529,7 @@ object fQB: TfQB
...
@@ -529,7 +529,7 @@ object fQB: TfQB
Width = 982
Width = 982
Height = 198
Height = 198
Align = alTop
Align = alTop
ActivePage = AdvOfficePager1
1
ActivePage = AdvOfficePager1
2
ButtonSettings.CloseButtonPicture.Data = {
ButtonSettings.CloseButtonPicture.Data = {
424DA20400000000000036040000280000000900000009000000010008000000
424DA20400000000000036040000280000000900000009000000010008000000
00006C000000C30E0000C30E00000001000000010000427B8400DEEFEF00FFFF
00006C000000C30E0000C30E00000001000000010000427B8400DEEFEF00FFFF
...
@@ -917,6 +917,7 @@ object fQB: TfQB
...
@@ -917,6 +917,7 @@ object fQB: TfQB
Height = 25
Height = 25
Caption = 'Clear Memo'
Caption = 'Clear Memo'
TabOrder = 0
TabOrder = 0
OnClick = Button13Click
end
end
end
end
end
end
...
@@ -1013,6 +1014,7 @@ object fQB: TfQB
...
@@ -1013,6 +1014,7 @@ object fQB: TfQB
Height = 25
Height = 25
Caption = 'Clear Memo'
Caption = 'Clear Memo'
TabOrder = 0
TabOrder = 0
OnClick = Button14Click
end
end
end
end
end
end
...
...
kgOrdersServer/Source/qbAPI.pas
View file @
ac7b38b2
...
@@ -148,6 +148,8 @@ type
...
@@ -148,6 +148,8 @@ type
procedure
Button10Click
(
Sender
:
TObject
);
procedure
Button10Click
(
Sender
:
TObject
);
procedure
Button11Click
(
Sender
:
TObject
);
procedure
Button11Click
(
Sender
:
TObject
);
procedure
Button12Click
(
Sender
:
TObject
);
procedure
Button12Click
(
Sender
:
TObject
);
procedure
Button13Click
(
Sender
:
TObject
);
procedure
Button14Click
(
Sender
:
TObject
);
private
private
{ Private declarations }
{ Private declarations }
strict
private
strict
private
...
@@ -220,6 +222,8 @@ procedure TfQB.Button10Click(Sender: TObject);
...
@@ -220,6 +222,8 @@ procedure TfQB.Button10Click(Sender: TObject);
var
var
msg
:
string
;
msg
:
string
;
begin
begin
Memo1
.
Clear
;
Memo1
.
Lines
.
Add
(
'Linking QB IDs'
);
if
(
(
QB_ID
=
''
)
or
(
ID
=
''
)
)
then
if
(
(
QB_ID
=
''
)
or
(
ID
=
''
)
)
then
begin
begin
Memo1
.
Lines
.
Add
(
'Please select a Quickbooks Customer and a KG Orders Customer'
);
Memo1
.
Lines
.
Add
(
'Please select a Quickbooks Customer and a KG Orders Customer'
);
...
@@ -280,7 +284,8 @@ var
...
@@ -280,7 +284,8 @@ var
ShipAddr
:
TJSONObject
;
ShipAddr
:
TJSONObject
;
sql
:
string
;
sql
:
string
;
begin
begin
Memo1
.
Clear
;
Memo1
.
Lines
.
Add
(
'Linking all QB Items to KG Orders'
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restClient
.
BaseURL
:=
'https://sandbox-quickbooks.api.intuit.com'
;
restClient
.
BaseURL
:=
'https://sandbox-quickbooks.api.intuit.com'
;
...
@@ -338,7 +343,7 @@ begin
...
@@ -338,7 +343,7 @@ begin
Memo1
.
lines
.
add
(
'Done'
);
// Load customer info
// Load customer info
restClient
.
Free
;
restClient
.
Free
;
...
@@ -371,6 +376,16 @@ begin
...
@@ -371,6 +376,16 @@ begin
end
;
end
;
procedure
TfQB
.
Button13Click
(
Sender
:
TObject
);
begin
Memo1
.
Clear
;
end
;
procedure
TfQB
.
Button14Click
(
Sender
:
TObject
);
begin
Memo2
.
Clear
;
end
;
procedure
TfQB
.
DeleteCustomers
();
procedure
TfQB
.
DeleteCustomers
();
var
var
SQL
:
string
;
SQL
:
string
;
...
@@ -380,6 +395,7 @@ var
...
@@ -380,6 +395,7 @@ var
I
:
integer
;
I
:
integer
;
ship_count
,
cust_count
:
integer
;
ship_count
,
cust_count
:
integer
;
begin
begin
Memo1
.
Clear
;
Memo1
.
Lines
.
Add
(
'Beginning to Delete Customers'
);
Memo1
.
Lines
.
Add
(
'Beginning to Delete Customers'
);
SQL
:=
'SELECT * FROM customers c '
+
SQL
:=
'SELECT * FROM customers c '
+
'WHERE NOT EXISTS (SELECT 1 FROM corrugated_plate_orders cpo WHERE cpo.COMPANY_ID = c.CUSTOMER_ID) '
+
'WHERE NOT EXISTS (SELECT 1 FROM corrugated_plate_orders cpo WHERE cpo.COMPANY_ID = c.CUSTOMER_ID) '
+
...
@@ -423,6 +439,7 @@ end;
...
@@ -423,6 +439,7 @@ end;
procedure
TfQB
.
Button1Click
(
Sender
:
TObject
);
procedure
TfQB
.
Button1Click
(
Sender
:
TObject
);
begin
begin
getCustomers
();
getCustomers
();
AdvPanel2
.
Text
:=
'kgOrders Customers'
end
;
end
;
procedure
TfQB
.
getCustomers
();
procedure
TfQB
.
getCustomers
();
...
@@ -433,6 +450,8 @@ var
...
@@ -433,6 +450,8 @@ var
Customer
,
ParsedCustomer
:
TJSONObject
;
Customer
,
ParsedCustomer
:
TJSONObject
;
I
:
integer
;
I
:
integer
;
begin
begin
Memo1
.
Clear
;
Memo1
.
Lines
.
Add
(
'Retrieving KG Orders Customers'
);
SQL
:=
'SELECT * FROM customers c'
;
SQL
:=
'SELECT * FROM customers c'
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
ModifiedList
:=
TJSONArray
.
Create
;
ModifiedList
:=
TJSONArray
.
Create
;
...
@@ -504,6 +523,8 @@ var
...
@@ -504,6 +523,8 @@ var
CustomerList
:
TJSONArray
;
CustomerList
:
TJSONArray
;
pair
:
TJSONPair
;
pair
:
TJSONPair
;
begin
begin
Memo1
.
Clear
;
Memo1
.
Lines
.
Add
(
'Retrieving QB Customer Based on ID'
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restClient
.
BaseURL
:=
'https://sandbox-quickbooks.api.intuit.com'
;
restClient
.
BaseURL
:=
'https://sandbox-quickbooks.api.intuit.com'
;
...
@@ -537,7 +558,8 @@ begin
...
@@ -537,7 +558,8 @@ begin
jsValue
:=
restResponse
.
JSONValue
;
jsValue
:=
restResponse
.
JSONValue
;
jsObj
:=
TJSONObject
(
jsValue
);
jsObj
:=
TJSONObject
(
jsValue
);
Memo1
.
Lines
.
Add
(
jsObj
.
Format
(
2
)
);
Memo2
.
Clear
;
Memo2
.
Lines
.
Add
(
jsObj
.
Format
(
2
)
);
// CustomerList := TJSONArray( TJSONObject( jsObj.GetValue('QueryResponse') ).GetValue('Customer')) ;
// CustomerList := TJSONArray( TJSONObject( jsObj.GetValue('QueryResponse') ).GetValue('Customer')) ;
...
@@ -597,6 +619,8 @@ var
...
@@ -597,6 +619,8 @@ var
ShipMethodRef
:
TJSONObject
;
ShipMethodRef
:
TJSONObject
;
unitPrice
:
double
;
unitPrice
:
double
;
begin
begin
Memo1
.
Clear
Memo1
.
Lines
.
Add
(
'Adding Order '
+
orderInfo
+
' to QB'
);
BillAddrJSON
:=
TJSONObject
.
Create
;
BillAddrJSON
:=
TJSONObject
.
Create
;
ShipAddrJSON
:=
TJSONObject
.
Create
;
ShipAddrJSON
:=
TJSONObject
.
Create
;
EstimateJSON
:=
TJSONObject
.
Create
;
EstimateJSON
:=
TJSONObject
.
Create
;
...
@@ -695,10 +719,7 @@ begin
...
@@ -695,10 +719,7 @@ begin
LineObj
.
AddPair
(
'Description'
,
ordersDB
.
UniQuery1
.
FieldByName
(
'item_desc'
).
AsString
+
' - '
+
ordersDB
.
UniQuery1
.
FieldByName
(
'general_special_instructions'
).
AsString
);
LineObj
.
AddPair
(
'Description'
,
ordersDB
.
UniQuery1
.
FieldByName
(
'item_desc'
).
AsString
+
' - '
+
ordersDB
.
UniQuery1
.
FieldByName
(
'general_special_instructions'
).
AsString
);
end
;
end
;
memo1
.
Lines
.
Add
(
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_price'
).
AsString
);
memo1
.
Lines
.
Add
(
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_quantity'
).
AsString
);
LineObj
.
AddPair
(
'Amount'
,
TJSONNumber
.
Create
(
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_price'
).
AsFloat
));
LineObj
.
AddPair
(
'Amount'
,
TJSONNumber
.
Create
(
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_price'
).
AsFloat
));
memo1
.
Lines
.
Add
(
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_price'
).
AsString
);
LineObj
.
AddPair
(
'DetailType'
,
'SalesItemLineDetail'
);
LineObj
.
AddPair
(
'DetailType'
,
'SalesItemLineDetail'
);
ItemRefObj
.
AddPair
(
'value'
,
ordersDB
.
UniQuery1
.
FieldByName
(
'qb_items_qb_id'
).
AsString
);
ItemRefObj
.
AddPair
(
'value'
,
ordersDB
.
UniQuery1
.
FieldByName
(
'qb_items_qb_id'
).
AsString
);
...
@@ -746,7 +767,8 @@ begin
...
@@ -746,7 +767,8 @@ begin
param
.
Options
:=
param
.
Options
+
[
TRESTRequestParameterOption
.
poDoNotEncode
];
param
.
Options
:=
param
.
Options
+
[
TRESTRequestParameterOption
.
poDoNotEncode
];
param
.
Value
:=
'Bearer '
+
AccessToken
;
param
.
Value
:=
'Bearer '
+
AccessToken
;
Memo1
.
Lines
.
Add
(
estimateJSON
.
Format
(
2
)
);
Memo2
.
Clear
;
Memo2
.
Lines
.
Add
(
estimateJSON
.
Format
(
2
)
);
restRequest
.
AddBody
(
estimateJSON
.
ToJSON
,
TRESTContentType
.
ctAPPLICATION_JSON
);
restRequest
.
AddBody
(
estimateJSON
.
ToJSON
,
TRESTContentType
.
ctAPPLICATION_JSON
);
...
@@ -777,6 +799,8 @@ var
...
@@ -777,6 +799,8 @@ var
Customer
,
ParsedCustomer
:
TJSONObject
;
Customer
,
ParsedCustomer
:
TJSONObject
;
I
:
integer
;
I
:
integer
;
begin
begin
Memo1
.
Clear
;
Memo1
.
Lines
.
Add
(
'Showing all KG Orders Customers without Orders'
);
SQL
:=
'SELECT * FROM customers c '
+
SQL
:=
'SELECT * FROM customers c '
+
'WHERE EXISTS (SELECT 1 FROM corrugated_plate_orders cpo WHERE cpo.COMPANY_ID = c.CUSTOMER_ID) '
+
'WHERE EXISTS (SELECT 1 FROM corrugated_plate_orders cpo WHERE cpo.COMPANY_ID = c.CUSTOMER_ID) '
+
'OR EXISTS (SELECT 1 FROM web_plate_orders wpo WHERE wpo.COMPANY_ID = c.CUSTOMER_ID) ORDER BY c.SHORT_NAME'
;
'OR EXISTS (SELECT 1 FROM web_plate_orders wpo WHERE wpo.COMPANY_ID = c.CUSTOMER_ID) ORDER BY c.SHORT_NAME'
;
...
@@ -932,7 +956,7 @@ var
...
@@ -932,7 +956,7 @@ var
restRequest
:
TRESTRequest
;
restRequest
:
TRESTRequest
;
restResponse
:
TRESTResponse
;
restResponse
:
TRESTResponse
;
param
:
TRESTRequestParameter
;
param
:
TRESTRequestParameter
;
res
:
string
;
res
,
SQL
:
string
;
jsValue
:
TJSONValue
;
jsValue
:
TJSONValue
;
jsObj
:
TJSONObject
;
jsObj
:
TJSONObject
;
CustomerList
:
TJSONArray
;
CustomerList
:
TJSONArray
;
...
@@ -942,7 +966,11 @@ var
...
@@ -942,7 +966,11 @@ var
I
:
integer
;
I
:
integer
;
BillAddr
:
TJSONObject
;
BillAddr
:
TJSONObject
;
ShipAddr
:
TJSONObject
;
ShipAddr
:
TJSONObject
;
ItemList
:
TJSONArray
;
Item
:
TJSONObject
;
begin
begin
Memo1
.
Clear
;
memo1
.
Lines
.
Add
(
'Getting KG and QB Items'
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restClient
.
BaseURL
:=
'https://sandbox-quickbooks.api.intuit.com'
;
restClient
.
BaseURL
:=
'https://sandbox-quickbooks.api.intuit.com'
;
...
@@ -979,11 +1007,13 @@ begin
...
@@ -979,11 +1007,13 @@ begin
jsObj
:=
TJSONObject
(
jsValue
);
jsObj
:=
TJSONObject
(
jsValue
);
//CustomerList := TJSONArray(restResponse.JSONValue);
//CustomerList := TJSONArray(restResponse.JSONValue);
Memo1
.
Lines
.
Add
(
jsObj
.
Format
(
2
)
);
Memo2
.
Clear
;
Memo2
.
Lines
.
Add
(
jsObj
.
Format
(
2
)
);
CustomerList
:=
TJSONArray
(
TJSONObject
(
jsObj
.
GetValue
(
'QueryResponse'
)
).
GetValue
(
'Item'
));
CustomerList
:=
TJSONArray
(
TJSONObject
(
jsObj
.
GetValue
(
'QueryResponse'
)
).
GetValue
(
'Item'
));
loadJSONArray
(
CustomerList
);
loadJSONArray
(
CustomerList
);
AdvPanel1
.
Text
:=
'QB Items'
;
// Load customer info
// Load customer info
...
@@ -991,7 +1021,26 @@ begin
...
@@ -991,7 +1021,26 @@ begin
restRequest
.
Free
;
restRequest
.
Free
;
restResponse
.
Free
;
restResponse
.
Free
;
SQL
:=
'select * from qb_items order by qb_item_name asc'
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
ItemList
:=
TJSONArray
.
Create
;
while
not
ordersDB
.
UniQuery1
.
Eof
do
begin
item
:=
TJSONObject
.
Create
;
item
.
AddPair
(
'ID'
,
ordersDB
.
UniQuery1
.
FieldByName
(
'qb_items_id'
).
AsString
);
item
.
AddPair
(
'name'
,
ordersDB
.
UniQuery1
.
FieldByName
(
'qb_item_name'
).
AsString
);
item
.
AddPair
(
'description'
,
ordersDB
.
UniQuery1
.
FieldByName
(
'item_desc'
).
AsString
);
item
.
AddPair
(
'status'
,
ordersDB
.
UniQuery1
.
FieldByName
(
'status'
).
AsString
);
item
.
AddPair
(
'QB_ID'
,
ordersDB
.
UniQuery1
.
FieldByName
(
'qb_items_qb_id'
).
AsString
);
ItemList
.
Add
(
item
);
ordersDB
.
UniQuery1
.
Next
;
end
;
LoadJSONArray2
(
ItemList
);
AdvPanel2
.
Text
:=
'KG Orders Items'
;
ordersDB
.
UniQuery1
.
Close
;
end
;
end
;
procedure
TfQB
.
Button9Click
(
Sender
:
TObject
);
procedure
TfQB
.
Button9Click
(
Sender
:
TObject
);
...
@@ -1011,7 +1060,8 @@ var
...
@@ -1011,7 +1060,8 @@ var
BillAddr
:
TJSONObject
;
BillAddr
:
TJSONObject
;
ShipAddr
:
TJSONObject
;
ShipAddr
:
TJSONObject
;
begin
begin
Memo1
.
Clear
;
Memo1
.
Lines
.
Add
(
'Retrieving Estimate from QB'
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restClient
.
BaseURL
:=
'https://sandbox-quickbooks.api.intuit.com'
;
restClient
.
BaseURL
:=
'https://sandbox-quickbooks.api.intuit.com'
;
...
@@ -1040,13 +1090,12 @@ begin
...
@@ -1040,13 +1090,12 @@ begin
param
.
Value
:=
'Bearer '
+
AccessToken
;
param
.
Value
:=
'Bearer '
+
AccessToken
;
restRequest
.
Execute
;
restRequest
.
Execute
;
Memo2
.
Clear
;
memo1
.
Lines
.
Add
(
restresponse
.
Content
);
jsValue
:=
restResponse
.
JSONValue
;
jsValue
:=
restResponse
.
JSONValue
;
jsObj
:=
TJSONObject
(
jsValue
);
jsObj
:=
TJSONObject
(
jsValue
);
Memo
1
.
Lines
.
Add
(
jsObj
.
Format
(
2
)
);
Memo
2
.
Lines
.
Add
(
jsObj
.
Format
(
2
)
);
restClient
.
Free
;
restClient
.
Free
;
...
@@ -1072,7 +1121,8 @@ var
...
@@ -1072,7 +1121,8 @@ var
BillAddr
:
TJSONObject
;
BillAddr
:
TJSONObject
;
ShipAddr
:
TJSONObject
;
ShipAddr
:
TJSONObject
;
begin
begin
Memo1
.
Clear
;
Memo1
.
Lines
.
Add
(
'Getting QB Customers'
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restClient
.
BaseURL
:=
'https://sandbox-quickbooks.api.intuit.com'
;
restClient
.
BaseURL
:=
'https://sandbox-quickbooks.api.intuit.com'
;
...
@@ -1109,7 +1159,8 @@ begin
...
@@ -1109,7 +1159,8 @@ begin
jsObj
:=
TJSONObject
(
jsValue
);
jsObj
:=
TJSONObject
(
jsValue
);
//CustomerList := TJSONArray(restResponse.JSONValue);
//CustomerList := TJSONArray(restResponse.JSONValue);
Memo1
.
Lines
.
Add
(
jsObj
.
Format
(
2
)
);
Memo2
.
Clear
;
Memo2
.
Lines
.
Add
(
jsObj
.
Format
(
2
)
);
CustomerList
:=
TJSONArray
(
TJSONObject
(
jsObj
.
GetValue
(
'QueryResponse'
)
).
GetValue
(
'Customer'
))
;
CustomerList
:=
TJSONArray
(
TJSONObject
(
jsObj
.
GetValue
(
'QueryResponse'
)
).
GetValue
(
'Customer'
))
;
...
@@ -1118,7 +1169,6 @@ begin
...
@@ -1118,7 +1169,6 @@ begin
for
I
:=
0
to
CustomerList
.
Count
-
1
do
for
I
:=
0
to
CustomerList
.
Count
-
1
do
begin
begin
Customer
:=
CustomerList
.
Items
[
I
]
as
TJSONObject
;
Customer
:=
CustomerList
.
Items
[
I
]
as
TJSONObject
;
Memo1
.
Lines
.
Add
(
Customer
.
Format
(
2
)
);
ParsedCustomer
:=
TJSONObject
.
Create
;
ParsedCustomer
:=
TJSONObject
.
Create
;
//sql := 'select CUSTOMER_ID from customers where QB_LIST_ID = ' + Customer.GetValue<string>('Id');
//sql := 'select CUSTOMER_ID from customers where QB_LIST_ID = ' + Customer.GetValue<string>('Id');
...
@@ -1176,6 +1226,7 @@ begin
...
@@ -1176,6 +1226,7 @@ begin
end
;
end
;
LoadJSONArray
(
ModifiedList
);
LoadJSONArray
(
ModifiedList
);
AdvPanel1
.
Text
:=
'QB Customers'
;
restClient
.
Free
;
restClient
.
Free
;
restRequest
.
Free
;
restRequest
.
Free
;
...
@@ -1416,6 +1467,7 @@ var
...
@@ -1416,6 +1467,7 @@ var
Customer
:
TJSONObject
;
Customer
:
TJSONObject
;
SQL
:
string
;
SQL
:
string
;
begin
begin
Memo1
.
Clear
;
Memo1
.
Lines
.
Add
(
'Matching '
+
JSONfield
+
' on '
+
DBField
);
Memo1
.
Lines
.
Add
(
'Matching '
+
JSONfield
+
' on '
+
DBField
);
for
I
:=
0
to
CustomerList
.
Count
-
1
do
for
I
:=
0
to
CustomerList
.
Count
-
1
do
begin
begin
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment