Best approach to display product category on invoices

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • novastream
    Member
    • May 2021
    • 61

    Best approach to display product category on invoices

    So I've been porting my invoice and quote themes from FusionInvoice and now for the final touches I want to display the product category on the invoices.

    I will have a column called article, this will be the product category then I will have a column called description where I will use the sales order, invoice, quote name attribute.

    Like this (bold isn't working):

    <!-- {{#each itemList}} -->
    <tr>
    <td style="font-size: 9px;">{{productCategory.name}}</td>
    <td style="width:40%; font-size: 9px;">{{name}}</td>
    <td style="width:10%; text-align: right; font-size: 9px;" nowrap>{{quantity}}</td>
    <td style="width:15%; text-align: right; font-size: 9px;" nowrap>{{unitPrice}}</td>
    <td style="width:15%; text-align: right; font-size: 9px;" nowrap>{{amount}}</td>
    </tr>
    <!-- {{/each}} -->​
  • emillod
    Active Community Member
    • Apr 2017
    • 1405

    #2
    It doesn't work, because InvoiceItem doesn't have information about category of product. You should create relation between Product categories and Invoice Item (or Quote Item) and use formula or hook to fetch id of product category after creation from linked product.

    Comment

    • novastream
      Member
      • May 2021
      • 61

      #3
      Originally posted by emillod
      It doesn't work, because InvoiceItem doesn't have information about category of product. You should create relation between Product categories and Invoice Item (or Quote Item) and use formula or hook to fetch id of product category after creation from linked product.
      Thank you for the tip, so I create a relation between invoice item -->​ product categories and then use formula inside the PDF template?

      Comment

      • emillod
        Active Community Member
        • Apr 2017
        • 1405

        #4
        I've prepared an extension for you which will populate product category
        Here you have link to download package: https://devcrm.it/download/?file=8ea...5-e802178cc528

        Comment

        • novastream
          Member
          • May 2021
          • 61

          #5
          Originally posted by emillod
          I've prepared an extension for you which will populate product category
          Here you have link to download package: https://devcrm.it/download/?file=8ea...5-e802178cc528
          Wow, thanks mate!

          How do I access the placeholders for the product category?

          Comment

          • emillod
            Active Community Member
            • Apr 2017
            • 1405

            #6
            novastream you can use {{productCategoryId}}, you can use also other fields, for example {{productCategory.parentName}} or {{{productCategory.description}}}

            Comment

            • emillod
              Active Community Member
              • Apr 2017
              • 1405

              #7
              Of course you have to use them in each tag like in your initial post to handle many products once

              Comment

              • novastream
                Member
                • May 2021
                • 61

                #8
                Originally posted by emillod
                Of course you have to use them in each tag like in your initial post to handle many products once
                Thanks, but I cant get it to work. I'm working on sales orders at the moment so I've added SalesOrderItem to your plugin, am I doing it wrong?

                Comment

                • emillod
                  Active Community Member
                  • Apr 2017
                  • 1405

                  #9
                  Aaaaah, i forgot about Sales Orders! I'm sorry! Pleasy try with Quotes or Invoices and let me know. In this time i'll add this to extension and test it on my environment

                  Comment

                  • emillod
                    Active Community Member
                    • Apr 2017
                    • 1405

                    #10
                    It's working You can download fixed package from the same url: https://devcrm.it/download/?file=8ea...5-e802178cc528
                    Click image for larger version

Name:	image.png
Views:	195
Size:	25.3 KB
ID:	85383
                    Attached Files

                    Comment

                    • emillod
                      Active Community Member
                      • Apr 2017
                      • 1405

                      #11
                      I use simply tag {{productCategoryName}}

                      Comment

                      • novastream
                        Member
                        • May 2021
                        • 61

                        #12
                        Originally posted by emillod
                        I use simply tag {{productCategoryName}}
                        Thank you for all the help, its working now if you ever come to sweden I will buy you a beer

                        Comment

                        • emillod
                          Active Community Member
                          • Apr 2017
                          • 1405

                          #13
                          novastream Haha, no problem, you're welcome )

                          Comment

                          Working...