Skip to content

Commit

Permalink
Merge PR #216 into 12.0
Browse files Browse the repository at this point in the history
Signed-off-by sbidoul
  • Loading branch information
OCA-git-bot committed Aug 19, 2024
2 parents 3f31bab + 0a56ed1 commit 3f30e00
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions l10n_be_vat_reports/wizard/partner_vat_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def _compute_declarant_reference(self):
_("No VAT number associated with your company.")
)

company_vat = company_vat.replace(" ", "").upper()
be_id = self.env.ref("base.be").id
company_vat = self.env["res.partner"].fix_eu_vat_number(be_id, company_vat)
for listing in self:
seq_declarantnum = self.env["ir.sequence"].next_by_code(
"declarantnum"
Expand All @@ -67,6 +68,7 @@ def get_partners(self):
date_start = date(int(self.year), 1, 1)
date_stop = date(int(self.year), 12, 31)

be_id = self.env.ref("base.be").id
partners = self.env["partner.vat.list.client"].browse([])
be_partners = self.env["res.partner"].search([("vat", "ilike", "BE%")])
if not be_partners:
Expand Down Expand Up @@ -140,7 +142,9 @@ def get_partners(self):
self.env.cr.execute(query, args)
seq = 0
for record in self.env.cr.dictfetchall():
record["vat"] = record["vat"].replace(" ", "").upper()
record["vat"] = self.env["res.partner"].fix_eu_vat_number(
be_id, record["vat"]
)
if record["turnover"] >= self.limit_amount:
seq += 1
record["seq"] = seq
Expand Down
6 changes: 3 additions & 3 deletions l10n_be_vat_reports/wizard/partner_vat_list_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ class VATListingClients(models.TransientModel):
@api.constrains("vat")
def _check_vat_number(self):
"""
Belgium VAT numbers must respect this pattern: 0[1-9]{1}[0-9]{8}
Belgium VAT numbers must respect this pattern: [0-1][0-9]{9}
todo current code assumes vat numbers start with a two-letter
country code
"""
be_vat_pattern = re.compile(r"^BE0[1-9]{1}[0-9]{8}$")
be_vat_pattern = re.compile(r"^BE[0-1][0-9]{9}$")
for client in self:
if not be_vat_pattern.match(client.vat):
raise ValidationError(
_(
"Belgian Intervat platform only accepts VAT numbers "
"matching this pattern: 0[1-9]{1}[0-9]{8} (number "
"matching this pattern: [0-1][0-9]{9} (number "
"part). Check vat number %s for client %s"
)
% (client.vat, client.name)
Expand Down

0 comments on commit 3f30e00

Please sign in to comment.