GithubHelp home page GithubHelp logo

fiscal-hr-python's Introduction

FiscalHr for Python

FiscalHr is Python helper class for fiscalization in Croatia.

Installation

pip install --process-dependency-links FiscalHr

or

pip install https://github.com/vingd/libxml2-python/archive/libxml2-python-2.7.8.zip
pip install FiscalHr

Certificate conversion

Example for openssl: :

umask 0077
openssl pkcs12 -in "FISKAL 1.P12" -out fiskal-1.pem

Example Usage

Send receipt

from fiscalhr.fiscal import Fiscal

fis = Fiscal('fiskal-1.pem', 'fiskal-1.pem', key_passphrase='some secret')

now = fis.localtime_now()

racun = fis.create('Racun')
racun.Oib = '01234567890'
racun.USustPdv = True
racun.DatVrijeme = fis.format_time(now)
racun.OznSlijed = 'P'
racun.BrRac.BrOznRac = 7
racun.BrRac.OznPosPr = 'PP-1'
racun.BrRac.OznNapUr = 'NAP-4'

porez = fis.create('Porez')
porez.Stopa = fis.format_decimal(25)
porez.Osnovica = fis.format_decimal(100)
porez.Iznos = fis.format_decimal(25)

racun.Pdv.Porez.append(porez)

racun.IznosUkupno = fis.format_decimal(125)
racun.NacinPlac = 'K'
racun.OibOper = '01234567890'
racun.NakDost = False

racun.ZastKod = fis.generate_zki(racun)

print racun.ZastKod

response = fis.send('racuni', racun)

print response

Register business premises

Example for registering internet shop, with no pass phrase on SSL key and test mode enabled:

from datetime import datetime
from fiscalhr.fiscal import Fiscal

fis = Fiscal('fiscal-key.pem', 'fiscal-cert.pem', test=True)

pp = fis.create('PoslovniProstor')
pp.Oib = '01234567890'
pp.OznPoslProstora = '1'
pp.RadnoVrijeme = 'non-stop'
pp.DatumPocetkaPrimjene = fis.format_time(datetime(2013, 7, 1), 'Datum')

adresa = fis.create('OstaliTipoviPP')
adresa = "Internet trgovina"

pp.AdresniPodatak.OstaliTipoviPP = adresa

response = fis.send('poslovniProstor', pp, nosend=False)

print response

FiscalHr for Python is Copyright (c) 2013 Vingd, Inc. and licensed under the MIT License.

fiscal-hr-python's People

Contributors

grakic avatar randomir avatar tturkalj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fiscal-hr-python's Issues

suds requirement and installation on osx

changing "suds-philpem>=0.4.3" w/ "suds-jurko>=0.6" in requirements.txt fixes the install issue.

mkvirtualenv -a $PWD fiscalhr
New python executable in /Users/aljosa/.virtualenvs/fiscalhr/bin/python2.7
Also creating executable in /Users/aljosa/.virtualenvs/fiscalhr/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating /Users/aljosa/.virtualenvs/fiscalhr/bin/predeactivate
virtualenvwrapper.user_scripts creating /Users/aljosa/.virtualenvs/fiscalhr/bin/postdeactivate
virtualenvwrapper.user_scripts creating /Users/aljosa/.virtualenvs/fiscalhr/bin/preactivate
virtualenvwrapper.user_scripts creating /Users/aljosa/.virtualenvs/fiscalhr/bin/postactivate
virtualenvwrapper.user_scripts creating /Users/aljosa/.virtualenvs/fiscalhr/bin/get_env_details
Setting project for fiscalhr to /Users/aljosa/Projects/tmp
(fiscalhr)
aljosa@imac - ~/Projects/tmp ⚡  - Wed Aug 10 14:10
tmp ➔  pip install --process-dependency-links FiscalHr
Collecting FiscalHr
  Using cached FiscalHr-0.2.7.tar.gz
  DEPRECATION: Dependency Links processing has been deprecated and will be removed in a future release.
Collecting backports.ssl-match-hostname>=3.2a3 (from FiscalHr)
Collecting libxml2-python>=2.6.21 (from FiscalHr)
Collecting pyOpenSSL>=0.13 (from FiscalHr)
  Using cached pyOpenSSL-16.0.0-py2.py3-none-any.whl
Collecting pytz (from FiscalHr)
  Using cached pytz-2016.6.1-py2.py3-none-any.whl
