Merge and FIX VAT declaration basing on stable sources

bzr revid: nel@tinyerp.com-20100407065502-62cik4iamvtzm4te
This commit is contained in:
nel@tinyerp.com 2010-04-07 08:55:02 +02:00
parent 59e15ebce0
commit 90f0071acb
5 changed files with 52 additions and 36 deletions

View File

@ -34,7 +34,7 @@ This module implements a dashboard for CRM that includes:
* Jobs Tracking (graph)
""",
'author': 'Tiny',
'depends': ['board', 'crm', 'report_crm'],
'depends': ['board', 'crm'],
'update_xml': ['board_crm_statistical_view.xml', 'board_crm_view.xml'],
'demo_xml': ['board_crm_demo.xml'],
'installable': True,

View File

@ -27,6 +27,15 @@ class event_registration_list(osv.osv_memory):
_description = "List Event Registrations"
def open_registration(self, cr, uid, ids, context={}):
if not context.get('active_id', None):
return {
'name': 'Event Registrations',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'event.registration',
'type': 'ir.actions.act_window'
}
cr.execute('SELECT section_id FROM event_event WHERE id = %s', (context['active_id'],))
res = cr.fetchone()
return {
@ -40,4 +49,4 @@ class event_registration_list(osv.osv_memory):
event_registration_list()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -25,7 +25,7 @@ class res_company(osv.osv):
_description = 'res.company'
def _get_default_ad(self, addresses):
city = post_code = address = ""
city = post_code = address = country_code = ""
for ads in addresses:
if ads.type == 'default':
city = ads.city or ""
@ -34,7 +34,9 @@ class res_company(osv.osv):
address = ads.street or ""
if ads.street2:
address += " " + ads.street2
return city, post_code, address
if ads.country_id:
country_code = ads.country_id and ads.country_id.code or ""
return city, post_code, address, country_code
res_company()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -18,25 +18,31 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import base64
import time
import datetime
import base64
from osv import osv, fields
from tools.translate import _
class l10n_be_vat_declaration(osv.osv_memory):
""" Periodical VAT Declaration """
""" Vat Declaration """
_name = "l1on_be.vat.declaration"
_description = "Vat Declaration"
_columns = {
'period_id': fields.many2one('account.period','Period', required=True),
'msg': fields.text('File created', size=64, readonly=True),
'file_save': fields.binary('Save File'),
}
'file_save' : fields.binary('Save File'),
'ask_resitution': fields.boolean('Ask Restitution'),
'ask_payment': fields.boolean('Ask Payment'),
'client_nihil': fields.boolean('Last Declaration of Entreprise', help = 'Thick this case only if it concerns only the last statement on the civil or cessation of activity')
}
_defaults = {
'msg': lambda *a:'''Save the File with '".xml"' extension.''',
}
}
def create_xml(self, cr, uid, ids, context={}):
obj_fyear = self.pool.get('account.fiscalyear')
@ -46,12 +52,12 @@ class l10n_be_vat_declaration(osv.osv_memory):
obj_comp = self.pool.get('res.company')
obj_data = self.pool.get('ir.model.data')
list_of_tags=['00','01','02','03','45','46','47','48','49','54','55','56','57','59','61','62','63','64','71','81','82','83','84','85','86','87','91']
list_of_tags=['00','01','02','03','44','45','46','47','48','49','54','55','56','57','59','61','62','63','64','71','81','82','83','84','85','86','87','88','91']
obj_company = obj_user.browse(cr, uid, uid, context=context).company_id
user_cmpny = obj_company.name
vat_no=obj_company.partner_id.vat
if not vat_no:
raise osv.except_osv(_('Data Insufficient'),_('No VAT Number Associated with Main Company!'))
raise wizard.except_wizard(_('Data Insufficient'),_('No VAT Number Associated with Main Company!'))
tax_code_ids = obj_tax_code.search(cr, uid, [], context=context)
ctx = context.copy()
@ -59,50 +65,46 @@ class l10n_be_vat_declaration(osv.osv_memory):
ctx['period_id'] = data['period_id'] #added context here
tax_info = obj_tax_code.read(cr, uid, tax_code_ids, ['code','sum_period'], context=ctx)
address = post_code = city = ''
if not obj_company.partner_id.address:
address = post_code = city = ''
address = post_code = city = country_code = ''
city, post_code, address, country_code = pooler.get_pool(cr.dbname).get('res.company')._get_default_ad(obj_company.partner_id.address)
city, post_code, address = obj_comp._get_default_ad(obj_company.partner_id.address)
year_id = obj_fyear.find(cr, uid)
account_period = obj_acc_period.browse(cr, uid, data['period_id'], context=context)
current_year = account_period.fiscalyear_id.name
period_code = account_period.code
send_ref = user_cmpny
if period_code:
send_ref = send_ref + period_code
send_ref = str(obj_company.partner_id.id) + str(account_period.date_start[5:7]) + str(account_period.date_stop[:4])
data_of_file='<?xml version="1.0"?>\n<VATSENDING xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="MultiDeclarationTVA-NoSignature-14.xml">'
data_of_file +='\n\t<DECLARER>\n\t\t<VATNUMBER>'+str(vat_no)+'</VATNUMBER>\n\t\t<NAME>'+str(obj_company.name)+'</NAME>\n\t\t<ADDRESS>'+address+'</ADDRESS>'
data_of_file +='\n\t\t<POSTCODE>'+post_code+'</POSTCODE>\n\t\t<CITY>'+city+'</CITY>\n\t\t<SENDINGREFERENCE>'+send_ref+'</SENDINGREFERENCE>\n\t</DECLARER>'
data_of_file +='\n\t<VATRECORD>\n\t\t<RECNUM>1</RECNUM>\n\t\t<VATNUMBER>'+str(vat_no)+'</VATNUMBER>\n\t\t<DPERIODE>\n\t\t\t'
data_of_file +='\n\t\t<POSTCODE>'+post_code+'</POSTCODE>\n\t\t<CITY>'+city+'</CITY>\n\t\t<COUNTRY>'+country_code+'</COUNTRY>\n\t\t<SENDINGREFERENCE>'+send_ref+'</SENDINGREFERENCE>\n\t</DECLARER>'
data_of_file +='\n\t<VATRECORD>\n\t\t<RECNUM>1</RECNUM>\n\t\t<VATNUMBER>'+str(vat_no[2:])+'</VATNUMBER>\n\t\t<DPERIODE>\n\t\t\t'
starting_month = account_period.date_start[5:7]
ending_month = account_period.date_stop[5:7]
if starting_month != ending_month:
#starting month and ending month of selected period are not the same
#it means that the accounting isn't based on periods of 1 month but on quarters
quarter = str(((int(starting_month) - 1) / 3) + 1)
data_of_file += '<QUARTER>' + quarter + '</QUARTER>\n\t\t\t'
data_of_file += '<QUARTER>'+quarter+'</QUARTER>\n\t\t\t'
else:
data_of_file += '<MONTH>' + starting_month + '</MONTH>\n\t\t\t'
data_of_file += '<MONTH>'+starting_month+'</MONTH>\n\t\t\t'
data_of_file += '<YEAR>' + str(account_period.date_stop[:4]) + '</YEAR>\n\t\t</DPERIODE>\n\t\t<ASK RESTITUTION="NO" PAYMENT="NO"/>'
data_of_file += '\n\t\t<ClientListingNihil>'+ (data['form']['client_nihil'] and 'YES' or 'NO') +'</ClientListingNihil>'
data_of_file +='\n\t\t<DATA>\n\t\t\t<DATA_ELEM>'
for item in tax_info:
if item['code']:
if item['code'] == '71-72':
item['code'] = '71'
item['code']='71'
if item['code'] in list_of_tags:
data_of_file +='\n\t\t\t\t<D' + str(int(item['code'])) +'>' + str(int(item['sum_period']*100)) + '</D'+str(int(item['code'])) +'>'
data_of_file +='\n\t\t\t\t<D'+str(int(item['code'])) +'>' + str(abs(int(item['sum_period']*100))) + '</D'+str(int(item['code'])) +'>'
data_of_file +='\n\t\t\t</DATA_ELEM>\n\t\t</DATA>\n\t</VATRECORD>\n</VATSENDING>'
data['file_save'] = base64.encodestring(data_of_file)
self.write(cr, uid, ids, {'file_save':data['file_save']}, context=context)
return True
l10n_be_vat_declaration()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -3,9 +3,9 @@
<data>
<menuitem
id="menu_finance_belgian_statement"
name="Belgium Statements"
parent="account.menu_finance_legal_statement"/>
id="menu_finance_belgian_statement"
name="Belgium Statements"
parent="account.menu_finance_legal_statement"/>
<record id="view_vat_declaration" model="ir.ui.view">
<field name="name">Select Period</field>
@ -13,9 +13,12 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Select Period">
<group colspan="4" >
<field name="period_id" select="1" default_focus="1"/>
<button colspan="1" name="create_xml" string="Create XML" type="object" icon="gtk-execute"/>
<group colspan="4" >
<field name="period_id" select="1"/>
<field name="ask_resitution"/>
<field name="ask_payment"/>
<field name="client_nihil"/>
<button colspan="1" name="create_xml" string="Create XML" type="object" default_focus="1"/>
</group>
<separator string="XML Flie has been Created." colspan="4"/>
<group colspan="4" >
@ -44,4 +47,4 @@
id="l10_be_vat_declaration"/>
</data>
</openerp>
</openerp>