-
Notifications
You must be signed in to change notification settings - Fork 476
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
Identify Payment Method #141
Comments
can you help, @duskybomb ? |
Hi all, I've added a new option to the template as follows:
It will look for all of the options and return Note that the list is in priority order i.e. will loop through the options in order and only return the first match. If no match is found, 'not_found' is returned as the value. e.g.
The code is as follows and is added to invoice_template.py for k, v in self['fields'].items():
if k.startswith('static_'):
logger.debug("field=%s | static value=%s", k, v)
output[k.replace('static_', '')] = v
# New code for <find_> option starts here
# check if the field name begins with 'find_' and we have a list of options
elif k.startswith('find_') and type(v) is list:
logger.debug("field=%s | find value=%s", k, v)
# Loop through options
for v_option in v:
# Break the options into the name and regex
find_type,find_regex = v_option.split(' ')
logger.debug("find_type=%s | find_regex=%s", find_type, find_regex)
if re.findall(find_regex, optimized_str):
output[k.replace('find_', '')] = find_type
logger.debug("Found=%s", find_type)
find_match = True
break
if not(find_match):
output[k.replace('find_', '')] = 'not_ found'
# New code for <find_> option ends here
else:
logger.debug("field=%s | regexp=%s", k, v) Feel free to add this to the code base if you think it is useful. Cheers, Michael |
Sometimes a bill is split into different payment methods, like half in cash and half through card.
Then there is slight change in
What do you think @m3nu? |
It's already possible to define custom fields. There is no need to hardcode it, like you did. If you do it like this, all your field settings will be in Python code eventually. Field settings need to be in the vendor template only. |
In that case this should work
I don't think we were handling lists properly
|
I think OP is only interested in the name of the payment method. Like "VISA", etc. So the amount doesn't need to be extracted. Can you make a PR and test case for this addition? |
Working on PR, but for test case we would need a sample invoice (preferably in PDF format). |
Merged. It would be interesting to see if Tesseract is good enough to process the invoice posted by OP. |
How i use it for extracting the retailer name ,date,total and the items with price from receipts.i want to preprocess lot of supermarket receipts before giving the tesseract 4.0 . can we use invoicetodata for receipts images only for extracting items and other fields .any suggestion ... |
You can define your own fields and add new templates. The process is roughly:
|
Thanks a lot Manu,
…On Thu 5 Jul, 2018, 6:43 AM Manu, ***@***.***> wrote:
You can define your own fields and add new templates. The process is
roughly:
1. Find the template folder in this repo or locally.
2. Choose a similar template as base and look into the template docs
<https://github.com/invoice-x/invoice2data/blob/master/TUTORIAL.rst>.
3. Make your own new template based on debugging and looking at OCR
output.
4. Add your own template folder to the templates to be loaded.
5. Done.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#141 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AcLe49tDl9j4O6HzpcNduiW-aSq4hPMiks5uDWg3gaJpZM4UfAHy>
.
|
Hi,
I'm looking for a way to identify the payment method used for the invoice or receipt.
This is typically indicated with the words "VISA", "CASH" or "MCARD" in the receipt (see attached)
but I don't think I can simply add a field to the template with REGEX that is searching for these terms as I need to return a standard ENUM for the different payment types.
Can anyone think of a way to do this in REGEX or suggest an approach for adding this to the invoice_template module?
Thanks,
Michael
The text was updated successfully, but these errors were encountered: