diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml new file mode 100644 index 0000000..1e8aafe --- /dev/null +++ b/.github/workflows/pythonapp.yml @@ -0,0 +1,30 @@ +name: Python application + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: Lint with flake8 + run: | + pip install flake8 + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics +# - name: Test with pytest +# run: | +# pip install pytest +# pytest diff --git a/rechnung/contract.py b/rechnung/contract.py index 09fd726..64b4094 100644 --- a/rechnung/contract.py +++ b/rechnung/contract.py @@ -31,17 +31,6 @@ def get_contracts(settings, year=None, month=None, inactive=False): return {k: contracts[k] for k in sorted(contracts)} -def create_contract(customer, positions): - contract_data = customer - contract_data["product"] = positions[0] - contract_data["product"]["price"] = round( - positions[0]["price"] * 1.0 + settings.vat, 2 - ) - contract_data["email"] = customer["email"] - - return contract_data - - def render_contracts(settings): template = get_template(settings.contract_template_file) logo_path = settings.assets_dir / "logo.png" @@ -74,22 +63,6 @@ def render_contracts(settings): ) -def save_contract_yaml(settings, contract_data): - outfilename = settings.contracts_dir / contract_data["cid"] + ".yaml" - try: - with open(outfilename, "x") as outfile: - outfile.write(yaml.dump(contract_data, default_flow_style=False)) - except FileExistsError: - print("Contract {} already exists.".format(outfilename)) - - -def create_yaml_contracts(settings, customers, positions): - for cid in customers.keys(): - print(f"Creating contract yaml for {cid}") - contract_data = create_contract(customers[cid], positions[cid]) - save_contract_yaml(settings, contract_data) - - def send_contract(settings, cid): mail_template = get_template(settings.contract_mail_template_file) contract_pdf_path = Path(settings.contracts_dir) / f"{cid}.pdf" @@ -153,8 +126,3 @@ def send_contract(settings, cid): settings.password, settings.insecure, ) - - -def create_contracts(settings): - positions = get_positions(settings.positions_dir) - create_yaml_contracts(settings)