Commit 5be931b6 by Cam Hayes

Cleaned up warnings on server side

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