pre for location (van)

This commit is contained in:
Rene Kaßeböhmer
2025-04-22 15:55:47 +02:00
parent 3f9fa0bbc7
commit 90a5e6b629
6 changed files with 42 additions and 731 deletions

View File

@ -1,72 +0,0 @@
{
"allOrNone": true,
"useSeparatedCSVFiles": true,
"pollingQueryTimeoutMs": 1000000,
"bulkApiVersion": "2.0",
"queryBulkApiThreshold ": 100,
"objectSets": [
{
"objects": [
{
"query": "SELECT Id, City__c, Country__c, GeoY__c, GeoX__c, PostalCode__c, Street__c, Extension__c, HouseNo__c, FlatNo__c, Floor__c FROM SCInstalledBaseLocation__c WHERE Country__c = 'NL' limit 1000",
"externalId": "Name",
"operation": "Readonly"
}
]
},{
"objects": [
{
"query": "SELECT Id, Name, CommissioningDate__c,InstallationDate__c,ProductEnergy__c, ProductUnitClass__c,ArticleNo__c,SerialNo__c, SerialNoException__c, ProductUnitType__c, InstalledBaseLocation__c FROM SCInstalledBase__c WHERE Country__c = 'NL'",
"externalId": "Name",
"operation": "Readonly",
"master":true,
"excludedFromUpdateFields": ["InstalledBaseLocation__c"],
"skipRecordsComparison": true,
"parallelRestJobs": 4,
"restApiBatchSize": 9500,
"fieldMapping": [
{
"sourceField": "InstalledBaseLocation__c",
"targetField": "Id",
"targetObject": "SCInstalledBaseLocation__c"
}
]
}
]
},{
"objects": [
{
"query": "SELECT Id, Serialnumber FROM Asset WHERE Location.ParentLocation.Name LIKE '%NL'",
"externalId": "Name",
"operation": "Readonly"
}
]
},{
"objects": [
{
"query": "SELECT Id, Country, CountryCode, Street, City, ParentId, PostalCode FROM Address WHERE CountryCode = 'NL'",
"externalId": "Name",
"operation": "Readonly",
"excludedFromUpdateFields": ["ParentId"]
}
]
},{
"objects": [
{
"query": "SELECT Id, ParentLocationId, Name FROM Location WHERE Name LIKE '%NL' OR ParentLocation.Name = '%NL'",
"externalId": "Name",
"operation": "Readonly"
}
]
},{
"objects": [
{
"query": "SELECT Id, Main_Product_Group__c, Family, MaterialType__c, Name, Product_Code__c, ProductCode, EAN_Product_Code__c FROM Product2",
"externalId": "Name",
"operation": "Readonly"
}
]
}
]
}

View File

@ -36,21 +36,25 @@ def get_credentials(context):
dict: Credentials dictionary with username, password, and security_token
"""
context = context.upper()
# Initialize credentials dictionary
credentials = {
'USERNAME': None,
'PASSWORD': None,
'SECURITY_TOKEN': None,
'DOMAIN': 'test'
'SECURITY_TOKEN': None
}
if context != 'PROD':
credentials['DOMAIN'] = 'test'
# Load the .env file explicitly from one directory above
env_file = find_dotenv("../.env")
load_dotenv(env_file)
# Load all environment variables
env_vars = os.environ
for key, value in env_vars.items():
#print(f'{context}_SF_', key, value)
@ -79,14 +83,23 @@ def extract_data(object_id, query, output_path='output', context='qa2'):
if not all(credentials.values()):
raise ValueError(f"Missing credentials for context: {context}")
# Initialize Salesforce bulk connector
sf = Salesforce(
username=credentials['USERNAME'],
password=credentials['PASSWORD'],
security_token=credentials['SECURITY_TOKEN'],
domain=credentials['DOMAIN'],
version='62.0'
)
if(context == 'prod'):
# Initialize Salesforce bulk connector
sf = Salesforce(
username=credentials['USERNAME'],
password=credentials['PASSWORD'],
security_token=credentials['SECURITY_TOKEN'],
version='62.0'
)
else:
# Initialize Salesforce bulk connector
sf = Salesforce(
username=credentials['USERNAME'],
password=credentials['PASSWORD'],
security_token=credentials['SECURITY_TOKEN'],
domain=credentials['DOMAIN'],
version='62.0'
)
# Create a simple query for the desired object
#soql_query = f"""

View File

@ -30,6 +30,9 @@
},{
"sobject": "SCPriceListItem__c",
"query": "SELECT Id, Article__r.Name, Price__c, PriceUnit__c, Pricelist__c, ValidFrom__c, ValidTo__c, Article__r.EANCode__c, Pricelist__r.Brand__r.Name, Pricelist__r.Country__c FROM SCPriceListItem__c WHERE Country__c = '{country}' AND PriceList__c != null AND (ValidTo__c >= TODAY OR ValidFrom__c >= TODAY) AND Article__c = 'a0Gw000001R9slpEAB'"
},{
"sobject": "SCResourceAssignment__c",
"query": "SELECT Id, ValidTo__c, ValidFrom__c, Country__c, City__c, District__c, Street__c, HouseNo__c, Extension__c, FlatNo__c, Floor__c, GeoY__c, GeoX__c, Resource__c, Stock__c FROM SCResourceAssignment__c WHERE Country__c = '{country}' AND ValidTo__c >= TODAY"
}
]
}