Browse Source

created cli command for filling the prepayment form separate from the final payment procedure

master
Holger Frey 1 day ago
parent
commit
a42e0b71b2
  1. 1
      pyproject.toml
  2. 18
      work_helpers/travels.py

1
pyproject.toml

@ -24,6 +24,7 @@ requires = [ @@ -24,6 +24,7 @@ requires = [
[tool.flit.scripts]
form_inspect = "work_helpers.fill_forms:inspect"
travel_pre_payment = "work_helpers.travels:fill_prepayment_form"
travel_final_payment = "work_helpers.travels:final_payment"
nice_path = "work_helpers.nice_path:make_nice_path"
random_password = "work_helpers.password:get_random_password"

18
work_helpers/travels.py

@ -50,6 +50,11 @@ class PrePayments: @@ -50,6 +50,11 @@ class PrePayments:
def __iter__(self) -> Iterable[PrePaymentEntry]:
return iter(self.payments)
@property
def nice_number(self) -> str:
if len(self.travel_nr) > 6:
return " ".join(self.travel_nr[:5], self.travel_nr[5:])
def to_form_data(self) -> dict[str, str]:
form_data = {
@ -239,7 +244,7 @@ def _create_text_stub(path: Pathlike, *, content: str = None) -> None: @@ -239,7 +244,7 @@ def _create_text_stub(path: Pathlike, *, content: str = None) -> None:
path.write_text(content)
def fill_pre_payments_form(destination_path: Pathlike) -> PrePayments:
def _fill_pre_payments_form(destination_path: Pathlike) -> PrePayments:
pre_payments = _read_pre_payments()
print(f"Projekt: {pre_payments.project}")
@ -263,18 +268,26 @@ def fill_pre_payments_form(destination_path: Pathlike) -> PrePayments: @@ -263,18 +268,26 @@ def fill_pre_payments_form(destination_path: Pathlike) -> PrePayments:
return pre_payments
@click.command()
def fill_prepayment_form():
destination_path = DESKTOP / f"{TODAY} UK-Abschlag.pdf"
_fill_pre_payments_form(destination_path)
@click.command()
@click.option("-l", "--search_last_name", prompt=True, required=True)
@click.option("-d", "--iso_date", prompt=True, required=True)
@click.option("-p", "--place", prompt=True, required=True)
def final_payment(search_last_name: str, iso_date: str, place: str):
print("---")
info = _complete_travel_info(search_last_name, iso_date, place)
print(f"Name: {info.first_last}")
folder = DESKTOP / f"{info.travel_name} (abgerechnet)"
folder.mkdir()
destination_path = folder / f"{TODAY} {info.travel_short}, UK-Abschlag.pdf"
payments = fill_pre_payments_form(destination_path)
payments = _fill_pre_payments_form(destination_path)
rk_path = folder / f"DATE {info.travel_short}, Reisekostenabrechnung.txt"
_create_text_stub(rk_path)
@ -288,6 +301,7 @@ def final_payment(search_last_name: str, iso_date: str, place: str): @@ -288,6 +301,7 @@ def final_payment(search_last_name: str, iso_date: str, place: str):
info.ger_date.replace(".", "/"),
info.first_last,
f"Schlusszahlung Dienstreise {info.place}, {info.ger_date}",
payments.nice_number
]
)
_create_text_stub(uka_hint_path, content=content)

Loading…
Cancel
Save