Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gisce/bankbarcode
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.1.3
Choose a base ref
...
head repository: gisce/bankbarcode
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Oct 26, 2015

  1. Merge pull request #8 from gisce/bump_to_v0.1.3

    Bump to v0.1.3
    guilleJB committed Oct 26, 2015
    Copy the full SHA
    6f8dbcf View commit details

Commits on May 5, 2016

  1. Add failed test

    guilleJB committed May 5, 2016
    Copy the full SHA
    f3d4824 View commit details
  2. Copy the full SHA
    9167d5e View commit details
  3. Change validation

    guilleJB committed May 5, 2016
    Copy the full SHA
    d273986 View commit details
  4. Merge pull request #9 from gisce/fix_checksum_operation

    Fix checksum operation
    guilleJB committed May 5, 2016
    Copy the full SHA
    647a04e View commit details
  5. Bump to v0.1.4

    guilleJB committed May 5, 2016
    Copy the full SHA
    d627008 View commit details
  6. Merge pull request #10 from gisce/Bump_to_v0.1.4

    Bump to v0.1.4
    guilleJB committed May 5, 2016
    Copy the full SHA
    c0550dc View commit details

Commits on Aug 29, 2016

  1. Add coverage

    ecarreras committed Aug 29, 2016

    Verified

    This commit was signed with the committer’s verified signature.
    ecarreras Eduard Carreras
    Copy the full SHA
    7a4070b View commit details
  2. Merge pull request #11 from gisce/add_coverage

    Add coverage
    ecarreras authored Aug 29, 2016
    Copy the full SHA
    16fdb31 View commit details
  3. Update README.rst

    ecarreras authored Aug 29, 2016
    Copy the full SHA
    b413097 View commit details
  4. Merge pull request #12 from gisce/coverage_badge

    Update README.rst
    ecarreras authored Aug 29, 2016
    Copy the full SHA
    dd3ab7c View commit details

Commits on Dec 9, 2019

  1. Inital support for py3

    ecarreras authored and GISCE Py3 committed Dec 9, 2019
    Copy the full SHA
    19f6542 View commit details

Commits on Jan 18, 2022

  1. Copy the full SHA
    c16e974 View commit details
  2. Add github actions

    polsala committed Jan 18, 2022
    Copy the full SHA
    930e896 View commit details
  3. change req

    polsala committed Jan 18, 2022
    Copy the full SHA
    71008be View commit details
  4. Fix version

    polsala committed Jan 18, 2022
    Copy the full SHA
    703c0ad View commit details
  5. update mamba reqs

    polsala committed Jan 18, 2022
    Copy the full SHA
    f34b994 View commit details
  6. unicode and max ints

    polsala committed Jan 18, 2022
    Copy the full SHA
    22e455c View commit details
  7. Copy the full SHA
    40209cf View commit details
  8. Use decode on file value

    polsala committed Jan 18, 2022
    Copy the full SHA
    a248c56 View commit details

Commits on Feb 23, 2023

  1. Merge pull request #14 from gisce/py3

    Inital support for py3
    ecarreras authored Feb 23, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    844169f View commit details

Commits on Mar 6, 2023

  1. Update ci

    polsala committed Mar 6, 2023
    Copy the full SHA
    63ee34d View commit details
  2. Copy the full SHA
    93c9813 View commit details
  3. Merge pull request #16 from gisce/CI_update

    Update ci
    polsala authored Mar 6, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3a238fe View commit details

Commits on Mar 7, 2024

  1. Bump to v0.3.0

    polsala committed Mar 7, 2024
    Copy the full SHA
    a52c333 View commit details

Commits on Mar 8, 2024

  1. Update python-app.yml

    polsala authored Mar 8, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    e2151bf View commit details
  2. Update python-app.yml

    polsala authored Mar 8, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    fca71e7 View commit details
2 changes: 2 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[bumpversion]
current_version = 0.3.0
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
source = ./bankbarcode
49 changes: 49 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: BANKBARCODE_CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
# You can use PyPy versions in python-version.
# For example, pypy2 and pypy3
fail-fast: false
matrix:
python-version: ["2.7", "3.11"]

steps:
- uses: actions/checkout@v4
- name: Set up Python 3
if: matrix.python-version == '3.11'
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Python 2
if: matrix.python-version == '2.7'
run: |
sudo apt update
sudo apt install python2 python-pip
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2
printf '1\n' | sudo update-alternatives --config python
cd /usr/bin
sudo ln -s /usr/bin/pip2 ./pip
- name: Install dependencies
run: |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
pip install -e .
- name: Run test
run: |
mamba --enable-coverage
40 changes: 40 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release

