Skip to content

Commit

Permalink
Merge 4627b9e into f6beab2
Browse files Browse the repository at this point in the history
  • Loading branch information
robinkeunen committed Jan 2, 2020
2 parents f6beab2 + 4627b9e commit 203bd0d
Show file tree
Hide file tree
Showing 20 changed files with 1,323 additions and 0 deletions.
56 changes: 56 additions & 0 deletions l10n_be_vat_reports/README.rst
@@ -0,0 +1,56 @@
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

===================
l10n_be_vat_reports
===================

This module contains the VAT reports for the Belgian localization


Usage
=====


.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/119/10.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/l10n-belgium/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://odoo-community.org/logo.png>`_.

Contributors
------------

* André Paramés <github@andreparames.com> (https://www.acsone.eu/)

Do not contact contributors directly about support or help with technical issues.

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit https://odoo-community.org.
1 change: 1 addition & 0 deletions l10n_be_vat_reports/__init__.py
@@ -0,0 +1 @@
from . import wizard
45 changes: 45 additions & 0 deletions l10n_be_vat_reports/__openerp__.py
@@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This file is part of l10n_be_mis_reports,
# an Odoo module.
#
# Copyright (c) 2018 ACSONE SA/NV (<http://acsone.eu>)
#
# l10n_be_mis_reports is free software:
# you can redistribute it and/or modify it under the terms of the GNU
# Affero General Public License as published by the Free Software
# Foundation,either version 3 of the License, or (at your option) any
# later version.
#
# l10n_be_mis_reports is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with l10n_be_mis_reports.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Belgium VAT Reports',
'author': 'ACSONE SA/NV,'
'Odoo Community Association (OCA)',
'website': 'http://acsone.eu',
'category': 'Reporting',
'version': '9.0.1.0.0',
'license': 'AGPL-3',
'depends': [
'l10n_be',
'account',
],
'data': [
'wizard/l10n_be_partner_vat_listing.xml',
'wizard/l10n_be_vat_intra_view.xml',
'views/report_vatintraprint.xml',
'views/report_vatpartnerlisting.xml',
'l10n_be_reports.xml',
],
'installable': True,
}
23 changes: 23 additions & 0 deletions l10n_be_vat_reports/l10n_be_reports.xml
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<openerp>
<data>
<report
id="action_report_l10nvatintraprint"
model="partner.vat.intra"
string="Partner VAT Intra"
report_type="qweb-pdf"
name="l10n_be_vat_reports.report_l10nvatintraprint"
file="l10n_be_vat_reports.report_l10nvatintraprint"
menu="False"
/>
<report
id="action_report_l10nvatpartnerlisting"
model="partner.vat.intra"
string="Annual Listing of VAT-Subjected"
report_type="qweb-pdf"
name="l10n_be_vat_reports.report_l10nvatpartnerlisting"
file="l10n_be_vat_reports.report_l10nvatpartnerlisting"
menu="False"
/>
</data>
</openerp>
24 changes: 24 additions & 0 deletions l10n_be_vat_reports/tests/__init__.py
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
#
##############################################################################
#
# Authors: Adrien Peiffer
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from . import test_vat_reports
from . import test_vat_intra
37 changes: 37 additions & 0 deletions l10n_be_vat_reports/tests/common.py
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
# Copyright 2018 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.tests.common import TransactionCase


class TestVatReportsCommon(TransactionCase):

def _create_test_data(self, invoice_tax):
chart = self.env.ref('l10n_be.l10nbe_chart_template')
chart.try_loading_for_current_company()
company = self.env.user.company_id
company.partner_id.write({'vat': 'PT999999990'})
self.partner = self.env.ref('base.res_partner_12')
self.partner.write({'vat': 'BE0477472701'})
account_rcv = self.partner.property_account_receivable_id
account_rev_type = self.env.ref('account.data_account_type_revenue')
account_line = self.env['account.account'].search([
('user_type_id', '=', account_rev_type.id)
], limit=1)
invoice = self.env['account.invoice'].create({
'company_id': company.id,
'currency_id': self.env.ref('base.EUR').id,
'account_id': account_rcv.id,
'invoice_line_ids': [(0, 0, {
'name': 'Computer SC234',
'price_unit': 450.0,
'quantity': 1.0,
'product_id': self.env.ref('product.product_product_3').id,
'uom_id': self.env.ref('product.product_uom_unit').id,
'invoice_line_tax_ids': [(6, 0, [invoice_tax.id])],
'account_id': account_line.id,
})],
'partner_id': self.partner.id,
})
invoice.action_invoice_open()
51 changes: 51 additions & 0 deletions l10n_be_vat_reports/tests/test_vat_intra.py
@@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
# Copyright 2018 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.addons.report.models import report

from lxml.etree import XML
import unittest
import time

from .common import TestVatReportsCommon


class TestVatIntra(TestVatReportsCommon):

