first commit

This commit is contained in:
root
2026-03-14 09:42:12 +00:00
commit 0adbd20c2c
10991 changed files with 1646955 additions and 0 deletions

View File

@@ -0,0 +1 @@
<T11102018010000><AUX> </AUX><T11101000> IB01000009DUNDER MIFFLIN 201801000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000001000000000000000001500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000015000000000000000000000000000000001500 </T11101000></T11102018010000>

View File

@@ -0,0 +1 @@
<T11502018010000><AUX> </AUX><T11501000> IB01000009DUNDER MIFFLIN 20180100000000000000000000000000000000000000000000000000000000000000000000000000000000000 </T11501000></T11502018010000>

View File

@@ -0,0 +1 @@
<T30302018010000><AUX> </AUX><T30301000> IB01000009DUNDER MIFFLIN 201801223222222 20000000000000000000004000000000000000000000000000000000000010000000000000000000000000000000020000021000000000000000420000000000000010000000000000000021000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000000630000000000000010000000000000000021000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000002100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000420000000000000002100 </T30301000><T30303000>00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000210010000000000000000021000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000021000000000000000000000000000000002100 </T30303000></T30302018010000>

View File

@@ -0,0 +1 @@
<T30302018020000><AUX> </AUX><T30301000> CB01000009DUNDER MIFFLIN 201802223222222 20000000000000000000004000000000000000000000000000000000000010000000000000000000000000000000005000021000000000000000105000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000000105000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001050 </T30301000><T30303000>00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000105010000000000000000010500000000000000000000000000000004000000000000000040000000000000000000000000000000000000N000000000000295000000000000000000N0000000000002950 </T30303000></T30302018020000>

View File

@@ -0,0 +1,2 @@
13472018B01000009DUNDER MIFFLIN T666666666DUNDER MIFFLIN 3472018000001 0000000000000000000001 000000000024200000000000 000000000000000
23472018B0100000900000000T PARTY D25 B 000000000024200 000000000000000 0000000000000000000 000000000024200 000000000000000 000000000000000 000000000000000 000000000000000 000000000000000 000000000000000 000000000000000 000000000000000

View File

@@ -0,0 +1,2 @@
13492018B01000009DUNDER MIFFLIN T666666666DUNDER MIFFLIN 3492018010001 000000000000001000000001000000000010000000000000000000000000015
23492018B01000009 BE0897290877 INTRACOMUNITARY SUPPLIER A0000000010000

View File

@@ -0,0 +1,2 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.

View File

@@ -0,0 +1,150 @@
=====================================
Account ES EC Operation List Scenario
=====================================
Imports::
>>> from decimal import Decimal
>>> from functools import partial
>>> from proteus import Model, Wizard
>>> from trytond.modules.account.tests.tools import (
... create_chart, create_fiscalyear, get_accounts)
>>> from trytond.modules.account_invoice.tests.tools import (
... set_fiscalyear_invoice_sequences)
>>> from trytond.modules.company.tests.tools import create_company, get_company
>>> from trytond.tests.tools import activate_modules
Activate modules::
>>> config = activate_modules(
... 'account_es',
... create_company, partial(create_chart, chart='account_es.pgc_0_pyme'))
Setup company::
>>> company = get_company()
>>> tax_identifier = company.party.identifiers.new()
>>> tax_identifier.type = 'eu_vat'
>>> tax_identifier.code = 'ESB01000009'
>>> company.party.save()
Create fiscal year::
>>> fiscalyear = set_fiscalyear_invoice_sequences(
... create_fiscalyear())
>>> fiscalyear.click('create_period')
>>> period = fiscalyear.periods[0]
Get accounts::
>>> accounts = get_accounts()
>>> expense = accounts['expense']
>>> revenue = accounts['revenue']
Create party::
>>> Party = Model.get('party.party')
>>> TaxRule = Model.get('account.tax.rule')
>>> tax_rule, = TaxRule.find([
... ('company', '=', company.id),
... ('kind', '=', 'purchase'),
... ('name', '=', 'Compras Intracomunitarias'),
... ])
>>> party = Party(name='Intracomunitary Supplier')
>>> party.supplier_tax_rule = tax_rule
>>> tax_identifier = party.identifiers.new()
>>> tax_identifier.type = 'eu_vat'
>>> tax_identifier.code = 'BE0897290877'
>>> party.save()
Create account category::
>>> Tax = Model.get('account.tax')
>>> tax, = Tax.find([
... ('company', '=', company.id),
... ('group.kind', '=', 'purchase'),
... ('name', '=', 'IVA 21% (bienes)'),
... ])
>>> 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.supplier_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 invoice::
>>> Invoice = Model.get('account.invoice')
>>> invoice = Invoice()
>>> invoice.type = 'in'
>>> invoice.party = party
>>> invoice.invoice_date = period.start_date
>>> line = invoice.lines.new()
>>> line.product = product
>>> line.quantity = 5
>>> line.unit_price = Decimal('40')
>>> invoice.click('post')
Operation appears in report::
>>> ECOperationList = Model.get('account.reporting.es_ec_operation_list')
>>> context = {
... 'company': company.id,
... 'start_date': period.start_date,
... 'end_date': period.end_date,
... }
>>> with config.set_context(context):
... record, = ECOperationList.find([])
Cancel invoice::
>>> invoice.click('cancel')
Operation does not appear in report::
>>> with config.set_context(context):
... ECOperationList.find([])
[]
Create another invoice::
>>> invoice = Invoice()
>>> invoice.type = 'in'
>>> invoice.party = party
>>> invoice.invoice_date = period.start_date
>>> line = invoice.lines.new()
>>> line.product = product
>>> line.quantity = 5
>>> line.unit_price = Decimal('40')
>>> invoice.click('post')
Refund invoice::
>>> credit = Wizard('account.invoice.credit', [invoice])
>>> credit.form.with_refund = True
>>> credit.form.invoice_date = invoice.invoice_date
>>> credit.execute('credit')
>>> invoice.reload()
Operation appears in report with amount zero::
>>> with config.set_context(context):
... record, = ECOperationList.find([])
>>> record.amount
Decimal('0.00')

View File

