ksef-utils


Nameksef-utils JSON
Version 1.4 PyPI version JSON
download
home_pagehttps://github.com/pprzetacznik/ksef-utils
Summary"KSeF Python client for creating invoices"
upload_time2024-10-27 22:19:14
maintainerNone
docs_urlNone
authorPiotr Przetacznik
requires_pythonNone
licenseNone
keywords invoices ksef
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # KSeF utils

[![ksef-utils Release](https://github.com/pprzetacznik/ksef-utils/actions/workflows/release.yml/badge.svg)](https://github.com/pprzetacznik/ksef-utils/actions/workflows/release.yml)
[![ksef-utils Test](https://github.com/pprzetacznik/ksef-utils/actions/workflows/test.yml/badge.svg)](https://github.com/pprzetacznik/ksef-utils/actions/workflows/test.yml)
[![PyPI version](https://badge.fury.io/py/ksef-utils.svg)](https://pypi.org/project/ksef-utils/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ksef-utils)](https://pypi.org/project/ksef-utils/)
[![Documentation Status](https://readthedocs.org/projects/ksef-utils/badge/?version=latest)](https://ksef-utils.readthedocs.io/en/latest/?badge=latest)

This project contains Python utilities and example requests that can be helpful when integrating with Polish central invoicing system called [Krajowy System e-Faktur (KSeF)](https://www.podatki.gov.pl/ksef/).

## Installation

### Creating python virtual environment

See [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/) documentation.

```Bash
$ mkvirtualenv ksef
$ workon ksef
(ksef) $
```

### Installing package from source

```Bash
(ksef) $ git clone https://github.com/pprzetacznik/ksef-utils.git
(ksef) $ cd ksef-utils
(ksef) $ pip install -e .
```

### Installing package from PyPI

```Bash
(ksef) $ pip install ksef-utils
```

## Run tests

### Set up secrets

Log in to https://ksef-test.mf.gov.pl/web/ and generate your individual `KSEF_TOKEN`.

```Bash
#!/bin/bash

export KSEF_TOKEN="..."
export KSEF_ENV="test"
export KSEF_NIP="..."
export KSEF_SIGN_CERT_PATH="cert.pem"
export KSEF_SIGN_KEY_PATH="privkey.pem"
export KSEF_SIGN_CA_PATH="cert.pem"
```

### Generate test cert

```Bash
KSEF_NIP=${KSEF_NIP:-2222222222}
KSEF_SUBJECT="/CN=John Doe/SN=Doe/GN=John/O=My Corp/C=PL/L=Lesser Voivodeship/serialNumber=NIP-${KSEF_NIP}/description=John Doe NIP-${KSEF_NIP}"
openssl req -x509 \
  -nodes \
  -subj "${KSEF_SUBJECT}" \
  -days 365 \
  -newkey rsa \
  -keyout $KSEF_SIGN_KEY_PATH \
  -out $KSEF_SIGN_CERT_PATH
```

### Run pytest framework

```Bash
(ksef) $ pip install -r requirements.txt
(ksef) $ pytest -svvv
```

### Markers

Run all e2e/functional/current tests
```
(ksef) $ pytest -svvv tests/test_ksef.py -m "e2e and not ignore"
(ksef) $ pytest -svvv tests/test_ksef.py -m "functional and not ignore"
(ksef) $ pytest -svvv tests/test_ksef.py -m "current and not ignore"
(ksef) $ ./run_tests.sh
(ksef) $ TESTS_MARKERS="init_signed and functional and not ignore" ./run_tests.sh
```

## Example

See [tests/test_e2e.py](tests/test_e2e.py) for detailed examples of usage.

```Python
from ksef_utils.server import KSEFServer, KSEFService
from ksef_utils.config import TestConfig, DemoConfig, ProdConfig

config = TestConfig()
server = KSEFServer(config)
service = KSEFService(service)

invoice_data = {
    # ...
    # see tests/conftest.py for example json invoice
}

session_token = service.init_signed()
response_send_invoice = service.send_invoice(**invoice_data)
```

## Using cli utilities

```
(ksef) $ python -m ksef_utils keygen --identifier 1111111111 --identifier_type NIP --working_directory .
(ksef) $ pip install .
(ksef) $ which ksef-utils
(...)/.envs/bin/ksef-utils
(ksef) $ ksef-utils keygen --identifier 1111111111 --identifier_type PESEL --working_directory .
```

## OpenAPI

```
/openapi/gtw/svc/api/KSeF-common.yaml
/openapi/gtw/svc/api/KSeF-batch.yaml
/openapi/gtw/svc/api/KSeF-online.yaml
```

## Publish new release

```Bash
$ git tag v1.0
$ git push origin v1.0
```

## Building documentation

```Bash
(ksef) $ sphinx-build -M html docs docs_build
```

## KSEF references

* https://www.podatki.gov.pl/ksef/
* https://ksef-test.mf.gov.pl/web/
* https://www.youtube.com/watch?v=dnBGO6IPtzA

## Contributing

* https://www.conventionalcommits.org/en/v1.0.0/

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pprzetacznik/ksef-utils",
    "name": "ksef-utils",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "invoices, ksef",
    "author": "Piotr Przetacznik",
    "author_email": "\"piotr.przetacznik+ksef@gmail.com\",",
    "download_url": "https://files.pythonhosted.org/packages/f8/d8/025ae474ced2148d157ab767335e1d65d88c6cce10d54143c377cd9d8acd/ksef-utils-1.4.tar.gz",
    "platform": null,
    "description": "# KSeF utils\n\n[![ksef-utils Release](https://github.com/pprzetacznik/ksef-utils/actions/workflows/release.yml/badge.svg)](https://github.com/pprzetacznik/ksef-utils/actions/workflows/release.yml)\n[![ksef-utils Test](https://github.com/pprzetacznik/ksef-utils/actions/workflows/test.yml/badge.svg)](https://github.com/pprzetacznik/ksef-utils/actions/workflows/test.yml)\n[![PyPI version](https://badge.fury.io/py/ksef-utils.svg)](https://pypi.org/project/ksef-utils/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ksef-utils)](https://pypi.org/project/ksef-utils/)\n[![Documentation Status](https://readthedocs.org/projects/ksef-utils/badge/?version=latest)](https://ksef-utils.readthedocs.io/en/latest/?badge=latest)\n\nThis project contains Python utilities and example requests that can be helpful when integrating with Polish central invoicing system called [Krajowy System e-Faktur (KSeF)](https://www.podatki.gov.pl/ksef/).\n\n## Installation\n\n### Creating python virtual environment\n\nSee [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/) documentation.\n\n```Bash\n$ mkvirtualenv ksef\n$ workon ksef\n(ksef) $\n```\n\n### Installing package from source\n\n```Bash\n(ksef) $ git clone https://github.com/pprzetacznik/ksef-utils.git\n(ksef) $ cd ksef-utils\n(ksef) $ pip install -e .\n```\n\n### Installing package from PyPI\n\n```Bash\n(ksef) $ pip install ksef-utils\n```\n\n## Run tests\n\n### Set up secrets\n\nLog in to https://ksef-test.mf.gov.pl/web/ and generate your individual `KSEF_TOKEN`.\n\n```Bash\n#!/bin/bash\n\nexport KSEF_TOKEN=\"...\"\nexport KSEF_ENV=\"test\"\nexport KSEF_NIP=\"...\"\nexport KSEF_SIGN_CERT_PATH=\"cert.pem\"\nexport KSEF_SIGN_KEY_PATH=\"privkey.pem\"\nexport KSEF_SIGN_CA_PATH=\"cert.pem\"\n```\n\n### Generate test cert\n\n```Bash\nKSEF_NIP=${KSEF_NIP:-2222222222}\nKSEF_SUBJECT=\"/CN=John Doe/SN=Doe/GN=John/O=My Corp/C=PL/L=Lesser Voivodeship/serialNumber=NIP-${KSEF_NIP}/description=John Doe NIP-${KSEF_NIP}\"\nopenssl req -x509 \\\n  -nodes \\\n  -subj \"${KSEF_SUBJECT}\" \\\n  -days 365 \\\n  -newkey rsa \\\n  -keyout $KSEF_SIGN_KEY_PATH \\\n  -out $KSEF_SIGN_CERT_PATH\n```\n\n### Run pytest framework\n\n```Bash\n(ksef) $ pip install -r requirements.txt\n(ksef) $ pytest -svvv\n```\n\n### Markers\n\nRun all e2e/functional/current tests\n```\n(ksef) $ pytest -svvv tests/test_ksef.py -m \"e2e and not ignore\"\n(ksef) $ pytest -svvv tests/test_ksef.py -m \"functional and not ignore\"\n(ksef) $ pytest -svvv tests/test_ksef.py -m \"current and not ignore\"\n(ksef) $ ./run_tests.sh\n(ksef) $ TESTS_MARKERS=\"init_signed and functional and not ignore\" ./run_tests.sh\n```\n\n## Example\n\nSee [tests/test_e2e.py](tests/test_e2e.py) for detailed examples of usage.\n\n```Python\nfrom ksef_utils.server import KSEFServer, KSEFService\nfrom ksef_utils.config import TestConfig, DemoConfig, ProdConfig\n\nconfig = TestConfig()\nserver = KSEFServer(config)\nservice = KSEFService(service)\n\ninvoice_data = {\n    # ...\n    # see tests/conftest.py for example json invoice\n}\n\nsession_token = service.init_signed()\nresponse_send_invoice = service.send_invoice(**invoice_data)\n```\n\n## Using cli utilities\n\n```\n(ksef) $ python -m ksef_utils keygen --identifier 1111111111 --identifier_type NIP --working_directory .\n(ksef) $ pip install .\n(ksef) $ which ksef-utils\n(...)/.envs/bin/ksef-utils\n(ksef) $ ksef-utils keygen --identifier 1111111111 --identifier_type PESEL --working_directory .\n```\n\n## OpenAPI\n\n```\n/openapi/gtw/svc/api/KSeF-common.yaml\n/openapi/gtw/svc/api/KSeF-batch.yaml\n/openapi/gtw/svc/api/KSeF-online.yaml\n```\n\n## Publish new release\n\n```Bash\n$ git tag v1.0\n$ git push origin v1.0\n```\n\n## Building documentation\n\n```Bash\n(ksef) $ sphinx-build -M html docs docs_build\n```\n\n## KSEF references\n\n* https://www.podatki.gov.pl/ksef/\n* https://ksef-test.mf.gov.pl/web/\n* https://www.youtube.com/watch?v=dnBGO6IPtzA\n\n## Contributing\n\n* https://www.conventionalcommits.org/en/v1.0.0/\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "\"KSeF Python client for creating invoices\"",
    "version": "1.4",
    "project_urls": {
        "Homepage": "https://github.com/pprzetacznik/ksef-utils"
    },
    "split_keywords": [
        "invoices",
        " ksef"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6c1b41ddbd03ec74a21c30695c1afb7031b6be6365e3e47e9cf2fc304f2ab302",
                "md5": "186ea2d09c566c57a70f9df0530276a2",
                "sha256": "68eebfb9ad2b729be6f000a9143939a48abf21d9a70771c963c518861e907a86"
            },
            "downloads": -1,
            "filename": "ksef_utils-1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "186ea2d09c566c57a70f9df0530276a2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 13606,
            "upload_time": "2024-10-27T22:19:13",
            "upload_time_iso_8601": "2024-10-27T22:19:13.548135Z",
            "url": "https://files.pythonhosted.org/packages/6c/1b/41ddbd03ec74a21c30695c1afb7031b6be6365e3e47e9cf2fc304f2ab302/ksef_utils-1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f8d8025ae474ced2148d157ab767335e1d65d88c6cce10d54143c377cd9d8acd",
                "md5": "a6e7bee8d1ffab14b9c505b503268adb",
                "sha256": "adb18a4588aedfa47e30e4ed02c275838bf6e12316b66ef4fc80ef843fb8514d"
            },
            "downloads": -1,
            "filename": "ksef-utils-1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "a6e7bee8d1ffab14b9c505b503268adb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 29514,
            "upload_time": "2024-10-27T22:19:14",
            "upload_time_iso_8601": "2024-10-27T22:19:14.581275Z",
            "url": "https://files.pythonhosted.org/packages/f8/d8/025ae474ced2148d157ab767335e1d65d88c6cce10d54143c377cd9d8acd/ksef-utils-1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-27 22:19:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pprzetacznik",
    "github_project": "ksef-utils",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "ksef-utils"
}
        
Elapsed time: 0.34580s