-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] Implement simples calculation of tax
- Loading branch information
1 parent
d5fb11d
commit 998f319
Showing
8 changed files
with
170 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# © 2018 Danimar Ribeiro <danimaribeiro@gmail.com>, Trustcode | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import res_company | ||
from . import simples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# © 2018 Danimar Ribeiro <danimaribeiro@gmail.com>, Trustcode | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
import datetime | ||
from odoo import api, fields, models | ||
|
||
|
||
class ResCompany(models.Model): | ||
_inherit = 'res.company' | ||
|
||
def get_gross_revenue_last_year(self): | ||
gross_revenues = {} | ||
date_max = datetime.date.today() | ||
date_min = date_max - datetime.timedelta(days=365) | ||
for simples_nacional_id in self.taxes_ids: | ||
account_lines = self.env['account.move.line'].search([ | ||
('account_id', '=', simples_nacional_id.account_id), | ||
('create_date', '>=', date_min), | ||
('create_date', '<=', date_max)]) | ||
gross_revenue = 0 | ||
for line in account_lines: | ||
gross_revenue += line.credit | ||
gross_revenues.update({simples_nacional_id: gross_revenue}) | ||
return gross_revenues | ||
|
||
def compute_new_taxes_simples_nacional(self): | ||
gross_revenues = self.get_gross_revenue_last_year() | ||
taxes = {} | ||
for simples_nacional_id in gross_revenues.keys(): | ||
default_tax = simples_nacional_id.tax | ||
pd = simples_nacional_id.deducao | ||
gross_revenue = gross_revenues[simples_nacional_id] | ||
tax = (default_tax*gross_revenue - pd)/gross_revenue | ||
taxes.update({simples_nacional_id: tax}) | ||
return taxes | ||
|
||
def compute_icms_credit_simples_nacional(self): | ||
icms = {} | ||
taxes = self.compute_new_taxes_simples_nacional() | ||
for simples_nacional_id in taxes.keys(): | ||
icms_credit = simples_nacional_id.icms_percent*taxes[ | ||
simples_nacional_id] | ||
icms.update({simples_nacional_id: icms_credit}) | ||
return icms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# © 2018 Danimar Ribeiro <danimaribeiro@gmail.com>, Trustcode | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class l10nBrTaxationSimples(models.Model): | ||
_name = 'l10n_br.taxation.simples' | ||
|
||
start_revenue = fields.Float(string="Start Revenue") | ||
end_revenue = fields.Float(string="End Revenue") | ||
amount_tax = fields.Float(string="Tax") | ||
amount_deduction = fields.Float(string="Amount to deduct") | ||
account_ids = fields.Many2many('account.account', string="Accounts") | ||
company_id = fields.Many2one('res.company') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record id="account_payment_mode_action" model="ir.actions.act_window"> | ||
<field name="name">Tabelas do simples</field> | ||
<field name="res_model">l10n_br.taxation.simples</field> | ||
<field name="view_mode">tree,form</field> | ||
</record> | ||
|
||
<menuitem id="account_payment_mode_menu" | ||
action="account_payment_mode_action" | ||
parent="account.account_management_menu" /> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters