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
95296f5f
Commit
95296f5f
authored
Jun 03, 2025
by
Cam Hayes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Customers form is complete and linked with quickbooks
parent
45495f71
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
721 additions
and
204 deletions
+721
-204
AddCustomer.pas
kgOrdersClient/AddCustomer.pas
+35
-12
View.AddOrder.dfm
kgOrdersClient/View.AddOrder.dfm
+25
-6
View.AddOrder.pas
kgOrdersClient/View.AddOrder.pas
+3
-0
View.Customers.pas
kgOrdersClient/View.Customers.pas
+0
-1
View.SelectCustomer.dfm
kgOrdersClient/View.SelectCustomer.dfm
+32
-12
View.SelectCustomer.pas
kgOrdersClient/View.SelectCustomer.pas
+22
-9
Data.dfm
kgOrdersServer/Source/Data.dfm
+4
-2
Lookup.ServiceImpl.pas
kgOrdersServer/Source/Lookup.ServiceImpl.pas
+120
-112
qbAPI.dfm
kgOrdersServer/Source/qbAPI.dfm
+346
-6
qbAPI.pas
kgOrdersServer/Source/qbAPI.pas
+130
-40
kgOrdersServer.ini
kgOrdersServer/kgOrdersServer.ini
+4
-4
No files found.
kgOrdersClient/AddCustomer.pas
View file @
95296f5f
...
...
@@ -117,6 +117,7 @@ type
function
VerifyCustomer
():
boolean
;
function
VerifyAddress
():
boolean
;
procedure
Clear
();
procedure
ShowSelectCustomerForm
();
var
customerID
:
string
;
notification
:
string
;
...
...
@@ -134,7 +135,7 @@ implementation
{$R *.dfm}
uses
View
.
Main
,
View
.
Customers
;
uses
View
.
Main
,
View
.
Customers
,
View
.
SelectCustomer
;
procedure
TFViewAddCustomer
.
Clear
();
// Clears the shipping address fields.
...
...
@@ -148,6 +149,28 @@ begin
edtFirstLine
.
Text
:=
''
;
end
;
procedure
TFViewAddCustomer
.
ShowSelectCustomerForm
();
// displays the add order pop-up so the user can choose a customer
var
newform
:
TFSelectCustomer
;
begin
newform
:=
TFSelectCustomer
.
CreateNew
;
newform
.
Caption
:=
'Select Customer and Order Type'
;
newForm
.
Popup
:=
True
;
newForm
.
Border
:=
fbDialog
;
// used to manage Back button handling to close subform
window
.
location
.
hash
:=
'subform'
;
newform
.
ShowModal
(
procedure
(
AValue
:
TModalResult
)
begin
end
);
end
;
procedure
TFViewAddCustomer
.
DelAddress
;
// Deletes a shipping address.
var
...
...
@@ -210,7 +233,7 @@ end;
procedure
TFViewAddCustomer
.
btnAddClick
(
Sender
:
TObject
);
// Takes the user to the Add Customer Page.
begin
FViewMain
.
ViewAddCustomer
(
''
,
''
);
ShowSelectCustomerForm
(
);
end
;
procedure
TFViewAddCustomer
.
btnCancelClick
(
Sender
:
TObject
);
...
...
@@ -601,16 +624,16 @@ begin
memoAddressBlock
.
Text
:=
string
(
customer
[
'staff_fields_invoice_to'
]);
if
(
not
xdwdsShipTo
.
IsEmpty
)
then
begin
edtShippingAddress
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'shipping_address
'
).
AsString
;
edtShippingCity
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'city
'
).
AsString
;
edtShippingState
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'state
'
).
AsString
;
edtShippingZip
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'zip
'
).
AsString
;
edtShippingContact
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'contact'
).
AsString
;
memoShipBlock
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'ADDRESS'
).
AsString
;
edtFirstLine
.
Text
:=
memoShipBlock
.
Lines
[
0
];
end
;
edtShippingAddress
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'shipping_address'
).
AsString
;
edtShippingCity
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'city'
).
AsString
;
edtShippingState
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'state
'
).
AsString
;
edtShippingZip
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'zip
'
).
AsString
;
edtShippingContact
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'contact
'
).
AsString
;
memoShipBlock
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'ADDRESS
'
).
AsString
;
if
memoShipBlock
.
Lines
.
Count
>
0
then
edtFirstLine
.
Text
:=
memoShipBlock
.
Lines
[
0
]
else
edtFirstLine
.
Text
:=
''
;
end
;
...
...
kgOrdersClient/View.AddOrder.dfm
View file @
95296f5f
...
...
@@ -12,7 +12,7 @@ object FAddOrder: TFAddOrder
WidthPercent = 100.000000000000000000
end
object WebLabel2: TWebLabel
Left = 1
43
Left = 1
35
Top = 81
Width = 113
Height = 15
...
...
@@ -20,6 +20,15 @@ object FAddOrder: TFAddOrder
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object WebLabel3: TWebLabel
Left = 283
Top = 81
Width = 134
Height = 15
Caption = 'Selected Customer Name'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtSearch: TWebEdit
Left = 4
Top = 102
...
...
@@ -30,7 +39,7 @@ object FAddOrder: TFAddOrder
OnChange = edtSearchChange
end
object edtID: TWebEdit
Left = 1
43
Left = 1
35
Top = 102
Width = 142
Height = 22
...
...
@@ -220,8 +229,8 @@ object FAddOrder: TFAddOrder
OnClick = cbWebPlateClick
end
object btnCancel: TWebButton
Left =
436
Top = 10
5
Left =
542
Top = 10
1
Width = 96
Height = 25
Caption = 'Cancel'
...
...
@@ -231,8 +240,8 @@ object FAddOrder: TFAddOrder
OnClick = btnCancelClick
end
object btnConfirm: TWebButton
Left =
328
Top = 10
5
Left =
436
Top = 10
1
Width = 96
Height = 25
Caption = 'Select'
...
...
@@ -273,6 +282,16 @@ object FAddOrder: TFAddOrder
TabOrder = 1
WidthPercent = 100.000000000000000000
end
object edtName: TWebEdit
Left = 283
Top = 102
Width = 142
Height = 22
ChildOrder = 1
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
Left = 780
...
...
kgOrdersClient/View.AddOrder.pas
View file @
95296f5f
...
...
@@ -33,6 +33,8 @@ type
edtNotification
:
TWebEdit
;
xdwdsCustomersstaff_fields_invoice_to
:
TStringField
;
xdwdsCustomersCUSTOMER_ID
:
TIntegerField
;
WebLabel3
:
TWebLabel
;
edtName
:
TWebEdit
;
procedure
WebFormShow
(
Sender
:
TObject
);
procedure
edtSearchChange
(
Sender
:
TObject
);
procedure
cbCorrugatedPlateClick
(
Sender
:
TObject
);
...
...
@@ -185,6 +187,7 @@ end;
procedure
TFAddOrder
.
TMSFNCGrid1CellClick
(
Sender
:
TObject
;
ACol
,
ARow
:
Integer
);
begin
edtID
.
Text
:=
TMSFNCGrid1
.
Cells
[
1
,
ARow
];
edtName
.
Text
:=
TMSFNCGrid1
.
Cells
[
2
,
ARow
];
DBID
:=
TMSFNCGrid1
.
Cells
[
0
,
ARow
];
end
;
...
...
kgOrdersClient/View.Customers.pas
View file @
95296f5f
...
...
@@ -221,7 +221,6 @@ end;
procedure
TFViewCustomers
.
btnAddCustomerClick
(
Sender
:
TObject
);
begin
ShowSelectCustomerForm
();
//FViewMain.ViewAddCustomer(string(notification['CustomerID']), string(notification['status']));
end
;
procedure
TFViewCustomers
.
edtFilterChange
(
Sender
:
TObject
);
...
...
kgOrdersClient/View.SelectCustomer.dfm
View file @
95296f5f
...
...
@@ -13,7 +13,7 @@ object FSelectCustomer: TFSelectCustomer
WidthPercent = 100.000000000000000000
end
object WebLabel2: TWebLabel
Left =
143
Left =
279
Top = 81
Width = 134
Height = 15
...
...
@@ -21,6 +21,15 @@ object FSelectCustomer: TFSelectCustomer
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object WebLabel3: TWebLabel
Left = 131
Top = 81
Width = 113
Height = 15
Caption = 'Selected Customer ID'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtSearch: TWebEdit
Left = 4
Top = 102
...
...
@@ -30,8 +39,8 @@ object FSelectCustomer: TFSelectCustomer
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edt
ID
: TWebEdit
Left =
143
object edt
Name
: TWebEdit
Left =
279
Top = 102
Width = 142
Height = 22
...
...
@@ -195,13 +204,11 @@ object FSelectCustomer: TFSelectCustomer
LeftCol = 0
ScrollMode = scmItemScrolling
DesignTimeSampleData = True
OnCellDblClick = TMSFNCGrid1CellDblClick
ExplicitLeft = 12
ExplicitTop = 185
OnCellClick = TMSFNCGrid1CellClick
end
object btnCancel: TWebButton
Left =
43
6
Top = 10
5
Left =
55
6
Top = 10
1
Width = 96
Height = 25
Caption = 'Cancel'
...
...
@@ -210,8 +217,8 @@ object FSelectCustomer: TFSelectCustomer
WidthPercent = 100.000000000000000000
end
object btnConfirm: TWebButton
Left =
328
Top = 10
5
Left =
440
Top = 10
1
Width = 96
Height = 25
Caption = 'Select'
...
...
@@ -241,10 +248,20 @@ object FSelectCustomer: TFSelectCustomer
TabOrder = 1
WidthPercent = 100.000000000000000000
end
object edtID: TWebEdit
Left = 131
Top = 102
Width = 142
Height = 22
ChildOrder = 1
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
Left =
56
0
Top =
61
Left =
63
0
Top =
47
end
object xdwdsCustomers: TXDataWebDataSet
Connection = DMConnection.ApiConnection
...
...
@@ -289,6 +306,9 @@ object FSelectCustomer: TFSelectCustomer
object xdwdsCustomersBillAddrZip: TStringField
FieldName = 'BillAddrZip'
end
object xdwdsCustomersInKGOrders: TBooleanField
FieldName = 'In KGOrders'
end
end
object wdsCustomers: TWebDataSource
DataSet = xdwdsCustomers
...
...
kgOrdersClient/View.SelectCustomer.pas
View file @
95296f5f
...
...
@@ -17,7 +17,7 @@ type
WebLabel1
:
TWebLabel
;
WebLabel2
:
TWebLabel
;
edtSearch
:
TWebEdit
;
edt
ID
:
TWebEdit
;
edt
Name
:
TWebEdit
;
TMSFNCGrid1
:
TTMSFNCGrid
;
btnCancel
:
TWebButton
;
btnConfirm
:
TWebButton
;
...
...
@@ -38,10 +38,14 @@ type
xdwdsCustomersBillAddrCity
:
TStringField
;
xdwdsCustomersBillAddrState
:
TStringField
;
xdwdsCustomersBillAddrZip
:
TStringField
;
WebLabel3
:
TWebLabel
;
edtID
:
TWebEdit
;
xdwdsCustomersInKGOrders
:
TBooleanField
;
procedure
WebFormCreate
(
Sender
:
TObject
);
procedure
WebFormShow
(
Sender
:
TObject
);
procedure
TMSFNCGrid1CellDblClick
(
Sender
:
TObject
;
ACol
,
ARow
:
Integer
);
procedure
btnConfirmClick
(
Sender
:
TObject
);
procedure
TMSFNCGrid1CellClick
(
Sender
:
TObject
;
ACol
,
ARow
:
Integer
);
private
{ Private declarations }
[
Async
]
procedure
GetCustomers
();
...
...
@@ -56,8 +60,7 @@ var
implementation
{$R *.dfm
}
{$R *.dfm}
uses
View
.
Main
;
...
...
@@ -83,7 +86,10 @@ begin
if
edtID
.
Text
=
''
then
edtNotification
.
Text
:=
'Please Select a Customer'
else
begin
xdwdsCustomers
.
Locate
(
'Id'
,
edtID
.
Text
,
[]);
SendCustomerToServer
();
end
;
end
;
[
async
]
procedure
TFSelectCustomer
.
getCustomers
();
...
...
@@ -124,9 +130,9 @@ begin
TMSFNCGrid1
.
ColumnCount
:=
4
;
TMSFNCGrid1
.
RowCount
:=
1
;
TMSFNCGrid1
.
Cells
[
0
,
0
]
:=
'Quickbooks ID'
;
TMSFNCGrid1
.
Cells
[
1
,
0
]
:=
'Customer
ID
'
;
TMSFNCGrid1
.
Cells
[
2
,
0
]
:=
'
Customer Name
'
;
TMSFNCGrid1
.
Cells
[
3
,
0
]
:=
'
Addres
s'
;
TMSFNCGrid1
.
Cells
[
1
,
0
]
:=
'Customer
Name
'
;
TMSFNCGrid1
.
Cells
[
2
,
0
]
:=
'
Address
'
;
TMSFNCGrid1
.
Cells
[
3
,
0
]
:=
'
In KGOrder
s'
;
// Populate the grid with data from the dataset
xdwdsCustomers
.
First
;
...
...
@@ -136,9 +142,9 @@ begin
begin
TMSFNCGrid1
.
RowCount
:=
RowIndex
+
1
;
TMSFNCGrid1
.
Cells
[
0
,
RowIndex
]
:=
xdwdsCustomers
.
FieldByName
(
'Id'
).
AsString
;
// TMSFNCGrid1.Cells[1, RowIndex] := xdwdsCustomers.FieldByName('SHORT_NAME
').AsString;
TMSFNCGrid1
.
Cells
[
2
,
RowIndex
]
:=
xdwdsCustomers
.
FieldByName
(
'
CompanyName
'
).
AsString
;
TMSFNCGrid1
.
Cells
[
3
,
RowIndex
]
:=
xdwdsCustomers
.
FieldByName
(
'
BillAddr
'
).
AsString
;
TMSFNCGrid1
.
Cells
[
1
,
RowIndex
]
:=
xdwdsCustomers
.
FieldByName
(
'CompanyName
'
).
AsString
;
TMSFNCGrid1
.
Cells
[
2
,
RowIndex
]
:=
xdwdsCustomers
.
FieldByName
(
'
BillAddr
'
).
AsString
;
TMSFNCGrid1
.
Cells
[
3
,
RowIndex
]
:=
xdwdsCustomers
.
FieldByName
(
'
In KGOrders
'
).
AsString
;
Inc
(
RowIndex
);
xdwdsCustomers
.
Next
;
end
;
...
...
@@ -148,6 +154,13 @@ begin
end
;
end
;
procedure
TFSelectCustomer
.
TMSFNCGrid1CellClick
(
Sender
:
TObject
;
ACol
,
ARow
:
Integer
);
begin
edtID
.
Text
:=
TMSFNCGrid1
.
Cells
[
0
,
ARow
];
edtName
.
Text
:=
TMSFNCGrid1
.
Cells
[
1
,
ARow
];
end
;
procedure
TFSelectCustomer
.
TMSFNCGrid1CellDblClick
(
Sender
:
TObject
;
ACol
,
ARow
:
Integer
);
begin
...
...
kgOrdersServer/Source/Data.dfm
View file @
95296f5f
...
...
@@ -43,6 +43,8 @@ object FData: TFData
Lines.Strings = (
'Memo1')
TabOrder = 1
ExplicitLeft = -2
ExplicitTop = 435
end
object DBAdvGrid1: TDBAdvGrid
Left = 6
...
...
@@ -1602,8 +1604,8 @@ object FData: TFData
object uqWeb: TUniQuery
SQL.Strings = (
'select * from web_plate_orders')
Left = 74
5
Top = 4
64
Left = 74
3
Top = 4
76
object uqWebORDER_ID: TIntegerField
FieldName = 'ORDER_ID'
Required = True
...
...
kgOrdersServer/Source/Lookup.ServiceImpl.pas
View file @
95296f5f
...
...
@@ -2370,64 +2370,61 @@ begin
for
I
:=
0
to
CustomerList
.
Count
-
1
do
begin
Customer
:=
CustomerList
.
Items
[
I
]
as
TJSONObject
;
ParsedCustomer
:=
TJSONObject
.
Create
;
sql
:=
'select CUSTOMER_ID from customers where QB_LIST_ID = '
+
Customer
.
GetValue
<
string
>(
'Id'
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
if
ordersDB
.
UniQuery1
.
IsEmpty
then
begin
try
ParsedCustomer
.
AddPair
(
'Id'
,
Customer
.
GetValue
<
string
>(
'Id'
));
ParsedCustomer
.
AddPair
(
'CompanyName'
,
Customer
.
GetValue
<
string
>(
'DisplayName'
));
try
ParsedCustomer
.
AddPair
(
'In KGOrders'
,
not
(
ordersDB
.
UniQuery1
.
IsEmpty
));
// Handle Bill Address
if
Customer
.
GetValue
(
'BillAddr'
)
is
TJSONObject
then
begin
BillAddr
:=
Customer
.
GetValue
(
'BillAddr'
)
as
TJSONObject
;
ParsedCustomer
.
AddPair
(
'BillAddrLine1'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'Line1'
,
''
)));
ParsedCustomer
.
AddPair
(
'BillAddrCity'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'City'
,
''
)));
ParsedCustomer
.
AddPair
(
'BillAddrState'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'CountrySubDivisionCode'
,
''
)));
ParsedCustomer
.
AddPair
(
'BillAddrZip'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'PostalCode'
,
''
)));
ParsedCustomer
.
AddPair
(
'BillAddr'
,
TJSONString
.
Create
(
Customer
.
GetValue
<
string
>(
'DisplayName'
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'Line1'
,
''
)
+
','
+
sLineBreak
+
BillAddr
.
GetValue
(
'City'
,
''
)
+
', '
+
BillAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
)
+
' '
+
BillAddr
.
GetValue
(
'PostalCode'
,
''
)
)
);
end
;
ParsedCustomer
.
AddPair
(
'Id'
,
Customer
.
GetValue
<
string
>(
'Id'
));
ParsedCustomer
.
AddPair
(
'CompanyName'
,
Customer
.
GetValue
<
string
>(
'DisplayName'
));
// Handle Ship
Address
if
Customer
.
GetValue
(
'Ship
Addr'
)
is
TJSONObject
then
begin
BillAddr
:=
Customer
.
GetValue
(
'Ship
Addr'
)
as
TJSONObject
;
ParsedCustomer
.
AddPair
(
'Ship
AddrLine1'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'Line1'
,
''
)));
ParsedCustomer
.
AddPair
(
'Ship
AddrCity'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'City'
,
''
)));
ParsedCustomer
.
AddPair
(
'Ship
AddrState'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'CountrySubDivisionCode'
,
''
)));
ParsedCustomer
.
AddPair
(
'Ship
AddrZip'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'PostalCode'
,
''
)));
ParsedCustomer
.
AddPair
(
'Ship
Addr'
,
TJSONString
.
Create
(
Customer
.
GetValue
<
string
>(
'DisplayName'
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'Line1'
,
''
)
+
','
+
sLineBreak
+
BillAddr
.
GetValue
(
'City'
,
''
)
+
', '
+
BillAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
)
+
' '
+
BillAddr
.
GetValue
(
'PostalCode'
,
''
)
)
);
end
;
// Handle Bill
Address
if
Customer
.
GetValue
(
'Bill
Addr'
)
is
TJSONObject
then
begin
BillAddr
:=
Customer
.
GetValue
(
'Bill
Addr'
)
as
TJSONObject
;
ParsedCustomer
.
AddPair
(
'Bill
AddrLine1'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'Line1'
,
''
)));
ParsedCustomer
.
AddPair
(
'Bill
AddrCity'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'City'
,
''
)));
ParsedCustomer
.
AddPair
(
'Bill
AddrState'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'CountrySubDivisionCode'
,
''
)));
ParsedCustomer
.
AddPair
(
'Bill
AddrZip'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'PostalCode'
,
''
)));
ParsedCustomer
.
AddPair
(
'Bill
Addr'
,
TJSONString
.
Create
(
Customer
.
GetValue
<
string
>(
'DisplayName'
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'Line1'
,
''
)
+
','
+
sLineBreak
+
BillAddr
.
GetValue
(
'City'
,
''
)
+
', '
+
BillAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
)
+
' '
+
BillAddr
.
GetValue
(
'PostalCode'
,
''
)
)
);
end
;
Result
.
AddElement
(
ParsedCustomer
);
except
ParsedCustomer
.
Free
;
raise
;
// Handle Ship Address
if
Customer
.
GetValue
(
'ShipAddr'
)
is
TJSONObject
then
begin
BillAddr
:=
Customer
.
GetValue
(
'ShipAddr'
)
as
TJSONObject
;
ParsedCustomer
.
AddPair
(
'ShipAddrLine1'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'Line1'
,
''
)));
ParsedCustomer
.
AddPair
(
'ShipAddrCity'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'City'
,
''
)));
ParsedCustomer
.
AddPair
(
'ShipAddrState'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'CountrySubDivisionCode'
,
''
)));
ParsedCustomer
.
AddPair
(
'ShipAddrZip'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'PostalCode'
,
''
)));
ParsedCustomer
.
AddPair
(
'ShipAddr'
,
TJSONString
.
Create
(
Customer
.
GetValue
<
string
>(
'DisplayName'
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'Line1'
,
''
)
+
','
+
sLineBreak
+
BillAddr
.
GetValue
(
'City'
,
''
)
+
', '
+
BillAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
)
+
' '
+
BillAddr
.
GetValue
(
'PostalCode'
,
''
)
)
);
end
;
end
;
Result
.
AddElement
(
ParsedCustomer
);
except
ParsedCustomer
.
Free
;
raise
;
end
;
end
;
finally
...
...
@@ -2556,112 +2553,123 @@ var
Pair
:
TJSONPair
;
Field
:
TField
;
DateFormat
:
TFormatSettings
;
CustomerID
:
i
nteger
;
CustomerID
:
I
nteger
;
mode
:
string
;
temp
:
string
;
msg
:
string
;
unique
:
boolean
;
QB_LIST_ID
:
string
;
unique
:
Boolean
;
begin
DateFormat
:=
TFormatSettings
.
Create
;
DateFormat
.
ShortDateFormat
:=
'yyyy-mm-dd'
;
DateFormat
.
DateSeparator
:=
'-'
;
JSONData
:=
TJSONObject
.
ParseJSONValue
(
customerInfo
)
as
TJSONObject
;
JSONData
:=
TJSONObject
.
ParseJSONValue
(
CustomerInfo
)
as
TJSONObject
;
if
JSONData
=
nil
then
raise
Exception
.
Create
(
'Invalid JSON format'
);
// If parsing fails, raise an exception
raise
Exception
.
Create
(
'Invalid JSON format'
);
mode
:=
JSONData
.
GetValue
<
string
>(
'mode'
);
QB_LIST_ID
:=
JSONData
.
GetValue
<
string
>(
'QB_LIST_ID'
);
if
mode
=
'ADD'
then
begin
// Update RevisionID
SQL
:=
'UPDATE idfield
set KEYVALUE = KEYVALUE + 1 WHERE KEYNAME = '
+
q
uotedStr
(
'GEN_CUSTOMER_ID'
);
SQL
:=
'UPDATE idfield
SET KEYVALUE = KEYVALUE + 1 WHERE KEYNAME = '
+
Q
uotedStr
(
'GEN_CUSTOMER_ID'
);
OrdersDB
.
UniQuery1
.
SQL
.
Text
:=
SQL
;
OrdersDB
.
UniQuery1
.
ExecSQL
;
// Retrieve updated RevisionID
SQL
:=
'
select KEYVALUE from idfield where KEYNAME = '
+
q
uotedStr
(
'GEN_CUSTOMER_ID'
);
SQL
:=
'
SELECT KEYVALUE FROM idfield WHERE KEYNAME = '
+
Q
uotedStr
(
'GEN_CUSTOMER_ID'
);
doQuery
(
OrdersDB
.
UniQuery1
,
SQL
);
CustomerID
:=
OrdersDB
.
UniQuery1
.
FieldByName
(
'KEYVALUE'
).
AsInteger
;
end
else
CustomerID
:=
JSONData
.
GetValue
<
integer
>(
'CUSTOMER_ID'
);
if
mode
=
'ADD'
then
SQL
:=
'select * from customers where CUSTOMER_ID = 0 and CUSTOMER_ID <> 0'
else
begin
SQL
:=
'select * from customers where CUSTOMER_ID = '
+
IntToStr
(
CustomerID
);
end
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
try
if
mode
=
'ADD'
then
ordersDB
.
UniQuery1
.
Insert
else
ordersDB
.
UniQuery1
.
Edit
;
SQL
:=
'SELECT * FROM customers WHERE QB_LIST_ID = '
+
QuotedStr
(
QB_LIST_ID
);
doQuery
(
OrdersDB
.
UniQuery1
,
SQL
);
for
Pair
in
JSONData
do
try
if
OrdersDB
.
UniQuery1
.
IsEmpty
then
begin
Field
:=
ordersDB
.
UniQuery1
.
FindField
(
Pair
.
JsonString
.
Value
);
// Checks if the field exists in the dataset
if
Assigned
(
Field
)
then
OrdersDB
.
UniQuery1
.
Insert
;
for
Pair
in
JSONData
do
begin
if
(
Field
is
TDateTimeField
)
then
Field
:=
OrdersDB
.
UniQuery1
.
FindField
(
Pair
.
JsonString
.
Value
);
if
Assigned
(
Field
)
then
begin
if
(
Pair
.
JsonValue
.
Value
=
''
)
or
(
Pair
.
JsonValue
.
Value
=
'null'
)
or
(
Pair
.
JsonValue
.
Value
=
'12/30/1899'
)
then
Field
.
Clear
// This sets the field to NULL (empty)
else
TDateTimeField
(
Field
).
AsDateTime
:=
StrToDate
(
Pair
.
JsonValue
.
Value
);
end
else
if
Pair
.
JsonValue
.
Value
<>
''
then
Field
.
AsString
:=
Pair
.
JsonValue
.
Value
;
if
Field
is
TDateTimeField
then
begin
if
(
Pair
.
JsonValue
.
Value
=
''
)
or
(
Pair
.
JsonValue
.
Value
=
'null'
)
or
(
Pair
.
JsonValue
.
Value
=
'12/30/1899'
)
then
Field
.
Clear
else
TDateTimeField
(
Field
).
AsDateTime
:=
StrToDate
(
Pair
.
JsonValue
.
Value
,
DateFormat
);
end
else
if
Pair
.
JsonValue
.
Value
<>
''
then
Field
.
AsString
:=
Pair
.
JsonValue
.
Value
;
end
;
end
;
end
;
o
rdersDB
.
UniQuery1
.
FieldByName
(
'CUSTOMER_ID'
).
AsInteger
:=
CustomerID
;
JSONData
.
AddPair
(
'customer_id'
,
CustomerID
);
O
rdersDB
.
UniQuery1
.
FieldByName
(
'CUSTOMER_ID'
).
AsInteger
:=
CustomerID
;
JSONData
.
AddPair
(
'customer_id'
,
TJSONNumber
.
Create
(
CustomerID
)
);
// Post the record to the database
ordersDB
.
UniQuery1
.
Post
;
if
mode
=
'ADD'
then
msg
:=
'Success:Customer Successfully Added'
else
msg
:=
'Success:Customer Successfully Edited'
;
OrdersDB
.
UniQuery1
.
Post
;
if
mode
=
'ADD'
then
msg
:=
'Success:Customer Successfully Added'
else
msg
:=
'Success:Customer Successfully Edited'
;
Result
:=
TJSONObject
.
Create
.
AddPair
(
'status'
,
msg
);
Result
.
AddPair
(
'CustomerID'
,
CustomerID
);
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
Result
:=
TJSONObject
.
Create
;
Result
.
AddPair
(
'status'
,
msg
);
Result
.
AddPair
(
'CustomerID'
,
CustomerID
);
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
//Add Shipping Information
SQL
:=
'select * from customers_ship where customer_id = 0 and customer_id <> 0'
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
ordersDB
.
UniQuery1
.
Insert
;
// Add Shipping Information
for
Pair
in
JSONData
do
begin
Field
:=
ordersDB
.
UniQuery1
.
FindField
(
Pair
.
JsonString
.
Value
);
// Checks if the field exists in the dataset
if
Assigned
(
Field
)
then
if
JSONData
.
GetValue
<
string
>(
'ship_block'
)
<>
''
then
begin
if
(
Field
is
TDateTimeField
)
then
SQL
:=
'SELECT * FROM customers_ship WHERE customer_id = 0 AND customer_id <> 0'
;
doQuery
(
OrdersDB
.
UniQuery1
,
SQL
);
OrdersDB
.
UniQuery1
.
Insert
;
for
Pair
in
JSONData
do
begin
if
(
Pair
.
JsonValue
.
Value
=
''
)
or
(
Pair
.
JsonValue
.
Value
=
'null'
)
or
(
Pair
.
JsonValue
.
Value
=
'12/30/1899'
)
then
Field
.
Clear
// This sets the field to NULL (empty)
else
TDateTimeField
(
Field
).
AsDateTime
:=
StrToDate
(
Pair
.
JsonValue
.
Value
);
end
else
if
Pair
.
JsonValue
.
Value
<>
''
then
Field
.
AsString
:=
Pair
.
JsonValue
.
Value
;
Field
:=
OrdersDB
.
UniQuery1
.
FindField
(
Pair
.
JsonString
.
Value
);
if
Assigned
(
Field
)
then
begin
if
Field
is
TDateTimeField
then
begin
if
(
Pair
.
JsonValue
.
Value
=
''
)
or
(
Pair
.
JsonValue
.
Value
=
'null'
)
or
(
Pair
.
JsonValue
.
Value
=
'12/30/1899'
)
then
Field
.
Clear
else
TDateTimeField
(
Field
).
AsDateTime
:=
StrToDate
(
Pair
.
JsonValue
.
Value
,
DateFormat
);
end
else
if
Pair
.
JsonValue
.
Value
<>
''
then
Field
.
AsString
:=
Pair
.
JsonValue
.
Value
;
end
;
end
;
OrdersDB
.
UniQuery1
.
Post
;
end
;
end
;
ordersDB
.
UniQuery1
.
Post
;
except
end
else
begin
msg
:=
'Failure:Customer Already in Database'
;
CustomerID
:=
OrdersDB
.
UniQuery1
.
FieldByName
(
'CUSTOMER_ID'
).
AsInteger
;
Result
:=
TJSONObject
.
Create
;
Result
.
AddPair
(
'status'
,
msg
);
Result
.
AddPair
(
'CustomerID'
,
CustomerID
);
end
;
except
on
E
:
Exception
do
begin
Result
:=
TJSONObject
.
Create
.
AddPair
(
'error'
,
E
.
Message
);
end
Result
:=
TJSONObject
.
Create
;
Result
.
AddPair
(
'error'
,
E
.
Message
);
end
;
end
;
end
;
initialization
RegisterServiceType
(
TLookupService
);
end
.
...
...
kgOrdersServer/Source/qbAPI.dfm
View file @
95296f5f
...
...
@@ -11,6 +11,7 @@ object fQB: TfQB
Font.Name = 'Segoe UI'
Font.Style = []
OnCreate = FormCreate
OnDestroy = FormDestroy
TextHeight = 15
object Memo1: TMemo
Left = 0
...
...
@@ -44,8 +45,8 @@ object fQB: TfQB
TabOrder = 2
end
object Button2: TButton
Left = 1
48
Top =
18
Left = 1
35
Top =
22
Width = 87
Height = 25
Caption = 'Get Customers'
...
...
@@ -197,8 +198,8 @@ object fQB: TfQB
22)
end
object Button3: TButton
Left = 2
60
Top =
18
Left = 2
28
Top =
22
Width = 139
Height = 25
Caption = 'Get Customer By ID'
...
...
@@ -206,12 +207,351 @@ object fQB: TfQB
OnClick = Button3Click
end
object Button4: TButton
Left =
460
Top =
18
Left =
373
Top =
22
Width = 95
Height = 25
Caption = 'Add Estimate'
TabOrder = 6
OnClick = Button4Click
end
object Button5: TButton
Left = 472
Top = 22
Width = 169
Height = 25
Caption = 'Show Customers with Orders'
TabOrder = 7
OnClick = Button5Click
end
object uq: TUniQuery
Connection = ApiDatabase.ucKG
SQL.Strings = (
'select * from web_plate_orders')
Left = 743
Top = 36
object uqORDER_ID: TIntegerField
FieldName = 'ORDER_ID'
Required = True
end
object uqCOMPANY_ID: TIntegerField
FieldName = 'COMPANY_ID'
Required = True
end
object uqUSER_ID: TIntegerField
FieldName = 'USER_ID'
Required = True
end
object uqORDER_DATE: TDateTimeField
FieldName = 'ORDER_DATE'
end
object uqSTART_DATE: TDateField
FieldName = 'START_DATE'
end
object uqEND_DATE: TDateField
FieldName = 'END_DATE'
end
object uqORDER_STATUS: TStringField
FieldName = 'ORDER_STATUS'
Size = 10
end
object uqSCHED_JSON: TStringField
FieldName = 'SCHED_JSON'
Size = 4096
end
object uqstaff_fields_order_date: TDateField
FieldName = 'staff_fields_order_date'
end
object uqstaff_fields_proof_date: TDateField
FieldName = 'staff_fields_proof_date'
end
object uqstaff_fields_ship_date: TDateField
FieldName = 'staff_fields_ship_date'
end
object uqstaff_fields_ship_via: TStringField
FieldName = 'staff_fields_ship_via'
Size = 45
end
object uqstaff_fields_price: TStringField
FieldName = 'staff_fields_price'
Size = 10
end
object uqstaff_fields_invoice_to: TStringField
FieldName = 'staff_fields_invoice_to'
Size = 128
end
object uqstaff_fields_invoice_attention: TStringField
FieldName = 'staff_fields_invoice_attention'
Size = 256
end
object uqstaff_fields_ship_to: TStringField
FieldName = 'staff_fields_ship_to'
Size = 128
end
object uqstaff_fields_ship_attention: TStringField
FieldName = 'staff_fields_ship_attention'
Size = 256
end
object uqstaff_fields_po_number: TStringField
FieldName = 'staff_fields_po_number'
Size = 16
end
object uqstaff_fields_job_name: TStringField
FieldName = 'staff_fields_job_name'
Size = 45
end
object uqstaff_fields_art_due: TDateField
FieldName = 'staff_fields_art_due'
end
object uqstaff_fields_plate_due: TDateField
FieldName = 'staff_fields_plate_due'
end
object uqplates_job_number: TStringField
FieldName = 'plates_job_number'
Size = 16
end
object uqsupplied_by_customer_b_w_or_co: TStringField
FieldName = 'supplied_by_customer_b_w_or_co'
Size = 4
end
object uqsupplied_by_customer_plates: TStringField
FieldName = 'supplied_by_customer_plates'
Size = 4
end
object uqsupplied_by_customer_sample: TStringField
FieldName = 'supplied_by_customer_sample'
Size = 45
end
object uqsupplied_by_customer_dimension: TStringField
FieldName = 'supplied_by_customer_dimension'
Size = 4
end
object uqsupplied_by_customer_other: TStringField
FieldName = 'supplied_by_customer_other'
Size = 45
end
object uqsupplied_by_customer_disk: TStringField
FieldName = 'supplied_by_customer_disk'
Size = 4
end
object uqsupplied_by_customer_e_mail: TStringField
FieldName = 'supplied_by_customer_e_mail'
Size = 128
end
object uqsupplied_by_customer_ftp: TStringField
FieldName = 'supplied_by_customer_ftp'
Size = 128
end
object uqplates_plate_material: TStringField
FieldName = 'plates_plate_material'
Size = 16
end
object uqplates_thickness: TStringField
FieldName = 'plates_thickness'
Size = 5
end
object uqsupplied_by_customer_total_inc: TStringField
FieldName = 'supplied_by_customer_total_inc'
Size = 32
end
object uqsupplied_by_customer_sheets_us: TStringField
FieldName = 'supplied_by_customer_sheets_us'
Size = 32
end
object uqsupplied_by_customer_initials: TStringField
FieldName = 'supplied_by_customer_initials'
Size = 16
end
object uqproofing_pdf: TStringField
FieldName = 'proofing_pdf'
Size = 1
end
object uqproofing_pdf_to: TStringField
FieldName = 'proofing_pdf_to'
Size = 256
end
object uqproofing_pdf_date_1: TDateField
FieldName = 'proofing_pdf_date_1'
end
object uqproofing_pdf_date_2: TDateField
FieldName = 'proofing_pdf_date_2'
end
object uqproofing_pdf_date_3: TDateField
FieldName = 'proofing_pdf_date_3'
end
object uqproofing_full_size_ink_jet_for: TStringField
FieldName = 'proofing_full_size_ink_jet_for'
Size = 1
end
object uqproofing_ink_jet_to: TStringField
FieldName = 'proofing_ink_jet_to'
Size = 256
end
object uqproofing_ink_jet_to_2: TStringField
FieldName = 'proofing_ink_jet_to_2'
Size = 256
end
object uqproofing_ink_jet_date_1: TDateField
FieldName = 'proofing_ink_jet_date_1'
end
object uqproofing_ink_jet_date_2: TDateField
FieldName = 'proofing_ink_jet_date_2'
end
object uqproofing_ink_jet_date_3: TDateField
FieldName = 'proofing_ink_jet_date_3'
end
object uqproofing_color_contract: TStringField
FieldName = 'proofing_color_contract'
Size = 17
end
object uqproofing_color_contrac_to: TStringField
FieldName = 'proofing_color_contrac_to'
Size = 256
end
object uqproofing_color_contrac_date_1: TDateField
FieldName = 'proofing_color_contrac_date_1'
end
object uqproofing_color_contrac_date_2: TDateField
FieldName = 'proofing_color_contrac_date_2'
end
object uqproofing_digital_color_key: TStringField
FieldName = 'proofing_digital_color_key'
Size = 10
end
object uqproofing_digital_color_to: TStringField
FieldName = 'proofing_digital_color_to'
Size = 256
end
object uqproofing_digital_color_date_1: TDateField
FieldName = 'proofing_digital_color_date_1'
end
object uqquantity_and_colors_press_name: TStringField
FieldName = 'quantity_and_colors_press_name'
Size = 64
end
object uqquantity_and_colors_anilox_info: TStringField
FieldName = 'quantity_and_colors_anilox_info'
Size = 64
end
object uqplate_marks_microdots: TStringField
FieldName = 'plate_marks_microdots'
Size = 10
end
object uqplate_marks_microdots_comments: TStringField
FieldName = 'plate_marks_microdots_comments'
Size = 128
end
object uqplate_marks_crosshairs: TStringField
FieldName = 'plate_marks_crosshairs'
Size = 10
end
object uqplate_marks_crosshairs_comments: TStringField
FieldName = 'plate_marks_crosshairs_comments'
Size = 128
end
object uqplate_marks_color_bars: TStringField
FieldName = 'plate_marks_color_bars'
Size = 10
end
object uqplate_marks_color_bars_comments: TStringField
FieldName = 'plate_marks_color_bars_comments'
Size = 128
end
object uqplate_marks_other: TStringField
FieldName = 'plate_marks_other'
Size = 16
end
object uqplate_marks_other_comments: TStringField
FieldName = 'plate_marks_other_comments'
Size = 128
end
object uqprint_orientation_print_orient: TStringField
FieldName = 'print_orientation_print_orient'
Size = 10
end
object uqlayout_around: TStringField
FieldName = 'layout_around'
Size = 10
end
object uqlayout_accross: TStringField
FieldName = 'layout_accross'
Size = 10
end
object uqlayout_surface_print: TStringField
FieldName = 'layout_surface_print'
Size = 10
end
object uqlayout_reverse_print: TStringField
FieldName = 'layout_reverse_print'
Size = 10
end
object uqlayout_cylinder_repeat: TStringField
FieldName = 'layout_cylinder_repeat'
Size = 16
end
object uqlayout_cutoff_dimension: TStringField
FieldName = 'layout_cutoff_dimension'
Size = 16
end
object uqlayout_pitch: TStringField
FieldName = 'layout_pitch'
Size = 16
end
object uqlayout_teeth: TStringField
FieldName = 'layout_teeth'
Size = 16
end
object uqlayout_bleed: TStringField
FieldName = 'layout_bleed'
Size = 16
end
object uqlayout_cutback: TStringField
FieldName = 'layout_cutback'
Size = 16
end
object uqlayout_minimum_trap_dim: TStringField
FieldName = 'layout_minimum_trap_dim'
Size = 10
end
object uqlayout_maximum_trap_dim: TStringField
FieldName = 'layout_maximum_trap_dim'
Size = 10
end
object uqupc_size: TStringField
FieldName = 'upc_size'
Size = 16
end
object uqupc_bar_width_reduction: TStringField
FieldName = 'upc_bar_width_reduction'
Size = 16
end
object uqquantity_and_colors_qty_colors: TStringField
FieldName = 'quantity_and_colors_qty_colors'
Size = 4096
end
object uqgeneral_comments: TStringField
FieldName = 'general_comments'
Size = 4096
end
object uqstaff_fields_quickbooks_item: TStringField
FieldName = 'staff_fields_quickbooks_item'
Size = 45
end
object uqstaff_fields_quantity: TStringField
FieldName = 'staff_fields_quantity'
Size = 10
end
object uqupc_distortion_percent: TStringField
FieldName = 'upc_distortion_percent'
Size = 16
end
object uqupc_distortion_amount: TStringField
FieldName = 'upc_distortion_amount'
Size = 16
end
object uqstaff_fields_art_location: TStringField
FieldName = 'staff_fields_art_location'
Size = 16
end
end
end
kgOrdersServer/Source/qbAPI.pas
View file @
95296f5f
...
...
@@ -23,13 +23,104 @@ type
asgData
:
TAdvStringGrid
;
Button3
:
TButton
;
Button4
:
TButton
;
Button5
:
TButton
;
uq
:
TUniQuery
;
uqORDER_ID
:
TIntegerField
;
uqCOMPANY_ID
:
TIntegerField
;
uqUSER_ID
:
TIntegerField
;
uqORDER_DATE
:
TDateTimeField
;
uqSTART_DATE
:
TDateField
;
uqEND_DATE
:
TDateField
;
uqORDER_STATUS
:
TStringField
;
uqSCHED_JSON
:
TStringField
;
uqstaff_fields_order_date
:
TDateField
;
uqstaff_fields_proof_date
:
TDateField
;
uqstaff_fields_ship_date
:
TDateField
;
uqstaff_fields_ship_via
:
TStringField
;
uqstaff_fields_price
:
TStringField
;
uqstaff_fields_invoice_to
:
TStringField
;
uqstaff_fields_invoice_attention
:
TStringField
;
uqstaff_fields_ship_to
:
TStringField
;
uqstaff_fields_ship_attention
:
TStringField
;
uqstaff_fields_po_number
:
TStringField
;
uqstaff_fields_job_name
:
TStringField
;
uqstaff_fields_art_due
:
TDateField
;
uqstaff_fields_plate_due
:
TDateField
;
uqplates_job_number
:
TStringField
;
uqsupplied_by_customer_b_w_or_co
:
TStringField
;
uqsupplied_by_customer_plates
:
TStringField
;
uqsupplied_by_customer_sample
:
TStringField
;
uqsupplied_by_customer_dimension
:
TStringField
;
uqsupplied_by_customer_other
:
TStringField
;
uqsupplied_by_customer_disk
:
TStringField
;
uqsupplied_by_customer_e_mail
:
TStringField
;
uqsupplied_by_customer_ftp
:
TStringField
;
uqplates_plate_material
:
TStringField
;
uqplates_thickness
:
TStringField
;
uqsupplied_by_customer_total_inc
:
TStringField
;
uqsupplied_by_customer_sheets_us
:
TStringField
;
uqsupplied_by_customer_initials
:
TStringField
;
uqproofing_pdf
:
TStringField
;
uqproofing_pdf_to
:
TStringField
;
uqproofing_pdf_date_1
:
TDateField
;
uqproofing_pdf_date_2
:
TDateField
;
uqproofing_pdf_date_3
:
TDateField
;
uqproofing_full_size_ink_jet_for
:
TStringField
;
uqproofing_ink_jet_to
:
TStringField
;
uqproofing_ink_jet_to_2
:
TStringField
;
uqproofing_ink_jet_date_1
:
TDateField
;
uqproofing_ink_jet_date_2
:
TDateField
;
uqproofing_ink_jet_date_3
:
TDateField
;
uqproofing_color_contract
:
TStringField
;
uqproofing_color_contrac_to
:
TStringField
;
uqproofing_color_contrac_date_1
:
TDateField
;
uqproofing_color_contrac_date_2
:
TDateField
;
uqproofing_digital_color_key
:
TStringField
;
uqproofing_digital_color_to
:
TStringField
;
uqproofing_digital_color_date_1
:
TDateField
;
uqquantity_and_colors_press_name
:
TStringField
;
uqquantity_and_colors_anilox_info
:
TStringField
;
uqplate_marks_microdots
:
TStringField
;
uqplate_marks_microdots_comments
:
TStringField
;
uqplate_marks_crosshairs
:
TStringField
;
uqplate_marks_crosshairs_comments
:
TStringField
;
uqplate_marks_color_bars
:
TStringField
;
uqplate_marks_color_bars_comments
:
TStringField
;
uqplate_marks_other
:
TStringField
;
uqplate_marks_other_comments
:
TStringField
;
uqprint_orientation_print_orient
:
TStringField
;
uqlayout_around
:
TStringField
;
uqlayout_accross
:
TStringField
;
uqlayout_surface_print
:
TStringField
;
uqlayout_reverse_print
:
TStringField
;
uqlayout_cylinder_repeat
:
TStringField
;
uqlayout_cutoff_dimension
:
TStringField
;
uqlayout_pitch
:
TStringField
;
uqlayout_teeth
:
TStringField
;
uqlayout_bleed
:
TStringField
;
uqlayout_cutback
:
TStringField
;
uqlayout_minimum_trap_dim
:
TStringField
;
uqlayout_maximum_trap_dim
:
TStringField
;
uqupc_size
:
TStringField
;
uqupc_bar_width_reduction
:
TStringField
;
uqquantity_and_colors_qty_colors
:
TStringField
;
uqgeneral_comments
:
TStringField
;
uqstaff_fields_quickbooks_item
:
TStringField
;
uqstaff_fields_quantity
:
TStringField
;
uqupc_distortion_percent
:
TStringField
;
uqupc_distortion_amount
:
TStringField
;
uqstaff_fields_art_location
:
TStringField
;
procedure
Button1Click
(
Sender
:
TObject
);
procedure
FormCreate
(
Sender
:
TObject
);
procedure
Button2Click
(
Sender
:
TObject
);
procedure
Button3Click
(
Sender
:
TObject
);
procedure
Button4Click
(
Sender
:
TObject
);
procedure
Button5Click
(
Sender
:
TObject
);
procedure
FormDestroy
(
Sender
:
TObject
);
private
{ Private declarations }
strict
private
ordersDB
:
TApiDatabase
;
httpReqTokenRefresh
:
TWebHttpRequest
;
var
...
...
@@ -51,7 +142,7 @@ var
implementation
uses
Common
.
Logging
;
Common
.
Logging
,
uLibrary
;
{$R *.dfm}
...
...
@@ -130,13 +221,13 @@ begin
restRequest
.
Execute
;
memo1
.
Lines
.
Add
(
restresponse
.
Content
);
//
memo1.Lines.Add(restresponse.Content);
jsValue
:=
restResponse
.
JSONValue
;
jsObj
:=
TJSONObject
(
jsValue
);
Memo2
.
Lines
.
Add
(
res
);
Memo
2
.
Lines
.
Add
(
jsObj
.
Format
(
2
)
);
//
Memo2.Lines.Add(res);
Memo
1
.
Lines
.
Add
(
jsObj
.
Format
(
2
)
);
// CustomerList := TJSONArray( TJSONObject( jsObj.GetValue('QueryResponse') ).GetValue('Customer')) ;
...
...
@@ -190,13 +281,13 @@ begin
restRequest
.
Execute
;
memo1
.
Lines
.
Add
(
restresponse
.
Content
);
//
memo1.Lines.Add(restresponse.Content);
jsValue
:=
restResponse
.
JSONValue
;
jsObj
:=
TJSONObject
(
jsValue
);
Memo2
.
Lines
.
Add
(
res
);
Memo
2
.
Lines
.
Add
(
jsObj
.
Format
(
2
)
);
//
Memo2.Lines.Add(res);
Memo
1
.
Lines
.
Add
(
jsObj
.
Format
(
2
)
);
//CustomerList := TJSONArray(restResponse.JSONValue);
// CustomerList := TJSONArray( TJSONObject( jsObj.GetValue('QueryResponse') ).GetValue('Customer')) ;
...
...
@@ -208,6 +299,27 @@ begin
restResponse
.
Free
;
end
;
procedure
TfQB
.
Button5Click
(
Sender
:
TObject
);
var
SQL
:
string
;
count
:
integer
;
begin
SQL
:=
'SELECT c.CUSTOMER_ID, c.SHORT_NAME, c.NAME 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'
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
while
not
ordersDB
.
UniQuery1
.
Eof
do
begin
Memo2
.
Lines
.
Add
(
ordersDB
.
UniQuery1
.
FieldByName
(
'CUSTOMER_ID'
).
AsString
+
', '
+
ordersDB
.
UniQuery1
.
FieldByName
(
'SHORT_NAME'
).
AsString
+
', '
+
ordersDB
.
UniQuery1
.
FieldByName
(
'NAME'
).
AsString
);
OrdersDB
.
UniQuery1
.
Next
;
count
:=
count
+
1
;
end
;
Memo2
.
Lines
.
Add
(
'Showing '
+
IntToStr
(
count
)
+
' entries'
);
end
;
procedure
TfQB
.
getCustomers
();
var
restClient
:
TRESTClient
;
...
...
@@ -260,43 +372,13 @@ begin
jsValue
:=
restResponse
.
JSONValue
;
jsObj
:=
TJSONObject
(
jsValue
);
{
Memo2.Lines.Add(res);
Memo2.Lines.Add( jsObj.Format(2) );
}
Memo2
.
Lines
.
Add
(
res
);
Memo2
.
Lines
.
Add
(
jsObj
.
Format
(
2
)
);
//CustomerList := TJSONArray(restResponse.JSONValue);
CustomerList
:=
TJSONArray
(
TJSONObject
(
jsObj
.
GetValue
(
'QueryResponse'
)
).
GetValue
(
'Customer'
))
;
ModifiedList
:=
TJSONArray
.
Create
;
for
I
:=
0
to
CustomerList
.
Count
-
1
do
begin
Customer
:=
CustomerList
.
Items
[
I
]
as
TJSONObject
;
ParsedCustomer
:=
TJSONObject
.
Create
;
try
// Directly add values without cloning
ParsedCustomer
.
AddPair
(
'id'
,
Customer
.
GetValue
(
'Id'
));
ParsedCustomer
.
AddPair
(
'name'
,
Customer
.
GetValue
(
'DisplayName'
));
if
Customer
.
GetValue
(
'BillAddr'
)
<>
nil
then
begin
BillAddr
:=
Customer
.
GetValue
(
'BillAddr'
)
as
TJSONObject
;
ParsedCustomer
.
AddPair
(
'BillAddr_line1'
,
BillAddr
.
GetValue
(
'Line1'
,
''
));
ParsedCustomer
.
AddPair
(
'BillAddr_City'
,
BillAddr
.
GetValue
(
'City'
,
''
));
ParsedCustomer
.
AddPair
(
'BillAddr_State'
,
BillAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
));
ParsedCustomer
.
AddPair
(
'BillAddr_Zip'
,
BillAddr
.
GetValue
(
'PostalCode'
,
''
));
ParsedCustomer
.
AddPair
(
'BillAddr'
,
BillAddr
.
GetValue
(
'Line1'
,
''
)
+
', '
+
BillAddr
.
GetValue
(
'City'
,
''
)
+
', '
+
BillAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
)
+
' '
+
BillAddr
.
GetValue
(
'PostalCode'
,
''
)
);
end
;
except
ParsedCustomer
.
Free
;
raise
;
end
;
end
;
LoadJSONArray
(
ModifiedList
);
LoadJSONArray
(
CustomerList
);
restClient
.
Free
;
restRequest
.
Free
;
...
...
@@ -326,6 +408,8 @@ procedure TfQB.FormCreate(Sender: TObject);
var
iniFile
:
TIniFile
;
begin
inherited
;
ordersDB
:=
TApiDatabase
.
Create
(
nil
);
iniFile
:=
TIniFile
.
Create
(
ExtractFilePath
(
Application
.
ExeName
)
+
'kgOrdersServer.ini'
);
Client
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'ClientID'
,
''
);
Secret
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'ClientSecret'
,
''
);
...
...
@@ -333,6 +417,12 @@ begin
RefreshToken
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'RefreshToken'
,
''
);
end
;
procedure
TfQB
.
FormDestroy
(
Sender
:
TObject
);
begin
ordersDB
.
Free
;
inherited
;
end
;
function
TfQB
.
RefreshAccessToken
:
string
;
// Refresh Token changes so make sure to save refresh token.
var
...
...
kgOrdersServer/kgOrdersServer.ini
View file @
95296f5f
...
...
@@ -2,7 +2,7 @@
MemoLogLevel
=
3
FileLogLevel
=
5
webClientVersion
=
0.9.2
LogFileNum
=
596
LogFileNum
=
621
[Database]
Server
=
192.168.159.131
...
...
@@ -17,6 +17,6 @@ Password=emsys01
CompanyID
=
9341454272655710
ClientID
=
ABgO14uvjh8XqLud7spQ8lkb98AUpcdA7HbyMJfCAtl65sQ5yy
ClientSecret
=
bQ06TRemHeAGFzVHRaTUvUoBU9jpU9itK6MOMgqN
RefreshToken
=
RT1-
208-H0-17567544350xgx6z1cqtacxchwp91p
AccessToken
=
eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2IiwieC5vcmciOiJIMCJ9..
7j1C_IbyEFT7N_dCC4YUMg.PgS3pkfr9Ze_N2m-D-GlXCZOHoAcCyN0Oym1nJpozlVqoMmEr340Oc8Qr3mcvWVyv1OxWx0kiVJMPWZ-gHazOP80IypMLc7e9HZPYm0qYbwex_9JGIfZq0vQX1Y6oJQSTM9h-v_oGIN_5b7hFMLzVPCPLwXMcimXLqaXEN9b-AGX2La-FeahLDz6MmrGL-HoYB-4ZintdaxWE4NYXEg71HgecTrfkxbNlJQBziGQgnXVPmwuyqI0gJKGIL1w3X651nGcZMB_nuY0y__BPH2zOnzuibqGylOwr9ZuFXobkjgvtqllRE0JgMbCD28FArwnA_-BGsz_g6fueCvsI3ewd61tmTLyvW1IWoOoowKd5bicHQPal34KO16wORmM5_RzjCO522w_n94m9gK6JYQbS3Kn-8omnDIBZjwSBnz4mCXm-CTpexrLJRgk5h1f-lx3Ow1d9A_91qriqwNkKln35nUO4ivNvmIkDvqYMaPVXAs.LVOKao4eo0CZQ8sSO9nHoA
LastRefresh
=
5/2
3/2025 3:20:36 P
M
RefreshToken
=
RT1-
113-H0-1757255538seyqgsf5e04vo9schkoa
AccessToken
=
eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2IiwieC5vcmciOiJIMCJ9..
Cqnj0xScf85NYKa6g4lanA.LN1AIU3ZlnDDbIMt-J4vl8V_gvcTfynSjGKYsmbhbfBJovq5IfZU4dHt6cqDAwUfnfOm42l-OpbwN9hWrZvUGlVx8x_3MA-vdtxIOByp7neq5vL2t4XcR5svPKIkX-CqlTsTb2ylBARiXehgk3tVHBysbHcnp0Ka0Ic_Waj64wQMYvE3Z-D19gCu-Xn9WFQwDICn8HSgJmHL2huLvRX-OrcxH6uERzLcQqRLsgT7fx9j68UWDW-KL_KRnzE43ieXlxXCwiCDnaF39Ei5iPHstnh19lGMgo1Z1mlF6tVZ9-8Z1prZutpiX8rzaPzS7Wdqo8pKtYaUqQZP6AGa6ZCqWR2BlF3y-R_FtheERNpafRiXWIDW68jOOrgp8QXc1uKA0sxDMjiLE7Bd0t9QAsIzln-0WiWIXFSlLGLimMd2oxxLoR7fpQvgB851I50b4S3V-c891WA8bHfuzScmjVwp40JxofhviFXwAevLNzRYvGkvIyz4oS9d6U6K_ZWKDB3iYxEgJzkFFwnfuPybWX7iNHwnmvFfAXz61jdaL9KRJM-lCChGuaQuv8_df9z_az_sbUtXJw2I8ivEppmDEQVxv49ZwzJlb6bFbqtnhy6ILO7_ecx3G1d4Utg-BrtgvzsR.oFJV6VBShL1-cERGZEqqkw
LastRefresh
=
5/2
8/2025 10:46:30 A
M
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