Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
@@ -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
32 changes: 0 additions & 32 deletions rechnung/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)