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

Adding missing supported fields to invoice sample #16547

Merged
merged 3 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class RecognizeInvoiceSampleAsync(object):

async def recognize_invoice(self):
path_to_sample_forms = os.path.abspath(os.path.join(os.path.abspath(__file__),
"..", "..", "./sample_forms/forms/Invoice_1.pdf"))
"..", "..", "./sample_forms/forms/sample_invoice.jpg"))

# [START recognize_invoices_async]
from azure.core.credentials import AzureKeyCredential
Expand All @@ -55,9 +55,15 @@ async def recognize_invoice(self):
vendor_address = invoice.fields.get("VendorAddress")
if vendor_address:
print("Vendor Address: {} has confidence: {}".format(vendor_address.value, vendor_address.confidence))
vendor_address_recipient = invoice.fields.get("VendorAddressRecipient")
if vendor_address_recipient:
print("Vendor Address Recipient: {} has confidence: {}".format(vendor_address_recipient.value, vendor_address_recipient.confidence))
customer_name = invoice.fields.get("CustomerName")
if customer_name:
print("Customer Name: {} has confidence: {}".format(customer_name.value, customer_name.confidence))
customer_id = invoice.fields.get("CustomerId")
if customer_id:
print("Customer Id: {} has confidence: {}".format(customer_id.value, customer_id.confidence))
customer_address = invoice.fields.get("CustomerAddress")
if customer_address:
print("Customer Address: {} has confidence: {}".format(customer_address.value, customer_address.confidence))
Expand All @@ -76,6 +82,51 @@ async def recognize_invoice(self):
due_date = invoice.fields.get("DueDate")
if due_date:
print("Due Date: {} has confidence: {}".format(due_date.value, due_date.confidence))
purchase_order = invoice.fields.get("PurchaseOrder")
if purchase_order:
print("Purchase Order: {} has confidence: {}".format(purchase_order.value, purchase_order.confidence))
billing_address = invoice.fields.get("BillingAddress")
if billing_address:
print("Billing Address: {} has confidence: {}".format(billing_address.value, billing_address.confidence))
billing_address_recipient = invoice.fields.get("BillingAddressRecipient")
if billing_address_recipient:
print("Billing Address Recipient: {} has confidence: {}".format(billing_address_recipient.value, billing_address_recipient.confidence))
shipping_address = invoice.fields.get("ShippingAddress")
if shipping_address:
print("Shipping Address: {} has confidence: {}".format(shipping_address.value, shipping_address.confidence))
shipping_address_recipient = invoice.fields.get("ShippingAddressRecipient")
if shipping_address_recipient:
print("Shipping Address Recipient: {} has confidence: {}".format(shipping_address_recipient.value, shipping_address_recipient.confidence))
subtotal = invoice.fields.get("SubTotal")
if subtotal:
print("Subtotal: {} has confidence: {}".format(subtotal.value, subtotal.confidence))
total_tax = invoice.fields.get("TotalTax")
if total_tax:
print("Total Tax: {} has confidence: {}".format(total_tax.value, total_tax.confidence))
previous_unpaid_balance = invoice.fields.get("PreviousUnpaidBalance")
if previous_unpaid_balance:
print("Previous Unpaid Balance: {} has confidence: {}".format(previous_unpaid_balance.value, previous_unpaid_balance.confidence))
amount_due = invoice.fields.get("AmountDue")
if amount_due:
print("Amount Due: {} has confidence: {}".format(amount_due.value, amount_due.confidence))
service_start_date = invoice.fields.get("ServiceStartDate")
if service_start_date:
print("Service Start Date: {} has confidence: {}".format(service_start_date.value, service_start_date.confidence))
service_end_date = invoice.fields.get("ServiceEndDate")
if service_end_date:
print("Service End Date: {} has confidence: {}".format(service_end_date.value, service_end_date.confidence))
service_address = invoice.fields.get("ServiceAddress")
if service_address:
print("Service Address: {} has confidence: {}".format(service_address.value, service_address.confidence))
service_address_recipient = invoice.fields.get("ServiceAddressRecipient")
if service_address_recipient:
print("Service Address Recipient: {} has confidence: {}".format(service_address_recipient.value, service_address_recipient.confidence))
remittance_address = invoice.fields.get("RemittanceAddress")
if remittance_address:
print("Remittance Address: {} has confidence: {}".format(remittance_address.value, remittance_address.confidence))
remittance_address_recipient = invoice.fields.get("RemittanceAddressRecipient")
if remittance_address_recipient:
print("Remittance Address Recipient: {} has confidence: {}".format(remittance_address_recipient.value, remittance_address_recipient.confidence))
# [END recognize_invoices_async]

