silverapp / silver

Automated billing and payments for Django with a REST API
https://www.presslabs.com/code/silver/
Other
300 stars 80 forks source link

Invoice PDFs never generated #674

Closed e-gor closed 4 years ago

e-gor commented 4 years ago

When running the task of "generate_docs", invoices are generated for active subscriptions. But when running the task of "generate_pdfs" (https://github.com/silverapp/silver/blob/6cb501d751a434033dcb9f5bffdbbeeeafab11b8/silver/tasks.py#L45), their PDF documents are never generated...

The code (https://github.com/silverapp/silver/blob/6cb501d751a434033dcb9f5bffdbbeeeafab11b8/silver/tasks.py#L46) looks for invoices or proformas whose "pdf" field (a ForeignKey to a PDF model instance) has in its "dirty" field (https://github.com/silverapp/silver/blob/6cb501d751a434033dcb9f5bffdbbeeeafab11b8/silver/models/documents/pdf.py#L54) a value greater than 0 and generates PDF documents for them.

The problem is that instances of PDF model are never created in the code (or at least I have not found any piece of code that does it), so PDF documents are never generated.

bogdanpetrea commented 4 years ago

Hey @e-gor, The invoices need to be issued first, then an empty PDF object will be automatically created. You can do that manually with code or with an admin action. Or you can set the default_document_state in your Provider object to issued.

Here is where the PDF is created: https://github.com/silverapp/silver/blob/047566804a3373647bb37f1afbf6b18fbda5a5b2/silver/models/documents/base.py#L369

And here is the method that marks a document for PDF generation, if you need it: https://github.com/silverapp/silver/blob/047566804a3373647bb37f1afbf6b18fbda5a5b2/silver/models/documents/base.py#L209

If you have an idea to improve the whole thing, consider sending a pull request.

e-gor commented 4 years ago

OK, thank you. I was unable to find those lines, I think I will manage with that.