on:
push:
tags:
- 'v[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+'
- 'v[0-9]+\.[0-9]+\.[0-9]+'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Get tag
id: tag
uses: dawidd6/action-get-tag@v1
with:
strip_v: false
- name: Run setup
run: |
python setup.py sdist
- name: Creating a realease/pre-release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{steps.tag.outputs.tag}}
draft: false
prerelease: ${{ contains(github.ref, '-rc') }}
generate_release_notes: true
- name: Publish a Python distribution to PyPI
if: ${{ contains(github.ref, '-rc') }} == false
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN_GITHUB_BANKBARCODE }}
63 changes: 63 additions & 0 deletions .github/workflows/python-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: GISCE_BANKBARCODE_VERION
on:
push:
branches: [ master ]
jobs:
bump:
runs-on: ubuntu-latest
if: ${{ !startsWith(github.event.head_commit.message, 'Bump to v') }}
steps:
- uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.SSH_PRIVATE }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Setup git
run: |
git config --global user.email "devel@gisce.net"
git config --global user.name "giscegit"
- name: Install python packages
run: |
pip install bump2version
pip install giscemultitools
- name: Get PR info
env:
GITHUB_TOKEN: ${{ secrets.GH_GIT_TOKEN }}
WORKSPACE: ${{github.workspace}}
run: |
echo 'PR_INFO<<EOF' >> $GITHUB_ENV
gisce_github get-commits-sha-from-merge-commit --owner gisce --repository bankbarcode --sha $GITHUB_SHA >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Retrive info
env:
GITHUB_TOKEN: ${{ secrets.GH_GIT_TOKEN }}
run: |
eval `ssh-agent -s`
ssh-add - <<< '${{ secrets.SSH_PRIVATE }}'
pr_labels=$( echo '${{ env.PR_INFO }}' | jq -r '.pullRequest.labels' )
is_minor=false
is_major=false
is_patch=false
for label in echo $( echo $pr_labels | jq -r '.[].name' ); do
if [[ $label == 'minor' ]]; then
is_minor=true
elif [[ $label == 'major' ]]; then
is_major=true
elif [[ $label == 'patch' ]]; then
is_patch=true
fi
done
VERSION_TYPE=false
if [[ $is_major == true ]]; then
VERSION_TYPE="major"
elif [[ $is_minor == true ]]; then
VERSION_TYPE="minor"
elif [[ $is_patch == true ]]; then
VERSION_TYPE="patch"
fi
if [[ $VERSION_TYPE != false ]]; then
bump2version $VERSION_TYPE --tag --commit -m "Bump to v{new_version}" setup.py
git push origin master --tags
fi
8 changes: 0 additions & 8 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -4,6 +4,9 @@ BankBarcode

.. image:: https://travis-ci.org/gisce/bankbarcode.svg?branch=master
:target: https://travis-ci.org/gisce/bankbarcode
.. image:: https://coveralls.io/repos/github/gisce/bankbarcode/badge.svg?branch=master
:target: https://coveralls.io/github/gisce/bankbarcode?branch=master


Python library to generate barcodes for financial documents

2 changes: 1 addition & 1 deletion bankbarcode/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
try:
__version__ = __import__('pkg_resources') \
.get_distribution(__name__).version
except Exception, e:
except Exception as e:
__version__ = 'unknown'
11 changes: 7 additions & 4 deletions bankbarcode/bankbarcode.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from barcode import generate
from StringIO import StringIO
import six
from six.moves import StringIO
from six import BytesIO
from six import string_types


class BankBarcode(object):
@@ -30,7 +33,7 @@ def _check_length(self, name, value, expected_length, description):
return True

def _strip_dotsvg(self, path):
if isinstance(path, basestring) and path[-4:] == '.svg':
if isinstance(path, string_types) and path[-4:] == '.svg':
new_path = path[:-4]
else:
new_path = path
@@ -74,6 +77,6 @@ def svg(self, writer_options=None):
http://pythonhosted.org/pyBarcode/writers/index.html?#common-options
:return: a string with the barcode in SVG format
"""
f = StringIO()
f = BytesIO()
self.save(f, writer_options)
return f.getvalue()
return f.getvalue().decode('utf-8')
24 changes: 14 additions & 10 deletions bankbarcode/cuaderno57.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# coding=utf-8
from __future__ import absolute_import, unicode_literals
from datetime import datetime

from bankbarcode import BankBarcode
from .bankbarcode import BankBarcode
from decimal import Decimal
from six import text_type, string_types


class Recibo(BankBarcode):
@@ -72,7 +74,7 @@ def _check_amount(self, amount):
raise ValueError('{} have more than 2 decimals'.format(name))
if decimal > 99999999.99:
raise ValueError('{} is too big'.format(name))
value = unicode(int(decimal * 100)).zfill(10)
value = text_type(int(decimal * 100)).zfill(10)
expected_length = 10
description = 'amount lenth should be 10'
return self._check_length(name, value, expected_length, description)
@@ -88,7 +90,7 @@ def _check_due_date(self, due_date, suffix):
name = 'due_date'
if due_date is None:
return True
if isinstance(due_date, basestring):
if isinstance(due_date, string_types):
try:
date = datetime.strptime(due_date, '%Y-%m-%d')
except:
@@ -225,7 +227,7 @@ def amount(self, value):
:param value: the amount (Importe)
"""
unicode_value = unicode(value)
unicode_value = text_type(value)
if self._check_amount(unicode_value):
self._amount = unicode_value