def setUp(self):
super(TestVatReportsCommon, self).setUp()
company = self.env.user.company_id
tax = self.env.ref('l10n_be.%s_attn_VAT-OUT-00-EU-S' % company.id)
self._create_test_data(tax)

def test_xml_list(self):
wizard = self.env['partner.vat.intra'].create({
'period_code': time.strftime('00%Y'),
'date_start': time.strftime('%Y-01-01'),
'date_end': time.strftime('%Y-12-31'),
})
wizard.create_xml()
ns = {'ns2': 'http://www.minfin.fgov.be/IntraConsignment'}
xml = XML(wizard.file_save.decode('base64'))
xml_vat_amount = xml.xpath(
'//ns2:IntraListing',
namespaces=ns)[0].attrib['AmountSum']
codes = xml.xpath(
'//ns2:IntraListing/ns2:IntraClient/ns2:Code',
namespaces=ns)
for code in codes:
self.assertTrue(code.text)
self.assertEqual('450.00', xml_vat_amount)

@unittest.skipIf(report.wkhtmltopdf_state == 'install',
'wkhtmltopdf not available')
def test_pdf_list(self):
wizard = self.env['partner.vat.intra'].create({
'period_code': time.strftime('00%Y'),
'date_start': time.strftime('%Y-01-01'),
'date_end': time.strftime('%Y-12-31'),
})
report_action = wizard.preview()
self.env['report'].get_pdf(
[], report_action['report_name'], data=report_action['data'])
60 changes: 60 additions & 0 deletions l10n_be_vat_reports/tests/test_vat_reports.py
@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*-
# Copyright 2018 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.addons.report.models import report

from lxml.etree import XML
import unittest

from .common import TestVatReportsCommon


class TestVatListing(TestVatReportsCommon):

def setUp(self):
super(TestVatReportsCommon, self).setUp()
company = self.env.user.company_id
tax = self.env.ref('l10n_be.%s_attn_VAT-OUT-21-S' % company.id)
self._create_test_data(tax)

def _prepare_listing(self):
wizard = self.env['partner.vat'].create({
'year': '2018',
'limit_amount': 1,
})
action = wizard.get_partner()
vat_listings_ids = action['context']['partner_ids']
vat_listings = self.env['vat.listing.clients'].browse(vat_listings_ids)
vat_listing = next(vl for vl in vat_listings
if vl.vat == self.partner.vat)
self.assertEqual(94.5, vat_listing.vat_amount)
context = dict(
self.env.context,
partner_ids=[vat_listing.id],
year='2018',
limit_amount=1,
)
full_list = self.env['partner.vat.list'].with_context(
context).create({})
return full_list

def test_xml_list(self):
full_list = self._prepare_listing()
full_list.create_xml()
ns = {'ns2': 'http://www.minfin.fgov.be/ClientListingConsignment'}
xml = XML(full_list.file_save.decode('base64'))
xml_vat_amount = xml.xpath(
'//ns2:Client[ns2:CompanyVATNumber[text() = "0477472701"]]'
'/ns2:VATAmount',
namespaces=ns)[0].text
self.assertEqual('94.50', xml_vat_amount)

@unittest.skipIf(report.wkhtmltopdf_state == 'install',
'wkhtmltopdf not available')
def test_pdf_list(self):
full_list = self._prepare_listing()
report_action = full_list.print_vatlist()
context = full_list.env.context
self.env['report'].with_context(context).get_pdf(
[], report_action['report_name'], data=report_action['data'])
51 changes: 51 additions & 0 deletions l10n_be_vat_reports/views/report_vatintraprint.xml
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_l10nvatintraprint">
<t t-call="report.html_container">
<t t-call="report.internal_layout">
<div class="page">
<div class="oe_structure"/>
<h2>Partner VAT Intra</h2>

<div class="row mt32 mb32">
<div class="col-xs-3">
<strong>Company Name:</strong>
<p t-esc="data['form']['company_name']"/>
</div>
<div class="col-xs-3">
<strong>Vat Number:</strong>
<p t-esc="data['form']['company_vat']"/>
</div>
<div class="col-xs-3">
<strong>Partners without VAT:</strong>
<p t-esc="data['form']['partner_wo_vat'] or '-'"/>
</div>
</div>

<table class="table table-condensed">
<thead>
<tr>
<th>Partner Name</th>
<th>Partner VAT</th>
<th>Code (Tax Code)</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<tr t-foreach="data['form']['clientlist']" t-as="l">
<td><span t-esc="l['partner_name']"/></td>
<td><span t-esc="l['vat']"/></td>
<td><span t-esc="l['code']"/></td>
<td><span t-esc="formatLang(l['amount'], currency_obj=res_company.currency_id)"/></td>
</tr>
</tbody>
</table>

<p>Total: <span t-esc="formatLang(data['form']['amountsum'], currency_obj=res_company.currency_id)"/></p>
</div>
</t>
</t>
</template>
</data>
</openerp>

0 comments on commit 203bd0d

Please sign in to comment.