Browse Source

[IMP] several dev points so far. still in wip

pull/1/head
houssine 8 years ago
parent
commit
f0bef876b7
  1. 79
      easy_my_coop_taxshelter_report/models/tax_shelter_declaration.py
  2. 141
      easy_my_coop_taxshelter_report/report/tax_shelter_report.xml
  3. 39
      easy_my_coop_taxshelter_report/views/tax_shelter_declaration_view.xml

79
easy_my_coop_taxshelter_report/models/tax_shelter_declaration.py

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import base64
from datetime import datetime
from openerp import api, fields, models, _
@ -13,9 +14,12 @@ class TaxShelterDeclaration(models.Model):
_name = "tax.shelter.declaration"
name = fields.Char(string='Declaration year', required=True)
fiscal_year = fields.Char(String="Fiscal year", required=True)
tax_shelter_certificates = fields.One2many('tax.shelter.certificate','declaration_id', string='Tax shelter certificates', readonly=True)
date_from = fields.Date(string='Date from', required=True)
date_to = fields.Date(string='Date to', required=True)
month_from = fields.Char(String='Month from', required=True)
month_to = fields.Char(String='Month to', required=True)
tax_shelter_percentage = fields.Selection([('30','30%'),
('45','45%')],
string='Tax Shelter percentage', required=True)
@ -23,6 +27,10 @@ class TaxShelterDeclaration(models.Model):
('computed','Computed'),
('validated','Validated')],
string='State',required=True, default="draft")
company_id = fields.Many2one('res.company', string='Company', required=True,
change_default=True, readonly=True,
default=lambda self: self.env['res.company']._company_default_get())
tax_shelter_capital_limit = fields.Float(string="Tax shelter capital limite", required=True)
def _prepare_line(self, certificate, entry):
line_vals = {}
@ -35,12 +43,7 @@ class TaxShelterDeclaration(models.Model):
line_vals['type'] = TYPE_MAP[entry.type]
return line_vals
@api.one
def compute_declaration(self):
entries = self.env['subscription.register'].search([('date','>=',self.date_from),
('date','<=',self.date_to),
('type','in',['subscription','sell_back','transfer'])])
partner_certificate = {}
def _compute_certificates(self,entries,partner_certificate):
for entry in entries:
certificate = partner_certificate.get(entry.partner_id.id, False)
if not certificate:
@ -53,6 +56,23 @@ class TaxShelterDeclaration(models.Model):
partner_certificate[entry.partner_id.id] = certificate
line_vals = self._prepare_line(certificate, entry)
self.env['certificate.line'].create(line_vals)
return partner_certificate
@api.one
def compute_declaration(self):
entries = self.env['subscription.register'].search([('date','>=',self.date_from),
('date','<=',self.date_to),
('type','=','subscription')])
partner_certificate = self._compute_certificates(entries, partner_certificate = {})
entries = self.env['subscription.register'].search([('date','<=',self.date_to),
('type','in',['sell_back','transfer'])])
partner_certificate = self._compute_certificates(entries, partner_certificate)
self.state = 'computed'
@api.one
def generate_attachments(self):
self.tax_shelter_certificates.generate_certificates_report()
@api.one
def validate_declaration(self):
@ -61,7 +81,11 @@ class TaxShelterDeclaration(models.Model):
@api.one
def reset_declaration(self):
if not self.state == 'validated':
certificate_ids = self.tax_shelter_certificates.ids
self.tax_shelter_certificates.unlink()
certificate_attchments = self.env['ir.attachment'].search([('res_model','=','tax.shelter.certificate'),
('res_id','in',certificate_ids)])
certificate_attchments.unlink
class TaxShelterCertificate(models.Model):
_name = "tax.shelter.certificate"
@ -83,13 +107,48 @@ class TaxShelterCertificate(models.Model):
total_amount_resold = fields.Float(compute='_compute_amounts', string='Total resold')
total_amount_transfered = fields.Float(compute='_compute_amounts', string='Total transfered')
total_amount = fields.Float(compute='_compute_amounts', string='Total', readonly=True)
company_id = fields.Many2one(related="declaration_id.company_id", string="Company")
def attach_to_certificate(self, report, report_name):
attachment_data = {
'name': report_name,
'datas_fname': report_name,
'datas': report,
'res_model': 'tax.shelter.certificate',
'res_id': self.id,
}
self.env['ir.attachment'].create(attachment_data)
@api.multi
def generate_certificates_report(self):
report_dic = {'easy_my_coop_taxshelter_report.tax_shelter_subscription_report':'Tax Shelter Subscription',
'easy_my_coop_taxshelter_report.tax_shelter_shares_report':'Tax Shelter Shares'}
for certificate in self:
for report_action, name in report_dic.items():
report = self.env['report'].get_pdf(certificate, report_action)
report = base64.b64encode(report)
report_name = certificate.partner_id.name + ' ' + name + ' ' + certificate.declaration_id.name + '.pdf'
certificate.attach_to_certificate(report, report_name)
@api.multi
def print_subscription_certificate(self):
self.ensure_one()
return self.env['report'].get_action(self, 'easy_my_coop_taxshelter_report.tax_shelter_subscription_report')
@api.multi
def print_shares_certificate(self):
self.ensure_one()
return self.env['report'].get_action(self, 'easy_my_coop_taxshelter_report.tax_shelter_shares_report')
@api.multi
def _compute_amounts(self):
total_amount_subscribed = 0
total_amount_transfered = 0
total_amount_resold = 0
for certificate in self:
total_amount_subscribed = 0
total_amount_transfered = 0
total_amount_resold = 0
for line in certificate.subscribed_lines:
total_amount_subscribed += line.amount_subscribed
certificate.total_amount_subscribed = total_amount_subscribed
@ -111,7 +170,7 @@ class TaxShelterCertificate(models.Model):
certificate.transfered_lines = certificate.lines.filtered(lambda r: r.type == 'transfered')
class TaxShelterCertificateLine(models.Model):
_name="certificate.line"
_name= "certificate.line"
tax_shelter_certificate = fields.Many2one('tax.shelter.certificate', string="Tax shelter certificate",ondelete='cascade',required=True)
share_type = fields.Many2one('product.product', string='Share type', required=True, readonly=True)

