Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect documentation for required_fields option #577

Open
flowrean opened this issue Dec 17, 2024 · 2 comments
Open

Incorrect documentation for required_fields option #577

flowrean opened this issue Dec 17, 2024 · 2 comments

Comments

@flowrean
Copy link

In TUTORIAL.md, required_fields is listed as an option, nested below the options key. I couldn't get this to work so I looked into the code and it seems required_fields should actually be at the same level as options. Is the documentation erroneous or should the code be changed to match what the docs say?

@bosd
Copy link
Collaborator

bosd commented Dec 17, 2024

Which section are you referring to?

It is listed as "optional'.

In the section of simple invoice template there is an example.

issuer: Microsoft Regional Sales Corporation
keywords:
- Microsoft
- M9-0002526-N
exclude_keywords:
- Already\s+paid
- Do not pay
fields:
  amount: GrandTotal(\d+\.\d+)HKD
  date: DocumentDate:(\d{1,2}\/\d{1,2}\/\d{4})
  invoice_number: InvoiceNo.:(\w+)
options:
  remove_whitespace: true
  currency: HKD

Since it is used in templates already. The code does not have to be changed.
The documentation could be clarified.

#576 Includes documentation improvements.

Do you have any suggestions, how it could be improved?

@flowrean
Copy link
Author

flowrean commented Jan 2, 2025

I am referring to the Options section (under Template Structure).

The example you give does not use required_fields, so I don't think it is relevant in this issue. The documentation suggests that the following should be a valid template:

issuer: Microsoft Regional Sales Corporation
keywords:
- Microsoft
- M9-0002526-N
exclude_keywords:
- Already\s+paid
- Do not pay
fields:
  amount: GrandTotal(\d+\.\d+)HKD
  date: DocumentDate:(\d{1,2}\/\d{1,2}\/\d{4})
  invoice_number: InvoiceNo.:(\w+)
options:
  remove_whitespace: true
  currency: HKD
  required_fields:
    - invoice_number

However, I can't get it to work like this. Instead, the correct version seems to be:

issuer: Microsoft Regional Sales Corporation
keywords:
- Microsoft
- M9-0002526-N
exclude_keywords:
- Already\s+paid
- Do not pay
fields:
  amount: GrandTotal(\d+\.\d+)HKD
  date: DocumentDate:(\d{1,2}\/\d{1,2}\/\d{4})
  invoice_number: InvoiceNo.:(\w+)
options:
  remove_whitespace: true
  currency: HKD
required_fields:
  - invoice_number

To reflect this, I think the info about required fields should be in its own section and not under Options. Or at least it should be clarified that it is not be nested under options in the template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants