diff --git a/addons/l10n_be/company.py b/addons/l10n_be/company.py index 8a53b029fa7..118696ec9f6 100644 --- a/addons/l10n_be/company.py +++ b/addons/l10n_be/company.py @@ -25,7 +25,7 @@ class res_company(osv.osv): _description = 'Company' def _get_default_ad(self, addresses): - city = post_code = address = country_code = "" + name = email = phone = city = post_code = address = country_code = "" for ads in addresses: if ads.type == 'default': city = ads.city or "" @@ -36,7 +36,10 @@ class res_company(osv.osv): address += " " + ads.street2 if ads.country_id: country_code = ads.country_id and ads.country_id.code or "" - return city, post_code, address, country_code + name = ads.name or "" + email = ads.email or "" + phone = ads.phone or "" + return name, email, phone, city, post_code, address, country_code res_company() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py b/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py index 138f6f668f8..b666006e782 100644 --- a/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py +++ b/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py @@ -42,17 +42,32 @@ class l10n_be_vat_declaration(osv.osv_memory): _columns = { 'name': fields.char('File Name', size=32), 'period_id': fields.many2one('account.period','Period', required=True), - 'tax_code_id': fields.many2one('account.tax.code', 'Tax Code', domain=[('parent_id', '=', False)]), + 'tax_code_id': fields.many2one('account.tax.code', 'Tax Code', domain=[('parent_id', '=', False)], help="Keep empty to use the user's company", required=True), 'msg': fields.text('File created', size=64, readonly=True), 'file_save': fields.binary('Save File'), 'ask_restitution': fields.boolean('Ask Restitution',help='It indicates whether a resitution is to made or not?'), 'ask_payment': fields.boolean('Ask Payment',help='It indicates whether a payment is to made or not?'), 'client_nihil': fields.boolean('Last Declaration of Enterprise',help='Tick this case only if it concerns only the last statement on the civil or cessation of activity'), + 'vat_declarations_nbr': fields.integer('VAT Declaration Number', help="Number of periodic VAT returns in the shipment"), + 'comments': fields.text('Comments'), + 'identification_type': fields.selection([('tin','TIN'), ('nvat','NVAT'), ('other','Other')], 'Identification Type', required=True), + 'other': fields.char('Other Qlf', size=16, help="Description of a Identification Type"), } + + def _get_tax_code(self, cr, uid, context=None): + obj_tax_code = self.pool.get('account.tax.code') + obj_user = self.pool.get('res.users') + company_id = obj_user.browse(cr, uid, uid, context=context).company_id.id + tax_code_ids = obj_tax_code.search(cr, uid, [('company_id', '=', company_id), ('parent_id', '=', False)], context=context) + return tax_code_ids and tax_code_ids[0] or False + _defaults = { 'msg': 'Save the File with '".xml"' extension.', 'file_save': _get_xml_data, 'name': 'vat_declaration.xml', + 'identification_type': 'nvat', + 'vat_declarations_nbr': 1, + 'tax_code_id': _get_tax_code, } def create_xml(self, cr, uid, ids, context=None): @@ -74,44 +89,99 @@ class l10n_be_vat_declaration(osv.osv_memory): if not vat_no: raise osv.except_osv(_('Data Insufficient'), _('No VAT Number Associated with Main Company!')) vat_no = vat_no.replace(' ','').upper() + vat = vat_no[2:] - tax_code_ids = obj_tax_code.search(cr, uid, [], context=context) + tax_code_ids = obj_tax_code.search(cr, uid, [('parent_id','child_of',data_tax.tax_code_id.id), ('company_id','=',obj_company.id)], context=context) ctx = context.copy() data = self.read(cr, uid, ids)[0] ctx['period_id'] = data['period_id'][0] #added context here 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 = self.pool.get('res.company')._get_default_ad(obj_company.partner_id.address) + name = email = phone = address = post_code = city = country_code = '' + name, email, phone, city, post_code, address, country_code = self.pool.get('res.company')._get_default_ad(obj_company.partner_id.address) account_period = obj_acc_period.browse(cr, uid, data['period_id'][0], context=context) - + issued_by = vat_no[:2] + comments = data['comments'] or '' + type = data['identification_type'] or '' + other = data['other'] or '' + send_ref = str(obj_company.partner_id.id) + str(account_period.date_start[5:7]) + str(account_period.date_stop[:4]) - data_of_file = '\n' - data_of_file +='\n\t\n\t\t'+str(vat_no)+'\n\t\t'+ obj_company.name +'\n\t\t
'+address+'
' - data_of_file +='\n\t\t'+post_code+'\n\t\t'+city+'\n\t\t'+country_code+'\n\t\t'+send_ref+'\n\t
' - data_of_file +='\n\t\n\t\t1\n\t\t'+((vat_no and str(vat_no[2:])) or '')+'\n\t\t\n\t\t\t' - + starting_month = account_period.date_start[5:7] ending_month = account_period.date_stop[5:7] + quarter = str(((int(starting_month) - 1) / 3) + 1) + + if not email: + raise osv.except_osv(_('Data Insufficient!'),_('No email address associated with the company.')) + if not phone: + raise osv.except_osv(_('Data Insufficient!'),_('No phone associated with the company.')) + file_data = { + 'vat_declarations_nbr': str(data['vat_declarations_nbr']), + 'type': type.upper(), + 'issued_by': issued_by, + 'other': other, + 'vat_no': vat_no, + 'only_vat': vat_no[2:], + 'cmpny_name': obj_company.name, + 'address': address, + 'post_code': post_code, + 'city': city, + 'country_code': country_code, + 'email': email, + 'phone': phone.replace('.','').replace('/','').replace('(','').replace(')','').replace(' ',''), + 'send_ref': send_ref, + 'quarter': quarter, + 'month': starting_month, + 'year': str(account_period.date_stop[:4]), + 'client_nihil': (data['client_nihil'] and 'YES' or 'NO'), + 'ask_restitution': (data['ask_restitution'] and 'YES' or 'NO'), + 'ask_payment': (data['ask_payment'] and 'YES' or 'NO'), + 'comments': comments, + } + + data_of_file = """ + + + %(only_vat)s + %(cmpny_name)s + %(address)s + %(post_code)s + %(city)s + %(country_code)s + %(email)s + %(phone)s + + + + %(only_vat)s + %(cmpny_name)s + %(address)s + %(post_code)s + %(city)s + %(country_code)s + %(email)s + %(phone)s + + + """ % (file_data) + 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+'\n\t\t\t' + data_of_file += '\t\t%(quarter)s\n\t\t' % (file_data) else: - data_of_file += ''+starting_month+'\n\t\t\t' - data_of_file += '' + str(account_period.date_stop[:4]) + '\n\t\t\n' - data_of_file += '\t\t' - data_of_file += '\n\t\t'+ (data['client_nihil'] and 'YES' or 'NO') +'' - data_of_file +='\n\t\t\n\t\t\t' - + data_of_file += '\t\t%(month)s\n\t\t' % (file_data) + data_of_file += '\t%(year)s' % (file_data) + data_of_file += '\n\t\t\n' + + data_of_file += '\t\t\t' cases_list = [] for item in tax_info: if item['code'] == '91' and ending_month != 12: #the tax code 91 can only be send for the declaration of December continue - if item['code']: + if item['code'] and item['sum_period']: if item['code'] == 'VI': if item['sum_period'] >= 0: item['code'] = '71' @@ -121,9 +191,17 @@ class l10n_be_vat_declaration(osv.osv_memory): cases_list.append(item) cases_list.sort() for item in cases_list: - data_of_file +='\n\t\t\t\t' + str(abs(int(round(item['sum_period']*100)))) + '' - - data_of_file += '\n\t\t\t\n\t\t\n\t\n
' + grid_amount_data = { + 'code': str(int(item['code'])), + 'amount': str(abs(item['sum_period'])), + } + data_of_file += '\n\t\t\t%(amount)s' % (grid_amount_data) + + data_of_file += '\n\t\t' + data_of_file += '\n\t\t%(client_nihil)s' % (file_data) + data_of_file += '\n\t\t' % (file_data) + data_of_file += '\n\t\t%(comments)s' % (file_data) + data_of_file += '\n\t \n' model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_vat_save')], context=context) resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] context['file_save'] = data_of_file diff --git a/addons/l10n_be/wizard/l10n_be_account_vat_declaration_view.xml b/addons/l10n_be/wizard/l10n_be_account_vat_declaration_view.xml index afe7328061e..f0f55427f65 100644 --- a/addons/l10n_be/wizard/l10n_be_account_vat_declaration_view.xml +++ b/addons/l10n_be/wizard/l10n_be_account_vat_declaration_view.xml @@ -2,60 +2,66 @@ - + - + Vat Declaraion l1on_be.vat.declaration form -
- - - - - - - - - - - - - - - -