Update tests. Update setup file

This commit is contained in:
Luciano Rossi 2020-06-03 14:32:26 -03:00
parent d93c04db76
commit 67b0ed62b7
14 changed files with 514 additions and 83 deletions

30
INSTALL
View File

@ -1,30 +0,0 @@
Installing trytond_account_retencion_ar
=======================================
Prerequisites
-------------
* Python 3.4 or later (http://www.python.org/)
* trytond (http://www.tryton.org/)
* account_voucher_ar (https://bitbucket.org/thymbra/account_voucher_ar)
Installation
------------
Once you've downloaded and unpacked the trytond_account_retencion_ar source
release, enter the directory where the archive was unpacked, and run:
python setup.py install
Note that you may need administrator/root privileges for this step, as
this command will by default attempt to install module to the Python
site-packages directory on your system.
For advanced options, please refer to the easy_install and/or the distutils
documentation:
http://peak.telecommunity.com/DevCenter/EasyInstall
http://docs.python.org/inst/inst.html
To use without installation, extract the archive into ``trytond/modules`` with
the directory name account_retencion_ar.

View File

@ -1,11 +1,5 @@
include INSTALL
include README
include TODO
include COPYRIGHT
include CHANGELOG
include COPYRIGHT
include LICENSE
include tryton.cfg
include *.xml
include view/*.xml
include *.odt
include locale/*.po
include README.rst
include doc/*

1
README.rst Symbolic link
View File

@ -0,0 +1 @@
doc/index.rst

0
TODO
View File

View File

@ -6,6 +6,8 @@ from trytond.pool import Pool
from . import account_retencion_ar
from . import account_voucher_ar
__all__ = ['register']
def register():
Pool.register(

45
doc/index.rst Normal file
View File

@ -0,0 +1,45 @@
trytonar_account_retencion_ar
=============================
The account_retencion_ar module of the Tryton application platform.
Installing
----------
See INSTALL
Support
-------
If you encounter any problems with this module, please don't hesitate to ask
questions on the module bug tracker:
https://github.com/tryton-ar/account_retencion_ar/issues
For more information please contact the programmers at tryton-ar
website: https://groups.google.com/forum/#!forum/tryton-ar
If you encounter any problems with Tryton, please don't hesitate to ask
questions on the Tryton bug tracker, mailing list, wiki or IRC channel:
http://bugs.tryton.org/
http://groups.tryton.org/
http://wiki.tryton.org/
irc://irc.freenode.net/tryton
irc://irc.freenode.net/tryton-es
License
-------
See LICENSE
Copyright
---------
See COPYRIGHT
For more information please visit the Tryton web site:
http://www.tryton.org/

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python3
# This file is part of the account_retencion_ar module for Tryton.
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
@ -7,24 +6,30 @@ import io
import os
import re
from configparser import ConfigParser
from setuptools import setup
from setuptools import setup, find_packages
def read(fname):
return io.open(
def read(fname, slice=None):
content = io.open(
os.path.join(os.path.dirname(__file__), fname),
'r', encoding='utf-8').read()
if slice:
content = '\n'.join(content.splitlines()[slice])
return content
def get_require_version(name):
require = '%s >= %s.%s, < %s.%s'
if minor_version % 2:
require = '%s >= %s.%s.dev0, < %s.%s'
else:
require = '%s >= %s.%s, < %s.%s'
require %= (name, major_version, minor_version,
major_version, minor_version + 1)
return require
config = ConfigParser()
config.read_file(open('tryton.cfg'))
config.read_file(open(os.path.join(os.path.dirname(__file__), 'tryton.cfg')))
info = dict(config.items('tryton'))
for key in ('depends', 'extras_depend', 'xml'):
if key in info:
@ -37,63 +42,105 @@ name = 'trytonar_account_retencion_ar'
download_url = 'https://github.com/tryton-ar/account_retencion_ar/tree/%s.%s' % (
major_version, minor_version)
if minor_version % 2:
version = '%s.%s.dev0' % (major_version, minor_version)
download_url = (
'git+http://github.com/tryton-ar/%s#egg=%s-%s' % (
name.replace('trytonar','trytond'), name, version))
local_version = []
for build in ['CI_BUILD_NUMBER', 'CI_JOB_NUMBER', 'CI_JOB_ID']:
if os.environ.get(build):
local_version.append(os.environ[build])
if local_version:
version += '+' + '.'.join(local_version)
requires = []
for dep in info.get('depends', []):
if dep == 'account_check_ar':
requires.append(get_require_version('trytonar_%s' % dep))
if dep == 'account_voucher_ar':
requires.append('trytonar_account_voucher_ar @ git+https://github.com/tryton-ar/account_voucher_ar.git@%s.%s#egg=trytonar_account_voucher_ar-%s.%s' % (major_version, minor_version, major_version, minor_version))
elif not re.match(r'(ir|res)(\W|$)', dep):
requires.append(get_require_version('trytond_%s' % dep))
requires.append(get_require_version('trytond'))
requires.append('trytonar_party_ar @ git+https://github.com/tryton-ar/party_ar.git@%s.%s#egg=trytonar_party_ar-%s.%s' % (major_version, minor_version, major_version, minor_version))
requires.append('pyafipws @ git+https://github.com/reingart/pyafipws.git@py3k#egg=pyafipws-py3k')
requires.append('pysimplesoap @ git+https://github.com/pysimplesoap/pysimplesoap.git@stable_py3k#egg=pysimplesoap-stable_py3k')
tests_require = [get_require_version('proteus')]
dependency_links = []
setup(name=name,
version=version,
description='Tryton module with accounting withholding for Argentina',
long_description=read('README'),
author='tryton-ar',
url='https://github.com/tryton-ar/account_retencion_ar',
description='',
long_description=read('README.rst'),
author='trytonar',
author_email='bugs@tryton.org.ar',
url='http://github.com/tryton-ar/account_retencion_ar',
download_url=download_url,
project_urls={
"Bug Tracker": 'https://bugs.tryton.org/',
"Documentation": 'https://docs.tryton.org/',
"Forum": 'https://www.tryton.org/forum',
"Source Code": 'https://github.com/tryton-ar/account_retencion_ar',
},
keywords='tryton, account, retencion',
package_dir={'trytond.modules.account_retencion_ar': '.'},
packages=[
'trytond.modules.account_retencion_ar',
'trytond.modules.account_retencion_ar.tests',
],
packages=(
['trytond.modules.account_retencion_ar']
+ ['trytond.modules.account_retencion_ar.%s' % p
for p in find_packages()]
),
package_data={
'trytond.modules.account_retencion_ar': (info.get('xml', [])
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po']),
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po', '*.fodt',
'icons/*.svg', 'tests/*.rst']),
},
classifiers=[
'Development Status :: 4 - Beta',
'Development Status :: 5 - Production/Stable',
'Environment :: Plugins',
'Framework :: Tryton',
'Intended Audience :: Developers',
'Intended Audience :: Financial and Insurance Industry',
'Intended Audience :: Legal Industry',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'License :: OSI Approved :: '
'GNU General Public License v3 or later (GPLv3+)',
'Natural Language :: Bulgarian',
'Natural Language :: Catalan',
'Natural Language :: Chinese (Simplified)',
'Natural Language :: Czech',
'Natural Language :: Dutch',
'Natural Language :: English',
'Natural Language :: Finnish',
'Natural Language :: French',
'Natural Language :: German',
'Natural Language :: Hungarian',
'Natural Language :: Indonesian',
'Natural Language :: Italian',
'Natural Language :: Persian',
'Natural Language :: Polish',
'Natural Language :: Portuguese (Brazilian)',
'Natural Language :: Russian',
'Natural Language :: Slovenian',
'Natural Language :: Spanish',
'Natural Language :: Turkish',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Office/Business',
'Topic :: Office/Business :: Financial :: Accounting',
],
license='GPL-3',
python_requires='>=3.4',
python_requires='>=3.5',
install_requires=requires,
dependency_links=dependency_links,
zip_safe=False,
entry_points="""
[trytond.modules]
account_retencion_ar = trytond.modules.account_retencion_ar
""",
""", # noqa: E501
test_suite='tests',
test_loader='trytond.test_loader:Loader',
tests_require=tests_require,

View File

@ -2,8 +2,8 @@
# this repository contains the full copyright notices and license terms.
try:
from trytond.modules.account_retencion_ar.tests.tests import suite
from trytond.modules.account_retencion_ar.tests.test_account_retencion_ar import suite
except ImportError:
from .tests import suite
from .test_account_retencion_ar import suite
__all__ = ['suite']

View File

@ -0,0 +1,328 @@
==========================
Account Retencion Scenario
==========================
Imports::
>>> import datetime
>>> from dateutil.relativedelta import relativedelta
>>> from decimal import Decimal
>>> from operator import attrgetter
>>> from proteus import Model, Wizard
>>> from trytond.tests.tools import activate_modules
>>> from trytond.modules.company.tests.tools import create_company, \
... get_company
>>> from trytond.modules.account.tests.tools import create_fiscalyear, \
... create_chart, get_accounts, create_tax, create_tax_code
>>> from trytond.modules.account_invoice.tests.tools import \
... set_fiscalyear_invoice_sequences
>>> from trytond.modules.account_voucher_ar.tests.tools import \
... set_fiscalyear_voucher_sequences
>>> from trytond.modules.account_retencion_ar.tests.tools import \
... create_retencion_sequence
>>> today = datetime.date.today()
Install account_invoice::
>>> config = activate_modules('account_retencion_ar')
Create company::
>>> _ = create_company()
>>> company = get_company()
>>> tax_identifier = company.party.identifiers.new()
>>> tax_identifier.type = 'eu_vat'
>>> tax_identifier.code = 'BE0897290877'
>>> company.party.save()
Create fiscal year::
>>> fiscalyear = set_fiscalyear_voucher_sequences(
... set_fiscalyear_invoice_sequences(
... create_fiscalyear(company)))
>>> fiscalyear.click('create_period')
>>> period = fiscalyear.periods[0]
>>> period_ids = [p.id for p in fiscalyear.periods]
Create chart of accounts::
>>> _ = create_chart(company)
>>> accounts = get_accounts(company)
>>> receivable = accounts['receivable']
>>> revenue = accounts['revenue']
>>> expense = accounts['expense']
>>> account_tax = accounts['tax']
>>> account_cash = accounts['cash']
Create tax::
>>> TaxCode = Model.get('account.tax.code')
>>> tax = create_tax(Decimal('.10'))
>>> tax.save()
>>> invoice_base_code = create_tax_code(tax, 'base', 'invoice')
>>> invoice_base_code.save()
>>> invoice_tax_code = create_tax_code(tax, 'tax', 'invoice')
>>> invoice_tax_code.save()
>>> credit_note_base_code = create_tax_code(tax, 'base', 'credit')
>>> credit_note_base_code.save()
>>> credit_note_tax_code = create_tax_code(tax, 'tax', 'credit')
>>> credit_note_tax_code.save()
Create payment method voucher_ar::
>>> AccountVoucherPayMode = Model.get('account.voucher.paymode')
>>> paymode = AccountVoucherPayMode()
>>> paymode.name = 'Cash'
>>> paymode.account = account_cash
>>> paymode.save()
Create payment method::
>>> Journal = Model.get('account.journal')
>>> PaymentMethod = Model.get('account.invoice.payment.method')
>>> journal_cash, = Journal.find([('type', '=', 'cash')])
>>> payment_method = PaymentMethod()
>>> payment_method.name = 'Cash'
>>> payment_method.journal = journal_cash
>>> payment_method.credit_account = account_cash
>>> payment_method.debit_account = account_cash
>>> payment_method.save()
Create Write Off method::
>>> WriteOff = Model.get('account.move.reconcile.write_off')
>>> Sequence = Model.get('ir.sequence')
>>> sequence_journal, = Sequence.find([('code', '=', 'account.journal')])
>>> journal_writeoff = Journal(name='Write-Off', type='write-off',
... sequence=sequence_journal)
>>> journal_writeoff.save()
>>> writeoff_method = WriteOff()
>>> writeoff_method.name = 'Rate loss'
>>> writeoff_method.journal = journal_writeoff
>>> writeoff_method.credit_account = expense
>>> writeoff_method.debit_account = expense
>>> writeoff_method.save()
Create party::
>>> Party = Model.get('party.party')
>>> party = Party(name='Party')
>>> party.iva_condition = 'consumidor_final'
>>> party.save()
Create account category::
>>> ProductCategory = Model.get('product.category')
>>> account_category = ProductCategory(name="Account Category")
>>> account_category.accounting = True
>>> account_category.account_expense = expense
>>> account_category.account_revenue = revenue
>>> account_category.customer_taxes.append(tax)
>>> account_category.save()
Create product::
>>> ProductUom = Model.get('product.uom')
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> ProductTemplate = Model.get('product.template')
>>> template = ProductTemplate()
>>> template.name = 'product'
>>> template.default_uom = unit
>>> template.type = 'service'
>>> template.list_price = Decimal('40')
>>> template.account_category = account_category
>>> template.save()
>>> product, = template.products
Create payment term::
>>> PaymentTerm = Model.get('account.invoice.payment_term')
>>> payment_term = PaymentTerm(name='Term')
>>> line = payment_term.lines.new(type='percent', ratio=Decimal('.5'))
>>> delta, = line.relativedeltas
>>> delta.days = 20
>>> line = payment_term.lines.new(type='remainder')
>>> delta = line.relativedeltas.new(days=40)
>>> payment_term.save()
Create Retenciones::
>>> Retencion = Model.get('account.retencion')
>>> retencion_soportada = Retencion(name='Retencion soportada')
>>> retencion_soportada.account = account_tax
>>> retencion_soportada.type = 'soportada'
>>> retencion_soportada.save()
>>> retencion_efectuada = Retencion(name='Retencion efectuada')
>>> retencion_efectuada.account = account_tax
>>> retencion_efectuada.type = 'efectuada'
>>> retencion_efectuada.sequence = create_retencion_sequence()
>>> retencion_efectuada.save()
Create invoice::
>>> Invoice = Model.get('account.invoice')
>>> InvoiceLine = Model.get('account.invoice.line')
>>> invoice = Invoice()
>>> invoice.party = party
>>> invoice.payment_term = None
>>> line = InvoiceLine()
>>> invoice.lines.append(line)
>>> line.product = product
>>> line.quantity = 5
>>> line.unit_price = Decimal('40')
>>> line = InvoiceLine()
>>> invoice.lines.append(line)
>>> line.account = revenue
>>> line.description = 'Test'
>>> line.quantity = 1
>>> line.unit_price = Decimal(20)
>>> invoice.untaxed_amount
Decimal('220.00')
>>> invoice.tax_amount
Decimal('20.00')
>>> invoice.total_amount
Decimal('240.00')
>>> invoice.save()
Post invoice::
>>> invoice.click('post')
>>> invoice.state
'posted'
>>> invoice.tax_identifier.code
'BE0897290877'
>>> invoice.untaxed_amount
Decimal('220.00')
>>> invoice.tax_amount
Decimal('20.00')
>>> invoice.total_amount
Decimal('240.00')
Pay invoice::
>>> AccountVoucher = Model.get('account.voucher')
>>> LinePaymode = Model.get('account.voucher.line.paymode')
>>> RetencionSoportada = Model.get('account.retencion.soportada')
>>> voucher = AccountVoucher()
>>> voucher.party = invoice.party
>>> voucher.date = today
>>> voucher.voucher_type = 'receipt'
>>> voucher.journal = journal_cash
>>> voucher.currency = invoice.currency
>>> #payment_line = voucher.lines[0]
>>> #payment_line.amount = payment_line.amount_unreconciled
>>> #payment_line = voucher.lines[1]
>>> #payment_line.amount = payment_line.amount_unreconciled
>>> payment_line, = voucher.lines
>>> payment_line.amount = payment_line.amount_unreconciled
>>> pay_line = LinePaymode()
>>> voucher.pay_lines.append(pay_line)
>>> pay_line.pay_mode = paymode
>>> pay_line.pay_amount = Decimal('200')
>>> retencion_line = RetencionSoportada()
>>> voucher.retenciones_soportadas.append(retencion_line)
>>> retencion_line.name = '1111'
>>> retencion_line.amount = Decimal('40')
>>> retencion_line.tax = retencion_soportada
>>> retencion_line.party = invoice.party
>>> voucher.save()
>>> voucher.click('post')
>>> voucher.state
'posted'
>>> bool(voucher.move)
True
>>> invoice.reload()
>>> invoice.state
'paid'
>>> len(invoice.payment_lines)
1
Create supplier invoice::
>>> Invoice = Model.get('account.invoice')
>>> InvoiceLine = Model.get('account.invoice.line')
>>> invoice = Invoice()
>>> invoice.party = party
>>> invoice.type = 'in'
>>> invoice.payment_term = None
>>> invoice.invoice_date = today
>>> line = InvoiceLine()
>>> invoice.lines.append(line)
>>> line.product = product
>>> line.quantity = 5
>>> line.unit_price = Decimal('40')
>>> line = InvoiceLine()
>>> invoice.lines.append(line)
>>> line.account = expense
>>> line.description = 'Test'
>>> line.quantity = 1
>>> line.unit_price = Decimal(20)
>>> invoice.untaxed_amount
Decimal('220.00')
>>> invoice.total_amount
Decimal('220.00')
>>> invoice.save()
>>> invoice.state
'draft'
>>> bool(invoice.move)
False
>>> invoice.click('validate_invoice')
>>> invoice.state
'validated'
>>> bool(invoice.move)
True
Post invoice::
>>> invoice.click('post')
>>> invoice.state
'posted'
>>> bool(invoice.move)
True
>>> invoice.move.state
'posted'
>>> invoice.tax_identifier.code
'BE0897290877'
>>> invoice.untaxed_amount
Decimal('220.00')
>>> invoice.total_amount
Decimal('220.00')
Pay invoice::
>>> AccountVoucher = Model.get('account.voucher')
>>> LinePaymode = Model.get('account.voucher.line.paymode')
>>> RetencionEfectuada = Model.get('account.retencion.efectuada')
>>> voucher = AccountVoucher()
>>> voucher.party = invoice.party
>>> voucher.date = today
>>> voucher.voucher_type = 'payment'
>>> voucher.journal = journal_cash
>>> voucher.currency = invoice.currency
>>> #payment_line = voucher.lines[0]
>>> #payment_line.amount = payment_line.amount_unreconciled
>>> #payment_line = voucher.lines[1]
>>> #payment_line.amount = payment_line.amount_unreconciled
>>> payment_line, = voucher.lines
>>> payment_line.amount = payment_line.amount_unreconciled
>>> pay_line = LinePaymode()
>>> voucher.pay_lines.append(pay_line)
>>> pay_line.pay_mode = paymode
>>> pay_line.pay_amount = Decimal('200')
>>> retencion_line = RetencionEfectuada()
>>> voucher.retenciones_efectuadas.append(retencion_line)
>>> retencion_line.name = '1111'
>>> retencion_line.amount = Decimal('20')
>>> retencion_line.tax = retencion_efectuada
>>> retencion_line.party = invoice.party
>>> voucher.save()
>>> voucher.click('post')
>>> voucher.state
'posted'
>>> bool(voucher.move)
True
>>> invoice.reload()
>>> invoice.state
'paid'
>>> len(invoice.payment_lines)
1

View File

@ -0,0 +1,28 @@
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
import unittest
import doctest
from trytond.tests.test_tryton import ModuleTestCase
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase
from trytond.tests.test_tryton import doctest_teardown
from trytond.tests.test_tryton import doctest_checker
class AccountRetencionArTestCase(ModuleTestCase):
'AccountRetencionAr Test module'
module = 'account_retencion_ar'
def suite():
suite = trytond.tests.test_tryton.suite()
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
AccountRetencionArTestCase))
suite.addTests(doctest.DocFileSuite(
'scenario_account_retencion_ar.rst',
tearDown=doctest_teardown, encoding='utf-8',
checker=doctest_checker,
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
return suite

View File

@ -1,18 +0,0 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import unittest
from trytond.tests.test_tryton import ModuleTestCase
from trytond.tests.test_tryton import suite as test_suite
class TestCase(ModuleTestCase):
'Test module'
module = 'account_retencion_ar'
def suite():
suite = test_suite()
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
TestCase))
return suite

19
tests/tools.py Normal file
View File

@ -0,0 +1,19 @@
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
from proteus import Model
from trytond.modules.company.tests.tools import get_company
__all__ = ['create_retencion_sequence']
def create_retencion_sequence(company=None, config=None):
"Create retencion sequence"
Sequence = Model.get('ir.sequence', config=config)
if not company:
company = get_company()
retencion_seq = Sequence(name='retencion', code='account.retencion',
company=company)
retencion_seq.save()
return retencion_seq

15
tox.ini Normal file
View File

@ -0,0 +1,15 @@
[tox]
envlist = {py35,py36,py37}-{sqlite,postgresql},pypy3-{sqlite,postgresql}
[testenv]
commands = {envpython} setup.py test
deps =
{py35,py36,py37}-postgresql: psycopg2 >= 2.5
pypy3-postgresql: psycopg2cffi >= 2.5
sqlite: sqlitebck
setenv =
sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://}
postgresql: TRYTOND_DATABASE_URI={env:POSTGRESQL_URI:postgresql://}
sqlite: DB_NAME={env:SQLITE_NAME::memory:}
postgresql: DB_NAME={env:POSTGRESQL_NAME:test}
install_command = pip install --pre --find-links https://trydevpi.tryton.org/ {opts} {packages}

View File

@ -1,7 +1,7 @@
[tryton]
version=5.1.0
depends:
account_check_ar
account_voucher_ar
xml:
account_retencion_ar.xml
account_voucher_ar.xml