Commit 5be931b6 by Cam Hayes

Cleaned up warnings on server side

parent e9209347
...@@ -17,7 +17,6 @@ type ...@@ -17,7 +17,6 @@ type
TAuthService = class(TInterfacedObject, IAuthService) TAuthService = class(TInterfacedObject, IAuthService)
strict private strict private
authDB: TAuthDatabase; authDB: TAuthDatabase;
function GetQuery: TUniQuery;
private private
userName: string; userName: string;
userFullName: string; userFullName: string;
...@@ -28,12 +27,12 @@ type ...@@ -28,12 +27,12 @@ type
userEmail: string; userEmail: string;
userStatus: string; userStatus: string;
qbEnabled: boolean; qbEnabled: boolean;
procedure AfterConstruction; override;
procedure BeforeDestruction; override;
function CheckUser(const user, password: string): Integer; function CheckUser(const user, password: string): Integer;
public public
function Login(const user, password: string): string; function Login(const user, password: string): string;
function VerifyVersion(ClientVersion: string): TJSONObject; function VerifyVersion(ClientVersion: string): TJSONObject;
procedure AfterConstruction; override;
procedure BeforeDestruction; override;
end; end;
implementation implementation
...@@ -72,11 +71,6 @@ begin ...@@ -72,11 +71,6 @@ begin
inherited; inherited;
end; end;
function TAuthService.GetQuery: TUniQuery;
begin
Result := authDB.uq;
end;
function TAuthService.VerifyVersion(ClientVersion: string): TJSONObject; function TAuthService.VerifyVersion(ClientVersion: string): TJSONObject;
var var
iniFile: TIniFile; iniFile: TIniFile;
...@@ -115,8 +109,6 @@ var ...@@ -115,8 +109,6 @@ var
JWT: TJWT; JWT: TJWT;
begin begin
Logger.Log(3, Format( 'AuthService.Login - User: "%s"', [User])); Logger.Log(3, Format( 'AuthService.Login - User: "%s"', [User]));
userState := CheckUser( user, password );
try try
userState := CheckUser(user, password); userState := CheckUser(user, password);
except except
...@@ -174,12 +166,10 @@ end; ...@@ -174,12 +166,10 @@ end;
function TAuthService.CheckUser(const user, password: string): Integer; function TAuthService.CheckUser(const user, password: string): Integer;
var var
userStr: string;
SQL: string; SQL: string;
name: string; name: string;
checkString: string; checkString: string;
begin begin
Result := 0;
Logger.Log(1, Format('AuthService.CheckUser - User: "%s"', [user]) ); Logger.Log(1, Format('AuthService.CheckUser - User: "%s"', [user]) );
SQL := 'select * from users where USER_NAME = ' + QuotedStr(user); SQL := 'select * from users where USER_NAME = ' + QuotedStr(user);
DoQuery(authDB.uq, SQL); DoQuery(authDB.uq, SQL);
......
...@@ -43,8 +43,6 @@ object FData: TFData ...@@ -43,8 +43,6 @@ object FData: TFData
Lines.Strings = ( Lines.Strings = (
'Memo1') 'Memo1')
TabOrder = 1 TabOrder = 1
ExplicitLeft = -2
ExplicitTop = 435
end end
object DBAdvGrid1: TDBAdvGrid object DBAdvGrid1: TDBAdvGrid
Left = 6 Left = 6
...@@ -174,7 +172,7 @@ object FData: TFData ...@@ -174,7 +172,7 @@ object FData: TFData
SortSettings.HeaderColorTo = clWhite SortSettings.HeaderColorTo = clWhite
SortSettings.HeaderMirrorColor = clWhite SortSettings.HeaderMirrorColor = clWhite
SortSettings.HeaderMirrorColorTo = clWhite SortSettings.HeaderMirrorColorTo = clWhite
Version = '2.8.3.3' Version = '2.8.3.8'
AutoCreateColumns = True AutoCreateColumns = True
AutoRemoveColumns = True AutoRemoveColumns = True
Columns = < Columns = <
...@@ -755,7 +753,7 @@ object FData: TFData ...@@ -755,7 +753,7 @@ object FData: TFData
SortSettings.HeaderColorTo = clWhite SortSettings.HeaderColorTo = clWhite
SortSettings.HeaderMirrorColor = clWhite SortSettings.HeaderMirrorColor = clWhite
SortSettings.HeaderMirrorColorTo = clWhite SortSettings.HeaderMirrorColorTo = clWhite
Version = '2.8.3.3' Version = '2.8.3.8'
AutoCreateColumns = True AutoCreateColumns = True
AutoRemoveColumns = True AutoRemoveColumns = True
Columns = < Columns = <
......
...@@ -130,8 +130,6 @@ type ...@@ -130,8 +130,6 @@ type
procedure Button1Click(Sender: TObject); procedure Button1Click(Sender: TObject);
private private
kgDB: TApiDatabase; kgDB: TApiDatabase;
accountSID: string;
authHeader: string;
public public
procedure RunOrdersReport(searchOptions: string); procedure RunOrdersReport(searchOptions: string);
end; end;
...@@ -190,7 +188,6 @@ procedure TFData.btnFindClick(Sender: TObject); ...@@ -190,7 +188,6 @@ procedure TFData.btnFindClick(Sender: TObject);
// whereSQL: where section of the SQL that is built in the function // whereSQL: where section of the SQL that is built in the function
var var
SQL: string; SQL: string;
whereSQL: string;
begin begin
Memo1.Lines.Add(uqUsers.Connection.Server); Memo1.Lines.Add(uqUsers.Connection.Server);
SQL := 'select * from users'; SQL := 'select * from users';
......
...@@ -72,14 +72,14 @@ type ...@@ -72,14 +72,14 @@ type
function CreateStatusSearchInfo(params: TStringList; statusNum: string): TStatusSearchInfo; function CreateStatusSearchInfo(params: TStringList; statusNum: string): TStatusSearchInfo;
function SetStatus(statusOptions: string): string; function SetStatus(statusOptions: string): string;
procedure AddToOrdersTable(mode, ORDER_TYPE: string; JSONData: TJSONObject); procedure AddToOrdersTable(mode, ORDER_TYPE: string; JSONData: TJSONObject);
procedure AfterConstruction; override;
procedure BeforeDestruction; override;
procedure AddToRevisionsTable(OrderID, table: string; order: TJSONObject); procedure AddToRevisionsTable(OrderID, table: string; order: TJSONObject);
procedure SaveTokens(AccessToken, RefreshToken: string); procedure SaveTokens(AccessToken, RefreshToken: string);
function RefreshAccessToken: string; function RefreshAccessToken: string;
function ImportQBCustomer(CustomerInfo: string): TJSONObject; function ImportQBCustomer(CustomerInfo: string): TJSONObject;
procedure AddAddrBlock(prefix: string; AddrJSON: TJSONObject);
function AddEstimate(orderInfo: string): TJSONObject; function AddEstimate(orderInfo: string): TJSONObject;
public
procedure AfterConstruction; override;
procedure BeforeDestruction; override;
end; end;
...@@ -135,16 +135,18 @@ begin ...@@ -135,16 +135,18 @@ begin
BillAddrJSON := TJSONObject.Create; BillAddrJSON := TJSONObject.Create;
ShipAddrJSON := TJSONObject.Create; ShipAddrJSON := TJSONObject.Create;
EstimateJSON := TJSONObject.Create; EstimateJSON := TJSONObject.Create;
CustomerRefJSON := TJSONObject.Create;
CustomFields := TJSONArray.Create; CustomFields := TJSONArray.Create;
CustomField := TJSONObject.Create; CustomField := TJSONObject.Create;
LineArray := TJSONArray.Create; LineArray := TJSONArray.Create;
LineObj := TJSONObject.Create;
DetailObj := TJSONObject.Create; DetailObj := TJSONObject.Create;
ItemRefObj := TJSONObject.Create; ItemRefObj := TJSONObject.Create;
TaxCodeRef := TJSONObject.Create; TaxCodeRef := TJSONObject.Create;
TxnTaxCodeRef := TJSONObject.Create; TxnTaxCodeRef := TJSONObject.Create;
TxnTaxDetail := TJSONObject.Create; TxnTaxDetail := TJSONObject.Create;
restClient := TRESTClient.Create(nil);
restRequest := TRESTRequest.Create(nil);
restResponse := TRESTResponse.Create(nil);
iniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini');
Logger.Log(3, 'TLookupService.AddEstimate'); Logger.Log(3, 'TLookupService.AddEstimate');
try try
try try
...@@ -250,17 +252,14 @@ begin ...@@ -250,17 +252,14 @@ begin
end; end;
restClient := TRESTClient.Create(nil);
restClient.BaseURL := 'https://sandbox-quickbooks.api.intuit.com'; restClient.BaseURL := 'https://sandbox-quickbooks.api.intuit.com';
restRequest := TRESTRequest.Create(nil);
restRequest.Client := restClient; restRequest.Client := restClient;
restResponse := TRESTResponse.Create(nil);
restRequest.Response := restResponse; restRequest.Response := restResponse;
iniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini');
if iniFile.ReadString('Quickbooks', 'LastRefresh', '') = '' then if iniFile.ReadString('Quickbooks', 'LastRefresh', '') = '' then
LastRefresh := 0 LastRefresh := 0
else else
...@@ -479,7 +478,6 @@ function TLookupService.GetCustomer(ID: string): TCustomerItem; ...@@ -479,7 +478,6 @@ function TLookupService.GetCustomer(ID: string): TCustomerItem;
var var
SQL: string; SQL: string;
ADDRESS: TAddressItem; ADDRESS: TAddressItem;
USER: TUserItem;
begin begin
logger.Log(3, 'TLookupService.GetCustomer'); logger.Log(3, 'TLookupService.GetCustomer');
try try
...@@ -617,14 +615,10 @@ var ...@@ -617,14 +615,10 @@ var
Field: TField; Field: TField;
ShipID: integer; ShipID: integer;
mode: string; mode: string;
temp: string;
msg: string; msg: string;
ship_block: string;
ADDRESS: TJSONObject; ADDRESS: TJSONObject;
ADDRESS_LIST:TJSONArray; ADDRESS_LIST:TJSONArray;
CustomerID: string; CustomerID: string;
JSONArray: TJSONArray;
Item: TAddressItem;
begin begin
logger.Log(3, 'TLookupSerivce.AddShippingAddress'); logger.Log(3, 'TLookupSerivce.AddShippingAddress');
result := TJSONObject.Create; result := TJSONObject.Create;
...@@ -635,13 +629,13 @@ begin ...@@ -635,13 +629,13 @@ begin
mode := JSONData.GetValue<string>('mode'); mode := JSONData.GetValue<string>('mode');
CustomerID := JSONData.GetValue<string>('customer_id'); CustomerID := JSONData.GetValue<string>('customer_id');
if mode = 'EDIT' then
ShipID := JSONData.GetValue<integer>('customer_ship_id');
if mode = 'ADD' then if mode = 'ADD' then
SQL := 'select * from customers_ship where customer_id = 0 and customer_id <> 0' SQL := 'select * from customers_ship where customer_id = 0 and customer_id <> 0'
else else
begin begin
ShipID := JSONData.GetValue<integer>('customer_ship_id');
SQL := 'select * from customers_ship where customer_ship_id = ' + IntToStr(ShipID); SQL := 'select * from customers_ship where customer_ship_id = ' + IntToStr(ShipID);
end; end;
doQuery(ordersDB.UniQuery1, SQL); doQuery(ordersDB.UniQuery1, SQL);
...@@ -716,7 +710,6 @@ var ...@@ -716,7 +710,6 @@ var
DateFormat: TFormatSettings; DateFormat: TFormatSettings;
CustomerID: integer; CustomerID: integer;
mode: string; mode: string;
temp: string;
msg: string; msg: string;
unique: boolean; unique: boolean;
begin begin
...@@ -957,8 +950,6 @@ function TLookupService.createStatusSearchInfo(params: TStringList; statusNum: s ...@@ -957,8 +950,6 @@ function TLookupService.createStatusSearchInfo(params: TStringList; statusNum: s
// statusNum: which status number we are on to make it easier to tell what info // statusNum: which status number we are on to make it easier to tell what info
// we want to take from client. I.E. differentiate between startDate1 and // we want to take from client. I.E. differentiate between startDate1 and
// startDate2 // startDate2
var
statusType: string;
begin begin
result := TStatusSearchInfo.Create; result := TStatusSearchInfo.Create;
result.startDate := params.Values['startDate' + statusNum]; result.startDate := params.Values['startDate' + statusNum];
...@@ -1040,7 +1031,7 @@ function TLookupService.generateOrdersSQL(searchOptions: string): TSQLQuery; ...@@ -1040,7 +1031,7 @@ function TLookupService.generateOrdersSQL(searchOptions: string): TSQLQuery;
var var
params: TStringList; params: TStringList;
PageNum, PageSize: integer; PageNum, PageSize: integer;
OrderBy, offset, limit, direction: string; OrderBy, offset, limit: string;
SQL, whereSQL, orderBySQL: string; SQL, whereSQL, orderBySQL: string;
OrderID, CompanyID, JobName, orderType: string; OrderID, CompanyID, JobName, orderType: string;
status1, status2: TStatusSearchInfo; status1, status2: TStatusSearchInfo;
...@@ -1256,10 +1247,8 @@ function TLookupService.GetCorrugatedOrder(orderInfo: string): TCorrugatedOrder; ...@@ -1256,10 +1247,8 @@ function TLookupService.GetCorrugatedOrder(orderInfo: string): TCorrugatedOrder;
// Gets on singular order from the database for the order entry page. // Gets on singular order from the database for the order entry page.
// orderInfo: the ORDER_ID. // orderInfo: the ORDER_ID.
var var
orderType: string;
orderID: string; orderID: string;
SQL: string; SQL: string;
table: string;
begin begin
logger.Log(3,'TLookupService.GetCorrugatedOrder'); logger.Log(3,'TLookupService.GetCorrugatedOrder');
orderID := orderInfo; orderID := orderInfo;
...@@ -1366,7 +1355,6 @@ end; ...@@ -1366,7 +1355,6 @@ end;
function TLookupService.GetWebOrder(orderInfo: string): TWebOrder; function TLookupService.GetWebOrder(orderInfo: string): TWebOrder;
var var
orderType: string;
orderID: string; orderID: string;
SQL: string; SQL: string;
begin begin
...@@ -1493,7 +1481,6 @@ end; ...@@ -1493,7 +1481,6 @@ end;
function TLookupService.GetCuttingDieOrder(orderInfo: string): TCuttingDie; function TLookupService.GetCuttingDieOrder(orderInfo: string): TCuttingDie;
var var
orderType: string;
orderID: string; orderID: string;
SQL: string; SQL: string;
begin begin
...@@ -1916,7 +1903,6 @@ function TLookupService.AddStatusSchedule(StatusType: string; order: TJSONObject ...@@ -1916,7 +1903,6 @@ function TLookupService.AddStatusSchedule(StatusType: string; order: TJSONObject
// ORDER_ID: order id sent from client if we are in edit mode empty if in add mode // ORDER_ID: order id sent from client if we are in edit mode empty if in add mode
var var
SQL: string; SQL: string;
mode: string;
change: boolean; change: boolean;
date: string; date: string;
begin begin
...@@ -1967,17 +1953,15 @@ var ...@@ -1967,17 +1953,15 @@ var
Status: string; Status: string;
UserID: string; UserID: string;
SQL: string; SQL: string;
NextStatus: string;
StatusField: string;
table: string; table: string;
OrderType: string; OrderType: string;
order: TJSONObject; order: TJSONObject;
begin begin
try
logger.Log(3, 'TLookupService.SetStatus'); logger.Log(3, 'TLookupService.SetStatus');
StatusInfo := TJSONObject.ParseJSONValue(statusOptions) as TJSONObject; StatusInfo := TJSONObject.ParseJSONValue(statusOptions) as TJSONObject;
params := TStringList.Create; params := TStringList.Create;
try try
try
params.Delimiter := '&'; params.Delimiter := '&';
params.StrictDelimiter := true; params.StrictDelimiter := true;
params.DelimitedText := statusOptions; params.DelimitedText := statusOptions;
...@@ -2082,7 +2066,6 @@ var ...@@ -2082,7 +2066,6 @@ var
perspective: string; perspective: string;
QB: string; QB: string;
SQL: string; SQL: string;
dateCreated: TDateTime;
rightsInt: Integer; rightsInt: Integer;
params: TStringList; params: TStringList;
begin begin
...@@ -2094,8 +2077,6 @@ begin ...@@ -2094,8 +2077,6 @@ begin
params.Delimiter := '&'; params.Delimiter := '&';
params.DelimitedText := userInfo; params.DelimitedText := userInfo;
dateCreated := Now;
user := params.Values['username']; user := params.Values['username'];
password := params.Values['password']; password := params.Values['password'];
full_name := params.Values['fullname']; full_name := params.Values['fullname'];
...@@ -2260,12 +2241,11 @@ function TLookupService.AddWebOrder(orderInfo: string): TJSONObject; ...@@ -2260,12 +2241,11 @@ function TLookupService.AddWebOrder(orderInfo: string): TJSONObject;
// and orders_status_schedule. This also functions as an edit function. // and orders_status_schedule. This also functions as an edit function.
// orderInfo - all the inputted order information from client side. // orderInfo - all the inputted order information from client side.
var var
JSONData, ResponseData: TJSONObject; JSONData: TJSONObject;
SQL: string; SQL: string;
Pair: TJSONPair; Pair: TJSONPair;
Field: TField; Field: TField;
DateFormat: TFormatSettings; DateFormat: TFormatSettings;
CurrDate: TDateTime;
ORDER_ID: integer; ORDER_ID: integer;
mode: string; mode: string;
msg: string; msg: string;
...@@ -2357,17 +2337,14 @@ end; ...@@ -2357,17 +2337,14 @@ end;
function TLookupService.AddCuttingDieOrder(orderInfo: string): TJSONObject; function TLookupService.AddCuttingDieOrder(orderInfo: string): TJSONObject;
var var
JSONData, ResponseData: TJSONObject; JSONData: TJSONObject;
SQL: string; SQL: string;
Pair: TJSONPair; Pair: TJSONPair;
Field: TField; Field: TField;
DateFormat: TFormatSettings; DateFormat: TFormatSettings;
CurrDate: TDateTime;
ORDER_ID: integer; ORDER_ID: integer;
mode: string; mode: string;
msg: string; msg: string;
temp: string;
temp2: boolean;
begin begin
logger.Log(3, 'TLookupService.AddCuttingDieOrder'); logger.Log(3, 'TLookupService.AddCuttingDieOrder');
DateFormat := TFormatSettings.Create; DateFormat := TFormatSettings.Create;
...@@ -2456,7 +2433,6 @@ function TLookupService.delOrder(OrderID, orderType, UserID: string): TJSONObjec ...@@ -2456,7 +2433,6 @@ function TLookupService.delOrder(OrderID, orderType, UserID: string): TJSONObjec
var var
table, table2, SQL: string; table, table2, SQL: string;
stream: TStringStream; stream: TStringStream;
DateFormat: TFormatSettings;
JSONValue: TJSONValue; JSONValue: TJSONValue;
JSONObject, DataObject, JSONData: TJSONObject; JSONObject, DataObject, JSONData: TJSONObject;
JSONArray: TJSONArray; JSONArray: TJSONArray;
...@@ -2585,7 +2561,7 @@ end; ...@@ -2585,7 +2561,7 @@ end;
procedure TLookupService.AddToRevisionsTable(OrderID: string; table: string; order: TJSONObject); procedure TLookupService.AddToRevisionsTable(OrderID: string; table: string; order: TJSONObject);
var var
SQL, UserID: string; SQL: string;
Pair: TJSONPair; Pair: TJSONPair;
rev_num, RevisionID: integer; rev_num, RevisionID: integer;
Field: TField; Field: TField;
...@@ -2792,8 +2768,6 @@ var ...@@ -2792,8 +2768,6 @@ var
jsValue: TJSONValue; jsValue: TJSONValue;
jsObj: TJSONObject; jsObj: TJSONObject;
ItemList: TJSONArray; ItemList: TJSONArray;
pair: TJSONPair;
ModifiedList: TJSONArray;
ParsedItem, Item: TJSONObject; ParsedItem, Item: TJSONObject;
I: integer; I: integer;
AccessToken, RefreshToken, CompanyID, Client, Secret, SQL, desc: string; AccessToken, RefreshToken, CompanyID, Client, Secret, SQL, desc: string;
...@@ -2883,28 +2857,17 @@ begin ...@@ -2883,28 +2857,17 @@ begin
end; end;
end; end;
procedure TLookupService.AddAddrBlock(prefix: string; AddrJSON: TJSONObject);
// the point of this function would be to save space in import QB Customer
begin
//TODO
end;
function TLookupService.RefreshAccessToken: string; function TLookupService.RefreshAccessToken: string;
// Refresh Token changes so make sure to save refresh token. // Refresh Token changes so make sure to save refresh token.
var var
IdHTTP: TIdHTTP; IdHTTP: TIdHTTP;
SSLIO: TIdSSLIOHandlerSocketOpenSSL; SSLIO: TIdSSLIOHandlerSocketOpenSSL;
RequestStream: TStringStream; RequestStream: TStringStream;
EncodedAuth, EncodedAuth2, PostData, response: string; EncodedAuth, PostData, response: string;
f: TStringList;
fi: string;
JSObj: TJSONObject; JSObj: TJSONObject;
iniFile: TIniFile; iniFile: TIniFile;
Encoder: TBase64Encoding; Encoder: TBase64Encoding;
AccessToken,RefreshToken,CompanyID,Client,Secret: string; AccessToken,RefreshToken,CompanyID,Client,Secret: string;
LastRefresh: TDateTime;
begin begin
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' ); iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
Client := iniFile.ReadString('Quickbooks', 'ClientID', ''); Client := iniFile.ReadString('Quickbooks', 'ClientID', '');
...@@ -2975,8 +2938,6 @@ end; ...@@ -2975,8 +2938,6 @@ end;
procedure TLookupService.SaveTokens(AccessToken, RefreshToken: string); procedure TLookupService.SaveTokens(AccessToken, RefreshToken: string);
var var
f: TStringList;
iniStr, line: string;
iniFile: TIniFile; iniFile: TIniFile;
begin begin
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' ); iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
...@@ -2989,12 +2950,6 @@ begin ...@@ -2989,12 +2950,6 @@ begin
finally finally
IniFile.Free; IniFile.Free;
end; end;
f := TStringList.Create;
// Save to file (overwrites existing file)
f.SaveToFile('QB.txt');
f.Free;
end; end;
function TLookupService.ImportQBCustomer(CustomerInfo: string): TJSONObject; function TLookupService.ImportQBCustomer(CustomerInfo: string): TJSONObject;
...@@ -3006,10 +2961,8 @@ var ...@@ -3006,10 +2961,8 @@ var
DateFormat: TFormatSettings; DateFormat: TFormatSettings;
CustomerID: Integer; CustomerID: Integer;
mode: string; mode: string;
temp: string;
msg: string; msg: string;
QB_LIST_ID: string; QB_LIST_ID: string;
unique: Boolean;
begin begin
logger.Log(3, 'TLookupService.ImportQBCustomer'); logger.Log(3, 'TLookupService.ImportQBCustomer');
DateFormat := TFormatSettings.Create; DateFormat := TFormatSettings.Create;
...@@ -3023,8 +2976,6 @@ begin ...@@ -3023,8 +2976,6 @@ begin
mode := JSONData.GetValue<string>('mode'); mode := JSONData.GetValue<string>('mode');
QB_LIST_ID := JSONData.GetValue<string>('QB_LIST_ID'); QB_LIST_ID := JSONData.GetValue<string>('QB_LIST_ID');
if mode = 'ADD' then
begin
// Update RevisionID // Update RevisionID
SQL := 'UPDATE idfield SET KEYVALUE = KEYVALUE + 1 WHERE KEYNAME = ' + QuotedStr('GEN_CUSTOMER_ID'); SQL := 'UPDATE idfield SET KEYVALUE = KEYVALUE + 1 WHERE KEYNAME = ' + QuotedStr('GEN_CUSTOMER_ID');
OrdersDB.UniQuery1.SQL.Text := SQL; OrdersDB.UniQuery1.SQL.Text := SQL;
...@@ -3034,7 +2985,6 @@ begin ...@@ -3034,7 +2985,6 @@ begin
SQL := 'SELECT KEYVALUE FROM idfield WHERE KEYNAME = ' + QuotedStr('GEN_CUSTOMER_ID'); SQL := 'SELECT KEYVALUE FROM idfield WHERE KEYNAME = ' + QuotedStr('GEN_CUSTOMER_ID');
doQuery(OrdersDB.UniQuery1, SQL); doQuery(OrdersDB.UniQuery1, SQL);
CustomerID := OrdersDB.UniQuery1.FieldByName('KEYVALUE').AsInteger; CustomerID := OrdersDB.UniQuery1.FieldByName('KEYVALUE').AsInteger;
end;
SQL := 'SELECT * FROM customers WHERE QB_LIST_ID = ' + QuotedStr(QB_LIST_ID); SQL := 'SELECT * FROM customers WHERE QB_LIST_ID = ' + QuotedStr(QB_LIST_ID);
doQuery(OrdersDB.UniQuery1, SQL); doQuery(OrdersDB.UniQuery1, SQL);
......
...@@ -12,7 +12,7 @@ uses ...@@ -12,7 +12,7 @@ uses
WEBLib.ExtCtrls, WEBLib.REST, WEBLib.WebTools,System.Net.HttpClient, WEBLib.ExtCtrls, WEBLib.REST, WEBLib.WebTools,System.Net.HttpClient,
System.Net.URLClient, System.Net.HttpClientComponent, System.netencoding, System.Net.URLClient, System.Net.HttpClientComponent, System.netencoding,
IdHTTP, IdSSLOpenSSL, IdSSLOpenSSLHeaders, System.DateUtils, System.IniFiles, IdHTTP, IdSSLOpenSSL, IdSSLOpenSSLHeaders, System.DateUtils, System.IniFiles,
AdvPanel, AdvOfficePager; AdvPanel, AdvOfficePager, System.UITypes;
type type
...@@ -156,7 +156,6 @@ type ...@@ -156,7 +156,6 @@ type
{ Private declarations } { Private declarations }
strict private strict private
ordersDB: TApiDatabase; ordersDB: TApiDatabase;
httpReqTokenRefresh: TWebHttpRequest;
var var
AccessToken,RefreshToken,CompanyID,Client,Secret: string; AccessToken,RefreshToken,CompanyID,Client,Secret: string;
...@@ -214,8 +213,6 @@ begin ...@@ -214,8 +213,6 @@ begin
end; end;
procedure TfQB.asgDataClickCell(Sender: TObject; ARow, ACol: Integer); procedure TfQB.asgDataClickCell(Sender: TObject; ARow, ACol: Integer);
var
point, origin: TPoint;
begin begin
QB_ID := asgData.Cells[1, asgData.Row]; QB_ID := asgData.Cells[1, asgData.Row];
end; end;
...@@ -278,12 +275,8 @@ var ...@@ -278,12 +275,8 @@ var
jsValue: TJSONValue; jsValue: TJSONValue;
jsObj: TJSONObject; jsObj: TJSONObject;
ItemList: TJSONArray; ItemList: TJSONArray;
pair: TJSONPair; Item: TJSONObject;
ModifiedList: TJSONArray;
ParsedCustomer, Item: TJSONObject;
I: integer; I: integer;
BillAddr: TJSONObject;
ShipAddr: TJSONObject;
sql: string; sql: string;
begin begin
Memo1.Clear; Memo1.Clear;
...@@ -304,8 +297,7 @@ begin ...@@ -304,8 +297,7 @@ begin
end; end;
restRequest.Method := rmGET; restRequest.Method := rmGET;
//res := '/v3/company/' + companyID + '/preferences'; res := '/v3/company/' + companyID + '/query?query=select * from Item&minorversion=75';
res := '/v3/company/' + companyID + '/query?query=select * from Item&minorversion=75'; // '/customer/58';
restRequest.Resource := res; restRequest.Resource := res;
...@@ -317,12 +309,9 @@ begin ...@@ -317,12 +309,9 @@ begin
restRequest.Execute; restRequest.Execute;
//memo1.Lines.Add(restresponse.Content);
jsValue := restResponse.JSONValue; jsValue := restResponse.JSONValue;
jsObj := TJSONObject(jsValue); jsObj := TJSONObject(jsValue);
//CustomerList := TJSONArray(restResponse.JSONValue);
Memo1.Lines.Add( jsObj.Format(2) ); Memo1.Lines.Add( jsObj.Format(2) );
ItemList := TJSONArray( TJSONObject( jsObj.GetValue('QueryResponse') ).GetValue('Item')); ItemList := TJSONArray( TJSONObject( jsObj.GetValue('QueryResponse') ).GetValue('Item'));
...@@ -343,10 +332,7 @@ begin ...@@ -343,10 +332,7 @@ begin
end; end;
Memo1.lines.add('Done'); Memo1.lines.add('Done');
// Load customer info
restClient.Free; restClient.Free;
restRequest.Free; restRequest.Free;
...@@ -416,10 +402,6 @@ end; ...@@ -416,10 +402,6 @@ end;
procedure TfQB.DeleteCustomers(); procedure TfQB.DeleteCustomers();
var var
SQL: string; SQL: string;
count: integer;
ModifiedList: TJSONArray;
Customer, ParsedCustomer: TJSONObject;
I: integer;
ship_count, cust_count: integer; ship_count, cust_count: integer;
begin begin
Memo1.Clear; Memo1.Clear;
...@@ -472,10 +454,8 @@ end; ...@@ -472,10 +454,8 @@ end;
procedure TfQB.getCustomers(); procedure TfQB.getCustomers();
var var
SQL: string; SQL: string;
count: integer;
ModifiedList: TJSONArray; ModifiedList: TJSONArray;
Customer, ParsedCustomer: TJSONObject; ParsedCustomer: TJSONObject;
I: integer;
begin begin
Memo1.Clear; Memo1.Clear;
Memo1.Lines.Add('Retrieving KG Orders Customers'); Memo1.Lines.Add('Retrieving KG Orders Customers');
...@@ -487,12 +467,7 @@ begin ...@@ -487,12 +467,7 @@ begin
begin begin
ParsedCustomer := TJSONObject.Create; ParsedCustomer := TJSONObject.Create;
//sql := 'select CUSTOMER_ID from customers where QB_LIST_ID = ' + Customer.GetValue<string>('Id');
//doQuery(ordersDB.UniQuery1, SQL);
try try
//ParsedCustomer.AddPair('In KGOrders', not(ordersDB.UniQuery1.IsEmpty));
ParsedCustomer.AddPair('Id', ordersDB.UniQuery1.FieldByName('CUSTOMER_ID').AsString); ParsedCustomer.AddPair('Id', ordersDB.UniQuery1.FieldByName('CUSTOMER_ID').AsString);
ParsedCustomer.AddPair('CompanyName', ordersDB.UniQuery1.FieldByName('NAME').AsString); ParsedCustomer.AddPair('CompanyName', ordersDB.UniQuery1.FieldByName('NAME').AsString);
ParsedCustomer.AddPair('BillAddrCity', ordersDB.UniQuery1.FieldByName('BILL_CITY').AsString); ParsedCustomer.AddPair('BillAddrCity', ordersDB.UniQuery1.FieldByName('BILL_CITY').AsString);
...@@ -517,8 +492,6 @@ end; ...@@ -517,8 +492,6 @@ end;
procedure TfQB.SaveTokens(AccessToken, RefreshToken: string); procedure TfQB.SaveTokens(AccessToken, RefreshToken: string);
var var
f: TStringList;
iniStr, line: string;
iniFile: TIniFile; iniFile: TIniFile;
begin begin
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' ); iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
...@@ -544,10 +517,7 @@ var ...@@ -544,10 +517,7 @@ var
param: TRESTRequestParameter; param: TRESTRequestParameter;
res: string; res: string;
jsValue: TJSONValue; jsValue: TJSONValue;
Customer: TJSONValue;
jsObj: TJSONObject; jsObj: TJSONObject;
CustomerList: TJSONArray;
pair: TJSONPair;
begin begin
Memo1.Clear; Memo1.Clear;
Memo1.Lines.Add('Retrieving QB Customer Based on ID'); Memo1.Lines.Add('Retrieving QB Customer Based on ID');
...@@ -567,7 +537,6 @@ begin ...@@ -567,7 +537,6 @@ begin
end; end;
restRequest.Method := rmGET; restRequest.Method := rmGET;
//GET /v3/company/<realmId>/customer/<customerId>
res := '/v3/company/' + companyid + '/customer/58'; res := '/v3/company/' + companyid + '/customer/58';
restRequest.Resource := res; restRequest.Resource := res;
...@@ -579,18 +548,12 @@ begin ...@@ -579,18 +548,12 @@ begin
restRequest.Execute; restRequest.Execute;
//memo1.Lines.Add(restresponse.Content);
jsValue := restResponse.JSONValue; jsValue := restResponse.JSONValue;
jsObj := TJSONObject(jsValue); jsObj := TJSONObject(jsValue);
Memo2.Clear; Memo2.Clear;
Memo2.Lines.Add( jsObj.Format(2) ); Memo2.Lines.Add( jsObj.Format(2) );
// CustomerList := TJSONArray( TJSONObject( jsObj.GetValue('QueryResponse') ).GetValue('Customer')) ;
// LoadJSONArray( CustomerList );
restClient.Free; restClient.Free;
restRequest.Free; restRequest.Free;
restResponse.Free; restResponse.Free;
...@@ -615,34 +578,20 @@ var ...@@ -615,34 +578,20 @@ var
res: string; res: string;
i: integer; i: integer;
jsValue: TJSONValue; jsValue: TJSONValue;
Customer: TJSONValue;
jsObj: TJSONObject; jsObj: TJSONObject;
CustomerList: TJSONArray;
pair: TJSONPair;
estimateJSON: TJSONObject; estimateJSON: TJSONObject;
SQL: string; SQL: string;
estimate: TEstimate;
CustomerRef: TRef;
CustomerRefJSON: TJSONObject; CustomerRefJSON: TJSONObject;
Lines: TArray<string>; Lines: TArray<string>;
BillAddr: TAddress;
BillAddrJSON: TJSONObject; BillAddrJSON: TJSONObject;
CustomField:TJSONObject; CustomField:TJSONObject;
CustomFields: TJSONArray; CustomFields: TJSONArray;
ShipAddr: TAddress;
ShipAddrJSON: TJSONObject; ShipAddrJSON: TJSONObject;
Items: TArray<TLine>;
ItemRef: TRef;
SalesItemLineDetail: TSalesItemLineDetail;
LineArray: TJSONArray; LineArray: TJSONArray;
LineObj, DetailObj, ItemRefObj: TJSONObject; LineObj, DetailObj, ItemRefObj: TJSONObject;
TaxCodeRef: TJSONObject;
TxnTaxCodeRef: TJSONObject;
TxnTaxDetail: TJSONObject;
JSONData: TJSONObject; JSONData: TJSONObject;
ORDER_ID: string; ORDER_ID: string;
table: string; table: string;
ShipMethodRef: TJSONObject;
unitPrice: double; unitPrice: double;
begin begin
Memo1.Clear; Memo1.Clear;
...@@ -657,13 +606,9 @@ begin ...@@ -657,13 +606,9 @@ begin
LineObj := TJSONObject.Create; LineObj := TJSONObject.Create;
DetailObj := TJSONObject.Create; DetailObj := TJSONObject.Create;
ItemRefObj := TJSONObject.Create; ItemRefObj := TJSONObject.Create;
TaxCodeRef := TJSONObject.Create;
TxnTaxCodeRef := TJSONObject.Create;
TxnTaxDetail := TJSONObject.Create;
JSONData := TJSONObject.ParseJSONValue(orderInfo) as TJSONObject; JSONData := TJSONObject.ParseJSONValue(orderInfo) as TJSONObject;
ORDER_ID := JSONData.GetValue<string>('ORDER_ID'); ORDER_ID := JSONData.GetValue<string>('ORDER_ID');
// add logic to figure out what type of order it is
SQL := 'select * from orders where ORDER_ID = ' + ORDER_ID; SQL := 'select * from orders where ORDER_ID = ' + ORDER_ID;
doQuery(ordersDB.UniQuery1, SQL); doQuery(ordersDB.UniQuery1, SQL);
if ordersDB.UniQuery1.FieldByName('ORDER_TYPE').AsString = 'corrugated_plate' then if ordersDB.UniQuery1.FieldByName('ORDER_TYPE').AsString = 'corrugated_plate' then
...@@ -685,10 +630,7 @@ begin ...@@ -685,10 +630,7 @@ begin
estimateJSON.AddPair('TxnDate', ordersDB.UniQuery1.FieldByName('staff_fields_order_date').AsString); estimateJSON.AddPair('TxnDate', ordersDB.UniQuery1.FieldByName('staff_fields_order_date').AsString);
// Update the Quickbooks list ID in the database // Update the Quickbooks list ID in the database
// CustomerRef.value :=
CustomerRefJSON := TJSONObject.Create;
CustomerRefJSON.AddPair('value', ordersDB.UniQuery1.FieldByName('QB_LIST_ID').AsString); CustomerRefJSON.AddPair('value', ordersDB.UniQuery1.FieldByName('QB_LIST_ID').AsString);
//CustomerRef.value := '59'
; ;
estimateJSON.AddPair('CustomerRef', CustomerRefJSON); estimateJSON.AddPair('CustomerRef', CustomerRefJSON);
...@@ -737,8 +679,6 @@ begin ...@@ -737,8 +679,6 @@ begin
estimateJSON.AddPair('ShipAddr', ShipAddrJSON); estimateJSON.AddPair('ShipAddr', ShipAddrJSON);
// 🔹 Line object representing one line item
LineObj := TJSONObject.Create;
if ( table = 'corrugated_plate_orders') or (table = 'cutting_die_orders' ) then if ( table = 'corrugated_plate_orders') or (table = 'cutting_die_orders' ) then
begin begin
if ordersDB.UniQuery1.FieldByName('general_special_instructions').AsString <> '' then if ordersDB.UniQuery1.FieldByName('general_special_instructions').AsString <> '' then
...@@ -800,17 +740,10 @@ begin ...@@ -800,17 +740,10 @@ begin
restRequest.Execute; restRequest.Execute;
//memo1.Lines.Add(restresponse.Content);
jsValue := restResponse.JSONValue; jsValue := restResponse.JSONValue;
jsObj := TJSONObject(jsValue); jsObj := TJSONObject(jsValue);
Memo1.Lines.Add( jsObj.Format(2) ); Memo1.Lines.Add( jsObj.Format(2) );
//CustomerList := TJSONArray(restResponse.JSONValue);
// CustomerList := TJSONArray( TJSONObject( jsObj.GetValue('QueryResponse') ).GetValue('Customer')) ;
// LoadJSONArray( CustomerList );
restClient.Free; restClient.Free;
restRequest.Free; restRequest.Free;
...@@ -820,10 +753,8 @@ end; ...@@ -820,10 +753,8 @@ end;
procedure TfQB.Button5Click(Sender: TObject); procedure TfQB.Button5Click(Sender: TObject);
var var
SQL: string; SQL: string;
count: integer;
ModifiedList: TJSONArray; ModifiedList: TJSONArray;
Customer, ParsedCustomer: TJSONObject; ParsedCustomer: TJSONObject;
I: integer;
begin begin
Memo1.Clear; Memo1.Clear;
Memo1.Lines.Add('Showing all KG Orders Customers without Orders'); Memo1.Lines.Add('Showing all KG Orders Customers without Orders');
...@@ -836,12 +767,7 @@ begin ...@@ -836,12 +767,7 @@ begin
while not ordersDB.UniQuery1.Eof do while not ordersDB.UniQuery1.Eof do
begin begin
ParsedCustomer := TJSONObject.Create; ParsedCustomer := TJSONObject.Create;
//sql := 'select CUSTOMER_ID from customers where QB_LIST_ID = ' + Customer.GetValue<string>('Id');
//doQuery(ordersDB.UniQuery1, SQL);
try try
//ParsedCustomer.AddPair('In KGOrders', not(ordersDB.UniQuery1.IsEmpty));
ParsedCustomer.AddPair('Id', ordersDB.UniQuery1.FieldByName('CUSTOMER_ID').AsString); ParsedCustomer.AddPair('Id', ordersDB.UniQuery1.FieldByName('CUSTOMER_ID').AsString);
ParsedCustomer.AddPair('CompanyName', ordersDB.UniQuery1.FieldByName('NAME').AsString); ParsedCustomer.AddPair('CompanyName', ordersDB.UniQuery1.FieldByName('NAME').AsString);
...@@ -874,13 +800,6 @@ var ...@@ -874,13 +800,6 @@ var
jsValue: TJSONValue; jsValue: TJSONValue;
jsObj: TJSONObject; jsObj: TJSONObject;
CustomerList: TJSONArray; CustomerList: TJSONArray;
pair: TJSONPair;
ModifiedList: TJSONArray;
ParsedCustomer, Customer: TJSONObject;
I: integer;
BillAddr: TJSONObject;
ShipAddr: TJSONObject;
SQL: string;
begin begin
restClient := TRESTClient.Create(nil); restClient := TRESTClient.Create(nil);
restClient.BaseURL := 'https://sandbox-quickbooks.api.intuit.com'; restClient.BaseURL := 'https://sandbox-quickbooks.api.intuit.com';
...@@ -898,11 +817,8 @@ begin ...@@ -898,11 +817,8 @@ begin
end; end;
restRequest.Method := rmGET; restRequest.Method := rmGET;
//res := '/v3/company/' + companyID + '/preferences'; res := '/v3/company/' + companyID + '/query?query=select * from Customer&minorversion=75';
res := '/v3/company/' + companyID + '/query?query=select * from Customer&minorversion=75'; // '/customer/58';
restRequest.Resource := res; restRequest.Resource := res;
///query?query=select * from Customer where CompanyName = ' + quotedStr('TYOGA CONTAINER') + '&minorversion=75';
param := restRequest.Params.AddItem; param := restRequest.Params.AddItem;
param.Name := 'Authorization'; param.Name := 'Authorization';
...@@ -912,21 +828,13 @@ begin ...@@ -912,21 +828,13 @@ begin
restRequest.Execute; restRequest.Execute;
//memo1.Lines.Add(restresponse.Content);
jsValue := restResponse.JSONValue; jsValue := restResponse.JSONValue;
jsObj := TJSONObject(jsValue); jsObj := TJSONObject(jsValue);
//CustomerList := TJSONArray(restResponse.JSONValue);
CustomerList := TJSONArray( TJSONObject( jsObj.GetValue('QueryResponse') ).GetValue('Customer')) ; CustomerList := TJSONArray( TJSONObject( jsObj.GetValue('QueryResponse') ).GetValue('Customer')) ;
//LoadJSONArray( CustomerList );
findMatches(CustomerList, 'DisplayName', 'Name'); findMatches(CustomerList, 'DisplayName', 'Name');
//findMatches(CustomerList, 'BillAddrLine1', 'BILL_ADDRESS');
//findMatches(CustomerList, 'BillAddrCity', 'BILL_CITY');
//findMatches(CustomerList, 'BillAddrState', 'BILL_STATE');
//findMatches(CustomerList, 'BillAddrZip', 'BILL_ZIP');
end; end;
...@@ -934,10 +842,8 @@ end; ...@@ -934,10 +842,8 @@ end;
procedure TfQB.Button7Click(Sender: TObject); procedure TfQB.Button7Click(Sender: TObject);
var var
SQL: string; SQL: string;
count: integer;
ModifiedList: TJSONArray; ModifiedList: TJSONArray;
Customer, ParsedCustomer: TJSONObject; ParsedCustomer: TJSONObject;
I: integer;
begin begin
SQL := 'SELECT * FROM customers c ' + SQL := 'SELECT * FROM customers c ' +
'WHERE NOT EXISTS (SELECT 1 FROM corrugated_plate_orders cpo WHERE cpo.COMPANY_ID = c.CUSTOMER_ID) '+ 'WHERE NOT EXISTS (SELECT 1 FROM corrugated_plate_orders cpo WHERE cpo.COMPANY_ID = c.CUSTOMER_ID) '+
...@@ -949,12 +855,7 @@ begin ...@@ -949,12 +855,7 @@ begin
begin begin
ParsedCustomer := TJSONObject.Create; ParsedCustomer := TJSONObject.Create;
//sql := 'select CUSTOMER_ID from customers where QB_LIST_ID = ' + Customer.GetValue<string>('Id');
//doQuery(ordersDB.UniQuery1, SQL);
try try
//ParsedCustomer.AddPair('In KGOrders', not(ordersDB.UniQuery1.IsEmpty));
ParsedCustomer.AddPair('Id', ordersDB.UniQuery1.FieldByName('CUSTOMER_ID').AsString); ParsedCustomer.AddPair('Id', ordersDB.UniQuery1.FieldByName('CUSTOMER_ID').AsString);
ParsedCustomer.AddPair('CompanyName', ordersDB.UniQuery1.FieldByName('NAME').AsString); ParsedCustomer.AddPair('CompanyName', ordersDB.UniQuery1.FieldByName('NAME').AsString);
ParsedCustomer.AddPair('BillAddrCity', ordersDB.UniQuery1.FieldByName('BILL_CITY').AsString); ParsedCustomer.AddPair('BillAddrCity', ordersDB.UniQuery1.FieldByName('BILL_CITY').AsString);
...@@ -986,12 +887,6 @@ var ...@@ -986,12 +887,6 @@ var
jsValue: TJSONValue; jsValue: TJSONValue;
jsObj: TJSONObject; jsObj: TJSONObject;
CustomerList: TJSONArray; CustomerList: TJSONArray;
pair: TJSONPair;
ModifiedList: TJSONArray;
ParsedCustomer, Customer: TJSONObject;
I: integer;
BillAddr: TJSONObject;
ShipAddr: TJSONObject;
ItemList: TJSONArray; ItemList: TJSONArray;
Item: TJSONObject; Item: TJSONObject;
begin begin
...@@ -1014,8 +909,7 @@ begin ...@@ -1014,8 +909,7 @@ begin
end; end;
restRequest.Method := rmGET; restRequest.Method := rmGET;
//res := '/v3/company/' + companyID + '/preferences'; res := '/v3/company/' + companyID + '/query?query=select * from Item&minorversion=75';
res := '/v3/company/' + companyID + '/query?query=select * from Item&minorversion=75'; // '/customer/58';
restRequest.Resource := res; restRequest.Resource := res;
...@@ -1027,12 +921,9 @@ begin ...@@ -1027,12 +921,9 @@ begin
restRequest.Execute; restRequest.Execute;
//memo1.Lines.Add(restresponse.Content);
jsValue := restResponse.JSONValue; jsValue := restResponse.JSONValue;
jsObj := TJSONObject(jsValue); jsObj := TJSONObject(jsValue);
//CustomerList := TJSONArray(restResponse.JSONValue);
Memo2.Clear; Memo2.Clear;
Memo2.Lines.Add( jsObj.Format(2) ); Memo2.Lines.Add( jsObj.Format(2) );
...@@ -1078,13 +969,6 @@ var ...@@ -1078,13 +969,6 @@ var
res: string; res: string;
jsValue: TJSONValue; jsValue: TJSONValue;
jsObj: TJSONObject; jsObj: TJSONObject;
CustomerList: TJSONArray;
pair: TJSONPair;
ModifiedList: TJSONArray;
ParsedCustomer, Customer: TJSONObject;
I: integer;
BillAddr: TJSONObject;
ShipAddr: TJSONObject;
begin begin
Memo1.Clear; Memo1.Clear;
Memo1.Lines.Add('Retrieving Estimate from QB'); Memo1.Lines.Add('Retrieving Estimate from QB');
...@@ -1104,7 +988,6 @@ begin ...@@ -1104,7 +988,6 @@ begin
end; end;
restRequest.Method := rmGET; restRequest.Method := rmGET;
//GET /v3/company/9341454243251288/query?query=<selectStatement>&minorversion=75
res := '/v3/company/' + companyID + '/query?query=select * from estimate where DocNumber = ' + quotedStr('1002') + '&minorversion=75'; res := '/v3/company/' + companyID + '/query?query=select * from estimate where DocNumber = ' + quotedStr('1002') + '&minorversion=75';
restRequest.Resource := res; restRequest.Resource := res;
...@@ -1140,7 +1023,6 @@ var ...@@ -1140,7 +1023,6 @@ var
jsValue: TJSONValue; jsValue: TJSONValue;
jsObj: TJSONObject; jsObj: TJSONObject;
CustomerList: TJSONArray; CustomerList: TJSONArray;
pair: TJSONPair;
ModifiedList: TJSONArray; ModifiedList: TJSONArray;
ParsedCustomer, Customer: TJSONObject; ParsedCustomer, Customer: TJSONObject;
I: integer; I: integer;
...@@ -1165,10 +1047,8 @@ begin ...@@ -1165,10 +1047,8 @@ begin
end; end;
restRequest.Method := rmGET; restRequest.Method := rmGET;
//res := '/v3/company/' + companyID + '/preferences'; res := '/v3/company/' + companyID + '/query?query=select * from Customer&minorversion=75';
res := '/v3/company/' + companyID + '/query?query=select * from Customer&minorversion=75'; // '/customer/58';
restRequest.Resource := res; restRequest.Resource := res;
///query?query=select * from Customer where CompanyName = ' + quotedStr('TYOGA CONTAINER') + '&minorversion=75';
param := restRequest.Params.AddItem; param := restRequest.Params.AddItem;
...@@ -1179,12 +1059,9 @@ begin ...@@ -1179,12 +1059,9 @@ begin
restRequest.Execute; restRequest.Execute;
//memo1.Lines.Add(restresponse.Content);
jsValue := restResponse.JSONValue; jsValue := restResponse.JSONValue;
jsObj := TJSONObject(jsValue); jsObj := TJSONObject(jsValue);
//CustomerList := TJSONArray(restResponse.JSONValue);
Memo2.Clear; Memo2.Clear;
Memo2.Lines.Add( jsObj.Format(2) ); Memo2.Lines.Add( jsObj.Format(2) );
...@@ -1197,11 +1074,7 @@ begin ...@@ -1197,11 +1074,7 @@ begin
Customer := CustomerList.Items[I] as TJSONObject; Customer := CustomerList.Items[I] as TJSONObject;
ParsedCustomer := TJSONObject.Create; ParsedCustomer := TJSONObject.Create;
//sql := 'select CUSTOMER_ID from customers where QB_LIST_ID = ' + Customer.GetValue<string>('Id');
//doQuery(ordersDB.UniQuery1, SQL);
try try
//ParsedCustomer.AddPair('In KGOrders', not(ordersDB.UniQuery1.IsEmpty));
ParsedCustomer.AddPair('Id', Customer.GetValue<string>('Id')); ParsedCustomer.AddPair('Id', Customer.GetValue<string>('Id'));
ParsedCustomer.AddPair('CompanyName', Customer.GetValue<string>('DisplayName')); ParsedCustomer.AddPair('CompanyName', Customer.GetValue<string>('DisplayName'));
...@@ -1228,18 +1101,18 @@ begin ...@@ -1228,18 +1101,18 @@ begin
// Handle Ship Address // Handle Ship Address
if Customer.GetValue('ShipAddr') is TJSONObject then if Customer.GetValue('ShipAddr') is TJSONObject then
begin begin
BillAddr := Customer.GetValue('ShipAddr') as TJSONObject; ShipAddr := Customer.GetValue('ShipAddr') as TJSONObject;
ParsedCustomer.AddPair('ShipAddrLine1', TJSONString.Create(BillAddr.GetValue<string>('Line1', ''))); ParsedCustomer.AddPair('ShipAddrLine1', TJSONString.Create(ShipAddr.GetValue<string>('Line1', '')));
ParsedCustomer.AddPair('ShipAddrCity', TJSONString.Create(BillAddr.GetValue<string>('City', ''))); ParsedCustomer.AddPair('ShipAddrCity', TJSONString.Create(ShipAddr.GetValue<string>('City', '')));
ParsedCustomer.AddPair('ShipAddrState', TJSONString.Create(BillAddr.GetValue<string>('CountrySubDivisionCode', ''))); ParsedCustomer.AddPair('ShipAddrState', TJSONString.Create(ShipAddr.GetValue<string>('CountrySubDivisionCode', '')));
ParsedCustomer.AddPair('ShipAddrZip', TJSONString.Create(BillAddr.GetValue<string>('PostalCode', ''))); ParsedCustomer.AddPair('ShipAddrZip', TJSONString.Create(ShipAddr.GetValue<string>('PostalCode', '')));
ParsedCustomer.AddPair('ShipAddr', ParsedCustomer.AddPair('ShipAddr',
TJSONString.Create( TJSONString.Create(
Customer.GetValue<string>('DisplayName') + sLineBreak + Customer.GetValue<string>('DisplayName') + sLineBreak +
BillAddr.GetValue('Line1', '') + ',' + sLineBreak + ShipAddr.GetValue('Line1', '') + ',' + sLineBreak +
BillAddr.GetValue('City', '') + ', ' + ShipAddr.GetValue('City', '') + ', ' +
BillAddr.GetValue('CountrySubDivisionCode', '') + ' ' + ShipAddr.GetValue('CountrySubDivisionCode', '') + ' ' +
BillAddr.GetValue('PostalCode', '') ShipAddr.GetValue('PostalCode', '')
) )
); );
end; end;
...@@ -1308,11 +1181,8 @@ var ...@@ -1308,11 +1181,8 @@ var
IdHTTP: TIdHTTP; IdHTTP: TIdHTTP;
SSLIO: TIdSSLIOHandlerSocketOpenSSL; SSLIO: TIdSSLIOHandlerSocketOpenSSL;
RequestStream: TStringStream; RequestStream: TStringStream;
EncodedAuth, EncodedAuth2, PostData, response: string; EncodedAuth, PostData, response: string;
f: TStringList;
fi: string;
JSObj: TJSONObject; JSObj: TJSONObject;
iniFile: TIniFile;
Encoder: TBase64Encoding; Encoder: TBase64Encoding;
begin begin
// 1. Encode credentials (same as working Postman request) // 1. Encode credentials (same as working Postman request)
...@@ -1381,8 +1251,6 @@ var ...@@ -1381,8 +1251,6 @@ var
restResponse: TRESTResponse; restResponse: TRESTResponse;
param: TRESTRequestParameter; param: TRESTRequestParameter;
res: string; res: string;
jsValue: TJSONValue;
jsObj, companyInfo: TJSONObject;
begin begin
restClient := TRESTClient.Create(nil); restClient := TRESTClient.Create(nil);
restClient.BaseURL := 'https://sandbox-quickbooks.api.intuit.com'; restClient.BaseURL := 'https://sandbox-quickbooks.api.intuit.com';
...@@ -1411,9 +1279,6 @@ begin ...@@ -1411,9 +1279,6 @@ begin
restRequest.Execute; restRequest.Execute;
memo1.Lines.Add(restresponse.Content) ; memo1.Lines.Add(restresponse.Content) ;
//jsValue := restResponse.JSONValue;
//jsObj := TJSONObject.ParseJSONValue(restresponse.Content) as TJSONObject;
//companyInfo := TJSONObject(jsObj.GetValue('CompanyInfo'));
restClient.Free; restClient.Free;
restRequest.Free; restRequest.Free;
......
...@@ -5,7 +5,7 @@ interface ...@@ -5,7 +5,7 @@ interface
uses uses
System.SysUtils, System.Classes, Data.DB, MemDS, DBAccess, Uni, Common.Logging, System.SysUtils, System.Classes, Data.DB, MemDS, DBAccess, Uni, Common.Logging,
frxClass, frxExportBaseDialog, frxExportPDF, frCoreClasses, frxDBSet, JS, JSON, frxClass, frxExportBaseDialog, frxExportPDF, frCoreClasses, frxDBSet, JS, JSON,
frxTableObject, frxUtils; frxTableObject, frxUtils, System.Generics.Collections;
type type
TrptOrderCorrugated = class(TDataModule) TrptOrderCorrugated = class(TDataModule)
...@@ -156,8 +156,7 @@ var ...@@ -156,8 +156,7 @@ var
colorArray: TJSONArray; colorArray: TJSONArray;
colorsObject, colorObject: TJSONObject; colorsObject, colorObject: TJSONObject;
colorsString: string; colorsString: string;
i, rowIndex: Integer; i: Integer;
temp: TObject;
begin begin
logger.Log(5, 'Adding Color Rows'); logger.Log(5, 'Adding Color Rows');
...@@ -181,31 +180,13 @@ end; ...@@ -181,31 +180,13 @@ end;
function TrptOrderCorrugated.PrepareReport(SQL: string): string; function TrptOrderCorrugated.PrepareReport(SQL: string): string;
var
orderList : TJSObject;
i: integer;
data: TJSArray;
order: TJSObject;
callListLength: integer;
tempString, strColorList: string;
colorObject: TJSONObject;
colorList: TJSArray;
colorLength: integer;
color: TJSObject;
colorJSON: TJSONObject;
colorListJSON: TJSONArray;
items: TJSObject;
begin begin
Logger.Log(5, 'Generated SQL for Prepare Report: ' + SQL); Logger.Log(5, 'Generated SQL for Prepare Report: ' + SQL);
doQuery(uqOrderCorrugated, SQL); doQuery(uqOrderCorrugated, SQL);
if ( string( uqOrderCorrugated.FieldByName('colors_colors').AsString ) ) <> '' then if ( string( uqOrderCorrugated.FieldByName('colors_colors').AsString ) ) <> '' then
begin begin
PopulateColorTable(); PopulateColorTable();
end; end;
result := GeneratePDF; result := GeneratePDF;
Logger.Log(5, 'Report preparation complete.'); Logger.Log(5, 'Report preparation complete.');
......
...@@ -82,29 +82,11 @@ end; ...@@ -82,29 +82,11 @@ end;
function TrptOrderCutting.PrepareReport(SQL: string): string; function TrptOrderCutting.PrepareReport(SQL: string): string;
var
orderList : TJSObject;
i: integer;
data: TJSArray;
order: TJSObject;
callListLength: integer;
tempString, strColorList: string;
colorObject: TJSONObject;
colorList: TJSArray;
colorLength: integer;
color: TJSObject;
colorJSON: TJSONObject;
colorListJSON: TJSONArray;
items: TJSObject;
begin begin
Logger.Log(3, 'Generated SQL for Prepare Report: ' + SQL); Logger.Log(3, 'Generated SQL for Prepare Report: ' + SQL);
//SQL := 'select * from corrugated_plate_orders where ORDER_ID = 18381';
doQuery(uqOrderCutting, SQL); doQuery(uqOrderCutting, SQL);
result := GeneratePDF; result := GeneratePDF;
Logger.Log(5, 'Report preparation complete.'); Logger.Log(5, 'Report preparation complete.');
end; end;
......
...@@ -3,7 +3,7 @@ object rptOrderList: TrptOrderList ...@@ -3,7 +3,7 @@ object rptOrderList: TrptOrderList
Height = 480 Height = 480
Width = 640 Width = 640
object frxOrderList: TfrxReport object frxOrderList: TfrxReport
Version = '2025.1.4' Version = '2025.2.4'
DotMatrixReport = False DotMatrixReport = False
IniFile = '\Software\Fast Reports' IniFile = '\Software\Fast Reports'
PreviewOptions.Buttons = [pbPrint, pbLoad, pbSave, pbExport, pbZoom, pbFind, pbOutline, pbPageSetup, pbTools, pbEdit, pbNavigator, pbExportQuick, pbCopy, pbSelection] PreviewOptions.Buttons = [pbPrint, pbLoad, pbSave, pbExport, pbZoom, pbFind, pbOutline, pbPageSetup, pbTools, pbEdit, pbNavigator, pbExportQuick, pbCopy, pbSelection]
...@@ -26,6 +26,7 @@ object rptOrderList: TrptOrderList ...@@ -26,6 +26,7 @@ object rptOrderList: TrptOrderList
end> end>
Variables = <> Variables = <>
Style = <> Style = <>
Watermarks = <>
object Data: TfrxDataPage object Data: TfrxDataPage
Height = 1000.000000000000000000 Height = 1000.000000000000000000
Width = 1000.000000000000000000 Width = 1000.000000000000000000
...@@ -1065,6 +1066,7 @@ object rptOrderList: TrptOrderList ...@@ -1065,6 +1066,7 @@ object rptOrderList: TrptOrderList
PdfA = False PdfA = False
PDFStandard = psNone PDFStandard = psNone
PDFVersion = pv17 PDFVersion = pv17
PDFColorSpace = csDeviceRGB
Left = 288 Left = 288
Top = 166 Top = 166
end end
......
...@@ -83,9 +83,7 @@ end; ...@@ -83,9 +83,7 @@ end;
function TrptOrderList.PrepareReport(SQL, CompanyName: string): string; function TrptOrderList.PrepareReport(SQL, CompanyName: string): string;
var var
memo: TFrxMemoView; memo: TFrxMemoView;
temp: TDateTime;
DateFormat: TFormatSettings; DateFormat: TFormatSettings;
tempStr: string;
begin begin
Logger.Log(5, 'Generated SQL for Prepare Report: ' + SQL); Logger.Log(5, 'Generated SQL for Prepare Report: ' + SQL);
...@@ -103,9 +101,6 @@ begin ...@@ -103,9 +101,6 @@ begin
DateFormat.TimeSeparator := ':'; DateFormat.TimeSeparator := ':';
DateFormat.ShortTimeFormat := 'HH:nn'; DateFormat.ShortTimeFormat := 'HH:nn';
tempStr := FormatDateTime('m/d/yyyy HH:nn', uqOrdersORDER_DATE.AsDateTime);
temp := StrToDateTime(FormatDateTime('m/d/yyyy HH:nn', uqOrdersORDER_DATE.AsDateTime), DateFormat);
uqOrdersORDER_DATE.AsDateTime := RecodeSecond(uqOrdersORDER_DATE.AsDateTime, 0); uqOrdersORDER_DATE.AsDateTime := RecodeSecond(uqOrdersORDER_DATE.AsDateTime, 0);
uqOrders.Post; uqOrders.Post;
......
...@@ -5,7 +5,7 @@ interface ...@@ -5,7 +5,7 @@ interface
uses uses
System.SysUtils, System.Classes, Data.DB, MemDS, DBAccess, Uni, Common.Logging, System.SysUtils, System.Classes, Data.DB, MemDS, DBAccess, Uni, Common.Logging,
frxClass, frxExportBaseDialog, frxExportPDF, frCoreClasses, frxDBSet, JS, JSON, frxClass, frxExportBaseDialog, frxExportPDF, frCoreClasses, frxDBSet, JS, JSON,
frxTableObject, frxUtils; frxTableObject, frxUtils, System.Generics.Collections;
type type
TrptOrderWeb = class(TDataModule) TrptOrderWeb = class(TDataModule)
...@@ -155,8 +155,7 @@ var ...@@ -155,8 +155,7 @@ var
colorArray: TJSONArray; colorArray: TJSONArray;
colorsObject, colorObject: TJSONObject; colorsObject, colorObject: TJSONObject;
colorsString: string; colorsString: string;
i, rowIndex: Integer; i: Integer;
temp: TObject;
begin begin
logger.Log(5, 'Adding Color Rows'); logger.Log(5, 'Adding Color Rows');
...@@ -180,32 +179,14 @@ end; ...@@ -180,32 +179,14 @@ end;
function TrptOrderWeb.PrepareReport(SQL: string): string; function TrptOrderWeb.PrepareReport(SQL: string): string;
var
orderList : TJSObject;
i: integer;
data: TJSArray;
order: TJSObject;
callListLength: integer;
tempString, strColorList: string;
colorObject: TJSONObject;
colorList: TJSArray;
colorLength: integer;
color: TJSObject;
colorJSON: TJSONObject;
colorListJSON: TJSONArray;
items: TJSObject;
begin begin
Logger.Log(3, 'Generated SQL for Prepare Report: ' + SQL); Logger.Log(3, 'Generated SQL for Prepare Report: ' + SQL);
//SQL := 'select * from corrugated_plate_orders where ORDER_ID = 18381';
doQuery(uqOrderWeb, SQL); doQuery(uqOrderWeb, SQL);
if ( string( uqOrderWeb.FieldByName('quantity_and_colors_qty_colors').AsString ) ) <> '' then if ( string( uqOrderWeb.FieldByName('quantity_and_colors_qty_colors').AsString ) ) <> '' then
begin begin
PopulateColorTable(); PopulateColorTable();
end; end;
result := GeneratePDF; result := GeneratePDF;
Logger.Log(3, 'Report preparation complete.'); Logger.Log(3, 'Report preparation complete.');
...@@ -233,7 +214,6 @@ begin ...@@ -233,7 +214,6 @@ begin
try try
frxOrderWeb.PrepareReport; frxOrderWeb.PrepareReport;
frxOrderWeb.Export(frxPDFExport1); frxOrderWeb.Export(frxPDFExport1);
//frxOrderWeb.ShowPreparedReport;
finally finally
frxOrderWeb.Clear; // Clears the report to avoid memory bloat frxOrderWeb.Clear; // Clears the report to avoid memory bloat
end; end;
......
...@@ -26,9 +26,7 @@ uses ...@@ -26,9 +26,7 @@ uses
rOrderCorrugated in 'Source\rOrderCorrugated.pas' {rptOrderCorrugated: TDataModule}, rOrderCorrugated in 'Source\rOrderCorrugated.pas' {rptOrderCorrugated: TDataModule},
rOrderWeb in 'Source\rOrderWeb.pas' {rptOrderWeb: TDataModule}, rOrderWeb in 'Source\rOrderWeb.pas' {rptOrderWeb: TDataModule},
rOrderCutting in 'Source\rOrderCutting.pas' {rptOrderCutting: TDataModule}, rOrderCutting in 'Source\rOrderCutting.pas' {rptOrderCutting: TDataModule},
qbAPI in 'Source\qbAPI.pas' {fQB}, qbAPI in 'Source\qbAPI.pas' {fQB};
QBService in 'Source\QBService.pas',
QBServiceImplementation in 'Source\QBServiceImplementation.pas';
type type
TMemoLogAppender = class( TInterfacedObject, ILogAppender ) TMemoLogAppender = class( TInterfacedObject, ILogAppender )
......
...@@ -205,8 +205,6 @@ ...@@ -205,8 +205,6 @@
<Form>fQB</Form> <Form>fQB</Form>
<FormType>dfm</FormType> <FormType>dfm</FormType>
</DCCReference> </DCCReference>
<DCCReference Include="Source\QBService.pas"/>
<DCCReference Include="Source\QBServiceImplementation.pas"/>
<BuildConfiguration Include="Base"> <BuildConfiguration Include="Base">
<Key>Base</Key> <Key>Base</Key>
</BuildConfiguration> </BuildConfiguration>
...@@ -235,13 +233,13 @@ ...@@ -235,13 +233,13 @@
</Excluded_Packages> </Excluded_Packages>
</Delphi.Personality> </Delphi.Personality>
<Deployment Version="5"> <Deployment Version="5">
<DeployFile LocalName="kgOrdersServer.exe" Configuration="Debug" Class="ProjectOutput"/> <DeployFile LocalName="bin\kgOrdersServer.exe" Configuration="Debug" Class="ProjectOutput">
<DeployFile LocalName="kgOrdersServer.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win32"> <Platform Name="Win32">
<RemoteName>kgOrdersServer.exe</RemoteName> <RemoteName>kgOrdersServer.exe</RemoteName>
<Overwrite>true</Overwrite> <Overwrite>true</Overwrite>
</Platform> </Platform>
</DeployFile> </DeployFile>
<DeployFile LocalName="kgOrdersServer.exe" Configuration="Debug" Class="ProjectOutput"/>
<DeployClass Name="AdditionalDebugSymbols"> <DeployClass Name="AdditionalDebugSymbols">
<Platform Name="iOSSimulator"> <Platform Name="iOSSimulator">
<Operation>1</Operation> <Operation>1</Operation>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment