From 7d0e2decfc59d109eb68f6cec41f31ba207760f7 Mon Sep 17 00:00:00 2001 From: Andrey Seligenenko Date: Thu, 3 Jul 2025 11:39:52 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D1=87=D0=B5=D0=BA=D0=BE=D0=B2=20=D0=B8=D0=B7=20?= =?UTF-8?q?=D0=A2=D0=B0=D0=BA=D1=81=D0=9A=D0=BE=D0=BC=20=D0=B8=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B0=20=D0=B8=D1=85=20?= =?UTF-8?q?=D0=B2=201=D0=A1=20=D0=BF=D0=BE=20=D0=BE=D1=80=D0=B3=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8=20Maverik?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- taxcom_maverik.py | 75 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 taxcom_maverik.py diff --git a/taxcom_maverik.py b/taxcom_maverik.py new file mode 100644 index 0000000..6d40294 --- /dev/null +++ b/taxcom_maverik.py @@ -0,0 +1,75 @@ +import json, filecmp, shutil, requests +from datetime import datetime +from pathlib import Path +from time import sleep +from icecream import ic + +ic.disable() + +ID = [ ('7385440800019283','c9722276-9dce-11ef-86ff-8a456ecaea20','Хабаровск'), + ('9961440300761252','34dfe5e2-9f7c-11ec-ed95-0cc47ab40806','Комсомольск_на_Амуре'), + ('7385440800015768','7f8bb0cc-d7a5-11ee-85fe-8a456ecaea20','Береста 6'), +] + +while True: + CurDate = datetime.date(datetime.now()) + prevDate = datetime.date(datetime.now()) + try: + for fn, salepoint, kassa in ID: + ic(fn, salepoint) + headers = { + "Content-Type": "application/json", + "Integrator-ID": "BFFFC47E-38BB-4845-8399-7C2F5AB11A3C" + } + data = { + "Login": "myasnikova@maverik.ru", + "Password": "qolabuyi" + } + 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}" + } + ic(result.text) + ic(sessionToken) + try: + 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)) + for i in result.json()['records']: + shiftNumber = i['shiftNumber'] + fnFactoryNumber = i['fnFactoryNumber'] + ic(result.text) + try: + result = requests.get(f'https://api-lk-ofd.taxcom.ru/API/v2/DocumentList?fn={fn}&shift={shiftNumber}&type=3', headers=headers, timeout=(20, 240)) + ic(result.text) + cheks = result.json()['records'] + except: + ic() + requests.get(f'https://api.telegram.org/bot5374522720:AAGoNUYCEyJ-7-bSAQPT7aV_W2GWcinnkQU/sendMessage?parse_mode=HTML&chat_id=394151541&text=Taxcom:\nЧека нет') + continue + with open('check', 'w', encoding='utf-8') as f: + f.write(str(cheks)) + if Path('check').is_file(): + if Path(kassa).is_file(): + if filecmp.cmp('check', kassa): + print(f'{kassa} -- Новые чеки отсутствуют') + continue + shutil.copy('check', kassa) + Path('check').unlink() + data = {"salepoint": salepoint, + "res": str(cheks)} + data = json.dumps(data, ensure_ascii=False).encode('utf-8') + print(kassa) + result = requests.post('http://10.15.0.3/bso_maverik/hs/exchange/saveTaxcomDocs', data=data, allow_redirects=False, auth=('robot', 's38*Cqy2L*PB'), timeout=(10, 120)) + print(result.text) + print('-----------------') + except: + continue + print('#################') + except Exception as e: + requests.get(f'https://api.telegram.org/bot5374522720:AAGoNUYCEyJ-7-bSAQPT7aV_W2GWcinnkQU/sendMessage?parse_mode=HTML&chat_id=394151541&text=Taxcom:\n{e}') + + print('#################') + print('#################') + print('#################') + sleep(120) \ No newline at end of file