[FIX] l10n_be: compliancy of belgian vat declaration with Intervat 5.1.0 (from 05 feb 2010)
bzr revid: nel@tinyerp.com-20100411193152-twcdvdgkpe321dir
This commit is contained in:
@@ -6466,9 +6466,20 @@
|
||||
</record>
|
||||
<record id="vat_code_a44" model="account.tax.code.template">
|
||||
<field name="code">44</field>
|
||||
<field name="name">Services intra-communautaires</field>
|
||||
<field name="name">Services intra-communautaires et ABC</field>
|
||||
<field name="parent_id" ref="vat_code_out"/>
|
||||
</record>
|
||||
<record id="vat_code_a44a" model="account.tax.code.template">
|
||||
<field name="code">44a</field>
|
||||
<field name="name">Services intra-communautaires</field>
|
||||
<field name="parent_id" ref="vat_code_a44"/>
|
||||
</record>
|
||||
<record id="vat_code_a44b" model="account.tax.code.template">
|
||||
<field name="code">44b</field>
|
||||
<field name="name">ABC intra-communautaires</field>
|
||||
<field name="parent_id" ref="vat_code_a44"/>
|
||||
</record>
|
||||
|
||||
<record id="vat_code_a45" model="account.tax.code.template">
|
||||
<field name="code">45</field>
|
||||
<field name="name">Operations avec TVA due par le cocontractant</field>
|
||||
@@ -7053,14 +7064,25 @@
|
||||
</record>
|
||||
<record id="vat_IO_S" model="account.tax.template">
|
||||
<field name="chart_template_id" ref="l10nbe_chart_template"/>
|
||||
<field name="name">TVA 0% Intracommunautaire (Services et ABC)</field>
|
||||
<field name="name">TVA 0% Services Intracommunautaires</field>
|
||||
<field name="description">V-INTRA-S 0</field>
|
||||
<field eval="0.00" name="amount"/>
|
||||
<field name="type">percent</field>
|
||||
<field name="base_code_id" ref="vat_code_a44"/>
|
||||
<field name="base_code_id" ref="vat_code_a44a"/>
|
||||
<field name="ref_base_code_id" ref="vat_code_a48"/>
|
||||
<field name="type_tax_use">sale</field>
|
||||
</record>
|
||||
<record id="vat_IO_S" model="account.tax.template">
|
||||
<field name="chart_template_id" ref="l10nbe_chart_template"/>
|
||||
<field name="name">TVA 0% ABC Intracommunautaire</field>
|
||||
<field name="description">V-INTRA-ABC 0</field>
|
||||
<field eval="0.00" name="amount"/>
|
||||
<field name="type">percent</field>
|
||||
<field name="base_code_id" ref="vat_code_a44b"/>
|
||||
<field name="ref_base_code_id" ref="vat_code_a48"/>
|
||||
<field name="type_tax_use">sale</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Purchases VAT -->
|
||||
<record id="vat_IO_buy_21b" model="account.tax.template">
|
||||
|
||||
@@ -37,6 +37,18 @@ class vat_listing_clients(osv.osv_memory):
|
||||
'amount': fields.float('Amount'),
|
||||
'turnover': fields.float('Turnover'),
|
||||
}
|
||||
def name_get(self, cr, uid, ids, context={}):
|
||||
if not len(ids):
|
||||
return []
|
||||
return [(r['id'], r['name'] + ' - ' + r['vat']) \
|
||||
for r in self.read(cr, uid, ids, ['name', 'vat'],
|
||||
context, load='_classic_write')]
|
||||
|
||||
def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100):
|
||||
client = self.search(cr, uid, [('vat', '=', name)]+args, limit=limit, context=context)
|
||||
if not client:
|
||||
client = self.search(cr, uid, [('name', 'ilike', '%%%s%%' % name)]+args, limit=limit, context=context)
|
||||
return self.name_get(cr, uid, client, context=context)
|
||||
|
||||
vat_listing_clients()
|
||||
|
||||
@@ -225,4 +237,4 @@ class partner_vat_list(osv.osv_memory):
|
||||
|
||||
partner_vat_list()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -56,7 +56,9 @@ class l10n_be_vat_declaration(osv.osv_memory):
|
||||
user_cmpny = obj_company.name
|
||||
vat_no=obj_company.partner_id.vat
|
||||
if not vat_no:
|
||||
raise wizard.except_wizard(_('Data Insufficient'),_('No VAT Number Associated with Main Company!'))
|
||||
# raise wizard.except_wizard(_('Data Insufficient'),_('No VAT Number Associated with Main Company!'))
|
||||
osv.except_osv(_('Data Insufficient'), _('No VAT Number Associated with Main Company!'))
|
||||
|
||||
|
||||
tax_code_ids = obj_tax_code.search(cr, uid, [], context=context)
|
||||
ctx = context.copy()
|
||||
@@ -65,7 +67,7 @@ class l10n_be_vat_declaration(osv.osv_memory):
|
||||
tax_info = obj_tax_code.read(cr, uid, tax_code_ids, ['code','sum_period'], context=ctx)
|
||||
|
||||
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, country_code =self.pool.get('res.company')._get_default_ad(obj_company.partner_id.address)
|
||||
|
||||
|
||||
year_id = obj_fyear.find(cr, uid)
|
||||
@@ -77,7 +79,7 @@ class l10n_be_vat_declaration(osv.osv_memory):
|
||||
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<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'
|
||||
data_of_file +='\n\t<VATRECORD>\n\t\t<RECNUM>1</RECNUM>\n\t\t<VATNUMBER>'+((vat_no and str(vat_no[2:])) or '')+'</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]
|
||||
@@ -89,7 +91,7 @@ class l10n_be_vat_declaration(osv.osv_memory):
|
||||
else:
|
||||
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<ClientListingNihil>'+ (data['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:
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
##############################################################################
|
||||
import time
|
||||
import base64
|
||||
from tools.translate import _
|
||||
|
||||
from osv import osv, fields
|
||||
|
||||
@@ -34,14 +35,18 @@ class partner_vat_intra(osv.osv_memory):
|
||||
return obj_country.search(cursor, user, [('code', 'in', ['AT', 'BG', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'GB'])])
|
||||
|
||||
_columns = {
|
||||
'trimester': fields.selection( [('1','Jan/Feb/Mar'),
|
||||
('2','Apr/May/Jun'),
|
||||
('3','Jul/Aug/Sep'),
|
||||
('4','Oct/Nov/Dec')],
|
||||
'Trimester Number', required=True, help="It will be the first digit of period"),
|
||||
'period_code': fields.char('Period Code',size = 6,required = True, help = '''This is where you have to set the period code for the intracom declaration using the format: ppyyyy
|
||||
PP can stand for a month: from '01' to '12'.
|
||||
PP can stand for a trimester: '31','32','33','34'
|
||||
The first figure means that it is a trimester,
|
||||
The second figure identify the trimester.
|
||||
PP can stand for a complete fiscal year: '00'.
|
||||
YYYY stands for the year (4 positions).
|
||||
'''
|
||||
),
|
||||
'period_ids': fields.many2many('account.period', 'account_period_rel', 'acc_id', 'period_id', 'Period (s)', help = 'Select here the period(s) you want to include in your intracom declaration'),
|
||||
'test_xml': fields.boolean('Test XML file', help="Sets the XML output as test file"),
|
||||
'mand_id' : fields.char('MandataireId', size=14, required=True, help="This identifies the representative of the sending company. This is a string of 14 characters"),
|
||||
'fyear': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True),
|
||||
'msg': fields.text('File created', size=64, readonly=True),
|
||||
'file_save' : fields.binary('Save File', readonly=True),
|
||||
'country_ids': fields.many2many('res.country', 'vat_country_rel', 'vat_id', 'country_id', 'European Countries'),
|
||||
@@ -60,19 +65,16 @@ class partner_vat_intra(osv.osv_memory):
|
||||
|
||||
data_cmpny = obj_user.browse(cursor, user, user).company_id
|
||||
data = self.read(cursor, user, ids)[0]
|
||||
data_fiscal = obj_fyear.browse(cursor, user, data['fyear'], context=context)
|
||||
|
||||
company_vat = data_cmpny.partner_id.vat
|
||||
if not company_vat:
|
||||
raise osv.except_osv(_('Data Insufficient'),_('No VAT Number Associated with Main Company!'))
|
||||
|
||||
seq_controlref = obj_sequence.get(cursor, user, 'controlref')
|
||||
seq_declarantnum = obj_sequence.get(cursor, user, 'declarantnum')
|
||||
cref = company_vat + seq_controlref
|
||||
dnum = cref + seq_declarantnum
|
||||
if len(data_fiscal.date_start.split('-')[0]) < 4:
|
||||
raise osv.except_osv(_('Data Insufficient'),_('Trimester year should be length of 4 digits!'))
|
||||
period_trimester = data['trimester'] + data_fiscal.date_start.split('-')[0]
|
||||
cref = company_vat[2:] + seq_controlref[-4:]
|
||||
dnum = cref + seq_declarantnum[-5:]
|
||||
if len(data['form']['period_code']) != 6:
|
||||
raise wizard.except_wizard(_('Wrong Period Code'), _('The period code you entered is not valid.'))
|
||||
|
||||
street = zip_city = country = ''
|
||||
addr = obj_partner.address_get(cursor, user, [data_cmpny.partner_id.id], ['invoice'])
|
||||
@@ -92,15 +94,11 @@ class partner_vat_intra(osv.osv_memory):
|
||||
sender_date = time.strftime('%Y-%m-%d')
|
||||
data_file = '<?xml version="1.0"?>\n<VatIntra xmlns="http://www.minfin.fgov.be/VatIntra" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" RecipientId="VAT-ADMIN" SenderId="' + str(company_vat) + '"'
|
||||
data_file +=' ControlRef="' + cref + '" MandataireId="' + data['mand_id'] + '" SenderDate="'+ str(sender_date)+ '"'
|
||||
if data['test_xml']:
|
||||
data_file += ' Test="1"'
|
||||
data_file += ' VersionTech="1.2">'
|
||||
data_file += ' VersionTech="1.3">'
|
||||
data_file +='\n\t<AgentRepr DecNumber="1">\n\t\t<CompanyInfo>\n\t\t\t<VATNum>' + str(company_vat)+'</VATNum>\n\t\t\t<Name>'+str(data_cmpny.name)+'</Name>\n\t\t\t<Street>'+ str(street) +'</Street>\n\t\t\t<CityAndZipCode>'+ str(zip_city) +'</CityAndZipCode>'
|
||||
data_file +='\n\t\t\t<Country>' + str(country) +'</Country>\n\t\t</CompanyInfo>\n\t</AgentRepr>'
|
||||
|
||||
data_comp ='\n\t\t<CompanyInfo>\n\t\t\t<VATNum>'+str(company_vat)+'</VATNum>\n\t\t\t<Name>'+str(data_cmpny.name)+'</Name>\n\t\t\t<Street>'+ str(street) +'</Street>\n\t\t\t<CityAndZipCode>'+ str(zip_city) +'</CityAndZipCode>\n\t\t\t<Country>'+ str(country) +'</Country>\n\t\t</CompanyInfo>'
|
||||
data_period = '\n\t\t<Period>'+ str(period_trimester) +'</Period>' #trimester
|
||||
|
||||
data_comp ='\n\t\t<CompanyInfo>\n\t\t\t<VATNum>'+str(company_vat[2:])+'</VATNum>\n\t\t\t<Name>'+str(data_cmpny.name)+'</Name>\n\t\t\t<Street>'+ str(street) +'</Street>\n\t\t\t<CityAndZipCode>'+ str(zip_city) +'</CityAndZipCode>\n\t\t\t<Country>'+ str(country) +'</Country>\n\t\t</CompanyInfo>'
|
||||
data_period = '\n\t\t<Period>'+ data['period_code'] +'</Period>' #trimester
|
||||
error_message = []
|
||||
seq = 0
|
||||
amount_sum = 0
|
||||
@@ -110,85 +108,23 @@ class partner_vat_intra(osv.osv_memory):
|
||||
|
||||
nb_period = len(data_fiscal.period_ids)
|
||||
fiscal_periods = data_fiscal.period_ids
|
||||
|
||||
if data['trimester'] == '1':
|
||||
if nb_period == 12:
|
||||
start_date = fiscal_periods[0].date_start
|
||||
end_date = fiscal_periods[2].date_stop
|
||||
elif nb_period == 4:
|
||||
start_date = fiscal_periods[0].date_start
|
||||
end_date = fiscal_periods[0].date_stop
|
||||
elif data['trimester'] == '2':
|
||||
if nb_period == 12:
|
||||
start_date = fiscal_periods[3].date_start
|
||||
end_date = fiscal_periods[5].date_stop
|
||||
elif nb_period == 4:
|
||||
start_date = fiscal_periods[1].date_start
|
||||
end_date = fiscal_periods[1].date_stop
|
||||
elif data['trimester'] == '3':
|
||||
if nb_period == 12:
|
||||
start_date = fiscal_periods[6].date_start
|
||||
end_date = fiscal_periods[8].date_stop
|
||||
elif nb_period == 4:
|
||||
start_date = fiscal_periods[2].date_start
|
||||
end_date = fiscal_periods[2].date_stop
|
||||
elif data['trimester'] == '4':
|
||||
if nb_period == 12:
|
||||
start_date = fiscal_periods[9].date_start
|
||||
end_date = fiscal_periods[11].date_stop
|
||||
elif nb_period == 4:
|
||||
start_date = fiscal_periods[3].date_start
|
||||
end_date = fiscal_periods[3].date_stop
|
||||
|
||||
period = "to_date('" + str(start_date) + "','yyyy-mm-dd') and to_date('" + str(end_date) +"','yyyy-mm-dd')"
|
||||
record = {}
|
||||
|
||||
for p_id in p_id_list:
|
||||
list_partner = []
|
||||
partner = obj_partner.browse(cursor, user, p_id, context=context)
|
||||
go_ahead = False
|
||||
country_code = ''
|
||||
for ads in partner.address:
|
||||
if ads.type == 'default' and (ads.country_id and ads.country_id.id in data['country_ids']):
|
||||
go_ahead = True
|
||||
country_code = ads.country_id.code
|
||||
break
|
||||
if not go_ahead:
|
||||
continue
|
||||
|
||||
cursor.execute('select sum(debit)-sum(credit) as amount from account_move_line l left join account_account a on (l.account_id=a.id) where a.type in ('"'receivable'"') and l.partner_id=%%s and l.date between %s' % (period,), (p_id,))
|
||||
res = cursor.dictfetchall()
|
||||
list_partner.append(res[0]['amount'])
|
||||
list_partner.append('T') #partner.ref ...should be check
|
||||
list_partner.append(partner.vat)
|
||||
list_partner.append(country_code)
|
||||
#...deprecated...
|
||||
# addr = pool.get('res.partner').address_get(cr, uid, [partner.id], ['invoice'])
|
||||
# if addr.get('invoice',False):
|
||||
# ads = pool.get('res.partner.address').browse(cr,uid,[addr['invoice']])[0]
|
||||
#
|
||||
# if ads.country_id:
|
||||
# code_country = ads.country_id.code
|
||||
# list_partner.append(code_country)
|
||||
# else:
|
||||
# error_message.append('Data Insufficient! : '+ 'The Partner "'+partner.name + '"'' has no country associated with its Invoice address!')
|
||||
# if len(list_partner)<4:
|
||||
# list_partner.append('')
|
||||
# error_message.append('Data Insufficient! : '+ 'The Partner "'+partner.name + '"'' has no Invoice address!')
|
||||
# list_partner.append(code_country or 'not avail')
|
||||
record[p_id] = list_partner
|
||||
|
||||
if len(error_message):
|
||||
data['msg'] = 'Exception : \n' +'-'*50+'\n'+ '\n'.join(error_message)
|
||||
return data['msg']
|
||||
list_partner = []
|
||||
data_clientinfo = ''
|
||||
cr.execute('''SELECT l.partner_id AS partner_id, p.vat AS vat, t.code AS intra_code, SUM(l.tax_amount) AS amount
|
||||
FROM account_move_line l
|
||||
LEFT JOIN account_tax_code t ON (l.tax_code_id = t.id)
|
||||
LEFT JOIN res_partner p ON (l.partner_id = p.id)
|
||||
WHERE t.code IN ('44a','44b','88')
|
||||
AND l.period_id IN %s
|
||||
GROUP BY l.partner_id, p.vat, t.code''', (tuple(data['form']['period_ids'][0][2]), ))
|
||||
for row in cr.dictfetchall():
|
||||
|
||||
for r in record:
|
||||
seq += 1
|
||||
amt = record[r][0] or 0
|
||||
amt = row['amount'] or 0
|
||||
amt = int(amt * 100)
|
||||
amount_sum += amt
|
||||
data_clientinfo +='\n\t\t<ClientList SequenceNum="'+str(seq)+'">\n\t\t\t<CompanyInfo>\n\t\t\t\t<VATNum>'+record[r][2] +'</VATNum>\n\t\t\t\t<Country>'+record[r][3] +'</Country>\n\t\t\t</CompanyInfo>\n\t\t\t<Amount>'+str(amt) +'</Amount>\n\t\t\t<Period>'+str(period_trimester) +'</Period>\n\t\t\t<Code>'+str(record[r][1]) +'</Code>\n\t\t</ClientList>'
|
||||
intra_code = row['intra_code'] == '88' and 'L' or (row['intra_code'] == '44b' and 'T' or (row['intra_code'] == '44a' and 'S' or ''))
|
||||
data_clientinfo +='\n\t\t<ClientList SequenceNum="'+str(seq)+'">\n\t\t\t<CompanyInfo>\n\t\t\t\t<VATNum>'+row['vat'][2:] +'</VATNum>\n\t\t\t\t<Country>'+row['vat'][:2] +'</Country>\n\t\t\t</CompanyInfo>\n\t\t\t<Amount>'+str(amt) +'</Amount>\n\t\t\t<Code>'+str(intra_code) +'</Code>\n\t\t</ClientList>'
|
||||
amount_sum = int(amount_sum)
|
||||
data_decl = '\n\t<DeclarantList SequenceNum="1" DeclarantNum="'+ dnum + '" ClientNbr="'+ str(seq) +'" AmountSum="'+ str(amount_sum) +'" >'
|
||||
data_file += str(data_decl) + str(data_comp) + str(data_period) + str(data_clientinfo) + '\n\t</DeclarantList>\n</VatIntra>'
|
||||
@@ -199,4 +135,4 @@ class partner_vat_intra(osv.osv_memory):
|
||||
|
||||
partner_vat_intra()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -18,12 +18,11 @@
|
||||
<label string="This wizard will create an XML file for Vat Intra" colspan="4"/>
|
||||
<newline/>
|
||||
<field name="fyear" default_focus="1" />
|
||||
<field name="period_code"/>
|
||||
<newline/>
|
||||
<field name="period_ids"/>
|
||||
<newline/>
|
||||
<field name="mand_id"/>
|
||||
<newline/>
|
||||
<field name="trimester"/>
|
||||
<newline/>
|
||||
<field name="test_xml"/>
|
||||
<newline/>
|
||||
<button colspan="4" name="create_xml" string="Create XML" type="object" icon="gtk-execute"/>
|
||||
<separator colspan="4"/>
|
||||
@@ -59,4 +58,4 @@
|
||||
id="l10_be_vat_intra"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user