DESKTOP EDITION CLOUD EDITION SERVER EDITION GUIDES FORUM

Custom view template does not show amounts credited


#1

Installed v15.4.13 today. Then entered a partial payment against a sales invoice. But the sales invoice does not show the amount credited when using a custom view template. All ledgers are correct, Summary is correct, and so on. If I edit the sales invoice to use the default view template, the amount credited shows. This problem seems related only to the fact that a custom view template is being used.

The same problem occurs on previous sales invoices. Invoices that were originally created using a custom view template now show ##### as their view templates. However, they apparently have reverted to the default view template. If I edit them to use the custom view template, amounts credited no longer appear and the Paid in Full stamp is missing.

On the chance that recent updates changed how the default template is used, I recreated a new custom view template from the current default one. My changes were minor:

  • Added some top padding and scaled the table width downwards and centered the form to create bigger margins.
  • Changed font size for the summary line
  • Inserted a “Make payment to” line above the business name

All those changes appear when using the new custom view template. But the amount credited and Paid in Full stamp are still missing.

Since I don’t frequently look at old invoices, I am not able to say when this problem first appeared. I only noticed it today because of the partial payment.


#2

The idea behind custom view templates is that users should make their own. There is some “default” one Manager has just to demonstrate how it works.

The previous default template was comprehensive but extremely difficult to understand (even for me) so new default template was greatly simplified and a lot of non-essential features removed.

I understand that sometime you don’t want to write new HTML template from scratch and just want to make minor modifications to the default look of your invoices. I get it.

Perhaps I will need to get rid of the default template altogether and just write some tutorial to explain how to create one from scratch. The you can cherry-pick from tutorial what you want on your invoice and what you don’t want. End result would be that your template does everything you want but it’s simple to understand, modify and extend.

By the way, if the invoice shows ##### as their template. It means the template has been deleted and thus default one will be used.


Added ability to create custom field as a drop-down list
#3

Is there a way to access the standard sales invoice code? I want its features, but would like to make very minor modifications. If I could get access to the standard, I could paste it into a view template and make my tweaks. No need to write from scratch.


#4

I would also like the comprehensive template.
I am currently using an older version and can still see amount credited.

Should I make a copy of the code In this template?

I have only added code to be able to see 2 custom fields that are printed on the standard invoice.

When I do update to the latest version then copy my code in, then update in the future, will I have to keep copying my code in or will it be memorised?

@Tut
You could maybe try reverting back to an older version (back to when the template was how you wanted it) make a copy the code updating then pasting that code into your template.

I don’t think it’s right that it’s changed previous invoices using custom template.

I thought they should always be exactly the same as how you issued it in the first place?


#5

@itmoto, I think the problem is a little more complex. I understand your suggestion, but I think @lubos made underlying changes that affected the way a custom view template was able to access and use data. For example, I entered a new invoice using the old custom template. The basic structure of the invoice matched my modified format. But even though the template hadn’t changed, the amount credited would not show.

And all prior invoices that used the custom template now show ##### in the template dropdown box, which @lubos says means their templates have been deleted. As you fear, this means that prior invoices are being changed, something that can create problems if there is a dispute. The only good thing is that the data is all there.

Try a test case and I believe you will understand what I mean.

Since I also had only a few minor changes, I thought I’d be able to apply them to new standard templates to take advantage of features being added, but still have my format changes. It turns out that is not true. And the problem is that the view template “baseline” that comes up for modification is not the default standard template the program uses.


#6

The problem is that there is no longer any “comprehensive” template for invoices.

It was a nightmare for me to maintain as there are a lot of conditions how invoice is ought to look like based on many variables. Don’t get me wrong, Liquid markup language is great for designing specific HTML template. It’s not great fit to design fit-for-all template as it gets really complicated. So while the concept was promising, it turns out it was not sustainable solution.

I will rather implement some invoice template generator where you could tick/untick features on invoice you like and then template would be generated based on selected options. This would be suitable if you don’t want to create one completely from scratch.

Also, here is the last “generic” template Manager had if you are interested.

