Получение чеков и загрузка в 1С по избранной точке продаж или смене

This commit is contained in:
2025-07-03 11:41:30 +03:00
parent 7d0e2decfc
commit b4b8e1b7c7
2 changed files with 130 additions and 0 deletions

69
taxcom_revers.py Normal file
View File

@ -0,0 +1,69 @@
import json, requests
from datetime import datetime
from time import sleep
# ID = [('7381440900834264','691807dd-2629-11e9-993e-f06a44526bea','Волгоград_Еременко'),]
# ID = [('7381440900835933','ee3baf4d-d98d-11e6-b191-e83935b036c7','Новороссийск'),]
# ID = [('7381440800374463','ad06d608-b690-11ed-87bd-0cc47ab40806','Самара_Кирова_виваленде '),]
# ID = [('7381440900834264','691807dd-2629-11e9-993e-f06a44526bea','Волгоград_Еременко'),]
ID = [('7381440800374463','ad06d608-b690-11ed-87bd-0cc47ab40806','Самара_Кирова_виваленде'),]
# ID = [('7381440900836042','147c9228-3d13-11ef-94eb-8a456ecaea20','Крымск_Синева'),]
# ID = [('9961440300763405','030c75c2-2f29-11eb-119f-0cc47ab40806','Волгоград_Энгельса'),]
# ID = [('7381440900836108','b4280c16-2629-11e9-993e-f06a44526bea','Краснодарривокзальная'),]
# ID = [('7381440900836108','b50bc5a3-12e1-11e5-9265-e83935b036c7','Краснодарривокзальная'),]
# while True:
CurDate = datetime(2025,7,2).date()
prevDate = datetime(2025,7,2).date()
try:
# for taxcom in ID:
# fn = taxcom.partition(',')[0]
# salepoint = taxcom.partition(',')[2]
taxcom = ID[0]
fn = taxcom[0]
salepoint = taxcom[1]
data = {"salepoint": salepoint}
data = json.dumps(data, ensure_ascii=False).encode('utf8')
# result = requests.post('https://1c.maverik.ru/bso_maverik/hs/exchange/GetTaxcomCredentials', data=data, verify=False, allow_redirects=False, auth=('robot', 's38*Cqy2L*PB'))
print(fn, salepoint)
headers = {
"Content-Type": "application/json",
"Integrator-ID": "BFFFC47E-38BB-4845-8399-7C2F5AB11A3C"
}
data = {
"Login": "kassa@ip-tr.ru",
"Password": "123456"
}
result = requests.post('https://api-lk-ofd.taxcom.ru/API/v2/Login', headers=headers, data=json.dumps(data), timeout=(20, 240))
sessionToken = result.json()['sessionToken']
headers = {
"Content-Type":"application/json",
"Session-Token": f"{sessionToken}"
}
print('Autorezation')
print(result.text)
try:
print('check 1')
result = requests.get(f"https://api-lk-ofd.taxcom.ru/API/v2/ShiftList?fn={fn}&begin={prevDate}T00:00:00&end={CurDate}T23:59:59", headers=headers, timeout=(20, 240))
print(result.text)
shiftNumber = result.json()['records'][0]['shiftNumber']
fnFactoryNumber = result.json()['records'][0]['fnFactoryNumber']
except Exception as e:
print(e)
result = requests.get(f'https://api-lk-ofd.taxcom.ru/API/v2/DocumentList?fn={fn}&shift={shiftNumber}&type=3', headers=headers, timeout=(20, 240))
# result = requests.get(f'https://api-lk-ofd.taxcom.ru/API/v2/DocumentList?fn={fn}&shift=133&type=3', headers=headers, timeout=(20, 240))
cheks = result.json()['records']
print(cheks)
data = {"salepoint": salepoint,
"res": str(cheks)}
data = json.dumps(data, ensure_ascii=False).encode('utf-8')
print('54')
# print(ID[0])
result = requests.post('https://1c.maverik.ru/bso_maverik/hs/exchange/saveTaxcomDocs', data=data, allow_redirects=False, auth=('robot', 's38*Cqy2L*PB'))
print(result.text)
print(fn, salepoint, taxcom[2])
except Exception as e:
print(e)
print('#################')
print('#################')
print('#################')