@@ -0,0 +1,266 @@
=============================
Account ES Reporting Scenario
=============================
Imports::
>>> import datetime as dt
>>> from decimal import Decimal
>>> from functools import partial
>>> from proteus import Model, Report, Wizard
>>> from trytond.modules.account.tests.tools import (
... create_chart, create_fiscalyear, get_accounts)
>>> from trytond.modules.account_invoice.tests.tools import (
... set_fiscalyear_invoice_sequences)
>>> from trytond.modules.company.tests.tools import create_company, get_company
>>> from trytond.tests.tools import activate_modules, assertEqual
>>> from trytond.tools import file_open
Activate modules::
>>> config = activate_modules(
... 'account_es',
... create_company, partial(create_chart, chart='account_es.pgc_0_pyme'))
>>> Country = Model.get('country.country')
Setup company::
>>> spain = Country(code="ES", name="Spain")
>>> spain.save()
>>> company = get_company()
>>> address, = company.party.addresses
>>> address.country = spain
>>> address.save()
>>> tax_identifier = company.party.identifiers.new()
>>> tax_identifier.type = 'eu_vat'
>>> tax_identifier.code = 'ESB01000009'
>>> phone = company.party.contact_mechanisms.new()
>>> phone.value = '666 66 66 66'
>>> company.party.save()
Create fiscal year::
>>> fiscalyear = set_fiscalyear_invoice_sequences(
... create_fiscalyear(
... today=(dt.date(2018, 1, 1), dt.date(2018, 12, 31))))
>>> fiscalyear.click('create_period')
>>> period = fiscalyear.periods[0]
Get accounts::
>>> accounts = get_accounts()
>>> expense = accounts['expense']
>>> revenue = accounts['revenue']
Create parties::
>>> Country = Model.get('country.country')
>>> spain = Country(name='Spain', code='ES')
>>> spain.save()
>>> Party = Model.get('party.party')
>>> TaxRule = Model.get('account.tax.rule')
>>> party = Party(name='Party')
>>> tax_identifier = party.identifiers.new()
>>> tax_identifier.type = 'es_vat'
>>> tax_identifier.code = '00000000T'
>>> address, = party.addresses
>>> address.country = spain
>>> address.postal_code = '25001'
>>> party.es_province_code
'25'
>>> party.save()
>>> tax_rule, = TaxRule.find([
... ('company', '=', company.id),
... ('kind', '=', 'purchase'),
... ('name', '=', 'Retención IRPF 15%'),
... ])
>>> supplier = Party(name='Supplier')
>>> supplier.supplier_tax_rule = tax_rule
>>> tax_identifier = supplier.identifiers.new()
>>> tax_identifier.type = 'eu_vat'
>>> tax_identifier.code = 'ES00000001R'
>>> supplier.es_province_code = '08'
>>> supplier.save()
>>> tax_rule, = TaxRule.find([
... ('company', '=', company.id),
... ('kind', '=', 'purchase'),
... ('name', '=', 'Compras Intracomunitarias'),
... ])
>>> ec_supplier = Party(name='Intracomunitary Supplier')
>>> ec_supplier.supplier_tax_rule = tax_rule
>>> tax_identifier = ec_supplier.identifiers.new()
>>> tax_identifier.type = 'eu_vat'
>>> tax_identifier.code = 'BE0897290877'
>>> ec_supplier.save()
Create account category::
>>> Tax = Model.get('account.tax')
>>> customer_tax, = Tax.find([
... ('company', '=', company.id),
... ('group.kind', '=', 'sale'),
... ('name', '=', 'IVA 21% (bienes)'),
... ])
>>> supplier_tax, = Tax.find([
... ('company', '=', company.id),
... ('group.kind', '=', 'purchase'),
... ('name', '=', 'IVA 21% (bienes)'),
... ])
>>> 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(customer_tax)
>>> account_category.supplier_taxes.append(supplier_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 invoices::
>>> Invoice = Model.get('account.invoice')
>>> invoice = Invoice()
>>> invoice.party = party
>>> invoice.invoice_date = period.start_date
>>> line = invoice.lines.new()
>>> line.product = product
>>> line.quantity = 5
>>> line.unit_price = Decimal('40')
>>> invoice.click('post')
>>> invoice.total_amount
Decimal('242.00')
>>> invoice = Invoice()
>>> invoice.type = 'in'
>>> invoice.party = supplier
>>> invoice.invoice_date = period.start_date
>>> line = invoice.lines.new()
>>> line.product = product
>>> line.quantity = 5
>>> line.unit_price = Decimal('20')
>>> invoice.click('post')
>>> invoice.total_amount
Decimal('106.00')
>>> invoice = Invoice()
>>> invoice.type = 'in'
>>> invoice.party = ec_supplier
>>> invoice.invoice_date = period.start_date
>>> line = invoice.lines.new()
>>> line.product = product
>>> line.quantity = 5
>>> line.unit_price = Decimal('20')
>>> invoice.click('post')
>>> invoice.total_amount
Decimal('100.00')
Generate aeat reports::
>>> aeat = Wizard('account.reporting.aeat')
>>> aeat.form.report = '111'
>>> aeat.form.start_period = period
>>> aeat.form.end_period = period
>>> aeat.execute('choice')
>>> extension, content, _, name = aeat.actions[0]
>>> extension
'txt'
>>> with file_open('account_es/tests/111.txt') as f:
... assertEqual(content, f.read())
>>> name
'AEAT Model 111-2018-01'
>>> aeat = Wizard('account.reporting.aeat')
>>> aeat.form.report = '115'
>>> aeat.form.start_period = period
>>> aeat.form.end_period = period
>>> aeat.execute('choice')
>>> extension, content, _, name = aeat.actions[0]
>>> extension
'txt'
>>> with file_open('account_es/tests/115.txt') as f:
... assertEqual(content, f.read())
>>> name
'AEAT Model 115-2018-01'
>>> aeat = Wizard('account.reporting.aeat')
>>> aeat.form.report = '303'
>>> aeat.form.start_period = period
>>> aeat.form.end_period = period
>>> aeat.execute('choice')
>>> extension, content, _, name = aeat.actions[0]
>>> extension
'txt'
>>> with file_open('account_es/tests/303.txt') as f:
... assertEqual(content, f.read())
>>> name
'AEAT Model 303-2018-01'
>>> VatList = Model.get('account.reporting.vat_list_es')
>>> context = {
... 'company': company.id,
... 'date': period.end_date,
... }
>>> with config.set_context(context):
... vat_list_records = VatList.find([])
... report = Report('account.reporting.aeat347')
... extension, content, _, name = report.execute(vat_list_records)
>>> extension
'txt'
>>> with file_open('account_es/tests/347.txt') as f:
... assertEqual(content, f.read())
>>> name
'AEAT Model 347-...'
>>> ECOperationList = Model.get('account.reporting.es_ec_operation_list')
>>> context = {
... 'company': company.id,
... 'start_date': period.start_date,
... 'end_date': period.end_date,
... }
>>> with config.set_context(context):
... records = ECOperationList.find([])
... report = Report('account.reporting.aeat349')
... extension, content, _, name = report.execute(records)
>>> extension
'txt'
>>> with file_open('account_es/tests/349.txt') as f:
... assertEqual(content, f.read())
>>> name
'AEAT Model 349-...'
Only one tax of intracomunitary invoices is included on VAT Book::
>>> VatBook = Model.get('account.reporting.vat_book_es')
>>> context = {
... 'company': company.id,
... 'fiscalyear': fiscalyear.id,
... 'es_vat_book_type': 'R',
... }
>>> with config.set_context(context):
... records = VatBook.find([])
>>> len(records)
2
>>> supplier_record, = [r for r in records if r.party == supplier]
>>> supplier_record.base_amount
Decimal('100.00')
>>> supplier_record.tax_amount
Decimal('21.00')
>>> ec_supplier_record, = [r for r in records if r.party == ec_supplier]
>>> ec_supplier_record.base_amount
Decimal('100.00')
>>> ec_supplier_record.tax_amount
Decimal('21.00')

View File

@@ -0,0 +1,134 @@
================================================
Account ES Reporting Alternate Currency Scenario
================================================
Imports::
>>> import datetime as dt
>>> from decimal import Decimal
>>> from functools import partial
>>> from proteus import Model
>>> from trytond.modules.account.tests.tools import (
... create_chart, create_fiscalyear, get_accounts)
>>> from trytond.modules.account_invoice.tests.tools import (
... set_fiscalyear_invoice_sequences)
>>> from trytond.modules.company.tests.tools import create_company, get_company
>>> from trytond.modules.currency.tests.tools import get_currency
>>> from trytond.tests.tools import activate_modules, assertEqual
>>> today = dt.date.today()
Activate modules::
>>> config = activate_modules(
... 'account_es',
... create_company, partial(create_chart, chart='account_es.pgc_0_pyme'))
Get company::
>>> currency = get_currency('USD')
>>> eur = get_currency('EUR')
>>> company = get_company()
Create fiscal year::
>>> fiscalyear = set_fiscalyear_invoice_sequences(
... create_fiscalyear(today=today))
>>> fiscalyear.click('create_period')
Create chart of accounts::
>>> accounts = get_accounts()
>>> expense = accounts['expense']
>>> revenue = accounts['revenue']
Create parties::
>>> Party = Model.get('party.party')
>>> TaxRule = Model.get('account.tax.rule')
>>> party = Party(name='Party')
>>> tax_identifier = party.identifiers.new()
>>> tax_identifier.type = 'eu_vat'
>>> tax_identifier.code = 'ES00000000T'
>>> party.es_province_code = '25'
>>> party.save()
>>> supplier = Party(name='Intracomunitary Supplier')
>>> supplier.save()
Create invoices::
>>> Tax = Model.get('account.tax')
>>> customer_tax, = Tax.find([
... ('company', '=', company.id),
... ('group.kind', '=', 'sale'),
... ('name', '=', 'IVA 21% (bienes)'),
... ])
>>> supplier_tax, = Tax.find([
... ('company', '=', company.id),
... ('group.kind', '=', 'purchase'),
... ('name', '=', 'IVA Intracomunitario 21% (bienes)'),
... ])
>>> Invoice = Model.get('account.invoice')
>>> invoice = Invoice()
>>> invoice.party = party
>>> invoice.invoice_date = today
>>> invoice.currency = eur
>>> line = invoice.lines.new()
>>> line.account = revenue
>>> line.taxes.append(customer_tax)
>>> line.quantity = 5
>>> line.unit_price = Decimal('40')
>>> invoice.click('post')
>>> invoice.total_amount
Decimal('242.00')
>>> invoice = Invoice()
>>> invoice.type = 'in'
>>> invoice.party = supplier
>>> invoice.currency = eur
>>> invoice.invoice_date = today
>>> line = invoice.lines.new()
>>> line.account = expense
>>> line.taxes.append(supplier_tax)
>>> line.quantity = 5
>>> line.unit_price = Decimal('20')
>>> invoice.click('post')
>>> invoice.total_amount
Decimal('100.00')
EC Operation and VATList report uses company currency::
>>> VatList = Model.get('account.reporting.vat_list_es')
>>> context = {
... 'company': company.id,
... 'date': today,
... }
>>> with config.set_context(context):
... record, = VatList.find([])
>>> assertEqual(record.party, party)
>>> record.amount
Decimal('121.00')
>>> ECOperationList = Model.get('account.reporting.es_ec_operation_list')
>>> context = {
... 'company': company.id,
... 'start_date': today,
... 'end_date': today,
... }
>>> with config.set_context(context):
... record, = ECOperationList.find([])
>>> assertEqual(record.party, supplier)
>>> record.amount
Decimal('50.00')
>>> VatBook = Model.get('account.reporting.vat_book_es')
>>> context = {
... 'company': company.id,
... 'fiscalyear': fiscalyear.id,
... 'es_vat_book_type': 'E',
... }
>>> with config.set_context(context):
... record, = VatBook.find([])
>>> assertEqual(record.party, party)
>>> record.base_amount
Decimal('100.00')
>>> record.tax_amount
Decimal('21.00')

View File

@@ -0,0 +1,172 @@
================================================
Account ES Reporting Cancelled Invoices Scenario
================================================
Imports::
>>> from decimal import Decimal
>>> from functools import partial
>>> from proteus import Model, Wizard
>>> from trytond.modules.account.tests.tools import (
... create_chart, create_fiscalyear, get_accounts)
>>> from trytond.modules.account_invoice.tests.tools import (
... set_fiscalyear_invoice_sequences)
>>> from trytond.modules.company.tests.tools import create_company, get_company
>>> from trytond.tests.tools import activate_modules
Activate modules::
>>> config = activate_modules(
... 'account_es',
... create_company, partial(create_chart, chart='account_es.pgc_0_pyme'))
Setup company::
>>> company = get_company()
>>> tax_identifier = company.party.identifiers.new()
>>> tax_identifier.type = 'eu_vat'
>>> tax_identifier.code = 'ESB01000009'
>>> company.party.save()
Create fiscal year::
>>> fiscalyear = set_fiscalyear_invoice_sequences(
... create_fiscalyear())
>>> fiscalyear.click('create_period')
>>> period = fiscalyear.periods[0]
Get accounts::
>>> accounts = get_accounts()
>>> expense = accounts['expense']
>>> revenue = accounts['revenue']
Create parties::
>>> Party = Model.get('party.party')
>>> party = Party(name='Party')
>>> party.save()
Create account category::
>>> Tax = Model.get('account.tax')
>>> supplier_tax, = Tax.find([
... ('company', '=', company.id),
... ('group.kind', '=', 'purchase'),
... ('name', '=', 'IVA 21% (bienes)'),
... ])
>>> 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.supplier_taxes.append(supplier_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 invoice::
>>> Invoice = Model.get('account.invoice')
>>> invoice = Invoice()
>>> invoice.type = 'in'
>>> invoice.party = party
>>> invoice.invoice_date = period.start_date
>>> line = invoice.lines.new()
>>> line.product = product
>>> line.quantity = 5
>>> line.unit_price = Decimal('40')
>>> invoice.click('post')
Compute reports::
>>> VatList = Model.get('account.reporting.vat_list_es')
>>> VatBook = Model.get('account.reporting.vat_book_es')
>>> vat_list_context = {
... 'company': company.id,
... 'date': period.end_date,
... }
>>> with config.set_context(vat_list_context):
... vat_list_records = VatList.find([])
>>> len(vat_list_records)
1
>>> vat_book_context = {
... 'company': company.id,
... 'fiscalyear': fiscalyear.id,
... 'es_vat_book_type': 'R',
... }
>>> with config.set_context(vat_book_context):
... vat_book_records = VatBook.find([])
>>> len(vat_book_records)
1
Refund the invoice::
>>> credit = Wizard('account.invoice.credit', [invoice])
>>> credit.form.with_refund = True
>>> credit.form.invoice_date = invoice.invoice_date
>>> credit.execute('credit')
>>> invoice.reload()
>>> invoice.state
'cancelled'
Check reports::
>>> with config.set_context(vat_list_context):
... vat_list_records = VatList.find([])
>>> vat_list_record, = vat_list_records
>>> vat_list_record.amount
Decimal('0.00')
>>> with config.set_context(vat_book_context):
... vat_book_records = VatBook.find([])
>>> len(vat_book_records)
2
Create another invoice::
>>> invoice = Invoice()
>>> invoice.type = 'in'
>>> invoice.party = party
>>> invoice.invoice_date = period.start_date
>>> line = invoice.lines.new()
>>> line.product = product
>>> line.quantity = 5
>>> line.unit_price = Decimal('40')
>>> invoice.click('post')
>>> with config.set_context(vat_list_context):
... vat_list_records = VatList.find([])
>>> vat_list_record, = vat_list_records
>>> vat_list_record.amount
Decimal('242.00')
>>> with config.set_context(vat_book_context):
... vat_book_records = VatBook.find([])
>>> len(vat_book_records)
3
Cancel the invoice and check reports::
>>> invoice.click('cancel')
>>> invoice.state
'cancelled'
>>> with config.set_context(vat_list_context):
... vat_list_records = VatList.find([])
>>> vat_list_record, = vat_list_records
>>> vat_list_record.amount
Decimal('0.00')
>>> with config.set_context(vat_book_context):
... vat_book_records = VatBook.find([])
>>> len(vat_book_records)
2

View File

@@ -0,0 +1,137 @@
=========================================
Account ES Compensated Reporting Scenario
=========================================
Imports::
>>> import datetime as dt
>>> from decimal import Decimal
>>> from functools import partial
>>> from proteus import Model, Wizard
>>> from trytond.modules.account.tests.tools import (
... create_chart, create_fiscalyear, get_accounts)
>>> from trytond.modules.account_invoice.tests.tools import (
... set_fiscalyear_invoice_sequences)
>>> from trytond.modules.company.tests.tools import create_company, get_company
>>> from trytond.tests.tools import activate_modules, assertEqual
>>> from trytond.tools import file_open
Activate modules::
>>> config = activate_modules(
... ['account_es', 'account_invoice'],
... create_company, partial(create_chart, chart='account_es.pgc_0_pyme'))
Setup company::
>>> company = get_company()
>>> tax_identifier = company.party.identifiers.new()
>>> tax_identifier.type = 'eu_vat'
>>> tax_identifier.code = 'ESB01000009'
>>> company.party.save()
Create fiscal year::
>>> fiscalyear = set_fiscalyear_invoice_sequences(
... create_fiscalyear(
... today=(dt.date(2018, 1, 1), dt.date(2018, 12, 31))))
>>> fiscalyear.click('create_period')
>>> previous_period = fiscalyear.periods[0]
>>> period = fiscalyear.periods[1]
Get accounts::
>>> accounts = get_accounts()
>>> expense = accounts['expense']
>>> revenue = accounts['revenue']
Create parties::
>>> Party = Model.get('party.party')
>>> party = Party(name='Party')
>>> party.save()
Create account category::
>>> Tax = Model.get('account.tax')
>>> customer_tax, = Tax.find([
... ('company', '=', company.id),
... ('group.kind', '=', 'sale'),
... ('name', '=', 'IVA 21% (bienes)'),
... ])
>>> 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(customer_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 invoice::
>>> Invoice = Model.get('account.invoice')
>>> invoice = Invoice()
>>> invoice.party = party
>>> invoice.invoice_date = period.start_date
>>> line = invoice.lines.new()
>>> line.product = product
>>> line.quantity = 1
>>> line.unit_price = Decimal('50')
>>> invoice.click('post')
>>> invoice.total_amount
Decimal('60.50')
Create previous period compensation move::
>>> Account = Model.get('account.account')
>>> Journal = Model.get('account.journal')
>>> Move = Model.get('account.move')
>>> journal_cash, = Journal.find([
... ('code', '=', 'CASH'),
... ])
>>> compensation_account, = Account.find([
... ('company', '=', company.id),
... ('code', '=', '4700'),
... ])
>>> move = Move()
>>> move.period = previous_period
>>> move.journal = journal_cash
>>> move.date = previous_period.start_date
>>> line = move.lines.new()
>>> line.account = expense
>>> line.credit = Decimal(40)
>>> line = move.lines.new()
>>> line.account = compensation_account
>>> line.debit = Decimal(40)
>>> move.click('post')
Generate aeat 303 report::
>>> aeat = Wizard('account.reporting.aeat')
>>> aeat.form.report = '303'
>>> aeat.form.start_period = period
>>> aeat.form.end_period = period
>>> aeat.execute('choice')
>>> extension, content, _, name = aeat.actions[0]
>>> extension
'txt'
>>> with file_open('account_es/tests/303_compensate.txt') as f:
... assertEqual(content, f.read())
>>> name
'AEAT Model 303-2018-02'

View File

@@ -0,0 +1,141 @@
===========================================
Account ES Reporting Surcharge Tax Scenario
===========================================
Imports::
>>> import datetime as dt
>>> from decimal import Decimal
>>> from functools import partial
>>> from proteus import Model, Report
>>> from trytond.modules.account.tests.tools import (
... create_chart, create_fiscalyear, get_accounts)
>>> from trytond.modules.account_invoice.tests.tools import (
... set_fiscalyear_invoice_sequences)
>>> from trytond.modules.company.tests.tools import create_company, get_company
>>> from trytond.tests.tools import activate_modules, assertEqual
>>> from trytond.tools import file_open
Activate modules::
>>> config = activate_modules(
... 'account_es',
... create_company, partial(create_chart, chart='account_es.pgc_0_pyme'))
Setup company::
>>> company = get_company()
>>> tax_identifier = company.party.identifiers.new()
>>> tax_identifier.type = 'eu_vat'
>>> tax_identifier.code = 'ESB01000009'
>>> company.party.save()
Create fiscal year::
>>> fiscalyear = set_fiscalyear_invoice_sequences(
... create_fiscalyear(
... company, (dt.date(2020, 1, 1), dt.date(2020, 12, 31))))
>>> fiscalyear.click('create_period')
Get accounts::
>>> accounts = get_accounts()
>>> expense = accounts['expense']
>>> revenue = accounts['revenue']
Create parties::
>>> Party = Model.get('party.party')
>>> party = Party(name='Party')
>>> tax_identifier = party.identifiers.new()
>>> tax_identifier.type = 'eu_vat'
>>> tax_identifier.code = 'ES00000000T'
>>> party.save()
>>> surcharge_party = Party(name='Surcharge Party')
>>> tax_identifier = surcharge_party.identifiers.new()
>>> tax_identifier.type = 'eu_vat'
>>> tax_identifier.code = 'ES00000001R'
>>> surcharge_party.save()
Create invoices::
>>> Tax = Model.get('account.tax')
>>> tax, = Tax.find([
... ('company', '=', company.id),
... ('group.kind', '=', 'sale'),
... ('name', '=', 'IVA 21% (bienes)'),
... ])
>>> surcharge_tax, = Tax.find([
... ('company', '=', company.id),
... ('group.kind', '=', 'sale'),
... ('es_reported_with', '=', tax.id),
... ])
>>> Invoice = Model.get('account.invoice')
>>> invoice = Invoice()
>>> invoice.party = party
>>> invoice.invoice_date = fiscalyear.start_date
>>> line = invoice.lines.new()
>>> line.account = revenue
>>> line.taxes.append(tax)
>>> line.quantity = 5
>>> line.unit_price = Decimal('20')
>>> invoice.click('post')
>>> invoice.click('post')
>>> invoice.total_amount
Decimal('121.00')
>>> invoice = Invoice()
>>> invoice.party = surcharge_party
>>> invoice.invoice_date = fiscalyear.start_date
>>> line = invoice.lines.new()
>>> line.account = revenue
>>> line.taxes.append(Tax(tax.id))
>>> line.taxes.append(surcharge_tax)
>>> line.quantity = 2
>>> line.unit_price = Decimal('25')
>>> invoice.click('post')
>>> invoice.total_amount
Decimal('63.10')
>>> invoice, = invoice.duplicate()
>>> invoice.invoice_date = fiscalyear.start_date
>>> line, = invoice.lines
>>> line.quantity = 1
>>> line.unit_price = Decimal('0.03')
>>> invoice.click('post')
>>> invoice.total_amount
Decimal('0.04')
Generate VAT Book::
>>> VatBook = Model.get('account.reporting.vat_book_es')
>>> context = {
... 'company': company.id,
... 'fiscalyear': fiscalyear.id,
... 'es_vat_book_type': 'E',
... }
>>> with config.set_context(context):
... records = VatBook.find([])
... report = Report('account.reporting.aeat.vat_book')
... extension, content, _, name = report.execute(records)
>>> len(records)
3
>>> tax_record = [r for r in records if not r.surcharge_tax][0]
>>> assertEqual(tax_record.party, party)
>>> tax_record.base_amount
Decimal('100.00')
>>> tax_record.tax_amount
Decimal('21.00')
>>> surcharge_tax_record = [r for r in records if r.surcharge_tax][0]
>>> assertEqual(surcharge_tax_record.party, surcharge_party)
>>> surcharge_tax_record.base_amount
Decimal('50.00')
>>> surcharge_tax_record.tax_amount
Decimal('10.50')
>>> surcharge_tax_record.surcharge_tax_amount
Decimal('2.60')
>>> with file_open('account_es/tests/vat_book.csv', 'rb') as f:
... assertEqual(content, f.read())
>>> name
'VAT Book-...'
>>> extension
'csv'

View File

@@ -0,0 +1,15 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.tests.test_tryton import ModuleTestCase
class AccountTestCase(ModuleTestCase):
'Test Account Es module'
module = 'account_es'
extras = [
'account_asset', 'account_payment_sepa', 'sale_advance_payment',
'sale_gift_card']
del ModuleTestCase

View File

@@ -0,0 +1,8 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.tests.test_tryton import load_doc_tests
def load_tests(*args, **kwargs):
return load_doc_tests(__name__, __file__, *args, **kwargs)

View File

@@ -0,0 +1,3 @@
2020;1T;E;;F1;;;01/01/2020;;;1;;00000000T;;Party;;121,00;100,00;21,00;21,00;;;;;;;;
2020;1T;E;;F1;;;01/01/2020;;;2;;00000001R;;Surcharge Party;;63,10;50,00;21,00;10,50;5,20;2,60;;;;;;
2020;1T;E;;F1;;;01/01/2020;;;3;;00000001R;;Surcharge Party;;0,04;0,03;21,00;0,01;5,20;0,00;;;;;;
1 2020 1T E F1 01/01/2020 1 00000000T Party 121,00 100,00 21,00 21,00
2 2020 1T E F1 01/01/2020 2 00000001R Surcharge Party 63,10 50,00 21,00 10,50 5,20 2,60
3 2020 1T E F1 01/01/2020 3 00000001R Surcharge Party 0,04 0,03 21,00 0,01 5,20 0,00