feat(fusion_accounting_l10n_ca): Canadian reports + tax return tracking
Replaces Enterprise's l10n_ca_reports with Fusion-native equivalents: - ca_balance_sheet, ca_profit_loss as fusion.report definitions - fusion.tax.return model for GST/HST/PST/T4/T5018 filing tracking - Auto-installs when l10n_ca + fusion_accounting_reports both present Removes Westin's last Canadian-compliance dependency on Enterprise's account_reports. Made-with: Cursor
This commit is contained in:
1
fusion_accounting_l10n_ca/models/__init__.py
Normal file
1
fusion_accounting_l10n_ca/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import fusion_tax_return
|
||||
92
fusion_accounting_l10n_ca/models/fusion_tax_return.py
Normal file
92
fusion_accounting_l10n_ca/models/fusion_tax_return.py
Normal file
@@ -0,0 +1,92 @@
|
||||
"""Fusion-native tax return tracking.
|
||||
|
||||
A simpler replacement for Enterprise's `account.return` model: a tax
|
||||
return is a (return_type, period_from, period_to, status) record. Filers
|
||||
mark them filed once submitted to CRA / Revenu Quebec / provincial
|
||||
authorities.
|
||||
"""
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class FusionTaxReturn(models.Model):
|
||||
_name = "fusion.tax.return"
|
||||
_inherit = ["mail.thread"]
|
||||
_description = "Fusion Tax Return Filing"
|
||||
_order = "date_to desc, id desc"
|
||||
|
||||
name = fields.Char(
|
||||
string="Reference",
|
||||
required=True,
|
||||
copy=False,
|
||||
index=True,
|
||||
default=lambda self: _("New"),
|
||||
)
|
||||
return_type = fields.Selection(
|
||||
[
|
||||
("gst_hst", "GST/HST Return"),
|
||||
("pst", "PST Return"),
|
||||
("qst", "QST Return"),
|
||||
("t4", "T4 Slip"),
|
||||
("t5018", "T5018 Statement"),
|
||||
("payroll_remittance", "Payroll Source Deductions"),
|
||||
("other", "Other"),
|
||||
],
|
||||
required=True,
|
||||
default="gst_hst",
|
||||
tracking=True,
|
||||
)
|
||||
|
||||
company_id = fields.Many2one(
|
||||
"res.company",
|
||||
required=True,
|
||||
default=lambda self: self.env.company,
|
||||
)
|
||||
currency_id = fields.Many2one(related="company_id.currency_id")
|
||||
|
||||
date_from = fields.Date(string="Period Start", required=True)
|
||||
date_to = fields.Date(string="Period End", required=True)
|
||||
|
||||
state = fields.Selection(
|
||||
[
|
||||
("draft", "Draft"),
|
||||
("to_file", "To File"),
|
||||
("filed", "Filed"),
|
||||
("cancelled", "Cancelled"),
|
||||
],
|
||||
default="draft",
|
||||
required=True,
|
||||
tracking=True,
|
||||
)
|
||||
|
||||
filing_date = fields.Date(string="Filed On")
|
||||
filing_reference = fields.Char(string="Confirmation #")
|
||||
notes = fields.Text()
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
for vals in vals_list:
|
||||
if vals.get("name", _("New")) == _("New"):
|
||||
vals["name"] = self.env["ir.sequence"].next_by_code(
|
||||
"fusion.tax.return"
|
||||
) or _("New")
|
||||
return super().create(vals_list)
|
||||
|
||||
@api.constrains("date_from", "date_to")
|
||||
def _check_period(self):
|
||||
for r in self:
|
||||
if r.date_from and r.date_to and r.date_from > r.date_to:
|
||||
raise UserError(_("Period start must precede period end."))
|
||||
|
||||
def action_mark_filed(self):
|
||||
self.ensure_one()
|
||||
if self.state != "to_file":
|
||||
raise UserError(_("Can only mark 'To File' returns as filed."))
|
||||
self.write(
|
||||
{
|
||||
"state": "filed",
|
||||
"filing_date": fields.Date.context_today(self),
|
||||
}
|
||||
)
|
||||
return True
|
||||
Reference in New Issue
Block a user