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
OnClick = Button5Click
end
object Button6: TButton
Left = 5
38
Left = 5
42
Top = 5
Width = 108
Height = 25
...
...
@@ -529,7 +529,7 @@ object fQB: TfQB
Width = 982
Height = 198
Align = alTop
ActivePage = AdvOfficePager1
1
ActivePage = AdvOfficePager1
2
ButtonSettings.CloseButtonPicture.Data = {
424DA20400000000000036040000280000000900000009000000010008000000
00006C000000C30E0000C30E00000001000000010000427B8400DEEFEF00FFFF
...
...
@@ -917,6 +917,7 @@ object fQB: TfQB
Height = 25
Caption = 'Clear Memo'
TabOrder = 0
OnClick = Button13Click
end
end
end
...
...
@@ -1013,6 +1014,7 @@ object fQB: TfQB
Height = 25
Caption = 'Clear Memo'
TabOrder = 0
OnClick = Button14Click
end
end
end
...
...
kgOrdersServer/Source/qbAPI.pas
View file @
ac7b38b2
...
...
@@ -148,6 +148,8 @@ type
procedure
Button10Click
(
Sender
:
TObject
);
procedure
Button11Click
(
Sender
:
TObject
);
procedure
Button12Click
(
Sender
:
TObject
);
procedure
Button13Click
(
Sender
:
TObject
);
procedure
Button14Click
(
Sender
:
TObject
);
private
{ Private declarations }
strict
private
...
...
@@ -220,6 +222,8 @@ procedure TfQB.Button10Click(Sender: TObject);
var
msg
:
string
;
begin
Memo1
.
Clear
;
Memo1
.
Lines
.
Add
(
'Linking QB IDs'
);
if
(
(
QB_ID
=
''
)
or
(
ID
=
''
)
)
then
begin
Memo1
.
Lines
.
Add
(
'Please select a Quickbooks Customer and a KG Orders Customer'
);
...
...
@@ -280,7 +284,8 @@ var
ShipAddr
:
TJSONObject
;
sql
:
string
;
begin
Memo1
.
Clear
;
Memo1
.
Lines
.
Add
(
'Linking all QB Items to KG Orders'
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restClient
.
BaseURL
:=
'https://sandbox-quickbooks.api.intuit.com'
;
...
...
@@ -338,7 +343,7 @@ begin
Memo1
.
lines
.
add
(
'Done'
);
// Load customer info
restClient
.
Free
;
...
...
@@ -371,6 +376,16 @@ begin
end
;
procedure
TfQB
.
Button13Click
(
Sender
:
TObject
);
begin
Memo1
.
Clear
;
end
;
procedure
TfQB
.
Button14Click
(
Sender
:
TObject
);
begin
Memo2
.
Clear
;
end
;
procedure
TfQB
.
DeleteCustomers
();
var
SQL
:
string
;
...
...
@@ -380,6 +395,7 @@ var
I
:
integer
;
ship_count
,
cust_count
:
integer
;
begin
Memo1
.
Clear
;
Memo1
.
Lines
.
Add
(
'Beginning to Delete Customers'
);
SQL
:=
'SELECT * FROM customers c '
+
'WHERE NOT EXISTS (SELECT 1 FROM corrugated_plate_orders cpo WHERE cpo.COMPANY_ID = c.CUSTOMER_ID) '
+
...
...
@@ -423,6 +439,7 @@ end;
procedure
TfQB
.
Button1Click
(
Sender
:
TObject
);
begin
getCustomers
();
AdvPanel2
.
Text
:=
'kgOrders Customers'
end
;
procedure
TfQB
.
getCustomers
();
...
...
@@ -433,6 +450,8 @@ var
Customer
,
ParsedCustomer
:
TJSONObject
;
I
:
integer
;
begin
Memo1
.
Clear
;
Memo1
.
Lines
.
Add
(
'Retrieving KG Orders Customers'
);
SQL
:=
'SELECT * FROM customers c'
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
ModifiedList
:=
TJSONArray
.
Create
;
...
...
@@ -504,6 +523,8 @@ var
CustomerList
:
TJSONArray
;
pair
:
TJSONPair
;
begin
Memo1
.
Clear
;
Memo1
.
Lines
.
Add
(
'Retrieving QB Customer Based on ID'
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restClient
.
BaseURL
:=
'https://sandbox-quickbooks.api.intuit.com'
;
...
...
@@ -537,7 +558,8 @@ begin
jsValue
:=
restResponse
.
JSONValue
;
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')) ;
...
...
@@ -597,6 +619,8 @@ var
ShipMethodRef
:
TJSONObject
;
unitPrice
:
double
;
begin
Memo1
.
Clear
Memo1
.
Lines
.
Add
(
'Adding Order '
+
orderInfo
+
' to QB'
);
BillAddrJSON
:=
TJSONObject
.
Create
;
ShipAddrJSON
:=
TJSONObject
.
Create
;
EstimateJSON
:=
TJSONObject
.
Create
;
...
...
@@ -695,10 +719,7 @@ begin
LineObj
.
AddPair
(
'Description'
,
ordersDB
.
UniQuery1
.
FieldByName
(
'item_desc'
).
AsString
+
' - '
+
ordersDB
.
UniQuery1
.
FieldByName
(
'general_special_instructions'
).
AsString
);
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
));
memo1
.
Lines
.
Add
(
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_price'
).
AsString
);
LineObj
.
AddPair
(
'DetailType'
,
'SalesItemLineDetail'
);
ItemRefObj
.
AddPair
(
'value'
,
ordersDB
.
UniQuery1
.
FieldByName
(
'qb_items_qb_id'
).
AsString
);
...
...
@@ -746,7 +767,8 @@ begin
param
.
Options
:=
param
.
Options
+
[
TRESTRequestParameterOption
.
poDoNotEncode
];
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
);
...
...
@@ -777,6 +799,8 @@ var
Customer
,
ParsedCustomer
:
TJSONObject
;
I
:
integer
;
begin
Memo1
.
Clear
;
Memo1
.
Lines
.
Add
(
'Showing all KG Orders Customers without Orders'
);
SQL
:=
'SELECT * FROM customers c '
+
'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'
;
...
...
@@ -932,7 +956,7 @@ var
restRequest
:
TRESTRequest
;
restResponse
:
TRESTResponse
;
param
:
TRESTRequestParameter
;
res
:
string
;
res
,
SQL
:
string
;
jsValue
:
TJSONValue
;
jsObj
:
TJSONObject
;
CustomerList
:
TJSONArray
;
...
...
@@ -942,7 +966,11 @@ var
I
:
integer
;
BillAddr
:
TJSONObject
;
ShipAddr
:
TJSONObject
;
ItemList
:
TJSONArray
;
Item
:
TJSONObject
;
begin
Memo1
.
Clear
;
memo1
.
Lines
.
Add
(
'Getting KG and QB Items'
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restClient
.
BaseURL
:=
'https://sandbox-quickbooks.api.intuit.com'
;
...
...
@@ -979,11 +1007,13 @@ begin
jsObj
:=
TJSONObject
(
jsValue
);
//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'
));
loadJSONArray
(
CustomerList
);
AdvPanel1
.
Text
:=
'QB Items'
;
// Load customer info
...
...
@@ -991,7 +1021,26 @@ begin
restRequest
.
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
;
procedure
TfQB
.
Button9Click
(
Sender
:
TObject
);
...
...
@@ -1011,7 +1060,8 @@ var
BillAddr
:
TJSONObject
;
ShipAddr
:
TJSONObject
;
begin
Memo1
.
Clear
;
Memo1
.
Lines
.
Add
(
'Retrieving Estimate from QB'
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restClient
.
BaseURL
:=
'https://sandbox-quickbooks.api.intuit.com'
;
...
...
@@ -1040,13 +1090,12 @@ begin
param
.
Value
:=
'Bearer '
+
AccessToken
;
restRequest
.
Execute
;
memo1
.
Lines
.
Add
(
restresponse
.
Content
);
Memo2
.
Clear
;
jsValue
:=
restResponse
.
JSONValue
;
jsObj
:=
TJSONObject
(
jsValue
);
Memo
1
.
Lines
.
Add
(
jsObj
.
Format
(
2
)
);
Memo
2
.
Lines
.
Add
(
jsObj
.
Format
(
2
)
);
restClient
.
Free
;
...
...
@@ -1072,7 +1121,8 @@ var
BillAddr
:
TJSONObject
;
ShipAddr
:
TJSONObject
;
begin
Memo1
.
Clear
;
Memo1
.
Lines
.
Add
(
'Getting QB Customers'
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restClient
.
BaseURL
:=
'https://sandbox-quickbooks.api.intuit.com'
;
...
...
@@ -1109,7 +1159,8 @@ begin
jsObj
:=
TJSONObject
(
jsValue
);
//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'
))
;
...
...
@@ -1118,7 +1169,6 @@ begin
for
I
:=
0
to
CustomerList
.
Count
-
1
do
begin
Customer
:=
CustomerList
.
Items
[
I
]
as
TJSONObject
;
Memo1
.
Lines
.
Add
(
Customer
.
Format
(
2
)
);
ParsedCustomer
:=
TJSONObject
.
Create
;
//sql := 'select CUSTOMER_ID from customers where QB_LIST_ID = ' + Customer.GetValue<string>('Id');
...
...
@@ -1176,6 +1226,7 @@ begin
end
;
LoadJSONArray
(
ModifiedList
);
AdvPanel1
.
Text
:=
'QB Customers'
;
restClient
.
Free
;
restRequest
.
Free
;
...
...
@@ -1416,6 +1467,7 @@ var
Customer
:
TJSONObject
;
SQL
:
string
;
begin
Memo1
.
Clear
;
Memo1
.
Lines
.
Add
(
'Matching '
+
JSONfield
+
' on '
+
DBField
);
for
I
:=
0
to
CustomerList
.
Count
-
1
do
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