141
easy_my_coop_taxshelter_report/report/tax_shelter_report.xml

@ -1,141 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="0">
<report
id="action_tax_shelter_report"
model="res.partner"
string="Tax shelter report"
report_type="qweb-pdf"
name="easy_my_coop_taxshelter_report.tax_shelter_report"
file="easy_my_coop_taxshelter_report.tax_shelter_report.xml"
multi="True"
menu="True"/>
</data>
<data>
<template id="tax_shelter_report_document">
<t t-call="theme_light.invoice_layout">
<div class="page">
<head>
<link href="/easy_my_coop_taxshelter_report/static/src/css/coop_report.css" rel="stylesheet"/>
<style type="text/css">
/* Montserrat */
@font-face {
font-family: 'Montserrat-Regular';
font-style: normal;
src: local('Montserrat Regular'), url('/theme_light/static/font/Montserrat-Regular.ttf') format('truetype');
}
/* Roboto Regular */
@font-face {
font-family: 'Roboto-Regular';
font-style: normal;
src: local('Roboto Regular'), url('/theme_light/static/font/Roboto-Regular.ttf') format('truetype');
}
/* Roboto Bold */
@font-face {
font-family: 'Roboto-Bold';
font-style: normal;
src: local('Roboto Bold'), url('/theme_light/static/font/Roboto-Bold.ttf') format('truetype');
}
/* BEBASNEUE Bold */
@font-face {
font-family: 'Bebasneue-Bold';
font-style: normal;
src: local('Bebasneue-Bold'), url('/theme_light/static/font/BEBASNEUE_BOLD.ttf') format('truetype');
}
</style>
</head>
<t t-call="theme_light.invoice_header"/>
<div class="row">
<div class="col-xs-5 col-xs-offset-7 easymy-coop-address" style="top:40px;">
<strong><span t-field="o.name" /><br/></strong>
<span> numéro de coopérateur </span>
<span t-field="o.cooperator_register_number"></span><br/><br/>
<span t-field="o.street" /><br/>
<span>
<span t-field="o.zip"/>
<span t-field="o.city"/>
</span><br/>
<span t-field="o.country_id.name" /><br/>
</div>
</div>
<div style="position:absolute; top:300px">
<h2 style="font-family:Bebasneue-Bold;font-size:20pt;line-height:14pt;">
<div>
<span>Déclaration Tax Shelter</span>
</div>
<div style="width:125px;position:relative;top:10px;border-bottom: 4pt solid #fcc300;"/>
</h2>
<div class="row">
<div class="col-xs-12 pull-left" style="position:relative;top:35px;font-size:16;color:black;font-family:Roboto-Regular;">
<div>
Cher membre fondateur,
</div>
<div style="position:relative;top:30px;">
Durant l'année 2015 vous êtes devenu coopérateur de la BEES Coop SCRLfs.<br/>
<t t-foreach="o.share_ids" t-as="line">
Vous avez souscrits en date <span t-field="line.effective_date" ></span>, <span t-field="line.share_number" ></span> parts pour un montant total de <span t-field="line.total_amount_line"
t-field-options='{"widget": "monetary", "display_currency": "res_company.currency_id"}'/> euros.<br/>
</t>
</div>
<div style="position:relative;top:45px;">
L' Article 145/26, CIR 92 sur les revenus 2015, connu aussi comme normative Tax Shelter, donnent droit à une réduction d’impôt à hauteur de 45% du montant de la valeur des parts souscrites depuis juillet 2015 (et avant décembre 2015 pour la déclaration des revenus 2015).<br/>
<br/>
Cette lettre vaut donc comme certificat que BEES coop scrl fs remplit en effet tous les critères permettant un tel avantage fiscal. Dans les grandes lignes : <br/>
<br/>
être une micro-entreprise qui répond à au moins deux des trois critères suivants : <br/><br/>
- le total du bilan est inférieur ou égal à 350.000 euros ; <br/>
- le chiffre d’affaires, hors taxe sur la valeur ajoutée, est inférieur ou égal à 700.000 euros ; <br/>
- la moyenne des travailleurs occupés pendant l’année est inférieure ou égale à 10. <br/>
<br/>
être une entreprise n’ayant encore jamais distribué de dividende et qui n'est pas issue d’une fusion ou scission de sociétés.<br/><br/>
Le maintien de la réduction d’impôt n’est possible que si l'investisseur conserve les parts de la coopérative pendant 4 ans au minimum, sauf si la sortie est imposée par des conditions extérieures (telles que la faillite, par exemple). En cas de sortie volontaire avant la période de 4 ans, l’avantage fiscal devra être remboursé au prorata du nombre de mois entre la sortie et les 4 ans. La coopérative s’engage à fournir pour chacune des quatre années suivant l’année d’acquisition une attestation certifiant que ces parts sont toujours en possession du souscripteur.<br/><br/>
L’apport de capitaux par le chef d’entreprise lui-même ou par des administrateurs existants de la société ne permet pas de bénéficier du tax shelter.<br/>
<br/>
Pour bénéficier de la réduction d’impôts, vous pouvez joindre cette lettre à votre déclaration fiscale pour les revenus 2015.<br/>
<br/>
<![CDATA[
Pour toute information complémentaire, consultez le texte de <a href="http://ccff02.minfin.fgov.be/KMWeb/document.do?method=view&id=e5996d67-4f3e-4465-b21e-7e59d968a55d">l’Arrêté Royale en ligne</a>.<br/>
]]>
<br/>
Cordialement,
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6 pull-left" style="position:relative;top:100px;font-size:16;color:black;font-family:Roboto-Regular;">
<div style="position:relative;top:10px;">
Pour le Conseil d'administration de BEES coop SCRLFs.
</div>
<div style="position:relative;top:20px;">
<strong>Carine Sottiaux</strong>
</div>
<div style="position:relative;top:30px;">
<img src="/theme_light/static/img/gallery/signature_certificat.png" style="width:240px;height:200px;padding-bottom:5px;"/>
</div>
</div>
</div>
</div>
</div>
</t>
</template>
<template id="tax_shelter_report">
<t t-call="theme_light.html_container">
<t t-set="data_report_margin_top" t-value="10"/>
<t t-set="data_report_header_spacing" t-value="5"/>
<t t-set="data_report_dpi" t-value="110"/>
<t t-foreach="docs" t-as="o">
<t t-call="easy_my_coop_taxshelter_report.tax_shelter_report_document" t-lang="o.lang"/>
</t>
</t>
</template>
</data>
</odoo>

