Uploaded image for project: 'Blesta Core'
  1. Blesta Core
  2. CORE-923

Add option to cache copy of invoice when generated

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.0
    • Fix Version/s: 5.1.0-b1
    • Component/s: None
    • Labels:
      None

      Description

      Currently invoice copies (PDFs, for example) are generated on the fly. This allows any changes made to the invoice to be reflected when the invoice is next viewed. However, some localities require that the invoice not change at all after being generated.

      To handle these instances, there should be a company setting to save a cached copy of the invoice to disk (Disabled by default). Once saved, all future requests to generate invoices will instead return the cached copy (if the company setting is enabled) if it exists. If a cached copy does not exist, it should be generated and cached to disk. Any future changes to the invoice would not affect the cached copy.

      In the rare event that a cached copy must be updated, there should be a "Recache" checkbox on the edit invoice page that allows the cached copy to be overwritten when saved. This option should only appear if the save cached copies company setting is enabled.

      We may need to also prevent an invoice from being updated once it's cached. Perhaps this would be a second setting? "Do not allow invoices to be modified after they are created.", but we would probably need a way to allow certain people to override this.

      As a sanity check, perhaps we should raise an error if an invoice is attempted to be edited without checking the "recache" option.

      This task should not apply to draft and proforma invoice types.

      UPDATE 12/11/20

      It has been suggested that we store the data only, rather than archiving a physical copy of the PDF which would be larger. We could store the invoices to disk in JSON format only – all of the data, and still generate the invoice PDF's on the fly, but rather than populating the invoice with data from the database, we populate from the invoice's JSON file if it exists. However, some indicate that it's not acceptable for the invoice template/design to change, others expect it to change. So there could be an option to store JSON only, or JSON + PDF.

        Issue Links

          Activity

          cody Cody Phillips (Inactive) created issue -
          admin Paul Phillips made changes -
          Field Original Value New Value
          Fix Version/s 3.3.0 [ 10100 ]
          Fix Version/s 3.2.0 [ 10002 ]
          admin Paul Phillips made changes -
          Security Private [ 10000 ]
          Hide
          admin Paul Phillips added a comment -

          Maybe this should be turned on automatically with proforma invoices, see CORE-497

          Show
          admin Paul Phillips added a comment - Maybe this should be turned on automatically with proforma invoices, see CORE-497
          Hide
          cody Cody Phillips (Inactive) added a comment -

          Considering each PDF is generally around 650KB, I would vote no for enabling automatically.

          Show
          cody Cody Phillips (Inactive) added a comment - Considering each PDF is generally around 650KB, I would vote no for enabling automatically.
          Hide
          admin Paul Phillips added a comment -

          Locations that necessitate proforma invoices usually require that invoices not be changed once generated. If we create these on the fly, addresses and names at minimum may change. If caching these is an issue due to size, perhaps caching all of the data to a json file or similar is preferable, and generating the PDF on the fly from the static data.

          Show
          admin Paul Phillips added a comment - Locations that necessitate proforma invoices usually require that invoices not be changed once generated. If we create these on the fly, addresses and names at minimum may change. If caching these is an issue due to size, perhaps caching all of the data to a json file or similar is preferable, and generating the PDF on the fly from the static data.
          Hide
          cody Cody Phillips (Inactive) added a comment -

          Caching to json file wouldn't work as the data structure the invoice data would be stored in may change at some point, necessitating that all previously cached records be updated to conform to the new expected format in order to be rendered into PDF format.

          There only two options, as far I as can tell:

          1. Cache the PDF document itself (makes the most sense, since this is the only way to prevent the document from being altered. Admin may change the PDF template used, etc., etc.)
          2. Cache all invoice data in the database. This would require storing a snapshot of all invoice related information across all joins. Super complex, as almost everything in the database is related to invoice data (client, contacts, transactions, services, company settings). This method also can't guarantee that a user using a custom invoice template will maintain state correctly (as their custom template might make other joins not anticipated).

          So really, that only leaves option #1.

          Show
          cody Cody Phillips (Inactive) added a comment - Caching to json file wouldn't work as the data structure the invoice data would be stored in may change at some point, necessitating that all previously cached records be updated to conform to the new expected format in order to be rendered into PDF format. There only two options, as far I as can tell: Cache the PDF document itself (makes the most sense, since this is the only way to prevent the document from being altered. Admin may change the PDF template used, etc., etc.) Cache all invoice data in the database. This would require storing a snapshot of all invoice related information across all joins. Super complex, as almost everything in the database is related to invoice data (client, contacts, transactions, services, company settings). This method also can't guarantee that a user using a custom invoice template will maintain state correctly (as their custom template might make other joins not anticipated). So really, that only leaves option #1.
          Hide
          admin Paul Phillips added a comment -

          There might be another option. Contact details are the things that would primarily change. Preventing an invoice from being updated otherwise wouldn't be difficult to do. We store all contact information changes. If we are able to fetch the contact details from the state they were in at the time the invoice was generated, we'll have the correct details.

          Show
          admin Paul Phillips added a comment - There might be another option. Contact details are the things that would primarily change. Preventing an invoice from being updated otherwise wouldn't be difficult to do. We store all contact information changes. If we are able to fetch the contact details from the state they were in at the time the invoice was generated, we'll have the correct details.
          Hide
          cody Cody Phillips (Inactive) added a comment - - edited

          I think it's much more than contact details and invoice line items.

          This also includes:

          • Client number
          • Client settings such as:
            • Tax ID
          • Company settings such as:
            • Terms
            • Company Address
            • Tax ID
            • Background image
            • Logo
            • Display logo/background image option

          And of course lets not forget custom invoice templates which we should also support, which again may perform additional joins on data.

          Show
          cody Cody Phillips (Inactive) added a comment - - edited I think it's much more than contact details and invoice line items. This also includes: Client number Client settings such as: Tax ID Company settings such as: Terms Company Address Tax ID Background image Logo Display logo/background image option And of course lets not forget custom invoice templates which we should also support, which again may perform additional joins on data.
          Hide
          cody Cody Phillips (Inactive) added a comment -

          Maybe we can add the following options as well:

          • Option to delete archived copy after X months
          • Store archived copies on Amazon AWS (tied into backup settings – will need to abstract and denote as "Cloud storage", and allow cloud storage provider extensions)
          Show
          cody Cody Phillips (Inactive) added a comment - Maybe we can add the following options as well: Option to delete archived copy after X months Store archived copies on Amazon AWS (tied into backup settings – will need to abstract and denote as "Cloud storage", and allow cloud storage provider extensions)
          cody Cody Phillips (Inactive) made changes -
          Link This issue relates to CORE-497 [ CORE-497 ]
          cody Cody Phillips (Inactive) made changes -
          Description Currently invoice copies (PDFs, for example) are generated on the fly. This allows any changes made to the invoice to be reflected when the invoice is next viewed. However, some localities require that the invoice not change at all after being generated.

          To handle these instances, there should be a company setting to save a cached copy of the invoice to disk. Once saved, all future requests to generate the invoice will instead return the cached copy (if the company setting is enabled). Any future changes to the invoice would not affect the cached copy.

          In the rare event that a cached copy must be updated, there should be a "Recache" checkbox on the edit invoice page that allows the cached copy to be overwritten when saved. This option should only appear if the save cached copies company setting is enabled.

          As a sanity check, perhaps we should raise an error if an invoice is attempted to be edited without checking the "recache" option.
          Currently invoice copies (PDFs, for example) are generated on the fly. This allows any changes made to the invoice to be reflected when the invoice is next viewed. However, some localities require that the invoice not change at all after being generated.

          To handle these instances, there should be a company setting to save a cached copy of the invoice to disk. Once saved, all future requests to generate the invoice will instead return the cached copy (if the company setting is enabled). Any future changes to the invoice would not affect the cached copy.

          In the rare event that a cached copy must be updated, there should be a "Recache" checkbox on the edit invoice page that allows the cached copy to be overwritten when saved. This option should only appear if the save cached copies company setting is enabled.

          As a sanity check, perhaps we should raise an error if an invoice is attempted to be edited without checking the "recache" option.

          *This task should not apply to draft and proforma invoice types.*
          admin Paul Phillips made changes -
          Fix Version/s 3.4.0 [ 10400 ]
          Fix Version/s 3.3.0 [ 10100 ]
          admin Paul Phillips made changes -
          Fix Version/s 3.5.0 [ 10401 ]
          Fix Version/s 3.4.0-b1 [ 10400 ]
          admin Paul Phillips made changes -
          Fix Version/s 3.5.0-b2 [ 10701 ]
          Fix Version/s 3.5.0-b1 [ 10401 ]
          admin Paul Phillips made changes -
          Fix Version/s 4.0.0 [ 10603 ]
          Fix Version/s 3.5.0-b2 [ 10701 ]
          cody Cody Phillips (Inactive) made changes -
          Fix Version/s 4.0.0 [ 10603 ]
          admin Paul Phillips made changes -
          Fix Version/s Short Term [ 10800 ]
          admin Paul Phillips made changes -
          Assignee Cody Phillips [ cody ]
          admin Paul Phillips made changes -
          Reporter Cody Phillips [ cody ] Paul Phillips [ admin ]
          admin Paul Phillips made changes -
          Description Currently invoice copies (PDFs, for example) are generated on the fly. This allows any changes made to the invoice to be reflected when the invoice is next viewed. However, some localities require that the invoice not change at all after being generated.

          To handle these instances, there should be a company setting to save a cached copy of the invoice to disk. Once saved, all future requests to generate the invoice will instead return the cached copy (if the company setting is enabled). Any future changes to the invoice would not affect the cached copy.

          In the rare event that a cached copy must be updated, there should be a "Recache" checkbox on the edit invoice page that allows the cached copy to be overwritten when saved. This option should only appear if the save cached copies company setting is enabled.

          As a sanity check, perhaps we should raise an error if an invoice is attempted to be edited without checking the "recache" option.

          *This task should not apply to draft and proforma invoice types.*
          Currently invoice copies (PDFs, for example) are generated on the fly. This allows any changes made to the invoice to be reflected when the invoice is next viewed. However, some localities require that the invoice not change at all after being generated.

          To handle these instances, there should be a company setting to save a cached copy of the invoice to disk (Disabled by default). Once saved, all future requests to generate invoices will instead return the cached copy (if the company setting is enabled) if it exists. If a cached copy does not exist, it should be generated and cached to disk. Any future changes to the invoice would not affect the cached copy.

          In the rare event that a cached copy must be updated, there should be a "Recache" checkbox on the edit invoice page that allows the cached copy to be overwritten when saved. This option should only appear if the save cached copies company setting is enabled.

          As a sanity check, perhaps we should raise an error if an invoice is attempted to be edited without checking the "recache" option.

          *This task should not apply to draft and proforma invoice types.*
          admin Paul Phillips made changes -
          Rank Ranked higher
          admin Paul Phillips made changes -
          Rank Ranked lower
          admin Paul Phillips made changes -
          Description Currently invoice copies (PDFs, for example) are generated on the fly. This allows any changes made to the invoice to be reflected when the invoice is next viewed. However, some localities require that the invoice not change at all after being generated.

          To handle these instances, there should be a company setting to save a cached copy of the invoice to disk (Disabled by default). Once saved, all future requests to generate invoices will instead return the cached copy (if the company setting is enabled) if it exists. If a cached copy does not exist, it should be generated and cached to disk. Any future changes to the invoice would not affect the cached copy.

          In the rare event that a cached copy must be updated, there should be a "Recache" checkbox on the edit invoice page that allows the cached copy to be overwritten when saved. This option should only appear if the save cached copies company setting is enabled.

          As a sanity check, perhaps we should raise an error if an invoice is attempted to be edited without checking the "recache" option.

          *This task should not apply to draft and proforma invoice types.*
          Currently invoice copies (PDFs, for example) are generated on the fly. This allows any changes made to the invoice to be reflected when the invoice is next viewed. However, some localities require that the invoice not change at all after being generated.

          To handle these instances, there should be a company setting to save a cached copy of the invoice to disk (Disabled by default). Once saved, all future requests to generate invoices will instead return the cached copy (if the company setting is enabled) if it exists. If a cached copy does not exist, it should be generated and cached to disk. Any future changes to the invoice would not affect the cached copy.

          In the rare event that a cached copy must be updated, there should be a "Recache" checkbox on the edit invoice page that allows the cached copy to be overwritten when saved. This option should only appear if the save cached copies company setting is enabled.

          We may need to also prevent an invoice from being updated once it's cached. Perhaps this would be a second setting? "Do not allow invoices to be modified after they are created.", but we would probably need a way to allow certain people to override this.

          As a sanity check, perhaps we should raise an error if an invoice is attempted to be edited without checking the "recache" option.

          *This task should not apply to draft and proforma invoice types.*
          jonathan Jonathan Reissmueller made changes -
          Rank Ranked higher
          admin Paul Phillips made changes -
          Description Currently invoice copies (PDFs, for example) are generated on the fly. This allows any changes made to the invoice to be reflected when the invoice is next viewed. However, some localities require that the invoice not change at all after being generated.

          To handle these instances, there should be a company setting to save a cached copy of the invoice to disk (Disabled by default). Once saved, all future requests to generate invoices will instead return the cached copy (if the company setting is enabled) if it exists. If a cached copy does not exist, it should be generated and cached to disk. Any future changes to the invoice would not affect the cached copy.

          In the rare event that a cached copy must be updated, there should be a "Recache" checkbox on the edit invoice page that allows the cached copy to be overwritten when saved. This option should only appear if the save cached copies company setting is enabled.

          We may need to also prevent an invoice from being updated once it's cached. Perhaps this would be a second setting? "Do not allow invoices to be modified after they are created.", but we would probably need a way to allow certain people to override this.

          As a sanity check, perhaps we should raise an error if an invoice is attempted to be edited without checking the "recache" option.

          *This task should not apply to draft and proforma invoice types.*
          Currently invoice copies (PDFs, for example) are generated on the fly. This allows any changes made to the invoice to be reflected when the invoice is next viewed. However, some localities require that the invoice not change at all after being generated.

          To handle these instances, there should be a company setting to save a cached copy of the invoice to disk (Disabled by default). Once saved, all future requests to generate invoices will instead return the cached copy (if the company setting is enabled) if it exists. If a cached copy does not exist, it should be generated and cached to disk. Any future changes to the invoice would not affect the cached copy.

          In the rare event that a cached copy must be updated, there should be a "Recache" checkbox on the edit invoice page that allows the cached copy to be overwritten when saved. This option should only appear if the save cached copies company setting is enabled.

          We may need to also prevent an invoice from being updated once it's cached. Perhaps this would be a second setting? "Do not allow invoices to be modified after they are created.", but we would probably need a way to allow certain people to override this.

          As a sanity check, perhaps we should raise an error if an invoice is attempted to be edited without checking the "recache" option.

          *This task should not apply to draft and proforma invoice types.*

          {color:#59afe1}*UPDATE 12/11/20*

          It has been suggested that we store the data only, rather than archiving a physical copy of the PDF which would be larger. We could store the invoices to disk in JSON format only -- all of the data, and still generate the invoice PDF's on the fly, but rather than populating the invoice with data from the database, we populate from the invoice's JSON file if it exists.{color}
          admin Paul Phillips made changes -
          Description Currently invoice copies (PDFs, for example) are generated on the fly. This allows any changes made to the invoice to be reflected when the invoice is next viewed. However, some localities require that the invoice not change at all after being generated.

          To handle these instances, there should be a company setting to save a cached copy of the invoice to disk (Disabled by default). Once saved, all future requests to generate invoices will instead return the cached copy (if the company setting is enabled) if it exists. If a cached copy does not exist, it should be generated and cached to disk. Any future changes to the invoice would not affect the cached copy.

          In the rare event that a cached copy must be updated, there should be a "Recache" checkbox on the edit invoice page that allows the cached copy to be overwritten when saved. This option should only appear if the save cached copies company setting is enabled.

          We may need to also prevent an invoice from being updated once it's cached. Perhaps this would be a second setting? "Do not allow invoices to be modified after they are created.", but we would probably need a way to allow certain people to override this.

          As a sanity check, perhaps we should raise an error if an invoice is attempted to be edited without checking the "recache" option.

          *This task should not apply to draft and proforma invoice types.*

          {color:#59afe1}*UPDATE 12/11/20*

          It has been suggested that we store the data only, rather than archiving a physical copy of the PDF which would be larger. We could store the invoices to disk in JSON format only -- all of the data, and still generate the invoice PDF's on the fly, but rather than populating the invoice with data from the database, we populate from the invoice's JSON file if it exists.{color}
          Currently invoice copies (PDFs, for example) are generated on the fly. This allows any changes made to the invoice to be reflected when the invoice is next viewed. However, some localities require that the invoice not change at all after being generated.

          To handle these instances, there should be a company setting to save a cached copy of the invoice to disk (Disabled by default). Once saved, all future requests to generate invoices will instead return the cached copy (if the company setting is enabled) if it exists. If a cached copy does not exist, it should be generated and cached to disk. Any future changes to the invoice would not affect the cached copy.

          In the rare event that a cached copy must be updated, there should be a "Recache" checkbox on the edit invoice page that allows the cached copy to be overwritten when saved. This option should only appear if the save cached copies company setting is enabled.

          We may need to also prevent an invoice from being updated once it's cached. Perhaps this would be a second setting? "Do not allow invoices to be modified after they are created.", but we would probably need a way to allow certain people to override this.

          As a sanity check, perhaps we should raise an error if an invoice is attempted to be edited without checking the "recache" option.

          *This task should not apply to draft and proforma invoice types.*

          {color:#59afe1}*UPDATE 12/11/20*

          It has been suggested that we store the data only, rather than archiving a physical copy of the PDF which would be larger. We could store the invoices to disk in JSON format only -- all of the data, and still generate the invoice PDF's on the fly, but rather than populating the invoice with data from the database, we populate from the invoice's JSON file if it exists. However, some indicate that it's not acceptable for the invoice template/design to change, others expect it to change. So there could be an option to store JSON only, or JSON + PDF.{color}
          jonathan Jonathan Reissmueller made changes -
          Fix Version/s 5.1.0-b1 [ 11703 ]
          Fix Version/s Short Term [ 10800 ]
          jonathan Jonathan Reissmueller made changes -
          Rank Ranked higher
          jonathan Jonathan Reissmueller made changes -
          Story Points 8
          jonathan Jonathan Reissmueller made changes -
          Rank Ranked higher
          jonathan Jonathan Reissmueller made changes -
          Sprint 5.1.0 Sprint 1 [ 125 ]
          jonathan Jonathan Reissmueller made changes -
          Rank Ranked higher
          abdy Abdy Franco made changes -
          Assignee Abdy Franco [ abdy ]
          abdy Abdy Franco made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          abdy Abdy Franco made changes -
          Remaining Estimate 0 minutes [ 0 ]
          Time Spent 1 hour, 15 minutes [ 4500 ]
          Worklog Id 14675 [ 14675 ]
          abdy Abdy Franco made changes -
          Time Spent 1 hour, 15 minutes [ 4500 ] 1 day, 1 hour, 8 minutes [ 32880 ]
          Worklog Id 14676 [ 14676 ]
          abdy Abdy Franco made changes -
          Time Spent 1 day, 1 hour, 8 minutes [ 32880 ] 2 days, 1 hour, 5 minutes [ 61500 ]
          Worklog Id 14677 [ 14677 ]
          abdy Abdy Franco made changes -
          Time Spent 2 days, 1 hour, 5 minutes [ 61500 ] 3 days, 1 hour, 5 minutes [ 90300 ]
          Worklog Id 14678 [ 14678 ]
          abdy Abdy Franco made changes -
          Time Spent 3 days, 1 hour, 5 minutes [ 90300 ] 3 days, 7 hours, 26 minutes [ 113160 ]
          Worklog Id 14680 [ 14680 ]
          abdy Abdy Franco made changes -
          Status In Progress [ 3 ] In Review [ 5 ]
          Resolution Fixed [ 1 ]
          abdy Abdy Franco made changes -
          Time Spent 3 days, 7 hours, 26 minutes [ 113160 ] 3 days, 7 hours, 50 minutes [ 114600 ]
          Worklog Id 14690 [ 14690 ]
          jonathan Jonathan Reissmueller made changes -
          Sprint 5.0.1 Sprint 1 [ 125 ] 5.1.0 Sprint 1 [ 129 ]
          jonathan Jonathan Reissmueller made changes -
          Rank Ranked lower
          jonathan Jonathan Reissmueller made changes -
          Rank Ranked higher
          abdy Abdy Franco made changes -
          Time Spent 3 days, 7 hours, 50 minutes [ 114600 ] 4 days, 2 minutes [ 115320 ]
          Worklog Id 14719 [ 14719 ]
          abdy Abdy Franco made changes -
          Time Spent 4 days, 2 minutes [ 115320 ] 4 days, 36 minutes [ 117360 ]
          Worklog Id 14722 [ 14722 ]
          abdy Abdy Franco made changes -
          Time Spent 4 days, 36 minutes [ 117360 ] 4 days, 41 minutes [ 117660 ]
          Worklog Id 14732 [ 14732 ]
          jonathan Jonathan Reissmueller made changes -
          Status In Review [ 5 ] Closed [ 6 ]

            People

            • Assignee:
              abdy Abdy Franco
              Reporter:
              admin Paul Phillips
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                8/Jun/21

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 days, 41 minutes
                4d 41m

                  Agile