@@ -244,7 +246,7 @@ def due_date(self, due_date):
self._due_date = None
else:
if self._check_due_date(due_date, self.suffix):
if isinstance(due_date, basestring):
if isinstance(due_date, string_types):
due_date = datetime.strptime(due_date, '%Y-%m-%d')
self._due_date = due_date
self._notice = self._due_date.strftime('%d%m%y')
@@ -273,19 +275,21 @@ def checksum(self):
+ int(self.notice) \
+ self.amount100()
decimals = int(Decimal(sum) / 97 % 1 * 100)
return unicode(100 - decimals).zfill(2)
if not decimals:
return '00'
return text_type(100 - decimals).zfill(2)

def code(self):
"""
Generate the code for the barcode
:return: an unicode string with the code for the barcode
"""
id_application = u'90'
format_type = u'507'
parity = u'0'
id_application = '90'
format_type = '507'
parity = '0'

amount100 = unicode(self.amount100()).zfill(10)
amount100 = text_type(self.amount100()).zfill(10)

code = (
'{id_application}'
3 changes: 2 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
mamba
mamba<=0.10.0;python_version<="2.7.18"
mamba;python_version>"2.7.18"
expects
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# python-barcode
# We need python-barcode v0.8, to have Code128 (EAN128), not released yet
# https://bitbucket.org/whitie/python-barcode/issues/16/pypi-08-release-request
https://bitbucket.org/whitie/python-barcode/get/6c22b96a2ca2.zip
# https://bitbucket.org/whitie/python-barcode/get/6c22b96a2ca2.zip 0.8.0 fro py2 compat check
python-barcode==0.8.0
9 changes: 3 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -5,20 +5,17 @@

setup(
name='bankbarcode',
version='0.1.3',
version='0.3.0',
packages=find_packages(),
url='https://github.com/gisce/bankbarcode',
license='GNU Affero General Public License v3',
author='GISCE-TI, S.L.',
author_email='devel@gisce.net',
# We need python-barcode v0.8, to have Code128 (EAN128), not released yet
# https://bitbucket.org/whitie/python-barcode/issues/16/pypi-08-release-request
dependency_links=[
"https://bitbucket.org/whitie/python-barcode/get/6c22b96.zip"
"#egg=pybarcode-0.8b1"
],
install_requires=[
'pybarcode>=0.8b1'
'python-barcode==0.8.0',
'six'
],
description='barcodes for financial documents'
)
9 changes: 9 additions & 0 deletions spec/cuaderno57_Recibo507_checksum_spec.py
Original file line number Diff line number Diff line change
@@ -28,3 +28,12 @@
amount = '37.62'
checksum = '56'
expect(Recibo507(entity, suffix, ref, notice, amount).checksum()).to(equal(checksum))

with it('accomplish another example'):
entity = '22350466'
suffix = '501'
ref = '00000085501'
notice = '130516'
amount = '56.92'
checksum = '00'
expect(Recibo507(entity, suffix, ref, notice, amount).checksum()).to(equal(checksum))
6 changes: 3 additions & 3 deletions spec/cuaderno57_Recibo507_due_date_spec.py
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ def callback():
ref = '12345678901'
notice = '123456'
amount = '6543.21'
due_date = datetime(2015, 11, 01)
due_date = datetime(2015, 11, 0o1)
recibo = Recibo507(entity, suffix, ref, notice, amount, due_date)
expect(callback).to(
raise_error(ValueError,
@@ -23,7 +23,7 @@ def callback():
ref = '00000000015'
notice = '300815'
amount = '53.98'
due_date = datetime(2015, 11, 01)
due_date = datetime(2015, 11, 0o1)
recibo = Recibo507(entity, suffix, ref, notice, amount, due_date)
expect(recibo.notice).not_to(equal(notice))
expect(recibo.notice).to(equal(due_date.strftime('%d%m%y')))
@@ -35,7 +35,7 @@ def callback():
notice = '300815'
amount = '53.98'
checksum = '27'
due_date = datetime(2015, 11, 01)
due_date = datetime(2015, 11, 0o1)
recibo = Recibo507(entity, suffix, ref, notice, amount, due_date)
expect(recibo.notice).to(equal(due_date.strftime('%d%m%y')))
expect(recibo.checksum()).to(equal(checksum))
Loading