<table style=""width: 100%"">
    <thead>
        <tr>
            <td style=""font-size: 36px; font-weight: bold; vertical-align: top; line-height: 36px"">{{ strings.invoice }}</td>
            <td style=""text-align: right"">{% if business.logo != null %}<img src=""{{ business.logo }}"" style=""max-width: 300px; max-height: 150px"">{% endif %}</td>
        </tr>
        <tr>
            <td colspan=""2"" style=""padding: 20px 0px"">
                <table style=""width: 100%"">
                    <tr>
                        <td style=""vertical-align: top; font-weight: bold; width: 1px; white-space: nowrap; padding-right: 10px; padding-top: {{ window_faced_envelope.vertical_padding }}px"">
                            {{ strings.to }}
                        </td>
                        <td style=""vertical-align: top; padding-top: {{ window_faced_envelope.vertical_padding }}px; padding-left: {{ window_faced_envelope.horizontal_padding }}px"">
                            <div>{{ customer.name }}</div>
                            <div>{{ billing_address | newline_to_br }}</div>
                            <div>{{ customer.identifier }}</div>
                        </td>
                        <td style=""vertical-align: top; width: 100px; padding-right: 20px; vertical-align: top; text-align: right"">
                            <div style=""font-weight: bold"">{{ strings.issue_date }}</div>
                            <div>{{ issue_date | date_to_string }}</div>
                            {% if due_date != null %}
                            <div style=""font-weight: bold; margin-top: 10px"">{{ strings.due_date }}</div>
                            <div>{{ due_date | date_to_string }}</div>
                            {% endif %}
                            <div style=""font-weight: bold; margin-top: 10px; white-space: nowrap"">{{ strings.invoice_number }}</div>
                            <div>{{ reference }}</div>
                            {% if sales_quote != empty %}
                            <div style=""font-weight: bold; margin-top: 10px; white-space: nowrap"">{{ strings.sales_quote }}</div>
                            <div>{{ sales_quote }}</div>
                            {% endif %}
                            {% if purchase_order != empty %}
                            <div style=""font-weight: bold; margin-top: 10px; white-space: nowrap"">{{ strings.purchase_order }}</div>
                            <div>{{ purchase_order }}</div>
                            {% endif %}
                        </td>
                        <td style=""vertical-align: top; width: 100px; border-left: 1px solid #000; padding-left: 20px; vertical-align: top"">
                            <div style=""font-weight: bold; white-space: nowrap"">{{ business.name }}</div>
                            <div style=""white-space: nowrap"">{{ business.contact_information | newline_to_br }}</div>
                            <div style=""white-space: nowrap"">{{ business.identifier }}</div>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td colspan=""2"">
                <div style=""font-weight: bold; padding-bottom: 20px; font-size: 14px"">{{ summary }}</div>
                <table style=""width: 100%"">
                    <tr>
                        {% if has_item %}<th style=""border: 1px solid #000; padding: 5px 10px"">{{ strings.item }}</th>{% endif %}
                        <th style=""border: 1px solid #000; padding: 5px 10px"">{{ strings.description }}</th>
                        {% if has_qty %}<th style=""width: 40px; border: 1px solid #000; padding: 5px 10px; text-align: center"">{{ strings.qty }}</th>{% endif %}
                        {% if has_qty %}<th style=""width: 80px; border: 1px solid #000; padding: 5px 10px; text-align: center"">{{ strings.unit_price }}</th>{% endif %}
                        {% if has_discount %}<th style=""width: 60px; border: 1px solid #000; padding: 5px 10px; text-align: center"">{{ strings.discount }}</th>{% endif %}
                        {% if distinct_taxes > 1 %}<th style=""width: 40px; border: 1px solid #000; padding: 5px 10px; text-align: center"">{{ strings.tax }}</th>{% endif %}
                        <th style=""width: 100px; border: 1px solid #000; padding: 5px 10px; text-align: center"">{{ strings.amount }}</th>
                    </tr>
                    {% for line in lines %}
                    <tr>
                        {% if has_item %}<td style=""border: 1px solid #000; padding: 5px 10px; border-bottom: none; border-top: none; vertical-align: top"">{{ line.item.name }}</td>{% endif %}
                        <td style=""border: 1px solid #000; padding: 5px 10px; border-bottom: none; border-top: none"">{{ line.description | newline_to_br }}</td>
                        {% if has_qty %}<td style=""border: 1px solid #000; padding: 5px 10px; border-bottom: none; border-top: none; text-align: center; vertical-align: top"">{{ line.qty }}</td>{% endif %}
                        {% if has_qty %}<td style=""border: 1px solid #000; padding: 5px 10px; border-bottom: none; border-top: none; text-align: right; vertical-align: top"">{{ line.unit_price | money_without_currency }}</td>{% endif %}
                        {% if has_discount %}<td style=""border: 1px solid #000; padding: 5px 10px; border-bottom: none; border-top: none; text-align: center; vertical-align: top"">{% if line.discount != null %}{{ line.discount }} %{% endif %}</td>{% endif %}
                        {% if distinct_taxes > 1 %}<td style=""border: 1px solid #000; padding: 5px 10px; border-bottom: none; border-top: none; text-align: center; vertical-align: top; white-space: nowrap"">{% if line.tax %}{{ line.tax.code }}{% else %}-{% endif %}</td>{% endif %}
                        <td style=""border: 1px solid #000; padding: 5px 10px; text-align: right; border-bottom: none; border-top: none; vertical-align: top; white-space: nowrap"">{{ line.total | money_without_currency }}</td>
                    </tr>
                    {% endfor %}
                    <tr>
                        {% if has_item %}<td style=""border: 1px solid #000; padding: 5px 10px; border-top: none"">&nbsp;</td>{% endif %}
                        <td style=""border: 1px solid #000; padding: 5px 10px; border-top: none"">&nbsp;</td>
                        {% if has_qty %}<td style=""border: 1px solid #000; padding: 5px 10px; border-top: none"">&nbsp;</td>{% endif %}
                        {% if has_qty %}<td style=""border: 1px solid #000; padding: 5px 10px; border-top: none"">&nbsp;</td>{% endif %}
                        {% if has_discount %}<td style=""border: 1px solid #000; padding: 5px 10px; border-top: none"">&nbsp;</td>{% endif %}
                        {% if distinct_taxes > 1 %}<td style=""border: 1px solid #000; padding: 5px 10px; border-top: none"">&nbsp;</td>{% endif %}
                        <td style=""border: 1px solid #000; padding: 5px 10px; border-top: none"">&nbsp;</td>
                    </tr>

                  {% assign colspan = 1 %}
                  {% if has_item %}{% assign colspan = colspan | plus:1 %}{% endif %}
                  {% if has_qty %}{% assign colspan = colspan | plus:2 %}{% endif %}
                  {% if has_discount %}{% assign colspan = colspan | plus:1 %}{% endif %}
                  {% if distinct_taxes > 1 %}{% assign colspan = colspan | plus:1 %}{% endif %}

                  {% if amounts_include_tax %}
                    {% if rounding != 0 %}
                    <tr>
                        <td colspan=""{{colspan}}"" style=""text-align: right; padding: 5px 10px"">Round off</td>
                        <td style=""border: 1px solid #000; text-align: right; padding: 5px 10px; white-space: nowrap"">{{ rounding | money }}</td>
                    </tr>
                    {% endif %}
                    <tr>
                        <td colspan=""{{colspan}}""  style=""text-align: right; padding: 5px 10px; font-weight: bold"">{{ strings.total }}</td>
                        <td style=""border: 1px solid #000; text-align: right; padding: 5px 10px; font-weight: bold; white-space: nowrap"">{{ total | money }}</td>
                    </tr>
                    {% for tax_component in tax_components %}
                    <tr>
                        <td colspan=""{{colspan}}""  style=""text-align: right; padding: 5px 10px"">{{ tax_component.code }}</td>
                        <td style=""border: 1px solid #000; text-align: right; padding: 5px 10px; white-space: nowrap"">{{ tax_component.amount | money }}</td>
                    </tr>
                  {% endfor %}
                  {% else %}
                    {% assign tax_components_count = tax_components | size %}
                    {% if tax_components_count > 0 %}
                    <tr>
                      <td colspan=""{{colspan}}"" style=""text-align: right; padding: 5px 10px; font-weight: bold"">{{ strings.subtotal }}</td>
                      <td style=""border: 1px solid #000; text-align: right; padding: 5px 10px; font-weight: bold; white-space: nowrap"">{{ subtotal | money }}</td>
                    </tr>
                    {% endif %}
                    {% for tax_component in tax_components %}
                    <tr>
                        <td colspan=""{{colspan}}""  style=""text-align: right; padding: 5px 10px"">{{ tax_component.code }}</td>
                        <td style=""border: 1px solid #000; text-align: right; padding: 5px 10px; white-space: nowrap"">{{ tax_component.amount | money }}</td>
                    </tr>
                    {% endfor %}
                    {% if rounding != 0 %}
                    <tr>
                        <td colspan=""{{colspan}}""  style=""text-align: right; padding: 5px 10px"">Rounding</td>
                        <td style=""border: 1px solid #000; text-align: right; padding: 5px 10px; white-space: nowrap"">{{ rounding | money }}</td>
                    </tr>
                    {% endif %}
                    <tr>
                        <td colspan=""{{colspan}}""  style=""text-align: right; padding: 5px 10px; font-weight: bold"">{{ strings.total }}</td>
                        <td style=""border: 1px solid #000; text-align: right; padding: 5px 10px; font-weight: bold; white-space: nowrap"">{{ total | money }}</td>
                    </tr>
                    {% endif %}
                    {% if amount_credited != 0 %}
                    <tr>
                        <td colspan=""{{colspan}}""  style=""text-align: right; padding: 5px 10px"">{{ strings.amount_credited }}</td>
                        <td style=""border: 1px solid #000; text-align: right; padding: 5px 10px; white-space: nowrap"">{{ amount_credited | money }}</td>
                    </tr>
                    <tr>
                        <td colspan=""{{colspan}}""  style=""text-align: right; padding: 5px 10px; font-weight: bold"">{{ strings.balance_due }}</td>
                        <td style=""border: 1px solid #000; text-align: right; padding: 5px 10px; font-weight: bold; white-space: nowrap"">{{ balance_due | money }}</td>
                    </tr>
                    {% endif %}
                </table>
                <div>{{ notes }}</div>
                
                {% if balance_due < 0 %}
                <div style=""text-align: center; margin-top: 40px; margin-bottom: 80px""><span style=""color: red; border: 10px solid red; padding: 10px; font-size: 40px; font-weight: bold; transform:rotate(-15deg); -ms-transform:rotate(-15deg); -moz-transform:rotate(-15deg); -webkit-transform:rotate(-15deg); -o-transform:rotate(-15deg);"">{{ strings.overpaid | capitalize }}</span></div>
                {% endif %}
                
                {% if balance_due > 0 %}
                <div>{{ terms_and_payment_advice }}</div>
                  {% if overdue %}
                    <div style=""text-align: center; margin-top: 40px; margin-bottom: 80px""><span style=""color: red; border: 5px solid red; padding: 10px; font-size: 20px; transform:rotate(-15deg); -ms-transform:rotate(-15deg); -moz-transform:rotate(-10deg); -webkit-transform:rotate(-10deg); -o-transform:rotate(-10deg);"">{{ strings.overdue | capitalize }}</span></div>
                  {% endif %}

                  {{ payment_advice_cutaway }}
                {% endif %}

                {% if balance_due == 0 %}
                  <div style=""text-align: center; margin-top: 40px; margin-bottom: 80px""><span style=""color: darkgreen; border: 5px solid darkgreen; padding: 10px; font-size: 20px; transform:rotate(10deg); -ms-transform:rotate(10deg); -moz-transform:rotate(10deg); -webkit-transform:rotate(10deg); -o-transform:rotate(10deg);"">{{ strings.paid_in_full | capitalize }}</span></div>
                {% endif %}
                
            </td>
        </tr>
    </tbody>
