1 ##############################################################################
3 # Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
5 # WARNING: This program as such is intended to be used by professional
6 # programmers who take the whole responsability of assessing all potential
7 # consequences resulting from its eventual inadequacies and bugs
8 # End users who are looking for a ready-to-use solution with commercial
9 # garantees and support are strongly adviced to contract a Free Software
12 # This program is Free Software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License
14 # as published by the Free Software Foundation; either version 2
15 # of the License, or (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 ##############################################################################
30 from report import report_sxw
32 class account_tax_report(report_sxw.rml_parse):
33 def __init__(self, cr, uid, name, context):
34 super(account_tax_report, self).__init__(cr, uid, name, context)
35 self.localcontext.update({
36 'get_invoice': self.getInvoices,
37 'add_invoice': self.addInvoice,
38 'get_tax': self.getTax,
39 'get_tax_detail' : self.getTaxDetail,
40 'get_retail' : self.getRetailTax,
41 'get_retail_detail' : self.getRetailTaxDetail,
42 'get_local_sale' : self.getLocalSale,
43 'get_retail_sale' : self.getRetailSale,
44 'total_local_sale' : self.getTotalLocalSale,
45 'total_local_tax' : self.getTotalLocalTax,
46 'total_retail_sale' : self.getTotalRetailSale,
47 'total_retail_tax' : self.getTotalRetailTax,
49 'get_period': self.getPeriod,
50 'test' : self.testMethod,
62 self.total_local_sale = 0
63 self.total_local_tax = 0
65 self.total_retail_sale = 0
66 self.total_retail_tax = 0
72 def getPeriod(self, period_id):
73 return self.pool.get('account.period').browse(self.cr, self.uid, period_id).name
76 def testMethod(self, obj):
77 print type(obj) == type({}), obj;
78 if type(obj) == type({}) and not self.flag:
79 if obj.has_key('form'):
81 ids = self.pool.get('account.move.line').search(self.cr, self.uid, [('period_id','=',obj['form']['period_id'])])
82 account = self.pool.get('account.move.line').read(self.cr, self.uid,ids,['invoice'])
86 if not i['invoice'][0] in invoice_ids:
87 inv = self.pool.get('account.invoice').browse(self.cr, self.uid,i['invoice'][0])
88 if inv.type == 'out_invoice' and inv.state == 'open':
89 if not i['invoice'][0] in self.invoices:
90 print '*********************** : ',i['invoice'][0]
91 self.invoices.append(i['invoice'][0])
96 elif self.flag == False:
97 self.invoices = self.ids
101 def getInvoices(self):
102 print '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>',self.invoices;
103 return self.pool.get('account.invoice').browse(self.cr, self.uid, self.invoices)
106 def addInvoice(self, invoice):
107 if invoice.retail_tax == 'tax':
108 self.total_local_sale += invoice.amount_untaxed
109 self.total_local_tax += invoice.amount_tax
111 for tax in invoice.tax_line:
112 if self.tax_tax.has_key(tax.name):
113 self.tax_tax[tax.name] += tax.tax_amount
114 self.sale_tax[tax.name] += tax.base_amount
116 self.tax_tax[tax.name] = tax.tax_amount
117 self.sale_tax[tax.name] = tax.base_amount
119 elif invoice.retail_tax == 'retail':
120 self.total_retail_sale += invoice.amount_untaxed
121 self.total_retail_tax += invoice.amount_tax
122 self. retail += invoice.amount_total
123 for tax in invoice.tax_line:
124 if self.retail_tax.has_key(tax.name):
125 self.retail_tax[tax.name] += tax.tax_amount
126 self.sale_retail[tax.name] += tax.base_amount
128 self.retail_tax[tax.name] = tax.tax_amount
129 self.sale_retail[tax.name] = tax.base_amount
135 def getTaxDetail(self, tax):
136 return self.tax_tax[tax];
140 for i in self.tax_tax:
145 def getRetailTaxDetail(self, tax):
146 return self.retail_tax[tax];
148 def getRetailTax(self):
150 for i in self.retail_tax:
155 def getLocalSale(self, tax):
156 return self.sale_tax[tax]
159 def getRetailSale(self, tax):
160 return self.sale_retail[tax]
163 def getTotalLocalSale(self):
164 return self.total_local_sale
167 def getTotalLocalTax(self):
168 return self.total_local_tax
171 def getTotalRetailSale(self):
172 return self.total_retail_sale
175 def getTotalRetailTax(self):
176 return self.total_retail_tax
180 report_sxw.report_sxw(
181 'report.indianvat.declaration',
183 'addons/india/account/report/tax_report.rml',
184 parser=account_tax_report,