开发者

Generating invoices with Rails

开发者 https://www.devze.com 2023-04-10 16:23 出处:网络
I have the requirement to create invoices for a number开发者_开发技巧 of customers of an application on a monthly basis.

I have the requirement to create invoices for a number开发者_开发技巧 of customers of an application on a monthly basis.

I have all the transaction data in the database (hopefully all the time).

The question is, is it generally better to generate the invoices once a month with some sort of cron, or to generate the invoice from the stored data when the user requests it, if they request it all?

There's pros and cons to both (for instance, changeable tax rates), but what's the general opinion on the best way to do this?


If it only takes a short amount of time to generate the invoice on demand, then why not do that? If it takes a long time to generate the invoice, as in too long to be acceptable from the perspective of the user simply trying to view one, then pre-generate them.

It's usually better to have something generated on demand so that you don't have to deal with trying to keep your cache up to date when something changes, the logic for which can get very complicated. If it takes a while to render your invoices, you can probably tune the queries better to cut down on rendering time.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号