MyFinances icon indicating copy to clipboard operation
MyFinances copied to clipboard

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

Open TreyWW opened this issue 10 months ago • 0 comments

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 avatar Feb 06 '25 13:02 TreyWW