</table>

#7

Thanks for sharing this code, @lubos. Before implementing a modified version of the last generic template, however, let me ask whether this implements all current sales invoice features? If it doesn’t, I don’t want to use it, for fear of being left behind as the program improves or I enable new tabs or encounter a new accounting need.

My hope is to be able to make my few small edits to whatever the standard version is to alter format slightly. I don’t mind having to do that periodically, whenever the changelog reveals a new feature I want to adopt. That was possible when the template that came up after clicking New View Template was the current one.

I completely understand the difficulty you face of making an all-purpose invoice. It just seems like your original approach of providing the current standard as a starting point for new view templates was a good solution. Users could still customize to their hearts’ desires, but those who wanted just small changes could make them without losing functionality.

If you go with this approach, will it still be possible to somehow make those small adjustments to format? I’m talking here about:

  • Top padding and scaling to increase margins (to accommodate binding)
  • Changing font size for the summary line
  • Inserting a line above business information that says “Make payment to”

Thanks for your attention.


#8

No it doesn’t. For example, I’ve added ability to specify unit name for inventory items or billable time. This generic template doesn’t know anything about that.

It doesn’t mean it’s broken though. It just means, you will see “Qty” instead of “Hours”. That’s just an example.

As for invoice template generator, of course, you will be able to make changes to output HTML as it suits you.


