~openerp-commiter/openobject-addons/5.0-opw-4298-dhs

« back to all changes in this revision

Viewing changes to l10n_be/wizard/account_vat_declaration.py

  • Committer: qdp
  • Date: 2009-02-03 14:03:11 UTC
  • mto: (2171.3.2 addons_trunk)
  • mto: This revision was merged to the branch mainline in revision 2179.
  • Revision ID: qdp@tinyerp.com-20090203140311-74erq47phor2l5q3
[FIX] bgufixed the 2 wizards of l10n_be 
        -vat_subjected wasn't take in considearation in vat_linting
        -wrong value was filled for <MONTH> tag in vat_declaration
+
[IMP] improved the vat_declaration wizard in oorder to:
        -work for quarter based accountings
        -have a generic solution for zip_id that is added in cci_partner

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import pooler
26
26
import base64
27
27
 
 
28
from tools.translate import _
 
29
 
28
30
form_fyear = """<?xml version="1.0"?>
29
31
<form string="Select Period">
30
32
    <field name="period" />
48
50
        'readonly': True,},
49
51
}
50
52
 
 
53
 
51
54
class wizard_vat_declaration(wizard.interface):
52
55
 
53
56
    def _create_xml(self, cr, uid, data, context):
58
61
        user_cmpny = obj_company.name
59
62
        vat_no=obj_company.partner_id.vat
60
63
        if not vat_no:
61
 
            raise wizard.except_wizard('Data Insufficient','No VAT Number Associated with Main Company!')
 
64
            raise wizard.except_wizard(_('Data Insufficient'),_('No VAT Number Associated with Main Company!'))
62
65
 
63
66
        tax_ids = pool_obj.get('account.tax.code').search(cr,uid,[])
64
67
        ctx = context.copy()
69
72
        if not obj_company.partner_id.address:
70
73
                address=post_code=city=''
71
74
 
72
 
        for ads in obj_company.partner_id.address:
73
 
                if ads.type=='default':
74
 
                    if ads.zip_id:
75
 
                        city=ads.zip_id.city
76
 
                        post_code=ads.zip_id.name
77
 
                    if ads.street:
78
 
                        address=ads.street
79
 
                    if ads.street2:
80
 
                        address +=ads.street2
 
75
        city, post_code, address = pooler.get_pool(cr.dbname).get('res.company')._get_default_ad(obj_company.partner_id.address)
81
76
 
82
77
        obj_fyear = pool_obj.get('account.fiscalyear')
83
78
        year_id = obj_fyear.find(cr, uid)
84
79
        current_year = obj_fyear.browse(cr,uid,year_id).name
85
 
        month=time.strftime('%m')
86
80
 
87
81
        period_code = pool_obj.get('account.period').browse(cr, uid, data['form']['period']).code
 
82
 
88
83
        send_ref = user_cmpny
89
84
        if period_code:
90
85
            send_ref = send_ref + period_code
91
86
 
92
87
        data_of_file='<?xml version="1.0"?>\n<VATSENDING xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="MultiDeclarationTVA-NoSignature-14.xml">'
93
 
        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>'+str(address)+'</ADDRESS>'
94
 
        data_of_file +='\n\t\t<POSTCODE>'+str(post_code)+'</POSTCODE>\n\t\t<CITY>'+str(city)+'</CITY>\n\t\t<SENDINGREFERENCE>'+send_ref+'</SENDINGREFERENCE>\n\t</DECLARER>'
95
 
        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<MONTH>'+str(month)+'</MONTH>\n\t\t\t<YEAR>'+str(current_year[-4:])+'</YEAR>\n\t\t</DPERIODE>\n\t\t<ASK RESTITUTION="NO" PAYMENT="NO"/>'
 
88
        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>'
 
89
        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>'
 
90
        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
 
 
92
        starting_month = pool_obj.get('account.period').browse(cr, uid, data['form']['period']).date_start[5:7]
 
93
        ending_month = pool_obj.get('account.period').browse(cr, uid, data['form']['period']).date_stop[5:7]
 
94
        if starting_month != ending_month:
 
95
            #starting month and ending month of selected period are not the same 
 
96
            #it means that the accounting isn't based on periods of 1 month but on quarters
 
97
            quarter = str(((int(starting_month) - 1) / 3) + 1)
 
98
            data_of_file += '<QUARTER>'+quarter+'</QUARTER>\n\t\t\t'
 
99
        else:
 
100
            data_of_file += '<MONTH>'+starting_month+'</MONTH>\n\t\t\t'
 
101
        data_of_file += '<YEAR>'+str(current_year[-4:])+'</YEAR>\n\t\t</DPERIODE>\n\t\t<ASK RESTITUTION="NO" PAYMENT="NO"/>'
96
102
        data_of_file +='\n\t\t<DATA>\n\t\t\t<DATA_ELEM>'
97
103
 
98
104
        for item in tax_info: