~openerp-community/openobject-addons/pheller_address-localization

« back to all changes in this revision

Viewing changes to l10n_be/wizard/account_vat_declaration.py

  • Committer: Stephane Wirtel
  • Date: 2010-04-23 09:30:06 UTC
  • mfrom: (2687.1.8 test-branch)
  • Revision ID: stephane@openerp.com-20100423093006-9kihhixeonlewkuz
[MERGE] lp:~qdp/openobject-addons/5.0-l10nbe-intervat5.1.0-compliancy:2695

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
form_fyear = """<?xml version="1.0"?>
31
31
<form string="Select Period">
32
32
    <field name="period" />
 
33
    <field name="ask_resitution"/>
 
34
    <field name="ask_payment"/>
 
35
    <field name="client_nihil"/>
33
36
</form>"""
34
37
 
35
38
fields_fyear = {
36
39
    'period': {'string': 'Period', 'type': 'many2one', 'relation': 'account.period', 'required': True,},
 
40
    'ask_resitution': {'type': 'boolean', 'string': 'Ask Restitution',},
 
41
    'ask_payment': {'type': 'boolean', 'string': 'Ask Payment',},
 
42
    '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'},
37
43
}
38
44
 
39
45
form = """<?xml version="1.0"?>
54
60
class wizard_vat_declaration(wizard.interface):
55
61
 
56
62
    def _create_xml(self, cr, uid, data, context):
57
 
        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']
 
63
        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']
58
64
        pool_obj = pooler.get_pool(cr.dbname)
59
65
        #obj_company = pool_obj.get('res.company').browse(cr,uid,1)
60
66
        obj_company = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid).company_id
68
74
        ctx['period_id'] = data['form']['period'] #added context here
69
75
        tax_info = pool_obj.get('account.tax.code').read(cr,uid,tax_ids,['code','sum_period'],context=ctx)
70
76
 
71
 
        address=post_code=city=''
72
 
        if not obj_company.partner_id.address:
73
 
                address=post_code=city=''
 
77
        address = post_code = city = country_code = ''
74
78
 
75
 
        city, post_code, address = pooler.get_pool(cr.dbname).get('res.company')._get_default_ad(obj_company.partner_id.address)
 
79
        city, post_code, address, country_code = pooler.get_pool(cr.dbname).get('res.company')._get_default_ad(obj_company.partner_id.address)
76
80
 
77
81
        obj_fyear = pool_obj.get('account.fiscalyear')
78
82
        year_id = obj_fyear.find(cr, uid)
79
83
        
80
84
        account_period=pool_obj.get('account.period').browse(cr, uid, data['form']['period'])
81
 
        current_year = account_period.fiscalyear_id.name
82
85
        period_code = account_period.code
83
86
 
84
 
        send_ref = user_cmpny
85
 
        if period_code:
86
 
            send_ref = send_ref + period_code
 
87
        send_ref = str(obj_company.partner_id.id) + str(account_period.date_start[5:7]) + str(account_period.date_stop[:4])
87
88
 
88
89
        data_of_file='<?xml version="1.0"?>\n<VATSENDING xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="MultiDeclarationTVA-NoSignature-14.xml">'
89
90
        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>'
90
 
        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>'
91
 
        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'
 
91
        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>'
 
92
        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'
92
93
 
93
94
        starting_month = account_period.date_start[5:7]
94
95
        ending_month = account_period.date_stop[5:7]
100
101
        else:
101
102
            data_of_file += '<MONTH>'+starting_month+'</MONTH>\n\t\t\t'
102
103
        data_of_file += '<YEAR>' + str(account_period.date_stop[:4]) + '</YEAR>\n\t\t</DPERIODE>\n\t\t<ASK RESTITUTION="NO" PAYMENT="NO"/>'
 
104
        data_of_file += '\n\t\t<ClientListingNihil>'+ (data['form']['client_nihil'] and 'YES' or 'NO') +'</ClientListingNihil>'
103
105
        data_of_file +='\n\t\t<DATA>\n\t\t\t<DATA_ELEM>'
104
106
 
105
107
        for item in tax_info:
107
109
                if item['code'] == '71-72':
108
110
                    item['code']='71'
109
111
                if item['code'] in list_of_tags:
110
 
                    data_of_file +='\n\t\t\t\t<D'+str(int(item['code'])) +'>' + str(int(item['sum_period']*100)) +  '</D'+str(int(item['code'])) +'>'
 
112
                    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'])) +'>'
111
113
 
112
114
        data_of_file +='\n\t\t\t</DATA_ELEM>\n\t\t</DATA>\n\t</VATRECORD>\n</VATSENDING>'
113
115
        data['form']['msg']='Save the File with '".xml"' extension.'