Package: pnowosie.ifirma-api
Python wrapper forifirma's APIRequiresPython 3.8or later.
This little project aims to refresh my python coding skills.Besides coding fun this code also supported invoicing in a few small online shops. It does its job pretty well.First version was inspired of @DariuszAniszewski'spython-ifirmabut covers slightly different operations and has evolved over the years to support more use cases.Natively supported by this package invoice type is ifirma'sfaktura krajowa.
However is not that hard to create other invoice types using arbitrary request feature.
Which is just to send any ifirma's json request from file template, you can find examples insample_invoicefolder.FeaturesIt supports following operationscreate invoice (VAT & non-VAT payers)listing invoices created in pastsend email with pdf-invoice attached(it sends also copy to the account owner)download invoice in pdf formatallows to authenticate andsend arbitrary json requestinvoice can be described withyaml formatWhen you add more? Are PRs welcomed?Probably never. It's here to support my business.
If you're looking for ideas how to extend it, 👉 see arbitrary requests fromsample_invoicedirectory.
These might be mostly interested if some non-standard ifirma's api operation is required:Arbitrary request of other type of invoiceCheck and change the current accounting monthOther ideas of extension can be find inissue #8discusion.Getting startedFinally ifirma-api got a proper python packaging process :) and newest version can
be installed from PyPI.pip install pnowosie.ifirma-api=={VERSION}or directly from GitHub from this repository, commit's id (SHA) and can be ommitted (defaults to HEAD).pip install -e git+https://github.com/pnowosie/ifirma-api.git@{SHA}#egg=pnowosie.ifirma-apiInvoice creationPlease review examples in./sample_invoicedirectory. You will find there how to create invoice from yaml file.
Send it via email and download pdf version to a location of choice.Or create invoice from codefromifirma.invoiceimport(Invoice,Customer,InvoicePosition,INVOICE_TYPE)invoice=Invoice(invoice_type=INVOICE_TYPE.NON_VAT_PAYER,issue_date=datetime(...)).with_issuer('Imię Nazwisko').with_payed(float(price)).with_comments(f"Nr zamówienia:{numer}").with_position(InvoicePosition(product_name,float(price),flat_rate=float(ryczałt))).with_new_customer(Customer(full_name,email,zip,city,street1,street2))if you registered your customer inifirmayou can useinvoice.with_known_customer(name,tax_id)Having invoice object, we can send it to create an invoice in the ifirma. Please mind that two environment variables
IFIRMA_API_USERNAME and IFIRMA_API_KEY have to be set to authenticate API request.fromifirmaimportapicreate_invoice_response=api.create_invoice(invoice)ifcreate_invoice_response.success:print(f"Invoice created with id{create_invoice_response}")else:print("Something bad has happened: "+create_invoice_response.message)Next step can be send an email with the invoice attached to the customer email address. CC is delivered also to our
address registered in the ifirma.fromifirmaimportapicustom_message="Can you please send me more money? I'm getting ambitious vacation plans!"email_send_response=api.email_invoice(invoice_id,customer_email_address,custom_message)If the pdf copy of the invoice is needed to be stored, we can download it as wellfromifirmaimportapifrompathlibimportPathfile_path=Path('/tmp')/f"invoice_{invoice_id}.pdf"api.download_invoice(invoice_id,file_path)Please checkthis example.Special ThanksDariusz Aniszewski-his projectwas an inspiration,Krystian Magdziarz- who helped and contribute to examples,Dane Hillardfor his amaizing book "Publishing Python Packages" which finally taugh me packaging mastery (or monkey-ry, choose most fitting)