Message Details
Back to MessagesMessage ID:
#465
Timestamp:
2026-04-24 15:12:23
From:
DM +254721499435
To:
+254705209200
Message:
import json
import requests
import sqlite3
import csv
import sys
from datetime import datetime
import pandas as pd
now = datetime.now()
print(now) # Example output: 2025-01-30 14:30:25.123456
url="http://192.168.100.48:8088/"
url="http://localhost:8088"
url="http://192.168.100.11:8088/"
url="http://localhost:8088"
url="http://192.168.100.16:8088/"
url="http://192.168.100.40:8088/"
url="http://localhost:8088"
url="http://109.123.240.141:8088"
## "109.123.240.141"
file_nam = "_testresults_"+ now.strftime("%Y-%m-%d_%H-%M-%S")
file_csv = file_nam +".csv"
with open(file_csv, 'a') as file:
file.write(",".join(["path", "resultCd", "resultMsg", "resultDt", "dataReturned"]) + "\n")
# Create an empty DataFrame with just headers
file_name = file_nam + '.xlsx'
# Define column headers
columns = ["path", "resultCd", "resultMsg", "resultDt", "dataReturned"]
# Create an empty DataFrame with just headers
df = pd.DataFrame(columns=columns)
# Print the DataFrame as a table (empty but with headers)
print(df.to_markdown(index=False))
# Save empty DataFrame to CSV and Excel (only headers)
df.to_excel(file_name, index=False, engine="openpyxl")
def selectInitInfo(data):
try:
response = KraSend("/initializer/selectInitInfo",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
x = data["resultCd"]
print(x)
x = data["resultMsg"]
print(x)
x = data["resultDt"]
print(x)
x = data["data"]
print(x)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectInitInfo' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectInitInfo' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def selectCodes(data):
try:
response = KraSend("/code/selectCodes",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
x = data["resultCd"]
print(x)
x = data["resultMsg"]
print(x)
x = data["resultDt"]
print(x)
x = data["data"]
print(x)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectCodes' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectCodes' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
x = data['data']['clsList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectCodesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectCodesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def selectItemsClass(data):
try:
response = KraSend("/itemClass/selectItemsClass",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
x = data["resultCd"]
print(x)
x = data["resultMsg"]
print(x)
x = data["resultDt"]
print(x)
x = data["data"]
print(x)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectItemsClass' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectItemsClass' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
x = data['data']['itemClsList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectItemsClassData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectItemsClassData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def selectCustomer(data):
try:
response = KraSend("/customers/selectCustomer",data)
data = json.loads(response.text)
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectCustomer' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectCustomer' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['custList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectCustomerData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectCustomerData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def selectBranches(data):
try:
response = KraSend("/branches/selectBranches",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectBranches' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectBranches' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['bhfList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectBranchesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectBranchesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def selectNotices(data):
try:
response = KraSend("/notices/selectNotices",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectNotices' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectNotices' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['noticeList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectNoticesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectNoticesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def saveBrancheCustomers(data):
try:
response = KraSend("/branches/saveBrancheCustomers",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveBrancheCustomers' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveBrancheCustomers' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['noticeList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectNoticesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectNoticesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def saveBrancheUsers(data):
try:
response = KraSend("/branches/saveBrancheUsers",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveBrancheUsers' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveBrancheUsers' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['noticeList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveBrancheUsersData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveBrancheUsersData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def saveBrancheInsurances(data):
try:
response = KraSend("/branches/saveBrancheInsurances",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveBrancheInsurances' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveBrancheInsurances' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['noticeList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveBrancheInsurancesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveBrancheInsurancesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def saveItems(data):
try:
response = KraSend("/items/saveItems",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['noticeList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def saveItemComposition(data):
try:
response = KraSend("/items/saveItemComposition",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveItemComposition' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveItemComposition' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['noticeList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveItemCompositionData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveItemCompositionData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def selectItems(data):
try:
response = KraSend("/items/selectItems",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['itemList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def selectImportItems(data):
try:
response = KraSend("/imports/selectImportItems",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectImportItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectImportItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['itemList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectImportItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectImportItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def updateImportItems(data):
try:
response = KraSend("/imports/updateImportItems",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('updateImportItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('updateImportItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['itemList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectImportItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectImportItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def saveSales(data):
try:
response = KraSend("/trnsSales/saveSales",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
'''
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
'''
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveSales' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveSales' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def selectTrnsPurchaseSales(data):
try:
response = KraSend("/trnsPurchase/selectTrnsPurchaseSales",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectTrnsPurchaseSales' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectTrnsPurchaseSales' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['saleList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectTrnsPurchaseSalesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectTrnsPurchaseSalesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def savePurchases(data):
try:
response = KraSend("/trnsPurchase/savePurchases",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('savePurchases' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('savePurchases' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['saleList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('savePurchasesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('savePurchasesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def selectStockItems(data):
try:
response = KraSend("/stock/selectStockItems",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectStockItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectStockItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['saleList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectStockItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectStockItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def saveStockItems(data):
try:
response = KraSend("/stock/saveStockItems",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveStockItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveStockItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['saleList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveStockItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveStockItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def saveStockMaster(data):
try:
response = KraSend("/stockMaster/saveStockMaster",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
#print(resultCd)
resultMsg= data["resultMsg"]
#print(resultMsg)
resultDt= data["resultDt"]
#print(resultDt)
dataReturned= data["data"]
#print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveStockMaster' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveStockMaster' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['saleList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveStockMasterData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveStockMasterData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def KraSend(path, data):
current_dateTime = datetime.now()
current_dateTime = current_dateTime.strftime("%Y%m%d%H%M%S")
url2 = url + path
print("\n\n\n"+path + " Processing...")
print("-"*100)
#response=requests.post(url2,json=data, timeout=60)
response=requests.post(url2,json=data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
#region
resultCd= data["resultCd"]
resultMsg= data["resultMsg"]
resultDt= data["resultDt"]
dataReturned= "" # data["data"]
# Open the file in append mode ('a')
with open(file_csv, 'a') as file:
# Append content to the file
file.write(f"{path},{resultCd},{resultMsg},{resultDt},{dataReturned}\n")
# Append the data without headers
data2 = [[path, resultCd, resultMsg, resultDt, dataReturned]]
df_data = pd.DataFrame(data2, columns=columns)
df_data.to_excel(file_name, index=False, header=False, engine="openpyxl")
#df = pd.DataFrame(f"{path},{resultCd},{resultMsg},{resultDt},{dataReturned}\n")
return response
import requests
import sqlite3
import csv
import sys
from datetime import datetime
import pandas as pd
now = datetime.now()
print(now) # Example output: 2025-01-30 14:30:25.123456
url="http://192.168.100.48:8088/"
url="http://localhost:8088"
url="http://192.168.100.11:8088/"
url="http://localhost:8088"
url="http://192.168.100.16:8088/"
url="http://192.168.100.40:8088/"
url="http://localhost:8088"
url="http://109.123.240.141:8088"
## "109.123.240.141"
file_nam = "_testresults_"+ now.strftime("%Y-%m-%d_%H-%M-%S")
file_csv = file_nam +".csv"
with open(file_csv, 'a') as file:
file.write(",".join(["path", "resultCd", "resultMsg", "resultDt", "dataReturned"]) + "\n")
# Create an empty DataFrame with just headers
file_name = file_nam + '.xlsx'
# Define column headers
columns = ["path", "resultCd", "resultMsg", "resultDt", "dataReturned"]
# Create an empty DataFrame with just headers
df = pd.DataFrame(columns=columns)
# Print the DataFrame as a table (empty but with headers)
print(df.to_markdown(index=False))
# Save empty DataFrame to CSV and Excel (only headers)
df.to_excel(file_name, index=False, engine="openpyxl")
def selectInitInfo(data):
try:
response = KraSend("/initializer/selectInitInfo",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
x = data["resultCd"]
print(x)
x = data["resultMsg"]
print(x)
x = data["resultDt"]
print(x)
x = data["data"]
print(x)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectInitInfo' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectInitInfo' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def selectCodes(data):
try:
response = KraSend("/code/selectCodes",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
x = data["resultCd"]
print(x)
x = data["resultMsg"]
print(x)
x = data["resultDt"]
print(x)
x = data["data"]
print(x)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectCodes' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectCodes' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
x = data['data']['clsList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectCodesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectCodesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def selectItemsClass(data):
try:
response = KraSend("/itemClass/selectItemsClass",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
x = data["resultCd"]
print(x)
x = data["resultMsg"]
print(x)
x = data["resultDt"]
print(x)
x = data["data"]
print(x)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectItemsClass' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectItemsClass' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
x = data['data']['itemClsList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectItemsClassData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectItemsClassData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def selectCustomer(data):
try:
response = KraSend("/customers/selectCustomer",data)
data = json.loads(response.text)
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectCustomer' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectCustomer' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['custList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectCustomerData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectCustomerData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def selectBranches(data):
try:
response = KraSend("/branches/selectBranches",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectBranches' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectBranches' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['bhfList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectBranchesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectBranchesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def selectNotices(data):
try:
response = KraSend("/notices/selectNotices",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectNotices' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectNotices' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['noticeList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectNoticesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectNoticesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def saveBrancheCustomers(data):
try:
response = KraSend("/branches/saveBrancheCustomers",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveBrancheCustomers' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveBrancheCustomers' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['noticeList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectNoticesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectNoticesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def saveBrancheUsers(data):
try:
response = KraSend("/branches/saveBrancheUsers",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveBrancheUsers' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveBrancheUsers' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['noticeList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveBrancheUsersData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveBrancheUsersData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def saveBrancheInsurances(data):
try:
response = KraSend("/branches/saveBrancheInsurances",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveBrancheInsurances' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveBrancheInsurances' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['noticeList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveBrancheInsurancesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveBrancheInsurancesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def saveItems(data):
try:
response = KraSend("/items/saveItems",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['noticeList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def saveItemComposition(data):
try:
response = KraSend("/items/saveItemComposition",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveItemComposition' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveItemComposition' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['noticeList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveItemCompositionData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveItemCompositionData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def selectItems(data):
try:
response = KraSend("/items/selectItems",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['itemList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def selectImportItems(data):
try:
response = KraSend("/imports/selectImportItems",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectImportItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectImportItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['itemList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectImportItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectImportItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def updateImportItems(data):
try:
response = KraSend("/imports/updateImportItems",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('updateImportItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('updateImportItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['itemList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectImportItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectImportItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def saveSales(data):
try:
response = KraSend("/trnsSales/saveSales",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
'''
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
'''
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveSales' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveSales' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def selectTrnsPurchaseSales(data):
try:
response = KraSend("/trnsPurchase/selectTrnsPurchaseSales",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectTrnsPurchaseSales' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectTrnsPurchaseSales' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['saleList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectTrnsPurchaseSalesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectTrnsPurchaseSalesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def savePurchases(data):
try:
response = KraSend("/trnsPurchase/savePurchases",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('savePurchases' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('savePurchases' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['saleList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('savePurchasesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('savePurchasesData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def selectStockItems(data):
try:
response = KraSend("/stock/selectStockItems",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectStockItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectStockItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['saleList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('selectStockItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('selectStockItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def saveStockItems(data):
try:
response = KraSend("/stock/saveStockItems",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
print(resultCd)
resultMsg= data["resultMsg"]
print(resultMsg)
resultDt= data["resultDt"]
print(resultDt)
dataReturned= data["data"]
print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveStockItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveStockItems' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['saleList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveStockItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveStockItemsData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def saveStockMaster(data):
try:
response = KraSend("/stockMaster/saveStockMaster",data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
print(data)
#region
resultCd= data["resultCd"]
#print(resultCd)
resultMsg= data["resultMsg"]
#print(resultMsg)
resultDt= data["resultDt"]
#print(resultDt)
dataReturned= data["data"]
#print(dataReturned)
#endregion
if response.status_code == 200:
try:
# Create a DataFrame from the
iterable_data = {key: [value] for key, value in data.items()}
# Create a DataFrame
df = pd.DataFrame(iterable_data)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveStockMaster' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveStockMaster' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
if (dataReturned is not None):
x = data['data']['saleList']
# Export the data
df = pd.DataFrame(x)
# Print the DataFrame as a table
print(df.to_markdown(index=False))
df.to_excel('saveStockMasterData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.xlsx', index=False)
# Export to CSV
df.to_csv('saveStockMasterData' + now.strftime("%Y-%m-%d_%H-%M-%S") + '.csv', index=False)
except Exception as e:
print(f"An error occurred: {e}")
else:
# we need to check the type return when there is an error
print("we need to check the type return when there is an error")
except Exception as e:
print(f"An error occurred: {e}")
print("-"*100)
def KraSend(path, data):
current_dateTime = datetime.now()
current_dateTime = current_dateTime.strftime("%Y%m%d%H%M%S")
url2 = url + path
print("\n\n\n"+path + " Processing...")
print("-"*100)
#response=requests.post(url2,json=data, timeout=60)
response=requests.post(url2,json=data)
data = json.loads(response.text)
'''
*Response data should look like the below
{
"resultCd": "902",
"resultMsg": "This device is installed",
"resultDt": "20250128092053",
"data": null
}
'''
#region
resultCd= data["resultCd"]
resultMsg= data["resultMsg"]
resultDt= data["resultDt"]
dataReturned= "" # data["data"]
# Open the file in append mode ('a')
with open(file_csv, 'a') as file:
# Append content to the file
file.write(f"{path},{resultCd},{resultMsg},{resultDt},{dataReturned}\n")
# Append the data without headers
data2 = [[path, resultCd, resultMsg, resultDt, dataReturned]]
df_data = pd.DataFrame(data2, columns=columns)
df_data.to_excel(file_name, index=False, header=False, engine="openpyxl")
#df = pd.DataFrame(f"{path},{resultCd},{resultMsg},{resultDt},{dataReturned}\n")
return response
Archived At:
2026-04-24 15:12:23