diff --git a/addons_extensions/employee_it_declaration/models/it_tax_statement_wizard.py b/addons_extensions/employee_it_declaration/models/it_tax_statement_wizard.py new file mode 100644 index 000000000..188b52811 --- /dev/null +++ b/addons_extensions/employee_it_declaration/models/it_tax_statement_wizard.py @@ -0,0 +1,114 @@ +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError +from datetime import date, datetime, time + +class ITTaxStatementWizard(models.TransientModel): + _name = 'it.tax.statement.wizard' + _description = 'Generate IT Tax Statement' + + def _period_line_id_domain(self): + pass + + employee_id = fields.Many2one('hr.employee', required=True, default=lambda self: self.env.user.employee_id.id) + emp_doj = fields.Date(related='employee_id.doj', store=True) + contract_id = fields.Many2one('hr.contract',related='employee_id.contract_id') + + period_id = fields.Many2one('payroll.period', required=True) + period_line = fields.Many2one('payroll.period.line') + tax_regime = fields.Selection([ + ('new', 'New Regime'), + ('old', 'Old Regime') + ], string="Tax Regime", required=True, default='new') + + def action_generate_report(self): + # declaration = self.env['emp.it.declaration'].search([ + # ('employee_id', '=', self.employee_id.id), + # ('period_id', '=', self.period_id.id) + # ], limit=1) + # + # if not declaration: + # raise ValidationError("No IT Declaration found for the selected employee and period.") + + # Prepare data for the report + report_data = self._prepare_income_tax_data() + + # Return the report action + return { + 'type': 'ir.actions.report', + 'report_name': 'employee_it_declaration.income_tax_statement_report', + 'report_type': 'qweb-pdf', + 'data': {'model': 'it.tax.statement.wizard', 'ids': self.ids, 'report_data': report_data}, + 'context': {'active_model': 'it.tax.statement.wizard', 'active_id': self.id}, + } + # return self.env.ref('your_module_name.action_report_it_tax_statement').report_action(declaration) + + def _prepare_income_tax_data(self): + # Get fiscal year (April to March) + today = date.today() + if today.month >= 4: + fiscal_year_start = date(today.year, 4, 1) + fiscal_year_end = date(today.year + 1, 3, 31) + else: + fiscal_year_start = date(today.year - 1, 4, 1) + fiscal_year_end = date(today.year, 3, 31) + + fiscal_year_str = f"{fiscal_year_start.year}-{fiscal_year_end.year}" + + # Get company information + company = self.env.company + company_address = ', '.join(filter(None, [ + company.street, + company.street2, + company.city, + company.state_id.name, + company.country_id.name, + company.zip + ])) + + # Get PAN and TAN (assuming they're stored in company) + pan_number = company.pan_number if hasattr(company, 'pan_number') else 'PAN1234567' + tan_number = company.tan_number if hasattr(company, 'tan_number') else 'TAN1234567' + + # Prepare report data + data = { + 'company_name': company.name, + 'company_address': company_address, + 'pan_number': pan_number, + 'tan_number': tan_number, + 'assessment_year': fiscal_year_end.year + 1, + 'financial_year': fiscal_year_str, + 'date': today.strftime('%d/%m/%Y'), + + # Income details (simplified - you would query actual data) + 'salary_income': 1200000.00, + 'house_property_income': 300000.00, + 'business_income': 500000.00, + 'capital_gains': 200000.00, + 'other_income': 100000.00, + 'total_income': 2300000.00, + + # Deductions + 'section_80c': 150000.00, + 'section_80d': 50000.00, + 'section_80g': 10000.00, + 'other_deductions': 30000.00, + 'total_deductions': 240000.00, + + # Tax computation + 'taxable_income': 2060000.00, + 'tax_payable': 450000.00, + 'tax_paid': 400000.00, + 'balance_tax': 50000.00, + + # Additional details + 'bank_name': 'State Bank of India', + 'account_number': '1234567890', + 'ifsc_code': 'SBIN0001234', + + # For employee reports (if needed) + 'employee_name': 'John Doe', + 'employee_pan': 'ABCDE1234F', + 'employee_address': '123, Main Street, Bangalore, Karnataka - 560001', + } + + return {'data': data} \ No newline at end of file diff --git a/addons_extensions/employee_it_declaration/report/income_tax_template.xml b/addons_extensions/employee_it_declaration/report/income_tax_template.xml new file mode 100644 index 000000000..6f7de88a1 --- /dev/null +++ b/addons_extensions/employee_it_declaration/report/income_tax_template.xml @@ -0,0 +1,145 @@ + + + + \ No newline at end of file