Collecting pyxmlsec-next>=0.3.1 (from FiscalHr)
Collecting suds-philpem>=0.4.3 (from FiscalHr)
  Using cached suds-philpem-0.4.3.tar.bz2
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/wc/rk_56sxj55qg20lwkqz_z1lw0000gn/T/pip-build-DMp7Fg/suds-philpem/setup.py", line 161, in <module>
        **extra
      File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 111, in setup
        _setup_distribution = dist = klass(attrs)
      File "/Users/aljosa/.virtualenvs/fiscalhr/lib/python2.7/site-packages/setuptools/dist.py", line 348, in __init__
        self.fetch_build_eggs(attrs['setup_requires'])
      File "/Users/aljosa/.virtualenvs/fiscalhr/lib/python2.7/site-packages/setuptools/dist.py", line 394, in fetch_build_eggs
        replace_conflicting=True,
      File "/Users/aljosa/.virtualenvs/fiscalhr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 826, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "/Users/aljosa/.virtualenvs/fiscalhr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1098, in best_match
        return self.obtain(req, installer)
      File "/Users/aljosa/.virtualenvs/fiscalhr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1110, in obtain
        return installer(requirement)
      File "/Users/aljosa/.virtualenvs/fiscalhr/lib/python2.7/site-packages/setuptools/dist.py", line 461, in fetch_build_egg
        return cmd.easy_install(req)
      File "/Users/aljosa/.virtualenvs/fiscalhr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 664, in easy_install
        return self.install_item(spec, dist.location, tmpdir, deps)
      File "/Users/aljosa/.virtualenvs/fiscalhr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 694, in install_item
        dists = self.install_eggs(spec, download, tmpdir)
      File "/Users/aljosa/.virtualenvs/fiscalhr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 875, in install_eggs
        return self.build_and_install(setup_script, setup_base)
      File "/Users/aljosa/.virtualenvs/fiscalhr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1114, in build_and_install
        self.run_setup(setup_script, setup_base, args)
      File "/Users/aljosa/.virtualenvs/fiscalhr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1100, in run_setup
        run_setup(setup_script, args)
      File "/Users/aljosa/.virtualenvs/fiscalhr/lib/python2.7/site-packages/setuptools/sandbox.py", line 249, in run_setup
        raise
      File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 35, in __exit__
        self.gen.throw(type, value, traceback)
      File "/Users/aljosa/.virtualenvs/fiscalhr/lib/python2.7/site-packages/setuptools/sandbox.py", line 197, in setup_context
        yield
      File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 35, in __exit__
        self.gen.throw(type, value, traceback)
      File "/Users/aljosa/.virtualenvs/fiscalhr/lib/python2.7/site-packages/setuptools/sandbox.py", line 168, in save_modules
        saved_exc.resume()
      File "/Users/aljosa/.virtualenvs/fiscalhr/lib/python2.7/site-packages/setuptools/sandbox.py", line 143, in resume
        six.reraise(type, exc, self._tb)
      File "/Users/aljosa/.virtualenvs/fiscalhr/lib/python2.7/site-packages/setuptools/sandbox.py", line 156, in save_modules
        yield saved
      File "/Users/aljosa/.virtualenvs/fiscalhr/lib/python2.7/site-packages/setuptools/sandbox.py", line 197, in setup_context
        yield
      File "/Users/aljosa/.virtualenvs/fiscalhr/lib/python2.7/site-packages/setuptools/sandbox.py", line 246, in run_setup
        DirectorySandbox(setup_dir).run(runner)
      File "/Users/aljosa/.virtualenvs/fiscalhr/lib/python2.7/site-packages/setuptools/sandbox.py", line 276, in run
        return func()
      File "/Users/aljosa/.virtualenvs/fiscalhr/lib/python2.7/site-packages/setuptools/sandbox.py", line 245, in runner
        _execfile(setup_script, ns)
      File "/Users/aljosa/.virtualenvs/fiscalhr/lib/python2.7/site-packages/setuptools/sandbox.py", line 47, in _execfile
        exec(code, globals, locals)
      File "/var/folders/wc/rk_56sxj55qg20lwkqz_z1lw0000gn/T/easy_install-AoxlMO/distribute-0.7.3/setup.py", line 58, in <module>
        #     they are already installed).
      File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
        dist.run_commands()
      File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "setuptools/command/bdist_egg.py", line 177, in run
      File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "setuptools/command/egg_info.py", line 177, in run
      File "pkg_resources.py", line 2241, in load
      File "pkg_resources.py", line 2254, in require
      File "pkg_resources.py", line 2471, in requires
      File "pkg_resources.py", line 2682, in _dep_map
      File "pkg_resources.py", line 2699, in _compute_dependencies
    ImportError: No module named _markerlib

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/wc/rk_56sxj55qg20lwkqz_z1lw0000gn/T/pip-build-DMp7Fg/suds-philpem/

libxml2-python dependancy not found

fiscalhr cannot be installed with pip, it fails with "Could not find any downloads that satisfy the requirement libxml2-python>=2.6.21 (from fiscalhr)"

pip install fiscalhr
Downloading/unpacking fiscalhr
  Downloading FiscalHr-0.2.4.tar.gz
  Running setup.py (path:/srv/www/venv/build/fiscalhr/setup.py) egg_info for package fiscalhr

Downloading/unpacking backports.ssl-match-hostname>=3.2a3 (from fiscalhr)
  Downloading backports.ssl_match_hostname-3.4.0.2.tar.gz
  Running setup.py (path:/srv/www/venv/build/backports.ssl-match-hostname/setup.py) egg_info for package backports.ssl-match-hostname

Downloading/unpacking libxml2-python>=2.6.21 (from fiscalhr)
  Could not find any downloads that satisfy the requirement libxml2-python>=2.6.21 (from fiscalhr)
  Some externally hosted files were ignored (use --allow-external libxml2-python to allow).
Cleaning up...
No distributions at all found for libxml2-python>=2.6.21 (from fiscalhr)
Storing debug log for failure in /home/ivoras/.pip/pip.log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.