juntagrico / juntagrico-billing

GNU Lesser General Public License v3.0
2 stars 3 forks source link

Error on negative bill amounts #40

Closed pascalfree closed 1 month ago

pascalfree commented 3 months ago

If a bill is overpaid the remaining amount will be negative, which will cause the below error.

ValueError at /jb/user_bill/3217
If provided, the amount must match the pattern '###.##' and cannot be larger than 999'999'999.99
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/juntagrico_billing/views.py", line 290, in user_bill
    qr_svg = get_qrbill_svg(bill, settings.default_paymenttype)
  File "/usr/local/lib/python3.9/site-packages/juntagrico_billing/util/qrbill.py", line 82, in get_qrbill_svg
    qr = QRBill(
  File "/usr/local/lib/python3.9/site-packages/qrbill/bill.py", line 284, in __init__
    raise ValueError(

if opened with a negative pending amount, the bill should not be created, but the user should be redirected to a page, informing them, that they don't have to pay anymore and they have a "Guthaben".

samuel-iseli commented 3 months ago

I think we should just display the negative amount with informational text, and suppress the rendering of the payslip.

iulica commented 3 months ago

I think we should just display the negative amount with informational text, and suppress the rendering of the payslip.

I agree with the simple solution. That's what I also do, with a conditional Text if the amount is negative.

nixnuex commented 3 months ago

Same error appeared here, I agree with Samuel's proposal

nixnuex commented 1 month ago

Is there any help needed?

samuel-iseli commented 1 month ago

will see that I fix it soon, should be easy.

samuel-iseli commented 1 month ago

Add negative open amount handling.