44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
# nacti uzaverku
|
|
import api_call
|
|
from pydantic import SecretStr
|
|
# ---------- API context ----------
|
|
def get_ctx():
|
|
ctx = api_call.ApiContext(
|
|
user="Alto",
|
|
base_url="http://127.0.0.1:8000",
|
|
refresh_url="http://127.0.0.1:8000",
|
|
client_id="99",
|
|
id_kas="01",
|
|
username="Kobrle",
|
|
password=SecretStr("heslo"),
|
|
)
|
|
return ctx
|
|
ctx = get_ctx()
|
|
# ---------- login ----------
|
|
api_call.login_API(ctx)
|
|
# ---------- dotaz na seznam uzávěrek ----------
|
|
closures, err = api_call.load_closures_API( ctx)
|
|
if err:
|
|
print(err)
|
|
exit()
|
|
# ---------- poslední 2 uzávěrky ----------
|
|
print("\nNAČÍTÁM POSLEDNÍ 2 UZÁVĚRKY:\n")
|
|
for c in closures[:2]:
|
|
print(
|
|
"UZÁVĚRKA:",
|
|
c.clsrep_no,
|
|
c.ucislo_od,
|
|
c.ucislo_do,
|
|
c.closed_at_od,
|
|
c.closed_at_do,
|
|
)
|
|
# ---------- načti detail uzávěrky ----------
|
|
detail, err = api_call.closure_detail_API(ctx, c.clsrep_no)
|
|
if err:
|
|
print("CHYBA:", err)
|
|
continue
|
|
print("POČET ÚČTŮ:", len(detail["ucty"]))
|
|
print("CLSREP:", detail["data"])
|
|
for u in detail["ucty"]:
|
|
print(" UCET:", u.get("ucislo"))
|
|
print() |