redstreet / fava_investor

Comprehensive set of reports, analyses, and tools for investments, for Beancount and Fava (plain text, double entry accounting software). Includes Fava plugins, command line tools, and libraries for each module.
GNU General Public License v3.0
134 stars 19 forks source link

Fava Investor Won't Load (Windows-only issue?) #51

Open floatingheads opened 4 years ago

floatingheads commented 4 years ago

When I click the Investor link (using the included huge-example) in Fava I get a loading failed error, similar to issue #47 . I get a slew of flask and jinja errors, but the trigger is:

File "<unknown>", line 45, in template jinja2.exceptions.TemplateSyntaxError: expected token 'end of print statement', got '_'

floatingheads commented 4 years ago

I looked further into this. It appears to be something with the investor.html file. I can delete out the tax loss harvester module (narrowed it down to deleting out lines 43 through 56) and the asset_tree macro (just the print statements in the very first <ol>) and it will load up just fine. I'm not savvy in jinja2 though, so I'm not sure what is going on in the chunks of code in those 2 sections.

floatingheads commented 4 years ago

In response to my last comment, after updating fava_investor and fiddling a little bit more, I only need to delete out a portion of the tax loss harvester, then everything works. I no longer need to mess with the asset_tree macro. Here is the portion of code that is causing the issue (lines 44-56):

`

{{ _('Summary') }}
        <th data-sort="string">{{ _('Val') }}</th>
      </tr>
    </thead>
    <tbody>
      {% for key, value in harvests[1].items() %}
      <tr>
        <td>{{ key }}</td>
        <td align="right">{{ value }}</td>
      </tr>
      {% endfor %}
    </tbody>`

Here is the code after I deleted the problem portions, which allowed everything to work (albeit missing those pieces of the table):

`

`
redstreet commented 4 years ago

Awesome, thanks for debugging this far. I'll look into this later in the week.

redstreet commented 4 years ago

I'm having trouble reproducing this. Would you mind sharing your software versions? I'm using: beancount 2.3.2 fava 1.15 fava-investor 0.2.0 jinja2 2.11.2 debian 10.4

Thanks.

floatingheads commented 4 years ago

beancount 2.3.2 fava 1.15 fava-investor 0.2.0 flask 1.1.2 (I get flask errors also, so figured I'd include that as well) jinja2 2.11.2 Windows 10

Also, I do have 95% functionality and just want to see this is great work. Thanks for putting it together. Definitely see myself using this a lot in the future.

bradyemerson commented 3 years ago

Can confirm this is a Windows issue. Same code works fine when I run in Docker Linux container

floatingheads commented 3 years ago

Managed to figure a portion of this out. I guess for some reason (maybe Windows only as suggested by bradyemerson) jinja doesn't like reusing variable names. For lines 50-53, use new variable names (I used summary_title and summaryvalue) in lieu of key, value and that works. They only things which still throw it for a loop are lines 45-46, which call ('Summary') and ('Val'). I'm not sure if maybe something needs to be imported or installed for the () function to work or if an alternate function can be used. I tried gettext() with no luck.

redstreet commented 3 years ago

@floatingheads, thanks a bunch for root causing and sharing! If you're up for submitting a PR, I'd gladly review it. If not, I'll put one in soon myself. Will leave this ticket open until the fix is in.

floatingheads commented 3 years ago

@redstreet I still can't figure out why the _() function is keeping it from working. It works elsewhere in the template, just not on those lines.