async def main():
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class RecognizeInvoiceSample(object):

def recognize_invoice(self):
path_to_sample_forms = os.path.abspath(os.path.join(os.path.abspath(__file__),
"..", "./sample_forms/forms/Invoice_1.pdf"))
"..", "./sample_forms/forms/sample_invoice.jpg"))

# [START recognize_invoices]
from azure.core.credentials import AzureKeyCredential
Expand All @@ -54,9 +54,15 @@ def recognize_invoice(self):
vendor_address = invoice.fields.get("VendorAddress")
if vendor_address:
print("Vendor Address: {} has confidence: {}".format(vendor_address.value, vendor_address.confidence))
vendor_address_recipient = invoice.fields.get("VendorAddressRecipient")
if vendor_address_recipient:
print("Vendor Address Recipient: {} has confidence: {}".format(vendor_address_recipient.value, vendor_address_recipient.confidence))
customer_name = invoice.fields.get("CustomerName")
if customer_name:
print("Customer Name: {} has confidence: {}".format(customer_name.value, customer_name.confidence))
customer_id = invoice.fields.get("CustomerId")
if customer_id:
print("Customer Id: {} has confidence: {}".format(customer_id.value, customer_id.confidence))
customer_address = invoice.fields.get("CustomerAddress")
if customer_address:
print("Customer Address: {} has confidence: {}".format(customer_address.value, customer_address.confidence))
Expand All @@ -75,6 +81,51 @@ def recognize_invoice(self):
due_date = invoice.fields.get("DueDate")
if due_date:
print("Due Date: {} has confidence: {}".format(due_date.value, due_date.confidence))
purchase_order = invoice.fields.get("PurchaseOrder")
if purchase_order:
print("Purchase Order: {} has confidence: {}".format(purchase_order.value, purchase_order.confidence))
billing_address = invoice.fields.get("BillingAddress")
if billing_address:
print("Billing Address: {} has confidence: {}".format(billing_address.value, billing_address.confidence))
billing_address_recipient = invoice.fields.get("BillingAddressRecipient")
if billing_address_recipient:
print("Billing Address Recipient: {} has confidence: {}".format(billing_address_recipient.value, billing_address_recipient.confidence))
shipping_address = invoice.fields.get("ShippingAddress")
if shipping_address:
print("Shipping Address: {} has confidence: {}".format(shipping_address.value, shipping_address.confidence))
shipping_address_recipient = invoice.fields.get("ShippingAddressRecipient")
if shipping_address_recipient:
print("Shipping Address Recipient: {} has confidence: {}".format(shipping_address_recipient.value, shipping_address_recipient.confidence))
subtotal = invoice.fields.get("SubTotal")
if subtotal:
print("Subtotal: {} has confidence: {}".format(subtotal.value, subtotal.confidence))
total_tax = invoice.fields.get("TotalTax")
if total_tax:
print("Total Tax: {} has confidence: {}".format(total_tax.value, total_tax.confidence))
previous_unpaid_balance = invoice.fields.get("PreviousUnpaidBalance")
if previous_unpaid_balance:
print("Previous Unpaid Balance: {} has confidence: {}".format(previous_unpaid_balance.value, previous_unpaid_balance.confidence))
amount_due = invoice.fields.get("AmountDue")
if amount_due:
print("Amount Due: {} has confidence: {}".format(amount_due.value, amount_due.confidence))
service_start_date = invoice.fields.get("ServiceStartDate")
if service_start_date:
print("Service Start Date: {} has confidence: {}".format(service_start_date.value, service_start_date.confidence))
service_end_date = invoice.fields.get("ServiceEndDate")
if service_end_date:
print("Service End Date: {} has confidence: {}".format(service_end_date.value, service_end_date.confidence))
service_address = invoice.fields.get("ServiceAddress")
if service_address:
print("Service Address: {} has confidence: {}".format(service_address.value, service_address.confidence))
service_address_recipient = invoice.fields.get("ServiceAddressRecipient")
if service_address_recipient:
print("Service Address Recipient: {} has confidence: {}".format(service_address_recipient.value, service_address_recipient.confidence))
remittance_address = invoice.fields.get("RemittanceAddress")
if remittance_address:
print("Remittance Address: {} has confidence: {}".format(remittance_address.value, remittance_address.confidence))
remittance_address_recipient = invoice.fields.get("RemittanceAddressRecipient")
if remittance_address_recipient:
print("Remittance Address Recipient: {} has confidence: {}".format(remittance_address_recipient.value, remittance_address_recipient.confidence))
# [END recognize_invoices]

if __name__ == '__main__':
Expand Down