Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
sr-invoice-parser
Readme
SR Invoice Parser is a small library that is parsing invoices and extracting relevant information. It is designed to work with invoices from the Tax Administration of the Republic of Serbia (Poreska uprava Republike Srbije).
QR code gives a URL to the invoice web page, and this parser extracts the relevant information from the web page, like a crawler.
To install SR Invoice Parser, follow these steps:
pip install sr-invoice-parser
The InvoiceParser
class is the entry point for using the parser.
get_data()
- Extracts all the data from the invoice and returns it as a dictionaryget_company_name()
- Extracts the company name.get_company_tin()
- Extracts the company's tax identification number/PFR.get_total_amount()
- Extracts the total amount of the invoice.get_dt()
- Extracts the date and time of the invoice and converts it to UTC as a datetime object.get_invoice_number()
- Extracts the invoice number.get_invoice_text()
- Extracts the full text of the invoice with QR code base64.get_items()
- Extracts items details from the invoice. This is array of dictionaries with keys: name
, quantity
, price
, total_price
.Here's a basic example of how to use it:
from sr_invoice_parser import InvoiceParser
parser = InvoiceParser(url="https://suf.purs.gov.rs/v/?vl=...")
# or
parser = InvoiceParser(html_text="<HTML source code of invoice web page>")
parser.data()
parser.get_company_name()
parser.get_company_tin()
parser.get_total_amount()
parser.get_dt()
parser.get_invoice_number()
parser.get_invoice_text()
parser.get_items()
{
"company_name": "Company Name",
"company_tin": "123456789",
"invoice_number": "QWERTYU1-QWERTYU1-12345",
"invoice_datetime": datetime.datetime(2021, 1, 1, 0, 0, tzinfo=datetime.timezone.utc),
"invoice_total_amount": 123.45,
"invoice_text": "============ ФИСКАЛНИ РАЧУН ============.....",
"invoice_items": [
{
"name": "Item 1",
"quantity": 1,
"price": 123.45,
"total_price": 123.45
}
]
}
Check the test_parser.py file for more examples.
The module has custom exceptions for handling various error scenarios:
ParserParseException
- Raised when any error occurs during parsing the HTML content.ParserRequestException
- Raised for errors related to fetching HTML content.Thanks to the following packages:
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
If you have any questions, please contact us via email: hello@innovigo.co
This project is licensed under the MIT License.
FAQs
SR Invoice Parser is a small library(crawler) that is parsing invoices and extracting relevant information from URL. For Serbian market.
We found that sr-invoice-parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.