#9

@lubos, I finally had some time to look into this issue of custom sales invoice templates further. I copied and pasted the entire block of code you posted in this topic 3 weeks ago under this heading:

into a new view template.

Without having made any changes to your code, I converted an existing invoice to that template, with fairly disastrous results. It generated a sales invoice (a) without the business logo, (b) without any vertical or horizontal border lines, and (3) with badly misaligned elements (such as currency symbols on wrong lines, customer and business information bunched towards the left side, etc.)

Although the functional elements were all there, such as an amount credited from Customer credits, something is obviously very wrong.

I don’t fully understand your earlier explanation that there is no longer any “comprehensive” template for invoices. Do you mean that the code used in any set of circumstances is generated on the fly? While I cannot conceive of how you would accomplish that, I can understand that in such a situation you cannot offer up whatever code is being used as a starting place in the View Templates setting environment. But, this creates big difficulties for anyone who needs a modified invoice but wants the features built into Manager.

It seems to me you have two kinds of users to consider. The first wants to generate completely different invoices from what Manager produces. It is reasonable to expect them to have or hire the HTML skills to start from scratch (or nearly from scratch). But the second kind is interested only in small changes: a little more space here, a custom field there, or some specially required tax statement. Many of those users could struggle through some simple changes and be thrilled with the results if they just had a place to start that they knew produced what they were seeing as the default invoice template. Is that not possible?

