Fixed reports request

This commit is contained in:
2026-04-03 16:48:44 +03:00
parent 65c04d1578
commit e03aed78f0
2 changed files with 19 additions and 15 deletions
+17 -13
View File
@@ -41,21 +41,25 @@ class Focus(Request):
:rtype: str
"""
response = self.get('/excerpt')
current_datetime = datetime.now().strftime('%d-%m-%Y_%H-%M')
filename = f'Выписка_{self.inn}_{current_datetime}.pdf'
if response.status_code != 404:
current_datetime = datetime.now().strftime('%d-%m-%Y_%H-%M')
filename = f'Выписка_{self.inn}_{current_datetime}.pdf'
if not path:
file_path = os.path.join(self._basedir, filename)
if not path:
file_path = os.path.join(self._basedir, filename)
else:
file_path = os.path.join(path, filename)
try:
with open(file_path, mode='wb') as file:
file.write(response.content)
return {'success': True, 'filename': filename, 'path': file_path}
except Exception as e:
return {'success': False, 'message': e}
else:
file_path = os.path.join(path, filename)
try:
with open(file_path, mode='wb') as file:
file.write(response.content)
return {'success': True, 'filename': filename, 'path': file_path}
except Exception as e:
return {'success': False, 'message': e}
return {'success': False, 'message': 'Not found'}
def express_report(self, pdf: bool = True, path: str = None) -> dict:
"""Экспресс-отчет по контрагенту