39
easy_my_coop_taxshelter_report/views/tax_shelter_declaration_view.xml

@ -10,7 +10,8 @@
<form string="Tax shelter declaration">
<header>
<button name="compute_declaration" string="Process Declaration" type="object" class="oe_highlight" groups="easy_my_coop.group_energiris_manager"/>
<button name="validate_declaration" string="Validate Declaration" type="object" states="computed" class="oe_highlight" groups="easy_my_coop.group_energiris_manager"/>
<button name="validate_declaration" string="Validate Declaration" type="object" states="computed" groups="easy_my_coop.group_energiris_manager"/>
<button name="generate_attachments" string="Generate Attachments" type="object" states="computed" groups="easy_my_coop.group_energiris_manager"/>
<button name="reset_declaration" string="Reset Declaration" type="object" groups="easy_my_coop.group_energiris_manager"/>
<field name="state" widget="statusbar"/>
</header>
@ -18,11 +19,15 @@
<group>
<group>
<field name="name"/>
<field name="fiscal_year"/>
<field name="tax_shelter_percentage"/>
<field name="tax_shelter_capital_limit"/>
</group>
<group>
<field name="date_from"/>
<field name="date_to"/>
<field name="month_from"/>
<field name="month_to"/>
</group>
</group>
<notebook>
@ -33,6 +38,9 @@
<field name="cooperator_number"/>
<field name="total_amount"/>
<field name="state"/>
<button type="object" name="print_subscription_certificate" icon="STOCK_MEDIA_PLAY" />
<button type="object" name="print_shares_certificate" icon="STOCK_MEDIA_PLAY" />
<button type="object" name="generate_certificates_report" icon="STOCK_MEDIA_PLAY" />
</tree>
</field>
</page>
@ -51,12 +59,13 @@
<field name="date_from"/>
<field name="date_to"/>
<field name="tax_shelter_percentage"/>
<field name="state"/>
</tree>
</field>
</record>
<record id="tax_shelter_declaration_action" model="ir.actions.act_window">
<field name="name">Tax Shelter Declaration</field>
<field name="name">Tax Shelter Declarations</field>
<field name="res_model">tax.shelter.declaration</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
@ -132,5 +141,31 @@
</form>
</field>
</record>
<record id="tax_shelter_certificate_tree" model="ir.ui.view">
<field name="name">tax.shelter.certificate.tree</field>
<field name="model">tax.shelter.certificate</field>
<field name="arch" type="xml">
<tree string="Tax shelter certificates">
<field name="partner_id"/>
<field name="cooperator_number"/>
<field name="total_amount_subscribed"/>
<field name="total_amount_resold"/>
<field name="total_amount_transfered"/>
<field name="total_amount"/>
<field name="state"/>
</tree>
</field>
</record>
<record id="tax_shelter_certificate_action" model="ir.actions.act_window">
<field name="name">Tax Shelter Certificates</field>
<field name="res_model">tax.shelter.certificate</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="tax_shelter_certificate_tree"/>
</record>
<menuitem action="tax_shelter_certificate_action" name="Tax Shelter Certificates" id="menu_tax_shelter_certificate" parent="menu_easy_my_coop_main_declaration" sequence="20" groups="easy_my_coop.group_energiris_manager"/>
</data>
</odoo>
Loading…
Cancel
Save