Let me give you a simple example of why this bothers me so much. I had a customer who paid a deposit. I had to send a sales invoice for the deposit to satisfy their accounting needs. They paid the invoice, and I received the payment as Other income and immediately transferred the deposit to Customer credits because I had not yet done the work to earn the revenue. Today, I completed the work, creating a new sales invoice from all the billable time and expenses recorded in the intervening weeks. The only way I can have the customer credit show on the final invoice is to use the default sales invoice, because that feature no longer works on my customized view template. Accounting-wise that is satisfactory, but the resulting document doesn’t look like I want.

The other way I could have handled the situation would have been to leave the deposit in an income account after they paid the first invoice and add a deduction line to the final invoice. But that would have misrepresented the financial situation in the interim by categorizing their payment as revenue rather than as a liability.

As you can tell from the length of this post, a small matter causes me much frustration. You mentioned the possibility of building an invoice generator via which users could tick off features they wanted in their invoices. Is that a near-term possibility? And would it allow small format changes? If not, this is all feeling like things just went too far, effectively spoiling what had been a great solution to special invoicing needs.


#10

I agree with you there two types of users when it comes to invoice customization.

Those who are after subtle changes, I don’t want to expose to HTML. I’m sort of moving that direction already. For example, it’s now possible to show custom field on invoice without using HTML. The next step will be to allow to control where custom field should show etc.

As for your use case, if customer demands an invoice before you actually do the work, you have no choice but to issue them an invoice. But instead of allocating the amount to Other income account, use some liability account such as Prepaid work in progress or something like that. That way money received from this customer will show under liabilities.

When work for this customer is done, don’t create another invoice. Simply make a journal entry to transfer the amount from liability account Prepaid work in progress to an income account.


How to enable PAID IN FULL Option in sales Invoice
#11

Two points:

  1. During the interval between receiving the deposit and issuing the final invoice, I wanted Manager to show that the customer had a credit. So I used a journal entry to transfer the payment from Other income to Customer credits (a liability account). This was equivalent to what you suggest; I just took advantage of what was built-in rather than create a new account.

  2. I had to create a second invoice to bill for the full range of work performed and expenses incurred. This invoice had to cover everything because the invoice sent in order to get the deposit didn’t specify any work having been done. Because the customer did not owe the full amount listed, I needed this invoice to show the amount credited from the deposit. Because I had already transferred the deposit to Customer credits, this happened automatically. So from the accounting standpoint, everything was perfect and simple. The problem was that I had to use the default template to get it all to show. So I lost my special features.

Bottom line: you are very close to a perfect system. I firmly believe you will get there.