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

bug: Failed lookup for key [to_is_representative] when creating a single invoice #549

Open
TreyWW opened this issue Feb 6, 2025 · 0 comments
Labels

Comments

@TreyWW
Copy link
Owner

TreyWW commented Feb 6, 2025

What version of MyFinances are you currently using?

latest

What device type are you currently facing the issue on?

No response

Describe the bug

Can't reach the page /dashboard/invoices/single/create/ at the moment on some deployments. But I haven't been able to clearly reproduce to get the exact cause.

Error

django.template.base.VariableDoesNotExist: Failed lookup for key [to_is_representative] in [{'True': True, 'False': False, 'None': None}, {}, {}, {'clients': <QuerySet [<Client: ***>]>, 'existing_products': <QuerySet []>, 'from_name': '', 'from_company': '', 'from_address': '', 'from_city': '', 'from_county': '', 'from_country': '', 'from_email': '', 'issue_date': '2025-02-06', 'due_date': '2025-02-13', 'sort_code': '', 'account_holder_name': '', 'account_number': '', 'page_template': 'pages/invoices/create/create_single.html'}]

Reference

The only place that to_is_representative is referenced is frontend/templates/pages/invoices/create/destinations/_to_destination.html

{% if existing_client %}
            <p class="text-md">{{ existing_client.name | default:"No Name" }}</p>
            <p class="text-sm">{{ existing_client.company | default:"No Company" }}</p>
            <p class="text-sm">{{ existing_client.address | default:"No address" }}</p>
            {#        <p class="text-sm">{{ existing_client.city | default:"Oxford" }}</p>#}
            {#        <p class="text-sm">{{ existing_client.county | default:"Oxfordshire" }}</p>#}
            <p class="text-sm">{{ existing_client.country | default:"No country" }}</p>
            <p class="text-sm">
                {% if existing_client.is_representative %}
                    Is a
                {% else %}
                    Is not a
                {% endif %}
                representative
            </p>
        {% else %}
            <p class="text-md">{{ to_name | default:"No Name" }}</p>
            <p class="text-sm">{{ to_company | default:"No Company" }}</p>
            <p class="text-sm">{{ to_email | default:"No Email Associated" }}</p>
            <p class="text-sm">{{ to_address | default:"No address" }}</p>
            <p class="text-sm">{{ to_city | default:"No city" }}</p>
            <p class="text-sm">{{ to_county | default:"No county" }}</p>
            <p class="text-sm">{{ to_country | default:"No country" }}</p>
            <p class="text-sm">
                {% if is_representative == "on" or to_is_representative == "on" %}
                    Is a
                {% else %}
                    Is not a
                {% endif %}
                representative
            </p>
        {% endif %}

or

    <input type="hidden"
           name="is_representative"
           value="{% if to_is_representative %}{{ is_representative | default:to_is_representative }}{% else %}{{ is_representative }}{% endif %}">

Could well be the default:to_is_representative part

@TreyWW TreyWW added the bug label Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant