Amit Dodiya (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/5.0-opw-381491-ado into 
lp:openobject-addons/5.0.

Requested reviews:
  nel (nel-tinyerp)
  Naresh(OpenERP) (nch-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/5.0-opw-381491-ado/+merge/91030

Hello,

Improve the Vat_List.xml file creation from wizard as per the new VAT format.

Thanks,
Amit
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/5.0-opw-381491-ado/+merge/91030
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/5.0-opw-381491-ado.
=== modified file 'l10n_be/company.py'
--- l10n_be/company.py	2010-04-06 09:41:18 +0000
+++ l10n_be/company.py	2012-02-01 09:27:19 +0000
@@ -39,7 +39,9 @@
                     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
+                email = ads.email or ""
+                phone = ads.phone or ""
+        return email, phone, city, post_code, address, country_code
 res_company()
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'l10n_be/wizard/account_vat_declaration.py'
--- l10n_be/wizard/account_vat_declaration.py	2010-08-23 13:47:14 +0000
+++ l10n_be/wizard/account_vat_declaration.py	2012-02-01 09:27:19 +0000
@@ -28,18 +28,37 @@
 from tools.translate import _
 
 form_fyear = """<?xml version="1.0"?>
-<form string="Select Period">
-    <field name="period" />
-    <field name="ask_resitution"/>
-    <field name="ask_payment"/>
-    <field name="client_nihil"/>
-</form>"""
+            <form string="Periodical VAT Declaration">
+                <group>
+                    <group colspan="4">
+                        <separator string="Declare Periodical VAT" colspan="4"/><newline/>
+                        <field name="vat_declarations_nbr"/>
+                        <field name="period"/>
+                        <field name="identification_type"/>
+                        <field name="other" attrs="{'invisible':[('identification_type','!=','other')], 'required':[('identification_type','=','other')]}"/>
+                        <field name="tax_code_id" string="Company" groups="base.group_multi_company"/>
+                        <newline/>
+                        <field name="ask_resitution"/>
+                        <field name="ask_payment"/>
+                        <field name="client_nihil" string="Is Last Declaration"/><label/>
+                    </group>
+                        <group colspan="4">
+                        <separator string="Comments" colspan="4"/>
+                        <field colspan="4" name="comments" nolabel="1"/>
+                    </group>
+                </group>
+            </form>"""
 
 fields_fyear = {
+    'vat_declarations_nbr': {'string': 'VAT Declaration Number', 'type': 'integer', 'required': True, 'default': 0},
     'period': {'string': 'Period', 'type': 'many2one', 'relation': 'account.period', 'required': True,},
     'ask_resitution': {'type': 'boolean', 'string': 'Ask Restitution',},
     'ask_payment': {'type': 'boolean', 'string': 'Ask Payment',},
     'client_nihil': {'type': 'boolean', 'string': 'Last Declaration of Entreprise', 'help': 'Thick this case only if it concerns only the last statement on the civil or cessation of activity'},
+    'identification_type':{'string':"Identification Type ",'type':'selection','selection':[('tin','TIN'), ('nvat','NVAT'), ('other','Other')], 'default': 'tin'},
+    'other': {'string': 'QLF', 'type': 'text', 'size': 64},
+    'tax_code_id': {'string': 'Company', 'type': 'many2one', 'relation': 'account.tax.code', 'required': True},
+    'comments': {'string': 'Comments', 'type': 'text', 'size' : 64},
 }
 
 form = """<?xml version="1.0"?>
@@ -73,48 +92,113 @@
         ctx = context.copy()
         ctx['period_id'] = data['form']['period'] #added context here
         tax_info = pool_obj.get('account.tax.code').read(cr,uid,tax_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)
+        
+        issued_by = vat_no[:2] 
+        comments = data['form']['comments'] or ''
+        type = data['form']['identification_type'] or ''
+        other = data['form']['other'] or ''
+        address = email = phone= post_code = city = country_code = ''
+
+        email, phone, city, post_code, address, country_code = pooler.get_pool(cr.dbname).get('res.company')._get_default_ad(obj_company.partner_id.address)
 
         obj_fyear = pool_obj.get('account.fiscalyear')
         year_id = obj_fyear.find(cr, uid)
         
         account_period=pool_obj.get('account.period').browse(cr, uid, data['form']['period'])
         period_code = account_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-16.xml">'
-        data_of_file +='\n\t<DECLARER>\n\t\t<VATNUMBER>'+str(vat_no)+'</VATNUMBER>\n\t\t<NAME>'+ 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'
-
         starting_month = account_period.date_start[5:7]
         ending_month = account_period.date_stop[5:7]
+        quarter = str(((int(starting_month) - 1) / 3) + 1)
+
+        send_ref = str(obj_company.partner_id.id) + str(account_period.date_start[5:7]) + str(account_period.date_stop[:4])
+        
+        file_data = {
+                        'vat_declarations_nbr': str(data['form']['vat_declarations_nbr']),
+                        'type': type,
+                        '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,
+                        'send_ref': send_ref,
+                        'quarter': quarter,
+                        'month': starting_month,
+                        'year': str(account_period.date_stop[:4]),
+                        'client_nihil': (data['form']['client_nihil'] and 'YES' or 'NO'),
+                        'ask_restitution': (data['form']['ask_resitution'] and 'YES' or 'NO'),
+                        'ask_payment': (data['form']['ask_payment'] and 'YES' or 'NO'),
+                        'comments': comments,
+                     }
+
+        data_of_file="""<?xml version="1.0"?><VATConsignment xmlns="http://www.minfin.fgov.be/VATConsignment"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; VATDeclarationsNbr="%(vat_declarations_nbr)s">
+                        <Representative>
+                            <RepresentativeID identificationType="%(type)s" issuedBy="%(issued_by)s" otherQlf="%(other)s">%(vat_no)s</RepresentativeID>
+                            <Name>%(cmpny_name)s</Name>
+                            <Street>%(address)s</Street>
+                            <PostCode>%(post_code)s</PostCode>
+                            <City>%(city)s</City>
+                            <CountryCode>%(country_code)s</CountryCode>
+                            <EmailAddress>%(email)s</EmailAddress>
+                            <Phone>%(phone)s</Phone>
+                        </Representative>
+                        <RepresentativeReference></RepresentativeReference>
+                        <VATDeclaration SequenceNumber="1" DeclarantReference="%(send_ref)s">
+                        <ReplacedVATDeclaration></ReplacedVATDeclaration>
+                        <Declarant>
+                            <VATNUMBER xmlns="http://www.minfin.fgov.be/InputCommon";>%(only_vat)s</VATNUMBER>
+                            <Name>%(cmpny_name)s</Name>
+                            <Street>%(address)s</Street>
+                            <PostCode>%(post_code)s</PostCode>
+                            <City>%(city)s</City>
+                            <CountryCode>%(country_code)s</CountryCode>
+                            <EmailAddress>%(email)s</EmailAddress>
+                            <Phone>%(phone)s</Phone>
+                        </Declarant>
+                        <Period>""" % (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>'+quarter+'</QUARTER>\n\t\t\t'
+            data_of_file += '\t\t<Quarter>%(quarter)s</Quarter>\n\t\t' % (file_data)
         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<DATA>\n\t\t\t<DATA_ELEM>'
+            data_of_file += '\t\t<Month>%(month)s</Month>\n\t\t' % (file_data)
+        data_of_file += '\t<Year>%(year)s</Year>' % (file_data)
+        data_of_file += '\n\t\t</Period>\n'
+        data_of_file += '\t\t<Data>\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'] == '71-72':
-                    item['code']='71'
+                if item['code'] == 'VI':
+                    if item['sum_period'] >= 0:
+                        item['code'] = '71'
+                    else:
+                        item['code'] = '72'
                 if item['code'] in list_of_tags:
-                    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'])) +'>'
+                    cases_list.append(item)
+        cases_list.sort()
+        for item in cases_list:
+            grid_amount_data = {
+                    'code': str(int(item['code'])),
+                    'amount': str(abs(int(round(item['sum_period']*100)))),
+                    }
+            data_of_file += '\n\t\t\t<Amount GridNumber="%(code)s">%(amount)s</Amount''>' % (grid_amount_data)
 
-        data_of_file +='\n\t\t\t</DATA_ELEM>\n\t\t</DATA>\n\t</VATRECORD>\n</VATSENDING>'
+        data_of_file += '\n\t\t</Data>'
+        data_of_file += '\n\t\t<ClientListingNihil>%(client_nihil)s</ClientListingNihil>' % (file_data)
+        data_of_file += '\n\t\t<Ask Restitution="%(ask_restitution)s" Payment="%(ask_payment)s"/>' % (file_data)
+        data_of_file += '\n\t\t<FileAttachment>''</FileAttachment>'
+        data_of_file += '\n\t\t<Comment>%(comments)s</Comment>' % (file_data)
+        data_of_file += '\n\t</VATDeclaration> \n</VATConsignment>'
         data['form']['msg']='Save the File with '".xml"' extension.'
         data['form']['file_save'] = base64.encodestring(data_of_file.encode('utf8'))
         return data['form']

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to