Skip to content

Org: Round invoice to 0.05 before grand total#2570

Merged
cyrillkuettel merged 14 commits into
masterfrom
ogc-2957-rundungen-auf-005-chf
Jul 17, 2026
Merged

Org: Round invoice to 0.05 before grand total#2570
cyrillkuettel merged 14 commits into
masterfrom
ogc-2957-rundungen-auf-005-chf

Conversation

@cyrillkuettel

@cyrillkuettel cyrillkuettel commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Please fill in the commit message below and work through the checklist. You can delete parts that are not needed, e.g. the optional description, the link to a ticket or irrelevant options of the checklist.

Commit message

Org: Round invoice to 0.05 before grand total

TYPE: Feature
LINK: OGC-2957

Checklist

  • I considered adding a reviewer
  • I have updated the PO files
  • I have tested my code thoroughly by hand
  • I have added tests for my changes/features

@linear

linear Bot commented Jul 9, 2026

Copy link
Copy Markdown

OGC-2957

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.10714% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.54%. Comparing base (70aaa8d) to head (00083fc).
⚠️ Report is 4 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/onegov/org/models/ticket.py 94.44% 1 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/onegov/org/constants.py 100.00% <ø> (ø)
src/onegov/org/forms/settings.py 73.22% <100.00%> (+0.06%) ⬆️
src/onegov/org/models/organisation.py 95.95% <100.00%> (+0.01%) ⬆️
src/onegov/org/utils.py 86.82% <100.00%> (+0.03%) ⬆️
src/onegov/org/views/form_submission.py 81.03% <100.00%> (+0.06%) ⬆️
src/onegov/org/views/reservation.py 71.77% <100.00%> (+0.07%) ⬆️
src/onegov/org/views/settings.py 87.00% <100.00%> (ø)
src/onegov/org/views/ticket.py 85.45% <100.00%> (ø)
src/onegov/pay/__init__.py 100.00% <100.00%> (ø)
src/onegov/pay/utils.py 96.81% <100.00%> (+2.17%) ⬆️
... and 3 more

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 70aaa8d...00083fc. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cyrillkuettel
cyrillkuettel requested a review from Daverball July 14, 2026 07:01
The ==7.16 pin was a local install workaround and doesn't belong in the
ticket.
Running darker over these files made black re-wrap every decorator it
touched, turning a three-word label rename into a 179 line diff. The
only actual change is 'Value Added Tax' -> 'Prices'.
The rounding call had been wrapped in a stray parenthesized block with a
trailing conditional. An early return for the missing resource reads
better.
apply_price_rounding lives in onegov.org.utils, so testing it from
tests.onegov.pay made the lower layer import the higher one.
round_to_five_rappen stays with onegov.pay.

@Daverball Daverball left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall this seems fine. However you forgot to apply rounding to form and directory entry submissions.

I think the design could also use some refactoring, so we're less likely to forget to apply rounding. The most robust idea I have is introducing a new helper type InvoiceMeta that is aware of the potential existence of a rounding base and manual invoice items on an existing invoice and return that new helper type in a lot of places instead of list[InvoiceItemMeta].

That way we can standardize a lot of the logic and bake it into this helper, instead of having to remember to call a utility function in half a dozen different places.

Comment thread src/onegov/org/forms/settings.py Outdated
Comment thread src/onegov/org/models/ticket.py Outdated
Comment thread src/onegov/org/views/reservation.py Outdated

@Daverball Daverball left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, I just have a few more follow-up suggestions.

Comment thread src/onegov/org/locale/de_CH/LC_MESSAGES/onegov.org.po Outdated
Comment thread src/onegov/org/models/ticket.py Outdated
new_item_metas = self.invoice_items(request)
if not new_item_metas:
invoice_meta = self.invoice_items(request, rounding_base)
if not invoice_meta.items:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I just realized this part is a little controversial, since we delete the invoice as soon as there are no automatic invoice items, regardless of whether are any manual items.

On the other hand, it's not possible to add manual invoice items when there is nothing to invoice, so maybe this is actually good for consistency. Otherwise we would have to consider always allowing manually adding invoice items to a ticket. Which could be useful, but for now I think we'll just leave it like this, until someone has an actual use-case..

Comment thread src/onegov/org/templates/macros.pt Outdated
Comment thread src/onegov/org/views/form_submission.py Outdated
Comment thread src/onegov/org/views/form_submission.py Outdated
Comment thread src/onegov/org/views/reservation.py Outdated
Comment thread src/onegov/org/constants.py Outdated
Comment thread src/onegov/pay/utils.py Outdated
Comment thread src/onegov/ticket/handler.py Outdated
Comment thread src/onegov/town6/templates/macros.pt Outdated
@cyrillkuettel

Copy link
Copy Markdown
Contributor Author

I think I have everything now

@Daverball Daverball left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, there's one minor footgun left with InvoiceMeta.total_vat we probably should address, but it won't matter until we allow setting a VAT rate on manual invoice items.

@cyrillkuettel
cyrillkuettel merged commit c2244f1 into master Jul 17, 2026
16 checks passed
@cyrillkuettel
cyrillkuettel deleted the ogc-2957-rundungen-auf-005-chf branch July 17, 2026 08:56
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