added wizard on l10n_be for vat listing and declation
bzr revid: mra@tinyerp.com-20080723102942-eztv9fg66w3x1248
This commit is contained in:
parent
413ff31a80
commit
4adced1f1b
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
|
||||
#
|
||||
# Sequences for controlref will be used in wizard for "Listing of VAT Customers"..in creating xml file
|
||||
#
|
||||
<record model="ir.sequence.type" id="seq_type_controlref">
|
||||
<field name="name">Controlref</field>
|
||||
<field name="code">controlref</field>
|
||||
</record>
|
||||
<record model="ir.sequence" id="seq_controlref">
|
||||
<field name="name">Controlref</field>
|
||||
<field name="code">controlref</field>
|
||||
<field name="padding">4</field>
|
||||
</record>
|
||||
|
||||
#
|
||||
# Sequences for declarantnum will be used in wizard for "Listing of VAT Customers"..in creating xml file
|
||||
#
|
||||
<record model="ir.sequence.type" id="seq_type_declarantnum">
|
||||
<field name="name">Declarantnum</field>
|
||||
<field name="code">declarantnum</field>
|
||||
</record>
|
||||
<record model="ir.sequence" id="seq_declarantnum">
|
||||
<field name="name">Declarantnum</field>
|
||||
<field name="code">declarantnum</field>
|
||||
<field name="padding">5</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</terp>
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<wizard
|
||||
string="Enlist Vat Details"
|
||||
model="res.partner"
|
||||
name="list.vat.detail"
|
||||
menu="False"
|
||||
id="partner.wizard_vat"/>
|
||||
<menuitem
|
||||
name="Financial Management/Reporting/Listing of VAT Customers"
|
||||
action="partner.wizard_vat"
|
||||
type="wizard"
|
||||
id="partner.wizard_vat_menu"/>
|
||||
<wizard
|
||||
string="VAT Declaration"
|
||||
name="wizard.account.vat.declaration"
|
||||
menu="False"
|
||||
id="account.wizard_vat_declaration"/>
|
||||
|
||||
<menuitem
|
||||
name="Financial Management/Periodical Processing/Taxes/VAT Declaration"
|
||||
action="account.wizard_vat_declaration"
|
||||
type="wizard"
|
||||
id="account_wizard_vat_declaration"/>
|
||||
|
||||
</data>
|
||||
</terp>
|
|
@ -0,0 +1,2 @@
|
|||
import account_vat_declaration
|
||||
import partner_vat_listing
|
|
@ -0,0 +1,101 @@
|
|||
import wizard
|
||||
import time
|
||||
import datetime
|
||||
import pooler
|
||||
import base64
|
||||
|
||||
form_fyear = """<?xml version="1.0"?>
|
||||
<form string="Select Period">
|
||||
<field name="period" />
|
||||
</form>"""
|
||||
|
||||
fields_fyear = {
|
||||
'period': {'string': 'Period', 'type': 'many2one', 'relation': 'account.period', 'required': True,},
|
||||
}
|
||||
|
||||
form = """<?xml version="1.0"?>
|
||||
<form string="Notification">
|
||||
<separator string="XML Flie has been Created." colspan="4"/>
|
||||
<field name="msg" colspan="4" nolabel="1"/>
|
||||
<field name="file_save" />
|
||||
</form>"""
|
||||
|
||||
fields = {
|
||||
'msg': {'string':'File created', 'type':'text', 'size':'100','readonly':True},
|
||||
'file_save':{'string': 'Save File',
|
||||
'type': 'binary',
|
||||
'readonly': True,},
|
||||
}
|
||||
|
||||
class wizard_vat_declaration(wizard.interface):
|
||||
|
||||
def _create_xml(self, cr, uid, data, context):
|
||||
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']
|
||||
pool_obj = pooler.get_pool(cr.dbname)
|
||||
#obj_company = pool_obj.get('res.company').browse(cr,uid,1)
|
||||
obj_company = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid).company_id
|
||||
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!')
|
||||
|
||||
tax_ids = pool_obj.get('account.tax.code').search(cr,uid,[])
|
||||
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=''
|
||||
if not obj_company.partner_id.address:
|
||||
address=post_code=city=''
|
||||
|
||||
for ads in obj_company.partner_id.address:
|
||||
if ads.type=='default':
|
||||
if ads.zip_id:
|
||||
city=ads.zip_id.city
|
||||
post_code=ads.zip_id.name
|
||||
if ads.street:
|
||||
address=ads.street
|
||||
if ads.street2:
|
||||
address +=ads.street2
|
||||
|
||||
obj_fyear = pool_obj.get('account.fiscalyear')
|
||||
year_id = obj_fyear.find(cr, uid)
|
||||
current_year = obj_fyear.browse(cr,uid,year_id).name
|
||||
month=time.strftime('%m')
|
||||
|
||||
period_code = pool_obj.get('account.period').browse(cr, uid, data['form']['period']).code
|
||||
send_ref = user_cmpny
|
||||
if period_code:
|
||||
send_ref = send_ref + '-' + period_code
|
||||
|
||||
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>'+str(address)+'</ADDRESS>'
|
||||
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>'
|
||||
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"/>'
|
||||
data_of_file +='\n\t\t<DATA>\n\t\t\t<DATA_ELEM>'
|
||||
|
||||
for item in tax_info:
|
||||
if item['code']:
|
||||
if item['code'] == '71-72':
|
||||
item['code']='71'
|
||||
if item['code'] in list_of_tags:
|
||||
data_of_file +='\n\t\t\t\t<D'+str(int(item['code'])) +'>' + str(int(item['sum_period']*100)) + '</D'+str(int(item['code'])) +'>'
|
||||
|
||||
data_of_file +='\n\t\t\t</DATA_ELEM>\n\t\t</DATA>\n\t</VATRECORD>\n</VATSENDING>'
|
||||
data['form']['msg']='Save the File with '".xml"' extension.'
|
||||
data['form']['file_save']=base64.encodestring(data_of_file)
|
||||
return data['form']
|
||||
|
||||
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {'type':'form', 'arch':form_fyear, 'fields':fields_fyear, 'state':[('end','Cancel'),('go','Create XML')]},
|
||||
},
|
||||
'go': {
|
||||
'actions': [_create_xml],
|
||||
'result': {'type':'form', 'arch':form, 'fields':fields, 'state':[('end','Ok')]},
|
||||
}
|
||||
}
|
||||
|
||||
wizard_vat_declaration('wizard.account.vat.declaration')
|
|
@ -0,0 +1,147 @@
|
|||
import wizard
|
||||
import time
|
||||
import datetime
|
||||
import pooler
|
||||
import base64
|
||||
|
||||
form = """<?xml version="1.0"?>
|
||||
<form string="Select Fiscal Year">
|
||||
<label string="This wizard will create an XML file for Vat details and total invoiced amounts per human entity(Partner)." colspan="4"/>
|
||||
<newline/>
|
||||
<field name="fyear" />
|
||||
<newline/>
|
||||
<field name="mand_id" />
|
||||
<newline/>
|
||||
<field name="test_xml"/>
|
||||
</form>"""
|
||||
|
||||
fields = {
|
||||
'fyear': {'string': 'Fiscal Year', 'type': 'many2one', 'relation': 'account.fiscalyear', 'required': True,},
|
||||
'mand_id':{'string':'MandatarieId','type':'char','size':'30','required': True,},
|
||||
'test_xml': {'string':'Test XML file', 'type':'boolean'},
|
||||
}
|
||||
msg_form = """<?xml version="1.0"?>
|
||||
<form string="Notification">
|
||||
<separator string="XML File has been Created." colspan="4"/>
|
||||
<field name="msg" colspan="4" nolabel="1"/>
|
||||
<field name="file_save" />
|
||||
</form>"""
|
||||
|
||||
msg_fields = {
|
||||
'msg': {'string':'File created', 'type':'text', 'size':'100','readonly':True},
|
||||
'file_save':{'string': 'Save File',
|
||||
'type': 'binary',
|
||||
'readonly': True,},
|
||||
}
|
||||
|
||||
class wizard_vat(wizard.interface):
|
||||
|
||||
def _create_xml(self, cr, uid, data, context):
|
||||
datas=[]
|
||||
# now wizard will use user->company instead of directly company from res.company
|
||||
|
||||
seq_controlref = pooler.get_pool(cr.dbname).get('ir.sequence').get(cr, uid,'controlref')
|
||||
seq_declarantnum = pooler.get_pool(cr.dbname).get('ir.sequence').get(cr, uid,'declarantnum')
|
||||
obj_cmpny = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid).company_id
|
||||
company_vat = obj_cmpny.partner_id.vat #should be check
|
||||
if not company_vat: #if not vat_company:
|
||||
raise wizard.except_wizard('Data Insufficient','No VAT Number Associated with Main Company!')
|
||||
|
||||
cref = company_vat + seq_controlref
|
||||
dnum = cref + seq_declarantnum
|
||||
# obj_company=pooler.get_pool(cr.dbname).get('res.company').browse(cr,uid,1)
|
||||
# vat_company=obj_company.partner_id.vat
|
||||
p_id_list=pooler.get_pool(cr.dbname).get('res.partner').search(cr,uid,[('vat','!=',False)])
|
||||
|
||||
if not p_id_list:
|
||||
raise wizard.except_wizard('Data Insufficient!','No partner has a VAT Number asociated with him.')
|
||||
obj_year=pooler.get_pool(cr.dbname).get('account.fiscalyear').browse(cr,uid,data['form']['fyear'])
|
||||
period="to_date('" + str(obj_year.date_start) + "','yyyy-mm-dd') and to_date('" + str(obj_year.date_stop) +"','yyyy-mm-dd')"
|
||||
|
||||
street=zip_city=country=''
|
||||
if not obj_cmpny.partner_id.address:
|
||||
street=zip_city=country=''
|
||||
|
||||
for ads in obj_cmpny.partner_id.address:
|
||||
if ads.type=='default':
|
||||
if ads.zip_id:
|
||||
zip_city=pooler.get_pool(cr.dbname).get('res.partner.zip').name_get(cr,uid,[ads.zip_id.id])[0][1]
|
||||
if ads.street:
|
||||
street=ads.street
|
||||
if ads.street2:
|
||||
street +=ads.street2
|
||||
if ads.country_id:
|
||||
country=ads.country_id.code
|
||||
|
||||
|
||||
sender_date=time.strftime('%Y-%m-%d')
|
||||
data_file='<?xml version="1.0"?>\n<VatList xmlns="http://www.minfin.fgov.be/VatList" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.minfin.fgov.be/VatList VatList.xml" RecipientId="VAT-ADMIN" SenderId="'+ str(company_vat) + '"'
|
||||
data_file +=' ControlRef="'+ cref + '" MandataireId="'+ data['form']['mand_id'] + '" SenderDate="'+ str(sender_date)+'" VersionTech="1.2">'
|
||||
if data['form']['test_xml']:
|
||||
data_file += '\n<Attribute name="Test" use="optional">\n\t<SimpleType>\n\t\t<Restriction base="string">\n\t\t\t<Enumeration value="0"/>\n\t\t\t<Enumeration value="false"/>\n\t\t</Restriction>\n\t</SimpleType>\n</Attribute>'
|
||||
data_file +='\n<AgentRepr DecNumber="1">\n\t<CompanyInfo>\n\t\t<VATNum>'+str(company_vat)+'</VATNum>\n\t\t<Name>'+str(obj_cmpny.name)+'</Name>\n\t\t<Street>'+ str(street) +'</Street>\n\t\t<CityAndZipCode>'+ str(zip_city) +'</CityAndZipCode>'
|
||||
data_file +='\n\t\t<Country>'+ str(country) +'</Country>\n\t</CompanyInfo>\n</AgentRepr>'
|
||||
data_comp ='\n<CompanyInfo>\n\t<VATNum>'+str(company_vat)+'</VATNum>\n\t<Name>'+str(obj_cmpny.name)+'</Name>\n\t<Street>'+ str(street) +'</Street>\n\t<CityAndZipCode>'+ str(zip_city) +'</CityAndZipCode>\n\t<Country>'+ str(country) +'</Country>\n</CompanyInfo>'
|
||||
data_period ='\n<Period>'+ str(obj_year.name[-4:]) +'</Period>'
|
||||
|
||||
for p_id in p_id_list:
|
||||
record=[] # this holds record per partner
|
||||
obj_partner=pooler.get_pool(cr.dbname).get('res.partner').browse(cr,uid,p_id)
|
||||
cr.execute('select a.type,sum(credit)-sum(debit) from account_move_line l left join account_account a on (l.account_id=a.id) where a.type in ('"'income'"','"'tax'"') and l.partner_id=%d and l.date between %s group by a.type'%(p_id,period))
|
||||
line_info=cr.fetchall()
|
||||
if not line_info:
|
||||
continue
|
||||
|
||||
record.append(obj_partner.vat)
|
||||
for ads in obj_partner.address:
|
||||
if ads.type=='default':
|
||||
if ads.country_id:
|
||||
record.append(ads.country_id.code)
|
||||
else:
|
||||
raise wizard.except_wizard('Data Insufficient!', 'The Partner "'+obj_partner.name + '"'' has no country associated with its default type address!')
|
||||
else:
|
||||
raise wizard.except_wizard('Data Insufficient!', 'The Partner "'+obj_partner.name + '"'' has no default type address!')
|
||||
if len(line_info)==1:
|
||||
if line_info[0][0]=='income':
|
||||
record.append(0.00)
|
||||
record.append(line_info[0][1])
|
||||
else:
|
||||
record.append(line_info[0][1])
|
||||
record.append(0.00)
|
||||
else:
|
||||
for item in line_info:
|
||||
record.append(item[1])
|
||||
datas.append(record)
|
||||
|
||||
seq=0
|
||||
data_clientinfo=''
|
||||
sum_tax=0.00
|
||||
sum_turnover=0.00
|
||||
for line in datas:
|
||||
if line[3]< 250.00:
|
||||
continue
|
||||
seq +=1
|
||||
sum_tax +=line[2]
|
||||
sum_turnover +=line[3]
|
||||
data_clientinfo +='\n<ClientList SequenceNum="'+str(seq)+'">\n\t<CompanyInfo>\n\t\t<VATNum>'+line[0] +'</VATNum>\n\t\t<Country>'+line[1] +'</Country>\n\t</CompanyInfo>\n\t<Amount>'+str(int(line[2] * 100)) +'</Amount>\n\t<TurnOver>'+str(int(line[3] * 100)) +'</TurnOver>\n</ClientList>'
|
||||
|
||||
data_decl ='\n<DeclarantList SequenceNum="1" DeclarantNum="'+ dnum + '" ClientNbr="'+ str(seq) +'" TurnOverSum="'+ str(int(sum_turnover * 100)) +'" TaxSum="'+ str(int(sum_tax * 100)) +'" />'
|
||||
data_file += str(data_decl) + str(data_comp) + str(data_period) + str(data_clientinfo) + '\n</VatList>'
|
||||
|
||||
data['form']['msg']='Save the File with '".xml"' extension.'
|
||||
data['form']['file_save']=base64.encodestring(data_file)
|
||||
return data['form']
|
||||
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {'type':'form', 'arch':form, 'fields':fields, 'state':[('end','Cancel'),('go','Create XML')]},
|
||||
},
|
||||
'go': {
|
||||
'actions': [_create_xml],
|
||||
'result': {'type':'form', 'arch':msg_form, 'fields':msg_fields, 'state':[('end','Ok')]},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
wizard_vat('list.vat.detail')
|
Loading…
Reference in New Issue