frappe / books

Free Accounting Software
https://frappe.io/books
GNU Affero General Public License v3.0
2.68k stars 614 forks source link

feat: detect unconfirmed invoices in invoice templates #749

Open mildred opened 9 months ago

mildred commented 9 months ago

It would be great to have a doc.confirmed boolean field in the invoice templates to know if the invoice is confirmed or not. It would allow to display unconfirmed invoices as such and ensure invoices are always confirmed before sent to the client.

18alantom commented 9 months ago

@mildred perhaps Form Customization would allow you to add the field (without additional functionality).

Else, you can read the doc.submitted field if Submitting the invoice in your workflow counts as confirming it.

mildred commented 9 months ago

doc.submitted would be what I was looking for , except I cannot see when this value would be true. On all my invoices, it is false.

Additional form customization would not work for what I was thinking, the goal is to show clearly on the invoice if it is a final invoice that will never change (submitted invoices cannot be modified) or if it is a draft invoice that is just provisional and should not be treated as an official document.

mildred commented 9 months ago

{{JSON.stringify(doc)}} on version 0.18 (august 22 this year) does not show any submitted field.

mildred commented 8 months ago

the submited field is ignored in the template values because it is a meta field:

https://github.com/frappe/books/blob/e86778f09eec7c44c144300bb424c840bd87ed4f/src/utils/printTemplates.ts#L139-L143

To include it, either we don't skip meta fields or we add it specifically around here:

https://github.com/frappe/books/blob/e86778f09eec7c44c144300bb424c840bd87ed4f/src/utils/printTemplates.ts#L62-L69

mildred commented 8 months ago

something like:

  values.doc.submitted = doc.submitted;
  values.doc.cancelled = doc.cancelled;
18alantom commented 8 months ago

Apologies for pointing you towards doc.submitted, it'd missed me that submitted is a meta field and so is not included as template values (or hints).

It's cause of this printTemplates.ts#L182 for values, and printTemplates.ts#L141 for hints.

Considering your use case, I see no reason to exclude, so if you'd like to raise a PR to make the change I'd be more than happy to merge it.