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
151f60b4
Commit
151f60b4
authored
Mar 27, 2026
by
Cam Hayes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Redesigned how GetQBCustomers worked
parent
4700fcf0
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
651 additions
and
420 deletions
+651
-420
Utils.pas
kgOrdersClient/Utils.pas
+0
-2
View.Customer.Add.dfm
kgOrdersClient/View.Customer.Add.dfm
+24
-32
View.Customer.Add.html
kgOrdersClient/View.Customer.Add.html
+6
-3
View.Customer.Add.pas
kgOrdersClient/View.Customer.Add.pas
+61
-24
View.Customer.Select.dfm
kgOrdersClient/View.Customer.Select.dfm
+24
-59
View.Customer.Select.pas
kgOrdersClient/View.Customer.Select.pas
+8
-87
View.Customers.dfm
kgOrdersClient/View.Customers.dfm
+12
-16
View.Main.dfm
kgOrdersClient/View.Main.dfm
+25
-25
View.Main.pas
kgOrdersClient/View.Main.pas
+3
-3
View.QBInfo.dfm
kgOrdersClient/View.QBInfo.dfm
+12
-12
View.QBInfo.pas
kgOrdersClient/View.QBInfo.pas
+26
-15
TMSWebRunner.ini
kgOrdersClient/Win64/Debug/TMSWebRunner.ini
+16
-0
Api.Database.dfm
kgOrdersServer/Source/Api.Database.dfm
+2
-17
Api.Database.pas
kgOrdersServer/Source/Api.Database.pas
+1
-11
Lookup.Service.pas
kgOrdersServer/Source/Lookup.Service.pas
+39
-5
Lookup.ServiceImpl.pas
kgOrdersServer/Source/Lookup.ServiceImpl.pas
+341
-85
qbAPI.dfm
kgOrdersServer/Source/qbAPI.dfm
+33
-15
kgOrdersServer - Copy.ini
kgOrdersServer/bin/kgOrdersServer - Copy.ini
+18
-9
No files found.
kgOrdersClient/Utils.pas
View file @
151f60b4
...
@@ -89,7 +89,6 @@ begin
...
@@ -89,7 +89,6 @@ begin
end
;
end
;
end
;
end
;
procedure
ShowErrorModal
(
msg
:
string
);
procedure
ShowErrorModal
(
msg
:
string
);
begin
begin
asm
asm
...
@@ -117,7 +116,6 @@ begin
...
@@ -117,7 +116,6 @@ begin
end
;
end
;
end
;
end
;
procedure
ShowNotificationModal
(
msg
:
string
);
procedure
ShowNotificationModal
(
msg
:
string
);
begin
begin
asm
asm
...
...
kgOrdersClient/View.Customer.Add.dfm
View file @
151f60b4
...
@@ -221,7 +221,7 @@ object FViewAddCustomer: TFViewAddCustomer
...
@@ -221,7 +221,7 @@ object FViewAddCustomer: TFViewAddCustomer
Title = 'ID'
Title = 'ID'
end
end
item
item
DataField = '
ADDRESS
'
DataField = '
ship_block
'
Title = 'Address'
Title = 'Address'
end>
end>
DataSource = wdsShipTo
DataSource = wdsShipTo
...
@@ -399,22 +399,6 @@ object FViewAddCustomer: TFViewAddCustomer
...
@@ -399,22 +399,6 @@ object FViewAddCustomer: TFViewAddCustomer
HeightPercent = 100.000000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
end
object wdblcbRep: TWebDBLookupComboBox
Left = 19
Top = 216
Width = 145
Height = 22
ElementID = 'wdblcbrep'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = wdblcbRepChange
OnEnter = wdblcbRepChange
DataField = 'REP_USER_ID'
DataSource = WebDataSource1
KeyField = 'userID'
ListField = 'representative'
ListSource = wdsUsers
end
object btnLink: TWebButton
object btnLink: TWebButton
Left = 19
Left = 19
Top = 566
Top = 566
...
@@ -441,6 +425,22 @@ object FViewAddCustomer: TFViewAddCustomer
...
@@ -441,6 +425,22 @@ object FViewAddCustomer: TFViewAddCustomer
WidthPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnUpdateClick
OnClick = btnUpdateClick
end
end
object edtRepUser: TWebDBEdit
Left = 19
Top = 216
Width = 121
Height = 22
ChildOrder = 12
ElementClassName = 'form-control'
ElementID = 'edtrepuser'
ElementFont = efCSS
Enabled = False
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'QB_TYPE'
DataSource = WebDataSource1
end
object XDataWebClient1: TXDataWebClient
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
Connection = DMConnection.ApiConnection
Left = 454
Left = 454
...
@@ -495,8 +495,8 @@ object FViewAddCustomer: TFViewAddCustomer
...
@@ -495,8 +495,8 @@ object FViewAddCustomer: TFViewAddCustomer
object XDataWebDataSet1CUSTOMER_ID: TIntegerField
object XDataWebDataSet1CUSTOMER_ID: TIntegerField
FieldName = 'CUSTOMER_ID'
FieldName = 'CUSTOMER_ID'
end
end
object XDataWebDataSet1
REP_USER_ID
: TStringField
object XDataWebDataSet1
QB_TYPE
: TStringField
FieldName = '
REP_USER_ID
'
FieldName = '
QB_TYPE
'
end
end
end
end
object wdsShipTo: TWebDataSource
object wdsShipTo: TWebDataSource
...
@@ -508,9 +508,6 @@ object FViewAddCustomer: TFViewAddCustomer
...
@@ -508,9 +508,6 @@ object FViewAddCustomer: TFViewAddCustomer
object xdwdsShipTo: TXDataWebDataSet
object xdwdsShipTo: TXDataWebDataSet
Left = 698
Left = 698
Top = 44
Top = 44
object xdwdsShipToADDRESS: TStringField
FieldName = 'ADDRESS'
end
object xdwdsShipToship_id: TStringField
object xdwdsShipToship_id: TStringField
FieldName = 'ship_id'
FieldName = 'ship_id'
end
end
...
@@ -529,6 +526,9 @@ object FViewAddCustomer: TFViewAddCustomer
...
@@ -529,6 +526,9 @@ object FViewAddCustomer: TFViewAddCustomer
object xdwdsShipTocontact: TStringField
object xdwdsShipTocontact: TStringField
FieldName = 'contact'
FieldName = 'contact'
end
end
object xdwdsShipToship_block: TStringField
FieldName = 'ship_block'
end
end
end
object tmrReturn: TWebTimer
object tmrReturn: TWebTimer
Enabled = False
Enabled = False
...
@@ -545,16 +545,8 @@ object FViewAddCustomer: TFViewAddCustomer
...
@@ -545,16 +545,8 @@ object FViewAddCustomer: TFViewAddCustomer
object xdwdsUsers: TXDataWebDataSet
object xdwdsUsers: TXDataWebDataSet
Left = 776
Left = 776
Top = 54
Top = 54
object xdwdsUsersuserID: TStringField
object xdwdsUsersQBID: TStringField
FieldName = 'userID'
FieldName = 'QBID'
end
object xdwdsUsersfull_name: TStringField
FieldName = 'full_name'
Size = 0
end
object xdwdsUsersrepresentative: TStringField
FieldName = 'representative'
Size = 0
end
end
end
end
end
end
kgOrdersClient/View.Customer.Add.html
View file @
151f60b4
...
@@ -57,12 +57,15 @@
...
@@ -57,12 +57,15 @@
<label
for=
"wdbe_first_name"
style=
"font-weight: 700; font-size: 15px;"
class=
"form-label mt-2"
>
Customer ID:
</label>
<label
for=
"wdbe_first_name"
style=
"font-weight: 700; font-size: 15px;"
class=
"form-label mt-2"
>
Customer ID:
</label>
<input
id=
"edtcompanyaccountname"
type=
"text"
class=
"form-control"
style=
"width: 150px"
required
/>
<input
id=
"edtcompanyaccountname"
type=
"text"
class=
"form-control"
style=
"width: 150px"
required
/>
<div
class=
"invalid-feedback"
id=
"shortnamefeedback"
style=
"font-size: 15px;"
>
<div
class=
"invalid-feedback"
id=
"shortnamefeedback"
style=
"font-size: 15px;"
>
Please Provide a Company
Account Name
.
Please Provide a Company
ID
.
</div>
</div>
</div>
</div>
<div
class=
"col-auto"
>
<div
class=
"col-auto"
>
<label
for=
"wdbe_first_name"
style=
"font-weight: 700; font-size: 15px;"
class=
"form-label mt-2"
>
Representative:
</label>
<label
for=
"wdbe_first_name"
style=
"font-weight: 700; font-size: 15px;"
class=
"form-label mt-2"
>
Territory:
</label>
<select
id=
"wdblcbrep"
class=
'form-select'
></select>
<input
id=
"edtrepuser"
type=
"text"
class=
"form-control"
style=
"width: 150px"
/>
<div
class=
"invalid-feedback"
id=
"territorywarning"
style=
"font-size: 15px;"
>
Territory not found in kgOrders
</div>
</div>
</div>
</div>
</div>
<h4
class=
"custom-h4 mt-3"
>
Billing Information
</h4>
<h4
class=
"custom-h4 mt-3"
>
Billing Information
</h4>
...
...
kgOrdersClient/View.Customer.Add.pas
View file @
151f60b4
...
@@ -50,7 +50,6 @@ type
...
@@ -50,7 +50,6 @@ type
edtShippingContact
:
TWebEdit
;
edtShippingContact
:
TWebEdit
;
edtShippingZip
:
TWebEdit
;
edtShippingZip
:
TWebEdit
;
edtShippingCity
:
TWebEdit
;
edtShippingCity
:
TWebEdit
;
xdwdsShipToADDRESS
:
TStringField
;
xdwdsShipToship_id
:
TStringField
;
xdwdsShipToship_id
:
TStringField
;
xdwdsShipToshipping_address
:
TStringField
;
xdwdsShipToshipping_address
:
TStringField
;
xdwdsShipTocity
:
TStringField
;
xdwdsShipTocity
:
TStringField
;
...
@@ -69,15 +68,14 @@ type
...
@@ -69,15 +68,14 @@ type
edtFirstLine
:
TWebEdit
;
edtFirstLine
:
TWebEdit
;
wdsUsers
:
TWebDataSource
;
wdsUsers
:
TWebDataSource
;
xdwdsUsers
:
TXDataWebDataSet
;
xdwdsUsers
:
TXDataWebDataSet
;
wdblcbRep
:
TWebDBLookupComboBox
;
xdwdsUsersuserID
:
TStringField
;
XDataWebDataSet1REP_USER_ID
:
TStringField
;
xdwdsUsersfull_name
:
TStringField
;
lblFormState
:
TWebLabel
;
lblFormState
:
TWebLabel
;
[
async
]
[
async
]
xdwdsUsersrepresentative
:
TStringField
;
btnLink
:
TWebButton
;
btnLink
:
TWebButton
;
btnUpdate
:
TWebButton
;
procedure
btnSaveClick
(
Sender
:
TObject
);
btnUpdate
:
TWebButton
;
edtRepUser
:
TWebDBEdit
;
xdwdsUsersQBID
:
TStringField
;
xdwdsShipToship_block
:
TStringField
;
XDataWebDataSet1QB_TYPE
:
TStringField
;
procedure
btnSaveClick
(
Sender
:
TObject
);
procedure
btnCancelClick
(
Sender
:
TObject
);
procedure
btnCancelClick
(
Sender
:
TObject
);
procedure
btnCloseClick
(
Sender
:
TObject
);
procedure
btnCloseClick
(
Sender
:
TObject
);
procedure
btnEditClick
(
Sender
:
TObject
);
procedure
btnEditClick
(
Sender
:
TObject
);
...
@@ -114,12 +112,12 @@ type
...
@@ -114,12 +112,12 @@ type
[
async
]
procedure
InitializeForm
;
[
async
]
procedure
InitializeForm
;
var
var
customerID
:
string
;
customerID
:
string
;
qbCustJSON
:
string
;
QB_ID
,
qbCustJSON
:
string
;
mode
:
string
;
mode
:
string
;
shipmode
:
string
;
shipmode
:
string
;
public
public
{ Public declarations }
{ Public declarations }
class
function
CreateForm
(
AElementID
,
custID
,
cust
JSON
:
string
):
TWebForm
;
class
function
CreateForm
(
AElementID
,
custID
,
cust
QB_ID
:
string
):
TWebForm
;
end
;
end
;
var
var
...
@@ -132,7 +130,7 @@ implementation
...
@@ -132,7 +130,7 @@ implementation
uses
View
.
Main
,
View
.
Customers
,
View
.
Customer
.
Select
,
Utils
;
uses
View
.
Main
,
View
.
Customers
,
View
.
Customer
.
Select
,
Utils
;
class
function
TFViewAddCustomer
.
CreateForm
(
AElementID
,
custID
,
cust
JSON
:
string
):
TWebForm
;
class
function
TFViewAddCustomer
.
CreateForm
(
AElementID
,
custID
,
cust
QB_ID
:
string
):
TWebForm
;
begin
begin
Application
.
CreateForm
(
TFViewAddCustomer
,
AElementID
,
Result
,
Application
.
CreateForm
(
TFViewAddCustomer
,
AElementID
,
Result
,
procedure
(
AForm
:
TObject
)
procedure
(
AForm
:
TObject
)
...
@@ -140,7 +138,7 @@ begin
...
@@ -140,7 +138,7 @@ begin
with
TFViewAddCustomer
(
AForm
)
do
with
TFViewAddCustomer
(
AForm
)
do
begin
begin
customerID
:=
custID
;
customerID
:=
custID
;
qbCustJSON
:=
custJSON
;
QB_ID
:=
custQB_ID
;
InitializeForm
;
InitializeForm
;
end
;
end
;
...
@@ -153,12 +151,22 @@ end;
...
@@ -153,12 +151,22 @@ end;
var
var
JSONObj
,
obj
:
TJSONObject
;
JSONObj
,
obj
:
TJSONObject
;
arr
:
TJSONArray
;
arr
:
TJSONArray
;
xdcResponse
:
TXDataClientResponse
;
RepUsers
,
QBCustomer
:
TJSObject
;
JSONStr
:
string
;
input
:
TJSHTMLInputElement
;
begin
begin
if
customerID
=
''
then
if
customerID
=
''
then
begin
begin
mode
:=
'ADD'
;
mode
:=
'ADD'
;
JSONObj
:=
TJSONObject
.
ParseJSONValue
(
qbCustJSON
)
as
TJSONObject
;
try
try
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetQBCustomer'
,
[
QB_ID
]));
qbCustJSON
:=
string
(
TJSJSON
.
stringify
(
xdcResponse
.
Result
));
console
.
log
(
qbCustJSON
);
JSONObj
:=
TJSONObject
.
ParseJSONValue
(
qbCustJSON
)
as
TJSONObject
;
//JSONObj := TJSONObject.ParseJSONValue(qbCustJSON) as TJSONObject;
XDataWebDataSet1
.
Open
;
XDataWebDataSet1
.
Open
;
XDataWebDataSet1
.
Append
;
XDataWebDataSet1
.
Append
;
...
@@ -169,21 +177,44 @@ begin
...
@@ -169,21 +177,44 @@ begin
XDataWebDataSet1
.
FieldByName
(
'BILL_STATE'
).
AsString
:=
JSONObj
.
GetValue
(
'BILL_STATE'
).
Value
;
XDataWebDataSet1
.
FieldByName
(
'BILL_STATE'
).
AsString
:=
JSONObj
.
GetValue
(
'BILL_STATE'
).
Value
;
XDataWebDataSet1
.
FieldByName
(
'BILL_ZIP'
).
AsString
:=
JSONObj
.
GetValue
(
'BILL_ZIP'
).
Value
;
XDataWebDataSet1
.
FieldByName
(
'BILL_ZIP'
).
AsString
:=
JSONObj
.
GetValue
(
'BILL_ZIP'
).
Value
;
XDataWebDataSet1
.
FieldByName
(
'BILL_CONTACT'
).
AsString
:=
JSONObj
.
GetValue
(
'BILL_CONTACT'
).
Value
;
XDataWebDataSet1
.
FieldByName
(
'BILL_CONTACT'
).
AsString
:=
JSONObj
.
GetValue
(
'BILL_CONTACT'
).
Value
;
XDataWebDataSet1QB_TYPE
.
AsString
:=
JSONObj
.
GetValue
(
'RepUser'
).
Value
;
//XDataWebDataSet1.FieldByName('BILL_ADDRESS_BLOCK').AsString := JSONObj.GetValue('BILL_ADDRESS_BLOCK').Value;
//XDataWebDataSet1.FieldByName('BILL_ADDRESS_BLOCK').AsString := JSONObj.GetValue('BILL_ADDRESS_BLOCK').Value;
XDataWebDataSet1
.
Post
;
XDataWebDataSet1
.
Post
;
xdwdsShipTo
.
Open
;
xdwdsShipTo
.
Open
;
xdwdsShipTo
.
Append
;
xdwdsShipTo
.
Append
;
xdwdsShipTo
.
FieldByName
(
'shipping_address'
).
AsString
:=
JSONObj
.
GetValue
(
'
address'
).
Value
;
xdwdsShipTo
.
FieldByName
(
'shipping_address'
).
AsString
:=
JSONObj
.
GetValue
(
'shipping_
address'
).
Value
;
xdwdsShipTo
.
FieldByName
(
'city'
).
AsString
:=
JSONObj
.
GetValue
(
'city'
).
Value
;
xdwdsShipTo
.
FieldByName
(
'city'
).
AsString
:=
JSONObj
.
GetValue
(
'city'
).
Value
;
xdwdsShipTo
.
FieldByName
(
'state'
).
AsString
:=
JSONObj
.
GetValue
(
'state'
).
Value
;
xdwdsShipTo
.
FieldByName
(
'state'
).
AsString
:=
JSONObj
.
GetValue
(
'state'
).
Value
;
xdwdsShipTo
.
FieldByName
(
'zip'
).
AsString
:=
JSONObj
.
GetValue
(
'zip'
).
Value
;
xdwdsShipTo
.
FieldByName
(
'zip'
).
AsString
:=
JSONObj
.
GetValue
(
'zip'
).
Value
;
xdwdsShipTo
.
FieldByName
(
'ADDRESS
'
).
AsString
:=
JSONObj
.
GetValue
(
'ship_block'
).
Value
;
xdwdsShipTo
.
FieldByName
(
'ship_block
'
).
AsString
:=
JSONObj
.
GetValue
(
'ship_block'
).
Value
;
xdwdsShipTo
.
FieldByName
(
'contact'
).
AsString
:=
JSONObj
.
GetValue
(
'contact'
).
Value
;
xdwdsShipTo
.
FieldByName
(
'contact'
).
AsString
:=
JSONObj
.
GetValue
(
'contact'
).
Value
;
xdwdsShipTo
.
Post
;
xdwdsShipTo
.
Post
;
xdwdsShipTo
.
First
;
xdwdsShipTo
.
First
;
EditMode
();
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetRepUsers'
,
[]));
RepUsers
:=
TJSObject
(
xdcResponse
.
Result
);
xdwdsUsers
.
Close
;
xdwdsUsers
.
SetJSONData
(
RepUsers
[
'value'
]);
xdwdsUsers
.
Open
;
CustomerID
:=
''
;
input
:=
TJSHTMLInputElement
(
document
.
getElementById
(
'edtrepuser'
));
if
not
xdwdsUsers
.
Locate
(
'QBID'
,
XDataWebDataSet1QB_TYPE
.
AsString
,
[])
then
begin
input
.
classList
.
add
(
'changed-field'
);
input
.
classList
.
add
(
'is-invalid'
);
end
else
input
.
classList
.
remove
(
'changed-field'
);
EditMode
();
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
E
.
ErrorResult
.
ErrorMessage
);
end
;
finally
finally
JSONObj
.
Free
;
JSONObj
.
Free
;
end
;
end
;
...
@@ -405,7 +436,7 @@ begin
...
@@ -405,7 +436,7 @@ begin
edtShippingState
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'state'
).
AsString
;
edtShippingState
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'state'
).
AsString
;
edtShippingZip
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'zip'
).
AsString
;
edtShippingZip
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'zip'
).
AsString
;
edtShippingContact
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'contact'
).
AsString
;
edtShippingContact
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'contact'
).
AsString
;
memoShipBlock
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'
ADDRESS
'
).
AsString
;
memoShipBlock
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'
ship_block
'
).
AsString
;
if
memoShipBlock
.
Lines
.
Count
>
0
then
if
memoShipBlock
.
Lines
.
Count
>
0
then
edtFirstLine
.
Text
:=
memoShipBlock
.
Lines
[
0
]
edtFirstLine
.
Text
:=
memoShipBlock
.
Lines
[
0
]
...
@@ -507,6 +538,7 @@ var
...
@@ -507,6 +538,7 @@ var
Response
:
TXDataClientResponse
;
Response
:
TXDataClientResponse
;
notification
:
TJSObject
;
notification
:
TJSObject
;
input
:
TJSHTMLElement
;
input
:
TJSHTMLElement
;
jsonObj
:
TJSONObject
;
msg
:
string
;
msg
:
string
;
BILL_ADDRESS_BLOCK
:
string
;
BILL_ADDRESS_BLOCK
:
string
;
begin
begin
...
@@ -547,17 +579,19 @@ begin
...
@@ -547,17 +579,19 @@ begin
Response
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.AddCustomer'
,
Response
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.AddCustomer'
,
[
customerJSON
.
ToJSON
]));
[
customerJSON
.
ToJSON
]));
notification
:=
TJSObject
(
Response
.
Result
);
end
end
else
else
begin
begin
JSONObj
:=
TJSONObject
.
ParseJSONValue
(
qbCustJSON
)
as
TJSONObject
;
JSONObj
.
AddPair
(
'SHORT_NAME'
,
XDataWebDataSet1SHORT_NAME
.
AsString
);
Response
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.ImportQBCustomer'
,
Response
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.ImportQBCustomer'
,
[
qbCustJSON
]));
[
JSONObj
.
ToString
]));
mode
:=
'EDIT'
;
XDataWebDataSet1
.
Edit
;
XDataWebDataSet1
.
Edit
;
notification
:=
TJSObject
(
Response
.
Result
);
XDataWebDataSet1Customer_ID
.
AsInteger
:=
integer
(
notification
[
'CustomerID'
]);
XDataWebDataSet1Customer_ID
.
AsInteger
:=
integer
(
notification
[
'CustomerID'
]);
XDataWebDataSet1
.
Post
;
XDataWebDataSet1
.
Post
;
end
;
end
;
notification
:=
TJSObject
(
Response
.
Result
);
msg
:=
string
(
notification
[
'status'
]);
msg
:=
string
(
notification
[
'status'
]);
if
CustomerID
=
''
then
if
CustomerID
=
''
then
CustomerID
:=
string
(
notification
[
'CustomerID'
]);
CustomerID
:=
string
(
notification
[
'CustomerID'
]);
...
@@ -579,6 +613,7 @@ begin
...
@@ -579,6 +613,7 @@ begin
TJSHTMLInputElement
(
document
.
getElementById
(
'edtbillingcity'
)).
classList
.
remove
(
'changed-field'
);
TJSHTMLInputElement
(
document
.
getElementById
(
'edtbillingcity'
)).
classList
.
remove
(
'changed-field'
);
TJSHTMLInputElement
(
document
.
getElementById
(
'edtbillingstate'
)).
classList
.
remove
(
'changed-field'
);
TJSHTMLInputElement
(
document
.
getElementById
(
'edtbillingstate'
)).
classList
.
remove
(
'changed-field'
);
TJSHTMLInputElement
(
document
.
getElementById
(
'edtbillingzip'
)).
classList
.
remove
(
'changed-field'
);
TJSHTMLInputElement
(
document
.
getElementById
(
'edtbillingzip'
)).
classList
.
remove
(
'changed-field'
);
mode
:=
'EDIT'
;
end
;
end
;
end
;
end
;
...
@@ -592,9 +627,14 @@ begin
...
@@ -592,9 +627,14 @@ begin
end
;
end
;
procedure
TFViewAddCustomer
.
Save
;
procedure
TFViewAddCustomer
.
Save
;
var
input
:
TJSHTMLInputElement
;
begin
begin
await
(
sendCustomerToServer
());
await
(
sendCustomerToServer
());
await
(
GetCustomer
());
await
(
GetCustomer
());
input
:=
TJSHTMLInputElement
(
document
.
getElementById
(
'edtrepuser'
));
input
.
classList
.
remove
(
'changed-field'
);
input
.
classList
.
remove
(
'is-invalid'
);
ViewMode
();
ViewMode
();
end
;
end
;
...
@@ -691,13 +731,13 @@ begin
...
@@ -691,13 +731,13 @@ begin
xdwdsShipTo
.
Open
;
xdwdsShipTo
.
Open
;
memoAddressBlock
.
Text
:=
string
(
customer
[
'staff_fields_invoice_to'
]);
memoAddressBlock
.
Text
:=
string
(
customer
[
'staff_fields_invoice_to'
]);
console
.
log
(
customer
[
'SHIPPING_ADDRESS_LIST'
]);
edtShippingAddress
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'shipping_address'
).
AsString
;
edtShippingAddress
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'shipping_address'
).
AsString
;
edtShippingCity
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'city'
).
AsString
;
edtShippingCity
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'city'
).
AsString
;
edtShippingState
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'state'
).
AsString
;
edtShippingState
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'state'
).
AsString
;
edtShippingZip
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'zip'
).
AsString
;
edtShippingZip
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'zip'
).
AsString
;
edtShippingContact
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'contact'
).
AsString
;
edtShippingContact
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'contact'
).
AsString
;
memoShipBlock
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'
ADDRESS
'
).
AsString
;
memoShipBlock
.
Text
:=
xdwdsShipTo
.
FieldByName
(
'
ship_block
'
).
AsString
;
if
memoShipBlock
.
Lines
.
Count
>
0
then
if
memoShipBlock
.
Lines
.
Count
>
0
then
edtFirstLine
.
Text
:=
memoShipBlock
.
Lines
[
0
]
edtFirstLine
.
Text
:=
memoShipBlock
.
Lines
[
0
]
else
else
...
@@ -914,8 +954,6 @@ begin
...
@@ -914,8 +954,6 @@ begin
edtShippingContact
.
Enabled
:=
true
;
edtShippingContact
.
Enabled
:=
true
;
edtFirstLine
.
Enabled
:=
true
;
edtFirstLine
.
Enabled
:=
true
;
wdblcbRep
.
Enabled
:=
false
;
lblFormState
.
Caption
:=
'Edit Address'
;
lblFormState
.
Caption
:=
'Edit Address'
;
lblFormState
.
ElementHandle
.
classList
.
remove
(
'text-danger'
);
lblFormState
.
ElementHandle
.
classList
.
remove
(
'text-danger'
);
lblFormState
.
ElementHandle
.
classList
.
add
(
'text-success'
);
lblFormState
.
ElementHandle
.
classList
.
add
(
'text-success'
);
...
@@ -949,7 +987,6 @@ begin
...
@@ -949,7 +987,6 @@ begin
btnShipSave
.
Enabled
:=
false
;
btnShipSave
.
Enabled
:=
false
;
btnShipCancel
.
Enabled
:=
false
;
btnShipCancel
.
Enabled
:=
false
;
wdblcbRep
.
Enabled
:=
true
;
lblFormState
.
Caption
:=
'View Mode'
;
lblFormState
.
Caption
:=
'View Mode'
;
lblFormState
.
ElementHandle
.
classList
.
remove
(
'text-success'
);
lblFormState
.
ElementHandle
.
classList
.
remove
(
'text-success'
);
...
...
kgOrdersClient/View.Customer.Select.dfm
View file @
151f60b4
...
@@ -9,8 +9,8 @@ object FSelectCustomer: TFSelectCustomer
...
@@ -9,8 +9,8 @@ object FSelectCustomer: TFSelectCustomer
Width = 95
Width = 95
Height = 15
Height = 15
Caption = 'Search Customers'
Caption = 'Search Customers'
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
end
end
object WebLabel2: TWebLabel
object WebLabel2: TWebLabel
Left = 279
Left = 279
...
@@ -18,8 +18,8 @@ object FSelectCustomer: TFSelectCustomer
...
@@ -18,8 +18,8 @@ object FSelectCustomer: TFSelectCustomer
Width = 134
Width = 134
Height = 15
Height = 15
Caption = 'Selected Customer Name'
Caption = 'Selected Customer Name'
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
end
end
object WebLabel3: TWebLabel
object WebLabel3: TWebLabel
Left = 131
Left = 131
...
@@ -27,8 +27,8 @@ object FSelectCustomer: TFSelectCustomer
...
@@ -27,8 +27,8 @@ object FSelectCustomer: TFSelectCustomer
Width = 113
Width = 113
Height = 15
Height = 15
Caption = 'Selected Customer ID'
Caption = 'Selected Customer ID'
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
end
end
object edtSearch: TWebEdit
object edtSearch: TWebEdit
Left = 4
Left = 4
...
@@ -36,8 +36,8 @@ object FSelectCustomer: TFSelectCustomer
...
@@ -36,8 +36,8 @@ object FSelectCustomer: TFSelectCustomer
Width = 121
Width = 121
Height = 22
Height = 22
ChildOrder = 2
ChildOrder = 2
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
OnChange = edtSearchChange
OnChange = edtSearchChange
end
end
object edtName: TWebEdit
object edtName: TWebEdit
...
@@ -47,8 +47,8 @@ object FSelectCustomer: TFSelectCustomer
...
@@ -47,8 +47,8 @@ object FSelectCustomer: TFSelectCustomer
Height = 22
Height = 22
ChildOrder = 1
ChildOrder = 1
Enabled = False
Enabled = False
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
end
end
object TMSFNCGrid1: TTMSFNCGrid
object TMSFNCGrid1: TTMSFNCGrid
Left = 0
Left = 0
...
@@ -59,7 +59,7 @@ object FSelectCustomer: TFSelectCustomer
...
@@ -59,7 +59,7 @@ object FSelectCustomer: TFSelectCustomer
ParentDoubleBuffered = False
ParentDoubleBuffered = False
DoubleBuffered = True
DoubleBuffered = True
TabOrder = 2
TabOrder = 2
DefaultRowHeight = 40.00000000000000000
0
DefaultRowHeight = 40.00000000000000000
FixedColumns = 0
FixedColumns = 0
ColumnCount = 4
ColumnCount = 4
Options.Bands.Enabled = True
Options.Bands.Enabled = True
...
@@ -85,7 +85,7 @@ object FSelectCustomer: TFSelectCustomer
...
@@ -85,7 +85,7 @@ object FSelectCustomer: TFSelectCustomer
Font.Name = 'Segoe UI'
Font.Name = 'Segoe UI'
Font.Style = []
Font.Style = []
ID = ''
ID = ''
Width = 90.00000000000000000
0
Width = 90.00000000000000000
end
end
item
item
BorderWidth = 1
BorderWidth = 1
...
@@ -100,7 +100,7 @@ object FSelectCustomer: TFSelectCustomer
...
@@ -100,7 +100,7 @@ object FSelectCustomer: TFSelectCustomer
Font.Name = 'Segoe UI'
Font.Name = 'Segoe UI'
Font.Style = []
Font.Style = []
ID = ''
ID = ''
Width = 150.00000000000000000
0
Width = 150.00000000000000000
end
end
item
item
BorderWidth = 1
BorderWidth = 1
...
@@ -115,7 +115,7 @@ object FSelectCustomer: TFSelectCustomer
...
@@ -115,7 +115,7 @@ object FSelectCustomer: TFSelectCustomer
Font.Name = 'Segoe UI'
Font.Name = 'Segoe UI'
Font.Style = []
Font.Style = []
ID = ''
ID = ''
Width =
200.0
00000000000000000
Width =
400.
00000000000000000
end
end
item
item
BorderWidth = 1
BorderWidth = 1
...
@@ -130,7 +130,7 @@ object FSelectCustomer: TFSelectCustomer
...
@@ -130,7 +130,7 @@ object FSelectCustomer: TFSelectCustomer
Font.Name = 'Segoe UI'
Font.Name = 'Segoe UI'
Font.Style = []
Font.Style = []
ID = ''
ID = ''
Width =
306.0
00000000000000000
Width =
106.
00000000000000000
end
end
item
item
BorderWidth = 1
BorderWidth = 1
...
@@ -145,7 +145,7 @@ object FSelectCustomer: TFSelectCustomer
...
@@ -145,7 +145,7 @@ object FSelectCustomer: TFSelectCustomer
Font.Name = 'Segoe UI'
Font.Name = 'Segoe UI'
Font.Style = []
Font.Style = []
ID = ''
ID = ''
Width =
90.0
00000000000000000
Width =
1.
00000000000000000
end>
end>
DefaultFont.Charset = DEFAULT_CHARSET
DefaultFont.Charset = DEFAULT_CHARSET
DefaultFont.Color = clWindowText
DefaultFont.Color = clWindowText
...
@@ -206,6 +206,7 @@ object FSelectCustomer: TFSelectCustomer
...
@@ -206,6 +206,7 @@ object FSelectCustomer: TFSelectCustomer
ScrollMode = scmItemScrolling
ScrollMode = scmItemScrolling
DesignTimeSampleData = True
DesignTimeSampleData = True
OnCellClick = TMSFNCGrid1CellClick
OnCellClick = TMSFNCGrid1CellClick
ExplicitLeft = 4
end
end
object btnCancel: TWebButton
object btnCancel: TWebButton
Left = 556
Left = 556
...
@@ -214,8 +215,8 @@ object FSelectCustomer: TFSelectCustomer
...
@@ -214,8 +215,8 @@ object FSelectCustomer: TFSelectCustomer
Height = 25
Height = 25
Caption = 'Cancel'
Caption = 'Cancel'
ChildOrder = 5
ChildOrder = 5
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
OnClick = btnCancelClick
OnClick = btnCancelClick
end
end
object btnConfirm: TWebButton
object btnConfirm: TWebButton
...
@@ -225,8 +226,8 @@ object FSelectCustomer: TFSelectCustomer
...
@@ -225,8 +226,8 @@ object FSelectCustomer: TFSelectCustomer
Height = 25
Height = 25
Caption = 'Select'
Caption = 'Select'
ChildOrder = 5
ChildOrder = 5
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
OnClick = btnConfirmClick
OnClick = btnConfirmClick
end
end
object edtID: TWebEdit
object edtID: TWebEdit
...
@@ -236,8 +237,8 @@ object FSelectCustomer: TFSelectCustomer
...
@@ -236,8 +237,8 @@ object FSelectCustomer: TFSelectCustomer
Height = 22
Height = 22
ChildOrder = 1
ChildOrder = 1
Enabled = False
Enabled = False
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
end
end
object XDataWebClient1: TXDataWebClient
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
Connection = DMConnection.ApiConnection
...
@@ -257,44 +258,8 @@ object FSelectCustomer: TFSelectCustomer
...
@@ -257,44 +258,8 @@ object FSelectCustomer: TFSelectCustomer
object xdwdsCustomersId: TStringField
object xdwdsCustomersId: TStringField
FieldName = 'Id'
FieldName = 'Id'
end
end
object xdwdsCustomersPrimaryPhone: TStringField
FieldName = 'PrimaryPhone'
end
object xdwdsCustomersShipAddr: TStringField
FieldName = 'ShipAddr'
end
object xdwdsCustomersShipAddrLine1: TStringField
FieldName = 'ShipAddrLine1'
end
object xdwdsCustomersShipAddrCity: TStringField
FieldName = 'ShipAddrCity'
end
object xdwdsCustomersShipAddrState: TStringField
FieldName = 'ShipAddrState'
end
object xdwdsCustomersShipAddrZip: TStringField
FieldName = 'ShipAddrZip'
end
object xdwdsCustomersBillAddrLine1: TStringField
FieldName = 'BillAddrLine1'
end
object xdwdsCustomersBillAddrCity: TStringField
FieldName = 'BillAddrCity'
end
object xdwdsCustomersBillAddrState: TStringField
FieldName = 'BillAddrState'
end
object xdwdsCustomersBillAddrZip: TStringField
FieldName = 'BillAddrZip'
end
object xdwdsCustomersInKGOrders: TBooleanField
object xdwdsCustomersInKGOrders: TBooleanField
FieldName = 'In KGOrders'
FieldName = 'InKGOrders'
end
object xdwdsCustomersBillAddrContact: TStringField
FieldName = 'BillAddrContact'
end
object xdwdsCustomersShipAddrContact: TStringField
FieldName = 'ShipAddrContact'
end
end
end
end
object wdsCustomers: TWebDataSource
object wdsCustomers: TWebDataSource
...
...
kgOrdersClient/View.Customer.Select.pas
View file @
151f60b4
...
@@ -27,21 +27,9 @@ type
...
@@ -27,21 +27,9 @@ type
xdwdsCustomersBillAddr
:
TStringField
;
xdwdsCustomersBillAddr
:
TStringField
;
xdwdsCustomersCompanyName
:
TStringField
;
xdwdsCustomersCompanyName
:
TStringField
;
xdwdsCustomersId
:
TStringField
;
xdwdsCustomersId
:
TStringField
;
xdwdsCustomersPrimaryPhone
:
TStringField
;
xdwdsCustomersShipAddr
:
TStringField
;
xdwdsCustomersShipAddrLine1
:
TStringField
;
xdwdsCustomersShipAddrCity
:
TStringField
;
xdwdsCustomersShipAddrState
:
TStringField
;
xdwdsCustomersShipAddrZip
:
TStringField
;
xdwdsCustomersBillAddrLine1
:
TStringField
;
xdwdsCustomersBillAddrCity
:
TStringField
;
xdwdsCustomersBillAddrState
:
TStringField
;
xdwdsCustomersBillAddrZip
:
TStringField
;
WebLabel3
:
TWebLabel
;
WebLabel3
:
TWebLabel
;
edtID
:
TWebEdit
;
edtID
:
TWebEdit
;
xdwdsCustomersInKGOrders
:
TBooleanField
;
xdwdsCustomersInKGOrders
:
TBooleanField
;
xdwdsCustomersBillAddrContact
:
TStringField
;
xdwdsCustomersShipAddrContact
:
TStringField
;
procedure
WebFormCreate
(
Sender
:
TObject
);
procedure
WebFormCreate
(
Sender
:
TObject
);
procedure
WebFormShow
(
Sender
:
TObject
);
procedure
WebFormShow
(
Sender
:
TObject
);
procedure
btnConfirmClick
(
Sender
:
TObject
);
procedure
btnConfirmClick
(
Sender
:
TObject
);
...
@@ -51,7 +39,6 @@ type
...
@@ -51,7 +39,6 @@ type
private
private
{ Private declarations }
{ Private declarations }
[
Async
]
procedure
GetCustomers
();
[
Async
]
procedure
GetCustomers
();
[
Async
]
procedure
SendCustomerToServer
();
procedure
PopulateGridManually
();
procedure
PopulateGridManually
();
procedure
ApplyFilter
();
procedure
ApplyFilter
();
var
var
...
@@ -99,41 +86,13 @@ begin
...
@@ -99,41 +86,13 @@ begin
ShowToast
(
'Please Select a Customer'
,
'danger'
)
ShowToast
(
'Please Select a Customer'
,
'danger'
)
else
else
begin
begin
if
(
string
(
self
.
Caption
).
ToLower
.
Contains
(
'add'
)
and
xdwdsCustomers
.
FieldByName
(
'In
KGOrders'
).
AsBoolean
)
then
if
(
string
(
self
.
Caption
).
ToLower
.
Contains
(
'add'
)
and
xdwdsCustomers
.
FieldByName
(
'InKGOrders'
).
AsBoolean
)
then
ShowToast
(
'failure:Customer Already in Database'
)
ShowToast
(
'failure:Customer Already in Database'
)
else
else
begin
begin
if
string
(
self
.
Caption
).
ToLower
.
Contains
(
'link'
)
then
begin
confirm
:=
true
;
confirm
:=
true
;
QB_ID
:=
xdwdsCustomers
.
FieldByName
(
'Id'
).
AsString
;
QB_ID
:=
xdwdsCustomers
.
FieldByName
(
'Id'
).
AsString
;
end
FViewMain
.
ViewAddCustomer
(
''
,
QB_ID
);
else
begin
xdwdsCustomers
.
Locate
(
'Id'
,
edtID
.
Text
,
[]);
CustomerJSON
:=
TJSONObject
.
Create
;
CustomerJSON
.
AddPair
(
'NAME'
,
xdwdsCustomers
.
FieldByName
(
'CompanyName'
).
AsString
);
CustomerJSON
.
AddPair
(
'QB_LIST_ID'
,
xdwdsCustomers
.
FieldByName
(
'Id'
).
AsString
);
CustomerJSON
.
AddPair
(
'PHONE'
,
xdwdsCustomers
.
FieldByName
(
'PrimaryPhone'
).
AsString
);
CustomerJSON
.
AddPair
(
'BILL_ADDRESS'
,
xdwdsCustomers
.
FieldByName
(
'BillAddrLine1'
).
AsString
);
CustomerJSON
.
AddPair
(
'BILL_CITY'
,
xdwdsCustomers
.
FieldByName
(
'BillAddrCity'
).
AsString
);
CustomerJSON
.
AddPair
(
'BILL_STATE'
,
xdwdsCustomers
.
FieldByName
(
'BillAddrState'
).
AsString
);
CustomerJSON
.
AddPair
(
'BILL_ZIP'
,
xdwdsCustomers
.
FieldByName
(
'BillAddrZip'
).
AsString
);
CustomerJSON
.
AddPair
(
'BILL_ADDRESS_BLOCK'
,
xdwdsCustomers
.
FieldByName
(
'BillAddr'
).
AsString
);
CustomerJSON
.
AddPair
(
'BILL_CONTACT'
,
xdwdsCustomers
.
FieldByName
(
'BillAddrContact'
).
AsString
);
CustomerJSON
.
AddPair
(
'address'
,
xdwdsCustomers
.
FieldByName
(
'ShipAddrLine1'
).
AsString
);
CustomerJSON
.
AddPair
(
'city'
,
xdwdsCustomers
.
FieldByName
(
'ShipAddrCity'
).
AsString
);
CustomerJSON
.
AddPair
(
'state'
,
xdwdsCustomers
.
FieldByName
(
'ShipAddrState'
).
AsString
);
CustomerJSON
.
AddPair
(
'zip'
,
xdwdsCustomers
.
FieldByName
(
'ShipAddrZip'
).
AsString
);
CustomerJSON
.
AddPair
(
'ship_block'
,
xdwdsCustomers
.
FieldByName
(
'ShipAddr'
).
AsString
);
CustomerJSON
.
AddPair
(
'contact'
,
xdwdsCustomers
.
FieldByName
(
'ShipAddrContact'
).
AsString
);
CustomerJSON
.
AddPair
(
'name'
,
xdwdsCustomers
.
FieldByName
(
'CompanyName'
).
AsString
);
CustomerJSON
.
AddPair
(
'mode'
,
'ADD'
);
FViewMain
.
ViewAddCustomer
(
''
,
CustomerJSON
.
ToString
);
end
;
Close
();
Close
();
end
;
end
;
end
;
end
;
...
@@ -155,10 +114,11 @@ begin
...
@@ -155,10 +114,11 @@ begin
// Fetch data from XData service
// Fetch data from XData service
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.getQBCustomers'
,
[]));
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.getQBCustomers'
,
[]));
customerList
:=
TJSObject
(
xdcResponse
.
Result
);
customerList
:=
TJSObject
(
xdcResponse
.
Result
);
console
.
log
(
customerList
);
// Load data into TXDataWebDataset
// Load data into TXDataWebDataset
xdwdsCustomers
.
Close
;
xdwdsCustomers
.
Close
;
xdwdsCustomers
.
SetJsonData
(
customerList
);
xdwdsCustomers
.
SetJsonData
(
customerList
[
'data'
]
);
xdwdsCustomers
.
Open
;
xdwdsCustomers
.
Open
;
// Manually populate the grid
// Manually populate the grid
...
@@ -194,10 +154,10 @@ begin
...
@@ -194,10 +154,10 @@ begin
while
not
xdwdsCustomers
.
EOF
do
while
not
xdwdsCustomers
.
EOF
do
begin
begin
TMSFNCGrid1
.
RowCount
:=
RowIndex
+
1
;
TMSFNCGrid1
.
RowCount
:=
RowIndex
+
1
;
TMSFNCGrid1
.
Cells
[
0
,
RowIndex
]
:=
xdwdsCustomers
.
FieldByName
(
'Id'
)
.
AsString
;
TMSFNCGrid1
.
Cells
[
0
,
RowIndex
]
:=
xdwdsCustomers
Id
.
AsString
;
TMSFNCGrid1
.
Cells
[
1
,
RowIndex
]
:=
xdwdsCustomers
.
FieldByName
(
'CompanyName'
)
.
AsString
;
TMSFNCGrid1
.
Cells
[
1
,
RowIndex
]
:=
xdwdsCustomers
CompanyName
.
AsString
;
TMSFNCGrid1
.
Cells
[
2
,
RowIndex
]
:=
xdwdsCustomers
.
FieldByName
(
'BillAddr'
)
.
AsString
;
TMSFNCGrid1
.
Cells
[
2
,
RowIndex
]
:=
xdwdsCustomers
BillAddr
.
AsString
;
TMSFNCGrid1
.
Cells
[
3
,
RowIndex
]
:=
xdwdsCustomers
.
FieldByName
(
'In KGOrders'
)
.
AsString
;
TMSFNCGrid1
.
Cells
[
3
,
RowIndex
]
:=
xdwdsCustomers
InKGOrders
.
AsString
;
Inc
(
RowIndex
);
Inc
(
RowIndex
);
xdwdsCustomers
.
Next
;
xdwdsCustomers
.
Next
;
end
;
end
;
...
@@ -216,45 +176,6 @@ begin
...
@@ -216,45 +176,6 @@ begin
edtName
.
Text
:=
TMSFNCGrid1
.
Cells
[
1
,
ARow
];
edtName
.
Text
:=
TMSFNCGrid1
.
Cells
[
1
,
ARow
];
end
;
end
;
procedure
TFSelectCustomer
.
SendCustomerToServer
;
var
CustomerJSON
:
TJSONObject
;
Response
:
TXDataClientResponse
;
notification
:
TJSObject
;
begin
CustomerJSON
:=
TJSONObject
.
Create
;
CustomerJSON
.
AddPair
(
'NAME'
,
xdwdsCustomers
.
FieldByName
(
'CompanyName'
).
AsString
);
CustomerJSON
.
AddPair
(
'QB_LIST_ID'
,
xdwdsCustomers
.
FieldByName
(
'Id'
).
AsString
);
CustomerJSON
.
AddPair
(
'PHONE'
,
xdwdsCustomers
.
FieldByName
(
'PrimaryPhone'
).
AsString
);
CustomerJSON
.
AddPair
(
'BILL_ADDRESS'
,
xdwdsCustomers
.
FieldByName
(
'BillAddrLine1'
).
AsString
);
CustomerJSON
.
AddPair
(
'BILL_CITY'
,
xdwdsCustomers
.
FieldByName
(
'BillAddrCity'
).
AsString
);
CustomerJSON
.
AddPair
(
'BILL_STATE'
,
xdwdsCustomers
.
FieldByName
(
'BillAddrState'
).
AsString
);
CustomerJSON
.
AddPair
(
'BILL_ZIP'
,
xdwdsCustomers
.
FieldByName
(
'BillAddrZip'
).
AsString
);
CustomerJSON
.
AddPair
(
'BILL_ADDRESS_BLOCK'
,
xdwdsCustomers
.
FieldByName
(
'BillAddr'
).
AsString
);
CustomerJSON
.
AddPair
(
'address'
,
xdwdsCustomers
.
FieldByName
(
'ShipAddrLine1'
).
AsString
);
CustomerJSON
.
AddPair
(
'city'
,
xdwdsCustomers
.
FieldByName
(
'ShipAddrCity'
).
AsString
);
CustomerJSON
.
AddPair
(
'state'
,
xdwdsCustomers
.
FieldByName
(
'ShipAddrState'
).
AsString
);
CustomerJSON
.
AddPair
(
'zip'
,
xdwdsCustomers
.
FieldByName
(
'ShipAddrZip'
).
AsString
);
CustomerJSON
.
AddPair
(
'ship_block'
,
xdwdsCustomers
.
FieldByName
(
'ShipAddr'
).
AsString
);
CustomerJSON
.
AddPair
(
'name'
,
xdwdsCustomers
.
FieldByName
(
'CompanyName'
).
AsString
);
CustomerJSON
.
AddPair
(
'mode'
,
'ADD'
);
Utils
.
ShowSpinner
(
'spinner'
);
Response
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.ImportQBCustomer'
,
[
customerJSON
.
ToString
]));
notification
:=
TJSObject
(
Response
.
Result
);
customerID
:=
string
(
notification
[
'CustomerID'
]);
msg
:=
string
(
notification
[
'status'
]);
Utils
.
HideSpinner
(
'spinner'
);
FViewMain
.
ViewAddCustomer
(
customerID
,
msg
);
Close
();
end
;
procedure
TFSelectCustomer
.
ApplyFilter
;
procedure
TFSelectCustomer
.
ApplyFilter
;
// filters the grid based on search textbox contents.
// filters the grid based on search textbox contents.
var
var
...
...
kgOrdersClient/View.Customers.dfm
View file @
151f60b4
...
@@ -13,8 +13,8 @@ object FViewCustomers: TFViewCustomers
...
@@ -13,8 +13,8 @@ object FViewCustomers: TFViewCustomers
ElementID = 'lblentries'
ElementID = 'lblentries'
ElementFont = efCSS
ElementFont = efCSS
HeightStyle = ssAuto
HeightStyle = ssAuto
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
end
end
object btnAddCustomer: TWebButton
object btnAddCustomer: TWebButton
Left = 12
Left = 12
...
@@ -26,10 +26,10 @@ object FViewCustomers: TFViewCustomers
...
@@ -26,10 +26,10 @@ object FViewCustomers: TFViewCustomers
ElementID = 'btnaddcustomer'
ElementID = 'btnaddcustomer'
ElementFont = efCSS
ElementFont = efCSS
HeightStyle = ssAuto
HeightStyle = ssAuto
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
TabOrder = 6
TabOrder = 6
TabStop = False
TabStop = False
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
OnClick = btnAddCustomerClick
OnClick = btnAddCustomerClick
end
end
object wcbPageSize: TWebComboBox
object wcbPageSize: TWebComboBox
...
@@ -41,9 +41,9 @@ object FViewCustomers: TFViewCustomers
...
@@ -41,9 +41,9 @@ object FViewCustomers: TFViewCustomers
ElementID = 'wcbpagesize'
ElementID = 'wcbpagesize'
ElementFont = efCSS
ElementFont = efCSS
HeightStyle = ssAuto
HeightStyle = ssAuto
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
Text = '50'
Text = '50'
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
OnChange = wcbPageSizeChange
OnChange = wcbPageSizeChange
ItemIndex = -1
ItemIndex = -1
Items.Strings = (
Items.Strings = (
...
@@ -66,8 +66,8 @@ object FViewCustomers: TFViewCustomers
...
@@ -66,8 +66,8 @@ object FViewCustomers: TFViewCustomers
Height = 15
Height = 15
Caption = 'Message'
Caption = 'Message'
ElementID = 'view.login.message.label'
ElementID = 'view.login.message.label'
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
end
end
object btnCloseNotification: TWebButton
object btnCloseNotification: TWebButton
Left = 96
Left = 96
...
@@ -76,8 +76,8 @@ object FViewCustomers: TFViewCustomers
...
@@ -76,8 +76,8 @@ object FViewCustomers: TFViewCustomers
Height = 25
Height = 25
ChildOrder = 1
ChildOrder = 1
ElementID = 'view.login.message.button'
ElementID = 'view.login.message.button'
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
end
end
end
end
object wdbtcCustomers: TWebDBTableControl
object wdbtcCustomers: TWebDBTableControl
...
@@ -129,10 +129,6 @@ object FViewCustomers: TFViewCustomers
...
@@ -129,10 +129,6 @@ object FViewCustomers: TFViewCustomers
item
item
DataField = 'NAME'
DataField = 'NAME'
Title = 'Customer Name'
Title = 'Customer Name'
end
item
DataField = 'START_DATE'
Title = 'Start Date'
end>
end>
DataSource = wdsCustomers
DataSource = wdsCustomers
end
end
...
@@ -143,8 +139,8 @@ object FViewCustomers: TFViewCustomers
...
@@ -143,8 +139,8 @@ object FViewCustomers: TFViewCustomers
Height = 22
Height = 22
ChildOrder = 5
ChildOrder = 5
ElementID = 'edtfilter'
ElementID = 'edtfilter'
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
OnChange = edtFilterChange
OnChange = edtFilterChange
end
end
object XDataWebClient1: TXDataWebClient
object XDataWebClient1: TXDataWebClient
...
...
kgOrdersClient/View.Main.dfm
View file @
151f60b4
...
@@ -18,9 +18,9 @@ object FViewMain: TFViewMain
...
@@ -18,9 +18,9 @@ object FViewMain: TFViewMain
Caption = 'lblUsername'
Caption = 'lblUsername'
ElementID = 'view.main.username'
ElementID = 'view.main.username'
ElementPosition = epRelative
ElementPosition = epRelative
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
Transparent = False
Transparent = False
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
end
end
object wllblUserProfile: TWebLinkLabel
object wllblUserProfile: TWebLinkLabel
Left = 529
Left = 529
...
@@ -28,8 +28,8 @@ object FViewMain: TFViewMain
...
@@ -28,8 +28,8 @@ object FViewMain: TFViewMain
Width = 59
Width = 59
Height = 14
Height = 14
ElementID = 'dropdown.menu.userprofile'
ElementID = 'dropdown.menu.userprofile'
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
OnClick = wllblUserProfileClick
OnClick = wllblUserProfileClick
Caption = ' User Profile'
Caption = ' User Profile'
end
end
...
@@ -39,8 +39,8 @@ object FViewMain: TFViewMain
...
@@ -39,8 +39,8 @@ object FViewMain: TFViewMain
Width = 36
Width = 36
Height = 14
Height = 14
ElementID = 'dropdown.menu.logout'
ElementID = 'dropdown.menu.logout'
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
OnClick = wllblLogoutClick
OnClick = wllblLogoutClick
Caption = ' Logout'
Caption = ' Logout'
end
end
...
@@ -50,8 +50,8 @@ object FViewMain: TFViewMain
...
@@ -50,8 +50,8 @@ object FViewMain: TFViewMain
Width = 27
Width = 27
Height = 14
Height = 14
ElementID = 'dropdown.menu.home'
ElementID = 'dropdown.menu.home'
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
OnClick = lblHomeClick
OnClick = lblHomeClick
Caption = 'Home'
Caption = 'Home'
end
end
...
@@ -63,9 +63,9 @@ object FViewMain: TFViewMain
...
@@ -63,9 +63,9 @@ object FViewMain: TFViewMain
Caption = 'Koehler-Gibson'
Caption = 'Koehler-Gibson'
ElementID = 'view.main.apptitle'
ElementID = 'view.main.apptitle'
ElementPosition = epRelative
ElementPosition = epRelative
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
Transparent = False
Transparent = False
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
end
end
object lblItemsList: TWebLinkLabel
object lblItemsList: TWebLinkLabel
Left = 560
Left = 560
...
@@ -74,8 +74,8 @@ object FViewMain: TFViewMain
...
@@ -74,8 +74,8 @@ object FViewMain: TFViewMain
Height = 14
Height = 14
ElementID = 'dropdown.menu.itemlist'
ElementID = 'dropdown.menu.itemlist'
ElementFont = efCSS
ElementFont = efCSS
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
OnClick = lblItemsListClick
OnClick = lblItemsListClick
Caption = 'Items'
Caption = 'Items'
end
end
...
@@ -86,8 +86,8 @@ object FViewMain: TFViewMain
...
@@ -86,8 +86,8 @@ object FViewMain: TFViewMain
Height = 14
Height = 14
ElementID = 'dropdown.menu.users'
ElementID = 'dropdown.menu.users'
ElementFont = efCSS
ElementFont = efCSS
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
OnClick = lblUsersClick
OnClick = lblUsersClick
Caption = 'Users'
Caption = 'Users'
end
end
...
@@ -101,8 +101,8 @@ object FViewMain: TFViewMain
...
@@ -101,8 +101,8 @@ object FViewMain: TFViewMain
ElementFont = efCSS
ElementFont = efCSS
ElementPosition = epRelative
ElementPosition = epRelative
HeightStyle = ssAuto
HeightStyle = ssAuto
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
OnClick = lblordersClick
OnClick = lblordersClick
end
end
object lblCustomers: TWebLabel
object lblCustomers: TWebLabel
...
@@ -115,8 +115,8 @@ object FViewMain: TFViewMain
...
@@ -115,8 +115,8 @@ object FViewMain: TFViewMain
ElementFont = efCSS
ElementFont = efCSS
ElementPosition = epRelative
ElementPosition = epRelative
HeightStyle = ssAuto
HeightStyle = ssAuto
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
OnClick = lblCustomersClick
OnClick = lblCustomersClick
end
end
object lblVersion: TWebLabel
object lblVersion: TWebLabel
...
@@ -129,8 +129,8 @@ object FViewMain: TFViewMain
...
@@ -129,8 +129,8 @@ object FViewMain: TFViewMain
ElementFont = efCSS
ElementFont = efCSS
ElementPosition = epRelative
ElementPosition = epRelative
HeightStyle = ssAuto
HeightStyle = ssAuto
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
end
end
object lblQBInfo: TWebLabel
object lblQBInfo: TWebLabel
Left = 552
Left = 552
...
@@ -141,8 +141,8 @@ object FViewMain: TFViewMain
...
@@ -141,8 +141,8 @@ object FViewMain: TFViewMain
ElementID = 'dropdown.menu.linktoqb'
ElementID = 'dropdown.menu.linktoqb'
ElementFont = efCSS
ElementFont = efCSS
HeightStyle = ssAuto
HeightStyle = ssAuto
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
OnClick = lblQBInfoClick
OnClick = lblQBInfoClick
end
end
object WebPanel1: TWebPanel
object WebPanel1: TWebPanel
...
@@ -173,7 +173,7 @@ object FViewMain: TFViewMain
...
@@ -173,7 +173,7 @@ object FViewMain: TFViewMain
ElementID = 'main.debugmemo'
ElementID = 'main.debugmemo'
ElementPosition = epRelative
ElementPosition = epRelative
Enabled = False
Enabled = False
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
Lines.Strings = (
Lines.Strings = (
'WebMemo1')
'WebMemo1')
Role = 'null'
Role = 'null'
...
@@ -181,7 +181,7 @@ object FViewMain: TFViewMain
...
@@ -181,7 +181,7 @@ object FViewMain: TFViewMain
SelStart = 0
SelStart = 0
ShowFocus = False
ShowFocus = False
Visible = False
Visible = False
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
end
end
object WebMessageDlg1: TWebMessageDlg
object WebMessageDlg1: TWebMessageDlg
Left = 47
Left = 47
...
@@ -208,7 +208,7 @@ object FViewMain: TFViewMain
...
@@ -208,7 +208,7 @@ object FViewMain: TFViewMain
'No to all'
'No to all'
'Help'
'Help'
'Close')
'Close')
Opacity = 0.20000000000000000
0
Opacity = 0.20000000000000000
end
end
object XDataWebClient: TXDataWebClient
object XDataWebClient: TXDataWebClient
Connection = DMConnection.ApiConnection
Connection = DMConnection.ApiConnection
...
...
kgOrdersClient/View.Main.pas
View file @
151f60b4
...
@@ -60,7 +60,7 @@ type
...
@@ -60,7 +60,7 @@ type
procedure
ViewOrders
(
info
:
string
);
procedure
ViewOrders
(
info
:
string
);
procedure
ViewCustomerList
(
info
:
string
);
procedure
ViewCustomerList
(
info
:
string
);
procedure
ShowUserForm
(
Info
:
string
);
procedure
ShowUserForm
(
Info
:
string
);
procedure
ViewAddCustomer
(
cust
omerInfo
,
info
:
string
);
procedure
ViewAddCustomer
(
cust
ID
,
custQB_ID
:
string
);
var
var
search
:
string
;
search
:
string
;
change
:
boolean
;
change
:
boolean
;
...
@@ -361,12 +361,12 @@ begin
...
@@ -361,12 +361,12 @@ begin
end
;
end
;
procedure
TFViewMain
.
ViewAddCustomer
(
cust
omerInfo
:
string
;
info
:
string
);
procedure
TFViewMain
.
ViewAddCustomer
(
cust
ID
:
string
;
custQB_ID
:
string
);
begin
begin
lblAppTitle
.
Caption
:=
'Koehler-Gibson Add Customer'
;
lblAppTitle
.
Caption
:=
'Koehler-Gibson Add Customer'
;
if
Assigned
(
FChildForm
)
then
if
Assigned
(
FChildForm
)
then
FChildForm
.
Free
;
FChildForm
.
Free
;
FChildForm
:=
TFViewAddCustomer
.
CreateForm
(
WebPanel1
.
ElementID
,
cust
omerInfo
,
info
);
FChildForm
:=
TFViewAddCustomer
.
CreateForm
(
WebPanel1
.
ElementID
,
cust
ID
,
custQB_ID
);
end
;
end
;
...
...
kgOrdersClient/View.QBInfo.dfm
View file @
151f60b4
...
@@ -13,9 +13,9 @@ object FQBInfo: TFQBInfo
...
@@ -13,9 +13,9 @@ object FQBInfo: TFQBInfo
Font.Height = -24
Font.Height = -24
Font.Name = 'Segoe UI'
Font.Name = 'Segoe UI'
Font.Style = []
Font.Style = []
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
ParentFont = False
ParentFont = False
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
end
end
object lblCompanyName: TWebLabel
object lblCompanyName: TWebLabel
Left = 16
Left = 16
...
@@ -28,9 +28,9 @@ object FQBInfo: TFQBInfo
...
@@ -28,9 +28,9 @@ object FQBInfo: TFQBInfo
Font.Height = -16
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Name = 'Segoe UI'
Font.Style = []
Font.Style = []
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
ParentFont = False
ParentFont = False
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
end
end
object lblCompanyID: TWebLabel
object lblCompanyID: TWebLabel
Left = 15
Left = 15
...
@@ -43,9 +43,9 @@ object FQBInfo: TFQBInfo
...
@@ -43,9 +43,9 @@ object FQBInfo: TFQBInfo
Font.Height = -16
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Name = 'Segoe UI'
Font.Style = []
Font.Style = []
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
ParentFont = False
ParentFont = False
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
end
end
object lblLastRefresh: TWebLabel
object lblLastRefresh: TWebLabel
Left = 16
Left = 16
...
@@ -58,9 +58,9 @@ object FQBInfo: TFQBInfo
...
@@ -58,9 +58,9 @@ object FQBInfo: TFQBInfo
Font.Height = -16
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Name = 'Segoe UI'
Font.Style = []
Font.Style = []
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
ParentFont = False
ParentFont = False
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
end
end
object btnLinkToQB: TWebButton
object btnLinkToQB: TWebButton
Left = 235
Left = 235
...
@@ -69,8 +69,8 @@ object FQBInfo: TFQBInfo
...
@@ -69,8 +69,8 @@ object FQBInfo: TFQBInfo
Height = 25
Height = 25
Caption = 'Link to QB'
Caption = 'Link to QB'
ChildOrder = 3
ChildOrder = 3
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
OnClick = btnLinkToQBClick
OnClick = btnLinkToQBClick
end
end
object btnClose: TWebButton
object btnClose: TWebButton
...
@@ -80,8 +80,8 @@ object FQBInfo: TFQBInfo
...
@@ -80,8 +80,8 @@ object FQBInfo: TFQBInfo
Height = 25
Height = 25
Caption = 'Close'
Caption = 'Close'
ChildOrder = 3
ChildOrder = 3
HeightPercent = 100.00000000000000000
0
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
0
WidthPercent = 100.00000000000000000
OnClick = btnCloseClick
OnClick = btnCloseClick
end
end
object XDataWebClient1: TXDataWebClient
object XDataWebClient1: TXDataWebClient
...
...
kgOrdersClient/View.QBInfo.pas
View file @
151f60b4
...
@@ -24,6 +24,7 @@ type
...
@@ -24,6 +24,7 @@ type
{ Private declarations }
{ Private declarations }
ClientID
:
string
;
ClientID
:
string
;
[
async
]
procedure
GetQBInfo
();
[
async
]
procedure
GetQBInfo
();
[
async
]
procedure
GetQBLink
();
public
public
{ Public declarations }
{ Public declarations }
end
;
end
;
...
@@ -38,22 +39,8 @@ implementation
...
@@ -38,22 +39,8 @@ implementation
uses
View
.
Main
,
Utils
;
uses
View
.
Main
,
Utils
;
procedure
TFQBInfo
.
btnLinkToQBClick
(
Sender
:
TObject
);
procedure
TFQBInfo
.
btnLinkToQBClick
(
Sender
:
TObject
);
var
qblink
,
redirectUri
:
string
;
qbWindow
:
TJSWindow
;
begin
begin
qblink
:=
'https://appcenter.intuit.com/connect/oauth2'
;
GetQBLink
();
qblink
:=
qblink
+
'?client_id='
+
ClientID
;
qblink
:=
qblink
+
'&response_type=code'
;
qblink
:=
qblink
+
'&scope=com.intuit.quickbooks.accounting'
;
qblink
:=
qblink
+
'&state=7'
;
redirectUri
:=
DMConnection
.
AuthConnection
.
URL
+
'AuthService/QBAuthorize'
;
qblink
:=
qblink
+
'&redirect_uri='
+
RedirectUri
;
qbWindow
:=
window
.
open
(
''
,
'_blank'
);
if
Assigned
(
qbWindow
)
then
qbWindow
.
location
.
href
:=
qbLink
;
Close
();
end
;
end
;
procedure
TFQBInfo
.
WebFormCreate
(
Sender
:
TObject
);
procedure
TFQBInfo
.
WebFormCreate
(
Sender
:
TObject
);
...
@@ -103,5 +90,29 @@ begin
...
@@ -103,5 +90,29 @@ begin
end
;
end
;
end
;
end
;
procedure
TFQBInfo
.
GetQBLink
();
var
xdcResponse
:
TXDataClientResponse
;
QBLinkObj
:
TJSObject
;
QBLink
:
String
;
qbWindow
:
TJSWindow
;
begin
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.getQBLink'
,
[]));
QBLinkObj
:=
TJSObject
(
xdcResponse
.
Result
);
QBLink
:=
String
(
QBLinkObj
[
'value'
]);
console
.
log
(
QBLinkObj
);
console
.
log
(
QBLink
);
qbWindow
:=
window
.
open
(
''
,
'_blank'
);
if
Assigned
(
qbWindow
)
then
qbWindow
.
location
.
href
:=
QBLink
;
Close
();
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
end
.
end
.
kgOrdersClient/Win64/Debug/TMSWebRunner.ini
0 → 100644
View file @
151f60b4
[Paths]
HtmlPath
=
C:
\P
rojects
\k
gOrders
\k
gOrders
\k
gOrdersClient
\T
MSWeb
\D
ebug
HtmlFile
=
index.html
DefaultURL
=
http://127.0.0.1:8000/webKGOrders
SingleInstance
=
0
Debug
=
0
DebugManager
=
C:
\R
ADTools
\T
MS
\P
roducts
\t
ms.webcore
\B
in
\W
in32
\T
MSDBGManager.exe
URL
=
http://127.0.0.1:8000/$(ProjectName)
URLParams
=
Browser
=
1
BrowserBin
=
BrowserParams
=
Electron
=
0
ElectronBuild
=
0
JSDebugger
=
0
kgOrdersServer/Source/Api.Database.dfm
View file @
151f60b4
...
@@ -411,25 +411,10 @@ object ApiDatabase: TApiDatabase
...
@@ -411,25 +411,10 @@ object ApiDatabase: TApiDatabase
Connection = ucKG
Connection = ucKG
SQL.Strings = (
SQL.Strings = (
'SELECT USER_ID, NAME, STATUS from users ORDER BY NAME')
'SELECT USER_ID, NAME, STATUS from users ORDER BY NAME')
OnCalcFields = uqUsersCalcFields
Left = 318
Left = 318
Top = 252
Top = 252
object uqUsersUSER_ID: TIntegerField
object uqUsersQB_ID: TStringField
FieldName = 'USER_ID'
FieldName = 'QB_ID'
Required = True
end
object uqUsersNAME: TStringField
FieldName = 'NAME'
Size = 40
end
object uqUsersSTATUS: TStringField
FieldName = 'STATUS'
Size = 7
end
object uqUsersREPRESENTATIVE: TStringField
FieldKind = fkCalculated
FieldName = 'REPRESENTATIVE'
Calculated = True
end
end
end
end
end
end
kgOrdersServer/Source/Api.Database.pas
View file @
151f60b4
...
@@ -113,12 +113,8 @@ type
...
@@ -113,12 +113,8 @@ type
uqOrdersStatusScheduleUSER_ID
:
TLongWordField
;
uqOrdersStatusScheduleUSER_ID
:
TLongWordField
;
uqOrdersStatusScheduleORDER_REVISION
:
TLongWordField
;
uqOrdersStatusScheduleORDER_REVISION
:
TLongWordField
;
uqUsers
:
TUniQuery
;
uqUsers
:
TUniQuery
;
uqUsersUSER_ID
:
TIntegerField
;
uqUsersQB_ID
:
TStringField
;
uqUsersNAME
:
TStringField
;
uqUsersSTATUS
:
TStringField
;
uqUsersREPRESENTATIVE
:
TStringField
;
procedure
DataModuleCreate
(
Sender
:
TObject
);
procedure
DataModuleCreate
(
Sender
:
TObject
);
procedure
uqUsersCalcFields
(
DataSet
:
TDataSet
);
private
private
{ Private declarations }
{ Private declarations }
public
public
...
@@ -166,10 +162,4 @@ begin
...
@@ -166,10 +162,4 @@ begin
end
;
end
;
procedure
TApiDatabase
.
uqUsersCalcFields
(
DataSet
:
TDataSet
);
begin
uqUsersREPRESENTATIVE
.
AsString
:=
uqUsersNAME
.
AsString
+
'('
+
uqUsersSTATUS
.
AsString
+
')'
;
end
;
end
.
end
.
kgOrdersServer/Source/Lookup.Service.pas
View file @
151f60b4
...
@@ -20,9 +20,42 @@ const
...
@@ -20,9 +20,42 @@ const
API_MODEL
=
'Api'
;
API_MODEL
=
'Api'
;
type
type
TQBCustomer
=
class
public
CUSTOMER_ID
:
string
;
NAME
:
string
;
BILL_ADDRESS
:
string
;
BILL_CITY
:
string
;
BILL_STATE
:
string
;
BILL_ZIP
:
string
;
BILL_CONTACT
:
string
;
BILL_ADDRESS_BLOCK
:
string
;
QB_LIST_ID
:
string
;
RepUser
:
string
;
ship_block
:
string
;
shipping_address
:
string
;
city
:
string
;
state
:
string
;
zip
:
string
;
contact
:
string
;
end
;
TQBCustomerItem
=
class
public
Id
:
string
;
CompanyName
:
string
;
BillAddr
:
string
;
InKGOrders
:
boolean
;
end
;
TQBCustomerList
=
class
public
count
:
integer
;
data
:
TList
<
TQBCustomerItem
>;
end
;
TQBInfo
=
class
TQBInfo
=
class
public
public
clientID
:
string
;
CompanyName
:
string
;
CompanyName
:
string
;
CompanyID
:
string
;
CompanyID
:
string
;
connected
:
boolean
;
connected
:
boolean
;
...
@@ -120,7 +153,7 @@ type
...
@@ -120,7 +153,7 @@ type
TAddressItem
=
class
TAddressItem
=
class
Public
Public
ADDRESS
:
string
;
ship_block
:
string
;
shipping_address
:
string
;
shipping_address
:
string
;
city
:
string
;
city
:
string
;
state
:
string
;
state
:
string
;
...
@@ -145,9 +178,8 @@ type
...
@@ -145,9 +178,8 @@ type
END_DATE
:
string
;
END_DATE
:
string
;
QB_LIST_ID
:
string
;
QB_LIST_ID
:
string
;
FFAX
:
string
;
FFAX
:
string
;
REP_USER_ID
:
string
;
QB_TYPE
:
string
;
SHIPPING_ADDRESS_LIST
:
TList
<
TAddressItem
>;
SHIPPING_ADDRESS_LIST
:
TList
<
TAddressItem
>;
REP_USERS
:
TList
<
TUserItem
>;
end
;
end
;
TCustomerList
=
class
TCustomerList
=
class
...
@@ -492,12 +524,14 @@ type
...
@@ -492,12 +524,14 @@ type
[
HttpGet
]
function
GenerateOrderCorrugatedPDF
(
orderID
:
string
):
string
;
[
HttpGet
]
function
GenerateOrderCorrugatedPDF
(
orderID
:
string
):
string
;
[
HttpGet
]
function
GenerateOrderWebPDF
(
orderID
:
string
):
string
;
[
HttpGet
]
function
GenerateOrderWebPDF
(
orderID
:
string
):
string
;
[
HttpGet
]
function
GenerateOrderCuttingPDF
(
orderID
:
string
):
string
;
[
HttpGet
]
function
GenerateOrderCuttingPDF
(
orderID
:
string
):
string
;
[
HttpGet
]
function
getQBCustomers
():
T
JSONArray
;
[
HttpGet
]
function
getQBCustomers
():
T
QBCustomerList
;
[
HttpGet
]
function
getQBItems
():
TJSONArray
;
[
HttpGet
]
function
getQBItems
():
TJSONArray
;
[
HttpGet
]
function
GetRepUsers
():
TList
<
TUserItem
>;
[
HttpGet
]
function
GetRepUsers
():
TList
<
TUserItem
>;
[
HttpGet
]
function
UpdateCustomer
(
QB_ID
:
string
):
TCustomerItem
;
[
HttpGet
]
function
UpdateCustomer
(
QB_ID
:
string
):
TCustomerItem
;
[
HttpGet
]
function
UpdateItem
(
itemName
:
string
):
TItemItem
;
[
HttpGet
]
function
UpdateItem
(
itemName
:
string
):
TItemItem
;
[
HttpGet
]
function
GetQBInfo
():
TQBInfo
;
[
HttpGet
]
function
GetQBInfo
():
TQBInfo
;
[
HttpGet
]
function
GetQBLink
():
string
;
[
HttpGet
]
function
GetQBCustomer
(
QB_ID
:
string
):
TQBCustomer
;
function
AddUser
(
userInfo
:
string
):
string
;
function
AddUser
(
userInfo
:
string
):
string
;
...
...
kgOrdersServer/Source/Lookup.ServiceImpl.pas
View file @
151f60b4
...
@@ -36,12 +36,15 @@ type
...
@@ -36,12 +36,15 @@ type
function
GetCustomer
(
ID
:
string
):
TCustomerItem
;
function
GetCustomer
(
ID
:
string
):
TCustomerItem
;
function
GetWebOrder
(
orderInfo
:
string
):
TWebOrder
;
function
GetWebOrder
(
orderInfo
:
string
):
TWebOrder
;
function
GetCuttingDieOrder
(
orderInfo
:
string
):
TCuttingDie
;
function
GetCuttingDieOrder
(
orderInfo
:
string
):
TCuttingDie
;
function
GetQBCustomers
:
T
JSONArray
;
function
GetQBCustomers
:
T
QBCustomerList
;
function
GetQBItems
:
TJSONArray
;
function
GetQBItems
:
TJSONArray
;
function
GetRepUsers
():
TList
<
TUserItem
>;
function
GetRepUsers
():
TList
<
TUserItem
>;
function
UpdateCustomer
(
QB_ID
:
string
):
TCustomerItem
;
function
UpdateCustomer
(
QB_ID
:
string
):
TCustomerItem
;
function
UpdateItem
(
itemName
:
string
):
TItemItem
;
function
UpdateItem
(
itemName
:
string
):
TItemItem
;
function
GetQBInfo
():
TQBInfo
;
function
GetQBInfo
():
TQBInfo
;
function
GetQBLink
():
string
;
function
GetQBCustomer
(
QB_ID
:
string
):
TQBCustomer
;
function
GetCustomerType
(
CustomerTypeId
:
string
):
string
;
function
EditUser
(
const
editOptions
:
string
):
string
;
function
EditUser
(
const
editOptions
:
string
):
string
;
...
@@ -104,19 +107,15 @@ var
...
@@ -104,19 +107,15 @@ var
LastRefresh
:
TDateTime
;
LastRefresh
:
TDateTime
;
iniFile
:
TIniFile
;
iniFile
:
TIniFile
;
begin
begin
logger
.
Log
(
3
,
'TLookupService.GetQBItems'
);
logger
.
Log
(
3
,
'TLookupService.GetQBInfo - start'
);
iniFile
:=
nil
;
restClient
:=
nil
;
restRequest
:=
nil
;
restResponse
:=
nil
;
try
try
result
:=
TQBInfo
.
Create
;
iniFile
:=
TIniFile
.
Create
(
ExtractFilePath
(
Application
.
ExeName
)
+
'kgOrdersServer.ini'
);
iniFile
:=
TIniFile
.
Create
(
ExtractFilePath
(
Application
.
ExeName
)
+
'kgOrdersServer.ini'
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restRequest
:=
TRESTRequest
.
Create
(
nil
);
restRequest
:=
TRESTRequest
.
Create
(
nil
);
restResponse
:=
TRESTResponse
.
Create
(
nil
);
restResponse
:=
TRESTResponse
.
Create
(
nil
);
result
.
clientID
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'ClientID'
,
''
);
try
try
result
:=
TQBInfo
.
Create
;
if
iniFile
.
ReadString
(
'Quickbooks'
,
'CompanyID'
,
''
)
=
''
then
if
iniFile
.
ReadString
(
'Quickbooks'
,
'CompanyID'
,
''
)
=
''
then
begin
begin
result
.
connected
:=
false
;
result
.
connected
:=
false
;
...
@@ -167,8 +166,8 @@ begin
...
@@ -167,8 +166,8 @@ begin
except
except
on
E
:
Exception
do
on
E
:
Exception
do
begin
begin
Logger
.
Log
(
1
,
'Error in getQBI
tems
: '
+
E
.
Message
);
Logger
.
Log
(
1
,
'Error in getQBI
nfo
: '
+
E
.
Message
);
raise
EXDataHttpException
.
Create
(
500
,
'Unable to retrieve QuickBooks I
tems
: A QuickBooks interface error has occurred!'
);
raise
EXDataHttpException
.
Create
(
500
,
'Unable to retrieve QuickBooks I
nfo
: A QuickBooks interface error has occurred!'
);
end
;
end
;
end
;
end
;
finally
finally
...
@@ -179,6 +178,29 @@ begin
...
@@ -179,6 +178,29 @@ begin
end
;
end
;
end
;
end
;
function
TLookupService
.
GetQBLink
():
string
;
var
iniFile
:
TIniFile
;
qbLink
,
ClientID
,
RedirectUri
:
string
;
begin
iniFile
:=
TIniFile
.
Create
(
ExtractFilePath
(
Application
.
ExeName
)
+
'kgOrdersServer.ini'
);
try
ClientID
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'ClientID'
,
''
);
RedirectUri
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'RedirectUri'
,
''
);
qblink
:=
'https://appcenter.intuit.com/connect/oauth2'
+
'?client_id='
+
ClientID
+
'&response_type=code'
+
'&scope=com.intuit.quickbooks.accounting'
+
'&state=7'
+
'&redirect_uri='
+
RedirectUri
;
result
:=
qbLink
;
finally
iniFile
.
Free
;
end
;
end
;
function
TLookupService
.
addEstimate
(
orderInfo
:
string
):
TJSONObject
;
function
TLookupService
.
addEstimate
(
orderInfo
:
string
):
TJSONObject
;
var
var
iniFile
:
TIniFile
;
iniFile
:
TIniFile
;
...
@@ -612,7 +634,7 @@ begin
...
@@ -612,7 +634,7 @@ begin
result
.
END_DATE
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'END_DATE'
).
AsString
;
result
.
END_DATE
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'END_DATE'
).
AsString
;
result
.
QB_LIST_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'QB_LIST_ID'
).
AsString
;
result
.
QB_LIST_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'QB_LIST_ID'
).
AsString
;
result
.
FFAX
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'FAX'
).
AsString
;
result
.
FFAX
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'FAX'
).
AsString
;
result
.
REP_USER_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'REP_USER_ID
'
).
AsString
;
result
.
QB_TYPE
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'QB_TYPE
'
).
AsString
;
result
.
SHIPPING_ADDRESS_LIST
:=
TList
<
TAddressItem
>.
Create
;
result
.
SHIPPING_ADDRESS_LIST
:=
TList
<
TAddressItem
>.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
.
SHIPPING_ADDRESS_LIST
);
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
.
SHIPPING_ADDRESS_LIST
);
...
@@ -620,7 +642,7 @@ begin
...
@@ -620,7 +642,7 @@ begin
begin
begin
ADDRESS
:=
TAddressItem
.
Create
;
ADDRESS
:=
TAddressItem
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
ADDRESS
);
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
ADDRESS
);
ADDRESS
.
ADDRESS
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ship_block'
).
AsString
;
ADDRESS
.
ship_block
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ship_block'
).
AsString
;
ADDRESS
.
shipping_address
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'address'
).
AsString
;
ADDRESS
.
shipping_address
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'address'
).
AsString
;
ADDRESS
.
city
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'city'
).
AsString
;
ADDRESS
.
city
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'city'
).
AsString
;
ADDRESS
.
state
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'state'
).
AsString
;
ADDRESS
.
state
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'state'
).
AsString
;
...
@@ -649,7 +671,7 @@ var
...
@@ -649,7 +671,7 @@ var
SQL
:
string
;
SQL
:
string
;
begin
begin
Logger
.
Log
(
3
,
'TLookupService.GetRepUsers - start'
);
Logger
.
Log
(
3
,
'TLookupService.GetRepUsers - start'
);
SQL
:=
'SELECT
USER_ID, NAME, STATUS from users
ORDER BY NAME'
;
SQL
:=
'SELECT
QB_ID from users WHERE STATUS = '
+
quotedStr
(
'ACTIVE'
)
+
'
ORDER BY NAME'
;
result
:=
TList
<
TUserItem
>.
Create
;
result
:=
TList
<
TUserItem
>.
Create
;
logger
.
Log
(
5
,
'Retrieving Rep Users with SQL: '
+
SQL
);
logger
.
Log
(
5
,
'Retrieving Rep Users with SQL: '
+
SQL
);
doQuery
(
ordersDB
.
uqUsers
,
SQL
);
doQuery
(
ordersDB
.
uqUsers
,
SQL
);
...
@@ -657,9 +679,7 @@ begin
...
@@ -657,9 +679,7 @@ begin
begin
begin
USER
:=
TUserItem
.
Create
;
USER
:=
TUserItem
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
USER
);
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
USER
);
USER
.
userID
:=
ordersDB
.
uqUsersUSER_ID
.
AsString
;
USER
.
QBID
:=
ordersDB
.
uqUsersQB_ID
.
AsString
;
USER
.
full_name
:=
ordersDB
.
uqUsersNAME
.
AsString
;
USER
.
representative
:=
ordersDB
.
uqUsersREPRESENTATIVE
.
AsString
;
result
.
Add
(
USER
);
result
.
Add
(
USER
);
ordersDB
.
uqUsers
.
Next
;
ordersDB
.
uqUsers
.
Next
;
end
;
end
;
...
@@ -2798,7 +2818,7 @@ begin
...
@@ -2798,7 +2818,7 @@ begin
ordersDB
.
UniQuery1
.
Post
;
ordersDB
.
UniQuery1
.
Post
;
end
;
end
;
function
TLookupService
.
getQBCustomers
:
TJSONArray
;
function
TLookupService
.
getQBCustomers
():
TQBCustomerList
;
var
var
iniFile
:
TIniFile
;
iniFile
:
TIniFile
;
restClient
:
TRESTClient
;
restClient
:
TRESTClient
;
...
@@ -2807,7 +2827,8 @@ var
...
@@ -2807,7 +2827,8 @@ var
param
:
TRESTRequestParameter
;
param
:
TRESTRequestParameter
;
res
:
string
;
res
:
string
;
jsValue
:
TJSONValue
;
jsValue
:
TJSONValue
;
ParsedCustomer
,
Customer
,
BillAddr
:
TJSONObject
;
Customer
,
BillAddr
:
TJSONObject
;
ParsedCustomer
:
TQBCustomerItem
;
jsObj
:
TJSONObject
;
jsObj
:
TJSONObject
;
PhoneObj
:
TJSONObject
;
PhoneObj
:
TJSONObject
;
CustomerList
:
TJSONArray
;
CustomerList
:
TJSONArray
;
...
@@ -2817,7 +2838,7 @@ var
...
@@ -2817,7 +2838,7 @@ var
SQL
:
string
;
SQL
:
string
;
begin
begin
logger
.
Log
(
3
,
'TLookupService.GetQBCustomers'
);
logger
.
Log
(
3
,
'TLookupService.GetQBCustomers'
);
Result
:=
T
JSONArray
.
Create
;
Result
:=
T
QBCustomerList
.
Create
;
iniFile
:=
TIniFile
.
Create
(
ExtractFilePath
(
Application
.
ExeName
)
+
'kgOrdersServer.ini'
);
iniFile
:=
TIniFile
.
Create
(
ExtractFilePath
(
Application
.
ExeName
)
+
'kgOrdersServer.ini'
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restRequest
:=
TRESTRequest
.
Create
(
nil
);
restRequest
:=
TRESTRequest
.
Create
(
nil
);
...
@@ -2856,6 +2877,15 @@ begin
...
@@ -2856,6 +2877,15 @@ begin
restRequest
.
Execute
;
restRequest
.
Execute
;
if
restResponse
.
StatusCode
<>
200
then
begin
Logger
.
Log
(
1
,
'QBO Error: '
+
restResponse
.
StatusText
+
' - '
+
restResponse
.
Content
);
raise
EXDataHttpException
.
Create
(
restResponse
.
StatusCode
,
'QuickBooks API Error: '
+
restResponse
.
StatusText
);
end
;
jsValue
:=
restResponse
.
JSONValue
;
jsValue
:=
restResponse
.
JSONValue
;
if
not
Assigned
(
jsValue
)
then
if
not
Assigned
(
jsValue
)
then
Exit
;
Exit
;
...
@@ -2868,118 +2898,243 @@ begin
...
@@ -2868,118 +2898,243 @@ begin
if
not
Assigned
(
CustomerList
)
then
if
not
Assigned
(
CustomerList
)
then
Exit
;
Exit
;
Result
.
data
:=
TList
<
TQBCustomerItem
>.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
.
data
);
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
;
ParsedCustomer
:=
TJSONObject
.
Create
;
ParsedCustomer
:=
TQBCustomerItem
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
ParsedCustomer
);
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'
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
try
try
ParsedCustomer
.
AddPair
(
'In KGOrders'
,
not
(
ordersDB
.
UniQuery1
.
IsEmpty
));
ParsedCustomer
.
InKGOrders
:=
not
(
ordersDB
.
UniQuery1
.
IsEmpty
);
ParsedCustomer
.
AddPair
(
'Id'
,
Customer
.
GetValue
<
string
>(
'Id'
));
ParsedCustomer
.
Id
:=
Customer
.
GetValue
<
string
>(
'Id'
);
ParsedCustomer
.
AddPair
(
'CompanyName'
,
Customer
.
GetValue
<
string
>(
'DisplayName'
));
ParsedCustomer
.
CompanyName
:=
Customer
.
GetValue
<
string
>(
'DisplayName'
);
if
Customer
.
TryGetValue
<
TJSONObject
>(
'PrimaryPhone'
,
PhoneObj
)
then
ParsedCustomer
.
AddPair
(
'PrimaryPhone'
,
PhoneObj
.
GetValue
<
string
>(
'FreeFormNumber'
));
// Handle Bill Address
if
Customer
.
GetValue
(
'BillAddr'
)
is
TJSONObject
then
if
Customer
.
GetValue
(
'BillAddr'
)
is
TJSONObject
then
begin
begin
BillAddr
:=
Customer
.
GetValue
(
'BillAddr'
)
as
TJSONObject
;
BillAddr
:=
Customer
.
GetValue
(
'BillAddr'
)
as
TJSONObject
;
Line1
:=
BillAddr
.
GetValue
<
string
>(
'Line1'
,
''
);
Line1
:=
BillAddr
.
GetValue
<
string
>(
'Line1'
,
''
);
Line2
:=
BillAddr
.
GetValue
<
string
>(
'Line2'
,
''
);
Line2
:=
BillAddr
.
GetValue
<
string
>(
'Line2'
,
''
);
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'
,
''
)));
if
Line2
<>
''
then
if
Line2
<>
''
then
begin
begin
ParsedCustomer
.
AddPair
(
'BillAddrLine1'
,
TJSONString
.
Create
(
Line2
));
ParsedCustomer
.
BillAddr
:=
ParsedCustomer
.
AddPair
(
'BillAddrContact'
,
TJSONString
.
Create
(
Line1
));
Customer
.
GetValue
<
string
>(
'DisplayName'
)
+
' '
+
ParsedCustomer
.
AddPair
(
'BillAddr'
,
BillAddr
.
GetValue
(
'Line1'
,
''
)
+
' '
+
TJSONString
.
Create
(
BillAddr
.
GetValue
(
'Line2'
,
''
)
+
' '
+
Customer
.
GetValue
<
string
>(
'DisplayName'
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'Line1'
,
''
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'Line2'
,
''
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'City'
,
''
)
+
', '
+
BillAddr
.
GetValue
(
'City'
,
''
)
+
', '
+
BillAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
)
+
' '
+
BillAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
)
+
' '
+
BillAddr
.
GetValue
(
'PostalCode'
,
''
)
BillAddr
.
GetValue
(
'PostalCode'
,
''
);
)
);
end
end
else
else
begin
begin
ParsedCustomer
.
AddPair
(
'BillAddrLine1'
,
TJSONString
.
Create
(
Line1
));
ParsedCustomer
.
BillAddr
:=
ParsedCustomer
.
AddPair
(
'BillAddrContact'
,
''
);
Customer
.
GetValue
<
string
>(
'DisplayName'
)
+
' '
+
ParsedCustomer
.
AddPair
(
'BillAddr'
,
BillAddr
.
GetValue
(
'Line1'
,
''
)
+
' '
+
TJSONString
.
Create
(
Customer
.
GetValue
<
string
>(
'DisplayName'
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'Line1'
,
''
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'City'
,
''
)
+
', '
+
BillAddr
.
GetValue
(
'City'
,
''
)
+
', '
+
BillAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
)
+
' '
+
BillAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
)
+
' '
+
BillAddr
.
GetValue
(
'PostalCode'
,
''
)
BillAddr
.
GetValue
(
'PostalCode'
,
''
);
)
end
;
);
end
;
Result
.
data
.
Add
(
ParsedCustomer
);
except
ParsedCustomer
.
Free
;
raise
;
end
;
end
;
end
;
except
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'Error in getQBCustomers: '
+
E
.
Message
);
raise
EXDataHttpException
.
Create
(
500
,
'Unable to retrieve QuickBooks Customers: A QuickBooks interface error has occurred!'
);
end
;
end
;
finally
iniFile
.
Free
;
restClient
.
Free
;
restRequest
.
Free
;
restResponse
.
Free
;
end
;
end
;
function
TLookupService
.
GetQBCustomer
(
QB_ID
:
string
):
TQBCustomer
;
var
iniFile
:
TIniFile
;
restClient
:
TRESTClient
;
restRequest
:
TRESTRequest
;
restResponse
:
TRESTResponse
;
param
:
TRESTRequestParameter
;
res
:
string
;
jsValue
:
TJSONValue
;
Customer
,
BillAddr
,
ShipAddr
,
CustomerTypeRef
:
TJSONObject
;
ParsedCustomer
:
TQBCustomer
;
jsObj
:
TJSONObject
;
PhoneObj
:
TJSONObject
;
CustomerList
:
TJSONArray
;
AccessToken
,
RefreshToken
,
CompanyID
,
Client
,
Secret
,
BaseUrl
,
Line1
,
Line2
:
string
;
LastRefresh
:
TDateTime
;
I
:
integer
;
SQL
,
CustomerTypeID
:
string
;
begin
logger
.
Log
(
3
,
'TLookupService.GetQBCustomer - start'
);
iniFile
:=
TIniFile
.
Create
(
ExtractFilePath
(
Application
.
ExeName
)
+
'kgOrdersServer.ini'
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restRequest
:=
TRESTRequest
.
Create
(
nil
);
restResponse
:=
TRESTResponse
.
Create
(
nil
);
try
try
restRequest
.
Client
:=
restClient
;
restRequest
.
Response
:=
restResponse
;
if
iniFile
.
ReadString
(
'Quickbooks'
,
'LastRefresh'
,
''
)
=
''
then
LastRefresh
:=
0
else
LastRefresh
:=
StrToDateTime
(
iniFile
.
ReadString
(
'Quickbooks'
,
'LastRefresh'
,
''
));
if
MinutesBetween
(
Now
,
LastRefresh
)
>
58
then
RefreshAccessToken
();
Client
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'ClientID'
,
''
);
Secret
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'ClientSecret'
,
''
);
CompanyID
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'CompanyID'
,
''
);
RefreshToken
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'RefreshToken'
,
''
);
AccessToken
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'AccessToken'
,
''
);
BaseUrl
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'BaseUrl'
,
''
);
restClient
.
BaseURL
:=
BaseUrl
;
restRequest
.
Method
:=
rmGET
;
res
:=
'/v3/company/'
+
CompanyID
+
'/query?query=select * from Customer where Id = '
+
quotedStr
(
QB_ID
)
+
'&minorversion=75'
;
restRequest
.
Resource
:=
res
;
param
:=
restRequest
.
Params
.
AddItem
;
param
.
Name
:=
'Authorization'
;
param
.
Kind
:=
pkHTTPHEADER
;
param
.
Options
:=
param
.
Options
+
[
TRESTRequestParameterOption
.
poDoNotEncode
];
param
.
Value
:=
'Bearer '
+
AccessToken
;
restRequest
.
Execute
;
if
restResponse
.
StatusCode
<>
200
then
begin
Logger
.
Log
(
1
,
'QBO Error: '
+
restResponse
.
StatusText
+
' - '
+
restResponse
.
Content
);
raise
EXDataHttpException
.
Create
(
restResponse
.
StatusCode
,
'QuickBooks API Error: '
+
restResponse
.
StatusText
);
end
;
end
;
// Handle Ship Address
jsValue
:=
restResponse
.
JSONValue
;
if
Customer
.
GetValue
(
'ShipAddr'
)
is
TJSONObject
then
if
not
Assigned
(
jsValue
)
then
Exit
;
jsObj
:=
jsValue
as
TJSONObject
;
if
not
Assigned
(
jsObj
)
then
Exit
;
CustomerList
:=
jsObj
.
GetValue
<
TJSONArray
>(
'QueryResponse.Customer'
);
if
not
Assigned
(
CustomerList
)
then
Exit
;
for
I
:=
0
to
CustomerList
.
Count
-
1
do
begin
begin
BillAddr
:=
Customer
.
GetValue
(
'ShipAddr'
)
as
TJSONObject
;
Customer
:=
CustomerList
.
Items
[
I
]
as
TJSONObject
;
Line1
:=
BillAddr
.
GetValue
<
string
>(
'Line1'
,
''
);
logger
.
Log
(
5
,
Customer
.
ToJSON
());
Line2
:=
BillAddr
.
GetValue
<
string
>(
'Line2'
,
''
);
ParsedCustomer
:=
TQBCustomer
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
ParsedCustomer
);
try
ParsedCustomer
.
QB_LIST_ID
:=
Customer
.
GetValue
<
string
>(
'Id'
);
ParsedCustomer
.
NAME
:=
Customer
.
GetValue
<
string
>(
'DisplayName'
);
// Handle Bill Address
if
Customer
.
GetValue
(
'BillAddr'
)
is
TJSONObject
then
begin
BillAddr
:=
Customer
.
GetValue
(
'BillAddr'
)
as
TJSONObject
;
ParsedCustomer
.
AddPair
(
'ShipAddrLine1'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'Line1'
,
''
)));
ParsedCustomer
.
BILL_CITY
:=
BillAddr
.
GetValue
<
string
>(
'City'
,
''
);
ParsedCustomer
.
AddPair
(
'ShipAddrCity'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'City'
,
''
)));
ParsedCustomer
.
BILL_STATE
:=
BillAddr
.
GetValue
<
string
>(
'CountrySubDivisionCode'
,
''
);
ParsedCustomer
.
AddPair
(
'ShipAddrState'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'CountrySubDivisionCode'
,
''
)));
ParsedCustomer
.
BILL_ZIP
:=
BillAddr
.
GetValue
<
string
>(
'PostalCode'
,
''
);
ParsedCustomer
.
AddPair
(
'ShipAddrZip'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'PostalCode'
,
''
)));
Line1
:=
BillAddr
.
GetValue
<
string
>(
'Line1'
,
''
);
Line2
:=
BillAddr
.
GetValue
<
string
>(
'Line2'
,
''
);
if
Line2
<>
''
then
if
Line2
<>
''
then
begin
begin
ParsedCustomer
.
AddPair
(
'ShipAddrLine1'
,
TJSONString
.
Create
(
Line2
));
ParsedCustomer
.
BILL_ADDRESS
:=
Line2
;
ParsedCustomer
.
AddPair
(
'ShipAddrContact'
,
TJSONString
.
Create
(
Line1
));
ParsedCustomer
.
BILL_CONTACT
:=
Line1
;
ParsedCustomer
.
AddPair
(
'ShipAddr'
,
ParsedCustomer
.
BILL_ADDRESS_BLOCK
:=
Customer
.
GetValue
<
string
>(
'DisplayName'
)
+
sLineBreak
+
TJSONString
.
Create
(
Customer
.
GetValue
<
string
>(
'DisplayName'
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'Line1'
,
''
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'Line1'
,
''
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'Line2'
,
''
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'Line2'
,
''
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'City'
,
''
)
+
', '
+
BillAddr
.
GetValue
(
'City'
,
''
)
+
', '
+
BillAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
)
+
' '
+
BillAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
)
+
' '
+
BillAddr
.
GetValue
(
'PostalCode'
,
''
)
BillAddr
.
GetValue
(
'PostalCode'
,
''
)
)
);
end
end
else
else
begin
begin
ParsedCustomer
.
AddPair
(
'ShipAddrLine1'
,
TJSONString
.
Create
(
Line1
));
ParsedCustomer
.
BILL_ADDRESS
:=
Line1
;
ParsedCustomer
.
AddPair
(
'ShipAddrContact'
,
''
);
ParsedCustomer
.
BILL_CONTACT
:=
''
;
ParsedCustomer
.
AddPair
(
'ShipAddr'
,
ParsedCustomer
.
BILL_ADDRESS_BLOCK
:=
Customer
.
GetValue
<
string
>(
'DisplayName'
)
+
sLineBreak
+
TJSONString
.
Create
(
Customer
.
GetValue
<
string
>(
'DisplayName'
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'Line1'
,
''
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'Line1'
,
''
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'City'
,
''
)
+
', '
+
BillAddr
.
GetValue
(
'City'
,
''
)
+
', '
+
BillAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
)
+
' '
+
BillAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
)
+
' '
+
BillAddr
.
GetValue
(
'PostalCode'
,
''
)
BillAddr
.
GetValue
(
'PostalCode'
,
''
)
)
);
end
;
end
;
end
;
end
;
Result
.
AddElement
(
ParsedCustomer
);
// Handle Ship Address
if
Customer
.
GetValue
(
'ShipAddr'
)
is
TJSONObject
then
begin
ShipAddr
:=
Customer
.
GetValue
(
'ShipAddr'
)
as
TJSONObject
;
ParsedCustomer
.
city
:=
ShipAddr
.
GetValue
<
string
>(
'City'
,
''
);
ParsedCustomer
.
state
:=
ShipAddr
.
GetValue
<
string
>(
'CountrySubDivisionCode'
,
''
);
ParsedCustomer
.
zip
:=
ShipAddr
.
GetValue
<
string
>(
'PostalCode'
,
''
);
Line1
:=
ShipAddr
.
GetValue
<
string
>(
'Line1'
,
''
);
Line2
:=
ShipAddr
.
GetValue
<
string
>(
'Line2'
,
''
);
if
Line2
<>
''
then
begin
ParsedCustomer
.
shipping_address
:=
Line2
;
ParsedCustomer
.
contact
:=
Line1
;
ParsedCustomer
.
ship_block
:=
Customer
.
GetValue
<
string
>(
'DisplayName'
)
+
sLineBreak
+
ShipAddr
.
GetValue
(
'Line1'
,
''
)
+
sLineBreak
+
ShipAddr
.
GetValue
(
'Line2'
,
''
)
+
sLineBreak
+
ShipAddr
.
GetValue
(
'City'
,
''
)
+
', '
+
ShipAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
)
+
' '
+
ShipAddr
.
GetValue
(
'PostalCode'
,
''
)
end
else
begin
ParsedCustomer
.
shipping_address
:=
Line1
;
ParsedCustomer
.
contact
:=
''
;
ParsedCustomer
.
ship_block
:=
Customer
.
GetValue
<
string
>(
'DisplayName'
)
+
sLineBreak
+
ShipAddr
.
GetValue
(
'Line1'
,
''
)
+
sLineBreak
+
ShipAddr
.
GetValue
(
'City'
,
''
)
+
', '
+
ShipAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
)
+
' '
+
ShipAddr
.
GetValue
(
'PostalCode'
,
''
)
end
;
end
;
if
Customer
.
GetValue
(
'CustomerTypeRef'
)
is
TJSONObject
then
begin
CustomerTypeRef
:=
Customer
.
GetValue
(
'CustomerTypeRef'
)
as
TJSONObject
;
logger
.
Log
(
5
,
CustomerTypeRef
.
ToJSON
);
ParsedCustomer
.
RepUser
:=
GetCustomerType
(
CustomerTypeRef
.
GetValue
<
string
>(
'value'
));
end
;
result
:=
ParsedCustomer
;
except
except
ParsedCustomer
.
Free
;
raise
;
raise
;
end
;
end
;
end
;
end
;
except
except
on
E
:
Exception
do
on
E
:
Exception
do
begin
begin
Logger
.
Log
(
2
,
'Error in getQBCustomer
s
: '
+
E
.
Message
);
Logger
.
Log
(
2
,
'Error in getQBCustomer: '
+
E
.
Message
);
raise
EXDataHttpException
.
Create
(
500
,
'Unable to retrieve QuickBooks Customers: A QuickBooks interface error has occurred!'
);
raise
EXDataHttpException
.
Create
(
500
,
'Unable to retrieve QuickBooks Customers: A QuickBooks interface error has occurred!'
);
end
;
end
;
end
;
end
;
...
@@ -2988,6 +3143,102 @@ begin
...
@@ -2988,6 +3143,102 @@ begin
restClient
.
Free
;
restClient
.
Free
;
restRequest
.
Free
;
restRequest
.
Free
;
restResponse
.
Free
;
restResponse
.
Free
;
logger
.
Log
(
3
,
'TLookupService.GetQBCustomer - end'
);
end
;
end
;
function
TLookupService
.
GetCustomerType
(
CustomerTypeId
:
string
):
string
;
var
iniFile
:
TIniFile
;
restClient
:
TRESTClient
;
restRequest
:
TRESTRequest
;
restResponse
:
TRESTResponse
;
param
:
TRESTRequestParameter
;
res
:
string
;
jsValue
:
TJSONValue
;
CustomerType
:
TJSONObject
;
jsObj
:
TJSONObject
;
CustomerTypeList
:
TJSONArray
;
AccessToken
,
RefreshToken
,
CompanyID
,
Client
,
Secret
,
BaseUrl
,
Line1
,
Line2
:
string
;
LastRefresh
:
TDateTime
;
begin
logger
.
Log
(
3
,
'TLookupService.GetQBCustomer - start'
);
iniFile
:=
TIniFile
.
Create
(
ExtractFilePath
(
Application
.
ExeName
)
+
'kgOrdersServer.ini'
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restRequest
:=
TRESTRequest
.
Create
(
nil
);
restResponse
:=
TRESTResponse
.
Create
(
nil
);
try
try
restRequest
.
Client
:=
restClient
;
restRequest
.
Response
:=
restResponse
;
if
iniFile
.
ReadString
(
'Quickbooks'
,
'LastRefresh'
,
''
)
=
''
then
LastRefresh
:=
0
else
LastRefresh
:=
StrToDateTime
(
iniFile
.
ReadString
(
'Quickbooks'
,
'LastRefresh'
,
''
));
if
MinutesBetween
(
Now
,
LastRefresh
)
>
58
then
RefreshAccessToken
();
Client
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'ClientID'
,
''
);
Secret
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'ClientSecret'
,
''
);
CompanyID
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'CompanyID'
,
''
);
RefreshToken
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'RefreshToken'
,
''
);
AccessToken
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'AccessToken'
,
''
);
BaseUrl
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'BaseUrl'
,
''
);
restClient
.
BaseURL
:=
BaseUrl
;
restRequest
.
Method
:=
rmGET
;
res
:=
'/v3/company/'
+
CompanyID
+
'/query?query=select * from CustomerType where Id = '
+
quotedStr
(
CustomerTypeID
)
+
'&minorversion=75'
;
restRequest
.
Resource
:=
res
;
param
:=
restRequest
.
Params
.
AddItem
;
param
.
Name
:=
'Authorization'
;
param
.
Kind
:=
pkHTTPHEADER
;
param
.
Options
:=
param
.
Options
+
[
TRESTRequestParameterOption
.
poDoNotEncode
];
param
.
Value
:=
'Bearer '
+
AccessToken
;
restRequest
.
Execute
;
if
restResponse
.
StatusCode
<>
200
then
begin
Logger
.
Log
(
1
,
'QBO Error: '
+
restResponse
.
StatusText
+
' - '
+
restResponse
.
Content
);
raise
EXDataHttpException
.
Create
(
restResponse
.
StatusCode
,
'QuickBooks API Error: '
+
restResponse
.
StatusText
);
end
;
jsValue
:=
restResponse
.
JSONValue
;
if
not
Assigned
(
jsValue
)
then
Exit
;
jsObj
:=
jsValue
as
TJSONObject
;
if
not
Assigned
(
jsObj
)
then
Exit
;
CustomerTypeList
:=
jsObj
.
GetValue
<
TJSONArray
>(
'QueryResponse.CustomerType'
);
if
not
Assigned
(
CustomerTypeList
)
then
Exit
;
CustomerType
:=
CustomerTypeList
.
Items
[
0
]
as
TJSONObject
;
logger
.
Log
(
5
,
CustomerType
.
ToJSON
());
result
:=
CustomerType
.
GetValue
<
string
>(
'Name'
);
except
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'Error in getQBCustomer: '
+
E
.
Message
);
raise
EXDataHttpException
.
Create
(
500
,
'Unable to retrieve QuickBooks Customers: A QuickBooks interface error has occurred!'
);
end
;
end
;
finally
iniFile
.
Free
;
restClient
.
Free
;
restRequest
.
Free
;
restResponse
.
Free
;
logger
.
Log
(
3
,
'TLookupService.GetQBCustomer - end'
);
end
;
end
;
end
;
end
;
...
@@ -3207,7 +3458,7 @@ var
...
@@ -3207,7 +3458,7 @@ var
param
:
TRESTRequestParameter
;
param
:
TRESTRequestParameter
;
res
:
string
;
res
:
string
;
jsValue
:
TJSONValue
;
jsValue
:
TJSONValue
;
ParsedCustomer
,
Customer
,
BillAddr
:
TJSONObject
;
ParsedCustomer
,
Customer
,
BillAddr
,
CustomerTypeRef
:
TJSONObject
;
jsObj
:
TJSONObject
;
jsObj
:
TJSONObject
;
PhoneObj
:
TJSONObject
;
PhoneObj
:
TJSONObject
;
CustomerList
:
TJSONArray
;
CustomerList
:
TJSONArray
;
...
@@ -3281,7 +3532,6 @@ begin
...
@@ -3281,7 +3532,6 @@ begin
custItem
.
NAME
:=
Customer
.
GetValue
<
string
>(
'DisplayName'
);
custItem
.
NAME
:=
Customer
.
GetValue
<
string
>(
'DisplayName'
);
custItem
.
CUSTOMER_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'CUSTOMER_ID'
).
AsInteger
;
custItem
.
CUSTOMER_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'CUSTOMER_ID'
).
AsInteger
;
custItem
.
SHORT_NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'SHORT_NAME'
).
AsString
;
custItem
.
SHORT_NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'SHORT_NAME'
).
AsString
;
custItem
.
REP_USER_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'REP_USER_ID'
).
AsString
;
// Handle Bill Address
// Handle Bill Address
if
Customer
.
GetValue
(
'BillAddr'
)
is
TJSONObject
then
if
Customer
.
GetValue
(
'BillAddr'
)
is
TJSONObject
then
begin
begin
...
@@ -3313,8 +3563,15 @@ begin
...
@@ -3313,8 +3563,15 @@ begin
BillAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
)
+
' '
+
BillAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
)
+
' '
+
BillAddr
.
GetValue
(
'PostalCode'
,
''
)
BillAddr
.
GetValue
(
'PostalCode'
,
''
)
end
;
end
;
end
;
if
Customer
.
GetValue
(
'CustomerTypeRef'
)
is
TJSONObject
then
begin
CustomerTypeRef
:=
Customer
.
GetValue
(
'CustomerTypeRef'
)
as
TJSONObject
;
logger
.
Log
(
5
,
CustomerTypeRef
.
ToJSON
);
custItem
.
QB_TYPE
:=
GetCustomerType
(
CustomerTypeRef
.
GetValue
<
string
>(
'value'
));
end
;
end
;
Result
:=
custItem
;
Result
:=
custItem
;
except
except
ParsedCustomer
.
Free
;
ParsedCustomer
.
Free
;
...
@@ -3452,7 +3709,6 @@ begin
...
@@ -3452,7 +3709,6 @@ begin
if
JSONData
=
nil
then
if
JSONData
=
nil
then
raise
Exception
.
Create
(
'Invalid JSON format'
);
raise
Exception
.
Create
(
'Invalid JSON format'
);
mode
:=
JSONData
.
GetValue
<
string
>(
'mode'
);
QB_LIST_ID
:=
JSONData
.
GetValue
<
string
>(
'QB_LIST_ID'
);
QB_LIST_ID
:=
JSONData
.
GetValue
<
string
>(
'QB_LIST_ID'
);
// Update RevisionID
// Update RevisionID
...
@@ -3491,14 +3747,13 @@ begin
...
@@ -3491,14 +3747,13 @@ begin
end
;
end
;
OrdersDB
.
UniQuery1
.
FieldByName
(
'CUSTOMER_ID'
).
AsInteger
:=
CustomerID
;
OrdersDB
.
UniQuery1
.
FieldByName
(
'CUSTOMER_ID'
).
AsInteger
:=
CustomerID
;
OrdersDB
.
UniQuery1
.
FieldByName
(
'QB_TYPE'
).
AsString
:=
JSONData
.
GetValue
<
string
>(
'RepUser'
);
JSONData
.
AddPair
(
'customer_id'
,
TJSONNumber
.
Create
(
CustomerID
));
JSONData
.
AddPair
(
'customer_id'
,
TJSONNumber
.
Create
(
CustomerID
));
OrdersDB
.
UniQuery1
.
Post
;
OrdersDB
.
UniQuery1
.
Post
;
if
mode
=
'ADD'
then
msg
:=
'Success: Customer Successfully Added'
;
msg
:=
'Success: Customer Successfully Added'
else
msg
:=
'Success: Customer Successfully Edited'
;
Result
:=
TJSONObject
.
Create
;
Result
:=
TJSONObject
.
Create
;
Result
.
AddPair
(
'status'
,
msg
);
Result
.
AddPair
(
'status'
,
msg
);
...
@@ -3529,6 +3784,7 @@ begin
...
@@ -3529,6 +3784,7 @@ begin
Field
.
AsString
:=
Pair
.
JsonValue
.
Value
;
Field
.
AsString
:=
Pair
.
JsonValue
.
Value
;
end
;
end
;
end
;
end
;
OrdersDB
.
UniQuery1
.
FieldByName
(
'address'
).
AsString
:=
JSONData
.
GetValue
<
string
>(
'shipping_address'
);
OrdersDB
.
UniQuery1
.
Post
;
OrdersDB
.
UniQuery1
.
Post
;
end
;
end
;
...
...
kgOrdersServer/Source/qbAPI.dfm
View file @
151f60b4
...
@@ -201,11 +201,19 @@ object fQB: TfQB
...
@@ -201,11 +201,19 @@ object fQB: TfQB
Width = 982
Width = 982
Height = 153
Height = 153
Align = alClient
Align = alClient
Color = clWhite
DrawingStyle = gdsClassic
DrawingStyle = gdsClassic
FixedColor = clWhite
FixedColor = clWhite
Font.Charset = DEFAULT_CHARSET
Font.Color = clBlack
Font.Height = -12
Font.Name = 'Segoe UI'
Font.Style = []
Options = [goVertLine, goHorzLine, goRangeSelect, goFixedRowDefAlign]
ParentFont = False
TabOrder = 0
TabOrder = 0
GridLineColor = 1
3948116
GridLineColor = 1
5987699
GridFixedLineColor = 1
1250603
GridFixedLineColor = 1
5987699
OnClickCell = asgData2ClickCell
OnClickCell = asgData2ClickCell
ActiveCellFont.Charset = DEFAULT_CHARSET
ActiveCellFont.Charset = DEFAULT_CHARSET
ActiveCellFont.Color = 4474440
ActiveCellFont.Color = 4474440
...
@@ -271,7 +279,7 @@ object fQB: TfQB
...
@@ -271,7 +279,7 @@ object fQB: TfQB
FixedRowHeight = 22
FixedRowHeight = 22
FixedRowAlways = True
FixedRowAlways = True
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Color =
3881787
FixedFont.Color =
clBlack
FixedFont.Height = -11
FixedFont.Height = -11
FixedFont.Name = 'Segoe UI'
FixedFont.Name = 'Segoe UI'
FixedFont.Style = [fsBold]
FixedFont.Style = [fsBold]
...
@@ -302,7 +310,7 @@ object fQB: TfQB
...
@@ -302,7 +310,7 @@ object fQB: TfQB
PrintSettings.FooterFont.Name = 'Segoe UI'
PrintSettings.FooterFont.Name = 'Segoe UI'
PrintSettings.FooterFont.Style = []
PrintSettings.FooterFont.Style = []
PrintSettings.PageNumSep = '/'
PrintSettings.PageNumSep = '/'
SearchFooter.ColorTo = cl
Non
e
SearchFooter.ColorTo = cl
Whit
e
SearchFooter.FindNextCaption = 'Find &next'
SearchFooter.FindNextCaption = 'Find &next'
SearchFooter.FindPrevCaption = 'Find &previous'
SearchFooter.FindPrevCaption = 'Find &previous'
SearchFooter.Font.Charset = DEFAULT_CHARSET
SearchFooter.Font.Charset = DEFAULT_CHARSET
...
@@ -322,7 +330,7 @@ object fQB: TfQB
...
@@ -322,7 +330,7 @@ object fQB: TfQB
SortSettings.HeaderColorTo = clWhite
SortSettings.HeaderColorTo = clWhite
SortSettings.HeaderMirrorColor = clWhite
SortSettings.HeaderMirrorColor = clWhite
SortSettings.HeaderMirrorColorTo = clWhite
SortSettings.HeaderMirrorColorTo = clWhite
Version = '9.
1.6.4
'
Version = '9.
2.2.0
'
ColWidths = (
ColWidths = (
64
64
64
64
...
@@ -648,7 +656,7 @@ object fQB: TfQB
...
@@ -648,7 +656,7 @@ object fQB: TfQB
Left = 1
Left = 1
Top = 26
Top = 26
Width = 980
Width = 980
Height = 17
0
Height = 17
1
Caption = 'Memo1'
Caption = 'Memo1'
DoubleBuffered = False
DoubleBuffered = False
PageAppearance.BorderColor = clNone
PageAppearance.BorderColor = clNone
...
@@ -713,12 +721,13 @@ object fQB: TfQB
...
@@ -713,12 +721,13 @@ object fQB: TfQB
Left = 2
Left = 2
Top = 35
Top = 35
Width = 976
Width = 976
Height = 13
3
Height = 13
4
Align = alClient
Align = alClient
Lines.Strings = (
Lines.Strings = (
'')
'')
ScrollBars = ssVertical
ScrollBars = ssVertical
TabOrder = 0
TabOrder = 0
ExplicitHeight = 133
end
end
object Panel2: TPanel
object Panel2: TPanel
Left = 2
Left = 2
...
@@ -742,7 +751,7 @@ object fQB: TfQB
...
@@ -742,7 +751,7 @@ object fQB: TfQB
Left = 1
Left = 1
Top = 26
Top = 26
Width = 980
Width = 980
Height = 17
0
Height = 17
1
Caption = 'QB API Memo'
Caption = 'QB API Memo'
DoubleBuffered = False
DoubleBuffered = False
PageAppearance.BorderColor = clNone
PageAppearance.BorderColor = clNone
...
@@ -807,13 +816,14 @@ object fQB: TfQB
...
@@ -807,13 +816,14 @@ object fQB: TfQB
Left = 2
Left = 2
Top = 35
Top = 35
Width = 976
Width = 976
Height = 13
3
Height = 13
4
Align = alClient
Align = alClient
Lines.Strings = (
Lines.Strings = (
'Memo2')
'Memo2')
ScrollBars = ssVertical
ScrollBars = ssVertical
TabOrder = 0
TabOrder = 0
WordWrap = False
WordWrap = False
ExplicitHeight = 133
end
end
object Panel3: TPanel
object Panel3: TPanel
Left = 2
Left = 2
...
@@ -837,7 +847,7 @@ object fQB: TfQB
...
@@ -837,7 +847,7 @@ object fQB: TfQB
Left = 1
Left = 1
Top = 26
Top = 26
Width = 980
Width = 980
Height = 17
0
Height = 17
1
Caption = 'AdvOfficePager13'
Caption = 'AdvOfficePager13'
DoubleBuffered = False
DoubleBuffered = False
PageAppearance.BorderColor = clNone
PageAppearance.BorderColor = clNone
...
@@ -945,11 +955,19 @@ object fQB: TfQB
...
@@ -945,11 +955,19 @@ object fQB: TfQB
Width = 982
Width = 982
Height = 205
Height = 205
Align = alClient
Align = alClient
Color = clWhite
DrawingStyle = gdsClassic
DrawingStyle = gdsClassic
FixedColor = clWhite
FixedColor = clWhite
Font.Charset = DEFAULT_CHARSET
Font.Color = clBlack
Font.Height = -12
Font.Name = 'Segoe UI'
Font.Style = []
Options = [goVertLine, goHorzLine, goRangeSelect, goFixedRowDefAlign]
ParentFont = False
TabOrder = 0
TabOrder = 0
GridLineColor = 1
3948116
GridLineColor = 1
5987699
GridFixedLineColor = 1
1250603
GridFixedLineColor = 1
5987699
OnClickCell = asgDataClickCell
OnClickCell = asgDataClickCell
ActiveCellFont.Charset = DEFAULT_CHARSET
ActiveCellFont.Charset = DEFAULT_CHARSET
ActiveCellFont.Color = 4474440
ActiveCellFont.Color = 4474440
...
@@ -1015,7 +1033,7 @@ object fQB: TfQB
...
@@ -1015,7 +1033,7 @@ object fQB: TfQB
FixedRowHeight = 22
FixedRowHeight = 22
FixedRowAlways = True
FixedRowAlways = True
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Color =
3881787
FixedFont.Color =
clBlack
FixedFont.Height = -11
FixedFont.Height = -11
FixedFont.Name = 'Segoe UI'
FixedFont.Name = 'Segoe UI'
FixedFont.Style = [fsBold]
FixedFont.Style = [fsBold]
...
@@ -1046,7 +1064,7 @@ object fQB: TfQB
...
@@ -1046,7 +1064,7 @@ object fQB: TfQB
PrintSettings.FooterFont.Name = 'Segoe UI'
PrintSettings.FooterFont.Name = 'Segoe UI'
PrintSettings.FooterFont.Style = []
PrintSettings.FooterFont.Style = []
PrintSettings.PageNumSep = '/'
PrintSettings.PageNumSep = '/'
SearchFooter.ColorTo = cl
Non
e
SearchFooter.ColorTo = cl
Whit
e
SearchFooter.FindNextCaption = 'Find &next'
SearchFooter.FindNextCaption = 'Find &next'
SearchFooter.FindPrevCaption = 'Find &previous'
SearchFooter.FindPrevCaption = 'Find &previous'
SearchFooter.Font.Charset = DEFAULT_CHARSET
SearchFooter.Font.Charset = DEFAULT_CHARSET
...
@@ -1066,7 +1084,7 @@ object fQB: TfQB
...
@@ -1066,7 +1084,7 @@ object fQB: TfQB
SortSettings.HeaderColorTo = clWhite
SortSettings.HeaderColorTo = clWhite
SortSettings.HeaderMirrorColor = clWhite
SortSettings.HeaderMirrorColor = clWhite
SortSettings.HeaderMirrorColorTo = clWhite
SortSettings.HeaderMirrorColorTo = clWhite
Version = '9.
1.6.4
'
Version = '9.
2.2.0
'
ColWidths = (
ColWidths = (
64
64
64
64
...
...
kgOrdersServer/bin/kgOrdersServer - Copy.ini
View file @
151f60b4
[Settings]
[Settings]
MemoLogLevel
=
3
MemoLogLevel
=
3
FileLogLevel
=
4
FileLogLevel
=
4
webClientVersion
=
0.9.1
3
webClientVersion
=
0.9.1
4.1
LogFileNum
=
10
0
LogFileNum
=
10
5
[Database]
[Database]
Server
=
192.168.116.132
--
Server
=
192.168.116.132
--Server
=
192.168.102.129
--Server
=
192.168.102.129
--Server
=
192.168.75.133
--Server
=
192.168.75.133
--
Server
=
192.168.159.10
Server
=
192.168.159.10
--Database
=
kg_order_entry
--Database
=
kg_order_entry
--Username
=
root
--Username
=
root
--Password
=
emsys01
--Password
=
emsys01
...
@@ -17,8 +17,17 @@ Server=192.168.116.132
...
@@ -17,8 +17,17 @@ Server=192.168.116.132
[Quickbooks]
[Quickbooks]
Enabled
=
1
Enabled
=
1
CompanyID
=
9341454336461805
CompanyID
=
9341454336461805
ClientID
=
ABYqlDx1EsacZYXvHIJ7RDB7zmnQdwABU3fwQLIZPmBgU0VW1P
--BaseUrl
=
https://sandbox-quickbooks.api.intuit.com
ClientSecret
=
PM7OnvQWsgOqjWfDpZAnyRttDN9446Am6d85pDxr
--ClientID
=
ABYqlDx1EsacZYXvHIJ7RDB7zmnQdwABU3fwQLIZPmBgU0VW1P
RefreshToken
=
RT1-246-H0-1774553264l4plin9y3f32d4cm7ncw
--ClientSecret
=
PM7OnvQWsgOqjWfDpZAnyRttDN9446Am6d85pDxr
AccessToken
=
eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2IiwieC5vcmciOiJIMCJ9..HDUyB-xbInAP_lJcZiix5w.REb-0D5HZfvm8UE7cWifSiXZTJK0_3Bpp44ybTT6-9h7fT1zA0-oMzxUHO-bL4tTWuVnJODgRHfHAadOml13dMTKOQ4msyW3Y5g-BF91aoQZi-HKw35w_gClKJ6zSn99AIwnffo_IhkotW8FY1wC7gRkDzHsFMajOWQWmji_EsDblGQW97_eW8Z6rwUCbsoWpankR5JOcZtvD5j9dmzQdaPkKJXqlB_6kLC-WXEpySA7heWsNfA1iq3Bn56J4C6_HxvpFZ8i-gWUE42-Ls1uhGG6EQw9vjDFRojG6Fvv0oK_bbKSZ24NqerGoeFmlWTHoCl6pQXX12DZgmJp3vwCLyAzw8dTFzRH4QKoN7D5NAQ3rp2LtzpIBjiuBxJIvr20GSDO6lgNzXGusNffmkJC5cPxh7NmwzbubFw6yL8P7ZGKIdviIaHPS0u5pGc3Bw_qJ0bKaRXTxMmyIAUR3BtExZMzHLN6pVij8R9rpEtGvPo.tA4XoJdViQb1JKoL9eDevw
--RedirectUri
=
http://localhost:2004/kgOrders/auth/AuthService/QBAuthorize
LastRefresh
=
12/15/2025
BaseUrl
=
https://quickbooks.api.intuit.com/v3
ClientID
=
ABXLUuBrwvodIZMtaPcBg9acYBPafUxP80qk5aQ9HOAw1i2W3s
ClientSecret
=
a0DSQZdXH1FRTAFhpp2igeNFKxu7kPlzt0az7nbQ
RedirectUri
=
https://webapps.em-sys.net/kgOrdersTest/auth/AuthService/QBAuthorize
RefreshToken
=
RT1-143-H0-1783193667426ef30b5u81echlyi4h
AccessToken
=
eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2IiwieC5vcmciOiJIMCJ9..aoofv422rMR8s5qxVjkk0A.n0SzfMojJdSwS6plIGJO3gT2gM2_xEGEFr1ZDBqFWA40XoHTixNhZ0HvndlcyDiaofP8WBDH7GIG2zAjVK67winsZ02b9ylTE9PnMWCgl2rskMccDeP9yDabJjgM7113cCoMHj6m93g1sQu2tKH5zV_5wjj6Q1KwcJgs8fmutdWkpsYD-DIn46ySVDjPaDa9EN4lLMPD5ip20rF0p_Mol-Fh4zRRhMF0BImRxtgHGfFBHAtntd0wBQ35vYlyfnG-FnK25NFxVhNQchA3JpYaLIw_qLaZ7LjHIlOhX0S64ROUq80LLwjCpctHFX-YYFUAL4G0DSe22cz9RgJmxLy-PvUAnpCia3NPeft0Vtg2Ysg1-WH8mEJb3tQWZOLaEKecNO7_SsA4Xdfk5pl0y0ukk8KQHQmPwsaYP1OAd9C6LFDqyyIXY6ULZigPUiiHRHc0-pcvFLuz_kaovO9-kapokXO6WhL9Fc9GUgn1Sn6PhT4.6r8dJQ6gVezO3SLIssoNBw
LastRefresh
=
3/26/2026 11:28:04 AM
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