Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making it run again #54

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open

Making it run again #54

wants to merge 9 commits into from

Conversation

aparcar
Copy link
Collaborator

@aparcar aparcar commented Apr 28, 2020

Not touched for a long time, trying to run it introduced a whole bunch of problem. Here are some solved.

aparcar added 7 commits April 27, 2020 15:12
The leadin `./` don't work with VSCode.
Also alphabetically sorted.

Signed-off-by: Paul Spooren <[email protected]>
Create contract before creating the invoices.

Also print the mail address in the overview.

Signed-off-by: Paul Spooren <[email protected]>
Use Pathlib to simplify template code.

Also send all outgoing invoices to BCC as `rechnung` does not store mail
in a *Sent* folder.

Signed-off-by: Paul Spooren <[email protected]>
Using Umlaute in templates or yaml files caused trouble, now handle
everything as UTF-8.

Signed-off-by: Paul Spooren <[email protected]>
Use the `locale` module to print the correct currency instead of some
self created format.

Signed-off-by: Paul Spooren <[email protected]>
Decreses time wasted during debugging.

Signed-off-by: Paul Spooren <[email protected]>
Copy link
Member

@cfra cfra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have looked over it and all in all it seems like a nice cleanup. 🙂

There are a a few minor comments inline.

Comment on lines +4 to +11
assets/
bin/
contracts/
docs/_build/
invoices/
lib*
pyvenv.cfg
settings.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking the current .gitignore with the ./ lead-in using git check-ignore --verbose, it seems indeed like these rules are broken and do never match.

However, it does not really seem like a good idea to me to add things like contracts/ or invoices/ to .gitignore without making them relative to the repository root:

Imagine you are changing the contract.py module in rechnung into its own contracts package.

With your change, this whole package would be ignored by git, because any directory that goes by the name of contracts will be ignored anywhere in the repository.

The better solution might be to change all occurrences of ./ in the .gitignore with /:

  • It's an allowed pattern
  • It seems to match the originally intended meaning
  • It doesn't ignore directories with common names broadly and unspecifically

Comment on lines +22 to +24
contract = yaml.safe_load(
(settings.contracts_dir / filename).read_text("utf-8")
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading everything into a buffer to then passing it to yaml.safe_load seems rather inelegant, as yaml.safe_load also accepts a stream.

Instead of using the read_text method of pathlib and duplicating everything in memory, the encoding problems could probably also be solved like this:

Suggested change
contract = yaml.safe_load(
(settings.contracts_dir / filename).read_text("utf-8")
)
with open(Path(settings.contracts_dir / filename), "r", "utf-8") as contract_file:
contract = yaml.safe_load(contract_file)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After all I think the encoding was partly a problem on my side. I think some Python files where for whatever reason in a different encoding causing a lot of trouble. Should I fix this particular issue or should I revert it?

@@ -23,6 +23,9 @@ def get_contracts(settings, year=None, month=None, cid_only=None, inactive=False
(settings.contracts_dir / filename).read_text("utf-8")
)

if not contract.get("active", False):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this seems like a newly introduced feature, wouldn't it be better to default to a contract being active, so that not all existing active contracts need to be explicitly marked as active, but instead only the new inactive contracts need to be marked as inactive?

Suggested change
if not contract.get("active", False):
if not contract.get("active", True):

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!

aparcar added 2 commits June 26, 2020 09:23
If no clear state of `active` is given, guess that they are active as
this is a new setting and may be missing in existing setups.

Signed-off-by: Paul Spooren <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants